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
This commit is contained in:
parent
ca280a1a84
commit
d6769ea207
|
@ -1149,7 +1149,7 @@ mgcp_header_done:
|
|||
/* 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;
|
||||
|
|
|
@ -128,7 +128,7 @@ static void test_strline(void)
|
|||
"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 @@ static void test_strline(void)
|
|||
"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 @@ static void test_strline(void)
|
|||
"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 @@ static void test_strline(void)
|
|||
|
||||
/* 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 @@ static const struct mgcp_test tests[] = {
|
|||
{"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},
|
||||
|
|
|
@ -97,7 +97,7 @@ Response matches our expectations.
|
|||
Dummy packets: 2
|
||||
|
||||
================================================
|
||||
Testing MDCX4
|
||||
Testing MDCX4_ADDR000
|
||||
creating message from statically defined input:
|
||||
---------8<---------
|
||||
MDCX 18983216 1@mgw MGCP 1.0
|
||||
|
@ -113,24 +113,48 @@ m=audio 4441 RTP/AVP 99
|
|||
a=rtpmap:99 AMR/8000
|
||||
a=ptime:40
|
||||
|
||||
---------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@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@mgw MGCP 1.0
|
||||
MDCX 18983218 1@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 @@ checking response:
|
|||
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@mgw MGCP 1.0
|
||||
MDCX 18983219 1@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 @@ checking response:
|
|||
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@mgw MGCP 1.0
|
||||
MDCX 18983220 1@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 @@ checking response:
|
|||
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@mgw MGCP 1.0
|
||||
MDCX 18983221 1@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 @@ checking response:
|
|||
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@mgw MGCP 1.0
|
||||
MDCX 18983222 1@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 @@ Response matches our expectations.
|
|||
Testing MDCX4_RO
|
||||
creating message from statically defined input:
|
||||
---------8<---------
|
||||
MDCX 18983222 1@mgw MGCP 1.0
|
||||
MDCX 18983223 1@mgw MGCP 1.0
|
||||
M: recvonly
C: 2
|
||||
I: %s
|
||||
L: p:20, a:AMR, nt:IN
|
||||
|
@ -248,6 +276,7 @@ checking response:
|
|||
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 @@ Dummy packets: 2
|
|||
Testing MDCX_TOO_LONG_CI
|
||||
creating message from statically defined input:
|
||||
---------8<---------
|
||||
MDCX 18983223 1@mgw MGCP 1.0
|
||||
MDCX 18983224 1@mgw MGCP 1.0
|
||||
I: 123456789012345678901234567890123
|
||||
|
||||
---------8<---------
|
||||
|
|
Loading…
Reference in New Issue