From 4c97435b3537cfe5a13e427b3d38ee591a686961 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 17 Aug 2015 15:50:01 +0200 Subject: [PATCH] mgcp: Test we don't crash on the NAT dummy MGCP message We want the port and IPv4 address to be extracted but don't expect any change in audio codecs. --- openbsc/tests/mgcp/mgcp_test.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c index df2ab29ae..b2cb938ce 100644 --- a/openbsc/tests/mgcp/mgcp_test.c +++ b/openbsc/tests/mgcp/mgcp_test.c @@ -364,6 +364,13 @@ static void test_strline(void) "a=rtpmap:101 telephone-event/8000\r\n" \ "a=fmtp:101 0-15\r\n" \ "a=recvonly\r\n" +#define MDCX_NAT_DUMMY \ + "MDCX 23 5@mgw MGCP 1.0\r\n" \ + "C: 1355c6041e\r\n" \ + "\r\n" \ + "c=IN IP4 8.8.8.8\r\n" \ + "m=audio 16434 RTP/AVP 255\r\n" + struct mgcp_test { const char *name; @@ -979,6 +986,7 @@ static void test_multilple_codec(void) struct mgcp_config *cfg; struct mgcp_endpoint *endp; struct msgb *inp, *resp; + struct in_addr addr; printf("Testing multiple payload types\n"); @@ -1051,6 +1059,20 @@ static void test_multilple_codec(void) OSMO_ASSERT(endp->net_end.codec.payload_type == 3); OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); + inp = create_msg(MDCX_NAT_DUMMY); + last_endpoint = -1; + resp = mgcp_handle_message(cfg, inp); + msgb_free(inp); + msgb_free(resp); + OSMO_ASSERT(last_endpoint == 5); + endp = &cfg->trunk.endpoints[last_endpoint]; + OSMO_ASSERT(endp->net_end.codec.payload_type == 3); + OSMO_ASSERT(endp->net_end.alt_codec.payload_type == -1); + OSMO_ASSERT(endp->net_end.rtp_port == htons(16434)); + memset(&addr, 0, sizeof(addr)); + inet_aton("8.8.8.8", &addr); + OSMO_ASSERT(endp->net_end.addr.s_addr == addr.s_addr); + /* Check what happens without that flag */ /* Free the previous endpoint and the data ... */