Change in osmo-mgw[master]: osmux: Use DUMMY ft msg as per Osmux spec

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Wed May 15 21:55:00 UTC 2019


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/14067


Change subject: osmux: Use DUMMY ft msg as per Osmux spec
......................................................................

osmux: Use DUMMY ft msg as per Osmux spec

That MGCP_DUMMY_LOAD is an old hack prior to Osmux spec update, and it's
not nice since it cannot be 100% distinguished from a usual AMR ft
frame.

Let's use the correct DUMMY ft type and build it according spec. Allow
handling differently the old format for a while until we are sure no old
implementations (like bsc-nat) exist sending that kind of message.

Change-Id: Ib17d20b87b28aade49ba60519b56a96e694819af
---
M src/libosmo-mgcp/mgcp_osmux.c
1 file changed, 11 insertions(+), 5 deletions(-)



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

diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c
index 7a817f8..3b788b6 100644
--- a/src/libosmo-mgcp/mgcp_osmux.c
+++ b/src/libosmo-mgcp/mgcp_osmux.c
@@ -20,6 +20,7 @@
 
 #include <osmocom/netif/osmux.h>
 #include <osmocom/netif/rtp.h>
+#include <osmocom/netif/amr.h>
 
 #include <osmocom/mgcp/mgcp.h>
 #include <osmocom/mgcp/mgcp_internal.h>
@@ -554,7 +555,8 @@
  *  \returns bytes sent, -1 on error */
 int osmux_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn)
 {
-	char buf[1 + sizeof(uint8_t)];
+	struct osmux_hdr *osmuxh;
+	int buf_len;
 	struct in_addr addr_unset = {};
 
 	/*! The dummy packet will not be sent via the actual OSMUX connection,
@@ -566,9 +568,6 @@
 	 *  endpoint may have already punched the hole in the firewall. This
 	 *  approach is simple though. */
 
-	buf[0] = MGCP_DUMMY_LOAD;
-	memcpy(&buf[1], &conn->osmux.cid, sizeof(conn->osmux.cid));
-
 	/* Wait until we have the connection information from MDCX */
 	if (memcmp(&conn->end.addr, &addr_unset, sizeof(addr_unset)) == 0)
 		return 0;
@@ -576,12 +575,19 @@
 	if (endp_osmux_state_check(endp, conn, true) < 0)
 		return 0;
 
+	buf_len = sizeof(struct osmux_hdr) + osmo_amr_bytes(AMR_FT_0);
+	osmuxh = (struct osmux_hdr *) alloca(buf_len);
+	memset(osmuxh, 0, buf_len);
+	osmuxh->ft = OSMUX_FT_DUMMY;
+	osmuxh->amr_ft = AMR_FT_0;
+	osmuxh->circuit_id = conn->osmux.cid;
+
 	LOGPCONN(conn->conn, DLMGCP, LOGL_DEBUG,
 		 "sending OSMUX dummy load to %s:%u CID %u\n",
 		 inet_ntoa(conn->end.addr), ntohs(conn->end.rtp_port), conn->osmux.cid);
 
 	return mgcp_udp_send(osmux_fd.fd, &conn->end.addr,
-			     conn->end.rtp_port, buf, sizeof(buf));
+			     conn->end.rtp_port, (char*)osmuxh, buf_len);
 }
 
 /* bsc-nat allocates/releases the Osmux circuit ID. +7 to round up to 8 bit boundary. */

-- 
To view, visit https://gerrit.osmocom.org/14067
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib17d20b87b28aade49ba60519b56a96e694819af
Gerrit-Change-Number: 14067
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190515/d81ff286/attachment.html>


More information about the gerrit-log mailing list