Commit b5daea15 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: netstat -iW truncates output; refactor this stuff for good

parent 99a46c13
......@@ -849,7 +849,8 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
'ipfw'
);
}
switch($mode) {
switch ($mode) {
case 'active':
$upints = legacy_interface_listget('up');
break;
......@@ -870,39 +871,35 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
$upints = legacy_interface_listget();
break;
}
/* build interface list with netstat */
$linkinfo = "";
exec("/usr/bin/netstat -inW -f link | awk '{ print $1, $4 }'", $linkinfo);
array_shift($linkinfo);
/* build ip address list with netstat */
$ipinfo = "";
exec("/usr/bin/netstat -inW -f inet | awk '{ print $1, $4 }'", $ipinfo);
array_shift($ipinfo);
foreach($linkinfo as $link) {
$friendly = "";
$alink = explode(" ", $link);
$ifname = rtrim(trim($alink[0]), '*');
/* trim out all numbers before checking for vfaces */
if (!in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces) &&
!stristr($ifname, "_vlan") && !stristr($ifname, "_wlan")) {
$ifnames = legacy_interface_listget();
foreach ($ifnames as $ifname) {
if (in_array(array_shift(preg_split('/\d/', $ifname)), $vfaces) ||
stristr($ifname, '_vlan') || stristr($ifname, '_wlan')) {
continue;
}
$ifdata = pfSense_get_interface_addresses($ifname);
$toput = array(
"mac" => trim($alink[1]),
"up" => in_array($ifname, $upints)
'up' => in_array($ifname, $upints),
'ipaddr' => $ifdata['ipaddr'],
'mac' => $ifdata['macaddr']
);
foreach($ipinfo as $ip) {
$aip = explode(" ", $ip);
if($aip[0] == $ifname) {
$toput['ipaddr'] = $aip[1];
}
}
$friendly = '';
if (isset($config['interfaces'])) {
foreach($config['interfaces'] as $name => $int) {
if($int['if'] == $ifname) $friendly = $name;
if ($int['if'] == $ifname) {
$friendly = $name;
}
}
switch($keyby) {
case "physical":
if($friendly != "") {
}
switch ($keyby) {
case 'physical':
if ($friendly != '') {
$toput['friendly'] = $friendly;
}
$dmesg_arr = array();
......@@ -915,17 +912,16 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
}
$iflist[$ifname] = $toput;
break;
case "ppp":
case "friendly":
if($friendly != "") {
case 'friendly':
case 'ppp':
if ($friendly != '') {
$toput['if'] = $ifname;
$iflist[$friendly] = $toput;
}
break;
}
}
}
return $iflist;
}
......
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