Hinzugefügt:
authorms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 5 Jul 2006 21:22:59 +0000 (21:22 +0000)
committerms <ms@ea5c0bd1-69bd-2848-81d8-4f18e57aeed8>
Wed, 5 Jul 2006 21:22:59 +0000 (21:22 +0000)
  * Fehlende Grafik.
  * QoS-Script, das aus den Einstellungen ein Bashscript generiert.
Geändert:
  * QoS-CGI-Update.

git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@197 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8

config/qos/makeqosscripts.pl [new file with mode: 0644]
html/cgi-bin/qos.cgi
html/html/images/addgreen.gif [new file with mode: 0644]
lfs/configroot

diff --git a/config/qos/makeqosscripts.pl b/config/qos/makeqosscripts.pl
new file mode 100644 (file)
index 0000000..e754652
--- /dev/null
@@ -0,0 +1,547 @@
+#!/usr/bin/perl
+#
+# IPFire Scripts
+#
+# This code is distributed under the terms of the GPL
+#
+# (c) The IPFire Team
+#
+
+use strict;
+# enable only the following on debugging purpose
+use warnings;
+
+require '/var/ipfire/general-functions.pl';
+require "${General::swroot}/lang.pl";
+require "${General::swroot}/header.pl";
+
+my %qossettings = ();
+my %checked = ();
+my %netsettings = ();
+my $message = "";
+my $errormessage = "";
+my $c = "";
+my $direntry = "";
+my $classentry = "";
+my $subclassentry = "";
+my $l7ruleentry = "";
+my $portruleentry = "";
+my @tmp = ();
+my @classes = ();
+my @subclasses = ();
+my @l7rules = ();
+my @portrules = ();
+my @tmpline = ();
+my @classline = ();
+my @subclassline = ();
+my @l7ruleline = ();
+my @portruleline = ();
+my @proto = ();
+my %selected= () ;
+my $classfile = "/var/ipfire/qos/classes";
+my $subclassfile = "/var/ipfire/qos/subclasses";
+my $level7file = "/var/ipfire/qos/level7config";
+my $portfile = "/var/ipfire/qos/portconfig";
+
+&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
+
+$qossettings{'ENABLED'} = 'off';
+$qossettings{'EDIT'} = 'no';
+$qossettings{'OUT_SPD'} = '';
+$qossettings{'INC_SPD'} = '';
+$qossettings{'DEF_OUT_SPD'} = '';
+$qossettings{'DEF_INC_SPD'} = '';
+$qossettings{'DEFCLASS_INC'} = '';
+$qossettings{'DEFCLASS_OUT'} = '';
+$qossettings{'ACK'} = '';
+$qossettings{'MTU'} = '1492';
+$qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
+$qossettings{'IMQ_DEV'} = 'imq0';
+$qossettings{'VALID'} = 'yes';
+
+&General::readhash("${General::swroot}/qos/settings", \%qossettings);
+
+open( FILE, "< $classfile" ) or die "Unable to read $classfile";
+@classes = <FILE>;
+close FILE;
+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, "< $portfile" ) or die "Unable to read $portfile";
+@portrules = <FILE>;
+close FILE;
+
+############################################################################################################################
+############################################################################################################################
+
+print <<END
+#/bin/bash
+#################################################
+# This is an autocreated QoS-Script for         #
+# IPFIRE                                        #
+# Copyright by the IPFire Team (GPLv2)          #
+# www.ipfire.org                                #
+#################################################
+
+### SYSTEMVARIABLES:
+# RED INTERFACE:       $qossettings{'RED_DEV'}
+# IMQ DEVICE:          $qossettings{'IMQ_DEV'}
+
+case "\$1" in
+
+  status)
+       echo "[qdisc]"
+       tc -s qdisc show dev $qossettings{'RED_DEV'}
+       tc -s qdisc show dev $qossettings{'IMQ_DEV'}
+       echo "[class]"
+       tc -s class show dev $qossettings{'RED_DEV'}
+       tc -s class show dev $qossettings{'IMQ_DEV'}
+       echo "[filter]"
+       tc -s filter show dev $qossettings{'RED_DEV'}
+       tc -s filter show dev $qossettings{'IMQ_DEV'}
+       echo "[iptables]"
+       iptables -t mangle -L QOS-OUT -v -x 2> /dev/null
+       iptables -t mangle -L QOS-INC -v -x 2> /dev/null
+       exit 0
+  ;;
+  start)
+       ### FIRST CLEAR EVERYTHING
+       \$0 clear
+
+       ###
+       ### $qossettings{'RED_DEV'}
+       ###
+
+       ### INIT KERNEL
+       modprobe sch_htb
+
+       ### SET QUEUE LENGTH & MTU - has just to be tested!!! IMPORTANT
+       ip link set dev $qossettings{'RED_DEV'} qlen $qossettings{'QLENGTH'}
+       ip link set dev $qossettings{'RED_DEV'} mtu $qossettings{'MTU'}
+
+       ### ADD HTB QDISC FOR $qossettings{'RED_DEV'}
+       tc qdisc add dev $qossettings{'RED_DEV'} root handle 1: htb default $qossettings{'DEFCLASS_OUT'}
+
+       ### MAIN RATE LIMIT
+       tc class add dev $qossettings{'RED_DEV'} parent 1: classid 1:1 htb rate $qossettings{'OUT_SPD'}kbit
+
+       ### CLASSES FOR $qossettings{'RED_DEV'}
+END
+;
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'RED_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               $qossettings{'PRIO'} = $classline[2];
+               $qossettings{'RATE'} = $classline[3];
+               $qossettings{'CEIL'} = $classline[4];
+               $qossettings{'BURST'} = $classline[5];
+               $qossettings{'CBURST'} = $classline[6];
+               print "\ttc class add dev $qossettings{'DEVICE'} parent 1:1 classid 1:$qossettings{'CLASS'} htb rate $qossettings{'RATE'}kbit ceil $qossettings{'CEIL'}kbit prio $qossettings{'PRIO'} ";
+               if ($qossettings{'BURST'} > 0) {
+                       print "burst $qossettings{'BURST'}k ";
+               }
+               if (($qossettings{'CBURST'} ne '') || ($qossettings{'CBURST'} ne 0)) {
+                       print "cburst $qossettings{'CBURST'}k";
+               }
+               print "\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       $qossettings{'DEVICE'} = $subclassline[0];
+       $qossettings{'CLASS'} = $subclassline[1];
+       $qossettings{'SCLASS'} = $subclassline[2];
+       $qossettings{'SPRIO'} = $subclassline[3];
+       $qossettings{'SRATE'} = $subclassline[4];
+       $qossettings{'SCEIL'} = $subclassline[5];
+       $qossettings{'SBURST'} = $subclassline[6];
+       $qossettings{'SCBURST'} = $subclassline[7];
+       print "\ttc class add dev $qossettings{'DEVICE'} parent 1:$qossettings{'CLASS'} classid 1:$qossettings{'SCLASS'} htb rate $qossettings{'SRATE'}kbit ceil $qossettings{'SCEIL'}kbit prio $qossettings{'SPRIO'} ";
+       if ($qossettings{'SBURST'} > 0) {
+               print "burst $qossettings{'SBURST'}k ";
+       }
+       if (($qossettings{'SCBURST'} ne '') || ($qossettings{'SCBURST'} ne 0)) {
+               print "cburst $qossettings{'CBURST'}k";
+       }
+       print "\n";
+}
+
+print "\n\t### ATTACH QDISC TO LEAF CLASSES\n";
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'RED_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               print "\ttc qdisc add dev $qossettings{'DEVICE'} parent 1:$qossettings{'CLASS'} handle $qossettings{'CLASS'}: sfq perturb $qossettings{'SFQ_PERTUB'}\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       if ($qossettings{'RED_DEV'} eq $subclassline[0]) {
+               $qossettings{'DEVICE'} = $subclassline[0];
+               $qossettings{'SCLASS'} = $subclassline[2];
+               print "\ttc qdisc add dev $qossettings{'DEVICE'} parent 1:$qossettings{'SCLASS'} handle $qossettings{'SCLASS'}: sfq perturb $qossettings{'SFQ_PERTUB'}\n";
+       }
+}
+print "\n\t### FILTER TRAFFIC INTO CLASSES\n";
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'RED_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               print "\ttc filter add dev $qossettings{'DEVICE'} parent 1:0 prio 0 protocol ip handle $qossettings{'CLASS'} fw flowid 1:$qossettings{'CLASS'}\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       if ($qossettings{'RED_DEV'} eq $subclassline[0]) {
+               $qossettings{'DEVICE'} = $subclassline[0];
+               $qossettings{'CLASS'} = $subclassline[1];
+               $qossettings{'SCLASS'} = $subclassline[2];
+               print "\ttc filter add dev $qossettings{'DEVICE'} parent 1:$qossettings{'CLASS'} prio 0 protocol ip handle $qossettings{'SCLASS'} fw flowid 1:$qossettings{'SCLASS'}\n";
+       }
+}
+print <<END
+
+       ### ADD QOS-OUT CHAIN TO THE MANGLE TABLE IN IPTABLES
+       iptables -t mangle -N QOS-OUT
+       iptables -t mangle -I POSTROUTING -o $qossettings{'RED_DEV'} -j QOS-OUT
+
+       ### MARK ACKs
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags SYN,RST SYN -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags SYN,RST SYN -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags SYN,RST SYN -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p icmp -m length --length 40:100 -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p icmp -m length --length 40:100 -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --syn -m length --length 40:68 -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --syn -m length --length 40:68 -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --syn -m length --length 40:68 -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL SYN,ACK -m length --length 40:68 -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL SYN,ACK -m length --length 40:68 -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL SYN,ACK -m length --length 40:68 -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK -m length --length 40:100 -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK -m length --length 40:100 -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK -m length --length 40:100 -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL RST -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL RST -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL RST -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,RST -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,RST -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,RST -j RETURN
+
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,FIN -j TOS --set-tos 4
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,FIN -j MARK --set-mark $qossettings{'ACK'}
+       iptables -t mangle -A QOS-OUT -o $qossettings{'RED_DEV'} -p tcp --tcp-flags ALL ACK,FIN -j RETURN
+
+       ### SET LEVEL7-RULES
+END
+;
+       foreach $l7ruleentry (sort @l7rules)
+       {
+               @l7ruleline = split( /\;/, $l7ruleentry );
+               if ( $l7ruleline[1] eq $qossettings{'RED_DEV'} )
+               {
+                       $qossettings{'CLASS'} = $l7ruleline[0];
+                       $qossettings{'DEVICE'} = $l7ruleline[1];
+                       $qossettings{'L7PROT'} = $l7ruleline[2];
+                       $qossettings{'QIP'} = $l7ruleline[3];
+                       $qossettings{'DIP'} = $l7ruleline[4];
+                       print "\tiptables -t mangle -A QOS-OUT -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j MARK --set-mark $qossettings{'CLASS'}\n";
+               }
+       }
+
+print "\n\t### SET PORT-RULES\n";
+       foreach $portruleentry (sort @portrules)
+       {
+               @portruleline = split( /\;/, $portruleentry );
+               if ( $portruleline[1] eq $qossettings{'RED_DEV'} )
+               {
+                       $qossettings{'CLASS'} = $portruleline[0];
+                       $qossettings{'DEVICE'} = $portruleline[1];
+                       $qossettings{'PPROT'} = $portruleline[2];
+                       $qossettings{'QIP'} = $portruleline[3];
+                       $qossettings{'QPORT'} = $portruleline[4];
+                       $qossettings{'DIP'} = $portruleline[5];
+                       $qossettings{'DPORT'} = $portruleline[6];
+                       print "\tiptables -t mangle -A QOS-OUT -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-p $qossettings{'PPROT'} ";
+                       if (($qossettings{'QPORT'} ne '') || ($qossettings{'DPORT'} ne '')){
+                               print "-m multiport ";
+                       }
+                       if ($qossettings{'QPORT'} ne ''){
+                               print "--sport $qossettings{'QPORT'} ";
+                       }
+                       if ($qossettings{'DPORT'} ne ''){
+                               print "--dport $qossettings{'DPORT'} ";
+                       }
+                       print "-j MARK --set-mark $qossettings{'CLASS'}\n";
+                       print "\tiptables -t mangle -A QOS-OUT -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-p $qossettings{'PPROT'} ";
+                       if (($qossettings{'QPORT'} ne '') || ($qossettings{'DPORT'} ne '')){
+                               print "-m multiport ";
+                       }
+                       if ($qossettings{'QPORT'} ne ''){
+                               print "--sport $qossettings{'QPORT'} ";
+                       }
+                       if ($qossettings{'DPORT'} ne ''){
+                               print "--dport $qossettings{'DPORT'} ";
+                       }
+                       print "-j RETURN\n\n";
+               }
+       }
+
+print <<END
+
+       ### REDUNDANT: SET ALL NONMARKED PACKETS TO DEFAULT CLASS
+       iptables -t mangle -A QOS-OUT -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_OUT'}
+
+       ###
+       ### $qossettings{'IMQ_DEV'}
+       ###
+
+       ### BRING UP $qossettings{'IMQ_DEV'}
+       modprobe imq numdevs=1
+       ip link set $qossettings{'IMQ_DEV'} up
+
+       ### SET QUEUE LENGTH & MTU - has just to be tested!!! IMPORTANT
+       ip link set dev $qossettings{'IMQ_DEV'} qlen $qossettings{'QLENGTH'}
+       ip link set dev $qossettings{'IMQ_DEV'} mtu $qossettings{'MTU'}
+
+       ### ADD HTB QDISC FOR $qossettings{'IMQ_DEV'}
+       tc qdisc add dev $qossettings{'IMQ_DEV'} root handle 2: htb default $qossettings{'DEFCLASS_INC'}
+
+       ### MAIN RATE LIMIT
+       tc class add dev $qossettings{'IMQ_DEV'} parent 2: classid 2:1 htb rate $qossettings{'INC_SPD'}kbit
+
+       ### CLASSES FOR $qossettings{'IMQ_DEV'}
+END
+;
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'IMQ_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               $qossettings{'PRIO'} = $classline[2];
+               $qossettings{'RATE'} = $classline[3];
+               $qossettings{'CEIL'} = $classline[4];
+               $qossettings{'BURST'} = $classline[5];
+               $qossettings{'CBURST'} = $classline[6];
+               print "\ttc class add dev $qossettings{'DEVICE'} parent 2:1 classid 2:$qossettings{'CLASS'} htb rate $qossettings{'RATE'}kbit ceil $qossettings{'CEIL'}kbit prio $qossettings{'PRIO'} ";
+               if ($qossettings{'BURST'} > 0) {
+                       print "burst $qossettings{'BURST'}k ";
+               }
+               if (($qossettings{'CBURST'} ne '') || ($qossettings{'CBURST'} ne 0)) {
+                       print "cburst $qossettings{'CBURST'}k";
+               }
+               print "\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       if ($qossettings{'IMQ_DEV'} eq $subclassline[0]) {
+               $qossettings{'DEVICE'} = $subclassline[0];
+               $qossettings{'CLASS'} = $subclassline[1];
+               $qossettings{'SCLASS'} = $subclassline[2];
+               $qossettings{'SPRIO'} = $subclassline[3];
+               $qossettings{'SRATE'} = $subclassline[4];
+               $qossettings{'SCEIL'} = $subclassline[5];
+               $qossettings{'SBURST'} = $subclassline[6];
+               $qossettings{'SCBURST'} = $subclassline[7];
+               print "\ttc class add dev $qossettings{'DEVICE'} parent 2:$qossettings{'CLASS'} classid 2:$qossettings{'SCLASS'} htb rate $qossettings{'SRATE'}kbit ceil $qossettings{'SCEIL'}kbit prio $qossettings{'SPRIO'} ";
+               if ($qossettings{'SBURST'} > 0) {
+                       print "burst $qossettings{'SBURST'}k ";
+               }
+               if (($qossettings{'SCBURST'} ne '') || ($qossettings{'SCBURST'} ne 0)) {
+                       print "cburst $qossettings{'CBURST'}k";
+               }
+               print "\n";
+       }
+}
+
+print "\n\t### ATTACH QDISC TO LEAF CLASSES\n";
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'IMQ_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               print "\ttc qdisc add dev $qossettings{'DEVICE'} parent 2:$qossettings{'CLASS'} handle $qossettings{'CLASS'}: sfq perturb $qossettings{'SFQ_PERTUB'}\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       if ($qossettings{'IMQ_DEV'} eq $subclassline[0]) {
+               $qossettings{'DEVICE'} = $subclassline[0];
+               $qossettings{'SCLASS'} = $subclassline[2];
+               print "\ttc qdisc add dev $qossettings{'DEVICE'} parent 2:$qossettings{'SCLASS'} handle $qossettings{'SCLASS'}: sfq perturb $qossettings{'SFQ_PERTUB'}\n";
+       }
+}
+print "\n\t### FILTER TRAFFIC INTO CLASSES\n";
+foreach $classentry (sort @classes)
+{
+       @classline = split( /\;/, $classentry );
+       if ($qossettings{'IMQ_DEV'} eq $classline[0]) {
+               $qossettings{'DEVICE'} = $classline[0];
+               $qossettings{'CLASS'} = $classline[1];
+               print "\ttc filter add dev $qossettings{'DEVICE'} parent 2:0 prio 0 protocol ip handle $qossettings{'CLASS'} fw flowid 2:$qossettings{'CLASS'}\n";
+       }
+}
+foreach $subclassentry (sort @subclasses) {
+       @subclassline = split( /\;/, $subclassentry );
+       if ($qossettings{'IMQ_DEV'} eq $subclassline[0]) {
+               $qossettings{'DEVICE'} = $subclassline[0];
+               $qossettings{'CLASS'} = $subclassline[1];
+               $qossettings{'SCLASS'} = $subclassline[2];
+               print "\ttc filter add dev $qossettings{'DEVICE'} parent 2:$qossettings{'CLASS'} prio 0 protocol ip handle $qossettings{'SCLASS'} fw flowid 2:$qossettings{'SCLASS'}\n";
+       }
+}
+print <<END
+
+       ### ADD QOS-OUT CHAIN TO THE MANGLE TABLE IN IPTABLES
+       iptables -t mangle -N QOS-INC
+       iptables -t mangle -I POSTROUTING -o $qossettings{'IMQ_DEV'} -j QOS-INC
+
+       ### SET LEVEL7-RULES
+END
+;
+       foreach $l7ruleentry (sort @l7rules)
+       {
+               @l7ruleline = split( /\;/, $l7ruleentry );
+               if ( $l7ruleline[1] eq $qossettings{'IMQ_DEV'} )
+               {
+                       $qossettings{'CLASS'} = $l7ruleline[0];
+                       $qossettings{'DEVICE'} = $l7ruleline[1];
+                       $qossettings{'L7PROT'} = $l7ruleline[2];
+                       $qossettings{'QIP'} = $l7ruleline[3];
+                       $qossettings{'DIP'} = $l7ruleline[4];
+                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-m layer7 --l7dir /etc/l7-protocols/protocols --l7proto $qossettings{'L7PROT'} -j MARK --set-mark $qossettings{'CLASS'}\n";
+               }
+       }
+
+print "\n\t### SET PORT-RULES\n";
+       foreach $portruleentry (sort @portrules)
+       {
+               @portruleline = split( /\;/, $portruleentry );
+               if ( $portruleline[1] eq $qossettings{'IMQ_DEV'} )
+               {
+                       $qossettings{'CLASS'} = $portruleline[0];
+                       $qossettings{'DEVICE'} = $portruleline[1];
+                       $qossettings{'PPROT'} = $portruleline[2];
+                       $qossettings{'QIP'} = $portruleline[3];
+                       $qossettings{'QPORT'} = $portruleline[4];
+                       $qossettings{'DIP'} = $portruleline[5];
+                       $qossettings{'DPORT'} = $portruleline[6];
+                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-p $qossettings{'PPROT'} ";
+                       if (($qossettings{'QPORT'} ne '') || ($qossettings{'DPORT'} ne '')){
+                               print "-m multiport ";
+                       }
+                       if ($qossettings{'QPORT'} ne ''){
+                               print "--sport $qossettings{'QPORT'} ";
+                       }
+                       if ($qossettings{'DPORT'} ne ''){
+                               print "--dport $qossettings{'DPORT'} ";
+                       }
+                       print "-j MARK --set-mark $qossettings{'CLASS'}\n";
+                       print "\tiptables -t mangle -A QOS-INC -o $qossettings{'DEVICE'} ";
+                       if ($qossettings{'QIP'} ne ''){
+                               print "-s $qossettings{'QIP'} ";
+                       }
+                       if ($qossettings{'DIP'} ne ''){
+                               print "-d $qossettings{'DIP'} ";
+                       }
+                       print "-p $qossettings{'PPROT'} ";
+                       if (($qossettings{'QPORT'} ne '') || ($qossettings{'DPORT'} ne '')){
+                               print "-m multiport ";
+                       }
+                       if ($qossettings{'QPORT'} ne ''){
+                               print "--sport $qossettings{'QPORT'} ";
+                       }
+                       if ($qossettings{'DPORT'} ne ''){
+                               print "--dport $qossettings{'DPORT'} ";
+                       }
+                       print "-j RETURN\n\n";
+               }
+       }
+
+print <<END
+
+       ### REDUNDANT: SET ALL NONMARKED PACKETS TO DEFAULT CLASS
+       iptables -t mangle -A QOS-INC -m mark --mark 0 -j MARK --set-mark $qossettings{'DEFCLASS_INC'}
+
+       echo "Quality of Service was successfully started!"
+       exit 0
+  ;;
+  clear)
+       ### RESET EVERYTHING TO A KNOWN STATE
+       # DELETE QDISCS
+       tc qdisc del dev $qossettings{'RED_DEV'} root &> /dev/null
+       tc qdisc del dev $qossettings{'IMQ_DEV'} root &> /dev/null
+       # REMOVE & FLUSH CHAINS
+       iptables -t mangle -D POSTROURING -o $qossettings{'RED_DEV'} -j QOS-OUT &> /dev/null
+       iptables -t mangle -F QOS-OUT &> /dev/null
+       iptables -t mangle -X QOS-OUT &> /dev/null
+       iptables -t mangle -D POSTROURING -o $qossettings{'IMQ_DEV'} -j QOS-INC &> /dev/null
+       iptables -t mangle -F QOS-INC &> /dev/null
+       iptables -t mangle -X QOS-INC &> /dev/null
+       # STOP IMQ-DEVICE
+       ip link set $qossettings{'IMQ_DEV'} down &> /dev/null
+       rmmod imq &> /dev/null
+       rmmod sch_htb &> /dev/null
+       echo "Quality of Service was successfully cleared!"
+  ;;
+esac
+### EOF
+END
+;
+
+############################################################################################################################
+############################################################################################################################
+
index 53390ac..06b3973 100644 (file)
@@ -26,19 +26,23 @@ my $direntry = "";
 my $classentry = "";
 my $subclassentry = "";
 my $l7ruleentry = "";
