Commit 2533e110 authored by Franco Fichtner's avatar Franco Fichtner

interfaces: portable alternative for php module function

BTW: 5000 commits on master branch, yay, party!
parent 6e5fbbc9
...@@ -210,17 +210,17 @@ function legacy_interface_details($intf) ...@@ -210,17 +210,17 @@ function legacy_interface_details($intf)
function legacy_netgraph_attach($ifs) function legacy_netgraph_attach($ifs)
{ {
mwexecf('/usr/local/sbin/ngattach %s', array($ifs)); mwexecf('/usr/local/sbin/ngattach %s', array($ifs));
} }
function legacy_netgraph_detach($ifs) function legacy_netgraph_detach($ifs)
{ {
mwexecf('/usr/sbin/ngctl msg %s: detach', array($ifs), true); mwexecf('/usr/sbin/ngctl msg %s: detach', array($ifs), true);
} }
function legacy_netgraph_rename($tmpifs, $ifs) function legacy_netgraph_rename($tmpifs, $ifs)
{ {
mwexecf('/usr/sbin/ngctl name %s: %s', array($tmpifs, $ifs)); mwexecf('/usr/sbin/ngctl name %s: %s', array($tmpifs, $ifs));
} }
/** /**
...@@ -259,3 +259,40 @@ function configure_interface_hardware($ifs) ...@@ -259,3 +259,40 @@ function configure_interface_hardware($ifs)
} }
} }
} }
function legacy_getall_interface_addresses($ifs)
{
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs);
$addrs = array();
exec($cmd . ' 2>&1', $out, $ret);
if ($ret) {
log_error('The command `' . $cmd . '\' failed to execute');
return $stats;
}
if (count($out)) {
foreach ($out as $line) {
if ($line[0] != "\t") {
continue;
}
$stat = explode(' ', $line);
if (isset($stat[0])) {
switch (trim($stat[0])) {
case 'inet':
$mask = substr_count(base_convert(hexdec($stat[3]), 10, 2), '1');
$addrs[] = $stat[1] . '/' . $mask;
break;
case 'inet6':
$addrs[] = strtok($stat[1], '%') . '/' . $stat[3];
break;
default:
/* not relevant to our interest */
break;
}
}
}
}
return $addrs;
}
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