Change in osmo-ttcn3-hacks[master]: mgw: Add 2 CRCX tests with Osmux enabled

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Tue May 14 15:19:22 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/14046


Change subject: mgw: Add 2 CRCX tests with Osmux enabled
......................................................................

mgw: Add 2 CRCX tests with Osmux enabled

This patch requires "osmux on" to be set in osmo-mgw's VTY cfg file.

Depends: osmo-mgw.git Iac073f1db46569b46eddeaecc9934a2986bd50f1
Change-Id: Ibb58b2a4e08d6f30cfe347c217794d0d1310954f
---
M library/MGCP_Templates.ttcn
M library/MGCP_Types.ttcn
M mgw/MGCP_Test.ttcn
M mgw/expected-results.xml
4 files changed, 105 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/46/14046/1

diff --git a/library/MGCP_Templates.ttcn b/library/MGCP_Templates.ttcn
index 506100f..9e6f5b7 100644
--- a/library/MGCP_Templates.ttcn
+++ b/library/MGCP_Templates.ttcn
@@ -49,6 +49,12 @@
 		val := hex2str(cid)
 	};
 
+	/* Osmocom extension: X-Osmux: {*,%u} */
+	template MgcpParameter ts_MgcpParOsmuxCID(MgcpOsmuxCID osmux_cid) := {
+		code := "X-OSMUX",
+		val := f_mgcp_osmux_cid_encode(osmux_cid)
+	};
+
 	/* osmo-bsc_mgcp implements L/C/M/X only, osmo-mgw adds 'I' */
 	/* SDP: osmo-bsc_mgcp implements Tx of v,o,s,c,t,m,a */
 
@@ -89,6 +95,18 @@
 		sdp := sdp
 	}
 
+	template MgcpCommand ts_CRCX_osmux(MgcpTransId trans_id, charstring ep, MgcpConnectionMode mode, MgcpCallId call_id, MgcpOsmuxCID osmux_cid, template SDP_Message sdp := omit) := {
+		line := t_MgcpCmdLine("CRCX", trans_id, ep),
+		params := {
+			t_MgcpParConnMode(mode),
+			ts_MgcpParCallId(call_id),
+			//t_MgcpParReqId(omit),
+			t_MgcpParLocConnOpt("p:20, a:AMR"),
+			ts_MgcpParOsmuxCID(osmux_cid)
+		},
+		sdp := sdp
+	}
+
 	template MgcpCommand tr_CRCX(template MgcpEndpoint ep := ?) := {
 		line := t_MgcpCmdLine("CRCX", ?, ep),
 		params := *,
@@ -105,6 +123,16 @@
 		sdp := ?
 	}
 
+	template MgcpResponse tr_CRCX_ACK_osmux := {
+		line := {
+			code := "200",
+			trans_id := ?,
+			string := "OK"
+		},
+		params:= { { "I", ? }, {"X-OSMUX", ?}, *},
+		sdp := ?
+	}
+
 	template MgcpResponse ts_CRCX_ACK(MgcpTransId trans_id, MgcpConnectionId conn_id, template SDP_Message sdp := omit) := {
 		line := {
 			code := "200",
@@ -286,6 +314,24 @@
 		}
 	}
 
+	/* -1 is wildcard, positive is translated as string */
+	function f_mgcp_osmux_cid_encode(MgcpOsmuxCID osmux_cid) return charstring {
+		if (osmux_cid < -1) {
+			return "ERROR-wrong-negative-value";
+		}
+		if (osmux_cid == -1) {
+			return "*";
+		}
+		return int2str(osmux_cid);
+	}
+
+	function f_mgcp_osmux_cid_decode(charstring osmux_cid) return MgcpOsmuxCID {
+		if (osmux_cid == "*") {
+			return -1;
+		}
+		return str2int(osmux_cid);
+	}
+
 	function f_mgcp_contains_par(MgcpMessage msg, MgcpInfoCode code) return boolean {
 		var MgcpParameterList pars;
 		if (ischosen(msg.command)) {
@@ -352,6 +398,10 @@
 		return str2hex(f_MgcpCmd_extract_par(cmd, "I"));
 	}
 
+	function f_MgcpCmd_extract_osmux_cid(MgcpCommand cmd) return MgcpOsmuxCID {
+		return f_mgcp_osmux_cid_decode(f_MgcpCmd_extract_par(cmd, "X-OSMUX"));
+	}
+
 
 	function f_mgcp_alloc_tid() return MgcpTransId {
 		return int2str(float2int(rnd()*2147483647.0));
diff --git a/library/MGCP_Types.ttcn b/library/MGCP_Types.ttcn
index 8e11c7a..b56734c 100644
--- a/library/MGCP_Types.ttcn
+++ b/library/MGCP_Types.ttcn
@@ -24,13 +24,14 @@
 	type hexstring MgcpCallId	length(1..32);	/* 3.2.2.2 */
 	type hexstring MgcpConnectionId	length(1..32);	/* 3.2.2.5 */
 	type hexstring MgcpRequestId	length(1..32);	/* 3.2.2.18 */
+	type integer MgcpOsmuxCID	(-1 .. 255);
 	type charstring MgcpResponseCode (pattern "\d#(3)");
 
 	type charstring MgcpInfoCode ("B", "C", "I", "N", "X", "L", "M", "R",
 				      "S", "D", "O", "P", "E", "Z", "Q", "T",
 				      "RC", "LC", "A", "ES", "RM", "RD", "PL",
-				      "MD", "X-Osmo-CP") with {
-		variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-Osmo-CP)',case_insensitive)"
+				      "MD", "X-OSMO-CP", "X-OSMUX") with {
+		variant "TEXT_CODING(,convert=upper_case,'([BCINXLMRSDOPEZQTA])|(RC)|(LC)|(ES)|(RM)|(RD)|(PL)|(MD)|(X-OSMO-CP)|(X-OSMUX)',case_insensitive)"
 	};
 
 	/* 3.2.2.6 */
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index 8cb2404..fa103c4 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -437,6 +437,40 @@
 		}
 	}
 
