Skip to content

Commit

Permalink
MT#62053 add support for RTP port ranges
Browse files Browse the repository at this point in the history
Change-Id: I1dc734b954772c03077c6576331e117c919d3d5c
  • Loading branch information
rfuchs committed Feb 4, 2025
1 parent b5b92ca commit 2b40e7b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/get_all_rtp_for_host
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions lib/get_all_rtp_for_instance
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions sbin/ngcp-network
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<min>,I<max>B<|none|delete>
Set a port range to be used for RTP media if different from the globally set
port range. Set to B<none> or B<delete> to remove the setting and revert to the
global port range.
=item B<--set-interface>=I<name>
Add specified network interface. Can be combined with options like B<--hwaddr>,
Expand Down

0 comments on commit 2b40e7b

Please sign in to comment.