+my $portruleentry = "";
 my @tmp = ();
 my @classes = ();
 my @subclasses = ();
 my @l7rules = ();
+my @portrules = ();
 my @tmpline = ();
 my @classline = ();
 my @subclassline = ();
 my @l7ruleline = ();
+my @portruleline = ();
 my @proto = ();
 my %selected= () ;
 my $classfile = "/var/ipfire/qos/classes";
 my $subclassfile = "/var/ipfire/qos/subclasses";
 my $level7file = "/var/ipfire/qos/level7config";
+my $portfile = "/var/ipfire/qos/portconfig";
 &General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
 
 &Header::showhttpheaders();
@@ -47,17 +51,46 @@ $qossettings{'ENABLED'} = 'off';
 $qossettings{'EDIT'} = 'no';
 $qossettings{'OUT_SPD'} = '';
 $qossettings{'INC_SPD'} = '';
+$qossettings{'DEF_OUT_SPD'} = '';
+$qossettings{'DEF_INC_SPD'} = '';
 $qossettings{'DEFCLASS_INC'} = '';
 $qossettings{'DEFCLASS_OUT'} = '';
 $qossettings{'ACK'} = '';
+$qossettings{'MTU'} = '1492';
+$qossettings{'QLENGTH'} = '30';
 $qossettings{'RED_DEV'} = `cat /var/ipfire/red/iface`;
 $qossettings{'IMQ_DEV'} = 'imq0';
 $qossettings{'VALID'} = 'yes';
