aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/mgcp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 07:10:56 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 07:10:56 +0800
commit15e7389cf06af3e83d4a5d232d9409fc02002cd0 (patch)
tree8e357703e73b5afc511a413fdbb9f654d36b444a /openbsc/src/mgcp
parenta3b46c9ac06adbd16fb0d9a6ae1e31395adca85a (diff)
mgcp: Prepare to have different port allocation strategies.
Diffstat (limited to 'openbsc/src/mgcp')
-rw-r--r--openbsc/src/mgcp/mgcp_protocol.c9
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c19
2 files changed, 18 insertions, 10 deletions
diff --git a/openbsc/src/mgcp/mgcp_protocol.c b/openbsc/src/mgcp/mgcp_protocol.c
index 211ec3ea..ba0ae8d8 100644
--- a/openbsc/src/mgcp/mgcp_protocol.c
+++ b/openbsc/src/mgcp/mgcp_protocol.c
@@ -427,10 +427,10 @@ static struct msgb *handle_create_con(struct mgcp_config *cfg, struct msgb *msg)
memset(&endp->net_end.addr, 0, sizeof(endp->net_end.addr));
/* bind to the port now */
- port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->rtp_bts_base_port);
+ port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->bts_ports.base_port);
endp->bts_end.local_port = port;
- port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->rtp_net_base_port);
+ port = rtp_calculate_port(ENDPOINT_NUMBER(endp), cfg->net_ports.base_port);
endp->net_end.local_port = port;
/* assign a local call identifier or fail */
@@ -710,8 +710,9 @@ struct mgcp_config *mgcp_config_alloc(void)
cfg->source_addr = talloc_strdup(cfg, "0.0.0.0");
cfg->audio_name = talloc_strdup(cfg, "GSM-EFR/8000");
cfg->audio_payload = 97;
- cfg->rtp_bts_base_port = RTP_PORT_DEFAULT;
- cfg->rtp_net_base_port = RTP_PORT_NET_DEFAULT;
+
+ cfg->bts_ports.base_port = RTP_PORT_DEFAULT;
+ cfg->net_ports.base_port = RTP_PORT_NET_DEFAULT;
return cfg;
}
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index fe73c7ac..0ba3511b 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -56,8 +56,11 @@ static int config_write_mgcp(struct vty *vty)
vty_out(vty, " bts ip %s%s", g_cfg->bts_ip, VTY_NEWLINE);
vty_out(vty, " bind ip %s%s", g_cfg->source_addr, VTY_NEWLINE);
vty_out(vty, " bind port %u%s", g_cfg->source_port, VTY_NEWLINE);
- vty_out(vty, " rtp bts-base %u%s", g_cfg->rtp_bts_base_port, VTY_NEWLINE);
- vty_out(vty, " rtp net-base %u%s", g_cfg->rtp_net_base_port, VTY_NEWLINE);
+
+ if (g_cfg->bts_ports.mode == PORT_ALLOC_STATIC)
+ vty_out(vty, " rtp bts-base %u%s", g_cfg->bts_ports.base_port, VTY_NEWLINE);
+ if (g_cfg->net_ports.mode == PORT_ALLOC_STATIC)
+ vty_out(vty, " rtp net-base %u%s", g_cfg->net_ports.base_port, VTY_NEWLINE);
vty_out(vty, " rtp ip-dscp %d%s", g_cfg->endp_dscp, VTY_NEWLINE);
if (g_cfg->audio_payload != -1)
vty_out(vty, " sdp audio payload number %d%s", g_cfg->audio_payload, VTY_NEWLINE);
@@ -160,7 +163,8 @@ DEFUN(cfg_mgcp_rtp_bts_base_port,
"Base port to use")
{
unsigned int port = atoi(argv[0]);
- g_cfg->rtp_bts_base_port = port;
+ g_cfg->bts_ports.mode = PORT_ALLOC_STATIC;
+ g_cfg->bts_ports.base_port = port;
return CMD_SUCCESS;
}
@@ -170,7 +174,8 @@ DEFUN(cfg_mgcp_rtp_net_base_port,
"Base port to use for network port\n" "Port\n")
{
unsigned int port = atoi(argv[0]);
- g_cfg->rtp_net_base_port = port;
+ g_cfg->net_ports.mode = PORT_ALLOC_STATIC;
+ g_cfg->net_ports.base_port = port;
return CMD_SUCCESS;
}
@@ -329,13 +334,15 @@ int mgcp_parse_config(const char *config_file, struct mgcp_config *cfg)
struct mgcp_endpoint *endp = &g_cfg->endpoints[i];
int rtp_port;
- rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), g_cfg->rtp_bts_base_port);
+ rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
+ g_cfg->bts_ports.base_port);
if (mgcp_bind_bts_rtp_port(endp, rtp_port) != 0) {
LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
return -1;
}
- rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp), g_cfg->rtp_net_base_port);
+ rtp_port = rtp_calculate_port(ENDPOINT_NUMBER(endp),
+ g_cfg->net_ports.base_port);
if (mgcp_bind_net_rtp_port(endp, rtp_port) != 0) {
LOGP(DMGCP, LOGL_FATAL, "Failed to bind: %d\n", rtp_port);
return -1;