BUG10941: fix single ip-addresses when no subnet given

Some functions when adding a new route where senseless.
Now the ip address is checked and in case of a missing / wrong
subnetmask an errormessage is raised. The ip address is preserved.
ELSE
we convert the subnetmask to cidr notation and calculate the network ip
correctly.

Signed-off-by: Alexander Marx <alexander.marx@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Alexander Marx
2015-10-17 19:27:03 +02:00
committed by Michael Tremer
parent 307327a946
commit 6be114f03a

View File

@@ -118,12 +118,16 @@ if ($settings{'ACTION'} eq $Lang::tr{'toggle enable disable'}) {
}
if ($settings{'ACTION'} eq $Lang::tr{'add'}) {
# Convert subnet masks to CIDR notation.
$settings{'IP'} = &General::iporsubtocidr($settings{'IP'});
# Validate inputs
if (( !&General::validip($settings{'IP'})) and ( !&General::validipandmask($settings{'IP'}))){
# Validate inputs
if (!&General::validipandmask($settings{'IP'}))){
$errormessage = $Lang::tr{'invalid ip'}." / ".$Lang::tr{'invalid netmask'};
}else{
#set networkip if not already correctly defined
my($ip,$cidr) = split(/\//,$settings{'IP'});
$cidr = &General::iporsubtocidr($cidr);
my $netip=&General::getnetworkip($ip,$cidr);
$settings{'IP'} = "$netip/$cidr";
}
if ($settings{'IP'} =~ /^0\.0\.0\.0/){