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
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
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 ###############################################################################
21
22 use RRDs;
23 use strict;
24 # enable only the following on debugging purpose
25 # use warnings;
26 # use CGI::Carp 'fatalsToBrowser';
27
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
32
33 my %qossettings = ();
34 my %checked = ();
35 my %netsettings = ();
36 my $message = '';
37 my $errormessage = "";
38 my $c = "";
39 my $direntry = "";
40 my $classentry = "";
41 my $subclassentry = "";
42 my $l7ruleentry = "";
43 my $portruleentry = "";
44 my $tosruleentry = "";
45 my @tmp = ();
46 my @classes = ();
47 my @subclasses = ();
48 my @l7rules = ();
49 my @portrules = ();
50 my @tosrules = ();
51 my @tmpline = ();
52 my @classline = ();
53 my @subclassline = ();
54 my @l7ruleline = ();
55 my @portruleline = ();
56 my @tosruleline = ();
57 my @proto = ();
58 my %selected= ();
59 my @checked = ();
60 my $classfile = "/var/ipfire/qos/classes";
61 my $subclassfile = "/var/ipfire/qos/subclasses";
62 my $level7file = "/var/ipfire/qos/level7config";
63 my $portfile = "/var/ipfire/qos/portconfig";
64 my $tosfile = "/var/ipfire/qos/tosconfig";
65 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
66
67 $qossettings{'ENABLED'} = 'off';
68 $qossettings{'EDIT'} = 'no';
69 $qossettings{'OUT_SPD'} = '';
70 $qossettings{'INC_SPD'} = '';
71 $qossettings{'DEF_OUT_SPD'} = '';
72 $qossettings{'DEF_INC_SPD'} = '';
73 $qossettings{'DEFCLASS_INC'} = '';
74 $qossettings{'DEFCLASS_OUT'} = '';
75 $qossettings{'ACK'} = '';
76 $qossettings{'RED_DEV'} = 'ppp0';
77 $qossettings{'IMQ_DEV'} = 'imq0';
78 $qossettings{'VALID'} = 'yes';
79 ### Values that have to be initialized
80 $qossettings{'ACTION'} = '';
81 $qossettings{'ACTIONDEF'} = '';
82 $qossettings{'ACTIONBW'} = '';
83 $qossettings{'RED_DEV_SEL'} = '';
84 $qossettings{'IMQ_DEV_SEL'} = '';
85 $qossettings{'PRIO'} = '';
86 $qossettings{'SPD'} = '';
87 $qossettings{'CLASS'} = '';
88 $qossettings{'SCLASS'} = '';
89 $qossettings{'QPORT'} = '';
90 $qossettings{'DPORT'} = '';
91 $qossettings{'QIP'} = '';
92 $qossettings{'DIP'} = '';
93 $qossettings{'PPROT'} = '';
94 $qossettings{'L7PROT'} = '';
95 $qossettings{'DEVICE'} = '';
96 $qossettings{'MINBWDTH'} = '';
97 $qossettings{'MAXBWDTH'} = '';
98 $qossettings{'BURST'} = '';
99 $qossettings{'CBURST'} = '';
100 $qossettings{'DOCLASS'} = '';
101 $qossettings{'DOSCLASS'} = '';
102 $qossettings{'DOLEVEL7'} = '';
103 $qossettings{'DOPORT'} = '';
104 $qossettings{'CLASS'} = '';
105 $qossettings{'CLASSPRFX'} = '';
106 $qossettings{'DEV'} = '';
107 $qossettings{'TOS'} = '';
108
109
110 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
111 &Header::getcgihash(\%qossettings);
112
113 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
114
115 my %color = ();
116 my %mainsettings = ();
117 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
118 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
119
120 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
121 $querry[0] = '' unless defined $querry[0];
122 $querry[1] = 'hour' unless defined $querry[1];
123
124 if ( $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);
133
134 ############################################################################################################################
135 ############################################################################################################################
136
137 if ($qossettings{'DOCLASS'} eq $Lang::tr{'save'})
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
145 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};$qossettings{'REMARK'};
146 END
147 ;
148 close FILE;
149 } else {
150 $qossettings{'ACTION'} = $Lang::tr{'parentclass add'};
151 }
152 }
153 elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'edit'})
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];
171 $qossettings{'TOS'} = $classline[7];
172 $qossettings{'REMARK'} = $classline[8];
173 $qossettings{'EDIT'} = 'yes';
174 }
175 }
176 close FILE;
177 &parentclass();
178 &Header::closebigbox();
179 &Header::closepage();
180 exit
181 }
182 elsif ($qossettings{'DOCLASS'} eq $Lang::tr{'delete'})
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;
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;
210 $message = "$Lang::tr{'Class'} $qossettings{'CLASS'} $Lang::tr{'Class was deleted'}";
211 }
212
213 ############################################################################################################################
214 ############################################################################################################################
215
216 if ($qossettings{'DOSCLASS'} eq $Lang::tr{'save'})
217 {
218 &validsubclass();
219 &validminbwdth();
220 if ( $qossettings{'VALID'} eq 'yes' ) {
221 open( FILE, ">> $subclassfile" ) or die "Unable to write $subclassfile";
222 print FILE <<END
223 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};$qossettings{'TOS'};
224 END
225 ;
226 close FILE;
227 } else {
228 $qossettings{'ACTION'} = $Lang::tr{'qos add subclass'};
229 }
230 } elsif ($qossettings{'DOSCLASS'} eq $Lang::tr{'delete'})
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;
245 $message = "$Lang::tr{'Subclass'} $qossettings{'CLASS'} $Lang::tr{'was deleted'}.";
246 }
247
248 ############################################################################################################################
249 ############################################################################################################################
250
251 if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'})
252 {
253 if ( $qossettings{'QIP'} ne '' ) {
254 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?)$/){
255 if (! &General::validipandmask($qossettings{'QIP'}) ) {
256 $qossettings{'VALID'} = 'no';
257 $message = $Lang::tr{'The source IP address is invalid.'};
258 }
259 }else{
260 if ( &General::validip($qossettings{'QIP'}) ) {
261 $qossettings{'VALID'} = 'no';
262 $message = $Lang::tr{'The source IP address is invalid.'};
263 }
264 }
265 }
266 if ( $qossettings{'DIP'} ne '' ) {
267 if ($qossettings{'QIP'} =~ /^(.*?)\/(.*?)$/){
268 if ( &General::validipandmask($qossettings{'DIP'}) ) {
269 $qossettings{'VALID'} = 'no';
270 $message = $Lang::tr{'The destination IP address is invalid.'};
271 }
272 }else{
273 if ( &General::validip($qossettings{'DIP'}) ) {
274 $qossettings{'VALID'} = 'no';
275 $message = $Lang::tr{'The destination IP address is invalid.'};
276 }
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'};
292 END
293 ;
294 close FILE;
295 } else {
296 $qossettings{'ACTION'} = $Lang::tr{'Add Level7 rule'};
297 }
298 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'delete'})
299 {
300 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
301 @l7rules = <FILE>;
302 close FILE;
303 system("rm $level7file");
304 foreach $l7ruleentry (sort @l7rules)
305 {
306 @l7ruleline = split( /\;/, $l7ruleentry );
307 if ( ($l7ruleline[0] eq $qossettings{'CLASS'}) && ($l7ruleline[2] eq $qossettings{'L7PROT'}))
308 {$message = "$Lang::tr{'Level7 Rule'} ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) $Lang::tr{'was deleted'}.";}
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;
316 } elsif ($qossettings{'DOLEVEL7'} eq $Lang::tr{'edit'})
317 {
318 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
319 @l7rules = <FILE>;
320 close FILE;
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 }
336
337 ############################################################################################################################
338 ############################################################################################################################
339
340 if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
341 {
342 if ( $qossettings{'QIP'} ne '' ) {
343 unless ( &General::validip($qossettings{'QIP'}) ) {
344 $qossettings{'VALID'} = 'no';
345 $message = "$Lang::tr{'The source IP address is invalid.'}";
346 }
347 }
348 if ( $qossettings{'DIP'} ne '' ) {
349 unless ( &General::validip($qossettings{'DIP'}) ) {
350 $qossettings{'VALID'} = 'no';
351 $message = "$Lang::tr{'The destination IP address is invalid.'}";
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'};
367 END
368 ;
369 close FILE;
370 } else {
371 $qossettings{'ACTION'} = $Lang::tr{'Add Port Rule'};
372 }
373 } elsif ($qossettings{'DOPORT'} eq $Lang::tr{'delete'})
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;
388 $message = "$Lang::tr{'Port Rule'} ($qossettings{'CLASS'} - $qossettings{'PPROT'}) $Lang::tr{'was deleted'}.";
389 } elsif ($qossettings{'DOPORT'} eq $Lang::tr{'edit'})
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 }
409
410 ############################################################################################################################
411 ############################################################################################################################
412
413 if ($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'};
427 END
428 ;
429 close FILE;
430 }
431 elsif ($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;
446 $message = "$Lang::tr{'TOS Rule'} ($qossettings{'CLASS'} - $qossettings{'TOS'}) $Lang::tr{'was deleted'}.";
447 } elsif ($qossettings{'DOTOS'} eq $Lang::tr{'edit'})
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
475 if ($qossettings{'ACTION'} eq $Lang::tr{'start'})
476 {
477 $qossettings{'ENABLED'} = 'on';
478 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
479 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
480 system("/usr/bin/touch /var/ipfire/qos/enable");
481 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
482 system("logger -t ipfire 'QoS started'");
483 }
484 elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'})
485 {
486 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
487 unlink "/var/ipfire/qos/bin/qos.sh";
488 unlink "/var/ipfire/qos/enable";
489 system("logger -t ipfire 'QoS stopped'");
490 $qossettings{'ENABLED'} = 'off';
491 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
492 }
493 elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'})
494 {
495 if ($qossettings{'ENABLED'} eq 'on'){
496 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
497 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
498 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
499 system("logger -t ipfire 'QoS restarted'");
500 }
501 }
502 elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
503 {
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 }
510 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
511 }
512 elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} )
513 {
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
529 imq0;200;1;$DOWN[10];$DOWN[1];;;8;VoIP;
530 imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
531 imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
532 imq0;210;6;1;$DOWN[1];;;0;Default;
533 imq0;220;7;1;$DOWN[1];;;1;P2P;
534 $qossettings{'RED_DEV'};101;1;$UP[2];$UP[1];;;8;ACKs;
535 $qossettings{'RED_DEV'};102;2;$UP[3];$UP[1];;;8;VoIP;
536 $qossettings{'RED_DEV'};104;5;$UP[10];$UP[1];;;8;Webtraffic;
537 $qossettings{'RED_DEV'};110;6;1;$UP[1];;;0;Default;
538 $qossettings{'RED_DEV'};120;7;1;$UP[1];;;1;P2P;
539 $qossettings{'RED_DEV'};103;4;$UP[2];$UP[1];;;2;VPN;
540 END
541 ;
542 close FILE;
543 open( FILE, "> $level7file" ) or die "Unable to write $level7file";
544 print FILE <<END
545 102;$qossettings{'RED_DEV'};dns;;;
546 102;$qossettings{'RED_DEV'};rtp;;;
547 102;$qossettings{'RED_DEV'};skypetoskype;;;
548 103;$qossettings{'RED_DEV'};ssh;;;
549 103;$qossettings{'RED_DEV'};rdp;;;
550 104;$qossettings{'RED_DEV'};http;;;
551 104;$qossettings{'RED_DEV'};ssl;;;
552 104;$qossettings{'RED_DEV'};pop3;;;
553 120;$qossettings{'RED_DEV'};applejuice;;;
554 120;$qossettings{'RED_DEV'};bittorrent;;;
555 200;imq0;rtp;;;
556 200;imq0;skypetoskype;;;
557 203;imq0;ssh;;;
558 203;imq0;rdp;;;
559 204;imq0;http;;;
560 204;imq0;pop3;;;
561 204;imq0;ssl;;;
562 220;imq0;applejuice;;;
563 220;imq0;bittorrent;;;
564 END
565 ;
566 close FILE;
567 open( FILE, "> $portfile" ) or die "Unable to write $portfile";
568 print FILE <<END
569 101;$qossettings{'RED_DEV'};icmp;;;;;
570 102;$qossettings{'RED_DEV'};tcp;;;;53;
571 102;$qossettings{'RED_DEV'};udp;;;;53;
572 103;$qossettings{'RED_DEV'};esp;;;;;
573 103;$qossettings{'RED_DEV'};tcp;;1194;;;
574 103;$qossettings{'RED_DEV'};udp;;1194;;;
575 103;$qossettings{'RED_DEV'};tcp;;;;1194;
576 103;$qossettings{'RED_DEV'};udp;;;;1194;
577 103;$qossettings{'RED_DEV'};udp;;4500;;4500;
578 103;$qossettings{'RED_DEV'};udp;;500;;500;
579 104;$qossettings{'RED_DEV'};tcp;;;;80;
580 200;imq0;icmp;;;;;
581 203;imq0;esp;;;;;
582 203;imq0;tcp;;;;1194;
583 203;imq0;udp;;;;1194;
584 203;imq0;tcp;;1194;;;
585 203;imq0;udp;;1194;;;
586 203;imq0;udp;;4500;;4500;
587 203;imq0;udp;;500;;500;
588 204;imq0;tcp;;80;;;
589 END
590 ;
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'};
609 }
610 }
611 elsif ($qossettings{'ACTION'} eq $Lang::tr{'status'} )
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";
619 } else { print "$Lang::tr{'QoS not enabled'}"; }
620 &Header::closebox();
621 &Header::closebigbox();
622 &Header::closepage();
623 exit
624 }
625 elsif ($qossettings{'ACTION'} eq $Lang::tr{'parentclass add'} )
626 {
627 &parentclass();
628 &Header::closebigbox();
629 &Header::closepage();
630 exit
631 }
632 elsif ($qossettings{'ACTION'} eq $Lang::tr{'qos add subclass'})
633 {
634 &subclass();
635 &Header::closebigbox();
636 &Header::closepage();
637 exit
638 }
639 elsif ($qossettings{'ACTION'} eq $Lang::tr{'Add Rule'})
640 {
641 &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'});
642 print <<END
643 <table>
644 <tr><td align='center'>$Lang::tr{'Choose Rule'}
645 <tr><td align='center'>
646 <input type="button" onClick="swapVisibility('l7rule')" value='$Lang::tr{'Level7 Rule'}' />
647 <input type="button" onClick="swapVisibility('portrule')" value='$Lang::tr{'Port Rule'}' />
648 <input type="button" onClick="swapVisibility('tosrule')" value='$Lang::tr{'TOS rule'}' />
649 </table>
650 END
651 ;
652 &Header::closebox();
653 print <<END
654 <div id='l7rule' style='display: none'>
655 END
656 ;
657 &level7rule();
658 print <<END
659 </div>
660 <div id='portrule' style='display: none'>
661 END
662 ;
663 &portrule();
664 print <<END
665 </div>
666 <div id='tosrule' style='display: none'>
667 END
668 ;
669 &tosrule();
670 print <<END
671 </div>
672 END
673 ;
674 &Header::closebigbox();
675 &Header::closepage();
676 exit
677 }
678 if ($qossettings{'ACTIONBW'} eq "$Lang::tr{'modify'}" )
679 {
680 &changebandwidth();
681 &Header::closebigbox();
682 &Header::closepage();
683 exit
684 }
685 if ($qossettings{'ACTIONDEF'} eq "$Lang::tr{'modify'}" )
686 {
687 &changedefclasses();
688 &Header::closebigbox();
689 &Header::closepage();
690 exit
691 }
692
693 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
694
695 my $status = $Lang::tr{'stopped'};
696 my $statuscolor = '#993333';
697 if ( $qossettings{'ENABLED'} eq 'on' ) {
698 $status = $Lang::tr{'running'};
699 $statuscolor = '#339933';
700 }
701
702 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
703 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
704 }
705
706 if ($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
713 ############################################################################################################################
714 ############################################################################################################################
715
716 &Header::openbox('100%', 'center', );
717
718 print <<END
719 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
720 <table width='66%'>
721 END
722 ;
723 if ( $message ne "" ) {
724 print "<tr><td colspan='2' align='center'><font color='red'>$message</font></tr>";
725 }
726 print <<END
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>
736 END
737 ;
738 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
739 print <<END
740 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
741 <table width='66%'>
742 <tr><td colspan='3'>&nbsp;
743 <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'}
744 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='$Lang::tr{'modify'}' />
745 <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'}
746 </table></form>
747 END
748 ;
749 }
750 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
751 print <<END
752 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
753 <table width='66%'>
754 <tr><td colspan='3'><hr />
755 <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'}
756 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='$Lang::tr{'modify'}' />
757 <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'}
758 <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'}
759 <tr><td colspan='3' width='100%'><hr />
760 <tr><td colspan='3' width='100%' align='center'>
761 </table>
762 </form>
763 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
764 <table width='66%' border='0'>
765 <tr><td width='100%' align='center'>
766 <input type='submit' name='ACTION' value='$Lang::tr{'parentclass add'}' />
767 <input type='submit' name='ACTION' value='$Lang::tr{'status'}' />
768 </td></tr></table>
769 </form>
770 END
771 ;
772 }
773 &Header::closebox();
774
775 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
776 &changebandwidth();
777 &Header::closebigbox();
778 &Header::closepage();
779 exit
780 }
781
782 if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
783 &changedefclasses();
784 &Header::closebigbox();
785 &Header::closepage();
786 exit
787 }
788
789 &Header::openbox('100%', 'center', "$qossettings{'RED_DEV'} $Lang::tr{'graph'}, $Lang::tr{'uplink'}");
790 &Graphs::makegraphbox("qos.cgi",$qossettings{'RED_DEV'},"hour","325");
791 &Header::closebox();
792 &Header::openbox('100%', 'center', "$qossettings{'IMQ_DEV'} $Lang::tr{'graph'}, $Lang::tr{'downlink'}");
793 &Graphs::makegraphbox("qos.cgi",$qossettings{'IMQ_DEV'},"hour","325");
794 &Header::closebox();
795
796 &showclasses($qossettings{'RED_DEV'});
797 &showclasses($qossettings{'IMQ_DEV'});
798
799 &Header::closebigbox();
800 &Header::closepage();
801
802 }
803
804 ############################################################################################################################
805 ############################################################################################################################
806
807 sub changedefclasses {
808 &Header::openbox('100%', 'center', $Lang::tr{'std classes'});
809 print <<END
810 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
811 <table width='66%'>
812 <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'}
813 <tr><td width='33%' align='right'>$Lang::tr{'download'}:<td width='33%' align='left'><select name='DEFCLASS_INC'>
814 END
815 ;
816 for ( $c = 200 ; $c <= 220 ; $c++ )
817 {
818 if ( $qossettings{'DEFCLASS_INC'} ne $c )
819 { print "<option value='$c'>$c</option>\n"; }
820 else { print "<option selected value='$c'>$c</option>\n"; }
821 }
822 print <<END
823 </select><td width='33%' align='center'>&nbsp;
824 <tr><td width='33%' align='right'>$Lang::tr{'upload'}:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
825 END
826 ;
827 for ( $c = 100 ; $c <= 120 ; $c++ )
828 {
829 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
830 { print "<option value='$c'>$c</option>\n"; }
831 else { print "<option selected value='$c'>$c</option>\n"; }
832 }
833 print <<END
834 </select><td width='33%' align='center'>&nbsp;
835 </table>
836 <hr />
837 <table width='66%'>
838 <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'}
839 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
840 END
841 ;
842 for ( $c = 100 ; $c <= 120 ; $c++ )
843 {
844 if ( $qossettings{'ACK'} ne $c )
845 { print "<option value='$c'>$c</option>\n"; }
846 else { print "<option selected value='$c'>$c</option>\n"; }
847 }
848 print <<END
849 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
850 </table>
851 </form>
852 END
853 ;
854 &Header::closebox();
855 }
856
857 sub changebandwidth {
858 &Header::openbox('100%', 'center', $Lang::tr{'bandwithsettings'});
859 if ($qossettings{'ENABLED'} eq 'on') {
860 print "$Lang::tr{'bandwitherror'}";
861 print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>";
862 } else {
863 print <<END
864 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
865 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
866 <table width='66%'>
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>
873 </table>
874 </form>
875 <font color='red'>$Lang::tr{'template warning'}</font>
876 END
877 ;
878 }
879 &Header::closebox();
880 }
881
882 sub parentclass {
883 &Header::openbox('100%', 'center', $Lang::tr{'parentclass'});
884 print <<END
885 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
886 <table width='66%'>
887 END
888 ;
889 if ( $message ne "" ) {
890 print "<tr><td colspan='3' align='center'>$message";
891 }
892 if ( $qossettings{'EDIT'} eq 'yes' ) {
893 print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />";
894 print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />";
895 }
896 print <<END
897 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
898 <tr><td width='33%' align='right'>$Lang::tr{'interface'}:
899 <td width='33%' align='left'>
900 END
901 ;
902 if ( $qossettings{'EDIT'} eq 'yes' ) {
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
913 <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
914 <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
915 <td width='33%' align='center'>&nbsp;
916 <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'>
917 END
918 ;
919 if ( $qossettings{'EDIT'} eq 'yes' ) {
920 print "<select name='CLASS' disabled>";
921 } else {
922 print "<select name='CLASS'>";
923 }
924 for ( $c = 100 ; $c <= 120 ; $c++ )
925 {
926 if ( $qossettings{'CLASS'} ne $c )
927 { print "<option value='$c'>$c</option>\n"; }
928 else { print "<option selected value='$c'>$c</option>\n"; }
929 }
930 for ( $c = 200 ; $c <= 220 ; $c++ )
931 {
932 if ( $qossettings{'CLASS'} ne $c )
933 { print "<option value='$c'>$c</option>\n"; }
934 else { print "<option selected value='$c'>$c</option>\n"; }
935 }
936 print <<END
937 </select>
938 <td width='33%' align='center'>&nbsp;
939 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
940 END
941 ;
942 for ( $c = 1 ; $c <= 7 ; $c++ )
943 {
944 if ( $qossettings{'PRIO'} ne $c )
945 { print "<option value='$c'>$c</option>\n"; }
946 else { print "<option selected value='$c'>$c</option>\n"; }
947 }
948 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
949 print <<END
950 </select>
951 <td width='33%' align='center'>&nbsp;
952 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
953 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
954 <td width='33%' align='center'>&nbsp;
955 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
956 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
957 <td width='33%' align='center'>&nbsp;
958 <tr><td width='33%' align='right'>Burst:
959 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
960 <td width='33%' align='center'>&nbsp;
961 <tr><td width='33%' align='right'>Ceilburst:
962 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
963 <td width='33%' align='center'>&nbsp;
964 END
965 ;
966 $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
967 print <<END
968 <tr><td width='33%' align='right'>TOS-Bit:
969 <td width='33%' align='left'><select name='TOS'>
970 <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
971 <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
972 <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
973 <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
974 <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
975 <td width='33%' align='center'>&nbsp;
976 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
977 <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> <img alt="" alt='blob' src='/blob.gif' />
978 <tr><td width='33%' align='right'>&nbsp;
979 <td width='33%' align='left'>&nbsp;
980 <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
981 </table></form>
982 END
983 ;
984 &Header::closebox();
985 }
986
987 sub subclass {
988 &Header::openbox('100%', 'center', $Lang::tr{'Subclass'});
989 print <<END
990 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
991 <table width='66%'>
992 END
993 ;
994 if ( $message ne "" ) {
995 print "<tr><td colspan='3' align='center'>$message";
996 }
997 print <<END
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'>
1001 END
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;
1023 <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'>
1024 END
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;
1034 <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}:
1035 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
1036 <td width='33%' align='center'>&nbsp;
1037 <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}:
1038 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
1039 <td width='33%' align='center'>&nbsp;
1040 <tr><td width='33%' align='right'>Burst:
1041 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
1042 <td width='33%' align='center'>&nbsp;
1043 <tr><td width='33%' align='right'>Ceilburst:
1044 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
1045 <td width='33%' align='center'>&nbsp;
1046 <tr><td width='33%' align='right'>TOS-Bit:
1047 <td width='33%' align='left'><select name='TOS'>
1048 <option value='0'>$Lang::tr{'disabled'} (0)</option>
1049 <option value='8'>$Lang::tr{'min delay'} (8)</option>
1050 <option value='4'>$Lang::tr{'max throughput'} (4)</option>
1051 <option value='2'>$Lang::tr{'max reliability'} (2)</option>
1052 <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
1053 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
1054 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
1055 <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' />&nbsp;<input type='reset' value='$Lang::tr{'reset'}' />
1056 </table></form>
1057 END
1058 ;
1059 &Header::closebox();
1060 }
1061
1062 sub level7rule {
1063 &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'});
1064 print <<END
1065 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1066 <table width='66%'>
1067 END
1068 ;
1069 if ( $message ne "" ) {
1070 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1071 }
1072 print <<END
1073 <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1074 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1075 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1076 <td width='33%' align='left'><select name='L7PROT'>
1077 END
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'} ) {
1087 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
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;
1095 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1096 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
1097 <td width='33%' align='center'>&nbsp;
1098 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1099 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
1100 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' />
1101 <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font>
1102 </table></form>
1103 END
1104 ;
1105 &Header::closebox();
1106 }
1107
1108 sub portrule {
1109 &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'});
1110 print <<END
1111 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1112 <table width='66%'>
1113 <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
1114 <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
1115 <td width='33%' align='left'><select name='PPROT'>
1116 END
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'} ) {
1126 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
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;
1133 <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
1134 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
1135 <td width='33%' align='center'>&nbsp;
1136 <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
1137 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
1138 <td width='33%' align='center'>&nbsp;
1139 <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
1140 <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' />
1141 <td width='33%' align='center'>&nbsp;
1142 <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
1143 <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' />
1144 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
1145 </table></form>
1146 END
1147 ;
1148 &Header::closebox();
1149 }
1150
1151 sub tosrule {
1152 &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'});
1153 if ($qossettings{'TOS'}) {
1154 $checked{$qossettings{'TOS'}} = "checked";
1155 }
1156 print <<END
1157 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1158 <table width='66%'>
1159 END
1160 ;
1161 if ( $message ne "" ) {
1162 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1163 }
1164 print <<END
1165 <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
1166 <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
1167 <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1168 <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1169 <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
1170 <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
1171 <tr><td width='100%' align='right' colspan='2'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOTOS' value='$Lang::tr{'save'}' />
1172 </table></form>
1173 END
1174 ;
1175 &Header::closebox();
1176 }
1177
1178 sub showclasses {
1179 $qossettings{'DEV'} = shift;
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;
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;
1196 foreach $classentry (sort @classes)
1197 {
1198 @classline = split( /\;/, $classentry );
1199 if ( $classline[0] eq $qossettings{'DEV'} )
1200 {
1201 &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]");
1202 print <<END
1203 <table border='0' width='100%' cellspacing='0'>
1204 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
1205 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
1206 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
1207 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
1208 <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
1209 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1210 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1211 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
1212 <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
1213 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1214 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1215 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1216 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1217 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1218 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1219 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1220 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1221 <td align='right' bgcolor='$color{'color22'}'>
1222 <table border='0'><tr>
1223 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1224 <input type='hidden' name='CLASS' value='$classline[1]' />
1225 <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
1226 <input type='image' alt='$Lang::tr{'add subclass'}' title='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
1227 </form>
1228 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1229 <input type='hidden' name='CLASS' value='$classline[1]' />
1230 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1231 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1232 </form>
1233 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1234 <input type='hidden' name='CLASS' value='$classline[1]' />
1235 <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
1236 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1237 </form>
1238 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1239 <input type='hidden' name='CLASS' value='$classline[1]' />
1240 <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
1241 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1242 </form>
1243 </table>
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]
1248 END
1249 ;
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
1258 <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
1259 <td align='center' colspan='6'>$l7ruleline[2]
1260 <td align='right' >
1261 <table border='0'><tr>
1262 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1263 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1264 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1265 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
1266 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1267 </form>
1268 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1269 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1270 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1271 <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
1272 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1273 </form>
1274 </table>
1275 END
1276 ;
1277 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1278 print <<END
1279 <tr><td align='center'>&nbsp;
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]
1282 END
1283 ;
1284 }
1285
1286
1287 END
1288 ;
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
1301 <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
1302 <td align='center'>($portruleline[2])
1303 <td align='center' colspan='2'>
1304 END
1305 ;
1306 if ($portruleline[4]) {
1307 print <<END
1308 <i>$Lang::tr{'source port'}:</i> $portruleline[4]
1309 END
1310 ;
1311 }
1312 print "<td align='center' colspan='2'>";
1313 if ($portruleline[6]) {
1314 print <<END
1315 <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
1316 END
1317 ;
1318 }
1319 print <<END
1320 <td>&nbsp;
1321 <td align='right'>
1322 <table border='0'><tr>
1323 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1324 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1325 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1326 <input type='hidden' name='QIP' value='$portruleline[3]' />
1327 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1328 <input type='hidden' name='DIP' value='$portruleline[5]' />
1329 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1330 <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
1331 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1332 </form>
1333 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1334 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1335 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1336 <input type='hidden' name='QIP' value='$portruleline[3]' />
1337 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1338 <input type='hidden' name='DIP' value='$portruleline[5]' />
1339 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1340 <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
1341 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1342 </form>
1343 </table>
1344 END
1345 ;
1346 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1347 print <<END
1348 <tr><td align='center'>&nbsp;
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]
1351 END
1352 ;
1353 }
1354 }
1355 }
1356 }
1357
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'>
1368 END
1369 ;
1370 if ( $tosruleline[2] eq "8") {
1371 print "$Lang::tr{'min delay'}\n";
1372 } elsif ( $tosruleline[2] eq "4") {
1373 print "$Lang::tr{'max throughput'}\n";
1374 } elsif ( $tosruleline[2] eq "2") {
1375 print "$Lang::tr{'max reliability'}\n";
1376 } elsif ( $tosruleline[2] eq "1") {
1377 print "$Lang::tr{'min costs'}\n";
1378 } else { print "&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'}'>
1385 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1386 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1387 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1388 <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
1389 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1390 </form>
1391 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1392 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1393 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1394 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1395 <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
1396 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1397 </form>
1398 </table>
1399 END
1400 ;
1401 }
1402 }
1403 }
1404 END
1405 ;
1406 foreach $subclassentry (sort @subclasses)
1407 {
1408 @subclassline = split( /\;/, $subclassentry );
1409 if ( $subclassline[1] eq $classline[1] ) {
1410 print <<END
1411 <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
1412 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1413 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1414 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1415 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1416 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1417 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1418 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1419 <td align='right' bgcolor='#FAFAFA'>
1420 <table border='0'><tr>
1421 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1422 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1423 <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
1424 <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
1425 </form>
1426 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1427 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1428 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
1429 <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' />
1430 </form>
1431 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
1432 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1433 <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
1434 <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' />
1435 </form>
1436 </table>
1437 END
1438 ;
1439 }
1440 }
1441 print <<END
1442 </table>
1443 END
1444 ;
1445 &Header::closebox();
1446 }
1447 }
1448 }
1449 }
1450 sub 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 }
1457 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
1458 $qossettings{'VALID'} = 'no';
1459 $message = "$Lang::tr{'false min bandwith'}";
1460 }
1461 $qossettings{'SPD'} = '';
1462 }
1463 }
1464
1465 sub 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';
1474 $message = "$Lang::tr{'false max bandwith'}";
1475 }
1476 $qossettings{'SPD'} = '';
1477 }
1478 }
1479
1480 sub 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';
1485 $message = "$Lang::tr{'false classnumber'}";
1486 }
1487 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1488 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1489 $qossettings{'VALID'} = 'no';
1490 $message = "$Lang::tr{'The class number does not match the specified interface.'}";
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';
1502 $message = "$Lang::tr{'false classnumber'}";
1503 last
1504 }
1505 }
1506 }
1507 }
1508
1509 sub 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';
1520 $message = "$Lang::tr{'class in use'}";
1521 last
1522 }
1523 }
1524 }
1525 }