X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fqos.cgi;h=de732842ca429d780f0ab93a8f4c60a727140a76;hb=40d3e729561e650bafa22b28f33da5bac813899e;hp=6c8067040ed5444130ec5eb0fcda2d9ef2e8ebe7;hpb=cb5e9c6c64d5281eba5c790f14c2e5f3066becbf;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/qos.cgi b/html/cgi-bin/qos.cgi index 6c8067040e..de732842ca 100644 --- a/html/cgi-bin/qos.cgi +++ b/html/cgi-bin/qos.cgi @@ -1,17 +1,29 @@ #!/usr/bin/perl -# -# IPFire CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The IPFire Team -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2011 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use RRDs; use strict; # enable only the following on debugging purpose # use warnings; -#use CGI::Carp 'fatalsToBrowser'; +# use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -52,8 +64,6 @@ my $portfile = "/var/ipfire/qos/portconfig"; my $tosfile = "/var/ipfire/qos/tosconfig"; &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); -&Header::showhttpheaders(); - $qossettings{'ENABLED'} = 'off'; $qossettings{'EDIT'} = 'no'; $qossettings{'OUT_SPD'} = ''; @@ -63,10 +73,7 @@ $qossettings{'DEF_INC_SPD'} = ''; $qossettings{'DEFCLASS_INC'} = ''; $qossettings{'DEFCLASS_OUT'} = ''; $qossettings{'ACK'} = ''; -$qossettings{'MTU'} = '1492'; -$qossettings{'SFQ_PERTUB'} = '10'; -$qossettings{'QLENGTH'} = '30'; -$qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`; +$qossettings{'RED_DEV'} = 'ppp0'; $qossettings{'IMQ_DEV'} = 'imq0'; $qossettings{'VALID'} = 'yes'; ### Values that have to be initialized @@ -103,13 +110,26 @@ $qossettings{'TOS'} = ''; &General::readhash("${General::swroot}/qos/settings", \%qossettings); &Header::getcgihash(\%qossettings); +$qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`; + my %color = (); my %mainsettings = (); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); -&Header::openpage('QoS', 1, ''); -&Header::openbigbox('100%', 'left', '', $errormessage); +my @querry = split(/\?/,$ENV{'QUERY_STRING'}); +$querry[0] = '' unless defined $querry[0]; +$querry[1] = 'hour' unless defined $querry[1]; + +if ( $querry[0] ne ""){ + print "Content-type: image/png\n\n"; + binmode(STDOUT); + &Graphs::updateqosgraph($querry[0],$querry[1]); +}else{ + &Header::showhttpheaders(); + + &Header::openpage('QoS', 1, ''); + &Header::openbigbox('100%', 'left', '', $errormessage); ############################################################################################################################ ############################################################################################################################ @@ -127,10 +147,10 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Parentklasse hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'parentclass add'}; } } -elsif ($qossettings{'DOCLASS'} eq 'Bearbeiten') +elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'edit'}) { open( FILE, "< $classfile" ) or die "Unable to read $classfile"; @classes = ; @@ -159,7 +179,7 @@ elsif ($qossettings{'DOCLASS'} eq 'Bearbeiten') &Header::closepage(); exit } -elsif ($qossettings{'DOCLASS'} eq 'Loeschen') +elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'delete'}) { open( FILE, "< $classfile" ) or die "Unable to read $classfile"; @tmp = ; @@ -205,9 +225,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Unterklasse hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'qos add subclass'}; } -} elsif ($qossettings{'DOSCLASS'} eq 'Loeschen') +} elsif ($qossettings{'DOSCLASS'} eq $Lang::tr{'delete'}) { open( FILE, "< $subclassfile" ) or die "Unable to read $classfile"; @tmp = ; @@ -231,15 +251,15 @@ END if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'}) { if ( $qossettings{'QIP'} ne '' ) { - unless ( &General::validip($qossettings{'QIP'}) ) { + unless ( &General::validip($qossettings{'QIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Quell-IP-Adresse ist ungueltig."; + $message = $Lang::tr{'The source IP address is invalid.'}; } } if ( $qossettings{'DIP'} ne '' ) { - unless ( &General::validip($qossettings{'DIP'}) ) { + unless ( &General::validip($qossettings{'DIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Ziel-IP-Adresse ist ungueltig."; + $message = $Lang::tr{'The destination IP address is invalid.'}; } } if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { @@ -259,9 +279,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Level7-Regel hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'}; } -} elsif ($qossettings{'DOLEVEL7'} eq 'Loeschen') +} elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'}) { open( FILE, "< $level7file" ) or die "Unable to read $level7file"; @l7rules = ; @@ -271,7 +291,7 @@ END { @l7ruleline = split( /\;/, $l7ruleentry ); if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'})) - {$message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";} + {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";} else { open( FILE, ">> $level7file" ) or die "Unable to read $level7file"; print FILE $l7ruleentry; @@ -279,7 +299,7 @@ END } } open( FILE, "< $level7file" ) or system("touch $level7file");close FILE; - } elsif ($qossettings{'DOLEVEL7'} eq 'Bearbeiten') + } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'}) { open( FILE, "< $level7file" ) or die "Unable to read $level7file"; @l7rules = ; @@ -306,15 +326,15 @@ END if ($qossettings{'DOPORT'} eq $Lang::tr{'save'}) { if ( $qossettings{'QIP'} ne '' ) { - unless ( &General::validip($qossettings{'QIP'}) ) { + unless ( &General::validip($qossettings{'QIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Quell-IP-Adresse ist ungueltig."; + $message = "$Lang::tr{'The source IP address is invalid.'}"; } } if ( $qossettings{'DIP'} ne '' ) { - unless ( &General::validip($qossettings{'DIP'}) ) { + unless ( &General::validip($qossettings{'DIP'}) ) { $qossettings{'VALID'} = 'no'; - $message = "Die Ziel-IP-Adresse ist ungueltig."; + $message = "$Lang::tr{'The destination IP address is invalid.'}"; } } if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { @@ -334,9 +354,9 @@ END ; close FILE; } else { - $qossettings{'ACTION'} = 'Port-Regel hinzufuegen'; + $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'}; } -} elsif ($qossettings{'DOPORT'} eq 'Loeschen') +} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'}) { open( FILE, "< $portfile" ) or die "Unable to read $portfile"; @portrules = ; @@ -352,7 +372,7 @@ END } close FILE; $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}."; -} elsif ($qossettings{'DOPORT'} eq 'Bearbeiten') +} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'}) { open( FILE, "< $portfile" ) or die "Unable to read $portfile"; @portrules = ; @@ -393,7 +413,7 @@ $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'}; END ; close FILE; -} +} elsif ($qossettings{'DOTOS'} eq 'Loeschen') { open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; @@ -410,7 +430,7 @@ elsif ($qossettings{'DOTOS'} eq 'Loeschen') } close FILE; $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}."; -} elsif ($qossettings{'DOTOS'} eq 'Bearbeiten') +} elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'}) { open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; @tosrules = ; @@ -438,16 +458,16 @@ elsif ($qossettings{'DOTOS'} eq 'Loeschen') ############################################################################################################################ ############################################################################################################################ -if ($qossettings{'ACTION'} eq 'Start') +if ($qossettings{'ACTION'} eq $Lang::tr{'start'}) { + $qossettings{'ENABLED'} = 'on'; + &General::writehash("${General::swroot}/qos/settings", \%qossettings); system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); system("/usr/bin/touch /var/ipfire/qos/enable"); system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); system("logger -t ipfire 'QoS started'"); - $qossettings{'ENABLED'} = 'on'; - &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Stop') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'}) { system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); unlink "/var/ipfire/qos/bin/qos.sh"; @@ -456,7 +476,7 @@ elsif ($qossettings{'ACTION'} eq 'Stop') $qossettings{'ENABLED'} = 'off'; &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Neustart') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'}) { if ($qossettings{'ENABLED'} eq 'on'){ system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); @@ -475,7 +495,106 @@ elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'}) } &General::writehash("${General::swroot}/qos/settings", \%qossettings); } -elsif ($qossettings{'ACTION'} eq 'Statusinformationen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} ) +{ + if (($qossettings{'OUT_SPD'} > 0) && ($qossettings{'INC_SPD'} > 0)) { + my @UP; + #print "UP
"; + for(my $i = 1; $i <= 10; $i++) { + $UP[$i] = int($qossettings{'OUT_SPD'} / $i ); + #print $i."=".$UP[$i]." "; + } + my @DOWN; + #print "

