aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c26
-rw-r--r--openbsc/src/libmgcp/osmux.c8
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c16
3 files changed, 36 insertions, 14 deletions
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 0989cc6eb..0681c1038 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -879,6 +879,24 @@ uint32_t mgcp_rtp_packet_duration(struct mgcp_endpoint *endp,
return rtp->rate * f * rtp->frame_duration_num / rtp->frame_duration_den;
}
+static int mgcp_osmux_setup(struct mgcp_endpoint *endp)
+{
+ if (!endp->cfg->osmux_init) {
+ if (osmux_init(OSMUX_ROLE_BSC, endp->cfg) < 0) {
+ LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n");
+ return -1;
+ }
+ LOGP(DMGCP, LOGL_NOTICE, "OSMUX socket has been set up\n");
+ }
+
+ if (osmux_enable_endpoint(endp, OSMUX_ROLE_BSC) < 0) {
+ LOGP(DMGCP, LOGL_ERROR,
+ "Could not activate Osmux in endpoint %d\n",
+ ENDPOINT_NUMBER(endp));
+ }
+ return 0;
+}
+
static struct msgb *handle_create_con(struct mgcp_parse_data *p)
{
struct mgcp_trunk_config *tcfg;
@@ -910,12 +928,8 @@ static struct msgb *handle_create_con(struct mgcp_parse_data *p)
mode = (const char *) line + 3;
break;
case 'X':
- if (strcmp("Osmux: on", line + 2) == 0 &&
- osmux_enable_endpoint(endp, OSMUX_ROLE_BSC) < 0) {
- LOGP(DMGCP, LOGL_ERROR,
- "Could not activate osmux in endpoint %d\n",
- ENDPOINT_NUMBER(endp));
- }
+ if (strcmp("Osmux: on", line + 2) == 0)
+ mgcp_osmux_setup(endp);
break;
case '\0':
have_sdp = 1;
diff --git a/openbsc/src/libmgcp/osmux.c b/openbsc/src/libmgcp/osmux.c
index a6deeaabb..1370c9f21 100644
--- a/openbsc/src/libmgcp/osmux.c
+++ b/openbsc/src/libmgcp/osmux.c
@@ -439,14 +439,6 @@ int osmux_enable_endpoint(struct mgcp_endpoint *endp, int role)
*/
static const uint32_t rtp_ssrc_winlen = UINT32_MAX / 256;
- if (!endp->cfg->osmux_init) {
- if (osmux_init(role, endp->cfg) < 0) {
- LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n");
- return -1;
- }
- LOGP(DMGCP, LOGL_NOTICE, "OSMUX requested, ENABLING.\n");
- }
-
osmux_xfrm_output_init(&endp->osmux.out,
(endp->ci * rtp_ssrc_winlen) +
(random() % rtp_ssrc_winlen));
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index ab89db838..5229976af 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -33,6 +33,7 @@
#include <osmocom/core/utils.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/misc.h>
+#include <openbsc/osmux.h>
#include <osmocom/sccp/sccp.h>
@@ -1184,12 +1185,27 @@ DEFUN(cfg_bsc_osmux,
OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n")
{
struct bsc_config *conf = vty->index;
+ int old = conf->osmux;
if (strcmp(argv[0], "on") == 0)
conf->osmux = 1;
else if (strcmp(argv[0], "off") == 0)
conf->osmux = 0;
+ if (old == 0 && conf->osmux == 1) {
+ if (osmux_init(OSMUX_ROLE_BSC_NAT, conf->nat->mgcp_cfg) < 0) {
+ LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n");
+ return -1;
+ }
+ LOGP(DMGCP, LOGL_NOTICE, "Setting up OSMUX socket\n");
+ } else if (old == 1 && conf->osmux == 0) {
+ LOGP(DMGCP, LOGL_NOTICE, "Disabling OSMUX socket\n");
+ /* Don't stop the socket, we may already have ongoing voice
+ * flows already using Osmux. This just switch indicates that
+ * new upcoming flows should use RTP.
+ */
+ }
+
return CMD_SUCCESS;
}