function autodetect_interface($ifname, &$in, &$out)
{
    $iflist_prev = network_get_interfaces();
    fwrite($out, "Connect the {$ifname} interface now and make sure that the link is up.\n" . "Then press RETURN to continue.\n");
    fgets($in);
    $iflist = network_get_interfaces();
    foreach ($iflist_prev as $ifn => $ifa) {
        if (!$ifa['up'] && $iflist[$ifn]['up']) {
            fwrite($out, "Detected link-up on interface {$ifn}.\n");
            return $ifn;
        }
    }
    fwrite($out, "No link-up detected.\n");
    return null;
}
Example #2
0
$cfgPtr['dnsserver'] =& $config['system']['dnsserver'];
// network topology
$cfgPtr['topology'] =& $config['interfaces']['lan']['topology'];
$cfgPtr['extipaddr'] =& $config['interfaces']['lan']['extipaddr'];
$cfgPtr['exthostname'] =& $config['interfaces']['lan']['exthostname'];
// dynamic dns settings
$cfgPtr['hostnameupdatesrc'] =& $config['interfaces']['lan']['hostnameupdatesrc'];
$cfgPtr['dyndnsusername'] =& $config['dyndns']['username'];
$cfgPtr['dyndnspassword'] =& $config['dyndns']['password'];
$cfgPtr['dyndnstype'] =& $config['dyndns']['type'];
$cfgPtr['dyndnsenable'] =& $config['dyndns']['enable'];
$cfgPtr['dyndnswildcard'] =& $config['dyndns']['wildcard'];
// static routes
$cfgPtr['route'] =& $config['system']['staticroutes']['route'];
// get ethernet interfaces list
$netInterfaces = network_get_interfaces();
// temporary variable to check later if static ip address is changed
$oldIpaddr = $netInterfaces[$cfgPtr['if']]['ipaddr'];
// instantiate the config form object
$form = new cfgForm('sys_network.php', 'method=post|name=iform|id=iform');
// initialize form
$form->startWrapper('tab-1');
$form->startFieldset('fset_lanport', _('Port') . " {$cfgPtr['if']} ({$netInterfaces[$cfgPtr['if']]['mac']})");
// if address mode selector
$form->startBlock('rw_usedhcp');
$form->setLabel(null, _('Settings'), 'dhcp', 'class=labelcol');
$form->startBlock('rw_usedhcp', 'right');
$form->setField('dhcp', 'select', 'name=dhcp', false, 'yes');
$selectOpts['yes'] = _('configured via DHCP client');
$selectOpts['no'] = _('configured manually');
$form->setSelectOptFill('dhcp', $selectOpts);