]>
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 | { | |
cfd19520 | 455 | system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); |
9833e7d8 | 456 | system("/usr/bin/touch /var/ipfire/qos/enable"); |
cfd19520 | 457 | system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); |
a7fb5630 | 458 | system("logger -t ipfire 'QoS started'"); |
904a41b9 MT |
459 | $qossettings{'ENABLED'} = 'on'; |
460 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); | |
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"; | |
da7e2665 CS |
573 | system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); |
574 | system("/usr/bin/touch /var/ipfire/qos/enable"); | |
575 | system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); | |
576 | system("logger -t ipfire 'QoS started'"); | |
577 | $qossettings{'ENABLED'} = 'on'; | |
33e1f48c | 578 | &General::writehash("${General::swroot}/qos/settings", \%qossettings); |
fcd5cb6f | 579 | |
33e1f48c | 580 | } |
92b5fba4 MT |
581 | elsif ($qossettings{'ACTION'} eq 'Statusinformationen') |
582 | { | |
583 | &Header::openbox('100%', 'left', 'QoS Status'); | |
584 | if ($qossettings{'ENABLED'} eq 'on'){ | |
585 | my $output = ""; | |
586 | $output = `/usr/local/bin/qosctrl status`; | |
587 | $output = &Header::cleanhtml($output,"y"); | |
588 | print "<pre>$output</pre>\n"; | |
0b1641db | 589 | } else { print "$Lang::tr{'QoS not enabled'}"; } |
92b5fba4 MT |
590 | &Header::closebox(); |
591 | &Header::closebigbox(); | |
592 | &Header::closepage(); | |
593 | exit | |
594 | } | |
2db5d932 MT |
595 | elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen') |
596 | { | |
597 | &parentclass(); | |
598 | &Header::closebigbox(); | |
599 | &Header::closepage(); | |
600 | exit | |
601 | } | |
414e011d MT |
602 | elsif ($qossettings{'ACTION'} eq 'Unterklasse hinzufuegen') |
603 | { | |
604 | &subclass(); | |
605 | &Header::closebigbox(); | |
606 | &Header::closepage(); | |
607 | exit | |
608 | } | |
e8babc92 | 609 | elsif ($qossettings{'ACTION'} eq 'Regel hinzufuegen') |
2db5d932 | 610 | { |
0b1641db | 611 | &Header::openbox('100%', 'center', $Lang::tr{'Add Rule'}); |
e8babc92 MT |
612 | print <<END |
613 | <table> | |
0b1641db | 614 | <tr><td align='center'>$Lang::tr{'Choose Rule'} |
e8babc92 | 615 | <tr><td align='center'> |
f013ab2b MT |
616 | <input type="button" onClick="swapVisibility('l7rule')" value='Level7-Regel' /> |
617 | <input type="button" onClick="swapVisibility('portrule')" value='Port-Regel' /> | |
618 | <input type="button" onClick="swapVisibility('tosrule')" value='TOS-Regel' /> | |
e8babc92 MT |
619 | </table> |
620 | END | |
621 | ; | |
622 | &Header::closebox(); | |
623 | print <<END | |
624 | <div id='l7rule' style='display: none'> | |
625 | END | |
626 | ; | |
627 | &level7rule(); | |
628 | print <<END | |
629 | </div> | |
630 | <div id='portrule' style='display: none'> | |
631 | END | |
632 | ; | |
633 | &portrule(); | |
634 | print <<END | |
635 | </div> | |
636 | <div id='tosrule' style='display: none'> | |
637 | END | |
638 | ; | |
639 | &tosrule(); | |
640 | print <<END | |
641 | </div> | |
642 | END | |
643 | ; | |
414e011d MT |
644 | &Header::closebigbox(); |
645 | &Header::closepage(); | |
646 | exit | |
647 | } | |
84cab473 MT |
648 | elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen') |
649 | { | |
650 | &expert(); | |
651 | &Header::closebigbox(); | |
652 | &Header::closepage(); | |
653 | exit | |
654 | } | |
655 | if ($qossettings{'ACTIONBW'} eq 'Andern') | |
904a41b9 | 656 | { |
2db5d932 MT |
657 | &changebandwidth(); |
658 | &Header::closebigbox(); | |
659 | &Header::closepage(); | |
660 | exit | |
661 | } | |
84cab473 | 662 | if ($qossettings{'ACTIONDEF'} eq 'Andern') |
2db5d932 MT |
663 | { |
664 | &changedefclasses(); | |
904a41b9 MT |
665 | &Header::closebigbox(); |
666 | &Header::closepage(); | |
667 | exit | |
668 | } | |
669 | ||
670 | &General::readhash("${General::swroot}/qos/settings", \%qossettings); | |
671 | ||
672 | my $status = $Lang::tr{'stopped'}; | |
84cab473 | 673 | my $statuscolor = '#993333'; |
904a41b9 MT |
674 | if ( $qossettings{'ENABLED'} eq 'on' ) { |
675 | $status = $Lang::tr{'running'}; | |
84cab473 | 676 | $statuscolor = '#339933'; |
904a41b9 MT |
677 | } |
678 | ||
679 | if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) { | |
680 | $qossettings{'RED_DEV'} = $netsettings{'RED_DEV'}; | |
681 | } | |
682 | ||
683 | if ($errormessage) { | |
684 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
685 | print "<class name='base'>$errormessage\n"; | |
686 | print " </class>\n"; | |
687 | &Header::closebox(); | |
688 | } | |
689 | ||
414e011d MT |
690 | ############################################################################################################################ |
691 | ############################################################################################################################ | |
692 | ||
904a41b9 | 693 | &Header::openbox('100%', 'center', 'Quality of Service'); |
f013ab2b | 694 | |
904a41b9 | 695 | print <<END |
f841744c CS |
696 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
697 | <table width='66%'> | |
414e011d MT |
698 | END |
699 | ; | |
700 | if ( $message ne "" ) { | |
701 | print "<tr><td colspan='2' align='center'><font color='red'>$message</font>"; | |
702 | } | |
703 | print <<END | |
904a41b9 MT |
704 | <tr><td width='50%' align='left'><b>Quality of Service:</b> |
705 | <td width='50%' align='center' bgcolor='$statuscolor'><font color='white'>$status</font> | |
2db5d932 | 706 | <tr><td width='100%' align='center' colspan='2'> |
fcd5cb6f MT |
707 | <input type='submit' name='ACTION' value="Start" /> |
708 | <input type='submit' name='ACTION' value="Stop" /> | |
f841744c | 709 | <input type='submit' name='ACTION' value="$Lang::tr{'restart'}" /></table></form> |
904a41b9 MT |
710 | END |
711 | ; | |
712 | if (($qossettings{'OUT_SPD'} ne '') && ($qossettings{'INC_SPD'} ne '')) { | |
713 | print <<END | |
f841744c CS |
714 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
715 | <table width='66%'> | |
904a41b9 | 716 | <tr><td colspan='3'> |
1b73b07e | 717 | <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}: <td width='30%' align='left'>$qossettings{'INC_SPD'} |
3a70a538 | 718 | <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='Andern' /> |
1b73b07e | 719 | <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}: <td width='30%' align='left'>$qossettings{'OUT_SPD'} |
f841744c | 720 | </table></form> |
2db5d932 MT |
721 | END |
722 | ; | |
723 | } | |
724 | if (($qossettings{'DEFCLASS_OUT'} ne '') && ($qossettings{'DEFCLASS_INC'} ne '')&& ($qossettings{'ACK'} ne '')) { | |
725 | print <<END | |
f841744c CS |
726 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
727 | <table width='66%'> | |
f013ab2b | 728 | <tr><td colspan='3'><hr /> |
fcd5cb6f | 729 | <tr><td width='50%' align='right'>$Lang::tr{'downlink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_INC'} |
f841744c | 730 | <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='Andern' /> |
1b73b07e CS |
731 | <tr><td width='50%' align='right'>$Lang::tr{'uplink std class'}: <td width='30%' align='left'>$qossettings{'DEFCLASS_OUT'} |
732 | <tr><td width='50%' align='right'>ACKs: <td width='30%' align='left'>$qossettings{'ACK'} | |
f013ab2b | 733 | <tr><td colspan='3' width='100%'><hr /> |
7ccede9b | 734 | <tr><td colspan='3' width='100%' align='center'> |
f841744c CS |
735 | </table> |
736 | </form> | |
737 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
738 | <table border='0' cellpadding='0' cellspacing='0'> | |
739 | <tr><td><input type='submit' name='ACTION' value='Parentklasse hinzufuegen' /> | |
740 | <td><input type='submit' name='ACTION' value='Erweiterte Einstellungen' /> | |
268292e7 CS |
741 | <td><input type='submit' name='ACTION' value='Statusinformationen' /> |
742 | </tr></table> | |
414e011d | 743 | </form> |
904a41b9 MT |
744 | END |
745 | ; | |
746 | } | |
904a41b9 MT |
747 | &Header::closebox(); |
748 | ||
749 | if ( ($qossettings{'OUT_SPD'} eq '') || ($qossettings{'INC_SPD'} eq '') ) { | |
2db5d932 | 750 | &changebandwidth(); |
2db5d932 MT |
751 | &Header::closebigbox(); |
752 | &Header::closepage(); | |
753 | exit | |
754 | } | |
755 | ||
756 | if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq '') || ($qossettings{'ACK'} eq '') ) { | |
757 | &changedefclasses(); | |
758 | &Header::closebigbox(); | |
759 | &Header::closepage(); | |
760 | exit | |
761 | } | |
762 | ||
f013ab2b | 763 | &Header::openbox('100%', 'center', $Lang::tr{'info'}); |
0b1641db CS |
764 | &Graphs::overviewgraph("3240",$qossettings{'RED_DEV'}); |
765 | &Graphs::overviewgraph("3240",$qossettings{'IMQ_DEV'}); | |
f013ab2b MT |
766 | print <<END |
767 | <table> | |
0b1641db CS |
768 | <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'} |
769 | <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 |
770 | END |
771 | ; | |
0b1641db | 772 | 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 | 773 | print <<END |
0b1641db CS |
774 | <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> |
775 | <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 |
776 | END |
777 | ;} | |
fcd5cb6f | 778 | else |
0b1641db | 779 | { |
33e1f48c | 780 | print "\t</table><br />".$Lang::tr{'no information available'}; |
0b1641db | 781 | } |
f013ab2b MT |
782 | print "\t</table>"; |
783 | ||
784 | &Header::closebox(); | |
785 | ||
786 | &showclasses($qossettings{'RED_DEV'}); | |
787 | &showclasses($qossettings{'IMQ_DEV'}); | |
2db5d932 | 788 | |
904a41b9 MT |
789 | &Header::closebigbox(); |
790 | &Header::closepage(); | |
904a41b9 | 791 | |
414e011d MT |
792 | ############################################################################################################################ |
793 | ############################################################################################################################ | |
2db5d932 MT |
794 | |
795 | sub changedefclasses { | |
0b1641db | 796 | &Header::openbox('100%', 'center', $Lang::tr{'std classes'}); |
904a41b9 | 797 | print <<END |
2db5d932 MT |
798 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> |
799 | <table width='66%'> | |
0b1641db | 800 | <tr><td width='100%' colspan='3'>$Lang::tr{'no filter pass'} |
2db5d932 MT |
801 | <tr><td width='33%' align='right'>Download:<td width='33%' align='left'><select name='DEFCLASS_INC'> |
802 | END | |
803 | ; | |
414e011d | 804 | for ( $c = 200 ; $c <= 220 ; $c++ ) |
2db5d932 MT |
805 | { |
806 | if ( $qossettings{'DEFCLASS_INC'} ne $c ) | |
fcd5cb6f | 807 | { print "<option value='$c'>$c</option>\n"; } |
414e011d | 808 | else { print "<option selected value='$c'>$c</option>\n"; } |
2db5d932 MT |
809 | } |
810 | print <<END | |
811 | </select><td width='33%' align='center'> | |
812 | <tr><td width='33%' align='right'>Upload:<td width='33%' align='left'><select name='DEFCLASS_OUT'> | |
813 | END | |
814 | ; | |
414e011d | 815 | for ( $c = 100 ; $c <= 120 ; $c++ ) |
2db5d932 MT |
816 | { |
817 | if ( $qossettings{'DEFCLASS_OUT'} ne $c ) | |
414e011d MT |
818 | { print "<option value='$c'>$c</option>\n"; } |
819 | else { print "<option selected value='$c'>$c</option>\n"; } | |
2db5d932 MT |
820 | } |
821 | print <<END | |
822 | </select><td width='33%' align='center'> | |
823 | </table> | |
f013ab2b | 824 | <hr /> |
2db5d932 | 825 | <table width='66%'> |
0b1641db | 826 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter ack class'} |
2db5d932 MT |
827 | <tr><td width='33%' align='right'>ACKs:<td width='33%' align='left'><select name='ACK'> |
828 | END | |
829 | ; | |
414e011d | 830 | for ( $c = 100 ; $c <= 120 ; $c++ ) |
2db5d932 MT |
831 | { |
832 | if ( $qossettings{'ACK'} ne $c ) | |
414e011d MT |
833 | { print "<option value='$c'>$c</option>\n"; } |
834 | else { print "<option selected value='$c'>$c</option>\n"; } | |
2db5d932 MT |
835 | } |
836 | print <<END | |
f013ab2b | 837 | </select><td width='33%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" /> |
2db5d932 MT |
838 | </table> |
839 | </form> | |
904a41b9 MT |
840 | END |
841 | ; | |
3a70a538 | 842 | &Header::closebox(); |
2db5d932 MT |
843 | } |
844 | ||
845 | sub changebandwidth { | |
0b1641db | 846 | &Header::openbox('100%', 'center', $Lang::tr{'bandwithsettings'}); |
2db5d932 | 847 | if ($qossettings{'ENABLED'} eq 'on') { |
0b1641db CS |
848 | print "$Lang::tr{'bandwitherror'}"; |
849 | print "<a href='/cgi-bin/qos.cgi'>$Lang::tr{'back'}</a>"; | |
2db5d932 MT |
850 | } else { |
851 | print <<END | |
852 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f013ab2b | 853 | <input type='hidden' name='DEF_OUT_SPD' value='' /><input type='hidden' name='DEF_INC_SPD' value='' /> |
2db5d932 | 854 | <table width='66%'> |
33e1f48c CS |
855 | <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr> |
856 | <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td> | |
857 | <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td> | |
858 | <td width='20%' align='center' rowspan='2'><input type='submit' name='ACTION' value="$Lang::tr{'template'}" /><br /><input type='submit' name='ACTION' value="$Lang::tr{'save'}" /><br /><input type='reset' name='ACTION' value="$Lang::tr{'reset'}" /></td></tr> | |
859 | <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td> | |
860 | <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr> | |
2db5d932 MT |
861 | </table> |
862 | </form> | |
33e1f48c | 863 | <font color='red'>$Lang::tr{'template warning'}</font> |
2db5d932 MT |
864 | END |
865 | ; | |
866 | } | |
904a41b9 | 867 | &Header::closebox(); |
904a41b9 MT |
868 | } |
869 | ||
2db5d932 | 870 | sub parentclass { |
0b1641db | 871 | &Header::openbox('100%', 'center', $Lang::tr{'parentclass'}); |
2db5d932 MT |
872 | print <<END |
873 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
874 | <table width='66%'> | |
414e011d MT |
875 | END |
876 | ; | |
877 | if ( $message ne "" ) { | |
878 | print "<tr><td colspan='3' align='center'>$message"; | |
879 | } | |
fcd5cb6f | 880 | if ( $qossettings{'EDIT'} eq 'yes' ) { |
18322edf CS |
881 | print "<input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' />"; |
882 | print "<input type='hidden' name='DEVICE' value='$qossettings{'DEVICE'}' />"; | |
414e011d MT |
883 | } |
884 | print <<END | |
0b1641db CS |
885 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} |
886 | <tr><td width='33%' align='right'>$Lang::tr{'interface'}: | |
414e011d MT |
887 | <td width='33%' align='left'> |
888 | END | |
889 | ; | |
fcd5cb6f | 890 | if ( $qossettings{'EDIT'} eq 'yes' ) { |
414e011d MT |
891 | print "<select name='DEVICE' disabled>"; |
892 | } else { | |
893 | print "<select name='DEVICE'>"; | |
894 | } | |
895 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
896 | $qossettings{'RED_DEV_SEL'} = 'selected'; | |
897 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
898 | $qossettings{'IMQ_DEV_SEL'} = 'selected'; | |
899 | } | |
900 | print <<END | |
18322edf CS |
901 | <option value='$qossettings{'RED_DEV'}' $qossettings{'RED_DEV_SEL'}>$qossettings{'RED_DEV'}</option> |
902 | <option value='$qossettings{'IMQ_DEV'}' $qossettings{'IMQ_DEV_SEL'}>$qossettings{'IMQ_DEV'}</option></select> | |
2db5d932 | 903 | <td width='33%' align='center'> |
0b1641db | 904 | <tr><td width='33%' align='right'>$Lang::tr{'Class'}:<td width='33%' align='left'> |
2db5d932 MT |
905 | END |
906 | ; | |
fcd5cb6f | 907 | if ( $qossettings{'EDIT'} eq 'yes' ) { |
414e011d MT |
908 | print "<select name='CLASS' disabled>"; |
909 | } else { | |
910 | print "<select name='CLASS'>"; | |
911 | } | |
2db5d932 MT |
912 | for ( $c = 100 ; $c <= 120 ; $c++ ) |
913 | { | |
914 | if ( $qossettings{'CLASS'} ne $c ) | |
414e011d MT |
915 | { print "<option value='$c'>$c</option>\n"; } |
916 | else { print "<option selected value='$c'>$c</option>\n"; } | |
2db5d932 MT |
917 | } |
918 | for ( $c = 200 ; $c <= 220 ; $c++ ) | |
919 | { | |
920 | if ( $qossettings{'CLASS'} ne $c ) | |
414e011d MT |
921 | { print "<option value='$c'>$c</option>\n"; } |
922 | else { print "<option selected value='$c'>$c</option>\n"; } | |
2db5d932 MT |
923 | } |
924 | print <<END | |
925 | </select> | |
926 | <td width='33%' align='center'> | |
0b1641db | 927 | <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'> |
2db5d932 MT |
928 | END |
929 | ; | |
930 | for ( $c = 1 ; $c <= 7 ; $c++ ) | |
931 | { | |
932 | if ( $qossettings{'PRIO'} ne $c ) | |
414e011d MT |
933 | { print "<option value='$c'>$c</option>\n"; } |
934 | else { print "<option selected value='$c'>$c</option>\n"; } | |
2db5d932 | 935 | } |
f013ab2b | 936 | if ($qossettings{'MINBWDTH'} eq "") { $qossettings{'MINBWDTH'} = "1"; } |
2db5d932 | 937 | print <<END |
f013ab2b | 938 | </select> |
2db5d932 | 939 | <td width='33%' align='center'> |
0b1641db | 940 | <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}: |
f013ab2b | 941 | <td width='33%' align='left'><input type='text' size='20' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" /> |
2db5d932 | 942 | <td width='33%' align='center'> |
0b1641db | 943 | <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}: |
f013ab2b | 944 | <td width='33%' align='left'><input type='text' size='20' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" /> |
2db5d932 MT |
945 | <td width='33%' align='center'> |
946 | <tr><td width='33%' align='right'>Burst: | |
f013ab2b | 947 | <td width='33%' align='left'><input type='text' size='20' name='BURST' maxlength='8' value="$qossettings{'BURST'}" /> |
2db5d932 MT |
948 | <td width='33%' align='center'> |
949 | <tr><td width='33%' align='right'>Ceilburst: | |
f013ab2b | 950 | <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" /> |
e8babc92 | 951 | <td width='33%' align='center'> |
bb2d1e47 MT |
952 | END |
953 | ; | |
954 | $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'"; | |
955 | print <<END | |
e8babc92 MT |
956 | <tr><td width='33%' align='right'>TOS-Bit: |
957 | <td width='33%' align='left'><select name='TOS'> | |
bb2d1e47 MT |
958 | <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option> |
959 | <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option> | |
960 | <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option> | |
961 | <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option> | |
962 | <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select> | |
f013ab2b MT |
963 | <td width='33%' align='center'> |
964 | <tr><td width='33%' align='right'>$Lang::tr{'remark'}: | |
f841744c | 965 | <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> <img alt="" alt='blob' src='/blob.gif' /> |
f013ab2b MT |
966 | <tr><td width='33%' align='right'> |
967 | <td width='33%' align='left'> | |
18322edf | 968 | <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' /> |
2db5d932 MT |
969 | </table></form> |
970 | END | |
971 | ; | |
972 | &Header::closebox(); | |
973 | } | |
904a41b9 | 974 | |
414e011d | 975 | sub subclass { |
0b1641db | 976 | &Header::openbox('100%', 'center', $Lang::tr{'Subclass'}); |
2db5d932 MT |
977 | print <<END |
978 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
979 | <table width='66%'> | |
414e011d MT |
980 | END |
981 | ; | |
982 | if ( $message ne "" ) { | |
983 | print "<tr><td colspan='3' align='center'>$message"; | |
984 | } | |
985 | print <<END | |
0b1641db CS |
986 | <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} |
987 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
988 | <tr><td width='33%' align='right'>$Lang::tr{'Subclass'}:<td width='33%' align='left'><select name='SCLASS'> | |
414e011d MT |
989 | END |
990 | ; | |
991 | if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) { | |
992 | $qossettings{'DEVICE'} = $qossettings{'RED_DEV'}; | |
993 | for ( $c = 1000 ; $c <= 1020 ; $c++ ) | |
994 | { | |
995 | if ( $qossettings{'SCLASS'} ne $c ) | |
996 | { print "<option value='$c'>$c</option>\n"; } | |
997 | else { print "<option selected value='$c'>$c</option>\n"; } | |
998 | } | |
999 | } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) { | |
1000 | $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'}; | |
1001 | for ( $c = 2000 ; $c <= 2020 ; $c++ ) | |
1002 | { | |
1003 | if ( $qossettings{'SCLASS'} ne $c ) | |
1004 | { print "<option value='$c'>$c</option>\n"; } | |
1005 | else { print "<option selected value='$c'>$c</option>\n"; } | |
1006 | } | |
1007 | } | |
1008 | print <<END | |
1009 | </select> | |
1010 | <td width='33%' align='center'> | |
0b1641db | 1011 | <tr><td width='33%' align='right'>$Lang::tr{'priority'}:<td width='33%' align='left'><select name='PRIO'> |
414e011d MT |
1012 | END |
1013 | ; | |
1014 | for ( $c = 1 ; $c <= 7 ; $c++ ) | |
1015 | { | |
1016 | if ( $qossettings{'PRIO'} ne $c ) | |
1017 | { print "<option value='$c'>$c</option>\n"; } | |
1018 | else { print "<option selected value='$c'>$c</option>\n"; } | |
1019 | } | |
1020 | print <<END | |
1021 | <td width='33%' align='center'> | |
0b1641db | 1022 | <tr><td width='33%' align='right'>$Lang::tr{'guaranteed bandwith'}: |
f013ab2b | 1023 | <td width='33%' align='left'><input type='text' name='MINBWDTH' maxlength='8' required='1' value="$qossettings{'MINBWDTH'}" /> |
414e011d | 1024 | <td width='33%' align='center'> |
0b1641db | 1025 | <tr><td width='33%' align='right'>$Lang::tr{'max bandwith'}: |
f013ab2b | 1026 | <td width='33%' align='left'><input type='text' name='MAXBWDTH' maxlength='8' required='1' value="$qossettings{'MAXBWDTH'}" /> |
414e011d MT |
1027 | <td width='33%' align='center'> |
1028 | <tr><td width='33%' align='right'>Burst: | |
f013ab2b | 1029 | <td width='33%' align='left'><input type='text' name='BURST' maxlength='8' value="$qossettings{'BURST'}" /> |
2db5d932 | 1030 | <td width='33%' align='center'> |
414e011d | 1031 | <tr><td width='33%' align='right'>Ceilburst: |
f013ab2b | 1032 | <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" /> |
e8babc92 MT |
1033 | <td width='33%' align='center'> |
1034 | <tr><td width='33%' align='right'>TOS-Bit: | |
1035 | <td width='33%' align='left'><select name='TOS'> | |
0b1641db CS |
1036 | <option value='0'>$Lang::tr{'disabled'} (0)</option> |
1037 | <option value='8'>$Lang::tr{'min delay'} (8)</option> | |
1038 | <option value='4'>$Lang::tr{'max throughput'} (4)</option> | |
1039 | <option value='2'>$Lang::tr{'max reliability'} (2)</option> | |
1040 | <option value='1'>$Lang::tr{'min costs'} (1)</option></select> | |
f013ab2b MT |
1041 | <td width='33%' align='center'><input type='hidden' name='CLASS' value="$qossettings{'CLASS'}" /> |
1042 | <input type='hidden' name='DEVICE' value="$qossettings{'DEVICE'}" /> | |
18322edf | 1043 | <input type='submit' name='DOSCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' /> |
414e011d MT |
1044 | </table></form> |
1045 | END | |
1046 | ; | |
1047 | &Header::closebox(); | |
1048 | } | |
1049 | ||
414e011d | 1050 | sub level7rule { |
0b1641db | 1051 | &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'}); |
414e011d MT |
1052 | print <<END |
1053 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
1054 | <table width='66%'> | |
1055 | END | |
1056 | ; | |
1057 | if ( $message ne "" ) { | |
1058 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
1059 | } | |
1060 | print <<END | |
0b1641db CS |
1061 | <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} |
1062 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
1063 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
2db5d932 MT |
1064 | <td width='33%' align='left'><select name='L7PROT'> |
1065 | END | |
1066 | ; | |
1067 | opendir( DIR, "/etc/l7-protocols/protocols" ); | |
1068 | foreach $direntry ( sort readdir(DIR) ) | |
1069 | { | |
1070 | next if $direntry eq "."; | |
1071 | next if $direntry eq ".."; | |
1072 | next if -d "/etc/l7-protocols/protocols/$direntry"; | |
1073 | @proto = split( /\./, $direntry ); | |
1074 | if ( $proto[0] eq $qossettings{'L7PROT'} ) { | |
fcd5cb6f | 1075 | print "<option value='$proto[0]' selected>$proto[0]</option>\n"; |
2db5d932 MT |
1076 | } else { |
1077 | print "<option value='$proto[0]'>$proto[0]</option>\n"; | |
1078 | } | |
1079 | } | |
1080 | closedir DIR; | |
1081 | print <<END | |
1082 | </select><td width='33%' align='center'> | |
0b1641db | 1083 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: |
18322edf | 1084 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value='$qossettings{'QIP'}' /> |
2db5d932 | 1085 | <td width='33%' align='center'> |
0b1641db | 1086 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: |
18322edf CS |
1087 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value='$qossettings{'DIP'}' /> |
1088 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' /> | |
2db5d932 MT |
1089 | </table></form> |
1090 | END | |
1091 | ; | |
1092 | &Header::closebox(); | |
414e011d MT |
1093 | } |
1094 | ||
1095 | sub portrule { | |
0b1641db | 1096 | &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'}); |
414e011d MT |
1097 | print <<END |
1098 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
1099 | <table width='66%'> | |
0b1641db CS |
1100 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} |
1101 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
414e011d MT |
1102 | <td width='33%' align='left'><select name='PPROT'> |
1103 | END | |
1104 | ; | |
1105 | open( FILE, "< /etc/protocols" ); | |
1106 | @proto = <FILE>; | |
1107 | close FILE; | |
1108 | foreach $direntry (sort @proto) | |
1109 | { | |
1110 | @tmpline = split( /\ /, $direntry ); | |
1111 | next if $tmpline[0] =~ "#"; | |
1112 | if ( $tmpline[0] eq $qossettings{'PPROT'} ) { | |
fcd5cb6f | 1113 | print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n"; |
414e011d MT |
1114 | } else { |
1115 | print "<option value='$tmpline[0]'>$tmpline[0]</option>\n"; | |
1116 | } | |
1117 | } | |
1118 | print <<END | |
1119 | </select><td width='33%' align='center'> | |
0b1641db | 1120 | <tr><td width='33%' align='right'>$Lang::tr{'source port'}: |
18322edf | 1121 | <td width='33%' align='left'><input type='text' name='QPORT' maxlength='5' value='$qossettings{'QPORT'}' /> |
414e011d | 1122 | <td width='33%' align='center'> |
0b1641db | 1123 | <tr><td width='33%' align='right'>$Lang::tr{'destination port'}: |
18322edf | 1124 | <td width='33%' align='left'><input type='text' name='DPORT' maxlength='5' value='$qossettings{'DPORT'}' /> |
414e011d | 1125 | <td width='33%' align='center'> |
0b1641db | 1126 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: |
18322edf | 1127 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value='$qossettings{'QIP'}' /> |
414e011d | 1128 | <td width='33%' align='center'> |
0b1641db | 1129 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: |
18322edf CS |
1130 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value='$qossettings{'DIP'}' /> |
1131 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' /> | |
414e011d MT |
1132 | </table></form> |
1133 | END | |
1134 | ; | |
1135 | &Header::closebox(); | |
1136 | } | |
1137 | ||
e8babc92 | 1138 | sub tosrule { |
0b1641db | 1139 | &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'}); |
e8babc92 | 1140 | if ($qossettings{'TOS'}) { |
0b1641db | 1141 | $checked{$qossettings{'TOS'}} = "checked"; |
e8babc92 MT |
1142 | } |
1143 | print <<END | |
1144 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
1145 | <table width='66%'> | |
1146 | END | |
1147 | ; | |
1148 | if ( $message ne "" ) { | |
1149 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
1150 | } | |
1151 | print <<END | |
0b1641db CS |
1152 | <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} |
1153 | <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'} | |
1154 | <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] /> | |
1155 | <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] /> | |
1156 | <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] /> | |
da7e2665 | 1157 | <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] /> |
18322edf | 1158 | <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 |
1159 | </table></form> |
1160 | END | |
1161 | ; | |
1162 | &Header::closebox(); | |
1163 | } | |
1164 | ||
414e011d | 1165 | sub showclasses { |
f013ab2b | 1166 | $qossettings{'DEV'} = shift; |
414e011d MT |
1167 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; |
1168 | @classes = <FILE>; | |
1169 | close FILE; | |
1170 | if (@classes) { | |
1171 | open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile"; | |
1172 | @subclasses = <FILE>; | |
1173 | close FILE; | |
f013ab2b MT |
1174 | open( FILE, "< $level7file" ) or die "Unable to read $level7file"; |
1175 | @l7rules = <FILE>; | |
1176 | close FILE; | |
1177 | open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; | |
1178 | @tosrules = <FILE>; | |
1179 | close FILE; | |
1180 | open( FILE, "< $portfile" ) or die "Unable to read $portfile"; | |
1181 | @portrules = <FILE>; | |
1182 | close FILE; | |
414e011d MT |
1183 | foreach $classentry (sort @classes) |
1184 | { | |
1185 | @classline = split( /\;/, $classentry ); | |
f013ab2b | 1186 | if ( $classline[0] eq $qossettings{'DEV'} ) |
414e011d | 1187 | { |
18322edf | 1188 | &Header::openbox('100%', 'center', "Klasse: $classline[1]"); |
414e011d | 1189 | print <<END |
f013ab2b | 1190 | <table border='0' width='100%' cellspacing='0'> |
f2fdd0c1 | 1191 | <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b> |
0b1641db CS |
1192 | <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b> |
1193 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'} | |
1194 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'} | |
1195 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'} | |
f2fdd0c1 CS |
1196 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst |
1197 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst | |
1198 | <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS | |
0b1641db | 1199 | <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'} |
f2fdd0c1 CS |
1200 | <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td> |
1201 | <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td> | |
1202 | <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td> | |
1203 | <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td> | |
1204 | <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td> | |
1205 | <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td> | |
1206 | <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td> | |
1207 | <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td> | |
1208 | <td align='right' bgcolor='$color{'color22'}'> | |
649fd295 | 1209 | <table border='0'><tr> |
649fd295 | 1210 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
f841744c CS |
1211 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
1212 | <input type='hidden' name='ACTION' value='Unterklasse hinzufuegen' /> | |
0b1641db | 1213 | <input type='image' alt='$Lang::tr{'add subclass'}' src='/images/addblue.gif' /> |
649fd295 MT |
1214 | </form> |
1215 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1216 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
1217 | <input type='hidden' name='ACTION' value='Regel hinzufuegen' /> | |
0b1641db | 1218 | <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' /> |
649fd295 MT |
1219 | </form> |
1220 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1221 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
1222 | <input type='hidden' name='DOCLASS' value='Bearbeiten' /> | |
0b1641db | 1223 | <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
649fd295 MT |
1224 | </form> |
1225 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1226 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
1227 | <input type='hidden' name='DOCLASS' value='Loeschen' /> | |
0b1641db | 1228 | <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
649fd295 MT |
1229 | </form> |
1230 | </table> | |
f013ab2b MT |
1231 | </td> |
1232 | <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b> | |
1233 | <td align='center' colspan='6'> $classline[8] | |
1234 | <td align='right'><b>Queueing:</b> $classline[9] | |
414e011d MT |
1235 | END |
1236 | ; | |
f013ab2b MT |
1237 | |
1238 | if (@l7rules) { | |
1239 | foreach $l7ruleentry (sort @l7rules) | |
1240 | { | |
1241 | @l7ruleline = split( /\;/, $l7ruleentry ); | |
1242 | if ( $l7ruleline[0] eq $classline[1] ) | |
1243 | { | |
1244 | print <<END | |
0b1641db | 1245 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b> |
f013ab2b MT |
1246 | <td align='center' colspan='6'>$l7ruleline[2] |
1247 | <td align='right' > | |
649fd295 | 1248 | <table border='0'><tr> |
649fd295 | 1249 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
f013ab2b MT |
1250 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> |
1251 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
1252 | <input type='hidden' name='DOLEVEL7' value='Bearbeiten' /> | |
1253 | <input type='image' alt='Bearbeiten' src='/images/edit.gif' /> | |
649fd295 MT |
1254 | </form> |
1255 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f013ab2b MT |
1256 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> |
1257 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
1258 | <input type='hidden' name='DOLEVEL7' value='Loeschen' /> | |
1259 | <input type='image' alt='Loeschen' src='/images/delete.gif' /> | |
649fd295 MT |
1260 | </form> |
1261 | </table> | |
414e011d MT |
1262 | END |
1263 | ; | |
f013ab2b MT |
1264 | if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){ |
1265 | print <<END | |
1266 | <tr><td align='center'> | |
0b1641db CS |
1267 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3] |
1268 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4] | |
84cab473 MT |
1269 | END |
1270 | ; | |
f013ab2b MT |
1271 | } |
1272 | ||
414e011d | 1273 | |
84cab473 MT |
1274 | END |
1275 | ; | |
f013ab2b MT |
1276 | } |
1277 | } | |
1278 | } | |
1279 | ||
1280 | ||
1281 | if (@portrules) { | |
1282 | foreach $portruleentry (sort @portrules) | |
1283 | { | |
1284 | @portruleline = split( /\;/, $portruleentry ); | |
1285 | if ( $portruleline[0] eq $classline[1] ) | |
1286 | { | |
1287 | print <<END | |
0b1641db | 1288 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b> |
f013ab2b MT |
1289 | <td align='center'>($portruleline[2]) |
1290 | <td align='center' colspan='2'> | |
84cab473 MT |
1291 | END |
1292 | ; | |
f013ab2b MT |
1293 | if ($portruleline[4]) { |
1294 | print <<END | |
99a6f5f9 | 1295 | <i>$Lang::tr{'source port'}:</i> $portruleline[4] |
84cab473 MT |
1296 | END |
1297 | ; | |
f013ab2b MT |
1298 | } |
1299 | print "<td align='center' colspan='2'>"; | |
1300 | if ($portruleline[6]) { | |
1301 | print <<END | |
99a6f5f9 | 1302 | <i>$Lang::tr{'destination port'}:</i> $portruleline[6] |
84cab473 MT |
1303 | END |
1304 | ; | |
f013ab2b MT |
1305 | } |
1306 | print <<END | |
1307 | <td> | |
1308 | <td align='right'> | |
8b0883b8 MT |
1309 | <table border='0'><tr> |
1310 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1311 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> |
1312 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
1313 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
1314 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
1315 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
1316 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
1317 | <input type='hidden' name='DOPORT' value='Bearbeiten' /> | |
0b1641db | 1318 | <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
8b0883b8 MT |
1319 | </form> |
1320 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1321 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> |
1322 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
1323 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
1324 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
1325 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
1326 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
1327 | <input type='hidden' name='DOPORT' value='Loeschen' /> | |
0b1641db | 1328 | <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
8b0883b8 MT |
1329 | </form> |
1330 | </table> | |
414e011d MT |
1331 | END |
1332 | ; | |
f013ab2b MT |
1333 | if (($portruleline[3] ne "") || ($portruleline[5] ne "")){ |
1334 | print <<END | |
1335 | <tr><td align='center'> | |
0b1641db CS |
1336 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3] |
1337 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5] | |
84cab473 MT |
1338 | END |
1339 | ; | |
f013ab2b MT |
1340 | } |
1341 | } | |
1342 | } | |
1343 | } | |
414e011d | 1344 | |
f013ab2b MT |
1345 | if (@tosrules) { |
1346 | foreach $tosruleentry (sort @tosrules) | |
1347 | { | |
1348 | @tosruleline = split( /\;/, $tosruleentry ); | |
1349 | if ( $tosruleline[0] eq $classline[1] ) | |
1350 | { | |
1351 | print <<END | |
1352 | <tr><td align='right' colspan='2'> | |
1353 | <b>TOS Bit matches:</b> | |
1354 | <td colspan='6' align='center'> | |
e8babc92 MT |
1355 | END |
1356 | ; | |
f013ab2b | 1357 | if ( $tosruleline[2] eq "8") { |
0b1641db | 1358 | print "$Lang::tr{'min delay'}\n"; |
f013ab2b | 1359 | } elsif ( $tosruleline[2] eq "4") { |
0b1641db | 1360 | print "$Lang::tr{'max throughput'}\n"; |
f013ab2b | 1361 | } elsif ( $tosruleline[2] eq "2") { |
0b1641db | 1362 | print "$Lang::tr{'max reliability'}\n"; |
f013ab2b | 1363 | } elsif ( $tosruleline[2] eq "1") { |
0b1641db | 1364 | print "$Lang::tr{'min costs'}\n"; |
f013ab2b MT |
1365 | } else { print " \n"; } |
1366 | ||
1367 | print <<END | |
1368 | ($tosruleline[2]) | |
1369 | <td align='right'> | |
1370 | <table border='0'><tr> | |
1371 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1372 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> |
1373 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
1374 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
1375 | <input type='hidden' name='DOTOS' value='Bearbeiten' /> | |
0b1641db | 1376 | <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
f013ab2b MT |
1377 | </form> |
1378 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1379 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> |
1380 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
1381 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
1382 | <input type='hidden' name='DOTOS' value='Loeschen' /> | |
0b1641db | 1383 | <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
f013ab2b MT |
1384 | </form> |
1385 | </table> | |
e8babc92 MT |
1386 | END |
1387 | ; | |
f013ab2b MT |
1388 | } |
1389 | } | |
1390 | } | |
e8babc92 MT |
1391 | END |
1392 | ; | |
f013ab2b MT |
1393 | foreach $subclassentry (sort @subclasses) |
1394 | { | |
1395 | @subclassline = split( /\;/, $subclassentry ); | |
1396 | if ( $subclassline[1] eq $classline[1] ) { | |
1397 | print <<END | |
0b1641db | 1398 | <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}: |
f013ab2b MT |
1399 | <td align='center' bgcolor='#FAFAFA'>$subclassline[2] |
1400 | <td align='center' bgcolor='#FAFAFA'>$subclassline[3] | |
1401 | <td align='center' bgcolor='#FAFAFA'>$subclassline[4] | |
1402 | <td align='center' bgcolor='#FAFAFA'>$subclassline[5] | |
1403 | <td align='center' bgcolor='#FAFAFA'>$subclassline[6] | |
1404 | <td align='center' bgcolor='#FAFAFA'>$subclassline[7] | |
1405 | <td align='center' bgcolor='#FAFAFA'>$subclassline[8] | |
1406 | <td align='right' bgcolor='#FAFAFA'> | |
1407 | <table border='0'><tr> | |
1408 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1409 | <input type='hidden' name='CLASS' value='$subclassline[2]' /> |
1410 | <input type='hidden' name='ACTION' value='Regel hinzufuegen' /> | |
0b1641db | 1411 | <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' /> |
f013ab2b MT |
1412 | </form> |
1413 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1414 | <input type='hidden' name='CLASS' value='$subclassline[2]' /> |
1415 | <input type='hidden' name='DOSCLASS' value='Bearbeiten' /> | |
0b1641db | 1416 | <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
f013ab2b MT |
1417 | </form> |
1418 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1419 | <input type='hidden' name='CLASS' value='$subclassline[2]' /> |
1420 | <input type='hidden' name='DOSCLASS' value='Loeschen' /> | |
0b1641db | 1421 | <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
f013ab2b MT |
1422 | </form> |
1423 | </table> | |
e8babc92 MT |
1424 | END |
1425 | ; | |
f013ab2b MT |
1426 | } |
1427 | } | |
1428 | print <<END | |
1429 | </table> | |
e8babc92 MT |
1430 | END |
1431 | ; | |
18322edf | 1432 | &Header::closebox(); |
e8babc92 | 1433 | } |
18322edf CS |
1434 | } |
1435 | } | |
e8babc92 | 1436 | } |
e8babc92 | 1437 | |
84cab473 MT |
1438 | sub expert |
1439 | { | |
0b1641db | 1440 | &Header::openbox('100%', 'center', $Lang::tr{'expertoptions'}); |
84cab473 MT |
1441 | print <<END |
1442 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
84cab473 MT |
1443 | <table width='66%'> |
1444 | <tr><td width='33%' align='right'>MTU:<td width='33%' align='left'> | |
18322edf | 1445 | <input type='text' name='MTU' maxlength='8' required='4' value='$qossettings{'MTU'}' /> |
0b1641db CS |
1446 | <td width='33%' align='center'>$Lang::tr{'mtu QoS'} |
1447 | <tr><td width='33%' align='right'>$Lang::tr{'Queuelenght'}:<td width='33%' align='left'> | |
18322edf | 1448 | <input type='text' name='QLENGTH' maxlength='8' required='2' value='$qossettings{'QLENGTH'}' /> |
84cab473 MT |
1449 | <td width='33%' align='center'> |
1450 | <tr><td width='33%' align='right'>SFQ Perturb:<td width='33%' align='left'> | |
18322edf CS |
1451 | <input type='text' name='SFQ_PERTUB' maxlength='8' required='1' value='$qossettings{'SFQ_PERTUB'}' /> |
1452 | <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /> | |
84cab473 MT |
1453 | </table> |
1454 | </form> | |
1455 | END | |
1456 | ; | |
1457 | &Header::closebox(); | |
1458 | } | |
414e011d MT |
1459 | |
1460 | sub validminbwdth { | |
1461 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1462 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1463 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
1464 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1465 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
1466 | } | |
363fb6af | 1467 | unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) { |
414e011d | 1468 | $qossettings{'VALID'} = 'no'; |
0b1641db | 1469 | $message = "$Lang::tr{'false min bandwith'}"; |
414e011d MT |
1470 | } |
1471 | $qossettings{'SPD'} = ''; | |
1472 | } | |
1473 | } | |
84cab473 | 1474 | |
414e011d MT |
1475 | sub validmaxbwdth { |
1476 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1477 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1478 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
1479 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1480 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
1481 | } | |
1482 | unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) { | |
1483 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1484 | $message = "$Lang::tr{'false max bandwith'}"; |
414e011d MT |
1485 | } |
1486 | $qossettings{'SPD'} = ''; | |
1487 | } | |
1488 | } | |
1489 | ||
1490 | sub validclass { | |
1491 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1492 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1493 | if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) { | |
1494 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1495 | $message = "$Lang::tr{'false classnumber'}"; |
414e011d MT |
1496 | } |
1497 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1498 | if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) { | |
1499 | $qossettings{'VALID'} = 'no'; | |
1500 | $message = "Die Klassennummer passt nicht zum angegebenen Interface."; | |
1501 | } | |
1502 | } | |
1503 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
1504 | @tmp = <FILE>; | |
1505 | close FILE; | |
1506 | foreach $classentry (sort @tmp) | |
1507 | { | |
1508 | @tmpline = split( /\;/, $classentry ); | |
1509 | if ( $tmpline[1] eq $qossettings{'CLASS'} ) | |
1510 | { | |
1511 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1512 | $message = "$Lang::tr{'false classnumber'}"; |
414e011d MT |
1513 | last |
1514 | } | |
1515 | } | |
1516 | } | |
1517 | } | |
84cab473 | 1518 | |
414e011d MT |
1519 | sub validsubclass { |
1520 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1521 | open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile"; | |
1522 | @tmp = <FILE>; | |
1523 | close FILE; | |
1524 | foreach $subclassentry (sort @tmp) | |
1525 | { | |
1526 | @tmpline = split( /\;/, $subclassentry ); | |
1527 | if ( $tmpline[2] eq $qossettings{'SCLASS'} ) | |
1528 | { | |
1529 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1530 | $message = "$Lang::tr{'class in use'}"; |
414e011d MT |
1531 | last |
1532 | } | |
1533 | } | |
1534 | } | |
84cab473 | 1535 | } |