. 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. */ function wireless_config_init() { global $optcfg, $pconfig; $pconfig['standard'] = $optcfg['wireless']['standard']; $pconfig['mode'] = $optcfg['wireless']['mode']; $pconfig['protmode'] = $optcfg['wireless']['protmode']; $pconfig['ssid'] = $optcfg['wireless']['ssid']; $pconfig['channel'] = $optcfg['wireless']['channel']; $pconfig['txpower'] = $optcfg['wireless']['txpower']; $pconfig['distance'] = $optcfg['wireless']['distance']; $pconfig['wme_enable'] = isset($optcfg['wireless']['wme']['enable']); $pconfig['pureg_enable'] = isset($optcfg['wireless']['pureg']['enable']); $pconfig['apbridge_enable'] = isset($optcfg['wireless']['apbridge']['enable']); $pconfig['authmode'] = $optcfg['wireless']['authmode']; $pconfig['hidessid_enable'] = isset($optcfg['wireless']['hidessid']['enable']); $pconfig['debug_mode'] = $optcfg['wireless']['wpa']['debug_mode']; $pconfig['macaddr_acl'] = $optcfg['wireless']['wpa']['macaddr_acl']; $pconfig['mac_acl_enable'] = isset($optcfg['wireless']['wpa']['mac_acl_enable']); $pconfig['auth_algs'] = $optcfg['wireless']['wpa']['auth_algs']; $pconfig['wpa_mode'] = $optcfg['wireless']['wpa']['wpa_mode']; $pconfig['wpa_key_mgmt'] = $optcfg['wireless']['wpa']['wpa_key_mgmt']; $pconfig['wpa_pairwise'] = $optcfg['wireless']['wpa']['wpa_pairwise']; $pconfig['wpa_group_rekey'] = $optcfg['wireless']['wpa']['wpa_group_rekey']; $pconfig['wpa_gmk_rekey'] = $optcfg['wireless']['wpa']['wpa_gmk_rekey']; $pconfig['wpa_strict_rekey'] = isset($optcfg['wireless']['wpa']['wpa_strict_rekey']); $pconfig['passphrase'] = $optcfg['wireless']['wpa']['passphrase']; $pconfig['ieee8021x_enable'] = isset($optcfg['wireless']['wpa']['ieee8021x']['enable']); $pconfig['ext_wpa_sw'] = $optcfg['wireless']['wpa']['ext_wpa_sw']; $pconfig['wpa_enable'] = isset($optcfg['wireless']['wpa']['enable']); $pconfig['wep_enable'] = isset($optcfg['wireless']['wep']['enable']); $pconfig['mac_acl'] = $optcfg['wireless']['mac_acl']; if (is_array($optcfg['wireless']['wep']['key'])) { $i = 1; foreach ($optcfg['wireless']['wep']['key'] as $wepkey) { $pconfig['key' . $i] = $wepkey['value']; if (isset($wepkey['txkey'])) $pconfig['txkey'] = $i; $i++; } if (!isset($wepkey['txkey'])) $pconfig['txkey'] = 1; } } function wireless_config_post() { global $optcfg, $pconfig; $input_errors = ""; unset($input_errors); /* input validation */ if ($_POST['enable']) { $reqdfields = explode(" ", "mode ssid"); $reqdfieldsn = explode(",", "Mode,SSID"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if (!$input_errors) { /* bridge check (hostap only!) */ if ($pconfig['bridge'] && ($pconfig['mode'] != "hostap")) $input_errors[] = "Bridging a wireless interface is only possible in hostap mode."; } } /* loop through keys and enforce size */ for ($i = 1; $i <= 4; $i++) { if ($_POST['key' . $i]) { /* 64 bit */ if(strlen($_POST['key' . $i]) == 5) continue; if(strlen($_POST['key' . $i]) == 10) { /* hex key */ if(stristr($_POST['key' . $i], "0x") == false) { $_POST['key' . $i] = "0x" . $_POST['key' . $i]; } continue; } if(strlen($_POST['key' . $i]) == 12) { /* hex key */ if(stristr($_POST['key' . $i], "0x") == false) { $_POST['key' . $i] = "0x" . $_POST['key' . $i]; } continue; } /* 128 bit */ if(strlen($_POST['key' . $i]) == 13) continue; if(strlen($_POST['key' . $i]) == 26) { /* hex key */ if(stristr($_POST['key' . $i], "0x") == false) { $_POST['key' . $i] = "0x" . $_POST['key' . $i]; } continue; } if(strlen($_POST['key' . $i]) == 28) continue; $input_errors[] = "Invalid wep key size. Sizes should be 40 (64) bit keys or 104 (128) bit."; break; } } if (!$input_errors) { $optcfg['wireless']['standard'] = $_POST['standard']; $optcfg['wireless']['mode'] = $_POST['mode']; $optcfg['wireless']['protmode'] = $_POST['protmode']; $optcfg['wireless']['ssid'] = $_POST['ssid']; $optcfg['wireless']['channel'] = $_POST['channel']; $optcfg['wireless']['authmode'] = $_POST['authmode']; $optcfg['wireless']['txpower'] = $_POST['txpower']; $optcfg['wireless']['distance'] = $_POST['distance']; $optcfg['wireless']['wpa']['macaddr_acl'] = $_POST['macaddr_acl']; $optcfg['wireless']['wpa']['auth_algs'] = $_POST['auth_algs']; $optcfg['wireless']['wpa']['wpa_mode'] = $_POST['wpa_mode']; $optcfg['wireless']['wpa']['wpa_key_mgmt'] = $_POST['wpa_key_mgmt']; $optcfg['wireless']['wpa']['wpa_pairwise'] = $_POST['wpa_pairwise']; $optcfg['wireless']['wpa']['wpa_group_rekey'] = $_POST['wpa_group_rekey']; $optcfg['wireless']['wpa']['wpa_gmk_rekey'] = $_POST['wpa_gmk_rekey']; $optcfg['wireless']['wpa']['passphrase'] = $_POST['passphrase']; $optcfg['wireless']['wpa']['ext_wpa_sw'] = $_POST['ext_wpa_sw']; if($_POST['hidessid_enable'] == "yes") $optcfg['wireless']['hidessid']['enable'] = true; else unset($optcfg['wireless']['hidessid']['enable']); if($_POST['mac_acl_enable'] == "yes") $optcfg['wireless']['wpa']['mac_acl_enable'] = true; else unset($optcfg['wireless']['wpa']['mac_acl_enable']); if($_POST['ieee8021x_enable'] == "yes") $optcfg['wireless']['wpa']['ieee8021x']['enable'] = true; else unset($optcfg['wireless']['wpa']['ieee8021x']['enable']); if($_POST['wpa_strict_rekey'] == "yes") $optcfg['wireless']['wpa']['wpa_strict_rekey'] = true; else unset($optcfg['wireless']['wpa']['wpa_strict_rekey']); if($_POST['debug_mode'] == "yes") $optcfg['wireless']['wpa']['debug_mode'] = true; else unset($optcfg['wireless']['wpa']['debug_mode']); if($_POST['wpa_enable'] == "yes") $optcfg['wireless']['wpa']['enable'] = $_POST['wpa_enable'] = true; else unset($optcfg['wireless']['wpa']['enable']); if($_POST['wep_enable'] == "yes") $optcfg['wireless']['wep']['enable'] = $_POST['wep_enable'] = true; else unset($optcfg['wireless']['wep']['enable']); if($_POST['wme_enable'] == "yes") $optcfg['wireless']['wme']['enable'] = $_POST['wme_enable'] = true; else unset($optcfg['wireless']['wme']['enable']); if($_POST['pureg_enable'] == "yes") $optcfg['wireless']['pureg']['enable'] = $_POST['pureg_enable'] = true; else unset($optcfg['wireless']['pureg']['enable']); if($_POST['apbridge_enable'] == "yes") $optcfg['wireless']['apbridge']['enable'] = $_POST['apbridge_enable'] = true; else unset($optcfg['wireless']['apbridge']['enable']); if($_POST['standard'] == "11a Turbo") $optcfg['wireless']['turbo']['enable'] = true; else unset($optcfg['wireless']['turbo']['enable']); $optcfg['wireless']['wep']['key'] = array(); for ($i = 1; $i <= 4; $i++) { if ($_POST['key' . $i]) { $newkey = array(); $newkey['value'] = $_POST['key' . $i]; if ($_POST['txkey'] == $i) $newkey['txkey'] = true; $optcfg['wireless']['wep']['key'][] = $newkey; } } } return $input_errors; } if($wancfg['if']) $curif = $lancfg['if']; if($wancfg['if']) $curif = $lancfg['if']; if($optcfg['if']) $curif = $optcfg['if']; $wl_modes = get_wireless_modes($curif); function wireless_config_print() { global $optcfg, $pconfig, $wl_modes, $g; ?> Wireless configuration Standard Mode 802.11g OFDM Protection Mode
For IEEE 802.11g, use the specified technique for protecting OFDM frames in a mixed 11b/11g network.
SSID 802.11g only >
When operating as an access point in 802.11g mode allow only 11g-capable stations to associate (11b-only stations are not permitted to associate). Allow intra-BSS communication >
When operating as an access point, enable this if you want to pass packets between wireless clients directly.
Disabling the internal bridging is useful when traffic is to be processed with packet filtering. Enable WME >
Setting this option will force the card to use WME (wireless QoS). Enable Hide SSID >
Setting this option will force the card to NOT broadcast its SSID
(this might create problems for some clients). Transmit power
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. Channel
Note: Not all channels may be supported by your card Distance setting
Note: This field can be used to tune ACK/CTS timers to fit the distance between AP and Client
(measured in Meters and works only for Atheros based cards !) WEP > Enable WEP
     TX key 
Key 1:   >
Key 2:   >
Key 3:   >
Key 4:   >

40 (64) bit keys may be entered as 5 ASCII characters or 10 hex digits preceded by '0x'.
104 (128) bit keys may be entered as 13 ASCII characters or 26 hex digits preceded by '0x'. WPA > Enable WPA

   WPA Pre Shared Key 
PSK:  

Passphrase must be from 8 to 63 chars. WPA Mode WPA Key Management Mode Enable MAC Filtering > Setting this option will enable the use of a mac filterlist to allow/deny association based on mac address



Setting this to "Allow" will allow all clients in not in deny list, while "Deny" will deny all clients not in allow list. Radius will cause allow and deny list to be searched and then query radius.
*/ ?> Authentication
Note: Shared Key Authentication requires WEP.
WPA Pairwise Key Rotation ">
Allowed values are 1-9999 but should not be longer than Master Key Regeneration time. Master Key Regeneration ">
Allowed values are 1-9999 but should not be shorter than Key Rotation time. Strict Key Regeneration >
Setting this option will force the AP to rekey whenever a client disassociates. Enable IEEE802.1X >
Setting this option will enable 802.1x authentication.