Down
"; + for(my $i = 1; $i <= 20; $i++) { + $DOWN[$i] = int($qossettings{'INC_SPD'} / $i); + #print $i."=".$DOWN[$i]." "; + } + open( FILE, "> $classfile" ) or die "Unable to write $classfile"; + print FILE < $level7file" ) or die "Unable to write $level7file"; + print FILE < $portfile" ) or die "Unable to write $portfile"; + print FILE </dev/null 2>&1"); + system("/usr/bin/touch /var/ipfire/qos/enable"); + system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); + system("logger -t ipfire 'QoS started'"); + } else { + $message = $Lang::tr{'qos enter bandwidths'}; + } +} +elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} ) { &Header::openbox('100%', 'left', 'QoS Status'); if ($qossettings{'ENABLED'} eq 'on'){ @@ -489,30 +608,30 @@ elsif ($qossettings{'ACTION'} eq 'Statusinformationen') &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} ) { &parentclass(); &Header::closebigbox(); &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'qos add subclass'}) { &subclass(); &Header::closebigbox(); &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Regel hinzufuegen') +elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'}) { &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'}); print < $Lang::tr{'Choose Rule'} - - - + + + END ; @@ -542,21 +661,14 @@ END &Header::closepage(); exit } -elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen') -{ - &expert(); - &Header::closebigbox(); - &Header::closepage(); - exit -} -if ($qossettings{'ACTIONBW'} eq 'Andern') +if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" ) { &changebandwidth(); &Header::closebigbox(); &Header::closepage(); exit } -if ($qossettings{'ACTIONDEF'} eq 'Andern') +if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" ) { &changedefclasses(); &Header::closebigbox(); @@ -601,8 +713,8 @@ END Quality of Service: $status - - + + END ; @@ -612,7 +724,7 @@ END
 
$Lang::tr{'downlink speed'}: $qossettings{'INC_SPD'} - +
$Lang::tr{'uplink speed'}: $qossettings{'OUT_SPD'}
END @@ -623,8 +735,8 @@ END

-
$Lang::tr{'downlink std class'}: $qossettings{'DEFCLASS_INC'} - +
$Lang::tr{'downlink std class'}: $qossettings{'DEFCLASS_INC'} +
$Lang::tr{'uplink std class'}: $qossettings{'DEFCLASS_OUT'}
ACKs: $qossettings{'ACK'}

@@ -632,11 +744,11 @@ END
- -
- - -
+ +
+ + +
END ; @@ -657,28 +769,12 @@ if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '' exit } -&Header::openbox('100%', 'center', $Lang::tr{'info'}); -&Graphs::overviewgraph("3240",$qossettings{'RED_DEV'}); -&Graphs::overviewgraph("3240",$qossettings{'IMQ_DEV'}); -print < -  $Lang::tr{'add subclass'} |  $Lang::tr{'Add Rule'} |  $Lang::tr{'edit'} |  $Lang::tr{'delete'}   - $Lang::tr{'TOS Bits'}:  0 - $Lang::tr{'disabled'} | 8 - $Lang::tr{'min delay'} | 4 - $Lang::tr{'max throughput'} | 2 - $Lang::tr{'max reliability'} | 1 - $Lang::tr{'min costs'}   -END -; -if (( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'RED_DEV'}-3240.png") && ( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'IMQ_DEV'}-3240.png")) { - print < - -END -;} -else -{ -print $Lang::tr{'no information available'}; -} -print "\t"; - -&Header::closebox(); + &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}"); + &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour","325"); + &Header::closebox(); + &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}"); + &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325"); + &Header::closebox(); &showclasses($qossettings{'RED_DEV'}); &showclasses($qossettings{'IMQ_DEV'}); @@ -686,6 +782,8 @@ print "\t"; &Header::closebigbox(); &Header::closepage(); +} + ############################################################################################################################ ############################################################################################################################ @@ -701,7 +799,7 @@ END for ( $c = 200 ; $c <= 220 ; $c++ ) { if ( $qossettings{'DEFCLASS_INC'} ne $c ) - { print "\n"; } + { print "\n"; } else { print "\n"; } } print < - + + + + +
$Lang::tr{'down and up speed'} -
$Lang::tr{'downlink speed'}: - -   -
$Lang::tr{'uplink speed'}: - -   +
$Lang::tr{'down and up speed'}
$Lang::tr{'downlink speed'}:

