Change in ...osmo-mgw[master]: mgw: Support receiving lowercase LCO codec

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


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

Change subject: mgw: Support receiving lowercase LCO codec
......................................................................

mgw: Support receiving lowercase LCO codec

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: I51dc1cdcbe2a5587769335fbecb5039ef22cae5d
---
M src/libosmo-mgcp/mgcp_codec.c
M src/libosmo-mgcp/mgcp_protocol.c
M tests/mgcp/mgcp_test.c
M tests/mgcp/mgcp_test.ok
4 files changed, 10 insertions(+), 5 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  dexter: Looks good to me, but someone else must approve
  osmith: Looks good to me, approved



diff --git a/src/libosmo-mgcp/mgcp_codec.c b/src/libosmo-mgcp/mgcp_codec.c
index 8bf0564..8be4c3c 100644
--- a/src/libosmo-mgcp/mgcp_codec.c
+++ b/src/libosmo-mgcp/mgcp_codec.c
@@ -99,7 +99,7 @@
 	conn->end.codec = NULL;
 }
 
-/* Set members of struct mgcp_rtp_codec, extrapolate in missing information */
+/* Set members of struct mgcp_rtp_codec, extrapolate in missing information. Param audio_name is expected in uppercase. */
 static int codec_set(void *ctx, struct mgcp_rtp_codec *codec, int payload_type, const char *audio_name,
 		     unsigned int pt_offset, struct mgcp_codec_param *param)
 {
@@ -239,7 +239,7 @@
  *  \param[out] codec configuration (caller provided memory).
  *  \param[out] conn related rtp-connection.
  *  \param[in] payload_type codec type id (e.g. 3 for GSM, -1 when undefined).
- *  \param[in] audio_name audio codec name (e.g. "GSM/8000/1").
+ *  \param[in] audio_name audio codec name, in uppercase (e.g. "GSM/8000/1").
  *  \param[in] param optional codec parameters (set to NULL when unused).
  *  \returns 0 on success, -EINVAL on failure. */
 int mgcp_codec_add(struct mgcp_conn_rtp *conn, int payload_type, const char *audio_name, struct mgcp_codec_param *param)
diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 3a4591f..6d9bd70 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -592,6 +592,7 @@
 {
 	char *lco_id;
 	char codec[17];
+	int len;
 
 	if (!options)
 		return 0;
@@ -622,7 +623,11 @@
 			 * codec only. */
 			if (sscanf(lco_id + 1, ":%16[^,]", codec) == 1) {
 				talloc_free(lco->codec);
-				lco->codec = talloc_strdup(ctx, codec);
+				/* MGCP header is case insensive, and we'll need
+				   codec in uppercase when using it later: */
+				len = strlen(codec);
+				lco->codec = talloc_size(ctx, len + 1);
+				osmo_str_toupper_buf(lco->codec, len + 1, codec);
 			}
 			break;
 		default:
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index 5a14bdf..39fe5d0 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -214,7 +214,7 @@
 	"m: sendrecv\r" \
 	"c: 2\r\n" \
 	"i: %s\r\n" \
-	"l: A:AMR, NT:IN\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" \
diff --git a/tests/mgcp/mgcp_test.ok b/tests/mgcp/mgcp_test.ok
index 358a85c..6f4da10 100644
--- a/tests/mgcp/mgcp_test.ok
+++ b/tests/mgcp/mgcp_test.ok
@@ -199,7 +199,7 @@
 MDCX 18983220 1 at mgw MGCP 1.0
 m: sendrecv
c: 2
 i: %s
-l: A:AMR, NT:IN
+l: A:amr, NT:IN
 
 v=0
 o=- %s 23 IN IP4 0.0.0.0

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

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I51dc1cdcbe2a5587769335fbecb5039ef22cae5d
Gerrit-Change-Number: 14596
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
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/fc270d9e/attachment.html>


More information about the gerrit-log mailing list