]>
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'> |
bb2d1e47 MT |
886 | END |
887 | ; | |
888 | $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'"; | |
889 | print <<END | |
e8babc92 MT |
890 | <tr><td width='33%' align='right'>TOS-Bit: |
891 | <td width='33%' align='left'><select name='TOS'> | |
bb2d1e47 MT |
892 | <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option> |
893 | <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option> | |
894 | <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option> | |
895 | <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option> | |
896 | <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select> | |
f013ab2b MT |
897 | <td width='33%' align='center'> |
898 | <tr><td width='33%' align='right'>$Lang::tr{'remark'}: | |
e3edceeb LS |
899 | <td width='66%' colspan='2' align='left'><input type='text' name='REMARK' size='40' maxlength='40' value="$qossettings{'REMARK'}" /> |
900 | <tr><td width='33%' align='right'><img src='/blob.gif' alt='*' /> $Lang::tr{'required field'} | |
f013ab2b | 901 | <td width='33%' align='left'> |
18322edf | 902 | <td width='33%' align='center'><input type='submit' name='DOCLASS' value='$Lang::tr{'save'}' /> <input type='reset' value='$Lang::tr{'reset'}' /> |
2db5d932 MT |
903 | </table></form> |
904 | END | |
905 | ; | |
906 | &Header::closebox(); | |
907 | } | |
904a41b9 | 908 | |
414e011d | 909 | sub level7rule { |
0b1641db | 910 | &Header::openbox('100%', 'center', $Lang::tr{'Level7 Rule'}); |
414e011d MT |
911 | print <<END |
912 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
913 | <table width='66%'> | |
914 | END | |
915 | ; | |
916 | if ( $message ne "" ) { | |
917 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
918 | } | |
919 | print <<END | |
0b1641db CS |
920 | <tr><td colspan='3' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} |
921 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} | |
922 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
2db5d932 MT |
923 | <td width='33%' align='left'><select name='L7PROT'> |
924 | END | |
925 | ; | |
926 | opendir( DIR, "/etc/l7-protocols/protocols" ); | |
927 | foreach $direntry ( sort readdir(DIR) ) | |
928 | { | |
929 | next if $direntry eq "."; | |
930 | next if $direntry eq ".."; | |
931 | next if -d "/etc/l7-protocols/protocols/$direntry"; | |
932 | @proto = split( /\./, $direntry ); | |
933 | if ( $proto[0] eq $qossettings{'L7PROT'} ) { | |
fcd5cb6f | 934 | print "<option value='$proto[0]' selected>$proto[0]</option>\n"; |
2db5d932 MT |
935 | } else { |
936 | print "<option value='$proto[0]'>$proto[0]</option>\n"; | |
937 | } | |
938 | } | |
939 | closedir DIR; | |
940 | print <<END | |
941 | </select><td width='33%' align='center'> | |
0b1641db | 942 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: |
5eee5a60 | 943 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' /> |
2db5d932 | 944 | <td width='33%' align='center'> |
0b1641db | 945 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: |
5eee5a60 | 946 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' /> |
18322edf | 947 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOLEVEL7' value='$Lang::tr{'save'}' /> |
11bccc3f | 948 | <tr><td colspan="3" align='center'><font color="red"><em>$Lang::tr{'qos warning'}</em></font> |
2db5d932 MT |
949 | </table></form> |
950 | END | |
951 | ; | |
952 | &Header::closebox(); | |
414e011d MT |
953 | } |
954 | ||
955 | sub portrule { | |
0b1641db | 956 | &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'}); |
414e011d MT |
957 | print <<END |
958 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
959 | <table width='66%'> | |
0b1641db CS |
960 | <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'} |
961 | <tr><td width='33%' align='right'>$Lang::tr{'protocol'}: | |
414e011d MT |
962 | <td width='33%' align='left'><select name='PPROT'> |
963 | END | |
964 | ; | |
965 | open( FILE, "< /etc/protocols" ); | |
966 | @proto = <FILE>; | |
967 | close FILE; | |
968 | foreach $direntry (sort @proto) | |
969 | { | |
970 | @tmpline = split( /\ /, $direntry ); | |
971 | next if $tmpline[0] =~ "#"; | |
972 | if ( $tmpline[0] eq $qossettings{'PPROT'} ) { | |
fcd5cb6f | 973 | print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n"; |
414e011d MT |
974 | } else { |
975 | print "<option value='$tmpline[0]'>$tmpline[0]</option>\n"; | |
976 | } | |
977 | } | |
978 | print <<END | |
979 | </select><td width='33%' align='center'> | |
0b1641db | 980 | <tr><td width='33%' align='right'>$Lang::tr{'source port'}: |
ec3573fc | 981 | <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' /> |
414e011d | 982 | <td width='33%' align='center'> |
0b1641db | 983 | <tr><td width='33%' align='right'>$Lang::tr{'destination port'}: |
ec3573fc | 984 | <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' /> |
414e011d | 985 | <td width='33%' align='center'> |
0b1641db | 986 | <tr><td width='33%' align='right'>$Lang::tr{'source ip'}: |
5eee5a60 | 987 | <td width='33%' align='left'><input type='text' name='QIP' maxlength='31' value='$qossettings{'QIP'}' /> |
414e011d | 988 | <td width='33%' align='center'> |
0b1641db | 989 | <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}: |
5eee5a60 | 990 | <td width='33%' align='left'><input type='text' name='DIP' maxlength='31' value='$qossettings{'DIP'}' /> |
18322edf | 991 | <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' /> |
414e011d MT |
992 | </table></form> |
993 | END | |
994 | ; | |
995 | &Header::closebox(); | |
996 | } | |
997 | ||
e8babc92 | 998 | sub tosrule { |
0b1641db | 999 | &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'}); |
e8babc92 | 1000 | if ($qossettings{'TOS'}) { |
0b1641db | 1001 | $checked{$qossettings{'TOS'}} = "checked"; |
e8babc92 MT |
1002 | } |
1003 | print <<END | |
1004 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
1005 | <table width='66%'> | |
1006 | END | |
1007 | ; | |
1008 | if ( $message ne "" ) { | |
1009 | print "<tr><td colspan='3' align='center'><font color='red'>$message</font>"; | |
1010 | } | |
1011 | print <<END | |
0b1641db CS |
1012 | <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'} |
1013 | <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'} | |
1014 | <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] /> | |
1015 | <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] /> | |
1016 | <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] /> | |
da7e2665 | 1017 | <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] /> |
18322edf | 1018 | <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 |
1019 | </table></form> |
1020 | END | |
1021 | ; | |
1022 | &Header::closebox(); | |
1023 | } | |
1024 | ||
414e011d | 1025 | sub showclasses { |
f013ab2b | 1026 | $qossettings{'DEV'} = shift; |
414e011d MT |
1027 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; |
1028 | @classes = <FILE>; | |
1029 | close FILE; | |
1030 | if (@classes) { | |
f013ab2b MT |
1031 | open( FILE, "< $level7file" ) or die "Unable to read $level7file"; |
1032 | @l7rules = <FILE>; | |
1033 | close FILE; | |
1034 | open( FILE, "< $tosfile" ) or die "Unable to read $tosfile"; | |
1035 | @tosrules = <FILE>; | |
1036 | close FILE; | |
1037 | open( FILE, "< $portfile" ) or die "Unable to read $portfile"; | |
1038 | @portrules = <FILE>; | |
1039 | close FILE; | |
414e011d MT |
1040 | foreach $classentry (sort @classes) |
1041 | { | |
1042 | @classline = split( /\;/, $classentry ); | |
f013ab2b | 1043 | if ( $classline[0] eq $qossettings{'DEV'} ) |
414e011d | 1044 | { |
be7534e3 | 1045 | &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1] $classline[8]"); |
414e011d | 1046 | print <<END |
f013ab2b | 1047 | <table border='0' width='100%' cellspacing='0'> |
f2fdd0c1 | 1048 | <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b> |
0b1641db CS |
1049 | <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b> |
1050 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'} | |
1051 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'} | |
1052 | <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'} | |
f2fdd0c1 CS |
1053 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst |
1054 | <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst | |
1055 | <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS | |
0b1641db | 1056 | <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'} |
f2fdd0c1 CS |
1057 | <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td> |
1058 | <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td> | |
1059 | <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td> | |
1060 | <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td> | |
1061 | <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td> | |
1062 | <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td> | |
1063 | <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td> | |
1064 | <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td> | |
1065 | <td align='right' bgcolor='$color{'color22'}'> | |
649fd295 | 1066 | <table border='0'><tr> |
649fd295 | 1067 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
f841744c | 1068 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
65e8619a | 1069 | <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' /> |
f8aa0679 | 1070 | <input type='image' alt='$Lang::tr{'Add Rule'}' title='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' /> |
649fd295 MT |
1071 | </form> |
1072 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c | 1073 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
65e8619a | 1074 | <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' /> |
f8aa0679 | 1075 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
649fd295 MT |
1076 | </form> |
1077 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c | 1078 | <input type='hidden' name='CLASS' value='$classline[1]' /> |
65e8619a | 1079 | <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' /> |
f8aa0679 | 1080 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
649fd295 MT |
1081 | </form> |
1082 | </table> | |
f013ab2b MT |
1083 | </td> |
1084 | <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b> | |
1085 | <td align='center' colspan='6'> $classline[8] | |
1086 | <td align='right'><b>Queueing:</b> $classline[9] | |
414e011d MT |
1087 | END |
1088 | ; | |
f013ab2b MT |
1089 | |
1090 | if (@l7rules) { | |
1091 | foreach $l7ruleentry (sort @l7rules) | |
1092 | { | |
1093 | @l7ruleline = split( /\;/, $l7ruleentry ); | |
1094 | if ( $l7ruleline[0] eq $classline[1] ) | |
1095 | { | |
1096 | print <<END | |
0b1641db | 1097 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b> |
f013ab2b MT |
1098 | <td align='center' colspan='6'>$l7ruleline[2] |
1099 | <td align='right' > | |
649fd295 | 1100 | <table border='0'><tr> |
649fd295 | 1101 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> |
f013ab2b MT |
1102 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> |
1103 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
65e8619a | 1104 | <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' /> |
f8aa0679 | 1105 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
649fd295 MT |
1106 | </form> |
1107 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f013ab2b MT |
1108 | <input type='hidden' name='CLASS' value='$l7ruleline[0]' /> |
1109 | <input type='hidden' name='L7PROT' value='$l7ruleline[2]' /> | |
65e8619a | 1110 | <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' /> |
f8aa0679 | 1111 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
649fd295 MT |
1112 | </form> |
1113 | </table> | |
414e011d MT |
1114 | END |
1115 | ; | |
f013ab2b MT |
1116 | if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){ |
1117 | print <<END | |
1118 | <tr><td align='center'> | |
0b1641db CS |
1119 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3] |
1120 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4] | |
84cab473 MT |
1121 | END |
1122 | ; | |
f013ab2b MT |
1123 | } |
1124 | ||
414e011d | 1125 | |
84cab473 MT |
1126 | END |
1127 | ; | |
f013ab2b MT |
1128 | } |
1129 | } | |
1130 | } | |
1131 | ||
1132 | ||
1133 | if (@portrules) { | |
1134 | foreach $portruleentry (sort @portrules) | |
1135 | { | |
1136 | @portruleline = split( /\;/, $portruleentry ); | |
1137 | if ( $portruleline[0] eq $classline[1] ) | |
1138 | { | |
1139 | print <<END | |
0b1641db | 1140 | <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b> |
f013ab2b MT |
1141 | <td align='center'>($portruleline[2]) |
1142 | <td align='center' colspan='2'> | |
84cab473 MT |
1143 | END |
1144 | ; | |
f013ab2b MT |
1145 | if ($portruleline[4]) { |
1146 | print <<END | |
99a6f5f9 | 1147 | <i>$Lang::tr{'source port'}:</i> $portruleline[4] |
84cab473 MT |
1148 | END |
1149 | ; | |
f013ab2b MT |
1150 | } |
1151 | print "<td align='center' colspan='2'>"; | |
1152 | if ($portruleline[6]) { | |
1153 | print <<END | |
99a6f5f9 | 1154 | <i>$Lang::tr{'destination port'}:</i> $portruleline[6] |
84cab473 MT |
1155 | END |
1156 | ; | |
f013ab2b MT |
1157 | } |
1158 | print <<END | |
1159 | <td> | |
1160 | <td align='right'> | |
8b0883b8 MT |
1161 | <table border='0'><tr> |
1162 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1163 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> |
1164 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
1165 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
1166 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
1167 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
1168 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
65e8619a | 1169 | <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' /> |
f8aa0679 | 1170 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
8b0883b8 MT |
1171 | </form> |
1172 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1173 | <input type='hidden' name='CLASS' value='$portruleline[0]' /> |
1174 | <input type='hidden' name='PPROT' value='$portruleline[2]' /> | |
1175 | <input type='hidden' name='QIP' value='$portruleline[3]' /> | |
1176 | <input type='hidden' name='QPORT' value='$portruleline[4]' /> | |
1177 | <input type='hidden' name='DIP' value='$portruleline[5]' /> | |
1178 | <input type='hidden' name='DPORT' value='$portruleline[6]' /> | |
65e8619a | 1179 | <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' /> |
f8aa0679 | 1180 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
8b0883b8 MT |
1181 | </form> |
1182 | </table> | |
414e011d MT |
1183 | END |
1184 | ; | |
f013ab2b MT |
1185 | if (($portruleline[3] ne "") || ($portruleline[5] ne "")){ |
1186 | print <<END | |
1187 | <tr><td align='center'> | |
0b1641db CS |
1188 | <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3] |
1189 | <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5] | |
84cab473 MT |
1190 | END |
1191 | ; | |
f013ab2b MT |
1192 | } |
1193 | } | |
1194 | } | |
1195 | } | |
414e011d | 1196 | |
f013ab2b MT |
1197 | if (@tosrules) { |
1198 | foreach $tosruleentry (sort @tosrules) | |
1199 | { | |
1200 | @tosruleline = split( /\;/, $tosruleentry ); | |
1201 | if ( $tosruleline[0] eq $classline[1] ) | |
1202 | { | |
1203 | print <<END | |
1204 | <tr><td align='right' colspan='2'> | |
1205 | <b>TOS Bit matches:</b> | |
1206 | <td colspan='6' align='center'> | |
e8babc92 MT |
1207 | END |
1208 | ; | |
f013ab2b | 1209 | if ( $tosruleline[2] eq "8") { |
0b1641db | 1210 | print "$Lang::tr{'min delay'}\n"; |
f013ab2b | 1211 | } elsif ( $tosruleline[2] eq "4") { |
0b1641db | 1212 | print "$Lang::tr{'max throughput'}\n"; |
f013ab2b | 1213 | } elsif ( $tosruleline[2] eq "2") { |
0b1641db | 1214 | print "$Lang::tr{'max reliability'}\n"; |
f013ab2b | 1215 | } elsif ( $tosruleline[2] eq "1") { |
0b1641db | 1216 | print "$Lang::tr{'min costs'}\n"; |
f013ab2b MT |
1217 | } else { print " \n"; } |
1218 | ||
1219 | print <<END | |
1220 | ($tosruleline[2]) | |
1221 | <td align='right'> | |
1222 | <table border='0'><tr> | |
1223 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1224 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> |
1225 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
1226 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
65e8619a | 1227 | <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' /> |
f8aa0679 | 1228 | <input type='image' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' src='/images/edit.gif' /> |
f013ab2b MT |
1229 | </form> |
1230 | <td><form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
f841744c CS |
1231 | <input type='hidden' name='CLASS' value='$tosruleline[0]' /> |
1232 | <input type='hidden' name='DEV' value='$tosruleline[1]' /> | |
1233 | <input type='hidden' name='TOS' value='$tosruleline[2]' /> | |
65e8619a | 1234 | <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' /> |
f8aa0679 | 1235 | <input type='image' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' src='/images/delete.gif' /> |
f013ab2b MT |
1236 | </form> |
1237 | </table> | |
e8babc92 MT |
1238 | END |
1239 | ; | |
f013ab2b MT |
1240 | } |
1241 | } | |
1242 | } | |
e8babc92 MT |
1243 | END |
1244 | ; | |
f013ab2b MT |
1245 | print <<END |
1246 | </table> | |
e8babc92 MT |
1247 | END |
1248 | ; | |
18322edf | 1249 | &Header::closebox(); |
e8babc92 | 1250 | } |
18322edf CS |
1251 | } |
1252 | } | |
e8babc92 | 1253 | } |
414e011d MT |
1254 | sub validminbwdth { |
1255 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1256 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1257 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
1258 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1259 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
1260 | } | |
363fb6af | 1261 | unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) { |
414e011d | 1262 | $qossettings{'VALID'} = 'no'; |
0b1641db | 1263 | $message = "$Lang::tr{'false min bandwith'}"; |
414e011d MT |
1264 | } |
1265 | $qossettings{'SPD'} = ''; | |
1266 | } | |
1267 | } | |
84cab473 | 1268 | |
414e011d MT |
1269 | sub validmaxbwdth { |
1270 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1271 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1272 | $qossettings{'SPD'} = $qossettings{'OUT_SPD'}; | |
1273 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1274 | $qossettings{'SPD'} = $qossettings{'INC_SPD'}; | |
1275 | } | |
1276 | unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) { | |
1277 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1278 | $message = "$Lang::tr{'false max bandwith'}"; |
414e011d MT |
1279 | } |
1280 | $qossettings{'SPD'} = ''; | |
1281 | } | |
1282 | } | |
1283 | ||
1284 | sub validclass { | |
1285 | if ( $qossettings{'VALID'} eq 'yes' ) { | |
1286 | if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) { | |
1287 | if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) { | |
1288 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1289 | $message = "$Lang::tr{'false classnumber'}"; |
414e011d MT |
1290 | } |
1291 | } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) { | |
1292 | if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) { | |
1293 | $qossettings{'VALID'} = 'no'; | |
65e8619a | 1294 | $message = "$Lang::tr{'The class number does not match the specified interface.'}"; |
414e011d MT |
1295 | } |
1296 | } | |
1297 | open( FILE, "< $classfile" ) or die "Unable to read $classfile"; | |
1298 | @tmp = <FILE>; | |
1299 | close FILE; | |
1300 | foreach $classentry (sort @tmp) | |
1301 | { | |
1302 | @tmpline = split( /\;/, $classentry ); | |
1303 | if ( $tmpline[1] eq $qossettings{'CLASS'} ) | |
1304 | { | |
1305 | $qossettings{'VALID'} = 'no'; | |
0b1641db | 1306 | $message = "$Lang::tr{'false classnumber'}"; |
414e011d MT |
1307 | last |
1308 | } | |
1309 | } | |
1310 | } | |
1311 | } |