]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/qos.cgi
corrected some smaller bugs in some cgiŽs
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / qos.cgi
index 606e9289484454b1fa27362f94f47bce20a16ff1..8a3d0024f5156a225c760475524a684974d1da73 100644 (file)
@@ -1,17 +1,29 @@
 #!/usr/bin/perl
-#
-# IPFire CGIs
-#
-# This code is distributed under the terms of the GPL
-#
-# (c) The IPFire Team
-#
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
 
 use RRDs;
 use strict;
 # enable only the following on debugging purpose
 # use warnings;
-use CGI::Carp 'fatalsToBrowser';
+use CGI::Carp 'fatalsToBrowser';
 
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
@@ -475,6 +487,95 @@ elsif ($qossettings{'ACTION'} eq $Lang::tr{'save'})
        }
        &General::writehash("${General::swroot}/qos/settings", \%qossettings);
 }
+elsif ($qossettings{'ACTION'} eq $Lang::tr{'template'} )
+{
+       my @UP;
+       #print "UP<br />";
+       for(my $i = 1; $i <= 10; $i++) {
+       $UP[$i] = int($qossettings{'OUT_SPD'} / $i );
+       #print $i."=".$UP[$i]." ";
+       }
+       my @DOWN;
+       #print "<br /><br />Down<br />";
+       for(my $i = 1; $i <= 20; $i++) {
+       $DOWN[$i] = int($qossettings{'INC_SPD'} / $i);
+       #print $i."=".$DOWN[$i]." ";
+       }
+       open( FILE, "> $classfile" ) or die "Unable to write $classfile";
+       print FILE <<END
+imq0;200;1;$DOWN[10];$DOWN[1];;;8;VoIP;
+imq0;203;4;$DOWN[20];$DOWN[1];;;0;VPN;
+imq0;204;5;$DOWN[20];$DOWN[1];;;8;Webtraffic;
+imq0;210;6;1;$DOWN[1];;;0;Standardklasse;
+imq0;220;7;1;$DOWN[1];;;1;P2P;
+ppp0;101;1;$UP[2];$UP[1];;;8;ACKs oder so;
+ppp0;102;2;$UP[3];$UP[1];;;8;VoIP;
+ppp0;104;5;$UP[10];$UP[1];;;8;Webtraffic;
+ppp0;110;6;1;$UP[1];;;0;Standardklasse;
+ppp0;120;7;1;$UP[1];;;1;P2P;
+ppp0;103;4;$UP[2];$UP[1];;;2;VPN;
+END
+;
+       close FILE;
+       open( FILE, "> $level7file" ) or die "Unable to write $level7file";
+       print FILE <<END
+102;ppp0;dns;;;
+102;ppp0;sip;;;
+102;ppp0;skypetoskype;;;
+103;ppp0;ssh;;;
+103;ppp0;rdp;;;
+104;ppp0;http;;;
+104;ppp0;ssl;;;
+104;ppp0;pop3;;;
+110;ppp0;ftp;;;
+120;ppp0;applejuice;;;
+120;ppp0;bittorrent;;;
+200;imq0;skypetoskype;;;
+203;imq0;ssh;;;
+203;imq0;rdp;;;
+204;imq0;http;;;
+204;imq0;pop3;;;
+204;imq0;ssl;;;
+220;imq0;applejuice;;;
+220;imq0;bittorrent;;;
+210;imq0;ftp;;;
+END
+;
+       close FILE;
+       open( FILE, "> $portfile" ) or die "Unable to write $portfile";
+       print FILE <<END
+101;ppp0;icmp;;;;;
+102;ppp0;tcp;;;;53;
+102;ppp0;udp;;;;53;
+103;ppp0;esp;;;;;
+103;ppp0;tcp;;;;1194;
+103;ppp0;udp;;4500;;4500;
+103;ppp0;udp;;500;;500;
+104;ppp0;tcp;;;;80;
+108;ppp0;esp;;;;;
+108;ppp0;l2tp;;;;;
+109;ppp0;icmp;;;;;
+200;imq0;icmp;;;;;
+203;imq0;esp;;;;;
+203;imq0;tcp;;;;1194;
+203;imq0;udp;;4500;;4500;
+203;imq0;udp;;500;;500;
+204;imq0;tcp;;;;80;
+END
+;
+       close FILE;
+       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);
+       }
+       $qossettings{'DEFCLASS_INC'} = "210";
+       $qossettings{'DEFCLASS_OUT'} = "110";
+       $qossettings{'ACK'} ="101";
+       &General::writehash("${General::swroot}/qos/settings", \%qossettings);
+       
+}
 elsif ($qossettings{'ACTION'} eq 'Statusinformationen')
 {
        &Header::openbox('100%', 'left', 'QoS Status');
@@ -674,7 +775,7 @@ END
 ;}
 else 
 {
-print $Lang::tr{'no information available'};
+print "\t</table><br />".$Lang::tr{'no information available'};
 }
 print "\t</table>";
 
