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.
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index df2ab29..b2cb938 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -364,6 +364,13 @@
"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 @@
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 @@
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 ... */