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:
Arne Fitzenreiter
2015-09-20 13:03:34 +02:00
parent 4d4f36ef55
commit 01d61d1549

View File

@@ -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;
}