osmux: Rename field osmux usage policy and define it with proper type

Change-Id: I7f41a443f488b75df792597ec3cec8f7e97a7411
This commit is contained in:
Pau Espin 2022-09-23 15:38:24 +02:00
parent b9022497d8
commit 928a20b540
6 changed files with 18 additions and 13 deletions

View File

@ -29,6 +29,7 @@
#include <osmocom/core/logging.h>
#include <osmocom/mgcp/mgcp_common.h>
#include <osmocom/mgcp/osmux.h>
#include <arpa/inet.h>
#include <sys/types.h>
@ -156,8 +157,8 @@ struct mgcp_config {
enum mgcp_role role;
/* osmux translator: 0 means disabled, 1 means enabled */
int osmux;
/* Osmux usage policy: */
enum osmux_usage osmux_use;
/* addr to bind the server to */
char osmux_addr[INET6_ADDRSTRLEN];
/* The BSC-NAT may ask for enabling osmux on demand. This tells us if

View File

@ -9,6 +9,10 @@ enum {
OSMUX_ROLE_BSC_NAT,
};
struct mgcp_trunk;
struct mgcp_endpoint;
struct mgcp_conn_rtp;
int osmux_init(int role, struct mgcp_trunk *trunk);
int osmux_enable_conn(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn,
const struct osmo_sockaddr *addr);

View File

@ -394,7 +394,7 @@ static int osmux_read_fd_cb(struct osmo_fd *ofd, unsigned int what)
rate_ctr_inc(rate_ctr_group_get_ctr(all_rtp_stats, OSMUX_PACKETS_RX_CTR));
if (!trunk->cfg->osmux) {
if (trunk->cfg->osmux_use == OSMUX_USAGE_OFF) {
LOGP(DOSMUX, LOGL_ERROR,
"bsc-nat wants to use Osmux but bsc did not request it\n");
goto out;

View File

@ -893,7 +893,7 @@ static struct msgb *handle_create_con(struct mgcp_request_data *rq)
case 'X':
if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
/* If osmux is disabled, just skip setting it up */
if (!rq->endp->trunk->cfg->osmux)
if (rq->endp->trunk->cfg->osmux_use == OSMUX_USAGE_OFF)
break;
osmux_cid = mgcp_osmux_setup(endp, line);
break;
@ -1007,7 +1007,7 @@ mgcp_header_done:
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
goto error2;
}
} else if (endp->trunk->cfg->osmux == OSMUX_USAGE_ONLY) {
} else if (endp->trunk->cfg->osmux_use == OSMUX_USAGE_ONLY) {
LOGPCONN(_conn, DLMGCP, LOGL_ERROR,
"CRCX: osmux only and no osmux offered\n");
rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
@ -1174,7 +1174,7 @@ static struct msgb *handle_modify_con(struct mgcp_request_data *rq)
case 'X':
if (strncasecmp("Osmux: ", line + 2, strlen("Osmux: ")) == 0) {
/* If osmux is disabled, just skip setting it up */
if (!endp->trunk->cfg->osmux)
if (endp->trunk->cfg->osmux_use == OSMUX_USAGE_OFF)
break;
osmux_cid = mgcp_osmux_setup(endp, line);
break;

View File

@ -99,7 +99,7 @@ static void mgcp_format_stats_rtp(char *str, size_t str_len,
str += nchars;
str_len -= nchars;
if (conn->conn->endp->trunk->cfg->osmux != OSMUX_USAGE_OFF) {
if (conn->conn->endp->trunk->cfg->osmux_use != OSMUX_USAGE_OFF) {
/* Error Counter */
nchars = snprintf(str, str_len,
"\r\nX-Osmo-CP: EC TI=%" PRIu64 ", TO=%" PRIu64,

View File

@ -129,7 +129,7 @@ static int config_write_mgcp(struct vty *vty)
vty_out(vty, " rtp force-ptime %d%s", g_cfg->force_ptime,
VTY_NEWLINE);
switch (g_cfg->osmux) {
switch (g_cfg->osmux_use) {
case OSMUX_USAGE_ON:
vty_out(vty, " osmux on%s", VTY_NEWLINE);
break;
@ -141,7 +141,7 @@ static int config_write_mgcp(struct vty *vty)
vty_out(vty, " osmux off%s", VTY_NEWLINE);
break;
}
if (g_cfg->osmux) {
if (g_cfg->osmux_use != OSMUX_USAGE_OFF) {
vty_out(vty, " osmux bind-ip %s%s",
g_cfg->osmux_addr, VTY_NEWLINE);
vty_out(vty, " osmux batch-factor %d%s",
@ -350,7 +350,7 @@ static int mgcp_show(struct vty *vty, int argc, const char **argv,
llist_for_each_entry(trunk, &g_cfg->trunks, entry)
dump_trunk(vty, trunk, show_stats, active_only);
if (g_cfg->osmux)
if (g_cfg->osmux_use != OSMUX_USAGE_OFF)
vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
VTY_NEWLINE);
@ -1547,12 +1547,12 @@ DEFUN(cfg_mgcp_osmux,
OSMO_ASSERT(trunk);
if (strcmp(argv[0], "off") == 0) {
g_cfg->osmux = OSMUX_USAGE_OFF;
g_cfg->osmux_use = OSMUX_USAGE_OFF;
return CMD_SUCCESS;
} else if (strcmp(argv[0], "on") == 0)
g_cfg->osmux = OSMUX_USAGE_ON;
g_cfg->osmux_use = OSMUX_USAGE_ON;
else if (strcmp(argv[0], "only") == 0)
g_cfg->osmux = OSMUX_USAGE_ONLY;
g_cfg->osmux_use = OSMUX_USAGE_ONLY;
return CMD_SUCCESS;