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