mgw: Test IPv6 addresses in MGCP messages

These tests verify that osmo-mgw handles requests no matter of IP
version used in the remote address.

Change-Id: Ib134dda5a8f7c8f50968b6ce330f9986ae72575d
diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn
index c41466a..b767dd4 100644
--- a/mgw/MGCP_Test.ttcn
+++ b/mgw/MGCP_Test.ttcn
@@ -2230,6 +2230,72 @@
 		setverdict(pass);
 	}
 
+	/* test valid CRCX then MDCX with IPv4 address, MGW provides a local IPv4 too */
+	testcase TC_crcx_mdcx_ip4() runs on dummy_CT {
+		var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain;
+		var template MgcpCommand cmd;
+		var MgcpResponse resp;
+		var MgcpCallId call_id := '1234'H;
+		var MgcpConnectionId conn_id;
+
+		f_init(ep);
+
+		/* create the connection on the MGW */
+		cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+		resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+		conn_id := extract_conn_id(resp);
+
+		cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, conn_id);
+		cmd.sdp := ts_SDP("127.0.0.2", "127.0.0.1", "23", "42", 2344, { "98" },
+				  { valueof(ts_SDP_rtpmap(98, "AMR/8000")),
+				    valueof(ts_SDP_ptime(20)) });
+		resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK);
+
+		if (not ispresent(resp.sdp) or not ispresent(resp.sdp.connection)) {
+			setverdict(fail, "No RemoteConnection info found in MDCX ACK!");
+		}
+		if (not match(resp.sdp.connection, ts_SDP_connection_IP("127.0.0.1", "IP4"))) {
+			setverdict(fail, "Wrong RemoteConnection in MDCX ACK!", resp.sdp.connection);
+		}
+
+		/* clean-up */
+		f_dlcx_ok(ep, call_id);
+		setverdict(pass);
+	}
+
+	/* test valid CRCX then MDCX with IPv6 address, MGW provides a local IPv6 too */
+	testcase TC_crcx_mdcx_ip6() runs on dummy_CT {
+		var MgcpEndpoint ep := c_mgw_ep_rtpbridge & "2@" & c_mgw_domain;
+		var template MgcpCommand cmd;
+		var MgcpResponse resp;
+		var MgcpCallId call_id := '1234'H;
+		var MgcpConnectionId conn_id;
+
+		f_init(ep);
+
+		/* create the connection on the MGW */
+		cmd := ts_CRCX(get_next_trans_id(), ep, "recvonly", call_id);
+		resp := mgcp_transceive_mgw(cmd, tr_CRCX_ACK);
+		conn_id := extract_conn_id(resp);
+
+		cmd := ts_MDCX(get_next_trans_id(), ep, "sendrecv", call_id, conn_id);
+		cmd.sdp := ts_SDP("::2", "::1", "23", "42", 2344, { "98" },
+				  { valueof(ts_SDP_rtpmap(98, "AMR/8000")),
+				    valueof(ts_SDP_ptime(20)) });
+		resp := mgcp_transceive_mgw(cmd, tr_MDCX_ACK);
+
+		if (not ispresent(resp.sdp) or not ispresent(resp.sdp.connection)) {
+			setverdict(fail, "No RemoteConnection info found in MDCX ACK!");
+		}
+		if (not match(resp.sdp.connection, ts_SDP_connection_IP("::1", "IP6"))) {
+			setverdict(fail, "Wrong RemoteConnection in MDCX ACK!", resp.sdp.connection);
+		}
+
+		/* clean-up */
+		f_dlcx_ok(ep, call_id);
+		setverdict(pass);
+	}
+
 	control {
 		execute(TC_selftest());
 		execute(TC_crcx());
@@ -2290,5 +2356,7 @@
 		execute(TC_e1_crcx_with_overlap());
 		execute(TC_e1_crcx_loopback());
 
+		execute(TC_crcx_mdcx_ip4());
+		execute(TC_crcx_mdcx_ip6());
 	}
 }