diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-09 00:38:06 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-22 15:15:13 +0200 |
commit | 48a071e3665a3e04fd7c341dd28422796682f5f5 (patch) | |
tree | 1365371e5c827fa1eaa04b40e83582dc8122256a | |
parent | 07ec8eebe0537848e00ee346b8d8ac2bcbe22fab (diff) |
osmux: Extract the dummy message, find the endpoint and set rtp port
Set the remote port for the endpoint. Somehow this needs to propagate
all the way to the handle.
-rw-r--r-- | openbsc/src/libmgcp/osmux.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/openbsc/src/libmgcp/osmux.c b/openbsc/src/libmgcp/osmux.c index 716b5f57a..ad9c2ee71 100644 --- a/openbsc/src/libmgcp/osmux.c +++ b/openbsc/src/libmgcp/osmux.c @@ -267,6 +267,39 @@ out: return 0; } +/* + * Try to figure out where it came from and enter the rtp_port + */ +static int osmux_handle_dummy(struct mgcp_config *cfg, + struct sockaddr_in *addr, struct msgb *msg) +{ + struct mgcp_endpoint *endp; + uint32_t ci; + + if (msg->len < 1 + sizeof(ci)) + goto out; + + /* extract the CI from the dummy message */ + memcpy(&ci, &msg->data[1], sizeof(ci)); + ci = ntohl(ci); + + endp = endpoint_lookup(cfg, ci & 0xff, &addr->sin_addr, MGCP_DEST_BTS); + if (!endp) { + LOGP(DMGCP, LOGL_ERROR, "Can not find CI=%d\n", ci & 0xff); + goto out; + } + + if (endp->bts_end.rtp_port == 0) { + endp->bts_end.rtp_port = addr->sin_port; + LOGP(DMGCP, LOGL_NOTICE, "0x%x found BTS on endpoint %s:%d\n", + ENDPOINT_NUMBER(endp), + inet_ntoa(addr->sin_addr), htons(addr->sin_port)); + } +out: + msgb_free(msg); + return 0; +} + int osmux_read_from_bsc_cb(struct osmo_fd *ofd, unsigned int what) { struct msgb *msg; @@ -282,7 +315,7 @@ int osmux_read_from_bsc_cb(struct osmo_fd *ofd, unsigned int what) /* not any further processing dummy messages */ if (msg->data[0] == MGCP_DUMMY_LOAD) - goto out; + return osmux_handle_dummy(cfg, &addr, msg); osmux_snprintf(buf, sizeof(buf), msg); LOGP(DMGCP, LOGL_DEBUG, |