]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/qos.cgi
26e0eef5084c815cfe67eee1860bde0e493e89a1
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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{'MTU'} = '1492';
77 $qossettings{'SFQ_PERTUB'} = '10';
78 $qossettings{'QLENGTH'} = '30';
79 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
80 $qossettings{'IMQ_DEV'} = 'imq0';
81 $qossettings{'VALID'} = 'yes';
82 ### Values that have to be initialized
83 $qossettings{'ACTION'} = '';
84 $qossettings{'ACTIONDEF'} = '';
85 $qossettings{'ACTIONBW'} = '';
86 $qossettings{'RED_DEV_SEL'} = '';
87 $qossettings{'IMQ_DEV_SEL'} = '';
88 $qossettings{'PRIO'} = '';
89 $qossettings{'SPD'} = '';
90 $qossettings{'CLASS'} = '';
91 $qossettings{'SCLASS'} = '';
92 $qossettings{'QPORT'} = '';
93 $qossettings{'DPORT'} = '';
94 $qossettings{'QIP'} = '';
95 $qossettings{'DIP'} = '';
96 $qossettings{'PPROT'} = '';
97 $qossettings{'L7PROT'} = '';
98 $qossettings{'DEVICE'} = '';
99 $qossettings{'MINBWDTH'} = '';
100 $qossettings{'MAXBWDTH'} = '';
101 $qossettings{'BURST'} = '';
102 $qossettings{'CBURST'} = '';
103 $qossettings{'DOCLASS'} = '';
104 $qossettings{'DOSCLASS'} = '';
105 $qossettings{'DOLEVEL7'} = '';
106 $qossettings{'DOPORT'} = '';
107 $qossettings{'CLASS'} = '';
108 $qossettings{'CLASSPRFX'} = '';
109 $qossettings{'DEV'} = '';
110 $qossettings{'TOS'} = '';
113 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
114 &Header
::getcgihash
(\
%qossettings);
117 my %mainsettings = ();
118 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
119 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
121 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
122 $querry[0] = '' unless defined $querry[0];
123 $querry[1] = 'hour' unless defined $querry[1];
125 if ( $querry[0] ne ""){
126 print "Content-type: image/png\n\n";
128 &Graphs
::updateqosgraph
($querry[0],$querry[1]);
130 &Header
::showhttpheaders
();
132 &Header
::openpage
('QoS', 1, '');
133 &Header
::openbigbox
('100%', 'left', '', $errormessage);
135 ############################################################################################################################
136 ############################################################################################################################
138 if ($qossettings{'DOCLASS'} eq $Lang::tr
{'save'})
143 if ( $qossettings{'VALID'} eq 'yes' ) {
144 open( FILE
, ">> $classfile" ) or die "Unable to write $classfile";
146 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};$qossettings{'REMARK'};
151 $qossettings{'ACTION'} = $Lang::tr
{'parentclass add'};
154 elsif ($qossettings{'DOCLASS'} eq $Lang::tr
{'edit'})
156 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
159 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
160 foreach $classentry (sort @classes)
162 @classline = split( /\;/, $classentry );
163 if ( $classline[1] ne $qossettings{'CLASS'} ) {
164 print FILE
$classentry;
166 $qossettings{'DEVICE'} = $classline[0];
167 $qossettings{'PRIO'} = $classline[2];
168 $qossettings{'MINBWDTH'} = $classline[3];
169 $qossettings{'MAXBWDTH'} = $classline[4];
170 $qossettings{'BURST'} = $classline[5];
171 $qossettings{'CBURST'} = $classline[6];
172 $qossettings{'TOS'} = $classline[7];
173 $qossettings{'REMARK'} = $classline[8];
174 $qossettings{'EDIT'} = 'yes';
179 &Header
::closebigbox
();
180 &Header
::closepage
();
183 elsif ($qossettings{'DOCLASS'} eq $Lang::tr
{'delete'})
185 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
188 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
189 foreach $classentry (sort @tmp)
191 @tmpline = split( /\;/, $classentry );
192 if ( $tmpline[1] ne $qossettings{'CLASS'} )
194 print FILE
$classentry;
198 open( FILE
, "< $subclassfile" ) or die "Unable to read $classfile";
201 open( FILE
, "> $subclassfile" ) or die "Unable to write $classfile";
202 foreach $subclassentry (sort @tmp)
204 @tmpline = split( /\;/, $subclassentry );
205 if ( $tmpline[1] ne $qossettings{'CLASS'} )
207 print FILE
$subclassentry;
211 $message = "$Lang::tr{'Class'} $qossettings{'CLASS'} $Lang::tr{'Class was deleted'}";
214 ############################################################################################################################
215 ############################################################################################################################
217 if ($qossettings{'DOSCLASS'} eq $Lang::tr
{'save'})
221 if ( $qossettings{'VALID'} eq 'yes' ) {
222 open( FILE
, ">> $subclassfile" ) or die "Unable to write $subclassfile";
224 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};
229 $qossettings{'ACTION'} = $Lang::tr
{'qos add subclass'};
231 } elsif ($qossettings{'DOSCLASS'} eq $Lang::tr
{'delete'})
233 open( FILE
, "< $subclassfile" ) or die "Unable to read $classfile";
236 open( FILE
, "> $subclassfile" ) or die "Unable to write $classfile";
237 foreach $subclassentry (sort @tmp)
239 @tmpline = split( /\;/, $subclassentry );
240 if ( $tmpline[2] ne $qossettings{'CLASS'} )
242 print FILE
$subclassentry;
246 $message = "$Lang::tr{'Subclass'} $qossettings{'CLASS'} $Lang::tr{'was deleted'}.";
249 ############################################################################################################################
250 ############################################################################################################################
252 if ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'save'})
254 if ( $qossettings{'QIP'} ne '' ) {
255 unless ( &General
::validip
($qossettings{'QIP'}) ) {
256 $qossettings{'VALID'} = 'no';
257 $message = $Lang::tr
{'The source IP address is invalid.'};
260 if ( $qossettings{'DIP'} ne '' ) {
261 unless ( &General
::validip
($qossettings{'DIP'}) ) {
262 $qossettings{'VALID'} = 'no';
263 $message = $Lang::tr
{'The destination IP address is invalid.'};
266 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
267 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
268 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
269 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
270 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
271 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
272 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
273 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
275 if ( $qossettings{'VALID'} eq 'yes' ) {
276 open( FILE
, ">> $level7file" ) or die "Unable to write $level7file";
278 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
283 $qossettings{'ACTION'} = $Lang::tr
{'Add Level7 rule'};
285 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'delete'})
287 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
290 system("rm $level7file");
291 foreach $l7ruleentry (sort @l7rules)
293 @l7ruleline = split( /\;/, $l7ruleentry );
294 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
295 {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";}
297 { open( FILE
, ">> $level7file" ) or die "Unable to read $level7file";
298 print FILE
$l7ruleentry;
302 open( FILE
, "< $level7file" ) or system("touch $level7file");close FILE
;
303 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr
{'edit'})
305 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
308 system("rm $level7file");
309 foreach $l7ruleentry (sort @l7rules)
311 @l7ruleline = split( /\;/, $l7ruleentry );
312 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
313 {$qossettings{'QIP'} = $l7ruleline[3];$qossettings{'DIP'} = $l7ruleline[4];}
315 open( FILE
, ">> $level7file" ) or die "Unable to write $level7file";
316 print FILE
$l7ruleentry;
321 open( FILE
, "< $level7file" ) or system("touch $level7file");close FILE
;
324 ############################################################################################################################
325 ############################################################################################################################
327 if ($qossettings{'DOPORT'} eq $Lang::tr
{'save'})
329 if ( $qossettings{'QIP'} ne '' ) {
330 unless ( &General
::validip
($qossettings{'QIP'}) ) {
331 $qossettings{'VALID'} = 'no';
332 $message = "$Lang::tr{'The source IP address is invalid.'}";
335 if ( $qossettings{'DIP'} ne '' ) {
336 unless ( &General
::validip
($qossettings{'DIP'}) ) {
337 $qossettings{'VALID'} = 'no';
338 $message = "$Lang::tr{'The destination IP address is invalid.'}";
341 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
342 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
343 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
344 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
345 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
346 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
347 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
348 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
350 if ( $qossettings{'VALID'} eq 'yes' ) {
351 open( FILE
, ">> $portfile" ) or die "Unable to write $portfile";
353 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
358 $qossettings{'ACTION'} = $Lang::tr
{'Add Port Rule'};
360 } elsif ($qossettings{'DOPORT'} eq $Lang::tr
{'delete'})
362 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
365 open( FILE
, "> $portfile" ) or die "Unable to read $portfile";
366 foreach $portruleentry (sort @portrules)
368 @portruleline = split( /\;/, $portruleentry );
369 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'}))
371 print FILE
$portruleentry;
375 $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}.";
376 } elsif ($qossettings{'DOPORT'} eq $Lang::tr
{'edit'})
378 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
381 system("rm $portfile");
382 foreach $portruleentry (sort @portrules)
384 @portruleline = split( /\;/, $portruleentry );
385 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'}))
386 {$qossettings{'CLASS'}=$portruleline[0];$qossettings{'PPROT'}=$portruleline[2];$qossettings{'QIP'}=$portruleline[3];$qossettings{'QPORT'}=$portruleline[4];$qossettings{'DIP'}=$portruleline[5];$qossettings{'DPORT'}=$portruleline[6];}
388 open( FILE
, ">> $portfile" ) or die "Unable to write $portfile";
389 print FILE
$portruleentry;
394 open( FILE
, "< $portfile" ) or system("touch $portfile");close FILE
;
397 ############################################################################################################################
398 ############################################################################################################################
400 if ($qossettings{'DOTOS'} eq $Lang::tr
{'save'})
402 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
403 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
404 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
405 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
406 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
407 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
408 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
409 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
411 open( FILE
, ">> $tosfile" ) or die "Unable to write $tosfile";
413 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'};
418 elsif ($qossettings{'DOTOS'} eq 'Loeschen')
420 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
423 open( FILE
, "> $tosfile" ) or die "Unable to read $tosfile";
424 foreach $tosruleentry (sort @tosrules)
426 @tosruleline = split( /\;/, $tosruleentry );
427 unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'}))
429 print FILE
$tosruleentry;
433 $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}.";
434 } elsif ($qossettings{'DOTOS'} eq $Lang::tr
{'edit'})
436 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
439 open( FILE
, "> $tosfile" ) or die "Unable to write $tosfile";
440 foreach $tosruleentry (sort @tosrules)
442 @tosruleline = split( /\;/, $tosruleentry );
443 if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) {
444 $qossettings{'DEVICE'} = $tosruleline[1];
445 $qossettings{'CLASS'} = $tosruleline[0];
446 $qossettings{'TOS'} = $tosruleline[2];
447 $qossettings{'EDIT'} = 'yes';
449 print FILE
$tosruleentry;
454 &Header
::closebigbox
();
455 &Header
::closepage
();
459 ############################################################################################################################
460 ############################################################################################################################
462 if ($qossettings{'ACTION'} eq $Lang::tr
{'start'})
464 $qossettings{'ENABLED'} = 'on';
465 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
466 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
467 system("/usr/bin/touch /var/ipfire/qos/enable");
468 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
469 system("logger -t ipfire 'QoS started'");
471 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'stop'})
473 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
474 unlink "/var/ipfire/qos/bin/qos.sh";
475 unlink "/var/ipfire/qos/enable";
476 system("logger -t ipfire 'QoS stopped'");
477 $qossettings{'ENABLED'} = 'off';
478 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
480 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'restart'})
482 if ($qossettings{'ENABLED'} eq 'on'){
483 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
484 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
485 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
486 system("logger -t ipfire 'QoS restarted'");
489 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'save'})
491 if ($qossettings{'DEF_INC_SPD'} eq '') {
492 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
494 if ($qossettings{'DEF_OUT_SPD'} eq '') {
495 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
497 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
499 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'template'} )
503 for(my $i = 1; $i <= 10; $i++) {
504 $UP[$i] = int($qossettings{'OUT_SPD'} / $i );
505 #print $i."=".$UP[$i]." ";
508 #print "<br /><br />Down<br />";
509 for(my $i = 1; $i <= 20; $i++) {
510 $DOWN[$i] = int($qossettings{'INC_SPD'} / $i);
511 #print $i."=".$DOWN[$i]." ";
513 open( FILE
, "> $classfile" ) or die "Unable to write $classfile";
515 imq0;200;1;$DOWN[10];$DOWN[1];;;8;VoIP;
516 imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
517 imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
518 imq0;210;6;1;$DOWN[1];;;0;Default;
519 imq0;220;7;1;$DOWN[1];;;1;P2P;
520 $qossettings{'RED_DEV'};101;1;$UP[2];$UP[1];;;8;ACKs;
521 $qossettings{'RED_DEV'};102;2;$UP[3];$UP[1];;;8;VoIP;
522 $qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic;
523 $qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default;
524 $qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P;
525 $qossettings{'RED_DEV'};103;4;$UP[2];$UP[1];;;2;VPN;
529 open( FILE
, "> $level7file" ) or die "Unable to write $level7file";
531 102;$qossettings{'RED_DEV'};dns;;;
532 102;$qossettings{'RED_DEV'};sip;;;
533 102;$qossettings{'RED_DEV'};skypetoskype;;;
534 103;$qossettings{'RED_DEV'};ssh;;;
535 103;$qossettings{'RED_DEV'};rdp;;;
536 104;$qossettings{'RED_DEV'};http;;;
537 104;$qossettings{'RED_DEV'};ssl;;;
538 104;$qossettings{'RED_DEV'};pop3;;;
539 120;$qossettings{'RED_DEV'};applejuice;;;
540 120;$qossettings{'RED_DEV'};bittorrent;;;
541 200;imq0;skypetoskype;;;
547 220;imq0;applejuice;;;
548 220;imq0;bittorrent;;;
552 open( FILE
, "> $portfile" ) or die "Unable to write $portfile";
554 101;$qossettings{'RED_DEV'};icmp;;;;;
555 102;$qossettings{'RED_DEV'};tcp;;;;53;
556 102;$qossettings{'RED_DEV'};udp;;;;53;
557 103;$qossettings{'RED_DEV'};esp;;;;;
558 103;$qossettings{'RED_DEV'};tcp;;1194;;;
559 103;$qossettings{'RED_DEV'};udp;;1194;;;
560 103;$qossettings{'RED_DEV'};tcp;;;;1194;
561 103;$qossettings{'RED_DEV'};udp;;;;1194;
562 103;$qossettings{'RED_DEV'};udp;;4500;;4500;
563 103;$qossettings{'RED_DEV'};udp;;500;;500;
564 104;$qossettings{'RED_DEV'};tcp;;;;80;
567 203;imq0;tcp;;;;1194;
568 203;imq0;udp;;;;1194;
569 203;imq0;tcp;;1194;;;
570 203;imq0;udp;;1194;;;
571 203;imq0;udp;;4500;;4500;
572 203;imq0;udp;;500;;500;
577 if ($qossettings{'DEF_INC_SPD'} eq '') {
578 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
580 if ($qossettings{'DEF_OUT_SPD'} eq '') {
581 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
583 $qossettings{'DEFCLASS_INC'} = "210";
584 $qossettings{'DEFCLASS_OUT'} = "110";
585 $qossettings{'ACK'} ="101";
586 $qossettings{'ENABLED'} = 'on';
587 &General
::writehash
("${General::swroot}/qos/settings", \
%qossettings);
588 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
589 system("/usr/bin/touch /var/ipfire/qos/enable");
590 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
591 system("logger -t ipfire 'QoS started'");
593 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'status'} )
595 &Header
::openbox
('100%', 'left', 'QoS Status');
596 if ($qossettings{'ENABLED'} eq 'on'){
598 $output = `/usr/local/bin/qosctrl status`;
599 $output = &Header
::cleanhtml
($output,"y");
600 print "<pre>$output</pre>\n";
601 } else { print "$Lang::tr{'QoS not enabled'}"; }
603 &Header
::closebigbox
();
604 &Header
::closepage
();
607 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'parentclass add'} )
610 &Header
::closebigbox
();
611 &Header
::closepage
();
614 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'qos add subclass'})
617 &Header
::closebigbox
();
618 &Header
::closepage
();
621 elsif ($qossettings{'ACTION'} eq $Lang::tr
{'Add Rule'})
623 &Header
::openbox
('100%', 'center', $Lang::tr
{'Add Rule'});
626 <tr><td align='center'>$Lang::tr{'Choose Rule'}
627 <tr><td align='center'>
628 <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' />
629 <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' />
630 <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' />
636 <div id='l7rule' style='display: none'>
642 <div id='portrule' style='display: none'>
648 <div id='tosrule' style='display: none'>
656 &Header
::closebigbox
();
657 &Header
::closepage
();
660 elsif ($qossettings{'ACTION'} eq "$Lang::tr{'urlfilter advanced settings'}" )
663 &Header
::closebigbox
();
664 &Header
::closepage
();
667 if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" )
670 &Header
::closebigbox
();
671 &Header
::closepage
();
674 if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" )
677 &Header
::closebigbox
();
678 &Header
::closepage
();
682 &General
::readhash
("${General::swroot}/qos/settings", \
%qossettings);
684 my $status = $Lang::tr
{'stopped'};
685 my $statuscolor = '#993333';
686 if ( $qossettings{'ENABLED'} eq 'on' ) {
687 $status = $Lang::tr
{'running'};
688 $statuscolor = '#339933';
691 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
692 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
696 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
697 print "<class name='base'>$errormessage\n";
698 print " </class>\n";
702 ############################################################################################################################
703 ############################################################################################################################
705 &Header
::openbox
('100%', 'center', 'Quality of Service');
708 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
712 if ( $message ne "" ) {
713 print "<tr><td colspan='2' align='center'><font color='red'>$message</font>";
716 <tr><td width='50%' align='left'><b>Quality of Service:</b>
717 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font>
718 <tr><td width='100%' align='center' colspan='2'>
719 <input type='submit' name='ACTION' value="$Lang::tr{'start'}" />
720 <input type='submit' name='ACTION' value="$Lang::tr{'stop'}" />
721 <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" /></table></form>
724 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
726 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
728 <tr><td colspan='3'>
729 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'}
730 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' />
731 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'}
736 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
738 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
740 <tr><td colspan='3'><hr />
741 <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'}
742 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' />
743 <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'}
744 <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'}
745 <tr><td colspan='3' width='100%'><hr />
746 <tr><td colspan='3' width='100%' align='center'>
749 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
750 <table border='0' cellpadding='0' cellspacing='0'>
751 <tr><td><input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' />
752 <td><input type='submit' name='ACTION' value='$Lang::tr{'urlfilter advanced settings'}' />
753 <td><input type='submit' name='ACTION' value='$Lang::tr{'status'}' />
761 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
763 &Header
::closebigbox
();
764 &Header
::closepage
();
768 if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
770 &Header
::closebigbox
();
771 &Header
::closepage
();
775 &Header
::openbox
('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}");
776 &Graphs
::makegraphbox
("qos.cgi",$qossettings{'RED_DEV'},"hour","325");
778 &Header
::openbox
('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}");
779 &Graphs
::makegraphbox
("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325");
782 &showclasses
($qossettings{'RED_DEV'});
783 &showclasses
($qossettings{'IMQ_DEV'});
785 &Header
::closebigbox
();
786 &Header
::closepage
();
790 ############################################################################################################################
791 ############################################################################################################################
793 sub changedefclasses
{
794 &Header
::openbox
('100%', 'center', $Lang::tr
{'std classes'});
796 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
798 <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'}
799 <tr><td width='33%' align='right'>Download:<td width='33%' align='left'><select name='DEFCLASS_INC'>
802 for ( $c = 200 ; $c <= 220 ; $c++ )
804 if ( $qossettings{'DEFCLASS_INC'} ne $c )
805 { print "<option value='$c'>$c</option>\n"; }
806 else { print "<option selected value='$c'>$c</option>\n"; }
809 </select><td width='33%' align='center'>
810 <tr><td width='33%' align='right'>Upload:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
813 for ( $c = 100 ; $c <= 120 ; $c++ )
815 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
816 { print "<option value='$c'>$c</option>\n"; }
817 else { print "<option selected value='$c'>$c</option>\n"; }
820 </select><td width='33%' align='center'>
824 <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'}
825 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
828 for ( $c = 100 ; $c <= 120 ; $c++ )
830 if ( $qossettings{'ACK'} ne $c )
831 { print "<option value='$c'>$c</option>\n"; }
832 else { print "<option selected value='$c'>$c</option>\n"; }
835 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
843 sub changebandwidth
{
844 &Header
::openbox
('100%', 'center', $Lang::tr
{'bandwithsettings'});
845 if ($qossettings{'ENABLED'} eq 'on') {
846 print "$Lang::tr{'bandwitherror'}";
847 print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>";
850 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
851 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
853 <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr>
854 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td>
855 <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td>
856 <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>
857 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td>
858 <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr>
861 <font color='red'>$Lang::tr{'template warning'}</font>
869 &Header
::openbox
('100%', 'center', $Lang::tr
{'parentclass'});
871 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
875 if ( $message ne "" ) {
876 print "<tr><td colspan='3' align='center'>$message";
878 if ( $qossettings{'EDIT'} eq 'yes' ) {
879 print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />";
880 print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />";
883 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
884 <tr><td width='33%' align='right'>$Lang::tr{'interface'}:
885 <td width='33%' align='left'>
888 if ( $qossettings{'EDIT'} eq 'yes' ) {
889 print "<select name='DEVICE' disabled>";
891 print "<select name='DEVICE'>";
893 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
894 $qossettings{'RED_DEV_SEL'} = 'selected';
895 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
896 $qossettings{'IMQ_DEV_SEL'} = 'selected';
899 <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
900 <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
901 <td width='33%' align='center'>
902 <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'>
905 if ( $qossettings{'EDIT'} eq 'yes' ) {
906 print "<select name='CLASS' disabled>";
908 print "<select name='CLASS'>";
910 for ( $c = 100 ; $c <= 120 ; $c++ )
912 if ( $qossettings{'CLASS'} ne $c )
913 { print "<option value='$c'>$c</option>\n"; }
914 else { print "<option selected value='$c'>$c</option>\n"; }
916 for ( $c = 200 ; $c <= 220 ; $c++ )
918 if ( $qossettings{'CLASS'} ne $c )
919 { print "<option value='$c'>$c</option>\n"; }
920 else { print "<option selected value='$c'>$c</option>\n"; }
924 <td width='33%' align='center'>
925 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
928 for ( $c = 1 ; $c <= 7 ; $c++ )
930 if ( $qossettings{'PRIO'} ne $c )
931 { print "<option value='$c'>$c</option>\n"; }
932 else { print "<option selected value='$c'>$c</option>\n"; }
934 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
937 <td width='33%' align='center'>
938 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
939 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
940 <td width='33%' align='center'>
941 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
942 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
943 <td width='33%' align='center'>
944 <tr><td width='33%' align='right'>Burst:
945 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
946 <td width='33%' align='center'>
947 <tr><td width='33%' align='right'>Ceilburst:
948 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
949 <td width='33%' align='center'>
952 $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
954 <tr><td width='33%' align='right'>TOS-Bit:
955 <td width='33%' align='left'><select name='TOS'>
956 <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
957 <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
958 <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
959 <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
960 <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
961 <td width='33%' align='center'>
962 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
963 <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' />
964 <tr><td width='33%' align='right'>
965 <td width='33%' align='left'>
966 <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' />
974 &Header
::openbox
('100%', 'center', $Lang::tr
{'Subclass'});
976 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
980 if ( $message ne "" ) {
981 print "<tr><td colspan='3' align='center'>$message";
984 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
985 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
986 <tr><td width='33%' align='right'>$Lang::tr{'Subclass'}:<td width='33%' align='left'><select name='SCLASS'>
989 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
990 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
991 for ( $c = 1000 ; $c <= 1020 ; $c++ )
993 if ( $qossettings{'SCLASS'} ne $c )
994 { print "<option value='$c'>$c</option>\n"; }
995 else { print "<option selected value='$c'>$c</option>\n"; }
997 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
998 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
999 for ( $c = 2000 ; $c <= 2020 ; $c++ )
1001 if ( $qossettings{'SCLASS'} ne $c )
1002 { print "<option value='$c'>$c</option>\n"; }
1003 else { print "<option selected value='$c'>$c</option>\n"; }
1008 <td width='33%' align='center'>
1009 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
1012 for ( $c = 1 ; $c <= 7 ; $c++ )
1014 if ( $qossettings{'PRIO'} ne $c )
1015 { print "<option value='$c'>$c</option>\n"; }
1016 else { print "<option selected value='$c'>$c</option>\n"; }
1019 <td width='33%' align='center'>
1020 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
1021 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
1022 <td width='33%' align='center'>
1023 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
1024 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
1025 <td width='33%' align='center'>
1026 <tr><td width='33%' align='right'>Burst:
1027 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
1028 <td width='33%' align='center'>
1029 <tr><td width='33%' align='right'>Ceilburst:
1030 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
1031 <td width='33%' align='center'>
1032 <tr><td width='33%' align='right'>TOS-Bit:
1033 <td width='33%' align='left'><select name='TOS'>
1034 <option value='0'>$Lang::tr{'disabled'} (0)</option>
1035 <option value='8'>$Lang::tr{'min delay'} (8)</option>
1036 <option value='4'>$Lang::tr{'max throughput'} (4)</option>
1037 <option value='2'>$Lang::tr{'max reliability'} (2)</option>
1038 <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
1039 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
1040 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
1041 <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' />
1045 &Header
::closebox
();
1049 &Header
::openbox
('100%', 'center', $Lang::tr
{'Level7 Rule'});
1051 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1055 if ( $message ne "" ) {
1056 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1059 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1060 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1061 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1062 <td width='33%' align='left'><select name='L7PROT'>
1065 opendir( DIR
, "/etc/l7-protocols/protocols" );
1066 foreach $direntry ( sort readdir(DIR
) )
1068 next if $direntry eq ".";
1069 next if $direntry eq "..";
1070 next if -d
"/etc/l7-protocols/protocols/$direntry";
1071 @proto = split( /\./, $direntry );
1072 if ( $proto[0] eq $qossettings{'L7PROT'} ) {
1073 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
1075 print "<option value='$proto[0]'>$proto[0]</option>\n";
1080 </select><td width='33%' align='center'>
1081 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1082 <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value='$qossettings{'QIP'}' />
1083 <td width='33%' align='center'>
1084 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1085 <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value='$qossettings{'DIP'}' />
1086 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' />
1087 <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font>
1091 &Header
::closebox
();
1095 &Header
::openbox
('100%', 'center', $Lang::tr
{'Add Port Rule'});
1097 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1099 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1100 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1101 <td width='33%' align='left'><select name='PPROT'>
1104 open( FILE
, "< /etc/protocols" );
1107 foreach $direntry (sort @proto)
1109 @tmpline = split( /\ /, $direntry );
1110 next if $tmpline[0] =~ "#";
1111 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
1112 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
1114 print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
1118 </select><td width='33%' align='center'>
1119 <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
1120 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
1121 <td width='33%' align='center'>
1122 <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
1123 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
1124 <td width='33%' align='center'>
1125 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1126 <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value='$qossettings{'QIP'}' />
1127 <td width='33%' align='center'>
1128 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1129 <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value='$qossettings{'DIP'}' />
1130 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
1134 &Header
::closebox
();
1138 &Header
::openbox
('100%', 'center', $Lang::tr
{'TOS Rule'});
1139 if ($qossettings{'TOS'}) {
1140 $checked{$qossettings{'TOS'}} = "checked";
1143 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1147 if ( $message ne "" ) {
1148 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1151 <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1152 <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
1153 <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1154 <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1155 <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
1156 <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
1157 <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'}' />
1161 &Header
::closebox
();
1165 $qossettings{'DEV'} = shift;
1166 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1170 open( FILE
, "< $subclassfile" ) or die "Unable to read $subclassfile";
1171 @subclasses = <FILE
>;
1173 open( FILE
, "< $level7file" ) or die "Unable to read $level7file";
1176 open( FILE
, "< $tosfile" ) or die "Unable to read $tosfile";
1179 open( FILE
, "< $portfile" ) or die "Unable to read $portfile";
1180 @portrules = <FILE
>;
1182 foreach $classentry (sort @classes)
1184 @classline = split( /\;/, $classentry );
1185 if ( $classline[0] eq $qossettings{'DEV'} )
1187 &Header
::openbox
('100%', 'center', "$Lang::tr{'Class'}: $classline[1]");
1189 <table border='0' width='100%' cellspacing='0'>
1190 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
1191 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
1192 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
1193 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
1194 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
1195 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1196 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1197 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
1198 <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
1199 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1200 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1201 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1202 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1203 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1204 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1205 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1206 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1207 <td align='right' bgcolor='$color{'color22'}'>
1208 <table border='0'><tr>
1209 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1210 <input type='hidden' name='CLASS' value='$classline[1]' />
1211 <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
1212 <input type='image' alt='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
1214 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1215 <input type='hidden' name='CLASS' value='$classline[1]' />
1216 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1217 <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1219 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1220 <input type='hidden' name='CLASS' value='$classline[1]' />
1221 <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
1222 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
1224 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1225 <input type='hidden' name='CLASS' value='$classline[1]' />
1226 <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
1227 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
1231 <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
1232 <td align='center' colspan='6'> $classline[8]
1233 <td align='right'><b>Queueing:</b> $classline[9]
1238 foreach $l7ruleentry (sort @l7rules)
1240 @l7ruleline = split( /\;/, $l7ruleentry );
1241 if ( $l7ruleline[0] eq $classline[1] )
1244 <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
1245 <td align='center' colspan='6'>$l7ruleline[2]
1247 <table border='0'><tr>
1248 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1249 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1250 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1251 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
1252 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
1254 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1255 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1256 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1257 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
1258 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
1263 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1265 <tr><td align='center'>
1266 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3]
1267 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4]
1281 foreach $portruleentry (sort @portrules)
1283 @portruleline = split( /\;/, $portruleentry );
1284 if ( $portruleline[0] eq $classline[1] )
1287 <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
1288 <td align='center'>($portruleline[2])
1289 <td align='center' colspan='2'>
1292 if ($portruleline[4]) {
1294 <i>$Lang::tr{'source port'}:</i> $portruleline[4]
1298 print "<td align='center' colspan='2'>";
1299 if ($portruleline[6]) {
1301 <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
1308 <table border='0'><tr>
1309 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1310 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1311 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1312 <input type='hidden' name='QIP' value='$portruleline[3]' />
1313 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1314 <input type='hidden' name='DIP' value='$portruleline[5]' />
1315 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1316 <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
1317 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
1319 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1320 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1321 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1322 <input type='hidden' name='QIP' value='$portruleline[3]' />
1323 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1324 <input type='hidden' name='DIP' value='$portruleline[5]' />
1325 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1326 <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
1327 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
1332 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1334 <tr><td align='center'>
1335 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3]
1336 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5]
1345 foreach $tosruleentry (sort @tosrules)
1347 @tosruleline = split( /\;/, $tosruleentry );
1348 if ( $tosruleline[0] eq $classline[1] )
1351 <tr><td align='right' colspan='2'>
1352 <b>TOS Bit matches:</b>
1353 <td colspan='6' align='center'>
1356 if ( $tosruleline[2] eq "8") {
1357 print "$Lang::tr{'min delay'}\n";
1358 } elsif ( $tosruleline[2] eq "4") {
1359 print "$Lang::tr{'max throughput'}\n";
1360 } elsif ( $tosruleline[2] eq "2") {
1361 print "$Lang::tr{'max reliability'}\n";
1362 } elsif ( $tosruleline[2] eq "1") {
1363 print "$Lang::tr{'min costs'}\n";
1364 } else { print " \n"; }
1369 <table border='0'><tr>
1370 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1371 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1372 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1373 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1374 <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
1375 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
1377 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1378 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1379 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1380 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1381 <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
1382 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
1392 foreach $subclassentry (sort @subclasses)
1394 @subclassline = split( /\;/, $subclassentry );
1395 if ( $subclassline[1] eq $classline[1] ) {
1397 <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
1398 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1399 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1400 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1401 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1402 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1403 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1404 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1405 <td align='right' bgcolor='#FAFAFA'>
1406 <table border='0'><tr>
1407 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1408 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1409 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1410 <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1412 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1413 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1414 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
1415 <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
1417 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1418 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1419 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
1420 <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
1431 &Header
::closebox
();
1439 &Header
::openbox
('100%', 'center', $Lang::tr
{'expertoptions'});
1441 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1443 <tr><td width='33%' align='right'>MTU:<td width='33%' align='left'>
1444 <input type='text' name='MTU' maxlength='8' required='4' value='$qossettings{'MTU'}' />
1445 <td width='33%' align='center'>$Lang::tr{'mtu QoS'}
1446 <tr><td width='33%' align='right'>$Lang::tr{'Queuelenght'}:<td width='33%' align='left'>
1447 <input type='text' name='QLENGTH' maxlength='8' required='2' value='$qossettings{'QLENGTH'}' />
1448 <td width='33%' align='center'>
1449 <tr><td width='33%' align='right'>SFQ Perturb:<td width='33%' align='left'>
1450 <input type='text' name='SFQ_PERTUB' maxlength='8' required='1' value='$qossettings{'SFQ_PERTUB'}' />
1451 <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
1456 &Header
::closebox
();
1460 if ( $qossettings{'VALID'} eq 'yes' ) {
1461 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1462 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1463 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1464 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1466 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
1467 $qossettings{'VALID'} = 'no';
1468 $message = "$Lang::tr{'false min bandwith'}";
1470 $qossettings{'SPD'} = '';
1475 if ( $qossettings{'VALID'} eq 'yes' ) {
1476 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1477 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1478 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1479 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1481 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1482 $qossettings{'VALID'} = 'no';
1483 $message = "$Lang::tr{'false max bandwith'}";
1485 $qossettings{'SPD'} = '';
1490 if ( $qossettings{'VALID'} eq 'yes' ) {
1491 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1492 if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1493 $qossettings{'VALID'} = 'no';
1494 $message = "$Lang::tr{'false classnumber'}";
1496 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1497 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1498 $qossettings{'VALID'} = 'no';
1499 $message = "$Lang::tr{'The class number does not match the specified interface.'}";
1502 open( FILE
, "< $classfile" ) or die "Unable to read $classfile";
1505 foreach $classentry (sort @tmp)
1507 @tmpline = split( /\;/, $classentry );
1508 if ( $tmpline[1] eq $qossettings{'CLASS'} )
1510 $qossettings{'VALID'} = 'no';
1511 $message = "$Lang::tr{'false classnumber'}";
1519 if ( $qossettings{'VALID'} eq 'yes' ) {
1520 open( FILE
, "< $subclassfile" ) or die "Unable to read $subclassfile";
1523 foreach $subclassentry (sort @tmp)
1525 @tmpline = split( /\;/, $subclassentry );
1526 if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1528 $qossettings{'VALID'} = 'no';
1529 $message = "$Lang::tr{'class in use'}";