#!/usr/local/bin/php . 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", "Rules"); 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(); $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; } } ?>

You must apply the changes in order for them to take effect.");?>

    'firewall_shaper.php', 'Pipes' => 'firewall_shaper_pipes.php', 'Queues' => 'firewall_shaper_queues.php', 'Magic shaper wizard' => 'firewall_shaper_magic.php'); dynamic_tab_menu($tabs); ?>
> Enable traffic shaper
 
If Proto Source Destination Target Description
"; $textse = ""; } else { $textss = $textse = ""; } $iflabels = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP'); for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) $iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr']; echo $textss . htmlspecialchars($iflabels[$shaperent['interface']]); echo "
"; echo ""; if ($shaperent['direction'] != "in") echo ""; if ($shaperent['direction'] != "out") echo ""; echo "" . $textse;; ?>

Port:

Port:
{$desc}"; } 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 "{$desc}"; } ?>   edit rule 0): ?> move up
delete rule move down add a new rule based on this one
add rule
incoming (as seen by firewall) outgoing (as seen by firewall)
incoming (disabled) outgoing (disabled)

Note:
the first rule that matches a packet will be executed.
The following match patterns are not shown in the list above: IP packet length, TCP flags.