In order to cleanup code, the old function IpInSubnet is deleted from general-functions.
In the future only network functions from network-functions.pl should be used.
So this commit deletes the IpInSubnet and replaces it with the ip_address_in_network from the new network-functions.pl
Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
foreach my $key (keys %ovpnconfhash) {
if ($ovpnconfhash{$key}[3] eq 'net'){
my @ovpnnet=split (/\//,$ovpnconfhash{$key}[11]);
- if (&IpInSubnet($ip,$ovpnnet[0],&iporsubtodec($ovpnnet[1]))){
+ if (&Network::ip_address_in_network($ip,$ovpnnet[0]."/".&iporsubtodec($ovpnnet[1]))){
$errormessage=$errormessage.$Lang::tr{'ccd err isovpnn2n'}." $ovpnconfhash{$key}[1] <br>";
return $errormessage;
}
return $errormessage;
}
my ($newip,$newsub) = split(/\//,$ccdnet);
- if (&IpInSubnet($newip,$ccdconf[0],&iporsubtodec($ccdconf[1])))
+ if (&Network::ip_address_in_network($newip,$ccdconf[0]."/".&iporsubtodec($ccdconf[1])))
{
$errormessage=$errormessage.$Lang::tr{'ccd err issubnet'}." $ccdconfhash{$key}[0]<br>";
return $errormessage;
my ($ipsecip,$ipsecsub) = split (/\//, $ipsecconf{$key}[11]);
$ipsecsub=&iporsubtodec($ipsecsub);
if($ipsecconf{$key}[1] ne $ccdname){
- if ( &IpInSubnet ($ip,$ipsecip,$ipsecsub) ){
+ if (&Network::ip_address_in_network($ip,$ipsecip."/".$ipsecsub)){
$errormessage=$Lang::tr{'ccd err isipsecnet'}." Name: $ipsecconf{$key}[1]";
return $errormessage;
}
&readhash("${General::swroot}/vpn/settings", \%vpnconf);
if ($vpnconf{'RW_NET'} ne ''){
my ($ipsecrwnet,$ipsecrwsub)=split (/\//, $vpnconf{'RW_NET'});
- if (&IpInSubnet($ip,$ipsecrwnet,&iporsubtodec($ipsecrwsub)))
+ if (&Network::ip_address_in_network($ip,$ipsecrwnet."/".&iporsubtodec($ipsecrwsub)))
{
$errormessage=$errormessage.$Lang::tr{'ccd err isipsecrw'}."<br>";
return $errormessage;
$cidr=&iporsubtocidr($cidr);
#check if we use one of ipfire's networks (green,orange,blue)
&readhash("${General::swroot}/ethernet/settings", \%ownnet);
- if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'GREEN_NETADDRESS'},&iporsubtodec($ownnet{'GREEN_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err green'};return $errormessage;}
- if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'ORANGE_NETADDRESS'},&iporsubtodec($ownnet{'ORANGE_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err orange'};return $errormessage;}
- if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'BLUE_NETADDRESS'},&iporsubtodec($ownnet{'BLUE_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err blue'};return $errormessage;}
- if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &IpInSubnet($ip,$ownnet{'RED_NETADDRESS'},&iporsubtodec($ownnet{'RED_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err red'};return $errormessage;}
+ if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip,$ownnet{'GREEN_NETADDRESS'}."/".&iporsubtodec($ownnet{'GREEN_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err green'};return $errormessage;}
+ if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip,$ownnet{'ORANGE_NETADDRESS'}."/".&iporsubtodec($ownnet{'ORANGE_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err orange'};return $errormessage;}
+ if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip,$ownnet{'BLUE_NETADDRESS'}."/".&iporsubtodec($ownnet{'BLUE_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err blue'};return $errormessage;}
+ if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ip,$ownnet{'RED_NETADDRESS'}."/".&iporsubtodec($ownnet{'RED_NETMASK'}))){ $errormessage=$Lang::tr{'ccd err red'};return $errormessage;}
}
sub check_net_internal_exact{
}
}
-sub IpInSubnet {
- my $addr = shift;
- my $network = shift;
- my $netmask = shift;
-
- return &Network::ip_address_in_network($addr, "$network/$netmask");
-}
-
#
# Return the following IP (IP+1) in dotted notation.
# Call: NextIP ('1.1.1.1');
chomp $ip;
# 100.64.0.0/10 is reserved for dual-stack lite (http://tools.ietf.org/html/rfc6598).
- if (&General::IpInSubnet ($ip,'10.0.0.0','255.0.0.0') ||
- &General::IpInSubnet ($ip,'172.16.0.0.','255.240.0.0') ||
- &General::IpInSubnet ($ip,'192.168.0.0','255.255.0.0') ||
- &General::IpInSubnet ($ip,'100.64.0.0', '255.192.0.0'))
+ if (&Network::ip_address_in_network($ip,'10.0.0.0/255.0.0.0') ||
+ &Network::ip_address_in_network($ip,'172.16.0.0/255.240.0.0') ||
+ &Network::ip_address_in_network($ip,'192.168.0.0/255.255.0.0') ||
+ &Network::ip_address_in_network($ip,'100.64.0.0/255.192.0.0'))
{
if ($settings{'BEHINDROUTER'} eq 'FETCH_IP') {
my $RealIP = &General::FetchPublicIp;
}elsif($f eq 'blue' && $ip eq $ifaces{'BLUE_NETADDRESS'}){
$field3='std_net_src';
$field4='BLUE';
- }elsif($f eq 'orange' && &General::IpInSubnet($ip,$ifaces{'ORANGE_NETADDRESS'},$ifaces{'ORANGE_NETMASK'})){
+ }elsif($f eq 'orange' && &Network::ip_address_in_network($ip,$ifaces{'ORANGE_NETADDRESS'}."/".$ifaces{'ORANGE_NETMASK'})){
$field3='src_addr';
$field4=$b;
- }elsif($f eq 'blue' && &General::IpInSubnet($ip,$ifaces{'BLUE_NETADDRESS'},$ifaces{'BLUE_NETMASK'})){
+ }elsif($f eq 'blue' && &Network::ip_address_in_network($ip,$ifaces{'BLUE_NETADDRESS'}."/".$ifaces{'BLUE_NETMASK'})){
$field3='src_addr';
$field4=$b;
}else{
}elsif($g eq 'blue' && $ip eq $ifaces{'BLUE_NETADDRESS'}){
$field5='std_net_tgt';
$field6='BLUE';
- }elsif($g eq 'green' && &General::IpInSubnet($ip,$ifaces{'GREEN_NETADDRESS'},$ifaces{'GREEN_NETMASK'})){
+ }elsif($g eq 'green' && &Network::ip_address_in_network($ip,$ifaces{'GREEN_NETADDRESS'}."/".$ifaces{'GREEN_NETMASK'})){
$field5='tgt_addr';
$field6=$c;
- }elsif($g eq 'blue' && &General::IpInSubnet($ip,$ifaces{'BLUE_NETADDRESS'},$ifaces{'BLUE_NETMASK'})){
+ }elsif($g eq 'blue' && &Network::ip_address_in_network($ip,$ifaces{'BLUE_NETADDRESS'}."/".$ifaces{'BLUE_NETMASK'})){
$field5='tgt_addr';
$field6=$c;
}else{
print LOG "Processing NETWORK $ippart/$subnet from Group $grp\n";
if(!&check_net($ippart,$subnet)){
#Check if this network is one one of IPFire internal networks
- if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
+ if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart,$ownnet{'GREEN_NETADDRESS'}."/".$ownnet{'GREEN_NETMASK'}))
{
$name2='GREEN';
$name3='Standard Network';
- }elsif (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
+ }elsif (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart,$ownnet{'ORANGE_NETADDRESS'}."/".$ownnet{'ORANGE_NETMASK'}))
{
$name2='ORANGE';
$name3='Standard Network';
- }elsif (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($ippart,$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
+ }elsif (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &Network::ip_address_in_network($ippart,$ownnet{'BLUE_NETADDRESS'}."/".$ownnet{'BLUE_NETMASK'}))
{
$name2='BLUE';
$name3='Standard Network';
my $zone_subnet = $netsettings{$zone . "_NETADDRESS"};
my $zone_mask = $netsettings{$zone . "_NETMASK"};
- if (&General::IpInSubnet($address, $zone_subnet, $zone_mask)) {
+ if (&Network::ip_address_in_network($address,$zone_subnet."/".$zone_mask)){
return $netsettings{$zone . "_ADDRESS"};
}
}
return 0;
}
- # Convert net mask into correct format for &General::IpInSubnet().
+ # Convert net mask into correct format for &Network::ip_address_in_network().
$net_mask = &General::iporsubtodec($net_mask);
my @addresses = &get_internal_firewall_ip_addresses($use_orange);
foreach my $zone_address (@addresses) {
- if (&General::IpInSubnet($zone_address, $net_address, $net_mask)) {
+ if (&Network::ip_address_in_network($zone_address,$net_address."/".$net_mask)){
return $zone_address;
}
}
$errormessage = "DHCP on ${itf}: " . $Lang::tr{'invalid end address'};
goto ERROR;
}
- if (! &General::IpInSubnet ( $dhcpsettings{"START_ADDR_${itf}"},
- $netsettings{"${itf}_NETADDRESS"},
- $netsettings{"${itf}_NETMASK"})) {
+ if (!&Network::ip_address_in_network($dhcpsettings{"START_ADDR_${itf}"},$netsettings{"${itf}_NETADDRESS"}."/".$netsettings{"${itf}_NETMASK"})){
$errormessage = "DHCP on ${itf}: " . $Lang::tr{'invalid start address'};
goto ERROR;
}
$errormessage = "DHCP on ${itf}: " . $Lang::tr{'invalid start address'};
goto ERROR;
}
- if (! &General::IpInSubnet ( $dhcpsettings{"END_ADDR_${itf}"},
- $netsettings{"${itf}_NETADDRESS"},
- $netsettings{"${itf}_NETMASK"})) {
+ if (!&Network::ip_address_in_network($dhcpsettings{"END_ADDR_${itf}"},$netsettings{"${itf}_NETADDRESS"}."/".$netsettings{"${itf}_NETMASK"})){
$errormessage = "DHCP on ${itf}: " . $Lang::tr{'invalid end address'};
goto ERROR;
}
# if ip are not inside a known subnet, I don't warn.
# Also it may be needed to put duplicate fixed lease in their right subnet definition..
foreach my $itf (@ITFs) {
- my $scoped = &General::IpInSubnet($dhcpsettings{'FIX_ADDR'},
- $netsettings{"${itf}_NETADDRESS"},
- $netsettings{"${itf}_NETMASK"}) &&
- $dhcpsettings{"ENABLE_${itf}"} eq 'on';
+ my $scoped = &Network::ip_address_in_network($dhcpsettings{'FIX_ADDR'},$netsettings{"${itf}_NETADDRESS"}."/".$netsettings{"${itf}_NETMASK"}) &&
+ $dhcpsettings{"ENABLE_${itf}"} eq 'on';
if ( $scoped &&
(lc($dhcpsettings{'FIX_MAC'}) eq lc($temp[0])) &&
- &General::IpInSubnet($temp[1],
- $netsettings{"${itf}_NETADDRESS"},
- $netsettings{"${itf}_NETMASK"})) {
+ &Network::ip_address_in_network($temp[1],$netsettings{"${itf}_NETADDRESS"}."/".$netsettings{"${itf}_NETMASK"})){
$errormessage = "$Lang::tr{'mac address in use'} $dhcpsettings{'FIX_MAC'}";
last CHECK;
}
# Mark IP addresses outwith known subnets
$ipoutside{$temp[1]} = 1;
foreach my $itf (@ITFs) {
- if ( &General::IpInSubnet($temp[1],
- $netsettings{"${itf}_NETADDRESS"},
- $netsettings{"${itf}_NETMASK"})) {
+ if (&Network::ip_address_in_network($temp[1],$netsettings{"${itf}_NETADDRESS"}."/".$netsettings{"${itf}_NETMASK"})){
$ipoutside{$temp[1]} = 0;
}
}
#use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
-require '/var/ipfire/network-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
require "${General::swroot}/geoip-functions.pl";
#check if manual ip (source) is orange network
if ($fwdfwsettings{'grp1'} eq 'src_addr'){
my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
- if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ if (&Network::ip_address_in_network($sip,$netsettings{'ORANGE_ADDRESS'}."/".$netsettings{'ORANGE_NETMASK'})){
$checkorange='on';
}
}
my $networkip1=&General::getnetworkip($sip,$scidr);
my $networkip2=&General::getnetworkip($tip,$tcidr);
if ($scidr gt $tcidr){
- if ( &General::IpInSubnet($networkip1,$tip,&General::iporsubtodec($tcidr))){
+ if (&Network::ip_address_in_network($networkip1,$tip."/".&General::iporsubtodec($tcidr))){
$errormessage.=$Lang::tr{'fwdfw err samesub'};
}
}elsif($scidr eq $tcidr && $scidr eq '32'){
$hint.=$Lang::tr{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
}
}else{
- if ( &General::IpInSubnet($networkip2,$sip,&General::iporsubtodec($scidr)) ){
+ if (&Network::ip_address_in_network($networkip2,$sip."/".&General::iporsubtodec($scidr))){
$errormessage.=$Lang::tr{'fwdfw err samesub'};
}
}
foreach my $key (sort keys %ccdnet){
my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
my $sub=&General::iporsubtodec($vpnsubnet);
- if (&General::IpInSubnet($ip,$vpnip,$sub)){
+ if (&Network::ip_address_in_network($ip,$vpnip."/".$sub)){
return 0;
}
}
return;
}elsif($val =~ /^(.*?)\/(.*?)$/){
my ($sip,$scidr) = split ("/",$val);
- if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ if (&Header::orange_used() && &Network::ip_address_in_network($sip,$netsettings{'ORANGE_ADDRESS'}."/".$netsettings{'ORANGE_NETMASK'})){
$tdcolor="style='background-color: $Header::colourorange;color:white;'";
return;
}
- if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
+ if (&Network::ip_address_in_network($sip,$netsettings{'GREEN_ADDRESS'}."/".$netsettings{'GREEN_NETMASK'})){
$tdcolor="style='background-color: $Header::colourgreen;color:white;'";
return;
}
- if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
+ if (&Header::blue_used() && &Network::ip_address_in_network($sip,$netsettings{'BLUE_ADDRESS'}."/".$netsettings{'BLUE_NETMASK'})){
$tdcolor="style='background-color: $Header::colourblue;color:white;'";
return;
}
#Check if IP is part of OpenVPN dynamic subnet
my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
my ($c,$d) = split("/",$val);
- if (&General::IpInSubnet($c,$a,$b)){
+ if (&Network::ip_address_in_network($c,$a."/".$b)){
$tdcolor="style='background-color: $Header::colourovpn;color:white;'";
return;
}
foreach my $key (sort keys %ccdnet){
my ($a,$b) = split("/",$ccdnet{$key}[1]);
$b =&General::iporsubtodec($b);
- if (&General::IpInSubnet($c,$a,$b)){
+ if (&Network::ip_address_in_network($c,$a."/".$b)){
$tdcolor="style='background-color: $Header::colourovpn;color:white;'";
return;
}
foreach my $key (sort keys %ccdhost){
if ($ccdhost{$key}[3] eq 'net'){
my ($a,$b) = split("/",$ccdhost{$key}[11]);
- if (&General::IpInSubnet($c,$a,$b)){
+ if (&Network::ip_address_in_network($c,$a."/".$b)){
$tdcolor="style='background-color: $Header::colourovpn;color:white;'";
return;
}
if ($ipsecsettings{'RW_NET'} ne ''){
my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
$b=&General::iporsubtodec($b);
- if (&General::IpInSubnet($c,$a,$b)){
+ if (&Network::ip_address_in_network($c,$a."/".$b)){
$tdcolor="style='background-color: $Header::colourvpn;color:white;'";
return;
}
if ($ipsecconf{$key}[11]){
my ($a,$b) = split("/",$ipsecconf{$key}[11]);
$b=&General::iporsubtodec($b);
- if (&General::IpInSubnet($c,$a,$b)){
+ if (&Network::ip_address_in_network($c,$a."/".$b)){
$tdcolor="style='background-color: $Header::colourvpn;color:white;'";
return;
}
#check if manual ip (source) is orange network
if ($fwdfwsettings{'grp1'} eq 'src_addr'){
my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
- if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ if (&Network::ip_address_in_network($sip,$netsettings{'ORANGE_ADDRESS'}."/".$netsettings{'ORANGE_NETMASK'})){
$fwdfwsettings{'oldorange'} ='on';
}
}
#check if manual ip (source) is orange network
if ($fwdfwsettings{'grp1'} eq 'src_addr'){
my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
- if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ if (&Network::ip_address_in_network($sip,$netsettings{'ORANGE_ADDRESS'}."/".$netsettings{'ORANGE_NETMASK'})){
$fwdfwsettings{'oldorange'} ='on';
}
}
use CGI::Carp 'fatalsToBrowser';
no warnings 'uninitialized';
require '/var/ipfire/general-functions.pl';
-require '/var/ipfire/network-functions.pl';
require "/var/ipfire/geoip-functions.pl";
require "/usr/lib/firewall/firewall-lib.pl";
require "${General::swroot}/lang.pl";
}
#Now check if IP is part of ORANGE,BLUE or GREEN
- if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ if (&Header::orange_used() && &Network::ip_address_in_network($sip,$netsettings{'ORANGE_ADDRESS'}."/".$netsettings{'ORANGE_NETMASK'})){
$tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
return $tdcolor;
}
- if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
+ if (&Network::ip_address_in_network($sip,$netsettings{'GREEN_ADDRESS'}."/".$netsettings{'GREEN_NETMASK'})){
$tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
return $tdcolor;
}
- if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
+ if (&Header::blue_used() && &Network::ip_address_in_network($sip,$netsettings{'BLUE_ADDRESS'}."/".$netsettings{'BLUE_NETMASK'})){
$tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
return $tdcolor;
}
foreach my $key (sort keys %ccdhost){
if ($ccdhost{$key}[3] eq 'net'){
my ($a,$b) = split("/",$ccdhost{$key}[11]);
- if (&General::IpInSubnet($sip,$a,$b)){
+ if (&Network::ip_address_in_network($sip,$a."/".$b)){
$tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
return $tdcolor;
}
#Check if IP is part of OpenVPN dynamic subnet
my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
- if (&General::IpInSubnet($sip,$a,$b)){
+ if (&Network::ip_address_in_network($sip,$a."/".$b)){
$tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
return $tdcolor;
}
foreach my $key (sort keys %ccdnet){
my ($a,$b) = split("/",$ccdnet{$key}[1]);
$b =&General::iporsubtodec($b);
- if (&General::IpInSubnet($sip,$a,$b)){
+ if (&Network::ip_address_in_network($sip,$a."/".$b)){
$tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
return $tdcolor;
}
if ($ipsecsettings{'RW_NET'} ne ''){
my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
$b=&General::iporsubtodec($b);
- if (&General::IpInSubnet($sip,$a,$b)){
+ if (&Network::ip_address_in_network($sip,$a."/".$b)){
$tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
return $tdcolor;
}
if ($ipsecconf{$key}[11]){
my ($a,$b) = split("/",$ipsecconf{$key}[11]);
$b=&General::iporsubtodec($b);
- if (&General::IpInSubnet($sip,$a,$b)){
+ if (&Network::ip_address_in_network($sip,$a."/".$b)){
$tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
return $tdcolor;
}
return 0;
}
#subnetcheck
- if (&General::IpInSubnet ($ip,$ip2,&General::iporsubtodec($cidr2))){
+ if (&Network::ip_address_in_network($ip,$ip2."/".&General::iporsubtodec($cidr2))){
return 0;
}
};
}
my ($ip2,$cidr2) = split (/\//,$ccdroutehash{$key}[$i]);
#subnetcheck
- if (&General::IpInSubnet ($ip,$ip2,$cidr2)&& $ccdroutehash{$key}[0] ne $cgiparams{'NAME'} ){
+ if (&Network::ip_address_in_network($ip,$ip2."/".$cidr2) && $ccdroutehash{$key}[0] ne $cgiparams{'NAME'}){
return 0;
}
}
}
my ($ip2,$cidr2) = split (/\//,$ccdconfhash{$key}[1]);
#subnetcheck
- if (&General::IpInSubnet ($ip,$ip2,&General::cidrtosub($cidr2))){
+ if (&Network::ip_address_in_network($ip,$ip2."/".&General::cidrtosub($cidr2))){
return 0;
}
goto ADV_ERROR;
}
my ($ip2,$cidr2) = split(/\//,$ccdroutehash{$key}[$i]);
- if (&General::IpInSubnet ($ip,$ip2,$cidr2)){
+ if (&Network::ip_address_in_network($ip,$ip2."/".$cidr2)){
$errormessage="Route $ip\/$cidr ".$Lang::tr{'ccd err inuse'}." $ccdroutehash{$key}[0]" ;
goto ADV_ERROR;
}
}
my @tmpovpnsubnet = split("\/",$cgiparams{'DOVPN_SUBNET'});
- if (&General::IpInSubnet ( $netsettings{'RED_ADDRESS'},
- $tmpovpnsubnet[0], $tmpovpnsubnet[1])) {
+ if (&Network::ip_address_in_network($netsettings{'RED_ADDRESS'},$tmpovpnsubnet[0]."/".$tmpovpnsubnet[1])){
$errormessage = "$Lang::tr{'ovpn subnet overlap'} IPFire RED Network $netsettings{'RED_ADDRESS'}";
goto SETTINGS_ERROR;
}
- if (&General::IpInSubnet ( $netsettings{'GREEN_ADDRESS'},
- $tmpovpnsubnet[0], $tmpovpnsubnet[1])) {
+ if (&Network::ip_address_in_network($netsettings{'GREEN_ADDRESS'},$tmpovpnsubnet[0]."/".$tmpovpnsubnet[1])){
$errormessage = "$Lang::tr{'ovpn subnet overlap'} IPFire Green Network $netsettings{'GREEN_ADDRESS'}";
goto SETTINGS_ERROR;
}
- if (&General::IpInSubnet ( $netsettings{'BLUE_ADDRESS'},
- $tmpovpnsubnet[0], $tmpovpnsubnet[1])) {
+ if (&Network::ip_address_in_network($netsettings{'BLUE_ADDRESS'},$tmpovpnsubnet[0]."/".$tmpovpnsubnet[1])){
$errormessage = "$Lang::tr{'ovpn subnet overlap'} IPFire Blue Network $netsettings{'BLUE_ADDRESS'}";
goto SETTINGS_ERROR;
}
- if (&General::IpInSubnet ( $netsettings{'ORANGE_ADDRESS'},
- $tmpovpnsubnet[0], $tmpovpnsubnet[1])) {
+ if (&Network::ip_address_in_network($netsettings{'ORANGE_ADDRESS'},$tmpovpnsubnet[0]."/".$tmpovpnsubnet[1])){
$errormessage = "$Lang::tr{'ovpn subnet overlap'} IPFire Orange Network $netsettings{'ORANGE_ADDRESS'}";
goto SETTINGS_ERROR;
}
chomp($_);
my @tempalias = split(/\,/,$_);
if ($tempalias[1] eq 'on') {
- if (&General::IpInSubnet ($tempalias[0] ,
- $tmpovpnsubnet[0], $tmpovpnsubnet[1])) {
+ if (&Network::ip_address_in_network($tempalias[0],$tmpovpnsubnet[0]."/".$tmpovpnsubnet[1])){
$errormessage = "$Lang::tr{'ovpn subnet overlap'} IPFire alias entry $tempalias[0]";
}
}
my ($ip1,$cidr1) = split (/\//, $val);
$ip1 = &General::getnetworkip($ip1,&General::iporsubtocidr($cidr1));
my ($ip2,$cidr2) = split (/\//, $ccdroutehash{$key}[$oldiroute]);
- if (&General::IpInSubnet ($ip1,$ip2,$cidr2)){
+ if (&Network::ip_address_in_network($ip1,$ip2."/".$cidr2)){
$errormessage=$errormessage.$Lang::tr{'ccd err irouteexist'};
goto VPNCONF_ERROR;
}
}
#check for existing network IP's
- if (&General::IpInSubnet ($ip,$netsettings{GREEN_NETADDRESS},$netsettings{GREEN_NETMASK}) && $netsettings{GREEN_NETADDRESS} ne '0.0.0.0')
+ if (&Network::ip_address_in_network($ip,$netsettings{GREEN_NETADDRESS}."/".$netsettings{GREEN_NETMASK}) && $netsettings{GREEN_NETADDRESS} ne '0.0.0.0')
{
$errormessage=$Lang::tr{'ccd err green'};
goto VPNCONF_ERROR;
- }elsif(&General::IpInSubnet ($ip,$netsettings{RED_NETADDRESS},$netsettings{RED_NETMASK}) && $netsettings{RED_NETADDRESS} ne '0.0.0.0')
+ }elsif(&Network::ip_address_in_network($ip,$netsettings{RED_NETADDRESS}."/".$netsettings{RED_NETMASK}) && $netsettings{RED_NETADDRESS} ne '0.0.0.0')
{
$errormessage=$Lang::tr{'ccd err red'};
goto VPNCONF_ERROR;
- }elsif(&General::IpInSubnet ($ip,$netsettings{BLUE_NETADDRESS},$netsettings{BLUE_NETMASK}) && $netsettings{BLUE_NETADDRESS} ne '0.0.0.0' && $netsettings{BLUE_NETADDRESS} gt '')
+ }elsif(&Network::ip_address_in_network($ip,$netsettings{BLUE_NETADDRESS}."/".$netsettings{BLUE_NETMASK}) && $netsettings{BLUE_NETADDRESS} ne '0.0.0.0' && $netsettings{BLUE_NETADDRESS} gt '')
{
$errormessage=$Lang::tr{'ccd err blue'};
goto VPNCONF_ERROR;
- }elsif(&General::IpInSubnet ($ip,$netsettings{ORANGE_NETADDRESS},$netsettings{ORANGE_NETMASK}) && $netsettings{ORANGE_NETADDRESS} ne '0.0.0.0' && $netsettings{ORANGE_NETADDRESS} gt '' )
+ }elsif(&Network::ip_address_in_network($ip,$netsettings{ORANGE_NETADDRESS}."/".$netsettings{ORANGE_NETMASK}) && $netsettings{ORANGE_NETADDRESS} ne '0.0.0.0' && $netsettings{ORANGE_NETADDRESS} gt '' )
{
$errormessage=$Lang::tr{'ccd err orange'};
goto VPNCONF_ERROR;
$hostname =~ s/\"//g;
} elsif ($line eq "}") {
# Select records in Blue subnet
- if ( &General::IpInSubnet ( $ip,
- $netsettings{"BLUE_NETADDRESS"},
- $netsettings{"BLUE_NETMASK"} ) ) {
+ if (&Network::ip_address_in_network($ip,$netsettings{'BLUE_NETADDRESS'}."/".$netsettings{'BLUE_NETMASK'})){
@record = ('IPADDR',$ip,'ENDTIME',$endtime,'ETHER',$ether,'HOSTNAME',$hostname);
$record = {}; # create a reference to empty hash
%{$record} = @record; # populate that hash with @record