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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Jun 25 22:00:43 UTC 2019


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


Change subject: mgw: Support upper-case header parameters
......................................................................

mgw: Support upper-case 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(-)



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

diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 841440b..6473394 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -812,7 +812,7 @@
 		if (!mgcp_check_param(endp, line))
 			continue;
 
-		switch (line[0]) {
+		switch (toupper(line[0])) {
 		case 'L':
 			local_options = (const char *)line + 3;
 			break;
@@ -830,7 +830,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)
@@ -1089,7 +1088,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]);
@@ -1114,7 +1113,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)
@@ -1313,7 +1311,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;
@@ -1464,7 +1462,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: 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/20190625/a95ca686/attachment.htm>


More information about the gerrit-log mailing list