This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/9260 )
Change subject: vty: clean up rtp port-range command
......................................................................
vty: clean up rtp port-range command
The VTY command that sets the RTP port range does not check if the data
entered by the user actually makes sens. Also it allwos to configur a
range that starts at 0.
- Make sure 0 can not be used as start or end of the range
- make sure the end port number is always greater then the begin
port number
- Autocorrect uneaven port range beginnings to one port number before to
ensure the range starts at an even port number
- Autocorrect even port range ends to the next odd port number to
ensure the range ends at an odd port number.
Change-Id: Ib1312acba4f03f378594dbbeb4f31afd891d68d7
Related: OS#2825
---
M src/libosmo-mgcp/mgcp_vty.c
1 file changed, 29 insertions(+), 9 deletions(-)
Approvals:
Jenkins Builder: Verified
Harald Welte: Looks good to me, approved
diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 392a176..3c1b596 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -282,13 +282,6 @@
return CMD_WARNING;
}
-static void parse_range(struct mgcp_port_range *range, const char **argv)
-{
- range->range_start = atoi(argv[0]);
- range->range_end = atoi(argv[1]);
- range->last_port = g_cfg->net_ports.range_start;
-}
-
#define RTP_STR "RTP configuration\n"
#define UDP_PORT_STR "UDP Port number\n"
#define NET_START_STR "First UDP port allocated\n"
@@ -297,11 +290,38 @@
DEFUN(cfg_mgcp_rtp_port_range,
cfg_mgcp_rtp_port_range_cmd,
- "rtp port-range <0-65534> <0-65534>",
+ "rtp port-range <1024-65534> <1025-65535>",
RTP_STR "Range of ports to use for the NET side\n"
RANGE_START_STR RANGE_END_STR)
{
- parse_range(&g_cfg->net_ports, argv);
+ int start;
+ int end;
+
+ start = atoi(argv[0]);
+ end = atoi(argv[1]);
+
+ if (end < start) {
+ vty_out(vty, "range end port (%i) must be greater than the range start port (%i)!%s",
+ end, start, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ if (start & 1) {
+ vty_out(vty, "range must begin at an even port number, autocorrecting port (%i) to: %i%s",
+ start, start & 0xFFFE, VTY_NEWLINE);
+ start &= 0xFFFE;
+ }
+
+ if ((end & 1) == 0) {
+ vty_out(vty, "range must end at an odd port number, autocorrecting port (%i) to: %i%s",
+ end, end | 1, VTY_NEWLINE);
+ end |= 1;
+ }
+
+ g_cfg->net_ports.range_start = start;
+ g_cfg->net_ports.range_end = end;
+ g_cfg->net_ports.last_port = g_cfg->net_ports.range_start;
+
return CMD_SUCCESS;
}
ALIAS_DEPRECATED(cfg_mgcp_rtp_port_range,
--
To view, visit https://gerrit.osmocom.org/9260
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib1312acba4f03f378594dbbeb4f31afd891d68d7
Gerrit-Change-Number: 9260
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180524/c86b745a/attachment.htm>