diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-04-05 09:10:30 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2010-04-05 09:10:30 +0200 |
commit | c6a1fe773d16eb20d4cb1d3097761419436f4537 (patch) | |
tree | 505aa6ba3f4d99d4b7da902271149a529e35e90e /openbsc/src | |
parent | 729d468fdf196fb674127e053ec8a058858655f5 (diff) |
nat: Remember where the BTS is listening for things.
Extract the port from the BSS's MGCP Gateway so we know
where to forward the data to.
Diffstat (limited to 'openbsc/src')
-rw-r--r-- | openbsc/src/nat/bsc_mgcp_utils.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c index 74ef67bb5..82eeefc6b 100644 --- a/openbsc/src/nat/bsc_mgcp_utils.c +++ b/openbsc/src/nat/bsc_mgcp_utils.c @@ -185,7 +185,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg) struct msgb *output; struct bsc_endpoint *bsc_endp = NULL; struct mgcp_endpoint *endp = NULL; - int i, code; + int i, code, port; char transaction_id[60]; /* Some assumption that our buffer is big enough.. and null terminate */ @@ -223,6 +223,9 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg) /* make it point to our endpoint */ endp->ci = bsc_mgcp_extract_ci((const char *) msg->l2h); + port = bsc_mgcp_extract_port((const char *) msg->l2h); + endp->bts_rtp = htons(port); + endp->bts_rtcp = htons(port + 1); output = bsc_mgcp_rewrite((char * ) msg->l2h, msgb_l2len(msg), bsc->nat->mgcp_cfg->source_addr, endp->rtp_port); if (!output) { @@ -254,6 +257,18 @@ int bsc_mgcp_extract_ci(const char *str) return ci; } +int bsc_mgcp_extract_port(const char *str) +{ + int port; + char *res = strstr(str, "m=audio "); + if (!res) + return 0; + + if (sscanf(res, "m=audio %d RTP/AVP %*d", &port) != 1) + return 0; + return port; +} + /* we need to replace some strings... */ struct msgb *bsc_mgcp_rewrite(char *input, int length, const char *ip, int port) { |