Approved-By: sullrich/cmb
This commit is contained in:
Erik Fonnesbeck 2010-03-02 12:29:25 -07:00
commit f4a4d91ef2
16 changed files with 602 additions and 138 deletions

View File

@ -279,6 +279,27 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
return $vlanif;
}
function interfaces_create_wireless_clones() {
global $config;
if($g['booting'])
echo "Creating other wireless clone interfaces...";
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
foreach ($config['wireless']['clone'] as $clone) {
if(empty($clone['cloneif']))
continue;
if(does_interface_exist($clone['cloneif']))
continue;
/* XXX: Maybe we should report any errors?! */
if(interface_wireless_clone($clone['cloneif'], $clone))
if($g['booting'])
echo " " . $clone['cloneif'];
}
}
if($g['booting'])
echo " done.\n";
}
function interfaces_bridge_configure() {
global $config;
@ -695,6 +716,9 @@ function interfaces_configure() {
}
}
/* create the unconfigured wireless clones */
interfaces_create_wireless_clones();
/* set up GRE virtual interfaces */
interfaces_gre_configure();
@ -1342,7 +1366,11 @@ function interface_wireless_clone($realif, $wlcfg) {
* If it has not been cloned then go ahead and clone it.
*/
$needs_clone = false;
switch($wlcfg['wireless']['mode']) {
if(is_array($wlcfg['wireless']))
$wlcfg_mode = $wlcfg['wireless']['mode'];
else
$wlcfg_mode = $wlcfg['mode'];
switch($wlcfg_mode) {
case "hostap":
$mode = "wlanmode hostap";
break;
@ -1353,19 +1381,20 @@ function interface_wireless_clone($realif, $wlcfg) {
$mode = "";
break;
}
$baseif = interface_get_wireless_base($wlcfg['if']);
if(does_interface_exist($realif)) {
exec("/sbin/ifconfig {$realif}", $output, $ret);
$ifconfig_str = implode($output);
if(($wlcfg['wireless']['mode'] == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) {
log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to hostap mode");
if(($wlcfg_mode == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) {
log_error("Interface {$realif} changed to hostap mode");
$needs_clone = true;
}
if(($wlcfg['wireless']['mode'] == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) {
log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to adhoc mode");
if(($wlcfg_mode == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) {
log_error("Interface {$realif} changed to adhoc mode");
$needs_clone = true;
}
if(($wlcfg['wireless']['mode'] == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) {
log_error("Interface {$wlcfg['if']}_wlan{$interface_num} changed to infrastructure mode");
if(($wlcfg_mode == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) {
log_error("Interface {$realif} changed to infrastructure mode");
$needs_clone = true;
}
} else {
@ -1380,15 +1409,45 @@ function interface_wireless_clone($realif, $wlcfg) {
log_error("Cloning new wireless interface {$realif}");
// Create the new wlan interface. FreeBSD returns the new interface name.
// example: wlan2
exec("/sbin/ifconfig wlan create wlandev {$wlcfg['if']} {$mode} 2>&1", $out, $ret);
exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} bssid 2>&1", $out, $ret);
if($ret <> 0) {
log_error("Failed to clone interface {$wlcfg['if']} with error code {$ret}, output {$out[0]}");
log_error("Failed to clone interface {$baseif} with error code {$ret}, output {$out[0]}");
return false;
}
$newif = trim($out[0]);
// Rename the interface to {$parentnic}_wlan{$number}#: EX: ath0_wlan0
mwexec("/sbin/ifconfig {$newif} name {$realif} 2>&1", false);
// FIXME: not sure what ngctl is for. Doesn't work.
// mwexec("/usr/sbin/ngctl name {$newif}: {$wlcfg['if']}_wlan{$interface_num}", false);
// mwexec("/usr/sbin/ngctl name {$newif}: {$realif}", false);
}
return true;
}
function interface_sync_wireless_clones(&$ifcfg, $sync_changes = false) {
global $config, $g;
$shared_settings = array('standard', 'turbo', 'protmode', 'channel', 'txpower');
if(!is_array($ifcfg['wireless']))
return;
$baseif = interface_get_wireless_base($ifcfg['if']);
$iflist = get_configured_interface_list(false, true);
foreach ($iflist as $if) {
if ($baseif == interface_get_wireless_base($config['interfaces'][$if]['if']) && $ifcfg['if'] != $config['interfaces'][$if]['if']) {
if (isset($config['interfaces'][$if]['wireless']['standard']) || $sync_changes) {
foreach ($shared_settings as $setting) {
if ($sync_changes) {
$config['interfaces'][$if]['wireless'][$setting] = $ifcfg['wireless'][$setting];
} else {
$ifcfg['wireless'][$setting] = $config['interfaces'][$if]['wireless'][$setting];
}
}
if (!$sync_changes)
break;
}
}
}
}
@ -1408,6 +1467,9 @@ function interface_wireless_configure($if, &$wl, &$wlcfg) {
// Clone wireless nic if needed.
interface_wireless_clone($if, $wl);
// Reject inadvertent changes to shared settings in case the interface hasn't been configured.
interface_sync_wireless_clones($wl, false);
$fd_set = fopen("{$g['tmp_path']}/{$if}_setup.sh","w");
fwrite($fd_set, "#!/bin/sh\n");
fwrite($fd_set, "# {$g['product_name']} wireless configuration script.\n\n");
@ -2340,6 +2402,22 @@ function interface_translate_type_to_real($interface) {
return $interface;
}
function interface_get_wireless_base($wlif) {
if(!stristr($wlif, "_wlan")) {
return $wlif;
} else {
return substr($wlif, 0, stripos($wlif, "_wlan"));
}
}
function interface_get_wireless_clone($wlif) {
if(!stristr($wlif, "_wlan")) {
return $wlif . "_wlan0";
} else {
return $wlif;
}
}
function get_real_interface($interface = "wan") {
global $config;
@ -2399,11 +2477,7 @@ function get_real_interface($interface = "wan") {
// interface name format: $parentnic_wlanparentnic#
// example: ath0_wlan0
if(is_interface_wireless($cfg['if'])) {
if ($interface == "wan")
$interface_num = 0;
else
$interface_num = substr($interface, 3);
$wanif = $cfg['if'] . "_wlan" . $interface_num;
$wanif = interface_get_wireless_clone($cfg['if']);
break;
}

View File

@ -499,6 +499,7 @@ function get_interface_list($mode = "active", $keyby = "physical", $vfaces = "")
'lo',
'ng',
'_vlan',
'_wlan',
'pflog',
'plip',
'pfsync',
@ -958,7 +959,7 @@ function is_interface_mismatch() {
$do_assign = false;
$i = 0;
foreach ($config['interfaces'] as $ifname => $ifcfg) {
if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan/i", $ifcfg['if'])) {
if (preg_match("/^enc|^tun|^ppp|^pptp|^pppoe|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i", $ifcfg['if'])) {
$i++;
}
else if (does_interface_exist($ifcfg['if']) == false) {

View File

@ -36,10 +36,10 @@ function listtags() {
* I know it's a pain, but it's a pain to find stuff too if it's not
*/
$ret = explode(" ",
"alias aliasurl allowedip authserver bridged ca cacert cert config container ".
"columnitem depends_on_package disk dnsserver dnsupdate domainoverrides ".
"dyndns earlyshellcmd element encryption-algorithm-option field ".
"fieldname hash-algorithm-option gateway_item gateway_group gif gre ".
"alias aliasurl allowedip authserver bridged ca cacert cert clone config ".
"container columnitem depends_on_package disk dnsserver dnsupdate ".
"domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ".
"field fieldname hash-algorithm-option gateway_item gateway_group gif gre ".
"group hosts member ifgroupentry igmpentry interface_array item key lagg " .
"lbaction lbpool l7rules lbprotocol ".
"member menu tab mobilekey monitor_type mount ntpserver onetoone ".

View File

@ -40,10 +40,10 @@ function listtags() {
* I know it's a pain, but it's a pain to find stuff too if it's not
*/
$ret = explode(" ",
"alias aliasurl allowedip authserver bridged ca cacert cert config container ".
"columnitem depends_on_package disk dnsserver dnsupdate domainoverrides ".
"dyndns earlyshellcmd element encryption-algorithm-option field ".
"fieldname hash-algorithm-option gateway_item gateway_group gif gre ".
"alias aliasurl allowedip authserver bridged ca cacert cert clone config ".
"container columnitem depends_on_package disk dnsserver dnsupdate ".
"domainoverrides dyndns earlyshellcmd element encryption-algorithm-option ".
"field fieldname hash-algorithm-option gateway_item gateway_group gif gre ".
"group hosts member ifgroupentry igmpentry interface_array item key lagg " .
"lbaction lbpool l7rules lbprotocol ".
"member menu tab mobilekey monitor_type mount ntpserver onetoone ".

View File

@ -215,6 +215,7 @@ if (isset($wancfg['wireless'])) {
/* Get wireless modes */
$wlanif = get_real_interface($if);
interface_wireless_clone($wlanif, $wancfg);
$wlanbaseif = interface_get_wireless_base($wancfg['if']);
$wl_modes = get_wireless_modes($if);
$pconfig['standard'] = $wancfg['wireless']['standard'];
$pconfig['mode'] = $wancfg['wireless']['mode'];
@ -295,6 +296,9 @@ if ($_POST['apply']) {
if ($_POST && $_POST['enable'] == "no") {
unset($wancfg['enable']);
interface_bring_down($if);
if (isset($wancfg['wireless'])) {
interface_sync_wireless_clones($wancfg, false);
}
write_config("Interface {$_POST['descr']}({$if}) is now disabled.");
mark_subsystem_dirty('interfaces');
header("Location: interfaces.php?if={$if}");
@ -773,6 +777,7 @@ function handle_wireless_post() {
$wancfg['wireless']['wep']['key'][] = $newkey;
}
}
interface_sync_wireless_clones($wancfg, true);
}
$pgtitle = array("Interfaces", $pconfig['descr']);
@ -1232,7 +1237,10 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
<td colspan="2" valign="top" height="16"></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic">Wireless configuration</td>
<td colspan="2" valign="top" class="listtopic">Common wireless configuration</td>
</tr>
<tr>
<td colspan="2" valign="top" class="vtable">These settings apply to all wireless networks on <?=$wlanbaseif;?>.</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Standard</td>
@ -1249,16 +1257,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
</select>
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Mode</td>
<td class="vtable">
<select name="mode" class="formselect" id="mode">
<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
</select>
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">802.11g OFDM Protection Mode</td>
<td class="vtable">
@ -1271,6 +1269,61 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
<br/>
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Transmit power</td>
<td class="vtable">
<select name="txpower" class="formselect" id="txpower">
<?
for($x = 99; $x > 0; $x--) {
if($pconfig["txpower"] == $x)
$SELECTED = " SELECTED";
else
$SELECTED = "";
echo "<option {$SELECTED}>{$x}</option>\n";
}
?>
</select><br/>
Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value. Not all adaptors support changing the transmit power setting.
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Channel</td>
<td class="vtable">
<select name="channel" class="formselect" id="channel">
<option <? if ($pconfig['channel'] == 0) echo "selected"; ?> value="0">Auto</option>
<?php
foreach($wl_modes as $wl_standard => $wl_channels) {
if($wl_standard == "11g") { $wl_standard = "11b/g"; }
foreach($wl_channels as $wl_channel) {
echo "<option ";
if ($pconfig['channel'] == "$wl_channel") {
echo "selected ";
}
echo "value=\"$wl_channel\">$wl_standard - $wl_channel</option>\n";
}
}
?>
</select>
<br/>
Note: Not all channels may be supported by your card
</td>
</tr>
<tr>
<td colspan="2" valign="top" height="16"></td>
</tr>
<tr>
<td colspan="2" valign="top" class="listtopic">Wireless configuration</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Mode</td>
<td class="vtable">
<select name="mode" class="formselect" id="mode">
<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
</select>
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">SSID</td>
@ -1311,45 +1364,6 @@ $types = array("none" => "None", "static" => "Static", "dhcp" => "DHCP", "pppoe"
<br/>
(this might create problems for some clients). </td>
</tr>
<tr>
<td valign="top" class="vncellreq">Transmit power</td>
<td class="vtable">
<select name="txpower" class="formselect" id="txpower">
<?
for($x = 99; $x > 0; $x--) {
if($pconfig["txpower"] == $x)
$SELECTED = " SELECTED";
else
$SELECTED = "";
echo "<option {$SELECTED}>{$x}</option>\n";
}
?>
</select><br/>
Note: Typically only a few discreet power settings are available and the driver will use the setting closest to the specified value. Not all adaptors support changing the transmit power setting.
</td>
</tr>
<tr>
<td valign="top" class="vncellreq">Channel</td>
<td class="vtable">
<select name="channel" class="formselect" id="channel">
<option <? if ($pconfig['channel'] == 0) echo "selected"; ?> value="0">Auto</option>
<?php
foreach($wl_modes as $wl_standard => $wl_channels) {
if($wl_standard == "11g") { $wl_standard = "11b/g"; }
foreach($wl_channels as $wl_channel) {
echo "<option ";
if ($pconfig['channel'] == "$wl_channel") {
echo "selected ";
}
echo "value=\"$wl_channel\">$wl_standard - $wl_channel</option>\n";
}
}
?>
</select>
<br/>
Note: Not all channels may be supported by your card
</td>
</tr>
<tr>
<td valign="top" class="vncell">Distance setting</td>
<td class="vtable">

View File

@ -58,6 +58,14 @@ require("rrd.inc");
/* get list without VLAN interfaces */
$portlist = get_interface_list();
/* add wireless clone interfaces */
if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) {
foreach ($config['wireless']['clone'] as $clone) {
$portlist[$clone['cloneif']] = $clone;
$portlist[$clone['cloneif']]['iswlclone'] = true;
}
}
/* add VLAN interfaces */
if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) {
foreach ($config['vlans']['vlan'] as $vlan) {
@ -312,8 +320,10 @@ if ($_GET['act'] == "add") {
}
if (!$portused) {
$config['interfaces'][$newifname]['if'] = $portname;
if (preg_match($g['wireless_regex'], $portname))
if (preg_match($g['wireless_regex'], $portname)) {
$config['interfaces'][$newifname]['wireless'] = array();
interface_sync_wireless_clones($config['interfaces'][$newifname], false);
}
break;
}
}
@ -356,13 +366,14 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
$tab_array = array();
$tab_array[0] = array("Interface assignments", true, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>
@ -392,6 +403,11 @@ if(file_exists("/var/run/interface_mismatch_reboot_needed"))
if ($portinfo['descr'])
$descr .= " (" . $portinfo['descr'] . ")";
echo htmlspecialchars($descr);
} elseif ($portinfo['iswlclone']) {
$descr = $portinfo['cloneif'];
if ($portinfo['descr'])
$descr .= " (" . $portinfo['descr'] . ")";
echo htmlspecialchars($descr);
} elseif ($portinfo['isppp']) {
$descr = "PPP {$portinfo['port']}";
if ($portinfo['descr'])

View File

@ -88,13 +88,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", true, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", true, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -87,13 +87,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", true, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", true, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -87,13 +87,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", true, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", true, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -73,13 +73,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", true, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -93,13 +93,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", true, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", true, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -87,13 +87,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", true, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", true, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -95,13 +95,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", true, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", true, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -89,13 +89,14 @@ include("head.inc");
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("VLANs", true, "interfaces_vlan.php");
$tab_array[3] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[4] = array("PPP", false, "interfaces_ppp.php");
$tab_array[5] = array("GRE", false, "interfaces_gre.php");
$tab_array[6] = array("GIF", false, "interfaces_gif.php");
$tab_array[7] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[8] = array("LAGG", false, "interfaces_lagg.php");
$tab_array[2] = array("Wireless", false, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", true, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>

View File

@ -0,0 +1,146 @@
<?php
/* $Id$ */
/*
interfaces_wireless.php
Copyright (C) 2010 Erik Fonnesbeck
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: interfaces_assign
*/
##|+PRIV
##|*IDENT=page-interfaces-wireless
##|*NAME=Interfaces: Wireless page
##|*DESCR=Allow access to the 'Interfaces: Wireless' page.
##|*MATCH=interfaces_wireless.php*
##|-PRIV
require("guiconfig.inc");
if (!is_array($config['wireless']['clone']))
$config['wireless']['clone'] = array();
$a_clones = &$config['wireless']['clone'];
function clone_inuse($num) {
global $config, $a_clones;
$iflist = get_configured_interface_list(false, true);
foreach ($iflist as $if) {
if ($config['interfaces'][$if]['if'] == $a_clones[$num]['cloneif'])
return true;
}
return false;
}
if ($_GET['act'] == "del") {
/* check if still in use */
if (clone_inuse($_GET['id'])) {
$input_errors[] = "This wireless clone cannot be deleted because it is still being used as an interface.";
} else {
mwexec("/sbin/ifconfig " . $a_clones[$_GET['id']]['cloneif'] . " destroy");
unset($a_clones[$_GET['id']]);
write_config();
header("Location: interfaces_wireless.php");
exit;
}
}
$pgtitle = array("Interfaces","Wireless");
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td>
<?php
$tab_array = array();
$tab_array[0] = array("Interface assignments", false, "interfaces_assign.php");
$tab_array[1] = array("Interface Groups", false, "interfaces_groups.php");
$tab_array[2] = array("Wireless", true, "interfaces_wireless.php");
$tab_array[3] = array("VLANs", false, "interfaces_vlan.php");
$tab_array[4] = array("QinQs", false, "interfaces_qinq.php");
$tab_array[5] = array("PPP", false, "interfaces_ppp.php");
$tab_array[6] = array("GRE", false, "interfaces_gre.php");
$tab_array[7] = array("GIF", false, "interfaces_gif.php");
$tab_array[8] = array("Bridges", false, "interfaces_bridge.php");
$tab_array[9] = array("LAGG", false, "interfaces_lagg.php");
display_top_tabs($tab_array);
?>
</td></tr>
<tr>
<td>
<div id="mainarea">
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="20%" class="listhdrr">Interface</td>
<td width="20%" class="listhdrr">Mode</td>
<td width="50%" class="listhdr">Description</td>
<td width="10%" class="list"></td>
</tr>
<?php $i = 0;
foreach ($a_clones as $clone): ?>
<tr ondblclick="document.location='interfaces_wireless_edit.php?id=<?=$i;?>'">
<td class="listlr">
<?=htmlspecialchars($clone['cloneif']);?>
</td>
<td class="listr">
<?=htmlspecialchars($clone['mode']);?>
</td>
<td class="listbg">
<?=htmlspecialchars($clone['descr']);?>&nbsp;
</td>
<td valign="middle" nowrap class="list"> <a href="interfaces_wireless_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a>
&nbsp;<a href="interfaces_wireless.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this wireless clone?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
</tr>
<?php $i++; endforeach; ?>
<tr>
<td class="list" colspan="3">&nbsp;</td>
<td class="list"> <a href="interfaces_wireless_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
<tr>
<td colspan="3" class="list"><p class="vexpl"><span class="red"><strong>
Note:<br>
</strong></span>
Here you can configure clones of wireless interfaces, which can be assigned as separate independent interfaces. Only available on wireless chipsets that support this, with limitations on the number that can be created in each mode.
</td>
<td class="list">&nbsp;</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<?php include("fend.inc"); ?>
</body>
</html>

View File

@ -0,0 +1,205 @@
<?php
/* $Id$ */
/*
interfaces_wireless_edit.php
Copyright (C) 2010 Erik Fonnesbeck
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/*
pfSense_MODULE: interfaces
*/
##|+PRIV
##|*IDENT=page-interfaces-wireless-edit
##|*NAME=Interfaces: Wireless edit page
##|*DESCR=Allow access to the 'Interfaces: Wireless : Edit' page.
##|*MATCH=interfaces_wireless_edit.php*
##|-PRIV
require("guiconfig.inc");
if (!is_array($config['wireless']['clone']))
$config['wireless']['clone'] = array();
$a_clones = &$config['wireless']['clone'];
function clone_inuse($num) {
global $config, $a_clones;
$iflist = get_configured_interface_list(false, true);
foreach ($iflist as $if) {
if ($config['interfaces'][$if]['if'] == $a_clones[$num]['cloneif'])
return true;
}
return false;
}
function clone_compare($a, $b) {
return strcmp($a['cloneif'], $b['cloneif']);
}
$portlist = get_interface_list();
$id = $_GET['id'];
if (isset($_POST['id']))
$id = $_POST['id'];
if (isset($id) && $a_clones[$id]) {
$pconfig['if'] = $a_clones[$id]['if'];
$pconfig['cloneif'] = $a_clones[$id]['cloneif'];
$pconfig['mode'] = $a_clones[$id]['mode'];
$pconfig['descr'] = $a_clones[$id]['descr'];
}
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
/* input validation */
$reqdfields = explode(" ", "if mode");
$reqdfieldsn = explode(",", "Parent interface,Mode");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if (!$input_errors) {
$clone = array();
$clone['if'] = $_POST['if'];
$clone['mode'] = $_POST['mode'];
$clone['descr'] = $_POST['descr'];
if (isset($id) && $a_clones[$id]) {
if ($clone['if'] == $a_clones[$id]['if'])
$clone['cloneif'] = $a_clones[$id]['cloneif'];
}
if (!$clone['cloneif']) {
$clone_id = 1;
do {
$clone_exists = false;
$clone['cloneif'] = "{$_POST['if']}_wlan{$clone_id}";
foreach ($a_clones as $existing) {
if ($clone['cloneif'] == $existing['cloneif']) {
$clone_exists = true;
$clone_id++;
break;
}
}
} while ($clone_exists);
}
if (isset($id) && $a_clones[$id]) {
if (clone_inuse($id)) {
if ($clone['if'] != $a_clones[$id]['if'])
$input_errors[] = "This wireless clone cannot be modified because it is still assigned as an interface.";
else if ($clone['mode'] != $a_clones[$id]['mode'])
$input_errors[] = "Use the configuration page for the assigned interface to change the mode.";
}
}
if (!$input_errors) {
if (!interface_wireless_clone($clone['cloneif'], $clone)) {
$input_errors[] = "Error creating interface with mode {$clone['mode']}. The {$clone['if']} interface may not support creating more clones with the selected mode.";
} else {
if (isset($id) && $a_clones[$id]) {
if ($clone['if'] != $a_clones[$id]['if'])
mwexec("/sbin/ifconfig " . $a_clones[$id]['cloneif'] . " destroy");
$input_errors[] = "Created with id {$id}";
$a_clones[$id] = $clone;
} else {
$input_errors[] = "Created without id";
$a_clones[] = $clone;
}
usort($a_clones, "clone_compare");
write_config();
header("Location: interfaces_wireless.php");
exit;
}
}
}
}
$pgtitle = array("Firewall","Wireless","Edit");
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<form action="interfaces_wireless_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
<td colspan="2" valign="top" class="listtopic">Wireless clone configuration</td>
</tr>
<tr>
<td width="22%" valign="top" class="vncellreq">Parent interface</td>
<td width="78%" class="vtable">
<select name="if" class="formselect">
<?php
foreach ($portlist as $ifn => $ifinfo)
if (is_interface_wireless($ifn)) {
echo "<option value=\"{$ifn}\"";
if ($ifn == $pconfig['if'])
echo "selected";
echo ">";
echo htmlspecialchars($ifn . " (" . $ifinfo['mac'] . ")");
echo "</option>";
}
?>
</select></td>
</tr>
<tr>
<td valign="top" class="vncellreq">Mode</td>
<td class="vtable">
<select name="mode" class="formselect">
<option <? if ($pconfig['mode'] == 'bss') echo "selected";?> value="bss">Infrastructure (BSS)</option>
<option <? if ($pconfig['mode'] == 'adhoc') echo "selected";?> value="adhoc">Ad-hoc (IBSS)</option>
<option <? if ($pconfig['mode'] == 'hostap') echo "selected";?> value="hostap">Access Point</option>
</select></td>
</tr>
<tr>
<td width="22%" valign="top" class="vncell">Description</td>
<td width="78%" class="vtable">
<input name="descr" type="text" class="formfld unknown" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>">
<br> <span class="vexpl">You may enter a description here
for your reference (not parsed).</span></td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input type="hidden" name="cloneif" value="<?=$pconfig['cloneif']; ?>">
<input name="Submit" type="submit" class="formbtn" value="Save"> <input type="button" value="Cancel" onclick="history.back()">
<?php if (isset($id) && $a_clones[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>">
<?php endif; ?>
</td>
</tr>
</table>
</form>
<?php include("fend.inc"); ?>
</body>
</html>