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