summaryrefslogtreecommitdiffstats
path: root/usr
diff options
context:
space:
mode:
authorSeth Mos <seth.mos@xs4all.nl>2007-10-19 19:10:16 +0000
committerSeth Mos <seth.mos@xs4all.nl>2007-10-19 19:10:16 +0000
commitd173230c708d56ee9857dfff84779be36194d05d (patch)
treeacd24a5ce6cfbc2e8602298799a700d5de05e47e /usr
parent84b28297752c9a99fdd20a318ebea1b3314234e0 (diff)
downloadpfsense-d173230c708d56ee9857dfff84779be36194d05d.zip
pfsense-d173230c708d56ee9857dfff84779be36194d05d.tar.gz
Add prelimenary Routing page.
Allow multiple gateways on one (static) interface
Diffstat (limited to 'usr')
-rwxr-xr-xusr/local/www/fbegin.inc2
-rwxr-xr-xusr/local/www/interfaces.php54
-rwxr-xr-xusr/local/www/interfaces_opt.php56
-rwxr-xr-xusr/local/www/interfaces_wan.php54
-rwxr-xr-xusr/local/www/system_gateways.php176
-rwxr-xr-xusr/local/www/system_gateways_edit.php223
-rwxr-xr-xusr/local/www/system_routes.php43
-rwxr-xr-xusr/local/www/system_routes_edit.php53
8 files changed, 533 insertions, 128 deletions
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index 450c3ec..a0f2a18 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -127,7 +127,7 @@ require_once("notices.inc");
<li><a href="/pkg_mgr.php" class="navlnk">Packages</a></li>
<?php endif; ?>
<li><a href="/wizard.php?xml=setup_wizard.xml" class="navlnk">Setup wizard</a></li>
- <li><a href="/system_routes.php" class="navlnk">Static routes</a></li>
+ <li><a href="/system_gateways.php" class="navlnk">Routing</a></li>
<li><a href="/firewall_system_tunables.php" class="navlnk">Tunables</a></li>
<li><a href="/system_usermanager.php" class="navlnk">User Manager</a></li>
</ul>
diff --git a/usr/local/www/interfaces.php b/usr/local/www/interfaces.php
index d4dc2d1..7dcfefa 100755
--- a/usr/local/www/interfaces.php
+++ b/usr/local/www/interfaces.php
@@ -68,6 +68,10 @@ function getMPDResetTimeFromConfig() {
require("guiconfig.inc");
+if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+$a_gateways = &$config['gateways']['gateway_item'];
+
$wancfg = &$config['interfaces']['wan'];
$optcfg = &$config['interfaces']['wan'];
@@ -136,7 +140,6 @@ $pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinter
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
$pconfig['alias-address'] = $wancfg['alias-address'];
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
-$pconfig['use_rrd_gateway'] = $wancfg['use_rrd_gateway'];
if ($wancfg['ipaddr'] == "dhcp") {
$pconfig['type'] = "DHCP";
@@ -252,8 +255,15 @@ if ($_POST) {
if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
$input_errors[] = "A valid alias subnet bit count must be specified.";
}
- if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
- $input_errors[] = "A valid gateway must be specified.";
+ if ($_POST['gateway']) {
+ $match = false;
+ foreach($a_gateways as $gateway) {
+ if(in_array($_POST['gateway'], $gateway)) {
+ $match = true;
+ }
+ }
+ if(!$match)
+ $input_errors[] = "A valid gateway must be specified.";
}
if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
$input_errors[] = "A valid point-to-point IP address must be specified.";
@@ -264,9 +274,6 @@ if ($_POST) {
if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
$input_errors[] = "The idle timeout value must be an integer.";
}
- if (($_POST['use_rrd_gateway'] && !is_ipaddr($_POST['use_rrd_gateway']))) {
- $input_errors[] = "A valid monitor IP address must be specified.";
- }
if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
@@ -358,11 +365,6 @@ if ($_POST) {
system_start_ftp_helpers();
}
- /* per interface rrd gateway monitor helper */
- if($_POST['use_rrd_gateway'] <> "") {
- $wancfg['use_rrd_gateway'] = $_POST['use_rrd_gateway'];
- }
-
if ($_POST['type'] == "Static") {
$wancfg['ipaddr'] = $_POST['ipaddr'];
$wancfg['subnet'] = $_POST['subnet'];
@@ -788,7 +790,19 @@ function show_mon_config() {
</tr><?php endif; ?>
<tr>
<td valign="top" class="vncellreq">Gateway</td>
- <td class="vtable"> <input name="gateway" type="text" class="formfld unknown" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>">
+ <td class="vtable"><select name="gateway" class="formselect" id="gateway">
+ <?php
+ foreach ($a_gateways as $gateway) {
+ if($gateway['interface'] == "wan") {
+ ?>
+ <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
+ <?=htmlspecialchars($gateway['name']);?>
+ </option>
+ <?php
+ }
+ }
+ ?>
+ </select> <br>
</td>
</tr>
<tr>
@@ -1009,22 +1023,6 @@ seconds<br>If no qualifying outgoing packets are transmitted for the specified n
<br />
</td>
</tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Monitor IP</td>
- <td width="78%" class="vtable">
- <div id="showmonbox">
- <input type="button" onClick="show_mon_config()" value="Advanced"></input> - Show Monitor IP configuration</a>
- </div>
- <div id="showmon" style="display:none">
- <input name="use_rrd_gateway" type="text" id="use_rrd_gateway" value="<?php echo ($wancfg['use_rrd_gateway']) ; ?>" />
- <strong>Alternative monitor IP</strong> <br />
- Enter a alternative address here to be used to monitor the link. This is used for the
- quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond
- to icmp requests.</strong>
- <br />
- </div>
- </td>
- </tr>
<?php
/* Wireless interface? */
if (isset($wancfg['wireless']))
diff --git a/usr/local/www/interfaces_opt.php b/usr/local/www/interfaces_opt.php
index 261f374..323183f 100755
--- a/usr/local/www/interfaces_opt.php
+++ b/usr/local/www/interfaces_opt.php
@@ -48,6 +48,10 @@ function remove_bad_chars($string) {
return preg_replace('/[^a-z|_|0-9]/i','',$string);
}
+if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+$a_gateways = &$config['gateways']['gateway_item'];
+
$optcfg = &$config['interfaces']['opt' . $index];
$optcfg['descr'] = remove_bad_chars($optcfg['descr']);
@@ -62,7 +66,6 @@ $pconfig['spoofmac'] = $optcfg['spoofmac'];
$pconfig['mtu'] = $optcfg['mtu'];
$pconfig['disableftpproxy'] = isset($optcfg['disableftpproxy']);
-$pconfig['use_rrd_gateway'] = $optcfg['use_rrd_gateway'];
/* Wireless interface? */
if (isset($optcfg['wireless'])) {
@@ -162,8 +165,15 @@ if ($_POST) {
if (($_POST['subnet'] && !is_numeric($_POST['subnet']))) {
$input_errors[] = "A valid subnet bit count must be specified.";
}
- if($_POST['gateway'] <> "" && !is_ipaddr($_POST['gateway'])) {
- $input_errors[] = "A valid gateway must be specified.";
+ if ($_POST['gateway']) {
+ $match = false;
+ foreach($a_gateways as $gateway) {
+ if(in_array($_POST['gateway'], $gateway)) {
+ $match = true;
+ }
+ }
+ if(!$match)
+ $input_errors[] = "A valid gateway must be specified.";
}
}
}
@@ -217,11 +227,6 @@ if ($_POST) {
$optcfg['bridge'] = $_POST['bridge'];
$optcfg['enable'] = $_POST['enable'] ? true : false;
- /* per interface rrd gateway monitor helper */
- if($_POST['use_rrd_gateway'] <> "") {
- $optcfg['use_rrd_gateway'] = $_POST['use_rrd_gateway'];
- }
-
if ($_POST['type'] == "Static") {
$optcfg['ipaddr'] = $_POST['ipaddr'];
$optcfg['subnet'] = $_POST['subnet'];
@@ -400,11 +405,20 @@ function show_mon_config() {
</td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell">Gateway</td>
- <td width="78%" class="vtable">
- <input name="gateway" value="<?php echo $pconfig['gateway']; ?>">
- <br>
- If you have multiple WAN connections, enter the next hop gateway (router) IP address here. Otherwise, leave this option blank.
+ <td valign="top" class="vncellreq">Gateway</td>
+ <td class="vtable"><select name="gateway" class="formselect" id="gateway">
+ <?php
+ foreach ($a_gateways as $gateway) {
+ if($gateway['interface'] == "opt{$index}") {
+ ?>
+ <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
+ <?=htmlspecialchars($gateway['name']);?>
+ </option>
+ <?php
+ }
+ }
+ ?>
+ </select> <br>
</td>
</tr>
<tr>
@@ -421,22 +435,6 @@ function show_mon_config() {
<br />
</td>
</tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Monitor IP</td>
- <td width="78%" class="vtable">
- <div id="showmonbox">
- <input type="button" onClick="show_mon_config()" value="Advanced"></input> - Show Monitor IP configuration
- </div>
- <div id="showmon" style="display:none">
- <input name="use_rrd_gateway" type="text" id="use_rrd_gateway" value="<?php echo ($optcfg['use_rrd_gateway']) ; ?>" />
- <strong>Alternative monitor IP</strong> <br />
- Enter a alternative address here to be used to monitor the link. This is used for the
- quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond
- to icmp requests.</strong>
- <br />
- </div>
- </td>
- </tr>
<?php /* Wireless interface? */
if (isset($optcfg['wireless']))
wireless_config_print();
diff --git a/usr/local/www/interfaces_wan.php b/usr/local/www/interfaces_wan.php
index d4dc2d1..7dcfefa 100755
--- a/usr/local/www/interfaces_wan.php
+++ b/usr/local/www/interfaces_wan.php
@@ -68,6 +68,10 @@ function getMPDResetTimeFromConfig() {
require("guiconfig.inc");
+if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+$a_gateways = &$config['gateways']['gateway_item'];
+
$wancfg = &$config['interfaces']['wan'];
$optcfg = &$config['interfaces']['wan'];
@@ -136,7 +140,6 @@ $pconfig['bigpond_minheartbeatinterval'] = $config['bigpond']['minheartbeatinter
$pconfig['dhcphostname'] = $wancfg['dhcphostname'];
$pconfig['alias-address'] = $wancfg['alias-address'];
$pconfig['alias-subnet'] = $wancfg['alias-subnet'];
-$pconfig['use_rrd_gateway'] = $wancfg['use_rrd_gateway'];
if ($wancfg['ipaddr'] == "dhcp") {
$pconfig['type'] = "DHCP";
@@ -252,8 +255,15 @@ if ($_POST) {
if (($_POST['alias-subnet'] && !is_numeric($_POST['alias-subnet']))) {
$input_errors[] = "A valid alias subnet bit count must be specified.";
}
- if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
- $input_errors[] = "A valid gateway must be specified.";
+ if ($_POST['gateway']) {
+ $match = false;
+ foreach($a_gateways as $gateway) {
+ if(in_array($_POST['gateway'], $gateway)) {
+ $match = true;
+ }
+ }
+ if(!$match)
+ $input_errors[] = "A valid gateway must be specified.";
}
if (($_POST['pointtopoint'] && !is_ipaddr($_POST['pointtopoint']))) {
$input_errors[] = "A valid point-to-point IP address must be specified.";
@@ -264,9 +274,6 @@ if ($_POST) {
if (($_POST['pppoe_idletimeout'] != "") && !is_numericint($_POST['pppoe_idletimeout'])) {
$input_errors[] = "The idle timeout value must be an integer.";
}
- if (($_POST['use_rrd_gateway'] && !is_ipaddr($_POST['use_rrd_gateway']))) {
- $input_errors[] = "A valid monitor IP address must be specified.";
- }
if ($_POST['pppoe_resethour'] <> "" && !is_numericint($_POST['pppoe_resethour']) &&
$_POST['pppoe_resethour'] >= 0 && $_POST['pppoe_resethour'] <=23) {
$input_errors[] = gettext("A valid PPPoE reset hour must be specified (0-23).");
@@ -358,11 +365,6 @@ if ($_POST) {
system_start_ftp_helpers();
}
- /* per interface rrd gateway monitor helper */
- if($_POST['use_rrd_gateway'] <> "") {
- $wancfg['use_rrd_gateway'] = $_POST['use_rrd_gateway'];
- }
-
if ($_POST['type'] == "Static") {
$wancfg['ipaddr'] = $_POST['ipaddr'];
$wancfg['subnet'] = $_POST['subnet'];
@@ -788,7 +790,19 @@ function show_mon_config() {
</tr><?php endif; ?>
<tr>
<td valign="top" class="vncellreq">Gateway</td>
- <td class="vtable"> <input name="gateway" type="text" class="formfld unknown" id="gateway" size="20" value="<?=htmlspecialchars($pconfig['gateway']);?>">
+ <td class="vtable"><select name="gateway" class="formselect" id="gateway">
+ <?php
+ foreach ($a_gateways as $gateway) {
+ if($gateway['interface'] == "wan") {
+ ?>
+ <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
+ <?=htmlspecialchars($gateway['name']);?>
+ </option>
+ <?php
+ }
+ }
+ ?>
+ </select> <br>
</td>
</tr>
<tr>
@@ -1009,22 +1023,6 @@ seconds<br>If no qualifying outgoing packets are transmitted for the specified n
<br />
</td>
</tr>
- <tr>
- <td width="22%" valign="top" class="vncell">Monitor IP</td>
- <td width="78%" class="vtable">
- <div id="showmonbox">
- <input type="button" onClick="show_mon_config()" value="Advanced"></input> - Show Monitor IP configuration</a>
- </div>
- <div id="showmon" style="display:none">
- <input name="use_rrd_gateway" type="text" id="use_rrd_gateway" value="<?php echo ($wancfg['use_rrd_gateway']) ; ?>" />
- <strong>Alternative monitor IP</strong> <br />
- Enter a alternative address here to be used to monitor the link. This is used for the
- quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond
- to icmp requests.</strong>
- <br />
- </div>
- </td>
- </tr>
<?php
/* Wireless interface? */
if (isset($wancfg['wireless']))
diff --git a/usr/local/www/system_gateways.php b/usr/local/www/system_gateways.php
new file mode 100755
index 0000000..bca50c4
--- /dev/null
+++ b/usr/local/www/system_gateways.php
@@ -0,0 +1,176 @@
+<?php
+/* $Id$ */
+/*
+ system_gateways.php
+ part of pfSense (http://pfsense.com)
+
+ Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>.
+ 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['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+
+$a_gateways = &$config['gateways']['gateway_item'];
+$changedesc = "Gateways: ";
+
+if ($_POST) {
+
+ $pconfig = $_POST;
+
+ if ($_POST['apply']) {
+
+ $retval = 0;
+
+ $retval = system_routing_configure();
+ $retval |= filter_configure();
+
+ $savemsg = get_std_save_message($retval);
+ if ($retval == 0) {
+ if (file_exists($d_staticroutesdirty_path)) {
+ config_lock();
+ unlink($d_staticroutesdirty_path);
+ config_unlock();
+ }
+ }
+ }
+}
+
+if ($_GET['act'] == "del") {
+ if ($a_gateways[$_GET['id']]) {
+ $changedesc .= "removed gateway {$_GET['id']}";
+ unset($a_gateways[$_GET['id']]);
+ write_config($changedesc);
+ touch($d_staticroutesdirty_path);
+ header("Location: system_gateways.php");
+ exit;
+ }
+}
+
+$pgtitle = "System: Gateways";
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle"><?=$pgtitle?></p>
+<form action="system_gateways.php" method="post">
+<input type="hidden" name="y1" value="1">
+<?php if ($savemsg) print_info_box($savemsg); ?>
+<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
+<?php print_info_box_np("The gateway configuration has been changed.<br>You must apply the changes in order for them to take
+effect.");?><br>
+<?php endif; ?>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array("Gateways", true, "system_gateways.php");
+ $tab_array[1] = array("Routes", false, "system_routes.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
+ <tr>
+ <td width="15%" class="listhdrr">Name</td>
+ <td width="15%" class="listhdrr">Interface</td>
+ <td width="20%" class="listhdrr">Gateway</td>
+ <td width="20%" class="listhdrr">Monitor IP</td>
+ <td width="30%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td><a href="system_gateways_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <?php $i = 0; foreach ($a_gateways as $gateway): ?>
+ <tr>
+ <td class="listlr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
+ <?php
+ echo $gateway['name'];
+ if(isset($gateway['defaultgw'])) {
+ echo " <strong>(default)<strong>";
+ }
+ ?>
+
+ </td>
+ <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
+ <?php
+ $iflabels = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
+ $iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
+ echo htmlspecialchars($iflabels[$gateway['interface']]); ?>
+ </td>
+ <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
+ <?php
+ if(isset($gateway['interfacegateway'])) {
+ echo strtoupper($gateway['interface']) . " ";
+ } else {
+ echo $gateway['gateway'] . " ";
+ }
+ ?>
+ </td>
+ <td class="listr" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
+ <?=htmlspecialchars($gateway['monitor']);?>&nbsp;
+ </td>
+ <td class="listbg" ondblclick="document.location='system_gateways_edit.php?id=<?=$i;?>';">
+ <font color="#FFFFFF"><?=htmlspecialchars($gateway['descr']);?>&nbsp;
+ </td>
+ <td valign="middle" nowrap class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td><a href="system_gateways_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
+ <td><a href="system_gateways.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this gateway?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ <tr>
+ <td width="17"></td>
+ <td><a href="system_gateways_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+
+ </tr>
+ <?php $i++; endforeach; ?>
+ <tr>
+ <td class="list" colspan="5"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td><a href="system_gateways_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </form>
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/usr/local/www/system_gateways_edit.php b/usr/local/www/system_gateways_edit.php
new file mode 100755
index 0000000..1ccd2d5
--- /dev/null
+++ b/usr/local/www/system_gateways_edit.php
@@ -0,0 +1,223 @@
+<?php
+/* $Id$ */
+/*
+ system_gateways_edit.php
+ part of pfSense (http://pfsense.com)
+
+ Copyright (C) 2007 Seth Mos <seth.mos@xs4all.nl>.
+ 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['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+
+$a_gateways = &$config['gateways']['gateway_item'];
+
+$id = $_GET['id'];
+if (isset($_POST['id']))
+ $id = $_POST['id'];
+
+if (isset($_GET['dup'])) {
+ $id = $_GET['dup'];
+}
+
+if (isset($id) && $a_gateways[$id]) {
+ $pconfig['name'] = $a_gateways[$id]['name'];
+ $pconfig['interface'] = $a_gateways[$id]['interface'];
+ $pconfig['gateway'] = $a_gateways[$id]['gateway'];
+ $pconfig['defaultgw'] = $a_gateways[$id]['defaultgw'];
+ $pconfig['monitor'] = $a_gateways[$id]['monitor'];
+ $pconfig['descr'] = $a_gateways[$id]['descr'];
+}
+
+if (isset($_GET['dup']))
+ unset($id);
+
+if ($_POST) {
+
+ unset($input_errors);
+ $pconfig = $_POST;
+
+ /* input validation */
+ $reqdfields = explode(" ", "interface name gateway");
+ $reqdfieldsn = explode(",", "Interface,Name,Gateway");
+
+ do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
+
+ if (! isset($_POST['name'])) {
+ $input_errors[] = "A valid gateway name must be specified.";
+ }
+ if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
+ $input_errors[] = "A valid gateway IP address must be specified.";
+ }
+ if (($_POST['monitor'] && !is_ipaddr($_POST['monitor']))) {
+ $input_errors[] = "A valid monitor IP address must be specified.";
+ }
+
+ if ($_POST['defaultgw'] == "yes") {
+ $i=0;
+ foreach ($a_gateways as $gateway) {
+ if($id != $i) {
+ unset($config['gateways']['gateway_item'][$i]['defaultgw']);
+ } else {
+ $config['gateways']['gateway_item'][$i]['defaultgw'] = true;
+ }
+ $i++;
+ }
+ } else {
+ $i=0;
+ foreach ($a_gateways as $gateway) {
+ if($id == $i) {
+ unset($config['gateways']['gateway_item'][$i]['defaultgw']);
+ }
+ $i++;
+ }
+ }
+
+ /* check for overlaps */
+ foreach ($a_gateways as $gateway) {
+ if (isset($id) && ($a_gateways[$id]) && ($a_gateways[$id] === $gateway))
+ continue;
+
+ if ($gateway['name'] == $_POST['name']) {
+ $input_errors[] = "A gateway with this name \"{$_POST['name']}\" already exists.";
+ break;
+ }
+ if ($gateway['gateway'] == $_POST['gateway']) {
+ $input_errors[] = "A gateway with the IP address \"{$_POST['gateway']}\" already exists.";
+ break;
+ }
+ if ($gateway['monitor'] == $_POST['monitor']) {
+ $input_errors[] = "A monitor with the IP address \"{$_POST['monitor']}\" already exists.";
+ break;
+ }
+ }
+
+ if (!$input_errors) {
+ $gateway = array();
+ $gateway['interface'] = $_POST['interface'];
+ $gateway['name'] = $_POST['name'];
+ $gateway['gateway'] = $_POST['gateway'];
+ $gateway['defaultgw'] = $_POST['defaultgw'];
+ $gateway['monitor'] = $_POST['monitor'];
+ $gateway['descr'] = $_POST['descr'];
+
+ if (isset($id) && $a_gateways[$id])
+ $a_gateways[$id] = $gateway;
+ else
+ $a_gateways[] = $gateway;
+
+ touch($d_staticroutesdirty_path);
+
+ write_config();
+
+ header("Location: system_gateways.php");
+ exit;
+ }
+}
+
+$pgtitle = "System: Gateways: Edit gateway";
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle"><?=$pgtitle?></p>
+<?php if ($input_errors) print_input_errors($input_errors); ?>
+ <form action="system_gateways_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">Interface</td>
+ <td width="78%" class="vtable">
+ <select name="interface" class="formselect">
+ <?php $interfaces = array('wan' => 'WAN', 'lan' => 'LAN');
+ for ($i = 1; isset($config['interfaces']['opt' . $i]['enable']); $i++) {
+ $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
+ }
+ 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 this gateway applies to.</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Name</td>
+ <td width="78%" class="vtable">
+ <input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>">
+ <br> <span class="vexpl">Gateway name</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Gateway</td>
+ <td width="78%" class="vtable">
+ <input name="gateway" type="text" class="formfld host" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
+ <br> <span class="vexpl">Gateway IP address</span></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Default Gateway</td>
+ <td width="78%" class="vtable">
+ <input name="defaultgw" type="checkbox" id="defaultgw" value="yes" <?php if (isset($pconfig['defaultgw'])) echo "checked"; ?> onclick="enable_change(false)" />
+ <strong>Default Gateway</strong><br />
+ This will select the above gateway as the default gateway
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncell">Monitor IP</td>
+ <td width="78%" class="vtable">
+ <input name="monitor" type="text" id="monitor" value="<?php echo ($pconfig['monitor']) ; ?>" />
+ <strong>Alternative monitor IP</strong> <br />
+ Enter a alternative address here to be used to monitor the link. This is used for the
+ quality RRD graphs as well as the load balancer entries. Use this if the gateway does not respond
+ to icmp requests.</strong>
+ <br />
+ </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"> <input type="button" value="Cancel" class="formbtn" onclick="history.back()">
+ <?php if (isset($id) && $a_gateways[$id]): ?>
+ <input name="id" type="hidden" value="<?=$id;?>">
+ <?php endif; ?>
+ </td>
+ </tr>
+ </table>
+</form>
+<?php include("fend.inc"); ?>
+<script language="JavaScript">
+ enable_change();
+</script>
+</body>
+</html>
diff --git a/usr/local/www/system_routes.php b/usr/local/www/system_routes.php
index a53e5c8..8bd3acd 100755
--- a/usr/local/www/system_routes.php
+++ b/usr/local/www/system_routes.php
@@ -34,8 +34,12 @@ require("guiconfig.inc");
if (!is_array($config['staticroutes']['route']))
$config['staticroutes']['route'] = array();
+if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
+
staticroutes_sort();
$a_routes = &$config['staticroutes']['route'];
+$a_gateways = &$config['gateways']['gateway_item'];
$changedesc = "Static Routes: ";
if ($_POST) {
@@ -112,10 +116,20 @@ include("head.inc");
<?php endif; ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+<?php
+ $tab_array = array();
+ $tab_array[0] = array("Gateways", false, "system_gateways.php");
+ $tab_array[1] = array("Routes", true, "system_routes.php");
+ display_top_tabs($tab_array);
+?>
+ </td>
+ </tr>
<tr>
- <td width="15%" class="listhdrr">Interface</td>
<td width="25%" class="listhdrr">Network</td>
<td width="20%" class="listhdrr">Gateway</td>
+ <td width="15%" class="listhdrr">Interface</td>
<td width="30%" class="listhdr">Description</td>
<td width="10%" class="list">
<table border="0" cellspacing="0" cellpadding="1">
@@ -126,26 +140,25 @@ include("head.inc");
</table>
</td>
</tr>
- <?php $i = 0; foreach ($a_routes as $route): ?>
<tr>
+ <?php $i = 0; foreach ($a_routes as $route): ?>
<td class="listlr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
- <?php
- $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 htmlspecialchars($iflabels[$route['interface']]); ?>
+ <?=strtolower($route['network']);?>
</td>
<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
- <?=strtolower($route['network']);?>
+ <?php
+ echo $route['gateway'] . " ";
+ ?>
</td>
<td class="listr" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
- <?php
- if(isset($route['interfacegateway'])) {
- echo strtoupper($route['interface']) . " ";
- } else {
- echo strtolower($route['gateway']) . " ";
+ <?php
+ foreach($a_gateways as $gateway) {
+ if($gateway['name'] == $route['gateway']) {
+ echo strtoupper($gateway['interface']) . " ";
}
- ?>
+ }
+
+ ?>
</td>
<td class="listbg" ondblclick="document.location='system_routes_edit.php?id=<?=$i;?>';">
<font color="#FFFFFF"><?=htmlspecialchars($route['descr']);?>&nbsp;
@@ -161,7 +174,7 @@ include("head.inc");
<td><a href="system_routes_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
-
+ </td>
</tr>
<?php $i++; endforeach; ?>
<tr>
diff --git a/usr/local/www/system_routes_edit.php b/usr/local/www/system_routes_edit.php
index da09d99..18e27e6 100755
--- a/usr/local/www/system_routes_edit.php
+++ b/usr/local/www/system_routes_edit.php
@@ -33,9 +33,12 @@ require("guiconfig.inc");
if (!is_array($config['staticroutes']['route']))
$config['staticroutes']['route'] = array();
+if (!is_array($config['gateways']['gateway_item']))
+ $config['gateways']['gateway_item'] = array();
staticroutes_sort();
$a_routes = &$config['staticroutes']['route'];
+$a_gateways = &$config['gateways']['gateway_item'];
$id = $_GET['id'];
if (isset($_POST['id']))
@@ -46,7 +49,6 @@ if (isset($_GET['dup'])) {
}
if (isset($id) && $a_routes[$id]) {
- $pconfig['interface'] = $a_routes[$id]['interface'];
list($pconfig['network'],$pconfig['network_subnet']) =
explode('/', $a_routes[$id]['network']);
$pconfig['gateway'] = $a_routes[$id]['gateway'];
@@ -62,8 +64,8 @@ if ($_POST) {
$pconfig = $_POST;
/* input validation */
- $reqdfields = explode(" ", "interface network network_subnet gateway");
- $reqdfieldsn = explode(",", "Interface,Destination network,Destination network bit count,Gateway");
+ $reqdfields = explode(" ", "network network_subnet gateway");
+ $reqdfieldsn = explode(",", "Destination network,Destination network bit count,Gateway");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
@@ -73,8 +75,15 @@ if ($_POST) {
if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) {
$input_errors[] = "A valid destination network bit count must be specified.";
}
- if (($_POST['gateway'] && !is_ipaddr($_POST['gateway']))) {
- $input_errors[] = "A valid gateway IP address must be specified.";
+ if ($_POST['gateway']) {
+ $match = false;
+ foreach($a_gateways as $gateway) {
+ if(in_array($_POST['gateway'], $gateway)) {
+ $match = true;
+ }
+ }
+ if(!$match)
+ $input_errors[] = "A valid gateway must be specified.";
}
/* check for overlaps */
@@ -91,7 +100,6 @@ if ($_POST) {
if (!$input_errors) {
$route = array();
- $route['interface'] = $_POST['interface'];
$route['network'] = $osn;
$route['gateway'] = $_POST['gateway'];
$route['descr'] = $_POST['descr'];
@@ -121,22 +129,6 @@ include("head.inc");
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="system_routes_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">Interface</td>
- <td width="78%" class="vtable">
- <select name="interface" class="formselect">
- <?php $interfaces = array('lan' => 'LAN', 'wan' => 'WAN', 'pptp' => 'PPTP');
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- $interfaces['opt' . $i] = $config['interfaces']['opt' . $i]['descr'];
- }
- 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 this route applies to.</span></td>
- </tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Destination network</td>
<td width="78%" class="vtable">
@@ -151,13 +143,20 @@ include("head.inc");
</select>
<br> <span class="vexpl">Destination network for this static route</span></td>
</tr>
- <tr>
+ <tr>
<td width="22%" valign="top" class="vncellreq">Gateway</td>
- <td width="78%" class="vtable">
- <input name="gateway" type="text" class="formfld host" id="gateway" size="40" value="<?=htmlspecialchars($pconfig['gateway']);?>">
- <br> <span class="vexpl">Gateway to be used to reach the destination network</span></td>
+ <td width="78%" class="vtable">
+ <select name="gateway" class="formselect">
+ <?php
+ foreach ($a_gateways as $gateway): ?>
+ <option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
+ <?=htmlspecialchars($gateway['name']);?>
+ </option>
+ <?php endforeach; ?>
+ </select> <br>
+ <span class="vexpl">Choose which gateway this route applies to.</span></td>
</tr>
- <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']);?>">
OpenPOWER on IntegriCloud