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