X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Frouting.cgi;h=c460a74e7ca1ab56d4d2dd44f8ecc9d69f9df6c2;hp=86e04293a406ada5098ee950a8e72818b02944fb;hb=e3c3a6ba5bae10987336ce8170f1d0359c6e8efb;hpb=9c7da0c6d9adc6020a4815a90f0bb5930d57a97b diff --git a/html/cgi-bin/routing.cgi b/html/cgi-bin/routing.cgi index 86e04293a..c460a74e7 100644 --- a/html/cgi-bin/routing.cgi +++ b/html/cgi-bin/routing.cgi @@ -118,13 +118,15 @@ 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'}))){ $errormessage = $Lang::tr{'invalid ip'}." / ".$Lang::tr{'invalid netmask'}; } - if ($settings{'IP'} =~ /0.0.0.0/){ + if ($settings{'IP'} =~ /^0\.0\.0\.0/){ $errormessage = $Lang::tr{'invalid ip'}." - 0.0.0.0"; } @@ -132,6 +134,27 @@ if ($settings{'ACTION'} eq $Lang::tr{'add'}) { $errormessage = $Lang::tr{'invalid ip'}. " - ".$Lang::tr{'gateway ip'}; } + #set networkip if not already correctly defined + my($ip,$cidr) = split(/\//,$settings{'IP'}); + my $netip=&General::getnetworkip($ip,$cidr); + $settings{'IP'} = "$netip/$cidr"; + + #Check for already existing routing entry + foreach my $line (@current) { + chomp($line); # remove newline + my @temp=split(/\,/,$line); + $temp[2] ='' unless defined $temp[2]; # not always populated + $temp[3] ='' unless defined $temp[2]; # not always populated + #Same ip already used? + if($temp[1] eq $settings{'IP'}){ + $errormessage = $Lang::tr{'ccd err irouteexist'}; + last; + } + #Is the network part of an internal network? + $errormessage .= &General::check_net_internal($settings{'IP'}); + last; + } + unless ($errormessage) { if ($settings{'KEY1'} eq '') { #add or edit ? unshift (@current, "$settings{'EN'},$settings{'IP'},$settings{'GATEWAY'},$settings{'REMARK'}\n"); @@ -242,10 +265,10 @@ print < -
+
- +
@@ -255,13 +278,13 @@ END &Header::openbox('100%', 'left', $Lang::tr{'routing table'}); print < - + +
- - - - + + + + END ; @@ -271,6 +294,7 @@ END # my $key = 0; +my $col=""; foreach my $line (@current) { chomp($line); # remove newline my @temp=split(/\,/,$line); @@ -292,15 +316,17 @@ foreach my $line (@current) { if ($settings{'KEY1'} eq $key) { print ""; } elsif ($key % 2) { - print ""; + print ""; + $col="bgcolor='$color{'color20'}'"; } else { - print ""; + print ""; + $col="bgcolor='$color{'color22'}'"; } print <$temp[1] - - - + + + - -
$Lang::tr{'host ip'} / $Lang::tr{'network'}$Lang::tr{'gateway'}$Lang::tr{'remark'}$Lang::tr{'action'}$Lang::tr{'host ip'} / $Lang::tr{'network'}$Lang::tr{'gateway'}$Lang::tr{'remark'}$Lang::tr{'action'}
$temp[2]$temp[3] +$temp[1]$temp[2]$temp[3]
@@ -308,7 +334,7 @@ foreach my $line (@current) {
+
@@ -316,7 +342,7 @@ foreach my $line (@current) {
+
@@ -443,4 +469,4 @@ sub SortDataFile # sub BuildConfiguration { system '/usr/local/bin/rebuildroutes'; -} \ No newline at end of file +}