diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-08-13 18:31:09 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-08-13 18:53:10 +0200 |
commit | e9f7c9925c26b23f7c29ace8da381e439a658eeb (patch) | |
tree | f78d8bb4f1cd8b590716dc0c401af2554133c667 /openbsc/src/osmo-bsc_nat | |
parent | 29d58b734d169021bb794d259fa0dde205545bf1 (diff) |
nat: Forward SDP files with multiple payload types in it
The parsing code assumed that there will be a single payload
type and this assumption is clearly wrong. Forward all of the
payload types. The code is still only extracting the first
type from the list. The variable name has been renamed to
reflect this.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index 5a024dbc4..f04c9815a 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -815,7 +815,7 @@ static void patch_mgcp(struct msgb *output, const char *op, const char *tok, /* we need to replace some strings... */ struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint, const char *ip, int port, int osmux_cid, - int *payload_type, int ensure_mode_set) + int *first_payload_type, int ensure_mode_set) { static const char crcx_str[] = "CRCX "; static const char dlcx_str[] = "DLCX "; @@ -873,14 +873,15 @@ struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint, output->l3h[0] = '\n'; } } else if (strncmp(aud_str, token, (sizeof aud_str) - 1) == 0) { - if (sscanf(token, "m=audio %*d RTP/AVP %d", &payload) != 1) { + int offset; + if (sscanf(token, "m=audio %*d RTP/AVP %n%d", &offset, &payload) != 1) { LOGP(DMGCP, LOGL_ERROR, "Could not parsed audio line.\n"); msgb_free(output); return NULL; } - snprintf(buf, sizeof(buf)-1, "m=audio %d RTP/AVP %d%s", - port, payload, cr ? "\r\n" : "\n"); + snprintf(buf, sizeof(buf)-1, "m=audio %d RTP/AVP %s\n", + port, &token[offset]); buf[sizeof(buf)-1] = '\0'; output->l3h = msgb_put(output, strlen(buf)); @@ -908,8 +909,8 @@ copy: memcpy(output->l3h, buf, strlen(buf)); } - if (payload != -1 && payload_type) - *payload_type = payload; + if (payload != -1 && first_payload_type) + *first_payload_type = payload; return output; } |