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