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 --- html/cgi-bin/routing.cgi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/html/cgi-bin/routing.cgi b/html/cgi-bin/routing.cgi index c460a74..2c60f67 100644 --- a/html/cgi-bin/routing.cgi +++ b/html/cgi-bin/routing.cgi @@ -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/){