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