Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/11378
Change subject: osmux: Move parse_cid of legacy dummy frames to own function ...................................................................... osmux: Move parse_cid of legacy dummy frames to own function Backport from openbsc b010f869c915016b7fa97a26621582cd89de96b0. Change-Id: I5766165985fbfcecc63d45b9e229322bc8cedf52 --- M src/libosmo-mgcp/mgcp_osmux.c 1 file changed, 15 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/78/11378/1 diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index 2e6307e..9081873 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -316,6 +316,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(DLMGCP, LOGL_ERROR, + "Discarding truncated Osmux dummy load\n"); + return -1; + } + + /* extract the osmux CID from the dummy message */ + memcpy(osmux_cid, &msg->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) @@ -379,17 +393,8 @@ uint8_t osmux_cid; struct mgcp_conn_rtp *conn_net = NULL; - if (msg->len < 1 + sizeof(osmux_cid)) { - LOGP(DLMGCP, LOGL_ERROR, - "Discarding truncated Osmux dummy load\n"); + if (osmux_legacy_dummy_parse_cid(addr, msg, &osmux_cid) < 0) goto out; - } - - LOGP(DLMGCP, LOGL_DEBUG, "Received Osmux dummy load from %s\n", - inet_ntoa(addr->sin_addr)); - - /* extract the osmux CID from the dummy message */ - memcpy(&osmux_cid, &msg->data[1], sizeof(osmux_cid)); endp = endpoint_lookup(cfg, osmux_cid, &addr->sin_addr, MGCP_DEST_BTS); if (!endp) { -- To view, visit https://gerrit.osmocom.org/11378 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: I5766165985fbfcecc63d45b9e229322bc8cedf52 Gerrit-Change-Number: 11378 Gerrit-PatchSet: 1 Gerrit-Owner: Pau Espin Pedrol <pes...@sysmocom.de>