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