summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-07-16 21:03:22 +0000
committerErmal Luçi <eri@pfsense.org>2008-07-16 21:03:22 +0000
commitae62bbcfae6816cfd519fbc633d017deb380f395 (patch)
treebb0a2396b5977fba3498c70f95e4b253c30c1568 /usr
parent48d418e8291a03f532f474cac5dd830f329536d3 (diff)
downloadpfsense-ae62bbcfae6816cfd519fbc633d017deb380f395.zip
pfsense-ae62bbcfae6816cfd519fbc633d017deb380f395.tar.gz
We have our own roll of dummynet now.
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper.php264
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_edit.php778
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_magic.php418
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_pipes.php175
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_pipes_edit.php168
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_queues.php149
-rwxr-xr-xusr/local/www/m0n0/firewall_shaper_queues_edit.php157
7 files changed, 0 insertions, 2109 deletions
diff --git a/usr/local/www/m0n0/firewall_shaper.php b/usr/local/www/m0n0/firewall_shaper.php
deleted file mode 100755
index f4380dd..0000000
--- a/usr/local/www/m0n0/firewall_shaper.php
+++ /dev/null
@@ -1,264 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['rule'])) {
- $config['shaper']['rule'] = array();
-}
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_shaper = &$config['shaper']['rule'];
-$a_pipe = &$config['shaper']['pipe'];
-$a_queue = &$config['shaper']['queue'];
-
-$pconfig['enable'] = isset($config['shaper']['enable']);
-
-if ($_POST) {
-
- if ($_POST['submit']) {
- $pconfig = $_POST;
- $config['shaper']['enable'] = $_POST['enable'] ? true : false;
- write_config();
- }
-
- if ($_POST['apply'] || $_POST['submit']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- require_once("m0n0/shaper.inc");
- $retval = shaper_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_shaperconfdirty_path))
- unlink($d_shaperconfdirty_path);
- }
- }
-}
-
-if ($_GET['act'] == "del") {
- if ($a_shaper[$_GET['id']]) {
- unset($a_shaper[$_GET['id']]);
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "down") {
- if ($a_shaper[$_GET['id']] && $a_shaper[$_GET['id']+1]) {
- $tmp = $a_shaper[$_GET['id']+1];
- $a_shaper[$_GET['id']+1] = $a_shaper[$_GET['id']];
- $a_shaper[$_GET['id']] = $tmp;
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "up") {
- if (($_GET['id'] > 0) && $a_shaper[$_GET['id']]) {
- $tmp = $a_shaper[$_GET['id']-1];
- $a_shaper[$_GET['id']-1] = $a_shaper[$_GET['id']];
- $a_shaper[$_GET['id']] = $tmp;
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-} else if ($_GET['act'] == "toggle") {
- if ($a_shaper[$_GET['id']]) {
- $a_shaper[$_GET['id']]['disabled'] = !isset($a_shaper[$_GET['id']]['disabled']);
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper.php");
- exit;
- }
-}
-
-$pgtitle = "Firewall: Traffic Shaper";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<form action="firewall_shaper.php" method="post">
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
-<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
-</p>
-<?php endif; ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
- <ul id="tabnav">
- <li class="tabact">Rules</li>
- <li class="tabinact"><a href="firewall_shaper_pipes.php">Pipes</a></li>
- <li class="tabinact"><a href="firewall_shaper_queues.php">Queues</a></li>
- <li class="tabinact"><a href="firewall_shaper_magic.php">Magic shaper wizard</a></li>
- </ul>
- </td></tr>
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td class="vtable">
- <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked";?>>
- <strong>Enable traffic shaper</strong></td>
- </tr>
- <tr>
- <td> <input name="submit" type="submit" class="formbtn" value="Save">
- </td>
- </tr>
- </table>
- &nbsp;<br>
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="5%" class="listhdrrns">If</td>
- <td width="5%" class="listhdrrns">Proto</td>
- <td width="20%" class="listhdrr">Source</td>
- <td width="20%" class="listhdrr">Destination</td>
- <td width="15%" class="listhdrrns">Target</td>
- <td width="25%" class="listhdr">Description</td>
- <td width="10%" class="list"></td>
- </tr>
- <?php $i = 0; foreach ($a_shaper as $shaperent): ?>
- <tr valign="top">
- <td class="listlr">
- <?php
- $dis = "";
- if (isset($shaperent['disabled'])) {
- $dis = "_d";
- $textss = "<span class=\"gray\">";
- $textse = "</span>";
- } else {
- $textss = $textse = "";
- }
- $iflabels = get_configured_interface_with_descr();
-
- echo $textss . htmlspecialchars($iflabels[$shaperent['interface']]);
- echo "<br>";
- echo "<a href=\"?act=toggle&id={$i}\">";
- if ($shaperent['direction'] != "in")
- echo "<img src=\"/themes/{$g['theme']}/images/icons/out{$dis}.gif\" width=\"11\" height=\"11\" border=\"0\" style=\"margin-top: 5px\" title=\"click to toggle enabled/disabled status\">";
- if ($shaperent['direction'] != "out")
- echo "<img src=\"/themes/{$g['theme']}/images/icons/in{$dis}.gif\" width=\"11\" height=\"11\" border=\"0\" style=\"margin-top: 5px\" title=\"click to toggle enabled/disabled status\">";
- echo "</a>" . $textse;;
- ?>
- </td>
- <td class="listr">
- <?=$textss;?><?php if (isset($shaperent['protocol'])) echo strtoupper($shaperent['protocol']); else echo "*"; ?><?=$textse;?>
- </td>
- <td class="listr"><?=$textss;?><?php echo htmlspecialchars(pprint_address($shaperent['source'])); ?>
- <?php if ($shaperent['source']['port']): ?><br>
- Port: <?=htmlspecialchars(pprint_port($shaperent['source']['port'])); ?>
- <?php endif; ?><?=$textse;?>
- </td>
- <td class="listr"><?=$textss;?><?php echo htmlspecialchars(pprint_address($shaperent['destination'])); ?>
- <?php if ($shaperent['destination']['port']): ?><br>
- Port: <?=htmlspecialchars(pprint_port($shaperent['destination']['port'])); ?>
- <?php endif; ?><?=$textse;?>
- </td>
- <td class="listr"><?=$textss;?>
- <?php
- if (isset($shaperent['targetpipe'])) {
- if ($a_pipe[$shaperent['targetpipe']]['descr'])
- $desc = htmlspecialchars($a_pipe[$shaperent['targetpipe']]['descr']);
- else
- $desc = "Pipe " . ($shaperent['targetpipe']+1);
- echo "<a href=\"firewall_shaper_pipes_edit.php?id={$shaperent['targetpipe']}\">{$desc}</a>";
- } else if (isset($shaperent['targetqueue'])) {
- if ($a_queue[$shaperent['targetqueue']]['descr'])
- $desc = htmlspecialchars($a_queue[$shaperent['targetqueue']]['descr']);
- else
- $desc = "Queue " . ($shaperent['targetqueue']+1);
- echo "<a href=\"firewall_shaper_queues_edit.php?id={$shaperent['targetqueue']}\">{$desc}</a>";
- }
- ?><?=$textse;?>
- </td>
- <td class="listbg">
- <?=$textss;?><font color="#ffffff"><?=htmlspecialchars($shaperent['descr']);?><?=$textse;?>
- &nbsp; </td>
- <td valign="middle" nowrap class="list"> <a href="firewall_shaper_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a>
- <?php if ($i > 0): ?>
- <a href="firewall_shaper.php?act=up&id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_up.gif" title="move up" width="17" height="17" border="0"></a>
- <?php else: ?>
- <img src="up_d.gif" width="17" height="17" border="0">
- <?php endif; ?><br>
- <a href="firewall_shaper.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this rule?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete rule" width="17" height="17" border="0"></a>
- <?php if (isset($a_shaper[$i+1])): ?>
- <a href="firewall_shaper.php?act=down&id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_down.gif" title="move down" width="17" height="17" border="0"></a>
- <?php else: ?>
- <img src="/themes/<?= $g['theme']; ?>/images/icons/icon_down_d.gif" width="17" height="17" border="0">
- <?php endif; ?>
- <a href="firewall_shaper_edit.php?dup=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" " title="add a new rule based on this one" width="17" height="17" border="0"></a>
- </td>
- </tr>
- <?php $i++; endforeach; ?>
- <tr>
- <td class="list" colspan="6"></td>
- <td class="list"> <a href="firewall_shaper_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" " title="add rule" width="17" height="17" border="0"></a></td>
- </tr>
- </table>
-
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td width="16"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/in.gif" width="11" height="11"></td>
- <td>incoming (as seen by firewall)</td>
- <td width="14"></td>
- <td width="16"><img src="/themes/<?php echo $g['theme']; ?>/images/icons/out.gif" width="11" height="11"></td>
- <td>outgoing (as seen by firewall)</td>
- </tr>
- <tr>
- <td colspan="5" height="4"></td>
- </tr>
- <tr>
- <td><img src="/themes/<?php echo $g['theme']; ?>/images/icons/in_d.gif" width="11" height="11"></td>
- <td>incoming (disabled)</td>
- <td width="14"></td>
- <td><img src="/themes/<?php echo $g['theme']; ?>/images/icons/out_d.gif" width="11" height="11"></td>
- <td>outgoing (disabled)</td>
- </tr>
- </table><br>
- <span class="red"><strong>Note:</strong></span><strong><br>
- </strong>the first rule that matches a packet will be executed.<br>
- The following match patterns are not shown in the list above:
- IP packet length, TCP flags.</td>
- </tr>
-</table>
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/m0n0/firewall_shaper_edit.php b/usr/local/www/m0n0/firewall_shaper_edit.php
deleted file mode 100755
index cccc7f6..0000000
--- a/usr/local/www/m0n0/firewall_shaper_edit.php
+++ /dev/null
@@ -1,778 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_edit.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper", "Edit rule");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['rule'])) {
- $config['shaper']['rule'] = array();
-}
-$a_shaper = &$config['shaper']['rule'];
-
-$specialsrcdst = explode(" ", "any lan pptp");
-
-$id = $_GET['id'];
-if (isset($_POST['id']))
- $id = $_POST['id'];
-
-$after = $_GET['after'];
-if (isset($_POST['after']))
- $after = $_POST['after'];
-
-if (isset($_GET['dup'])) {
- $id = $_GET['dup'];
- $after = $_GET['dup'];
-}
-
-function is_specialnet($net) {
- global $specialsrcdst;
-
- if (in_array($net, $specialsrcdst) || strstr($net, "opt"))
- return true;
- else
- return false;
-}
-
-function address_to_pconfig($adr, &$padr, &$pmask, &$pnot, &$pbeginport, &$pendport) {
-
- if (isset($adr['any']))
- $padr = "any";
- else if ($adr['network'])
- $padr = $adr['network'];
- else if ($adr['address']) {
- list($padr, $pmask) = explode("/", $adr['address']);
- if (!$pmask)
- $pmask = 32;
- }
-
- if (isset($adr['not']))
- $pnot = 1;
- else
- $pnot = 0;
-
- if ($adr['port']) {
- list($pbeginport, $pendport) = explode("-", $adr['port']);
- if (!$pendport)
- $pendport = $pbeginport;
- } else {
- $pbeginport = "any";
- $pendport = "any";
- }
-}
-
-function pconfig_to_address(&$adr, $padr, $pmask, $pnot, $pbeginport, $pendport) {
-
- $adr = array();
-
- if ($padr == "any")
- $adr['any'] = true;
- else if (is_specialnet($padr))
- $adr['network'] = $padr;
- else {
- $adr['address'] = $padr;
- if ($pmask != 32)
- $adr['address'] .= "/" . $pmask;
- }
-
- $adr['not'] = $pnot ? true : false;
-
- if (($pbeginport != 0) && ($pbeginport != "any")) {
- if ($pbeginport != $pendport)
- $adr['port'] = $pbeginport . "-" . $pendport;
- else
- $adr['port'] = $pbeginport;
- }
-}
-
-if (isset($id) && $a_shaper[$id]) {
- $pconfig['interface'] = $a_shaper[$id]['interface'];
-
- if (isset($a_shaper[$id]['protocol']))
- $pconfig['proto'] = $a_shaper[$id]['protocol'];
- else
- $pconfig['proto'] = "any";
-
- address_to_pconfig($a_shaper[$id]['source'], $pconfig['src'],
- $pconfig['srcmask'], $pconfig['srcnot'],
- $pconfig['srcbeginport'], $pconfig['srcendport']);
-
- address_to_pconfig($a_shaper[$id]['destination'], $pconfig['dst'],
- $pconfig['dstmask'], $pconfig['dstnot'],
- $pconfig['dstbeginport'], $pconfig['dstendport']);
-
- if (isset($a_shaper[$id]['targetpipe'])) {
- $pconfig['target'] = "targetpipe:" . $a_shaper[$id]['targetpipe'];
- } else if (isset($a_shaper[$id]['targetqueue'])) {
- $pconfig['target'] = "targetqueue:" . $a_shaper[$id]['targetqueue'];
- }
-
- $pconfig['direction'] = $a_shaper[$id]['direction'];
- $pconfig['iptos'] = $a_shaper[$id]['iptos'];
- $pconfig['iplen'] = $a_shaper[$id]['iplen'];
- $pconfig['tcpflags'] = $a_shaper[$id]['tcpflags'];
- $pconfig['descr'] = $a_shaper[$id]['descr'];
- $pconfig['disabled'] = isset($a_shaper[$id]['disabled']);
-
- if ($pconfig['srcbeginport'] == 0) {
- $pconfig['srcbeginport'] = "any";
- $pconfig['srcendport'] = "any";
- }
- if ($pconfig['dstbeginport'] == 0) {
- $pconfig['dstbeginport'] = "any";
- $pconfig['dstendport'] = "any";
- }
-
-} else {
- /* defaults */
- $pconfig['src'] = "any";
- $pconfig['dst'] = "any";
-}
-
-if (isset($_GET['dup']))
- unset($id);
-
-if ($_POST) {
-
- if (($_POST['proto'] != "tcp") && ($_POST['proto'] != "udp") && ($_POST['proto'] != "any")) {
- $_POST['srcbeginport'] = 0;
- $_POST['srcendport'] = 0;
- $_POST['dstbeginport'] = 0;
- $_POST['dstendport'] = 0;
- } else {
-
- if ($_POST['srcbeginport_cust'] && !$_POST['srcbeginport'])
- $_POST['srcbeginport'] = $_POST['srcbeginport_cust'];
- if ($_POST['srcendport_cust'] && !$_POST['srcendport'])
- $_POST['srcendport'] = $_POST['srcendport_cust'];
-
- if ($_POST['srcbeginport'] == "any") {
- $_POST['srcbeginport'] = 0;
- $_POST['srcendport'] = 0;
- } else {
- if (!$_POST['srcendport'])
- $_POST['srcendport'] = $_POST['srcbeginport'];
- }
- if ($_POST['srcendport'] == "any")
- $_POST['srcendport'] = $_POST['srcbeginport'];
-
- if ($_POST['dstbeginport_cust'] && !$_POST['dstbeginport'])
- $_POST['dstbeginport'] = $_POST['dstbeginport_cust'];
- if ($_POST['dstendport_cust'] && !$_POST['dstendport'])
- $_POST['dstendport'] = $_POST['dstendport_cust'];
-
- if ($_POST['dstbeginport'] == "any") {
- $_POST['dstbeginport'] = 0;
- $_POST['dstendport'] = 0;
- } else {
- if (!$_POST['dstendport'])
- $_POST['dstendport'] = $_POST['dstbeginport'];
- }
- if ($_POST['dstendport'] == "any")
- $_POST['dstendport'] = $_POST['dstbeginport'];
- }
-
- if (is_specialnet($_POST['srctype'])) {
- $_POST['src'] = $_POST['srctype'];
- $_POST['srcmask'] = 0;
- } else if ($_POST['srctype'] == "single") {
- $_POST['srcmask'] = 32;
- }
- if (is_specialnet($_POST['dsttype'])) {
- $_POST['dst'] = $_POST['dsttype'];
- $_POST['dstmask'] = 0;
- } else if ($_POST['dsttype'] == "single") {
- $_POST['dstmask'] = 32;
- }
-
- $intos = array();
- foreach ($iptos as $tos) {
- if ($_POST['iptos_' . $tos] == "on")
- $intos[] = $tos;
- else if ($_POST['iptos_' . $tos] == "off")
- $intos[] = "!" . $tos;
- }
- $_POST['iptos'] = join(",", $intos);
-
- $intcpflags = array();
- foreach ($tcpflags as $tcpflag) {
- if ($_POST['tcpflags_' . $tcpflag] == "on")
- $intcpflags[] = $tcpflag;
- else if ($_POST['tcpflags_' . $tcpflag] == "off")
- $intcpflags[] = "!" . $tcpflag;
- }
- $_POST['tcpflags'] = join(",", $intcpflags);
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "target proto src dst");
- $reqdfieldsn = explode(",", "Target,Protocol,Source,Destination");
-
- if (!(is_specialnet($_POST['srctype']) || ($_POST['srctype'] == "single"))) {
- $reqdfields[] = "srcmask";
- $reqdfieldsn[] = "Source bit count";
- }
- if (!(is_specialnet($_POST['dsttype']) || ($_POST['dsttype'] == "single"))) {
- $reqdfields[] = "dstmask";
- $reqdfieldsn[] = "Destination bit count";
- }
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (!$_POST['srcbeginport']) {
- $_POST['srcbeginport'] = 0;
- $_POST['srcendport'] = 0;
- }
- if (!$_POST['dstbeginport']) {
- $_POST['dstbeginport'] = 0;
- $_POST['dstendport'] = 0;
- }
-
- if (($_POST['srcbeginport'] && !is_port($_POST['srcbeginport']))) {
- $input_errors[] = "The start source port must be an integer between 1 and 65535.";
- }
- if (($_POST['srcendport'] && !is_port($_POST['srcendport']))) {
- $input_errors[] = "The end source port must be an integer between 1 and 65535.";
- }
- if (($_POST['dstbeginport'] && !is_port($_POST['dstbeginport']))) {
- $input_errors[] = "The start destination port must be an integer between 1 and 65535.";
- }
- if (($_POST['dstendport'] && !is_port($_POST['dstendport']))) {
- $input_errors[] = "The end destination port must be an integer between 1 and 65535.";
- }
-
- if (!is_specialnet($_POST['srctype'])) {
- if (($_POST['src'] && !is_ipaddroranyalias($_POST['src']))) {
- $input_errors[] = "A valid source IP address or alias must be specified.";
- }
- if (($_POST['srcmask'] && !is_int($_POST['srcmask']))) {
- $input_errors[] = "A valid source bit count must be specified.";
- }
- }
- if (!is_specialnet($_POST['dsttype'])) {
- if (($_POST['dst'] && !is_ipaddroranyalias($_POST['dst']))) {
- $input_errors[] = "A valid destination IP address or alias must be specified.";
- }
- if (($_POST['dstmask'] && !is_int($_POST['dstmask']))) {
- $input_errors[] = "A valid destination bit count must be specified.";
- }
- }
-
- if ($_POST['srcbeginport'] > $_POST['srcendport']) {
- /* swap */
- $tmp = $_POST['srcendport'];
- $_POST['srcendport'] = $_POST['srcbeginport'];
- $_POST['srcbeginport'] = $tmp;
- }
- if ($_POST['dstbeginport'] > $_POST['dstendport']) {
- /* swap */
- $tmp = $_POST['dstendport'];
- $_POST['dstendport'] = $_POST['dstbeginport'];
- $_POST['dstbeginport'] = $tmp;
- }
-
- if (($_POST['iplen'] && !preg_match("/^(\d+)(-(\d+))?$/", $_POST['iplen']))) {
- $input_errors[] = "The IP packet length must be an integer or a range (from-to).";
- }
-
- if (!$input_errors) {
- $shaperent = array();
- $shaperent['interface'] = $_POST['interface'];
-
- if ($_POST['proto'] != "any")
- $shaperent['protocol'] = $_POST['proto'];
- else
- unset($shaperent['protocol']);
-
- pconfig_to_address($shaperent['source'], $_POST['src'],
- $_POST['srcmask'], $_POST['srcnot'],
- $_POST['srcbeginport'], $_POST['srcendport']);
-
- pconfig_to_address($shaperent['destination'], $_POST['dst'],
- $_POST['dstmask'], $_POST['dstnot'],
- $_POST['dstbeginport'], $_POST['dstendport']);
-
- $shaperent['direction'] = $_POST['direction'];
- $shaperent['iplen'] = $_POST['iplen'];
- $shaperent['iptos'] = $_POST['iptos'];
- $shaperent['tcpflags'] = $_POST['tcpflags'];
- $shaperent['descr'] = $_POST['descr'];
- $shaperent['disabled'] = $_POST['disabled'] ? true : false;
-
- list($targettype,$target) = explode(":", $_POST['target']);
- $shaperent[$targettype] = $target;
-
- if (isset($id) && $a_shaper[$id])
- $a_shaper[$id] = $shaperent;
- else {
- if (is_numeric($after))
- array_splice($a_shaper, $after+1, 0, array($shaperent));
- else
- $a_shaper[] = $shaperent;
- }
-
- write_config();
- touch($d_shaperconfdirty_path);
-
- header("Location: firewall_shaper.php");
- exit;
- }
-}
-$pgtitle = "Firewall: Traffic Shaper Edit";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-
-<script type="text/javascript">
- var portsenabled = 1;
-
- function ext_change() {
- if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
- document.iform.srcbeginport_cust.disabled = 0;
- } else {
- document.iform.srcbeginport_cust.value = "";
- document.iform.srcbeginport_cust.disabled = 1;
- }
- if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
- document.iform.srcendport_cust.disabled = 0;
- } else {
- document.iform.srcendport_cust.value = "";
- document.iform.srcendport_cust.disabled = 1;
- }
- if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled) {
- document.iform.dstbeginport_cust.disabled = 0;
- } else {
- document.iform.dstbeginport_cust.value = "";
- document.iform.dstbeginport_cust.disabled = 1;
- }
- if ((document.iform.dstendport.selectedIndex == 0) && portsenabled) {
- document.iform.dstendport_cust.disabled = 0;
- } else {
- document.iform.dstendport_cust.value = "";
- document.iform.dstendport_cust.disabled = 1;
- }
-
- if (!portsenabled) {
- document.iform.srcbeginport.disabled = 1;
- document.iform.srcendport.disabled = 1;
- document.iform.dstbeginport.disabled = 1;
- document.iform.dstendport.disabled = 1;
- } else {
- document.iform.srcbeginport.disabled = 0;
- document.iform.srcendport.disabled = 0;
- document.iform.dstbeginport.disabled = 0;
- document.iform.dstendport.disabled = 0;
- }
- }
-
- function typesel_change() {
- switch (document.iform.srctype.selectedIndex) {
- case 1: /* single */
- document.iform.src.disabled = 0;
- document.iform.srcmask.value = "";
- document.iform.srcmask.disabled = 1;
- break;
- case 2: /* network */
- document.iform.src.disabled = 0;
- document.iform.srcmask.disabled = 0;
- break;
- default:
- document.iform.src.value = "";
- document.iform.src.disabled = 1;
- document.iform.srcmask.value = "";
- document.iform.srcmask.disabled = 1;
- break;
- }
- switch (document.iform.dsttype.selectedIndex) {
- case 1: /* single */
- document.iform.dst.disabled = 0;
- document.iform.dstmask.value = "";
- document.iform.dstmask.disabled = 1;
- break;
- case 2: /* network */
- document.iform.dst.disabled = 0;
- document.iform.dstmask.disabled = 0;
- break;
- default:
- document.iform.dst.value = "";
- document.iform.dst.disabled = 1;
- document.iform.dstmask.value = "";
- document.iform.dstmask.disabled = 1;
- break;
- }
- }
-
- function proto_change() {
- if (document.iform.proto.selectedIndex < 2 || document.iform.proto.selectedIndex == 8) {
- portsenabled = 1;
- } else {
- portsenabled = 0;
- }
-
- ext_change();
- }
-
- function src_rep_change() {
- document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
- }
- function dst_rep_change() {
- document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
- }
-</script>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if (is_array($config['shaper']['pipe']) && (count($config['shaper']['pipe']) > 0)): ?>
- <form action="firewall_shaper_edit.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td valign="top" class="vncellreq">Target</td>
- <td class="vtable"><select name="target" class="formselect">
- <?php
- foreach ($config['shaper']['pipe'] as $pipei => $pipe): ?>
- <option value="<?="targetpipe:$pipei";?>" <?php if ("targetpipe:$pipei" == $pconfig['target']) echo "selected"; ?>>
- <?php
- echo htmlspecialchars("Pipe " . ($pipei + 1));
- if ($pipe['descr'])
- echo htmlspecialchars(" (" . $pipe['descr'] . ")");
- ?>
- </option>
- <?php endforeach;
- foreach ($config['shaper']['queue'] as $queuei => $queue): ?>
- <option value="<?="targetqueue:$queuei";?>" <?php if ("targetqueue:$queuei" == $pconfig['target']) echo "selected"; ?>>
- <?php
- echo htmlspecialchars("Queue " . ($queuei + 1));
- if ($queue['descr'])
- echo htmlspecialchars(" (" . $queue['descr'] . ")");
- ?>
- </option>
- <?php endforeach; ?>
- </select> <br>
- <span class="vexpl">Choose a pipe or queue where packets that
- match this rule should be sent.</span></td>
- </tr>
- <tr>
- <td valign="top" class="vncellreq">Disabled</td>
- <td class="vtable">
- <input name="disabled" type="checkbox" id="disabled" value="yes" <?php if ($pconfig['disabled']) echo "checked"; ?>>
- <strong>Disable this rule</strong><br>
- <span class="vexpl">Set this option to disable this rule without removing it from the list.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Interface</td>
- <td width="78%" class="vtable"><select name="interface" class="formselect">
- <?php $interfaces = get_configured_interface_with_descr();
- $interfaces['pptp'] = 'PPTP';
-
- foreach ($interfaces as $iface => $ifacename): ?>
- <option value="<?=$iface;?>" <?php if ($iface == $pconfig['interface']) echo "selected"; ?>>
- <?=htmlspecialchars($ifacename);?>
- </option>
- <?php endforeach; ?>
- </select> <br>
- <span class="vexpl">Choose which interface packets must pass
- through to match this rule.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Protocol</td>
- <td width="78%" class="vtable"><select name="proto" class="formselect" onchange="proto_change()">
- <?php $protocols = explode(" ", "TCP UDP ICMP ESP AH GRE IPv6 IGMP any"); foreach ($protocols as $proto): ?>
- <option value="<?=strtolower($proto);?>" <?php if (strtolower($proto) == $pconfig['proto']) echo "selected"; ?>>
- <?=htmlspecialchars($proto);?>
- </option>
- <?php endforeach; ?>
- </select> <br> <span class="vexpl">Choose which IP protocol
- this rule should match.<br>
- Hint: in most cases, you should specify <em>TCP</em> &nbsp;here.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Source</td>
- <td width="78%" class="vtable"> <input name="srcnot" type="checkbox" id="srcnot" value="yes" <?php if ($pconfig['srcnot']) echo "checked"; ?>>
- <strong>not</strong><br>
- Use this option to invert the sense of the match.<br> <br>
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td>Type:&nbsp;&nbsp;</td>
- <td></td>
- <td><select name="srctype" class="formselect" onChange="typesel_change()">
- <?php $sel = is_specialnet($pconfig['src']); ?>
- <option value="any" <?php if ($pconfig['src'] == "any") { echo "selected"; } ?>>
- any</option>
- <option value="single" <?php if (($pconfig['srcmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
- Single host or alias</option>
- <option value="network" <?php if (!$sel) echo "selected"; ?>>
- Network</option>
- <option value="lan" <?php if ($pconfig['src'] == "lan") { echo "selected"; } ?>>
- LAN subnet</option>
- <option value="pptp" <?php if ($pconfig['src'] == "pptp") { echo "selected"; } ?>>
- PPTP clients</option>
- <?php $iflist = get_configured_interface_with_descr(true);
- foreach ($iflist as $opt => $ifdesc): ?>
- <option value="<?=$opt;?>" <?php if ($pconfig['src'] == $opt) { echo "selected"; } ?>>
- <?=htmlspecialchars($ifdesc);?>
- subnet</option>
- <?php endfor; ?>
- </select></td>
- </tr>
- <tr>
- <td>Address:&nbsp;&nbsp;</td>
- <td><?=$mandfldhtmlspc;?></td>
- <td><input name="src" type="text" class="formfldalias" id="src" size="20" value="<?php if (!is_specialnet($pconfig['src'])) echo htmlspecialchars($pconfig['src']);?>">
- /
- <select name="srcmask" class="formselect" id="srcmask">
- <?php for ($i = 31; $i > 0; $i--): ?>
- <option value="<?=$i;?>" <?php if ($i == $pconfig['srcmask']) echo "selected"; ?>>
- <?=$i;?>
- </option>
- <?php endfor; ?>
- </select></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Source port range
- </td>
- <td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td>from:&nbsp;&nbsp;</td>
- <td><select name="srcbeginport" class="formselect" onchange="src_rep_change();ext_change()">
- <option value="">(other)</option>
- <option value="any" <?php $bfound = 0; if ($pconfig['srcbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
- <?php foreach ($wkports as $wkport => $wkportdesc): ?>
- <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcbeginport']) {
- echo "selected";
- $bfound = 1;
- }?>>
- <?=htmlspecialchars($wkportdesc);?>
- </option>
- <?php endforeach; ?>
- </select> <input name="srcbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcbeginport']) echo $pconfig['srcbeginport']; ?>"></td>
- </tr>
- <tr>
- <td>to:</td>
- <td><select name="srcendport" class="formselect" onchange="ext_change()">
- <option value="">(other)</option>
- <option value="any" <?php $bfound = 0; if ($pconfig['srcendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
- <?php foreach ($wkports as $wkport => $wkportdesc): ?>
- <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['srcendport']) {
- echo "selected";
- $bfound = 1;
- }?>>
- <?=htmlspecialchars($wkportdesc);?>
- </option>
- <?php endforeach; ?>
- </select> <input name="srcendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['srcendport']) echo $pconfig['srcendport']; ?>"></td>
- </tr>
- </table>
- <br> <span class="vexpl">Specify the port or port range for
- the source of the packet for this rule.<br>
- Hint: you can leave the <em>'to'</em> field empty if you only
- want to filter a single port</span></td>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Destination</td>
- <td width="78%" class="vtable"> <input name="dstnot" type="checkbox" id="dstnot" value="yes" <?php if ($pconfig['dstnot']) echo "checked"; ?>>
- <strong>not</strong><br>
- Use this option to invert the sense of the match.<br> <br>
- <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td>Type:&nbsp;&nbsp;</td>
- <td></td>
- <td><select name="dsttype" class="formselect" onChange="typesel_change()">
- <?php $sel = is_specialnet($pconfig['dst']); ?>
- <option value="any" <?php if ($pconfig['dst'] == "any") { echo "selected"; } ?>>
- any</option>
- <option value="single" <?php if (($pconfig['dstmask'] == 32) && !$sel) { echo "selected"; $sel = 1; } ?>>
- Single host or alias</option>
- <option value="network" <?php if (!$sel) echo "selected"; ?>>
- Network</option>
- <option value="lan" <?php if ($pconfig['dst'] == "lan") { echo "selected"; } ?>>
- LAN subnet</option>
- <option value="pptp" <?php if ($pconfig['dst'] == "pptp") { echo "selected"; } ?>>
- PPTP clients</option>
- <?php $iflist = get_configured_interface_with_descr(true);
- foreach ($iflist as $opt => $ifdesc): ?>
- <option value="<?=$opt;?>" <?php if ($pconfig['dst'] == $opt) { echo "selected"; } ?>>
- <?=htmlspecialchars($ifdesc);?>
- subnet</option>
- <?php endfor; ?>
- </select> </td>
- </tr>
- <tr>
- <td>Address:&nbsp;&nbsp;</td>
- <td><?=$mandfldhtmlspc;?></td>
- <td><input name="dst" type="text" class="formfldalias" id="dst" size="20" value="<?php if (!is_specialnet($pconfig['dst'])) echo htmlspecialchars($pconfig['dst']);?>">
- /
- <select name="dstmask" class="formselect" id="dstmask">
- <?php for ($i = 31; $i > 0; $i--): ?>
- <option value="<?=$i;?>" <?php if ($i == $pconfig['dstmask']) echo "selected"; ?>>
- <?=$i;?>
- </option>
- <?php endfor; ?>
- </select></td>
- </tr>
- </table></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Destination port
- range </td>
- <td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td>from:&nbsp;&nbsp;</td>
- <td><select name="dstbeginport" class="formselect" onchange="dst_rep_change();ext_change()">
- <option value="">(other)</option>
- <option value="any" <?php $bfound = 0; if ($pconfig['dstbeginport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
- <?php foreach ($wkports as $wkport => $wkportdesc): ?>
- <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstbeginport']) {
- echo "selected";
- $bfound = 1;
- }?>>
- <?=htmlspecialchars($wkportdesc);?>
- </option>
- <?php endforeach; ?>
- </select> <input name="dstbeginport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstbeginport']) echo $pconfig['dstbeginport']; ?>"></td>
- </tr>
- <tr>
- <td>to:</td>
- <td><select name="dstendport" class="formselect" onchange="ext_change()">
- <option value="">(other)</option>
- <option value="any" <?php $bfound = 0; if ($pconfig['dstendport'] == "any") { echo "selected"; $bfound = 1; } ?>>any</option>
- <?php foreach ($wkports as $wkport => $wkportdesc): ?>
- <option value="<?=$wkport;?>" <?php if ($wkport == $pconfig['dstendport']) {
- echo "selected";
- $bfound = 1;
- }?>>
- <?=htmlspecialchars($wkportdesc);?>
- </option>
- <?php endforeach; ?>
- </select> <input name="dstendport_cust" type="text" size="5" value="<?php if (!$bfound && $pconfig['dstendport']) echo $pconfig['dstendport']; ?>"></td>
- </tr>
- </table>
- <br> <span class="vexpl">Specify the port or port range for
- the destination of the packet for this rule.<br>
- Hint: you can leave the <em>'to'</em> field empty if you only
- want to filter a single port</span></td>
- <tr>
- <td valign="top" class="vncell">Direction</td>
- <td class="vtable"> <select name="direction" class="formselect">
- <option value="" <?php if (!$pconfig['direction']) echo "selected"; ?>>any</option>
- <option value="in" <?php if ($pconfig['direction'] == "in") echo "selected"; ?>>in</option>
- <option value="out" <?php if ($pconfig['direction'] == "out") echo "selected"; ?>>out</option>
- </select> <br>
- Use this to match only packets travelling in a given direction
- on the interface specified above (as seen from the firewall's
- perspective). </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">IP Type of Service (TOS)</td>
- <td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
- <?php
- $iniptos = explode(",", $pconfig['iptos']);
- foreach ($iptos as $tos): $dontcare = true; ?>
- <tr>
- <td width="80" nowrap><strong>
- <?echo $tos;?>
- </strong></td>
- <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="on" <?php if (array_search($tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
- yes&nbsp;&nbsp;&nbsp;</td>
- <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="off" <?php if (array_search("!" . $tos, $iniptos) !== false) { echo "checked"; $dontcare = false; }?>>
- no&nbsp;&nbsp;&nbsp;</td>
- <td nowrap> <input type="radio" name="iptos_<?=$tos;?>" value="" <?php if ($dontcare) echo "checked";?>>
- don't care</td>
- </tr>
- <?php endforeach; ?>
- </table>
- <span class="vexpl">Use this to match packets according to their IP TOS values.
- </span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">IP packet length</td>
- <td width="78%" class="vtable"><input name="iplen" type="text" id="iplen" size="10" value="<?=htmlspecialchars($pconfig['iplen']);?>">
- <br>
- Setting this makes the rule match packets of a given length
- (either a single value or a range in the syntax <em>from-to</em>,
- e.g. 0-80). </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">TCP flags</td>
- <td width="78%" class="vtable"> <table border="0" cellspacing="0" cellpadding="0">
- <?php
- $inflags = explode(",", $pconfig['tcpflags']);
- foreach ($tcpflags as $tcpflag): $dontcare = true; ?>
- <tr>
- <td width="40" nowrap><strong>
- <?=strtoupper($tcpflag);?>
- </strong></td>
- <td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="on" <?php if (array_search($tcpflag, $inflags) !== false) { echo "checked"; $dontcare = false; }?>>
- set&nbsp;&nbsp;&nbsp;</td>
- <td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="off" <?php if (array_search("!" . $tcpflag, $inflags) !== false) { echo "checked"; $dontcare = false; }?>>
- cleared&nbsp;&nbsp;&nbsp;</td>
- <td nowrap> <input type="radio" name="tcpflags_<?=$tcpflag;?>" value="" <?php if ($dontcare) echo "checked";?>>
- don't care</td>
- </tr>
- <?php endforeach; ?>
- </table>
- <span class="vexpl">Use this to choose TCP flags that must
- be set or cleared for this rule to match.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable"> <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
- <br> <span class="vexpl">You may enter a description here
- for your reference (not parsed).</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save">
- <?php if (isset($id) && $a_shaper[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>">
- <?php endif; ?>
- <input name="after" type="hidden" value="<?=$after;?>">
- </td>
- </tr>
- </table>
-</form>
-<script language="JavaScript">
-<!--
-ext_change();
-typesel_change();
-proto_change();
-//-->
-</script>
-<?php else: ?>
-<p><strong>You need to create a pipe or queue before you can add a new rule.</strong></p>
-<?php endif; ?>
-
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/m0n0/firewall_shaper_magic.php b/usr/local/www/m0n0/firewall_shaper_magic.php
deleted file mode 100755
index f4f25c1..0000000
--- a/usr/local/www/m0n0/firewall_shaper_magic.php
+++ /dev/null
@@ -1,418 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_magic.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2004 Justin Ellison <justin@techadvise.com>
- Copyright (C) 2004 Dinesh Nair <dinesh@alphaque.com>
-
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-function wipe_magic () {
- global $config;
-
- /* wipe previous */
- $types=array("pipe","queue","rule");
- foreach ($types as $type) {
- foreach (array_keys($config['shaper'][$type]) as $num) {
- if (substr($config['shaper'][$type][$num]['descr'],0,2) == "m_") {
- unset($config['shaper'][$type][$num]);
- }
- }
- }
- /* Although we don't delete user-defined rules, it's probably best to
- disable the shaper to prevent bad things from happening */
- $config['shaper']['enable'] = FALSE;
-}
-
-function populate_p2p(&$rulei) {
- global $config;
-
- /* To add p2p clients, push Descr,Protocol,Start,End,src/dest/both onto p2plist */
- $p2plist[] = array('BitTorrent','tcp','6881','6999','both');
- $p2plist[] = array('DirectConnect','','412','412','both');
- $p2plist[] = array('DirectFileExpress','','1044','1045','both');
- $p2plist[] = array('FastTrack','','1214','1214','both');
- $p2plist[] = array('CuteMX','','2340','2340','both');
- $p2plist[] = array('iMest','','4329','4329','both');
- $p2plist[] = array('EDonkey2000','','4661','4665','both');
- $p2plist[] = array('SongSpy','','5190','5190','both');
- $p2plist[] = array('HotlineConnect','','5500','5503','both');
- $p2plist[] = array('Gnutella','','6346','6346','both');
- $p2plist[] = array('dcc','','6666','6668','both');
- $p2plist[] = array('Napster','','6699','6701','both');
- $p2plist[] = array('Aimster','','7668','7668','both');
- $p2plist[] = array('BuddyShare','','7788','7788','both');
- $p2plist[] = array('Scour','','8311','8311','both');
- $p2plist[] = array('OpenNap','','8888','8889','both');
- $p2plist[] = array('hotComm','','28864','28865','both');
-
- /* Set up/down p2p as lowest weight */
- $direction = array("in","out");
- foreach ($p2plist as $p2pclient) {
- foreach ($direction as $dir) {
- foreach (array('source','destination') as $srcdest) {
- if (($p2pclient[4] == $srcdest) || ($p2pclient[4] == 'both')) {
- $config['shaper']['rule'][$rulei]['descr'] = "m_P2P $p2pclient[0]";
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "$dir";
- $config['shaper']['rule'][$rulei]['source']['any'] = 1;
- $config['shaper']['rule'][$rulei]['destination']['any'] = 1;
- $config['shaper']['rule'][$rulei][$srcdest]['port'] = $p2pclient[2]."-".$p2pclient[3];
- if($p2pclient[1] != '')
- $config['shaper']['rule'][$rulei]['protocol'] = $p2pclient[1];
- if ($dir == "out") {
- $config['shaper']['rule'][$rulei]['targetqueue'] = 4;
- } else {
- $config['shaper']['rule'][$rulei]['targetqueue'] = 6;
- }
- $rulei++;
- }
- }
- }
- }
-}
-
-function create_magic ($maxup, $maxdown, $p2plow,$maskq) {
- global $config;
-
- $config['shaper']['enable'] = TRUE;
- $pipei = 0;
- $queuei = 0;
- $rulei = 0;
-
- /* Create new pipes */
- $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Upload";
- $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxup * .90);
- $pipei++;
- $config['shaper']['pipe'][$pipei]['descr'] = "m_Total Download";
- $config['shaper']['pipe'][$pipei]['bandwidth'] = round($maxdown * .95);
- $pipei++;
-
- /* Create new queues */
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #1 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 50;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #2 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 30;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority #3 Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 15;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 4;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Upload";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 0;
- $config['shaper']['queue'][$queuei]['weight'] = 1;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Bulk Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 30;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_Hated Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 10;
- $queuei++;
- $config['shaper']['queue'][$queuei]['descr'] = "m_High Priority Download";
- $config['shaper']['queue'][$queuei]['targetpipe'] = 1;
- $config['shaper']['queue'][$queuei]['weight'] = 60;
- $queuei++;
- if ($maskq) {
- for ($i = 0; $i < $queuei; $i++) {
- if (stristr($config['shaper']['queue'][$i]['descr'],"upload")) {
- $config['shaper']['queue'][$i]['mask'] = 'source';
- } else if (stristr($config['shaper']['queue'][$i]['descr'],"download")) {
- $config['shaper']['queue'][$i]['mask'] = 'destination';
- }
- }
- }
-
- /* Create new rules */
- if ($p2plow)
- populate_p2p($rulei);
-
- $config['shaper']['rule'][$rulei]['descr'] = "m_TCP ACK Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 2;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-80";
- $config['shaper']['rule'][$rulei]['protocol'] = "tcp";
- $config['shaper']['rule'][$rulei]['tcpflags'] = "ack";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Outbound DNS Query";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['port'] = 53;
- $config['shaper']['rule'][$rulei]['protocol'] = "udp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_AH Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "ah";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "esp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 0;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "gre";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 1;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Upload";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 3;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "out";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ICMP Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "icmp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Small Pkt Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['iplen'] = "0-100";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_AH Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "ah";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_ESP Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "esp";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_GRE Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 7;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['protocol'] = "gre";
- $rulei++;
- $config['shaper']['rule'][$rulei]['descr'] = "m_Catch-All Download";
- $config['shaper']['rule'][$rulei]['targetqueue'] = 5;
- $config['shaper']['rule'][$rulei]['interface'] = "wan";
- $config['shaper']['rule'][$rulei]['direction'] = "in";
- $config['shaper']['rule'][$rulei]['source']['any'] = TRUE;
- $config['shaper']['rule'][$rulei]['destination']['any'] = TRUE;
- $rulei++;
-}
-
-if (!is_array($config['shaper']['rule'])) {
- $config['shaper']['rule'] = array();
-}
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-
-$a_shaper = &$config['shaper']['rule'];
-$a_queues = &$config['shaper']['queue'];
-$a_pipes = &$config['shaper']['pipe'];
-
-$pconfig['p2plow'] = isset($config['shaper']['magic']['p2plow']);
-$pconfig['maskq'] = isset($config['shaper']['magic']['maskq']);
-$pconfig['maxup'] = $config['shaper']['magic']['maxup'];
-$pconfig['maxdown'] = $config['shaper']['magic']['maxdown'];
-
-if ($_POST) {
-
- if ($_POST['install']) {
- unset($input_errors);
- $pconfig = $_POST;
- $reqdfields = explode(" ", "maxup maxdown");
- $reqdfieldsn = explode(",", "Max. Upload,Max.Download");
- do_input_validation($_POST,$reqdfields, $reqdfieldsn, &$input_errors);
- if (($_POST['maxup'] && !is_int($_POST['maxup']))) {
- //$input_errors[] = "The max upload bandwidth must be an integer.";
- }
- if (($_POST['maxdown'] && !is_int($_POST['maxdown']))) {
- //$input_errors[] = "The max download bandwidth must be an integer.";
- }
- if (!$input_errors) {
- if ($_POST['install']) {
- unset ($config['shaper']);
- create_magic($_POST['maxup'],$_POST['maxdown'],$_POST['p2plow']?TRUE:FALSE,$_POST['maskq']?TRUE:FALSE);
- touch($d_shaperconfdirty_path);
- }
- $config['shaper']['magic']['p2plow'] = $_POST['p2plow'] ? TRUE : FALSE;
- $config['shaper']['magic']['maskq'] = $_POST['maskq'] ? TRUE : FALSE;
- $config['shaper']['magic']['maxup'] = $_POST['maxup'];
- $config['shaper']['magic']['maxdown'] = $_POST['maxdown'];
- write_config();
- }
- }
- if ($_POST['remove']) {
- wipe_magic();
- $note = '<p><span class="red"><strong>Note: The traffic shaper has been disabled.<br>All of your user-defined rules/pipes/queues are still intact.</strong></span><strong><br>';
- touch($d_shaperconfdirty_path);
- write_config();
- }
- if ($_POST['apply']) {
- $retval = 0;
- if (!file_exists($d_sysrebootreqd_path)) {
- config_lock();
- require_once("m0n0/shaper.inc");
- $retval = shaper_configure();
- config_unlock();
- }
- $savemsg = get_std_save_message($retval);
- if ($retval == 0) {
- if (file_exists($d_shaperconfdirty_path))
- unlink($d_shaperconfdirty_path);
- }
- }
-}
-
-$pgtitle = "Firewall: Traffic Shaper: Magic Shaper Wizard";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<form action="firewall_shaper_magic.php" method="post">
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
-<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.$note");?><br>
-</p>
-<?php endif; ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
- <ul id="tabnav">
- <li class="tabinact1"><a href="firewall_shaper.php">Rules</a></li>
- <li class="tabinact"><a href="firewall_shaper_pipes.php">Pipes</a></li>
- <li class="tabinact"><a href="firewall_shaper_queues.php">Queues</a></li>
- <li class="tabact">Magic shaper wizard</li>
- </ul>
- </td></tr>
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="p2plow" type="checkbox" id="p2plow" value="yes" <?php if ($pconfig['p2plow']) echo "checked";?>>
- Set P2P traffic to lowest priority</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vtable">&nbsp;</td>
- <td width="78%" class="vtable">
- <input name="maskq" type="checkbox" id="maskq" value="yes" <?php if ($pconfig['maskq']) echo "checked";?>>
- Share bandwidth evenly on LAN</td>
- </tr>
- <tr valign="top">
- <td width="22%" class="vncellreq">Downstream<br>
- speed </td>
- <td width="78%" class="vtable">
- <?=$mandfldhtml;?><input name="maxdown" type="text" size="10" value="<?php if ($pconfig['maxdown']) echo $pconfig['maxdown']; ?>">
- kbps<br>
- Enter the speed of your WAN downstream link here.</td>
- </tr>
- <tr valign="top">
- <td width="22%" class="vncellreq">Upstream<br>
- speed</td>
- <td width="78%" class="vtable"><?=$mandfldhtml;?><input name="maxup" type="text" size="10" value="<?php if ($pconfig['maxup']) echo $pconfig['maxup']; ?>">
- kbps<br>
- Enter the speed of your WAN upstream link here.</td>
- </tr>
- <tr>
- <td width="22%">&nbsp;</td>
- <td width="78%">
- <input name="install" type="submit" class="formbtn" id="install" value="Install/Update">
- &nbsp;
- <input name="remove" type="submit" class="formbtn" id="remove" value="Remove">
- <br><br>
- <span class="red"><strong>All existing traffic shaper <strong>rules</strong>/pipes/queues will be deleted once "Install/Update" has been pressed! Backup your configuration before proceeding! </strong></span></td>
- </tr>
- </table><br>
- <span class="vexpl"><span class="red"><strong>Note:</strong></span><strong><br>
- </strong>By entering your maximum upload and download values and pressing the "Install/Update" button, the magic shaper will do its best to create the optimum shaping rules, queues, and pipes for you. These rules will help ensure that interactive traffic remains acceptable while the upstream bandwidth is being consumed by heavy traffic.</span>
- </td>
- </tr>
-</table>
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/m0n0/firewall_shaper_pipes.php b/usr/local/www/m0n0/firewall_shaper_pipes.php
deleted file mode 100755
index aefc307..0000000
--- a/usr/local/www/m0n0/firewall_shaper_pipes.php
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_pipes.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_pipes = &$config['shaper']['pipe'];
-
-if ($_GET['act'] == "del") {
- if ($a_pipes[$_GET['id']]) {
- /* check that no rule references this pipe */
- if (is_array($config['shaper']['rule'])) {
- foreach ($config['shaper']['rule'] as $rule) {
- if (isset($rule['targetpipe']) && ($rule['targetpipe'] == $_GET['id'])) {
- $input_errors[] = "This pipe cannot be deleted because it is still referenced by a rule.";
- break;
- }
- }
- }
-
- /* check that no queue references this pipe */
- if (is_array($config['shaper']['queue'])) {
- foreach ($config['shaper']['queue'] as $queue) {
- if ($queue['targetpipe'] == $_GET['id']) {
- $input_errors[] = "This pipe cannot be deleted because it is still referenced by a queue.";
- break;
- }
- }
- }
-
- if (!$input_errors) {
- unset($a_pipes[$_GET['id']]);
-
- /* renumber all rules and queues */
- if (is_array($config['shaper']['rule'])) {
- for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
- $currule = &$config['shaper']['rule'][$i];
- if (isset($currule['targetpipe']) && ($currule['targetpipe'] > $_GET['id']))
- $currule['targetpipe']--;
- }
- }
- if (is_array($config['shaper']['queue'])) {
- for ($i = 0; isset($config['shaper']['queue'][$i]); $i++) {
- $curqueue = &$config['shaper']['queue'][$i];
- if ($curqueue['targetpipe'] > $_GET['id'])
- $curqueue['targetpipe']--;
- }
- }
-
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper_pipes.php");
- exit;
- }
- }
-}
-$pgtitle = "Firewall: Traffic Shaper - Pipes";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<form action="firewall_shaper.php" method="post">
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
-<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
-</p>
-<?php endif; ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
- <ul id="tabnav">
- <li class="tabinact1"><a href="firewall_shaper.php">Rules</a></li>
- <li class="tabact">Pipes</li>
- <li class="tabinact"><a href="firewall_shaper_queues.php">Queues</a></li>
- <li class="tabinact"><a href="firewall_shaper_magic.php">Magic shaper wizard</a></li>
- </ul>
- </td></tr>
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="10%" class="listhdrr">No.</td>
- <td width="15%" class="listhdrr">Bandwidth</td>
- <td width="10%" class="listhdrr">Delay</td>
- <td width="10%" class="listhdrr">PLR</td>
- <td width="10%" class="listhdrr">Queue</td>
- <td width="15%" class="listhdrr">Mask</td>
- <td width="20%" class="listhdr">Description</td>
- <td width="10%" class="list"></td>
- </tr>
- <?php $i = 0; foreach ($a_pipes as $pipe): ?>
- <tr valign="top">
- <td class="listlr">
- <?=($i+1);?></td>
- <td class="listr">
- <?=htmlspecialchars($pipe['bandwidth']);?>
- Kbit/s </td>
- <td class="listr">
- <?php if ($pipe['delay']): ?>
- <?=$pipe['delay'];?>
- ms
- <?php endif; ?>
- &nbsp; </td>
- <td class="listr">
- <?php if ($pipe['plr']): ?>
- <?=$pipe['plr'];?>
- <?php endif; ?>
- &nbsp; </td>
- <td class="listr">
- <?php if ($pipe['qsize']): ?>
- <?=htmlspecialchars($pipe['qsize']);?>
- <?php endif; ?>
- &nbsp; </td>
- <td class="listr">
- <?php if ($pipe['mask']): ?>
- <?=$pipe['mask'];?>
- <?php endif; ?>
- &nbsp; </td>
- <td class="listbg">
- <font color="#ffffff">
- <?=htmlspecialchars($pipe['descr']);?>
- &nbsp; </td>
- <td valign="middle" nowrap class="list"> <a href="firewall_shaper_pipes_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit pipe" width="17" height="17" border="0"></a>
- &nbsp;<a href="firewall_shaper_pipes.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this pipe?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete pipe" width="17" height="17" border="0"></a></td>
- </tr>
- <?php $i++; endforeach; ?>
- <tr>
- <td class="list" colspan="7"></td>
- <td class="list"> <a href="firewall_shaper_pipes_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add pipe" width="17" height="17" border="0"></a></td>
- </tr>
- </table><br>
- <strong><span class="red">Note:</span></strong> a pipe can
- only be deleted if it is not referenced by any rules or queues.</td>
- </tr>
-</table>
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/m0n0/firewall_shaper_pipes_edit.php b/usr/local/www/m0n0/firewall_shaper_pipes_edit.php
deleted file mode 100755
index d9cf01f..0000000
--- a/usr/local/www/m0n0/firewall_shaper_pipes_edit.php
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_pipes_edit.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper", "Edit pipe");
-require("guiconfig.inc");
-
-$a_pipes = &$config['shaper']['pipe'];
-
-$id = $_GET['id'];
-if (isset($_POST['id']))
- $id = $_POST['id'];
-
-if (isset($id) && $a_pipes[$id]) {
- $pconfig['bandwidth'] = $a_pipes[$id]['bandwidth'];
- $pconfig['delay'] = $a_pipes[$id]['delay'];
- $pconfig['plr'] = $a_pipes[$id]['plr'];
- $pconfig['qsize'] = $a_pipes[$id]['qsize'];
- $pconfig['mask'] = $a_pipes[$id]['mask'];
- $pconfig['descr'] = $a_pipes[$id]['descr'];
-}
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "bandwidth");
- $reqdfieldsn = explode(",", "Bandwidth");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (($_POST['bandwidth'] && !is_int($_POST['bandwidth']))) {
- $input_errors[] = "The bandwidth must be an integer.";
- }
- if (($_POST['delay'] && !is_int($_POST['delay']))) {
- $input_errors[] = "The delay must be an integer.";
- }
- if ($_POST['plr'] && (!is_numeric($_POST['plr']) || $_POST['plr'] < 0 || $_POST['plr'] > 1)) {
- $input_errors[] = "The packet loss rate must be a number between 0 and 1.";
- }
- if ($_POST['qsize'] && (!is_int($_POST['qsize']) || $_POST['qsize'] < 2 || $_POST['qsize'] > 100)) {
- $input_errors[] = "The queue size must be an integer between 2 and 100.";
- }
-
- if (!$input_errors) {
- $pipe = array();
-
- $pipe['bandwidth'] = $_POST['bandwidth'];
- if ($_POST['delay'])
- $pipe['delay'] = $_POST['delay'];
- if ($_POST['plr'])
- $pipe['plr'] = $_POST['plr'];
- if ($_POST['qsize'])
- $pipe['qsize'] = $_POST['qsize'];
- if ($_POST['mask'])
- $pipe['mask'] = $_POST['mask'];
- $pipe['descr'] = $_POST['descr'];
-
- if (isset($id) && $a_pipes[$id])
- $a_pipes[$id] = $pipe;
- else
- $a_pipes[] = $pipe;
-
- write_config();
- touch($d_shaperconfdirty_path);
-
- header("Location: firewall_shaper_pipes.php");
- exit;
- }
-}
-
-$pgtitle = "Firewall: Traffic Shaper - Pipes Edit";
-include("head.inc");
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
- <form action="firewall_shaper_pipes_edit.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td width="22%" valign="top" class="vncellreq">Bandwidth</td>
- <td width="78%" class="vtable"><?=$mandfldhtml;?><input name="bandwidth" type="text" id="bandwidth" size="5" value="<?=htmlspecialchars($pconfig['bandwidth']);?>">
- &nbsp;Kbit/s</td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Delay</td>
- <td width="78%" class="vtable"> <input name="delay" type="text" id="delay" size="5" value="<?=htmlspecialchars($pconfig['delay']);?>">
- &nbsp;ms<br> <span class="vexpl">Hint: in most cases, you
- should specify 0 here (or leave the field empty)</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Packet loss rate</td>
- <td width="78%" class="vtable"> <input name="plr" type="text" id="plr" size="5" value="<?=htmlspecialchars($pconfig['plr']);?>">
- <br> <span class="vexpl">Hint: in most cases, you
- should specify 0 here (or leave the field empty). A value of 0.001 means one packet in 1000 gets dropped.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Queue size</td>
- <td width="78%" class="vtable"> <input name="qsize" type="text" id="qsize" size="8" value="<?=htmlspecialchars($pconfig['qsize']);?>">
- &nbsp;slots<br>
- <span class="vexpl">Hint: in most cases, you
- should leave the field empty. All packets in this pipe are placed into a fixed-size queue first,
- then they are delayed by value specified in the Delay field, and then they are delivered to their destination.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Mask</td>
- <td width="78%" class="vtable"> <select name="mask" class="formselect">
- <option value="" <?php if (!$pconfig['mask']) echo "selected"; ?>>none</option>
- <option value="source" <?php if ($pconfig['mask'] == "source") echo "selected"; ?>>source</option>
- <option value="destination" <?php if ($pconfig['mask'] == "destination") echo "selected"; ?>>destination</option>
- </select> <br>
- <span class="vexpl">If 'source' or 'destination' is chosen,
- a dynamic pipe with the bandwidth, delay, packet loss and queue size given above will
- be created for each source/destination IP address encountered,
- respectively. This makes it possible to easily specify bandwidth
- limits per host.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable"> <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
- <br> <span class="vexpl">You may enter a description here
- for your reference (not parsed).</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save">
- <?php if (isset($id) && $a_pipes[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>">
- <?php endif; ?>
- </td>
- </tr>
- </table>
-
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
-
diff --git a/usr/local/www/m0n0/firewall_shaper_queues.php b/usr/local/www/m0n0/firewall_shaper_queues.php
deleted file mode 100755
index 85f2525..0000000
--- a/usr/local/www/m0n0/firewall_shaper_queues.php
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_queues.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper");
-require("guiconfig.inc");
-
-if (!is_array($config['shaper']['pipe'])) {
- $config['shaper']['pipe'] = array();
-}
-if (!is_array($config['shaper']['queue'])) {
- $config['shaper']['queue'] = array();
-}
-$a_queues = &$config['shaper']['queue'];
-$a_pipe = &$config['shaper']['pipe'];
-
-if ($_GET['act'] == "del") {
- if ($a_queues[$_GET['id']]) {
- /* check that no rule references this queue */
- if (is_array($config['shaper']['rule'])) {
- foreach ($config['shaper']['rule'] as $rule) {
- if (isset($rule['targetqueue']) && ($rule['targetqueue'] == $_GET['id'])) {
- $input_errors[] = "This queue cannot be deleted because it is still referenced by a rule.";
- break;
- }
- }
- }
-
- if (!$input_errors) {
- unset($a_queues[$_GET['id']]);
-
- /* renumber all rules */
- if (is_array($config['shaper']['rule'])) {
- for ($i = 0; isset($config['shaper']['rule'][$i]); $i++) {
- $currule = &$config['shaper']['rule'][$i];
- if (isset($currule['targetqueue']) && ($currule['targetqueue'] > $_GET['id']))
- $currule['targetqueue']--;
- }
- }
-
- write_config();
- touch($d_shaperconfdirty_path);
- header("Location: firewall_shaper_queues.php");
- exit;
- }
- }
-}
-
-$pgtitle = "Firewall: Traffic Shaper - Queues";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<form action="firewall_shaper.php" method="post">
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if ($savemsg) print_info_box($savemsg); ?>
-<?php if (file_exists($d_shaperconfdirty_path)): ?><p>
-<?php print_info_box_np("The traffic shaper configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
-</p>
-<?php endif; ?>
-<table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr><td class="tabnavtbl">
- <ul id="tabnav">
- <li class="tabinact1"><a href="firewall_shaper.php">Rules</a></li>
- <li class="tabinact"><a href="firewall_shaper_pipes.php">Pipes</a></li>
- <li class="tabact">Queues</li>
- <li class="tabinact"><a href="firewall_shaper_magic.php">Magic shaper wizard</a></li>
- </ul>
- </td></tr>
- <tr>
- <td class="tabcont">
- <table width="100%" border="0" cellpadding="0" cellspacing="0">
- <tr>
- <td width="10%" class="listhdrr">No.</td>
- <td width="25%" class="listhdrr">Pipe</td>
- <td width="5%" class="listhdrr">Weight</td>
- <td width="20%" class="listhdrr">Mask</td>
- <td width="30%" class="listhdr">Description</td>
- <td width="10%" class="list"></td>
- </tr>
- <?php $i = 0; foreach ($a_queues as $queue): ?>
- <tr valign="top">
- <td class="listlr">
- <?=($i+1);?></td>
- <td class="listr">
- <?php
- if ($a_pipe[$queue['targetpipe']]['descr'])
- $desc = htmlspecialchars($a_pipe[$queue['targetpipe']]['descr']);
- else
- $desc = "Pipe " . ($queue['targetpipe']+1);
- ?>
- <a href="firewall_shaper_pipes_edit.php?id=<?=$queue['targetpipe'];?>"><?=$desc;?></a></td>
- <td class="listr">
- <?=$queue['weight'];?></td>
- <td class="listr">
- <?php if ($queue['mask']): ?>
- <?=$queue['mask'];?>
- <?php endif; ?>
- &nbsp; </td>
- <td class="listbg">
- <font color="#ffffff">
- <?=htmlspecialchars($queue['descr']);?>
- &nbsp; </td>
- <td valign="middle" nowrap class="list"> <a href="firewall_shaper_queues_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit queue" width="17" height="17" border="0"></a>
- &nbsp;<a href="firewall_shaper_queues.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this queue?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete queue" width="17" height="17" border="0"></a></td>
- </tr>
- <?php $i++; endforeach; ?>
- <tr>
- <td class="list" colspan="5"></td>
- <td class="list"> <a href="firewall_shaper_queues_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add queue" width="17" height="17" border="0"></a></td>
- </tr>
- </table><br>
- <strong><span class="red">Note:</span></strong> a queue can
- only be deleted if it is not referenced by any rules.</td>
- </tr>
-</table>
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
diff --git a/usr/local/www/m0n0/firewall_shaper_queues_edit.php b/usr/local/www/m0n0/firewall_shaper_queues_edit.php
deleted file mode 100755
index efa9ea4..0000000
--- a/usr/local/www/m0n0/firewall_shaper_queues_edit.php
+++ /dev/null
@@ -1,157 +0,0 @@
-#!/usr/local/bin/php
-<?php
-/*
- firewall_shaper_queues_edit.php
- part of m0n0wall (http://m0n0.ch/wall)
-
- Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- 1. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-*/
-
-$pgtitle = array("Firewall", "Traffic shaper", "Edit queue");
-require("guiconfig.inc");
-
-$a_queues = &$config['shaper']['queue'];
-
-$id = $_GET['id'];
-if (isset($_POST['id']))
- $id = $_POST['id'];
-
-if (isset($id) && $a_queues[$id]) {
- $pconfig['targetpipe'] = $a_queues[$id]['targetpipe'];
- $pconfig['weight'] = $a_queues[$id]['weight'];
- $pconfig['mask'] = $a_queues[$id]['mask'];
- $pconfig['descr'] = $a_queues[$id]['descr'];
-}
-
-if ($_POST) {
-
- unset($input_errors);
- $pconfig = $_POST;
-
- /* input validation */
- $reqdfields = explode(" ", "weight");
- $reqdfieldsn = explode(",", "Weight");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if ($_POST['weight'] && (!is_int($_POST['weight'])
- || ($_POST['weight'] < 1) || ($_POST['weight'] > 100))) {
- $input_errors[] = "The weight must be an integer between 1 and 100.";
- }
-
- if (!$input_errors) {
- $queue = array();
-
- $queue['targetpipe'] = $_POST['targetpipe'];
- $queue['weight'] = $_POST['weight'];
- if ($_POST['mask'])
- $queue['mask'] = $_POST['mask'];
- $queue['descr'] = $_POST['descr'];
-
- if (isset($id) && $a_queues[$id])
- $a_queues[$id] = $queue;
- else
- $a_queues[] = $queue;
-
- write_config();
- touch($d_shaperconfdirty_path);
-
- header("Location: firewall_shaper_queues.php");
- exit;
- }
-}
-$pgtitle = "Firewall: Traffic Shaper: Queues Edit";
-include("head.inc");
-
-?>
-<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
-<?php include("fbegin.inc"); ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if (is_array($config['shaper']['pipe']) && (count($config['shaper']['pipe']) > 0)): ?>
- <form action="firewall_shaper_queues_edit.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td valign="top" class="vncellreq">Pipe</td>
- <td class="vtable"><select name="targetpipe" class="formselect">
- <?php
- foreach ($config['shaper']['pipe'] as $pipei => $pipe): ?>
- <option value="<?=$pipei;?>" <?php if ($pipei == $pconfig['targetpipe']) echo "selected"; ?>>
- <?php
- echo htmlspecialchars("Pipe " . ($pipei + 1));
- if ($pipe['descr'])
- echo htmlspecialchars(" (" . $pipe['descr'] . ")");
- ?>
- </option>
- <?php endforeach; ?>
- </select> <br>
- <span class="vexpl">Choose the pipe that this queue is linked
- to.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Weight</td>
- <td width="78%" class="vtable"><?=$mandfldhtml;?><input name="weight" type="text" id="weight" size="5" value="<?=htmlspecialchars($pconfig['weight']);?>">
- <br> <span class="vexpl">Valid range: 1..100.<br>
- All backlogged (i.e., with packets queued) queues linked to
- the same pipe share the pipe's bandwidth proportionally to
- their weights (higher weight = higher share of bandwidth).
- Note that weights are not priorities; a queue with a lower
- weight is still guaranteed to get its fraction of the bandwidth
- even if a queue with a higher weight is permanently backlogged.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Mask</td>
- <td width="78%" class="vtable"> <select name="mask" class="formselect">
- <option value="" <?php if (!$pconfig['mask']) echo "selected"; ?>>none</option>
- <option value="source" <?php if ($pconfig['mask'] == "source") echo "selected"; ?>>source</option>
- <option value="destination" <?php if ($pconfig['mask'] == "destination") echo "selected"; ?>>destination</option>
- </select> <br> <span class="vexpl">If 'source' or 'destination'
- is chosen, a dynamic queue associated with the pipe and with
- the weight given above will be created for each source/destination
- IP address encountered, respectively.</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Description</td>
- <td width="78%" class="vtable"> <input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
- <br> <span class="vexpl">You may enter a description here
- for your reference (not parsed).</span></td>
- </tr>
- <tr>
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%"> <input name="Submit" type="submit" class="formbtn" value="Save">
- <?php if (isset($id) && $a_queues[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>">
- <?php endif; ?>
- </td>
- </tr>
- </table>
-<?php else: ?>
-<p><strong>You need to create a pipe before you can add a new queue.</strong></p>
-<?php endif; ?>
-</form>
-<?php include("fend.inc"); ?>
-</body>
-</html>
-
OpenPOWER on IntegriCloud