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