Change in ...osmo-mgw[master]: mgw: Support lowercase header parameters

pespin gerrit-no-reply at lists.osmocom.org
Wed Jul 3 10:40:55 UTC 2019


pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-mgw/+/14590 )

Change subject: mgw: Support lowercase header parameters
......................................................................

mgw: Support lowercase header parameters

MGCP RFC3435 (https://tools.ietf.org/html/rfc3435) states almost all
text has to be handled in a case-insensitive way, except SDP parts.

Related: OS#4001
Change-Id: I48252415f9d0cd985ad097f334aa4c1665f52511
---
M src/libosmo-mgcp/mgcp_protocol.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
3 files changed, 18 insertions(+), 20 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 9baf50d..3a4591f 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -813,7 +813,7 @@
 		if (!mgcp_check_param(endp, line))
 			continue;
 
-		switch (line[0]) {
+		switch (toupper(line[0])) {
 		case 'L':
 			local_options = (const char *)line + 3;
 			break;
@@ -831,7 +831,6 @@
 			mode = (const char *)line + 3;
 			break;
 		case 'X':
-		case 'x':
 			if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
 				/* If osmux is disabled, just skip setting it up */
 				if (!p->endp->cfg->osmux)
@@ -1090,7 +1089,7 @@
 		if (!mgcp_check_param(endp, line))
 			continue;
 
-		switch (line[0]) {
+		switch (toupper(line[0])) {
 		case 'C':
 			if (mgcp_verify_call_id(endp, line + 3) != 0) {
 				rate_ctr_inc(&rate_ctrs->ctr[MGCP_MDCX_FAIL_INVALID_CALLID]);
@@ -1115,7 +1114,6 @@
 			silent = strcmp("noanswer", line + 3) == 0;
 			break;
 		case 'X':
-		case 'x':
 			if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
 				/* If osmux is disabled, just skip setting it up */
 				if (!p->endp->cfg->osmux)
@@ -1314,7 +1312,7 @@
 		if (!mgcp_check_param(endp, line))
 			continue;
 
-		switch (line[0]) {
+		switch (toupper(line[0])) {
 		case 'C':
 			if (mgcp_verify_call_id(endp, line + 3) != 0) {
 				error_code = 516;
@@ -1465,7 +1463,7 @@
 	LOGP(DLMGCP, LOGL_NOTICE, "RQNT: processing request for notification ...\n");
 
 	for_each_line(line, p->save) {
-		switch (line[0]) {
+		switch (toupper(line[0])) {
 		case 'S':
 			tone = extract_tone(line);
 			break;
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index ab6d0ce..c67b9d5 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -211,10 +211,10 @@
 /* Test different upper/lower case in options */
 #define MDCX4_PT4 \
 	"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" \
+	"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" \
@@ -260,7 +260,7 @@
 
 #define CRCX \
 	"CRCX 2 1 at mgw MGCP 1.0\r\n" \
-	"M: recvonly\r\n" \
+	"m: recvonly\r\n" \
 	"C: 2\r\n" \
 	"L: p:20\r\n" \
 	"\r\n" \
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index 3929d79..08ea438 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -65,7 +65,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 
@@ -197,9 +197,9 @@
 creating message from statically defined input:
 ---------8<---------
 MDCX 18983220 1 at mgw MGCP 1.0
-M: sendrecv
C: 2
-I: %s
-L: A:AMR, NT:IN
+m: sendrecv
c: 2
+i: %s
+l: A:AMR, NT:IN
 
 v=0
 o=- %s 23 IN IP4 0.0.0.0
@@ -383,7 +383,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 
@@ -508,7 +508,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 
@@ -526,7 +526,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 
@@ -638,7 +638,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 
@@ -1189,7 +1189,7 @@
 creating message from statically defined input:
 ---------8<---------
 CRCX 2 1 at mgw MGCP 1.0
-M: recvonly
+m: recvonly
 C: 2
 L: p:20
 

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I48252415f9d0cd985ad097f334aa4c1665f52511
Gerrit-Change-Number: 14590
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190703/b9b06f0b/attachment.html>


More information about the gerrit-log mailing list