53390ac3e400d31c362931e7e3640b09239ddc6d
[ipfire-2.x.git] / html / cgi-bin / qos.cgi
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The IPFire Team
8 #
9
10 use strict;
11 # enable only the following on debugging purpose
12 use warnings;
13 use CGI::Carp 'fatalsToBrowser';
14
15 require '/var/ipfire/general-functions.pl';
16 require "${General::swroot}/lang.pl";
17 require "${General::swroot}/header.pl";
18
19 my %qossettings = ();
20 my %checked = ();
21 my %netsettings = ();
22 my $message = "";
23 my $errormessage = "";
24 my $c = "";
25 my $direntry = "";
26 my $classentry = "";
27 my $subclassentry = "";
28 my $l7ruleentry = "";
29 my @tmp = ();
30 my @classes = ();
31 my @subclasses = ();
32 my @l7rules = ();
33 my @tmpline = ();
34 my @classline = ();
35 my @subclassline = ();
36 my @l7ruleline = ();
37 my @proto = ();
38 my %selected= () ;
39 my $classfile = "/var/ipfire/qos/classes";
40 my $subclassfile = "/var/ipfire/qos/subclasses";
41 my $level7file = "/var/ipfire/qos/level7config";
42 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
43
44 &Header::showhttpheaders();
45
46 $qossettings{'ENABLED'} = 'off';
47 $qossettings{'EDIT'} = 'no';
48 $qossettings{'OUT_SPD'} = '';
49 $qossettings{'INC_SPD'} = '';
50 $qossettings{'DEFCLASS_INC'} = '';
51 $qossettings{'DEFCLASS_OUT'} = '';
52 $qossettings{'ACK'} = '';
53 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
54 $qossettings{'IMQ_DEV'} = 'imq0';
55 $qossettings{'VALID'} = 'yes';
56
57 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
58 &Header::getcgihash(\%qossettings);
59
60 &Header::openpage('QoS', 1, '');
61 print <<END
62 <script type="text/javascript">
63 <!--
64 function BorderOn (id) { id.className='btnOn'  }
65 function BorderOff(id) { id.className='btnOff' }
66 //-->
67 </script>
68 <style type=text/css>
69 .btnOn {
70         border-right: #D5F0FF 2px Inset;
71         border-top: #D5F0FF 2px Inset;
72         border-left: #D5F0FF 2px Inset;
73         border-bottom: #D5F0FF 2px Inset;
74        text-align: Center;
75        text-decoration: None;
76         background-color: #FFFFFF;
77 }
78 .btnOff {
79         border-right: #D5F0FF 2px Outset;
80         border-top: #D5F0FF 2px Outset;
81         border-left: #D5F0FF 2px Outset;
82         border-bottom: #D5F0FF 2px Outset;
83         text-align: Center;
84         text-decoration: None;
85         background-color: #FFFFFF;
86 }
87 </style>
88 END
89 ;
90
91 &Header::openbigbox('100%', 'left', '', $errormessage);
92
93 if ($qossettings{'DO_CLASS'} eq $Lang::tr{'save'})
94 {
95         &validclass();
96         &validminbwdth();
97         &validmaxbwdth();
98         if ( $qossettings{'VALID'} eq 'yes' ) {
99                 open( FILE, ">> $classfile" ) or die "Unable to write $classfile";
100                 print FILE <<END
101 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};
102 END
103 ;
104                 close FILE;
105         } else {
106                 $qossettings{'ACTION'} = 'Parentklasse hinzufuegen';
107         }
108 }
109 elsif ($qossettings{'DO_CLASS'} eq 'Bearbeiten')
110 {
111         open( FILE, "< $classfile" ) or die "Unable to read $classfile";
112         @classes = <FILE>;
113         close FILE;
114         open( FILE, "> $classfile" ) or die "Unable to write $classfile";
115         foreach $classentry (sort @classes)
116         {
117                 @classline = split( /\;/, $classentry );
118                 if ( $classline[1] ne $qossettings{'CLASS'} ) {
119                         print FILE $classentry;
120                 } else {
121                         $qossettings{'DEVICE'} = $classline[0];
122                         $qossettings{'PRIO'} = $classline[2];
123                         $qossettings{'MINBWDTH'} = $classline[3];
124                         $qossettings{'MAXBWDTH'} = $classline[4];
125                         $qossettings{'BURST'} = $classline[5];
126                         $qossettings{'CBURST'} = $classline[6];
127                         $qossettings{'EDIT'} = 'yes';
128                 }
129         }
130         close FILE;
131         &parentclass();
132         &Header::closebigbox();
133         &Header::closepage();
134         exit
135 }
136 elsif ($qossettings{'DO_CLASS'} eq 'Loeschen')
137 {
138         open( FILE, "< $classfile" ) or die "Unable to read $classfile";
139         @tmp = <FILE>;
140         close FILE;
141         open( FILE, "> $classfile" ) or die "Unable to write $classfile";
142         foreach $classentry (sort @tmp)
143         {
144                 @tmpline = split( /\;/, $classentry );
145                 if ( $tmpline[1] ne $qossettings{'CLASS'} )
146                 {
147                         print FILE $classentry;
148                 }
149         }
150         close FILE;
151         $message = "Klasse $qossettings{'CLASS'} wurde geloescht.";
152 }
153 if ($qossettings{'DO_SCLASS'} eq $Lang::tr{'save'})
154 {
155         if ($qossettings{'SCLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
156                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
157         } elsif ($qossettings{'SCLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
158                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
159         }
160         &validsubclass();
161         &validminbwdth();
162         if ( $qossettings{'VALID'} eq 'yes' ) {
163                 open( FILE, ">> $subclassfile" ) or die "Unable to write $subclassfile";
164                 print FILE <<END
165 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};
166 END
167 ;
168                 close FILE;
169         } else {
170                 $qossettings{'ACTION'} = 'Unterklasse hinzufuegen';
171         }
172 } elsif ($qossettings{'DO_SCLASS'} eq 'Loeschen')
173 {
174         open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
175         @tmp = <FILE>;
176         close FILE;
177         open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
178         foreach $subclassentry (sort @tmp)
179         {
180                 @tmpline = split( /\;/, $subclassentry );
181                 if ( $tmpline[2] ne $qossettings{'CLASS'} )
182                 {
183                         print FILE $subclassentry;
184                 }
185         }
186         close FILE;
187         $message = "Unterklasse $qossettings{'CLASS'} wurde geloescht.";
188 }
189 if ($qossettings{'DO_LEVEL7'} eq $Lang::tr{'save'})
190 {
191         if ( $qossettings{'QIP'} ne '' ) {
192                 unless ( &General::validip($qossettings{'QIP'}) ) { 
193                         $qossettings{'VALID'} = 'no';
194                         $message = "Die Quell-IP-Adresse ist ungueltig."; 
195                 }
196         }
197         if ( $qossettings{'DIP'} ne '' ) {
198                 unless ( &General::validip($qossettings{'DIP'}) ) { 
199                         $qossettings{'VALID'} = 'no';
200                         $message = "Die Ziel-IP-Adresse ist ungueltig."; 
201                 }
202         }
203         if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
204                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
205         } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
206                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
207         } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
208                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
209         } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
210                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
211         }
212         if ( $qossettings{'VALID'} eq 'yes' ) {
213                 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
214                 print FILE <<END
215 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
216 END
217 ;
218                 close FILE;
219         } else {
220                 $qossettings{'ACTION'} = 'Level7-Regel hinzufuegen';
221         }
222
223 elsif ($qossettings{'DO_LEVEL7'} eq 'Loeschen')
224 {
225         open( FILE, "< $level7file" ) or die "Unable to read $level7file";
226         @l7rules = <FILE>;
227         close FILE;
228         open( FILE, "> $level7file" ) or die "Unable to read $level7file";
229         foreach $l7ruleentry (sort @l7rules)
230         {
231                 @l7ruleline = split( /\;/, $l7ruleentry );
232                 if ( ($l7ruleline[0] ne $qossettings{'CLASS'}) && ($l7ruleline[2] ne $qossettings{'L7PROT'}))
233                 {
234                         print FILE $l7ruleentry;
235                 }
236         }
237         close FILE;
238         $message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";
239 }
240 if ($qossettings{'ACTION'} eq 'Start')
241 {
242         system("/bin/touch /var/ipfire/qos/enable");
243         $qossettings{'ENABLED'} = 'on';
244         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
245 }
246 elsif ($qossettings{'ACTION'} eq 'Stop')
247 {
248         unlink "/var/ipfire/qos/enable";
249         $qossettings{'ENABLED'} = 'off';
250         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
251 }
252 elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
253 {
254         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
255 }
256 elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen')
257 {
258         &parentclass();
259         &Header::closebigbox();
260         &Header::closepage();
261         exit
262 }
263 elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen')
264 {
265         &subclass();
266         &Header::closebigbox();
267         &Header::closepage();
268         exit
269 }
270 elsif ($qossettings{'ACTION'} eq 'Level7-Regel hinzufuegen')
271 {
272         &level7rule();
273         &Header::closebigbox();
274         &Header::closepage();
275         exit
276 }
277 elsif ($qossettings{'ACTION'} eq 'Port-Regel hinzufuegen')
278 {
279         &portrule();
280         &Header::closebigbox();
281         &Header::closepage();
282         exit
283 }
284 if ($qossettings{'ACTION_BW'} eq 'Andern')
285 {
286         &changebandwidth();
287         &Header::closebigbox();
288         &Header::closepage();
289         exit
290 }
291 if ($qossettings{'ACTION_DEF'} eq 'Andern')
292 {
293         &changedefclasses();
294         &Header::closebigbox();
295         &Header::closepage();
296         exit
297 }
298
299 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
300
301 my $status = $Lang::tr{'stopped'};
302 my $statuscolor = $Header::colourred;
303 if ( $qossettings{'ENABLED'} eq 'on' ) {
304   $status = $Lang::tr{'running'};
305   $statuscolor = $Header::colourgreen;
306 }
307
308 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
309         $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
310 }
311
312 if ($errormessage) {
313         &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
314         print "<class name='base'>$errormessage\n";
315         print "&nbsp;</class>\n";
316         &Header::closebox();
317 }
318
319 ############################################################################################################################
320 ############################################################################################################################
321
322 &Header::openbox('100%', 'center', 'Quality of Service');
323 print <<END
324         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
325         <table width='33%'>
326 END
327 ;
328         if ( $message ne "" ) {
329                 print "<tr><td colspan='2' align='center'><font color='red'>$message</font>";
330         }
331         print <<END
332                 <tr><td width='50%' align='left'><b>Quality of Service:</b>
333                     <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font>
334                 <tr><td width='100%' align='center' colspan='2'>
335                 <input type='submit' name='ACTION' value='Start' /> 
336                 <input type='submit' name='ACTION' value='Stop' /> 
337                 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
338 END
339 ;
340         if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
341                 print <<END
342                 <tr><td colspan='3'>&nbsp;
343                 <tr><td width='40%' align='right'>Downloadgeschwindigkeit:      <td width='40%' align='left'>$qossettings{'INC_SPD'} kbps
344                     <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTION_BW' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Andern'>
345                 <tr><td width='40%' align='right'>Uploadgeschwindigkeit:        <td width='40%' align='left'>$qossettings{'OUT_SPD'} kbps
346 END
347 ;
348         }
349         if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
350                 print <<END
351                 <tr><td colspan='3'><hr>
352                 <tr><td width='40%' align='right'>Downloadstandardklasse:       <td width='40%' align='left'>$qossettings{'DEFCLASS_INC'}       
353                     <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTION_DEF' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Andern'>
354                 <tr><td width='40%' align='right'>Uploadstandardklasse:         <td width='40%' align='left'>$qossettings{'DEFCLASS_OUT'}
355                 <tr><td width='40%' align='right'>ACKs:                         <td width='40%' align='left'>$qossettings{'ACK'}
356                 <tr><td colspan='3' width='100%'><hr>
357                 <tr><td colspan='3' width='100%' align='center'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Parentklasse hinzufuegen'>
358         </form>
359 END
360 ;
361         }
362 print "</table>";
363 &Header::closebox();
364
365 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
366         &changebandwidth();
367         &Header::closebox();
368         &Header::closebigbox();
369         &Header::closepage();
370         exit
371 }
372
373 if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
374         &changedefclasses();
375         &Header::closebigbox();
376         &Header::closepage();
377         exit
378 }
379
380 &showclasses();
381 &showl7rules();
382
383 &Header::closebigbox();
384 &Header::closepage();
385
386 ############################################################################################################################
387 ############################################################################################################################
388
389 sub changedefclasses {
390         &Header::openbox('100%', 'center', 'Standardklassen:');
391         print <<END
392                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
393                 <table width='66%'>
394                 <tr><td width='100%' colspan='3'>Legen sie hier die Standardklassen fest durch die nicht-gefilterte Pakete gehen.
395                 <tr><td width='33%' align='right'>Download:<td width='33%' align='left'><select name='DEFCLASS_INC'>
396 END
397 ;
398                 for ( $c = 200 ; $c <= 220 ; $c++ )
399                 {
400                         if ( $qossettings{'DEFCLASS_INC'} ne $c )
401                         { print "<option value='$c'>$c</option>\n"; } 
402                         else    { print "<option selected value='$c'>$c</option>\n"; }
403                 }
404                 print <<END
405                 </select><td width='33%' align='center'>&nbsp;
406                 <tr><td width='33%' align='right'>Upload:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
407 END
408 ;
409                 for ( $c = 100 ; $c <= 120 ; $c++ )
410                 {
411                         if ( $qossettings{'DEFCLASS_OUT'} ne $c )
412                         { print "<option value='$c'>$c</option>\n"; }
413                         else { print "<option selected value='$c'>$c</option>\n"; }
414                 }
415                 print <<END
416                 </select><td width='33%' align='center'>&nbsp;
417                 </table>
418                 <hr>
419                 <table width='66%'>
420                 <tr><td width='100%' colspan='3'>Legen sie hier die ACK-Klasse fest <br> und klicken Sie danach auf <i>Speichern</i>.
421                 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
422 END
423 ;
424                 for ( $c = 100 ; $c <= 120 ; $c++ )
425                 {
426                         if ( $qossettings{'ACK'} ne $c )
427                         { print "<option value='$c'>$c</option>\n"; }
428                         else {  print "<option selected value='$c'>$c</option>\n"; }
429                 }
430                 print <<END
431                 </select><td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
432                 </table>
433                 </form>
434 END
435 ;
436         &Header::closebox();
437 }
438
439 sub changebandwidth {
440         &Header::openbox('100%', 'center', 'Bandbreiteneinstellungen');
441         if ($qossettings{'ENABLED'} eq 'on') {
442                 print "Sie koennen die Bandbreiteneinstellungen nicht bearbeiten, wenn QoS eingeschaltet ist. Schalten sie es zuerst dazu aus.<p>";
443                 print "<a href='/cgi-bin/qos.cgi'>Zurueck</a>";
444         } else {
445                 print <<END
446                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
447                 <table width='66%'>
448                 <tr><td width='100%' colspan='3'>Geben Sie bitte hier ihre Download- bzw. Upload-Geschwindigkeit ein <br> und klicken Sie danach auf <i>Speichern</i>.
449                 <tr><td width='33%' align='right'>Download-Geschwindigkeit:
450                     <td width='33%' align='left'><input type='text' name='INC_SPD' maxlength='8' value=$qossettings{'INC_SPD'}> &nbsp; kbps
451                     <td width='33%' align='center'>&nbsp;
452                 <tr><td width='33%' align='right'>Upload-Geschwindigkeit:
453                     <td width='33%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value=$qossettings{'OUT_SPD'}> &nbsp; kbps
454                     <td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />&nbsp;<input type='reset' name='ACTION' value=$Lang::tr{'reset'} />
455                 </table>
456                 </form>
457 END
458 ;
459         }
460         &Header::closebox();
461 }
462
463 sub parentclass {
464         &Header::openbox('100%', 'center', 'Parentklasse');
465         print <<END
466                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
467                 <table width='66%'>
468 END
469 ;
470         if ( $message ne "" ) {
471                 print "<tr><td colspan='3' align='center'>$message";
472         }
473         if ( $qossettings{'EDIT'} eq 'yes' ) { 
474                 print "<input type='hidden' name='CLASS' value=$qossettings{'CLASS'}>";
475                 print "<input type='hidden' name='DEVICE' value=$qossettings{'DEVICE'}>";
476         }
477         print <<END
478                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
479                 <tr><td width='33%' align='right'>Interface:
480                     <td width='33%' align='left'>
481 END
482 ;
483                 if ( $qossettings{'EDIT'} eq 'yes' ) { 
484                         print "<select name='DEVICE' disabled>";
485                 } else {
486                         print "<select name='DEVICE'>";
487                 }
488                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
489                         $qossettings{'RED_DEV_SEL'} = 'selected';
490                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
491                         $qossettings{'IMQ_DEV_SEL'} = 'selected';
492                 }
493                 print <<END
494                         <option value=$qossettings{'RED_DEV'} $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
495                         <option value=$qossettings{'IMQ_DEV'} $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
496                     <td width='33%' align='center'>&nbsp;
497                 <tr><td width='33%' align='right'>Klasse:<td width='33%' align='left'>
498 END
499 ;
500                 if ( $qossettings{'EDIT'} eq 'yes' ) { 
501                         print "<select name='CLASS' disabled>";
502                 } else {
503                         print "<select name='CLASS'>";
504                 }
505                 for ( $c = 100 ; $c <= 120 ; $c++ )
506                 {
507                         if ( $qossettings{'CLASS'} ne $c )
508                         { print "<option value='$c'>$c</option>\n"; }
509                         else { print "<option selected value='$c'>$c</option>\n"; }
510                 }
511                 for ( $c = 200 ; $c <= 220 ; $c++ )
512                 {
513                         if ( $qossettings{'CLASS'} ne $c )
514                         { print "<option value='$c'>$c</option>\n"; }
515                         else { print "<option selected value='$c'>$c</option>\n"; }
516                 }
517                 print <<END
518                 </select>
519                 <td width='33%' align='center'>&nbsp;
520                 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
521 END
522 ;
523                 for ( $c = 1 ; $c <= 7 ; $c++ )
524                 {
525                         if ( $qossettings{'PRIO'} ne $c )
526                         { print "<option value='$c'>$c</option>\n"; }
527                         else { print "<option selected value='$c'>$c</option>\n"; }
528                 }
529                 print <<END
530                 <td width='33%' align='center'>&nbsp;
531                 <tr><td width='33%' align='right'>Garantierte Bandbreite:
532                     <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value=$qossettings{'MINBWDTH'} >
533                     <td width='33%' align='center'>&nbsp;
534                 <tr><td width='33%' align='right'>Maximale Bandbreite:
535                     <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value=$qossettings{'MAXBWDTH'}>
536                     <td width='33%' align='center'>&nbsp;
537                 <tr><td width='33%' align='right'>Burst:
538                     <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value=$qossettings{'BURST'}>
539                     <td width='33%' align='center'>&nbsp;
540                 <tr><td width='33%' align='right'>Ceilburst:
541                     <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
542                     <td width='33%' align='center'><input type='submit' name='DO_CLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
543                 </table></form>
544 END
545 ;
546         &Header::closebox();
547 }
548
549 sub subclass {
550         &Header::openbox('100%', 'center', 'Unterklasse');
551         print <<END
552                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
553                 <table width='66%'>
554 END
555 ;
556         if ( $message ne "" ) {
557                 print "<tr><td colspan='3' align='center'>$message";
558         }
559         print <<END
560                 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
561                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
562                 <tr><td width='33%' align='right'>Unterklasse:<td width='33%' align='left'><select name='SCLASS'>
563 END
564 ;
565         if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
566                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
567                 for ( $c = 1000 ; $c <= 1020 ; $c++ )
568                 {
569                         if ( $qossettings{'SCLASS'} ne $c )
570                         { print "<option value='$c'>$c</option>\n"; }
571                         else { print "<option selected value='$c'>$c</option>\n"; }
572                 }
573         } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
574                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
575                 for ( $c = 2000 ; $c <= 2020 ; $c++ )
576                 {
577                         if ( $qossettings{'SCLASS'} ne $c )
578                         { print "<option value='$c'>$c</option>\n"; }
579                         else { print "<option selected value='$c'>$c</option>\n"; }
580                 }
581         }
582         print <<END
583                 </select>
584                 <td width='33%' align='center'>&nbsp;
585                 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
586 END
587 ;
588                 for ( $c = 1 ; $c <= 7 ; $c++ )
589                 {
590                         if ( $qossettings{'PRIO'} ne $c )
591                         { print "<option value='$c'>$c</option>\n"; }
592                         else { print "<option selected value='$c'>$c</option>\n"; }
593                 }
594                 print <<END
595                 <td width='33%' align='center'>&nbsp;
596                 <tr><td width='33%' align='right'>Garantierte Bandbreite:
597                     <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value=$qossettings{'MINBWDTH'} >
598                     <td width='33%' align='center'>&nbsp;
599                 <tr><td width='33%' align='right'>Maximale Bandbreite:
600                     <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value=$qossettings{'MAXBWDTH'}>
601                     <td width='33%' align='center'>&nbsp;
602                 <tr><td width='33%' align='right'>Burst:
603                     <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value=$qossettings{'BURST'}>
604                     <td width='33%' align='center'>&nbsp;
605                 <tr><td width='33%' align='right'>Ceilburst:
606                     <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
607                     <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DO_SCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
608                 </table></form>
609 END
610 ;
611         &Header::closebox();
612 }
613
614
615 sub level7rule {
616         &Header::openbox('100%', 'center', 'Level7-Regel');
617         print <<END
618                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
619                 <table width='66%'>
620 END
621 ;
622         if ( $message ne "" ) {
623                 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
624         }
625         print <<END
626                 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
627                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
628                 <tr><td width='33%' align='right'>Protokoll:
629                     <td width='33%' align='left'><select name='L7PROT'>
630 END
631 ;
632                 opendir( DIR, "/etc/l7-protocols/protocols" );
633                 foreach $direntry ( sort readdir(DIR) )
634                 {
635                         next if $direntry eq ".";
636                         next if $direntry eq "..";
637                         next if -d "/etc/l7-protocols/protocols/$direntry";
638                         @proto = split( /\./, $direntry );
639                         if ( $proto[0] eq $qossettings{'L7PROT'} ) {
640                                 print "<option value='$proto[0]' selected>$proto[0]</option>\n";                        
641                         } else {
642                                 print "<option value='$proto[0]'>$proto[0]</option>\n";
643                         }
644                 }
645                 closedir DIR;
646         print <<END
647                     </select><td width='33%' align='center'>&nbsp;
648                 <tr><td width='33%' align='right'>Quell-IP-Adresse:
649                     <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'}>
650                     <td width='33%' align='center'>&nbsp;
651                 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
652                     <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'}>
653                     <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DO_LEVEL7' value=$Lang::tr{'save'} />
654                 </table></form>
655 END
656 ;
657         &Header::closebox();
658 }
659
660 sub portrule {
661         &Header::openbox('100%', 'center', 'Port-Regel hinzufuegen');
662         print <<END
663                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
664                 <table width='66%'>
665                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
666                 <tr><td width='33%' align='right'>Name:
667                     <td width='33%' align='left'><input type='text' name='NAME' maxlength='20' value=$qossettings{'NAME'}>
668                     <td width='33%' align='center'>&nbsp;
669                 <tr><td width='33%' align='right'>Protokoll:
670                     <td width='33%' align='left'><select name='PPROT'>
671 END
672 ;
673                         open( FILE, "< /etc/protocols" );
674                         @proto = <FILE>;
675                         close FILE;
676                         foreach $direntry (sort @proto)
677                         {
678                                 @tmpline = split( /\ /, $direntry );
679                                 next if $tmpline[0] =~ "#";
680                                 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
681                                         print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";                    
682                                 } else {
683                                         print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
684                                 }
685                         }
686         print <<END
687                     </select><td width='33%' align='center'>&nbsp;
688                 <tr><td width='33%' align='right'>Quell-Port:
689                     <td width='33%' align='left'><input type='text' name='QPORT' maxlength='5' value=$qossettings{'QPORT'}>
690                     <td width='33%' align='center'>&nbsp;
691                 <tr><td width='33%' align='right'>Ziel-Port:
692                     <td width='33%' align='left'><input type='text' name='DPORT' maxlength='5' value=$qossettings{'DPORT'}>
693                     <td width='33%' align='center'>&nbsp;
694                 <tr><td width='33%' align='right'>Quell-IP-Adresse:
695                     <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'}>
696                     <td width='33%' align='center'>&nbsp;
697                 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
698                     <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'}>
699                     <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
700                 </table></form>
701 END
702 ;
703         &Header::closebox();
704 }
705
706 sub showclasses {
707         open( FILE, "< $classfile" ) or die "Unable to read $classfile";
708         @classes = <FILE>;
709         close FILE;
710         if (@classes) {
711                 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
712                 @subclasses = <FILE>;
713                 close FILE;
714                 &Header::openbox('100%', 'center', 'Klassen');
715                 print <<END
716                 <table border='0' width='100%' cellspacing='0'>
717                 <tr><td bgcolor='lightgrey' width='10%'>Interface
718                     <td bgcolor='lightgrey' width='10%'>Klasse
719                     <td bgcolor='lightgrey' width='10%'>Prioritaet
720                     <td bgcolor='lightgrey' width='10%'>Garantierte Bandbreite
721                     <td bgcolor='lightgrey' width='10%'>Maximale Bandbreite
722                     <td bgcolor='lightgrey' width='10%'>Burst
723                     <td bgcolor='lightgrey' width='10%'>Ceil Burst
724                     <td bgcolor='lightgrey' width='30%'>Aktionen
725 END
726 ;
727                 foreach $classentry (sort @classes)
728                 {
729                         @classline = split( /\;/, $classentry );
730                         if ( $classline[0] eq $qossettings{'RED_DEV'} )
731                         {
732                                 print <<END
733                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
734                                 <tr><td align='center' bgcolor='#EAEAEA'>$classline[0]
735                                     <td align='center' bgcolor='#EAEAEA'>$classline[1]
736                                     <td align='center' bgcolor='#EAEAEA'>$classline[2]
737                                     <td align='center' bgcolor='#EAEAEA'>$classline[3]
738                                     <td align='center' bgcolor='#EAEAEA'>$classline[4]
739                                     <td align='center' bgcolor='#EAEAEA'>$classline[5]
740                                     <td align='center' bgcolor='#EAEAEA'>$classline[6]
741                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
742                                         <button type='submit' name='DO_CLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
743                                         <button type='submit' name='ACTION' value='Unterklasse hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addblue.gif' width="20" height="20" alt="Unterklasse hinzufuegen"></button>&nbsp;
744                                         <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
745                                         <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
746                                         <button type='submit' name='DO_CLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
747                                 </form>
748 END
749 ;
750                                 foreach $subclassentry (sort @subclasses)
751                                 {
752                                         @subclassline = split( /\;/, $subclassentry );
753                                         if ( $subclassline[1] eq $classline[1] ) {
754                                                 print <<END
755                                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
756                                                         <tr><td align='center' bgcolor='#FFFFFF'>Subklasse:
757                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
758                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
759                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
760                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
761                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
762                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
763                                                             <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
764                                                                 <button type='submit' name='DO_SCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
765                                                                 <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
766                                                                 <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
767                                                                 <button type='submit' name='DO_SCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
768                                                 </form>
769 END
770 ;
771                                         }
772                                 }
773                         }
774                 }
775                 print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
776                 foreach $classentry (sort @classes)
777                 {
778                         @classline = split( /\;/, $classentry );
779                         if ( $classline[0] eq $qossettings{'IMQ_DEV'} )
780                         {
781                                 print <<END
782                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
783                                 <tr><td align='center' bgcolor='#EAEAEA'>$classline[0]
784                                     <td align='center' bgcolor='#EAEAEA'>$classline[1]
785                                     <td align='center' bgcolor='#EAEAEA'>$classline[2]
786                                     <td align='center' bgcolor='#EAEAEA'>$classline[3]
787                                     <td align='center' bgcolor='#EAEAEA'>$classline[4]
788                                     <td align='center' bgcolor='#EAEAEA'>$classline[5]
789                                     <td align='center' bgcolor='#EAEAEA'>$classline[6]
790                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
791                                         <button type='submit' name='DO_CLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
792                                         <button type='submit' name='ACTION' value='Unterklasse hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addblue.gif' width="20" height="20" alt="Unterklasse hinzufuegen"></button>&nbsp;
793                                         <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
794                                         <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
795                                         <button type='submit' name='DO_CLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
796                                 </form>
797 END
798 ;
799                                 foreach $subclassentry (sort @subclasses)
800                                 {
801                                         @subclassline = split( /\;/, $subclassentry );
802                                         if ( $subclassline[1] eq $classline[1] ) {
803                                                 print <<END
804                                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
805                                                         <tr><td align='center' bgcolor='#FFFFFF'>Subklasse:
806                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
807                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
808                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
809                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
810                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
811                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
812                                                             <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
813                                                                 <button type='submit' name='DO_SCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
814                                                                 <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
815                                                                 <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
816                                                                 <button type='submit' name='DO_SCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
817                                                 </form>
818 END
819 ;
820                                         }
821                                 }
822                         }
823                 }
824                 print "\t</table>\n";
825                 &Header::closebox();
826         }
827 }
828
829 sub showl7rules {
830         open( FILE, "< $level7file" ) or die "Unable to read $level7file";
831         @l7rules = <FILE>;
832         close FILE;
833         if (@l7rules) {
834                 &Header::openbox('100%', 'center', 'Level7-Regeln');
835                 print <<END
836                 <table border='0' width='100%' cellspacing='0'>
837                 <tr><td bgcolor='lightgrey' width='14%'>Interface
838                     <td bgcolor='lightgrey' width='14%'>Klasse
839                     <td bgcolor='lightgrey' width='14%'>Protokoll
840                     <td bgcolor='lightgrey' width='14%'>Quell-IP-Adresse
841                     <td bgcolor='lightgrey' width='14%'>Ziel-IP-Adresse
842                     <td bgcolor='lightgrey' width='30%'>Aktionen
843 END
844 ;
845                 foreach $l7ruleentry (sort @l7rules)
846                 {
847                         @l7ruleline = split( /\;/, $l7ruleentry );
848                         if ( $l7ruleline[1] eq $qossettings{'RED_DEV'} )
849                         {
850                                 print <<END
851                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
852                                 <tr><td align='center' bgcolor='#EAEAEA'>$l7ruleline[1]
853                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[0]
854                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[2]
855                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
856                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
857                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
858                                         <button type='submit' name='DO_LEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
859                                         <button type='submit' name='DO_LEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
860                                 </form>
861 END
862 ;
863                         }
864                 }
865                 print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
866                 foreach $l7ruleentry (sort @l7rules)
867                 {
868                         @l7ruleline = split( /\;/, $l7ruleentry );
869                         if ( $l7ruleline[1] eq $qossettings{'IMQ_DEV'} )
870                         {
871                                 print <<END
872                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
873                                 <tr><td align='center' bgcolor='#EAEAEA'>$l7ruleline[1]
874                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[0]
875                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[2]
876                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
877                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
878                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
879                                         <button type='submit' name='DO_LEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
880                                         <button type='submit' name='DO_LEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
881                                 </form>
882 END
883 ;
884                         }
885                 }
886                 print "\t</table>\n";
887                 &Header::closebox();
888         }
889 }
890
891
892 sub validminbwdth {
893         if ( $qossettings{'VALID'} eq 'yes' ) {
894                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
895                         $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
896                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
897                         $qossettings{'SPD'} = $qossettings{'INC_SPD'};
898                 }
899                 unless ( ( $qossettings{'MINBDWTH'} >= 0 ) && ( $qossettings{'MINBDWTH'} <= $qossettings{'SPD'} ) ) {
900                         $qossettings{'VALID'} = 'no';
901                         $message = "Mindestbandbreite ist ungueltig.";
902                 }
903                 $qossettings{'SPD'} = '';
904         }
905 }
906 sub validmaxbwdth {
907         if ( $qossettings{'VALID'} eq 'yes' ) {
908                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
909                         $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
910                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
911                         $qossettings{'SPD'} = $qossettings{'INC_SPD'};
912                 }
913                 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
914                         $qossettings{'VALID'} = 'no';
915                         $message = "Mamimalbandbreite ist ungueltig.";
916                 }
917                 $qossettings{'SPD'} = '';
918         }
919 }
920
921 sub validclass {
922         if ( $qossettings{'VALID'} eq 'yes' ) {
923                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
924                         if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
925                                 $qossettings{'VALID'} = 'no';
926                                 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
927                         }
928                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
929                         if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
930                                 $qossettings{'VALID'} = 'no';
931                                 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
932                         }
933                 }
934                 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
935                 @tmp = <FILE>;
936                 close FILE;
937                 foreach $classentry (sort @tmp)
938                 {
939                         @tmpline = split( /\;/, $classentry );
940                         if ( $tmpline[1] eq $qossettings{'CLASS'} )
941                         {
942                                 $qossettings{'VALID'} = 'no';
943                                 $message = "Die aktuelle Klasse wird bereits verwendet.";
944                                 last
945                         }
946                 }
947         }
948 }
949 sub validsubclass {
950         if ( $qossettings{'VALID'} eq 'yes' ) {
951                 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
952                 @tmp = <FILE>;
953                 close FILE;
954                 foreach $subclassentry (sort @tmp)
955                 {
956                         @tmpline = split( /\;/, $subclassentry );
957                         if ( $tmpline[2] eq $qossettings{'SCLASS'} )
958                         {
959                                 $qossettings{'VALID'} = 'no';
960                                 $message = "Die aktuelle Klasse wird bereits verwendet.";
961                                 last
962                         }
963                 }
964         }
965 }