From 648ec0c2fcb75be8c9eb838b97bf677d963952b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ermal=20Lu=C3=A7i?= Date: Fri, 25 Jul 2008 15:55:24 +0000 Subject: Implement Bridge interfaces with full options available. Much improvement over how we do brigding currently. Remaining is lagg(4) from the list on clone interfaces as far as i am concerned. --- usr/local/www/interfaces_bridge.php | 135 ++++++++ usr/local/www/interfaces_bridge_edit.php | 554 +++++++++++++++++++++++++++++++ 2 files changed, 689 insertions(+) create mode 100644 usr/local/www/interfaces_bridge.php create mode 100644 usr/local/www/interfaces_bridge_edit.php (limited to 'usr/local') diff --git a/usr/local/www/interfaces_bridge.php b/usr/local/www/interfaces_bridge.php new file mode 100644 index 0000000..edfb979 --- /dev/null +++ b/usr/local/www/interfaces_bridge.php @@ -0,0 +1,135 @@ +
{$if}"; + return true; + } + } + + return false; +} + +if ($_GET['act'] == "del") { + /* check if still in use */ + if (bridge_inuse($_GET['id'])) { + $input_errors[] = "This bridge TUNNEL cannot be deleted because it is still being used as an interface."; + } else { + mwexec("/sbin/ifconfig " . $a_bridges[$_GET['id']]['bridgeif'] . " destroy"); + unset($a_bridges[$_GET['id']]); + + write_config(); + + header("Location: interfaces_bridge.php"); + exit; + } +} + + +$pgtitle = array("Interfaces","Bridge"); +include("head.inc"); + +?> + + + + + + + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
InterfaceMembersDescription
+ + + + + +   + + +  
 

