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