From db2dc0494eda03880551013001073a71f539634f Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 7 Sep 2020 16:30:29 +0200 Subject: [PATCH] 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 --- mgw/MGCP_Test.ttcn | 68 ++++++++++++++++++++++++++++++++++++++++++++++ mgw/osmo-mgw.cfg | 1 + 2 files changed, 69 insertions(+) diff --git a/mgw/MGCP_Test.ttcn b/mgw/MGCP_Test.ttcn index c41466a44..b767dd408 100644 --- a/mgw/MGCP_Test.ttcn +++ b/mgw/MGCP_Test.ttcn @@ -2230,6 +2230,72 @@ module MGCP_Test { 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 @@ module MGCP_Test { execute(TC_e1_crcx_with_overlap()); execute(TC_e1_crcx_loopback()); + execute(TC_crcx_mdcx_ip4()); + execute(TC_crcx_mdcx_ip6()); } } diff --git a/mgw/osmo-mgw.cfg b/mgw/osmo-mgw.cfg index edc819046..beb6fdf00 100644 --- a/mgw/osmo-mgw.cfg +++ b/mgw/osmo-mgw.cfg @@ -22,6 +22,7 @@ mgcp bind port 2427 rtp port-range 4002 16000 rtp bind-ip 127.0.0.1 + rtp bind-ip-v6 ::1 rtp ip-probing rtp ip-dscp 184 no rtp keep-alive