+### Values that have to be initialized
+$qossettings{'ACTION'} = '';
+$qossettings{'ACTIONDEF'} = '';
+$qossettings{'ACTIONBW'} = '';
+$qossettings{'PRIO'} = '';
+$qossettings{'SPD'} = '';
+$qossettings{'CLASS'} = '';
+$qossettings{'SCLASS'} = '';
+$qossettings{'QPORT'} = '';
+$qossettings{'DPORT'} = '';
+$qossettings{'QIP'} = '';
+$qossettings{'DIP'} = '';
+$qossettings{'PPROT'} = '';
+$qossettings{'L7PROT'} = '';
+$qossettings{'DEVICE'} = '';
+$qossettings{'MINBWDTH'} = '';
+$qossettings{'MAXBWDTH'} = '';
+$qossettings{'BURST'} = '';
+$qossettings{'CBURST'} = '';
+$qossettings{'DOCLASS'} = '';
+$qossettings{'DOSCLASS'} = '';
+$qossettings{'DOLEVEL7'} = '';
+$qossettings{'DOPORT'} = '';
+
 
 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
 &Header::getcgihash(\%qossettings);
 
 &Header::openpage('QoS', 1, '');
+
 print <<END
 <script type="text/javascript">
 <!--
@@ -90,7 +123,10 @@ END
 
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
-if ($qossettings{'DO_CLASS'} eq $Lang::tr{'save'})
+############################################################################################################################
+############################################################################################################################
+
+if ($qossettings{'DOCLASS'} eq $Lang::tr{'save'})
 {
        &validclass();
        &validminbwdth();
@@ -106,7 +142,7 @@ END
                $qossettings{'ACTION'} = 'Parentklasse hinzufuegen';
        }
 }
