From: Holger Hans Peter Freyther <[email protected]>

Some systems only want to use Osmux. In case only Osmux
should be used fail if it has not be offered/acked.

Client:

Verified On, Off and Only with X-Osmux: 3 and without this field.
<000b> mgcp_protocol.c:823 Osmux only and no osmux offered on 0x14
<000b> mgcp_protocol.c:884 Resource error on 0x14

NAT:

Not tested and implemented

Fixes: OW#1492
---
 openbsc/include/openbsc/osmux.h     |  6 +++++
 openbsc/src/libmgcp/mgcp_protocol.c |  4 ++++
 openbsc/src/libmgcp/mgcp_vty.c      | 45 +++++++++++++++++++++++++------------
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/openbsc/include/openbsc/osmux.h b/openbsc/include/openbsc/osmux.h
index 0e727d5..88d045b 100644
--- a/openbsc/include/openbsc/osmux.h
+++ b/openbsc/include/openbsc/osmux.h
@@ -30,4 +30,10 @@ enum osmux_state {
        OSMUX_STATE_ENABLED,
 };

+enum osmux_usage {
+       OSMUX_USAGE_OFF = 0,
+       OSMUX_USAGE_ON = 1,
+       OSMUX_USAGE_ONLY = 2,
+};
+
 #endif
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c 
b/openbsc/src/libmgcp/mgcp_protocol.c
index ab98be1..e2bda3a 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -818,6 +818,10 @@ mgcp_header_done:
        if (osmux_cid >= 0) {
                endp->osmux.cid = osmux_cid;
                endp->osmux.state = OSMUX_STATE_ACTIVATING;
+       } else if(endp->cfg->osmux == OSMUX_USAGE_ONLY) {
+               LOGP(DMGCP, LOGL_ERROR,
+                       "Osmux only and no osmux offered on 0x%x\n", 
ENDPOINT_NUMBER(endp));
+               goto error2;
        }

        endp->allocated = 1;
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index 2b76436..c478b0a 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -139,8 +139,19 @@ static int config_write_mgcp(struct vty *vty)
        if (g_cfg->bts_force_ptime > 0)
                vty_out(vty, "  rtp force-ptime %d%s", g_cfg->bts_force_ptime, 
VTY_NEWLINE);
        vty_out(vty, "  transcoder-remote-base %u%s", 
g_cfg->transcoder_remote_base, VTY_NEWLINE);
-       vty_out(vty, "  osmux %s%s",
-               g_cfg->osmux == 1 ? "on" : "off", VTY_NEWLINE);
+
+       switch (g_cfg->osmux) {
+       case OSMUX_USAGE_ON:
+               vty_out(vty, "  osmux on%s", VTY_NEWLINE);
+               break;
+       case OSMUX_USAGE_ONLY:
+               vty_out(vty, "  osmux only%s", VTY_NEWLINE);
+               break;
+       case OSMUX_USAGE_OFF:
+       default:
+               vty_out(vty, "  osmux off%s", VTY_NEWLINE);
+               break;
+       }
        if (g_cfg->osmux) {
                vty_out(vty, "  osmux batch-factor %d%s",
                        g_cfg->osmux_batch, VTY_NEWLINE);
@@ -1249,18 +1260,24 @@ DEFUN(reset_all_endp, reset_all_endp_cmd,
 #define OSMUX_STR "RTP multiplexing\n"
 DEFUN(cfg_mgcp_osmux,
       cfg_mgcp_osmux_cmd,
-      "osmux (on|off)",
-       OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n")
-{
-       if (strcmp(argv[0], "on") == 0) {
-               g_cfg->osmux = 1;
-               if (g_cfg->trunk.audio_loop) {
-                       vty_out(vty, "Cannot use `loop' with `osmux'.%s",
-                               VTY_NEWLINE);
-                       return CMD_WARNING;
-               }
-       } else if (strcmp(argv[0], "off") == 0)
-               g_cfg->osmux = 0;
+      "osmux (on|off|only)",
+       OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n")
+{
+       if (strcmp(argv[0], "off") == 0) {
+               g_cfg->osmux = OSMUX_USAGE_OFF;
+               return CMD_SUCCESS;
+       }
+
+       if (strcmp(argv[0], "on") == 0)
+               g_cfg->osmux = OSMUX_USAGE_ON;
+       else if (strcmp(argv[0], "only") == 0)
+               g_cfg->osmux = OSMUX_USAGE_ONLY;
+
+       if (g_cfg->trunk.audio_loop) {
+               vty_out(vty, "Cannot use `loop' with `osmux'.%s",
+                       VTY_NEWLINE);
+               return CMD_WARNING;
+       }

        return CMD_SUCCESS;
 }
-- 
2.6.0

Reply via email to