QOS: IP-Addresses can now be simple IP-Address or IP-Address and subnet
[people/teissler/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 '' ) {
5eee5a60
AM
254 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?)$/){
255 if (! &General::validipandmask($qossettings{'QIP'}) ) {
256 $qossettings{'VALID'} = 'no';
257 $message = $Lang::tr{'The source IP address is invalid.'};
258 }
259 }else{
260 if ( &General::validip($qossettings{'QIP'}) ) {
261 $qossettings{'VALID'} = 'no';
262 $message = $Lang::tr{'The source IP address is invalid.'};
263 }
414e011d
MT
264 }
265 }
266 if ( $qossettings{'DIP'} ne '' ) {
5eee5a60
AM
267 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?)$/){
268 if ( &General::validipandmask($qossettings{'DIP'}) ) {
269 $qossettings{'VALID'} = 'no';
270 $message = $Lang::tr{'The destination IP address is invalid.'};
271 }
272 }else{
273 if ( &General::validip($qossettings{'DIP'}) ) {
274 $qossettings{'VALID'} = 'no';
275 $message = $Lang::tr{'The destination IP address is invalid.'};
276 }
414e011d
MT
277 }
278 }
279 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
280 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
281 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
282 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
283 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
284 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
285 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
286 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
287 }
288 if ( $qossettings{'VALID'} eq 'yes' ) {
289 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
290 print FILE <<END
291$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
292END
293;
294 close FILE;
295 } else {
65e8619a 296 $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'};
414e011d 297 }
65e8619a 298} elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'})
414e011d
MT
299{
300 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
301 @l7rules = <FILE>;
302 close FILE;
399d32cb 303 system("rm $level7file");
414e011d
MT
304 foreach $l7ruleentry (sort @l7rules)
305 {
306 @l7ruleline = split( /\;/, $l7ruleentry );
399d32cb 307 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
65e8619a 308 {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";}
399d32cb
CS
309 else
310 { open( FILE, ">> $level7file" ) or die "Unable to read $level7file";
311 print FILE $l7ruleentry;
312 close FILE;
313 }
314 }
315 open( FILE, "< $level7file" ) or system("touch $level7file");close FILE;
65e8619a 316 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'})
399d32cb
CS
317{
318 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
319 @l7rules = <FILE>;
414e011d 320 close FILE;
399d32cb
CS
321 system("rm $level7file");
322 foreach $l7ruleentry (sort @l7rules)
323 {
324 @l7ruleline = split( /\;/, $l7ruleentry );
325 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
326 {$qossettings{'QIP'} = $l7ruleline[3];$qossettings{'DIP'} = $l7ruleline[4];}
327 else {
328 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
329 print FILE $l7ruleentry;
330 close FILE;
331 }
332 }
333 &level7rule;
334 open( FILE, "< $level7file" ) or system("touch $level7file");close FILE;
335 }
84cab473
MT
336
337############################################################################################################################
338############################################################################################################################
339
340if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
341{
342 if ( $qossettings{'QIP'} ne '' ) {
fcd5cb6f 343 unless ( &General::validip($qossettings{'QIP'}) ) {
84cab473 344 $qossettings{'VALID'} = 'no';
65e8619a 345 $message = "$Lang::tr{'The source IP address is invalid.'}";
84cab473
MT
346 }
347 }
348 if ( $qossettings{'DIP'} ne '' ) {
fcd5cb6f 349 unless ( &General::validip($qossettings{'DIP'}) ) {
84cab473 350 $qossettings{'VALID'} = 'no';
65e8619a 351 $message = "$Lang::tr{'The destination IP address is invalid.'}";
84cab473
MT
352 }
353 }
354 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
355 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
356 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
357 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
358 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
359 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
360 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
361 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
362 }
363 if ( $qossettings{'VALID'} eq 'yes' ) {
364 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
365 print FILE <<END
366$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
367END
368;
369 close FILE;
370 } else {
65e8619a 371 $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'};
84cab473 372 }
65e8619a 373} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'})
84cab473
MT
374{
375 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
376 @portrules = <FILE>;
377 close FILE;
378 open( FILE, "> $portfile" ) or die "Unable to read $portfile";
379 foreach $portruleentry (sort @portrules)
380 {
381 @portruleline = split( /\;/, $portruleentry );
382 unless ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'}))
383 {
384 print FILE $portruleentry;
385 }
386 }
387 close FILE;
0b1641db 388 $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}.";
65e8619a 389} elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'})
399d32cb
CS
390{
391 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
392 @portrules = <FILE>;
393 close FILE;
394 system("rm $portfile");
395 foreach $portruleentry (sort @portrules)
396 {
397 @portruleline = split( /\;/, $portruleentry );
398 if ( ($portruleline[0] eq $qossettings{'CLASS'}) && ($portruleline[2] eq $qossettings{'PPROT'}) && ($portruleline[3] eq $qossettings{'QIP'}) && ($portruleline[4] eq $qossettings{'QPORT'}) && ($portruleline[5] eq $qossettings{'DIP'}) && ($portruleline[6] eq $qossettings{'DPORT'}))
399 {$qossettings{'CLASS'}=$portruleline[0];$qossettings{'PPROT'}=$portruleline[2];$qossettings{'QIP'}=$portruleline[3];$qossettings{'QPORT'}=$portruleline[4];$qossettings{'DIP'}=$portruleline[5];$qossettings{'DPORT'}=$portruleline[6];}
400 else {
401 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
402 print FILE $portruleentry;
403 close FILE;
404 }
405 }
406 &portrule;
407 open( FILE, "< $portfile" ) or system("touch $portfile");close FILE;
408 }
84cab473
MT
409
410############################################################################################################################
411############################################################################################################################
412
e8babc92
MT
413if ($qossettings{'DOTOS'} eq $Lang::tr{'save'})
414{
415 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
416 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
417 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
418 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
419 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
420 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
421 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
422 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
423 }
424 open( FILE, ">> $tosfile" ) or die "Unable to write $tosfile";
425 print FILE <<END
426$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'};
427END
428;
429 close FILE;
fcd5cb6f 430}
e8babc92
MT
431elsif ($qossettings{'DOTOS'} eq 'Loeschen')
432{
433 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
434 @tosrules = <FILE>;
435 close FILE;
436 open( FILE, "> $tosfile" ) or die "Unable to read $tosfile";
437 foreach $tosruleentry (sort @tosrules)
438 {
439 @tosruleline = split( /\;/, $tosruleentry );
440 unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'}))
441 {
442 print FILE $tosruleentry;
443 }
444 }
445 close FILE;
0b1641db 446 $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}.";
65e8619a 447} elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'})
e8babc92
MT
448{
449 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
450 @tosrules = <FILE>;
451 close FILE;
452 open( FILE, "> $tosfile" ) or die "Unable to write $tosfile";
453 foreach $tosruleentry (sort @tosrules)
454 {
455 @tosruleline = split( /\;/, $tosruleentry );
456 if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) {
457 $qossettings{'DEVICE'} = $tosruleline[1];
458 $qossettings{'CLASS'} = $tosruleline[0];
459 $qossettings{'TOS'} = $tosruleline[2];
460 $qossettings{'EDIT'} = 'yes';
461 } else {
462 print FILE $tosruleentry;
463 }
464 }
465 close FILE;
466 &tosrule();
467 &Header::closebigbox();
468 &Header::closepage();
469 exit
470}
471
472############################################################################################################################
473############################################################################################################################
474
65e8619a 475if ($qossettings{'ACTION'} eq $Lang::tr{'start'})
904a41b9 476{
8b6a7fde
CS
477 $qossettings{'ENABLED'} = 'on';
478 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
cfd19520 479 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
9833e7d8 480 system("/usr/bin/touch /var/ipfire/qos/enable");
cfd19520 481 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 482 system("logger -t ipfire 'QoS started'");
904a41b9 483}
65e8619a 484elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'})
904a41b9 485{
a7fb5630 486 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
84cab473 487 unlink "/var/ipfire/qos/bin/qos.sh";
904a41b9 488 unlink "/var/ipfire/qos/enable";
a7fb5630 489 system("logger -t ipfire 'QoS stopped'");
904a41b9
MT
490 $qossettings{'ENABLED'} = 'off';
491 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
492}
65e8619a 493elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'})
84cab473
MT
494{
495 if ($qossettings{'ENABLED'} eq 'on'){
a7fb5630 496 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
cfd19520
MT
497 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
498 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 499 system("logger -t ipfire 'QoS restarted'");
84cab473
MT
500 }
501}
904a41b9
MT
502elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
503{
84cab473
MT
504 if ($qossettings{'DEF_INC_SPD'} eq '') {
505 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
506 }
507 if ($qossettings{'DEF_OUT_SPD'} eq '') {
508 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
509 }
904a41b9
MT
510 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
511}
33e1f48c
CS
512elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} )
513{
40d3e729
MT
514 if (($qossettings{'OUT_SPD'} > 0) && ($qossettings{'INC_SPD'} > 0)) {
515 my @UP;
516 #print "UP<br />";
517 for(my $i = 1; $i <= 10; $i++) {
518 $UP[$i] = int($qossettings{'OUT_SPD'} / $i );
519 #print $i."=".$UP[$i]." ";
520 }
521 my @DOWN;
522 #print "<br /><br />Down<br />";
523 for(my $i = 1; $i <= 20; $i++) {
524 $DOWN[$i] = int($qossettings{'INC_SPD'} / $i);
525 #print $i."=".$DOWN[$i]." ";
526 }
527 open( FILE, "> $classfile" ) or die "Unable to write $classfile";
528 print FILE <<END
33e1f48c
CS
529imq0;200;1;$DOWN[10];$DOWN[1];;;8;VoIP;
530imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
531imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
99a6f5f9 532imq0;210;6;1;$DOWN[1];;;0;Default;
33e1f48c 533imq0;220;7;1;$DOWN[1];;;1;P2P;
99a6f5f9 534$qossettings{'RED_DEV'};101;1;$UP[2];$UP[1];;;8;ACKs;
fcd5cb6f
MT
535$qossettings{'RED_DEV'};102;2;$UP[3];$UP[1];;;8;VoIP;
536$qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic;
99a6f5f9 537$qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default;
fcd5cb6f
MT
538$qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P;
539$qossettings{'RED_DEV'};103;4;$UP[2];$UP[1];;;2;VPN;
33e1f48c
CS
540END
541;
40d3e729
MT
542 close FILE;
543 open( FILE, "> $level7file" ) or die "Unable to write $level7file";
544 print FILE <<END
fcd5cb6f 545102;$qossettings{'RED_DEV'};dns;;;
21067331 546102;$qossettings{'RED_DEV'};rtp;;;
fcd5cb6f
MT
547102;$qossettings{'RED_DEV'};skypetoskype;;;
548103;$qossettings{'RED_DEV'};ssh;;;
549103;$qossettings{'RED_DEV'};rdp;;;
550104;$qossettings{'RED_DEV'};http;;;
551104;$qossettings{'RED_DEV'};ssl;;;
552104;$qossettings{'RED_DEV'};pop3;;;
fcd5cb6f
MT
553120;$qossettings{'RED_DEV'};applejuice;;;
554120;$qossettings{'RED_DEV'};bittorrent;;;
21067331 555200;imq0;rtp;;;
33e1f48c
CS
556200;imq0;skypetoskype;;;
557203;imq0;ssh;;;
558203;imq0;rdp;;;
559204;imq0;http;;;
560204;imq0;pop3;;;
561204;imq0;ssl;;;
562220;imq0;applejuice;;;
563220;imq0;bittorrent;;;
33e1f48c
CS
564END
565;
40d3e729
MT
566 close FILE;
567 open( FILE, "> $portfile" ) or die "Unable to write $portfile";
568 print FILE <<END
fcd5cb6f
MT
569101;$qossettings{'RED_DEV'};icmp;;;;;
570102;$qossettings{'RED_DEV'};tcp;;;;53;
571102;$qossettings{'RED_DEV'};udp;;;;53;
572103;$qossettings{'RED_DEV'};esp;;;;;
8de8a508
AF
573103;$qossettings{'RED_DEV'};tcp;;1194;;;
574103;$qossettings{'RED_DEV'};udp;;1194;;;
fcd5cb6f 575103;$qossettings{'RED_DEV'};tcp;;;;1194;
99a6f5f9 576103;$qossettings{'RED_DEV'};udp;;;;1194;
fcd5cb6f
MT
577103;$qossettings{'RED_DEV'};udp;;4500;;4500;
578103;$qossettings{'RED_DEV'};udp;;500;;500;
579104;$qossettings{'RED_DEV'};tcp;;;;80;
33e1f48c
CS
580200;imq0;icmp;;;;;
581203;imq0;esp;;;;;
582203;imq0;tcp;;;;1194;
773362c5 583203;imq0;udp;;;;1194;
8de8a508
AF
584203;imq0;tcp;;1194;;;
585203;imq0;udp;;1194;;;
33e1f48c
CS
586203;imq0;udp;;4500;;4500;
587203;imq0;udp;;500;;500;
8de8a508 588204;imq0;tcp;;80;;;
33e1f48c
CS
589END
590;
40d3e729
MT
591 close FILE;
592 if ($qossettings{'DEF_INC_SPD'} eq '') {
593 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
594 }
595 if ($qossettings{'DEF_OUT_SPD'} eq '') {
596 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
597 }
598 $qossettings{'DEFCLASS_INC'} = "210";
599 $qossettings{'DEFCLASS_OUT'} = "110";
600 $qossettings{'ACK'} ="101";
601 $qossettings{'ENABLED'} = 'on';
602 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
603 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
604 system("/usr/bin/touch /var/ipfire/qos/enable");
605 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
606 system("logger -t ipfire 'QoS started'");
607 } else {
608 $message = $Lang::tr{'qos enter bandwidths'};
33e1f48c 609 }
33e1f48c 610}
65e8619a 611elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} )
92b5fba4
MT
612{
613 &Header::openbox('100%', 'left', 'QoS Status');
614 if ($qossettings{'ENABLED'} eq 'on'){
615 my $output = "";
616 $output = `/usr/local/bin/qosctrl status`;
617 $output = &Header::cleanhtml($output,"y");
618 print "<pre>$output</pre>\n";
0b1641db 619 } else { print "$Lang::tr{'QoS not enabled'}"; }
92b5fba4
MT
620 &Header::closebox();
621 &Header::closebigbox();
622 &Header::closepage();
623 exit
624}
65e8619a 625elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} )
2db5d932
MT
626{
627 &parentclass();
628 &Header::closebigbox();
629 &Header::closepage();
630 exit
631}
65e8619a 632elsif ($qossettings{'ACTION'} eq $Lang::tr{'qos add subclass'})
414e011d
MT
633{
634 &subclass();
635 &Header::closebigbox();
636 &Header::closepage();
637 exit
638}
65e8619a 639elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'})
2db5d932 640{
0b1641db 641 &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'});
e8babc92
MT
642 print <<END
643 <table>
0b1641db 644 <tr><td align='center'>$Lang::tr{'Choose Rule'}
e8babc92 645 <tr><td align='center'>
65e8619a
JPT
646 <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' />
647 <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' />
648 <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' />
e8babc92
MT
649 </table>
650END
651;
652 &Header::closebox();
653 print <<END
654 <div id='l7rule' style='display: none'>
655END
656;
657 &level7rule();
658 print <<END
659 </div>
660 <div id='portrule' style='display: none'>
661END
662;
663 &portrule();
664 print <<END
665 </div>
666 <div id='tosrule' style='display: none'>
667END
668;
669 &tosrule();
670 print <<END
671 </div>
672END
673;
414e011d
MT
674 &Header::closebigbox();
675 &Header::closepage();
676 exit
677}
1dd22be2 678if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" )
904a41b9 679{
2db5d932
MT
680 &changebandwidth();
681 &Header::closebigbox();
682 &Header::closepage();
683 exit
684}
1dd22be2 685if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" )
2db5d932
MT
686{
687 &changedefclasses();
904a41b9
MT
688 &Header::closebigbox();
689 &Header::closepage();
690 exit
691}
692
693&General::readhash("${General::swroot}/qos/settings", \%qossettings);
694
695my $status = $Lang::tr{'stopped'};
84cab473 696my $statuscolor = '#993333';
904a41b9
MT
697if ( $qossettings{'ENABLED'} eq 'on' ) {
698 $status = $Lang::tr{'running'};
84cab473 699 $statuscolor = '#339933';
904a41b9
MT
700}
701
702if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
703 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
704}
705
706if ($errormessage) {
707 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
708 print "<class name='base'>$errormessage\n";
709 print "&nbsp;</class>\n";
710 &Header::closebox();
711}
712
414e011d
MT
713############################################################################################################################
714############################################################################################################################
715
5ef70cca 716&Header::openbox('100%', 'center', );
f013ab2b 717
904a41b9 718print <<END
f841744c
CS
719 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
720 <table width='66%'>
414e011d
MT
721END
722;
723 if ( $message ne "" ) {
5ef70cca 724 print "<tr><td colspan='2' align='center'><font color='red'>$message</font></tr>";
414e011d
MT
725 }
726 print <<END
5ef70cca
AM
727 <tr><td width='50%' align='left'><b>Quality of Service:</b></td>
728 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font></td></tr>
729 <tr>
730 <td colspan='2'><br></td>
731 </tr>
732 <tr><td width='100%' align='right' colspan='2'>
733 <input type='submit' name='ACTION' value="$Lang::tr{'start'}">
734 <input type='submit' name='ACTION' value="$Lang::tr{'stop'}">
735 <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" ></td></tr></table></form>
904a41b9
MT
736END
737;
738 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
739 print <<END
f841744c
CS
740 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
741 <table width='66%'>
904a41b9 742 <tr><td colspan='3'>&nbsp;
1b73b07e 743 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'}
1dd22be2 744 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' />
1b73b07e 745 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'}
f841744c 746 </table></form>
2db5d932
MT
747END
748;
749 }
750 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
751 print <<END
f841744c
CS
752 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
753 <table width='66%'>
f013ab2b 754 <tr><td colspan='3'><hr />
fcd5cb6f 755 <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'}
1dd22be2 756 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' />
1b73b07e
CS
757 <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'}
758 <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'}
f013ab2b 759 <tr><td colspan='3' width='100%'><hr />
7ccede9b 760 <tr><td colspan='3' width='100%' align='center'>
f841744c
CS
761 </table>
762 </form>
763 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
48d9bbba
SS
764 <table width='66%' border='0'>
765 <tr><td width='100%' align='center'>
766 <input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' />
767 <input type='submit' name='ACTION' value='$Lang::tr{'status'}' />
768 </td></tr></table>
414e011d 769 </form>
904a41b9
MT
770END
771;
772 }
904a41b9
MT
773&Header::closebox();
774
775if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
2db5d932 776 &changebandwidth();
2db5d932
MT
777 &Header::closebigbox();
778 &Header::closepage();
779 exit
780}
781
782if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
783 &changedefclasses();
784 &Header::closebigbox();
785 &Header::closepage();
786 exit
787}
788
be7534e3 789 &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}, $Lang::tr{'uplink'}");
bcad0fd0
CS
790 &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour","325");
791 &Header::closebox();
be7534e3 792 &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}, $Lang::tr{'downlink'}");
bcad0fd0
CS
793 &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325");
794 &Header::closebox();
f013ab2b
MT
795
796&showclasses($qossettings{'RED_DEV'});
797&showclasses($qossettings{'IMQ_DEV'});
2db5d932 798
904a41b9
MT
799&Header::closebigbox();
800&Header::closepage();
904a41b9 801
bcad0fd0
CS
802}
803
414e011d
MT
804############################################################################################################################
805############################################################################################################################
2db5d932
MT
806
807sub changedefclasses {
0b1641db 808 &Header::openbox('100%', 'center', $Lang::tr{'std classes'});
904a41b9 809 print <<END
2db5d932
MT
810 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
811 <table width='66%'>
0b1641db 812 <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'}
597005f5 813 <tr><td width='33%' align='right'>$Lang::tr{'download'}:<td width='33%' align='left'><select name='DEFCLASS_INC'>
2db5d932
MT
814END
815;
414e011d 816 for ( $c = 200 ; $c <= 220 ; $c++ )
2db5d932
MT
817 {
818 if ( $qossettings{'DEFCLASS_INC'} ne $c )
fcd5cb6f 819 { print "<option value='$c'>$c</option>\n"; }
414e011d 820 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
821 }
822 print <<END
823 </select><td width='33%' align='center'>&nbsp;
597005f5 824 <tr><td width='33%' align='right'>$Lang::tr{'upload'}:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
2db5d932
MT
825END
826;
414e011d 827 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
828 {
829 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
414e011d
MT
830 { print "<option value='$c'>$c</option>\n"; }
831 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
832 }
833 print <<END
834 </select><td width='33%' align='center'>&nbsp;
835 </table>
f013ab2b 836 <hr />
2db5d932 837 <table width='66%'>
0b1641db 838 <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'}
2db5d932
MT
839 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
840END
841;
414e011d 842 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
843 {
844 if ( $qossettings{'ACK'} ne $c )
414e011d
MT
845 { print "<option value='$c'>$c</option>\n"; }
846 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
847 }
848 print <<END
f013ab2b 849 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
2db5d932
MT
850 </table>
851 </form>
904a41b9
MT
852END
853;
3a70a538 854 &Header::closebox();
2db5d932
MT
855}
856
857sub changebandwidth {
0b1641db 858 &Header::openbox('100%', 'center', $Lang::tr{'bandwithsettings'});
2db5d932 859 if ($qossettings{'ENABLED'} eq 'on') {
0b1641db
CS
860 print "$Lang::tr{'bandwitherror'}";
861 print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>";
2db5d932
MT
862 } else {
863 print <<END
864 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b 865 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
2db5d932 866 <table width='66%'>
33e1f48c
CS
867 <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr>
868 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td>
869 <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td>
870 <td width='20%' align='center' rowspan='2'><input type='submit' name='ACTION' value="$Lang::tr{'template'}" /><br /><input type='submit' name='ACTION' value="$Lang::tr{'save'}" /><br /><input type='reset' name='ACTION' value="$Lang::tr{'reset'}" /></td></tr>
871 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td>
872 <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr>
2db5d932
MT
873 </table>
874 </form>
33e1f48c 875 <font color='red'>$Lang::tr{'template warning'}</font>
2db5d932
MT
876END
877;
878 }
904a41b9 879 &Header::closebox();
904a41b9
MT
880}
881
2db5d932 882sub parentclass {
0b1641db 883 &Header::openbox('100%', 'center', $Lang::tr{'parentclass'});
2db5d932
MT
884 print <<END
885 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
886 <table width='66%'>
414e011d
MT
887END
888;
889 if ( $message ne "" ) {
890 print "<tr><td colspan='3' align='center'>$message";
891 }
fcd5cb6f 892 if ( $qossettings{'EDIT'} eq 'yes' ) {
18322edf
CS
893 print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />";
894 print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />";
414e011d
MT
895 }
896 print <<END
0b1641db
CS
897 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
898 <tr><td width='33%' align='right'>$Lang::tr{'interface'}:
414e011d
MT
899 <td width='33%' align='left'>
900END
901;
fcd5cb6f 902 if ( $qossettings{'EDIT'} eq 'yes' ) {
414e011d
MT
903 print "<select name='DEVICE' disabled>";
904 } else {
905 print "<select name='DEVICE'>";
906 }
907 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
908 $qossettings{'RED_DEV_SEL'} = 'selected';
909 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
910 $qossettings{'IMQ_DEV_SEL'} = 'selected';
911 }
912 print <<END
18322edf
CS
913 <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
914 <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
2db5d932 915 <td width='33%' align='center'>&nbsp;
0b1641db 916 <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'>
2db5d932
MT
917END
918;
fcd5cb6f 919 if ( $qossettings{'EDIT'} eq 'yes' ) {
414e011d
MT
920 print "<select name='CLASS' disabled>";
921 } else {
922 print "<select name='CLASS'>";
923 }
2db5d932
MT
924 for ( $c = 100 ; $c <= 120 ; $c++ )
925 {
926 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
927 { print "<option value='$c'>$c</option>\n"; }
928 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
929 }
930 for ( $c = 200 ; $c <= 220 ; $c++ )
931 {
932 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
933 { print "<option value='$c'>$c</option>\n"; }
934 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
935 }
936 print <<END
937 </select>
938 <td width='33%' align='center'>&nbsp;
0b1641db 939 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
2db5d932
MT
940END
941;
942 for ( $c = 1 ; $c <= 7 ; $c++ )
943 {
944 if ( $qossettings{'PRIO'} ne $c )
414e011d
MT
945 { print "<option value='$c'>$c</option>\n"; }
946 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932 947 }
f013ab2b 948 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
2db5d932 949 print <<END
f013ab2b 950 </select>
2db5d932 951 <td width='33%' align='center'>&nbsp;
0b1641db 952 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
f013ab2b 953 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
2db5d932 954 <td width='33%' align='center'>&nbsp;
0b1641db 955 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
f013ab2b 956 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
2db5d932
MT
957 <td width='33%' align='center'>&nbsp;
958 <tr><td width='33%' align='right'>Burst:
f013ab2b 959 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932
MT
960 <td width='33%' align='center'>&nbsp;
961 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 962 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92 963 <td width='33%' align='center'>&nbsp;
bb2d1e47
MT
964END
965;
966 $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
967print <<END
e8babc92
MT
968 <tr><td width='33%' align='right'>TOS-Bit:
969 <td width='33%' align='left'><select name='TOS'>
bb2d1e47
MT
970 <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
971 <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
972 <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
973 <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
974 <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
f013ab2b
MT
975 <td width='33%' align='center'>&nbsp;
976 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
f841744c 977 <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> <img alt="" alt='blob' src='/blob.gif' />
f013ab2b
MT
978 <tr><td width='33%' align='right'>&nbsp;
979 <td width='33%' align='left'>&nbsp;
18322edf 980 <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
2db5d932
MT
981 </table></form>
982END
983;
984 &Header::closebox();
985}
904a41b9 986
414e011d 987sub subclass {
0b1641db 988 &Header::openbox('100%', 'center', $Lang::tr{'Subclass'});
2db5d932
MT
989 print <<END
990 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
991 <table width='66%'>
414e011d
MT
992END
993;
994 if ( $message ne "" ) {
995 print "<tr><td colspan='3' align='center'>$message";
996 }
997 print <<END
0b1641db
CS
998 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
999 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1000 <tr><td width='33%' align='right'>$Lang::tr{'Subclass'}:<td width='33%' align='left'><select name='SCLASS'>
414e011d
MT
1001END
1002;
1003 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
1004 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
1005 for ( $c = 1000 ; $c <= 1020 ; $c++ )
1006 {
1007 if ( $qossettings{'SCLASS'} ne $c )
1008 { print "<option value='$c'>$c</option>\n"; }
1009 else { print "<option selected value='$c'>$c</option>\n"; }
1010 }
1011 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
1012 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
1013 for ( $c = 2000 ; $c <= 2020 ; $c++ )
1014 {
1015 if ( $qossettings{'SCLASS'} ne $c )
1016 { print "<option value='$c'>$c</option>\n"; }
1017 else { print "<option selected value='$c'>$c</option>\n"; }
1018 }
1019 }
1020 print <<END
1021 </select>
1022 <td width='33%' align='center'>&nbsp;
0b1641db 1023 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
414e011d
MT
1024END
1025;
1026 for ( $c = 1 ; $c <= 7 ; $c++ )
1027 {
1028 if ( $qossettings{'PRIO'} ne $c )
1029 { print "<option value='$c'>$c</option>\n"; }
1030 else { print "<option selected value='$c'>$c</option>\n"; }
1031 }
1032 print <<END
1033 <td width='33%' align='center'>&nbsp;
0b1641db 1034 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
f013ab2b 1035 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
414e011d 1036 <td width='33%' align='center'>&nbsp;
0b1641db 1037 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
f013ab2b 1038 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
414e011d
MT
1039 <td width='33%' align='center'>&nbsp;
1040 <tr><td width='33%' align='right'>Burst:
f013ab2b 1041 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932 1042 <td width='33%' align='center'>&nbsp;
414e011d 1043 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 1044 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92
MT
1045 <td width='33%' align='center'>&nbsp;
1046 <tr><td width='33%' align='right'>TOS-Bit:
1047 <td width='33%' align='left'><select name='TOS'>
0b1641db
CS
1048 <option value='0'>$Lang::tr{'disabled'} (0)</option>
1049 <option value='8'>$Lang::tr{'min delay'} (8)</option>
1050 <option value='4'>$Lang::tr{'max throughput'} (4)</option>
1051 <option value='2'>$Lang::tr{'max reliability'} (2)</option>
1052 <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
f013ab2b
MT
1053 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
1054 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
18322edf 1055 <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
414e011d
MT
1056 </table></form>
1057END
1058;
1059 &Header::closebox();
1060}
1061
414e011d 1062sub level7rule {
0b1641db 1063 &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'});
414e011d
MT
1064 print <<END
1065 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1066 <table width='66%'>
1067END
1068;
1069 if ( $message ne "" ) {
1070 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1071 }
1072 print <<END
0b1641db
CS
1073 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1074 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1075 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
2db5d932
MT
1076 <td width='33%' align='left'><select name='L7PROT'>
1077END
1078;
1079 opendir( DIR, "/etc/l7-protocols/protocols" );
1080 foreach $direntry ( sort readdir(DIR) )
1081 {
1082 next if $direntry eq ".";
1083 next if $direntry eq "..";
1084 next if -d "/etc/l7-protocols/protocols/$direntry";
1085 @proto = split( /\./, $direntry );
1086 if ( $proto[0] eq $qossettings{'L7PROT'} ) {
fcd5cb6f 1087 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
2db5d932
MT
1088 } else {
1089 print "<option value='$proto[0]'>$proto[0]</option>\n";
1090 }
1091 }
1092 closedir DIR;
1093 print <<END
1094 </select><td width='33%' align='center'>&nbsp;
0b1641db 1095 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
5eee5a60 1096 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
2db5d932 1097 <td width='33%' align='center'>&nbsp;
0b1641db 1098 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
5eee5a60 1099 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
18322edf 1100 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' />
11bccc3f 1101 <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font>
2db5d932
MT
1102 </table></form>
1103END
1104;
1105 &Header::closebox();
414e011d
MT
1106}
1107
1108sub portrule {
0b1641db 1109 &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'});
414e011d
MT
1110 print <<END
1111 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1112 <table width='66%'>
0b1641db
CS
1113 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1114 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
414e011d
MT
1115 <td width='33%' align='left'><select name='PPROT'>
1116END
1117;
1118 open( FILE, "< /etc/protocols" );
1119 @proto = <FILE>;
1120 close FILE;
1121 foreach $direntry (sort @proto)
1122 {
1123 @tmpline = split( /\ /, $direntry );
1124 next if $tmpline[0] =~ "#";
1125 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
fcd5cb6f 1126 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
414e011d
MT
1127 } else {
1128 print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
1129 }
1130 }
1131 print <<END
1132 </select><td width='33%' align='center'>&nbsp;
0b1641db 1133 <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
ec3573fc 1134 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
414e011d 1135 <td width='33%' align='center'>&nbsp;
0b1641db 1136 <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
ec3573fc 1137 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
414e011d 1138 <td width='33%' align='center'>&nbsp;
0b1641db 1139 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
5eee5a60 1140 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
414e011d 1141 <td width='33%' align='center'>&nbsp;
0b1641db 1142 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
5eee5a60 1143 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
18322edf 1144 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
414e011d
MT
1145 </table></form>
1146END
1147;
1148 &Header::closebox();
1149}
1150
e8babc92 1151sub tosrule {
0b1641db 1152 &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'});
e8babc92 1153 if ($qossettings{'TOS'}) {
0b1641db 1154 $checked{$qossettings{'TOS'}} = "checked";
e8babc92
MT
1155 }
1156 print <<END
1157 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1158 <table width='66%'>
1159END
1160;
1161 if ( $message ne "" ) {
1162 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1163 }
1164 print <<END
0b1641db
CS
1165 <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1166 <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
1167 <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1168 <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1169 <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
da7e2665 1170 <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
18322edf 1171 <tr><td width='100%' align='right' colspan='2'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOTOS' value='$Lang::tr{'save'}' />
e8babc92
MT
1172 </table></form>
1173END
1174;
1175 &Header::closebox();
1176}
1177
414e011d 1178sub showclasses {
f013ab2b 1179 $qossettings{'DEV'} = shift;
414e011d
MT
1180 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1181 @classes = <FILE>;
1182 close FILE;
1183 if (@classes) {
1184 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1185 @subclasses = <FILE>;
1186 close FILE;
f013ab2b
MT
1187 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
1188 @l7rules = <FILE>;
1189 close FILE;
1190 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
1191 @tosrules = <FILE>;
1192 close FILE;
1193 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
1194 @portrules = <FILE>;
1195 close FILE;
414e011d
MT
1196 foreach $classentry (sort @classes)
1197 {
1198 @classline = split( /\;/, $classentry );
f013ab2b 1199 if ( $classline[0] eq $qossettings{'DEV'} )
414e011d 1200 {
be7534e3 1201 &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]");
414e011d 1202 print <<END
f013ab2b 1203 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1 1204 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
0b1641db
CS
1205 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
1206 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
1207 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
1208 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
f2fdd0c1
CS
1209 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1210 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1211 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
0b1641db 1212 <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
f2fdd0c1
CS
1213 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1214 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1215 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1216 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1217 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1218 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1219 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1220 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1221 <td align='right' bgcolor='$color{'color22'}'>
649fd295 1222 <table border='0'><tr>
649fd295 1223 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1224 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1225 <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
f8aa0679 1226 <input type='image' alt='$Lang::tr{'add subclass'}' title='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
649fd295
MT
1227 </form>
1228 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1229 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1230 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
f8aa0679 1231 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
649fd295
MT
1232 </form>
1233 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1234 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1235 <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
f8aa0679 1236 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
649fd295
MT
1237 </form>
1238 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1239 <input type='hidden' name='CLASS' value='$classline[1]' />
65e8619a 1240 <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
f8aa0679 1241 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
649fd295
MT
1242 </form>
1243 </table>
f013ab2b
MT
1244 </td>
1245 <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
1246 <td align='center' colspan='6'> $classline[8]
1247 <td align='right'><b>Queueing:</b> $classline[9]
414e011d
MT
1248END
1249;
f013ab2b
MT
1250
1251 if (@l7rules) {
1252 foreach $l7ruleentry (sort @l7rules)
1253 {
1254 @l7ruleline = split( /\;/, $l7ruleentry );
1255 if ( $l7ruleline[0] eq $classline[1] )
1256 {
1257 print <<END
0b1641db 1258 <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
f013ab2b
MT
1259 <td align='center' colspan='6'>$l7ruleline[2]
1260 <td align='right' >
649fd295 1261 <table border='0'><tr>
649fd295 1262 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1263 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1264 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
65e8619a 1265 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
f8aa0679 1266 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
649fd295
MT
1267 </form>
1268 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1269 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1270 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
65e8619a 1271 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
f8aa0679 1272 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
649fd295
MT
1273 </form>
1274 </table>
414e011d
MT
1275END
1276;
f013ab2b
MT
1277 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1278 print <<END
1279 <tr><td align='center'>&nbsp;
0b1641db
CS
1280 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3]
1281 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4]
84cab473
MT
1282END
1283;
f013ab2b
MT
1284 }
1285
414e011d 1286
84cab473
MT
1287END
1288;
f013ab2b
MT
1289 }
1290 }
1291 }
1292
1293
1294 if (@portrules) {
1295 foreach $portruleentry (sort @portrules)
1296 {
1297 @portruleline = split( /\;/, $portruleentry );
1298 if ( $portruleline[0] eq $classline[1] )
1299 {
1300 print <<END
0b1641db 1301 <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
f013ab2b
MT
1302 <td align='center'>($portruleline[2])
1303 <td align='center' colspan='2'>
84cab473
MT
1304END
1305;
f013ab2b
MT
1306 if ($portruleline[4]) {
1307 print <<END
99a6f5f9 1308 <i>$Lang::tr{'source port'}:</i> $portruleline[4]
84cab473
MT
1309END
1310;
f013ab2b
MT
1311 }
1312 print "<td align='center' colspan='2'>";
1313 if ($portruleline[6]) {
1314 print <<END
99a6f5f9 1315 <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
84cab473
MT
1316END
1317;
f013ab2b
MT
1318 }
1319 print <<END
1320 <td>&nbsp;
1321 <td align='right'>
8b0883b8
MT
1322 <table border='0'><tr>
1323 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1324 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1325 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1326 <input type='hidden' name='QIP' value='$portruleline[3]' />
1327 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1328 <input type='hidden' name='DIP' value='$portruleline[5]' />
1329 <input type='hidden' name='DPORT' value='$portruleline[6]' />
65e8619a 1330 <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
f8aa0679 1331 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
8b0883b8
MT
1332 </form>
1333 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1334 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1335 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1336 <input type='hidden' name='QIP' value='$portruleline[3]' />
1337 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1338 <input type='hidden' name='DIP' value='$portruleline[5]' />
1339 <input type='hidden' name='DPORT' value='$portruleline[6]' />
65e8619a 1340 <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
f8aa0679 1341 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
8b0883b8
MT
1342 </form>
1343 </table>
414e011d
MT
1344END
1345;
f013ab2b
MT
1346 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1347 print <<END
1348 <tr><td align='center'>&nbsp;
0b1641db
CS
1349 <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3]
1350 <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5]
84cab473
MT
1351END
1352;
f013ab2b
MT
1353 }
1354 }
1355 }
1356 }
414e011d 1357
f013ab2b
MT
1358 if (@tosrules) {
1359 foreach $tosruleentry (sort @tosrules)
1360 {
1361 @tosruleline = split( /\;/, $tosruleentry );
1362 if ( $tosruleline[0] eq $classline[1] )
1363 {
1364 print <<END
1365 <tr><td align='right' colspan='2'>
1366 <b>TOS Bit matches:</b>
1367 <td colspan='6' align='center'>
e8babc92
MT
1368END
1369;
f013ab2b 1370 if ( $tosruleline[2] eq "8") {
0b1641db 1371 print "$Lang::tr{'min delay'}\n";
f013ab2b 1372 } elsif ( $tosruleline[2] eq "4") {
0b1641db 1373 print "$Lang::tr{'max throughput'}\n";
f013ab2b 1374 } elsif ( $tosruleline[2] eq "2") {
0b1641db 1375 print "$Lang::tr{'max reliability'}\n";
f013ab2b 1376 } elsif ( $tosruleline[2] eq "1") {
0b1641db 1377 print "$Lang::tr{'min costs'}\n";
f013ab2b
MT
1378 } else { print "&nbsp;\n"; }
1379
1380 print <<END
1381 ($tosruleline[2])
1382 <td align='right'>
1383 <table border='0'><tr>
1384 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1385 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1386 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1387 <input type='hidden' name='TOS' value='$tosruleline[2]' />
65e8619a 1388 <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
f8aa0679 1389 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
f013ab2b
MT
1390 </form>
1391 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1392 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1393 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1394 <input type='hidden' name='TOS' value='$tosruleline[2]' />
65e8619a 1395 <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
f8aa0679 1396 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
f013ab2b
MT
1397 </form>
1398 </table>
e8babc92
MT
1399END
1400;
f013ab2b
MT
1401 }
1402 }
1403 }
e8babc92
MT
1404END
1405;
f013ab2b
MT
1406 foreach $subclassentry (sort @subclasses)
1407 {
1408 @subclassline = split( /\;/, $subclassentry );
1409 if ( $subclassline[1] eq $classline[1] ) {
1410 print <<END
0b1641db 1411 <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
f013ab2b
MT
1412 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1413 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1414 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1415 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1416 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1417 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1418 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1419 <td align='right' bgcolor='#FAFAFA'>
1420 <table border='0'><tr>
1421 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1422 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1423 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
f8aa0679 1424 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
f013ab2b
MT
1425 </form>
1426 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1427 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1428 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
f8aa0679 1429 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
f013ab2b
MT
1430 </form>
1431 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c 1432 <input type='hidden' name='CLASS' value='$subclassline[2]' />
65e8619a 1433 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
f8aa0679 1434 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
f013ab2b
MT
1435 </form>
1436 </table>
e8babc92
MT
1437END
1438;
f013ab2b
MT
1439 }
1440 }
1441 print <<END
1442 </table>
e8babc92
MT
1443END
1444;
18322edf 1445 &Header::closebox();
e8babc92 1446 }
18322edf
CS
1447 }
1448 }
e8babc92 1449 }
414e011d
MT
1450sub validminbwdth {
1451 if ( $qossettings{'VALID'} eq 'yes' ) {
1452 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1453 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1454 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1455 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1456 }
363fb6af 1457 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
414e011d 1458 $qossettings{'VALID'} = 'no';
0b1641db 1459 $message = "$Lang::tr{'false min bandwith'}";
414e011d
MT
1460 }
1461 $qossettings{'SPD'} = '';
1462 }
1463}
84cab473 1464
414e011d
MT
1465sub validmaxbwdth {
1466 if ( $qossettings{'VALID'} eq 'yes' ) {
1467 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1468 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1469 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1470 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1471 }
1472 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1473 $qossettings{'VALID'} = 'no';
0b1641db 1474 $message = "$Lang::tr{'false max bandwith'}";
414e011d
MT
1475 }
1476 $qossettings{'SPD'} = '';
1477 }
1478}
1479
1480sub validclass {
1481 if ( $qossettings{'VALID'} eq 'yes' ) {
1482 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1483 if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1484 $qossettings{'VALID'} = 'no';
0b1641db 1485 $message = "$Lang::tr{'false classnumber'}";
414e011d
MT
1486 }
1487 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1488 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1489 $qossettings{'VALID'} = 'no';
65e8619a 1490 $message = "$Lang::tr{'The class number does not match the specified interface.'}";
414e011d
MT
1491 }
1492 }
1493 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1494 @tmp = <FILE>;
1495 close FILE;
1496 foreach $classentry (sort @tmp)
1497 {
1498 @tmpline = split( /\;/, $classentry );
1499 if ( $tmpline[1] eq $qossettings{'CLASS'} )
1500 {
1501 $qossettings{'VALID'} = 'no';
0b1641db 1502 $message = "$Lang::tr{'false classnumber'}";
414e011d
MT
1503 last
1504 }
1505 }
1506 }
1507}
84cab473 1508
414e011d
MT
1509sub validsubclass {
1510 if ( $qossettings{'VALID'} eq 'yes' ) {
1511 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1512 @tmp = <FILE>;
1513 close FILE;
1514 foreach $subclassentry (sort @tmp)
1515 {
1516 @tmpline = split( /\;/, $subclassentry );
1517 if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1518 {
1519 $qossettings{'VALID'} = 'no';
0b1641db 1520 $message = "$Lang::tr{'class in use'}";
414e011d
MT
1521 last
1522 }
1523 }
1524 }
84cab473 1525}