Alpha2 - Aenderungen von Arne F. eingepflegt.
[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 }
263}
84cab473 264elsif ($qossettings{'DOLEVEL7'} eq 'Loeschen')
414e011d
MT
265{
266 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
267 @l7rules = <FILE>;
268 close FILE;
269 open( FILE, "> $level7file" ) or die "Unable to read $level7file";
270 foreach $l7ruleentry (sort @l7rules)
271 {
272 @l7ruleline = split( /\;/, $l7ruleentry );
273 if ( ($l7ruleline[0] ne $qossettings{'CLASS'}) && ($l7ruleline[2] ne $qossettings{'L7PROT'}))
274 {
275 print FILE $l7ruleentry;
276 }
277 }
278 close FILE;
279 $message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";
280}
84cab473
MT
281
282############################################################################################################################
283############################################################################################################################
284
285if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
286{
287 if ( $qossettings{'QIP'} ne '' ) {
288 unless ( &General::validip($qossettings{'QIP'}) ) {
289 $qossettings{'VALID'} = 'no';
290 $message = "Die Quell-IP-Adresse ist ungueltig.";
291 }
292 }
293 if ( $qossettings{'DIP'} ne '' ) {
294 unless ( &General::validip($qossettings{'DIP'}) ) {
295 $qossettings{'VALID'} = 'no';
296 $message = "Die Ziel-IP-Adresse ist ungueltig.";
297 }
298 }
299 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
300 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
301 } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
302 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
303 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
304 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
305 } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
306 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
307 }
308 if ( $qossettings{'VALID'} eq 'yes' ) {
309 open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
310 print FILE <<END
311$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
312END
313;
314 close FILE;
315 } else {
316 $qossettings{'ACTION'} = 'Port-Regel hinzufuegen';
317 }
318} elsif ($qossettings{'DOPORT'} eq 'Loeschen')
319{
320 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
321 @portrules = <FILE>;
322 close FILE;
323 open( FILE, "> $portfile" ) or die "Unable to read $portfile";
324 foreach $portruleentry (sort @portrules)
325 {
326 @portruleline = split( /\;/, $portruleentry );
327 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'}))
328 {
329 print FILE $portruleentry;
330 }
331 }
332 close FILE;
333 $message = "Port-Regel ($qossettings{'CLASS'} - $qossettings{'PPROT'}) wurde geloescht.";
334}
335
336############################################################################################################################
337############################################################################################################################
338
e8babc92
MT
339if ($qossettings{'DOTOS'} eq $Lang::tr{'save'})
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 open( FILE, ">> $tosfile" ) or die "Unable to write $tosfile";
351 print FILE <<END
352$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'TOS'};
353END
354;
355 close FILE;
356}
357elsif ($qossettings{'DOTOS'} eq 'Loeschen')
358{
359 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
360 @tosrules = <FILE>;
361 close FILE;
362 open( FILE, "> $tosfile" ) or die "Unable to read $tosfile";
363 foreach $tosruleentry (sort @tosrules)
364 {
365 @tosruleline = split( /\;/, $tosruleentry );
366 unless ( ($tosruleline[0] eq $qossettings{'CLASS'}) && ($tosruleline[2] eq $qossettings{'TOS'}))
367 {
368 print FILE $tosruleentry;
369 }
370 }
371 close FILE;
372 $message = "TOS-Regel ($qossettings{'CLASS'} - $qossettings{'TOS'}) wurde geloescht.";
373} elsif ($qossettings{'DOTOS'} eq 'Bearbeiten')
374{
375 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
376 @tosrules = <FILE>;
377 close FILE;
378 open( FILE, "> $tosfile" ) or die "Unable to write $tosfile";
379 foreach $tosruleentry (sort @tosrules)
380 {
381 @tosruleline = split( /\;/, $tosruleentry );
382 if (( $tosruleline[0] eq $qossettings{'CLASS'} ) && ( $tosruleline[2] eq $qossettings{'TOS'} )) {
383 $qossettings{'DEVICE'} = $tosruleline[1];
384 $qossettings{'CLASS'} = $tosruleline[0];
385 $qossettings{'TOS'} = $tosruleline[2];
386 $qossettings{'EDIT'} = 'yes';
387 } else {
388 print FILE $tosruleentry;
389 }
390 }
391 close FILE;
392 &tosrule();
393 &Header::closebigbox();
394 &Header::closepage();
395 exit
396}
397
398############################################################################################################################
399############################################################################################################################
400
904a41b9
MT
401if ($qossettings{'ACTION'} eq 'Start')
402{
cfd19520 403 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
9833e7d8 404 system("/usr/bin/touch /var/ipfire/qos/enable");
cfd19520 405 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 406 system("logger -t ipfire 'QoS started'");
904a41b9
MT
407 $qossettings{'ENABLED'} = 'on';
408 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
409}
410elsif ($qossettings{'ACTION'} eq 'Stop')
411{
a7fb5630 412 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
84cab473 413 unlink "/var/ipfire/qos/bin/qos.sh";
904a41b9 414 unlink "/var/ipfire/qos/enable";
a7fb5630 415 system("logger -t ipfire 'QoS stopped'");
904a41b9
MT
416 $qossettings{'ENABLED'} = 'off';
417 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
418}
84cab473
MT
419elsif ($qossettings{'ACTION'} eq 'Neustart')
420{
421 if ($qossettings{'ENABLED'} eq 'on'){
a7fb5630 422 system("/usr/local/bin/qosctrl stop >/dev/null 2>&1");
cfd19520
MT
423 system("/usr/local/bin/qosctrl generate >/dev/null 2>&1");
424 system("/usr/local/bin/qosctrl start >/dev/null 2>&1");
a7fb5630 425 system("logger -t ipfire 'QoS restarted'");
84cab473
MT
426 }
427}
904a41b9
MT
428elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
429{
84cab473
MT
430 if ($qossettings{'DEF_INC_SPD'} eq '') {
431 $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
432 }
433 if ($qossettings{'DEF_OUT_SPD'} eq '') {
434 $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
435 }
904a41b9
MT
436 &General::writehash("${General::swroot}/qos/settings", \%qossettings);
437}
92b5fba4
MT
438elsif ($qossettings{'ACTION'} eq 'Statusinformationen')
439{
440 &Header::openbox('100%', 'left', 'QoS Status');
441 if ($qossettings{'ENABLED'} eq 'on'){
442 my $output = "";
443 $output = `/usr/local/bin/qosctrl status`;
444 $output = &Header::cleanhtml($output,"y");
445 print "<pre>$output</pre>\n";
446 } else { print "QoS ist nicht aktiviert!"; }
447 &Header::closebox();
448 &Header::closebigbox();
449 &Header::closepage();
450 exit
451}
7ccede9b
MT
452elsif ($qossettings{'ACTION'} eq 'Grafische Auswertung')
453{
7ccede9b
MT
454 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
455 @classes = <FILE>;
456 close FILE;
363fb6af
MT
457 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
458 @subclasses = <FILE>;
459 close FILE;
e8babc92
MT
460 &Header::openbox('100%', 'left', 'QoS Graphen');
461 print <<END
462 <table width='100%'> <tr><td align='center'><font color='red'>Diese Seite braucht je nach Geschwindigkeit des Computers laenger zum Laden.</font>
463 <tr><td align='center'><b>Klasse:</b>
464END
465;
466 foreach $classentry (sort @classes)
467 {
468 @classline = split( /\;/, $classentry );
469 $qossettings{'CLASS'}=$classline[1];
470 print <<END
f841744c 471 <input type="button" onClick="swapVisibility('$qossettings{'CLASS'}')" value='$qossettings{'CLASS'}' />
e8babc92
MT
472END
473;
474 }
475 print <<END
476 </table>
477END
478;
479 &Header::closebox();
7ccede9b
MT
480 foreach $classentry (sort @classes)
481 {
482 @classline = split( /\;/, $classentry );
483 $qossettings{'DEV'}=$classline[0];
484 $qossettings{'CLASS'}=$classline[1];
485 &gengraph($qossettings{'DEV'},$qossettings{'CLASS'});
e8babc92 486 print "<div id='$qossettings{'CLASS'}' style='display: none'>";
363fb6af 487 &Header::openbox('100%', 'center', "$qossettings{'CLASS'} ($qossettings{'DEV'})");
7ccede9b 488 print <<END
363fb6af 489 <table>
f841744c
CS
490 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-packets.png' />
491 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-borrowed.png' />
492 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-bytes.png' />
7ccede9b
MT
493END
494;
363fb6af
MT
495 foreach $subclassentry (sort @subclasses)
496 {
497 @subclassline = split( /\;/, $subclassentry );
498 if ($subclassline[1] eq $classline[1]) {
499 $qossettings{'DEV'}=$subclassline[0];
500 $qossettings{'SCLASS'}=$subclassline[2];
501 &gengraph($qossettings{'DEV'},$qossettings{'SCLASS'});
502 print <<END
f841744c
CS
503 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'SCLASS'}_$qossettings{'DEV'}-packets.png' />
504 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'SCLASS'}_$qossettings{'DEV'}-borrowed.png' />
505 <tr><td colspan='2' align='center'><img src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'SCLASS'}_$qossettings{'DEV'}-bytes.png' />
363fb6af
MT
506END
507;
508 }
509 }
e8babc92
MT
510 print "\t\t</table>";
511 &Header::closebox();
512 print "</div>\n";
7ccede9b
MT
513 }
514print <<END
515 </table>
516END
517;
7ccede9b
MT
518 &Header::closebigbox();
519 &Header::closepage();
520 exit
521}
2db5d932
MT
522elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen')
523{
524 &parentclass();
525 &Header::closebigbox();
526 &Header::closepage();
527 exit
528}
414e011d
MT
529elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen')
530{
531 &subclass();
532 &Header::closebigbox();
533 &Header::closepage();
534 exit
535}
e8babc92 536elsif ($qossettings{'ACTION'} eq 'Regel hinzufuegen')
2db5d932 537{
e8babc92
MT
538 &Header::openbox('100%', 'center', 'Regel hinzufuegen');
539 print <<END
540 <table>
541 <tr><td align='center'>Waehlen sie <u>eine</u> der untenstehenden Regeln aus.
542 <tr><td align='center'>
f013ab2b
MT
543 <input type="button" onClick="swapVisibility('l7rule')" value='Level7-Regel' />
544 <input type="button" onClick="swapVisibility('portrule')" value='Port-Regel' />
545 <input type="button" onClick="swapVisibility('tosrule')" value='TOS-Regel' />
e8babc92
MT
546 </table>
547END
548;
549 &Header::closebox();
550 print <<END
551 <div id='l7rule' style='display: none'>
552END
553;
554 &level7rule();
555 print <<END
556 </div>
557 <div id='portrule' style='display: none'>
558END
559;
560 &portrule();
561 print <<END
562 </div>
563 <div id='tosrule' style='display: none'>
564END
565;
566 &tosrule();
567 print <<END
568 </div>
569END
570;
414e011d
MT
571 &Header::closebigbox();
572 &Header::closepage();
573 exit
574}
84cab473
MT
575elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen')
576{
577 &expert();
578 &Header::closebigbox();
579 &Header::closepage();
580 exit
581}
582if ($qossettings{'ACTIONBW'} eq 'Andern')
904a41b9 583{
2db5d932
MT
584 &changebandwidth();
585 &Header::closebigbox();
586 &Header::closepage();
587 exit
588}
84cab473 589if ($qossettings{'ACTIONDEF'} eq 'Andern')
2db5d932
MT
590{
591 &changedefclasses();
904a41b9
MT
592 &Header::closebigbox();
593 &Header::closepage();
594 exit
595}
596
597&General::readhash("${General::swroot}/qos/settings", \%qossettings);
598
599my $status = $Lang::tr{'stopped'};
84cab473 600my $statuscolor = '#993333';
904a41b9
MT
601if ( $qossettings{'ENABLED'} eq 'on' ) {
602 $status = $Lang::tr{'running'};
84cab473 603 $statuscolor = '#339933';
904a41b9
MT
604}
605
606if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
607 $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'};
608}
609
610if ($errormessage) {
611 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
612 print "<class name='base'>$errormessage\n";
613 print "&nbsp;</class>\n";
614 &Header::closebox();
615}
616
414e011d
MT
617############################################################################################################################
618############################################################################################################################
619
904a41b9 620&Header::openbox('100%', 'center', 'Quality of Service');
f013ab2b 621
904a41b9 622print <<END
f841744c
CS
623 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
624 <table width='66%'>
414e011d
MT
625END
626;
627 if ( $message ne "" ) {
628 print "<tr><td colspan='2' align='center'><font color='red'>$message</font>";
629 }
630 print <<END
904a41b9
MT
631 <tr><td width='50%' align='left'><b>Quality of Service:</b>
632 <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font>
2db5d932 633 <tr><td width='100%' align='center' colspan='2'>
f013ab2b
MT
634 <input type='submit' name='ACTION' value="Start" />
635 <input type='submit' name='ACTION' value="Stop" />
f841744c 636 <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" /></table></form>
904a41b9
MT
637END
638;
639 if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) {
640 print <<END
f841744c
CS
641 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
642 <table width='66%'>
904a41b9 643 <tr><td colspan='3'>&nbsp;
2db5d932 644 <tr><td width='40%' align='right'>Downloadgeschwindigkeit: <td width='40%' align='left'>$qossettings{'INC_SPD'} kbps
3a70a538 645 <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='Andern' />
2db5d932 646 <tr><td width='40%' align='right'>Uploadgeschwindigkeit: <td width='40%' align='left'>$qossettings{'OUT_SPD'} kbps
f841744c 647 </table></form>
2db5d932
MT
648END
649;
650 }
651 if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) {
652 print <<END
f841744c
CS
653 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
654 <table width='66%'>
f013ab2b 655 <tr><td colspan='3'><hr />
2db5d932 656 <tr><td width='40%' align='right'>Downloadstandardklasse: <td width='40%' align='left'>$qossettings{'DEFCLASS_INC'}
f841744c 657 <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='Andern' />
2db5d932
MT
658 <tr><td width='40%' align='right'>Uploadstandardklasse: <td width='40%' align='left'>$qossettings{'DEFCLASS_OUT'}
659 <tr><td width='40%' align='right'>ACKs: <td width='40%' align='left'>$qossettings{'ACK'}
f013ab2b 660 <tr><td colspan='3' width='100%'><hr />
7ccede9b 661 <tr><td colspan='3' width='100%' align='center'>
f841744c
CS
662 </table>
663 </form>
664 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
665 <table border='0' cellpadding='0' cellspacing='0'>
666 <tr><td><input type='submit' name='ACTION' value='Parentklasse hinzufuegen' />
667 <td><input type='submit' name='ACTION' value='Erweiterte Einstellungen' />
668 <tr><td><input type='submit' name='ACTION' value='Statusinformationen' />
669 <td><input type='submit' name='ACTION' value='Grafische Auswertung' />
7ccede9b 670 </table>
414e011d 671 </form>
904a41b9
MT
672END
673;
674 }
904a41b9
MT
675&Header::closebox();
676
677if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) {
2db5d932 678 &changebandwidth();
2db5d932
MT
679 &Header::closebigbox();
680 &Header::closepage();
681 exit
682}
683
684if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) {
685 &changedefclasses();
686 &Header::closebigbox();
687 &Header::closepage();
688 exit
689}
690
f013ab2b
MT
691&Header::openbox('100%', 'center', $Lang::tr{'info'});
692&overviewgraph($qossettings{'RED_DEV'});
693&overviewgraph($qossettings{'IMQ_DEV'});
694print <<END
695 <table>
f841744c 696 <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
697 <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;
698END
699;
6f300951 700if (( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'RED_DEV'}.png") && ( -e "/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'IMQ_DEV'}.png")) {
f013ab2b 701 print <<END
f841744c
CS
702 <tr><td colspan='9' align='center'><img alt="" src="/graphs/qos-graph-$qossettings{'RED_DEV'}.png" />
703 <tr><td colspan='9' align='center'><img alt="" src="/graphs/qos-graph-$qossettings{'IMQ_DEV'}.png" />
f013ab2b
MT
704END
705;}
706print "\t</table>";
707
708&Header::closebox();
709
710&showclasses($qossettings{'RED_DEV'});
711&showclasses($qossettings{'IMQ_DEV'});
2db5d932 712
904a41b9
MT
713&Header::closebigbox();
714&Header::closepage();
904a41b9 715
414e011d
MT
716############################################################################################################################
717############################################################################################################################
2db5d932
MT
718
719sub changedefclasses {
720 &Header::openbox('100%', 'center', 'Standardklassen:');
904a41b9 721 print <<END
2db5d932
MT
722 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
723 <table width='66%'>
724 <tr><td width='100%' colspan='3'>Legen sie hier die Standardklassen fest durch die nicht-gefilterte Pakete gehen.
725 <tr><td width='33%' align='right'>Download:<td width='33%' align='left'><select name='DEFCLASS_INC'>
726END
727;
414e011d 728 for ( $c = 200 ; $c <= 220 ; $c++ )
2db5d932
MT
729 {
730 if ( $qossettings{'DEFCLASS_INC'} ne $c )
414e011d
MT
731 { print "<option value='$c'>$c</option>\n"; }
732 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
733 }
734 print <<END
735 </select><td width='33%' align='center'>&nbsp;
736 <tr><td width='33%' align='right'>Upload:<td width='33%' align='left'><select name='DEFCLASS_OUT'>
737END
738;
414e011d 739 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
740 {
741 if ( $qossettings{'DEFCLASS_OUT'} ne $c )
414e011d
MT
742 { print "<option value='$c'>$c</option>\n"; }
743 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
744 }
745 print <<END
746 </select><td width='33%' align='center'>&nbsp;
747 </table>
f013ab2b 748 <hr />
2db5d932 749 <table width='66%'>
f013ab2b 750 <tr><td width='100%' colspan='3'>Legen sie hier die ACK-Klasse fest <br /> und klicken Sie danach auf <i>Speichern</i>.
2db5d932
MT
751 <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'>
752END
753;
414e011d 754 for ( $c = 100 ; $c <= 120 ; $c++ )
2db5d932
MT
755 {
756 if ( $qossettings{'ACK'} ne $c )
414e011d
MT
757 { print "<option value='$c'>$c</option>\n"; }
758 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
759 }
760 print <<END
f013ab2b 761 </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />
2db5d932
MT
762 </table>
763 </form>
904a41b9
MT
764END
765;
3a70a538 766 &Header::closebox();
2db5d932
MT
767}
768
769sub changebandwidth {
770 &Header::openbox('100%', 'center', 'Bandbreiteneinstellungen');
771 if ($qossettings{'ENABLED'} eq 'on') {
772 print "Sie koennen die Bandbreiteneinstellungen nicht bearbeiten, wenn QoS eingeschaltet ist. Schalten sie es zuerst dazu aus.<p>";
773 print "<a href='/cgi-bin/qos.cgi'>Zurueck</a>";
774 } else {
775 print <<END
776 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b 777 <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' />
2db5d932 778 <table width='66%'>
f013ab2b 779 <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 780 <tr><td width='33%' align='right'>Download-Geschwindigkeit:
f013ab2b 781 <td width='33%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /> &nbsp; kbps
2db5d932
MT
782 <td width='33%' align='center'>&nbsp;
783 <tr><td width='33%' align='right'>Upload-Geschwindigkeit:
f013ab2b
MT
784 <td width='33%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /> &nbsp; kbps
785 <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
786 </table>
787 </form>
788END
789;
790 }
904a41b9 791 &Header::closebox();
904a41b9
MT
792}
793
2db5d932 794sub parentclass {
414e011d 795 &Header::openbox('100%', 'center', 'Parentklasse');
2db5d932
MT
796 print <<END
797 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
798 <table width='66%'>
414e011d
MT
799END
800;
801 if ( $message ne "" ) {
802 print "<tr><td colspan='3' align='center'>$message";
803 }
804 if ( $qossettings{'EDIT'} eq 'yes' ) {
f841744c
CS
805 print "<input type='hidden' name='CLASS' value=$qossettings{'CLASS'} />";
806 print "<input type='hidden' name='DEVICE' value=$qossettings{'DEVICE'} />";
414e011d
MT
807 }
808 print <<END
f013ab2b 809 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br /> und klicken Sie danach auf <i>Speichern</i>.
2db5d932 810 <tr><td width='33%' align='right'>Interface:
414e011d
MT
811 <td width='33%' align='left'>
812END
813;
814 if ( $qossettings{'EDIT'} eq 'yes' ) {
815 print "<select name='DEVICE' disabled>";
816 } else {
817 print "<select name='DEVICE'>";
818 }
819 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
820 $qossettings{'RED_DEV_SEL'} = 'selected';
821 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
822 $qossettings{'IMQ_DEV_SEL'} = 'selected';
823 }
824 print <<END
825 <option value=$qossettings{'RED_DEV'} $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option>
826 <option value=$qossettings{'IMQ_DEV'} $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select>
2db5d932 827 <td width='33%' align='center'>&nbsp;
414e011d 828 <tr><td width='33%' align='right'>Klasse:<td width='33%' align='left'>
2db5d932
MT
829END
830;
414e011d
MT
831 if ( $qossettings{'EDIT'} eq 'yes' ) {
832 print "<select name='CLASS' disabled>";
833 } else {
834 print "<select name='CLASS'>";
835 }
2db5d932
MT
836 for ( $c = 100 ; $c <= 120 ; $c++ )
837 {
838 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
839 { print "<option value='$c'>$c</option>\n"; }
840 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
841 }
842 for ( $c = 200 ; $c <= 220 ; $c++ )
843 {
844 if ( $qossettings{'CLASS'} ne $c )
414e011d
MT
845 { print "<option value='$c'>$c</option>\n"; }
846 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932
MT
847 }
848 print <<END
849 </select>
850 <td width='33%' align='center'>&nbsp;
851 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
852END
853;
854 for ( $c = 1 ; $c <= 7 ; $c++ )
855 {
856 if ( $qossettings{'PRIO'} ne $c )
414e011d
MT
857 { print "<option value='$c'>$c</option>\n"; }
858 else { print "<option selected value='$c'>$c</option>\n"; }
2db5d932 859 }
f013ab2b 860 if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; }
2db5d932 861 print <<END
f013ab2b 862 </select>
2db5d932
MT
863 <td width='33%' align='center'>&nbsp;
864 <tr><td width='33%' align='right'>Garantierte Bandbreite:
f013ab2b 865 <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
2db5d932
MT
866 <td width='33%' align='center'>&nbsp;
867 <tr><td width='33%' align='right'>Maximale Bandbreite:
f013ab2b 868 <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
2db5d932
MT
869 <td width='33%' align='center'>&nbsp;
870 <tr><td width='33%' align='right'>Burst:
f013ab2b 871 <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932
MT
872 <td width='33%' align='center'>&nbsp;
873 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 874 <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92
MT
875 <td width='33%' align='center'>&nbsp;
876 <tr><td width='33%' align='right'>TOS-Bit:
877 <td width='33%' align='left'><select name='TOS'>
878 <option value='0'>Ausgeschaltet (0)</option>
879 <option value='8'>Minimale Verzoegerung (8)</option>
880 <option value='4'>Maximaler Durchsatz (4)</option>
881 <option value='2'>Maximale Zuverlaessigkeit (2)</option>
882 <option value='1'>Minimale Kosten (1)</option></select>
f013ab2b
MT
883 <td width='33%' align='center'>&nbsp;
884 <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
f841744c 885 <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
886 <tr><td width='33%' align='right'>&nbsp;
887 <td width='33%' align='left'>&nbsp;
84cab473 888 <td width='33%' align='center'><input type='submit' name='DOCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
2db5d932
MT
889 </table></form>
890END
891;
892 &Header::closebox();
893}
904a41b9 894
414e011d
MT
895sub subclass {
896 &Header::openbox('100%', 'center', 'Unterklasse');
2db5d932
MT
897 print <<END
898 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
899 <table width='66%'>
414e011d
MT
900END
901;
902 if ( $message ne "" ) {
903 print "<tr><td colspan='3' align='center'>$message";
904 }
905 print <<END
906 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
f013ab2b 907 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br /> und klicken Sie danach auf <i>Speichern</i>.
414e011d
MT
908 <tr><td width='33%' align='right'>Unterklasse:<td width='33%' align='left'><select name='SCLASS'>
909END
910;
911 if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
912 $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
913 for ( $c = 1000 ; $c <= 1020 ; $c++ )
914 {
915 if ( $qossettings{'SCLASS'} ne $c )
916 { print "<option value='$c'>$c</option>\n"; }
917 else { print "<option selected value='$c'>$c</option>\n"; }
918 }
919 } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
920 $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
921 for ( $c = 2000 ; $c <= 2020 ; $c++ )
922 {
923 if ( $qossettings{'SCLASS'} ne $c )
924 { print "<option value='$c'>$c</option>\n"; }
925 else { print "<option selected value='$c'>$c</option>\n"; }
926 }
927 }
928 print <<END
929 </select>
930 <td width='33%' align='center'>&nbsp;
931 <tr><td width='33%' align='right'>Prioritaet:<td width='33%' align='left'><select name='PRIO'>
932END
933;
934 for ( $c = 1 ; $c <= 7 ; $c++ )
935 {
936 if ( $qossettings{'PRIO'} ne $c )
937 { print "<option value='$c'>$c</option>\n"; }
938 else { print "<option selected value='$c'>$c</option>\n"; }
939 }
940 print <<END
941 <td width='33%' align='center'>&nbsp;
942 <tr><td width='33%' align='right'>Garantierte Bandbreite:
f013ab2b 943 <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" />
414e011d
MT
944 <td width='33%' align='center'>&nbsp;
945 <tr><td width='33%' align='right'>Maximale Bandbreite:
f013ab2b 946 <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" />
414e011d
MT
947 <td width='33%' align='center'>&nbsp;
948 <tr><td width='33%' align='right'>Burst:
f013ab2b 949 <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" />
2db5d932 950 <td width='33%' align='center'>&nbsp;
414e011d 951 <tr><td width='33%' align='right'>Ceilburst:
f013ab2b 952 <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
e8babc92
MT
953 <td width='33%' align='center'>&nbsp;
954 <tr><td width='33%' align='right'>TOS-Bit:
955 <td width='33%' align='left'><select name='TOS'>
956 <option value='0'>Ausgeschaltet (0)</option>
957 <option value='8'>Minimale Verzoegerung (8)</option>
958 <option value='4'>Maximaler Durchsatz (4)</option>
959 <option value='2'>Maximale Zuverlaessigkeit (2)</option>
960 <option value='1'>Minimale Kosten (1)</option></select>
f013ab2b
MT
961 <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" />
962 <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" />
363fb6af 963 <input type='submit' name='DOSCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
414e011d
MT
964 </table></form>
965END
966;
967 &Header::closebox();
968}
969
414e011d
MT
970sub level7rule {
971 &Header::openbox('100%', 'center', 'Level7-Regel');
972 print <<END
973 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
974 <table width='66%'>
975END
976;
977 if ( $message ne "" ) {
978 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
979 }
980 print <<END
981 <tr><td colspan='3' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
f013ab2b 982 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br /> und klicken Sie danach auf <i>Speichern</i>.
2db5d932
MT
983 <tr><td width='33%' align='right'>Protokoll:
984 <td width='33%' align='left'><select name='L7PROT'>
985END
986;
987 opendir( DIR, "/etc/l7-protocols/protocols" );
988 foreach $direntry ( sort readdir(DIR) )
989 {
990 next if $direntry eq ".";
991 next if $direntry eq "..";
992 next if -d "/etc/l7-protocols/protocols/$direntry";
993 @proto = split( /\./, $direntry );
994 if ( $proto[0] eq $qossettings{'L7PROT'} ) {
995 print "<option value='$proto[0]' selected>$proto[0]</option>\n";
996 } else {
997 print "<option value='$proto[0]'>$proto[0]</option>\n";
998 }
999 }
1000 closedir DIR;
1001 print <<END
1002 </select><td width='33%' align='center'>&nbsp;
1003 <tr><td width='33%' align='right'>Quell-IP-Adresse:
f841744c 1004 <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'} />
2db5d932
MT
1005 <td width='33%' align='center'>&nbsp;
1006 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
f841744c
CS
1007 <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'} />
1008 <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'} /><input type='submit' name='DOLEVEL7' value=$Lang::tr{'save'} />
2db5d932
MT
1009 </table></form>
1010END
1011;
1012 &Header::closebox();
414e011d
MT
1013}
1014
1015sub portrule {
1016 &Header::openbox('100%', 'center', 'Port-Regel hinzufuegen');
1017 print <<END
1018 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1019 <table width='66%'>
f013ab2b 1020 <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br /> und klicken Sie danach auf <i>Speichern</i>.
414e011d
MT
1021 <tr><td width='33%' align='right'>Protokoll:
1022 <td width='33%' align='left'><select name='PPROT'>
1023END
1024;
1025 open( FILE, "< /etc/protocols" );
1026 @proto = <FILE>;
1027 close FILE;
1028 foreach $direntry (sort @proto)
1029 {
1030 @tmpline = split( /\ /, $direntry );
1031 next if $tmpline[0] =~ "#";
1032 if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
1033 print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
1034 } else {
1035 print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
1036 }
1037 }
1038 print <<END
1039 </select><td width='33%' align='center'>&nbsp;
1040 <tr><td width='33%' align='right'>Quell-Port:
f841744c 1041 <td width='33%' align='left'><input type='text' name='QPORT' maxlength='5' value=$qossettings{'QPORT'} />
414e011d
MT
1042 <td width='33%' align='center'>&nbsp;
1043 <tr><td width='33%' align='right'>Ziel-Port:
f841744c 1044 <td width='33%' align='left'><input type='text' name='DPORT' maxlength='5' value=$qossettings{'DPORT'} />
414e011d
MT
1045 <td width='33%' align='center'>&nbsp;
1046 <tr><td width='33%' align='right'>Quell-IP-Adresse:
f841744c 1047 <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value=$qossettings{'QIP'} />
414e011d
MT
1048 <td width='33%' align='center'>&nbsp;
1049 <tr><td width='33%' align='right'>Ziel-IP-Adresse:
f841744c
CS
1050 <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value=$qossettings{'DIP'} />
1051 <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value=$Lang::tr{'save'} />
414e011d
MT
1052 </table></form>
1053END
1054;
1055 &Header::closebox();
1056}
1057
e8babc92
MT
1058sub tosrule {
1059 &Header::openbox('100%', 'center', 'TOS-Regel');
1060 if ($qossettings{'TOS'}) {
1061 $checked[$qossettings{'TOS'}] = "checked";
1062 }
1063 print <<END
1064 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1065 <table width='66%'>
1066END
1067;
1068 if ( $message ne "" ) {
1069 print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
1070 }
1071 print <<END
1072 <tr><td colspan='2' width='100%'>Aktuelle Klasse: $qossettings{'CLASS'}
f013ab2b 1073 <tr><td width='100%' colspan='2'>Aktivieren oder deaktivieren sie die TOS-Bits <br /> und klicken Sie danach auf <i>Speichern</i>.
f841744c
CS
1074 <tr><td width='50%' align='left'>Minimale Verzoegerung (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
1075 <tr><td width='50%' align='left'>Maximaler Durchsatz (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
1076 <tr><td width='50%' align='left'>Maximale Zuverlaessigkeit (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
1077 <tr><td width='50%' align='left'>Minimale Kosten (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
1078 <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
1079 </table></form>
1080END
1081;
1082 &Header::closebox();
1083}
1084
414e011d 1085sub showclasses {
f013ab2b 1086 $qossettings{'DEV'} = shift;
414e011d
MT
1087 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1088 @classes = <FILE>;
1089 close FILE;
1090 if (@classes) {
1091 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1092 @subclasses = <FILE>;
1093 close FILE;
f013ab2b
MT
1094 open( FILE, "< $level7file" ) or die "Unable to read $level7file";
1095 @l7rules = <FILE>;
1096 close FILE;
1097 open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
1098 @tosrules = <FILE>;
1099 close FILE;
1100 open( FILE, "< $portfile" ) or die "Unable to read $portfile";
1101 @portrules = <FILE>;
1102 close FILE;
414e011d
MT
1103 foreach $classentry (sort @classes)
1104 {
1105 @classline = split( /\;/, $classentry );
f013ab2b 1106 if ( $classline[0] eq $qossettings{'DEV'} )
414e011d 1107 {
f013ab2b
MT
1108 gengraph($qossettings{'DEV'},$classline[1]);
1109 &Header::openbox('100%', 'center', "Klasse: $classline[1]");
414e011d 1110 print <<END
f013ab2b 1111 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1
CS
1112 <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
1113 <td bgcolor='$color{'color20'}' width='10%' align='center'><b>Klasse</b>
1114 <td bgcolor='$color{'color20'}' width='10%' align='center'>Prioritaet
1115 <td bgcolor='$color{'color20'}' width='10%' align='center'>Garantierte Bandbreite
1116 <td bgcolor='$color{'color20'}' width='10%' align='center'>Maximale Bandbreite
1117 <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
1118 <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
1119 <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
1120 <td bgcolor='$color{'color20'}' width='20%' align='center'>Aktionen
1121 <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
1122 <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
1123 <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
1124 <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
1125 <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
1126 <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
1127 <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
1128 <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
1129 <td align='right' bgcolor='$color{'color22'}'>
649fd295 1130 <table border='0'><tr>
649fd295 1131 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1132 <input type='hidden' name='CLASS' value='$classline[1]' />
1133 <input type='hidden' name='ACTION' value='Unterklasse hinzufuegen' />
1134 <input type='image' alt='Unterklasse hinzufuegen' src='/images/addblue.gif' />
649fd295
MT
1135 </form>
1136 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1137 <input type='hidden' name='CLASS' value='$classline[1]' />
1138 <input type='hidden' name='ACTION' value='Regel hinzufuegen' />
1139 <input type='image' alt='Regel hinzufuegen' src='/images/addgreen.gif' />
649fd295
MT
1140 </form>
1141 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1142 <input type='hidden' name='CLASS' value='$classline[1]' />
1143 <input type='hidden' name='DOCLASS' value='Bearbeiten' />
1144 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
649fd295
MT
1145 </form>
1146 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1147 <input type='hidden' name='CLASS' value='$classline[1]' />
1148 <input type='hidden' name='DOCLASS' value='Loeschen' />
1149 <input type='image' alt='Loeschen' src='/images/delete.gif' />
649fd295
MT
1150 </form>
1151 </table>
f013ab2b
MT
1152 </td>
1153 <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
1154 <td align='center' colspan='6'> $classline[8]
1155 <td align='right'><b>Queueing:</b> $classline[9]
414e011d
MT
1156END
1157;
f013ab2b
MT
1158
1159 if (@l7rules) {
1160 foreach $l7ruleentry (sort @l7rules)
1161 {
1162 @l7ruleline = split( /\;/, $l7ruleentry );
1163 if ( $l7ruleline[0] eq $classline[1] )
1164 {
1165 print <<END
1166 <tr><td align='right' colspan='2'><b>Level7-Protokoll:</b>
1167 <td align='center' colspan='6'>$l7ruleline[2]
1168 <td align='right' >
649fd295 1169 <table border='0'><tr>
649fd295 1170 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1171 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1172 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1173 <input type='hidden' name='DOLEVEL7' value='Bearbeiten' />
1174 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
649fd295
MT
1175 </form>
1176 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f013ab2b
MT
1177 <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
1178 <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
1179 <input type='hidden' name='DOLEVEL7' value='Loeschen' />
1180 <input type='image' alt='Loeschen' src='/images/delete.gif' />
649fd295
MT
1181 </form>
1182 </table>
414e011d
MT
1183END
1184;
f013ab2b
MT
1185 if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
1186 print <<END
1187 <tr><td align='center'>&nbsp;
1188 <td align='right' colspan='3'><b>Quell-IP:</b> $l7ruleline[3]
1189 <td align='right' colspan='3'><b>Ziel-IP:</b> $l7ruleline[4]
84cab473
MT
1190END
1191;
f013ab2b
MT
1192 }
1193
414e011d 1194
84cab473
MT
1195END
1196;
f013ab2b
MT
1197 }
1198 }
1199 }
1200
1201
1202 if (@portrules) {
1203 foreach $portruleentry (sort @portrules)
1204 {
1205 @portruleline = split( /\;/, $portruleentry );
1206 if ( $portruleline[0] eq $classline[1] )
1207 {
1208 print <<END
1209 <tr><td align='right' colspan='2'><b>Port-Regel:</b>
1210 <td align='center'>($portruleline[2])
1211 <td align='center' colspan='2'>
84cab473
MT
1212END
1213;
f013ab2b
MT
1214 if ($portruleline[4]) {
1215 print <<END
1216 <i>Quell-Port:</i> $portruleline[4]
84cab473
MT
1217END
1218;
f013ab2b
MT
1219 }
1220 print "<td align='center' colspan='2'>";
1221 if ($portruleline[6]) {
1222 print <<END
1223 <i>Ziel-Port:</i> $portruleline[6]
84cab473
MT
1224END
1225;
f013ab2b
MT
1226 }
1227 print <<END
1228 <td>&nbsp;
1229 <td align='right'>
8b0883b8
MT
1230 <table border='0'><tr>
1231 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1232 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1233 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1234 <input type='hidden' name='QIP' value='$portruleline[3]' />
1235 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1236 <input type='hidden' name='DIP' value='$portruleline[5]' />
1237 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1238 <input type='hidden' name='DOPORT' value='Bearbeiten' />
1239 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
8b0883b8
MT
1240 </form>
1241 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1242 <input type='hidden' name='CLASS' value='$portruleline[0]' />
1243 <input type='hidden' name='PPROT' value='$portruleline[2]' />
1244 <input type='hidden' name='QIP' value='$portruleline[3]' />
1245 <input type='hidden' name='QPORT' value='$portruleline[4]' />
1246 <input type='hidden' name='DIP' value='$portruleline[5]' />
1247 <input type='hidden' name='DPORT' value='$portruleline[6]' />
1248 <input type='hidden' name='DOPORT' value='Loeschen' />
1249 <input type='image' alt='Loeschen' src='/images/delete.gif' />
8b0883b8
MT
1250 </form>
1251 </table>
414e011d
MT
1252END
1253;
f013ab2b
MT
1254 if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
1255 print <<END
1256 <tr><td align='center'>&nbsp;
1257 <td align='right' colspan='3'><b>Quell-IP:</b> $portruleline[3]
1258 <td align='right' colspan='3'><b>Ziel-IP:</b> $portruleline[5]
84cab473
MT
1259END
1260;
f013ab2b
MT
1261 }
1262 }
1263 }
1264 }
414e011d 1265
f013ab2b
MT
1266 if (@tosrules) {
1267 foreach $tosruleentry (sort @tosrules)
1268 {
1269 @tosruleline = split( /\;/, $tosruleentry );
1270 if ( $tosruleline[0] eq $classline[1] )
1271 {
1272 print <<END
1273 <tr><td align='right' colspan='2'>
1274 <b>TOS Bit matches:</b>
1275 <td colspan='6' align='center'>
e8babc92
MT
1276END
1277;
f013ab2b
MT
1278 if ( $tosruleline[2] eq "8") {
1279 print "Minimale Verzoegerung\n";
1280 } elsif ( $tosruleline[2] eq "4") {
1281 print "Maximaler Durchsatz\n";
1282 } elsif ( $tosruleline[2] eq "2") {
1283 print "Maximaler Durchsatz\n";
1284 } elsif ( $tosruleline[2] eq "1") {
1285 print "Minimale Kosten\n";
1286 } else { print "&nbsp;\n"; }
1287
1288 print <<END
1289 ($tosruleline[2])
1290 <td align='right'>
1291 <table border='0'><tr>
1292 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1293 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1294 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1295 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1296 <input type='hidden' name='DOTOS' value='Bearbeiten' />
1297 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
f013ab2b
MT
1298 </form>
1299 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1300 <input type='hidden' name='CLASS' value='$tosruleline[0]' />
1301 <input type='hidden' name='DEV' value='$tosruleline[1]' />
1302 <input type='hidden' name='TOS' value='$tosruleline[2]' />
1303 <input type='hidden' name='DOTOS' value='Loeschen' />
1304 <input type='image' alt='Loeschen' src='/images/delete.gif' />
f013ab2b
MT
1305 </form>
1306 </table>
e8babc92
MT
1307END
1308;
f013ab2b
MT
1309 }
1310 }
1311 }
1312
6f300951 1313 if ( -e "/srv/web/ipfire/html/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-packets.png") {
f013ab2b 1314 print <<END
f841744c 1315 <tr><td colspan='9' align='center'><img alt="" src='/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-packets.png' />
e8babc92
MT
1316END
1317;
f013ab2b
MT
1318 }
1319
1320
1321 foreach $subclassentry (sort @subclasses)
1322 {
1323 @subclassline = split( /\;/, $subclassentry );
1324 if ( $subclassline[1] eq $classline[1] ) {
1325 print <<END
1326 <tr><td align='center' bgcolor='#FAFAFA'>Subklasse:
1327 <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
1328 <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
1329 <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
1330 <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
1331 <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
1332 <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
1333 <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
1334 <td align='right' bgcolor='#FAFAFA'>
1335 <table border='0'><tr>
1336 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1337 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1338 <input type='hidden' name='ACTION' value='Regel hinzufuegen' />
1339 <input type='image' alt='Regel hinzufuegen' src='/images/addgreen.gif' />
f013ab2b
MT
1340 </form>
1341 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1342 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1343 <input type='hidden' name='DOSCLASS' value='Bearbeiten' />
1344 <input type='image' alt='Bearbeiten' src='/images/edit.gif' />
f013ab2b
MT
1345 </form>
1346 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
f841744c
CS
1347 <input type='hidden' name='CLASS' value='$subclassline[2]' />
1348 <input type='hidden' name='DOSCLASS' value='Loeschen' />
1349 <input type='image' alt='Loeschen' src='/images/delete.gif' />
f013ab2b
MT
1350 </form>
1351 </table>
e8babc92
MT
1352END
1353;
f013ab2b
MT
1354 }
1355 }
1356 print <<END
1357 </table>
e8babc92
MT
1358END
1359;
f013ab2b 1360 &Header::closebox();
e8babc92
MT
1361 }
1362 }
e8babc92
MT
1363 }
1364}
1365
84cab473
MT
1366sub expert
1367{
1368 &Header::openbox('100%', 'center', 'Expertenoptionen:');
1369 print <<END
1370 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
84cab473
MT
1371 <table width='66%'>
1372 <tr><td width='33%' align='right'>MTU:<td width='33%' align='left'>
f841744c 1373 <input type='text' name='MTU' maxlength='8' required='4' value=$qossettings{'MTU'} />
84cab473
MT
1374 <td width='33%' align='center'>Diese Einstellung aendert die MTU nicht global sondern nur fuer das QoS.
1375 <tr><td width='33%' align='right'>Queue Laenge:<td width='33%' align='left'>
f841744c 1376 <input type='text' name='QLENGTH' maxlength='8' required='2' value=$qossettings{'QLENGTH'} />
84cab473
MT
1377 <td width='33%' align='center'>&nbsp;
1378 <tr><td width='33%' align='right'>SFQ Perturb:<td width='33%' align='left'>
f841744c 1379 <input type='text' name='SFQ_PERTUB' maxlength='8' required='1' value=$qossettings{'SFQ_PERTUB'} />
84cab473
MT
1380 <td width='33%' align='center'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
1381 </table>
1382 </form>
1383END
1384;
1385 &Header::closebox();
1386}
414e011d
MT
1387
1388sub validminbwdth {
1389 if ( $qossettings{'VALID'} eq 'yes' ) {
1390 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1391 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1392 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1393 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1394 }
363fb6af 1395 unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
414e011d
MT
1396 $qossettings{'VALID'} = 'no';
1397 $message = "Mindestbandbreite ist ungueltig.";
1398 }
1399 $qossettings{'SPD'} = '';
1400 }
1401}
84cab473 1402
414e011d
MT
1403sub validmaxbwdth {
1404 if ( $qossettings{'VALID'} eq 'yes' ) {
1405 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1406 $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
1407 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1408 $qossettings{'SPD'} = $qossettings{'INC_SPD'};
1409 }
1410 unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
1411 $qossettings{'VALID'} = 'no';
1412 $message = "Mamimalbandbreite ist ungueltig.";
1413 }
1414 $qossettings{'SPD'} = '';
1415 }
1416}
1417
1418sub validclass {
1419 if ( $qossettings{'VALID'} eq 'yes' ) {
1420 if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
1421 if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
1422 $qossettings{'VALID'} = 'no';
1423 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
1424 }
1425 } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
1426 if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
1427 $qossettings{'VALID'} = 'no';
1428 $message = "Die Klassennummer passt nicht zum angegebenen Interface.";
1429 }
1430 }
1431 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1432 @tmp = <FILE>;
1433 close FILE;
1434 foreach $classentry (sort @tmp)
1435 {
1436 @tmpline = split( /\;/, $classentry );
1437 if ( $tmpline[1] eq $qossettings{'CLASS'} )
1438 {
1439 $qossettings{'VALID'} = 'no';
1440 $message = "Die aktuelle Klasse wird bereits verwendet.";
1441 last
1442 }
1443 }
1444 }
1445}
84cab473 1446
414e011d
MT
1447sub validsubclass {
1448 if ( $qossettings{'VALID'} eq 'yes' ) {
1449 open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
1450 @tmp = <FILE>;
1451 close FILE;
1452 foreach $subclassentry (sort @tmp)
1453 {
1454 @tmpline = split( /\;/, $subclassentry );
1455 if ( $tmpline[2] eq $qossettings{'SCLASS'} )
1456 {
1457 $qossettings{'VALID'} = 'no';
1458 $message = "Die aktuelle Klasse wird bereits verwendet.";
1459 last
1460 }
1461 }
1462 }
84cab473 1463}
7ccede9b
MT
1464
1465sub gengraph {
1466 $qossettings{'DEV'} = shift;
1467 $qossettings{'CLASS'} = shift;
1468 my $ERROR="";
1469 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
363fb6af 1470 $qossettings{'CLASSPRFX'} = '1';
7ccede9b 1471 } else {
363fb6af 1472 $qossettings{'CLASSPRFX'} = '2';
7ccede9b 1473 }
f013ab2b 1474 my $color=random_hex_color(6);
7ccede9b 1475
6f300951 1476 RRDs::graph ("/srv/web/ipfire/html/graphs/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}-packets.png",
7ccede9b 1477 "--start", "-3240", "-aPNG", "-i", "-z",
e8babc92 1478 "--alt-y-grid", "-w 600", "-h 150", "-r",
7ccede9b
MT
1479 "--color", "SHADEA#EAE9EE",
1480 "--color", "SHADEB#EAE9EE",
1481 "--color", "BACK#FFFFFF",
1482 "-t $qossettings{'CLASS'} ($qossettings{'DEV'})",
1483 "DEF:pkts=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:pkts:AVERAGE",
1484 "DEF:dropped=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:dropped:AVERAGE",
1485 "DEF:overlimits=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$qossettings{'CLASS'}_$qossettings{'DEV'}.rrd:overlimits:AVERAGE",
f013ab2b 1486 "AREA:pkts$color:packets",
7ccede9b
MT
1487 "GPRINT:pkts:LAST:total packets\\:%8.3lf %s packets\\j",
1488 "LINE3:dropped#FF0000:dropped",
1489 "GPRINT:dropped:LAST:dropped packets\\:%8.3lf %s packets\\j",
1490 "LINE3:overlimits#0000FF:overlimits",
1491 "GPRINT:overlimits:LAST:overlimits\\:%8.3lf %s packets\\j",
1492 );
9833e7d8
MT
1493 $ERROR = RRDs::error;
1494 #print "$ERROR";
f013ab2b 1495}
7ccede9b 1496
f013ab2b
MT
1497sub overviewgraph {
1498 $qossettings{'DEV'} = shift;
1499 if ( $qossettings{'DEV'} eq $qossettings{'RED_DEV'} ) {
1500 $qossettings{'CLASSPRFX'} = '1';
1501 } else {
1502 $qossettings{'CLASSPRFX'} = '2';
1503 }
1504 my $ERROR="";
1505 my $count="1";
1506 my $color="#000000";
6f300951 1507 my @command=("/srv/web/ipfire/html/graphs/qos-graph-$qossettings{'DEV'}.png",
7ccede9b 1508 "--start", "-3240", "-aPNG", "-i", "-z",
e8babc92 1509 "--alt-y-grid", "-w 600", "-h 150", "-r",
7ccede9b
MT
1510 "--color", "SHADEA#EAE9EE",
1511 "--color", "SHADEB#EAE9EE",
1512 "--color", "BACK#FFFFFF",
f013ab2b 1513 "-t Auslastung auf ($qossettings{'DEV'})"
7ccede9b 1514 );
f013ab2b
MT
1515 open( FILE, "< $classfile" ) or die "Unable to read $classfile";
1516 @classes = <FILE>;
1517 close FILE;
1518 foreach $classentry (sort @classes)
1519 {
1520 @classline = split( /\;/, $classentry );
1521 if ( $classline[0] eq $qossettings{'DEV'} )
1522 {
1523 $color=random_hex_color(6);
1524 push(@command, "DEF:$classline[1]=/var/log/rrd/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bits:AVERAGE");
7ccede9b 1525
f013ab2b
MT
1526 if ($count eq "1") {
1527 push(@command, "AREA:$classline[1]$color:Klasse $classline[1] - $classline[8]\\j");
1528 } else {
1529 push(@command, "STACK:$classline[1]$color:Klasse $classline[1] - $classline[8]\\j");
1530 }
1531 $count++;
1532 }
1533 }
1534 RRDs::graph (@command);
1535 $ERROR = RRDs::error;
9833e7d8 1536 #print "$ERROR";
f013ab2b 1537}
7ccede9b 1538
f013ab2b
MT
1539sub random_hex_color {
1540 my $size = shift;
1541 $size = 6 if $size !~ /^3|6$/;
1542 my @hex = ( 0 .. 9, 'a' .. 'f' );
1543 my @color;
1544 push @color, @hex[rand(@hex)] for 1 .. $size;
1545 return join('', '#', @color);
f2fdd0c1 1546}