aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-08-30 16:36:44 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-08-30 16:36:44 +0200
commitdc75669e42d561d0526b53f7cb2054b56ba93abf (patch)
tree5c2c817458086f8881689b8b3b984500ee55c742 /openbsc/src/osmo-bsc_nat
parent1650d5d50b0282af51b6e6929cc955cf99852c96 (diff)
mgcp: Add a per BSC option to use compression or not use it.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c20
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c13
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c2
3 files changed, 31 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 9ac54dabe..ddeb2413c 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -339,7 +339,8 @@ int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int state,
/* we need to generate a new and patched message */
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);
+ nat->mgcp_cfg->source_addr, mgcp_endp->bts_end.local_port,
+ sccp->bsc->cfg->allow_compr);
if (!bsc_msg) {
LOGP(DMGCP, LOGL_ERROR, "Failed to patch the msg.\n");
return MGCP_POLICY_CONT;
@@ -471,7 +472,8 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
* with the value of 0 should be no problem.
*/
output = bsc_mgcp_rewrite((char * ) msg->l2h, msgb_l2len(msg), -1,
- bsc->nat->mgcp_cfg->source_addr, endp->net_end.local_port);
+ bsc->nat->mgcp_cfg->source_addr, endp->net_end.local_port,
+ bsc->cfg->allow_compr);
if (!output) {
LOGP(DMGCP, LOGL_ERROR, "Failed to rewrite MGCP msg.\n");
@@ -523,7 +525,8 @@ 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)
+struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint,
+ const char *ip, int port, int allow_compr)
{
static const char *crcx_str = "CRCX ";
static const char *dlcx_str = "DLCX ";
@@ -535,6 +538,7 @@ struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint, const char
char buf[128];
char *running, *token;
struct msgb *output;
+ int is_crcx;
if (length > 4096 - 128) {
LOGP(DMGCP, LOGL_ERROR, "Input is too long.\n");
@@ -555,11 +559,21 @@ struct msgb *bsc_mgcp_rewrite(char *input, int length, int endpoint, const char
int cr = len > 0 && token[len - 1] == '\r';
if (strncmp(crcx_str, token, (sizeof crcx_str) - 1) == 0) {
+ is_crcx = 1;
patch_mgcp(output, "CRCX", token, endpoint, len, cr);
} else if (strncmp(dlcx_str, token, (sizeof dlcx_str) - 1) == 0) {
patch_mgcp(output, "DLCX", token, endpoint, len, cr);
} else if (strncmp(mdcx_str, token, (sizeof mdcx_str) - 1) == 0) {
patch_mgcp(output, "MDCX", token, endpoint, len, cr);
+ } else if (strncmp("C:", token, 2) == 0 && is_crcx && allow_compr) {
+ output->l3h = msgb_put(output, len + 1);
+ memcpy(output->l3h, token, len);
+ output->l3h[len] = '\n';
+
+ snprintf(buf, sizeof(buf) - 1,
+ "X-ow-encr: 1%s", cr ? "\r\n" : "\n");
+ output->l3h = msgb_put(output, strlen(buf));
+ memcpy(output->l3h, buf, strlen(buf));
} else if (strncmp(ip_str, token, (sizeof ip_str) - 1) == 0) {
output->l3h = msgb_put(output, strlen(ip_str));
memcpy(output->l3h, ip_str, strlen(ip_str));
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index 55b3958c0..78b19558b 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -149,6 +149,8 @@ static void config_write_bsc_single(struct vty *vty, struct bsc_config *bsc)
if (bsc->paging_group != -1)
vty_out(vty, " paging group %d%s", bsc->paging_group, VTY_NEWLINE);
vty_out(vty, " paging forbidden %d%s", bsc->forbid_paging, VTY_NEWLINE);
+ if (bsc->allow_compr)
+ vty_out(vty, " allow-compression allow%s", VTY_NEWLINE);
}
static int config_write_bsc(struct vty *vty)
@@ -790,6 +792,16 @@ DEFUN(cfg_bsc_no_paging_grp,
return CMD_SUCCESS;
}
+DEFUN(cfg_bsc_allow_compr,
+ cfg_bsc_allow_compr_cmd,
+ "allow-compression (forbid|allow)",
+ "Allow RTP compression for this BSC\n" "Forbid\n" "Allow\n")
+{
+ struct bsc_config *conf = vty->index;
+ conf->allow_compr = argv[0][0] == 'a' ? 1 : 0;
+ return CMD_SUCCESS;
+}
+
DEFUN(test_regex, test_regex_cmd,
"test regex PATTERN STRING",
"Check if the string is matching the current pattern.")
@@ -983,6 +995,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(NAT_BSC_NODE, &cfg_bsc_old_grp_cmd);
install_element(NAT_BSC_NODE, &cfg_bsc_paging_grp_cmd);
install_element(NAT_BSC_NODE, &cfg_bsc_no_paging_grp_cmd);
+ install_element(NAT_BSC_NODE, &cfg_bsc_allow_compr_cmd);
mgcp_vty_init();
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index bbbeead9a..1bae02c75 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -386,7 +386,7 @@ int bsc_check_ussd(struct sccp_connections *con, struct bsc_nat_parsed *parsed,
return 0;
if (regexec(&con->bsc->nat->ussd_query_re,
- req.text, 0, NULL, 0) == REG_NOMATCH)
+ (const char *) req.text, 0, NULL, 0) == REG_NOMATCH)
return 0;
/* found a USSD query for our subscriber */