]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/qos.cgi
proxy: Drop support for throttling only certain mime types
[ipfire-2.x.git] / html / cgi-bin / qos.cgi
CommitLineData
904a41b9 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
21067331 5# Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
70df8302
MT
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
904a41b9 21
7ccede9b 22use RRDs;
904a41b9
MT
23use strict;
24# enable only the following on debugging purpose
e8babc92 25# use warnings;
33e1f48c 26# use CGI::Carp 'fatalsToBrowser';
904a41b9
MT
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
0b1641db 31require "${General::swroot}/graphs.pl";
904a41b9 32
2db5d932
MT
33my %qossettings = ();
34my %checked = ();
35my %netsettings = ();
363fb6af 36my $message = '';
904a41b9 37my $errormessage = "";
2db5d932
MT
38my $c = "";
39my $direntry = "";
414e011d
MT
40my $classentry = "";
41my $subclassentry = "";
42my $l7ruleentry = "";
84cab473 43my $portruleentry = "";
e8babc92 44my $tosruleentry = "";
414e011d
MT
45my @tmp = ();
46my @classes = ();
47my @subclasses = ();
48my @l7rules = ();
84cab473 49my @portrules = ();
e8babc92 50my @tosrules = ();
414e011d
MT
51my @tmpline = ();
52my @classline = ();
53my @subclassline = ();
54my @l7ruleline = ();
84cab473 55my @portruleline = ();
e8babc92 56my @tosruleline = ();
2db5d932 57my @proto = ();
e8babc92
MT
58my %selected= ();
59my @checked = ();
414e011d
MT
60my $classfile = "/var/ipfire/qos/classes";
61my $subclassfile = "/var/ipfire/qos/subclasses";
62my $level7file = "/var/ipfire/qos/level7config";
84cab473 63my $portfile = "/var/ipfire/qos/portconfig";
e8babc92 64my $tosfile = "/var/ipfire/qos/tosconfig";
904a41b9
MT
65&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
66
2db5d932 67$qossettings{'ENABLED'} = 'off';
414e011d 68$qossettings{'EDIT'} = 'no';
904a41b9
MT
69$qossettings{'OUT_SPD'} = '';
70$qossettings{'INC_SPD'} = '';
84cab473
MT
71$qossettings{'DEF_OUT_SPD'} = '';
72$qossettings{'DEF_INC_SPD'} = '';
2db5d932
MT
73$qossettings{'DEFCLASS_INC'} = '';
74$qossettings{'DEFCLASS_OUT'} = '';
75$qossettings{'ACK'} = '';
4d17a269 76$qossettings{'RED_DEV'} = 'ppp0';
904a41b9 77$qossettings{'IMQ_DEV'} = 'imq0';
414e011d 78$qossettings{'VALID'} = 'yes';
84cab473
MT
79### Values that have to be initialized
80$qossettings{'ACTION'} = '';
81$qossettings{'ACTIONDEF'} = '';
82$qossettings{'ACTIONBW'} = '';
e8babc92
MT
83$qossettings{'RED_DEV_SEL'} = '';
84$qossettings{'IMQ_DEV_SEL'} = '';
84cab473
MT
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'} = '';
7ccede9b
MT
104$qossettings{'CLASS'} = '';
105$qossettings{'CLASSPRFX'} = '';
106$qossettings{'DEV'} = '';
e8babc92 107$qossettings{'TOS'} = '';
84cab473 108
904a41b9
MT
109
110&General::readhash("${General::swroot}/qos/settings", \%qossettings);
111&Header::getcgihash(\%qossettings);
112
4d17a269
CS
113$qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
114
f2fdd0c1
CS
115my %color = ();
116my %mainsettings = ();
117&General::readhash("${General::swroot}/main/settings", \%mainsettings);
118&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
119
bcad0fd0
CS
120my @querry = split(/\?/,$ENV{'QUERY_STRING'});
121$querry[0] = '' unless defined $querry[0];
122$querry[1] = 'hour' unless defined $querry[1];
123
124if ( $querry[0] ne ""){
125 print "Content-type: image/png\n\n";
126 binmode(STDOUT);
127 &Graphs::updateqosgraph($querry[0],$querry[1]);
128}else{
129 &Header::showhttpheaders();
130
131 &Header::openpage('QoS', 1, '');
132 &Header::openbigbox('100%', 'left', '', $errormessage);
904a41b9 133
84cab473
MT
134############################################################################################################################
135############################################################################################################################
136
137if ($qossettings{'DOCLASS'} eq $Lang::tr{'save'})
414e011d
MT
138{
139 &validclass();
140 &validminbwdth();
141 &validmaxbwdth();
142 if ( $qossettings{'VALID'} eq 'yes' ) {
143 open( FILE, ">> $classfile" ) or die "Unable to write $classfile";
144 print FILE <<END
f013ab2b 145$qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};$qossettings{'REMARK'};
414e011d
MT
146END
147;
148 close FILE;
149 } else {
65e8619a 150 $qossettings{'ACTION'} = $Lang::tr{'parentclass add'};
414e011d
MT
151 }
152}
65e8619a 153elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'edit'})
414e011d
MT
154{
155 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
156 @classes = <FILE>;
157 close FILE;
158 open( FILE, "> $classfile" ) or die "Unable to write $classfile";
159 foreach $classentry (sort @classes)
160 {
161 @classline = split( /\;/, $classentry );
162 if ( $classline[1] ne $qossettings{'CLASS'} ) {
163 print FILE $classentry;
164 } else {
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];
f013ab2b
MT
171 $qossettings{'TOS'} = $classline[7];
172 $qossettings{'REMARK'} = $classline[8];
414e011d
MT
173 $qossettings{'EDIT'} = 'yes';
174 }
175 }
176 close FILE;
177 &parentclass();
178 &Header::closebigbox();
179 &Header::closepage();
180 exit
181}
65e8619a 182elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'delete'})
414e011d
MT
183{
184 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
185 @tmp = <FILE>;
186 close FILE;
187 open( FILE, "> $classfile" ) or die "Unable to write $classfile";
188 foreach $classentry (sort @tmp)
189 {
190 @tmpline = split( /\;/, $classentry );
191 if ( $tmpline[1] ne $qossettings{'CLASS'} )
192 {
193 print FILE $classentry;
194 }
195 }
196 close FILE;
84cab473
MT
197 open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
198 @tmp = <FILE>;
199 close FILE;
200 open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
201 foreach $subclassentry (sort @tmp)
202 {
203 @tmpline = split( /\;/, $subclassentry );
204 if ( $tmpline[1] ne $qossettings{'CLASS'} )
205 {
206 print FILE $subclassentry;
207 }
208 }
209 close FILE;
0b1641db 210 $message = "$Lang::tr{'Class'} $qossettings{'CLASS'} $Lang::tr{'Class was deleted'}";
414e011d 211}
84cab473
MT
212
213############################################################################################################################
214############################################################################################################################
215
216if ($qossettings{'DOSCLASS'} eq $Lang::tr{'save'})
414e011d 217{
414e011d
MT
218 &validsubclass();
219 &validminbwdth();
220 if ( $qossettings{'VALID'} eq 'yes' ) {
221 open( FILE, ">> $subclassfile" ) or die "Unable to write $subclassfile";
222 print FILE <<END
e8babc92 223$qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};
414e011d
MT
224END
225;
226 close FILE;
227 } else {
65e8619a 228 $qossettings{'ACTION'} = $Lang::tr{'qos add subclass'};
414e011d 229 }
65e8619a 230} elsif ($qossettings{'DOSCLASS'} eq $Lang::tr{'delete'})
414e011d
MT
231{
232 open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
233 @tmp = <FILE>;
234 close FILE;
235 open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
236 foreach $subclassentry (sort @tmp)
237 {
238 @tmpline = split( /\;/, $subclassentry );
239 if ( $tmpline[2] ne $qossettings{'CLASS'} )
240 {
241 print FILE $subclassentry;
242 }
243 }
244 close FILE;
0b1641db 245 $message = "$Lang::tr{'Subclass'} $qossettings{'CLASS'} $Lang::tr{'was deleted'}.";
414e011d 246}
84cab473
MT
247
248############################################################################################################################
249############################################################################################################################
250
251if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'})
414e011d
MT
252{
253 if ( $qossettings{'QIP'} ne '' ) {
5a7491ff
MT
254 if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) {
255 $qossettings{'VALID'} = 'no';
256 $message = $Lang::tr{'The source IP address is invalid.'};
414e011d
MT
257 }
258 }
259 if ( $qossettings{'DIP'} ne '' ) {
5a7491ff
MT
260 if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) {
261 $qossettings{'VALID'} = 'no';
262 $message = $Lang::tr{'The destination IP address is invalid.'};
414e011d
MT
263 }
264 }
265 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
266 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
267 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
268 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
269 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
270 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
271 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
272 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
273 }
274 if ( $qossettings{'VALID'} eq 'yes' ) {
275 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
276 print FILE <<END
277$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
278END
279;
280 close FILE;
281 } else {
65e8619a 282 $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'};
414e011d 283 }
65e8619a 284} elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'})
414e011d
MT
285{
286 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
287 @l7rules = <FILE>;
288 close FILE;
399d32cb 289 system("rm $level7file");
414e011d
MT
290 foreach $l7ruleentry (sort @l7rules)
291 {
292 @l7ruleline = split( /\;/, $l7ruleentry );
399d32cb 293 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
65e8619a 294 {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";}
399d32cb
CS
295 else
296 { open( FILE, ">> $level7file" ) or die "Unable to read $level7file";
297 print FILE $l7ruleentry;
298 close FILE;
299 }
300 }
301 open( FILE, "< $level7file" ) or system("touch $level7file");close FILE;
65e8619a 302 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'})
399d32cb
CS
303{
304 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
305 @l7rules = <FILE>;
414e011d 306 close FILE;
399d32cb
CS
307 system("rm $level7file");
308 foreach $l7ruleentry (sort @l7rules)
309 {
310 @l7ruleline = split( /\;/, $l7ruleentry );
311 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
312 {$qossettings{'QIP'} = $l7ruleline[3];$qossettings{'DIP'} = $l7ruleline[4];}
313 else {
314 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
315 print FILE $l7ruleentry;
316 close FILE;
317 }
318 }
319 &level7rule;
320 open( FILE, "< $level7file" ) or system("touch $level7file");close FILE;
321 }
84cab473
MT
322
323############################################################################################################################
324############################################################################################################################
325
326if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
327{
328 if ( $qossettings{'QIP'} ne '' ) {
5a7491ff 329 if ((!&General::validipandmask($qossettings{'QIP'})) && (!&General::validip($qossettings{'QIP'}))) {
84cab473 330 $qossettings{'VALID'} = 'no';
5a7491ff 331 $message = $Lang::tr{'The source IP address is invalid.'};
84cab473
MT
332 }
333 }
334 if ( $qossettings{'DIP'} ne '' ) {
5a7491ff 335 if ((!&General::validipandmask($qossettings{'DIP'})) && (!&General::validip($qossettings{'DIP'}))) {
84cab473 336 $qossettings{'VALID'} = 'no';
5a7491ff 337 $message = $Lang::tr{'The destination IP address is invalid.'};
84cab473
MT
338 }
339 }
340 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
341 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
342 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
343 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
344 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
345 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
346 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
347 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
348 }
349 if ( $qossettings{'VALID'} eq 'yes' ) {
350 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
351 print FILE <<END
352$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
353END
354;
355 close FILE;
356 } else {
65e8619a 357 $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'};
84cab473 358 }
65e8619a 359} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'})
84cab473
MT
360{
361 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
362 @portrules = <FILE>;
363 close FILE;
364 open( FILE, "> $portfile" ) or die "Unable to read $portfile";
365 foreach $portruleentry (sort @portrules)
366 {
367 @portruleline = split( /\;/, $portruleentry );
368 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'}))
369 {
370 print FILE $portruleentry;
371 }
372 }
373 close FILE;
0b1641db 374 $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}.";
65e8619a 375} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'})
399d32cb
CS
376{
377 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
378 @portrules = <FILE>;
379 close FILE;
380 system("rm $portfile");
381 foreach $portruleentry (sort @portrules)
382 {
383 @portruleline = split( /\;/, $portruleentry );
384 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'}))
385 {$qossettings{'CLASS'}=$portruleline[0];$qossettings{'PPROT'}=$portruleline[2];$qossettings{'QIP'}=$portruleline[3];$qossettings{'QPORT'}=$portruleline[4];$qossettings{'DIP'}=$portruleline[5];$qossettings{'DPORT'}=$portruleline[6];}
386 else {
387 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
388 print FILE $portruleentry;
389 close FILE;
390 }
391 }
392 &portrule;
393 open( FILE, "< $portfile" ) or system("touch $portfile");close FILE;
394 }
84cab473
MT
395
396############################################################################################################################
397############################################################################################################################
398
e8babc92
MT
399if ($qossettings{'DOTOS'} eq $Lang::tr{'save'})
400{
401 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
402 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
403 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
404 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
405 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
406 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
407 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
408 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
409 }
410 open( FILE, ">> $tosfile" ) or die "Unable to write $tosfile";
411 print FILE <<END
412$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'};
413END
414;
415 close FILE;
fcd5cb6f 416}
e8babc92
MT
417elsif ($qossettings{'DOTOS'} eq 'Loeschen')
418{
419 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
420 @tosrules = <FILE>;
421 close FILE;
422 open( FILE, "> $tosfile" ) or die "Unable to read $tosfile";
423 foreach $tosruleentry (sort @tosrules)
424 {
425 @tosruleline = split( /\;/, $tosruleentry );
426 unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'}))
427 {
428 print FILE $tosruleentry;
429 }
430 }
431 close FILE;
0b1641db 432 $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}.";
65e8619a 433} elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'})
e8babc92
MT
434{
435 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
436 @tosrules = <FILE>;
437 close FILE;
438 open( FILE, "> $tosfile" ) or die "Unable to write $tosfile";
439 foreach $tosruleentry (sort @tosrules)
440 {
441 @tosruleline = split( /\;/, $tosruleentry );
442 if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) {
443 $qossettings{'DEVICE'} = $tosruleline[1];
444 $qossettings{'CLASS'} = $tosruleline[0];
445 $qossettings{'TOS'} = $tosruleline[2];
446 $qossettings{'EDIT'} = 'yes';
447 } else {
448 print FILE $tosruleentry;
449 }
450 }
451 close FILE;
452 &tosrule();
453 &Header::closebigbox();
454 &Header::closepage();
455 exit
456}
457
458############################################################################################################################
459############################################################################################################################
460
65e8619a 461if ($qossettings{'ACTION'} eq $Lang::tr{'start'})
904a41b9 462{
8b6a7fde
CS
463 $qossettings{'ENABLED'} = 'on';
464 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
cfd19520 465 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
cfd19520 466 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 467 system("logger -t ipfire 'QoS started'");
904a41b9 468}
65e8619a 469elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'})
904a41b9 470{
904a41b9
MT
471 $qossettings{'ENABLED'} = 'off';
472 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
b0a014b7
MT
473 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
474 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
475 system("logger -t ipfire 'QoS stopped'");
904a41b9 476}
65e8619a 477elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'})
84cab473
MT
478{
479 if ($qossettings{'ENABLED'} eq 'on'){
a7fb5630 480 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
cfd19520
MT
481 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
482 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 483 system("logger -t ipfire 'QoS restarted'");
84cab473
MT
484 }
485}
904a41b9
MT
486elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
487{
84cab473
MT
488 if ($qossettings{'DEF_INC_SPD'} eq '') {
489 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
490 }
491 if ($qossettings{'DEF_OUT_SPD'} eq '') {
492 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
493 }
904a41b9
MT
494 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
495}
33e1f48c
CS
496elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} )
497{
40d3e729
MT
498 if (($qossettings{'OUT_SPD'} > 0) && ($qossettings{'INC_SPD'} > 0)) {
499 my @UP;
500 #print "UP<br />";
501 for(my $i = 1; $i <= 10; $i++) {
502 $UP[$i] = int($qossettings{'OUT_SPD'} / $i );
503 #print $i."=".$UP[$i]." ";
504 }
505 my @DOWN;
506 #print "<br /><br />Down<br />";
507 for(my $i = 1; $i <= 20; $i++) {
508 $DOWN[$i] = int($qossettings{'INC_SPD'} / $i);
509 #print $i."=".$DOWN[$i]." ";
510 }
511 open( FILE, "> $classfile" ) or die "Unable to write $classfile";
512 print FILE <<END
20ffa7d1 513imq0;200;1;$DOWN[20];$DOWN[1];;;8;VoIP;
33e1f48c
CS
514imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
515imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
99a6f5f9 516imq0;210;6;1;$DOWN[1];;;0;Default;
33e1f48c 517imq0;220;7;1;$DOWN[1];;;1;P2P;
20ffa7d1
DW
518$qossettings{'RED_DEV'};101;1;$UP[10];$UP[1];;;8;ACKs;
519$qossettings{'RED_DEV'};102;2;$UP[10];$UP[1];;;8;VoIP;
520$qossettings{'RED_DEV'};103;4;$UP[10];$UP[1];;;2;VPN;
fcd5cb6f 521$qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic;
99a6f5f9 522$qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default;
fcd5cb6f 523$qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P;
33e1f48c
CS
524END
525;
40d3e729
MT
526 close FILE;
527 open( FILE, "> $level7file" ) or die "Unable to write $level7file";
528 print FILE <<END
fcd5cb6f 529102;$qossettings{'RED_DEV'};dns;;;
21067331 530102;$qossettings{'RED_DEV'};rtp;;;
fcd5cb6f
MT
531102;$qossettings{'RED_DEV'};skypetoskype;;;
532103;$qossettings{'RED_DEV'};ssh;;;
533103;$qossettings{'RED_DEV'};rdp;;;
534104;$qossettings{'RED_DEV'};http;;;
535104;$qossettings{'RED_DEV'};ssl;;;
536104;$qossettings{'RED_DEV'};pop3;;;
fcd5cb6f
MT
537120;$qossettings{'RED_DEV'};applejuice;;;
538120;$qossettings{'RED_DEV'};bittorrent;;;
21067331 539200;imq0;rtp;;;
33e1f48c
CS
540200;imq0;skypetoskype;;;
541203;imq0;ssh;;;
542203;imq0;rdp;;;
543204;imq0;http;;;
544204;imq0;pop3;;;
545204;imq0;ssl;;;
546220;imq0;applejuice;;;
547220;imq0;bittorrent;;;
33e1f48c
CS
548END
549;
40d3e729
MT
550 close FILE;
551 open( FILE, "> $portfile" ) or die "Unable to write $portfile";
552 print FILE <<END
fcd5cb6f
MT
553101;$qossettings{'RED_DEV'};icmp;;;;;
554102;$qossettings{'RED_DEV'};tcp;;;;53;
555102;$qossettings{'RED_DEV'};udp;;;;53;
556103;$qossettings{'RED_DEV'};esp;;;;;
8de8a508
AF
557103;$qossettings{'RED_DEV'};tcp;;1194;;;
558103;$qossettings{'RED_DEV'};udp;;1194;;;
fcd5cb6f 559103;$qossettings{'RED_DEV'};tcp;;;;1194;
99a6f5f9 560103;$qossettings{'RED_DEV'};udp;;;;1194;
fcd5cb6f
MT
561103;$qossettings{'RED_DEV'};udp;;4500;;4500;
562103;$qossettings{'RED_DEV'};udp;;500;;500;
563104;$qossettings{'RED_DEV'};tcp;;;;80;
33e1f48c
CS
564200;imq0;icmp;;;;;
565203;imq0;esp;;;;;
566203;imq0;tcp;;;;1194;
773362c5 567203;imq0;udp;;;;1194;
8de8a508
AF
568203;imq0;tcp;;1194;;;
569203;imq0;udp;;1194;;;
33e1f48c
CS
570203;imq0;udp;;4500;;4500;
571203;imq0;udp;;500;;500;
8de8a508 572204;imq0;tcp;;80;;;
33e1f48c
CS
573END
574;
40d3e729
MT
575 close FILE;
576 if ($qossettings{'DEF_INC_SPD'} eq '') {
577 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
578 }
579 if ($qossettings{'DEF_OUT_SPD'} eq '') {
580 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
581 }
582 $qossettings{'DEFCLASS_INC'} = "210";
583 $qossettings{'DEFCLASS_OUT'} = "110";
584 $qossettings{'ACK'} ="101";
585 $qossettings{'ENABLED'} = 'on';
586 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
587 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
40d3e729
MT
588 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
589 system("logger -t ipfire 'QoS started'");
590 } else {
591 $message = $Lang::tr{'qos enter bandwidths'};
33e1f48c 592 }
33e1f48c 593}
65e8619a 594elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} )
92b5fba4
MT
595{
596 &Header::openbox('100%', 'left', 'QoS Status');
597 if ($qossettings{'ENABLED'} eq 'on'){
598 my $output = "";
599 $output = `/usr/local/bin/qosctrl status`;
600 $output = &Header::cleanhtml($output,"y");
601 print "<pre>$output</pre>\n";
0b1641db 602 } else { print "$Lang::tr{'QoS not enabled'}"; }
92b5fba4
MT
603 &Header::closebox();
604 &Header::closebigbox();
605 &Header::closepage();
606 exit
607}
65e8619a 608elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} )
2db5d932
MT
609{
610 &parentclass();
611 &Header::closebigbox();
612 &Header::closepage();
613 exit
614}
65e8619a 615elsif ($qossettings{'ACTION'} eq $Lang::tr{'qos add subclass'})
414e011d
MT
616{
617 &subclass();
618 &Header::closebigbox();
619 &Header::closepage();
620 exit
621}
65e8619a 622elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'})
2db5d932 623{
0b1641db 624 &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'});
e8babc92
MT
625 print <<END
626 <table>
0b1641db 627 <tr><td align='center'>$Lang::tr{'Choose Rule'}
e8babc92 628 <tr><td align='center'>
65e8619a
JPT
629 <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' />
630 <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' />
631 <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' />
e8babc92
MT
632 </table>
633END
634;
635 &Header::closebox();
636 print <<END
637 <div id='l7rule' style='display: none'>
638END
639;
640 &level7rule();
641 print <<END
642 </div>
643 <div id='portrule' style='display: none'>
644END
645;
646 &portrule();
647 print <<END
648 </div>
649 <div id='tosrule' style='display: none'>
650END
651;
652 &tosrule();
653 print <<END
654 </div>
655END
656;
414e011d
MT
657 &Header::closebigbox();
658 &Header::closepage();
659 exit
660}
1dd22be2 661if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" )
904a41b9 662{
2db5d932
MT
663 &changebandwidth();
664 &Header::closebigbox();
665 &Header::closepage();
666 exit
667}
1dd22be2 668if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" )
2db5d932
MT
669{
670 &changedefclasses();
904a41b9
MT
671 &Header::closebigbox();
672 &Header::closepage();
673 exit
674}
675
676&General::readhash("${General::swroot}/qos/settings", \%qossettings);
677
678my $status = $Lang::tr{'stopped'};
84cab473 679my $statuscolor = '#993333';
904a41b9
MT
680if ( $qossettings{'ENABLED'} eq 'on' ) {
681 $status = $Lang::tr{'running'};
84cab473 682 $statuscolor = '#339933';
904a41b9
MT
683}
684
685if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
686 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
687}
688
689if ($errormessage) {
690 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
691 print "<class name='base'>$errormessage\n";
692 print "&nbsp;</class>\n";
693 &Header::closebox();
694}
695
414e011d
MT
696############################################################################################################################
697############################################################################################################################
698
5ef70cca 699&Header::openbox('100%', 'center', );
f013ab2b 700
904a41b9 701print <<END
f841744c
CS
702 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
703 <table width='66%'>
414e011d
MT
704END
705;
706 if ( $message ne "" ) {
5ef70cca 707 print "<tr><td colspan='2' align='center'><font color='red'>$message</font></tr>";
414e011d
MT
708 }
709 print <<END
5ef70cca
AM
710 <tr><td width='50%' align='left'><b>Quality of Service:</b></td>
711 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font></td></tr>
712 <tr>
713 <td colspan='2'><br></td>
714 </tr>
715 <tr><td width='100%' align='right' colspan='2'>
716 <input type='submit' name='ACTION' value="$Lang::tr{'start'}">
717 <input type='submit' name='ACTION' value="$Lang::tr{'stop'}">
718 <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" ></td></tr></table></form>
904a41b9
MT
719END
720;
721 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
722 print <<END
f841744c
CS
723 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
724 <table width='66%'>
904a41b9 725 <tr><td colspan='3'>&nbsp;
1b73b07e 726 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'}
1dd22be2 727 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' />
1b73b07e 728 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'}
f841744c 729 </table></form>
2db5d932
MT
730END
731;
732 }
733 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
734 print <<END
f841744c
CS
735 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
736 <table width='66%'>
f013ab2b 737 <tr><td colspan='3'><hr />
fcd5cb6f 738 <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'}
1dd22be2 739 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' />
1b73b07e
CS
740 <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'}
741 <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'}
f013ab2b 742 <tr><td colspan='3' width='100%'><hr />
7ccede9b 743 <tr><td colspan='3' width='100%' align='center'>
f841744c
CS
744 </table>
745 </form>
746 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
48d9bbba
SS
747 <table width='66%' border='0'>
748 <tr><td width='100%' align='center'>
749 <input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' />
750 <input type='submit' name='ACTION' value='$Lang::tr{'status'}' />
751 </td></tr></table>
414e011d 752 </form>
904a41b9
MT
753END
754;
755 }
904a41b9
MT
756&Header::closebox();
757
758if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
2db5d932 759 &changebandwidth();
2db5d932
MT
760 &Header::closebigbox();
761 &Header::closepage();
762 exit
763}
764
765if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
766 &changedefclasses();
767 &Header::closebigbox();
768 &Header::closepage();
769 exit
770}
771
be7534e3 772 &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}, $Lang::tr{'uplink'}");
a249ccd2 773 &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour");
bcad0fd0 774 &Header::closebox();
be7534e3 775 &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}, $Lang::tr{'downlink'}");
a249ccd2 776 &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour");
bcad0fd0 777 &Header::closebox();
f013ab2b
MT
778
779&showclasses($qossettings{'RED_DEV'});
780&showclasses($qossettings{'IMQ_DEV'});
2db5d932 781
904a41b9
MT
782&Header::closebigbox();
783&Header::closepage();
904a41b9 784
bcad0fd0
CS
785}
786
414e011d
MT
787############################################################################################################################
788############################################################################################################################
2db5d932
MT
789
790sub changedefclasses {
0b1641db 791 &Header::openbox('100%', 'center', $Lang::tr{'std classes'});
904a41b9 792 print <<END
2db5d932
MT
793 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
794 <table width='66%'>
0b1641db 795 <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'}
597005f5 796 <tr><td width='33%' align='right'>$Lang::tr{'download'}:<td width='33%' align='left'><select name='DEFCLASS_INC'>
2db5d932
MT
797END
798;
414e011d 799 for ( $c = 200 ; $c <= 220 ; $c++ )
2db5d932
MT
800 {
801 if ( $qossettings{'DEFCLASS_INC'} ne $c )
fcd5cb6f 802 { print "<option value='$c'>$c</option>\n"; }
414e011d 803 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
804 }
805 print <<END
806 </select><td width='33%' align='center'>&nbsp;
597005f5 807 <tr><td width='33%' align='right'>$Lang::tr{'upload'}:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
2db5d932
MT
808END
809;
414e011d 810 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
811 {
812 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
414e011d
MT
813 { print "<option value='$c'>$c</option>\n"; }
814 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
815 }
816 print <<END
817 </select><td width='33%' align='center'>&nbsp;
818 </table>
f013ab2b 819 <hr />
2db5d932 820 <table width='66%'>
0b1641db 821 <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'}
2db5d932
MT
822 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
823END
824;
414e011d 825 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
826 {
827 if ( $qossettings{'ACK'} ne $c )
414e011d
MT
828 { print "<option value='$c'>$c</option>\n"; }
829 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
830 }
831 print <<END
f013ab2b 832 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
2db5d932
MT
833 </table>
834 </form>
904a41b9
MT
835END
836;
3a70a538 837 &Header::closebox();
2db5d932
MT
838}
839
840sub changebandwidth {
0b1641db 841 &Header::openbox('100%', 'center', $Lang::tr{'bandwithsettings'});
2db5d932 842 if ($qossettings{'ENABLED'} eq 'on') {
0b1641db
CS
843 print "$Lang::tr{'bandwitherror'}";
844 print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>";
2db5d932
MT
845 } else {
846 print <<END
847 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b 848 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
2db5d932 849 <table width='66%'>
33e1f48c
CS
850 <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr>
851 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td>
852 <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td>
853 <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>
854 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td>
855 <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr>
2db5d932
MT
856 </table>
857 </form>
33e1f48c 858 <font color='red'>$Lang::tr{'template warning'}</font>
2db5d932
MT
859END
860;
861 }
904a41b9 862 &Header::closebox();
904a41b9
MT
863}
864
2db5d932 865sub parentclass {
0b1641db 866 &Header::openbox('100%', 'center', $Lang::tr{'parentclass'});
2db5d932
MT
867 print <<END
868 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
869 <table width='66%'>
414e011d
MT
870END
871;
872 if ( $message ne "" ) {
873 print "<tr><td colspan='3' align='center'>$message";
874 }
fcd5cb6f 875 if ( $qossettings{'EDIT'} eq 'yes' ) {
18322edf
CS
876 print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />";
877 print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />";
414e011d
MT
878 }
879 print <<END
0b1641db
CS
880 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
881 <tr><td width='33%' align='right'>$Lang::tr{'interface'}:
414e011d
MT
882 <td width='33%' align='left'>
883END
884;
fcd5cb6f 885 if ( $qossettings{'EDIT'} eq 'yes' ) {
414e011d
MT
886 print "<select name='DEVICE' disabled>";
887 } else {
888 print "<select name='DEVICE'>";
889 }
890 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
891 $qossettings{'RED_DEV_SEL'} = 'selected';
892 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
893 $qossettings{'IMQ_DEV_SEL'} = 'selected';
894 }
895 print <<END
18322edf
CS
896 <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
897 <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
2db5d932 898 <td width='33%' align='center'>&nbsp;
0b1641db 899 <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'>
2db5d932
MT
900END
901;
fcd5cb6f 902 if ( $qossettings{'EDIT'} eq 'yes' ) {
414e011d
MT
903 print "<select name='CLASS' disabled>";
904 } else {
905 print "<select name='CLASS'>";
906 }
2db5d932
MT
907 for ( $c = 100 ; $c <= 120 ; $c++ )
908 {
909 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
910 { print "<option value='$c'>$c</option>\n"; }
911 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
912 }
913 for ( $c = 200 ; $c <= 220 ; $c++ )
914 {
915 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
916 { print "<option value='$c'>$c</option>\n"; }
917 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
918 }
919 print <<END
920 </select>
921 <td width='33%' align='center'>&nbsp;
0b1641db 922 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
2db5d932
MT
923END
924;
925 for ( $c = 1 ; $c <= 7 ; $c++ )
926 {
927 if ( $qossettings{'PRIO'} ne $c )
414e011d
MT
928 { print "<option value='$c'>$c</option>\n"; }
929 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932 930 }
f013ab2b 931 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
2db5d932 932 print <<END
f013ab2b 933 </select>
2db5d932 934 <td width='33%' align='center'>&nbsp;
0b1641db 935 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
f013ab2b 936 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
2db5d932 937 <td width='33%' align='center'>&nbsp;
e3edceeb 938 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}&nbsp;<img src='/blob.gif' alt='*' />:
f013ab2b 939 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
2db5d932
MT
940 <td width='33%' align='center'>&nbsp;
941 <tr><td width='33%' align='right'>Burst:
f013ab2b 942 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932
MT
943 <td width='33%' align='center'>&nbsp;
944 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 945 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92 946 <td width='33%' align='center'>&nbsp;
bb2d1e47
MT
947END
948;
949 $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
950print <<END
e8babc92
MT
951 <tr><td width='33%' align='right'>TOS-Bit:
952 <td width='33%' align='left'><select name='TOS'>
bb2d1e47
MT
953 <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
954 <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
955 <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
956 <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
957 <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
f013ab2b
MT
958 <td width='33%' align='center'>&nbsp;
959 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
e3edceeb
LS
960 <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" />
961 <tr><td width='33%' align='right'><img src='/blob.gif' alt='*' />&nbsp;$Lang::tr{'required field'}
f013ab2b 962 <td width='33%' align='left'>&nbsp;
18322edf 963 <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
2db5d932
MT
964 </table></form>
965END
966;
967 &Header::closebox();
968}
904a41b9 969
414e011d 970sub subclass {
0b1641db 971 &Header::openbox('100%', 'center', $Lang::tr{'Subclass'});
2db5d932
MT
972 print <<END
973 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
974 <table width='66%'>
414e011d
MT
975END
976;
977 if ( $message ne "" ) {
978 print "<tr><td colspan='3' align='center'>$message";
979 }
980 print <<END
0b1641db
CS
981 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
982 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
983 <tr><td width='33%' align='right'>$Lang::tr{'Subclass'}:<td width='33%' align='left'><select name='SCLASS'>
414e011d
MT
984END
985;
986 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
987 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
988 for ( $c = 1000 ; $c <= 1020 ; $c++ )
989 {
990 if ( $qossettings{'SCLASS'} ne $c )
991 { print "<option value='$c'>$c</option>\n"; }
992 else { print "<option selected value='$c'>$c</option>\n"; }
993 }
994 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
995 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
996 for ( $c = 2000 ; $c <= 2020 ; $c++ )
997 {
998 if ( $qossettings{'SCLASS'} ne $c )
999 { print "<option value='$c'>$c</option>\n"; }
1000 else { print "<option selected value='$c'>$c</option>\n"; }
1001 }
1002 }
1003 print <<END
1004 </select>
1005 <td width='33%' align='center'>&nbsp;
0b1641db 1006 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
414e011d
MT
1007END
1008;
1009 for ( $c = 1 ; $c <= 7 ; $c++ )
1010 {
1011 if ( $qossettings{'PRIO'} ne $c )
1012 { print "<option value='$c'>$c</option>\n"; }
1013 else { print "<option selected value='$c'>$c</option>\n"; }
1014 }
1015 print <<END
1016 <td width='33%' align='center'>&nbsp;
0b1641db 1017 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
f013ab2b 1018 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
414e011d 1019 <td width='33%' align='center'>&nbsp;
0b1641db 1020 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
f013ab2b 1021 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
414e011d
MT
1022 <td width='33%' align='center'>&nbsp;
1023 <tr><td width='33%' align='right'>Burst:
f013ab2b 1024 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932 1025 <td width='33%' align='center'>&nbsp;
414e011d 1026 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 1027 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92
MT
1028 <td width='33%' align='center'>&nbsp;
1029 <tr><td width='33%' align='right'>TOS-Bit:
1030 <td width='33%' align='left'><select name='TOS'>
0b1641db
CS
1031 <option value='0'>$Lang::tr{'disabled'} (0)</option>
1032 <option value='8'>$Lang::tr{'min delay'} (8)</option>
1033 <option value='4'>$Lang::tr{'max throughput'} (4)</option>
1034 <option value='2'>$Lang::tr{'max reliability'} (2)</option>
1035 <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
f013ab2b
MT
1036 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
1037 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
18322edf 1038 <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
414e011d
MT
1039 </table></form>
1040END
1041;
1042 &Header::closebox();
1043}
1044
414e011d 1045sub level7rule {
0b1641db 1046 &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'});
414e011d
MT
1047 print <<END
1048 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1049 <table width='66%'>
1050END
1051;
1052 if ( $message ne "" ) {
1053 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1054 }
1055 print <<END
0b1641db
CS
1056 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1057 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1058 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
2db5d932
MT
1059 <td width='33%' align='left'><select name='L7PROT'>
1060END
1061;
1062 opendir( DIR, "/etc/l7-protocols/protocols" );
1063 foreach $direntry ( sort readdir(DIR) )
1064 {
1065 next if $direntry eq ".";
1066 next if $direntry eq "..";
1067 next if -d "/etc/l7-protocols/protocols/$direntry";
1068 @proto = split( /\./, $direntry );
1069 if ( $proto[0] eq $qossettings{'L7PROT'} ) {
fcd5cb6f 1070 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
2db5d932
MT
1071 } else {
1072 print "<option value='$proto[0]'>$proto[0]</option>\n";
1073 }
1074 }
1075 closedir DIR;
1076 print <<END
1077 </select><td width='33%' align='center'>&nbsp;
0b1641db 1078 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
5eee5a60 1079 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
2db5d932 1080 <td width='33%' align='center'>&nbsp;
0b1641db 1081 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
5eee5a60 1082 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
18322edf 1083 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' />
11bccc3f 1084 <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font>
2db5d932
MT
1085 </table></form>
1086END
1087;
1088 &Header::closebox();
414e011d
MT
1089}
1090
1091sub portrule {
0b1641db 1092 &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'});
414e011d
MT
1093 print <<END
1094 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1095 <table width='66%'>
0b1641db
CS
1096 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1097 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
414e011d
MT
1098 <td width='33%' align='left'><select name='PPROT'>
1099END
1100;
1101 open( FILE, "< /etc/protocols" );
1102 @proto = <FILE>;
1103 close FILE;
1104 foreach $direntry (sort @proto)
1105 {
1106 @tmpline = split( /\ /, $direntry );
1107 next if $tmpline[0] =~ "#";
1108 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
fcd5cb6f 1109 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
414e011d
MT
1110 } else {
1111 print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
1112 }
1113 }
1114 print <<END
1115 </select><td width='33%' align='center'>&nbsp;
0b1641db 1116 <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
ec3573fc 1117 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
414e011d 1118 <td width='33%' align='center'>&nbsp;
0b1641db 1119 <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
ec3573fc 1120 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
414e011d 1121 <td width='33%' align='center'>&nbsp;
0b1641db 1122 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
5eee5a60 1123 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
414e011d 1124 <td width='33%' align='center'>&nbsp;
0b1641db 1125 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
5eee5a60 1126 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
18322edf 1127 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
414e011d
MT
1128 </table></form>
1129END
1130;
1131 &Header::closebox();
1132}
1133
e8babc92 1134sub tosrule {
0b1641db 1135 &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'});
e8babc92 1136 if ($qossettings{'TOS'}) {
0b1641db 1137 $checked{$qossettings{'TOS'}} = "checked";
e8babc92
MT
1138 }
1139 print <<END
1140 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1141 <table width='66%'>
1142END
1143;
1144 if ( $message ne "" ) {
1145 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1146 }
1147 print <<END
0b1641db
CS
1148 <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1149 <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
1150 <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1151 <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1152 <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
da7e2665 1153 <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
18322edf 1154 <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'}' />
e8babc92
MT
1155 </table></form>
1156END
1157;
1158 &Header::closebox();
1159}
1160
414e011d 1161sub showclasses {
f013ab2b 1162 $qossettings{'DEV'} = shift;
414e011d
MT
1163 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1164 @classes = <FILE>;
1165 close FILE;
1166 if (@classes) {
1167 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1168 @subclasses = <FILE>;
1169 close FILE;
f013ab2b
MT
1170 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
1171 @l7rules = <FILE>;
1172 close FILE;
1173 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
1174 @tosrules = <FILE>;
1175 close FILE;
1176 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
1177 @portrules = <FILE>;
1178 close FILE;
414e011d
MT
1179 foreach $classentry (sort @classes)
1180 {
1181 @classline = split( /\;/, $classentry );
f013ab2b 1182 if ( $classline[0] eq $qossettings{'DEV'} )
414e011d 1183 {
be7534e3 1184 &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]");
414e011d 1185 print <<END
f013ab2b 1186 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1 1187 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
0b1641db
CS
1188 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
1189 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
1190 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
1191 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
f2fdd0c1
CS
1192 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1193 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1194 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
0b1641db 1195 <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
f2fdd0c1
CS
1196 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1197 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1198 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1199 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1200 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1201 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1202 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1203 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1204 <td align='right' bgcolor='$color{'color22'}'>
649fd295 1205 <table border='0'><tr>
649fd295 1206 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1207 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1208 <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
f8aa0679 1209 <input type='image' alt='$Lang::tr{'add subclass'}' title='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
649fd295
MT
1210 </form>
1211 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1212 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1213 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
f8aa0679 1214 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
649fd295
MT
1215 </form>
1216 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1217 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1218 <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
f8aa0679 1219 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
649fd295
MT
1220 </form>
1221 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1222 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1223 <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
f8aa0679 1224 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
649fd295
MT
1225 </form>
1226 </table>
f013ab2b
MT
1227 </td>
1228 <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
1229 <td align='center' colspan='6'> $classline[8]
1230 <td align='right'><b>Queueing:</b> $classline[9]
414e011d
MT
1231END
1232;
f013ab2b
MT
1233
1234 if (@l7rules) {
1235 foreach $l7ruleentry (sort @l7rules)
1236 {
1237 @l7ruleline = split( /\;/, $l7ruleentry );
1238 if ( $l7ruleline[0] eq $classline[1] )
1239 {
1240 print <<END
0b1641db 1241 <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
f013ab2b
MT
1242 <td align='center' colspan='6'>$l7ruleline[2]
1243 <td align='right' >
649fd295 1244 <table border='0'><tr>
649fd295 1245 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1246 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1247 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
65e8619a 1248 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
f8aa0679 1249 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
649fd295
MT
1250 </form>
1251 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1252 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1253 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
65e8619a 1254 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
f8aa0679 1255 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
649fd295
MT
1256 </form>
1257 </table>
414e011d
MT
1258END
1259;
f013ab2b
MT
1260 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1261 print <<END
1262 <tr><td align='center'>&nbsp;
0b1641db
CS
1263 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3]
1264 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4]
84cab473
MT
1265END
1266;
f013ab2b
MT
1267 }
1268
414e011d 1269
84cab473
MT
1270END
1271;
f013ab2b
MT
1272 }
1273 }
1274 }
1275
1276
1277 if (@portrules) {
1278 foreach $portruleentry (sort @portrules)
1279 {
1280 @portruleline = split( /\;/, $portruleentry );
1281 if ( $portruleline[0] eq $classline[1] )
1282 {
1283 print <<END
0b1641db 1284 <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
f013ab2b
MT
1285 <td align='center'>($portruleline[2])
1286 <td align='center' colspan='2'>
84cab473
MT
1287END
1288;
f013ab2b
MT
1289 if ($portruleline[4]) {
1290 print <<END
99a6f5f9 1291 <i>$Lang::tr{'source port'}:</i> $portruleline[4]
84cab473
MT
1292END
1293;
f013ab2b
MT
1294 }
1295 print "<td align='center' colspan='2'>";
1296 if ($portruleline[6]) {
1297 print <<END
99a6f5f9 1298 <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
84cab473
MT
1299END
1300;
f013ab2b
MT
1301 }
1302 print <<END
1303 <td>&nbsp;
1304 <td align='right'>
8b0883b8
MT
1305 <table border='0'><tr>
1306 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1307 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1308 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1309 <input type='hidden' name='QIP' value='$portruleline[3]' />
1310 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1311 <input type='hidden' name='DIP' value='$portruleline[5]' />
1312 <input type='hidden' name='DPORT' value='$portruleline[6]' />
65e8619a 1313 <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
f8aa0679 1314 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
8b0883b8
MT
1315 </form>
1316 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1317 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1318 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1319 <input type='hidden' name='QIP' value='$portruleline[3]' />
1320 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1321 <input type='hidden' name='DIP' value='$portruleline[5]' />
1322 <input type='hidden' name='DPORT' value='$portruleline[6]' />
65e8619a 1323 <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
f8aa0679 1324 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
8b0883b8
MT
1325 </form>
1326 </table>
414e011d
MT
1327END
1328;
f013ab2b
MT
1329 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1330 print <<END
1331 <tr><td align='center'>&nbsp;
0b1641db
CS
1332 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3]
1333 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5]
84cab473
MT
1334END
1335;
f013ab2b
MT
1336 }
1337 }
1338 }
1339 }
414e011d 1340
f013ab2b
MT
1341 if (@tosrules) {
1342 foreach $tosruleentry (sort @tosrules)
1343 {
1344 @tosruleline = split( /\;/, $tosruleentry );
1345 if ( $tosruleline[0] eq $classline[1] )
1346 {
1347 print <<END
1348 <tr><td align='right' colspan='2'>
1349 <b>TOS Bit matches:</b>
1350 <td colspan='6' align='center'>
e8babc92
MT
1351END
1352;
f013ab2b 1353 if ( $tosruleline[2] eq "8") {
0b1641db 1354 print "$Lang::tr{'min delay'}\n";
f013ab2b 1355 } elsif ( $tosruleline[2] eq "4") {
0b1641db 1356 print "$Lang::tr{'max throughput'}\n";
f013ab2b 1357 } elsif ( $tosruleline[2] eq "2") {
0b1641db 1358 print "$Lang::tr{'max reliability'}\n";
f013ab2b 1359 } elsif ( $tosruleline[2] eq "1") {
0b1641db 1360 print "$Lang::tr{'min costs'}\n";
f013ab2b
MT
1361 } else { print "&nbsp;\n"; }
1362
1363 print <<END
1364 ($tosruleline[2])
1365 <td align='right'>
1366 <table border='0'><tr>
1367 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1368 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1369 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1370 <input type='hidden' name='TOS' value='$tosruleline[2]' />
65e8619a 1371 <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
f8aa0679 1372 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
f013ab2b
MT
1373 </form>
1374 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1375 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1376 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1377 <input type='hidden' name='TOS' value='$tosruleline[2]' />
65e8619a 1378 <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
f8aa0679 1379 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
f013ab2b
MT
1380 </form>
1381 </table>
e8babc92
MT
1382END
1383;
f013ab2b
MT
1384 }
1385 }
1386 }
e8babc92
MT
1387END
1388;
f013ab2b
MT
1389 foreach $subclassentry (sort @subclasses)
1390 {
1391 @subclassline = split( /\;/, $subclassentry );
1392 if ( $subclassline[1] eq $classline[1] ) {
1393 print <<END
0b1641db 1394 <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
f013ab2b
MT
1395 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1396 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1397 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1398 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1399 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1400 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1401 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1402 <td align='right' bgcolor='#FAFAFA'>
1403 <table border='0'><tr>
1404 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1405 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1406 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
f8aa0679 1407 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
f013ab2b
MT
1408 </form>
1409 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1410 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1411 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
f8aa0679 1412 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
f013ab2b
MT
1413 </form>
1414 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1415 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1416 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
f8aa0679 1417 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
f013ab2b
MT
1418 </form>
1419 </table>
e8babc92
MT
1420END
1421;
f013ab2b
MT
1422 }
1423 }
1424 print <<END
1425 </table>
e8babc92
MT
1426END
1427;
18322edf 1428 &Header::closebox();
e8babc92 1429 }
18322edf
CS
1430 }
1431 }
e8babc92 1432 }
414e011d
MT
1433sub validminbwdth {
1434 if ( $qossettings{'VALID'} eq 'yes' ) {
1435 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1436 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1437 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1438 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1439 }
363fb6af 1440 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
414e011d 1441 $qossettings{'VALID'} = 'no';
0b1641db 1442 $message = "$Lang::tr{'false min bandwith'}";
414e011d
MT
1443 }
1444 $qossettings{'SPD'} = '';
1445 }
1446}
84cab473 1447
414e011d
MT
1448sub validmaxbwdth {
1449 if ( $qossettings{'VALID'} eq 'yes' ) {
1450 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1451 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1452 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1453 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1454 }
1455 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1456 $qossettings{'VALID'} = 'no';
0b1641db 1457 $message = "$Lang::tr{'false max bandwith'}";
414e011d
MT
1458 }
1459 $qossettings{'SPD'} = '';
1460 }
1461}
1462
1463sub validclass {
1464 if ( $qossettings{'VALID'} eq 'yes' ) {
1465 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1466 if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1467 $qossettings{'VALID'} = 'no';
0b1641db 1468 $message = "$Lang::tr{'false classnumber'}";
414e011d
MT
1469 }
1470 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1471 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1472 $qossettings{'VALID'} = 'no';
65e8619a 1473 $message = "$Lang::tr{'The class number does not match the specified interface.'}";
414e011d
MT
1474 }
1475 }
1476 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1477 @tmp = <FILE>;
1478 close FILE;
1479 foreach $classentry (sort @tmp)
1480 {
1481 @tmpline = split( /\;/, $classentry );
1482 if ( $tmpline[1] eq $qossettings{'CLASS'} )
1483 {
1484 $qossettings{'VALID'} = 'no';
0b1641db 1485 $message = "$Lang::tr{'false classnumber'}";
414e011d
MT
1486 last
1487 }
1488 }
1489 }
1490}
84cab473 1491
414e011d
MT
1492sub validsubclass {
1493 if ( $qossettings{'VALID'} eq 'yes' ) {
1494 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1495 @tmp = <FILE>;
1496 close FILE;
1497 foreach $subclassentry (sort @tmp)
1498 {
1499 @tmpline = split( /\;/, $subclassentry );
1500 if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1501 {
1502 $qossettings{'VALID'} = 'no';
0b1641db 1503 $message = "$Lang::tr{'class in use'}";
414e011d
MT
1504 last
1505 }
1506 }
1507 }
84cab473 1508}