$Lang::tr{'uplink speed'}:
+ $Lang::tr{'template warning'} END ; } @@ -774,7 +872,7 @@ END if ( $message ne "" ) { print "$message"; } - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; print ""; } @@ -784,7 +882,7 @@ END END ; - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; @@ -801,7 +899,7 @@ END $Lang::tr{'Class'}: END ; - if ( $qossettings{'EDIT'} eq 'yes' ) { + if ( $qossettings{'EDIT'} eq 'yes' ) { print ""; @@ -846,13 +944,17 @@ END Ceilburst:   +END +; + $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'"; +print <TOS-Bit: + + + + +   $Lang::tr{'remark'}: @@ -965,7 +1067,7 @@ END next if -d "/etc/l7-protocols/protocols/$direntry"; @proto = split( /\./, $direntry ); if ( $proto[0] eq $qossettings{'L7PROT'} ) { - print "\n"; + print "\n"; } else { print "\n"; } @@ -979,6 +1081,7 @@ END $Lang::tr{'destination ip'}: + $Lang::tr{'qos warning'} END ; @@ -1003,7 +1106,7 @@ END @tmpline = split( /\ /, $direntry ); next if $tmpline[0] =~ "#"; if ( $tmpline[0] eq $qossettings{'PPROT'} ) { - print "\n"; + print "\n"; } else { print "\n"; } @@ -1011,10 +1114,10 @@ END print <  $Lang::tr{'source port'}: - +   $Lang::tr{'destination port'}: - +   $Lang::tr{'source ip'}: @@ -1047,7 +1150,7 @@ END $Lang::tr{'min delay'} (8) $Lang::tr{'max throughput'} (4) $Lang::tr{'max reliability'} (2) - + $Lang::tr{'min costs'} (1) END @@ -1078,7 +1181,7 @@ sub showclasses { @classline = split( /\;/, $classentry ); if ( $classline[0] eq $qossettings{'DEV'} ) { - &Header::openbox('100%', 'center', "Klasse: $classline[1]"); + &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1]"); print < $Lang::tr{'interface'} @@ -1102,22 +1205,22 @@ sub showclasses {
- +
- +
- +
- +
@@ -1142,14 +1245,14 @@ END
- - + +
- - + +
END @@ -1185,14 +1288,14 @@ END ; if ($portruleline[4]) { print <Quell-Port: $portruleline[4] + $Lang::tr{'source port'}: $portruleline[4] END ; } print ""; if ($portruleline[6]) { print <Ziel-Port: $portruleline[6] + $Lang::tr{'destination port'}: $portruleline[6] END ; } @@ -1207,7 +1310,7 @@ END - +
@@ -1217,7 +1320,7 @@ END - +
@@ -1265,14 +1368,14 @@ END - +
- +
@@ -1300,17 +1403,17 @@ END
- +
- +
- +
@@ -1327,29 +1430,6 @@ END } } } - -sub expert -{ - &Header::openbox('100%', 'center', $Lang::tr{'expertoptions'}); - print < - -
MTU: - - $Lang::tr{'mtu QoS'} -
$Lang::tr{'Queuelenght'}: - -   -
SFQ Perturb: - - -
- -END -; - &Header::closebox(); -} - sub validminbwdth { if ( $qossettings{'VALID'} eq 'yes' ) { if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { @@ -1390,7 +1470,7 @@ sub validclass { } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) { $qossettings{'VALID'} = 'no'; - $message = "Die Klassennummer passt nicht zum angegebenen Interface."; + $message = "$Lang::tr{'The class number does not match the specified interface.'}"; } } open( FILE, "< $classfile" ) or die "Unable to read $classfile";