Change in openbsc[master]: mgcp: osmux: Move parse_cid of legacy dummy frames to own function

2018-10-15 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/11336 )

Change subject: mgcp: osmux: Move parse_cid of legacy dummy frames to own 
function
..

mgcp: osmux: Move parse_cid of legacy dummy frames to own function

Change-Id: If9249fb0ee2e33c7dd2ab817480776acaa784cc2
---
M openbsc/src/libmgcp/mgcp_osmux.c
1 file changed, 15 insertions(+), 10 deletions(-)

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



diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c
index 7590f18..ea0372b 100644
--- a/openbsc/src/libmgcp/mgcp_osmux.c
+++ b/openbsc/src/libmgcp/mgcp_osmux.c
@@ -261,6 +261,20 @@
return msg;
 }

+static int osmux_legacy_dummy_parse_cid(struct sockaddr_in *addr, struct msgb 
*msg,
+   uint8_t *osmux_cid)
+{
+   if (msg->len < 1 + sizeof(osmux_cid)) {
+   LOGP(DMGCP, LOGL_ERROR,
+"Discarding truncated Osmux dummy load\n");
+   return -1;
+   }
+
+   /* extract the osmux CID from the dummy message */
+   memcpy(osmux_cid, >data[1], sizeof(*osmux_cid));
+   return 0;
+}
+
 #define osmux_chunk_length(msg, rem) (rem - msg->len);

 int osmux_read_from_bsc_nat_cb(struct osmo_fd *ofd, unsigned int what)
@@ -316,17 +330,8 @@
struct mgcp_endpoint *endp;
uint8_t osmux_cid;

-   if (msg->len < 1 + sizeof(osmux_cid)) {
-   LOGP(DMGCP, LOGL_ERROR,
-"Discarding truncated Osmux dummy load\n");
+   if (osmux_legacy_dummy_parse_cid(addr, msg, _cid) < 0)
goto out;
-   }
-
-   LOGP(DMGCP, LOGL_DEBUG, "Received Osmux dummy load from %s\n",
-inet_ntoa(addr->sin_addr));
-
-   /* extract the osmux CID from the dummy message */
-   memcpy(_cid, >data[1], sizeof(osmux_cid));

endp = endpoint_lookup(cfg, osmux_cid, >sin_addr, MGCP_DEST_BTS);
if (!endp) {

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

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If9249fb0ee2e33c7dd2ab817480776acaa784cc2
Gerrit-Change-Number: 11336
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 


Change in openbsc[master]: mgcp: osmux: Move parse_cid of legacy dummy frames to own function

2018-10-12 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/11336


Change subject: mgcp: osmux: Move parse_cid of legacy dummy frames to own 
function
..

mgcp: osmux: Move parse_cid of legacy dummy frames to own function

Change-Id: If9249fb0ee2e33c7dd2ab817480776acaa784cc2
---
M openbsc/src/libmgcp/mgcp_osmux.c
1 file changed, 15 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/36/11336/1

diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c
index 7590f18..ea0372b 100644
--- a/openbsc/src/libmgcp/mgcp_osmux.c
+++ b/openbsc/src/libmgcp/mgcp_osmux.c
@@ -261,6 +261,20 @@
return msg;
 }

+static int osmux_legacy_dummy_parse_cid(struct sockaddr_in *addr, struct msgb 
*msg,
+   uint8_t *osmux_cid)
+{
+   if (msg->len < 1 + sizeof(osmux_cid)) {
+   LOGP(DMGCP, LOGL_ERROR,
+"Discarding truncated Osmux dummy load\n");
+   return -1;
+   }
+
+   /* extract the osmux CID from the dummy message */
+   memcpy(osmux_cid, >data[1], sizeof(*osmux_cid));
+   return 0;
+}
+
 #define osmux_chunk_length(msg, rem) (rem - msg->len);

 int osmux_read_from_bsc_nat_cb(struct osmo_fd *ofd, unsigned int what)
@@ -316,17 +330,8 @@
struct mgcp_endpoint *endp;
uint8_t osmux_cid;

-   if (msg->len < 1 + sizeof(osmux_cid)) {
-   LOGP(DMGCP, LOGL_ERROR,
-"Discarding truncated Osmux dummy load\n");
+   if (osmux_legacy_dummy_parse_cid(addr, msg, _cid) < 0)
goto out;
-   }
-
-   LOGP(DMGCP, LOGL_DEBUG, "Received Osmux dummy load from %s\n",
-inet_ntoa(addr->sin_addr));
-
-   /* extract the osmux CID from the dummy message */
-   memcpy(_cid, >data[1], sizeof(osmux_cid));

endp = endpoint_lookup(cfg, osmux_cid, >sin_addr, MGCP_DEST_BTS);
if (!endp) {

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

Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9249fb0ee2e33c7dd2ab817480776acaa784cc2
Gerrit-Change-Number: 11336
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol