mirror of
https://github.com/vincentmli/bpfire.git
synced 2026-04-14 21:12:59 +02:00
network_functions.pl: fix ip_address_in_network for x86_64
calculation of last address must use only 32bit of inverted netmask. Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
This commit is contained in:
@@ -256,7 +256,7 @@ sub ip_address_in_network($$) {
|
||||
my ($network_bin, $netmask_bin) = &network2bin($network);
|
||||
|
||||
# Find end address
|
||||
my $broadcast_bin = $network_bin ^ ~$netmask_bin;
|
||||
my $broadcast_bin = $network_bin ^ (~$netmask_bin % 2 ** 32);
|
||||
|
||||
return (($address_bin ge $network_bin) && ($address_bin le $broadcast_bin));
|
||||
}
|
||||
@@ -342,6 +342,9 @@ sub testsuite() {
|
||||
$result = &ip_address_in_network("10.0.1.4", "10.0.0.0/8");
|
||||
assert($result);
|
||||
|
||||
$result = &ip_address_in_network("192.168.30.11", "192.168.30.0/255.255.255.0");
|
||||
assert($result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user