+	function f_crcx_osmux(charstring ep_prefix, MgcpOsmuxCID osmux_cid) runs on dummy_CT {
+		var MgcpEndpoint ep := ep_prefix & "2@" & c_mgw_domain;
+		var template MgcpCommand cmd;
+		var MgcpResponse resp;
+		var MgcpCallId call_id := '1234'H;
+		var charstring cid_response;
+
+		f_init(ep);
+
+		/* create the connection on the MGW */
+		cmd := ts_CRCX_osmux(get_next_trans_id(), ep, "recvonly", call_id, osmux_cid);
+		resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK_osmux);
+		extract_conn_id(resp);
+
+		/* extract Osmux CID we got assigned by the MGW */
+		var MgcpMessage resp_msg := {
+			response := resp
+		}
+
+		if (f_mgcp_find_param(resp_msg, "X-OSMUX", cid_response) == false) {
+			setverdict(fail, "No Osmux CID in MGCP response", resp);
+			mtc.stop;
+		}
+
+		/* Make sure response is no wildcard */
+		if (f_mgcp_osmux_cid_decode(cid_response) == -1) {
+			setverdict(fail, "Osmux CID in MGCP response contains unexpected wildcard");
+			mtc.stop;
+		}
+
+		/* clean-up */
+		f_dlcx_ok(ep, call_id);
+	}
+
 	/* test valid CRCX without SDP */
 	testcase TC_crcx() runs on dummy_CT {
 		f_crcx(c_mgw_ep_rtpbridge);
@@ -791,6 +825,18 @@
 		setverdict(pass);
 	}
 
+	/* test valid CRCX without SDP */
+	testcase TC_crcx_osmux_wildcard() runs on dummy_CT {
+		f_crcx_osmux(c_mgw_ep_rtpbridge, -1);
+		setverdict(pass);
+	}
+
+	/* test valid CRCX without SDP */
+	testcase TC_crcx_osmux_fixed() runs on dummy_CT {
+		f_crcx_osmux(c_mgw_ep_rtpbridge, 2);
+		setverdict(pass);
+	}
+
 	function f_crcx_and_dlcx_ep_callid_connid(MgcpEndpoint ep, MgcpCallId call_id) runs on dummy_CT {
 		var template MgcpCommand cmd;
 		var MgcpResponse resp;
@@ -1482,6 +1528,9 @@
 		execute(TC_crcx_and_dlcx_ep_callid_connid_inval());
 		execute(TC_crcx_and_dlcx_retrans());
 
+		execute(TC_crcx_osmux_wildcard());
+		execute(TC_crcx_osmux_fixed());
+
 		execute(TC_crcx_dlcx_30ep());
 
 		execute(TC_rtpem_selftest());
diff --git a/mgw/expected-results.xml b/mgw/expected-results.xml
index 5c520c5..f968859 100644
--- a/mgw/expected-results.xml
+++ b/mgw/expected-results.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<testsuite name='Titan' tests='35' failures='0' errors='0' skipped='1' inconc='0' time='MASKED'>
+<testsuite name='Titan' tests='37' failures='0' errors='0' skipped='1' inconc='0' time='MASKED'>
   <testcase classname='MGCP_Test' name='TC_selftest' time='MASKED'>
     <skipped>no verdict</skipped>
   </testcase>
@@ -26,6 +26,8 @@
   <testcase classname='MGCP_Test' name='TC_crcx_and_dlcx_ep_callid_inval' time='MASKED'/>
   <testcase classname='MGCP_Test' name='TC_crcx_and_dlcx_ep_callid_connid_inval' time='MASKED'/>
   <testcase classname='MGCP_Test' name='TC_crcx_and_dlcx_retrans' time='MASKED'/>
+  <testcase classname='MGCP_Test' name='TC_crcx_osmux_wildcard' time='MASKED'/>
+  <testcase classname='MGCP_Test' name='TC_crcx_osmux_fixed' time='MASKED'/>
   <testcase classname='MGCP_Test' name='TC_crcx_dlcx_30ep' time='MASKED'/>
   <testcase classname='MGCP_Test' name='TC_rtpem_selftest' time='MASKED'/>
   <testcase classname='MGCP_Test' name='TC_one_crcx_receive_only_rtp' time='MASKED'/>

-- 
To view, visit https://gerrit.osmocom.org/14046
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb58b2a4e08d6f30cfe347c217794d0d1310954f
Gerrit-Change-Number: 14046
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190514/b273ffe1/attachment.htm>


More information about the gerrit-log mailing list