-elsif ($qossettings{'DO_CLASS'} eq 'Bearbeiten')
+elsif ($qossettings{'DOCLASS'} eq 'Bearbeiten')
 {
        open( FILE, "< $classfile" ) or die "Unable to read $classfile";
        @classes = <FILE>;
@@ -133,7 +169,7 @@ elsif ($qossettings{'DO_CLASS'} eq 'Bearbeiten')
        &Header::closepage();
        exit
 }
-elsif ($qossettings{'DO_CLASS'} eq 'Loeschen')
+elsif ($qossettings{'DOCLASS'} eq 'Loeschen')
 {
        open( FILE, "< $classfile" ) or die "Unable to read $classfile";
        @tmp = <FILE>;
@@ -148,9 +184,26 @@ elsif ($qossettings{'DO_CLASS'} eq 'Loeschen')
                }
        }
        close FILE;
-       $message = "Klasse $qossettings{'CLASS'} wurde geloescht.";
+       open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
+       @tmp = <FILE>;
+       close FILE;
+       open( FILE, "> $subclassfile" ) or die "Unable to write $classfile";
+       foreach $subclassentry (sort @tmp)
+       {
+               @tmpline = split( /\;/, $subclassentry );
+               if ( $tmpline[1] ne $qossettings{'CLASS'} )
+               {
+                       print FILE $subclassentry;
+               }
+       }
+       close FILE;
+       $message = "Klasse $qossettings{'CLASS'} wurde mit eventuell vorhandenen Unterklassen geloescht.";
 }