+ Note:
+
+ Something meaningful here. +

 
+
+
+ + + diff --git a/usr/local/www/interfaces_bridge_edit.php b/usr/local/www/interfaces_bridge_edit.php new file mode 100644 index 0000000..1a1a7d5 --- /dev/null +++ b/usr/local/www/interfaces_bridge_edit.php @@ -0,0 +1,554 @@ +. + 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['bridges']['bridge'])) + $config['bridges']['bridge'] = array(); + +$a_bridges = &$config['bridges']['bridge']; + +$ifacelist = get_configured_interface_with_descr(); + +$id = $_GET['id']; +if (isset($_POST['id'])) + $id = $_POST['id']; + +if (isset($id) && $a_bridges[$id]) { + $pconfig['enablestp'] = isset($a_bridges[$id]['enablestp']); + $pconfig['descr'] = $a_bridges[$id]['descr']; + $pconfig['bridgeif'] = $a_bridges[$id]['bridgeif']; + $pconfig['members'] = $a_bridges[$id]['members']; + $pconfig['maxaddr'] = $a_bridges[$id]['maxaddr']; + $pconfig['timeout'] = $a_bridges[$id]['timeout']; + if ($a_bridges[$id]['static']) + $pconfig['static'] = $a_bridges[$id]['static']; + if ($a_bridges[$id]['private']) + $pconfig['private'] = $a_bridges[$id]['private']; + if (isset($a_bridges[$id]['stp'])) + $pconfig['stp'] = $a_bridges[$id]['stp']; + $pconfig['maxage'] = $a_bridges[$id]['maxage']; + $pconfig['fwdelay'] = $a_bridges[$id]['fwdelay']; + $pconfig['hellotime'] = $a_bridges[$id]['hellotime']; + $pconfig['priority'] = $a_bridges[$id]['priority']; + $pconfig['proto'] = $a_bridges[$id]['proto']; + $pconfig['holdcount'] = $a_bridges[$id]['holdcount']; + $pconfig['ifpriority'] = explode(",", $a_bridges[$id]['ifpriority']); + $ifpriority = array(); + foreach ($pconfig['ifpriority'] as $cfg) { + $embcfg = explode(":", $cfg); + foreach ($embcfg as $key => $value) + $ifpriority[$key] = $value; + } + $pconfig['ifpriority'] = $ifpriority; + $pconfig['ifpathcost'] = explode(",", $a_bridges[$id]['ifpathcost']); + $ifpathcost = array(); + foreach ($pconfig['ifpathcost'] as $cfg) { + $embcfg = explode(":", $cfg); + foreach ($embcfg as $key => $value) + $ifpathcost[$key] = $value; + } + $pconfig['ifpathcost'] = $ifpathcost; + $pconfig['span'] = $a_bridges[$id]['span']; + if (isset($a_bridges[$id]['edge'])) + $pconfig['edge'] = $a_bridges[$id]['edge']; + if (isset($a_bridges[$id]['autoedge'])) + $pconfig['autoedge'] = $a_bridges[$id]['autoedge']; + if (isset($a_bridges[$id]['ptp'])) + $pconfig['ptp'] = $a_bridges[$id]['ptp']; + if (isset($a_bridges[$id]['autoptp'])) + $pconfig['autoptp'] = $a_bridges[$id]['autoptp']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + $reqdfields = explode(" ", "members"); + $reqdfieldsn = explode(",", "Member Interfaces"); + + do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if ($_POST['maxage'] && !is_numeric($_POST['maxage'])) + $input_errors[] = "Maxage needs to be an interger between 6 and 40."; + if ($_POST['maxaddr'] && !is_numeric($_POST['maxaddr'])) + $input_errors[] = "Maxaddr needs to be an interger."; + if ($_POST['timeout'] && !is_numeric($_POST['timeout'])) + $input_errors[] = "Timeout needs to be an interger."; + if ($_POST['fwdelay'] && !is_numeric($_POST['fwdelay'])) + $input_errors[] = "Forward Delay needs to be an interger between 4 and 30."; + if ($_POST['hellotime'] && !is_numeric($_POST['hellotime'])) + $input_errors[] = "Hello time for STP needs to be an interger between 1 and 2."; + if ($_POST['priority'] && !is_numeric($_POST['priority'])) + $input_errors[] = "Priority for STP needs to be an interger between 0 and 61440."; + if ($_POST['holdcnt'] && !is_numeric($_POST['holdcnt'])) + $input_errors[] = "Transmit Hold Count for STP needs to be an interger between 1 and 10."; + foreach ($ifacelist as $ifn => $ifdescr) { + if ($_POST[$ifn] <> "" && !is_numeric($_POST[$ifn])) + $input_errors[] = "{$ifdescr} interface priority for STP needs to be an interger between 0 and 240."; + } + $i = 0; + foreach ($ifacelist as $ifn => $ifdescr) { + if ($_POST["{$ifn}{$i}"] <> "" && !is_numeric($_POST["{$ifn}{$i}"])) + $input_errors[] = "{$ifdescr} interface path cost for STP needs to be an interger between 1 and 200000000."; + $i++; + } + if (!$input_errors) { + $bridge = array(); + $bridge['members'] = implode(',', $_POST['members']); + $bridge['enablestp'] = isset($_POST['enablestp']); + $bridge['descr'] = $_POST['descr']; + $bridge['maxaddr'] = $_POST['maxaddr']; + $bridge['timeout'] = $_POST['timeout']; + if ($_POST['static']) + $bridge['static'] = implode(',', $_POST['static']); + if ($_POST['private']) + $bridge['private'] = implode(',', $_POST['private']); + if (isset($_POST['stp'])) + $bridge['stp'] = implode(',', $_POST['stp']); + $bridge['maxage'] = $_POST['maxage']; + $bridge['fwdelay'] = $_POST['fwdelay']; + $bridge['hellotime'] = $_POST['hellotime']; + $bridge['priority'] = $_POST['priority']; + $bridge['proto'] = $_POST['proto']; + $bridge['holdcount'] = $_POST['holdcount']; + $i = 0; + $ifpriority = ""; + $ifpathcost = ""; + foreach ($ifacelist as $ifn => $ifdescr) { + if ($_POST[$ifn] <> "") { + if ($i > 0) + $ifpriority .= ","; + $ifpriority .= $ifn.":".$_POST[$ifn]; + } + if ($_POST["{$ifn}{$i}"] <> "") { + if ($i > 0) + $ifpathcost .= ","; + $ifpathcost .= $ifn.":".$_POST[$ifn]; + } + $i++; + } + $bridge['ifpriority'] = $ifpriority; + $bridge['ifpathcost'] = $ifpathcost; + $bridge['span'] = $_POST['span']; + if (isset($_POST['edge'])) + $bridge['edge'] = implode(',', $_POST['edge']); + if (isset($_POST['autoedge'])) + $bridge['autoedge'] = implode(',', $_POST['autoedge']); + if (isset($_POST['ptp'])) + $bridge['ptp'] = implode(',', $_POST['ptp']); + if (isset($_POST['autoptp'])) + $bridge['autoptp'] = implode(',', $_POST['autoptp']); + + $bridge['bridgeif'] = $_POST['bridgeif']; + $bridge['bridgeif'] = interface_bridge_configure($bridge); + if ($bridge['bridgeif'] == "" || !stristr($bridge['bridgeif'], "bridge")) + $input_errors[] = "Error occured creating interface, please retry."; + else { + if (isset($id) && $a_bridges[$id]) + $a_bridges[$id] = $bridge; + else + $a_bridges[] = $bridge; + + write_config(); + + header("Location: interfaces_bridge.php"); + exit; + } + } +} + +$pgtitle = array("Firewall","Bridge","Edit"); +include("head.inc"); + +?> + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Member interfaces + +
+ Interfaces participating in the bridge. +
Description + +
+

+
  + + + + + +
+
+ + + -- cgit v1.1