mgw: make f_dlcx_{ok,ignore}() support EP, EP+call_id or EP+call_id+conn_id
A MGCP DLCX can contain either only the EP, or EP+call_id or
EP+call_id+conn_id in order to specify what shall be deleted. Let's
structure ts_DLCX() and the f_dlcx_{ok,ignore}() function in a way to
support this in an intuitive way.
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index 3decaed..844980f 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -135,12 +135,21 @@
sdp := sdp
}
- template MgcpCommand ts_DLCX(MgcpTransId trans_id, charstring ep, MgcpCallId call_id) := {
- line := t_MgcpCmdLine("DLCX", trans_id, ep),
- params := {
- ts_MgcpParCallId(call_id)
- },
- sdp := omit
+ /* have a function that generates a template, rather than a template in order to handle
+ * optional parameters */
+ function ts_DLCX(MgcpTransId trans_id, charstring ep, template MgcpCallId call_id := omit,
+ template MgcpConnectionId conn_id := omit) return template MgcpCommand {
+ var template MgcpCommand cmd;
+ cmd.line := t_MgcpCmdLine("DLCX", trans_id, ep);
+ cmd.params := {};
+ cmd.sdp := omit;
+ if (isvalue(call_id)) {
+ f_mgcp_par_append(cmd.params, ts_MgcpParCallId(valueof(call_id)));
+ if (isvalue(conn_id)) {
+ f_mgcp_par_append(cmd.params, ts_MgcpParConnectionId(valueof(conn_id)));
+ }
+ }
+ return cmd;
}
/* SDP Templates */
@@ -347,7 +356,7 @@
}
/* Send DLCX and expect OK response */
- function f_dlcx_ok(MgcpEndpoint ep, MgcpCallId call_id,
+ function f_dlcx_ok(MgcpEndpoint ep, template MgcpCallId call_id := omit,
template MgcpConnectionId conn_id := omit) runs on dummy_CT {
var template MgcpCommand cmd;
var MgcpResponse resp;
@@ -359,13 +368,12 @@
params := *,
sdp := *
};
- cmd := ts_DLCX(get_next_trans_id(), ep, call_id);
- /* FIXME: add conn_id if present */
+ cmd := ts_DLCX(get_next_trans_id(), ep, call_id, conn_id);
resp := mgcp_transceive_mgw(cmd, rtmpl);
}
/* Send DLCX and accept any response */
- function f_dlcx_ignore(MgcpEndpoint ep, MgcpCallId call_id,
+ function f_dlcx_ignore(MgcpEndpoint ep, template MgcpCallId call_id := omit,
template MgcpConnectionId conn_id := omit) runs on dummy_CT {
var template MgcpCommand cmd;
var MgcpResponse resp;
@@ -377,8 +385,7 @@
params := *,
sdp := *
};
- cmd := ts_DLCX(get_next_trans_id(), ep, call_id);
- /* FIXME: add conn_id if present */
+ cmd := ts_DLCX(get_next_trans_id(), ep, call_id, conn_id);
resp := mgcp_transceive_mgw(cmd, rtmpl);
}