@@ -749,15 +850,15 @@ sub changebandwidth {
                <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'>$Lang::tr{'down and up speed'}
-               <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:
-                   <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" />
-                   <td width='20%' align='center'>&nbsp;
-               <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:
-                   <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" />
-                   <td width='20%' align='center'><input type='submit' name='ACTION' value="$Lang::tr{'save'}" />&nbsp;<input type='reset' name='ACTION' value="$Lang::tr{'reset'}" />
+               <tr><td width='100%' colspan='3'>$Lang::tr{'down and up speed'}</td></tr>
+               <tr><td width='50%' align='right'>$Lang::tr{'downlink speed'}:</td>
+                               <td width='30%' align='left'><input type='text' name='INC_SPD' maxlength='8' value="$qossettings{'INC_SPD'}" /></td>
+                               <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>
+               <tr><td width='50%' align='right'>$Lang::tr{'uplink speed'}:</td>
+                               <td width='30%' align='left'><input type='text' name='OUT_SPD' maxlength='8' value="$qossettings{'OUT_SPD'}" /></td></tr>
                </table>
                </form>
+               <font color='red'>$Lang::tr{'template warning'}</font>
 END
 ;
        }
@@ -846,13 +947,17 @@ END
                <tr><td width='33%' align='right'>Ceilburst:
                    <td width='33%' align='left'><input type='text' size='20' name='CBURST' maxlength='8' value="$qossettings{'CBURST'}" />
                    <td width='33%' align='center'>&nbsp;
+END
+;
+                       $selected{'TOS'}{$qossettings{'TOS'}} = "selected='selected'";
+print <<END
                <tr><td width='33%' align='right'>TOS-Bit:
                    <td width='33%' align='left'><select name='TOS'>
-                               <option value='0'>$Lang::tr{'disabled'} (0)</option>
-                               <option value='8'>$Lang::tr{'min delay'} (8)</option>
-                               <option value='4'>$Lang::tr{'max throughput'} (4)</option>
-                               <option value='2'>$Lang::tr{'max reliability'} (2)</option>
-                               <option value='1'>$Lang::tr{'min costs'} (1)</option></select>
+                               <option value='0' $selected{'TOS'}{'0'}>$Lang::tr{'disabled'} (0)</option>
+                               <option value='8' $selected{'TOS'}{'8'}>$Lang::tr{'min delay'} (8)</option>
+                               <option value='4' $selected{'TOS'}{'4'}>$Lang::tr{'max throughput'} (4)</option>
+                               <option value='2' $selected{'TOS'}{'2'}>$Lang::tr{'max reliability'} (2)</option>
+                               <option value='1' $selected{'TOS'}{'1'}>$Lang::tr{'min costs'} (1)</option></select>
                    <td width='33%' align='center'>&nbsp;
                <tr><td width='33%' align='right'>$Lang::tr{'remark'}:
                    <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' />