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
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 4fb93b0..56271e2 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 5bb7b27..6978b1d 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@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@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983218 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983219 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983220 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983221 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983222 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983223 1@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@mgw MGCP 1.0\r\n" \
+	"MDCX 18983224 1@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
Binary files differ