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