From: Michael Tremer Date: Tue, 29 Jul 2014 10:12:38 +0000 (+0200) Subject: Revert "General-functions.pl: rewrite getnetworkip without inet_aton" X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8df091d9680ca0230723fc62b56c9e1d29acb481;p=people%2Fms%2Fipfire-2.x.git Revert "General-functions.pl: rewrite getnetworkip without inet_aton" This reverts commit 1be398ae381d4d0cdbd50272bff4434121d36f65. Some users reported some issues with the generated firewall ruleset with the new function: http://forum.ipfire.org/index.php?topic=11124.0 --- diff --git a/config/cfgroot/general-functions.pl b/config/cfgroot/general-functions.pl index 6994f333d5..ebf6214201 100644 --- a/config/cfgroot/general-functions.pl +++ b/config/cfgroot/general-functions.pl @@ -413,9 +413,9 @@ sub getnetworkip #Gets: IP, CIDR (10.10.10.0-255, 24) #Gives: 10.10.10.0 my ($ccdip,$ccdsubnet) = @_; - my $ip_address_binary = &Socket::inet_pton( AF_INET,$ccdip ); - my $netmask_binary = &Socket::inet_pton(AF_INET,&iporsubtodec($ccdsubnet)); - my $network_address = &Socket::inet_ntop( AF_INET,$ip_address_binary & $netmask_binary ); + my $ip_address_binary = inet_aton( $ccdip ); + my $netmask_binary = ~pack("N", (2**(32-$ccdsubnet))-1); + my $network_address = inet_ntoa( $ip_address_binary & $netmask_binary ); return $network_address; }