-if ($qossettings{'DO_SCLASS'} eq $Lang::tr{'save'})
+
+############################################################################################################################
+############################################################################################################################
+
+if ($qossettings{'DOSCLASS'} eq $Lang::tr{'save'})
 {
        if ($qossettings{'SCLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
                $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
@@ -169,7 +222,7 @@ END
        } else {
                $qossettings{'ACTION'} = 'Unterklasse hinzufuegen';
        }
-} elsif ($qossettings{'DO_SCLASS'} eq 'Loeschen')
+} elsif ($qossettings{'DOSCLASS'} eq 'Loeschen')
 {
        open( FILE, "< $subclassfile" ) or die "Unable to read $classfile";
        @tmp = <FILE>;
@@ -186,7 +239,11 @@ END
        close FILE;
        $message = "Unterklasse $qossettings{'CLASS'} wurde geloescht.";
 }
-if ($qossettings{'DO_LEVEL7'} eq $Lang::tr{'save'})
+
+############################################################################################################################
+############################################################################################################################
+
+if ($qossettings{'DOLEVEL7'} eq $Lang::tr{'save'})
 {
        if ( $qossettings{'QIP'} ne '' ) {
                unless ( &General::validip($qossettings{'QIP'}) ) { 
@@ -220,7 +277,7 @@ END
                $qossettings{'ACTION'} = 'Level7-Regel hinzufuegen';
        }
 } 
-elsif ($qossettings{'DO_LEVEL7'} eq 'Loeschen')
+elsif ($qossettings{'DOLEVEL7'} eq 'Loeschen')
 {
        open( FILE, "< $level7file" ) or die "Unable to read $level7file";
        @l7rules = <FILE>;
@@ -237,20 +294,92 @@ elsif ($qossettings{'DO_LEVEL7'} eq 'Loeschen')
        close FILE;
        $message = "Level7-Regel ($qossettings{'CLASS'} - $qossettings{'L7PROT'}) wurde geloescht.";
 }
+
+############################################################################################################################
+############################################################################################################################
+
+if ($qossettings{'DOPORT'} eq $Lang::tr{'save'})
+{
+       if ( $qossettings{'QIP'} ne '' ) {
+               unless ( &General::validip($qossettings{'QIP'}) ) { 
+                       $qossettings{'VALID'} = 'no';
+                       $message = "Die Quell-IP-Adresse ist ungueltig."; 
+               }
+       }
+       if ( $qossettings{'DIP'} ne '' ) {
+               unless ( &General::validip($qossettings{'DIP'}) ) { 
+                       $qossettings{'VALID'} = 'no';
+                       $message = "Die Ziel-IP-Adresse ist ungueltig."; 
+               }
+       }
+       if ($qossettings{'CLASS'} >= 100 && $qossettings{'CLASS'} < 121) {
+               $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
+       } elsif ($qossettings{'CLASS'} >= 1000 && $qossettings{'CLASS'} < 1021) {
+               $qossettings{'DEVICE'} = $qossettings{'RED_DEV'};
+       } elsif ($qossettings{'CLASS'} >= 200 && $qossettings{'CLASS'} < 221) {
+               $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
+       } elsif ($qossettings{'CLASS'} >= 2000 && $qossettings{'CLASS'} < 2021) {
+               $qossettings{'DEVICE'} = $qossettings{'IMQ_DEV'};
+       }
+       if ( $qossettings{'VALID'} eq 'yes' ) {
+               open( FILE, ">> $portfile" ) or die "Unable to write $portfile";
+               print FILE <<END
+$qossettings{'CLASS'};$qossettings{'DEVICE'};$qossettings{'PPROT'};$qossettings{'QIP'};$qossettings{'QPORT'};$qossettings{'DIP'};$qossettings{'DPORT'};
+END
+;
+               close FILE;
+       } else {
+               $qossettings{'ACTION'} = 'Port-Regel hinzufuegen';
+       }
+} elsif ($qossettings{'DOPORT'} eq 'Loeschen')
+{
+       open( FILE, "< $portfile" ) or die "Unable to read $portfile";
+       @portrules = <FILE>;
+       close FILE;
+       open( FILE, "> $portfile" ) or die "Unable to read $portfile";
+       foreach $portruleentry (sort @portrules)
+       {
+               @portruleline = split( /\;/, $portruleentry );
+               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'}))
+               {
+                       print FILE $portruleentry;
+               }
+       }
+       close FILE;
+       $message = "Port-Regel ($qossettings{'CLASS'} - $qossettings{'PPROT'}) wurde geloescht.";
+}
+
+############################################################################################################################
+############################################################################################################################
+
 if ($qossettings{'ACTION'} eq 'Start')
 {
+       system("sleep 2 && /usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh &");
        system("/bin/touch /var/ipfire/qos/enable");
        $qossettings{'ENABLED'} = 'on';
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
 }
 elsif ($qossettings{'ACTION'} eq 'Stop')
 {
+       unlink "/var/ipfire/qos/bin/qos.sh";
        unlink "/var/ipfire/qos/enable";
        $qossettings{'ENABLED'} = 'off';
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
 }
+elsif ($qossettings{'ACTION'} eq 'Neustart')
+{
+       if ($qossettings{'ENABLED'} eq 'on'){
+               system("sleep 2 && /usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh &");
+       }
+}
 elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
 {
+       if ($qossettings{'DEF_INC_SPD'} eq '') {
+               $qossettings{'DEF_INC_SPD'} = int($qossettings{'INC_SPD'} * 0.9);
+       }
+       if ($qossettings{'DEF_OUT_SPD'} eq '') {
+               $qossettings{'DEF_OUT_SPD'} = int($qossettings{'OUT_SPD'} * 0.9);
+       }
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
 }
 elsif ($qossettings{'ACTION'} eq 'Parentklasse hinzufuegen')
@@ -281,14 +410,21 @@ elsif ($qossettings{'ACTION'} eq 'Port-Regel hinzufuegen')
        &Header::closepage();
        exit
 }
