mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Already in base includes
This commit is contained in:
parent
ec5a5d652b
commit
0bcbfa736d
@ -176,116 +176,6 @@ if ($_POST) {
|
||||
}
|
||||
}
|
||||
|
||||
function get_interface_info($ifdescr) {
|
||||
|
||||
global $config, $linkinfo, $netstatrninfo;
|
||||
|
||||
$ifinfo = array();
|
||||
|
||||
/* find out interface name */
|
||||
$ifinfo['hwif'] = $config['interfaces'][$ifdescr]['if'];
|
||||
if ($ifdescr == "wan")
|
||||
$ifinfo['if'] = get_real_wan_interface();
|
||||
else
|
||||
$ifinfo['if'] = $ifinfo['hwif'];
|
||||
|
||||
/* run netstat to determine link info */
|
||||
|
||||
unset($linkinfo);
|
||||
exec("/usr/bin/netstat -I " . $ifinfo['hwif'] . " -nWb -f link", $linkinfo);
|
||||
$linkinfo = preg_split("/\s+/", $linkinfo[1]);
|
||||
if (preg_match("/\*$/", $linkinfo[0])) {
|
||||
$ifinfo['status'] = "down";
|
||||
} else {
|
||||
$ifinfo['status'] = "up";
|
||||
}
|
||||
|
||||
/* PPPoE interface? -> get status from virtual interface */
|
||||
if (($ifdescr == "wan") && ($config['interfaces']['wan']['ipaddr'] == "pppoe")) {
|
||||
unset($linkinfo);
|
||||
exec("/usr/bin/netstat -I " . $ifinfo['if'] . " -nWb -f link", $linkinfo);
|
||||
$linkinfo = preg_split("/\s+/", $linkinfo[1]);
|
||||
if (preg_match("/\*$/", $linkinfo[0])) {
|
||||
$ifinfo['pppoelink'] = "down";
|
||||
} else {
|
||||
/* get PPPoE link status for dial on demand */
|
||||
$ifconfiginfo = "";
|
||||
unset($ifconfiginfo);
|
||||
exec("/sbin/ifconfig " . $ifinfo['if'], $ifconfiginfo);
|
||||
|
||||
$ifinfo['pppoelink'] = "up";
|
||||
|
||||
foreach ($ifconfiginfo as $ici) {
|
||||
if (strpos($ici, 'LINK0') !== false)
|
||||
$ifinfo['pppoelink'] = "down";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* PPTP interface? -> get status from virtual interface */
|
||||
if (($ifdescr == "wan") && ($config['interfaces']['wan']['ipaddr'] == "pptp")) {
|
||||
unset($linkinfo);
|
||||
exec("/usr/bin/netstat -I " . $ifinfo['if'] . " -nWb -f link", $linkinfo);
|
||||
$linkinfo = preg_split("/\s+/", $linkinfo[1]);
|
||||
if (preg_match("/\*$/", $linkinfo[0])) {
|
||||
$ifinfo['pptplink'] = "down";
|
||||
} else {
|
||||
/* get PPTP link status for dial on demand */
|
||||
unset($ifconfiginfo);
|
||||
exec("/sbin/ifconfig " . $ifinfo['if'], $ifconfiginfo);
|
||||
|
||||
$ifinfo['pptplink'] = "up";
|
||||
|
||||
foreach ($ifconfiginfo as $ici) {
|
||||
if (strpos($ici, 'LINK0') !== false)
|
||||
$ifinfo['pptplink'] = "down";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ifinfo['status'] == "up") {
|
||||
/* try to determine media with ifconfig */
|
||||
$matches = "";
|
||||
|
||||
if ($ifinfo['pppoelink'] != "down" && $ifinfo['pptplink'] != "down") {
|
||||
/* try to determine IP address and netmask with ifconfig */
|
||||
unset($ifconfiginfo);
|
||||
exec("/sbin/ifconfig " . $ifinfo['if'], $ifconfiginfo);
|
||||
|
||||
foreach ($ifconfiginfo as $ici) {
|
||||
if (preg_match("/inet (\S+)/", $ici, $matches)) {
|
||||
$ifinfo['ipaddr'] = $matches[1];
|
||||
}
|
||||
if (preg_match("/netmask (\S+)/", $ici, $matches)) {
|
||||
if (preg_match("/^0x/", $matches[1]))
|
||||
$ifinfo['subnet'] = long2ip(hexdec($matches[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if ($ifdescr == "wan") {
|
||||
/* run netstat to determine the default gateway */
|
||||
unset($netstatrninfo);
|
||||
exec("/usr/bin/netstat -rnf inet", $netstatrninfo);
|
||||
|
||||
foreach ($netstatrninfo as $nsr) {
|
||||
if (preg_match("/^default\s*(\S+)/", $nsr, $matches)) {
|
||||
$ifinfo['gateway'] = $matches[1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* deterimine interface gateway */
|
||||
$int = convert_friendly_interface_to_real_interface_name($ifdescr);
|
||||
$gw = get_interface_gateway($int);
|
||||
if($gw)
|
||||
$ifinfo['gateway'] = $gw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ifinfo;
|
||||
}
|
||||
|
||||
|
||||
$pgtitle = "Load Balancer: Pool: Edit";
|
||||
include("head.inc");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user