From c458f43bf5ed39067e203ab198320756d023b9f9 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Thu, 21 Dec 2017 12:42:22 +0100 Subject: osmo-bsc_nat: Reenable osmux support Change-Id: Ib98b65767884d615aac5c537dc58f2cdf5ff4bfa --- openbsc/include/openbsc/mgcp.h | 41 +++---- openbsc/include/openbsc/osmux.h | 3 +- openbsc/include/openbsc/vty.h | 3 +- openbsc/src/libcommon/common_vty.c | 1 + openbsc/src/libmgcp/mgcp_osmux.c | 78 ++++++++------ openbsc/src/libmgcp/mgcp_protocol.c | 9 +- openbsc/src/libmgcp/mgcp_vty.c | 172 ++++++++++++++++++------------ openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 4 +- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 9 +- 9 files changed, 184 insertions(+), 136 deletions(-) diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h index dbb9ff1ee..3445777c5 100644 --- a/openbsc/include/openbsc/mgcp.h +++ b/openbsc/include/openbsc/mgcp.h @@ -170,6 +170,28 @@ enum mgcp_role { MGCP_BSC_NAT, }; +struct osmux_config { + struct llist_head *mgcp_cfgs; + /* osmux translator: 0 means disabled, 1 means enabled */ + int osmux_enabled; + /* addr to bind the server to */ + char *osmux_addr; + /* The BSC-NAT may ask for enabling osmux on demand. This tells us if + * the osmux socket is already initialized. + */ + int osmux_init; + /* osmux batch factor: from 1 to 4 maximum */ + int osmux_batch; + /* osmux batch size (in bytes) */ + int osmux_batch_size; + /* osmux port */ + uint16_t osmux_port; + /* Pad circuit with dummy messages until we see the first voice + * message. + */ + uint16_t osmux_dummy; +}; + struct mgcp_config { struct llist_head entry; int nr; @@ -220,24 +242,7 @@ struct mgcp_config { enum mgcp_role role; - /* osmux translator: 0 means disabled, 1 means enabled */ - int osmux; - /* addr to bind the server to */ - char *osmux_addr; - /* The BSC-NAT may ask for enabling osmux on demand. This tells us if - * the osmux socket is already initialized. - */ - int osmux_init; - /* osmux batch factor: from 1 to 4 maximum */ - int osmux_batch; - /* osmux batch size (in bytes) */ - int osmux_batch_size; - /* osmux port */ - uint16_t osmux_port; - /* Pad circuit with dummy messages until we see the first voice - * message. - */ - uint16_t osmux_dummy; + struct osmux_config *osmux_cfg; }; /* config management */ diff --git a/openbsc/include/openbsc/osmux.h b/openbsc/include/openbsc/osmux.h index f3ea72a85..f6ff10830 100644 --- a/openbsc/include/openbsc/osmux.h +++ b/openbsc/include/openbsc/osmux.h @@ -10,7 +10,8 @@ enum { OSMUX_ROLE_BSC_NAT, }; -int osmux_init(int role, struct mgcp_config *cfg); +int osmux_is_inited(struct osmux_config *cfg); +int osmux_init(int role, struct osmux_config* cfg); int osmux_enable_endpoint(struct mgcp_endpoint *endp, struct in_addr *addr, uint16_t port); void osmux_disable_endpoint(struct mgcp_endpoint *endp); void osmux_allocate_cid(struct mgcp_endpoint *endp); diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h index 9e34eda7c..562c0be61 100644 --- a/openbsc/include/openbsc/vty.h +++ b/openbsc/include/openbsc/vty.h @@ -38,7 +38,8 @@ enum bsc_vty_node { SMPP_NODE, SMPP_ESME_NODE, GTPHUB_NODE, - NAT_MSC_NODE + NAT_MSC_NODE, + OSMUX_NODE }; extern int bsc_vty_is_config_node(struct vty *vty, int node); diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c index ad914f3d2..9422138a2 100644 --- a/openbsc/src/libcommon/common_vty.c +++ b/openbsc/src/libcommon/common_vty.c @@ -127,6 +127,7 @@ int bsc_vty_go_parent(struct vty *vty) case MSC_NODE: case MNCC_INT_NODE: case NITB_NODE: + case OSMUX_NODE: default: if (bsc_vty_is_config_node(vty, vty->node)) vty->node = CONFIG_NODE; diff --git a/openbsc/src/libmgcp/mgcp_osmux.c b/openbsc/src/libmgcp/mgcp_osmux.c index c52984b32..79b5fefb4 100644 --- a/openbsc/src/libmgcp/mgcp_osmux.c +++ b/openbsc/src/libmgcp/mgcp_osmux.c @@ -120,9 +120,9 @@ osmux_handle_alloc(struct mgcp_config *cfg, struct in_addr *addr, int rem_port) } h->in->osmux_seq = 0; /* sequence number to start OSmux message from */ - h->in->batch_factor = cfg->osmux_batch; + h->in->batch_factor = cfg->osmux_cfg->osmux_batch; /* If batch size is zero, the library defaults to 1470 bytes. */ - h->in->batch_size = cfg->osmux_batch_size; + h->in->batch_size = cfg->osmux_cfg->osmux_batch_size; h->in->deliver = osmux_deliver; osmux_xfrm_input_init(h->in); h->in->data = h; @@ -171,36 +171,39 @@ int osmux_xfrm_to_osmux(int type, char *buf, int rc, struct mgcp_endpoint *endp) } static struct mgcp_endpoint * -endpoint_lookup(struct mgcp_config *cfg, int cid, +endpoint_lookup(struct llist_head *cfgs, int cid, struct in_addr *from_addr, int type) { struct mgcp_endpoint *tmp = NULL; + struct mgcp_config *cfg; int i; - /* Lookup for the endpoint that corresponds to this port */ - for (i=0; itrunk.number_endpoints; i++) { - struct in_addr *this; + llist_for_each_entry(cfg, cfgs, entry) { + /* Lookup for the endpoint that corresponds to this port */ + for (i=0; itrunk.number_endpoints; i++) { + struct in_addr *this; - tmp = &cfg->trunk.endpoints[i]; + tmp = &cfg->trunk.endpoints[i]; - if (!tmp->allocated) - continue; + if (!tmp->allocated) + continue; - switch(type) { - case MGCP_DEST_NET: - this = &tmp->net_end.addr; - break; - case MGCP_DEST_BTS: - this = &tmp->bts_end.addr; - break; - default: - /* Should not ever happen */ - LOGP(DMGCP, LOGL_ERROR, "Bad type %d. Fix your code.\n", type); - return NULL; - } + switch(type) { + case MGCP_DEST_NET: + this = &tmp->net_end.addr; + break; + case MGCP_DEST_BTS: + this = &tmp->bts_end.addr; + break; + default: + /* Should not ever happen */ + LOGP(DMGCP, LOGL_ERROR, "Bad type %d. Fix your code.\n", type); + return NULL; + } - if (tmp->osmux.cid == cid && this->s_addr == from_addr->s_addr) - return tmp; + if (tmp->osmux.cid == cid && this->s_addr == from_addr->s_addr) + return tmp; + } } LOGP(DMGCP, LOGL_ERROR, "Cannot find endpoint with cid=%d\n", cid); @@ -269,7 +272,7 @@ int osmux_read_from_bsc_nat_cb(struct osmo_fd *ofd, unsigned int what) struct osmux_hdr *osmuxh; struct llist_head list; struct sockaddr_in addr; - struct mgcp_config *cfg = ofd->data; + struct osmux_config *cfg = ofd->data; uint32_t rem; msg = osmux_recv(ofd, &addr); @@ -285,7 +288,7 @@ int osmux_read_from_bsc_nat_cb(struct osmo_fd *ofd, unsigned int what) struct mgcp_endpoint *endp; /* Yes, we use MGCP_DEST_NET to locate the origin */ - endp = endpoint_lookup(cfg, osmuxh->circuit_id, + endp = endpoint_lookup(cfg->mgcp_cfgs, osmuxh->circuit_id, &addr.sin_addr, MGCP_DEST_NET); if (!endp) { LOGP(DMGCP, LOGL_ERROR, @@ -306,7 +309,7 @@ out: } /* This is called from the bsc-nat */ -static int osmux_handle_dummy(struct mgcp_config *cfg, struct sockaddr_in *addr, +static int osmux_handle_dummy(struct osmux_config *cfg, struct sockaddr_in *addr, struct msgb *msg) { struct mgcp_endpoint *endp; @@ -321,7 +324,7 @@ static int osmux_handle_dummy(struct mgcp_config *cfg, struct sockaddr_in *addr, LOGP(DMGCP, LOGL_DEBUG, "Received Osmux dummy load from %s\n", inet_ntoa(addr->sin_addr)); - if (!cfg->osmux) { + if (!cfg->osmux_enabled) { LOGP(DMGCP, LOGL_ERROR, "bsc wants to use Osmux but bsc-nat did not request it\n"); goto out; @@ -330,7 +333,7 @@ static int osmux_handle_dummy(struct mgcp_config *cfg, struct sockaddr_in *addr, /* extract the osmux CID from the dummy message */ memcpy(&osmux_cid, &msg->data[1], sizeof(osmux_cid)); - endp = endpoint_lookup(cfg, osmux_cid, &addr->sin_addr, MGCP_DEST_BTS); + endp = endpoint_lookup(cfg->mgcp_cfgs, osmux_cid, &addr->sin_addr, MGCP_DEST_BTS); if (!endp) { LOGP(DMGCP, LOGL_ERROR, "Cannot find endpoint for Osmux CID %d\n", osmux_cid); @@ -361,7 +364,7 @@ int osmux_read_from_bsc_cb(struct osmo_fd *ofd, unsigned int what) struct osmux_hdr *osmuxh; struct llist_head list; struct sockaddr_in addr; - struct mgcp_config *cfg = ofd->data; + struct osmux_config *cfg = ofd->data; uint32_t rem; msg = osmux_recv(ofd, &addr); @@ -377,7 +380,7 @@ int osmux_read_from_bsc_cb(struct osmo_fd *ofd, unsigned int what) struct mgcp_endpoint *endp; /* Yes, we use MGCP_DEST_BTS to locate the origin */ - endp = endpoint_lookup(cfg, osmuxh->circuit_id, + endp = endpoint_lookup(cfg->mgcp_cfgs, osmuxh->circuit_id, &addr.sin_addr, MGCP_DEST_BTS); if (!endp) { LOGP(DMGCP, LOGL_ERROR, @@ -397,7 +400,12 @@ out: return 0; } -int osmux_init(int role, struct mgcp_config *cfg) +int osmux_is_inited(struct osmux_config *cfg) +{ + return cfg->osmux_init; +} + +int osmux_init(int role, struct osmux_config *cfg) { int ret; @@ -461,7 +469,7 @@ int osmux_enable_endpoint(struct mgcp_endpoint *endp, struct in_addr *addr, uint return -1; } if (!osmux_xfrm_input_open_circuit(endp->osmux.in, endp->osmux.cid, - endp->cfg->osmux_dummy)) { + endp->cfg->osmux_cfg->osmux_dummy)) { LOGP(DMGCP, LOGL_ERROR, "Cannot open osmux circuit %u\n", endp->osmux.cid); return -1; @@ -521,7 +529,7 @@ int osmux_send_dummy(struct mgcp_endpoint *endp) if (endp->osmux.state == OSMUX_STATE_ACTIVATING) { if (osmux_enable_endpoint(endp, &endp->net_end.addr, - htons(endp->cfg->osmux_port)) < 0) { + htons(endp->cfg->osmux_cfg->osmux_port)) < 0) { LOGP(DMGCP, LOGL_ERROR, "Could not activate osmux in endpoint %d\n", ENDPOINT_NUMBER(endp)); @@ -529,14 +537,14 @@ int osmux_send_dummy(struct mgcp_endpoint *endp) LOGP(DMGCP, LOGL_ERROR, "Osmux CID %u for %s:%u is now enabled\n", endp->osmux.cid, inet_ntoa(endp->net_end.addr), - endp->cfg->osmux_port); + endp->cfg->osmux_cfg->osmux_port); } LOGP(DMGCP, LOGL_DEBUG, "sending OSMUX dummy load to %s CID %u\n", inet_ntoa(endp->net_end.addr), endp->osmux.cid); return mgcp_udp_send(osmux_fd.fd, &endp->net_end.addr, - htons(endp->cfg->osmux_port), buf, sizeof(buf)); + htons(endp->cfg->osmux_cfg->osmux_port), buf, sizeof(buf)); } /* bsc-nat allocates/releases the Osmux circuit ID */ diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c index 0305f5678..765e461a7 100644 --- a/openbsc/src/libmgcp/mgcp_protocol.c +++ b/openbsc/src/libmgcp/mgcp_protocol.c @@ -701,8 +701,8 @@ static int mgcp_parse_osmux_cid(const char *line) static int mgcp_osmux_setup(struct mgcp_endpoint *endp, const char *line) { - if (!endp->cfg->osmux_init) { - if (osmux_init(OSMUX_ROLE_BSC, endp->cfg) < 0) { + if (!endp->cfg->osmux_cfg->osmux_init) { + if (osmux_init(OSMUX_ROLE_BSC, endp->cfg->osmux_cfg) < 0) { LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n"); return -1; } @@ -746,7 +746,7 @@ static struct msgb *handle_create_con(struct mgcp_parse_data *p) /* Osmux is not enabled in this bsc, ignore it so the * bsc-nat knows that we don't want to use Osmux. */ - if (!p->endp->cfg->osmux) + if (!endp->cfg->osmux_cfg->osmux_enabled) break; if (strncmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) @@ -821,7 +821,7 @@ mgcp_header_done: if (osmux_cid >= 0) { endp->osmux.cid = osmux_cid; endp->osmux.state = OSMUX_STATE_NEGOTIATING; - } else if (endp->cfg->osmux == OSMUX_USAGE_ONLY) { + } else if (endp->cfg->osmux_cfg->osmux_enabled == OSMUX_USAGE_ONLY) { LOGP(DMGCP, LOGL_ERROR, "Osmux only and no osmux offered on 0x%x\n", ENDPOINT_NUMBER(endp)); goto error2; @@ -1195,7 +1195,6 @@ struct mgcp_config *mgcp_config_alloc(void) cfg->source_port = 2427; cfg->source_addr = talloc_strdup(cfg, "0.0.0.0"); - cfg->osmux_addr = talloc_strdup(cfg, "0.0.0.0"); cfg->transcoder_remote_base = 4000; diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c index 84a2f9661..8c8abef91 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -35,6 +35,7 @@ #define RTP_KEEPALIVE_STR "Send dummy UDP packet to net RTP destination\n" static LLIST_HEAD(mgcp_configs); +static struct osmux_config osmux_cfg; static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int nr) { @@ -51,6 +52,12 @@ static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int nr) /* * vty code for mgcp below */ +struct cmd_node osmux_node = { + OSMUX_NODE, + "%s(osmux)# ", + 1, +}; + struct cmd_node mgcp_node = { MGCP_NODE, "%s(config-mgcp)# ", @@ -63,6 +70,34 @@ struct cmd_node trunk_node = { 1, }; +static void config_write_osmux(struct vty *vty) +{ + switch (osmux_cfg.osmux_enabled) { + case OSMUX_USAGE_ON: + vty_out(vty, " osmux-enable on%s", VTY_NEWLINE); + break; + case OSMUX_USAGE_ONLY: + vty_out(vty, " osmux-enable only%s", VTY_NEWLINE); + break; + case OSMUX_USAGE_OFF: + default: + vty_out(vty, " osmux-enable off%s", VTY_NEWLINE); + break; + } + if (osmux_cfg.osmux_enabled) { + vty_out(vty, " bind-ip %s%s", + osmux_cfg.osmux_addr, VTY_NEWLINE); + vty_out(vty, " batch-factor %d%s", + osmux_cfg.osmux_batch, VTY_NEWLINE); + vty_out(vty, " batch-size %u%s", + osmux_cfg.osmux_batch_size, VTY_NEWLINE); + vty_out(vty, " port %u%s", + osmux_cfg.osmux_port, VTY_NEWLINE); + vty_out(vty, " dummy %s%s", + osmux_cfg.osmux_dummy ? "on" : "off", VTY_NEWLINE); + } +} + static void config_write_mgcp_single(struct vty *vty, struct mgcp_config *cfg) { vty_out(vty, "mgcp %u%s", cfg->nr, VTY_NEWLINE); @@ -140,30 +175,6 @@ static void config_write_mgcp_single(struct vty *vty, struct mgcp_config *cfg) vty_out(vty, " rtp force-ptime %d%s", cfg->bts_force_ptime, VTY_NEWLINE); vty_out(vty, " transcoder-remote-base %u%s", cfg->transcoder_remote_base, VTY_NEWLINE); - switch (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 (cfg->osmux) { - vty_out(vty, " osmux bind-ip %s%s", - cfg->osmux_addr, VTY_NEWLINE); - vty_out(vty, " osmux batch-factor %d%s", - cfg->osmux_batch, VTY_NEWLINE); - vty_out(vty, " osmux batch-size %u%s", - cfg->osmux_batch_size, VTY_NEWLINE); - vty_out(vty, " osmux port %u%s", - cfg->osmux_port, VTY_NEWLINE); - vty_out(vty, " osmux dummy %s%s", - cfg->osmux_dummy ? "on" : "off", VTY_NEWLINE); - } } static int config_write_mgcp(struct vty *vty) @@ -262,12 +273,30 @@ DEFUN(show_mcgp, show_mgcp_cmd, llist_for_each_entry(trunk, &mgcp->trunks, entry) dump_trunk(vty, trunk, show_stats); - if (mgcp->osmux) + if (osmux_cfg.osmux_enabled) vty_out(vty, "Osmux used CID: %d%s", osmux_used_cid(), VTY_NEWLINE); return CMD_SUCCESS; } +DEFUN(cfg_osmux, + cfg_osmux_cmd, + "osmux", + "Configure osmux support") +{ + osmux_cfg.mgcp_cfgs = &mgcp_configs; + osmux_cfg.osmux_port = OSMUX_PORT; + osmux_cfg.osmux_batch = 4; + osmux_cfg.osmux_batch_size = OSMUX_BATCH_DEFAULT_MAX; + osmux_cfg.osmux_addr = talloc_strdup(NULL, "0.0.0.0"); + + vty->node = OSMUX_NODE; + vty->index = &osmux_cfg; + + return CMD_SUCCESS; +} + + DEFUN(cfg_mgcp, cfg_mgcp_cmd, "mgcp [MGCP_NR]", @@ -298,9 +327,7 @@ DEFUN(cfg_mgcp, vty->index = mgcp; vty->node = MGCP_NODE; - mgcp->osmux_port = OSMUX_PORT; - mgcp->osmux_batch = 4; - mgcp->osmux_batch_size = OSMUX_BATCH_DEFAULT_MAX; + mgcp->osmux_cfg = &osmux_cfg; llist_add_tail(&mgcp->entry, &mgcp_configs); @@ -690,7 +717,7 @@ DEFUN(cfg_mgcp_loop, { struct mgcp_config *cfg = vty->index; - if (cfg->osmux) { + if (cfg->osmux_cfg->osmux_enabled) { vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); return CMD_WARNING; } @@ -1023,7 +1050,7 @@ DEFUN(cfg_trunk_loop, { struct mgcp_trunk_config *trunk = vty->index; - if (trunk->cfg->osmux) { + if (trunk->cfg->osmux_cfg->osmux_enabled) { vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); return CMD_WARNING; } @@ -1435,82 +1462,84 @@ 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|only)", +DEFUN(cfg_osmux_enable, + cfg_osmux_enable_cmd, + "osmux-enable (on|off|only)", OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only use OSMUX\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; if (strcmp(argv[0], "off") == 0) { - cfg->osmux = OSMUX_USAGE_OFF; + cfg->osmux_enabled = OSMUX_USAGE_OFF; return CMD_SUCCESS; } if (strcmp(argv[0], "on") == 0) - cfg->osmux = OSMUX_USAGE_ON; + cfg->osmux_enabled = OSMUX_USAGE_ON; else if (strcmp(argv[0], "only") == 0) - cfg->osmux = OSMUX_USAGE_ONLY; + cfg->osmux_enabled = OSMUX_USAGE_ONLY; +#warning fix +/* if (cfg->trunk.audio_loop) { vty_out(vty, "Cannot use `loop' with `osmux'.%s", VTY_NEWLINE); return CMD_WARNING; } - +*/ return CMD_SUCCESS; } -DEFUN(cfg_mgcp_osmux_ip, - cfg_mgcp_osmux_ip_cmd, - "osmux bind-ip A.B.C.D", - OSMUX_STR IP_STR "IPv4 Address to bind to\n") +DEFUN(cfg_osmux_ip, + cfg_osmux_ip_cmd, + "bind-ip A.B.C.D", + IP_STR "IPv4 Address to bind to\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; osmo_talloc_replace_string(cfg, &cfg->osmux_addr, argv[0]); return CMD_SUCCESS; } -DEFUN(cfg_mgcp_osmux_batch_factor, - cfg_mgcp_osmux_batch_factor_cmd, - "osmux batch-factor <1-8>", - OSMUX_STR "Batching factor\n" "Number of messages in the batch\n") +DEFUN(cfg_osmux_batch_factor, + cfg_osmux_batch_factor_cmd, + "batch-factor <1-8>", + "Batching factor\n" "Number of messages in the batch\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; cfg->osmux_batch = atoi(argv[0]); return CMD_SUCCESS; } -DEFUN(cfg_mgcp_osmux_batch_size, - cfg_mgcp_osmux_batch_size_cmd, - "osmux batch-size <1-65535>", - OSMUX_STR "batch size\n" "Batch size in bytes\n") +DEFUN(cfg_osmux_batch_size, + cfg_osmux_batch_size_cmd, + "batch-size <1-65535>", + "batch size\n" "Batch size in bytes\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; cfg->osmux_batch_size = atoi(argv[0]); return CMD_SUCCESS; } -DEFUN(cfg_mgcp_osmux_port, - cfg_mgcp_osmux_port_cmd, - "osmux port <1-65535>", - OSMUX_STR "port\n" "UDP port\n") +DEFUN(cfg_osmux_port, + cfg_osmux_port_cmd, + "port <1-65535>", + "port\n" "UDP port\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; cfg->osmux_port = atoi(argv[0]); return CMD_SUCCESS; } -DEFUN(cfg_mgcp_osmux_dummy, - cfg_mgcp_osmux_dummy_cmd, - "osmux dummy (on|off)", - OSMUX_STR "Dummy padding\n" "Enable dummy padding\n" "Disable dummy padding\n") +DEFUN(cfg_osmux_dummy, + cfg_osmux_dummy_cmd, + "dummy (on|off)", + "Dummy padding\n" "Enable dummy padding\n" "Disable dummy padding\n") { - struct mgcp_config *cfg = vty->index; + struct osmux_config *cfg = vty->index; if (strcmp(argv[0], "on") == 0) cfg->osmux_dummy = 1; @@ -1529,6 +1558,17 @@ int mgcp_vty_init(void) install_element(ENABLE_NODE, &reset_endp_cmd); install_element(ENABLE_NODE, &reset_all_endp_cmd); + install_element(CONFIG_NODE, &cfg_osmux_cmd); + install_node(&osmux_node, config_write_osmux); + + vty_install_default(OSMUX_NODE); + install_element(OSMUX_NODE, &cfg_osmux_enable_cmd); + install_element(OSMUX_NODE, &cfg_osmux_ip_cmd); + install_element(OSMUX_NODE, &cfg_osmux_batch_factor_cmd); + install_element(OSMUX_NODE, &cfg_osmux_batch_size_cmd); + install_element(OSMUX_NODE, &cfg_osmux_port_cmd); + install_element(OSMUX_NODE, &cfg_osmux_dummy_cmd); + install_element(CONFIG_NODE, &cfg_mgcp_cmd); install_node(&mgcp_node, config_write_mgcp); @@ -1578,12 +1618,6 @@ int mgcp_vty_init(void) install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd); install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_name_cmd); install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_name_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_ip_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_factor_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_batch_size_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_port_cmd); - install_element(MGCP_NODE, &cfg_mgcp_osmux_dummy_cmd); install_element(MGCP_NODE, &cfg_mgcp_allow_transcoding_cmd); install_element(MGCP_NODE, &cfg_mgcp_no_allow_transcoding_cmd); diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c index 3432d6b9a..efb56f9c6 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c @@ -511,7 +511,7 @@ struct nat_sccp_connection *bsc_mgcp_find_con(struct bsc_nat *nat, struct mgcp_c static int nat_osmux_only(struct mgcp_config *mgcp_cfg, struct bsc_config *bsc_cfg) { - if (mgcp_cfg->osmux == OSMUX_USAGE_ONLY) + if (mgcp_cfg->osmux_cfg->osmux_enabled == OSMUX_USAGE_ONLY) return 1; if (bsc_cfg->osmux == OSMUX_USAGE_ONLY) return 1; @@ -567,7 +567,7 @@ static int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int /* Allocate a Osmux circuit ID */ if (state == MGCP_ENDP_CRCX) { - if (tcfg->cfg->osmux && sccp->bsc->cfg->osmux) { + if (tcfg->cfg->osmux_cfg->osmux_enabled && sccp->bsc->cfg->osmux) { osmux_allocate_cid(mgcp_endp); if (mgcp_endp->osmux.allocated_cid < 0 && nat_osmux_only(tcfg->cfg, sccp->bsc->cfg)) { diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index f18098210..b0b6be0e8 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -1302,6 +1302,7 @@ DEFUN(cfg_bsc_osmux, OSMUX_STR "Enable OSMUX\n" "Disable OSMUX\n" "Only OSMUX\n") { struct bsc_config *conf = vty->index; + struct mgcp_config *mgcp_cfg; int old = conf->osmux; if (strcmp(argv[0], "on") == 0) @@ -1311,14 +1312,13 @@ DEFUN(cfg_bsc_osmux, else if (strcmp(argv[0], "only") == 0) conf->osmux = OSMUX_USAGE_ONLY; -#warning "OSMUX is missing support for multiple mgcp" if (conf->osmux != OSMUX_USAGE_OFF) return CMD_WARNING; -#if 0 - if (old == 0 && conf->osmux > 0 && !conf->nat->mgcp_cfg->osmux_init) { + mgcp_cfg = mgcp_config_by_num(conf->nat->mgcp_cfgs, 0); + if (old == 0 && conf->osmux > 0 && !osmux_is_inited(mgcp_cfg->osmux_cfg)) { LOGP(DMGCP, LOGL_NOTICE, "Setting up OSMUX socket\n"); - if (osmux_init(OSMUX_ROLE_BSC_NAT, conf->nat->mgcp_cfg) < 0) { + if (osmux_init(OSMUX_ROLE_BSC_NAT, mgcp_cfg->osmux_cfg) < 0) { LOGP(DMGCP, LOGL_ERROR, "Cannot init OSMUX\n"); vty_out(vty, "%% failed to create Osmux socket%s", VTY_NEWLINE); @@ -1331,7 +1331,6 @@ DEFUN(cfg_bsc_osmux, * new upcoming flows should use RTP. */ } -#endif return CMD_SUCCESS; } -- cgit v1.2.3