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