+sub portrule {
+ &Header::openbox('100%', 'center', $Lang::tr{'Add Port Rule'});
+ print <<END
+ <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <table width='66%'>
+ <tr><td width='100%' colspan='3'>$Lang::tr{'enter data'}
+ <tr><td width='33%' align='right'>$Lang::tr{'protocol'}:
+ <td width='33%' align='left'><select name='PPROT'>
+END
+;
+ open( FILE, "< /etc/protocols" );
+ @proto = <FILE>;
+ close FILE;
+ foreach $direntry (sort @proto)
+ {
+ @tmpline = split( /\ /, $direntry );
+ next if $tmpline[0] =~ "#";
+ if ( $tmpline[0] eq $qossettings{'PPROT'} ) {
+ print "<option value='$tmpline[0]' selected>$tmpline[0]</option>\n";
+ } else {
+ print "<option value='$tmpline[0]'>$tmpline[0]</option>\n";
+ }
+ }
+ print <<END
+ </select><td width='33%' align='center'>
+ <tr><td width='33%' align='right'>$Lang::tr{'source port'}:
+ <td width='33%' align='left'><input type='text' name='QPORT' maxlength='11' value='$qossettings{'QPORT'}' />
+ <td width='33%' align='center'>
+ <tr><td width='33%' align='right'>$Lang::tr{'destination port'}:
+ <td width='33%' align='left'><input type='text' name='DPORT' maxlength='11' value='$qossettings{'DPORT'}' />
+ <td width='33%' align='center'>
+ <tr><td width='33%' align='right'>$Lang::tr{'source ip'}:
+ <td width='33%' align='left'><input type='text' name='QIP' maxlength='15' value='$qossettings{'QIP'}' />
+ <td width='33%' align='center'>
+ <tr><td width='33%' align='right'>$Lang::tr{'destination ip'}:
+ <td width='33%' align='left'><input type='text' name='DIP' maxlength='15' value='$qossettings{'DIP'}' />
+ <td width='33%' align='center'><input type='hidden' name='CLASS' value='$qossettings{'CLASS'}' /><input type='submit' name='DOPORT' value='$Lang::tr{'save'}' />
+ </table></form>
+END
+;
+ &Header::closebox();
+}
+
+sub tosrule {
+ &Header::openbox('100%', 'center', $Lang::tr{'TOS Rule'});
+ if ($qossettings{'TOS'}) {
+ $checked{$qossettings{'TOS'}} = "checked";
+ }
+ print <<END
+ <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <table width='66%'>
+END
+;
+ if ( $message ne "" ) {
+ print "<tr><td colspan='3' align='center'><font color='red'>$message</font>";
+ }
+ print <<END
+ <tr><td colspan='2' width='100%'>$Lang::tr{'current class'}: $qossettings{'CLASS'}
+ <tr><td width='100%' colspan='2'>$Lang::tr{'Enter TOS'}
+ <tr><td width='50%' align='left'>$Lang::tr{'min delay'} (8) <td width='50%'><input type="radio" name="TOS" value="8" $checked[8] />
+ <tr><td width='50%' align='left'>$Lang::tr{'max throughput'} (4) <td width='50%'><input type="radio" name="TOS" value="4" $checked[4] />
+ <tr><td width='50%' align='left'>$Lang::tr{'max reliability'} (2) <td width='50%'><input type="radio" name="TOS" value="2" $checked[2] />
+ <tr><td width='50%' align='left'>$Lang::tr{'min costs'} (1) <td width='50%'><input type="radio" name="TOS" value="1" $checked[1] />
+ <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'}' />
+ </table></form>
+END
+;
+ &Header::closebox();
+}
+
+sub showclasses {
+ $qossettings{'DEV'} = shift;
+ open( FILE, "< $classfile" ) or die "Unable to read $classfile";
+ @classes = <FILE>;
+ close FILE;
+ if (@classes) {
+ open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
+ @subclasses = <FILE>;
+ close FILE;
+ open( FILE, "< $level7file" ) or die "Unable to read $level7file";
+ @l7rules = <FILE>;
+ close FILE;
+ open( FILE, "< $tosfile" ) or die "Unable to read $tosfile";
+ @tosrules = <FILE>;
+ close FILE;
+ open( FILE, "< $portfile" ) or die "Unable to read $portfile";
+ @portrules = <FILE>;
+ close FILE;
+ foreach $classentry (sort @classes)
+ {
+ @classline = split( /\;/, $classentry );
+ if ( $classline[0] eq $qossettings{'DEV'} )
+ {
+ &Header::openbox('100%', 'center', "$Lang::tr{'Class'}: $classline[1]");
+ print <<END
+ <table border='0' width='100%' cellspacing='0'>
+ <tr><td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'interface'}</b>
+ <td bgcolor='$color{'color20'}' width='10%' align='center'><b>$Lang::tr{'Class'}</b>
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'priority'}
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'guaranteed bandwith'}
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>$Lang::tr{'max bandwith'}
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>Burst
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>Ceil Burst
+ <td bgcolor='$color{'color20'}' width='10%' align='center'>TOS
+ <td bgcolor='$color{'color20'}' width='20%' align='center'>$Lang::tr{'action'}
+ <tr><td align='center' bgcolor='$color{'color22'}'>$classline[0]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[1]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[2]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[3]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[4]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[5]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[6]</td>
+ <td align='center' bgcolor='$color{'color22'}'>$classline[7]</td>
+ <td align='right' bgcolor='$color{'color22'}'>
+ <table border='0'><tr>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$classline[1]' />
+ <input type='hidden' name='ACTION' value='$Lang::tr{'qos add subclass'}' />
+ <input type='image' alt='$Lang::tr{'add subclass'}' src='/images/addblue.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$classline[1]' />
+ <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
+ <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$classline[1]' />
+ <input type='hidden' name='DOCLASS' value='$Lang::tr{'edit'}' />
+ <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$classline[1]' />
+ <input type='hidden' name='DOCLASS' value='$Lang::tr{'delete'}' />
+ <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
+ </form>
+ </table>
+ </td>
+ <tr><td align='right' colspan='2'><b>$Lang::tr{'remark'}:</b>
+ <td align='center' colspan='6'> $classline[8]
+ <td align='right'><b>Queueing:</b> $classline[9]
+END
+;
+
+ if (@l7rules) {
+ foreach $l7ruleentry (sort @l7rules)
+ {
+ @l7ruleline = split( /\;/, $l7ruleentry );
+ if ( $l7ruleline[0] eq $classline[1] )
+ {
+ print <<END
+ <tr><td align='right' colspan='2'><b>$Lang::tr{'Level7 Protocol'}:</b>
+ <td align='center' colspan='6'>$l7ruleline[2]
+ <td align='right' >
+ <table border='0'><tr>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
+ <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
+ <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'edit'}' />
+ <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$l7ruleline[0]' />
+ <input type='hidden' name='L7PROT' value='$l7ruleline[2]' />
+ <input type='hidden' name='DOLEVEL7' value='$Lang::tr{'delete'}' />
+ <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
+ </form>
+ </table>
+END
+;
+ if (($l7ruleline[3] ne "") || ($l7ruleline[4] ne "")){
+ print <<END
+ <tr><td align='center'>
+ <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $l7ruleline[3]
+ <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $l7ruleline[4]
+END
+;
+ }
+
+
+END
+;
+ }
+ }
+ }
+
+
+ if (@portrules) {
+ foreach $portruleentry (sort @portrules)
+ {
+ @portruleline = split( /\;/, $portruleentry );
+ if ( $portruleline[0] eq $classline[1] )
+ {
+ print <<END
+ <tr><td align='right' colspan='2'><b>$Lang::tr{'Port Rule'}:</b>
+ <td align='center'>($portruleline[2])
+ <td align='center' colspan='2'>
+END
+;
+ if ($portruleline[4]) {
+ print <<END
+ <i>$Lang::tr{'source port'}:</i> $portruleline[4]
+END
+;
+ }
+ print "<td align='center' colspan='2'>";
+ if ($portruleline[6]) {
+ print <<END
+ <i>$Lang::tr{'destination port'}:</i> $portruleline[6]
+END
+;
+ }
+ print <<END
+ <td>
+ <td align='right'>
+ <table border='0'><tr>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$portruleline[0]' />
+ <input type='hidden' name='PPROT' value='$portruleline[2]' />
+ <input type='hidden' name='QIP' value='$portruleline[3]' />
+ <input type='hidden' name='QPORT' value='$portruleline[4]' />
+ <input type='hidden' name='DIP' value='$portruleline[5]' />
+ <input type='hidden' name='DPORT' value='$portruleline[6]' />
+ <input type='hidden' name='DOPORT' value='$Lang::tr{'edit'}' />
+ <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$portruleline[0]' />
+ <input type='hidden' name='PPROT' value='$portruleline[2]' />
+ <input type='hidden' name='QIP' value='$portruleline[3]' />
+ <input type='hidden' name='QPORT' value='$portruleline[4]' />
+ <input type='hidden' name='DIP' value='$portruleline[5]' />
+ <input type='hidden' name='DPORT' value='$portruleline[6]' />
+ <input type='hidden' name='DOPORT' value='$Lang::tr{'delete'}' />
+ <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
+ </form>
+ </table>
+END
+;
+ if (($portruleline[3] ne "") || ($portruleline[5] ne "")){
+ print <<END
+ <tr><td align='center'>
+ <td align='right' colspan='3'><b>$Lang::tr{'source ip'}:</b> $portruleline[3]
+ <td align='right' colspan='3'><b>$Lang::tr{'destination ip'}:</b> $portruleline[5]
+END
+;
+ }
+ }
+ }
+ }
+
+ if (@tosrules) {
+ foreach $tosruleentry (sort @tosrules)
+ {
+ @tosruleline = split( /\;/, $tosruleentry );
+ if ( $tosruleline[0] eq $classline[1] )
+ {
+ print <<END
+ <tr><td align='right' colspan='2'>
+ <b>TOS Bit matches:</b>
+ <td colspan='6' align='center'>
+END
+;
+ if ( $tosruleline[2] eq "8") {
+ print "$Lang::tr{'min delay'}\n";
+ } elsif ( $tosruleline[2] eq "4") {
+ print "$Lang::tr{'max throughput'}\n";
+ } elsif ( $tosruleline[2] eq "2") {
+ print "$Lang::tr{'max reliability'}\n";
+ } elsif ( $tosruleline[2] eq "1") {
+ print "$Lang::tr{'min costs'}\n";
+ } else { print " \n"; }
+
+ print <<END
+ ($tosruleline[2])
+ <td align='right'>
+ <table border='0'><tr>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$tosruleline[0]' />
+ <input type='hidden' name='DEV' value='$tosruleline[1]' />
+ <input type='hidden' name='TOS' value='$tosruleline[2]' />
+ <input type='hidden' name='DOTOS' value='$Lang::tr{'edit'}' />
+ <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$tosruleline[0]' />
+ <input type='hidden' name='DEV' value='$tosruleline[1]' />
+ <input type='hidden' name='TOS' value='$tosruleline[2]' />
+ <input type='hidden' name='DOTOS' value='$Lang::tr{'delete'}' />
+ <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
+ </form>
+ </table>
+END
+;
+ }
+ }
+ }
+END
+;
+ foreach $subclassentry (sort @subclasses)
+ {
+ @subclassline = split( /\;/, $subclassentry );
+ if ( $subclassline[1] eq $classline[1] ) {
+ print <<END
+ <tr><td align='center' bgcolor='#FAFAFA'>$Lang::tr{'Subclass'}:
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[2]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[3]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[4]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[5]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
+ <td align='center' bgcolor='#FAFAFA'>$subclassline[8]
+ <td align='right' bgcolor='#FAFAFA'>
+ <table border='0'><tr>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$subclassline[2]' />
+ <input type='hidden' name='ACTION' value='$Lang::tr{'Add Rule'}' />
+ <input type='image' alt='$Lang::tr{'Add Rule'}' src='/images/addgreen.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$subclassline[2]' />
+ <input type='hidden' name='DOSCLASS' value='$Lang::tr{'edit'}' />
+ <input type='image' alt='$Lang::tr{'edit'}' src='/images/edit.gif' />
+ </form>
+ <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <input type='hidden' name='CLASS' value='$subclassline[2]' />
+ <input type='hidden' name='DOSCLASS' value='$Lang::tr{'delete'}' />
+ <input type='image' alt='$Lang::tr{'delete'}' src='/images/delete.gif' />
+ </form>
+ </table>
+END
+;
+ }
+ }
+ print <<END
+ </table>
+END
+;
+ &Header::closebox();
+ }
+ }
+ }
+ }
+
+sub expert
+{
+ &Header::openbox('100%', 'center', $Lang::tr{'expertoptions'});
+ print <<END
+ <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+ <table width='66%'>
+ <tr><td width='33%' align='right'>MTU:<td width='33%' align='left'>
+ <input type='text' name='MTU' maxlength='8' required='4' value='$qossettings{'MTU'}' />
+ <td width='33%' align='center'>$Lang::tr{'mtu QoS'}
+ <tr><td width='33%' align='right'>$Lang::tr{'Queuelenght'}:<td width='33%' align='left'>
+ <input type='text' name='QLENGTH' maxlength='8' required='2' value='$qossettings{'QLENGTH'}' />
+ <td width='33%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' />
+ </table>
+ </form>
+END
+;
+ &Header::closebox();
+}
+
+sub validminbwdth {
+ if ( $qossettings{'VALID'} eq 'yes' ) {
+ if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
+ $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
+ } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
+ $qossettings{'SPD'} = $qossettings{'INC_SPD'};
+ }
+ unless ( ( $qossettings{'MINBWDTH'} >= 1 ) && ( $qossettings{'MINBWDTH'} <= $qossettings{'SPD'} ) ) {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'false min bandwith'}";
+ }
+ $qossettings{'SPD'} = '';
+ }
+}
+
+sub validmaxbwdth {
+ if ( $qossettings{'VALID'} eq 'yes' ) {
+ if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
+ $qossettings{'SPD'} = $qossettings{'OUT_SPD'};
+ } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
+ $qossettings{'SPD'} = $qossettings{'INC_SPD'};
+ }
+ unless ( ( $qossettings{'MAXBDWTH'} >= 0 ) && ($qossettings{'MAXBDWTH'} >= $qossettings{'MINBDWTH'}) &&( $qossettings{'MAXBDWTH'} <= $qossettings{'SPD'} ) ) {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'false max bandwith'}";
+ }
+ $qossettings{'SPD'} = '';
+ }
+}
+
+sub validclass {
+ if ( $qossettings{'VALID'} eq 'yes' ) {
+ if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
+ if ($qossettings{'CLASS'} lt 100 || $qossettings{'CLASS'} ge 121) {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'false classnumber'}";
+ }
+ } elsif ( $qossettings{'DEVICE'} eq $qossettings{'IMQ_DEV'} ) {
+ if ($qossettings{'CLASS'} lt 200 || $qossettings{'CLASS'} ge 221) {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'The class number does not match the specified interface.'}";
+ }
+ }
+ open( FILE, "< $classfile" ) or die "Unable to read $classfile";
+ @tmp = <FILE>;
+ close FILE;
+ foreach $classentry (sort @tmp)
+ {
+ @tmpline = split( /\;/, $classentry );
+ if ( $tmpline[1] eq $qossettings{'CLASS'} )
+ {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'false classnumber'}";
+ last
+ }
+ }
+ }
+}
+
+sub validsubclass {
+ if ( $qossettings{'VALID'} eq 'yes' ) {
+ open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
+ @tmp = <FILE>;
+ close FILE;
+ foreach $subclassentry (sort @tmp)
+ {
+ @tmpline = split( /\;/, $subclassentry );
+ if ( $tmpline[2] eq $qossettings{'SCLASS'} )
+ {
+ $qossettings{'VALID'} = 'no';
+ $message = "$Lang::tr{'class in use'}";
+ last
+ }
+ }
+ }
+}