]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/qos.cgi
6d4d025bfdbc228283fe472127bcf3d521e61394
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 # use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
37 my $errormessage = "";
41 my $subclassentry = "";
43 my $portruleentry = "";
44 my $tosruleentry = "";
53 my @subclassline = ();
55 my @portruleline = ();
60 my $classfile = "/var/ipfire/qos/classes";
61 my $subclassfile = "/var/ipfire/qos/subclasses";
62 my $level7file = "/var/ipfire/qos/level7config";
63 my $portfile = "/var/ipfire/qos/portconfig";
64 my $tosfile = "/var/ipfire/qos/tosconfig";
65 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
67 $qossettings{'ENABLED'} = 'off';
68 $qossettings{'EDIT'} = 'no';
69 $qossettings{'OUT_SPD'} = '';
70 $qossettings{'INC_SPD'} = '';
71 $qossettings{'DEF_OUT_SPD'} = '';
72 $qossettings{'DEF_INC_SPD'} = '';
73 $qossettings{'DEFCLASS_INC'} = '';
74 $qossettings{'DEFCLASS_OUT'} = '';
75 $qossettings{'ACK'} = '';
76 $qossettings{'RED_DEV'} = 'ppp0';
77 $qossettings{'IMQ_DEV'} = 'imq0';
78 $qossettings{'VALID'} = 'yes';
79 ### Values that have to be initialized
80 $qossettings{'ACTION'} = '';
81 $qossettings{'ACTIONDEF'} = '';
82 $qossettings{'ACTIONBW'} = '';
83 $qossettings{'RED_DEV_SEL'} = '';
84 $qossettings{'IMQ_DEV_SEL'} = '';
85 $qossettings{'PRIO'} = '';
86 $qossettings{'SPD'} = '';
87 $qossettings{'CLASS'} = '';
88 $qossettings{'SCLASS'} = '';
89 $qossettings{'QPORT'} = '';
90 $qossettings{'DPORT'} = '';
91 $qossettings{'QIP'} = '';
92 $qossettings{'DIP'} = '';
93 $qossettings{'PPROT'} = '';
94 $qossettings{'L7PROT'} = '';
95 $qossettings{'DEVICE'} = '';
96 $qossettings{'MINBWDTH'} = '';
97 $qossettings{'MAXBWDTH'} = '';
98 $qossettings{'BURST'} = '';
99 $qossettings{'CBURST'} = '';
100 $qossettings{'DOCLASS'} = '';
101 $qossettings{'DOSCLASS'} = '';
102 $qossettings{'DOLEVEL7'} = '';
103 $qossettings{'DOPORT'} = '';
104 $qossettings{'CLASS'} = '';
105 $qossettings{'CLASSPRFX'} = '';
106 $qossettings{'DEV'} = '';
107 $qossettings{'TOS'} = '';
110 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
111 &Header
::getcgihash
(\
%qossettings);
113 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
116 my %mainsettings = ();
117 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
118 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
120 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
121 $querry[0] = '' unless defined $querry[0];
122 $querry[1] = 'hour' unless defined $querry[1];
124 if ( $querry[0] ne ""){
125 print "Content-type: image/png\n\n";
127 &Graphs
::updateqosgraph
($querry[0],$querry[1]);
129 &Header
::showhttpheaders
();
131 &Header
::openpage
('QoS', 1, '');
132 &Header
::openbigbox
('100%', 'left', '', $errormessage);
134 ############################################################################################################################
135 ############################################################################################################################
137 if ($qossettings{'DOCLASS'} eq $Lang::tr
{'save'})
142 if ( $qossettings{'VALID'} eq 'yes' ) {
143 open( FILE
, ">> $classfile" ) or die "Unable to write $classfile";
145 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};$qossettings{'REMARK'};
150 $qossettings{'ACTION'} = $Lang::tr
{'parentclass add'};
153 elsif ($qossettings{'DOCLASS'} eq $Lang::tr
{'edit'})
155 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
158 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
159 foreach $classentry (sort @classes)
161 @classline = split( /\;/, $classentry );
162 if ( $classline[1] ne $qossettings{'CLASS'} ) {
163 print FILE
$classentry;
165 $qossettings{'DEVICE'} = $classline[0];
166 $qossettings{'PRIO'} = $classline[2];
167 $qossettings{'MINBWDTH'} = $classline[3];
168 $qossettings{'MAXBWDTH'} = $classline[4];
169 $qossettings{'BURST'} = $classline[5];
170 $qossettings{'CBURST'} = $classline[6];
171 $qossettings{'TOS'} = $classline[7];
172 $qossettings{'REMARK'} = $classline[8];
173 $qossettings{'EDIT'} = 'yes';
178 &Header
::closebigbox
();
179 &Header
::closepage
();
182 elsif ($qossettings{'DOCLASS'} eq $Lang::tr
{'delete'})
184 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
187 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
188 foreach $classentry (sort @tmp)
190 @tmpline = split( /\;/, $classentry );
191 if ( $tmpline[1] ne $qossettings{'CLASS'} )
193 print FILE
$classentry;
197 open( FILE
, "< $subclassfile" ) or die "Unable to read $classfile";
200 open( FILE
, "> $subclassfile" ) or die "Unable to write $classfile";
201 foreach $subclassentry (sort @tmp)
203 @tmpline = split( /\;/, $subclassentry );
204 if ( $tmpline[1] ne $qossettings{'CLASS'} )
206 print FILE
$subclassentry;
210 $message = "$Lang::tr{'Class'} $qossettings{'CLASS'} $Lang::tr{'Class was deleted'}";
213 ############################################################################################################################
214 ############################################################################################################################
216 if ($qossettings{'DOSCLASS'} eq $Lang::tr
{'save'})
220 if ( $qossettings{'VALID'} eq 'yes' ) {
221 open( FILE
, ">> $subclassfile" ) or die "Unable to write $subclassfile";
223 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};
228 $qossettings{'ACTION'} = $Lang::tr
{'qos add subclass'};
230 } elsif ($qossettings{'DOSCLASS'} eq $Lang::tr
{'delete'})
232 open( FILE
, "< $subclassfile" ) or die "Unable to read $classfile";
235 open( FILE
, "> $subclassfile" ) or die "Unable to write $classfile";
236 foreach $subclassentry (sort @tmp)
238 @tmpline = split( /\;/, $subclassentry );
239 if ( $tmpline[2] ne $qossettings{'CLASS'} )
241 print FILE
$subclassentry;
245 $message = "$Lang::tr{'Subclass'} $qossettings{'CLASS'} $Lang::tr{'was deleted'}.";
248 ############################################################################################################################
249 ############################################################################################################################
251 if ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'save'})
253 if ( $qossettings{'QIP'} ne '' ) {
254 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?
)$/){
255 if (! &General
::validipandmask
($qossettings{'QIP'}) ) {
256 $qossettings{'VALID'} = 'no';
257 $message = $Lang::tr
{'The source IP address is invalid.'};
260 if ( &General
::validip
($qossettings{'QIP'}) ) {
261 $qossettings{'VALID'} = 'no';
262 $message = $Lang::tr
{'The source IP address is invalid.'};
266 if ( $qossettings{'DIP'} ne '' ) {
267 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?
)$/){
268 if ( &General
::validipandmask
($qossettings{'DIP'}) ) {
269 $qossettings{'VALID'} = 'no';
270 $message = $Lang::tr
{'The destination IP address is invalid.'};
273 if ( &General
::validip
($qossettings{'DIP'}) ) {
274 $qossettings{'VALID'} = 'no';
275 $message = $Lang::tr
{'The destination IP address is invalid.'};
279 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
280 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
281 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
282 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
283 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
284 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
285 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
286 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
288 if ( $qossettings{'VALID'} eq 'yes' ) {
289 open( FILE
, ">> $level7file" ) or die "Unable to write $level7file";
291 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
296 $qossettings{'ACTION'} = $Lang::tr
{'Add Level7 rule'};
298 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'delete'})
300 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
303 system("rm $level7file");
304 foreach $l7ruleentry (sort @l7rules)
306 @l7ruleline = split( /\;/, $l7ruleentry );
307 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
308 {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";}
310 { open( FILE
, ">> $level7file" ) or die "Unable to read $level7file";
311 print FILE
$l7ruleentry;
315 open( FILE
, "< $level7file" ) or system("touch $level7file");close FILE
;
316 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'edit'})
318 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
321 system("rm $level7file");
322 foreach $l7ruleentry (sort @l7rules)
324 @l7ruleline = split( /\;/, $l7ruleentry );
325 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
326 {$qossettings{'QIP'} = $l7ruleline[3];$qossettings{'DIP'} = $l7ruleline[4];}
328 open( FILE
, ">> $level7file" ) or die "Unable to write $level7file";
329 print FILE
$l7ruleentry;
334 open( FILE
, "< $level7file" ) or system("touch $level7file");close FILE
;
337 ############################################################################################################################
338 ############################################################################################################################
340 if ($qossettings{'DOPORT'} eq $Lang::tr
{'save'})
342 if ( $qossettings{'QIP'} ne '' ) {
343 unless ( &General
::validip
($qossettings{'QIP'}) ) {
344 $qossettings{'VALID'} = 'no';
345 $message = "$Lang::tr{'The source IP address is invalid.'}";
348 if ( $qossettings{'DIP'} ne '' ) {
349 unless ( &General
::validip
($qossettings{'DIP'}) ) {
350 $qossettings{'VALID'} = 'no';
351 $message = "$Lang::tr{'The destination IP address is invalid.'}";
354 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
355 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
356 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
357 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
358 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
359 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
360 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
361 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
363 if ( $qossettings{'VALID'} eq 'yes' ) {
364 open( FILE
, ">> $portfile" ) or die "Unable to write $portfile";
366 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
371 $qossettings{'ACTION'} = $Lang::tr
{'Add Port Rule'};
373 } elsif ($qossettings{'DOPORT'} eq $Lang::tr
{'delete'})
375 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
378 open( FILE
, "> $portfile" ) or die "Unable to read $portfile";
379 foreach $portruleentry (sort @portrules)
381 @portruleline = split( /\;/, $portruleentry );
382 unless ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'}))
384 print FILE
$portruleentry;
388 $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}.";
389 } elsif ($qossettings{'DOPORT'} eq $Lang::tr
{'edit'})
391 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
394 system("rm $portfile");
395 foreach $portruleentry (sort @portrules)
397 @portruleline = split( /\;/, $portruleentry );
398 if ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'}))
399 {$qossettings{'CLASS'}=$portruleline[0];$qossettings{'PPROT'}=$portruleline[2];$qossettings{'QIP'}=$portruleline[3];$qossettings{'QPORT'}=$portruleline[4];$qossettings{'DIP'}=$portruleline[5];$qossettings{'DPORT'}=$portruleline[6];}
401 open( FILE
, ">> $portfile" ) or die "Unable to write $portfile";
402 print FILE
$portruleentry;
407 open( FILE
, "< $portfile" ) or system("touch $portfile");close FILE
;
410 ############################################################################################################################
411 ############################################################################################################################
413 if ($qossettings{'DOTOS'} eq $Lang::tr
{'save'})
415 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
416 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
417 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
418 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
419 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
420 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
421 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
422 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
424 open( FILE
, ">> $tosfile" ) or die "Unable to write $tosfile";
426 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'};
431 elsif ($qossettings{'DOTOS'} eq 'Loeschen')
433 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
436 open( FILE
, "> $tosfile" ) or die "Unable to read $tosfile";
437 foreach $tosruleentry (sort @tosrules)
439 @tosruleline = split( /\;/, $tosruleentry );
440 unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'}))
442 print FILE
$tosruleentry;
446 $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}.";
447 } elsif ($qossettings{'DOTOS'} eq $Lang::tr
{'edit'})
449 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
452 open( FILE
, "> $tosfile" ) or die "Unable to write $tosfile";
453 foreach $tosruleentry (sort @tosrules)
455 @tosruleline = split( /\;/, $tosruleentry );
456 if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) {
457 $qossettings{'DEVICE'} = $tosruleline[1];
458 $qossettings{'CLASS'} = $tosruleline[0];
459 $qossettings{'TOS'} = $tosruleline[2];
460 $qossettings{'EDIT'} = 'yes';
462 print FILE
$tosruleentry;
467 &Header
::closebigbox
();
468 &Header
::closepage
();
472 ############################################################################################################################
473 ############################################################################################################################
475 if ($qossettings{'ACTION'} eq $Lang::tr
{'start'})
477 $qossettings{'ENABLED'} = 'on';
478 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
479 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
480 system("/usr/bin/touch /var/ipfire/qos/enable");
481 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
482 system("logger -t ipfire 'QoS started'");
484 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'stop'})
486 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
487 unlink "/var/ipfire/qos/bin/qos.sh";
488 unlink "/var/ipfire/qos/enable";
489 system("logger -t ipfire 'QoS stopped'");
490 $qossettings{'ENABLED'} = 'off';
491 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
493 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'restart'})
495 if ($qossettings{'ENABLED'} eq 'on'){
496 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
497 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
498 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
499 system("logger -t ipfire 'QoS restarted'");
502 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'save'})
504 if ($qossettings{'DEF_INC_SPD'} eq '') {
505 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
507 if ($qossettings{'DEF_OUT_SPD'} eq '') {
508 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
510 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
512 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'template'} )
514 if (($qossettings{'OUT_SPD'} > 0) && ($qossettings{'INC_SPD'} > 0)) {
517 for(my $i = 1; $i <= 10; $i++) {
518 $UP[$i] = int($qossettings{'OUT_SPD'} / $i );
519 #print $i."=".$UP[$i]." ";
522 #print "<br /><br />Down<br />";
523 for(my $i = 1; $i <= 20; $i++) {
524 $DOWN[$i] = int($qossettings{'INC_SPD'} / $i);
525 #print $i."=".$DOWN[$i]." ";
527 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
529 imq0;200;1;$DOWN[10];$DOWN[1];;;8;VoIP;
530 imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
531 imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
532 imq0;210;6;1;$DOWN[1];;;0;Default;
533 imq0;220;7;1;$DOWN[1];;;1;P2P;
534 $qossettings{'RED_DEV'};101;1;$UP[2];$UP[1];;;8;ACKs;
535 $qossettings{'RED_DEV'};102;2;$UP[3];$UP[1];;;8;VoIP;
536 $qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic;
537 $qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default;
538 $qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P;
539 $qossettings{'RED_DEV'};103;4;$UP[2];$UP[1];;;2;VPN;
543 open( FILE
, "> $level7file" ) or die "Unable to write $level7file";
545 102;$qossettings{'RED_DEV'};dns;;;
546 102;$qossettings{'RED_DEV'};rtp;;;
547 102;$qossettings{'RED_DEV'};skypetoskype;;;
548 103;$qossettings{'RED_DEV'};ssh;;;
549 103;$qossettings{'RED_DEV'};rdp;;;
550 104;$qossettings{'RED_DEV'};http;;;
551 104;$qossettings{'RED_DEV'};ssl;;;
552 104;$qossettings{'RED_DEV'};pop3;;;
553 120;$qossettings{'RED_DEV'};applejuice;;;
554 120;$qossettings{'RED_DEV'};bittorrent;;;
556 200;imq0;skypetoskype;;;
562 220;imq0;applejuice;;;
563 220;imq0;bittorrent;;;
567 open( FILE
, "> $portfile" ) or die "Unable to write $portfile";
569 101;$qossettings{'RED_DEV'};icmp;;;;;
570 102;$qossettings{'RED_DEV'};tcp;;;;53;
571 102;$qossettings{'RED_DEV'};udp;;;;53;
572 103;$qossettings{'RED_DEV'};esp;;;;;
573 103;$qossettings{'RED_DEV'};tcp;;1194;;;
574 103;$qossettings{'RED_DEV'};udp;;1194;;;
575 103;$qossettings{'RED_DEV'};tcp;;;;1194;
576 103;$qossettings{'RED_DEV'};udp;;;;1194;
577 103;$qossettings{'RED_DEV'};udp;;4500;;4500;
578 103;$qossettings{'RED_DEV'};udp;;500;;500;
579 104;$qossettings{'RED_DEV'};tcp;;;;80;
582 203;imq0;tcp;;;;1194;
583 203;imq0;udp;;;;1194;
584 203;imq0;tcp;;1194;;;
585 203;imq0;udp;;1194;;;
586 203;imq0;udp;;4500;;4500;
587 203;imq0;udp;;500;;500;
592 if ($qossettings{'DEF_INC_SPD'} eq '') {
593 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
595 if ($qossettings{'DEF_OUT_SPD'} eq '') {
596 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
598 $qossettings{'DEFCLASS_INC'} = "210";
599 $qossettings{'DEFCLASS_OUT'} = "110";
600 $qossettings{'ACK'} ="101";
601 $qossettings{'ENABLED'} = 'on';
602 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
603 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
604 system("/usr/bin/touch /var/ipfire/qos/enable");
605 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
606 system("logger -t ipfire 'QoS started'");
608 $message = $Lang::tr
{'qos enter bandwidths'};
611 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'status'} )
613 &Header
::openbox
('100%', 'left', 'QoS Status');
614 if ($qossettings{'ENABLED'} eq 'on'){
616 $output = `/usr/local/bin/qosctrl status`;
617 $output = &Header
::cleanhtml
($output,"y");
618 print "<pre>$output</pre>\n";
619 } else { print "$Lang::tr{'QoS not enabled'}"; }
621 &Header
::closebigbox
();
622 &Header
::closepage
();
625 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'parentclass add'} )
628 &Header
::closebigbox
();
629 &Header
::closepage
();
632 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'qos add subclass'})
635 &Header
::closebigbox
();
636 &Header
::closepage
();
639 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'Add Rule'})
641 &Header
::openbox
('100%', 'center', $Lang::tr
{'Add Rule'});
644 <tr><td align='center'>$Lang::tr{'Choose Rule'}
645 <tr><td align='center'>
646 <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' />
647 <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' />
648 <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' />
654 <div id='l7rule' style='display: none'>
660 <div id='portrule' style='display: none'>
666 <div id='tosrule' style='display: none'>
674 &Header
::closebigbox
();
675 &Header
::closepage
();
678 if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" )
681 &Header
::closebigbox
();
682 &Header
::closepage
();
685 if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" )
688 &Header
::closebigbox
();
689 &Header
::closepage
();
693 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
695 my $status = $Lang::tr
{'stopped'};
696 my $statuscolor = '#993333';
697 if ( $qossettings{'ENABLED'} eq 'on' ) {
698 $status = $Lang::tr
{'running'};
699 $statuscolor = '#339933';
702 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
703 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
707 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
708 print "<class name='base'>$errormessage\n";
709 print " </class>\n";
713 ############################################################################################################################
714 ############################################################################################################################
716 &Header
::openbox
('100%', 'center', );
719 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
723 if ( $message ne "" ) {
724 print "<tr><td colspan='2' align='center'><font color='red'>$message</font></tr>";
727 <tr><td width='50%' align='left'><b>Quality of Service:</b></td>
728 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font></td></tr>
730 <td colspan='2'><br></td>
732 <tr><td width='100%' align='right' colspan='2'>
733 <input type='submit' name='ACTION' value="$Lang::tr{'start'}">
734 <input type='submit' name='ACTION' value="$Lang::tr{'stop'}">
735 <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" ></td></tr></table></form>
738 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
740 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
742 <tr><td colspan='3'>
743 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'}
744 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' />
745 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'}
750 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
752 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
754 <tr><td colspan='3'><hr />
755 <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'}
756 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' />
757 <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'}
758 <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'}
759 <tr><td colspan='3' width='100%'><hr />
760 <tr><td colspan='3' width='100%' align='center'>
763 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
764 <table width='66%' border='0'>
765 <tr><td width='100%' align='center'>
766 <input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' />
767 <input type='submit' name='ACTION' value='$Lang::tr{'status'}' />
775 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
777 &Header
::closebigbox
();
778 &Header
::closepage
();
782 if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
784 &Header
::closebigbox
();
785 &Header
::closepage
();
789 &Header
::openbox
('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}, $Lang::tr{'uplink'}");
790 &Graphs
::makegraphbox
("qos.cgi",$qossettings{'RED_DEV'},"hour","325");
792 &Header
::openbox
('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}, $Lang::tr{'downlink'}");
793 &Graphs
::makegraphbox
("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325");
796 &showclasses
($qossettings{'RED_DEV'});
797 &showclasses
($qossettings{'IMQ_DEV'});
799 &Header
::closebigbox
();
800 &Header
::closepage
();
804 ############################################################################################################################
805 ############################################################################################################################
807 sub changedefclasses
{
808 &Header
::openbox
('100%', 'center', $Lang::tr
{'std classes'});
810 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
812 <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'}
813 <tr><td width='33%' align='right'>$Lang::tr{'download'}:<td width='33%' align='left'><select name='DEFCLASS_INC'>
816 for ( $c = 200 ; $c <= 220 ; $c++ )
818 if ( $qossettings{'DEFCLASS_INC'} ne $c )
819 { print "<option value='$c'>$c</option>\n"; }
820 else { print "<option selected value='$c'>$c</option>\n"; }
823 </select><td width='33%' align='center'>
824 <tr><td width='33%' align='right'>$Lang::tr{'upload'}:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
827 for ( $c = 100 ; $c <= 120 ; $c++ )
829 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
830 { print "<option value='$c'>$c</option>\n"; }
831 else { print "<option selected value='$c'>$c</option>\n"; }
834 </select><td width='33%' align='center'>
838 <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'}
839 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
842 for ( $c = 100 ; $c <= 120 ; $c++ )
844 if ( $qossettings{'ACK'} ne $c )
845 { print "<option value='$c'>$c</option>\n"; }
846 else { print "<option selected value='$c'>$c</option>\n"; }
849 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
857 sub changebandwidth
{
858 &Header
::openbox
('100%', 'center', $Lang::tr
{'bandwithsettings'});
859 if ($qossettings{'ENABLED'} eq 'on') {
860 print "$Lang::tr{'bandwitherror'}";
861 print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>";
864 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
865 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
867 <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr>
868 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td>
869 <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td>
870 <td width='20%' align='center' rowspan='2'><input type='submit' name='ACTION' value="$Lang::tr{'template'}" /><br /><input type='submit' name='ACTION' value="$Lang::tr{'save'}" /><br /><input type='reset' name='ACTION' value="$Lang::tr{'reset'}" /></td></tr>
871 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td>
872 <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr>
875 <font color='red'>$Lang::tr{'template warning'}</font>
883 &Header
::openbox
('100%', 'center', $Lang::tr
{'parentclass'});
885 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
889 if ( $message ne "" ) {
890 print "<tr><td colspan='3' align='center'>$message";
892 if ( $qossettings{'EDIT'} eq 'yes' ) {
893 print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />";
894 print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />";
897 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
898 <tr><td width='33%' align='right'>$Lang::tr{'interface'}:
899 <td width='33%' align='left'>
902 if ( $qossettings{'EDIT'} eq 'yes' ) {
903 print "<select name='DEVICE' disabled>";
905 print "<select name='DEVICE'>";
907 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
908 $qossettings{'RED_DEV_SEL'} = 'selected';
909 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
910 $qossettings{'IMQ_DEV_SEL'} = 'selected';
913 <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
914 <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
915 <td width='33%' align='center'>
916 <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'>
919 if ( $qossettings{'EDIT'} eq 'yes' ) {
920 print "<select name='CLASS' disabled>";
922 print "<select name='CLASS'>";
924 for ( $c = 100 ; $c <= 120 ; $c++ )
926 if ( $qossettings{'CLASS'} ne $c )
927 { print "<option value='$c'>$c</option>\n"; }
928 else { print "<option selected value='$c'>$c</option>\n"; }
930 for ( $c = 200 ; $c <= 220 ; $c++ )
932 if ( $qossettings{'CLASS'} ne $c )
933 { print "<option value='$c'>$c</option>\n"; }
934 else { print "<option selected value='$c'>$c</option>\n"; }
938 <td width='33%' align='center'>
939 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
942 for ( $c = 1 ; $c <= 7 ; $c++ )
944 if ( $qossettings{'PRIO'} ne $c )
945 { print "<option value='$c'>$c</option>\n"; }
946 else { print "<option selected value='$c'>$c</option>\n"; }
948 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
951 <td width='33%' align='center'>
952 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
953 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
954 <td width='33%' align='center'>
955 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
956 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
957 <td width='33%' align='center'>
958 <tr><td width='33%' align='right'>Burst:
959 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
960 <td width='33%' align='center'>
961 <tr><td width='33%' align='right'>Ceilburst:
962 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
963 <td width='33%' align='center'>
966 $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
968 <tr><td width='33%' align='right'>TOS-Bit:
969 <td width='33%' align='left'><select name='TOS'>
970 <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
971 <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
972 <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
973 <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
974 <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
975 <td width='33%' align='center'>
976 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
977 <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> <img alt="" alt='blob' src='/blob.gif' />
978 <tr><td width='33%' align='right'>
979 <td width='33%' align='left'>
980 <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' />
988 &Header
::openbox
('100%', 'center', $Lang::tr
{'Subclass'});
990 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
994 if ( $message ne "" ) {
995 print "<tr><td colspan='3' align='center'>$message";
998 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
999 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1000 <tr><td width='33%' align='right'>$Lang::tr{'Subclass'}:<td width='33%' align='left'><select name='SCLASS'>
1003 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
1004 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
1005 for ( $c = 1000 ; $c <= 1020 ; $c++ )
1007 if ( $qossettings{'SCLASS'} ne $c )
1008 { print "<option value='$c'>$c</option>\n"; }
1009 else { print "<option selected value='$c'>$c</option>\n"; }
1011 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
1012 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
1013 for ( $c = 2000 ; $c <= 2020 ; $c++ )
1015 if ( $qossettings{'SCLASS'} ne $c )
1016 { print "<option value='$c'>$c</option>\n"; }
1017 else { print "<option selected value='$c'>$c</option>\n"; }
1022 <td width='33%' align='center'>
1023 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
1026 for ( $c = 1 ; $c <= 7 ; $c++ )
1028 if ( $qossettings{'PRIO'} ne $c )
1029 { print "<option value='$c'>$c</option>\n"; }
1030 else { print "<option selected value='$c'>$c</option>\n"; }
1033 <td width='33%' align='center'>
1034 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
1035 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
1036 <td width='33%' align='center'>
1037 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
1038 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
1039 <td width='33%' align='center'>
1040 <tr><td width='33%' align='right'>Burst:
1041 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
1042 <td width='33%' align='center'>
1043 <tr><td width='33%' align='right'>Ceilburst:
1044 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
1045 <td width='33%' align='center'>
1046 <tr><td width='33%' align='right'>TOS-Bit:
1047 <td width='33%' align='left'><select name='TOS'>
1048 <option value='0'>$Lang::tr{'disabled'} (0)</option>
1049 <option value='8'>$Lang::tr{'min delay'} (8)</option>
1050 <option value='4'>$Lang::tr{'max throughput'} (4)</option>
1051 <option value='2'>$Lang::tr{'max reliability'} (2)</option>
1052 <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
1053 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
1054 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
1055 <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' />
1059 &Header
::closebox
();
1063 &Header
::openbox
('100%', 'center', $Lang::tr
{'Level7 Rule'});
1065 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1069 if ( $message ne "" ) {
1070 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1073 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1074 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1075 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1076 <td width='33%' align='left'><select name='L7PROT'>
1079 opendir( DIR
, "/etc/l7-protocols/protocols" );
1080 foreach $direntry ( sort readdir(DIR
) )
1082 next if $direntry eq ".";
1083 next if $direntry eq "..";
1084 next if -d
"/etc/l7-protocols/protocols/$direntry";
1085 @proto = split( /\./, $direntry );
1086 if ( $proto[0] eq $qossettings{'L7PROT'} ) {
1087 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
1089 print "<option value='$proto[0]'>$proto[0]</option>\n";
1094 </select><td width='33%' align='center'>
1095 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1096 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
1097 <td width='33%' align='center'>
1098 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1099 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
1100 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' />
1101 <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font>
1105 &Header
::closebox
();
1109 &Header
::openbox
('100%', 'center', $Lang::tr
{'Add Port Rule'});
1111 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1113 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1114 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1115 <td width='33%' align='left'><select name='PPROT'>
1118 open( FILE
, "< /etc/protocols" );
1121 foreach $direntry (sort @proto)
1123 @tmpline = split( /\ /, $direntry );
1124 next if $tmpline[0] =~ "#";
1125 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
1126 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
1128 print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
1132 </select><td width='33%' align='center'>
1133 <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
1134 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
1135 <td width='33%' align='center'>
1136 <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
1137 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
1138 <td width='33%' align='center'>
1139 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1140 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
1141 <td width='33%' align='center'>
1142 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1143 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
1144 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
1148 &Header
::closebox
();
1152 &Header
::openbox
('100%', 'center', $Lang::tr
{'TOS Rule'});
1153 if ($qossettings{'TOS'}) {
1154 $checked{$qossettings{'TOS'}} = "checked";
1157 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1161 if ( $message ne "" ) {
1162 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1165 <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1166 <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
1167 <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1168 <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1169 <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
1170 <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
1171 <tr><td width='100%' align='right' colspan='2'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOTOS' value='$Lang::tr{'save'}' />
1175 &Header
::closebox
();
1179 $qossettings{'DEV'} = shift;
1180 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1184 open( FILE
, "< $subclassfile" ) or die "Unable to read $subclassfile";
1185 @subclasses = <FILE
>;
1187 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
1190 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
1193 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
1194 @portrules = <FILE
>;
1196 foreach $classentry (sort @classes)
1198 @classline = split( /\;/, $classentry );
1199 if ( $classline[0] eq $qossettings{'DEV'} )
1201 &Header
::openbox
('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]");
1203 <table border='0' width='100%' cellspacing='0'>
1204 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
1205 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
1206 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
1207 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
1208 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
1209 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1210 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1211 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
1212 <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
1213 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1214 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1215 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1216 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1217 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1218 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1219 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1220 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1221 <td align='right' bgcolor='$color{'color22'}'>
1222 <table border='0'><tr>
1223 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1224 <input type='hidden' name='CLASS' value='$classline[1]' />
1225 <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
1226 <input type='image' alt='$Lang::tr{'add subclass'}' title='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
1228 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1229 <input type='hidden' name='CLASS' value='$classline[1]' />
1230 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1231 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1233 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1234 <input type='hidden' name='CLASS' value='$classline[1]' />
1235 <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
1236 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1238 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1239 <input type='hidden' name='CLASS' value='$classline[1]' />
1240 <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
1241 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1245 <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
1246 <td align='center' colspan='6'> $classline[8]
1247 <td align='right'><b>Queueing:</b> $classline[9]
1252 foreach $l7ruleentry (sort @l7rules)
1254 @l7ruleline = split( /\;/, $l7ruleentry );
1255 if ( $l7ruleline[0] eq $classline[1] )
1258 <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
1259 <td align='center' colspan='6'>$l7ruleline[2]
1261 <table border='0'><tr>
1262 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1263 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1264 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1265 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
1266 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1268 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1269 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1270 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1271 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
1272 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1277 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1279 <tr><td align='center'>
1280 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3]
1281 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4]
1295 foreach $portruleentry (sort @portrules)
1297 @portruleline = split( /\;/, $portruleentry );
1298 if ( $portruleline[0] eq $classline[1] )
1301 <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
1302 <td align='center'>($portruleline[2])
1303 <td align='center' colspan='2'>
1306 if ($portruleline[4]) {
1308 <i>$Lang::tr{'source port'}:</i> $portruleline[4]
1312 print "<td align='center' colspan='2'>";
1313 if ($portruleline[6]) {
1315 <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
1322 <table border='0'><tr>
1323 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1324 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1325 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1326 <input type='hidden' name='QIP' value='$portruleline[3]' />
1327 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1328 <input type='hidden' name='DIP' value='$portruleline[5]' />
1329 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1330 <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
1331 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1333 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1334 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1335 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1336 <input type='hidden' name='QIP' value='$portruleline[3]' />
1337 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1338 <input type='hidden' name='DIP' value='$portruleline[5]' />
1339 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1340 <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
1341 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1346 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1348 <tr><td align='center'>
1349 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3]
1350 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5]
1359 foreach $tosruleentry (sort @tosrules)
1361 @tosruleline = split( /\;/, $tosruleentry );
1362 if ( $tosruleline[0] eq $classline[1] )
1365 <tr><td align='right' colspan='2'>
1366 <b>TOS Bit matches:</b>
1367 <td colspan='6' align='center'>
1370 if ( $tosruleline[2] eq "8") {
1371 print "$Lang::tr{'min delay'}\n";
1372 } elsif ( $tosruleline[2] eq "4") {
1373 print "$Lang::tr{'max throughput'}\n";
1374 } elsif ( $tosruleline[2] eq "2") {
1375 print "$Lang::tr{'max reliability'}\n";
1376 } elsif ( $tosruleline[2] eq "1") {
1377 print "$Lang::tr{'min costs'}\n";
1378 } else { print " \n"; }
1383 <table border='0'><tr>
1384 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1385 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1386 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1387 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1388 <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
1389 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1391 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1392 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1393 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1394 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1395 <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
1396 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1406 foreach $subclassentry (sort @subclasses)
1408 @subclassline = split( /\;/, $subclassentry );
1409 if ( $subclassline[1] eq $classline[1] ) {
1411 <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
1412 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1413 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1414 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1415 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1416 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1417 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1418 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1419 <td align='right' bgcolor='#FAFAFA'>
1420 <table border='0'><tr>
1421 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1422 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1423 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1424 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1426 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1427 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1428 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
1429 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1431 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1432 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1433 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
1434 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1445 &Header
::closebox
();
1451 if ( $qossettings{'VALID'} eq 'yes' ) {
1452 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1453 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1454 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1455 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1457 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
1458 $qossettings{'VALID'} = 'no';
1459 $message = "$Lang::tr{'false min bandwith'}";
1461 $qossettings{'SPD'} = '';
1466 if ( $qossettings{'VALID'} eq 'yes' ) {
1467 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1468 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1469 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1470 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1472 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1473 $qossettings{'VALID'} = 'no';
1474 $message = "$Lang::tr{'false max bandwith'}";
1476 $qossettings{'SPD'} = '';
1481 if ( $qossettings{'VALID'} eq 'yes' ) {
1482 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1483 if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1484 $qossettings{'VALID'} = 'no';
1485 $message = "$Lang::tr{'false classnumber'}";
1487 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1488 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1489 $qossettings{'VALID'} = 'no';
1490 $message = "$Lang::tr{'The class number does not match the specified interface.'}";
1493 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1496 foreach $classentry (sort @tmp)
1498 @tmpline = split( /\;/, $classentry );
1499 if ( $tmpline[1] eq $qossettings{'CLASS'} )
1501 $qossettings{'VALID'} = 'no';
1502 $message = "$Lang::tr{'false classnumber'}";
1510 if ( $qossettings{'VALID'} eq 'yes' ) {
1511 open( FILE
, "< $subclassfile" ) or die "Unable to read $subclassfile";
1514 foreach $subclassentry (sort @tmp)
1516 @tmpline = split( /\;/, $subclassentry );
1517 if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1519 $qossettings{'VALID'} = 'no';
1520 $message = "$Lang::tr{'class in use'}";