aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 07:20:09 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-08-05 07:20:09 +0800
commit1be9f2fddcfd9ba02f9f3a8203fa79b3b4e9b3e2 (patch)
tree00108dd09b873de1261d1d347faa739c0ecd3f8e
parent15e7389cf06af3e83d4a5d232d9409fc02002cd0 (diff)
mgcp: Allow to have a different port allocation mode
-rw-r--r--openbsc/include/openbsc/mgcp.h5
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c60
2 files changed, 55 insertions, 10 deletions
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index e8d4bb02..8f591700 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -91,6 +91,11 @@ struct mgcp_port_range {
/* pre-allocated from a base? */
int base_port;
+
+ /* dynamically allocated */
+ int range_start;
+ int range_end;
+ int last_port;
};
struct mgcp_config {
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index 0ba3511b..d8f61196 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -59,8 +59,16 @@ static int config_write_mgcp(struct vty *vty)
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);
+ else
+ vty_out(vty, " rtp bts-range %u %u%s",
+ g_cfg->bts_ports.range_start, g_cfg->bts_ports.range_end, 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);
+ else
+ vty_out(vty, " rtp net-range %u %u%s",
+ g_cfg->net_ports.range_start, g_cfg->net_ports.range_end, 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);
@@ -168,6 +176,32 @@ DEFUN(cfg_mgcp_rtp_bts_base_port,
return CMD_SUCCESS;
}
+DEFUN(cfg_mgcp_rtp_bts_range,
+ cfg_mgcp_rtp_bts_range_cmd,
+ "rtp bts-range <0-65534> <0-65534>",
+ "Range of ports to allocate for endpoints\n"
+ "Start of the range of ports\n" "End of the range of ports\n")
+{
+ g_cfg->bts_ports.mode = PORT_ALLOC_DYNAMIC;
+ g_cfg->bts_ports.range_start = atoi(argv[0]);
+ g_cfg->bts_ports.range_end = atoi(argv[1]);
+ g_cfg->bts_ports.last_port = g_cfg->bts_ports.range_start;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_mgcp_rtp_net_range,
+ cfg_mgcp_rtp_net_range_cmd,
+ "rtp net-range <0-65534> <0-65534>",
+ "Range of ports to allocate for endpoints\n"
+ "Start of the range of ports\n" "End of the range of ports\n")
+{
+ g_cfg->net_ports.mode = PORT_ALLOC_DYNAMIC;
+ g_cfg->net_ports.range_start = atoi(argv[0]);
+ g_cfg->net_ports.range_end = atoi(argv[1]);
+ g_cfg->net_ports.last_port = g_cfg->net_ports.range_start;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_mgcp_rtp_net_base_port,
cfg_mgcp_rtp_net_base_port_cmd,
"rtp net-base <0-65534>",
@@ -294,6 +328,8 @@ int mgcp_vty_init(void)
install_element(MGCP_NODE, &cfg_mgcp_rtp_base_port_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_bts_base_port_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_net_base_port_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_rtp_bts_range_cmd);
+ install_element(MGCP_NODE, &cfg_mgcp_rtp_net_range_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_dscp_cmd);
install_element(MGCP_NODE, &cfg_mgcp_rtp_ip_tos_cmd);
install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_number_cmd);
@@ -334,18 +370,22 @@ 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->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;
+ if (g_cfg->bts_ports.mode == PORT_ALLOC_STATIC) {
+ 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->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;
+ if (g_cfg->net_ports.mode == PORT_ALLOC_STATIC) {
+ 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;
+ }
}
}