HinzugefĆ¼gt:
[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 $portruleentry = "";
30 my @tmp = ();
31 my @classes = ();
32 my @subclasses = ();
33 my @l7rules = ();
34 my @portrules = ();
35 my @tmpline = ();
36 my @classline = ();
37 my @subclassline = ();
38 my @l7ruleline = ();
39 my @portruleline = ();
40 my @proto = ();
41 my %selected= () ;
42 my $classfile = "/var/ipfire/qos/classes";
43 my $subclassfile = "/var/ipfire/qos/subclasses";
44 my $level7file = "/var/ipfire/qos/level7config";
45 my $portfile = "/var/ipfire/qos/portconfig";
46 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
47
48 &Header::showhttpheaders();
49
50 $qossettings{'ENABLED'} = 'off';
51 $qossettings{'EDIT'} = 'no';
52 $qossettings{'OUT_SPD'} = '';
53 $qossettings{'INC_SPD'} = '';
54 $qossettings{'DEF_OUT_SPD'} = '';
55 $qossettings{'DEF_INC_SPD'} = '';
56 $qossettings{'DEFCLASS_INC'} = '';
57 $qossettings{'DEFCLASS_OUT'} = '';
58 $qossettings{'ACK'} = '';
59 $qossettings{'MTU'} = '1492';
60 $qossettings{'QLENGTH'} = '30';
61 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
62 $qossettings{'IMQ_DEV'} = 'imq0';
63 $qossettings{'VALID'} = 'yes';
64 ### Values that have to be initialized
65 $qossettings{'ACTION'} = '';
66 $qossettings{'ACTIONDEF'} = '';
67 $qossettings{'ACTIONBW'} = '';
68 $qossettings{'PRIO'} = '';
69 $qossettings{'SPD'} = '';
70 $qossettings{'CLASS'} = '';
71 $qossettings{'SCLASS'} = '';
72 $qossettings{'QPORT'} = '';
73 $qossettings{'DPORT'} = '';
74 $qossettings{'QIP'} = '';
75 $qossettings{'DIP'} = '';
76 $qossettings{'PPROT'} = '';
77 $qossettings{'L7PROT'} = '';
78 $qossettings{'DEVICE'} = '';
79 $qossettings{'MINBWDTH'} = '';
80 $qossettings{'MAXBWDTH'} = '';
81 $qossettings{'BURST'} = '';
82 $qossettings{'CBURST'} = '';
83 $qossettings{'DOCLASS'} = '';
84 $qossettings{'DOSCLASS'} = '';
85 $qossettings{'DOLEVEL7'} = '';
86 $qossettings{'DOPORT'} = '';
87
88
89 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
90 &Header::getcgihash(\%qossettings);
91
92 &Header::openpage('QoS', 1, '');
93
94 print <<END
95 <script type="text/javascript">
96 <!--
97 function BorderOn (id) { id.className='btnOn'  }
98 function BorderOff(id) { id.className='btnOff' }
99 //-->
100 </script>
101 <style type=text/css>
102 .btnOn {
103         border-right: #D5F0FF 2px Inset;
104         border-top: #D5F0FF 2px Inset;
105         border-left: #D5F0FF 2px Inset;
106         border-bottom: #D5F0FF 2px Inset;
107        text-align: Center;
108        text-decoration: None;
109         background-color: #FFFFFF;
110 }
111 .btnOff {
112         border-right: #D5F0FF 2px Outset;
113         border-top: #D5F0FF 2px Outset;
114         border-left: #D5F0FF 2px Outset;
115         border-bottom: #D5F0FF 2px Outset;
116         text-align: Center;
117         text-decoration: None;
118         background-color: #FFFFFF;
119 }
120 </style>
121 END
122 ;
123
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'};
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{'EDIT'} = 'yes';
164                 }
165         }
166         close FILE;
167         &parentclass();
168         &Header::closebigbox();
169         &Header::closepage();
170         exit
171 }
172 elsif ($qossettings{'DOCLASS'} eq 'Loeschen')
173 {
174         open( FILE, "< $classfile" ) or die "Unable to read $classfile";
175         @tmp = <FILE>;
176         close FILE;
177         open( FILE, "> $classfile" ) or die "Unable to write $classfile";
178         foreach $classentry (sort @tmp)
179         {
180                 @tmpline = split( /\;/, $classentry );
181                 if ( $tmpline[1] ne $qossettings{'CLASS'} )
182                 {
183                         print FILE $classentry;
184                 }
185         }
186         close FILE;
187         open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
188         @tmp = <FILE>;
189         close FILE;
190         open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
191         foreach $subclassentry (sort @tmp)
192         {
193                 @tmpline = split( /\;/, $subclassentry );
194                 if ( $tmpline[1] ne $qossettings{'CLASS'} )
195                 {
196                         print FILE $subclassentry;
197                 }
198         }
199         close FILE;
200         $message = "Klasse $qossettings{'CLASS'} wurde mit eventuell vorhandenen Unterklassen geloescht.";
201 }
202
203 ############################################################################################################################
204 ############################################################################################################################
205
206 if ($qossettings{'DOSCLASS'} eq $Lang::tr{'save'})
207 {
208         if ($qossettings{'SCLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
209                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
210         } elsif ($qossettings{'SCLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
211                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
212         }
213         &validsubclass();
214         &validminbwdth();
215         if ( $qossettings{'VALID'} eq 'yes' ) {
216                 open( FILE, ">> $subclassfile" ) or die "Unable to write $subclassfile";
217                 print FILE <<END
218 $qossettings{'DEVICE'};$qossettings{'CLASS'};$qossettings{'SCLASS'};$qossettings{'PRIO'};$qossettings{'MINBWDTH'};$qossettings{'MAXBWDTH'};$qossettings{'BURST'};$qossettings{'CBURST'};
219 END
220 ;
221                 close FILE;
222         } else {
223                 $qossettings{'ACTION'} = 'Unterklasse hinzufuegen';
224         }
225 } elsif ($qossettings{'DOSCLASS'} eq 'Loeschen')
226 {
227         open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
228         @tmp = <FILE>;
229         close FILE;
230         open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
231         foreach $subclassentry (sort @tmp)
232         {
233                 @tmpline = split( /\;/, $subclassentry );
234                 if ( $tmpline[2] ne $qossettings{'CLASS'} )
235                 {
236                         print FILE $subclassentry;
237                 }
238         }
239         close FILE;
240         $message = "Unterklasse $qossettings{'CLASS'} wurde geloescht.";
241 }
242
243 ############################################################################################################################
244 ############################################################################################################################
245
246 if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'})
247 {
248         if ( $qossettings{'QIP'} ne '' ) {
249                 unless ( &General::validip($qossettings{'QIP'}) ) { 
250                         $qossettings{'VALID'} = 'no';
251                         $message = "Die Quell-IP-Adresse ist ungueltig."; 
252                 }
253         }
254         if ( $qossettings{'DIP'} ne '' ) {
255                 unless ( &General::validip($qossettings{'DIP'}) ) { 
256                         $qossettings{'VALID'} = 'no';
257                         $message = "Die Ziel-IP-Adresse ist ungueltig."; 
258                 }
259         }
260         if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
261                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
262         } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
263                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
264         } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
265                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
266         } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
267                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
268         }
269         if ( $qossettings{'VALID'} eq 'yes' ) {
270                 open( FILE, ">> $level7file" ) or die "Unable to write $level7file";
271                 print FILE <<END
272 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'L7PROT'};$qossettings{'QIP'};$qossettings{'DIP'};
273 END
274 ;
275                 close FILE;
276         } else {
277                 $qossettings{'ACTION'} = 'Level7-Regel hinzufuegen';
278         }
279
280 elsif ($qossettings{'DOLEVEL7'} eq 'Loeschen')
281 {
282         open( FILE, "< $level7file" ) or die "Unable to read $level7file";
283         @l7rules = <FILE>;
284         close FILE;
285         open( FILE, "> $level7file" ) or die "Unable to read $level7file";
286         foreach $l7ruleentry (sort @l7rules)
287         {
288                 @l7ruleline = split( /\;/, $l7ruleentry );
289                 if ( ($l7ruleline[0] ne $qossettings{'CLASS'}) && ($l7ruleline[2] ne $qossettings{'L7PROT'}))
290                 {
291                         print FILE $l7ruleentry;
292                 }
293         }
294         close FILE;
295         $message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";
296 }
297
298 ############################################################################################################################
299 ############################################################################################################################
300
301 if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
302 {
303         if ( $qossettings{'QIP'} ne '' ) {
304                 unless ( &General::validip($qossettings{'QIP'}) ) { 
305                         $qossettings{'VALID'} = 'no';
306                         $message = "Die Quell-IP-Adresse ist ungueltig."; 
307                 }
308         }
309         if ( $qossettings{'DIP'} ne '' ) {
310                 unless ( &General::validip($qossettings{'DIP'}) ) { 
311                         $qossettings{'VALID'} = 'no';
312                         $message = "Die Ziel-IP-Adresse ist ungueltig."; 
313                 }
314         }
315         if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
316                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
317         } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
318                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
319         } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
320                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
321         } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
322                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
323         }
324         if ( $qossettings{'VALID'} eq 'yes' ) {
325                 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
326                 print FILE <<END
327 $qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
328 END
329 ;
330                 close FILE;
331         } else {
332                 $qossettings{'ACTION'} = 'Port-Regel hinzufuegen';
333         }
334 } elsif ($qossettings{'DOPORT'} eq 'Loeschen')
335 {
336         open( FILE, "< $portfile" ) or die "Unable to read $portfile";
337         @portrules = <FILE>;
338         close FILE;
339         open( FILE, "> $portfile" ) or die "Unable to read $portfile";
340         foreach $portruleentry (sort @portrules)
341         {
342                 @portruleline = split( /\;/, $portruleentry );
343                 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'}))
344                 {
345                         print FILE $portruleentry;
346                 }
347         }
348         close FILE;
349         $message = "Port-Regel ($qossettings{'CLASS'} - $qossettings{'PPROT'}) wurde geloescht.";
350 }
351
352 ############################################################################################################################
353 ############################################################################################################################
354
355 if ($qossettings{'ACTION'} eq 'Start')
356 {
357         system("sleep 2 && /usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh &");
358         system("/bin/touch /var/ipfire/qos/enable");
359         $qossettings{'ENABLED'} = 'on';
360         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
361 }
362 elsif ($qossettings{'ACTION'} eq 'Stop')
363 {
364         unlink "/var/ipfire/qos/bin/qos.sh";
365         unlink "/var/ipfire/qos/enable";
366         $qossettings{'ENABLED'} = 'off';
367         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
368 }
369 elsif ($qossettings{'ACTION'} eq 'Neustart')
370 {
371         if ($qossettings{'ENABLED'} eq 'on'){
372                 system("sleep 2 && /usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh &");
373         }
374 }
375 elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
376 {
377         if ($qossettings{'DEF_INC_SPD'} eq '') {
378                 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
379         }
380         if ($qossettings{'DEF_OUT_SPD'} eq '') {
381                 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
382         }
383         &General::writehash("${General::swroot}/qos/settings", \%qossettings);
384 }
385 elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen')
386 {
387         &parentclass();
388         &Header::closebigbox();
389         &Header::closepage();
390         exit
391 }
392 elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen')
393 {
394         &subclass();
395         &Header::closebigbox();
396         &Header::closepage();
397         exit
398 }
399 elsif ($qossettings{'ACTION'} eq 'Level7-Regel hinzufuegen')
400 {
401         &level7rule();
402         &Header::closebigbox();
403         &Header::closepage();
404         exit
405 }
406 elsif ($qossettings{'ACTION'} eq 'Port-Regel hinzufuegen')
407 {
408         &portrule();
409         &Header::closebigbox();
410         &Header::closepage();
411         exit
412 }
413 elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen')
414 {
415         &expert();
416         &Header::closebigbox();
417         &Header::closepage();
418         exit
419 }
420 if ($qossettings{'ACTIONBW'} eq 'Andern')
421 {
422         &changebandwidth();
423         &Header::closebigbox();
424         &Header::closepage();
425         exit
426 }
427 if ($qossettings{'ACTIONDEF'} eq 'Andern')
428 {
429         &changedefclasses();
430         &Header::closebigbox();
431         &Header::closepage();
432         exit
433 }
434
435 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
436
437 my $status = $Lang::tr{'stopped'};
438 my $statuscolor = '#993333';
439 if ( $qossettings{'ENABLED'} eq 'on' ) {
440   $status = $Lang::tr{'running'};
441   $statuscolor = '#339933';
442 }
443
444 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
445         $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
446 }
447
448 if ($errormessage) {
449         &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
450         print "<class name='base'>$errormessage\n";
451         print "&nbsp;</class>\n";
452         &Header::closebox();
453 }
454
455 ############################################################################################################################
456 ############################################################################################################################
457
458 &Header::openbox('100%', 'center', 'Quality of Service');
459 print <<END
460         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
461         <table width='33%'>
462 END
463 ;
464         if ( $message ne "" ) {
465                 print "<tr><td colspan='2' align='center'><font color='red'>$message</font>";
466         }
467         print <<END
468                 <tr><td width='50%' align='left'><b>Quality of Service:</b>
469                     <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font>
470                 <tr><td width='100%' align='center' colspan='2'>
471                 <input type='submit' name='ACTION' value='Start' /> 
472                 <input type='submit' name='ACTION' value='Stop' /> 
473                 <input type='submit' name='ACTION' value='$Lang::tr{'restart'}' />
474 END
475 ;
476         if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
477                 print <<END
478                 <tr><td colspan='3'>&nbsp;
479                 <tr><td width='40%' align='right'>Downloadgeschwindigkeit:      <td width='40%' align='left'>$qossettings{'INC_SPD'} kbps
480                     <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='Andern'>
481                 <tr><td width='40%' align='right'>Uploadgeschwindigkeit:        <td width='40%' align='left'>$qossettings{'OUT_SPD'} kbps
482 END
483 ;
484         }
485         if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
486                 print <<END
487                 <tr><td colspan='3'><hr>
488                 <tr><td width='40%' align='right'>Downloadstandardklasse:       <td width='40%' align='left'>$qossettings{'DEFCLASS_INC'}       
489                     <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='Andern'>
490                 <tr><td width='40%' align='right'>Uploadstandardklasse:         <td width='40%' align='left'>$qossettings{'DEFCLASS_OUT'}
491                 <tr><td width='40%' align='right'>ACKs:                         <td width='40%' align='left'>$qossettings{'ACK'}
492                 <tr><td colspan='3' width='100%'><hr>
493                 <tr><td colspan='3' width='100%' align='center'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Parentklasse hinzufuegen'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Erweiterte Einstellungen'>
494         </form>
495 END
496 ;
497         }
498 print "</table>";
499 &Header::closebox();
500
501 if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
502         &changebandwidth();
503         &Header::closebox();
504         &Header::closebigbox();
505         &Header::closepage();
506         exit
507 }
508
509 if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
510         &changedefclasses();
511         &Header::closebigbox();
512         &Header::closepage();
513         exit
514 }
515
516 &showclasses();
517 &showl7rules();
518 &showportrules();
519
520 &Header::closebigbox();
521 &Header::closepage();
522
523 ############################################################################################################################
524 ############################################################################################################################
525
526 sub changedefclasses {
527         &Header::openbox('100%', 'center', 'Standardklassen:');
528         print <<END
529                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
530                 <table width='66%'>
531                 <tr><td width='100%' colspan='3'>Legen sie hier die Standardklassen fest durch die nicht-gefilterte Pakete gehen.
532                 <tr><td width='33%' align='right'>Download:<td width='33%' align='left'><select name='DEFCLASS_INC'>
533 END
534 ;
535                 for ( $c = 200 ; $c <= 220 ; $c++ )
536                 {
537                         if ( $qossettings{'DEFCLASS_INC'} ne $c )
538                         { print "<option value='$c'>$c</option>\n"; } 
539                         else    { print "<option selected value='$c'>$c</option>\n"; }
540                 }
541                 print <<END
542                 </select><td width='33%' align='center'>&nbsp;
543                 <tr><td width='33%' align='right'>Upload:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
544 END
545 ;
546                 for ( $c = 100 ; $c <= 120 ; $c++ )
547                 {
548                         if ( $qossettings{'DEFCLASS_OUT'} ne $c )
549                         { print "<option value='$c'>$c</option>\n"; }
550                         else { print "<option selected value='$c'>$c</option>\n"; }
551                 }
552                 print <<END
553                 </select><td width='33%' align='center'>&nbsp;
554                 </table>
555                 <hr>
556                 <table width='66%'>
557                 <tr><td width='100%' colspan='3'>Legen sie hier die ACK-Klasse fest <br> und klicken Sie danach auf <i>Speichern</i>.
558                 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
559 END
560 ;
561                 for ( $c = 100 ; $c <= 120 ; $c++ )
562                 {
563                         if ( $qossettings{'ACK'} ne $c )
564                         { print "<option value='$c'>$c</option>\n"; }
565                         else {  print "<option selected value='$c'>$c</option>\n"; }
566                 }
567                 print <<END
568                 </select><td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
569                 </table>
570                 </form>
571 END
572 ;
573         &Header::closebox();
574 }
575
576 sub changebandwidth {
577         &Header::openbox('100%', 'center', 'Bandbreiteneinstellungen');
578         if ($qossettings{'ENABLED'} eq 'on') {
579                 print "Sie koennen die Bandbreiteneinstellungen nicht bearbeiten, wenn QoS eingeschaltet ist. Schalten sie es zuerst dazu aus.<p>";
580                 print "<a href='/cgi-bin/qos.cgi'>Zurueck</a>";
581         } else {
582                 print <<END
583                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
584                 <input type='hidden' name='DEF_OUT_SPD' value=''><input type='hidden' name='DEF_INC_SPD' value=''>
585                 <table width='66%'>
586                 <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>.
587                 <tr><td width='33%' align='right'>Download-Geschwindigkeit:
588                     <td width='33%' align='left'><input type='text' name='INC_SPD' maxlength='8' value=$qossettings{'INC_SPD'}> &nbsp; kbps
589                     <td width='33%' align='center'>&nbsp;
590                 <tr><td width='33%' align='right'>Upload-Geschwindigkeit:
591                     <td width='33%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value=$qossettings{'OUT_SPD'}> &nbsp; kbps
592                     <td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />&nbsp;<input type='reset' name='ACTION' value=$Lang::tr{'reset'} />
593                 </table>
594                 </form>
595 END
596 ;
597         }
598         &Header::closebox();
599 }
600
601 sub parentclass {
602         &Header::openbox('100%', 'center', 'Parentklasse');
603         print <<END
604                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
605                 <table width='66%'>
606 END
607 ;
608         if ( $message ne "" ) {
609                 print "<tr><td colspan='3' align='center'>$message";
610         }
611         if ( $qossettings{'EDIT'} eq 'yes' ) { 
612                 print "<input type='hidden' name='CLASS' value=$qossettings{'CLASS'}>";
613                 print "<input type='hidden' name='DEVICE' value=$qossettings{'DEVICE'}>";
614         }
615         print <<END
616                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
617                 <tr><td width='33%' align='right'>Interface:
618                     <td width='33%' align='left'>
619 END
620 ;
621                 if ( $qossettings{'EDIT'} eq 'yes' ) { 
622                         print "<select name='DEVICE' disabled>";
623                 } else {
624                         print "<select name='DEVICE'>";
625                 }
626                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
627                         $qossettings{'RED_DEV_SEL'} = 'selected';
628                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
629                         $qossettings{'IMQ_DEV_SEL'} = 'selected';
630                 }
631                 print <<END
632                         <option value=$qossettings{'RED_DEV'} $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
633                         <option value=$qossettings{'IMQ_DEV'} $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
634                     <td width='33%' align='center'>&nbsp;
635                 <tr><td width='33%' align='right'>Klasse:<td width='33%' align='left'>
636 END
637 ;
638                 if ( $qossettings{'EDIT'} eq 'yes' ) { 
639                         print "<select name='CLASS' disabled>";
640                 } else {
641                         print "<select name='CLASS'>";
642                 }
643                 for ( $c = 100 ; $c <= 120 ; $c++ )
644                 {
645                         if ( $qossettings{'CLASS'} ne $c )
646                         { print "<option value='$c'>$c</option>\n"; }
647                         else { print "<option selected value='$c'>$c</option>\n"; }
648                 }
649                 for ( $c = 200 ; $c <= 220 ; $c++ )
650                 {
651                         if ( $qossettings{'CLASS'} ne $c )
652                         { print "<option value='$c'>$c</option>\n"; }
653                         else { print "<option selected value='$c'>$c</option>\n"; }
654                 }
655                 print <<END
656                 </select>
657                 <td width='33%' align='center'>&nbsp;
658                 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
659 END
660 ;
661                 for ( $c = 1 ; $c <= 7 ; $c++ )
662                 {
663                         if ( $qossettings{'PRIO'} ne $c )
664                         { print "<option value='$c'>$c</option>\n"; }
665                         else { print "<option selected value='$c'>$c</option>\n"; }
666                 }
667                 print <<END
668                 <td width='33%' align='center'>&nbsp;
669                 <tr><td width='33%' align='right'>Garantierte Bandbreite:
670                     <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value=$qossettings{'MINBWDTH'} >
671                     <td width='33%' align='center'>&nbsp;
672                 <tr><td width='33%' align='right'>Maximale Bandbreite:
673                     <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value=$qossettings{'MAXBWDTH'}>
674                     <td width='33%' align='center'>&nbsp;
675                 <tr><td width='33%' align='right'>Burst:
676                     <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value=$qossettings{'BURST'}>
677                     <td width='33%' align='center'>&nbsp;
678                 <tr><td width='33%' align='right'>Ceilburst:
679                     <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
680                     <td width='33%' align='center'><input type='submit' name='DOCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
681                 </table></form>
682 END
683 ;
684         &Header::closebox();
685 }
686
687 sub subclass {
688         &Header::openbox('100%', 'center', 'Unterklasse');
689         print <<END
690                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
691                 <table width='66%'>
692 END
693 ;
694         if ( $message ne "" ) {
695                 print "<tr><td colspan='3' align='center'>$message";
696         }
697         print <<END
698                 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
699                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
700                 <tr><td width='33%' align='right'>Unterklasse:<td width='33%' align='left'><select name='SCLASS'>
701 END
702 ;
703         if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
704                 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
705                 for ( $c = 1000 ; $c <= 1020 ; $c++ )
706                 {
707                         if ( $qossettings{'SCLASS'} ne $c )
708                         { print "<option value='$c'>$c</option>\n"; }
709                         else { print "<option selected value='$c'>$c</option>\n"; }
710                 }
711         } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
712                 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
713                 for ( $c = 2000 ; $c <= 2020 ; $c++ )
714                 {
715                         if ( $qossettings{'SCLASS'} ne $c )
716                         { print "<option value='$c'>$c</option>\n"; }
717                         else { print "<option selected value='$c'>$c</option>\n"; }
718                 }
719         }
720         print <<END
721                 </select>
722                 <td width='33%' align='center'>&nbsp;
723                 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
724 END
725 ;
726                 for ( $c = 1 ; $c <= 7 ; $c++ )
727                 {
728                         if ( $qossettings{'PRIO'} ne $c )
729                         { print "<option value='$c'>$c</option>\n"; }
730                         else { print "<option selected value='$c'>$c</option>\n"; }
731                 }
732                 print <<END
733                 <td width='33%' align='center'>&nbsp;
734                 <tr><td width='33%' align='right'>Garantierte Bandbreite:
735                     <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value=$qossettings{'MINBWDTH'} >
736                     <td width='33%' align='center'>&nbsp;
737                 <tr><td width='33%' align='right'>Maximale Bandbreite:
738                     <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value=$qossettings{'MAXBWDTH'}>
739                     <td width='33%' align='center'>&nbsp;
740                 <tr><td width='33%' align='right'>Burst:
741                     <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value=$qossettings{'BURST'}>
742                     <td width='33%' align='center'>&nbsp;
743                 <tr><td width='33%' align='right'>Ceilburst:
744                     <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
745                     <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DOSCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
746                 </table></form>
747 END
748 ;
749         &Header::closebox();
750 }
751
752 sub level7rule {
753         &Header::openbox('100%', 'center', 'Level7-Regel');
754         print <<END
755                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
756                 <table width='66%'>
757 END
758 ;
759         if ( $message ne "" ) {
760                 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
761         }
762         print <<END
763                 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
764                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
765                 <tr><td width='33%' align='right'>Protokoll:
766                     <td width='33%' align='left'><select name='L7PROT'>
767 END
768 ;
769                 opendir( DIR, "/etc/l7-protocols/protocols" );
770                 foreach $direntry ( sort readdir(DIR) )
771                 {
772                         next if $direntry eq ".";
773                         next if $direntry eq "..";
774                         next if -d "/etc/l7-protocols/protocols/$direntry";
775                         @proto = split( /\./, $direntry );
776                         if ( $proto[0] eq $qossettings{'L7PROT'} ) {
777                                 print "<option value='$proto[0]' selected>$proto[0]</option>\n";                        
778                         } else {
779                                 print "<option value='$proto[0]'>$proto[0]</option>\n";
780                         }
781                 }
782                 closedir DIR;
783         print <<END
784                     </select><td width='33%' align='center'>&nbsp;
785                 <tr><td width='33%' align='right'>Quell-IP-Adresse:
786                     <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'}>
787                     <td width='33%' align='center'>&nbsp;
788                 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
789                     <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'}>
790                     <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DOLEVEL7' value=$Lang::tr{'save'} />
791                 </table></form>
792 END
793 ;
794         &Header::closebox();
795 }
796
797 sub portrule {
798         &Header::openbox('100%', 'center', 'Port-Regel hinzufuegen');
799         print <<END
800                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
801                 <table width='66%'>
802                 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
803                 <tr><td width='33%' align='right'>Protokoll:
804                     <td width='33%' align='left'><select name='PPROT'>
805 END
806 ;
807                         open( FILE, "< /etc/protocols" );
808                         @proto = <FILE>;
809                         close FILE;
810                         foreach $direntry (sort @proto)
811                         {
812                                 @tmpline = split( /\ /, $direntry );
813                                 next if $tmpline[0] =~ "#";
814                                 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
815                                         print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";                    
816                                 } else {
817                                         print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
818                                 }
819                         }
820         print <<END
821                     </select><td width='33%' align='center'>&nbsp;
822                 <tr><td width='33%' align='right'>Quell-Port:
823                     <td width='33%' align='left'><input type='text' name='QPORT' maxlength='5' value=$qossettings{'QPORT'}>
824                     <td width='33%' align='center'>&nbsp;
825                 <tr><td width='33%' align='right'>Ziel-Port:
826                     <td width='33%' align='left'><input type='text' name='DPORT' maxlength='5' value=$qossettings{'DPORT'}>
827                     <td width='33%' align='center'>&nbsp;
828                 <tr><td width='33%' align='right'>Quell-IP-Adresse:
829                     <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'}>
830                     <td width='33%' align='center'>&nbsp;
831                 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
832                     <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'}>
833                     <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}'><input type='submit' name='DOPORT' value=$Lang::tr{'save'} />
834                 </table></form>
835 END
836 ;
837         &Header::closebox();
838 }
839
840 sub showclasses {
841         open( FILE, "< $classfile" ) or die "Unable to read $classfile";
842         @classes = <FILE>;
843         close FILE;
844         if (@classes) {
845                 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
846                 @subclasses = <FILE>;
847                 close FILE;
848                 &Header::openbox('100%', 'center', 'Klassen');
849                 print <<END
850                 <table border='0' width='100%' cellspacing='0'>
851                 <tr><td bgcolor='lightgrey' width='10%'>Interface
852                     <td bgcolor='lightgrey' width='10%'>Klasse
853                     <td bgcolor='lightgrey' width='10%'>Prioritaet
854                     <td bgcolor='lightgrey' width='10%'>Garantierte Bandbreite
855                     <td bgcolor='lightgrey' width='10%'>Maximale Bandbreite
856                     <td bgcolor='lightgrey' width='10%'>Burst
857                     <td bgcolor='lightgrey' width='10%'>Ceil Burst
858                     <td bgcolor='lightgrey' width='30%'>Aktionen
859 END
860 ;
861                 foreach $classentry (sort @classes)
862                 {
863                         @classline = split( /\;/, $classentry );
864                         if ( $classline[0] eq $qossettings{'RED_DEV'} )
865                         {
866                                 print <<END
867                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
868                                 <tr><td align='center' bgcolor='#EAEAEA'>$classline[0]
869                                     <td align='center' bgcolor='#EAEAEA'>$classline[1]
870                                     <td align='center' bgcolor='#EAEAEA'>$classline[2]
871                                     <td align='center' bgcolor='#EAEAEA'>$classline[3]
872                                     <td align='center' bgcolor='#EAEAEA'>$classline[4]
873                                     <td align='center' bgcolor='#EAEAEA'>$classline[5]
874                                     <td align='center' bgcolor='#EAEAEA'>$classline[6]
875                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
876                                         <button type='submit' name='DOCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
877                                         <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;
878                                         <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;
879                                         <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;
880                                         <button type='submit' name='DOCLASS' 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                                 foreach $subclassentry (sort @subclasses)
885                                 {
886                                         @subclassline = split( /\;/, $subclassentry );
887                                         if ( $subclassline[1] eq $classline[1] ) {
888                                                 print <<END
889                                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
890                                                         <tr><td align='center' bgcolor='#FFFFFF'>Subklasse:
891                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
892                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
893                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
894                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
895                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
896                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
897                                                             <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
898                                                                 <button type='submit' name='DOSCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
899                                                                 <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;
900                                                                 <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;
901                                                                 <button type='submit' name='DOSCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
902                                                 </form>
903 END
904 ;
905                                         }
906                                 }
907                         }
908                 }
909                 print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
910                 foreach $classentry (sort @classes)
911                 {
912                         @classline = split( /\;/, $classentry );
913                         if ( $classline[0] eq $qossettings{'IMQ_DEV'} )
914                         {
915                                 print <<END
916                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
917                                 <tr><td align='center' bgcolor='#EAEAEA'>$classline[0]
918                                     <td align='center' bgcolor='#EAEAEA'>$classline[1]
919                                     <td align='center' bgcolor='#EAEAEA'>$classline[2]
920                                     <td align='center' bgcolor='#EAEAEA'>$classline[3]
921                                     <td align='center' bgcolor='#EAEAEA'>$classline[4]
922                                     <td align='center' bgcolor='#EAEAEA'>$classline[5]
923                                     <td align='center' bgcolor='#EAEAEA'>$classline[6]
924                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
925                                         <button type='submit' name='DOCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
926                                         <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;
927                                         <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;
928                                         <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;
929                                         <button type='submit' name='DOCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
930                                 </form>
931 END
932 ;
933                                 foreach $subclassentry (sort @subclasses)
934                                 {
935                                         @subclassline = split( /\;/, $subclassentry );
936                                         if ( $subclassline[1] eq $classline[1] ) {
937                                                 print <<END
938                                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
939                                                         <tr><td align='center' bgcolor='#FFFFFF'>Subklasse:
940                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
941                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
942                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
943                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
944                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
945                                                             <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
946                                                             <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
947                                                                 <button type='submit' name='DOSCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
948                                                                 <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;
949                                                                 <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;
950                                                                 <button type='submit' name='DOSCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
951                                                 </form>
952 END
953 ;
954                                         }
955                                 }
956                         }
957                 }
958                 print <<END
959                 <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Klasse bearbeiten | <img src='/images/addblue.gif'>&nbsp;Unterklasse hinzufuegen | <img src='/images/addgreen.gif'>&nbsp;Level7-Regel hinzufuegen | <img src='/images/add.gif'>&nbsp;Port-Regel hinzufuegen | <img src='/images/delete.gif'>&nbsp;Klasse loeschen &nbsp;
960                 </table>
961 END
962 ;
963                 &Header::closebox();
964         }
965 }
966
967 sub showl7rules {
968         open( FILE, "< $level7file" ) or die "Unable to read $level7file";
969         @l7rules = <FILE>;
970         close FILE;
971         if (@l7rules) {
972                 &Header::openbox('100%', 'center', 'Level7-Regeln');
973                 print <<END
974                 <table border='0' width='100%' cellspacing='0'>
975                 <tr><td bgcolor='lightgrey' width='14%'>Interface
976                     <td bgcolor='lightgrey' width='14%'>Klasse
977                     <td bgcolor='lightgrey' width='14%'>Protokoll
978                     <td bgcolor='lightgrey' width='14%'>Quell-IP-Adresse
979                     <td bgcolor='lightgrey' width='14%'>Ziel-IP-Adresse
980                     <td bgcolor='lightgrey' width='30%'>Aktionen
981 END
982 ;
983                 foreach $l7ruleentry (sort @l7rules)
984                 {
985                         @l7ruleline = split( /\;/, $l7ruleentry );
986                         if ( $l7ruleline[1] eq $qossettings{'RED_DEV'} )
987                         {
988                                 print <<END
989                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
990                                 <tr><td align='center' bgcolor='#EAEAEA'>$l7ruleline[1]
991                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[0]
992                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[2]
993                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
994                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
995                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
996                                         <button type='submit' name='DOLEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
997                                         <button type='submit' name='DOLEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
998                                 </form>
999 END
1000 ;
1001                         }
1002                 }
1003                 print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
1004                 foreach $l7ruleentry (sort @l7rules)
1005                 {
1006                         @l7ruleline = split( /\;/, $l7ruleentry );
1007                         if ( $l7ruleline[1] eq $qossettings{'IMQ_DEV'} )
1008                         {
1009                                 print <<END
1010                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1011                                 <tr><td align='center' bgcolor='#EAEAEA'>$l7ruleline[1]
1012                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[0]
1013                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[2]
1014                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
1015                                     <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
1016                                     <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
1017                                         <button type='submit' name='DOLEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
1018                                         <button type='submit' name='DOLEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
1019                                 </form>
1020 END
1021 ;
1022                         }
1023                 }
1024                 print <<END
1025                 <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Regel bearbeiten | <img src='/images/delete.gif'>&nbsp;Regel loeschen &nbsp;
1026                 </table>
1027 END
1028 ;
1029                 &Header::closebox();
1030         }
1031 }
1032
1033 sub showportrules {
1034         open( FILE, "< $portfile" ) or die "Unable to read $portfile";
1035         @portrules = <FILE>;
1036         close FILE;
1037         if (@portrules) {
1038                 &Header::openbox('100%', 'center', 'Port-Regeln');
1039                 print <<END
1040                 <table border='0' width='100%' cellspacing='0'>
1041                 <tr><td bgcolor='lightgrey' width='10%'>Interface
1042                     <td bgcolor='lightgrey' width='10%'>Klasse
1043                     <td bgcolor='lightgrey' width='10%'>Protokoll
1044                     <td bgcolor='lightgrey' width='10%'>Quell-IP-Adresse
1045                     <td bgcolor='lightgrey' width='10%'>Quell-Port
1046                     <td bgcolor='lightgrey' width='10%'>Ziel-IP-Adresse
1047                     <td bgcolor='lightgrey' width='10%'>Ziel-Port
1048                     <td bgcolor='lightgrey' width='30%'>Aktionen
1049 END
1050 ;
1051                 foreach $portruleentry (sort @portrules)
1052                 {
1053                         @portruleline = split( /\;/, $portruleentry );
1054                         if ( $portruleline[1] eq $qossettings{'RED_DEV'} )
1055                         {
1056                                 print <<END
1057                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1058                                 <tr><td align='center' bgcolor='#EAEAEA'>$portruleline[1]
1059                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[0]
1060                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[2]
1061                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[3]
1062                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[4]
1063                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[5]
1064                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[6]
1065                                     <td align='right'  bgcolor='#EAEAEA'>
1066                                         <input type='hidden' name='CLASS' value='$portruleline[0]'>
1067                                         <input type='hidden' name='PPROT' value='$portruleline[2]'>
1068                                         <input type='hidden' name='QIP' value='$portruleline[3]'>
1069                                         <input type='hidden' name='QPORT' value='$portruleline[4]'>
1070                                         <input type='hidden' name='DIP' value='$portruleline[5]'>
1071                                         <input type='hidden' name='DPORT' value='$portruleline[6]'>
1072                                         <button type='submit' name='DOPORT' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
1073                                         <button type='submit' name='DOPORT' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
1074                                 </form>
1075 END
1076 ;
1077                         }
1078                 }
1079                 print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
1080                 foreach $portruleentry (sort @portrules)
1081                 {
1082                         @portruleline = split( /\;/, $portruleentry );
1083                         if ( $portruleline[1] eq $qossettings{'IMQ_DEV'} )
1084                         {
1085                                 print <<END
1086                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1087                                 <tr><td align='center' bgcolor='#EAEAEA'>$portruleline[1]
1088                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[0]
1089                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[2]
1090                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[3]
1091                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[4]
1092                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[5]
1093                                     <td align='center' bgcolor='#EAEAEA'>$portruleline[6]
1094                                     <td align='right'  bgcolor='#EAEAEA'>
1095                                         <input type='hidden' name='CLASS' value='$portruleline[0]'>
1096                                         <input type='hidden' name='PPROT' value='$portruleline[2]'>
1097                                         <input type='hidden' name='QIP' value='$portruleline[3]'>
1098                                         <input type='hidden' name='QPORT' value='$portruleline[4]'>
1099                                         <input type='hidden' name='DIP' value='$portruleline[5]'>
1100                                         <input type='hidden' name='DPORT' value='$portruleline[6]'>
1101                                         <button type='submit' name='DOPORT' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
1102                                         <button type='submit' name='DOPORT' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
1103                                 </form>
1104 END
1105 ;
1106                         }
1107                 }
1108                 print <<END
1109                 <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Regel bearbeiten | <img src='/images/delete.gif'>&nbsp;Regel loeschen &nbsp;
1110                 </table>
1111 END
1112 ;
1113                 &Header::closebox();
1114         }
1115 }
1116
1117 sub expert
1118 {
1119         &Header::openbox('100%', 'center', 'Expertenoptionen:');
1120         print <<END
1121                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1122                 <table width='66%'>
1123                 <tr><td width='100%' colspan='3'>Diese Einstellungen sollten sie nur veraendern, wenn sie wirklich wissen, was sie tun.
1124                 <tr><td width='33%' align='right'>Download-Rate 90\%:<td width='33%' align='left'>
1125                         <input type='text' name='DEF_INC_SPD' maxlength='8' required='4' value=$qossettings{'DEF_INC_SPD'}>
1126                     <td width='33%' align='center'>&nbsp;
1127                 <tr><td width='33%' align='right'>Upload-Rate 90\%:<td width='33%' align='left'>
1128                         <input type='text' name='DEF_OUT_SPD' maxlength='8' required='4' value=$qossettings{'DEF_OUT_SPD'}>
1129                     <td width='33%' align='center'>&nbsp;
1130                 </table>
1131                 <hr>
1132                 <table width='66%'>
1133                 <tr><td width='33%' align='right'>MTU:<td width='33%' align='left'>
1134                         <input type='text' name='MTU' maxlength='8' required='4' value=$qossettings{'MTU'}>
1135                     <td width='33%' align='center'>Diese Einstellung aendert die MTU nicht global sondern nur fuer das QoS.
1136                 <tr><td width='33%' align='right'>Queue Laenge:<td width='33%' align='left'>
1137                         <input type='text' name='QLENGTH' maxlength='8' required='2' value=$qossettings{'QLENGTH'}>
1138                     <td width='33%' align='center'>&nbsp;
1139                 <tr><td width='33%' align='right'>SFQ Perturb:<td width='33%' align='left'>
1140                         <input type='text' name='SFQ_PERTUB' maxlength='8' required='1' value=$qossettings{'SFQ_PERTUB'}>
1141                     <td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
1142                 </table>
1143                 </form>
1144 END
1145 ;
1146         &Header::closebox();
1147 }
1148
1149 sub validminbwdth {
1150         if ( $qossettings{'VALID'} eq 'yes' ) {
1151                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1152                         $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1153                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1154                         $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1155                 }
1156                 unless ( ( $qossettings{'MINBDWTH'} >= 0 ) && ( $qossettings{'MINBDWTH'} <= $qossettings{'SPD'} ) ) {
1157                         $qossettings{'VALID'} = 'no';
1158                         $message = "Mindestbandbreite ist ungueltig.";
1159                 }
1160                 $qossettings{'SPD'} = '';
1161         }
1162 }
1163
1164 sub validmaxbwdth {
1165         if ( $qossettings{'VALID'} eq 'yes' ) {
1166                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1167                         $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1168                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1169                         $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1170                 }
1171                 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1172                         $qossettings{'VALID'} = 'no';
1173                         $message = "Mamimalbandbreite ist ungueltig.";
1174                 }
1175                 $qossettings{'SPD'} = '';
1176         }
1177 }
1178
1179 sub validclass {
1180         if ( $qossettings{'VALID'} eq 'yes' ) {
1181                 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1182                         if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1183                                 $qossettings{'VALID'} = 'no';
1184                                 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
1185                         }
1186                 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1187                         if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1188                                 $qossettings{'VALID'} = 'no';
1189                                 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
1190                         }
1191                 }
1192                 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1193                 @tmp = <FILE>;
1194                 close FILE;
1195                 foreach $classentry (sort @tmp)
1196                 {
1197                         @tmpline = split( /\;/, $classentry );
1198                         if ( $tmpline[1] eq $qossettings{'CLASS'} )
1199                         {
1200                                 $qossettings{'VALID'} = 'no';
1201                                 $message = "Die aktuelle Klasse wird bereits verwendet.";
1202                                 last
1203                         }
1204                 }
1205         }
1206 }
1207
1208 sub validsubclass {
1209         if ( $qossettings{'VALID'} eq 'yes' ) {
1210                 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1211                 @tmp = <FILE>;
1212                 close FILE;
1213                 foreach $subclassentry (sort @tmp)
1214                 {
1215                         @tmpline = split( /\;/, $subclassentry );
1216                         if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1217                         {
1218                                 $qossettings{'VALID'} = 'no';
1219                                 $message = "Die aktuelle Klasse wird bereits verwendet.";
1220                                 last
1221                         }
1222                 }
1223         }
1224 }