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