[MERGED] osmo-mgw[master]: protocol: fix missing carriage return

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Fri Jan 26 00:32:23 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: protocol: fix missing carriage return
......................................................................


protocol: fix missing carriage return

Some of the line breaks lack the \r character, which leads to an
inconsistancy. While our software and even wireshark does ignore
the problem, other third party implementations might reject those
messages.

- Add the missing \r characters to make the message format
  consistant.

Change-Id: I0cd80afae65accd3b4ddc5d82e5d30385879141c
---
M src/libosmo-mgcp/mgcp_protocol.c
M tests/mgcp/mgcp_test.c
2 files changed, 17 insertions(+), 17 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c
index 49c4c3c..73d7f5e 100644
--- a/src/libosmo-mgcp/mgcp_protocol.c
+++ b/src/libosmo-mgcp/mgcp_protocol.c
@@ -201,14 +201,14 @@
 	/* NOTE: Only in the virtual trunk we allow dynamic endpoint names */
 	if (endp->wildcarded_crcx
 	    && endp->tcfg->trunk_type == MGCP_TRUNK_VIRTUAL) {
-		rc = msgb_printf(msg, "Z: %s%u@%s\n",
+		rc = msgb_printf(msg, "Z: %s%u@%s\r\n",
 				 MGCP_ENDPOINT_PREFIX_VIRTUAL_TRUNK,
 				 ENDPOINT_NUMBER(endp), endp->cfg->domain);
 		if (rc < 0)
 			return -EINVAL;
 	}
 
-	rc = msgb_printf(msg, "I: %s\n", conn->conn->id);
+	rc = msgb_printf(msg, "I: %s\r\n", conn->conn->id);
 	if (rc < 0)
 		return -EINVAL;
 
@@ -254,13 +254,13 @@
 
 	/* Attach optional OSMUX parameters */
 	if (conn->osmux.state == OSMUX_STATE_NEGOTIATING) {
-		rc = msgb_printf(sdp, "%s\n", osmux_extension);
+		rc = msgb_printf(sdp, "%s\r\n", osmux_extension);
 		if (rc < 0)
 			goto error;
 	}
 
 	/* Attach line break to separate the parameters from the SDP block */
-	rc = msgb_printf(sdp, "\n");
+	rc = msgb_printf(sdp, "\r\n");
 
 	rc = mgcp_write_response_sdp(endp, conn, sdp, addr);
 	if (rc < 0)
diff --git a/tests/mgcp/mgcp_test.c b/tests/mgcp/mgcp_test.c
index ddee8c5..1790444 100644
--- a/tests/mgcp/mgcp_test.c
+++ b/tests/mgcp/mgcp_test.c
@@ -86,7 +86,7 @@
 
 #define MDCX3_RET \
 	"200 18983215 OK\r\n" \
-	"\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -98,7 +98,7 @@
 
 #define MDCX3A_RET \
 	"200 18983215 OK\r\n" \
-	"\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -110,7 +110,7 @@
 
 #define MDCX3_FMTP_RET \
 	"200 18983215 OK\r\n" \
-	"\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -138,7 +138,7 @@
 
 #define MDCX4_RET(Ident) \
 	"200 " Ident " OK\r\n" \
-	"\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -150,7 +150,7 @@
 
 #define MDCX4_RO_RET(Ident) \
 	"200 " Ident " OK\r\n" \
-	"\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -247,8 +247,8 @@
 
 #define CRCX_RET \
 	"200 2 OK\r\n" \
-	"I: %s\n" \
-	"\n" \
+	"I: %s\r\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -260,8 +260,8 @@
 
 #define CRCX_RET_NO_RTPMAP \
 	"200 2 OK\r\n" \
-	"I: %s\n" \
-	"\n" \
+	"I: %s\r\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -272,8 +272,8 @@
 
 #define CRCX_FMTP_RET \
 	"200 2 OK\r\n" \
-	"I: %s\n" \
-	"\n" \
+	"I: %s\r\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \
@@ -296,8 +296,8 @@
 
 #define CRCX_ZYN_RET \
 	"200 2 OK\r\n" \
-	"I: %s\n" \
-	"\n" \
+	"I: %s\r\n" \
+	"\r\n" \
 	"v=0\r\n" \
 	"o=- %s 23 IN IP4 0.0.0.0\r\n" \
 	"s=-\r\n" \

-- 
To view, visit https://gerrit.osmocom.org/5981
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0cd80afae65accd3b4ddc5d82e5d30385879141c
Gerrit-PatchSet: 3
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list