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