From 2b40e7b986834e96a8538fdd18c11947afb2a9ba Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 4 Feb 2025 08:58:55 -0400 Subject: [PATCH] MT#62053 add support for RTP port ranges Change-Id: I1dc734b954772c03077c6576331e117c919d3d5c --- lib/get_all_rtp_for_host | 4 ++++ lib/get_all_rtp_for_instance | 4 ++++ sbin/ngcp-network | 31 +++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/lib/get_all_rtp_for_host b/lib/get_all_rtp_for_host index a8666d83..5eeece3c 100644 --- a/lib/get_all_rtp_for_host +++ b/lib/get_all_rtp_for_host @@ -80,6 +80,8 @@ IF status.item(hosts.$X_host.status); name = X_name address = X_ip adv_addr = X_adv_ip + port_min = X_ifc.rtp_port_min || 0 + port_max = X_ifc.rtp_port_max || 0 }; out.push(X_obj); ELSE; @@ -111,6 +113,8 @@ IF status.item(hosts.$X_host.status); X_obj = { name = X_name address = X_ip + port_min = X_ifc.rtp_port_min || 0 + port_max = X_ifc.rtp_port_max || 0 }; out.push(X_obj); ELSE; diff --git a/lib/get_all_rtp_for_instance b/lib/get_all_rtp_for_instance index 7a04ddf8..87dcdf21 100644 --- a/lib/get_all_rtp_for_instance +++ b/lib/get_all_rtp_for_instance @@ -70,6 +70,8 @@ FOREACH X_ifc IN argv.instance.interfaces; name = X_name address = X_ip adv_addr = X_adv_ip + port_min = X_ifc.rtp_port_min || 0 + port_max = X_ifc.rtp_port_max || 0 }; out.push(X_obj); ELSE; @@ -101,6 +103,8 @@ FOREACH X_ifc IN argv.instance.interfaces; X_obj = { name = X_name address = X_ip + port_min = X_ifc.rtp_port_min || 0 + port_max = X_ifc.rtp_port_max || 0 }; out.push(X_obj); ELSE; diff --git a/sbin/ngcp-network b/sbin/ngcp-network index 3e453ff2..5a44b527 100755 --- a/sbin/ngcp-network +++ b/sbin/ngcp-network @@ -68,6 +68,7 @@ my $peer; my @remove_host; my @remove_interface; my @roles; +my $rtp_ports, my @set_interface; my $shared_ip; my $shared_ip_only; @@ -125,6 +126,7 @@ GetOptions( 'peer=s' => \$peer, 'remove-host=s' => \@remove_host, 'remove-interface=s' => \@remove_interface, + 'rtp-ports=s' => \$rtp_ports, 'role=s' => \@roles, 'set-interface=s' => \@set_interface, 'shared-ip=s' => \$shared_ip, @@ -192,6 +194,27 @@ foreach my $opt ( } } +my ($rtp_port_min, $rtp_port_max); +if (defined $rtp_ports) { + if ($rtp_ports =~ /^none$|^delete$/msx) { + $rtp_port_min = "none"; + $rtp_port_max = "none"; + } + elsif ($rtp_ports =~ /^(\d+),(\d+)$/msx) { + ($rtp_port_min, $rtp_port_max) = ($1, $2); + if ($rtp_port_min <= 0 || $rtp_port_max <= 0 + || $rtp_port_min > 65535 || $rtp_port_max > 65535 + || $rtp_port_min >= $rtp_port_max) { + logger("invalid RTP port range $rtp_ports"); + croak "Invalid RTP port range '$rtp_ports'"; + } + } + else { + logger("invalid RTP port range $rtp_ports"); + croak "Invalid RTP port range '$rtp_ports'"; + } +} + # }}} logger("reading input file $inputfile"); @@ -335,6 +358,8 @@ sub set_interface { 'openvpn_key_template' => $openvpn_key_template, 'openvpn_key_inline' => $openvpn_key_inline, 'v6netmask' => $netmask_ip_v6, + 'rtp_port_max' => $rtp_port_max, + 'rtp_port_min' => $rtp_port_min, 'shared_ip' => $shared_ip, 'shared_ip_only' => $shared_ip_only, 'shared_v6ip' => $shared_ip_v6, @@ -865,6 +890,12 @@ Can be specified multiple times (B<--remove-interface=eth5 --remove-interface=et Set role configuration for host to specified argument. Can be specified multiple times (B<--role=lb --role=proxy ...>). +=item B<--rtp-ports>=I,IB<|none|delete> + +Set a port range to be used for RTP media if different from the globally set +port range. Set to B or B to remove the setting and revert to the +global port range. + =item B<--set-interface>=I Add specified network interface. Can be combined with options like B<--hwaddr>,