-if ($qossettings{'ACTION_BW'} eq 'Andern')
+elsif ($qossettings{'ACTION'} eq 'Erweiterte Einstellungen')
+{
+       &expert();
+       &Header::closebigbox();
+       &Header::closepage();
+       exit
+}
+if ($qossettings{'ACTIONBW'} eq 'Andern')
 {
        &changebandwidth();
        &Header::closebigbox();
        &Header::closepage();
        exit
 }
-if ($qossettings{'ACTION_DEF'} eq 'Andern')
+if ($qossettings{'ACTIONDEF'} eq 'Andern')
 {
        &changedefclasses();
        &Header::closebigbox();
@@ -299,10 +435,10 @@ if ($qossettings{'ACTION_DEF'} eq 'Andern')
 &General::readhash("${General::swroot}/qos/settings", \%qossettings);
 
 my $status = $Lang::tr{'stopped'};
-my $statuscolor = $Header::colourred;
+my $statuscolor = '#993333';
 if ( $qossettings{'ENABLED'} eq 'on' ) {
   $status = $Lang::tr{'running'};
-  $statuscolor = $Header::colourgreen;
+  $statuscolor = '#339933';
 }
 
 if ( $netsettings{'RED_TYPE'} ne 'PPPOE' ) {
@@ -341,7 +477,7 @@ END
                print <<END
                <tr><td colspan='3'>&nbsp;
                <tr><td width='40%' align='right'>Downloadgeschwindigkeit:      <td width='40%' align='left'>$qossettings{'INC_SPD'} kbps
-                   <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTION_BW' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Andern'>
+                   <td width='20%' rowspan='2' align='center' valign='middle'><input type='submit' name='ACTIONBW' value='Andern'>
                <tr><td width='40%' align='right'>Uploadgeschwindigkeit:        <td width='40%' align='left'>$qossettings{'OUT_SPD'} kbps
 END
 ;
@@ -350,11 +486,11 @@ END
                print <<END
                <tr><td colspan='3'><hr>
                <tr><td width='40%' align='right'>Downloadstandardklasse:       <td width='40%' align='left'>$qossettings{'DEFCLASS_INC'}       
-                   <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTION_DEF' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Andern'>
+                   <td width='20%' rowspan='3' align='center' valign='middle'><input type='submit' name='ACTIONDEF' value='Andern'>
                <tr><td width='40%' align='right'>Uploadstandardklasse:         <td width='40%' align='left'>$qossettings{'DEFCLASS_OUT'}
                <tr><td width='40%' align='right'>ACKs:                         <td width='40%' align='left'>$qossettings{'ACK'}
                <tr><td colspan='3' width='100%'><hr>
-               <tr><td colspan='3' width='100%' align='center'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Parentklasse hinzufuegen'>
+               <tr><td colspan='3' width='100%' align='center'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Parentklasse hinzufuegen'><input type='submit' name='ACTION' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)' value='Erweiterte Einstellungen'>
        </form>
 END
 ;
@@ -379,6 +515,7 @@ if ( ($qossettings{'DEFCLASS_INC'} eq '') || ($qossettings{'DEFCLASS_OUT'} eq ''
 
 &showclasses();
 &showl7rules();
+&showportrules();
 
 &Header::closebigbox();
 &Header::closepage();
@@ -444,6 +581,7 @@ sub changebandwidth {
        } else {
                print <<END
                <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+               <input type='hidden' name='DEF_OUT_SPD' value=''><input type='hidden' name='DEF_INC_SPD' value=''>
                <table width='66%'>
                <tr><td width='100%' colspan='3'>Geben Sie bitte hier ihre Download- bzw. Upload-Geschwindigkeit ein <br> und klicken Sie danach auf <i>Speichern</i>.
                <tr><td width='33%' align='right'>Download-Geschwindigkeit:
@@ -539,7 +677,7 @@ END
                    <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>Ceilburst:
                    <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
-                   <td width='33%' align='center'><input type='submit' name='DO_CLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
+                   <td width='33%' align='center'><input type='submit' name='DOCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
                </table></form>
 END
 ;
@@ -604,14 +742,13 @@ END
                    <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>Ceilburst:
                    <td width='33%' align='left'><input type='text' name='CBURST' maxlength='8' value=$qossettings{'CBURST'}>
-                   <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DO_SCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
+                   <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DOSCLASS' value=$Lang::tr{'save'} />&nbsp;<input type='reset' value=$Lang::tr{'reset'} />
                </table></form>
 END
 ;
        &Header::closebox();
 }
 
-
 sub level7rule {
        &Header::openbox('100%', 'center', 'Level7-Regel');
        print <<END
@@ -650,7 +787,7 @@ END
                    <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>Ziel-IP-Adresse:
                    <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='DO_LEVEL7' value=$Lang::tr{'save'} />
+                   <td width='33%' align='center'><input type='hidden' name='CLASS' value=$qossettings{'CLASS'}><input type='submit' name='DOLEVEL7' value=$Lang::tr{'save'} />
                </table></form>
 END
 ;
@@ -663,9 +800,6 @@ sub portrule {
                <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                <table width='66%'>
                <tr><td width='100%' colspan='3'>Geben sie die Daten ein <br> und klicken Sie danach auf <i>Speichern</i>.
-               <tr><td width='33%' align='right'>Name:
-                   <td width='33%' align='left'><input type='text' name='NAME' maxlength='20' value=$qossettings{'NAME'}>
-                   <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>Protokoll:
                    <td width='33%' align='left'><select name='PPROT'>
 END
@@ -696,7 +830,7 @@ END
                    <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>Ziel-IP-Adresse:
                    <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='ACTION' value=$Lang::tr{'save'} />
+                   <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
 ;
@@ -739,11 +873,11 @@ END
                                    <td align='center' bgcolor='#EAEAEA'>$classline[5]
                                    <td align='center' bgcolor='#EAEAEA'>$classline[6]
                                    <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
-                                       <button type='submit' name='DO_CLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Unterklasse hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addblue.gif' width="20" height="20" alt="Unterklasse hinzufuegen"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
-                                       <button type='submit' name='DO_CLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                       <button type='submit' name='DOCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                </form>
 END
 ;
@@ -761,10 +895,10 @@ END
                                                            <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
                                                            <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
                                                            <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
-                                                               <button type='submit' name='DO_SCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                                               <button type='submit' name='DOSCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
                                                                <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
                                                                <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
-                                                               <button type='submit' name='DO_SCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                                               <button type='submit' name='DOSCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                                </form>
 END
 ;
@@ -788,11 +922,11 @@ END
                                    <td align='center' bgcolor='#EAEAEA'>$classline[5]
                                    <td align='center' bgcolor='#EAEAEA'>$classline[6]
                                    <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$classline[1]'>
-                                       <button type='submit' name='DO_CLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Unterklasse hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addblue.gif' width="20" height="20" alt="Unterklasse hinzufuegen"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
                                        <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
-                                       <button type='submit' name='DO_CLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                       <button type='submit' name='DOCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                </form>
 END
 ;
@@ -810,10 +944,10 @@ END
                                                            <td align='center' bgcolor='#FAFAFA'>$subclassline[6]
                                                            <td align='center' bgcolor='#FAFAFA'>$subclassline[7]
                                                            <td align='right'  bgcolor='#FAFAFA'><input type='hidden' name='CLASS' value='$subclassline[2]'>
-                                                               <button type='submit' name='DO_SCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                                               <button type='submit' name='DOSCLASS' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
                                                                <button type='submit' name='ACTION' value='Level7-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/addgreen.gif' width="20" height="20" alt="Level7-Regel hinzufuegen"></button>&nbsp;
                                                                <button type='submit' name='ACTION' value='Port-Regel hinzufuegen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/add.gif' width="20" height="20" alt="Port-Regel hinzufuegen"></button>&nbsp;
-                                                               <button type='submit' name='DO_SCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                                               <button type='submit' name='DOSCLASS' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                                </form>
 END
 ;
@@ -821,7 +955,11 @@ END
                                }
                        }
                }
-               print "\t</table>\n";
+               print <<END
+               <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Klasse bearbeiten | <img src='/images/addblue.gif'>&nbsp;Unterklasse hinzufuegen | <img src='/images/addgreen.gif'>&nbsp;Level7-Regel hinzufuegen | <img src='/images/add.gif'>&nbsp;Port-Regel hinzufuegen | <img src='/images/delete.gif'>&nbsp;Klasse loeschen &nbsp;
+               </table>
+END
+;
                &Header::closebox();
        }
 }
@@ -855,8 +993,8 @@ END
                                    <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
                                    <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
                                    <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
-                                       <button type='submit' name='DO_LEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
-                                       <button type='submit' name='DO_LEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                       <button type='submit' name='DOLEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOLEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                </form>
 END
 ;
@@ -876,18 +1014,137 @@ END
                                    <td align='center' bgcolor='#EAEAEA'>$l7ruleline[3]
                                    <td align='center' bgcolor='#EAEAEA'>$l7ruleline[4]
                                    <td align='right'  bgcolor='#EAEAEA'><input type='hidden' name='CLASS' value='$l7ruleline[0]'><input type='hidden' name='L7PROT' value='$l7ruleline[2]'>
-                                       <button type='submit' name='DO_LEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
-                                       <button type='submit' name='DO_LEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                                       <button type='submit' name='DOLEVEL7' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOLEVEL7' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                               </form>
+END
+;
+                       }
+               }
+               print <<END
+               <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Regel bearbeiten | <img src='/images/delete.gif'>&nbsp;Regel loeschen &nbsp;
+               </table>
+END
+;
+               &Header::closebox();
+       }
+}
+
+sub showportrules {
+       open( FILE, "< $portfile" ) or die "Unable to read $portfile";
+       @portrules = <FILE>;
+       close FILE;
+       if (@portrules) {
+               &Header::openbox('100%', 'center', 'Port-Regeln');
+               print <<END
+               <table border='0' width='100%' cellspacing='0'>
+               <tr><td bgcolor='lightgrey' width='10%'>Interface
+                   <td bgcolor='lightgrey' width='10%'>Klasse
+                   <td bgcolor='lightgrey' width='10%'>Protokoll
+                   <td bgcolor='lightgrey' width='10%'>Quell-IP-Adresse
+                   <td bgcolor='lightgrey' width='10%'>Quell-Port
+                   <td bgcolor='lightgrey' width='10%'>Ziel-IP-Adresse
+                   <td bgcolor='lightgrey' width='10%'>Ziel-Port
+                   <td bgcolor='lightgrey' width='30%'>Aktionen
+END
+;
+               foreach $portruleentry (sort @portrules)
+               {
+                       @portruleline = split( /\;/, $portruleentry );
+                       if ( $portruleline[1] eq $qossettings{'RED_DEV'} )
+                       {
+                               print <<END
+                               <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+                               <tr><td align='center' bgcolor='#EAEAEA'>$portruleline[1]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[0]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[2]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[3]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[4]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[5]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[6]
+                                   <td align='right'  bgcolor='#EAEAEA'>
+                                       <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]'>
+                                       <button type='submit' name='DOPORT' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOPORT' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
+                               </form>
+END
+;
+                       }
+               }
+               print "\t<tr><td colspan='8' bgcolor='lightgrey' height='2'>";
+               foreach $portruleentry (sort @portrules)
+               {
+                       @portruleline = split( /\;/, $portruleentry );
+                       if ( $portruleline[1] eq $qossettings{'IMQ_DEV'} )
+                       {
+                               print <<END
+                               <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+                               <tr><td align='center' bgcolor='#EAEAEA'>$portruleline[1]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[0]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[2]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[3]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[4]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[5]
+                                   <td align='center' bgcolor='#EAEAEA'>$portruleline[6]
+                                   <td align='right'  bgcolor='#EAEAEA'>
+                                       <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]'>
+                                       <button type='submit' name='DOPORT' value='Bearbeiten' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/edit.gif' width="20" height="20" alt="Klasse bearbeiten"></button>&nbsp;
+                                       <button type='submit' name='DOPORT' value='Loeschen' class='btnOff' onmouseover='BorderOn(this)' onmouseout='BorderOff(this)'><img src='/images/delete.gif' width="20" height="20" alt="Klasse loeschen"></button>
                                </form>
 END
 ;
                        }
                }
