Commit cd4b8267 authored by Franco Fichtner's avatar Franco Fichtner

wireless: only advertise supported modes; closes #377

parent a0b1e854
......@@ -440,6 +440,25 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
return $vlanif;
}
function interfaces_test_wireless_capability($if, $cap)
{
$caps = array('hostap' => 'HOSTAP', 'adhoc' => 'IBSS');
if (!isset($caps[$cap])) {
return false;
}
exec(sprintf('/sbin/ifconfig %s list caps', escapeshellarg($if)), $lines);
foreach ($lines as $line) {
if (preg_match("/^drivercaps=.*<.*{$caps[$cap]}.*>$/", $line)) {
return true;
}
}
return false;
}
function interfaces_create_wireless_clones() {
global $config;
......
......@@ -147,8 +147,11 @@ $wkports = array(
69 => "TFTP",
5900 => "VNC");
$wlan_modes = array("bss" => "Infrastructure (BSS)", "adhoc" => "Ad-hoc (IBSS)",
"hostap" => "Access Point");
$wlan_modes = array(
'bss' => 'Infrastructure (BSS)',
'adhoc' => 'Ad-hoc (IBSS)',
'hostap' => 'Access Point'
);
function do_input_validation($postdata, $reqdfields, $reqdfieldsn, &$input_errors)
{
......
......@@ -3304,8 +3304,12 @@ $types6 = array("none" => gettext("None"), "staticv6" => gettext("Static IPv6"),
<td class="vtable">
<select name="mode" class="selectpicker" data-style="btn-default" id="mode">
<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)"); ?></option>
<?php if (interfaces_test_wireless_capability(get_real_interface($wancfg['if']), 'adhoc')): ?>
<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)"); ?></option>
<?php endif; ?>
<?php if (interfaces_test_wireless_capability(get_real_interface($wancfg['if']), 'hostap')): ?>
<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point"); ?></option>
<?php endif; ?>
</select>
</td>
</tr>
......
......@@ -182,8 +182,12 @@ include("head.inc");
<td class="vtable">
<select name="mode" class="selectpicker">
<option <?php if ($pconfig['mode'] == 'bss') echo "selected=\"selected\"";?> value="bss"><?=gettext("Infrastructure (BSS)");?></option>
<?php if (interfaces_test_wireless_capability($pconfig['cloneif'], 'adhoc')): ?>
<option <?php if ($pconfig['mode'] == 'adhoc') echo "selected=\"selected\"";?> value="adhoc"><?=gettext("Ad-hoc (IBSS)");?></option>
<?php endif; ?>
<?php if (interfaces_test_wireless_capability($pconfig['cloneif'], 'hostap')): ?>
<option <?php if ($pconfig['mode'] == 'hostap') echo "selected=\"selected\"";?> value="hostap"><?=gettext("Access Point");?></option>
<?php endif; ?>
</select></td>
</tr>
<tr>
......
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