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