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