Automatic merge of /spare/repo/netdev-2.6 branch we18-ieee80211
This commit is contained in:
commit
6cd15a9daf
28 changed files with 25247 additions and 121 deletions
246
Documentation/networking/README.ipw2100
Normal file
246
Documentation/networking/README.ipw2100
Normal file
|
@ -0,0 +1,246 @@
|
|||
|
||||
===========================
|
||||
Intel(R) PRO/Wireless 2100 Network Connection Driver for Linux
|
||||
README.ipw2100
|
||||
|
||||
March 14, 2005
|
||||
|
||||
===========================
|
||||
Index
|
||||
---------------------------
|
||||
0. Introduction
|
||||
1. Release 1.1.0 Current Features
|
||||
2. Command Line Parameters
|
||||
3. Sysfs Helper Files
|
||||
4. Radio Kill Switch
|
||||
5. Dynamic Firmware
|
||||
6. Power Management
|
||||
7. Support
|
||||
8. License
|
||||
|
||||
|
||||
===========================
|
||||
0. Introduction
|
||||
------------ ----- ----- ---- --- -- -
|
||||
|
||||
This document provides a brief overview of the features supported by the
|
||||
IPW2100 driver project. The main project website, where the latest
|
||||
development version of the driver can be found, is:
|
||||
|
||||
http://ipw2100.sourceforge.net
|
||||
|
||||
There you can find the not only the latest releases, but also information about
|
||||
potential fixes and patches, as well as links to the development mailing list
|
||||
for the driver project.
|
||||
|
||||
|
||||
===========================
|
||||
1. Release 1.1.0 Current Supported Features
|
||||
---------------------------
|
||||
- Managed (BSS) and Ad-Hoc (IBSS)
|
||||
- WEP (shared key and open)
|
||||
- Wireless Tools support
|
||||
- 802.1x (tested with XSupplicant 1.0.1)
|
||||
|
||||
Enabled (but not supported) features:
|
||||
- Monitor/RFMon mode
|
||||
- WPA/WPA2
|
||||
|
||||
The distinction between officially supported and enabled is a reflection
|
||||
on the amount of validation and interoperability testing that has been
|
||||
performed on a given feature.
|
||||
|
||||
|
||||
===========================
|
||||
2. Command Line Parameters
|
||||
---------------------------
|
||||
|
||||
If the driver is built as a module, the following optional parameters are used
|
||||
by entering them on the command line with the modprobe command using this
|
||||
syntax:
|
||||
|
||||
modprobe ipw2100 [<option>=<VAL1><,VAL2>...]
|
||||
|
||||
For example, to disable the radio on driver loading, enter:
|
||||
|
||||
modprobe ipw2100 disable=1
|
||||
|
||||
The ipw2100 driver supports the following module parameters:
|
||||
|
||||
Name Value Example:
|
||||
debug 0x0-0xffffffff debug=1024
|
||||
mode 0,1,2 mode=1 /* AdHoc */
|
||||
channel int channel=3 /* Only valid in AdHoc or Monitor */
|
||||
associate boolean associate=0 /* Do NOT auto associate */
|
||||
disable boolean disable=1 /* Do not power the HW */
|
||||
|
||||
|
||||
===========================
|
||||
3. Sysfs Helper Files
|
||||
---------------------------
|
||||
|
||||
There are several ways to control the behavior of the driver. Many of the
|
||||
general capabilities are exposed through the Wireless Tools (iwconfig). There
|
||||
are a few capabilities that are exposed through entries in the Linux Sysfs.
|
||||
|
||||
|
||||
----- Driver Level ------
|
||||
For the driver level files, look in /sys/bus/pci/drivers/ipw2100/
|
||||
|
||||
debug_level
|
||||
|
||||
This controls the same global as the 'debug' module parameter. For
|
||||
information on the various debugging levels available, run the 'dvals'
|
||||
script found in the driver source directory.
|
||||
|
||||
NOTE: 'debug_level' is only enabled if CONFIG_IPW2100_DEBUG is turn
|
||||
on.
|
||||
|
||||
----- Device Level ------
|
||||
For the device level files look in
|
||||
|
||||
/sys/bus/pci/drivers/ipw2100/{PCI-ID}/
|
||||
|
||||
For example:
|
||||
/sys/bus/pci/drivers/ipw2100/0000:02:01.0
|
||||
|
||||
For the device level files, see /sys/bus/pci/drivers/ipw2100:
|
||||
|
||||
rf_kill
|
||||
read -
|
||||
0 = RF kill not enabled (radio on)
|
||||
1 = SW based RF kill active (radio off)
|
||||
2 = HW based RF kill active (radio off)
|
||||
3 = Both HW and SW RF kill active (radio off)
|
||||
write -
|
||||
0 = If SW based RF kill active, turn the radio back on
|
||||
1 = If radio is on, activate SW based RF kill
|
||||
|
||||
NOTE: If you enable the SW based RF kill and then toggle the HW
|
||||
based RF kill from ON -> OFF -> ON, the radio will NOT come back on
|
||||
|
||||
|
||||
===========================
|
||||
4. Radio Kill Switch
|
||||
---------------------------
|
||||
Most laptops provide the ability for the user to physically disable the radio.
|
||||
Some vendors have implemented this as a physical switch that requires no
|
||||
software to turn the radio off and on. On other laptops, however, the switch
|
||||
is controlled through a button being pressed and a software driver then making
|
||||
calls to turn the radio off and on. This is referred to as a "software based
|
||||
RF kill switch"
|
||||
|
||||
See the Sysfs helper file 'rf_kill' for determining the state of the RF switch
|
||||
on your system.
|
||||
|
||||
|
||||
===========================
|
||||
5. Dynamic Firmware
|
||||
---------------------------
|
||||
As the firmware is licensed under a restricted use license, it can not be
|
||||
included within the kernel sources. To enable the IPW2100 you will need a
|
||||
firmware image to load into the wireless NIC's processors.
|
||||
|
||||
You can obtain these images from <http://ipw2100.sf.net/firmware.php>.
|
||||
|
||||
See INSTALL for instructions on installing the firmware.
|
||||
|
||||
|
||||
===========================
|
||||
6. Power Management
|
||||
---------------------------
|
||||
The IPW2100 supports the configuration of the Power Save Protocol
|
||||
through a private wireless extension interface. The IPW2100 supports
|
||||
the following different modes:
|
||||
|
||||
off No power management. Radio is always on.
|
||||
on Automatic power management
|
||||
1-5 Different levels of power management. The higher the
|
||||
number the greater the power savings, but with an impact to
|
||||
packet latencies.
|
||||
|
||||
Power management works by powering down the radio after a certain
|
||||
interval of time has passed where no packets are passed through the
|
||||
radio. Once powered down, the radio remains in that state for a given
|
||||
period of time. For higher power savings, the interval between last
|
||||
packet processed to sleep is shorter and the sleep period is longer.
|
||||
|
||||
When the radio is asleep, the access point sending data to the station
|
||||
must buffer packets at the AP until the station wakes up and requests
|
||||
any buffered packets. If you have an AP that does not correctly support
|
||||
the PSP protocol you may experience packet loss or very poor performance
|
||||
while power management is enabled. If this is the case, you will need
|
||||
to try and find a firmware update for your AP, or disable power
|
||||
management (via `iwconfig eth1 power off`)
|
||||
|
||||
To configure the power level on the IPW2100 you use a combination of
|
||||
iwconfig and iwpriv. iwconfig is used to turn power management on, off,
|
||||
and set it to auto.
|
||||
|
||||
iwconfig eth1 power off Disables radio power down
|
||||
iwconfig eth1 power on Enables radio power management to
|
||||
last set level (defaults to AUTO)
|
||||
iwpriv eth1 set_power 0 Sets power level to AUTO and enables
|
||||
power management if not previously
|
||||
enabled.
|
||||
iwpriv eth1 set_power 1-5 Set the power level as specified,
|
||||
enabling power management if not
|
||||
previously enabled.
|
||||
|
||||
You can view the current power level setting via:
|
||||
|
||||
iwpriv eth1 get_power
|
||||
|
||||
It will return the current period or timeout that is configured as a string
|
||||
in the form of xxxx/yyyy (z) where xxxx is the timeout interval (amount of
|
||||
time after packet processing), yyyy is the period to sleep (amount of time to
|
||||
wait before powering the radio and querying the access point for buffered
|
||||
packets), and z is the 'power level'. If power management is turned off the
|
||||
xxxx/yyyy will be replaced with 'off' -- the level reported will be the active
|
||||
level if `iwconfig eth1 power on` is invoked.
|
||||
|
||||
|
||||
===========================
|
||||
7. Support
|
||||
---------------------------
|
||||
|
||||
For general development information and support,
|
||||
go to:
|
||||
|
||||
http://ipw2100.sf.net/
|
||||
|
||||
The ipw2100 1.1.0 driver and firmware can be downloaded from:
|
||||
|
||||
http://support.intel.com
|
||||
|
||||
For installation support on the ipw2100 1.1.0 driver on Linux kernels
|
||||
2.6.8 or greater, email support is available from:
|
||||
|
||||
http://supportmail.intel.com
|
||||
|
||||
===========================
|
||||
8. License
|
||||
---------------------------
|
||||
|
||||
Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License (version 2) as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in the
|
||||
file called LICENSE.
|
||||
|
||||
License Contact Information:
|
||||
James P. Ketrenos <ipw2100-admin@linux.intel.com>
|
||||
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
||||
|
300
Documentation/networking/README.ipw2200
Normal file
300
Documentation/networking/README.ipw2200
Normal file
|
@ -0,0 +1,300 @@
|
|||
|
||||
Intel(R) PRO/Wireless 2915ABG Driver for Linux in support of:
|
||||
|
||||
Intel(R) PRO/Wireless 2200BG Network Connection
|
||||
Intel(R) PRO/Wireless 2915ABG Network Connection
|
||||
|
||||
Note: The Intel(R) PRO/Wireless 2915ABG Driver for Linux and Intel(R)
|
||||
PRO/Wireless 2200BG Driver for Linux is a unified driver that works on
|
||||
both hardware adapters listed above. In this document the Intel(R)
|
||||
PRO/Wireless 2915ABG Driver for Linux will be used to reference the
|
||||
unified driver.
|
||||
|
||||
Copyright (C) 2004-2005, Intel Corporation
|
||||
|
||||
README.ipw2200
|
||||
|
||||
Version: 1.0.0
|
||||
Date : January 31, 2005
|
||||
|
||||
|
||||
Index
|
||||
-----------------------------------------------
|
||||
1. Introduction
|
||||
1.1. Overview of features
|
||||
1.2. Module parameters
|
||||
1.3. Wireless Extension Private Methods
|
||||
1.4. Sysfs Helper Files
|
||||
2. About the Version Numbers
|
||||
3. Support
|
||||
4. License
|
||||
|
||||
|
||||
1. Introduction
|
||||
-----------------------------------------------
|
||||
The following sections attempt to provide a brief introduction to using
|
||||
the Intel(R) PRO/Wireless 2915ABG Driver for Linux.
|
||||
|
||||
This document is not meant to be a comprehensive manual on
|
||||
understanding or using wireless technologies, but should be sufficient
|
||||
to get you moving without wires on Linux.
|
||||
|
||||
For information on building and installing the driver, see the INSTALL
|
||||
file.
|
||||
|
||||
|
||||
1.1. Overview of Features
|
||||
-----------------------------------------------
|
||||
The current release (1.0.0) supports the following features:
|
||||
|
||||
+ BSS mode (Infrastructure, Managed)
|
||||
+ IBSS mode (Ad-Hoc)
|
||||
+ WEP (OPEN and SHARED KEY mode)
|
||||
+ 802.1x EAP via wpa_supplicant and xsupplicant
|
||||
+ Wireless Extension support
|
||||
+ Full B and G rate support (2200 and 2915)
|
||||
+ Full A rate support (2915 only)
|
||||
+ Transmit power control
|
||||
+ S state support (ACPI suspend/resume)
|
||||
+ long/short preamble support
|
||||
|
||||
|
||||
|
||||
1.2. Command Line Parameters
|
||||
-----------------------------------------------
|
||||
|
||||
Like many modules used in the Linux kernel, the Intel(R) PRO/Wireless
|
||||
2915ABG Driver for Linux allows certain configuration options to be
|
||||
provided as module parameters. The most common way to specify a module
|
||||
parameter is via the command line.
|
||||
|
||||
The general form is:
|
||||
|
||||
% modprobe ipw2200 parameter=value
|
||||
|
||||
Where the supported parameter are:
|
||||
|
||||
associate
|
||||
Set to 0 to disable the auto scan-and-associate functionality of the
|
||||
driver. If disabled, the driver will not attempt to scan
|
||||
for and associate to a network until it has been configured with
|
||||
one or more properties for the target network, for example configuring
|
||||
the network SSID. Default is 1 (auto-associate)
|
||||
|
||||
Example: % modprobe ipw2200 associate=0
|
||||
|
||||
auto_create
|
||||
Set to 0 to disable the auto creation of an Ad-Hoc network
|
||||
matching the channel and network name parameters provided.
|
||||
Default is 1.
|
||||
|
||||
channel
|
||||
channel number for association. The normal method for setting
|
||||
the channel would be to use the standard wireless tools
|
||||
(i.e. `iwconfig eth1 channel 10`), but it is useful sometimes
|
||||
to set this while debugging. Channel 0 means 'ANY'
|
||||
|
||||
debug
|
||||
If using a debug build, this is used to control the amount of debug
|
||||
info is logged. See the 'dval' and 'load' script for more info on
|
||||
how to use this (the dval and load scripts are provided as part
|
||||
of the ipw2200 development snapshot releases available from the
|
||||
SourceForge project at http://ipw2200.sf.net)
|
||||
|
||||
mode
|
||||
Can be used to set the default mode of the adapter.
|
||||
0 = Managed, 1 = Ad-Hoc
|
||||
|
||||
|
||||
1.3. Wireless Extension Private Methods
|
||||
-----------------------------------------------
|
||||
|
||||
As an interface designed to handle generic hardware, there are certain
|
||||
capabilities not exposed through the normal Wireless Tool interface. As
|
||||
such, a provision is provided for a driver to declare custom, or
|
||||
private, methods. The Intel(R) PRO/Wireless 2915ABG Driver for Linux
|
||||
defines several of these to configure various settings.
|
||||
|
||||
The general form of using the private wireless methods is:
|
||||
|
||||
% iwpriv $IFNAME method parameters
|
||||
|
||||
Where $IFNAME is the interface name the device is registered with
|
||||
(typically eth1, customized via one of the various network interface
|
||||
name managers, such as ifrename)
|
||||
|
||||
The supported private methods are:
|
||||
|
||||
get_mode
|
||||
Can be used to report out which IEEE mode the driver is
|
||||
configured to support. Example:
|
||||
|
||||
% iwpriv eth1 get_mode
|
||||
eth1 get_mode:802.11bg (6)
|
||||
|
||||
set_mode
|
||||
Can be used to configure which IEEE mode the driver will
|
||||
support.
|
||||
|
||||
Usage:
|
||||
% iwpriv eth1 set_mode {mode}
|
||||
Where {mode} is a number in the range 1-7:
|
||||
1 802.11a (2915 only)
|
||||
2 802.11b
|
||||
3 802.11ab (2915 only)
|
||||
4 802.11g
|
||||
5 802.11ag (2915 only)
|
||||
6 802.11bg
|
||||
7 802.11abg (2915 only)
|
||||
|
||||
get_preamble
|
||||
Can be used to report configuration of preamble length.
|
||||
|
||||
set_preamble
|
||||
Can be used to set the configuration of preamble length:
|
||||
|
||||
Usage:
|
||||
% iwpriv eth1 set_preamble {mode}
|
||||
Where {mode} is one of:
|
||||
1 Long preamble only
|
||||
0 Auto (long or short based on connection)
|
||||
|
||||
|
||||
1.4. Sysfs Helper Files:
|
||||
-----------------------------------------------
|
||||
|
||||
The Linux kernel provides a pseudo file system that can be used to
|
||||
access various components of the operating system. The Intel(R)
|
||||
PRO/Wireless 2915ABG Driver for Linux exposes several configuration
|
||||
parameters through this mechanism.
|
||||
|
||||
An entry in the sysfs can support reading and/or writing. You can
|
||||
typically query the contents of a sysfs entry through the use of cat,
|
||||
and can set the contents via echo. For example:
|
||||
|
||||
% cat /sys/bus/pci/drivers/ipw2200/debug_level
|
||||
|
||||
Will report the current debug level of the driver's logging subsystem
|
||||
(only available if CONFIG_IPW_DEBUG was configured when the driver was
|
||||
built).
|
||||
|
||||
You can set the debug level via:
|
||||
|
||||
% echo $VALUE > /sys/bus/pci/drivers/ipw2200/debug_level
|
||||
|
||||
Where $VALUE would be a number in the case of this sysfs entry. The
|
||||
input to sysfs files does not have to be a number. For example, the
|
||||
firmware loader used by hotplug utilizes sysfs entries for transferring
|
||||
the firmware image from user space into the driver.
|
||||
|
||||
The Intel(R) PRO/Wireless 2915ABG Driver for Linux exposes sysfs entries
|
||||
at two levels -- driver level, which apply to all instances of the
|
||||
driver (in the event that there are more than one device installed) and
|
||||
device level, which applies only to the single specific instance.
|
||||
|
||||
|
||||
1.4.1 Driver Level Sysfs Helper Files
|
||||
-----------------------------------------------
|
||||
|
||||
For the driver level files, look in /sys/bus/pci/drivers/ipw2200/
|
||||
|
||||
debug_level
|
||||
|
||||
This controls the same global as the 'debug' module parameter
|
||||
|
||||
|
||||
1.4.2 Device Level Sysfs Helper Files
|
||||
-----------------------------------------------
|
||||
|
||||
For the device level files, look in
|
||||
|
||||
/sys/bus/pci/drivers/ipw2200/{PCI-ID}/
|
||||
|
||||
For example:
|
||||
/sys/bus/pci/drivers/ipw2200/0000:02:01.0
|
||||
|
||||
For the device level files, see /sys/bus/pci/[drivers/ipw2200:
|
||||
|
||||
rf_kill
|
||||
read -
|
||||
0 = RF kill not enabled (radio on)
|
||||
1 = SW based RF kill active (radio off)
|
||||
2 = HW based RF kill active (radio off)
|
||||
3 = Both HW and SW RF kill active (radio off)
|
||||
write -
|
||||
0 = If SW based RF kill active, turn the radio back on
|
||||
1 = If radio is on, activate SW based RF kill
|
||||
|
||||
NOTE: If you enable the SW based RF kill and then toggle the HW
|
||||
based RF kill from ON -> OFF -> ON, the radio will NOT come back on
|
||||
|
||||
ucode
|
||||
read-only access to the ucode version number
|
||||
|
||||
|
||||
2. About the Version Numbers
|
||||
-----------------------------------------------
|
||||
|
||||
Due to the nature of open source development projects, there are
|
||||
frequently changes being incorporated that have not gone through
|
||||
a complete validation process. These changes are incorporated into
|
||||
development snapshot releases.
|
||||
|
||||
Releases are numbered with a three level scheme:
|
||||
|
||||
major.minor.development
|
||||
|
||||
Any version where the 'development' portion is 0 (for example
|
||||
1.0.0, 1.1.0, etc.) indicates a stable version that will be made
|
||||
available for kernel inclusion.
|
||||
|
||||
Any version where the 'development' portion is not a 0 (for
|
||||
example 1.0.1, 1.1.5, etc.) indicates a development version that is
|
||||
being made available for testing and cutting edge users. The stability
|
||||
and functionality of the development releases are not know. We make
|
||||
efforts to try and keep all snapshots reasonably stable, but due to the
|
||||
frequency of their release, and the desire to get those releases
|
||||
available as quickly as possible, unknown anomalies should be expected.
|
||||
|
||||
The major version number will be incremented when significant changes
|
||||
are made to the driver. Currently, there are no major changes planned.
|
||||
|
||||
|
||||
3. Support
|
||||
-----------------------------------------------
|
||||
|
||||
For installation support of the 1.0.0 version, you can contact
|
||||
http://supportmail.intel.com, or you can use the open source project
|
||||
support.
|
||||
|
||||
For general information and support, go to:
|
||||
|
||||
http://ipw2200.sf.net/
|
||||
|
||||
|
||||
4. License
|
||||
-----------------------------------------------
|
||||
|
||||
Copyright(c) 2003 - 2005 Intel Corporation. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License version 2 as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in the
|
||||
file called LICENSE.
|
||||
|
||||
Contact Information:
|
||||
James P. Ketrenos <ipw2100-admin@linux.intel.com>
|
||||
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
||||
|
||||
|
|
@ -137,6 +137,111 @@ config PCMCIA_RAYCS
|
|||
comment "Wireless 802.11b ISA/PCI cards support"
|
||||
depends on NET_RADIO && (ISA || PCI || PPC_PMAC || PCMCIA)
|
||||
|
||||
config IPW2100
|
||||
tristate "Intel PRO/Wireless 2100 Network Connection"
|
||||
depends on NET_RADIO && PCI && IEEE80211
|
||||
select FW_LOADER
|
||||
---help---
|
||||
A driver for the Intel PRO/Wireless 2100 Network
|
||||
Connection 802.11b wireless network adapter.
|
||||
|
||||
See <file:Documentation/networking/README.ipw2100> for information on
|
||||
the capabilities currently enabled in this driver and for tips
|
||||
for debugging issues and problems.
|
||||
|
||||
In order to use this driver, you will need a firmware image for it.
|
||||
You can obtain the firmware from
|
||||
<http://ipw2100.sf.net/>. Once you have the firmware image, you
|
||||
will need to place it in /etc/firmware.
|
||||
|
||||
You will also very likely need the Wireless Tools in order to
|
||||
configure your card:
|
||||
|
||||
<http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
|
||||
|
||||
If you want to compile the driver as a module ( = code which can be
|
||||
inserted in and remvoed from the running kernel whenever you want),
|
||||
say M here and read <file:Documentation/modules.txt>. The module
|
||||
will be called ipw2100.ko.
|
||||
|
||||
config IPW2100_PROMISC
|
||||
bool "Enable promiscuous mode"
|
||||
depends on IPW2100
|
||||
---help---
|
||||
Enables promiscuous/monitor mode support for the ipw2100 driver.
|
||||
With this feature compiled into the driver, you can switch to
|
||||
promiscuous mode via the Wireless Tool's Monitor mode. While in this
|
||||
mode, no packets can be sent.
|
||||
|
||||
config IPW_DEBUG
|
||||
bool "Enable full debugging output in IPW2100 module."
|
||||
depends on IPW2100
|
||||
---help---
|
||||
This option will enable debug tracing output for the IPW2100.
|
||||
|
||||
This will result in the kernel module being ~60k larger. You can
|
||||
control which debug output is sent to the kernel log by setting the
|
||||
value in
|
||||
|
||||
/sys/bus/pci/drivers/ipw2100/debug_level
|
||||
|
||||
This entry will only exist if this option is enabled.
|
||||
|
||||
If you are not trying to debug or develop the IPW2100 driver, you
|
||||
most likely want to say N here.
|
||||
|
||||
config IPW2200
|
||||
tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
|
||||
depends on NET_RADIO && PCI
|
||||
select FW_LOADER
|
||||
select IEEE80211
|
||||
---help---
|
||||
A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network
|
||||
Connection adapters.
|
||||
|
||||
See <file:Documentation/networking/README.ipw2200> for
|
||||
information on the capabilities currently enabled in this
|
||||
driver and for tips for debugging issues and problems.
|
||||
|
||||
In order to use this driver, you will need a firmware image for it.
|
||||
You can obtain the firmware from
|
||||
<http://ipw2200.sf.net/>. See the above referenced README.ipw2200
|
||||
for information on where to install the firmare images.
|
||||
|
||||
You will also very likely need the Wireless Tools in order to
|
||||
configure your card:
|
||||
|
||||
<http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
|
||||
|
||||
If you want to compile the driver as a module ( = code which can be
|
||||
inserted in and remvoed from the running kernel whenever you want),
|
||||
say M here and read <file:Documentation/modules.txt>. The module
|
||||
will be called ipw2200.ko.
|
||||
|
||||
config IPW_DEBUG
|
||||
bool "Enable full debugging output in IPW2200 module."
|
||||
depends on IPW2200
|
||||
---help---
|
||||
This option will enable debug tracing output for the IPW2200.
|
||||
|
||||
This will result in the kernel module being ~100k larger. You can
|
||||
control which debug output is sent to the kernel log by setting the
|
||||
value in
|
||||
|
||||
/sys/bus/pci/drivers/ipw2200/debug_level
|
||||
|
||||
This entry will only exist if this option is enabled.
|
||||
|
||||
To set a value, simply echo an 8-byte hex value to the same file:
|
||||
|
||||
% echo 0x00000FFO > /sys/bus/pci/drivers/ipw2200/debug_level
|
||||
|
||||
You can find the list of debug mask values in
|
||||
drivers/net/wireless/ipw2200.h
|
||||
|
||||
If you are not trying to debug or develop the IPW2200 driver, you
|
||||
most likely want to say N here.
|
||||
|
||||
config AIRO
|
||||
tristate "Cisco/Aironet 34X/35X/4500/4800 ISA and PCI cards"
|
||||
depends on NET_RADIO && ISA && (PCI || BROKEN)
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
# Makefile for the Linux Wireless network device drivers.
|
||||
#
|
||||
|
||||
obj-$(CONFIG_IPW2100) += ipw2100.o
|
||||
|
||||
obj-$(CONFIG_IPW2200) += ipw2200.o
|
||||
|
||||
obj-$(CONFIG_STRIP) += strip.o
|
||||
obj-$(CONFIG_ARLAN) += arlan.o
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
#include <linux/device.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/firmware.h>
|
||||
#include "ieee802_11.h"
|
||||
#include <net/ieee80211.h>
|
||||
#include "atmel.h"
|
||||
|
||||
#define DRIVER_MAJOR 0
|
||||
|
@ -618,12 +618,12 @@ static int atmel_lock_mac(struct atmel_private *priv);
|
|||
static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
|
||||
static void atmel_command_irq(struct atmel_private *priv);
|
||||
static int atmel_validate_channel(struct atmel_private *priv, int channel);
|
||||
static void atmel_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u16 frame_len, u8 rssi);
|
||||
static void atmel_management_timer(u_long a);
|
||||
static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size);
|
||||
static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size);
|
||||
static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u8 *body, int body_len);
|
||||
|
||||
static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
|
||||
|
@ -827,7 +827,7 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
|
|||
static int start_tx (struct sk_buff *skb, struct net_device *dev)
|
||||
{
|
||||
struct atmel_private *priv = netdev_priv(dev);
|
||||
struct ieee802_11_hdr header;
|
||||
struct ieee80211_hdr header;
|
||||
unsigned long flags;
|
||||
u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
|
||||
u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
|
||||
|
@ -863,17 +863,17 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
|
|||
return 1;
|
||||
}
|
||||
|
||||
frame_ctl = IEEE802_11_FTYPE_DATA;
|
||||
frame_ctl = IEEE80211_FTYPE_DATA;
|
||||
header.duration_id = 0;
|
||||
header.seq_ctl = 0;
|
||||
if (priv->wep_is_on)
|
||||
frame_ctl |= IEEE802_11_FCTL_WEP;
|
||||
frame_ctl |= IEEE80211_FCTL_WEP;
|
||||
if (priv->operating_mode == IW_MODE_ADHOC) {
|
||||
memcpy(&header.addr1, skb->data, 6);
|
||||
memcpy(&header.addr2, dev->dev_addr, 6);
|
||||
memcpy(&header.addr3, priv->BSSID, 6);
|
||||
} else {
|
||||
frame_ctl |= IEEE802_11_FCTL_TODS;
|
||||
frame_ctl |= IEEE80211_FCTL_TODS;
|
||||
memcpy(&header.addr1, priv->CurrentBSSID, 6);
|
||||
memcpy(&header.addr2, dev->dev_addr, 6);
|
||||
memcpy(&header.addr3, skb->data, 6);
|
||||
|
@ -902,7 +902,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
|
|||
}
|
||||
|
||||
static void atmel_transmit_management_frame(struct atmel_private *priv,
|
||||
struct ieee802_11_hdr *header,
|
||||
struct ieee80211_hdr *header,
|
||||
u8 *body, int body_len)
|
||||
{
|
||||
u16 buff;
|
||||
|
@ -917,7 +917,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
|
|||
tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT);
|
||||
}
|
||||
|
||||
static void fast_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u16 msdu_size, u16 rx_packet_loc, u32 crc)
|
||||
{
|
||||
/* fast path: unfragmented packet copy directly into skbuf */
|
||||
|
@ -955,7 +955,7 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *head
|
|||
}
|
||||
|
||||
memcpy(skbp, header->addr1, 6); /* destination address */
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS)
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
|
||||
memcpy(&skbp[6], header->addr3, 6);
|
||||
else
|
||||
memcpy(&skbp[6], header->addr2, 6); /* source address */
|
||||
|
@ -990,14 +990,14 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
|
|||
return (crc ^ 0xffffffff) == netcrc;
|
||||
}
|
||||
|
||||
static void frag_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags)
|
||||
{
|
||||
u8 mac4[6];
|
||||
u8 source[6];
|
||||
struct sk_buff *skb;
|
||||
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS)
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
|
||||
memcpy(source, header->addr3, 6);
|
||||
else
|
||||
memcpy(source, header->addr2, 6);
|
||||
|
@ -1082,7 +1082,7 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee802_11_hdr *head
|
|||
static void rx_done_irq(struct atmel_private *priv)
|
||||
{
|
||||
int i;
|
||||
struct ieee802_11_hdr header;
|
||||
struct ieee80211_hdr header;
|
||||
|
||||
for (i = 0;
|
||||
atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
|
||||
|
@ -1117,7 +1117,7 @@ static void rx_done_irq(struct atmel_private *priv)
|
|||
/* probe for CRC use here if needed once five packets have arrived with
|
||||
the same crc status, we assume we know what's happening and stop probing */
|
||||
if (priv->probe_crc) {
|
||||
if (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP)) {
|
||||
if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_WEP)) {
|
||||
priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size);
|
||||
} else {
|
||||
priv->do_rx_crc = probe_crc(priv, rx_packet_loc + 24, msdu_size - 24);
|
||||
|
@ -1132,16 +1132,16 @@ static void rx_done_irq(struct atmel_private *priv)
|
|||
}
|
||||
|
||||
/* don't CRC header when WEP in use */
|
||||
if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE802_11_FCTL_WEP))) {
|
||||
if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_WEP))) {
|
||||
crc = crc32_le(0xffffffff, (unsigned char *)&header, 24);
|
||||
}
|
||||
msdu_size -= 24; /* header */
|
||||
|
||||
if ((frame_ctl & IEEE802_11_FCTL_FTYPE) == IEEE802_11_FTYPE_DATA) {
|
||||
if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) {
|
||||
|
||||
int more_fragments = frame_ctl & IEEE802_11_FCTL_MOREFRAGS;
|
||||
u8 packet_fragment_no = seq_control & IEEE802_11_SCTL_FRAG;
|
||||
u16 packet_sequence_no = (seq_control & IEEE802_11_SCTL_SEQ) >> 4;
|
||||
int more_fragments = frame_ctl & IEEE80211_FCTL_MOREFRAGS;
|
||||
u8 packet_fragment_no = seq_control & IEEE80211_SCTL_FRAG;
|
||||
u16 packet_sequence_no = (seq_control & IEEE80211_SCTL_SEQ) >> 4;
|
||||
|
||||
if (!more_fragments && packet_fragment_no == 0 ) {
|
||||
fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc);
|
||||
|
@ -1151,7 +1151,7 @@ static void rx_done_irq(struct atmel_private *priv)
|
|||
}
|
||||
}
|
||||
|
||||
if ((frame_ctl & IEEE802_11_FCTL_FTYPE) == IEEE802_11_FTYPE_MGMT) {
|
||||
if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
|
||||
/* copy rest of packet into buffer */
|
||||
atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size);
|
||||
|
||||
|
@ -2663,10 +2663,10 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
|
|||
|
||||
static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len)
|
||||
{
|
||||
struct ieee802_11_hdr header;
|
||||
struct ieee80211_hdr header;
|
||||
struct auth_body auth;
|
||||
|
||||
header.frame_ctl = cpu_to_le16(IEEE802_11_FTYPE_MGMT | IEEE802_11_STYPE_AUTH);
|
||||
header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
|
||||
header.duration_id = cpu_to_le16(0x8000);
|
||||
header.seq_ctl = 0;
|
||||
memcpy(header.addr1, priv->CurrentBSSID, 6);
|
||||
|
@ -2677,7 +2677,7 @@ static void send_authentication_request(struct atmel_private *priv, u8 *challeng
|
|||
auth.alg = cpu_to_le16(C80211_MGMT_AAN_SHAREDKEY);
|
||||
/* no WEP for authentication frames with TrSeqNo 1 */
|
||||
if (priv->CurrentAuthentTransactionSeqNum != 1)
|
||||
header.frame_ctl |= cpu_to_le16(IEEE802_11_FCTL_WEP);
|
||||
header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_WEP);
|
||||
} else {
|
||||
auth.alg = cpu_to_le16(C80211_MGMT_AAN_OPENSYSTEM);
|
||||
}
|
||||
|
@ -2701,7 +2701,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
|
|||
{
|
||||
u8 *ssid_el_p;
|
||||
int bodysize;
|
||||
struct ieee802_11_hdr header;
|
||||
struct ieee80211_hdr header;
|
||||
struct ass_req_format {
|
||||
u16 capability;
|
||||
u16 listen_interval;
|
||||
|
@ -2714,8 +2714,8 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
|
|||
u8 rates[4];
|
||||
} body;
|
||||
|
||||
header.frame_ctl = cpu_to_le16(IEEE802_11_FTYPE_MGMT |
|
||||
(is_reassoc ? IEEE802_11_STYPE_REASSOC_REQ : IEEE802_11_STYPE_ASSOC_REQ));
|
||||
header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
(is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
|
||||
header.duration_id = cpu_to_le16(0x8000);
|
||||
header.seq_ctl = 0;
|
||||
|
||||
|
@ -2751,9 +2751,9 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
|
|||
atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize);
|
||||
}
|
||||
|
||||
static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee802_11_hdr *header)
|
||||
static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr *header)
|
||||
{
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_FROMDS)
|
||||
if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
|
||||
return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
|
||||
else
|
||||
return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0;
|
||||
|
@ -2801,7 +2801,7 @@ static int retrieve_bss(struct atmel_private *priv)
|
|||
}
|
||||
|
||||
|
||||
static void store_bss_info(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u16 capability, u16 beacon_period, u8 channel, u8 rssi,
|
||||
u8 ssid_len, u8 *ssid, int is_beacon)
|
||||
{
|
||||
|
@ -3085,12 +3085,12 @@ static void atmel_smooth_qual(struct atmel_private *priv)
|
|||
}
|
||||
|
||||
/* deals with incoming managment frames. */
|
||||
static void atmel_management_frame(struct atmel_private *priv, struct ieee802_11_hdr *header,
|
||||
static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr *header,
|
||||
u16 frame_len, u8 rssi)
|
||||
{
|
||||
u16 subtype;
|
||||
|
||||
switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE802_11_FCTL_STYPE) {
|
||||
switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE) {
|
||||
case C80211_SUBTYPE_MGMT_BEACON :
|
||||
case C80211_SUBTYPE_MGMT_ProbeResponse:
|
||||
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
#ifndef _IEEE802_11_H
|
||||
#define _IEEE802_11_H
|
||||
|
||||
#define IEEE802_11_DATA_LEN 2304
|
||||
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
|
||||
6.2.1.1.2.
|
||||
|
||||
The figure in section 7.1.2 suggests a body size of up to 2312
|
||||
bytes is allowed, which is a bit confusing, I suspect this
|
||||
represents the 2304 bytes of real data, plus a possible 8 bytes of
|
||||
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
|
||||
|
||||
|
||||
#define IEEE802_11_HLEN 30
|
||||
#define IEEE802_11_FRAME_LEN (IEEE802_11_DATA_LEN + IEEE802_11_HLEN)
|
||||
|
||||
struct ieee802_11_hdr {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
u8 addr4[ETH_ALEN];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* Frame control field constants */
|
||||
#define IEEE802_11_FCTL_VERS 0x0002
|
||||
#define IEEE802_11_FCTL_FTYPE 0x000c
|
||||
#define IEEE802_11_FCTL_STYPE 0x00f0
|
||||
#define IEEE802_11_FCTL_TODS 0x0100
|
||||
#define IEEE802_11_FCTL_FROMDS 0x0200
|
||||
#define IEEE802_11_FCTL_MOREFRAGS 0x0400
|
||||
#define IEEE802_11_FCTL_RETRY 0x0800
|
||||
#define IEEE802_11_FCTL_PM 0x1000
|
||||
#define IEEE802_11_FCTL_MOREDATA 0x2000
|
||||
#define IEEE802_11_FCTL_WEP 0x4000
|
||||
#define IEEE802_11_FCTL_ORDER 0x8000
|
||||
|
||||
#define IEEE802_11_FTYPE_MGMT 0x0000
|
||||
#define IEEE802_11_FTYPE_CTL 0x0004
|
||||
#define IEEE802_11_FTYPE_DATA 0x0008
|
||||
|
||||
/* management */
|
||||
#define IEEE802_11_STYPE_ASSOC_REQ 0x0000
|
||||
#define IEEE802_11_STYPE_ASSOC_RESP 0x0010
|
||||
#define IEEE802_11_STYPE_REASSOC_REQ 0x0020
|
||||
#define IEEE802_11_STYPE_REASSOC_RESP 0x0030
|
||||
#define IEEE802_11_STYPE_PROBE_REQ 0x0040
|
||||
#define IEEE802_11_STYPE_PROBE_RESP 0x0050
|
||||
#define IEEE802_11_STYPE_BEACON 0x0080
|
||||
#define IEEE802_11_STYPE_ATIM 0x0090
|
||||
#define IEEE802_11_STYPE_DISASSOC 0x00A0
|
||||
#define IEEE802_11_STYPE_AUTH 0x00B0
|
||||
#define IEEE802_11_STYPE_DEAUTH 0x00C0
|
||||
|
||||
/* control */
|
||||
#define IEEE802_11_STYPE_PSPOLL 0x00A0
|
||||
#define IEEE802_11_STYPE_RTS 0x00B0
|
||||
#define IEEE802_11_STYPE_CTS 0x00C0
|
||||
#define IEEE802_11_STYPE_ACK 0x00D0
|
||||
#define IEEE802_11_STYPE_CFEND 0x00E0
|
||||
#define IEEE802_11_STYPE_CFENDACK 0x00F0
|
||||
|
||||
/* data */
|
||||
#define IEEE802_11_STYPE_DATA 0x0000
|
||||
#define IEEE802_11_STYPE_DATA_CFACK 0x0010
|
||||
#define IEEE802_11_STYPE_DATA_CFPOLL 0x0020
|
||||
#define IEEE802_11_STYPE_DATA_CFACKPOLL 0x0030
|
||||
#define IEEE802_11_STYPE_NULLFUNC 0x0040
|
||||
#define IEEE802_11_STYPE_CFACK 0x0050
|
||||
#define IEEE802_11_STYPE_CFPOLL 0x0060
|
||||
#define IEEE802_11_STYPE_CFACKPOLL 0x0070
|
||||
|
||||
#define IEEE802_11_SCTL_FRAG 0x000F
|
||||
#define IEEE802_11_SCTL_SEQ 0xFFF0
|
||||
|
||||
#endif /* _IEEE802_11_H */
|
8649
drivers/net/wireless/ipw2100.c
Normal file
8649
drivers/net/wireless/ipw2100.c
Normal file
File diff suppressed because it is too large
Load diff
1278
drivers/net/wireless/ipw2100.h
Normal file
1278
drivers/net/wireless/ipw2100.h
Normal file
File diff suppressed because it is too large
Load diff
7348
drivers/net/wireless/ipw2200.c
Normal file
7348
drivers/net/wireless/ipw2200.c
Normal file
File diff suppressed because it is too large
Load diff
1770
drivers/net/wireless/ipw2200.h
Normal file
1770
drivers/net/wireless/ipw2200.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -464,6 +464,8 @@
|
|||
#include <linux/etherdevice.h>
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/system.h>
|
||||
|
@ -471,7 +473,6 @@
|
|||
#include "hermes.h"
|
||||
#include "hermes_rid.h"
|
||||
#include "orinoco.h"
|
||||
#include "ieee802_11.h"
|
||||
|
||||
/********************************************************************/
|
||||
/* Module information */
|
||||
|
@ -509,7 +510,7 @@ MODULE_PARM_DESC(suppress_linkstatus, "Don't log link status changes");
|
|||
/********************************************************************/
|
||||
|
||||
#define ORINOCO_MIN_MTU 256
|
||||
#define ORINOCO_MAX_MTU (IEEE802_11_DATA_LEN - ENCAPS_OVERHEAD)
|
||||
#define ORINOCO_MAX_MTU (IEEE80211_DATA_LEN - ENCAPS_OVERHEAD)
|
||||
|
||||
#define SYMBOL_MAX_VER_LEN (14)
|
||||
#define USER_BAP 0
|
||||
|
@ -760,7 +761,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu)
|
|||
if ( (new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU) )
|
||||
return -EINVAL;
|
||||
|
||||
if ( (new_mtu + ENCAPS_OVERHEAD + IEEE802_11_HLEN) >
|
||||
if ( (new_mtu + ENCAPS_OVERHEAD + IEEE80211_HLEN) >
|
||||
(priv->nicbuf_size - ETH_HLEN) )
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -1104,7 +1105,7 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw)
|
|||
stats->rx_dropped++;
|
||||
goto drop;
|
||||
}
|
||||
if (length > IEEE802_11_DATA_LEN) {
|
||||
if (length > IEEE80211_DATA_LEN) {
|
||||
printk(KERN_WARNING "%s: Oversized frame received (%d bytes)\n",
|
||||
dev->name, length);
|
||||
stats->rx_length_errors++;
|
||||
|
@ -2264,7 +2265,7 @@ static int orinoco_init(struct net_device *dev)
|
|||
|
||||
/* No need to lock, the hw_unavailable flag is already set in
|
||||
* alloc_orinocodev() */
|
||||
priv->nicbuf_size = IEEE802_11_FRAME_LEN + ETH_HLEN;
|
||||
priv->nicbuf_size = IEEE80211_FRAME_LEN + ETH_HLEN;
|
||||
|
||||
/* Initialize the firmware */
|
||||
err = hermes_init(hw);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define __WL3501_H__
|
||||
|
||||
#include <linux/spinlock.h>
|
||||
#include "ieee802_11.h"
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
/* define for WLA 2.0 */
|
||||
#define WL3501_BLKSZ 256
|
||||
|
@ -548,7 +548,7 @@ struct wl3501_80211_tx_plcp_hdr {
|
|||
|
||||
struct wl3501_80211_tx_hdr {
|
||||
struct wl3501_80211_tx_plcp_hdr pclp_hdr;
|
||||
struct ieee802_11_hdr mac_hdr;
|
||||
struct ieee80211_hdr mac_hdr;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* This file define a set of standard wireless extensions
|
||||
*
|
||||
* Version : 17 21.6.04
|
||||
* Version : 18 12.3.05
|
||||
*
|
||||
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
|
||||
* Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
|
||||
* Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_WIRELESS_H
|
||||
|
@ -82,7 +82,7 @@
|
|||
* (there is some stuff that will be added in the future...)
|
||||
* I just plan to increment with each new version.
|
||||
*/
|
||||
#define WIRELESS_EXT 17
|
||||
#define WIRELESS_EXT 18
|
||||
|
||||
/*
|
||||
* Changes :
|
||||
|
@ -182,6 +182,21 @@
|
|||
* - Document (struct iw_quality *)->updated, add new flags (INVALID)
|
||||
* - Wireless Event capability in struct iw_range
|
||||
* - Add support for relative TxPower (yick !)
|
||||
*
|
||||
* V17 to V18 (From Jouni Malinen <jkmaline@cc.hut.fi>)
|
||||
* ----------
|
||||
* - Add support for WPA/WPA2
|
||||
* - Add extended encoding configuration (SIOCSIWENCODEEXT and
|
||||
* SIOCGIWENCODEEXT)
|
||||
* - Add SIOCSIWGENIE/SIOCGIWGENIE
|
||||
* - Add SIOCSIWMLME
|
||||
* - Add SIOCSIWPMKSA
|
||||
* - Add struct iw_range bit field for supported encoding capabilities
|
||||
* - Add optional scan request parameters for SIOCSIWSCAN
|
||||
* - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
|
||||
* related parameters (extensible up to 4096 parameter values)
|
||||
* - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
|
||||
* IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
|
||||
*/
|
||||
|
||||
/**************************** CONSTANTS ****************************/
|
||||
|
@ -256,6 +271,30 @@
|
|||
#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
|
||||
#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
|
||||
|
||||
/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
|
||||
* This ioctl uses struct iw_point and data buffer that includes IE id and len
|
||||
* fields. More than one IE may be included in the request. Setting the generic
|
||||
* IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
|
||||
* are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
|
||||
* are required to report the used IE as a wireless event, e.g., when
|
||||
* associating with an AP. */
|
||||
#define SIOCSIWGENIE 0x8B30 /* set generic IE */
|
||||
#define SIOCGIWGENIE 0x8B31 /* get generic IE */
|
||||
|
||||
/* WPA : IEEE 802.11 MLME requests */
|
||||
#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
|
||||
* struct iw_mlme */
|
||||
/* WPA : Authentication mode parameters */
|
||||
#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
|
||||
#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
|
||||
|
||||
/* WPA : Extended version of encoding configuration */
|
||||
#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
|
||||
#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
|
||||
|
||||
/* WPA2 : PMKSA cache management */
|
||||
#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
|
||||
|
||||
/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
|
||||
|
||||
/* These 32 ioctl are wireless device private, for 16 commands.
|
||||
|
@ -297,6 +336,34 @@
|
|||
#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
|
||||
#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
|
||||
#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
|
||||
#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
|
||||
* (scan results); This includes id and
|
||||
* length fields. One IWEVGENIE may
|
||||
* contain more than one IE. Scan
|
||||
* results may contain one or more
|
||||
* IWEVGENIE events. */
|
||||
#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
|
||||
* (struct iw_michaelmicfailure)
|
||||
*/
|
||||
#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
|
||||
* The data includes id and length
|
||||
* fields and may contain more than one
|
||||
* IE. This event is required in
|
||||
* Managed mode if the driver
|
||||
* generates its own WPA/RSN IE. This
|
||||
* should be sent just before
|
||||
* IWEVREGISTERED event for the
|
||||
* association. */
|
||||
#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
|
||||
* Response. The data includes id and
|
||||
* length fields and may contain more
|
||||
* than one IE. This may be sent
|
||||
* between IWEVASSOCREQIE and
|
||||
* IWEVREGISTERED events for the
|
||||
* association. */
|
||||
#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
|
||||
* pre-authentication
|
||||
* (struct iw_pmkid_cand) */
|
||||
|
||||
#define IWEVFIRST 0x8C00
|
||||
|
||||
|
@ -432,12 +499,94 @@
|
|||
#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
|
||||
#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
|
||||
#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
|
||||
/* struct iw_scan_req scan_type */
|
||||
#define IW_SCAN_TYPE_ACTIVE 0
|
||||
#define IW_SCAN_TYPE_PASSIVE 1
|
||||
/* Maximum size of returned data */
|
||||
#define IW_SCAN_MAX_DATA 4096 /* In bytes */
|
||||
|
||||
/* Max number of char in custom event - use multiple of them if needed */
|
||||
#define IW_CUSTOM_MAX 256 /* In bytes */
|
||||
|
||||
/* Generic information element */
|
||||
#define IW_GENERIC_IE_MAX 1024
|
||||
|
||||
/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
|
||||
#define IW_MLME_DEAUTH 0
|
||||
#define IW_MLME_DISASSOC 1
|
||||
|
||||
/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
|
||||
#define IW_AUTH_INDEX 0x0FFF
|
||||
#define IW_AUTH_FLAGS 0xF000
|
||||
/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
|
||||
* (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
|
||||
* parameter that is being set/get to; value will be read/written to
|
||||
* struct iw_param value field) */
|
||||
#define IW_AUTH_WPA_VERSION 0
|
||||
#define IW_AUTH_CIPHER_PAIRWISE 1
|
||||
#define IW_AUTH_CIPHER_GROUP 2
|
||||
#define IW_AUTH_KEY_MGMT 3
|
||||
#define IW_AUTH_TKIP_COUNTERMEASURES 4
|
||||
#define IW_AUTH_DROP_UNENCRYPTED 5
|
||||
#define IW_AUTH_80211_AUTH_ALG 6
|
||||
#define IW_AUTH_WPA_ENABLED 7
|
||||
#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
|
||||
#define IW_AUTH_ROAMING_CONTROL 9
|
||||
#define IW_AUTH_PRIVACY_INVOKED 10
|
||||
|
||||
/* IW_AUTH_WPA_VERSION values (bit field) */
|
||||
#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
|
||||
#define IW_AUTH_WPA_VERSION_WPA 0x00000002
|
||||
#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
|
||||
|
||||
/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
|
||||
#define IW_AUTH_CIPHER_NONE 0x00000001
|
||||
#define IW_AUTH_CIPHER_WEP40 0x00000002
|
||||
#define IW_AUTH_CIPHER_TKIP 0x00000004
|
||||
#define IW_AUTH_CIPHER_CCMP 0x00000008
|
||||
#define IW_AUTH_CIPHER_WEP104 0x00000010
|
||||
|
||||
/* IW_AUTH_KEY_MGMT values (bit field) */
|
||||
#define IW_AUTH_KEY_MGMT_802_1X 1
|
||||
#define IW_AUTH_KEY_MGMT_PSK 2
|
||||
|
||||
/* IW_AUTH_80211_AUTH_ALG values (bit field) */
|
||||
#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
|
||||
#define IW_AUTH_ALG_SHARED_KEY 0x00000002
|
||||
#define IW_AUTH_ALG_LEAP 0x00000004
|
||||
|
||||
/* IW_AUTH_ROAMING_CONTROL values */
|
||||
#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
|
||||
#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
|
||||
* control */
|
||||
|
||||
/* SIOCSIWENCODEEXT definitions */
|
||||
#define IW_ENCODE_SEQ_MAX_SIZE 8
|
||||
/* struct iw_encode_ext ->alg */
|
||||
#define IW_ENCODE_ALG_NONE 0
|
||||
#define IW_ENCODE_ALG_WEP 1
|
||||
#define IW_ENCODE_ALG_TKIP 2
|
||||
#define IW_ENCODE_ALG_CCMP 3
|
||||
/* struct iw_encode_ext ->ext_flags */
|
||||
#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
|
||||
#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
|
||||
#define IW_ENCODE_EXT_GROUP_KEY 0x00000004
|
||||
#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
|
||||
|
||||
/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
|
||||
#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
|
||||
#define IW_MICFAILURE_GROUP 0x00000004
|
||||
#define IW_MICFAILURE_PAIRWISE 0x00000008
|
||||
#define IW_MICFAILURE_STAKEY 0x00000010
|
||||
#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
|
||||
*/
|
||||
|
||||
/* Bit field values for enc_capa in struct iw_range */
|
||||
#define IW_ENC_CAPA_WPA 0x00000001
|
||||
#define IW_ENC_CAPA_WPA2 0x00000002
|
||||
#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
|
||||
#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
|
||||
|
||||
/* Event capability macros - in (struct iw_range *)->event_capa
|
||||
* Because we have more than 32 possible events, we use an array of
|
||||
* 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
|
||||
|
@ -546,6 +695,132 @@ struct iw_thrspy
|
|||
struct iw_quality high; /* High threshold */
|
||||
};
|
||||
|
||||
/*
|
||||
* Optional data for scan request
|
||||
*
|
||||
* Note: these optional parameters are controlling parameters for the
|
||||
* scanning behavior, these do not apply to getting scan results
|
||||
* (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
|
||||
* provide a merged results with all BSSes even if the previous scan
|
||||
* request limited scanning to a subset, e.g., by specifying an SSID.
|
||||
* Especially, scan results are required to include an entry for the
|
||||
* current BSS if the driver is in Managed mode and associated with an AP.
|
||||
*/
|
||||
struct iw_scan_req
|
||||
{
|
||||
__u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
|
||||
__u8 essid_len;
|
||||
__u8 num_channels; /* num entries in channel_list;
|
||||
* 0 = scan all allowed channels */
|
||||
__u8 flags; /* reserved as padding; use zero, this may
|
||||
* be used in the future for adding flags
|
||||
* to request different scan behavior */
|
||||
struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
|
||||
* individual address of a specific BSS */
|
||||
|
||||
/*
|
||||
* Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
|
||||
* the current ESSID. This allows scan requests for specific ESSID
|
||||
* without having to change the current ESSID and potentially breaking
|
||||
* the current association.
|
||||
*/
|
||||
__u8 essid[IW_ESSID_MAX_SIZE];
|
||||
|
||||
/*
|
||||
* Optional parameters for changing the default scanning behavior.
|
||||
* These are based on the MLME-SCAN.request from IEEE Std 802.11.
|
||||
* TU is 1.024 ms. If these are set to 0, driver is expected to use
|
||||
* reasonable default values. min_channel_time defines the time that
|
||||
* will be used to wait for the first reply on each channel. If no
|
||||
* replies are received, next channel will be scanned after this. If
|
||||
* replies are received, total time waited on the channel is defined by
|
||||
* max_channel_time.
|
||||
*/
|
||||
__u32 min_channel_time; /* in TU */
|
||||
__u32 max_channel_time; /* in TU */
|
||||
|
||||
struct iw_freq channel_list[IW_MAX_FREQUENCIES];
|
||||
};
|
||||
|
||||
/* ------------------------- WPA SUPPORT ------------------------- */
|
||||
|
||||
/*
|
||||
* Extended data structure for get/set encoding (this is used with
|
||||
* SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
|
||||
* flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
|
||||
* only the data contents changes (key data -> this structure, including
|
||||
* key data).
|
||||
*
|
||||
* If the new key is the first group key, it will be set as the default
|
||||
* TX key. Otherwise, default TX key index is only changed if
|
||||
* IW_ENCODE_EXT_SET_TX_KEY flag is set.
|
||||
*
|
||||
* Key will be changed with SIOCSIWENCODEEXT in all cases except for
|
||||
* special "change TX key index" operation which is indicated by setting
|
||||
* key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
|
||||
*
|
||||
* tx_seq/rx_seq are only used when respective
|
||||
* IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
|
||||
* TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
|
||||
* TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
|
||||
* used only by an Authenticator (AP or an IBSS station) to get the
|
||||
* current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
|
||||
* RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
|
||||
* debugging/testing.
|
||||
*/
|
||||
struct iw_encode_ext
|
||||
{
|
||||
__u32 ext_flags; /* IW_ENCODE_EXT_* */
|
||||
__u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
|
||||
__u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
|
||||
struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
|
||||
* (group) keys or unicast address for
|
||||
* individual keys */
|
||||
__u16 alg; /* IW_ENCODE_ALG_* */
|
||||
__u16 key_len;
|
||||
__u8 key[0];
|
||||
};
|
||||
|
||||
/* SIOCSIWMLME data */
|
||||
struct iw_mlme
|
||||
{
|
||||
__u16 cmd; /* IW_MLME_* */
|
||||
__u16 reason_code;
|
||||
struct sockaddr addr;
|
||||
};
|
||||
|
||||
/* SIOCSIWPMKSA data */
|
||||
#define IW_PMKSA_ADD 1
|
||||
#define IW_PMKSA_REMOVE 2
|
||||
#define IW_PMKSA_FLUSH 3
|
||||
|
||||
#define IW_PMKID_LEN 16
|
||||
|
||||
struct iw_pmksa
|
||||
{
|
||||
__u32 cmd; /* IW_PMKSA_* */
|
||||
struct sockaddr bssid;
|
||||
__u8 pmkid[IW_PMKID_LEN];
|
||||
};
|
||||
|
||||
/* IWEVMICHAELMICFAILURE data */
|
||||
struct iw_michaelmicfailure
|
||||
{
|
||||
__u32 flags;
|
||||
struct sockaddr src_addr;
|
||||
__u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
|
||||
};
|
||||
|
||||
/* IWEVPMKIDCAND data */
|
||||
#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
|
||||
struct iw_pmkid_cand
|
||||
{
|
||||
__u32 flags; /* IW_PMKID_CAND_* */
|
||||
__u32 index; /* the smaller the index, the higher the
|
||||
* priority */
|
||||
struct sockaddr bssid;
|
||||
};
|
||||
|
||||
/* ------------------------ WIRELESS STATS ------------------------ */
|
||||
/*
|
||||
* Wireless statistics (used for /proc/net/wireless)
|
||||
|
@ -725,6 +1000,8 @@ struct iw_range
|
|||
struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
|
||||
/* Note : this frequency list doesn't need to fit channel numbers,
|
||||
* because each entry contain its channel index */
|
||||
|
||||
__u32 enc_capa; /* IW_ENC_CAPA_* bit field */
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
887
include/net/ieee80211.h
Normal file
887
include/net/ieee80211.h
Normal file
|
@ -0,0 +1,887 @@
|
|||
/*
|
||||
* Merged with mainline ieee80211.h in Aug 2004. Original ieee802_11
|
||||
* remains copyright by the original authors
|
||||
*
|
||||
* Portions of the merged code are based on Host AP (software wireless
|
||||
* LAN access point) driver for Intersil Prism2/2.5/3.
|
||||
*
|
||||
* Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
||||
* <jkmaline@cc.hut.fi>
|
||||
* Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
*
|
||||
* Adaption to a generic IEEE 802.11 stack by James Ketrenos
|
||||
* <jketreno@linux.intel.com>
|
||||
* Copyright (c) 2004, Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
#ifndef IEEE80211_H
|
||||
#define IEEE80211_H
|
||||
#include <linux/if_ether.h> /* ETH_ALEN */
|
||||
#include <linux/kernel.h> /* ARRAY_SIZE */
|
||||
|
||||
#if WIRELESS_EXT < 17
|
||||
#define IW_QUAL_QUAL_INVALID 0x10
|
||||
#define IW_QUAL_LEVEL_INVALID 0x20
|
||||
#define IW_QUAL_NOISE_INVALID 0x40
|
||||
#define IW_QUAL_QUAL_UPDATED 0x1
|
||||
#define IW_QUAL_LEVEL_UPDATED 0x2
|
||||
#define IW_QUAL_NOISE_UPDATED 0x4
|
||||
#endif
|
||||
|
||||
#define IEEE80211_DATA_LEN 2304
|
||||
/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
|
||||
6.2.1.1.2.
|
||||
|
||||
The figure in section 7.1.2 suggests a body size of up to 2312
|
||||
bytes is allowed, which is a bit confusing, I suspect this
|
||||
represents the 2304 bytes of real data, plus a possible 8 bytes of
|
||||
WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */
|
||||
|
||||
|
||||
#define IEEE80211_HLEN 30
|
||||
#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN)
|
||||
|
||||
struct ieee80211_hdr {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
u8 addr4[ETH_ALEN];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_hdr_3addr {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[ETH_ALEN];
|
||||
u8 addr2[ETH_ALEN];
|
||||
u8 addr3[ETH_ALEN];
|
||||
u16 seq_ctl;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
enum eap_type {
|
||||
EAP_PACKET = 0,
|
||||
EAPOL_START,
|
||||
EAPOL_LOGOFF,
|
||||
EAPOL_KEY,
|
||||
EAPOL_ENCAP_ASF_ALERT
|
||||
};
|
||||
|
||||
static const char *eap_types[] = {
|
||||
[EAP_PACKET] = "EAP-Packet",
|
||||
[EAPOL_START] = "EAPOL-Start",
|
||||
[EAPOL_LOGOFF] = "EAPOL-Logoff",
|
||||
[EAPOL_KEY] = "EAPOL-Key",
|
||||
[EAPOL_ENCAP_ASF_ALERT] = "EAPOL-Encap-ASF-Alert"
|
||||
};
|
||||
|
||||
static inline const char *eap_get_type(int type)
|
||||
{
|
||||
return (type >= ARRAY_SIZE(eap_types)) ? "Unknown" : eap_types[type];
|
||||
}
|
||||
|
||||
struct eapol {
|
||||
u8 snap[6];
|
||||
u16 ethertype;
|
||||
u8 version;
|
||||
u8 type;
|
||||
u16 length;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define IEEE80211_3ADDR_LEN 24
|
||||
#define IEEE80211_4ADDR_LEN 30
|
||||
#define IEEE80211_FCS_LEN 4
|
||||
|
||||
#define MIN_FRAG_THRESHOLD 256U
|
||||
#define MAX_FRAG_THRESHOLD 2346U
|
||||
|
||||
/* Frame control field constants */
|
||||
#define IEEE80211_FCTL_VERS 0x0002
|
||||
#define IEEE80211_FCTL_FTYPE 0x000c
|
||||
#define IEEE80211_FCTL_STYPE 0x00f0
|
||||
#define IEEE80211_FCTL_TODS 0x0100
|
||||
#define IEEE80211_FCTL_FROMDS 0x0200
|
||||
#define IEEE80211_FCTL_MOREFRAGS 0x0400
|
||||
#define IEEE80211_FCTL_RETRY 0x0800
|
||||
#define IEEE80211_FCTL_PM 0x1000
|
||||
#define IEEE80211_FCTL_MOREDATA 0x2000
|
||||
#define IEEE80211_FCTL_WEP 0x4000
|
||||
#define IEEE80211_FCTL_ORDER 0x8000
|
||||
|
||||
#define IEEE80211_FTYPE_MGMT 0x0000
|
||||
#define IEEE80211_FTYPE_CTL 0x0004
|
||||
#define IEEE80211_FTYPE_DATA 0x0008
|
||||
|
||||
/* management */
|
||||
#define IEEE80211_STYPE_ASSOC_REQ 0x0000
|
||||
#define IEEE80211_STYPE_ASSOC_RESP 0x0010
|
||||
#define IEEE80211_STYPE_REASSOC_REQ 0x0020
|
||||
#define IEEE80211_STYPE_REASSOC_RESP 0x0030
|
||||
#define IEEE80211_STYPE_PROBE_REQ 0x0040
|
||||
#define IEEE80211_STYPE_PROBE_RESP 0x0050
|
||||
#define IEEE80211_STYPE_BEACON 0x0080
|
||||
#define IEEE80211_STYPE_ATIM 0x0090
|
||||
#define IEEE80211_STYPE_DISASSOC 0x00A0
|
||||
#define IEEE80211_STYPE_AUTH 0x00B0
|
||||
#define IEEE80211_STYPE_DEAUTH 0x00C0
|
||||
|
||||
/* control */
|
||||
#define IEEE80211_STYPE_PSPOLL 0x00A0
|
||||
#define IEEE80211_STYPE_RTS 0x00B0
|
||||
#define IEEE80211_STYPE_CTS 0x00C0
|
||||
#define IEEE80211_STYPE_ACK 0x00D0
|
||||
#define IEEE80211_STYPE_CFEND 0x00E0
|
||||
#define IEEE80211_STYPE_CFENDACK 0x00F0
|
||||
|
||||
/* data */
|
||||
#define IEEE80211_STYPE_DATA 0x0000
|
||||
#define IEEE80211_STYPE_DATA_CFACK 0x0010
|
||||
#define IEEE80211_STYPE_DATA_CFPOLL 0x0020
|
||||
#define IEEE80211_STYPE_DATA_CFACKPOLL 0x0030
|
||||
#define IEEE80211_STYPE_NULLFUNC 0x0040
|
||||
#define IEEE80211_STYPE_CFACK 0x0050
|
||||
#define IEEE80211_STYPE_CFPOLL 0x0060
|
||||
#define IEEE80211_STYPE_CFACKPOLL 0x0070
|
||||
|
||||
#define IEEE80211_SCTL_FRAG 0x000F
|
||||
#define IEEE80211_SCTL_SEQ 0xFFF0
|
||||
|
||||
|
||||
/* debug macros */
|
||||
|
||||
#ifdef CONFIG_IEEE80211_DEBUG
|
||||
extern u32 ieee80211_debug_level;
|
||||
#define IEEE80211_DEBUG(level, fmt, args...) \
|
||||
do { if (ieee80211_debug_level & (level)) \
|
||||
printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
|
||||
in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
|
||||
#else
|
||||
#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
|
||||
#endif /* CONFIG_IEEE80211_DEBUG */
|
||||
|
||||
/*
|
||||
* To use the debug system;
|
||||
*
|
||||
* If you are defining a new debug classification, simply add it to the #define
|
||||
* list here in the form of:
|
||||
*
|
||||
* #define IEEE80211_DL_xxxx VALUE
|
||||
*
|
||||
* shifting value to the left one bit from the previous entry. xxxx should be
|
||||
* the name of the classification (for example, WEP)
|
||||
*
|
||||
* You then need to either add a IEEE80211_xxxx_DEBUG() macro definition for your
|
||||
* classification, or use IEEE80211_DEBUG(IEEE80211_DL_xxxx, ...) whenever you want
|
||||
* to send output to that classification.
|
||||
*
|
||||
* To add your debug level to the list of levels seen when you perform
|
||||
*
|
||||
* % cat /proc/net/ipw/debug_level
|
||||
*
|
||||
* you simply need to add your entry to the ipw_debug_levels array.
|
||||
*
|
||||
* If you do not see debug_level in /proc/net/ipw then you do not have
|
||||
* CONFIG_IEEE80211_DEBUG defined in your kernel configuration
|
||||
*
|
||||
*/
|
||||
|
||||
#define IEEE80211_DL_INFO (1<<0)
|
||||
#define IEEE80211_DL_WX (1<<1)
|
||||
#define IEEE80211_DL_SCAN (1<<2)
|
||||
#define IEEE80211_DL_STATE (1<<3)
|
||||
#define IEEE80211_DL_MGMT (1<<4)
|
||||
#define IEEE80211_DL_FRAG (1<<5)
|
||||
#define IEEE80211_DL_EAP (1<<6)
|
||||
#define IEEE80211_DL_DROP (1<<7)
|
||||
|
||||
#define IEEE80211_DL_TX (1<<8)
|
||||
#define IEEE80211_DL_RX (1<<9)
|
||||
|
||||
#define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a)
|
||||
#define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a)
|
||||
#define IEEE80211_DEBUG_INFO(f, a...) IEEE80211_DEBUG(IEEE80211_DL_INFO, f, ## a)
|
||||
|
||||
#define IEEE80211_DEBUG_WX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_WX, f, ## a)
|
||||
#define IEEE80211_DEBUG_SCAN(f, a...) IEEE80211_DEBUG(IEEE80211_DL_SCAN, f, ## a)
|
||||
#define IEEE80211_DEBUG_STATE(f, a...) IEEE80211_DEBUG(IEEE80211_DL_STATE, f, ## a)
|
||||
#define IEEE80211_DEBUG_MGMT(f, a...) IEEE80211_DEBUG(IEEE80211_DL_MGMT, f, ## a)
|
||||
#define IEEE80211_DEBUG_FRAG(f, a...) IEEE80211_DEBUG(IEEE80211_DL_FRAG, f, ## a)
|
||||
#define IEEE80211_DEBUG_EAP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_EAP, f, ## a)
|
||||
#define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a)
|
||||
#define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a)
|
||||
#define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a)
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/if_arp.h> /* ARPHRD_ETHER */
|
||||
|
||||
#ifndef WIRELESS_SPY
|
||||
#define WIRELESS_SPY // enable iwspy support
|
||||
#endif
|
||||
#include <net/iw_handler.h> // new driver API
|
||||
|
||||
#ifndef ETH_P_PAE
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#endif /* ETH_P_PAE */
|
||||
|
||||
#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */
|
||||
|
||||
#ifndef ETH_P_80211_RAW
|
||||
#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
|
||||
#endif
|
||||
|
||||
/* IEEE 802.11 defines */
|
||||
|
||||
#define P80211_OUI_LEN 3
|
||||
|
||||
struct ieee80211_snap_hdr {
|
||||
|
||||
u8 dsap; /* always 0xAA */
|
||||
u8 ssap; /* always 0xAA */
|
||||
u8 ctrl; /* always 0x03 */
|
||||
u8 oui[P80211_OUI_LEN]; /* organizational universal id */
|
||||
|
||||
} __attribute__ ((packed));
|
||||
|
||||
#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr)
|
||||
|
||||
#define WLAN_FC_GET_TYPE(fc) ((fc) & IEEE80211_FCTL_FTYPE)
|
||||
#define WLAN_FC_GET_STYPE(fc) ((fc) & IEEE80211_FCTL_STYPE)
|
||||
|
||||
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
|
||||
#define WLAN_GET_SEQ_SEQ(seq) ((seq) & IEEE80211_SCTL_SEQ)
|
||||
|
||||
/* Authentication algorithms */
|
||||
#define WLAN_AUTH_OPEN 0
|
||||
#define WLAN_AUTH_SHARED_KEY 1
|
||||
|
||||
#define WLAN_AUTH_CHALLENGE_LEN 128
|
||||
|
||||
#define WLAN_CAPABILITY_BSS (1<<0)
|
||||
#define WLAN_CAPABILITY_IBSS (1<<1)
|
||||
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
|
||||
#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3)
|
||||
#define WLAN_CAPABILITY_PRIVACY (1<<4)
|
||||
#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5)
|
||||
#define WLAN_CAPABILITY_PBCC (1<<6)
|
||||
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
|
||||
|
||||
/* Status codes */
|
||||
#define WLAN_STATUS_SUCCESS 0
|
||||
#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
|
||||
#define WLAN_STATUS_CAPS_UNSUPPORTED 10
|
||||
#define WLAN_STATUS_REASSOC_NO_ASSOC 11
|
||||
#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
|
||||
#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
|
||||
#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
|
||||
#define WLAN_STATUS_CHALLENGE_FAIL 15
|
||||
#define WLAN_STATUS_AUTH_TIMEOUT 16
|
||||
#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
|
||||
#define WLAN_STATUS_ASSOC_DENIED_RATES 18
|
||||
/* 802.11b */
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
|
||||
#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
|
||||
|
||||
/* Reason codes */
|
||||
#define WLAN_REASON_UNSPECIFIED 1
|
||||
#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
|
||||
#define WLAN_REASON_DEAUTH_LEAVING 3
|
||||
#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
|
||||
#define WLAN_REASON_DISASSOC_AP_BUSY 5
|
||||
#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
|
||||
#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
|
||||
#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
|
||||
#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
|
||||
|
||||
|
||||
/* Information Element IDs */
|
||||
#define WLAN_EID_SSID 0
|
||||
#define WLAN_EID_SUPP_RATES 1
|
||||
#define WLAN_EID_FH_PARAMS 2
|
||||
#define WLAN_EID_DS_PARAMS 3
|
||||
#define WLAN_EID_CF_PARAMS 4
|
||||
#define WLAN_EID_TIM 5
|
||||
#define WLAN_EID_IBSS_PARAMS 6
|
||||
#define WLAN_EID_CHALLENGE 16
|
||||
#define WLAN_EID_RSN 48
|
||||
#define WLAN_EID_GENERIC 221
|
||||
|
||||
#define IEEE80211_MGMT_HDR_LEN 24
|
||||
#define IEEE80211_DATA_HDR3_LEN 24
|
||||
#define IEEE80211_DATA_HDR4_LEN 30
|
||||
|
||||
|
||||
#define IEEE80211_STATMASK_SIGNAL (1<<0)
|
||||
#define IEEE80211_STATMASK_RSSI (1<<1)
|
||||
#define IEEE80211_STATMASK_NOISE (1<<2)
|
||||
#define IEEE80211_STATMASK_RATE (1<<3)
|
||||
#define IEEE80211_STATMASK_WEMASK 0x7
|
||||
|
||||
|
||||
#define IEEE80211_CCK_MODULATION (1<<0)
|
||||
#define IEEE80211_OFDM_MODULATION (1<<1)
|
||||
|
||||
#define IEEE80211_24GHZ_BAND (1<<0)
|
||||
#define IEEE80211_52GHZ_BAND (1<<1)
|
||||
|
||||
#define IEEE80211_CCK_RATE_1MB 0x02
|
||||
#define IEEE80211_CCK_RATE_2MB 0x04
|
||||
#define IEEE80211_CCK_RATE_5MB 0x0B
|
||||
#define IEEE80211_CCK_RATE_11MB 0x16
|
||||
#define IEEE80211_OFDM_RATE_6MB 0x0C
|
||||
#define IEEE80211_OFDM_RATE_9MB 0x12
|
||||
#define IEEE80211_OFDM_RATE_12MB 0x18
|
||||
#define IEEE80211_OFDM_RATE_18MB 0x24
|
||||
#define IEEE80211_OFDM_RATE_24MB 0x30
|
||||
#define IEEE80211_OFDM_RATE_36MB 0x48
|
||||
#define IEEE80211_OFDM_RATE_48MB 0x60
|
||||
#define IEEE80211_OFDM_RATE_54MB 0x6C
|
||||
#define IEEE80211_BASIC_RATE_MASK 0x80
|
||||
|
||||
#define IEEE80211_CCK_RATE_1MB_MASK (1<<0)
|
||||
#define IEEE80211_CCK_RATE_2MB_MASK (1<<1)
|
||||
#define IEEE80211_CCK_RATE_5MB_MASK (1<<2)
|
||||
#define IEEE80211_CCK_RATE_11MB_MASK (1<<3)
|
||||
#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4)
|
||||
#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5)
|
||||
#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6)
|
||||
#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7)
|
||||
#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8)
|
||||
#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9)
|
||||
#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10)
|
||||
#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11)
|
||||
|
||||
#define IEEE80211_CCK_RATES_MASK 0x0000000F
|
||||
#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \
|
||||
IEEE80211_CCK_RATE_2MB_MASK)
|
||||
#define IEEE80211_CCK_DEFAULT_RATES_MASK (IEEE80211_CCK_BASIC_RATES_MASK | \
|
||||
IEEE80211_CCK_RATE_5MB_MASK | \
|
||||
IEEE80211_CCK_RATE_11MB_MASK)
|
||||
|
||||
#define IEEE80211_OFDM_RATES_MASK 0x00000FF0
|
||||
#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_12MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_24MB_MASK)
|
||||
#define IEEE80211_OFDM_DEFAULT_RATES_MASK (IEEE80211_OFDM_BASIC_RATES_MASK | \
|
||||
IEEE80211_OFDM_RATE_9MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_18MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_36MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_48MB_MASK | \
|
||||
IEEE80211_OFDM_RATE_54MB_MASK)
|
||||
#define IEEE80211_DEFAULT_RATES_MASK (IEEE80211_OFDM_DEFAULT_RATES_MASK | \
|
||||
IEEE80211_CCK_DEFAULT_RATES_MASK)
|
||||
|
||||
#define IEEE80211_NUM_OFDM_RATES 8
|
||||
#define IEEE80211_NUM_CCK_RATES 4
|
||||
#define IEEE80211_OFDM_SHIFT_MASK_A 4
|
||||
|
||||
|
||||
|
||||
|
||||
/* NOTE: This data is for statistical purposes; not all hardware provides this
|
||||
* information for frames received. Not setting these will not cause
|
||||
* any adverse affects. */
|
||||
struct ieee80211_rx_stats {
|
||||
u32 mac_time;
|
||||
s8 rssi;
|
||||
u8 signal;
|
||||
u8 noise;
|
||||
u16 rate; /* in 100 kbps */
|
||||
u8 received_channel;
|
||||
u8 control;
|
||||
u8 mask;
|
||||
u8 freq;
|
||||
u16 len;
|
||||
};
|
||||
|
||||
/* IEEE 802.11 requires that STA supports concurrent reception of at least
|
||||
* three fragmented frames. This define can be increased to support more
|
||||
* concurrent frames, but it should be noted that each entry can consume about
|
||||
* 2 kB of RAM and increasing cache size will slow down frame reassembly. */
|
||||
#define IEEE80211_FRAG_CACHE_LEN 4
|
||||
|
||||
struct ieee80211_frag_entry {
|
||||
unsigned long first_frag_time;
|
||||
unsigned int seq;
|
||||
unsigned int last_frag;
|
||||
struct sk_buff *skb;
|
||||
u8 src_addr[ETH_ALEN];
|
||||
u8 dst_addr[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct ieee80211_stats {
|
||||
unsigned int tx_unicast_frames;
|
||||
unsigned int tx_multicast_frames;
|
||||
unsigned int tx_fragments;
|
||||
unsigned int tx_unicast_octets;
|
||||
unsigned int tx_multicast_octets;
|
||||
unsigned int tx_deferred_transmissions;
|
||||
unsigned int tx_single_retry_frames;
|
||||
unsigned int tx_multiple_retry_frames;
|
||||
unsigned int tx_retry_limit_exceeded;
|
||||
unsigned int tx_discards;
|
||||
unsigned int rx_unicast_frames;
|
||||
unsigned int rx_multicast_frames;
|
||||
unsigned int rx_fragments;
|
||||
unsigned int rx_unicast_octets;
|
||||
unsigned int rx_multicast_octets;
|
||||
unsigned int rx_fcs_errors;
|
||||
unsigned int rx_discards_no_buffer;
|
||||
unsigned int tx_discards_wrong_sa;
|
||||
unsigned int rx_discards_undecryptable;
|
||||
unsigned int rx_message_in_msg_fragments;
|
||||
unsigned int rx_message_in_bad_msg_fragments;
|
||||
};
|
||||
|
||||
struct ieee80211_device;
|
||||
|
||||
#include "ieee80211_crypt.h"
|
||||
|
||||
#define SEC_KEY_1 (1<<0)
|
||||
#define SEC_KEY_2 (1<<1)
|
||||
#define SEC_KEY_3 (1<<2)
|
||||
#define SEC_KEY_4 (1<<3)
|
||||
#define SEC_ACTIVE_KEY (1<<4)
|
||||
#define SEC_AUTH_MODE (1<<5)
|
||||
#define SEC_UNICAST_GROUP (1<<6)
|
||||
#define SEC_LEVEL (1<<7)
|
||||
#define SEC_ENABLED (1<<8)
|
||||
|
||||
#define SEC_LEVEL_0 0 /* None */
|
||||
#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */
|
||||
#define SEC_LEVEL_2 2 /* Level 1 + TKIP */
|
||||
#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */
|
||||
#define SEC_LEVEL_3 4 /* Level 2 + CCMP */
|
||||
|
||||
#define WEP_KEYS 4
|
||||
#define WEP_KEY_LEN 13
|
||||
|
||||
struct ieee80211_security {
|
||||
u16 active_key:2,
|
||||
enabled:1,
|
||||
auth_mode:2,
|
||||
auth_algo:4,
|
||||
unicast_uses_group:1;
|
||||
u8 key_sizes[WEP_KEYS];
|
||||
u8 keys[WEP_KEYS][WEP_KEY_LEN];
|
||||
u8 level;
|
||||
u16 flags;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
/*
|
||||
|
||||
802.11 data frame from AP
|
||||
|
||||
,-------------------------------------------------------------------.
|
||||
Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
|
||||
|------|------|---------|---------|---------|------|---------|------|
|
||||
Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs |
|
||||
| | tion | (BSSID) | | | ence | data | |
|
||||
`-------------------------------------------------------------------'
|
||||
|
||||
Total: 28-2340 bytes
|
||||
|
||||
*/
|
||||
|
||||
struct ieee80211_header_data {
|
||||
u16 frame_ctl;
|
||||
u16 duration_id;
|
||||
u8 addr1[6];
|
||||
u8 addr2[6];
|
||||
u8 addr3[6];
|
||||
u16 seq_ctrl;
|
||||
};
|
||||
|
||||
#define BEACON_PROBE_SSID_ID_POSITION 12
|
||||
|
||||
/* Management Frame Information Element Types */
|
||||
#define MFIE_TYPE_SSID 0
|
||||
#define MFIE_TYPE_RATES 1
|
||||
#define MFIE_TYPE_FH_SET 2
|
||||
#define MFIE_TYPE_DS_SET 3
|
||||
#define MFIE_TYPE_CF_SET 4
|
||||
#define MFIE_TYPE_TIM 5
|
||||
#define MFIE_TYPE_IBSS_SET 6
|
||||
#define MFIE_TYPE_CHALLENGE 16
|
||||
#define MFIE_TYPE_RSN 48
|
||||
#define MFIE_TYPE_RATES_EX 50
|
||||
#define MFIE_TYPE_GENERIC 221
|
||||
|
||||
struct ieee80211_info_element_hdr {
|
||||
u8 id;
|
||||
u8 len;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_info_element {
|
||||
u8 id;
|
||||
u8 len;
|
||||
u8 data[0];
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/*
|
||||
* These are the data types that can make up management packets
|
||||
*
|
||||
u16 auth_algorithm;
|
||||
u16 auth_sequence;
|
||||
u16 beacon_interval;
|
||||
u16 capability;
|
||||
u8 current_ap[ETH_ALEN];
|
||||
u16 listen_interval;
|
||||
struct {
|
||||
u16 association_id:14, reserved:2;
|
||||
} __attribute__ ((packed));
|
||||
u32 time_stamp[2];
|
||||
u16 reason;
|
||||
u16 status;
|
||||
*/
|
||||
|
||||
struct ieee80211_authentication {
|
||||
struct ieee80211_header_data header;
|
||||
u16 algorithm;
|
||||
u16 transaction;
|
||||
u16 status;
|
||||
struct ieee80211_info_element info_element;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct ieee80211_probe_response {
|
||||
struct ieee80211_header_data header;
|
||||
u32 time_stamp[2];
|
||||
u16 beacon_interval;
|
||||
u16 capability;
|
||||
struct ieee80211_info_element info_element;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_assoc_request_frame {
|
||||
u16 capability;
|
||||
u16 listen_interval;
|
||||
u8 current_ap[ETH_ALEN];
|
||||
struct ieee80211_info_element info_element;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct ieee80211_assoc_response_frame {
|
||||
struct ieee80211_hdr_3addr header;
|
||||
u16 capability;
|
||||
u16 status;
|
||||
u16 aid;
|
||||
struct ieee80211_info_element info_element; /* supported rates */
|
||||
} __attribute__ ((packed));
|
||||
|
||||
|
||||
struct ieee80211_txb {
|
||||
u8 nr_frags;
|
||||
u8 encrypted;
|
||||
u16 reserved;
|
||||
u16 frag_size;
|
||||
u16 payload_size;
|
||||
struct sk_buff *fragments[0];
|
||||
};
|
||||
|
||||
|
||||
/* SWEEP TABLE ENTRIES NUMBER*/
|
||||
#define MAX_SWEEP_TAB_ENTRIES 42
|
||||
#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7
|
||||
/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs
|
||||
* only use 8, and then use extended rates for the remaining supported
|
||||
* rates. Other APs, however, stick all of their supported rates on the
|
||||
* main rates information element... */
|
||||
#define MAX_RATES_LENGTH ((u8)12)
|
||||
#define MAX_RATES_EX_LENGTH ((u8)16)
|
||||
#define MAX_NETWORK_COUNT 128
|
||||
|
||||
#define CRC_LENGTH 4U
|
||||
|
||||
#define MAX_WPA_IE_LEN 64
|
||||
|
||||
#define NETWORK_EMPTY_ESSID (1<<0)
|
||||
#define NETWORK_HAS_OFDM (1<<1)
|
||||
#define NETWORK_HAS_CCK (1<<2)
|
||||
|
||||
struct ieee80211_network {
|
||||
/* These entries are used to identify a unique network */
|
||||
u8 bssid[ETH_ALEN];
|
||||
u8 channel;
|
||||
/* Ensure null-terminated for any debug msgs */
|
||||
u8 ssid[IW_ESSID_MAX_SIZE + 1];
|
||||
u8 ssid_len;
|
||||
|
||||
/* These are network statistics */
|
||||
struct ieee80211_rx_stats stats;
|
||||
u16 capability;
|
||||
u8 rates[MAX_RATES_LENGTH];
|
||||
u8 rates_len;
|
||||
u8 rates_ex[MAX_RATES_EX_LENGTH];
|
||||
u8 rates_ex_len;
|
||||
unsigned long last_scanned;
|
||||
u8 mode;
|
||||
u8 flags;
|
||||
u32 last_associate;
|
||||
u32 time_stamp[2];
|
||||
u16 beacon_interval;
|
||||
u16 listen_interval;
|
||||
u16 atim_window;
|
||||
u8 wpa_ie[MAX_WPA_IE_LEN];
|
||||
size_t wpa_ie_len;
|
||||
u8 rsn_ie[MAX_WPA_IE_LEN];
|
||||
size_t rsn_ie_len;
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
enum ieee80211_state {
|
||||
IEEE80211_UNINITIALIZED = 0,
|
||||
IEEE80211_INITIALIZED,
|
||||
IEEE80211_ASSOCIATING,
|
||||
IEEE80211_ASSOCIATED,
|
||||
IEEE80211_AUTHENTICATING,
|
||||
IEEE80211_AUTHENTICATED,
|
||||
IEEE80211_SHUTDOWN
|
||||
};
|
||||
|
||||
#define DEFAULT_MAX_SCAN_AGE (15 * HZ)
|
||||
#define DEFAULT_FTS 2346
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define MAC_ARG(x) ((u8*)(x))[0],((u8*)(x))[1],((u8*)(x))[2],((u8*)(x))[3],((u8*)(x))[4],((u8*)(x))[5]
|
||||
|
||||
|
||||
extern inline int is_multicast_ether_addr(const u8 *addr)
|
||||
{
|
||||
return ((addr[0] != 0xff) && (0x01 & addr[0]));
|
||||
}
|
||||
|
||||
extern inline int is_broadcast_ether_addr(const u8 *addr)
|
||||
{
|
||||
return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \
|
||||
(addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
|
||||
}
|
||||
|
||||
#define CFG_IEEE80211_RESERVE_FCS (1<<0)
|
||||
#define CFG_IEEE80211_COMPUTE_FCS (1<<1)
|
||||
|
||||
struct ieee80211_device {
|
||||
struct net_device *dev;
|
||||
|
||||
/* Bookkeeping structures */
|
||||
struct net_device_stats stats;
|
||||
struct ieee80211_stats ieee_stats;
|
||||
|
||||
/* Probe / Beacon management */
|
||||
struct list_head network_free_list;
|
||||
struct list_head network_list;
|
||||
struct ieee80211_network *networks;
|
||||
int scans;
|
||||
int scan_age;
|
||||
|
||||
int iw_mode; /* operating mode (IW_MODE_*) */
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
int tx_headroom; /* Set to size of any additional room needed at front
|
||||
* of allocated Tx SKBs */
|
||||
u32 config;
|
||||
|
||||
/* WEP and other encryption related settings at the device level */
|
||||
int open_wep; /* Set to 1 to allow unencrypted frames */
|
||||
|
||||
int reset_on_keychange; /* Set to 1 if the HW needs to be reset on
|
||||
* WEP key changes */
|
||||
|
||||
/* If the host performs {en,de}cryption, then set to 1 */
|
||||
int host_encrypt;
|
||||
int host_decrypt;
|
||||
int ieee802_1x; /* is IEEE 802.1X used */
|
||||
|
||||
/* WPA data */
|
||||
int wpa_enabled;
|
||||
int drop_unencrypted;
|
||||
int tkip_countermeasures;
|
||||
int privacy_invoked;
|
||||
size_t wpa_ie_len;
|
||||
u8 *wpa_ie;
|
||||
|
||||
struct list_head crypt_deinit_list;
|
||||
struct ieee80211_crypt_data *crypt[WEP_KEYS];
|
||||
int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */
|
||||
struct timer_list crypt_deinit_timer;
|
||||
|
||||
int bcrx_sta_key; /* use individual keys to override default keys even
|
||||
* with RX of broad/multicast frames */
|
||||
|
||||
/* Fragmentation structures */
|
||||
struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN];
|
||||
unsigned int frag_next_idx;
|
||||
u16 fts; /* Fragmentation Threshold */
|
||||
|
||||
/* Association info */
|
||||
u8 bssid[ETH_ALEN];
|
||||
|
||||
enum ieee80211_state state;
|
||||
|
||||
int mode; /* A, B, G */
|
||||
int modulation; /* CCK, OFDM */
|
||||
int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */
|
||||
int abg_ture; /* ABG flag */
|
||||
|
||||
/* Callback functions */
|
||||
void (*set_security)(struct net_device *dev,
|
||||
struct ieee80211_security *sec);
|
||||
int (*hard_start_xmit)(struct ieee80211_txb *txb,
|
||||
struct net_device *dev);
|
||||
int (*reset_port)(struct net_device *dev);
|
||||
|
||||
/* This must be the last item so that it points to the data
|
||||
* allocated beyond this structure by alloc_ieee80211 */
|
||||
u8 priv[0];
|
||||
};
|
||||
|
||||
#define IEEE_A (1<<0)
|
||||
#define IEEE_B (1<<1)
|
||||
#define IEEE_G (1<<2)
|
||||
#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G)
|
||||
|
||||
extern inline void *ieee80211_priv(struct net_device *dev)
|
||||
{
|
||||
return ((struct ieee80211_device *)netdev_priv(dev))->priv;
|
||||
}
|
||||
|
||||
extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
|
||||
{
|
||||
/* Single white space is for Linksys APs */
|
||||
if (essid_len == 1 && essid[0] == ' ')
|
||||
return 1;
|
||||
|
||||
/* Otherwise, if the entire essid is 0, we assume it is hidden */
|
||||
while (essid_len) {
|
||||
essid_len--;
|
||||
if (essid[essid_len] != '\0')
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode)
|
||||
{
|
||||
/*
|
||||
* It is possible for both access points and our device to support
|
||||
* combinations of modes, so as long as there is one valid combination
|
||||
* of ap/device supported modes, then return success
|
||||
*
|
||||
*/
|
||||
if ((mode & IEEE_A) &&
|
||||
(ieee->modulation & IEEE80211_OFDM_MODULATION) &&
|
||||
(ieee->freq_band & IEEE80211_52GHZ_BAND))
|
||||
return 1;
|
||||
|
||||
if ((mode & IEEE_G) &&
|
||||
(ieee->modulation & IEEE80211_OFDM_MODULATION) &&
|
||||
(ieee->freq_band & IEEE80211_24GHZ_BAND))
|
||||
return 1;
|
||||
|
||||
if ((mode & IEEE_B) &&
|
||||
(ieee->modulation & IEEE80211_CCK_MODULATION) &&
|
||||
(ieee->freq_band & IEEE80211_24GHZ_BAND))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern inline int ieee80211_get_hdrlen(u16 fc)
|
||||
{
|
||||
int hdrlen = 24;
|
||||
|
||||
switch (WLAN_FC_GET_TYPE(fc)) {
|
||||
case IEEE80211_FTYPE_DATA:
|
||||
if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))
|
||||
hdrlen = 30; /* Addr4 */
|
||||
break;
|
||||
case IEEE80211_FTYPE_CTL:
|
||||
switch (WLAN_FC_GET_STYPE(fc)) {
|
||||
case IEEE80211_STYPE_CTS:
|
||||
case IEEE80211_STYPE_ACK:
|
||||
hdrlen = 10;
|
||||
break;
|
||||
default:
|
||||
hdrlen = 16;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return hdrlen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ieee80211.c */
|
||||
extern void free_ieee80211(struct net_device *dev);
|
||||
extern struct net_device *alloc_ieee80211(int sizeof_priv);
|
||||
|
||||
extern int ieee80211_set_encryption(struct ieee80211_device *ieee);
|
||||
|
||||
/* ieee80211_tx.c */
|
||||
|
||||
|
||||
extern int ieee80211_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev);
|
||||
extern void ieee80211_txb_free(struct ieee80211_txb *);
|
||||
|
||||
|
||||
/* ieee80211_rx.c */
|
||||
extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
|
||||
struct ieee80211_rx_stats *rx_stats);
|
||||
extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
|
||||
struct ieee80211_hdr *header,
|
||||
struct ieee80211_rx_stats *stats);
|
||||
|
||||
/* iee80211_wx.c */
|
||||
extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *key);
|
||||
extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *key);
|
||||
extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *key);
|
||||
|
||||
|
||||
extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee)
|
||||
{
|
||||
ieee->scans++;
|
||||
}
|
||||
|
||||
extern inline int ieee80211_get_scans(struct ieee80211_device *ieee)
|
||||
{
|
||||
return ieee->scans;
|
||||
}
|
||||
|
||||
static inline const char *escape_essid(const char *essid, u8 essid_len) {
|
||||
static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
|
||||
const char *s = essid;
|
||||
char *d = escaped;
|
||||
|
||||
if (ieee80211_is_empty_essid(essid, essid_len)) {
|
||||
memcpy(escaped, "<hidden>", sizeof("<hidden>"));
|
||||
return escaped;
|
||||
}
|
||||
|
||||
essid_len = min(essid_len, (u8)IW_ESSID_MAX_SIZE);
|
||||
while (essid_len--) {
|
||||
if (*s == '\0') {
|
||||
*d++ = '\\';
|
||||
*d++ = '0';
|
||||
s++;
|
||||
} else {
|
||||
*d++ = *s++;
|
||||
}
|
||||
}
|
||||
*d = '\0';
|
||||
return escaped;
|
||||
}
|
||||
#endif /* IEEE80211_H */
|
86
include/net/ieee80211_crypt.h
Normal file
86
include/net/ieee80211_crypt.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Original code based on Host AP (software wireless LAN access point) driver
|
||||
* for Intersil Prism2/2.5/3.
|
||||
*
|
||||
* Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
||||
* <jkmaline@cc.hut.fi>
|
||||
* Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
*
|
||||
* Adaption to a generic IEEE 802.11 stack by James Ketrenos
|
||||
* <jketreno@linux.intel.com>
|
||||
*
|
||||
* Copyright (c) 2004, Intel Corporation
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file defines the interface to the ieee80211 crypto module.
|
||||
*/
|
||||
#ifndef IEEE80211_CRYPT_H
|
||||
#define IEEE80211_CRYPT_H
|
||||
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
struct ieee80211_crypto_ops {
|
||||
const char *name;
|
||||
|
||||
/* init new crypto context (e.g., allocate private data space,
|
||||
* select IV, etc.); returns NULL on failure or pointer to allocated
|
||||
* private data on success */
|
||||
void * (*init)(int keyidx);
|
||||
|
||||
/* deinitialize crypto context and free allocated private data */
|
||||
void (*deinit)(void *priv);
|
||||
|
||||
/* encrypt/decrypt return < 0 on error or >= 0 on success. The return
|
||||
* value from decrypt_mpdu is passed as the keyidx value for
|
||||
* decrypt_msdu. skb must have enough head and tail room for the
|
||||
* encryption; if not, error will be returned; these functions are
|
||||
* called for all MPDUs (i.e., fragments).
|
||||
*/
|
||||
int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
|
||||
int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv);
|
||||
|
||||
/* These functions are called for full MSDUs, i.e. full frames.
|
||||
* These can be NULL if full MSDU operations are not needed. */
|
||||
int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv);
|
||||
int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len,
|
||||
void *priv);
|
||||
|
||||
int (*set_key)(void *key, int len, u8 *seq, void *priv);
|
||||
int (*get_key)(void *key, int len, u8 *seq, void *priv);
|
||||
|
||||
/* procfs handler for printing out key information and possible
|
||||
* statistics */
|
||||
char * (*print_stats)(char *p, void *priv);
|
||||
|
||||
/* maximum number of bytes added by encryption; encrypt buf is
|
||||
* allocated with extra_prefix_len bytes, copy of in_buf, and
|
||||
* extra_postfix_len; encrypt need not use all this space, but
|
||||
* the result must start at the beginning of the buffer and correct
|
||||
* length must be returned */
|
||||
int extra_prefix_len, extra_postfix_len;
|
||||
|
||||
struct module *owner;
|
||||
};
|
||||
|
||||
struct ieee80211_crypt_data {
|
||||
struct list_head list; /* delayed deletion list */
|
||||
struct ieee80211_crypto_ops *ops;
|
||||
void *priv;
|
||||
atomic_t refcnt;
|
||||
};
|
||||
|
||||
int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops);
|
||||
int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops);
|
||||
struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name);
|
||||
void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int);
|
||||
void ieee80211_crypt_deinit_handler(unsigned long);
|
||||
void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
|
||||
struct ieee80211_crypt_data **crypt);
|
||||
|
||||
#endif
|
|
@ -640,6 +640,8 @@ source "net/irda/Kconfig"
|
|||
|
||||
source "net/bluetooth/Kconfig"
|
||||
|
||||
source "net/ieee80211/Kconfig"
|
||||
|
||||
source "drivers/net/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -42,6 +42,7 @@ obj-$(CONFIG_DECNET) += decnet/
|
|||
obj-$(CONFIG_ECONET) += econet/
|
||||
obj-$(CONFIG_VLAN_8021Q) += 8021q/
|
||||
obj-$(CONFIG_IP_SCTP) += sctp/
|
||||
obj-$(CONFIG_IEEE80211) += ieee80211/
|
||||
|
||||
ifeq ($(CONFIG_NET),y)
|
||||
obj-$(CONFIG_SYSCTL) += sysctl_net.o
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This file implement the Wireless Extensions APIs.
|
||||
*
|
||||
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
|
||||
* Copyright (c) 1997-2004 Jean Tourrilhes, All Rights Reserved.
|
||||
* Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
|
||||
*
|
||||
* (As all part of the Linux kernel, this file is GPL)
|
||||
*/
|
||||
|
@ -187,6 +187,12 @@ static const struct iw_ioctl_description standard_ioctl[] = {
|
|||
.header_type = IW_HEADER_TYPE_ADDR,
|
||||
.flags = IW_DESCR_FLAG_DUMP,
|
||||
},
|
||||
[SIOCSIWMLME - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.min_tokens = sizeof(struct iw_mlme),
|
||||
.max_tokens = sizeof(struct iw_mlme),
|
||||
},
|
||||
[SIOCGIWAPLIST - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = sizeof(struct sockaddr) +
|
||||
|
@ -195,7 +201,10 @@ static const struct iw_ioctl_description standard_ioctl[] = {
|
|||
.flags = IW_DESCR_FLAG_NOMAX,
|
||||
},
|
||||
[SIOCSIWSCAN - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_PARAM,
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.min_tokens = 0,
|
||||
.max_tokens = sizeof(struct iw_scan_req),
|
||||
},
|
||||
[SIOCGIWSCAN - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
|
@ -273,6 +282,42 @@ static const struct iw_ioctl_description standard_ioctl[] = {
|
|||
[SIOCGIWPOWER - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_PARAM,
|
||||
},
|
||||
[SIOCSIWGENIE - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = IW_GENERIC_IE_MAX,
|
||||
},
|
||||
[SIOCGIWGENIE - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = IW_GENERIC_IE_MAX,
|
||||
},
|
||||
[SIOCSIWAUTH - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_PARAM,
|
||||
},
|
||||
[SIOCGIWAUTH - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_PARAM,
|
||||
},
|
||||
[SIOCSIWENCODEEXT - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.min_tokens = sizeof(struct iw_encode_ext),
|
||||
.max_tokens = sizeof(struct iw_encode_ext) +
|
||||
IW_ENCODING_TOKEN_MAX,
|
||||
},
|
||||
[SIOCGIWENCODEEXT - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.min_tokens = sizeof(struct iw_encode_ext),
|
||||
.max_tokens = sizeof(struct iw_encode_ext) +
|
||||
IW_ENCODING_TOKEN_MAX,
|
||||
},
|
||||
[SIOCSIWPMKSA - SIOCIWFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.min_tokens = sizeof(struct iw_pmksa),
|
||||
.max_tokens = sizeof(struct iw_pmksa),
|
||||
},
|
||||
};
|
||||
static const int standard_ioctl_num = (sizeof(standard_ioctl) /
|
||||
sizeof(struct iw_ioctl_description));
|
||||
|
@ -299,6 +344,31 @@ static const struct iw_ioctl_description standard_event[] = {
|
|||
[IWEVEXPIRED - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_ADDR,
|
||||
},
|
||||
[IWEVGENIE - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = IW_GENERIC_IE_MAX,
|
||||
},
|
||||
[IWEVMICHAELMICFAILURE - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = sizeof(struct iw_michaelmicfailure),
|
||||
},
|
||||
[IWEVASSOCREQIE - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = IW_GENERIC_IE_MAX,
|
||||
},
|
||||
[IWEVASSOCRESPIE - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = IW_GENERIC_IE_MAX,
|
||||
},
|
||||
[IWEVPMKIDCAND - IWEVFIRST] = {
|
||||
.header_type = IW_HEADER_TYPE_POINT,
|
||||
.token_size = 1,
|
||||
.max_tokens = sizeof(struct iw_pmkid_cand),
|
||||
},
|
||||
};
|
||||
static const int standard_event_num = (sizeof(standard_event) /
|
||||
sizeof(struct iw_ioctl_description));
|
||||
|
|
67
net/ieee80211/Kconfig
Normal file
67
net/ieee80211/Kconfig
Normal file
|
@ -0,0 +1,67 @@
|
|||
config IEEE80211
|
||||
tristate "Generic IEEE 802.11 Networking Stack"
|
||||
select NET_RADIO
|
||||
---help---
|
||||
This option enables the hardware independent IEEE 802.11
|
||||
networking stack.
|
||||
|
||||
config IEEE80211_DEBUG
|
||||
bool "Enable full debugging output"
|
||||
depends on IEEE80211
|
||||
---help---
|
||||
This option will enable debug tracing output for the
|
||||
ieee80211 network stack.
|
||||
|
||||
This will result in the kernel module being ~70k larger. You
|
||||
can control which debug output is sent to the kernel log by
|
||||
setting the value in
|
||||
|
||||
/proc/net/ieee80211/debug_level
|
||||
|
||||
For example:
|
||||
|
||||
% echo 0x00000FFO > /proc/net/ieee80211/debug_level
|
||||
|
||||
For a list of values you can assign to debug_level, you
|
||||
can look at the bit mask values in <net/ieee80211.h>
|
||||
|
||||
If you are not trying to debug or develop the ieee80211
|
||||
subsystem, you most likely want to say N here.
|
||||
|
||||
config IEEE80211_CRYPT_WEP
|
||||
tristate "IEEE 802.11 WEP encryption (802.1x)"
|
||||
depends on IEEE80211
|
||||
select CRYPTO
|
||||
select CRYPTO_ARC4
|
||||
select CRC32
|
||||
---help---
|
||||
Include software based cipher suites in support of IEEE
|
||||
802.11's WEP. This is needed for WEP as well as 802.1x.
|
||||
|
||||
This can be compiled as a modules and it will be called
|
||||
"ieee80211_crypt_wep".
|
||||
|
||||
config IEEE80211_CRYPT_CCMP
|
||||
tristate "IEEE 802.11i CCMP support"
|
||||
depends on IEEE80211
|
||||
select CRYPTO_AES
|
||||
---help---
|
||||
Include software based cipher suites in support of IEEE 802.11i
|
||||
(aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with CCMP enabled
|
||||
networks.
|
||||
|
||||
This can be compiled as a modules and it will be called
|
||||
"ieee80211_crypt_ccmp".
|
||||
|
||||
config IEEE80211_CRYPT_TKIP
|
||||
tristate "IEEE 802.11i TKIP encryption"
|
||||
depends on IEEE80211
|
||||
select CRYPTO_MICHAEL_MIC
|
||||
---help---
|
||||
Include software based cipher suites in support of IEEE 802.11i
|
||||
(aka TGi, WPA, WPA2, WPA-PSK, etc.) for use with TKIP enabled
|
||||
networks.
|
||||
|
||||
This can be compiled as a modules and it will be called
|
||||
"ieee80211_crypt_tkip".
|
||||
|
11
net/ieee80211/Makefile
Normal file
11
net/ieee80211/Makefile
Normal file
|
@ -0,0 +1,11 @@
|
|||
obj-$(CONFIG_IEEE80211) += ieee80211.o
|
||||
obj-$(CONFIG_IEEE80211) += ieee80211_crypt.o
|
||||
obj-$(CONFIG_IEEE80211_CRYPT_WEP) += ieee80211_crypt_wep.o
|
||||
obj-$(CONFIG_IEEE80211_CRYPT_CCMP) += ieee80211_crypt_ccmp.o
|
||||
obj-$(CONFIG_IEEE80211_CRYPT_TKIP) += ieee80211_crypt_tkip.o
|
||||
ieee80211-objs := \
|
||||
ieee80211_module.o \
|
||||
ieee80211_tx.o \
|
||||
ieee80211_rx.o \
|
||||
ieee80211_wx.o
|
||||
|
259
net/ieee80211/ieee80211_crypt.c
Normal file
259
net/ieee80211/ieee80211_crypt.c
Normal file
|
@ -0,0 +1,259 @@
|
|||
/*
|
||||
* Host AP crypto routines
|
||||
*
|
||||
* Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
* Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/string.h>
|
||||
#include <asm/errno.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
MODULE_AUTHOR("Jouni Malinen");
|
||||
MODULE_DESCRIPTION("HostAP crypto");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
struct ieee80211_crypto_alg {
|
||||
struct list_head list;
|
||||
struct ieee80211_crypto_ops *ops;
|
||||
};
|
||||
|
||||
|
||||
struct ieee80211_crypto {
|
||||
struct list_head algs;
|
||||
spinlock_t lock;
|
||||
};
|
||||
|
||||
static struct ieee80211_crypto *hcrypt;
|
||||
|
||||
void ieee80211_crypt_deinit_entries(struct ieee80211_device *ieee,
|
||||
int force)
|
||||
{
|
||||
struct list_head *ptr, *n;
|
||||
struct ieee80211_crypt_data *entry;
|
||||
|
||||
for (ptr = ieee->crypt_deinit_list.next, n = ptr->next;
|
||||
ptr != &ieee->crypt_deinit_list; ptr = n, n = ptr->next) {
|
||||
entry = list_entry(ptr, struct ieee80211_crypt_data, list);
|
||||
|
||||
if (atomic_read(&entry->refcnt) != 0 && !force)
|
||||
continue;
|
||||
|
||||
list_del(ptr);
|
||||
|
||||
if (entry->ops) {
|
||||
entry->ops->deinit(entry->priv);
|
||||
module_put(entry->ops->owner);
|
||||
}
|
||||
kfree(entry);
|
||||
}
|
||||
}
|
||||
|
||||
void ieee80211_crypt_deinit_handler(unsigned long data)
|
||||
{
|
||||
struct ieee80211_device *ieee = (struct ieee80211_device *)data;
|
||||
unsigned long flags;
|
||||
|
||||
spin_lock_irqsave(&ieee->lock, flags);
|
||||
ieee80211_crypt_deinit_entries(ieee, 0);
|
||||
if (!list_empty(&ieee->crypt_deinit_list)) {
|
||||
printk(KERN_DEBUG "%s: entries remaining in delayed crypt "
|
||||
"deletion list\n", ieee->dev->name);
|
||||
ieee->crypt_deinit_timer.expires = jiffies + HZ;
|
||||
add_timer(&ieee->crypt_deinit_timer);
|
||||
}
|
||||
spin_unlock_irqrestore(&ieee->lock, flags);
|
||||
|
||||
}
|
||||
|
||||
void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee,
|
||||
struct ieee80211_crypt_data **crypt)
|
||||
{
|
||||
struct ieee80211_crypt_data *tmp;
|
||||
unsigned long flags;
|
||||
|
||||
if (*crypt == NULL)
|
||||
return;
|
||||
|
||||
tmp = *crypt;
|
||||
*crypt = NULL;
|
||||
|
||||
/* must not run ops->deinit() while there may be pending encrypt or
|
||||
* decrypt operations. Use a list of delayed deinits to avoid needing
|
||||
* locking. */
|
||||
|
||||
spin_lock_irqsave(&ieee->lock, flags);
|
||||
list_add(&tmp->list, &ieee->crypt_deinit_list);
|
||||
if (!timer_pending(&ieee->crypt_deinit_timer)) {
|
||||
ieee->crypt_deinit_timer.expires = jiffies + HZ;
|
||||
add_timer(&ieee->crypt_deinit_timer);
|
||||
}
|
||||
spin_unlock_irqrestore(&ieee->lock, flags);
|
||||
}
|
||||
|
||||
int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct ieee80211_crypto_alg *alg;
|
||||
|
||||
if (hcrypt == NULL)
|
||||
return -1;
|
||||
|
||||
alg = kmalloc(sizeof(*alg), GFP_KERNEL);
|
||||
if (alg == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(alg, 0, sizeof(*alg));
|
||||
alg->ops = ops;
|
||||
|
||||
spin_lock_irqsave(&hcrypt->lock, flags);
|
||||
list_add(&alg->list, &hcrypt->algs);
|
||||
spin_unlock_irqrestore(&hcrypt->lock, flags);
|
||||
|
||||
printk(KERN_DEBUG "ieee80211_crypt: registered algorithm '%s'\n",
|
||||
ops->name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head *ptr;
|
||||
struct ieee80211_crypto_alg *del_alg = NULL;
|
||||
|
||||
if (hcrypt == NULL)
|
||||
return -1;
|
||||
|
||||
spin_lock_irqsave(&hcrypt->lock, flags);
|
||||
for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
|
||||
struct ieee80211_crypto_alg *alg =
|
||||
(struct ieee80211_crypto_alg *) ptr;
|
||||
if (alg->ops == ops) {
|
||||
list_del(&alg->list);
|
||||
del_alg = alg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&hcrypt->lock, flags);
|
||||
|
||||
if (del_alg) {
|
||||
printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
|
||||
"'%s'\n", ops->name);
|
||||
kfree(del_alg);
|
||||
}
|
||||
|
||||
return del_alg ? 0 : -1;
|
||||
}
|
||||
|
||||
|
||||
struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name)
|
||||
{
|
||||
unsigned long flags;
|
||||
struct list_head *ptr;
|
||||
struct ieee80211_crypto_alg *found_alg = NULL;
|
||||
|
||||
if (hcrypt == NULL)
|
||||
return NULL;
|
||||
|
||||
spin_lock_irqsave(&hcrypt->lock, flags);
|
||||
for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
|
||||
struct ieee80211_crypto_alg *alg =
|
||||
(struct ieee80211_crypto_alg *) ptr;
|
||||
if (strcmp(alg->ops->name, name) == 0) {
|
||||
found_alg = alg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock_irqrestore(&hcrypt->lock, flags);
|
||||
|
||||
if (found_alg)
|
||||
return found_alg->ops;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void * ieee80211_crypt_null_init(int keyidx) { return (void *) 1; }
|
||||
static void ieee80211_crypt_null_deinit(void *priv) {}
|
||||
|
||||
static struct ieee80211_crypto_ops ieee80211_crypt_null = {
|
||||
.name = "NULL",
|
||||
.init = ieee80211_crypt_null_init,
|
||||
.deinit = ieee80211_crypt_null_deinit,
|
||||
.encrypt_mpdu = NULL,
|
||||
.decrypt_mpdu = NULL,
|
||||
.encrypt_msdu = NULL,
|
||||
.decrypt_msdu = NULL,
|
||||
.set_key = NULL,
|
||||
.get_key = NULL,
|
||||
.extra_prefix_len = 0,
|
||||
.extra_postfix_len = 0,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
||||
static int __init ieee80211_crypto_init(void)
|
||||
{
|
||||
int ret = -ENOMEM;
|
||||
|
||||
hcrypt = kmalloc(sizeof(*hcrypt), GFP_KERNEL);
|
||||
if (!hcrypt)
|
||||
goto out;
|
||||
|
||||
memset(hcrypt, 0, sizeof(*hcrypt));
|
||||
INIT_LIST_HEAD(&hcrypt->algs);
|
||||
spin_lock_init(&hcrypt->lock);
|
||||
|
||||
ret = ieee80211_register_crypto_ops(&ieee80211_crypt_null);
|
||||
if (ret < 0) {
|
||||
kfree(hcrypt);
|
||||
hcrypt = NULL;
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void __exit ieee80211_crypto_deinit(void)
|
||||
{
|
||||
struct list_head *ptr, *n;
|
||||
|
||||
if (hcrypt == NULL)
|
||||
return;
|
||||
|
||||
for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs;
|
||||
ptr = n, n = ptr->next) {
|
||||
struct ieee80211_crypto_alg *alg =
|
||||
(struct ieee80211_crypto_alg *) ptr;
|
||||
list_del(ptr);
|
||||
printk(KERN_DEBUG "ieee80211_crypt: unregistered algorithm "
|
||||
"'%s' (deinit)\n", alg->ops->name);
|
||||
kfree(alg);
|
||||
}
|
||||
|
||||
kfree(hcrypt);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(ieee80211_crypt_deinit_entries);
|
||||
EXPORT_SYMBOL(ieee80211_crypt_deinit_handler);
|
||||
EXPORT_SYMBOL(ieee80211_crypt_delayed_deinit);
|
||||
|
||||
EXPORT_SYMBOL(ieee80211_register_crypto_ops);
|
||||
EXPORT_SYMBOL(ieee80211_unregister_crypto_ops);
|
||||
EXPORT_SYMBOL(ieee80211_get_crypto_ops);
|
||||
|
||||
module_init(ieee80211_crypto_init);
|
||||
module_exit(ieee80211_crypto_deinit);
|
470
net/ieee80211/ieee80211_crypt_ccmp.c
Normal file
470
net/ieee80211/ieee80211_crypt_ccmp.c
Normal file
|
@ -0,0 +1,470 @@
|
|||
/*
|
||||
* Host AP crypt: host-based CCMP encryption implementation for Host AP driver
|
||||
*
|
||||
* Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <asm/string.h>
|
||||
#include <linux/wireless.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/scatterlist.h>
|
||||
|
||||
MODULE_AUTHOR("Jouni Malinen");
|
||||
MODULE_DESCRIPTION("Host AP crypt: CCMP");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
#define AES_BLOCK_LEN 16
|
||||
#define CCMP_HDR_LEN 8
|
||||
#define CCMP_MIC_LEN 8
|
||||
#define CCMP_TK_LEN 16
|
||||
#define CCMP_PN_LEN 6
|
||||
|
||||
struct ieee80211_ccmp_data {
|
||||
u8 key[CCMP_TK_LEN];
|
||||
int key_set;
|
||||
|
||||
u8 tx_pn[CCMP_PN_LEN];
|
||||
u8 rx_pn[CCMP_PN_LEN];
|
||||
|
||||
u32 dot11RSNAStatsCCMPFormatErrors;
|
||||
u32 dot11RSNAStatsCCMPReplays;
|
||||
u32 dot11RSNAStatsCCMPDecryptErrors;
|
||||
|
||||
int key_idx;
|
||||
|
||||
struct crypto_tfm *tfm;
|
||||
|
||||
/* scratch buffers for virt_to_page() (crypto API) */
|
||||
u8 tx_b0[AES_BLOCK_LEN], tx_b[AES_BLOCK_LEN],
|
||||
tx_e[AES_BLOCK_LEN], tx_s0[AES_BLOCK_LEN];
|
||||
u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN];
|
||||
};
|
||||
|
||||
void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
|
||||
const u8 pt[16], u8 ct[16])
|
||||
{
|
||||
struct scatterlist src, dst;
|
||||
|
||||
src.page = virt_to_page(pt);
|
||||
src.offset = offset_in_page(pt);
|
||||
src.length = AES_BLOCK_LEN;
|
||||
|
||||
dst.page = virt_to_page(ct);
|
||||
dst.offset = offset_in_page(ct);
|
||||
dst.length = AES_BLOCK_LEN;
|
||||
|
||||
crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
|
||||
}
|
||||
|
||||
static void * ieee80211_ccmp_init(int key_idx)
|
||||
{
|
||||
struct ieee80211_ccmp_data *priv;
|
||||
|
||||
priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
|
||||
if (priv == NULL)
|
||||
goto fail;
|
||||
memset(priv, 0, sizeof(*priv));
|
||||
priv->key_idx = key_idx;
|
||||
|
||||
priv->tfm = crypto_alloc_tfm("aes", 0);
|
||||
if (priv->tfm == NULL) {
|
||||
printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate "
|
||||
"crypto API aes\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return priv;
|
||||
|
||||
fail:
|
||||
if (priv) {
|
||||
if (priv->tfm)
|
||||
crypto_free_tfm(priv->tfm);
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void ieee80211_ccmp_deinit(void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *_priv = priv;
|
||||
if (_priv && _priv->tfm)
|
||||
crypto_free_tfm(_priv->tfm);
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
|
||||
static inline void xor_block(u8 *b, u8 *a, size_t len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
b[i] ^= a[i];
|
||||
}
|
||||
|
||||
|
||||
static void ccmp_init_blocks(struct crypto_tfm *tfm,
|
||||
struct ieee80211_hdr *hdr,
|
||||
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
|
||||
u8 *s0)
|
||||
{
|
||||
u8 *pos, qc = 0;
|
||||
size_t aad_len;
|
||||
u16 fc;
|
||||
int a4_included, qc_included;
|
||||
u8 aad[2 * AES_BLOCK_LEN];
|
||||
|
||||
fc = le16_to_cpu(hdr->frame_ctl);
|
||||
a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
|
||||
(IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS));
|
||||
qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) &&
|
||||
(WLAN_FC_GET_STYPE(fc) & 0x08));
|
||||
aad_len = 22;
|
||||
if (a4_included)
|
||||
aad_len += 6;
|
||||
if (qc_included) {
|
||||
pos = (u8 *) &hdr->addr4;
|
||||
if (a4_included)
|
||||
pos += 6;
|
||||
qc = *pos & 0x0f;
|
||||
aad_len += 2;
|
||||
}
|
||||
|
||||
/* CCM Initial Block:
|
||||
* Flag (Include authentication header, M=3 (8-octet MIC),
|
||||
* L=1 (2-octet Dlen))
|
||||
* Nonce: 0x00 | A2 | PN
|
||||
* Dlen */
|
||||
b0[0] = 0x59;
|
||||
b0[1] = qc;
|
||||
memcpy(b0 + 2, hdr->addr2, ETH_ALEN);
|
||||
memcpy(b0 + 8, pn, CCMP_PN_LEN);
|
||||
b0[14] = (dlen >> 8) & 0xff;
|
||||
b0[15] = dlen & 0xff;
|
||||
|
||||
/* AAD:
|
||||
* FC with bits 4..6 and 11..13 masked to zero; 14 is always one
|
||||
* A1 | A2 | A3
|
||||
* SC with bits 4..15 (seq#) masked to zero
|
||||
* A4 (if present)
|
||||
* QC (if present)
|
||||
*/
|
||||
pos = (u8 *) hdr;
|
||||
aad[0] = 0; /* aad_len >> 8 */
|
||||
aad[1] = aad_len & 0xff;
|
||||
aad[2] = pos[0] & 0x8f;
|
||||
aad[3] = pos[1] & 0xc7;
|
||||
memcpy(aad + 4, hdr->addr1, 3 * ETH_ALEN);
|
||||
pos = (u8 *) &hdr->seq_ctl;
|
||||
aad[22] = pos[0] & 0x0f;
|
||||
aad[23] = 0; /* all bits masked */
|
||||
memset(aad + 24, 0, 8);
|
||||
if (a4_included)
|
||||
memcpy(aad + 24, hdr->addr4, ETH_ALEN);
|
||||
if (qc_included) {
|
||||
aad[a4_included ? 30 : 24] = qc;
|
||||
/* rest of QC masked */
|
||||
}
|
||||
|
||||
/* Start with the first block and AAD */
|
||||
ieee80211_ccmp_aes_encrypt(tfm, b0, auth);
|
||||
xor_block(auth, aad, AES_BLOCK_LEN);
|
||||
ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
|
||||
xor_block(auth, &aad[AES_BLOCK_LEN], AES_BLOCK_LEN);
|
||||
ieee80211_ccmp_aes_encrypt(tfm, auth, auth);
|
||||
b0[0] &= 0x07;
|
||||
b0[14] = b0[15] = 0;
|
||||
ieee80211_ccmp_aes_encrypt(tfm, b0, s0);
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *key = priv;
|
||||
int data_len, i, blocks, last, len;
|
||||
u8 *pos, *mic;
|
||||
struct ieee80211_hdr *hdr;
|
||||
u8 *b0 = key->tx_b0;
|
||||
u8 *b = key->tx_b;
|
||||
u8 *e = key->tx_e;
|
||||
u8 *s0 = key->tx_s0;
|
||||
|
||||
if (skb_headroom(skb) < CCMP_HDR_LEN ||
|
||||
skb_tailroom(skb) < CCMP_MIC_LEN ||
|
||||
skb->len < hdr_len)
|
||||
return -1;
|
||||
|
||||
data_len = skb->len - hdr_len;
|
||||
pos = skb_push(skb, CCMP_HDR_LEN);
|
||||
memmove(pos, pos + CCMP_HDR_LEN, hdr_len);
|
||||
pos += hdr_len;
|
||||
mic = skb_put(skb, CCMP_MIC_LEN);
|
||||
|
||||
i = CCMP_PN_LEN - 1;
|
||||
while (i >= 0) {
|
||||
key->tx_pn[i]++;
|
||||
if (key->tx_pn[i] != 0)
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
|
||||
*pos++ = key->tx_pn[5];
|
||||
*pos++ = key->tx_pn[4];
|
||||
*pos++ = 0;
|
||||
*pos++ = (key->key_idx << 6) | (1 << 5) /* Ext IV included */;
|
||||
*pos++ = key->tx_pn[3];
|
||||
*pos++ = key->tx_pn[2];
|
||||
*pos++ = key->tx_pn[1];
|
||||
*pos++ = key->tx_pn[0];
|
||||
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
ccmp_init_blocks(key->tfm, hdr, key->tx_pn, data_len, b0, b, s0);
|
||||
|
||||
blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
|
||||
last = data_len % AES_BLOCK_LEN;
|
||||
|
||||
for (i = 1; i <= blocks; i++) {
|
||||
len = (i == blocks && last) ? last : AES_BLOCK_LEN;
|
||||
/* Authentication */
|
||||
xor_block(b, pos, len);
|
||||
ieee80211_ccmp_aes_encrypt(key->tfm, b, b);
|
||||
/* Encryption, with counter */
|
||||
b0[14] = (i >> 8) & 0xff;
|
||||
b0[15] = i & 0xff;
|
||||
ieee80211_ccmp_aes_encrypt(key->tfm, b0, e);
|
||||
xor_block(pos, e, len);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
for (i = 0; i < CCMP_MIC_LEN; i++)
|
||||
mic[i] = b[i] ^ s0[i];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *key = priv;
|
||||
u8 keyidx, *pos;
|
||||
struct ieee80211_hdr *hdr;
|
||||
u8 *b0 = key->rx_b0;
|
||||
u8 *b = key->rx_b;
|
||||
u8 *a = key->rx_a;
|
||||
u8 pn[6];
|
||||
int i, blocks, last, len;
|
||||
size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN;
|
||||
u8 *mic = skb->data + skb->len - CCMP_MIC_LEN;
|
||||
|
||||
if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
|
||||
key->dot11RSNAStatsCCMPFormatErrors++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
pos = skb->data + hdr_len;
|
||||
keyidx = pos[3];
|
||||
if (!(keyidx & (1 << 5))) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "CCMP: received packet without ExtIV"
|
||||
" flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
|
||||
}
|
||||
key->dot11RSNAStatsCCMPFormatErrors++;
|
||||
return -2;
|
||||
}
|
||||
keyidx >>= 6;
|
||||
if (key->key_idx != keyidx) {
|
||||
printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame "
|
||||
"keyidx=%d priv=%p\n", key->key_idx, keyidx, priv);
|
||||
return -6;
|
||||
}
|
||||
if (!key->key_set) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "CCMP: received packet from " MAC_FMT
|
||||
" with keyid=%d that does not have a configured"
|
||||
" key\n", MAC_ARG(hdr->addr2), keyidx);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
|
||||
pn[0] = pos[7];
|
||||
pn[1] = pos[6];
|
||||
pn[2] = pos[5];
|
||||
pn[3] = pos[4];
|
||||
pn[4] = pos[1];
|
||||
pn[5] = pos[0];
|
||||
pos += 8;
|
||||
|
||||
if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "CCMP: replay detected: STA=" MAC_FMT
|
||||
" previous PN %02x%02x%02x%02x%02x%02x "
|
||||
"received PN %02x%02x%02x%02x%02x%02x\n",
|
||||
MAC_ARG(hdr->addr2), MAC_ARG(key->rx_pn),
|
||||
MAC_ARG(pn));
|
||||
}
|
||||
key->dot11RSNAStatsCCMPReplays++;
|
||||
return -4;
|
||||
}
|
||||
|
||||
ccmp_init_blocks(key->tfm, hdr, pn, data_len, b0, a, b);
|
||||
xor_block(mic, b, CCMP_MIC_LEN);
|
||||
|
||||
blocks = (data_len + AES_BLOCK_LEN - 1) / AES_BLOCK_LEN;
|
||||
last = data_len % AES_BLOCK_LEN;
|
||||
|
||||
for (i = 1; i <= blocks; i++) {
|
||||
len = (i == blocks && last) ? last : AES_BLOCK_LEN;
|
||||
/* Decrypt, with counter */
|
||||
b0[14] = (i >> 8) & 0xff;
|
||||
b0[15] = i & 0xff;
|
||||
ieee80211_ccmp_aes_encrypt(key->tfm, b0, b);
|
||||
xor_block(pos, b, len);
|
||||
/* Authentication */
|
||||
xor_block(a, pos, len);
|
||||
ieee80211_ccmp_aes_encrypt(key->tfm, a, a);
|
||||
pos += len;
|
||||
}
|
||||
|
||||
if (memcmp(mic, a, CCMP_MIC_LEN) != 0) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "CCMP: decrypt failed: STA="
|
||||
MAC_FMT "\n", MAC_ARG(hdr->addr2));
|
||||
}
|
||||
key->dot11RSNAStatsCCMPDecryptErrors++;
|
||||
return -5;
|
||||
}
|
||||
|
||||
memcpy(key->rx_pn, pn, CCMP_PN_LEN);
|
||||
|
||||
/* Remove hdr and MIC */
|
||||
memmove(skb->data + CCMP_HDR_LEN, skb->data, hdr_len);
|
||||
skb_pull(skb, CCMP_HDR_LEN);
|
||||
skb_trim(skb, skb->len - CCMP_MIC_LEN);
|
||||
|
||||
return keyidx;
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *data = priv;
|
||||
int keyidx;
|
||||
struct crypto_tfm *tfm = data->tfm;
|
||||
|
||||
keyidx = data->key_idx;
|
||||
memset(data, 0, sizeof(*data));
|
||||
data->key_idx = keyidx;
|
||||
data->tfm = tfm;
|
||||
if (len == CCMP_TK_LEN) {
|
||||
memcpy(data->key, key, CCMP_TK_LEN);
|
||||
data->key_set = 1;
|
||||
if (seq) {
|
||||
data->rx_pn[0] = seq[5];
|
||||
data->rx_pn[1] = seq[4];
|
||||
data->rx_pn[2] = seq[3];
|
||||
data->rx_pn[3] = seq[2];
|
||||
data->rx_pn[4] = seq[1];
|
||||
data->rx_pn[5] = seq[0];
|
||||
}
|
||||
crypto_cipher_setkey(data->tfm, data->key, CCMP_TK_LEN);
|
||||
} else if (len == 0)
|
||||
data->key_set = 0;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *data = priv;
|
||||
|
||||
if (len < CCMP_TK_LEN)
|
||||
return -1;
|
||||
|
||||
if (!data->key_set)
|
||||
return 0;
|
||||
memcpy(key, data->key, CCMP_TK_LEN);
|
||||
|
||||
if (seq) {
|
||||
seq[0] = data->tx_pn[5];
|
||||
seq[1] = data->tx_pn[4];
|
||||
seq[2] = data->tx_pn[3];
|
||||
seq[3] = data->tx_pn[2];
|
||||
seq[4] = data->tx_pn[1];
|
||||
seq[5] = data->tx_pn[0];
|
||||
}
|
||||
|
||||
return CCMP_TK_LEN;
|
||||
}
|
||||
|
||||
|
||||
static char * ieee80211_ccmp_print_stats(char *p, void *priv)
|
||||
{
|
||||
struct ieee80211_ccmp_data *ccmp = priv;
|
||||
p += sprintf(p, "key[%d] alg=CCMP key_set=%d "
|
||||
"tx_pn=%02x%02x%02x%02x%02x%02x "
|
||||
"rx_pn=%02x%02x%02x%02x%02x%02x "
|
||||
"format_errors=%d replays=%d decrypt_errors=%d\n",
|
||||
ccmp->key_idx, ccmp->key_set,
|
||||
MAC_ARG(ccmp->tx_pn), MAC_ARG(ccmp->rx_pn),
|
||||
ccmp->dot11RSNAStatsCCMPFormatErrors,
|
||||
ccmp->dot11RSNAStatsCCMPReplays,
|
||||
ccmp->dot11RSNAStatsCCMPDecryptErrors);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static struct ieee80211_crypto_ops ieee80211_crypt_ccmp = {
|
||||
.name = "CCMP",
|
||||
.init = ieee80211_ccmp_init,
|
||||
.deinit = ieee80211_ccmp_deinit,
|
||||
.encrypt_mpdu = ieee80211_ccmp_encrypt,
|
||||
.decrypt_mpdu = ieee80211_ccmp_decrypt,
|
||||
.encrypt_msdu = NULL,
|
||||
.decrypt_msdu = NULL,
|
||||
.set_key = ieee80211_ccmp_set_key,
|
||||
.get_key = ieee80211_ccmp_get_key,
|
||||
.print_stats = ieee80211_ccmp_print_stats,
|
||||
.extra_prefix_len = CCMP_HDR_LEN,
|
||||
.extra_postfix_len = CCMP_MIC_LEN,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
||||
static int __init ieee80211_crypto_ccmp_init(void)
|
||||
{
|
||||
return ieee80211_register_crypto_ops(&ieee80211_crypt_ccmp);
|
||||
}
|
||||
|
||||
|
||||
static void __exit ieee80211_crypto_ccmp_exit(void)
|
||||
{
|
||||
ieee80211_unregister_crypto_ops(&ieee80211_crypt_ccmp);
|
||||
}
|
||||
|
||||
|
||||
module_init(ieee80211_crypto_ccmp_init);
|
||||
module_exit(ieee80211_crypto_ccmp_exit);
|
708
net/ieee80211/ieee80211_crypt_tkip.c
Normal file
708
net/ieee80211/ieee80211_crypt_tkip.c
Normal file
|
@ -0,0 +1,708 @@
|
|||
/*
|
||||
* Host AP crypt: host-based TKIP encryption implementation for Host AP driver
|
||||
*
|
||||
* Copyright (c) 2003-2004, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <asm/string.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include <linux/crc32.h>
|
||||
|
||||
MODULE_AUTHOR("Jouni Malinen");
|
||||
MODULE_DESCRIPTION("Host AP crypt: TKIP");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
struct ieee80211_tkip_data {
|
||||
#define TKIP_KEY_LEN 32
|
||||
u8 key[TKIP_KEY_LEN];
|
||||
int key_set;
|
||||
|
||||
u32 tx_iv32;
|
||||
u16 tx_iv16;
|
||||
u16 tx_ttak[5];
|
||||
int tx_phase1_done;
|
||||
|
||||
u32 rx_iv32;
|
||||
u16 rx_iv16;
|
||||
u16 rx_ttak[5];
|
||||
int rx_phase1_done;
|
||||
u32 rx_iv32_new;
|
||||
u16 rx_iv16_new;
|
||||
|
||||
u32 dot11RSNAStatsTKIPReplays;
|
||||
u32 dot11RSNAStatsTKIPICVErrors;
|
||||
u32 dot11RSNAStatsTKIPLocalMICFailures;
|
||||
|
||||
int key_idx;
|
||||
|
||||
struct crypto_tfm *tfm_arc4;
|
||||
struct crypto_tfm *tfm_michael;
|
||||
|
||||
/* scratch buffers for virt_to_page() (crypto API) */
|
||||
u8 rx_hdr[16], tx_hdr[16];
|
||||
};
|
||||
|
||||
static void * ieee80211_tkip_init(int key_idx)
|
||||
{
|
||||
struct ieee80211_tkip_data *priv;
|
||||
|
||||
priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
|
||||
if (priv == NULL)
|
||||
goto fail;
|
||||
memset(priv, 0, sizeof(*priv));
|
||||
priv->key_idx = key_idx;
|
||||
|
||||
priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
|
||||
if (priv->tfm_arc4 == NULL) {
|
||||
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
||||
"crypto API arc4\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
priv->tfm_michael = crypto_alloc_tfm("michael_mic", 0);
|
||||
if (priv->tfm_michael == NULL) {
|
||||
printk(KERN_DEBUG "ieee80211_crypt_tkip: could not allocate "
|
||||
"crypto API michael_mic\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return priv;
|
||||
|
||||
fail:
|
||||
if (priv) {
|
||||
if (priv->tfm_michael)
|
||||
crypto_free_tfm(priv->tfm_michael);
|
||||
if (priv->tfm_arc4)
|
||||
crypto_free_tfm(priv->tfm_arc4);
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void ieee80211_tkip_deinit(void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *_priv = priv;
|
||||
if (_priv && _priv->tfm_michael)
|
||||
crypto_free_tfm(_priv->tfm_michael);
|
||||
if (_priv && _priv->tfm_arc4)
|
||||
crypto_free_tfm(_priv->tfm_arc4);
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
|
||||
static inline u16 RotR1(u16 val)
|
||||
{
|
||||
return (val >> 1) | (val << 15);
|
||||
}
|
||||
|
||||
|
||||
static inline u8 Lo8(u16 val)
|
||||
{
|
||||
return val & 0xff;
|
||||
}
|
||||
|
||||
|
||||
static inline u8 Hi8(u16 val)
|
||||
{
|
||||
return val >> 8;
|
||||
}
|
||||
|
||||
|
||||
static inline u16 Lo16(u32 val)
|
||||
{
|
||||
return val & 0xffff;
|
||||
}
|
||||
|
||||
|
||||
static inline u16 Hi16(u32 val)
|
||||
{
|
||||
return val >> 16;
|
||||
}
|
||||
|
||||
|
||||
static inline u16 Mk16(u8 hi, u8 lo)
|
||||
{
|
||||
return lo | (((u16) hi) << 8);
|
||||
}
|
||||
|
||||
|
||||
static inline u16 Mk16_le(u16 *v)
|
||||
{
|
||||
return le16_to_cpu(*v);
|
||||
}
|
||||
|
||||
|
||||
static const u16 Sbox[256] =
|
||||
{
|
||||
0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154,
|
||||
0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A,
|
||||
0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B,
|
||||
0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B,
|
||||
0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F,
|
||||
0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F,
|
||||
0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5,
|
||||
0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F,
|
||||
0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB,
|
||||
0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397,
|
||||
0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED,
|
||||
0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A,
|
||||
0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194,
|
||||
0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3,
|
||||
0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104,
|
||||
0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D,
|
||||
0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39,
|
||||
0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695,
|
||||
0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83,
|
||||
0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76,
|
||||
0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4,
|
||||
0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B,
|
||||
0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0,
|
||||
0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018,
|
||||
0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751,
|
||||
0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85,
|
||||
0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12,
|
||||
0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9,
|
||||
0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7,
|
||||
0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A,
|
||||
0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8,
|
||||
0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A,
|
||||
};
|
||||
|
||||
|
||||
static inline u16 _S_(u16 v)
|
||||
{
|
||||
u16 t = Sbox[Hi8(v)];
|
||||
return Sbox[Lo8(v)] ^ ((t << 8) | (t >> 8));
|
||||
}
|
||||
|
||||
|
||||
#define PHASE1_LOOP_COUNT 8
|
||||
|
||||
static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
/* Initialize the 80-bit TTAK from TSC (IV32) and TA[0..5] */
|
||||
TTAK[0] = Lo16(IV32);
|
||||
TTAK[1] = Hi16(IV32);
|
||||
TTAK[2] = Mk16(TA[1], TA[0]);
|
||||
TTAK[3] = Mk16(TA[3], TA[2]);
|
||||
TTAK[4] = Mk16(TA[5], TA[4]);
|
||||
|
||||
for (i = 0; i < PHASE1_LOOP_COUNT; i++) {
|
||||
j = 2 * (i & 1);
|
||||
TTAK[0] += _S_(TTAK[4] ^ Mk16(TK[1 + j], TK[0 + j]));
|
||||
TTAK[1] += _S_(TTAK[0] ^ Mk16(TK[5 + j], TK[4 + j]));
|
||||
TTAK[2] += _S_(TTAK[1] ^ Mk16(TK[9 + j], TK[8 + j]));
|
||||
TTAK[3] += _S_(TTAK[2] ^ Mk16(TK[13 + j], TK[12 + j]));
|
||||
TTAK[4] += _S_(TTAK[3] ^ Mk16(TK[1 + j], TK[0 + j])) + i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK,
|
||||
u16 IV16)
|
||||
{
|
||||
/* Make temporary area overlap WEP seed so that the final copy can be
|
||||
* avoided on little endian hosts. */
|
||||
u16 *PPK = (u16 *) &WEPSeed[4];
|
||||
|
||||
/* Step 1 - make copy of TTAK and bring in TSC */
|
||||
PPK[0] = TTAK[0];
|
||||
PPK[1] = TTAK[1];
|
||||
PPK[2] = TTAK[2];
|
||||
PPK[3] = TTAK[3];
|
||||
PPK[4] = TTAK[4];
|
||||
PPK[5] = TTAK[4] + IV16;
|
||||
|
||||
/* Step 2 - 96-bit bijective mixing using S-box */
|
||||
PPK[0] += _S_(PPK[5] ^ Mk16_le((u16 *) &TK[0]));
|
||||
PPK[1] += _S_(PPK[0] ^ Mk16_le((u16 *) &TK[2]));
|
||||
PPK[2] += _S_(PPK[1] ^ Mk16_le((u16 *) &TK[4]));
|
||||
PPK[3] += _S_(PPK[2] ^ Mk16_le((u16 *) &TK[6]));
|
||||
PPK[4] += _S_(PPK[3] ^ Mk16_le((u16 *) &TK[8]));
|
||||
PPK[5] += _S_(PPK[4] ^ Mk16_le((u16 *) &TK[10]));
|
||||
|
||||
PPK[0] += RotR1(PPK[5] ^ Mk16_le((u16 *) &TK[12]));
|
||||
PPK[1] += RotR1(PPK[0] ^ Mk16_le((u16 *) &TK[14]));
|
||||
PPK[2] += RotR1(PPK[1]);
|
||||
PPK[3] += RotR1(PPK[2]);
|
||||
PPK[4] += RotR1(PPK[3]);
|
||||
PPK[5] += RotR1(PPK[4]);
|
||||
|
||||
/* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value
|
||||
* WEPSeed[0..2] is transmitted as WEP IV */
|
||||
WEPSeed[0] = Hi8(IV16);
|
||||
WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F;
|
||||
WEPSeed[2] = Lo8(IV16);
|
||||
WEPSeed[3] = Lo8((PPK[5] ^ Mk16_le((u16 *) &TK[0])) >> 1);
|
||||
|
||||
#ifdef __BIG_ENDIAN
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 6; i++)
|
||||
PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
int len;
|
||||
u8 rc4key[16], *pos, *icv;
|
||||
struct ieee80211_hdr *hdr;
|
||||
u32 crc;
|
||||
struct scatterlist sg;
|
||||
|
||||
if (skb_headroom(skb) < 8 || skb_tailroom(skb) < 4 ||
|
||||
skb->len < hdr_len)
|
||||
return -1;
|
||||
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
if (!tkey->tx_phase1_done) {
|
||||
tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2,
|
||||
tkey->tx_iv32);
|
||||
tkey->tx_phase1_done = 1;
|
||||
}
|
||||
tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16);
|
||||
|
||||
len = skb->len - hdr_len;
|
||||
pos = skb_push(skb, 8);
|
||||
memmove(pos, pos + 8, hdr_len);
|
||||
pos += hdr_len;
|
||||
icv = skb_put(skb, 4);
|
||||
|
||||
*pos++ = rc4key[0];
|
||||
*pos++ = rc4key[1];
|
||||
*pos++ = rc4key[2];
|
||||
*pos++ = (tkey->key_idx << 6) | (1 << 5) /* Ext IV included */;
|
||||
*pos++ = tkey->tx_iv32 & 0xff;
|
||||
*pos++ = (tkey->tx_iv32 >> 8) & 0xff;
|
||||
*pos++ = (tkey->tx_iv32 >> 16) & 0xff;
|
||||
*pos++ = (tkey->tx_iv32 >> 24) & 0xff;
|
||||
|
||||
crc = ~crc32_le(~0, pos, len);
|
||||
icv[0] = crc;
|
||||
icv[1] = crc >> 8;
|
||||
icv[2] = crc >> 16;
|
||||
icv[3] = crc >> 24;
|
||||
|
||||
crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
|
||||
sg.page = virt_to_page(pos);
|
||||
sg.offset = offset_in_page(pos);
|
||||
sg.length = len + 4;
|
||||
crypto_cipher_encrypt(tkey->tfm_arc4, &sg, &sg, len + 4);
|
||||
|
||||
tkey->tx_iv16++;
|
||||
if (tkey->tx_iv16 == 0) {
|
||||
tkey->tx_phase1_done = 0;
|
||||
tkey->tx_iv32++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
u8 rc4key[16];
|
||||
u8 keyidx, *pos;
|
||||
u32 iv32;
|
||||
u16 iv16;
|
||||
struct ieee80211_hdr *hdr;
|
||||
u8 icv[4];
|
||||
u32 crc;
|
||||
struct scatterlist sg;
|
||||
int plen;
|
||||
|
||||
if (skb->len < hdr_len + 8 + 4)
|
||||
return -1;
|
||||
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
pos = skb->data + hdr_len;
|
||||
keyidx = pos[3];
|
||||
if (!(keyidx & (1 << 5))) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "TKIP: received packet without ExtIV"
|
||||
" flag from " MAC_FMT "\n", MAC_ARG(hdr->addr2));
|
||||
}
|
||||
return -2;
|
||||
}
|
||||
keyidx >>= 6;
|
||||
if (tkey->key_idx != keyidx) {
|
||||
printk(KERN_DEBUG "TKIP: RX tkey->key_idx=%d frame "
|
||||
"keyidx=%d priv=%p\n", tkey->key_idx, keyidx, priv);
|
||||
return -6;
|
||||
}
|
||||
if (!tkey->key_set) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "TKIP: received packet from " MAC_FMT
|
||||
" with keyid=%d that does not have a configured"
|
||||
" key\n", MAC_ARG(hdr->addr2), keyidx);
|
||||
}
|
||||
return -3;
|
||||
}
|
||||
iv16 = (pos[0] << 8) | pos[2];
|
||||
iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24);
|
||||
pos += 8;
|
||||
|
||||
if (iv32 < tkey->rx_iv32 ||
|
||||
(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) {
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "TKIP: replay detected: STA=" MAC_FMT
|
||||
" previous TSC %08x%04x received TSC "
|
||||
"%08x%04x\n", MAC_ARG(hdr->addr2),
|
||||
tkey->rx_iv32, tkey->rx_iv16, iv32, iv16);
|
||||
}
|
||||
tkey->dot11RSNAStatsTKIPReplays++;
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (iv32 != tkey->rx_iv32 || !tkey->rx_phase1_done) {
|
||||
tkip_mixing_phase1(tkey->rx_ttak, tkey->key, hdr->addr2, iv32);
|
||||
tkey->rx_phase1_done = 1;
|
||||
}
|
||||
tkip_mixing_phase2(rc4key, tkey->key, tkey->rx_ttak, iv16);
|
||||
|
||||
plen = skb->len - hdr_len - 12;
|
||||
|
||||
crypto_cipher_setkey(tkey->tfm_arc4, rc4key, 16);
|
||||
sg.page = virt_to_page(pos);
|
||||
sg.offset = offset_in_page(pos);
|
||||
sg.length = plen + 4;
|
||||
crypto_cipher_decrypt(tkey->tfm_arc4, &sg, &sg, plen + 4);
|
||||
|
||||
crc = ~crc32_le(~0, pos, plen);
|
||||
icv[0] = crc;
|
||||
icv[1] = crc >> 8;
|
||||
icv[2] = crc >> 16;
|
||||
icv[3] = crc >> 24;
|
||||
if (memcmp(icv, pos + plen, 4) != 0) {
|
||||
if (iv32 != tkey->rx_iv32) {
|
||||
/* Previously cached Phase1 result was already lost, so
|
||||
* it needs to be recalculated for the next packet. */
|
||||
tkey->rx_phase1_done = 0;
|
||||
}
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "TKIP: ICV error detected: STA="
|
||||
MAC_FMT "\n", MAC_ARG(hdr->addr2));
|
||||
}
|
||||
tkey->dot11RSNAStatsTKIPICVErrors++;
|
||||
return -5;
|
||||
}
|
||||
|
||||
/* Update real counters only after Michael MIC verification has
|
||||
* completed */
|
||||
tkey->rx_iv32_new = iv32;
|
||||
tkey->rx_iv16_new = iv16;
|
||||
|
||||
/* Remove IV and ICV */
|
||||
memmove(skb->data + 8, skb->data, hdr_len);
|
||||
skb_pull(skb, 8);
|
||||
skb_trim(skb, skb->len - 4);
|
||||
|
||||
return keyidx;
|
||||
}
|
||||
|
||||
|
||||
static int michael_mic(struct ieee80211_tkip_data *tkey, u8 *key, u8 *hdr,
|
||||
u8 *data, size_t data_len, u8 *mic)
|
||||
{
|
||||
struct scatterlist sg[2];
|
||||
|
||||
if (tkey->tfm_michael == NULL) {
|
||||
printk(KERN_WARNING "michael_mic: tfm_michael == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
sg[0].page = virt_to_page(hdr);
|
||||
sg[0].offset = offset_in_page(hdr);
|
||||
sg[0].length = 16;
|
||||
|
||||
sg[1].page = virt_to_page(data);
|
||||
sg[1].offset = offset_in_page(data);
|
||||
sg[1].length = data_len;
|
||||
|
||||
crypto_digest_init(tkey->tfm_michael);
|
||||
crypto_digest_setkey(tkey->tfm_michael, key, 8);
|
||||
crypto_digest_update(tkey->tfm_michael, sg, 2);
|
||||
crypto_digest_final(tkey->tfm_michael, mic);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
|
||||
{
|
||||
struct ieee80211_hdr *hdr11;
|
||||
|
||||
hdr11 = (struct ieee80211_hdr *) skb->data;
|
||||
switch (le16_to_cpu(hdr11->frame_ctl) &
|
||||
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
|
||||
case IEEE80211_FCTL_TODS:
|
||||
memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
|
||||
memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
|
||||
break;
|
||||
case IEEE80211_FCTL_FROMDS:
|
||||
memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
|
||||
memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
|
||||
break;
|
||||
case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
|
||||
memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
|
||||
memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
|
||||
break;
|
||||
case 0:
|
||||
memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
|
||||
memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
|
||||
break;
|
||||
}
|
||||
|
||||
hdr[12] = 0; /* priority */
|
||||
hdr[13] = hdr[14] = hdr[15] = 0; /* reserved */
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
u8 *pos;
|
||||
|
||||
if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
|
||||
printk(KERN_DEBUG "Invalid packet for Michael MIC add "
|
||||
"(tailroom=%d hdr_len=%d skb->len=%d)\n",
|
||||
skb_tailroom(skb), hdr_len, skb->len);
|
||||
return -1;
|
||||
}
|
||||
|
||||
michael_mic_hdr(skb, tkey->tx_hdr);
|
||||
pos = skb_put(skb, 8);
|
||||
if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
|
||||
skb->data + hdr_len, skb->len - 8 - hdr_len, pos))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if WIRELESS_EXT >= 18
|
||||
static void ieee80211_michael_mic_failure(struct net_device *dev,
|
||||
struct ieee80211_hdr *hdr,
|
||||
int keyidx)
|
||||
{
|
||||
union iwreq_data wrqu;
|
||||
struct iw_michaelmicfailure ev;
|
||||
|
||||
/* TODO: needed parameters: count, keyid, key type, TSC */
|
||||
memset(&ev, 0, sizeof(ev));
|
||||
ev.flags = keyidx & IW_MICFAILURE_KEY_ID;
|
||||
if (hdr->addr1[0] & 0x01)
|
||||
ev.flags |= IW_MICFAILURE_GROUP;
|
||||
else
|
||||
ev.flags |= IW_MICFAILURE_PAIRWISE;
|
||||
ev.src_addr.sa_family = ARPHRD_ETHER;
|
||||
memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
|
||||
memset(&wrqu, 0, sizeof(wrqu));
|
||||
wrqu.data.length = sizeof(ev);
|
||||
wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
|
||||
}
|
||||
#elif WIRELESS_EXT >= 15
|
||||
static void ieee80211_michael_mic_failure(struct net_device *dev,
|
||||
struct ieee80211_hdr *hdr,
|
||||
int keyidx)
|
||||
{
|
||||
union iwreq_data wrqu;
|
||||
char buf[128];
|
||||
|
||||
/* TODO: needed parameters: count, keyid, key type, TSC */
|
||||
sprintf(buf, "MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
|
||||
MAC_FMT ")", keyidx, hdr->addr1[0] & 0x01 ? "broad" : "uni",
|
||||
MAC_ARG(hdr->addr2));
|
||||
memset(&wrqu, 0, sizeof(wrqu));
|
||||
wrqu.data.length = strlen(buf);
|
||||
wireless_send_event(dev, IWEVCUSTOM, &wrqu, buf);
|
||||
}
|
||||
#else /* WIRELESS_EXT >= 15 */
|
||||
static inline void ieee80211_michael_mic_failure(struct net_device *dev,
|
||||
struct ieee80211_hdr *hdr,
|
||||
int keyidx)
|
||||
{
|
||||
}
|
||||
#endif /* WIRELESS_EXT >= 15 */
|
||||
|
||||
|
||||
static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
|
||||
int hdr_len, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
u8 mic[8];
|
||||
|
||||
if (!tkey->key_set)
|
||||
return -1;
|
||||
|
||||
michael_mic_hdr(skb, tkey->rx_hdr);
|
||||
if (michael_mic(tkey, &tkey->key[24], tkey->rx_hdr,
|
||||
skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
|
||||
return -1;
|
||||
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
|
||||
struct ieee80211_hdr *hdr;
|
||||
hdr = (struct ieee80211_hdr *) skb->data;
|
||||
printk(KERN_DEBUG "%s: Michael MIC verification failed for "
|
||||
"MSDU from " MAC_FMT " keyidx=%d\n",
|
||||
skb->dev ? skb->dev->name : "N/A", MAC_ARG(hdr->addr2),
|
||||
keyidx);
|
||||
if (skb->dev)
|
||||
ieee80211_michael_mic_failure(skb->dev, hdr, keyidx);
|
||||
tkey->dot11RSNAStatsTKIPLocalMICFailures++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Update TSC counters for RX now that the packet verification has
|
||||
* completed. */
|
||||
tkey->rx_iv32 = tkey->rx_iv32_new;
|
||||
tkey->rx_iv16 = tkey->rx_iv16_new;
|
||||
|
||||
skb_trim(skb, skb->len - 8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_tkip_set_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
int keyidx;
|
||||
struct crypto_tfm *tfm = tkey->tfm_michael;
|
||||
struct crypto_tfm *tfm2 = tkey->tfm_arc4;
|
||||
|
||||
keyidx = tkey->key_idx;
|
||||
memset(tkey, 0, sizeof(*tkey));
|
||||
tkey->key_idx = keyidx;
|
||||
tkey->tfm_michael = tfm;
|
||||
tkey->tfm_arc4 = tfm2;
|
||||
if (len == TKIP_KEY_LEN) {
|
||||
memcpy(tkey->key, key, TKIP_KEY_LEN);
|
||||
tkey->key_set = 1;
|
||||
tkey->tx_iv16 = 1; /* TSC is initialized to 1 */
|
||||
if (seq) {
|
||||
tkey->rx_iv32 = (seq[5] << 24) | (seq[4] << 16) |
|
||||
(seq[3] << 8) | seq[2];
|
||||
tkey->rx_iv16 = (seq[1] << 8) | seq[0];
|
||||
}
|
||||
} else if (len == 0)
|
||||
tkey->key_set = 0;
|
||||
else
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkey = priv;
|
||||
|
||||
if (len < TKIP_KEY_LEN)
|
||||
return -1;
|
||||
|
||||
if (!tkey->key_set)
|
||||
return 0;
|
||||
memcpy(key, tkey->key, TKIP_KEY_LEN);
|
||||
|
||||
if (seq) {
|
||||
/* Return the sequence number of the last transmitted frame. */
|
||||
u16 iv16 = tkey->tx_iv16;
|
||||
u32 iv32 = tkey->tx_iv32;
|
||||
if (iv16 == 0)
|
||||
iv32--;
|
||||
iv16--;
|
||||
seq[0] = tkey->tx_iv16;
|
||||
seq[1] = tkey->tx_iv16 >> 8;
|
||||
seq[2] = tkey->tx_iv32;
|
||||
seq[3] = tkey->tx_iv32 >> 8;
|
||||
seq[4] = tkey->tx_iv32 >> 16;
|
||||
seq[5] = tkey->tx_iv32 >> 24;
|
||||
}
|
||||
|
||||
return TKIP_KEY_LEN;
|
||||
}
|
||||
|
||||
|
||||
static char * ieee80211_tkip_print_stats(char *p, void *priv)
|
||||
{
|
||||
struct ieee80211_tkip_data *tkip = priv;
|
||||
p += sprintf(p, "key[%d] alg=TKIP key_set=%d "
|
||||
"tx_pn=%02x%02x%02x%02x%02x%02x "
|
||||
"rx_pn=%02x%02x%02x%02x%02x%02x "
|
||||
"replays=%d icv_errors=%d local_mic_failures=%d\n",
|
||||
tkip->key_idx, tkip->key_set,
|
||||
(tkip->tx_iv32 >> 24) & 0xff,
|
||||
(tkip->tx_iv32 >> 16) & 0xff,
|
||||
(tkip->tx_iv32 >> 8) & 0xff,
|
||||
tkip->tx_iv32 & 0xff,
|
||||
(tkip->tx_iv16 >> 8) & 0xff,
|
||||
tkip->tx_iv16 & 0xff,
|
||||
(tkip->rx_iv32 >> 24) & 0xff,
|
||||
(tkip->rx_iv32 >> 16) & 0xff,
|
||||
(tkip->rx_iv32 >> 8) & 0xff,
|
||||
tkip->rx_iv32 & 0xff,
|
||||
(tkip->rx_iv16 >> 8) & 0xff,
|
||||
tkip->rx_iv16 & 0xff,
|
||||
tkip->dot11RSNAStatsTKIPReplays,
|
||||
tkip->dot11RSNAStatsTKIPICVErrors,
|
||||
tkip->dot11RSNAStatsTKIPLocalMICFailures);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
|
||||
.name = "TKIP",
|
||||
.init = ieee80211_tkip_init,
|
||||
.deinit = ieee80211_tkip_deinit,
|
||||
.encrypt_mpdu = ieee80211_tkip_encrypt,
|
||||
.decrypt_mpdu = ieee80211_tkip_decrypt,
|
||||
.encrypt_msdu = ieee80211_michael_mic_add,
|
||||
.decrypt_msdu = ieee80211_michael_mic_verify,
|
||||
.set_key = ieee80211_tkip_set_key,
|
||||
.get_key = ieee80211_tkip_get_key,
|
||||
.print_stats = ieee80211_tkip_print_stats,
|
||||
.extra_prefix_len = 4 + 4, /* IV + ExtIV */
|
||||
.extra_postfix_len = 8 + 4, /* MIC + ICV */
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
||||
static int __init ieee80211_crypto_tkip_init(void)
|
||||
{
|
||||
return ieee80211_register_crypto_ops(&ieee80211_crypt_tkip);
|
||||
}
|
||||
|
||||
|
||||
static void __exit ieee80211_crypto_tkip_exit(void)
|
||||
{
|
||||
ieee80211_unregister_crypto_ops(&ieee80211_crypt_tkip);
|
||||
}
|
||||
|
||||
|
||||
module_init(ieee80211_crypto_tkip_init);
|
||||
module_exit(ieee80211_crypto_tkip_exit);
|
272
net/ieee80211/ieee80211_crypt_wep.c
Normal file
272
net/ieee80211/ieee80211_crypt_wep.c
Normal file
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
* Host AP crypt: host-based WEP encryption implementation for Host AP driver
|
||||
*
|
||||
* Copyright (c) 2002-2004, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation. See README and COPYING for
|
||||
* more details.
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <asm/string.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
|
||||
#include <linux/crypto.h>
|
||||
#include <asm/scatterlist.h>
|
||||
#include <linux/crc32.h>
|
||||
|
||||
MODULE_AUTHOR("Jouni Malinen");
|
||||
MODULE_DESCRIPTION("Host AP crypt: WEP");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
|
||||
struct prism2_wep_data {
|
||||
u32 iv;
|
||||
#define WEP_KEY_LEN 13
|
||||
u8 key[WEP_KEY_LEN + 1];
|
||||
u8 key_len;
|
||||
u8 key_idx;
|
||||
struct crypto_tfm *tfm;
|
||||
};
|
||||
|
||||
|
||||
static void * prism2_wep_init(int keyidx)
|
||||
{
|
||||
struct prism2_wep_data *priv;
|
||||
|
||||
priv = kmalloc(sizeof(*priv), GFP_ATOMIC);
|
||||
if (priv == NULL)
|
||||
goto fail;
|
||||
memset(priv, 0, sizeof(*priv));
|
||||
priv->key_idx = keyidx;
|
||||
|
||||
priv->tfm = crypto_alloc_tfm("arc4", 0);
|
||||
if (priv->tfm == NULL) {
|
||||
printk(KERN_DEBUG "ieee80211_crypt_wep: could not allocate "
|
||||
"crypto API arc4\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* start WEP IV from a random value */
|
||||
get_random_bytes(&priv->iv, 4);
|
||||
|
||||
return priv;
|
||||
|
||||
fail:
|
||||
if (priv) {
|
||||
if (priv->tfm)
|
||||
crypto_free_tfm(priv->tfm);
|
||||
kfree(priv);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void prism2_wep_deinit(void *priv)
|
||||
{
|
||||
struct prism2_wep_data *_priv = priv;
|
||||
if (_priv && _priv->tfm)
|
||||
crypto_free_tfm(_priv->tfm);
|
||||
kfree(priv);
|
||||
}
|
||||
|
||||
|
||||
/* Perform WEP encryption on given skb that has at least 4 bytes of headroom
|
||||
* for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted,
|
||||
* so the payload length increases with 8 bytes.
|
||||
*
|
||||
* WEP frame payload: IV + TX key idx, RC4(data), ICV = RC4(CRC32(data))
|
||||
*/
|
||||
static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct prism2_wep_data *wep = priv;
|
||||
u32 crc, klen, len;
|
||||
u8 key[WEP_KEY_LEN + 3];
|
||||
u8 *pos, *icv;
|
||||
struct scatterlist sg;
|
||||
|
||||
if (skb_headroom(skb) < 4 || skb_tailroom(skb) < 4 ||
|
||||
skb->len < hdr_len)
|
||||
return -1;
|
||||
|
||||
len = skb->len - hdr_len;
|
||||
pos = skb_push(skb, 4);
|
||||
memmove(pos, pos + 4, hdr_len);
|
||||
pos += hdr_len;
|
||||
|
||||
klen = 3 + wep->key_len;
|
||||
|
||||
wep->iv++;
|
||||
|
||||
/* Fluhrer, Mantin, and Shamir have reported weaknesses in the key
|
||||
* scheduling algorithm of RC4. At least IVs (KeyByte + 3, 0xff, N)
|
||||
* can be used to speedup attacks, so avoid using them. */
|
||||
if ((wep->iv & 0xff00) == 0xff00) {
|
||||
u8 B = (wep->iv >> 16) & 0xff;
|
||||
if (B >= 3 && B < klen)
|
||||
wep->iv += 0x0100;
|
||||
}
|
||||
|
||||
/* Prepend 24-bit IV to RC4 key and TX frame */
|
||||
*pos++ = key[0] = (wep->iv >> 16) & 0xff;
|
||||
*pos++ = key[1] = (wep->iv >> 8) & 0xff;
|
||||
*pos++ = key[2] = wep->iv & 0xff;
|
||||
*pos++ = wep->key_idx << 6;
|
||||
|
||||
/* Copy rest of the WEP key (the secret part) */
|
||||
memcpy(key + 3, wep->key, wep->key_len);
|
||||
|
||||
/* Append little-endian CRC32 and encrypt it to produce ICV */
|
||||
crc = ~crc32_le(~0, pos, len);
|
||||
icv = skb_put(skb, 4);
|
||||
icv[0] = crc;
|
||||
icv[1] = crc >> 8;
|
||||
icv[2] = crc >> 16;
|
||||
icv[3] = crc >> 24;
|
||||
|
||||
crypto_cipher_setkey(wep->tfm, key, klen);
|
||||
sg.page = virt_to_page(pos);
|
||||
sg.offset = offset_in_page(pos);
|
||||
sg.length = len + 4;
|
||||
crypto_cipher_encrypt(wep->tfm, &sg, &sg, len + 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Perform WEP decryption on given buffer. Buffer includes whole WEP part of
|
||||
* the frame: IV (4 bytes), encrypted payload (including SNAP header),
|
||||
* ICV (4 bytes). len includes both IV and ICV.
|
||||
*
|
||||
* Returns 0 if frame was decrypted successfully and ICV was correct and -1 on
|
||||
* failure. If frame is OK, IV and ICV will be removed.
|
||||
*/
|
||||
static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
|
||||
{
|
||||
struct prism2_wep_data *wep = priv;
|
||||
u32 crc, klen, plen;
|
||||
u8 key[WEP_KEY_LEN + 3];
|
||||
u8 keyidx, *pos, icv[4];
|
||||
struct scatterlist sg;
|
||||
|
||||
if (skb->len < hdr_len + 8)
|
||||
return -1;
|
||||
|
||||
pos = skb->data + hdr_len;
|
||||
key[0] = *pos++;
|
||||
key[1] = *pos++;
|
||||
key[2] = *pos++;
|
||||
keyidx = *pos++ >> 6;
|
||||
if (keyidx != wep->key_idx)
|
||||
return -1;
|
||||
|
||||
klen = 3 + wep->key_len;
|
||||
|
||||
/* Copy rest of the WEP key (the secret part) */
|
||||
memcpy(key + 3, wep->key, wep->key_len);
|
||||
|
||||
/* Apply RC4 to data and compute CRC32 over decrypted data */
|
||||
plen = skb->len - hdr_len - 8;
|
||||
|
||||
crypto_cipher_setkey(wep->tfm, key, klen);
|
||||
sg.page = virt_to_page(pos);
|
||||
sg.offset = offset_in_page(pos);
|
||||
sg.length = plen + 4;
|
||||
crypto_cipher_decrypt(wep->tfm, &sg, &sg, plen + 4);
|
||||
|
||||
crc = ~crc32_le(~0, pos, plen);
|
||||
icv[0] = crc;
|
||||
icv[1] = crc >> 8;
|
||||
icv[2] = crc >> 16;
|
||||
icv[3] = crc >> 24;
|
||||
if (memcmp(icv, pos + plen, 4) != 0) {
|
||||
/* ICV mismatch - drop frame */
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* Remove IV and ICV */
|
||||
memmove(skb->data + 4, skb->data, hdr_len);
|
||||
skb_pull(skb, 4);
|
||||
skb_trim(skb, skb->len - 4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct prism2_wep_data *wep = priv;
|
||||
|
||||
if (len < 0 || len > WEP_KEY_LEN)
|
||||
return -1;
|
||||
|
||||
memcpy(wep->key, key, len);
|
||||
wep->key_len = len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv)
|
||||
{
|
||||
struct prism2_wep_data *wep = priv;
|
||||
|
||||
if (len < wep->key_len)
|
||||
return -1;
|
||||
|
||||
memcpy(key, wep->key, wep->key_len);
|
||||
|
||||
return wep->key_len;
|
||||
}
|
||||
|
||||
|
||||
static char * prism2_wep_print_stats(char *p, void *priv)
|
||||
{
|
||||
struct prism2_wep_data *wep = priv;
|
||||
p += sprintf(p, "key[%d] alg=WEP len=%d\n",
|
||||
wep->key_idx, wep->key_len);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
static struct ieee80211_crypto_ops ieee80211_crypt_wep = {
|
||||
.name = "WEP",
|
||||
.init = prism2_wep_init,
|
||||
.deinit = prism2_wep_deinit,
|
||||
.encrypt_mpdu = prism2_wep_encrypt,
|
||||
.decrypt_mpdu = prism2_wep_decrypt,
|
||||
.encrypt_msdu = NULL,
|
||||
.decrypt_msdu = NULL,
|
||||
.set_key = prism2_wep_set_key,
|
||||
.get_key = prism2_wep_get_key,
|
||||
.print_stats = prism2_wep_print_stats,
|
||||
.extra_prefix_len = 4, /* IV */
|
||||
.extra_postfix_len = 4, /* ICV */
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
|
||||
static int __init ieee80211_crypto_wep_init(void)
|
||||
{
|
||||
return ieee80211_register_crypto_ops(&ieee80211_crypt_wep);
|
||||
}
|
||||
|
||||
|
||||
static void __exit ieee80211_crypto_wep_exit(void)
|
||||
{
|
||||
ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep);
|
||||
}
|
||||
|
||||
|
||||
module_init(ieee80211_crypto_wep_init);
|
||||
module_exit(ieee80211_crypto_wep_exit);
|
268
net/ieee80211/ieee80211_module.c
Normal file
268
net/ieee80211/ieee80211_module.c
Normal file
|
@ -0,0 +1,268 @@
|
|||
/*******************************************************************************
|
||||
|
||||
Copyright(c) 2004 Intel Corporation. All rights reserved.
|
||||
|
||||
Portions of this file are based on the WEP enablement code provided by the
|
||||
Host AP project hostap-drivers v0.1.3
|
||||
Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
||||
<jkmaline@cc.hut.fi>
|
||||
Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of version 2 of the GNU General Public License as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in the
|
||||
file called LICENSE.
|
||||
|
||||
Contact Information:
|
||||
James P. Ketrenos <ipw2100-admin@linux.intel.com>
|
||||
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
||||
|
||||
*******************************************************************************/
|
||||
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/config.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/in6.h>
|
||||
#include <linux/in.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <net/arp.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
MODULE_DESCRIPTION("802.11 data/management/control stack");
|
||||
MODULE_AUTHOR("Copyright (C) 2004 Intel Corporation <jketreno@linux.intel.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
#define DRV_NAME "ieee80211"
|
||||
|
||||
static inline int ieee80211_networks_allocate(struct ieee80211_device *ieee)
|
||||
{
|
||||
if (ieee->networks)
|
||||
return 0;
|
||||
|
||||
ieee->networks = kmalloc(
|
||||
MAX_NETWORK_COUNT * sizeof(struct ieee80211_network),
|
||||
GFP_KERNEL);
|
||||
if (!ieee->networks) {
|
||||
printk(KERN_WARNING "%s: Out of memory allocating beacons\n",
|
||||
ieee->dev->name);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
memset(ieee->networks, 0,
|
||||
MAX_NETWORK_COUNT * sizeof(struct ieee80211_network));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void ieee80211_networks_free(struct ieee80211_device *ieee)
|
||||
{
|
||||
if (!ieee->networks)
|
||||
return;
|
||||
kfree(ieee->networks);
|
||||
ieee->networks = NULL;
|
||||
}
|
||||
|
||||
static inline void ieee80211_networks_initialize(struct ieee80211_device *ieee)
|
||||
{
|
||||
int i;
|
||||
|
||||
INIT_LIST_HEAD(&ieee->network_free_list);
|
||||
INIT_LIST_HEAD(&ieee->network_list);
|
||||
for (i = 0; i < MAX_NETWORK_COUNT; i++)
|
||||
list_add_tail(&ieee->networks[i].list, &ieee->network_free_list);
|
||||
}
|
||||
|
||||
|
||||
struct net_device *alloc_ieee80211(int sizeof_priv)
|
||||
{
|
||||
struct ieee80211_device *ieee;
|
||||
struct net_device *dev;
|
||||
int err;
|
||||
|
||||
IEEE80211_DEBUG_INFO("Initializing...\n");
|
||||
|
||||
dev = alloc_etherdev(sizeof(struct ieee80211_device) + sizeof_priv);
|
||||
if (!dev) {
|
||||
IEEE80211_ERROR("Unable to network device.\n");
|
||||
goto failed;
|
||||
}
|
||||
ieee = netdev_priv(dev);
|
||||
dev->hard_start_xmit = ieee80211_xmit;
|
||||
|
||||
ieee->dev = dev;
|
||||
|
||||
err = ieee80211_networks_allocate(ieee);
|
||||
if (err) {
|
||||
IEEE80211_ERROR("Unable to allocate beacon storage: %d\n",
|
||||
err);
|
||||
goto failed;
|
||||
}
|
||||
ieee80211_networks_initialize(ieee);
|
||||
|
||||
/* Default fragmentation threshold is maximum payload size */
|
||||
ieee->fts = DEFAULT_FTS;
|
||||
ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
|
||||
ieee->open_wep = 1;
|
||||
|
||||
/* Default to enabling full open WEP with host based encrypt/decrypt */
|
||||
ieee->host_encrypt = 1;
|
||||
ieee->host_decrypt = 1;
|
||||
ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
|
||||
|
||||
INIT_LIST_HEAD(&ieee->crypt_deinit_list);
|
||||
init_timer(&ieee->crypt_deinit_timer);
|
||||
ieee->crypt_deinit_timer.data = (unsigned long)ieee;
|
||||
ieee->crypt_deinit_timer.function = ieee80211_crypt_deinit_handler;
|
||||
|
||||
spin_lock_init(&ieee->lock);
|
||||
|
||||
ieee->wpa_enabled = 0;
|
||||
ieee->tkip_countermeasures = 0;
|
||||
ieee->drop_unencrypted = 0;
|
||||
ieee->privacy_invoked = 0;
|
||||
ieee->ieee802_1x = 1;
|
||||
|
||||
return dev;
|
||||
|
||||
failed:
|
||||
if (dev)
|
||||
free_netdev(dev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void free_ieee80211(struct net_device *dev)
|
||||
{
|
||||
struct ieee80211_device *ieee = netdev_priv(dev);
|
||||
|
||||
int i;
|
||||
|
||||
del_timer_sync(&ieee->crypt_deinit_timer);
|
||||
ieee80211_crypt_deinit_entries(ieee, 1);
|
||||
|
||||
for (i = 0; i < WEP_KEYS; i++) {
|
||||
struct ieee80211_crypt_data *crypt = ieee->crypt[i];
|
||||
if (crypt) {
|
||||
if (crypt->ops) {
|
||||
crypt->ops->deinit(crypt->priv);
|
||||
module_put(crypt->ops->owner);
|
||||
}
|
||||
kfree(crypt);
|
||||
ieee->crypt[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
ieee80211_networks_free(ieee);
|
||||
free_netdev(dev);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IEEE80211_DEBUG
|
||||
|
||||
static int debug = 0;
|
||||
u32 ieee80211_debug_level = 0;
|
||||
struct proc_dir_entry *ieee80211_proc = NULL;
|
||||
|
||||
static int show_debug_level(char *page, char **start, off_t offset,
|
||||
int count, int *eof, void *data)
|
||||
{
|
||||
return snprintf(page, count, "0x%08X\n", ieee80211_debug_level);
|
||||
}
|
||||
|
||||
static int store_debug_level(struct file *file, const char *buffer,
|
||||
unsigned long count, void *data)
|
||||
{
|
||||
char buf[] = "0x00000000";
|
||||
unsigned long len = min(sizeof(buf) - 1, (u32)count);
|
||||
char *p = (char *)buf;
|
||||
unsigned long val;
|
||||
|
||||
if (copy_from_user(buf, buffer, len))
|
||||
return count;
|
||||
buf[len] = 0;
|
||||
if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') {
|
||||
p++;
|
||||
if (p[0] == 'x' || p[0] == 'X')
|
||||
p++;
|
||||
val = simple_strtoul(p, &p, 16);
|
||||
} else
|
||||
val = simple_strtoul(p, &p, 10);
|
||||
if (p == buf)
|
||||
printk(KERN_INFO DRV_NAME
|
||||
": %s is not in hex or decimal form.\n", buf);
|
||||
else
|
||||
ieee80211_debug_level = val;
|
||||
|
||||
return strnlen(buf, count);
|
||||
}
|
||||
|
||||
static int __init ieee80211_init(void)
|
||||
{
|
||||
struct proc_dir_entry *e;
|
||||
|
||||
ieee80211_debug_level = debug;
|
||||
ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net);
|
||||
if (ieee80211_proc == NULL) {
|
||||
IEEE80211_ERROR("Unable to create " DRV_NAME
|
||||
" proc directory\n");
|
||||
return -EIO;
|
||||
}
|
||||
e = create_proc_entry("debug_level", S_IFREG | S_IRUGO | S_IWUSR,
|
||||
ieee80211_proc);
|
||||
if (!e) {
|
||||
remove_proc_entry(DRV_NAME, proc_net);
|
||||
ieee80211_proc = NULL;
|
||||
return -EIO;
|
||||
}
|
||||
e->read_proc = show_debug_level;
|
||||
e->write_proc = store_debug_level;
|
||||
e->data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit ieee80211_exit(void)
|
||||
{
|
||||
if (ieee80211_proc) {
|
||||
remove_proc_entry("debug_level", ieee80211_proc);
|
||||
remove_proc_entry(DRV_NAME, proc_net);
|
||||
ieee80211_proc = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#include <linux/moduleparam.h>
|
||||
module_param(debug, int, 0444);
|
||||
MODULE_PARM_DESC(debug, "debug output mask");
|
||||
|
||||
|
||||
module_exit(ieee80211_exit);
|
||||
module_init(ieee80211_init);
|
||||
#endif
|
||||
|
||||
EXPORT_SYMBOL(alloc_ieee80211);
|
||||
EXPORT_SYMBOL(free_ieee80211);
|
1206
net/ieee80211/ieee80211_rx.c
Normal file
1206
net/ieee80211/ieee80211_rx.c
Normal file
File diff suppressed because it is too large
Load diff
448
net/ieee80211/ieee80211_tx.c
Normal file
448
net/ieee80211/ieee80211_tx.c
Normal file
|
@ -0,0 +1,448 @@
|
|||
/******************************************************************************
|
||||
|
||||
Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of version 2 of the GNU General Public License as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in the
|
||||
file called LICENSE.
|
||||
|
||||
Contact Information:
|
||||
James P. Ketrenos <ipw2100-admin@linux.intel.com>
|
||||
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
||||
|
||||
******************************************************************************/
|
||||
#include <linux/compiler.h>
|
||||
#include <linux/config.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <linux/in6.h>
|
||||
#include <linux/in.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
802.11 Data Frame
|
||||
|
||||
,-------------------------------------------------------------------.
|
||||
Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
|
||||
|------|------|---------|---------|---------|------|---------|------|
|
||||
Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs |
|
||||
| | tion | (BSSID) | | | ence | data | |
|
||||
`--------------------------------------------------| |------'
|
||||
Total: 28 non-data bytes `----.----'
|
||||
|
|
||||
.- 'Frame data' expands to <---------------------------'
|
||||
|
|
||||
V
|
||||
,---------------------------------------------------.
|
||||
Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 |
|
||||
|------|------|---------|----------|------|---------|
|
||||
Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP |
|
||||
| DSAP | SSAP | | | | Packet |
|
||||
| 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | |
|
||||
`-----------------------------------------| |
|
||||
Total: 8 non-data bytes `----.----'
|
||||
|
|
||||
.- 'IP Packet' expands, if WEP enabled, to <--'
|
||||
|
|
||||
V
|
||||
,-----------------------.
|
||||
Bytes | 4 | 0-2296 | 4 |
|
||||
|-----|-----------|-----|
|
||||
Desc. | IV | Encrypted | ICV |
|
||||
| | IP Packet | |
|
||||
`-----------------------'
|
||||
Total: 8 non-data bytes
|
||||
|
||||
|
||||
802.3 Ethernet Data Frame
|
||||
|
||||
,-----------------------------------------.
|
||||
Bytes | 6 | 6 | 2 | Variable | 4 |
|
||||
|-------|-------|------|-----------|------|
|
||||
Desc. | Dest. | Source| Type | IP Packet | fcs |
|
||||
| MAC | MAC | | | |
|
||||
`-----------------------------------------'
|
||||
Total: 18 non-data bytes
|
||||
|
||||
In the event that fragmentation is required, the incoming payload is split into
|
||||
N parts of size ieee->fts. The first fragment contains the SNAP header and the
|
||||
remaining packets are just data.
|
||||
|
||||
If encryption is enabled, each fragment payload size is reduced by enough space
|
||||
to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
|
||||
So if you have 1500 bytes of payload with ieee->fts set to 500 without
|
||||
encryption it will take 3 frames. With WEP it will take 4 frames as the
|
||||
payload of each frame is reduced to 492 bytes.
|
||||
|
||||
* SKB visualization
|
||||
*
|
||||
* ,- skb->data
|
||||
* |
|
||||
* | ETHERNET HEADER ,-<-- PAYLOAD
|
||||
* | | 14 bytes from skb->data
|
||||
* | 2 bytes for Type --> ,T. | (sizeof ethhdr)
|
||||
* | | | |
|
||||
* |,-Dest.--. ,--Src.---. | | |
|
||||
* | 6 bytes| | 6 bytes | | | |
|
||||
* v | | | | | |
|
||||
* 0 | v 1 | v | v 2
|
||||
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
|
||||
* ^ | ^ | ^ |
|
||||
* | | | | | |
|
||||
* | | | | `T' <---- 2 bytes for Type
|
||||
* | | | |
|
||||
* | | '---SNAP--' <-------- 6 bytes for SNAP
|
||||
* | |
|
||||
* `-IV--' <-------------------- 4 bytes for IV (WEP)
|
||||
*
|
||||
* SNAP HEADER
|
||||
*
|
||||
*/
|
||||
|
||||
static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 };
|
||||
static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 };
|
||||
|
||||
static inline int ieee80211_put_snap(u8 *data, u16 h_proto)
|
||||
{
|
||||
struct ieee80211_snap_hdr *snap;
|
||||
u8 *oui;
|
||||
|
||||
snap = (struct ieee80211_snap_hdr *)data;
|
||||
snap->dsap = 0xaa;
|
||||
snap->ssap = 0xaa;
|
||||
snap->ctrl = 0x03;
|
||||
|
||||
if (h_proto == 0x8137 || h_proto == 0x80f3)
|
||||
oui = P802_1H_OUI;
|
||||
else
|
||||
oui = RFC1042_OUI;
|
||||
snap->oui[0] = oui[0];
|
||||
snap->oui[1] = oui[1];
|
||||
snap->oui[2] = oui[2];
|
||||
|
||||
*(u16 *)(data + SNAP_SIZE) = htons(h_proto);
|
||||
|
||||
return SNAP_SIZE + sizeof(u16);
|
||||
}
|
||||
|
||||
static inline int ieee80211_encrypt_fragment(
|
||||
struct ieee80211_device *ieee,
|
||||
struct sk_buff *frag,
|
||||
int hdr_len)
|
||||
{
|
||||
struct ieee80211_crypt_data* crypt = ieee->crypt[ieee->tx_keyidx];
|
||||
int res;
|
||||
|
||||
#ifdef CONFIG_IEEE80211_CRYPT_TKIP
|
||||
struct ieee80211_hdr *header;
|
||||
|
||||
if (ieee->tkip_countermeasures &&
|
||||
crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
|
||||
header = (struct ieee80211_hdr *) frag->data;
|
||||
if (net_ratelimit()) {
|
||||
printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
|
||||
"TX packet to " MAC_FMT "\n",
|
||||
ieee->dev->name, MAC_ARG(header->addr1));
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
/* To encrypt, frame format is:
|
||||
* IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) */
|
||||
|
||||
// PR: FIXME: Copied from hostap. Check fragmentation/MSDU/MPDU encryption.
|
||||
/* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so
|
||||
* call both MSDU and MPDU encryption functions from here. */
|
||||
atomic_inc(&crypt->refcnt);
|
||||
res = 0;
|
||||
if (crypt->ops->encrypt_msdu)
|
||||
res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv);
|
||||
if (res == 0 && crypt->ops->encrypt_mpdu)
|
||||
res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv);
|
||||
|
||||
atomic_dec(&crypt->refcnt);
|
||||
if (res < 0) {
|
||||
printk(KERN_INFO "%s: Encryption failed: len=%d.\n",
|
||||
ieee->dev->name, frag->len);
|
||||
ieee->ieee_stats.tx_discards++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ieee80211_txb_free(struct ieee80211_txb *txb) {
|
||||
int i;
|
||||
if (unlikely(!txb))
|
||||
return;
|
||||
for (i = 0; i < txb->nr_frags; i++)
|
||||
if (txb->fragments[i])
|
||||
dev_kfree_skb_any(txb->fragments[i]);
|
||||
kfree(txb);
|
||||
}
|
||||
|
||||
struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size,
|
||||
int gfp_mask)
|
||||
{
|
||||
struct ieee80211_txb *txb;
|
||||
int i;
|
||||
txb = kmalloc(
|
||||
sizeof(struct ieee80211_txb) + (sizeof(u8*) * nr_frags),
|
||||
gfp_mask);
|
||||
if (!txb)
|
||||
return NULL;
|
||||
|
||||
memset(txb, 0, sizeof(struct ieee80211_txb));
|
||||
txb->nr_frags = nr_frags;
|
||||
txb->frag_size = txb_size;
|
||||
|
||||
for (i = 0; i < nr_frags; i++) {
|
||||
txb->fragments[i] = dev_alloc_skb(txb_size);
|
||||
if (unlikely(!txb->fragments[i])) {
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unlikely(i != nr_frags)) {
|
||||
while (i >= 0)
|
||||
dev_kfree_skb_any(txb->fragments[i--]);
|
||||
kfree(txb);
|
||||
return NULL;
|
||||
}
|
||||
return txb;
|
||||
}
|
||||
|
||||
/* SKBs are added to the ieee->tx_queue. */
|
||||
int ieee80211_xmit(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct ieee80211_device *ieee = netdev_priv(dev);
|
||||
struct ieee80211_txb *txb = NULL;
|
||||
struct ieee80211_hdr *frag_hdr;
|
||||
int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
|
||||
unsigned long flags;
|
||||
struct net_device_stats *stats = &ieee->stats;
|
||||
int ether_type, encrypt;
|
||||
int bytes, fc, hdr_len;
|
||||
struct sk_buff *skb_frag;
|
||||
struct ieee80211_hdr header = { /* Ensure zero initialized */
|
||||
.duration_id = 0,
|
||||
.seq_ctl = 0
|
||||
};
|
||||
u8 dest[ETH_ALEN], src[ETH_ALEN];
|
||||
|
||||
struct ieee80211_crypt_data* crypt;
|
||||
|
||||
spin_lock_irqsave(&ieee->lock, flags);
|
||||
|
||||
/* If there is no driver handler to take the TXB, dont' bother
|
||||
* creating it... */
|
||||
if (!ieee->hard_start_xmit) {
|
||||
printk(KERN_WARNING "%s: No xmit handler.\n",
|
||||
ieee->dev->name);
|
||||
goto success;
|
||||
}
|
||||
|
||||
if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) {
|
||||
printk(KERN_WARNING "%s: skb too small (%d).\n",
|
||||
ieee->dev->name, skb->len);
|
||||
goto success;
|
||||
}
|
||||
|
||||
ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
|
||||
|
||||
crypt = ieee->crypt[ieee->tx_keyidx];
|
||||
|
||||
encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) &&
|
||||
ieee->host_encrypt && crypt && crypt->ops;
|
||||
|
||||
if (!encrypt && ieee->ieee802_1x &&
|
||||
ieee->drop_unencrypted && ether_type != ETH_P_PAE) {
|
||||
stats->tx_dropped++;
|
||||
goto success;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IEEE80211_DEBUG
|
||||
if (crypt && !encrypt && ether_type == ETH_P_PAE) {
|
||||
struct eapol *eap = (struct eapol *)(skb->data +
|
||||
sizeof(struct ethhdr) - SNAP_SIZE - sizeof(u16));
|
||||
IEEE80211_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n",
|
||||
eap_get_type(eap->type));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Save source and destination addresses */
|
||||
memcpy(&dest, skb->data, ETH_ALEN);
|
||||
memcpy(&src, skb->data+ETH_ALEN, ETH_ALEN);
|
||||
|
||||
/* Advance the SKB to the start of the payload */
|
||||
skb_pull(skb, sizeof(struct ethhdr));
|
||||
|
||||
/* Determine total amount of storage required for TXB packets */
|
||||
bytes = skb->len + SNAP_SIZE + sizeof(u16);
|
||||
|
||||
if (encrypt)
|
||||
fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA |
|
||||
IEEE80211_FCTL_WEP;
|
||||
else
|
||||
fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
|
||||
|
||||
if (ieee->iw_mode == IW_MODE_INFRA) {
|
||||
fc |= IEEE80211_FCTL_TODS;
|
||||
/* To DS: Addr1 = BSSID, Addr2 = SA,
|
||||
Addr3 = DA */
|
||||
memcpy(&header.addr1, ieee->bssid, ETH_ALEN);
|
||||
memcpy(&header.addr2, &src, ETH_ALEN);
|
||||
memcpy(&header.addr3, &dest, ETH_ALEN);
|
||||
} else if (ieee->iw_mode == IW_MODE_ADHOC) {
|
||||
/* not From/To DS: Addr1 = DA, Addr2 = SA,
|
||||
Addr3 = BSSID */
|
||||
memcpy(&header.addr1, dest, ETH_ALEN);
|
||||
memcpy(&header.addr2, src, ETH_ALEN);
|
||||
memcpy(&header.addr3, ieee->bssid, ETH_ALEN);
|
||||
}
|
||||
header.frame_ctl = cpu_to_le16(fc);
|
||||
hdr_len = IEEE80211_3ADDR_LEN;
|
||||
|
||||
/* Determine fragmentation size based on destination (multicast
|
||||
* and broadcast are not fragmented) */
|
||||
if (is_multicast_ether_addr(dest) ||
|
||||
is_broadcast_ether_addr(dest))
|
||||
frag_size = MAX_FRAG_THRESHOLD;
|
||||
else
|
||||
frag_size = ieee->fts;
|
||||
|
||||
/* Determine amount of payload per fragment. Regardless of if
|
||||
* this stack is providing the full 802.11 header, one will
|
||||
* eventually be affixed to this fragment -- so we must account for
|
||||
* it when determining the amount of payload space. */
|
||||
bytes_per_frag = frag_size - IEEE80211_3ADDR_LEN;
|
||||
if (ieee->config &
|
||||
(CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
|
||||
bytes_per_frag -= IEEE80211_FCS_LEN;
|
||||
|
||||
/* Each fragment may need to have room for encryptiong pre/postfix */
|
||||
if (encrypt)
|
||||
bytes_per_frag -= crypt->ops->extra_prefix_len +
|
||||
crypt->ops->extra_postfix_len;
|
||||
|
||||
/* Number of fragments is the total bytes_per_frag /
|
||||
* payload_per_fragment */
|
||||
nr_frags = bytes / bytes_per_frag;
|
||||
bytes_last_frag = bytes % bytes_per_frag;
|
||||
if (bytes_last_frag)
|
||||
nr_frags++;
|
||||
else
|
||||
bytes_last_frag = bytes_per_frag;
|
||||
|
||||
/* When we allocate the TXB we allocate enough space for the reserve
|
||||
* and full fragment bytes (bytes_per_frag doesn't include prefix,
|
||||
* postfix, header, FCS, etc.) */
|
||||
txb = ieee80211_alloc_txb(nr_frags, frag_size, GFP_ATOMIC);
|
||||
if (unlikely(!txb)) {
|
||||
printk(KERN_WARNING "%s: Could not allocate TXB\n",
|
||||
ieee->dev->name);
|
||||
goto failed;
|
||||
}
|
||||
txb->encrypted = encrypt;
|
||||
txb->payload_size = bytes;
|
||||
|
||||
for (i = 0; i < nr_frags; i++) {
|
||||
skb_frag = txb->fragments[i];
|
||||
|
||||
if (encrypt)
|
||||
skb_reserve(skb_frag, crypt->ops->extra_prefix_len);
|
||||
|
||||
frag_hdr = (struct ieee80211_hdr *)skb_put(skb_frag, hdr_len);
|
||||
memcpy(frag_hdr, &header, hdr_len);
|
||||
|
||||
/* If this is not the last fragment, then add the MOREFRAGS
|
||||
* bit to the frame control */
|
||||
if (i != nr_frags - 1) {
|
||||
frag_hdr->frame_ctl = cpu_to_le16(
|
||||
fc | IEEE80211_FCTL_MOREFRAGS);
|
||||
bytes = bytes_per_frag;
|
||||
} else {
|
||||
/* The last fragment takes the remaining length */
|
||||
bytes = bytes_last_frag;
|
||||
}
|
||||
|
||||
/* Put a SNAP header on the first fragment */
|
||||
if (i == 0) {
|
||||
ieee80211_put_snap(
|
||||
skb_put(skb_frag, SNAP_SIZE + sizeof(u16)),
|
||||
ether_type);
|
||||
bytes -= SNAP_SIZE + sizeof(u16);
|
||||
}
|
||||
|
||||
memcpy(skb_put(skb_frag, bytes), skb->data, bytes);
|
||||
|
||||
/* Advance the SKB... */
|
||||
skb_pull(skb, bytes);
|
||||
|
||||
/* Encryption routine will move the header forward in order
|
||||
* to insert the IV between the header and the payload */
|
||||
if (encrypt)
|
||||
ieee80211_encrypt_fragment(ieee, skb_frag, hdr_len);
|
||||
if (ieee->config &
|
||||
(CFG_IEEE80211_COMPUTE_FCS | CFG_IEEE80211_RESERVE_FCS))
|
||||
skb_put(skb_frag, 4);
|
||||
}
|
||||
|
||||
|
||||
success:
|
||||
spin_unlock_irqrestore(&ieee->lock, flags);
|
||||
|
||||
dev_kfree_skb_any(skb);
|
||||
|
||||
if (txb) {
|
||||
if ((*ieee->hard_start_xmit)(txb, dev) == 0) {
|
||||
stats->tx_packets++;
|
||||
stats->tx_bytes += txb->payload_size;
|
||||
return 0;
|
||||
}
|
||||
ieee80211_txb_free(txb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
failed:
|
||||
spin_unlock_irqrestore(&ieee->lock, flags);
|
||||
netif_stop_queue(dev);
|
||||
stats->tx_errors++;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(ieee80211_txb_free);
|
471
net/ieee80211/ieee80211_wx.c
Normal file
471
net/ieee80211/ieee80211_wx.c
Normal file
|
@ -0,0 +1,471 @@
|
|||
/******************************************************************************
|
||||
|
||||
Copyright(c) 2004 Intel Corporation. All rights reserved.
|
||||
|
||||
Portions of this file are based on the WEP enablement code provided by the
|
||||
Host AP project hostap-drivers v0.1.3
|
||||
Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
||||
<jkmaline@cc.hut.fi>
|
||||
Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of version 2 of the GNU General Public License as
|
||||
published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in the
|
||||
file called LICENSE.
|
||||
|
||||
Contact Information:
|
||||
James P. Ketrenos <ipw2100-admin@linux.intel.com>
|
||||
Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
||||
|
||||
******************************************************************************/
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/module.h>
|
||||
|
||||
#include <net/ieee80211.h>
|
||||
static const char *ieee80211_modes[] = {
|
||||
"?", "a", "b", "ab", "g", "ag", "bg", "abg"
|
||||
};
|
||||
|
||||
#define MAX_CUSTOM_LEN 64
|
||||
static inline char *ipw2100_translate_scan(struct ieee80211_device *ieee,
|
||||
char *start, char *stop,
|
||||
struct ieee80211_network *network)
|
||||
{
|
||||
char custom[MAX_CUSTOM_LEN];
|
||||
char *p;
|
||||
struct iw_event iwe;
|
||||
int i, j;
|
||||
u8 max_rate, rate;
|
||||
|
||||
/* First entry *MUST* be the AP MAC address */
|
||||
iwe.cmd = SIOCGIWAP;
|
||||
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
||||
memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN);
|
||||
start = iwe_stream_add_event(start, stop, &iwe, IW_EV_ADDR_LEN);
|
||||
|
||||
/* Remaining entries will be displayed in the order we provide them */
|
||||
|
||||
/* Add the ESSID */
|
||||
iwe.cmd = SIOCGIWESSID;
|
||||
iwe.u.data.flags = 1;
|
||||
if (network->flags & NETWORK_EMPTY_ESSID) {
|
||||
iwe.u.data.length = sizeof("<hidden>");
|
||||
start = iwe_stream_add_point(start, stop, &iwe, "<hidden>");
|
||||
} else {
|
||||
iwe.u.data.length = min(network->ssid_len, (u8)32);
|
||||
start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
|
||||
}
|
||||
|
||||
/* Add the protocol name */
|
||||
iwe.cmd = SIOCGIWNAME;
|
||||
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]);
|
||||
start = iwe_stream_add_event(start, stop, &iwe, IW_EV_CHAR_LEN);
|
||||
|
||||
/* Add mode */
|
||||
iwe.cmd = SIOCGIWMODE;
|
||||
if (network->capability &
|
||||
(WLAN_CAPABILITY_BSS | WLAN_CAPABILITY_IBSS)) {
|
||||
if (network->capability & WLAN_CAPABILITY_BSS)
|
||||
iwe.u.mode = IW_MODE_MASTER;
|
||||
else
|
||||
iwe.u.mode = IW_MODE_ADHOC;
|
||||
|
||||
start = iwe_stream_add_event(start, stop, &iwe,
|
||||
IW_EV_UINT_LEN);
|
||||
}
|
||||
|
||||
/* Add frequency/channel */
|
||||
iwe.cmd = SIOCGIWFREQ;
|
||||
/* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode);
|
||||
iwe.u.freq.e = 3; */
|
||||
iwe.u.freq.m = network->channel;
|
||||
iwe.u.freq.e = 0;
|
||||
iwe.u.freq.i = 0;
|
||||
start = iwe_stream_add_event(start, stop, &iwe, IW_EV_FREQ_LEN);
|
||||
|
||||
/* Add encryption capability */
|
||||
iwe.cmd = SIOCGIWENCODE;
|
||||
if (network->capability & WLAN_CAPABILITY_PRIVACY)
|
||||
iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
|
||||
else
|
||||
iwe.u.data.flags = IW_ENCODE_DISABLED;
|
||||
iwe.u.data.length = 0;
|
||||
start = iwe_stream_add_point(start, stop, &iwe, network->ssid);
|
||||
|
||||
/* Add basic and extended rates */
|
||||
max_rate = 0;
|
||||
p = custom;
|
||||
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
|
||||
for (i = 0, j = 0; i < network->rates_len; ) {
|
||||
if (j < network->rates_ex_len &&
|
||||
((network->rates_ex[j] & 0x7F) <
|
||||
(network->rates[i] & 0x7F)))
|
||||
rate = network->rates_ex[j++] & 0x7F;
|
||||
else
|
||||
rate = network->rates[i++] & 0x7F;
|
||||
if (rate > max_rate)
|
||||
max_rate = rate;
|
||||
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
|
||||
"%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
|
||||
}
|
||||
for (; j < network->rates_ex_len; j++) {
|
||||
rate = network->rates_ex[j] & 0x7F;
|
||||
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
|
||||
"%d%s ", rate >> 1, (rate & 1) ? ".5" : "");
|
||||
if (rate > max_rate)
|
||||
max_rate = rate;
|
||||
}
|
||||
|
||||
iwe.cmd = SIOCGIWRATE;
|
||||
iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
|
||||
iwe.u.bitrate.value = max_rate * 500000;
|
||||
start = iwe_stream_add_event(start, stop, &iwe,
|
||||
IW_EV_PARAM_LEN);
|
||||
|
||||
iwe.cmd = IWEVCUSTOM;
|
||||
iwe.u.data.length = p - custom;
|
||||
if (iwe.u.data.length)
|
||||
start = iwe_stream_add_point(start, stop, &iwe, custom);
|
||||
|
||||
/* Add quality statistics */
|
||||
/* TODO: Fix these values... */
|
||||
iwe.cmd = IWEVQUAL;
|
||||
iwe.u.qual.qual = network->stats.signal;
|
||||
iwe.u.qual.level = network->stats.rssi;
|
||||
iwe.u.qual.noise = network->stats.noise;
|
||||
iwe.u.qual.updated = network->stats.mask & IEEE80211_STATMASK_WEMASK;
|
||||
if (!(network->stats.mask & IEEE80211_STATMASK_RSSI))
|
||||
iwe.u.qual.updated |= IW_QUAL_LEVEL_INVALID;
|
||||
if (!(network->stats.mask & IEEE80211_STATMASK_NOISE))
|
||||
iwe.u.qual.updated |= IW_QUAL_NOISE_INVALID;
|
||||
if (!(network->stats.mask & IEEE80211_STATMASK_SIGNAL))
|
||||
iwe.u.qual.updated |= IW_QUAL_QUAL_INVALID;
|
||||
|
||||
start = iwe_stream_add_event(start, stop, &iwe, IW_EV_QUAL_LEN);
|
||||
|
||||
iwe.cmd = IWEVCUSTOM;
|
||||
p = custom;
|
||||
|
||||
iwe.u.data.length = p - custom;
|
||||
if (iwe.u.data.length)
|
||||
start = iwe_stream_add_point(start, stop, &iwe, custom);
|
||||
|
||||
if (ieee->wpa_enabled && network->wpa_ie_len){
|
||||
char buf[MAX_WPA_IE_LEN * 2 + 30];
|
||||
|
||||
u8 *p = buf;
|
||||
p += sprintf(p, "wpa_ie=");
|
||||
for (i = 0; i < network->wpa_ie_len; i++) {
|
||||
p += sprintf(p, "%02x", network->wpa_ie[i]);
|
||||
}
|
||||
|
||||
memset(&iwe, 0, sizeof(iwe));
|
||||
iwe.cmd = IWEVCUSTOM;
|
||||
iwe.u.data.length = strlen(buf);
|
||||
start = iwe_stream_add_point(start, stop, &iwe, buf);
|
||||
}
|
||||
|
||||
if (ieee->wpa_enabled && network->rsn_ie_len){
|
||||
char buf[MAX_WPA_IE_LEN * 2 + 30];
|
||||
|
||||
u8 *p = buf;
|
||||
p += sprintf(p, "rsn_ie=");
|
||||
for (i = 0; i < network->rsn_ie_len; i++) {
|
||||
p += sprintf(p, "%02x", network->rsn_ie[i]);
|
||||
}
|
||||
|
||||
memset(&iwe, 0, sizeof(iwe));
|
||||
iwe.cmd = IWEVCUSTOM;
|
||||
iwe.u.data.length = strlen(buf);
|
||||
start = iwe_stream_add_point(start, stop, &iwe, buf);
|
||||
}
|
||||
|
||||
/* Add EXTRA: Age to display seconds since last beacon/probe response
|
||||
* for given network. */
|
||||
iwe.cmd = IWEVCUSTOM;
|
||||
p = custom;
|
||||
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom),
|
||||
" Last beacon: %lums ago", (jiffies - network->last_scanned) / (HZ / 100));
|
||||
iwe.u.data.length = p - custom;
|
||||
if (iwe.u.data.length)
|
||||
start = iwe_stream_add_point(start, stop, &iwe, custom);
|
||||
|
||||
|
||||
return start;
|
||||
}
|
||||
|
||||
int ieee80211_wx_get_scan(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *extra)
|
||||
{
|
||||
struct ieee80211_network *network;
|
||||
unsigned long flags;
|
||||
|
||||
char *ev = extra;
|
||||
char *stop = ev + IW_SCAN_MAX_DATA;
|
||||
int i = 0;
|
||||
|
||||
IEEE80211_DEBUG_WX("Getting scan\n");
|
||||
|
||||
spin_lock_irqsave(&ieee->lock, flags);
|
||||
|
||||
list_for_each_entry(network, &ieee->network_list, list) {
|
||||
i++;
|
||||
if (ieee->scan_age == 0 ||
|
||||
time_after(network->last_scanned + ieee->scan_age, jiffies))
|
||||
ev = ipw2100_translate_scan(ieee, ev, stop, network);
|
||||
else
|
||||
IEEE80211_DEBUG_SCAN(
|
||||
"Not showing network '%s ("
|
||||
MAC_FMT ")' due to age (%lums).\n",
|
||||
escape_essid(network->ssid,
|
||||
network->ssid_len),
|
||||
MAC_ARG(network->bssid),
|
||||
(jiffies - network->last_scanned) / (HZ / 100));
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&ieee->lock, flags);
|
||||
|
||||
wrqu->data.length = ev - extra;
|
||||
wrqu->data.flags = 0;
|
||||
|
||||
IEEE80211_DEBUG_WX("exit: %d networks returned.\n", i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *keybuf)
|
||||
{
|
||||
struct iw_point *erq = &(wrqu->encoding);
|
||||
struct net_device *dev = ieee->dev;
|
||||
struct ieee80211_security sec = {
|
||||
.flags = 0
|
||||
};
|
||||
int i, key, key_provided, len;
|
||||
struct ieee80211_crypt_data **crypt;
|
||||
|
||||
IEEE80211_DEBUG_WX("SET_ENCODE\n");
|
||||
|
||||
key = erq->flags & IW_ENCODE_INDEX;
|
||||
if (key) {
|
||||
if (key > WEP_KEYS)
|
||||
return -EINVAL;
|
||||
key--;
|
||||
key_provided = 1;
|
||||
} else {
|
||||
key_provided = 0;
|
||||
key = ieee->tx_keyidx;
|
||||
}
|
||||
|
||||
IEEE80211_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
|
||||
"provided" : "default");
|
||||
|
||||
crypt = &ieee->crypt[key];
|
||||
|
||||
if (erq->flags & IW_ENCODE_DISABLED) {
|
||||
if (key_provided && *crypt) {
|
||||
IEEE80211_DEBUG_WX("Disabling encryption on key %d.\n",
|
||||
key);
|
||||
ieee80211_crypt_delayed_deinit(ieee, crypt);
|
||||
} else
|
||||
IEEE80211_DEBUG_WX("Disabling encryption.\n");
|
||||
|
||||
/* Check all the keys to see if any are still configured,
|
||||
* and if no key index was provided, de-init them all */
|
||||
for (i = 0; i < WEP_KEYS; i++) {
|
||||
if (ieee->crypt[i] != NULL) {
|
||||
if (key_provided)
|
||||
break;
|
||||
ieee80211_crypt_delayed_deinit(
|
||||
ieee, &ieee->crypt[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (i == WEP_KEYS) {
|
||||
sec.enabled = 0;
|
||||
sec.level = SEC_LEVEL_0;
|
||||
sec.flags |= SEC_ENABLED | SEC_LEVEL;
|
||||
}
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sec.enabled = 1;
|
||||
sec.flags |= SEC_ENABLED;
|
||||
|
||||
if (*crypt != NULL && (*crypt)->ops != NULL &&
|
||||
strcmp((*crypt)->ops->name, "WEP") != 0) {
|
||||
/* changing to use WEP; deinit previously used algorithm
|
||||
* on this key */
|
||||
ieee80211_crypt_delayed_deinit(ieee, crypt);
|
||||
}
|
||||
|
||||
if (*crypt == NULL) {
|
||||
struct ieee80211_crypt_data *new_crypt;
|
||||
|
||||
/* take WEP into use */
|
||||
new_crypt = kmalloc(sizeof(struct ieee80211_crypt_data),
|
||||
GFP_KERNEL);
|
||||
if (new_crypt == NULL)
|
||||
return -ENOMEM;
|
||||
memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
|
||||
new_crypt->ops = ieee80211_get_crypto_ops("WEP");
|
||||
if (!new_crypt->ops) {
|
||||
request_module("ieee80211_crypt_wep");
|
||||
new_crypt->ops = ieee80211_get_crypto_ops("WEP");
|
||||
}
|
||||
|
||||
if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
|
||||
new_crypt->priv = new_crypt->ops->init(key);
|
||||
|
||||
if (!new_crypt->ops || !new_crypt->priv) {
|
||||
kfree(new_crypt);
|
||||
new_crypt = NULL;
|
||||
|
||||
printk(KERN_WARNING "%s: could not initialize WEP: "
|
||||
"load module ieee80211_crypt_wep\n",
|
||||
dev->name);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
*crypt = new_crypt;
|
||||
}
|
||||
|
||||
/* If a new key was provided, set it up */
|
||||
if (erq->length > 0) {
|
||||
len = erq->length <= 5 ? 5 : 13;
|
||||
memcpy(sec.keys[key], keybuf, erq->length);
|
||||
if (len > erq->length)
|
||||
memset(sec.keys[key] + erq->length, 0,
|
||||
len - erq->length);
|
||||
IEEE80211_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
|
||||
key, escape_essid(sec.keys[key], len),
|
||||
erq->length, len);
|
||||
sec.key_sizes[key] = len;
|
||||
(*crypt)->ops->set_key(sec.keys[key], len, NULL,
|
||||
(*crypt)->priv);
|
||||
sec.flags |= (1 << key);
|
||||
/* This ensures a key will be activated if no key is
|
||||
* explicitely set */
|
||||
if (key == sec.active_key)
|
||||
sec.flags |= SEC_ACTIVE_KEY;
|
||||
} else {
|
||||
len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN,
|
||||
NULL, (*crypt)->priv);
|
||||
if (len == 0) {
|
||||
/* Set a default key of all 0 */
|
||||
IEEE80211_DEBUG_WX("Setting key %d to all zero.\n",
|
||||
key);
|
||||
memset(sec.keys[key], 0, 13);
|
||||
(*crypt)->ops->set_key(sec.keys[key], 13, NULL,
|
||||
(*crypt)->priv);
|
||||
sec.key_sizes[key] = 13;
|
||||
sec.flags |= (1 << key);
|
||||
}
|
||||
|
||||
/* No key data - just set the default TX key index */
|
||||
if (key_provided) {
|
||||
IEEE80211_DEBUG_WX(
|
||||
"Setting key %d to default Tx key.\n", key);
|
||||
ieee->tx_keyidx = key;
|
||||
sec.active_key = key;
|
||||
sec.flags |= SEC_ACTIVE_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
ieee->open_wep = !(erq->flags & IW_ENCODE_RESTRICTED);
|
||||
sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
|
||||
sec.flags |= SEC_AUTH_MODE;
|
||||
IEEE80211_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
|
||||
"OPEN" : "SHARED KEY");
|
||||
|
||||
/* For now we just support WEP, so only set that security level...
|
||||
* TODO: When WPA is added this is one place that needs to change */
|
||||
sec.flags |= SEC_LEVEL;
|
||||
sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */
|
||||
|
||||
if (ieee->set_security)
|
||||
ieee->set_security(dev, &sec);
|
||||
|
||||
/* Do not reset port if card is in Managed mode since resetting will
|
||||
* generate new IEEE 802.11 authentication which may end up in looping
|
||||
* with IEEE 802.1X. If your hardware requires a reset after WEP
|
||||
* configuration (for example... Prism2), implement the reset_port in
|
||||
* the callbacks structures used to initialize the 802.11 stack. */
|
||||
if (ieee->reset_on_keychange &&
|
||||
ieee->iw_mode != IW_MODE_INFRA &&
|
||||
ieee->reset_port && ieee->reset_port(dev)) {
|
||||
printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ieee80211_wx_get_encode(struct ieee80211_device *ieee,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu, char *keybuf)
|
||||
{
|
||||
struct iw_point *erq = &(wrqu->encoding);
|
||||
int len, key;
|
||||
struct ieee80211_crypt_data *crypt;
|
||||
|
||||
IEEE80211_DEBUG_WX("GET_ENCODE\n");
|
||||
|
||||
key = erq->flags & IW_ENCODE_INDEX;
|
||||
if (key) {
|
||||
if (key > WEP_KEYS)
|
||||
return -EINVAL;
|
||||
key--;
|
||||
} else
|
||||
key = ieee->tx_keyidx;
|
||||
|
||||
crypt = ieee->crypt[key];
|
||||
erq->flags = key + 1;
|
||||
|
||||
if (crypt == NULL || crypt->ops == NULL) {
|
||||
erq->length = 0;
|
||||
erq->flags |= IW_ENCODE_DISABLED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(crypt->ops->name, "WEP") != 0) {
|
||||
/* only WEP is supported with wireless extensions, so just
|
||||
* report that encryption is used */
|
||||
erq->length = 0;
|
||||
erq->flags |= IW_ENCODE_ENABLED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = crypt->ops->get_key(keybuf, WEP_KEY_LEN, NULL, crypt->priv);
|
||||
erq->length = (len >= 0 ? len : 0);
|
||||
|
||||
erq->flags |= IW_ENCODE_ENABLED;
|
||||
|
||||
if (ieee->open_wep)
|
||||
erq->flags |= IW_ENCODE_OPEN;
|
||||
else
|
||||
erq->flags |= IW_ENCODE_RESTRICTED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(ieee80211_wx_get_scan);
|
||||
EXPORT_SYMBOL(ieee80211_wx_set_encode);
|
||||
EXPORT_SYMBOL(ieee80211_wx_get_encode);
|
Reference in a new issue