-               print "\t</table>\n";
+               print <<END
+               <tr><td colspan='8' align='right' valign='middle'><b>Legende:</b>&nbsp;&nbsp;<img src='/images/edit.gif'>&nbsp;Regel bearbeiten | <img src='/images/delete.gif'>&nbsp;Regel loeschen &nbsp;
+               </table>
+END
+;
                &Header::closebox();
        }
 }
 
+sub expert
+{
+       &Header::openbox('100%', 'center', 'Expertenoptionen:');
+       print <<END
+               <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+               <table width='66%'>
+               <tr><td width='100%' colspan='3'>Diese Einstellungen sollten sie nur veraendern, wenn sie wirklich wissen, was sie tun.
+               <tr><td width='33%' align='right'>Download-Rate 90\%:<td width='33%' align='left'>
+                       <input type='text' name='DEF_INC_SPD' maxlength='8' required='4' value=$qossettings{'DEF_INC_SPD'}>
+                   <td width='33%' align='center'>&nbsp;
+               <tr><td width='33%' align='right'>Upload-Rate 90\%:<td width='33%' align='left'>
+                       <input type='text' name='DEF_OUT_SPD' maxlength='8' required='4' value=$qossettings{'DEF_OUT_SPD'}>
+                   <td width='33%' align='center'>&nbsp;
+               </table>
+               <hr>
+               <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'>Diese Einstellung aendert die MTU nicht global sondern nur fuer das QoS.
+               <tr><td width='33%' align='right'>Queue Laenge:<td width='33%' align='left'>
+                       <input type='text' name='QLENGTH' maxlength='8' required='2' value=$qossettings{'QLENGTH'}>
+                   <td width='33%' align='center'>&nbsp;
+               <tr><td width='33%' align='right'>SFQ Perturb:<td width='33%' align='left'>
+                       <input type='text' name='SFQ_PERTUB' maxlength='8' required='1' value=$qossettings{'SFQ_PERTUB'}>
+                   <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' ) {
@@ -903,6 +1160,7 @@ sub validminbwdth {
                $qossettings{'SPD'} = '';
        }
 }
