Change in osmo-mgw[master]: Fail rx MDCX sendrecv with invalid remote addr

pespin gerrit-no-reply at lists.osmocom.org
Tue Jul 6 17:53:43 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24863 )


Change subject: Fail rx MDCX sendrecv with invalid remote addr
......................................................................

Fail rx MDCX sendrecv with invalid remote addr

use the recently new available API to check both remote address and
port, instead of only the port.
It doesn't make sense to configure a conn as sendrecv if we have no IP
address to send stuff to, similar to what was already being checked with
the port.

Change-Id: I6ce8cf52930d423d3db8c27251be8350a26a4ede
---
M src/libosmo-mgcp/mgcp_protocol.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
3 files changed, 93 insertions(+), 45 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/63/24863/1

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index c71a3ba..b716cf3 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -1149,7 +1149,7 @@
 	/* check connection mode setting */
 	if (conn->conn->mode != MGCP_CONN_LOOPBACK
 	    && conn->conn->mode != MGCP_CONN_RECV_ONLY
-	    && conn->end.rtp_port == 0) {
+	    && !mgcp_rtp_end_remote_addr_available(&conn->end)) {
 		LOGPCONN(conn->conn, DLMGCP, LOGL_ERROR,
 			 "MDCX: selected connection mode type requires an opposite end!\n");
 		error_code = 527;
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 03d600f..c000e41 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -128,7 +128,7 @@
 	"a=fmtp:126 0/1/2\r\n" \
 	"a=ptime:40\r\n"
 
-#define MDCX4 \
+#define MDCX4_ADDR0000 \
 	"MDCX 18983216 1 at mgw MGCP 1.0\r\n" \
 	"M: sendrecv\r" \
 	"C: 2\r\n" \
@@ -143,6 +143,24 @@
 	"a=rtpmap:99 AMR/8000\r\n" \
 	"a=ptime:40\r\n"
 
+#define MDCX4_ADDR0000_RET \
+	"527 18983216 FAIL\r\n"
+
+#define MDCX4 \
+	"MDCX 18983217 1 at mgw MGCP 1.0\r\n" \
+	"M: sendrecv\r" \
+	"C: 2\r\n" \
+	"I: %s\r\n" \
+	"L: p:20, a:AMR, nt:IN\r\n" \
+	"\n" \
+	"v=0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
+	"t=0 0\r\n" \
+	"m=audio 4441 RTP/AVP 99\r\n" \
+	"a=rtpmap:99 AMR/8000\r\n" \
+	"a=ptime:40\r\n"
+
 #define MDCX4_RET(Ident) \
 	"200 " Ident " OK\r\n" \
 	"\r\n" \
@@ -168,45 +186,45 @@
 	"a=ptime:40\r\n"
 
 #define MDCX4_PT1 \
-	"MDCX 18983217 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983218 1 at mgw MGCP 1.0\r\n" \
 	"M: SENDRECV\r" \
 	"C: 2\r\n" \
 	"I: %s\r\n" \
 	"L: p:20-40, a:AMR, nt:IN\r\n" \
 	"\n" \
 	"v=0\r\n" \
-	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
-	"c=IN IP4 0.0.0.0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
 	"t=0 0\r\n" \
 	"m=audio 4441 RTP/AVP 99\r\n" \
 	"a=rtpmap:99 AMR/8000\r\n" \
 	"a=ptime:40\r\n"
 
 #define MDCX4_PT2 \
-	"MDCX 18983218 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983219 1 at mgw MGCP 1.0\r\n" \
 	"M: sendrecv\r" \
 	"C: 2\r\n" \
 	"I: %s\r\n" \
 	"L: p:20-20, a:AMR, nt:IN\r\n" \
 	"\n" \
 	"v=0\r\n" \
-	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
-	"c=IN IP4 0.0.0.0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
 	"t=0 0\r\n" \
 	"m=audio 4441 RTP/AVP 99\r\n" \
 	"a=rtpmap:99 AMR/8000\r\n" \
 	"a=ptime:40\r\n"
 
 #define MDCX4_PT3 \
-	"MDCX 18983219 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983220 1 at mgw MGCP 1.0\r\n" \
 	"M: sendrecv\r" \
 	"C: 2\r\n" \
 	"I: %s\r\n" \
 	"L: a:AMR, nt:IN\r\n" \
 	"\n" \
 	"v=0\r\n" \
-	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
-	"c=IN IP4 0.0.0.0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
 	"t=0 0\r\n" \
 	"m=audio 4441 RTP/AVP 99\r\n" \
 	"a=rtpmap:99 AMR/8000\r\n" \
@@ -214,47 +232,47 @@
 
 /* Test different upper/lower case in options */
 #define MDCX4_PT4 \
-	"MDCX 18983220 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983221 1 at mgw MGCP 1.0\r\n" \
 	"m: sendrecv\r" \
 	"c: 2\r\n" \
 	"i: %s\r\n" \
 	"l: A:amr, NT:IN\r\n" \
 	"\n" \
 	"v=0\r\n" \
-	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
-	"c=IN IP4 0.0.0.0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
 	"t=0 0\r\n" \
 	"m=audio 4441 RTP/AVP 99\r\n" \
 	"a=rtpmap:99 AMR/8000\r\n" \
 	"a=ptime:40\r\n"
 
 #define MDCX4_SO \
-	"MDCX 18983221 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983222 1 at mgw MGCP 1.0\r\n" \
 	"M: sendonly\r" \
 	"C: 2\r\n" \
 	"I: %s\r\n" \
 	"L: p:20, a:AMR, nt:IN\r\n" \
 	"\n" \
 	"v=0\r\n" \
-	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
-	"c=IN IP4 0.0.0.0\r\n" \
+	"o=- %s 23 IN IP4 5.6.7.8\r\n" \
+	"c=IN IP4 5.6.7.8\r\n" \
 	"t=0 0\r\n" \
 	"m=audio 4441 RTP/AVP 99\r\n" \
 	"a=rtpmap:99 AMR/8000\r\n" \
 	"a=ptime:40\r\n"
 
 #define MDCX4_RO \
-	"MDCX 18983222 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983223 1 at mgw MGCP 1.0\r\n" \
 	"M: recvonly\r" \
 	"C: 2\r\n" \
 	"I: %s\r\n" \
 	"L: p:20, a:AMR, nt:IN\r\n"
 
 #define MDCX_TOO_LONG_CI \
-	"MDCX 18983223 1 at mgw MGCP 1.0\r\n" \
+	"MDCX 18983224 1 at mgw MGCP 1.0\r\n" \
 	"I: 123456789012345678901234567890123\n"
 
-#define MDCX_TOO_LONG_CI_RET "510 18983223 FAIL\r\n"
+#define MDCX_TOO_LONG_CI_RET "510 18983224 FAIL\r\n"
 
 #define SHORT2	"CRCX 1"
 #define SHORT2_RET "510 000000 FAIL\r\n"
@@ -542,13 +560,14 @@
 	{"MDCX2", MDCX_UNALLOCATED, MDCX_RET},
 	{"CRCX", CRCX, CRCX_RET, 97},
 	{"MDCX3", MDCX3, MDCX3_RET, PTYPE_IGNORE},
-	{"MDCX4", MDCX4, MDCX4_RET("18983216"), 99},
-	{"MDCX4_PT1", MDCX4_PT1, MDCX4_RET("18983217"), 99},
-	{"MDCX4_PT2", MDCX4_PT2, MDCX4_RET("18983218"), 99},
-	{"MDCX4_PT3", MDCX4_PT3, MDCX4_RET("18983219"), 99},
-	{"MDCX4_PT4", MDCX4_PT4, MDCX4_RET("18983220"), 99},
-	{"MDCX4_SO", MDCX4_SO, MDCX4_RET("18983221"), 99},
-	{"MDCX4_RO", MDCX4_RO, MDCX4_RO_RET("18983222"), PTYPE_IGNORE},
+	{"MDCX4_ADDR000", MDCX4_ADDR0000, MDCX4_ADDR0000_RET},
+	{"MDCX4", MDCX4, MDCX4_RET("18983217"), 99},
+	{"MDCX4_PT1", MDCX4_PT1, MDCX4_RET("18983218"), 99},
+	{"MDCX4_PT2", MDCX4_PT2, MDCX4_RET("18983219"), 99},
+	{"MDCX4_PT3", MDCX4_PT3, MDCX4_RET("18983220"), 99},
+	{"MDCX4_PT4", MDCX4_PT4, MDCX4_RET("18983221"), 99},
+	{"MDCX4_SO", MDCX4_SO, MDCX4_RET("18983222"), 99},
+	{"MDCX4_RO", MDCX4_RO, MDCX4_RO_RET("18983223"), PTYPE_IGNORE},
 	{"DLCX", DLCX, DLCX_RET, PTYPE_IGNORE},
 	{"CRCX_ZYN", CRCX_ZYN, CRCX_ZYN_RET, 97},
 	{"EMPTY", EMPTY, EMPTY_RET},
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index d3f8a26..575fd83 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -97,7 +97,7 @@
 Dummy packets: 2
 
 ================================================
-Testing MDCX4
+Testing MDCX4_ADDR000
 creating message from statically defined input:
 ---------8<---------
 MDCX 18983216 1 at mgw MGCP 1.0
@@ -115,22 +115,46 @@
 
 ---------8<---------
 checking response:
+using message as statically defined for comparison
+Response matches our expectations.
+(response does not contain a connection id)
+
+================================================
+Testing MDCX4
+creating message from statically defined input:
+---------8<---------
+MDCX 18983217 1 at mgw MGCP 1.0
+M: sendrecv
C: 2
+I: %s
+L: p:20, a:AMR, nt:IN
+
+v=0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
+t=0 0
+m=audio 4441 RTP/AVP 99
+a=rtpmap:99 AMR/8000
+a=ptime:40
+
+---------8<---------
+checking response:
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing MDCX4_PT1
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983217 1 at mgw MGCP 1.0
+MDCX 18983218 1 at mgw MGCP 1.0
 M: SENDRECV
C: 2
 I: %s
 L: p:20-40, a:AMR, nt:IN
 
 v=0
-o=- %s 23 IN IP4 0.0.0.0
-c=IN IP4 0.0.0.0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
 t=0 0
 m=audio 4441 RTP/AVP 99
 a=rtpmap:99 AMR/8000
@@ -141,19 +165,20 @@
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing MDCX4_PT2
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983218 1 at mgw MGCP 1.0
+MDCX 18983219 1 at mgw MGCP 1.0
 M: sendrecv
C: 2
 I: %s
 L: p:20-20, a:AMR, nt:IN
 
 v=0
-o=- %s 23 IN IP4 0.0.0.0
-c=IN IP4 0.0.0.0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
 t=0 0
 m=audio 4441 RTP/AVP 99
 a=rtpmap:99 AMR/8000
@@ -164,19 +189,20 @@
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing MDCX4_PT3
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983219 1 at mgw MGCP 1.0
+MDCX 18983220 1 at mgw MGCP 1.0
 M: sendrecv
C: 2
 I: %s
 L: a:AMR, nt:IN
 
 v=0
-o=- %s 23 IN IP4 0.0.0.0
-c=IN IP4 0.0.0.0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
 t=0 0
 m=audio 4441 RTP/AVP 99
 a=rtpmap:99 AMR/8000
@@ -187,19 +213,20 @@
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing MDCX4_PT4
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983220 1 at mgw MGCP 1.0
+MDCX 18983221 1 at mgw MGCP 1.0
 m: sendrecv
c: 2
 i: %s
 l: A:amr, NT:IN
 
 v=0
-o=- %s 23 IN IP4 0.0.0.0
-c=IN IP4 0.0.0.0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
 t=0 0
 m=audio 4441 RTP/AVP 99
 a=rtpmap:99 AMR/8000
@@ -210,19 +237,20 @@
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing MDCX4_SO
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983221 1 at mgw MGCP 1.0
+MDCX 18983222 1 at mgw MGCP 1.0
 M: sendonly
C: 2
 I: %s
 L: p:20, a:AMR, nt:IN
 
 v=0
-o=- %s 23 IN IP4 0.0.0.0
-c=IN IP4 0.0.0.0
+o=- %s 23 IN IP4 5.6.7.8
+c=IN IP4 5.6.7.8
 t=0 0
 m=audio 4441 RTP/AVP 99
 a=rtpmap:99 AMR/8000
@@ -238,7 +266,7 @@
 Testing MDCX4_RO
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983222 1 at mgw MGCP 1.0
+MDCX 18983223 1 at mgw MGCP 1.0
 M: recvonly
C: 2
 I: %s
 L: p:20, a:AMR, nt:IN
@@ -248,6 +276,7 @@
 using message with patched conn_id for comparison
 Response matches our expectations.
 (response contains a connection id)
+Dummy packets: 2
 
 ================================================
 Testing DLCX
@@ -463,7 +492,7 @@
 Testing MDCX_TOO_LONG_CI
 creating message from statically defined input:
 ---------8<---------
-MDCX 18983223 1 at mgw MGCP 1.0
+MDCX 18983224 1 at mgw MGCP 1.0
 I: 123456789012345678901234567890123
 
 ---------8<---------

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/24863
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I6ce8cf52930d423d3db8c27251be8350a26a4ede
Gerrit-Change-Number: 24863
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210706/2d60170b/attachment.htm>


More information about the gerrit-log mailing list