summaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-23 20:25:17 -0400
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-04-23 20:27:30 -0400
commit7f100c9712de5c684462e809bf31a58c0c326337 (patch)
treea0679413f21ddea3c2656f0463595056f4769989 /openbsc/src/osmo-bsc_nat
parentd4b03187c68c6136192f7a41335982b5ceeeb036 (diff)
nat: Make mode-set patching optional
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c10
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c3
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c23
3 files changed, 32 insertions, 4 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 97593031c..5a024dbc4 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -552,7 +552,8 @@ static int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int
bsc_msg = bsc_mgcp_rewrite((char *) nat->mgcp_msg, nat->mgcp_length,
sccp->bsc_endp, nat->mgcp_cfg->source_addr,
mgcp_endp->bts_end.local_port, osmux_cid,
- &mgcp_endp->net_end.codec.payload_type);
+ &mgcp_endp->net_end.codec.payload_type,
+ nat->sdp_ensure_amr_mode_set);
if (!bsc_msg) {
LOGP(DMGCP, LOGL_ERROR, "Failed to patch the msg.\n");
return MGCP_POLICY_CONT;
@@ -746,7 +747,8 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
output = bsc_mgcp_rewrite((char * ) msg->l2h, msgb_l2len(msg), -1,
bsc->nat->mgcp_cfg->source_addr,
endp->net_end.local_port, -1,
- &endp->bts_end.codec.payload_type);
+ &endp->bts_end.codec.payload_type,
+ bsc->nat->sdp_ensure_amr_mode_set);
if (!output) {
LOGP(DMGCP, LOGL_ERROR, "Failed to rewrite MGCP msg.\n");
return;
@@ -813,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 *payload_type, int ensure_mode_set)
{
static const char crcx_str[] = "CRCX ";
static const char dlcx_str[] = "DLCX ";
@@ -898,7 +900,7 @@ copy:
* the above code made sure that we have 128 bytes lefts. So we can
* safely append another line.
*/
- if (!found_fmtp && payload != -1) {
+ if (ensure_mode_set && !found_fmtp && payload != -1) {
snprintf(buf, sizeof(buf) - 1, "a=fmtp:%d mode-set=2%s",
payload, cr ? "\r\n" : "\n");
buf[sizeof(buf) - 1] = '\0';
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 93a91450c..5c3b696e2 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1526,6 +1526,9 @@ int main(int argc, char **argv)
return -5;
}
+ /* We need to add mode-set for amr codecs */
+ nat->sdp_ensure_amr_mode_set = 1;
+
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
logging_vty_add_cmds(&log_info);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index 2b7db2ee8..9e66cdc28 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -156,6 +156,8 @@ static int config_write_nat(struct vty *vty)
write_pgroup_lst(vty, pgroup);
if (_nat->mgcp_ipa)
vty_out(vty, " use-msc-ipa-for-mgcp%s", VTY_NEWLINE);
+ vty_out(vty, " %ssdp-ensure-amr-mode-set%s",
+ _nat->sdp_ensure_amr_mode_set ? "" : "no ", VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -773,6 +775,24 @@ DEFUN(cfg_nat_use_ipa_for_mgcp,
return CMD_SUCCESS;
}
+DEFUN(cfg_nat_sdp_amr_mode_set,
+ cfg_nat_sdp_amr_mode_set_cmd,
+ "sdp-ensure-amr-mode-set",
+ "Ensure that SDP records include a mode-set\n")
+{
+ _nat->sdp_ensure_amr_mode_set = 1;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_nat_no_sdp_amr_mode_set,
+ cfg_nat_no_sdp_amr_mode_set_cmd,
+ "no sdp-ensure-amr-mode-set",
+ NO_STR "Ensure that SDP records include a mode-set\n")
+{
+ _nat->sdp_ensure_amr_mode_set = 0;
+ return CMD_SUCCESS;
+}
+
/* per BSC configuration */
DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR",
"BSC configuration\n" "Identifier of the BSC\n")
@@ -1274,6 +1294,9 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(NAT_NODE, &cfg_nat_prefix_trie_cmd);
install_element(NAT_NODE, &cfg_nat_no_prefix_trie_cmd);
+ install_element(NAT_NODE, &cfg_nat_sdp_amr_mode_set_cmd);
+ install_element(NAT_NODE, &cfg_nat_no_sdp_amr_mode_set_cmd);
+
install_element(NAT_NODE, &cfg_nat_pgroup_cmd);
install_element(NAT_NODE, &cfg_nat_no_pgroup_cmd);
install_node(&pgroup_node, config_write_pgroup);