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