From 21ba5574f9955bbd7925b9a25e50d38e6050fc26 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 19 Sep 2017 17:55:05 +0800 Subject: MGCP_Test: Add comments throughout the code to help readability --- mgw/MGCP_Test.ttcn | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn index 34fa0c17..002d23f6 100644 --- a/mgw/MGCP_Test.ttcn +++ b/mgw/MGCP_Test.ttcn @@ -5,6 +5,9 @@ module MGCP_Test { 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 @@ module MGCP_Test { 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 @@ module MGCP_Test { 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 @@ module MGCP_Test { } 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 @@ module MGCP_Test { 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 @@ module MGCP_Test { * - 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 @@ module MGCP_Test { 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 @@ module MGCP_Test { 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 @@ module MGCP_Test { 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; -- cgit v1.2.3