+
 sub validmaxbwdth {
        if ( $qossettings{'VALID'} eq 'yes' ) {
                if ( $qossettings{'DEVICE'} eq $qossettings{'RED_DEV'} ) {
@@ -946,6 +1204,7 @@ sub validclass {
                }
        }
 }
+
 sub validsubclass {
        if ( $qossettings{'VALID'} eq 'yes' ) {
                open( FILE, "< $subclassfile" ) or die "Unable to read $subclassfile";
@@ -962,4 +1221,4 @@ sub validsubclass {
                        }
                }
        }
-}
\ No newline at end of file
+}
diff --git a/html/html/images/addgreen.gif b/html/html/images/addgreen.gif
new file mode 100644 (file)
index 0000000..c30ad11
Binary files /dev/null and b/html/html/images/addgreen.gif differ
index 48c4ff2..5daaa14 100644 (file)
@@ -52,7 +52,7 @@ $(TARGET) :
        # Create all directories
        for i in addon-lang alcatelusb auth backup backup/sets ca certs cnx_pci crls ddns dhcp dhcpc dmzholes \
            eagle-usb eciadsl ethernet isdn key langs logging main modem net-traffic nfs optionsfw patches pakfire portfw \
-           ppp private proxy/advanced qos red remote snort time urlfilter/autoupdate urlfilter/bin vpn wireless xtaccess ; do \
+           ppp private proxy/advanced qos/bin red remote snort time urlfilter/autoupdate urlfilter/bin vpn wireless xtaccess ; do \
                mkdir -p $(CONFIG_ROOT)/$$i; \
        done
 
@@ -82,6 +82,7 @@ $(TARGET) :
        cp $(DIR_SRC)/config/cfgroot/net-traffic-lib.pl         $(CONFIG_ROOT)/net-traffic/net-traffic-lib.pl
        cp $(DIR_SRC)/config/cfgroot/nfs-server                 $(CONFIG_ROOT)/nfs/nfs-server
        cp $(DIR_SRC)/config/cfgroot/proxy-acl                  $(CONFIG_ROOT)/proxy/acl-1.4
+       cp $(DIR_SRC)/config/qos/makeqosscripts.pl              $(CONFIG_ROOT)/qos/bin/makeqosscripts.pl
        cp $(DIR_SRC)/config/cfgroot/ssh-settings                       $(CONFIG_ROOT)/remote/settings
        cp $(DIR_SRC)/config/cfgroot/xtaccess-config            $(CONFIG_ROOT)/xtaccess/config
        cp $(DIR_SRC)/config/cfgroot/time-settings              $(CONFIG_ROOT)/time/settings