summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2008-06-21 00:28:50 +0000
committerErmal Luçi <eri@pfsense.org>2008-06-21 00:28:50 +0000
commitb6db92176273cdd9b1dfbf6b44b42e55a35ee7af (patch)
treedd6c6916b9443469466dfa3f1c09cd70f0a9a002
parent19604f5d9680dad1a5e12d1bea8d7e5aa9f37193 (diff)
downloadpfsense-b6db92176273cdd9b1dfbf6b44b42e55a35ee7af.zip
pfsense-b6db92176273cdd9b1dfbf6b44b42e55a35ee7af.tar.gz
Continue interface improvements.
-rw-r--r--etc/inc/interfaces.inc18
-rw-r--r--etc/inc/system.inc9
-rwxr-xr-xetc/rc.linkup7
-rwxr-xr-xusr/local/www/fbegin.inc8
-rwxr-xr-xusr/local/www/interfaces_assign.php4
-rwxr-xr-xusr/local/www/interfaces_opt.php76
-rw-r--r--usr/local/www/widgets/widgets/interfaces.widget.php13
7 files changed, 62 insertions, 73 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index 2e263dc..d4c91b4 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -234,12 +234,14 @@ function interfaces_lan_configure() {
}
function interfaces_optional_configure() {
- global $config, $g;
- global $bridgeconfig;
+ global $g;
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- interfaces_optional_configure_if($i);
- }
+ /* XXX: unify with wan when pppoe/pptp fixups are done. */
+ /* optional interface if list */
+ $iflist = get_configured_interface_list(true);
+
+ foreach($iflist as $if => $ifname)
+ interfaces_optional_configure_if($if);
if (!$g['booting']) {
/* reconfigure static routes (kernel may have deleted them) */
@@ -270,13 +272,13 @@ function interfaces_optional_configure_if($opti) {
$bridges_total = get_next_available_bridge_interface();
- $optcfg = $config['interfaces']['opt' . $opti];
+ $optcfg = $config['interfaces'][$opti];
if ($g['booting']) {
$optdescr = "";
if ($optcfg['descr'])
$optdescr = " ({$optcfg['descr']})";
- print "\tOPT{$opti}{$optdescr}... ";
+ print "\t{$opti}{$optdescr}... ";
}
if(file_exists("/tmp/{$optcfg['if']}_router"))
@@ -372,7 +374,7 @@ function interfaces_optional_configure_if($opti) {
} else {
/* if user has selected DHCP type then act accordingly */
if($optcfg['ipaddr'] == "dhcp") {
- interfaces_opt_dhcp_configure("opt{$opti}");
+ interfaces_opt_dhcp_configure($opti);
} else {
mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . " " .
escapeshellarg($optcfg['ipaddr'] . "/" . $optcfg['subnet']));
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index d7da50e..ab7a5ee 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -214,14 +214,7 @@ function system_routing_configure() {
}
/* if list */
- if ($config['interfaces']['lan']) {
- $iflist = array("lan", "wan");
- } else {
- $iflist = array("wan");
- }
-
- for ($i = 1; isset($config['interfaces']['opt' . $i]['enable']); $i++)
- $iflist['opt' . $i] = "opt{$i}";
+ $iflist = get_configured_interface_list();
$dont_remove_route = false;
foreach ($iflist as $ifent => $ifname) {
diff --git a/etc/rc.linkup b/etc/rc.linkup
index bbf44d6..e840f19 100755
--- a/etc/rc.linkup
+++ b/etc/rc.linkup
@@ -93,10 +93,9 @@
interfaces_lan_configure();
break;
default:
- $int = str_replace("opt", "", $interface);
- interfaces_optional_configure_if($int);
- echo "interfaces_optional_configure_if($int);\n";
- log_error("HOTPLUG: Configuring optional interface {$interface} - opt{$int}");
+ interfaces_optional_configure_if($interface);
+ echo "interfaces_optional_configure_if($interface);\n";
+ log_error("HOTPLUG: Configuring optional interface {$interface}");
break;
}
}
diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc
index 0b210df..d66560a 100755
--- a/usr/local/www/fbegin.inc
+++ b/usr/local/www/fbegin.inc
@@ -145,9 +145,11 @@ if ($_REQUEST['noticeaction'] == 'acknowledge') {
output_menu_item("/interfaces_lan.php", "LAN");
}
?>
- <?php for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++): if (!isset($config['interfaces']['opt' . $i]['ovpn'])): ?>
- <?=output_menu_item("/interfaces_opt.php?index={$i}", htmlspecialchars($config['interfaces']['opt' . $i]['descr']))?>
- <?php endif; endfor; ?>
+ <?php $opts = get_configured_interface_with_descr(true);
+ foreach ($opts as $oif => $odescr):
+ if (!isset($config['interfaces'][$oif]['ovpn'])): ?>
+ <?=output_menu_item("/interfaces_opt.php?optif={$oif}", htmlspecialchars($odescr))?>
+ <?php endif; endforeach; ?>
<?php echo return_ext_menu("Interfaces"); ?>
</ul>
</li>
diff --git a/usr/local/www/interfaces_assign.php b/usr/local/www/interfaces_assign.php
index d58fc36..898d3e7 100755
--- a/usr/local/www/interfaces_assign.php
+++ b/usr/local/www/interfaces_assign.php
@@ -137,7 +137,7 @@ if ($_GET['act'] == "del") {
$i = substr($id, 3); /* the number of the OPTn port being deleted */
unset($config['interfaces'][$id]['enable']);
- interfaces_optional_configure_if($i); /* down the interface */
+ interfaces_optional_configure_if($id); /* down the interface */
unset($config['interfaces'][$id]); /* delete the specified OPTn or LAN*/
@@ -338,4 +338,4 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
exec("/etc/rc.reboot");
}
-?> \ No newline at end of file
+?>
diff --git a/usr/local/www/interfaces_opt.php b/usr/local/www/interfaces_opt.php
index b043948..5bcc65f 100755
--- a/usr/local/www/interfaces_opt.php
+++ b/usr/local/www/interfaces_opt.php
@@ -35,13 +35,13 @@
require("guiconfig.inc");
-unset($index);
-if ($_GET['index'])
- $index = $_GET['index'];
-else if ($_POST['index'])
- $index = $_POST['index'];
+unset($optif);
+if ($_GET['optif'])
+ $optif = $_GET['optif'];
+else if ($_POST['optif'])
+ $optif = $_POST['optif'];
-if (!$index)
+if (!$optif)
exit;
function remove_bad_chars($string) {
@@ -52,16 +52,15 @@ if (!is_array($config['gateways']['gateway_item']))
$config['gateways']['gateway_item'] = array();
$a_gateways = &$config['gateways']['gateway_item'];
-$optcfg = &$config['interfaces']['opt' . $index];
+$optcfg = &$config['interfaces'][$optif];
$optcfg['descr'] = remove_bad_chars($optcfg['descr']);
if (!is_array($config['aliases']['alias']))
$config['aliases']['alias'] = array();
-if(is_array($config['aliases']['alias']))
- foreach($config['aliases']['alias'] as $alias)
- if($alias['name'] == $optcfg['descr'])
- $input_errors[] = gettext("Sorry, an alias with the name {$optcfg['descr']} already exists.");
+foreach($config['aliases']['alias'] as $alias)
+ if($alias['name'] == $optcfg['descr'])
+ $input_errors[] = gettext("Sorry, an alias with the name {$optcfg['descr']} already exists.");
$pconfig['descr'] = $optcfg['descr'];
$pconfig['bridge'] = $optcfg['bridge'];
@@ -132,26 +131,26 @@ if ($_POST) {
/* input validation */
if ($_POST['enable']) {
+ /* optional interface if list */
+ $iflist = get_configured_interface_with_descr(true);
+
/* description unique? */
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- if ($i != $index) {
- if ($config['interfaces']['opt' . $i]['descr'] == $_POST['descr']) {
- $input_errors[] = "An interface with the specified description already exists.";
- }
- }
+ foreach ($iflist as $if => $ifdescr) {
+ if ($if != $optif && $ifdescr == $_POST['descr'])
+ $input_errors[] = "An interface with the specified description already exists.";
}
if ($_POST['bridge']) {
/* double bridging? */
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- if ($i != $index) {
- if ($config['interfaces']['opt' . $i]['bridge'] == $_POST['bridge']) {
- //$input_errors[] = "Optional interface {$i} " .
- // "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
+ foreach($iflist as $oif => $oifname) {
+ if ($oif != $optif) {
+ if ($config['interfaces'][$oif]['bridge'] == $_POST['bridge']) {
+ //$input_errors[] = "Optional interface {$optif} " .
+ // "({$config['interfaces'][$oif]['descr']}) is already bridged to " .
// "the specified interface.";
- } else if ($config['interfaces']['opt' . $i]['bridge'] == "opt{$index}") {
- //$input_errors[] = "Optional interface {$i} " .
- // "({$config['interfaces']['opt' . $i]['descr']}) is already bridged to " .
+ } else if ($config['interfaces'][$oif]['bridge'] == $optif) {
+ //$input_errors[] = "Optional interface {$optif} " .
+ // "({$config['interfaces'][$oif]['descr']}) is already bridged to " .
// "this interface.";
}
}
@@ -265,7 +264,7 @@ if ($_POST) {
}
-$pgtitle = array("Interfaces","Optional {$index} (" . htmlspecialchars($optcfg['descr']) . ")");
+$pgtitle = array("Interfaces","Optional {$optif} (" . htmlspecialchars($optcfg['descr']) . ")");
include("head.inc");
?>
@@ -321,7 +320,7 @@ function show_mon_config() {
<td width="22%" valign="top" class="vtable">&nbsp;</td>
<td width="78%" class="vtable">
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
- <strong>Enable Optional <?=$index;?> interface</strong></td>
+ <strong>Enable Optional <?=$optif;?> interface</strong></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
@@ -410,15 +409,12 @@ function show_mon_config() {
<td width="78%" class="vtable">
<select name="bridge" class="formselect" id="bridge" onChange="enable_change(false)">
<option <?php if (!$pconfig['bridge']) echo "selected";?> value="">none</option>
- <?php $opts = array('lan' => "LAN", 'wan' => "WAN");
- for ($i = 1; isset($config['interfaces']['opt' . $i]); $i++) {
- if ($i != $index)
- $opts['opt' . $i] = "Optional " . $i . " (" .
- $config['interfaces']['opt' . $i]['descr'] . ")";
- }
- foreach ($opts as $opt => $optname): ?>
- <option <?php if ($opt == $pconfig['bridge']) echo "selected";?> value="<?=htmlspecialchars($opt);?>">
- <?=htmlspecialchars($optname);?>
+ <?php $opts = get_configured_interface_with_descr();
+ foreach ($opts as $opt => $optname): ?>
+ <option
+ <?php if ($opt != $optif && $opt == $pconfig['bridge'])
+ echo "selected";?> value="<?=htmlspecialchars($opt);?>">
+ <?=htmlspecialchars($if ."(".$optname.")");?>
</option>
<?php endforeach; ?>
</select> </td>
@@ -446,7 +442,7 @@ function show_mon_config() {
<?php
if(count($a_gateways) > 0) {
foreach ($a_gateways as $gateway) {
- if($gateway['interface'] == "opt{$index}") {
+ if($gateway['interface'] == $optif) {
?>
<option value="<?=$gateway['name'];?>" <?php if ($gateway['name'] == $pconfig['gateway']) echo "selected"; ?>>
<?=htmlspecialchars($gateway['name']);?>
@@ -515,7 +511,7 @@ function show_mon_config() {
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
- <input name="index" type="hidden" value="<?=$index;?>">
+ <input name="optif" type="hidden" value="<?=$optif;?>">
<input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
</td>
</tr>
@@ -534,7 +530,7 @@ enable_change(false);
//-->
</script>
<?php else: ?>
-<p><strong>Optional <?=$index;?> has been disabled because there is no OPT<?=$index;?> interface.</strong></p>
+<p><strong>Optional <?=$optif;?> has been disabled because there is no <?=strtoupper($optif);?> interface.</strong></p>
<?php endif; ?>
<?php include("fend.inc"); ?>
</body>
@@ -549,7 +545,7 @@ if ($_POST) {
flush();
sleep(1);
- interfaces_optional_configure_if($index);
+ interfaces_optional_configure_if($optif);
reset_carp();
diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php
index f8186ca..d85b08f 100644
--- a/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -35,14 +35,12 @@ require_once("pfsense-utils.inc");
require_once("functions.inc");
require_once("/usr/local/www/widgets/include/interfaces.inc");
- $i = 0; $ifdescrs = array('wan' => 'WAN', 'lan' => 'LAN');
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $ifdescrs['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
- }?>
+ $i = 0;
+ $ifdescrs = get_configured_interface_with_descr();
+?>
<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0">
<?php
- $counter = 1;
foreach ($ifdescrs as $ifdescr => $ifname){
$ifinfo = get_interface_info($ifdescr);
$iswireless = is_interface_wireless($ifdescr);
@@ -65,9 +63,8 @@ require_once("/usr/local/www/widgets/include/interfaces.inc");
<? } else if ($ifname == "LAN") { ?>
<span onClick="location.href='/interfaces_lan.php'" style="cursor:pointer">
<? } else { ?>
- <span onClick="location.href='/interfaces_opt.php?index=<?=$counter; ?>'" style="cursor:pointer">
+ <span onClick="location.href='/interfaces_opt.php?optif=<?=$ifdescr; ?>'" style="cursor:pointer">
<?
- $counter++;
} ?>
@@ -101,4 +98,4 @@ require_once("/usr/local/www/widgets/include/interfaces.inc");
</td></tr><?php
}//end for each
?>
- </table> \ No newline at end of file
+ </table>
OpenPOWER on IntegriCloud