Commit 75c5ddf1 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: small follow-up on get_interface_list()

parent 97d35c56
...@@ -431,7 +431,7 @@ Then press ENTER to continue. ...@@ -431,7 +431,7 @@ Then press ENTER to continue.
EOD; EOD;
fgets($fp); fgets($fp);
$iflist = get_interface_list("media"); $iflist = get_interface_list('media');
foreach ($iflist_prev as $ifn => $ifa) { foreach ($iflist_prev as $ifn => $ifa) {
if (!$ifa['up'] && $iflist[$ifn]['up']) { if (!$ifa['up'] && $iflist[$ifn]['up']) {
......
...@@ -813,49 +813,52 @@ function get_configured_ipv6_addresses() ...@@ -813,49 +813,52 @@ function get_configured_ipv6_addresses()
/* /*
* get_interface_list() - Return a list of all physical interfaces * get_interface_list() - Return a list of all physical interfaces
* along with MAC and status. * along with MAC, IPv4 and status.
* *
* $mode = "active" - use ifconfig -lu * $mode = "active" - use ifconfig -lu
* "media" - use ifconfig to check physical connection * "media" - use ifconfig to check physical connection
* status (much slower) * status (much slower)
*/ */
function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") { function get_interface_list($mode = 'active', $keyby = 'physical')
{
global $config; global $config;
$upints = array(); $upints = array();
/* get a list of virtual interface types */
if(!$vfaces) { /* list of virtual interface types */
$vfaces = array ( $vfaces = array(
'bridge', '_vlan',
'ppp', '_wlan',
'pppoe', 'bridge',
'pptp', 'carp',
'l2tp', 'enc',
'sl', 'faith',
'gif', 'gif',
'gre', 'gre',
'faith', 'ipfw',
'lo', 'l2tp',
'ng', 'lagg',
'_vlan', 'lo',
'_wlan', 'ng',
'pflog', 'pflog',
'plip', 'plip',
'pfsync', 'ppp',
'enc', 'pppoe',
'tun', 'pptp',
'carp', 'pfsync',
'lagg', 'sl',
'vip', 'tun',
'ipfw' 'vip'
); );
}
$ifnames = legacy_interface_listget();
switch ($mode) { switch ($mode) {
case 'active': case 'active':
$upints = legacy_interface_listget('up'); $upints = legacy_interface_listget('up');
break; break;
case 'media': case 'media':
$intlist = legacy_interface_listget(); $intlist = $ifnames;
$ifconfig = ""; $ifconfig = "";
exec("/sbin/ifconfig -a", $ifconfig); exec("/sbin/ifconfig -a", $ifconfig);
$regexp = '/(' . implode('|', $intlist) . '):\s/'; $regexp = '/(' . implode('|', $intlist) . '):\s/';
...@@ -868,15 +871,12 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "") ...@@ -868,15 +871,12 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
} }
break; break;
default: default:
$upints = legacy_interface_listget(); $upints = $ifnames;
break; break;
} }
$ifnames = legacy_interface_listget();
foreach ($ifnames as $ifname) { foreach ($ifnames as $ifname) {
if (in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces) || if (in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces)) {
stristr($ifname, '_vlan') || stristr($ifname, '_wlan')) {
continue; continue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment