mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
interfaces: move two legacy functions to their only callers
This commit is contained in:
parent
293fe8ab43
commit
e7fcd3e2bf
@ -72,16 +72,6 @@ function legacy_interface_flags($ifs, $flag, $report_errors = true)
|
||||
}
|
||||
}
|
||||
|
||||
function legacy_interface_rename($ifs, $name)
|
||||
{
|
||||
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' name ' . escapeshellarg($name);
|
||||
|
||||
exec($cmd . ' 2>&1', $out, $ret);
|
||||
if ($ret) {
|
||||
log_error('The command `' . $cmd . '\' failed to execute');
|
||||
}
|
||||
}
|
||||
|
||||
function legacy_interface_create($ifs, $name = null)
|
||||
{
|
||||
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' create';
|
||||
@ -98,7 +88,14 @@ function legacy_interface_create($ifs, $name = null)
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
legacy_interface_rename($new, $name);
|
||||
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' name ' . escapeshellarg($name);
|
||||
|
||||
exec($cmd . ' 2>&1', $out, $ret);
|
||||
if ($ret) {
|
||||
log_error('The command `' . $cmd . '\' failed to execute');
|
||||
}
|
||||
|
||||
/* return new name here anyway to force proper device not found errors later */
|
||||
$new = $name;
|
||||
}
|
||||
|
||||
@ -507,42 +504,3 @@ function legacy_get_interface_addresses($ifs, $ifconfig_details = null)
|
||||
}
|
||||
return $addrs;
|
||||
}
|
||||
|
||||
function legacy_serial_devices()
|
||||
{
|
||||
// collect 3g/4g modems
|
||||
$dmesg = array();
|
||||
exec('/sbin/sysctl -a', $dmesg);
|
||||
$modems = array();
|
||||
foreach ($dmesg as $line) {
|
||||
if (strpos($line, 'dev.u3g.') === 0) {
|
||||
$portnum = explode('.', $line)[2];
|
||||
if (is_numeric($portnum)) {
|
||||
if (!isset($modems[$portnum])) {
|
||||
$modems[$portnum] = array();
|
||||
}
|
||||
if (strpos($line, '%desc:') !== false) {
|
||||
$modems[$portnum]['descr'] = explode('%desc:', $line)[1];
|
||||
} elseif (strpos($line, '%pnpinfo:') !== false) {
|
||||
foreach (explode(' ', explode('%pnpinfo:', $line)[1]) as $prop) {
|
||||
$tmp = explode('=', $prop);
|
||||
if (count($tmp) == 2) {
|
||||
$modems[$portnum][$tmp[0]] = $tmp[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$serialports = array();
|
||||
foreach (glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE) as $device) {
|
||||
$serialports[$device] = array('descr' => '');
|
||||
$tty = explode('.', explode('cua', $device)[1])[0];
|
||||
foreach ($modems as $modem) {
|
||||
if (isset($modem['ttyname']) && $modem['ttyname'] == $tty) {
|
||||
$serialports[$device] = $modem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $serialports;
|
||||
}
|
||||
|
||||
@ -31,6 +31,45 @@
|
||||
require_once("guiconfig.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
function serial_devices()
|
||||
{
|
||||
// collect 3g/4g modems
|
||||
$dmesg = array();
|
||||
exec('/sbin/sysctl -a', $dmesg);
|
||||
$modems = array();
|
||||
foreach ($dmesg as $line) {
|
||||
if (strpos($line, 'dev.u3g.') === 0) {
|
||||
$portnum = explode('.', $line)[2];
|
||||
if (is_numeric($portnum)) {
|
||||
if (!isset($modems[$portnum])) {
|
||||
$modems[$portnum] = array();
|
||||
}
|
||||
if (strpos($line, '%desc:') !== false) {
|
||||
$modems[$portnum]['descr'] = explode('%desc:', $line)[1];
|
||||
} elseif (strpos($line, '%pnpinfo:') !== false) {
|
||||
foreach (explode(' ', explode('%pnpinfo:', $line)[1]) as $prop) {
|
||||
$tmp = explode('=', $prop);
|
||||
if (count($tmp) == 2) {
|
||||
$modems[$portnum][$tmp[0]] = $tmp[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$serialports = array();
|
||||
foreach (glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE) as $device) {
|
||||
$serialports[$device] = array('descr' => '');
|
||||
$tty = explode('.', explode('cua', $device)[1])[0];
|
||||
foreach ($modems as $modem) {
|
||||
if (isset($modem['ttyname']) && $modem['ttyname'] == $tty) {
|
||||
$serialports[$device] = $modem;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $serialports;
|
||||
}
|
||||
|
||||
$a_ppps = &config_read_array('ppps', 'ppp');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
@ -433,7 +472,7 @@ include("head.inc");
|
||||
<td>
|
||||
<select class="selectpicker" multiple="multiple" size="3" name="ports[]" id="ports" >
|
||||
<?php
|
||||
foreach (legacy_serial_devices() as $port => $port_info):?>
|
||||
foreach (serial_devices() as $port => $port_info):?>
|
||||
<option data-type="serial" value="<?=$port;?>" <?=in_array($port, $pconfig['ports']) ? "selected=\"selected\"" : "";?> >
|
||||
<?=$port;?> <?=!empty($port_info['descr']) ? "(".$port_info['descr'].")" : "" ;?>
|
||||
</option>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user