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