MGCP_Test: Add comments throughout the code to help readability
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index 34fa0c1..002d23f 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -5,6 +5,9 @@
import from MGCP_CodecPort_CtrlFunct all;
import from IPL4asp_Types all;
+ /* any variables declared in the component will be available to
+ * all functions that 'run on' the named component, similar to
+ * class members in C++ */
type component dummy_CT {
port MGCP_CODEC_PT MGCP;
var boolean initialized := false;
@@ -18,6 +21,10 @@
return tid;
}
+ /* all parameters declared here can be modified / overridden by
+ * the config file in the [MODULE_PARAMETERS] section. If no
+ * config file is used or the file doesn't specify them, the
+ * default values assigned below are used */
modulepar {
PortNumber mp_local_udp_port := 2727;
charstring mp_local_ip := "127.0.0.1";
@@ -25,6 +32,9 @@
charstring mp_remote_ip := "127.0.0.1";
}
+ /* initialization function, called by each test case at the
+ * beginning, but 'initialized' variable ensures its body is
+ * only executed once */
private function f_init()runs on dummy_CT {
var Result res;
if (initialized == true) {
@@ -32,8 +42,12 @@
}
initialized := true;
+ /* some random number for the initial transaction id */
g_trans_id := float2int(rnd()*65535.0);
map(self:MGCP, system:MGCP_CODEC_PT);
+ /* connect the MGCP test port using the given
+ * source/destionation ip/port and store the connection id in g_conn_id
+ * */
res := f_IPL4_connect(MGCP, mp_remote_ip, mp_remote_udp_port, mp_local_ip, mp_local_udp_port, 0, { udp := {} });
g_conn_id := res.connId;
}
@@ -164,6 +178,7 @@
attributes := attributes
}
+ /* master template for generating SDP based in template arguments */
template SDP_Message ts_SDP(charstring local_addr, charstring remote_addr,
charstring session_id, charstring session_version,
integer rtp_port, SDP_fmt_list fmts,
@@ -261,7 +276,10 @@
* - unsupported LocalConnectionOptions ("b", "a", "e", "gc", "s", "r", "k", ..)
*/
- /* build a receive template for receiving a MGCP message */
+ /* build a receive template for receiving a MGCP message. You
+ * pass the MGCP response template in, and it will generate an
+ * MGCP_RecvFrom template that can match the primitives arriving on the
+ * MGCP_CodecPort */
function tr_MGCP_RecvFrom_R(template MgcpResponse resp) runs on dummy_CT return template MGCP_RecvFrom {
var template MGCP_RecvFrom mrf := {
connId := g_conn_id,
@@ -333,7 +351,9 @@
setverdict(pass);
}
- /* test CRCX with early bi-directional mode, expect 527 */
+ /* test CRCX with early bi-directional mode, expect 527 as
+ * bi-diretional media can only be established once both local and
+ * remote side are specified, see MGCP RFC */
testcase TC_crcx_early_bidir_mode() runs on dummy_CT {
var template MgcpCommand cmd;
var MgcpResponse resp;
@@ -430,6 +450,7 @@
cmd.params := {
t_MgcpParConnMode("recvonly"),
ts_MgcpParCallId('1234'H),
+ /* p:20 is permitted only once and not twice! */
t_MgcpParLocConnOpt("p:20, a:AMR, p:20")
}
resp := mgcp_transceive_mgw(cmd, rtmpl);
@@ -512,6 +533,7 @@
setverdict(pass);
}
+ /* Test (valid) CRCX followed by (valid) DLCX */
testcase TC_crcx_and_dlcx() runs on dummy_CT {
var template MgcpCommand cmd;
var MgcpResponse resp;