aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-09-17 23:34:36 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-09-20 02:51:29 +0800
commitc5f9248c3f3027e7ca44ae8593e7a74da190146c (patch)
tree718f1313d71084976f9d85250bb76e9f3acf9971
parenta2a10ebf033e618ec9dc69d8d9089940f540a3a7 (diff)
mgcp: Share the range parsing code for net/bts
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index b1c006cb..b222f65d 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -167,14 +167,28 @@ DEFUN(cfg_mgcp_bind_early,
return CMD_WARNING;
}
+static void parse_base(struct mgcp_port_range *range, const char **argv)
+{
+ unsigned int port = atoi(argv[0]);
+ range->mode = PORT_ALLOC_STATIC;
+ range->base_port = port;
+}
+
+static void parse_range(struct mgcp_port_range *range, const char **argv)
+{
+ range->mode = PORT_ALLOC_DYNAMIC;
+ range->range_start = atoi(argv[0]);
+ range->range_end = atoi(argv[1]);
+ range->last_port = g_cfg->bts_ports.range_start;
+}
+
+
DEFUN(cfg_mgcp_rtp_bts_base_port,
cfg_mgcp_rtp_bts_base_port_cmd,
"rtp bts-base <0-65534>",
"Base port to use")
{
- unsigned int port = atoi(argv[0]);
- g_cfg->bts_ports.mode = PORT_ALLOC_STATIC;
- g_cfg->bts_ports.base_port = port;
+ parse_base(&g_cfg->bts_ports, argv);
return CMD_SUCCESS;
}
@@ -184,10 +198,7 @@ DEFUN(cfg_mgcp_rtp_bts_range,
"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;
+ parse_range(&g_cfg->bts_ports, argv);
return CMD_SUCCESS;
}
@@ -197,10 +208,7 @@ DEFUN(cfg_mgcp_rtp_net_range,
"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;
+ parse_range(&g_cfg->net_ports, argv);
return CMD_SUCCESS;
}
@@ -209,9 +217,7 @@ DEFUN(cfg_mgcp_rtp_net_base_port,
"rtp net-base <0-65534>",
"Base port to use for network port\n" "Port\n")
{
- unsigned int port = atoi(argv[0]);
- g_cfg->net_ports.mode = PORT_ALLOC_STATIC;
- g_cfg->net_ports.base_port = port;
+ parse_base(&g_cfg->net_ports, argv);
return CMD_SUCCESS;
}