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