Staging: add wlan-ng prism2 usb driver

This adds the wlan-ng prism2 USB driver to the drivers/staging tree.

The code was originally written by the linux-wlan-ng team, patched by
some Novell engineers to properly work on newer kernels, and then hacked
into place in order to get it to build properly in a single subdirectory
within the kernel tree by me.

It supports a wide range of older USB prism2 devices, and contains a
80211 stack to support this single driver.

Cc: Christian Zoz <zoz@suse.de>
Cc: Andreas Gruenbacher <agruen@suse.de>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Cc: John Linville <linville@tuxdriver.com>
Cc: Helmut Schaa <helmut.schaa@googlemail.com>
Cc: linux-wlan-ng <solomon@linux-wlan.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2008-10-02 11:29:28 -07:00
parent 66101de109
commit 00b3ed1685
37 changed files with 36060 additions and 0 deletions

View File

@ -37,4 +37,6 @@ source "drivers/staging/usbip/Kconfig"
source "drivers/staging/winbond/Kconfig"
source "drivers/staging/wlan-ng/Kconfig"
endif # STAGING

View File

@ -7,3 +7,4 @@ obj-$(CONFIG_ME4000) += me4000/
obj-$(CONFIG_VIDEO_GO7007) += go7007/
obj-$(CONFIG_USB_IP_COMMON) += usbip/
obj-$(CONFIG_W35UND) += winbond/
obj-$(CONFIG_PRISM2_USB) += wlan-ng/

View File

@ -0,0 +1,10 @@
config PRISM2_USB
tristate "Prism2.5 USB driver"
depends on USB
default n
---help---
This is the wlan-ng prism 2.5 USB driver for a wide range of
old USB wireless devices.
To compile this driver as a module, choose M here: the module
will be called prism2_usb.

View File

@ -0,0 +1,9 @@
obj-$(CONFIG_PRISM2_USB) += prism2_usb.o
obj-$(CONFIG_PRISM2_USB) += p80211.o
p80211-objs := p80211mod.o \
p80211conv.o \
p80211req.o \
p80211wep.o \
p80211wext.o \
p80211netdev.o

View File

@ -0,0 +1,8 @@
TODO:
- checkpatch.pl cleanups
- sparse warnings
- Lindent cleanups
- move to use the in-kernel wireless stack
- possible enable the pcmcia and pci portions of the driver
Please send all patches to Greg Kroah-Hartman <greg@kroah.com>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,683 @@
/* src/p80211/p80211conv.c
*
* Ether/802.11 conversions and packet buffer routines
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file defines the functions that perform Ethernet to/from
* 802.11 frame conversions.
*
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
#define __NO_VERSION__ /* prevent the static definition */
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/wireless.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/if_ether.h>
#include <asm/byteorder.h>
#include "version.h"
#include "wlan_compat.h"
/*================================================================*/
/* Project Includes */
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211conv.h"
#include "p80211mgmt.h"
#include "p80211msg.h"
#include "p80211netdev.h"
#include "p80211ioctl.h"
#include "p80211req.h"
/*================================================================*/
/* Local Constants */
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/
/* Local Static Definitions */
static UINT8 oui_rfc1042[] = {0x00, 0x00, 0x00};
static UINT8 oui_8021h[] = {0x00, 0x00, 0xf8};
/*================================================================*/
/* Local Function Declarations */
/*================================================================*/
/* Function Definitions */
/*----------------------------------------------------------------
* p80211pb_ether_to_80211
*
* Uses the contents of the ether frame and the etherconv setting
* to build the elements of the 802.11 frame.
*
* We don't actually set
* up the frame header here. That's the MAC's job. We're only handling
* conversion of DIXII or 802.3+LLC frames to something that works
* with 802.11.
*
* Note -- 802.11 header is NOT part of the skb. Likewise, the 802.11
* FCS is also not present and will need to be added elsewhere.
*
* Arguments:
* ethconv Conversion type to perform
* skb skbuff containing the ether frame
* p80211_hdr 802.11 header
*
* Returns:
* 0 on success, non-zero otherwise
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int skb_ether_to_p80211( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep)
{
UINT16 fc;
UINT16 proto;
wlan_ethhdr_t e_hdr;
wlan_llc_t *e_llc;
wlan_snap_t *e_snap;
int foo;
DBFENTER;
memcpy(&e_hdr, skb->data, sizeof(e_hdr));
if (skb->len <= 0) {
WLAN_LOG_DEBUG(1, "zero-length skb!\n");
return 1;
}
if ( ethconv == WLAN_ETHCONV_ENCAP ) { /* simplest case */
WLAN_LOG_DEBUG(3, "ENCAP len: %d\n", skb->len);
/* here, we don't care what kind of ether frm. Just stick it */
/* in the 80211 payload */
/* which is to say, leave the skb alone. */
} else {
/* step 1: classify ether frame, DIX or 802.3? */
proto = ntohs(e_hdr.type);
if ( proto <= 1500 ) {
WLAN_LOG_DEBUG(3, "802.3 len: %d\n", skb->len);
/* codes <= 1500 reserved for 802.3 lengths */
/* it's 802.3, pass ether payload unchanged, */
/* trim off ethernet header */
skb_pull(skb, WLAN_ETHHDR_LEN);
/* leave off any PAD octets. */
skb_trim(skb, proto);
} else {
WLAN_LOG_DEBUG(3, "DIXII len: %d\n", skb->len);
/* it's DIXII, time for some conversion */
/* trim off ethernet header */
skb_pull(skb, WLAN_ETHHDR_LEN);
/* tack on SNAP */
e_snap = (wlan_snap_t *) skb_push(skb, sizeof(wlan_snap_t));
e_snap->type = htons(proto);
if ( ethconv == WLAN_ETHCONV_8021h && p80211_stt_findproto(proto) ) {
memcpy( e_snap->oui, oui_8021h, WLAN_IEEE_OUI_LEN);
} else {
memcpy( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN);
}
/* tack on llc */
e_llc = (wlan_llc_t *) skb_push(skb, sizeof(wlan_llc_t));
e_llc->dsap = 0xAA; /* SNAP, see IEEE 802 */
e_llc->ssap = 0xAA;
e_llc->ctl = 0x03;
}
}
/* Set up the 802.11 header */
/* It's a data frame */
fc = host2ieee16( WLAN_SET_FC_FTYPE(WLAN_FTYPE_DATA) |
WLAN_SET_FC_FSTYPE(WLAN_FSTYPE_DATAONLY));
switch ( wlandev->macmode ) {
case WLAN_MACMODE_IBSS_STA:
memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a3, wlandev->bssid, WLAN_ADDR_LEN);
break;
case WLAN_MACMODE_ESS_STA:
fc |= host2ieee16(WLAN_SET_FC_TODS(1));
memcpy(p80211_hdr->a3.a1, wlandev->bssid, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, WLAN_ADDR_LEN);
break;
case WLAN_MACMODE_ESS_AP:
fc |= host2ieee16(WLAN_SET_FC_FROMDS(1));
memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a2, wlandev->bssid, WLAN_ADDR_LEN);
memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, WLAN_ADDR_LEN);
break;
default:
WLAN_LOG_ERROR("Error: Converting eth to wlan in unknown mode.\n");
return 1;
break;
}
p80211_wep->data = NULL;
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && (wlandev->hostwep & HOSTWEP_ENCRYPT)) {
// XXXX need to pick keynum other than default?
#if 1
p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
#else
p80211_wep->data = skb->data;
#endif
if ((foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
skb->len,
(wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
p80211_wep->iv, p80211_wep->icv))) {
WLAN_LOG_WARNING("Host en-WEP failed, dropping frame (%d).\n", foo);
return 2;
}
fc |= host2ieee16(WLAN_SET_FC_ISWEP(1));
}
// skb->nh.raw = skb->data;
p80211_hdr->a3.fc = fc;
p80211_hdr->a3.dur = 0;
p80211_hdr->a3.seq = 0;
DBFEXIT;
return 0;
}
/* jkriegl: from orinoco, modified */
static void orinoco_spy_gather(wlandevice_t *wlandev, char *mac,
p80211_rxmeta_t *rxmeta)
{
int i;
/* Gather wireless spy statistics: for each packet, compare the
* source address with out list, and if match, get the stats... */
for (i = 0; i < wlandev->spy_number; i++) {
if (!memcmp(wlandev->spy_address[i], mac, ETH_ALEN)) {
memcpy(wlandev->spy_address[i], mac, ETH_ALEN);
wlandev->spy_stat[i].level = rxmeta->signal;
wlandev->spy_stat[i].noise = rxmeta->noise;
wlandev->spy_stat[i].qual = (rxmeta->signal > rxmeta->noise) ? \
(rxmeta->signal - rxmeta->noise) : 0;
wlandev->spy_stat[i].updated = 0x7;
}
}
}
/*----------------------------------------------------------------
* p80211pb_80211_to_ether
*
* Uses the contents of a received 802.11 frame and the etherconv
* setting to build an ether frame.
*
* This function extracts the src and dest address from the 802.11
* frame to use in the construction of the eth frame.
*
* Arguments:
* ethconv Conversion type to perform
* skb Packet buffer containing the 802.11 frame
*
* Returns:
* 0 on success, non-zero otherwise
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *skb)
{
netdevice_t *netdev = wlandev->netdev;
UINT16 fc;
UINT payload_length;
UINT payload_offset;
UINT8 daddr[WLAN_ETHADDR_LEN];
UINT8 saddr[WLAN_ETHADDR_LEN];
p80211_hdr_t *w_hdr;
wlan_ethhdr_t *e_hdr;
wlan_llc_t *e_llc;
wlan_snap_t *e_snap;
int foo;
DBFENTER;
payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
payload_offset = WLAN_HDR_A3_LEN;
w_hdr = (p80211_hdr_t *) skb->data;
/* setup some vars for convenience */
fc = ieee2host16(w_hdr->a3.fc);
if ( (WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0) ) {
memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN);
memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN);
} else if( (WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1) ) {
memcpy(daddr, w_hdr->a3.a1, WLAN_ETHADDR_LEN);
memcpy(saddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN);
} else if( (WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0) ) {
memcpy(daddr, w_hdr->a3.a3, WLAN_ETHADDR_LEN);
memcpy(saddr, w_hdr->a3.a2, WLAN_ETHADDR_LEN);
} else {
payload_offset = WLAN_HDR_A4_LEN;
payload_length -= ( WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN );
if (payload_length < 0 ) {
WLAN_LOG_ERROR("A4 frame too short!\n");
return 1;
}
memcpy(daddr, w_hdr->a4.a3, WLAN_ETHADDR_LEN);
memcpy(saddr, w_hdr->a4.a4, WLAN_ETHADDR_LEN);
}
/* perform de-wep if necessary.. */
if ((wlandev->hostwep & HOSTWEP_PRIVACYINVOKED) && WLAN_GET_FC_ISWEP(fc) && (wlandev->hostwep & HOSTWEP_DECRYPT)) {
if (payload_length <= 8) {
WLAN_LOG_ERROR("WEP frame too short (%u).\n",
skb->len);
return 1;
}
if ((foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
payload_length - 8, -1,
skb->data + payload_offset,
skb->data + payload_offset + payload_length - 4))) {
/* de-wep failed, drop skb. */
WLAN_LOG_DEBUG(1, "Host de-WEP failed, dropping frame (%d).\n", foo);
wlandev->rx.decrypt_err++;
return 2;
}
/* subtract the IV+ICV length off the payload */
payload_length -= 8;
/* chop off the IV */
skb_pull(skb, 4);
/* chop off the ICV. */
skb_trim(skb, skb->len - 4);
wlandev->rx.decrypt++;
}
e_hdr = (wlan_ethhdr_t *) (skb->data + payload_offset);
e_llc = (wlan_llc_t *) (skb->data + payload_offset);
e_snap = (wlan_snap_t *) (skb->data + payload_offset + sizeof(wlan_llc_t));
/* Test for the various encodings */
if ( (payload_length >= sizeof(wlan_ethhdr_t)) &&
( e_llc->dsap != 0xaa || e_llc->ssap != 0xaa ) &&
((memcmp(daddr, e_hdr->daddr, WLAN_ETHADDR_LEN) == 0) ||
(memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) {
WLAN_LOG_DEBUG(3, "802.3 ENCAP len: %d\n", payload_length);
/* 802.3 Encapsulated */
/* Test for an overlength frame */
if ( payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
/* A bogus length ethfrm has been encap'd. */
/* Is someone trying an oflow attack? */
WLAN_LOG_ERROR("ENCAP frame too large (%d > %d)\n",
payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
return 1;
}
/* Chop off the 802.11 header. it's already sane. */
skb_pull(skb, payload_offset);
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
(e_llc->dsap == 0xaa) &&
(e_llc->ssap == 0xaa) &&
(e_llc->ctl == 0x03) &&
(((memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)==0) &&
(ethconv == WLAN_ETHCONV_8021h) &&
(p80211_stt_findproto(ieee2host16(e_snap->type)))) ||
(memcmp( e_snap->oui, oui_rfc1042, WLAN_IEEE_OUI_LEN)!=0)))
{
WLAN_LOG_DEBUG(3, "SNAP+RFC1042 len: %d\n", payload_length);
/* it's a SNAP + RFC1042 frame && protocol is in STT */
/* build 802.3 + RFC1042 */
/* Test for an overlength frame */
if ( payload_length > netdev->mtu ) {
/* A bogus length ethfrm has been sent. */
/* Is someone trying an oflow attack? */
WLAN_LOG_ERROR("SNAP frame too large (%d > %d)\n",
payload_length, netdev->mtu);
return 1;
}
/* chop 802.11 header from skb. */
skb_pull(skb, payload_offset);
/* create 802.3 header at beginning of skb. */
e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
e_hdr->type = htons(payload_length);
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
} else if ((payload_length >= sizeof(wlan_llc_t) + sizeof(wlan_snap_t)) &&
(e_llc->dsap == 0xaa) &&
(e_llc->ssap == 0xaa) &&
(e_llc->ctl == 0x03) ) {
WLAN_LOG_DEBUG(3, "802.1h/RFC1042 len: %d\n", payload_length);
/* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */
/* build a DIXII + RFC894 */
/* Test for an overlength frame */
if ((payload_length - sizeof(wlan_llc_t) - sizeof(wlan_snap_t))
> netdev->mtu) {
/* A bogus length ethfrm has been sent. */
/* Is someone trying an oflow attack? */
WLAN_LOG_ERROR("DIXII frame too large (%ld > %d)\n",
(long int) (payload_length - sizeof(wlan_llc_t) -
sizeof(wlan_snap_t)),
netdev->mtu);
return 1;
}
/* chop 802.11 header from skb. */
skb_pull(skb, payload_offset);
/* chop llc header from skb. */
skb_pull(skb, sizeof(wlan_llc_t));
/* chop snap header from skb. */
skb_pull(skb, sizeof(wlan_snap_t));
/* create 802.3 header at beginning of skb. */
e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
e_hdr->type = e_snap->type;
memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
} else {
WLAN_LOG_DEBUG(3, "NON-ENCAP len: %d\n", payload_length);
/* any NON-ENCAP */
/* it's a generic 80211+LLC or IPX 'Raw 802.3' */
/* build an 802.3 frame */
/* allocate space and setup hostbuf */
/* Test for an overlength frame */
if ( payload_length > netdev->mtu ) {
/* A bogus length ethfrm has been sent. */
/* Is someone trying an oflow attack? */
WLAN_LOG_ERROR("OTHER frame too large (%d > %d)\n",
payload_length,
netdev->mtu);
return 1;
}
/* Chop off the 802.11 header. */
skb_pull(skb, payload_offset);
/* create 802.3 header at beginning of skb. */
e_hdr = (wlan_ethhdr_t *) skb_push(skb, WLAN_ETHHDR_LEN);
memcpy(e_hdr->daddr, daddr, WLAN_ETHADDR_LEN);
memcpy(e_hdr->saddr, saddr, WLAN_ETHADDR_LEN);
e_hdr->type = htons(payload_length);
/* chop off the 802.11 CRC */
skb_trim(skb, skb->len - WLAN_CRC_LEN);
}
skb->protocol = eth_type_trans(skb, netdev);
skb_reset_mac_header(skb);
/* jkriegl: process signal and noise as set in hfa384x_int_rx() */
/* jkriegl: only process signal/noise if requested by iwspy */
if (wlandev->spy_number)
orinoco_spy_gather(wlandev, eth_hdr(skb)->h_source, P80211SKB_RXMETA(skb));
/* Free the metadata */
p80211skb_rxmeta_detach(skb);
DBFEXIT;
return 0;
}
/*----------------------------------------------------------------
* p80211_stt_findproto
*
* Searches the 802.1h Selective Translation Table for a given
* protocol.
*
* Arguments:
* proto protocl number (in host order) to search for.
*
* Returns:
* 1 - if the table is empty or a match is found.
* 0 - if the table is non-empty and a match is not found.
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int p80211_stt_findproto(UINT16 proto)
{
/* Always return found for now. This is the behavior used by the */
/* Zoom Win95 driver when 802.1h mode is selected */
/* TODO: If necessary, add an actual search we'll probably
need this to match the CMAC's way of doing things.
Need to do some testing to confirm.
*/
if (proto == 0x80f3) /* APPLETALK */
return 1;
return 0;
}
/*----------------------------------------------------------------
* p80211skb_rxmeta_detach
*
* Disconnects the frmmeta and rxmeta from an skb.
*
* Arguments:
* wlandev The wlandev this skb belongs to.
* skb The skb we're attaching to.
*
* Returns:
* 0 on success, non-zero otherwise
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
void
p80211skb_rxmeta_detach(struct sk_buff *skb)
{
p80211_rxmeta_t *rxmeta;
p80211_frmmeta_t *frmmeta;
DBFENTER;
/* Sanity checks */
if ( skb==NULL ) { /* bad skb */
WLAN_LOG_DEBUG(1, "Called w/ null skb.\n");
goto exit;
}
frmmeta = P80211SKB_FRMMETA(skb);
if ( frmmeta == NULL ) { /* no magic */
WLAN_LOG_DEBUG(1, "Called w/ bad frmmeta magic.\n");
goto exit;
}
rxmeta = frmmeta->rx;
if ( rxmeta == NULL ) { /* bad meta ptr */
WLAN_LOG_DEBUG(1, "Called w/ bad rxmeta ptr.\n");
goto exit;
}
/* Free rxmeta */
kfree(rxmeta);
/* Clear skb->cb */
memset(skb->cb, 0, sizeof(skb->cb));
exit:
DBFEXIT;
return;
}
/*----------------------------------------------------------------
* p80211skb_rxmeta_attach
*
* Allocates a p80211rxmeta structure, initializes it, and attaches
* it to an skb.
*
* Arguments:
* wlandev The wlandev this skb belongs to.
* skb The skb we're attaching to.
*
* Returns:
* 0 on success, non-zero otherwise
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
int
p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb)
{
int result = 0;
p80211_rxmeta_t *rxmeta;
p80211_frmmeta_t *frmmeta;
DBFENTER;
/* If these already have metadata, we error out! */
if (P80211SKB_RXMETA(skb) != NULL) {
WLAN_LOG_ERROR("%s: RXmeta already attached!\n",
wlandev->name);
result = 0;
goto exit;
}
/* Allocate the rxmeta */
rxmeta = kmalloc(sizeof(p80211_rxmeta_t), GFP_ATOMIC);
if ( rxmeta == NULL ) {
WLAN_LOG_ERROR("%s: Failed to allocate rxmeta.\n",
wlandev->name);
result = 1;
goto exit;
}
/* Initialize the rxmeta */
memset(rxmeta, 0, sizeof(p80211_rxmeta_t));
rxmeta->wlandev = wlandev;
rxmeta->hosttime = jiffies;
/* Overlay a frmmeta_t onto skb->cb */
memset(skb->cb, 0, sizeof(p80211_frmmeta_t));
frmmeta = (p80211_frmmeta_t*)(skb->cb);
frmmeta->magic = P80211_FRMMETA_MAGIC;
frmmeta->rx = rxmeta;
exit:
DBFEXIT;
return result;
}
/*----------------------------------------------------------------
* p80211skb_free
*
* Frees an entire p80211skb by checking and freeing the meta struct
* and then freeing the skb.
*
* Arguments:
* wlandev The wlandev this skb belongs to.
* skb The skb we're attaching to.
*
* Returns:
* 0 on success, non-zero otherwise
*
* Call context:
* May be called in interrupt or non-interrupt context
----------------------------------------------------------------*/
void
p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb)
{
p80211_frmmeta_t *meta;
DBFENTER;
meta = P80211SKB_FRMMETA(skb);
if ( meta && meta->rx) {
p80211skb_rxmeta_detach(skb);
} else {
WLAN_LOG_ERROR("Freeing an skb (%p) w/ no frmmeta.\n", skb);
}
dev_kfree_skb(skb);
DBFEXIT;
return;
}

View File

@ -0,0 +1,186 @@
/* p80211conv.h
*
* Ether/802.11 conversions and packet buffer routines
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares the functions, types and macros that perform
* Ethernet to/from 802.11 frame conversions.
*
* --------------------------------------------------------------------
*/
#ifndef _LINUX_P80211CONV_H
#define _LINUX_P80211CONV_H
/*================================================================*/
/* Constants */
#define WLAN_ETHADDR_LEN 6
#define WLAN_IEEE_OUI_LEN 3
#define WLAN_ETHCONV_ENCAP 1
#define WLAN_ETHCONV_RFC1042 2
#define WLAN_ETHCONV_8021h 3
#define WLAN_MIN_ETHFRM_LEN 60
#define WLAN_MAX_ETHFRM_LEN 1514
#define WLAN_ETHHDR_LEN 14
#define P80211CAPTURE_VERSION 0x80211001
/*================================================================*/
/* Macros */
#define P80211_FRMMETA_MAGIC 0x802110
#define P80211SKB_FRMMETA(s) \
(((((p80211_frmmeta_t*)((s)->cb))->magic)==P80211_FRMMETA_MAGIC) ? \
((p80211_frmmeta_t*)((s)->cb)) : \
(NULL))
#define P80211SKB_RXMETA(s) \
(P80211SKB_FRMMETA((s)) ? P80211SKB_FRMMETA((s))->rx : ((p80211_rxmeta_t*)(NULL)))
typedef struct p80211_rxmeta
{
struct wlandevice *wlandev;
UINT64 mactime; /* Hi-rez MAC-supplied time value */
UINT64 hosttime; /* Best-rez host supplied time value */
UINT rxrate; /* Receive data rate in 100kbps */
UINT priority; /* 0-15, 0=contention, 6=CF */
INT signal; /* An SSI, see p80211netdev.h */
INT noise; /* An SSI, see p80211netdev.h */
UINT channel; /* Receive channel (mostly for snifs) */
UINT preamble; /* P80211ENUM_preambletype_* */
UINT encoding; /* P80211ENUM_encoding_* */
} p80211_rxmeta_t;
typedef struct p80211_frmmeta
{
UINT magic;
p80211_rxmeta_t *rx;
} p80211_frmmeta_t;
void p80211skb_free(struct wlandevice *wlandev, struct sk_buff *skb);
int p80211skb_rxmeta_attach(struct wlandevice *wlandev, struct sk_buff *skb);
void p80211skb_rxmeta_detach(struct sk_buff *skb);
/*================================================================*/
/* Types */
/*
* Frame capture header. (See doc/capturefrm.txt)
*/
typedef struct p80211_caphdr
{
UINT32 version;
UINT32 length;
UINT64 mactime;
UINT64 hosttime;
UINT32 phytype;
UINT32 channel;
UINT32 datarate;
UINT32 antenna;
UINT32 priority;
UINT32 ssi_type;
INT32 ssi_signal;
INT32 ssi_noise;
UINT32 preamble;
UINT32 encoding;
} p80211_caphdr_t;
/* buffer free method pointer type */
typedef void (* freebuf_method_t)(void *buf, int size);
typedef struct p80211_metawep {
void *data;
UINT8 iv[4];
UINT8 icv[4];
} p80211_metawep_t;
/* local ether header type */
typedef struct wlan_ethhdr
{
UINT8 daddr[WLAN_ETHADDR_LEN];
UINT8 saddr[WLAN_ETHADDR_LEN];
UINT16 type;
} __WLAN_ATTRIB_PACK__ wlan_ethhdr_t;
/* local llc header type */
typedef struct wlan_llc
{
UINT8 dsap;
UINT8 ssap;
UINT8 ctl;
} __WLAN_ATTRIB_PACK__ wlan_llc_t;
/* local snap header type */
typedef struct wlan_snap
{
UINT8 oui[WLAN_IEEE_OUI_LEN];
UINT16 type;
} __WLAN_ATTRIB_PACK__ wlan_snap_t;
/* Circular include trick */
struct wlandevice;
/*================================================================*/
/* Externs */
/*================================================================*/
/*Function Declarations */
int skb_p80211_to_ether( struct wlandevice *wlandev, UINT32 ethconv,
struct sk_buff *skb);
int skb_ether_to_p80211( struct wlandevice *wlandev, UINT32 ethconv,
struct sk_buff *skb, p80211_hdr_t *p80211_hdr,
p80211_metawep_t *p80211_wep );
int p80211_stt_findproto(UINT16 proto);
int p80211_stt_addproto(UINT16 proto);
#endif

View File

@ -0,0 +1,299 @@
/* p80211hdr.h
*
* Macros, types, and functions for handling 802.11 MAC headers
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares the constants and types used in the interface
* between a wlan driver and the user mode utilities.
*
* Note:
* - Constant values are always in HOST byte order. To assign
* values to multi-byte fields they _must_ be converted to
* ieee byte order. To retrieve multi-byte values from incoming
* frames, they must be converted to host order.
*
* All functions declared here are implemented in p80211.c
* --------------------------------------------------------------------
*/
#ifndef _P80211HDR_H
#define _P80211HDR_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
/*--- Sizes -----------------------------------------------*/
#define WLAN_ADDR_LEN 6
#define WLAN_CRC_LEN 4
#define WLAN_BSSID_LEN 6
#define WLAN_BSS_TS_LEN 8
#define WLAN_HDR_A3_LEN 24
#define WLAN_HDR_A4_LEN 30
#define WLAN_SSID_MAXLEN 32
#define WLAN_DATA_MAXLEN 2312
#define WLAN_A3FR_MAXLEN (WLAN_HDR_A3_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
#define WLAN_A4FR_MAXLEN (WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)
#define WLAN_BEACON_FR_MAXLEN (WLAN_HDR_A3_LEN + 334)
#define WLAN_ATIM_FR_MAXLEN (WLAN_HDR_A3_LEN + 0)
#define WLAN_DISASSOC_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
#define WLAN_ASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 48)
#define WLAN_ASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
#define WLAN_REASSOCREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 54)
#define WLAN_REASSOCRESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 16)
#define WLAN_PROBEREQ_FR_MAXLEN (WLAN_HDR_A3_LEN + 44)
#define WLAN_PROBERESP_FR_MAXLEN (WLAN_HDR_A3_LEN + 78)
#define WLAN_AUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 261)
#define WLAN_DEAUTHEN_FR_MAXLEN (WLAN_HDR_A3_LEN + 2)
#define WLAN_WEP_NKEYS 4
#define WLAN_WEP_MAXKEYLEN 13
#define WLAN_CHALLENGE_IE_LEN 130
#define WLAN_CHALLENGE_LEN 128
#define WLAN_WEP_IV_LEN 4
#define WLAN_WEP_ICV_LEN 4
/*--- Frame Control Field -------------------------------------*/
/* Frame Types */
#define WLAN_FTYPE_MGMT 0x00
#define WLAN_FTYPE_CTL 0x01
#define WLAN_FTYPE_DATA 0x02
/* Frame subtypes */
/* Management */
#define WLAN_FSTYPE_ASSOCREQ 0x00
#define WLAN_FSTYPE_ASSOCRESP 0x01
#define WLAN_FSTYPE_REASSOCREQ 0x02
#define WLAN_FSTYPE_REASSOCRESP 0x03
#define WLAN_FSTYPE_PROBEREQ 0x04
#define WLAN_FSTYPE_PROBERESP 0x05
#define WLAN_FSTYPE_BEACON 0x08
#define WLAN_FSTYPE_ATIM 0x09
#define WLAN_FSTYPE_DISASSOC 0x0a
#define WLAN_FSTYPE_AUTHEN 0x0b
#define WLAN_FSTYPE_DEAUTHEN 0x0c
/* Control */
#define WLAN_FSTYPE_BLOCKACKREQ 0x8
#define WLAN_FSTYPE_BLOCKACK 0x9
#define WLAN_FSTYPE_PSPOLL 0x0a
#define WLAN_FSTYPE_RTS 0x0b
#define WLAN_FSTYPE_CTS 0x0c
#define WLAN_FSTYPE_ACK 0x0d
#define WLAN_FSTYPE_CFEND 0x0e
#define WLAN_FSTYPE_CFENDCFACK 0x0f
/* Data */
#define WLAN_FSTYPE_DATAONLY 0x00
#define WLAN_FSTYPE_DATA_CFACK 0x01
#define WLAN_FSTYPE_DATA_CFPOLL 0x02
#define WLAN_FSTYPE_DATA_CFACK_CFPOLL 0x03
#define WLAN_FSTYPE_NULL 0x04
#define WLAN_FSTYPE_CFACK 0x05
#define WLAN_FSTYPE_CFPOLL 0x06
#define WLAN_FSTYPE_CFACK_CFPOLL 0x07
/*================================================================*/
/* Macros */
/*--- FC Macros ----------------------------------------------*/
/* Macros to get/set the bitfields of the Frame Control Field */
/* GET_FC_??? - takes the host byte-order value of an FC */
/* and retrieves the value of one of the */
/* bitfields and moves that value so its lsb is */
/* in bit 0. */
/* SET_FC_??? - takes a host order value for one of the FC */
/* bitfields and moves it to the proper bit */
/* location for ORing into a host order FC. */
/* To send the FC produced from SET_FC_???, */
/* one must put the bytes in IEEE order. */
/* e.g. */
/* printf("the frame subtype is %x", */
/* GET_FC_FTYPE( ieee2host( rx.fc ))) */
/* */
/* tx.fc = host2ieee( SET_FC_FTYPE(WLAN_FTYP_CTL) | */
/* SET_FC_FSTYPE(WLAN_FSTYPE_RTS) ); */
/*------------------------------------------------------------*/
#define WLAN_GET_FC_PVER(n) (((UINT16)(n)) & (BIT0 | BIT1))
#define WLAN_GET_FC_FTYPE(n) ((((UINT16)(n)) & (BIT2 | BIT3)) >> 2)
#define WLAN_GET_FC_FSTYPE(n) ((((UINT16)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
#define WLAN_GET_FC_TODS(n) ((((UINT16)(n)) & (BIT8)) >> 8)
#define WLAN_GET_FC_FROMDS(n) ((((UINT16)(n)) & (BIT9)) >> 9)
#define WLAN_GET_FC_MOREFRAG(n) ((((UINT16)(n)) & (BIT10)) >> 10)
#define WLAN_GET_FC_RETRY(n) ((((UINT16)(n)) & (BIT11)) >> 11)
#define WLAN_GET_FC_PWRMGT(n) ((((UINT16)(n)) & (BIT12)) >> 12)
#define WLAN_GET_FC_MOREDATA(n) ((((UINT16)(n)) & (BIT13)) >> 13)
#define WLAN_GET_FC_ISWEP(n) ((((UINT16)(n)) & (BIT14)) >> 14)
#define WLAN_GET_FC_ORDER(n) ((((UINT16)(n)) & (BIT15)) >> 15)
#define WLAN_SET_FC_PVER(n) ((UINT16)(n))
#define WLAN_SET_FC_FTYPE(n) (((UINT16)(n)) << 2)
#define WLAN_SET_FC_FSTYPE(n) (((UINT16)(n)) << 4)
#define WLAN_SET_FC_TODS(n) (((UINT16)(n)) << 8)
#define WLAN_SET_FC_FROMDS(n) (((UINT16)(n)) << 9)
#define WLAN_SET_FC_MOREFRAG(n) (((UINT16)(n)) << 10)
#define WLAN_SET_FC_RETRY(n) (((UINT16)(n)) << 11)
#define WLAN_SET_FC_PWRMGT(n) (((UINT16)(n)) << 12)
#define WLAN_SET_FC_MOREDATA(n) (((UINT16)(n)) << 13)
#define WLAN_SET_FC_ISWEP(n) (((UINT16)(n)) << 14)
#define WLAN_SET_FC_ORDER(n) (((UINT16)(n)) << 15)
/*--- Duration Macros ----------------------------------------*/
/* Macros to get/set the bitfields of the Duration Field */
/* - the duration value is only valid when bit15 is zero */
/* - the firmware handles these values, so I'm not going */
/* these macros right now. */
/*------------------------------------------------------------*/
/*--- Sequence Control Macros -------------------------------*/
/* Macros to get/set the bitfields of the Sequence Control */
/* Field. */
/*------------------------------------------------------------*/
#define WLAN_GET_SEQ_FRGNUM(n) (((UINT16)(n)) & (BIT0|BIT1|BIT2|BIT3))
#define WLAN_GET_SEQ_SEQNUM(n) ((((UINT16)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
/*--- Data ptr macro -----------------------------------------*/
/* Creates a UINT8* to the data portion of a frame */
/* Assumes you're passing in a ptr to the beginning of the hdr*/
/*------------------------------------------------------------*/
#define WLAN_HDR_A3_DATAP(p) (((UINT8*)(p)) + WLAN_HDR_A3_LEN)
#define WLAN_HDR_A4_DATAP(p) (((UINT8*)(p)) + WLAN_HDR_A4_LEN)
#define DOT11_RATE5_ISBASIC_GET(r) (((UINT8)(r)) & BIT7)
/*================================================================*/
/* Types */
/* BSS Timestamp */
typedef UINT8 wlan_bss_ts_t[WLAN_BSS_TS_LEN];
/* Generic 802.11 Header types */
typedef struct p80211_hdr_a3
{
UINT16 fc;
UINT16 dur;
UINT8 a1[WLAN_ADDR_LEN];
UINT8 a2[WLAN_ADDR_LEN];
UINT8 a3[WLAN_ADDR_LEN];
UINT16 seq;
} __WLAN_ATTRIB_PACK__ p80211_hdr_a3_t;
typedef struct p80211_hdr_a4
{
UINT16 fc;
UINT16 dur;
UINT8 a1[WLAN_ADDR_LEN];
UINT8 a2[WLAN_ADDR_LEN];
UINT8 a3[WLAN_ADDR_LEN];
UINT16 seq;
UINT8 a4[WLAN_ADDR_LEN];
} __WLAN_ATTRIB_PACK__ p80211_hdr_a4_t;
typedef union p80211_hdr
{
p80211_hdr_a3_t a3;
p80211_hdr_a4_t a4;
} __WLAN_ATTRIB_PACK__ p80211_hdr_t;
/*================================================================*/
/* Extern Declarations */
/*================================================================*/
/* Function Declarations */
/* Frame and header lenght macros */
#define WLAN_CTL_FRAMELEN(fstype) (\
(fstype) == WLAN_FSTYPE_BLOCKACKREQ ? 24 : \
(fstype) == WLAN_FSTYPE_BLOCKACK ? 152 : \
(fstype) == WLAN_FSTYPE_PSPOLL ? 20 : \
(fstype) == WLAN_FSTYPE_RTS ? 20 : \
(fstype) == WLAN_FSTYPE_CTS ? 14 : \
(fstype) == WLAN_FSTYPE_ACK ? 14 : \
(fstype) == WLAN_FSTYPE_CFEND ? 20 : \
(fstype) == WLAN_FSTYPE_CFENDCFACK ? 20 : 4)
#define WLAN_FCS_LEN 4
/* ftcl in HOST order */
inline static UINT16 p80211_headerlen(UINT16 fctl)
{
UINT16 hdrlen = 0;
switch ( WLAN_GET_FC_FTYPE(fctl) ) {
case WLAN_FTYPE_MGMT:
hdrlen = WLAN_HDR_A3_LEN;
break;
case WLAN_FTYPE_DATA:
hdrlen = WLAN_HDR_A3_LEN;
if ( WLAN_GET_FC_TODS(fctl) && WLAN_GET_FC_FROMDS(fctl) ) {
hdrlen += WLAN_ADDR_LEN;
}
break;
case WLAN_FTYPE_CTL:
hdrlen = WLAN_CTL_FRAMELEN(WLAN_GET_FC_FSTYPE(fctl)) -
WLAN_FCS_LEN;
break;
default:
hdrlen = WLAN_HDR_A3_LEN;
}
return hdrlen;
}
#endif /* _P80211HDR_H */

View File

@ -0,0 +1,123 @@
/* p80211ioctl.h
*
* Declares constants and types for the p80211 ioctls
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* While this file is called 'ioctl' is purpose goes a little beyond
* that. This file defines the types and contants used to implement
* the p80211 request/confirm/indicate interfaces on Linux. The
* request/confirm interface is, in fact, normally implemented as an
* ioctl. The indicate interface on the other hand, is implemented
* using the Linux 'netlink' interface.
*
* The reason I say that request/confirm is 'normally' implemented
* via ioctl is that we're reserving the right to be able to send
* request commands via the netlink interface. This will be necessary
* if we ever need to send request messages when there aren't any
* wlan network devices present (i.e. sending a message that only p80211
* cares about.
* --------------------------------------------------------------------
*/
#ifndef _P80211IOCTL_H
#define _P80211IOCTL_H
/*================================================================*/
/* Constants */
/*----------------------------------------------------------------*/
/* p80211 ioctl "request" codes. See argument 2 of ioctl(2). */
#define P80211_IFTEST (SIOCDEVPRIVATE + 0)
#define P80211_IFREQ (SIOCDEVPRIVATE + 1)
/*----------------------------------------------------------------*/
/* Magic number, a quick test to see we're getting the desired struct */
#define P80211_IOCTL_MAGIC (0x4a2d464dUL)
/*----------------------------------------------------------------*/
/* Netlink protocol numbers for the indication interface */
#define P80211_NL_SOCK_IND NETLINK_USERSOCK
/*----------------------------------------------------------------*/
/* Netlink multicast bits for different types of messages */
#define P80211_NL_MCAST_GRP_MLME BIT0 /* Local station messages */
#define P80211_NL_MCAST_GRP_SNIFF BIT1 /* Sniffer messages */
#define P80211_NL_MCAST_GRP_DIST BIT2 /* Distribution system messages */
/*================================================================*/
/* Macros */
/*================================================================*/
/* Types */
/*----------------------------------------------------------------*/
/* A ptr to the following structure type is passed as the third */
/* argument to the ioctl system call when issuing a request to */
/* the p80211 module. */
typedef struct p80211ioctl_req
{
char name[WLAN_DEVNAMELEN_MAX];
caddr_t data;
UINT32 magic;
UINT16 len;
UINT32 result;
} __WLAN_ATTRIB_PACK__ p80211ioctl_req_t;
/*================================================================*/
/* Extern Declarations */
/*================================================================*/
/* Function Declarations */
#endif /* _P80211IOCTL_H */

View File

@ -0,0 +1,169 @@
/* p80211meta.h
*
* Macros, constants, types, and funcs for p80211 metadata
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares some of the constants and types used in various
* parts of the linux-wlan system.
*
* Notes:
* - Constant values are always in HOST byte order.
*
* All functions and statics declared here are implemented in p80211types.c
* --------------------------------------------------------------------
*/
#ifndef _P80211META_H
#define _P80211META_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Macros */
/*----------------------------------------------------------------*/
/* The following macros are used to ensure consistent naming */
/* conventions for all the different metadata lists. */
#define MKREQMETANAME(name) p80211meta_ ## req ## _ ## name
#define MKINDMETANAME(name) p80211meta_ ## ind ## _ ## name
#define MKMIBMETANAME(name) p80211meta_ ## mib ## _ ## name
#define MKGRPMETANAME(name) p80211meta_ ## grp ## _ ## name
#define MKREQMETASIZE(name) p80211meta_ ## req ## _ ## name ## _ ## size
#define MKINDMETASIZE(name) p80211meta_ ## ind ## _ ## name ## _ ## size
#define MKMIBMETASIZE(name) p80211meta_ ## mib ## _ ## name ## _ ## size
#define MKGRPMETASIZE(name) p80211meta_ ## grp ## _ ## name ## _ ## size
#define GETMETASIZE(aptr) (**((UINT32**)(aptr)))
/*----------------------------------------------------------------*/
/* The following ifdef depends on the following defines: */
/* P80211_NOINCLUDESTRINGS - if defined, all metadata name fields */
/* are empty strings */
#ifdef P80211_NOINCLUDESTRINGS
#define MKITEMNAME(s) ("")
#else
#define MKITEMNAME(s) (s)
#endif
/*================================================================*/
/* Types */
/*----------------------------------------------------------------*/
/* The following structure types are used for the metadata */
/* representation of category list metadata, group list metadata, */
/* and data item metadata for both Mib and Messages. */
typedef struct p80211meta
{
char *name; /* data item name */
UINT32 did; /* partial did */
UINT32 flags; /* set of various flag bits */
UINT32 min; /* min value of a BOUNDEDINT */
UINT32 max; /* max value of a BOUNDEDINT */
UINT32 maxlen; /* maxlen of a OCTETSTR or DISPLAYSTR */
UINT32 minlen; /* minlen of a OCTETSTR or DISPLAYSTR */
p80211enum_t *enumptr; /* ptr to the enum type for ENUMINT */
p80211_totext_t totextptr; /* ptr to totext conversion function */
p80211_fromtext_t fromtextptr; /* ptr to totext conversion function */
p80211_valid_t validfunptr; /* ptr to totext conversion function */
} p80211meta_t;
typedef struct grplistitem
{
char *name;
p80211meta_t *itemlist;
} grplistitem_t;
typedef struct catlistitem
{
char *name;
grplistitem_t *grplist;
} catlistitem_t;
/*================================================================*/
/* Extern Declarations */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Function Declarations */
/*----------------------------------------------------------------*/
/* */
UINT32 p80211_text2did(catlistitem_t *catlist, char *catname, char *grpname, char *itemname);
UINT32 p80211_text2catdid(catlistitem_t *list, char *name );
UINT32 p80211_text2grpdid(grplistitem_t *list, char *name );
UINT32 p80211_text2itemdid(p80211meta_t *list, char *name );
UINT32 p80211_isvalid_did( catlistitem_t *catlist, UINT32 did );
UINT32 p80211_isvalid_catdid( catlistitem_t *catlist, UINT32 did );
UINT32 p80211_isvalid_grpdid( catlistitem_t *catlist, UINT32 did );
UINT32 p80211_isvalid_itemdid( catlistitem_t *catlist, UINT32 did );
catlistitem_t *p80211_did2cat( catlistitem_t *catlist, UINT32 did );
grplistitem_t *p80211_did2grp( catlistitem_t *catlist, UINT32 did );
p80211meta_t *p80211_did2item( catlistitem_t *catlist, UINT32 did );
UINT32 p80211item_maxdatalen( struct catlistitem *metalist, UINT32 did );
UINT32 p80211_metaname2did(struct catlistitem *metalist, char *itemname);
UINT32 p80211item_getoffset( struct catlistitem *metalist, UINT32 did );
int p80211item_gettype(p80211meta_t *meta);
#endif /* _P80211META_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,105 @@
/* p80211metamib.h
*
* Macros, const, types, and funcs for p80211 mib metadata
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares some of the constants and types used in various
* parts of the linux-wlan system.
*
* Notes:
* - Constant values are always in HOST byte order.
*
* All functions and statics declared here are implemented in p80211types.c
* --------------------------------------------------------------------
*/
#ifndef _P80211METAMIB_H
#define _P80211METAMIB_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Macros */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Types */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Extern Declarations */
/*----------------------------------------------------------------*/
/* The following is the external declaration for the mib */
/* category metadata list */
extern catlistitem_t mib_catlist[];
extern UINT32 mib_catlist_size;
/*================================================================*/
/* Function Declarations */
/*----------------------------------------------------------------*/
/* */
#endif /* _P80211METAMIB_H */

View File

@ -0,0 +1,105 @@
/* p80211metamsg.h
*
* Macros, const, types, and funcs for p80211 msg metadata
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares some of the constants and types used in various
* parts of the linux-wlan system.
*
* Notes:
* - Constant values are always in HOST byte order.
*
* All functions and statics declared here are implemented in p80211types.c
* --------------------------------------------------------------------
*/
#ifndef _P80211METAMSG_H
#define _P80211METAMSG_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Macros */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Types */
/*----------------------------------------------------------------*/
/* */
/*================================================================*/
/* Extern Declarations */
/*----------------------------------------------------------------*/
/* The following is the external declaration for the message */
/* category metadata list */
extern catlistitem_t msg_catlist[];
extern UINT32 msg_catlist_size;
/*================================================================*/
/* Function Declarations */
/*----------------------------------------------------------------*/
/* */
#endif /* _P80211METAMSG_H */

View File

@ -0,0 +1,644 @@
/* This file is GENERATED AUTOMATICALLY. DO NOT EDIT OR MODIFY.
* --------------------------------------------------------------------
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
#ifndef _P80211MKMETASTRUCT_H
#define _P80211MKMETASTRUCT_H
typedef struct p80211msg_dot11req_mibget
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_unk392_t mibattribute ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_mibget_t;
typedef struct p80211msg_dot11req_mibset
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_unk392_t mibattribute ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_mibset_t;
typedef struct p80211msg_dot11req_powermgmt
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t powermgmtmode ;
p80211item_uint32_t wakeup ;
p80211item_uint32_t receivedtims ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_powermgmt_t;
typedef struct p80211msg_dot11req_scan
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t bsstype ;
p80211item_pstr6_t bssid ;
UINT8 pad_0C[1] ;
p80211item_pstr32_t ssid ;
UINT8 pad_1D[3] ;
p80211item_uint32_t scantype ;
p80211item_uint32_t probedelay ;
p80211item_pstr14_t channellist ;
UINT8 pad_2C[1] ;
p80211item_uint32_t minchanneltime ;
p80211item_uint32_t maxchanneltime ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t numbss ;
p80211item_uint32_t append ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_scan_t;
typedef struct p80211msg_dot11req_scan_results
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t bssindex ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t signal ;
p80211item_uint32_t noise ;
p80211item_pstr6_t bssid ;
UINT8 pad_3C[1] ;
p80211item_pstr32_t ssid ;
UINT8 pad_4D[3] ;
p80211item_uint32_t bsstype ;
p80211item_uint32_t beaconperiod ;
p80211item_uint32_t dtimperiod ;
p80211item_uint32_t timestamp ;
p80211item_uint32_t localtime ;
p80211item_uint32_t fhdwelltime ;
p80211item_uint32_t fhhopset ;
p80211item_uint32_t fhhoppattern ;
p80211item_uint32_t fhhopindex ;
p80211item_uint32_t dschannel ;
p80211item_uint32_t cfpcount ;
p80211item_uint32_t cfpperiod ;
p80211item_uint32_t cfpmaxduration ;
p80211item_uint32_t cfpdurremaining ;
p80211item_uint32_t ibssatimwindow ;
p80211item_uint32_t cfpollable ;
p80211item_uint32_t cfpollreq ;
p80211item_uint32_t privacy ;
p80211item_uint32_t basicrate1 ;
p80211item_uint32_t basicrate2 ;
p80211item_uint32_t basicrate3 ;
p80211item_uint32_t basicrate4 ;
p80211item_uint32_t basicrate5 ;
p80211item_uint32_t basicrate6 ;
p80211item_uint32_t basicrate7 ;
p80211item_uint32_t basicrate8 ;
p80211item_uint32_t supprate1 ;
p80211item_uint32_t supprate2 ;
p80211item_uint32_t supprate3 ;
p80211item_uint32_t supprate4 ;
p80211item_uint32_t supprate5 ;
p80211item_uint32_t supprate6 ;
p80211item_uint32_t supprate7 ;
p80211item_uint32_t supprate8 ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_scan_results_t;
typedef struct p80211msg_dot11req_join
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t bssid ;
UINT8 pad_5C[1] ;
p80211item_uint32_t joinfailuretimeout ;
p80211item_uint32_t basicrate1 ;
p80211item_uint32_t basicrate2 ;
p80211item_uint32_t basicrate3 ;
p80211item_uint32_t basicrate4 ;
p80211item_uint32_t basicrate5 ;
p80211item_uint32_t basicrate6 ;
p80211item_uint32_t basicrate7 ;
p80211item_uint32_t basicrate8 ;
p80211item_uint32_t operationalrate1 ;
p80211item_uint32_t operationalrate2 ;
p80211item_uint32_t operationalrate3 ;
p80211item_uint32_t operationalrate4 ;
p80211item_uint32_t operationalrate5 ;
p80211item_uint32_t operationalrate6 ;
p80211item_uint32_t operationalrate7 ;
p80211item_uint32_t operationalrate8 ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_join_t;
typedef struct p80211msg_dot11req_authenticate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_6C[1] ;
p80211item_uint32_t authenticationtype ;
p80211item_uint32_t authenticationfailuretimeout ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_authenticate_t;
typedef struct p80211msg_dot11req_deauthenticate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_7C[1] ;
p80211item_uint32_t reasoncode ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_deauthenticate_t;
typedef struct p80211msg_dot11req_associate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_8C[1] ;
p80211item_uint32_t associatefailuretimeout ;
p80211item_uint32_t cfpollable ;
p80211item_uint32_t cfpollreq ;
p80211item_uint32_t privacy ;
p80211item_uint32_t listeninterval ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_associate_t;
typedef struct p80211msg_dot11req_reassociate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t newapaddress ;
UINT8 pad_9C[1] ;
p80211item_uint32_t reassociatefailuretimeout ;
p80211item_uint32_t cfpollable ;
p80211item_uint32_t cfpollreq ;
p80211item_uint32_t privacy ;
p80211item_uint32_t listeninterval ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_reassociate_t;
typedef struct p80211msg_dot11req_disassociate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_10C[1] ;
p80211item_uint32_t reasoncode ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_disassociate_t;
typedef struct p80211msg_dot11req_reset
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t setdefaultmib ;
p80211item_pstr6_t macaddress ;
UINT8 pad_11C[1] ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_reset_t;
typedef struct p80211msg_dot11req_start
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr32_t ssid ;
UINT8 pad_12D[3] ;
p80211item_uint32_t bsstype ;
p80211item_uint32_t beaconperiod ;
p80211item_uint32_t dtimperiod ;
p80211item_uint32_t cfpperiod ;
p80211item_uint32_t cfpmaxduration ;
p80211item_uint32_t fhdwelltime ;
p80211item_uint32_t fhhopset ;
p80211item_uint32_t fhhoppattern ;
p80211item_uint32_t dschannel ;
p80211item_uint32_t ibssatimwindow ;
p80211item_uint32_t probedelay ;
p80211item_uint32_t cfpollable ;
p80211item_uint32_t cfpollreq ;
p80211item_uint32_t basicrate1 ;
p80211item_uint32_t basicrate2 ;
p80211item_uint32_t basicrate3 ;
p80211item_uint32_t basicrate4 ;
p80211item_uint32_t basicrate5 ;
p80211item_uint32_t basicrate6 ;
p80211item_uint32_t basicrate7 ;
p80211item_uint32_t basicrate8 ;
p80211item_uint32_t operationalrate1 ;
p80211item_uint32_t operationalrate2 ;
p80211item_uint32_t operationalrate3 ;
p80211item_uint32_t operationalrate4 ;
p80211item_uint32_t operationalrate5 ;
p80211item_uint32_t operationalrate6 ;
p80211item_uint32_t operationalrate7 ;
p80211item_uint32_t operationalrate8 ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11req_start_t;
typedef struct p80211msg_dot11ind_authenticate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_13C[1] ;
p80211item_uint32_t authenticationtype ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11ind_authenticate_t;
typedef struct p80211msg_dot11ind_deauthenticate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_14C[1] ;
p80211item_uint32_t reasoncode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11ind_deauthenticate_t;
typedef struct p80211msg_dot11ind_associate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_15C[1] ;
p80211item_uint32_t aid ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11ind_associate_t;
typedef struct p80211msg_dot11ind_reassociate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_16C[1] ;
p80211item_uint32_t aid ;
p80211item_pstr6_t oldapaddress ;
UINT8 pad_17C[1] ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11ind_reassociate_t;
typedef struct p80211msg_dot11ind_disassociate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t peerstaaddress ;
UINT8 pad_18C[1] ;
p80211item_uint32_t reasoncode ;
} __WLAN_ATTRIB_PACK__ p80211msg_dot11ind_disassociate_t;
typedef struct p80211msg_lnxreq_ifstate
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t ifstate ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_ifstate_t;
typedef struct p80211msg_lnxreq_wlansniff
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t enable ;
p80211item_uint32_t channel ;
p80211item_uint32_t prismheader ;
p80211item_uint32_t wlanheader ;
p80211item_uint32_t keepwepflags ;
p80211item_uint32_t stripfcs ;
p80211item_uint32_t packet_trunc ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_wlansniff_t;
typedef struct p80211msg_lnxreq_hostwep
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t decrypt ;
p80211item_uint32_t encrypt ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_hostwep_t;
typedef struct p80211msg_lnxreq_commsquality
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t dbm ;
p80211item_uint32_t link ;
p80211item_uint32_t level ;
p80211item_uint32_t noise ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_commsquality_t;
typedef struct p80211msg_lnxreq_autojoin
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr32_t ssid ;
UINT8 pad_19D[3] ;
p80211item_uint32_t authtype ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxreq_autojoin_t;
typedef struct p80211msg_lnxind_wlansniffrm
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t hosttime ;
p80211item_uint32_t mactime ;
p80211item_uint32_t channel ;
p80211item_uint32_t rssi ;
p80211item_uint32_t sq ;
p80211item_uint32_t signal ;
p80211item_uint32_t noise ;
p80211item_uint32_t rate ;
p80211item_uint32_t istx ;
p80211item_uint32_t frmlen ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxind_wlansniffrm_t;
typedef struct p80211msg_lnxind_roam
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t reason ;
} __WLAN_ATTRIB_PACK__ p80211msg_lnxind_roam_t;
typedef struct p80211msg_p2req_join
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_pstr6_t bssid ;
UINT8 pad_20C[1] ;
p80211item_uint32_t basicrate1 ;
p80211item_uint32_t basicrate2 ;
p80211item_uint32_t basicrate3 ;
p80211item_uint32_t basicrate4 ;
p80211item_uint32_t basicrate5 ;
p80211item_uint32_t basicrate6 ;
p80211item_uint32_t basicrate7 ;
p80211item_uint32_t basicrate8 ;
p80211item_uint32_t operationalrate1 ;
p80211item_uint32_t operationalrate2 ;
p80211item_uint32_t operationalrate3 ;
p80211item_uint32_t operationalrate4 ;
p80211item_uint32_t operationalrate5 ;
p80211item_uint32_t operationalrate6 ;
p80211item_uint32_t operationalrate7 ;
p80211item_uint32_t operationalrate8 ;
p80211item_pstr32_t ssid ;
UINT8 pad_21D[3] ;
p80211item_uint32_t channel ;
p80211item_uint32_t authtype ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_join_t;
typedef struct p80211msg_p2req_readpda
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_unk1024_t pda ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_readpda_t;
typedef struct p80211msg_p2req_readcis
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_unk1024_t cis ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_readcis_t;
typedef struct p80211msg_p2req_auxport_state
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t enable ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_auxport_state_t;
typedef struct p80211msg_p2req_auxport_read
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t len ;
p80211item_unk1024_t data ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_auxport_read_t;
typedef struct p80211msg_p2req_auxport_write
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t len ;
p80211item_unk1024_t data ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_auxport_write_t;
typedef struct p80211msg_p2req_low_level
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t command ;
p80211item_uint32_t param0 ;
p80211item_uint32_t param1 ;
p80211item_uint32_t param2 ;
p80211item_uint32_t resp0 ;
p80211item_uint32_t resp1 ;
p80211item_uint32_t resp2 ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_low_level_t;
typedef struct p80211msg_p2req_test_command
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t testcode ;
p80211item_uint32_t testparam ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t status ;
p80211item_uint32_t resp0 ;
p80211item_uint32_t resp1 ;
p80211item_uint32_t resp2 ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_test_command_t;
typedef struct p80211msg_p2req_mmi_read
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t value ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_mmi_read_t;
typedef struct p80211msg_p2req_mmi_write
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t data ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_mmi_write_t;
typedef struct p80211msg_p2req_ramdl_state
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t enable ;
p80211item_uint32_t exeaddr ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_ramdl_state_t;
typedef struct p80211msg_p2req_ramdl_write
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t len ;
p80211item_unk4096_t data ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_ramdl_write_t;
typedef struct p80211msg_p2req_flashdl_state
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t enable ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_flashdl_state_t;
typedef struct p80211msg_p2req_flashdl_write
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t addr ;
p80211item_uint32_t len ;
p80211item_unk4096_t data ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_flashdl_write_t;
typedef struct p80211msg_p2req_mm_state
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t enable ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_mm_state_t;
typedef struct p80211msg_p2req_dump_state
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t level ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_dump_state_t;
typedef struct p80211msg_p2req_channel_info
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t channellist ;
p80211item_uint32_t channeldwelltime ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t numchinfo ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_channel_info_t;
typedef struct p80211msg_p2req_channel_info_results
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t channel ;
p80211item_uint32_t resultcode ;
p80211item_uint32_t avgnoiselevel ;
p80211item_uint32_t peaknoiselevel ;
p80211item_uint32_t bssactive ;
p80211item_uint32_t pcfactive ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_channel_info_results_t;
typedef struct p80211msg_p2req_enable
{
UINT32 msgcode ;
UINT32 msglen ;
UINT8 devname[WLAN_DEVNAMELEN_MAX] ;
p80211item_uint32_t resultcode ;
} __WLAN_ATTRIB_PACK__ p80211msg_p2req_enable_t;
#endif

View File

@ -0,0 +1,575 @@
/* p80211mgmt.h
*
* Macros, types, and functions to handle 802.11 mgmt frames
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares the constants and types used in the interface
* between a wlan driver and the user mode utilities.
*
* Notes:
* - Constant values are always in HOST byte order. To assign
* values to multi-byte fields they _must_ be converted to
* ieee byte order. To retrieve multi-byte values from incoming
* frames, they must be converted to host order.
*
* - The len member of the frame structure does NOT!!! include
* the MAC CRC. Therefore, the len field on rx'd frames should
* have 4 subtracted from it.
*
* All functions declared here are implemented in p80211.c
*
* The types, macros, and functions defined here are primarily
* used for encoding and decoding management frames. They are
* designed to follow these patterns of use:
*
* DECODE:
* 1) a frame of length len is received into buffer b
* 2) using the hdr structure and macros, we determine the type
* 3) an appropriate mgmt frame structure, mf, is allocated and zeroed
* 4) mf.hdr = b
* mf.buf = b
* mf.len = len
* 5) call mgmt_decode( mf )
* 6) the frame field pointers in mf are now set. Note that any
* multi-byte frame field values accessed using the frame field
* pointers are in ieee byte order and will have to be converted
* to host order.
*
* ENCODE:
* 1) Library client allocates buffer space for maximum length
* frame of the desired type
* 2) Library client allocates a mgmt frame structure, called mf,
* of the desired type
* 3) Set the following:
* mf.type = <desired type>
* mf.buf = <allocated buffer address>
* 4) call mgmt_encode( mf )
* 5) all of the fixed field pointers and fixed length information element
* pointers in mf are now set to their respective locations in the
* allocated space (fortunately, all variable length information elements
* fall at the end of their respective frames).
* 5a) The length field is set to include the last of the fixed and fixed
* length fields. It may have to be updated for optional or variable
* length information elements.
* 6) Optional and variable length information elements are special cases
* and must be handled individually by the client code.
* --------------------------------------------------------------------
*/
#ifndef _P80211MGMT_H
#define _P80211MGMT_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
#ifndef _P80211HDR_H
#include "p80211hdr.h"
#endif
/*================================================================*/
/* Constants */
/*-- Information Element IDs --------------------*/
#define WLAN_EID_SSID 0
#define WLAN_EID_SUPP_RATES 1
#define WLAN_EID_FH_PARMS 2
#define WLAN_EID_DS_PARMS 3
#define WLAN_EID_CF_PARMS 4
#define WLAN_EID_TIM 5
#define WLAN_EID_IBSS_PARMS 6
/*-- values 7-15 reserved --*/
#define WLAN_EID_CHALLENGE 16
/*-- values 17-31 reserved for challenge text extension --*/
/*-- values 32-255 reserved --*/
/*-- Reason Codes -------------------------------*/
#define WLAN_MGMT_REASON_RSVD 0
#define WLAN_MGMT_REASON_UNSPEC 1
#define WLAN_MGMT_REASON_PRIOR_AUTH_INVALID 2
#define WLAN_MGMT_REASON_DEAUTH_LEAVING 3
#define WLAN_MGMT_REASON_DISASSOC_INACTIVE 4
#define WLAN_MGMT_REASON_DISASSOC_AP_BUSY 5
#define WLAN_MGMT_REASON_CLASS2_NONAUTH 6
#define WLAN_MGMT_REASON_CLASS3_NONASSOC 7
#define WLAN_MGMT_REASON_DISASSOC_STA_HASLEFT 8
#define WLAN_MGMT_REASON_CANT_ASSOC_NONAUTH 9
/*-- Status Codes -------------------------------*/
#define WLAN_MGMT_STATUS_SUCCESS 0
#define WLAN_MGMT_STATUS_UNSPEC_FAILURE 1
#define WLAN_MGMT_STATUS_CAPS_UNSUPPORTED 10
#define WLAN_MGMT_STATUS_REASSOC_NO_ASSOC 11
#define WLAN_MGMT_STATUS_ASSOC_DENIED_UNSPEC 12
#define WLAN_MGMT_STATUS_UNSUPPORTED_AUTHALG 13
#define WLAN_MGMT_STATUS_RX_AUTH_NOSEQ 14
#define WLAN_MGMT_STATUS_CHALLENGE_FAIL 15
#define WLAN_MGMT_STATUS_AUTH_TIMEOUT 16
#define WLAN_MGMT_STATUS_ASSOC_DENIED_BUSY 17
#define WLAN_MGMT_STATUS_ASSOC_DENIED_RATES 18
/* p80211b additions */
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOSHORT 19
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOPBCC 20
#define WLAN_MGMT_STATUS_ASSOC_DENIED_NOAGILITY 21
/*-- Auth Algorithm Field ---------------------------*/
#define WLAN_AUTH_ALG_OPENSYSTEM 0
#define WLAN_AUTH_ALG_SHAREDKEY 1
/*-- Management Frame Field Offsets -------------*/
/* Note: Not all fields are listed because of variable lengths, */
/* see the code in p80211.c to see how we search for fields */
/* Note: These offsets are from the start of the frame data */
#define WLAN_BEACON_OFF_TS 0
#define WLAN_BEACON_OFF_BCN_INT 8
#define WLAN_BEACON_OFF_CAPINFO 10
#define WLAN_BEACON_OFF_SSID 12
#define WLAN_DISASSOC_OFF_REASON 0
#define WLAN_ASSOCREQ_OFF_CAP_INFO 0
#define WLAN_ASSOCREQ_OFF_LISTEN_INT 2
#define WLAN_ASSOCREQ_OFF_SSID 4
#define WLAN_ASSOCRESP_OFF_CAP_INFO 0
#define WLAN_ASSOCRESP_OFF_STATUS 2
#define WLAN_ASSOCRESP_OFF_AID 4
#define WLAN_ASSOCRESP_OFF_SUPP_RATES 6
#define WLAN_REASSOCREQ_OFF_CAP_INFO 0
#define WLAN_REASSOCREQ_OFF_LISTEN_INT 2
#define WLAN_REASSOCREQ_OFF_CURR_AP 4
#define WLAN_REASSOCREQ_OFF_SSID 10
#define WLAN_REASSOCRESP_OFF_CAP_INFO 0
#define WLAN_REASSOCRESP_OFF_STATUS 2
#define WLAN_REASSOCRESP_OFF_AID 4
#define WLAN_REASSOCRESP_OFF_SUPP_RATES 6
#define WLAN_PROBEREQ_OFF_SSID 0
#define WLAN_PROBERESP_OFF_TS 0
#define WLAN_PROBERESP_OFF_BCN_INT 8
#define WLAN_PROBERESP_OFF_CAP_INFO 10
#define WLAN_PROBERESP_OFF_SSID 12
#define WLAN_AUTHEN_OFF_AUTH_ALG 0
#define WLAN_AUTHEN_OFF_AUTH_SEQ 2
#define WLAN_AUTHEN_OFF_STATUS 4
#define WLAN_AUTHEN_OFF_CHALLENGE 6
#define WLAN_DEAUTHEN_OFF_REASON 0
/*================================================================*/
/* Macros */
/*-- Capability Field ---------------------------*/
#define WLAN_GET_MGMT_CAP_INFO_ESS(n) ((n) & BIT0)
#define WLAN_GET_MGMT_CAP_INFO_IBSS(n) (((n) & BIT1) >> 1)
#define WLAN_GET_MGMT_CAP_INFO_CFPOLLABLE(n) (((n) & BIT2) >> 2)
#define WLAN_GET_MGMT_CAP_INFO_CFPOLLREQ(n) (((n) & BIT3) >> 3)
#define WLAN_GET_MGMT_CAP_INFO_PRIVACY(n) (((n) & BIT4) >> 4)
/* p80211b additions */
#define WLAN_GET_MGMT_CAP_INFO_SHORT(n) (((n) & BIT5) >> 5)
#define WLAN_GET_MGMT_CAP_INFO_PBCC(n) (((n) & BIT6) >> 6)
#define WLAN_GET_MGMT_CAP_INFO_AGILITY(n) (((n) & BIT7) >> 7)
#define WLAN_SET_MGMT_CAP_INFO_ESS(n) (n)
#define WLAN_SET_MGMT_CAP_INFO_IBSS(n) ((n) << 1)
#define WLAN_SET_MGMT_CAP_INFO_CFPOLLABLE(n) ((n) << 2)
#define WLAN_SET_MGMT_CAP_INFO_CFPOLLREQ(n) ((n) << 3)
#define WLAN_SET_MGMT_CAP_INFO_PRIVACY(n) ((n) << 4)
/* p80211b additions */
#define WLAN_SET_MGMT_CAP_INFO_SHORT(n) ((n) << 5)
#define WLAN_SET_MGMT_CAP_INFO_PBCC(n) ((n) << 6)
#define WLAN_SET_MGMT_CAP_INFO_AGILITY(n) ((n) << 7)
/*================================================================*/
/* Types */
/*-- Information Element Types --------------------*/
/* prototype structure, all IEs start with these members */
typedef struct wlan_ie
{
UINT8 eid;
UINT8 len;
} __WLAN_ATTRIB_PACK__ wlan_ie_t;
/*-- Service Set Identity (SSID) -----------------*/
typedef struct wlan_ie_ssid
{
UINT8 eid;
UINT8 len;
UINT8 ssid[1]; /* may be zero, ptrs may overlap */
} __WLAN_ATTRIB_PACK__ wlan_ie_ssid_t;
/*-- Supported Rates -----------------------------*/
typedef struct wlan_ie_supp_rates
{
UINT8 eid;
UINT8 len;
UINT8 rates[1]; /* had better be at LEAST one! */
} __WLAN_ATTRIB_PACK__ wlan_ie_supp_rates_t;
/*-- FH Parameter Set ----------------------------*/
typedef struct wlan_ie_fh_parms
{
UINT8 eid;
UINT8 len;
UINT16 dwell;
UINT8 hopset;
UINT8 hoppattern;
UINT8 hopindex;
} __WLAN_ATTRIB_PACK__ wlan_ie_fh_parms_t;
/*-- DS Parameter Set ----------------------------*/
typedef struct wlan_ie_ds_parms
{
UINT8 eid;
UINT8 len;
UINT8 curr_ch;
} __WLAN_ATTRIB_PACK__ wlan_ie_ds_parms_t;
/*-- CF Parameter Set ----------------------------*/
typedef struct wlan_ie_cf_parms
{
UINT8 eid;
UINT8 len;
UINT8 cfp_cnt;
UINT8 cfp_period;
UINT16 cfp_maxdur;
UINT16 cfp_durremaining;
} __WLAN_ATTRIB_PACK__ wlan_ie_cf_parms_t;
/*-- TIM ------------------------------------------*/
typedef struct wlan_ie_tim
{
UINT8 eid;
UINT8 len;
UINT8 dtim_cnt;
UINT8 dtim_period;
UINT8 bitmap_ctl;
UINT8 virt_bm[1];
} __WLAN_ATTRIB_PACK__ wlan_ie_tim_t;
/*-- IBSS Parameter Set ---------------------------*/
typedef struct wlan_ie_ibss_parms
{
UINT8 eid;
UINT8 len;
UINT16 atim_win;
} __WLAN_ATTRIB_PACK__ wlan_ie_ibss_parms_t;
/*-- Challenge Text ------------------------------*/
typedef struct wlan_ie_challenge
{
UINT8 eid;
UINT8 len;
UINT8 challenge[1];
} __WLAN_ATTRIB_PACK__ wlan_ie_challenge_t;
/*-------------------------------------------------*/
/* Frame Types */
/* prototype structure, all mgmt frame types will start with these members */
typedef struct wlan_fr_mgmt
{
UINT16 type;
UINT16 len; /* DOES NOT include CRC !!!!*/
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
/*-- info elements ----------*/
} wlan_fr_mgmt_t;
/*-- Beacon ---------------------------------------*/
typedef struct wlan_fr_beacon
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT64 *ts;
UINT16 *bcn_int;
UINT16 *cap_info;
/*-- info elements ----------*/
wlan_ie_ssid_t *ssid;
wlan_ie_supp_rates_t *supp_rates;
wlan_ie_fh_parms_t *fh_parms;
wlan_ie_ds_parms_t *ds_parms;
wlan_ie_cf_parms_t *cf_parms;
wlan_ie_ibss_parms_t *ibss_parms;
wlan_ie_tim_t *tim;
} wlan_fr_beacon_t;
/*-- IBSS ATIM ------------------------------------*/
typedef struct wlan_fr_ibssatim
{
UINT16 type;
UINT16 len;
UINT8* buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
/*-- info elements ----------*/
/* this frame type has a null body */
} wlan_fr_ibssatim_t;
/*-- Disassociation -------------------------------*/
typedef struct wlan_fr_disassoc
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *reason;
/*-- info elements ----------*/
} wlan_fr_disassoc_t;
/*-- Association Request --------------------------*/
typedef struct wlan_fr_assocreq
{
UINT16 type;
UINT16 len;
UINT8* buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *cap_info;
UINT16 *listen_int;
/*-- info elements ----------*/
wlan_ie_ssid_t *ssid;
wlan_ie_supp_rates_t *supp_rates;
} wlan_fr_assocreq_t;
/*-- Association Response -------------------------*/
typedef struct wlan_fr_assocresp
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *cap_info;
UINT16 *status;
UINT16 *aid;
/*-- info elements ----------*/
wlan_ie_supp_rates_t *supp_rates;
} wlan_fr_assocresp_t;
/*-- Reassociation Request ------------------------*/
typedef struct wlan_fr_reassocreq
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *cap_info;
UINT16 *listen_int;
UINT8 *curr_ap;
/*-- info elements ----------*/
wlan_ie_ssid_t *ssid;
wlan_ie_supp_rates_t *supp_rates;
} wlan_fr_reassocreq_t;
/*-- Reassociation Response -----------------------*/
typedef struct wlan_fr_reassocresp
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *cap_info;
UINT16 *status;
UINT16 *aid;
/*-- info elements ----------*/
wlan_ie_supp_rates_t *supp_rates;
} wlan_fr_reassocresp_t;
/*-- Probe Request --------------------------------*/
typedef struct wlan_fr_probereq
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
/*-- info elements ----------*/
wlan_ie_ssid_t *ssid;
wlan_ie_supp_rates_t *supp_rates;
} wlan_fr_probereq_t;
/*-- Probe Response -------------------------------*/
typedef struct wlan_fr_proberesp
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT64 *ts;
UINT16 *bcn_int;
UINT16 *cap_info;
/*-- info elements ----------*/
wlan_ie_ssid_t *ssid;
wlan_ie_supp_rates_t *supp_rates;
wlan_ie_fh_parms_t *fh_parms;
wlan_ie_ds_parms_t *ds_parms;
wlan_ie_cf_parms_t *cf_parms;
wlan_ie_ibss_parms_t *ibss_parms;
} wlan_fr_proberesp_t;
/*-- Authentication -------------------------------*/
typedef struct wlan_fr_authen
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *auth_alg;
UINT16 *auth_seq;
UINT16 *status;
/*-- info elements ----------*/
wlan_ie_challenge_t *challenge;
} wlan_fr_authen_t;
/*-- Deauthenication -----------------------------*/
typedef struct wlan_fr_deauthen
{
UINT16 type;
UINT16 len;
UINT8 *buf;
p80211_hdr_t *hdr;
/* used for target specific data, skb in Linux */
void *priv;
/*-- fixed fields -----------*/
UINT16 *reason;
/*-- info elements ----------*/
} wlan_fr_deauthen_t;
/*================================================================*/
/* Extern Declarations */
/*================================================================*/
/* Function Declarations */
void wlan_mgmt_encode_beacon( wlan_fr_beacon_t *f );
void wlan_mgmt_decode_beacon( wlan_fr_beacon_t *f );
void wlan_mgmt_encode_disassoc( wlan_fr_disassoc_t *f );
void wlan_mgmt_decode_disassoc( wlan_fr_disassoc_t *f );
void wlan_mgmt_encode_assocreq( wlan_fr_assocreq_t *f );
void wlan_mgmt_decode_assocreq( wlan_fr_assocreq_t *f );
void wlan_mgmt_encode_assocresp( wlan_fr_assocresp_t *f );
void wlan_mgmt_decode_assocresp( wlan_fr_assocresp_t *f );
void wlan_mgmt_encode_reassocreq( wlan_fr_reassocreq_t *f );
void wlan_mgmt_decode_reassocreq( wlan_fr_reassocreq_t *f );
void wlan_mgmt_encode_reassocresp( wlan_fr_reassocresp_t *f );
void wlan_mgmt_decode_reassocresp( wlan_fr_reassocresp_t *f );
void wlan_mgmt_encode_probereq( wlan_fr_probereq_t *f );
void wlan_mgmt_decode_probereq( wlan_fr_probereq_t *f );
void wlan_mgmt_encode_proberesp( wlan_fr_proberesp_t *f );
void wlan_mgmt_decode_proberesp( wlan_fr_proberesp_t *f );
void wlan_mgmt_encode_authen( wlan_fr_authen_t *f );
void wlan_mgmt_decode_authen( wlan_fr_authen_t *f );
void wlan_mgmt_encode_deauthen( wlan_fr_deauthen_t *f );
void wlan_mgmt_decode_deauthen( wlan_fr_deauthen_t *f );
#endif /* _P80211MGMT_H */

View File

@ -0,0 +1,216 @@
/* src/p80211/p80211mod.c
*
* Module entry and exit for p80211
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file contains the p80211.o entry and exit points defined for linux
* kernel modules.
*
* Notes:
* - all module parameters for p80211.o should be defined here.
*
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
#include <linux/version.h>
#include <linux/module.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,25))
#include <linux/moduleparam.h>
#endif
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/wireless.h>
#include <linux/netdevice.h>
#include "version.h"
#include "wlan_compat.h"
/*================================================================*/
/* Project Includes */
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211mgmt.h"
#include "p80211conv.h"
#include "p80211msg.h"
#include "p80211netdev.h"
#include "p80211req.h"
/*================================================================*/
/* Local Constants */
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/
/* Local Static Definitions */
static char *version = "p80211.o: " WLAN_RELEASE;
/*----------------------------------------------------------------*/
/* --Module Parameters */
int wlan_watchdog = 5000;
module_param(wlan_watchdog, int, 0644);
MODULE_PARM_DESC(wlan_watchdog, "transmit timeout in milliseconds");
int wlan_wext_write = 0;
#if WIRELESS_EXT > 12
module_param(wlan_wext_write, int, 0644);
MODULE_PARM_DESC(wlan_wext_write, "enable write wireless extensions");
#endif
#ifdef WLAN_INCLUDE_DEBUG
int wlan_debug=0;
module_param(wlan_debug, int, 0644);
MODULE_PARM_DESC(wlan_debug, "p80211 debug level");
#endif
MODULE_LICENSE("Dual MPL/GPL");
/*================================================================*/
/* Local Function Declarations */
int init_module(void);
void cleanup_module(void);
/*================================================================*/
/* Function Definitions */
/*----------------------------------------------------------------
* init_module
*
* Module initialization routine, called once at module load time.
*
* Arguments:
* none
*
* Returns:
* 0 - success
* ~0 - failure, module is unloaded.
*
* Side effects:
* TODO: define
*
* Call context:
* process thread (insmod or modprobe)
----------------------------------------------------------------*/
int init_module(void)
{
DBFENTER;
#if 0
printk(KERN_NOTICE "%s (%s) Loaded\n", version, WLAN_BUILD_DATE);
#endif
p80211netdev_startup();
#ifdef CONFIG_HOTPLUG
p80211_run_sbin_hotplug(NULL, WLAN_HOTPLUG_STARTUP);
#endif
DBFEXIT;
return 0;
}
/*----------------------------------------------------------------
* cleanup_module
*
* Called at module unload time. This is our last chance to
* clean up after ourselves.
*
* Arguments:
* none
*
* Returns:
* nothing
*
* Side effects:
* TODO: define
*
* Call context:
* process thread
*
----------------------------------------------------------------*/
void cleanup_module(void)
{
DBFENTER;
#ifdef CONFIG_HOTPLUG
p80211_run_sbin_hotplug(NULL, WLAN_HOTPLUG_SHUTDOWN);
#endif
p80211netdev_shutdown();
printk(KERN_NOTICE "%s Unloaded\n", version);
DBFEXIT;
return;
}
EXPORT_SYMBOL(p80211netdev_hwremoved);
EXPORT_SYMBOL(register_wlandev);
EXPORT_SYMBOL(p80211netdev_rx);
EXPORT_SYMBOL(unregister_wlandev);
EXPORT_SYMBOL(wlan_setup);
EXPORT_SYMBOL(wlan_unsetup);
EXPORT_SYMBOL(p80211_suspend);
EXPORT_SYMBOL(p80211_resume);
EXPORT_SYMBOL(p80211skb_free);
EXPORT_SYMBOL(p80211skb_rxmeta_attach);
EXPORT_SYMBOL(p80211wext_event_associated);

View File

@ -0,0 +1,102 @@
/* p80211msg.h
*
* Macros, constants, types, and funcs for req and ind messages
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
#ifndef _P80211MSG_H
#define _P80211MSG_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/* Project Includes */
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
#define MSG_BUFF_LEN 4000
#define WLAN_DEVNAMELEN_MAX 16
/*================================================================*/
/* Macros */
/*================================================================*/
/* Types */
/*--------------------------------------------------------------------*/
/*----- Message Structure Types --------------------------------------*/
/*--------------------------------------------------------------------*/
/* Prototype msg type */
typedef struct p80211msg
{
UINT32 msgcode;
UINT32 msglen;
UINT8 devname[WLAN_DEVNAMELEN_MAX];
} __WLAN_ATTRIB_PACK__ p80211msg_t;
typedef struct p80211msgd
{
UINT32 msgcode;
UINT32 msglen;
UINT8 devname[WLAN_DEVNAMELEN_MAX];
UINT8 args[0];
} __WLAN_ATTRIB_PACK__ p80211msgd_t;
/*================================================================*/
/* Extern Declarations */
/*================================================================*/
/* Function Declarations */
#endif /* _P80211MSG_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,336 @@
/* p80211netdev.h
*
* WLAN net device structure and functions
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares the structure type that represents each wlan
* interface.
*
* --------------------------------------------------------------------
*/
#ifndef _LINUX_P80211NETDEV_H
#define _LINUX_P80211NETDEV_H
#include <linux/interrupt.h>
#include <linux/wireless.h>
/*================================================================*/
/* Constants */
#define WLAN_DEVICE_CLOSED 0
#define WLAN_DEVICE_OPEN 1
#define WLAN_MACMODE_NONE 0
#define WLAN_MACMODE_IBSS_STA 1
#define WLAN_MACMODE_ESS_STA 2
#define WLAN_MACMODE_ESS_AP 3
/* MSD States */
#define WLAN_MSD_START -1
#define WLAN_MSD_DRIVERLOADED 0
#define WLAN_MSD_HWPRESENT_PENDING 1
#define WLAN_MSD_HWFAIL 2
#define WLAN_MSD_HWPRESENT 3
#define WLAN_MSD_FWLOAD_PENDING 4
#define WLAN_MSD_FWLOAD 5
#define WLAN_MSD_RUNNING_PENDING 6
#define WLAN_MSD_RUNNING 7
#ifndef ETH_P_ECONET
#define ETH_P_ECONET 0x0018 /* needed for 2.2.x kernels */
#endif
#define ETH_P_80211_RAW (ETH_P_ECONET + 1)
#ifndef ARPHRD_IEEE80211
#define ARPHRD_IEEE80211 801 /* kernel 2.4.6 */
#endif
#ifndef ARPHRD_IEEE80211_PRISM /* kernel 2.4.18 */
#define ARPHRD_IEEE80211_PRISM 802
#endif
/*--- NSD Capabilities Flags ------------------------------*/
#define P80211_NSDCAP_HARDWAREWEP 0x01 /* hardware wep engine */
#define P80211_NSDCAP_TIEDWEP 0x02 /* can't decouple en/de */
#define P80211_NSDCAP_NOHOSTWEP 0x04 /* must use hardware wep */
#define P80211_NSDCAP_PBCC 0x08 /* hardware supports PBCC */
#define P80211_NSDCAP_SHORT_PREAMBLE 0x10 /* hardware supports */
#define P80211_NSDCAP_AGILITY 0x20 /* hardware supports */
#define P80211_NSDCAP_AP_RETRANSMIT 0x40 /* nsd handles retransmits */
#define P80211_NSDCAP_HWFRAGMENT 0x80 /* nsd handles frag/defrag */
#define P80211_NSDCAP_AUTOJOIN 0x100 /* nsd does autojoin */
#define P80211_NSDCAP_NOSCAN 0x200 /* nsd can scan */
/*================================================================*/
/* Macros */
/*================================================================*/
/* Types */
/* Received frame statistics */
typedef struct p80211_frmrx_t
{
UINT32 mgmt;
UINT32 assocreq;
UINT32 assocresp;
UINT32 reassocreq;
UINT32 reassocresp;
UINT32 probereq;
UINT32 proberesp;
UINT32 beacon;
UINT32 atim;
UINT32 disassoc;
UINT32 authen;
UINT32 deauthen;
UINT32 mgmt_unknown;
UINT32 ctl;
UINT32 pspoll;
UINT32 rts;
UINT32 cts;
UINT32 ack;
UINT32 cfend;
UINT32 cfendcfack;
UINT32 ctl_unknown;
UINT32 data;
UINT32 dataonly;
UINT32 data_cfack;
UINT32 data_cfpoll;
UINT32 data__cfack_cfpoll;
UINT32 null;
UINT32 cfack;
UINT32 cfpoll;
UINT32 cfack_cfpoll;
UINT32 data_unknown;
UINT32 decrypt;
UINT32 decrypt_err;
} p80211_frmrx_t;
#ifdef WIRELESS_EXT
/* called by /proc/net/wireless */
struct iw_statistics* p80211wext_get_wireless_stats(netdevice_t *dev);
/* wireless extensions' ioctls */
int p80211wext_support_ioctl(netdevice_t *dev, struct ifreq *ifr, int cmd);
#if WIRELESS_EXT > 12
extern struct iw_handler_def p80211wext_handler_def;
#endif
int p80211wext_event_associated(struct wlandevice *wlandev, int assoc);
#endif /* wireless extensions */
/* WEP stuff */
#define NUM_WEPKEYS 4
#define MAX_KEYLEN 32
#define HOSTWEP_DEFAULTKEY_MASK (BIT1|BIT0)
#define HOSTWEP_DECRYPT BIT4
#define HOSTWEP_ENCRYPT BIT5
#define HOSTWEP_PRIVACYINVOKED BIT6
#define HOSTWEP_EXCLUDEUNENCRYPTED BIT7
extern int wlan_watchdog;
extern int wlan_wext_write;
/* WLAN device type */
typedef struct wlandevice
{
struct wlandevice *next; /* link for list of devices */
void *priv; /* private data for MSD */
/* Subsystem State */
char name[WLAN_DEVNAMELEN_MAX]; /* Dev name, from register_wlandev()*/
char *nsdname;
UINT32 state; /* Device I/F state (open/closed) */
UINT32 msdstate; /* state of underlying driver */
UINT32 hwremoved; /* Has the hw been yanked out? */
/* Hardware config */
UINT irq;
UINT iobase;
UINT membase;
UINT32 nsdcaps; /* NSD Capabilities flags */
/* Config vars */
UINT ethconv;
/* device methods (init by MSD, used by p80211 */
int (*open)(struct wlandevice *wlandev);
int (*close)(struct wlandevice *wlandev);
void (*reset)(struct wlandevice *wlandev );
int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, p80211_hdr_t *p80211_hdr, p80211_metawep_t *p80211_wep);
int (*mlmerequest)(struct wlandevice *wlandev, p80211msg_t *msg);
int (*set_multicast_list)(struct wlandevice *wlandev,
netdevice_t *dev);
void (*tx_timeout)(struct wlandevice *wlandev);
#ifdef CONFIG_PROC_FS
int (*nsd_proc_read)(char *page, char **start, off_t offset, int count, int *eof, void *data);
#endif
/* 802.11 State */
UINT8 bssid[WLAN_BSSID_LEN];
p80211pstr32_t ssid;
UINT32 macmode;
int linkstatus;
int shortpreamble; /* C bool */
/* WEP State */
UINT8 wep_keys[NUM_WEPKEYS][MAX_KEYLEN];
UINT8 wep_keylens[NUM_WEPKEYS];
int hostwep;
/* Request/Confirm i/f state (used by p80211) */
unsigned long request_pending; /* flag, access atomically */
/* netlink socket */
/* queue for indications waiting for cmd completion */
/* Linux netdevice and support */
netdevice_t *netdev; /* ptr to linux netdevice */
struct net_device_stats linux_stats;
#ifdef CONFIG_PROC_FS
/* Procfs support */
struct proc_dir_entry *procdir;
struct proc_dir_entry *procwlandev;
#endif
/* Rx bottom half */
struct tasklet_struct rx_bh;
struct sk_buff_head nsd_rxq;
/* 802.11 device statistics */
struct p80211_frmrx_t rx;
/* compatibility to wireless extensions */
#ifdef WIRELESS_EXT
struct iw_statistics wstats;
/* jkriegl: iwspy fields */
UINT8 spy_number;
char spy_address[IW_MAX_SPY][ETH_ALEN];
struct iw_quality spy_stat[IW_MAX_SPY];
#endif
} wlandevice_t;
/* WEP stuff */
int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen);
int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv);
int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv);
/*================================================================*/
/* Externs */
/*================================================================*/
/* Function Declarations */
void p80211netdev_startup(void);
void p80211netdev_shutdown(void);
int wlan_setup(wlandevice_t *wlandev);
int wlan_unsetup(wlandevice_t *wlandev);
int register_wlandev(wlandevice_t *wlandev);
int unregister_wlandev(wlandevice_t *wlandev);
void p80211netdev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
void p80211netdev_hwremoved(wlandevice_t *wlandev);
void p80211_suspend(wlandevice_t *wlandev);
void p80211_resume(wlandevice_t *wlandev);
/*================================================================*/
/* Function Definitions */
static inline void
p80211netdev_stop_queue(wlandevice_t *wlandev)
{
if ( !wlandev ) return;
if ( !wlandev->netdev ) return;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 1;
wlandev->netdev->start = 0;
#else
netif_stop_queue(wlandev->netdev);
#endif
}
static inline void
p80211netdev_start_queue(wlandevice_t *wlandev)
{
if ( !wlandev ) return;
if ( !wlandev->netdev ) return;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 0;
wlandev->netdev->start = 1;
#else
netif_start_queue(wlandev->netdev);
#endif
}
static inline void
p80211netdev_wake_queue(wlandevice_t *wlandev)
{
if ( !wlandev ) return;
if ( !wlandev->netdev ) return;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 0;
mark_bh(NET_BH);
#else
netif_wake_queue(wlandev->netdev);
#endif
}
#ifdef CONFIG_HOTPLUG
#define WLAN_HOTPLUG_REGISTER "register"
#define WLAN_HOTPLUG_REMOVE "remove"
#define WLAN_HOTPLUG_STARTUP "startup"
#define WLAN_HOTPLUG_SHUTDOWN "shutdown"
#define WLAN_HOTPLUG_SUSPEND "suspend"
#define WLAN_HOTPLUG_RESUME "resume"
int p80211_run_sbin_hotplug(wlandevice_t *wlandev, char *action);
#endif
#endif

View File

@ -0,0 +1,329 @@
/* src/p80211/p80211req.c
*
* Request/Indication/MacMgmt interface handling functions
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file contains the functions, types, and macros to support the
* MLME request interface that's implemented via the device ioctls.
*
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
#include <linux/version.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/types.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
#include <linux/wireless.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <net/sock.h>
#include <linux/netlink.h>
#include "version.h"
#include "wlan_compat.h"
/*================================================================*/
/* Project Includes */
#include "p80211types.h"
#include "p80211hdr.h"
#include "p80211mgmt.h"
#include "p80211conv.h"
#include "p80211msg.h"
#include "p80211netdev.h"
#include "p80211ioctl.h"
#include "p80211metadef.h"
#include "p80211metastruct.h"
#include "p80211req.h"
/*================================================================*/
/* Local Constants */
/* Maximum amount of time we'll wait for a request to complete */
#define P80211REQ_MAXTIME 3*HZ /* 3 seconds */
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/
/* Local Static Definitions */
/*================================================================*/
/* Local Function Declarations */
static void p80211req_handlemsg( wlandevice_t *wlandev, p80211msg_t *msg);
static int p80211req_mibset_mibget(wlandevice_t *wlandev, p80211msg_dot11req_mibget_t *mib_msg, int isget);
/*================================================================*/
/* Function Definitions */
/*----------------------------------------------------------------
* p80211req_dorequest
*
* Handles an MLME reqest/confirm message.
*
* Arguments:
* wlandev WLAN device struct
* msgbuf Buffer containing a request message
*
* Returns:
* 0 on success, an errno otherwise
*
* Call context:
* Potentially blocks the caller, so it's a good idea to
* not call this function from an interrupt context.
----------------------------------------------------------------*/
int p80211req_dorequest( wlandevice_t *wlandev, UINT8 *msgbuf)
{
int result = 0;
p80211msg_t *msg = (p80211msg_t*)msgbuf;
DBFENTER;
/* Check to make sure the MSD is running */
if (
!((wlandev->msdstate == WLAN_MSD_HWPRESENT &&
msg->msgcode == DIDmsg_lnxreq_ifstate) ||
wlandev->msdstate == WLAN_MSD_RUNNING ||
wlandev->msdstate == WLAN_MSD_FWLOAD) ) {
return -ENODEV;
}
/* Check Permissions */
if (!capable(CAP_NET_ADMIN) &&
(msg->msgcode != DIDmsg_dot11req_mibget)) {
WLAN_LOG_ERROR("%s: only dot11req_mibget allowed for non-root.\n", wlandev->name);
return -EPERM;
}
/* Check for busy status */
if ( test_and_set_bit(1, &(wlandev->request_pending))) {
return -EBUSY;
}
/* Allow p80211 to look at msg and handle if desired. */
/* So far, all p80211 msgs are immediate, no waitq/timer necessary */
/* This may change. */
p80211req_handlemsg(wlandev, msg);
/* Pass it down to wlandev via wlandev->mlmerequest */
if ( wlandev->mlmerequest != NULL )
wlandev->mlmerequest(wlandev, msg);
clear_bit( 1, &(wlandev->request_pending));
DBFEXIT;
return result; /* if result==0, msg->status still may contain an err */
}
/*----------------------------------------------------------------
* p80211req_handlemsg
*
* p80211 message handler. Primarily looks for messages that
* belong to p80211 and then dispatches the appropriate response.
* TODO: we don't do anything yet. Once the linuxMIB is better
* defined we'll need a get/set handler.
*
* Arguments:
* wlandev WLAN device struct
* msg message structure
*
* Returns:
* nothing (any results are set in the status field of the msg)
*
* Call context:
* Process thread
----------------------------------------------------------------*/
static void p80211req_handlemsg( wlandevice_t *wlandev, p80211msg_t *msg)
{
DBFENTER;
switch (msg->msgcode) {
case DIDmsg_lnxreq_hostwep: {
p80211msg_lnxreq_hostwep_t *req = (p80211msg_lnxreq_hostwep_t*) msg;
wlandev->hostwep &= ~(HOSTWEP_DECRYPT|HOSTWEP_ENCRYPT);
if (req->decrypt.data == P80211ENUM_truth_true)
wlandev->hostwep |= HOSTWEP_DECRYPT;
if (req->encrypt.data == P80211ENUM_truth_true)
wlandev->hostwep |= HOSTWEP_ENCRYPT;
break;
}
case DIDmsg_dot11req_mibget:
case DIDmsg_dot11req_mibset: {
int isget = (msg->msgcode == DIDmsg_dot11req_mibget);
p80211msg_dot11req_mibget_t *mib_msg = (p80211msg_dot11req_mibget_t *) msg;
p80211req_mibset_mibget (wlandev, mib_msg, isget);
}
default:
// XXX do nothing!
;
} /* switch msg->msgcode */
DBFEXIT;
return;
}
static int p80211req_mibset_mibget(wlandevice_t *wlandev,
p80211msg_dot11req_mibget_t *mib_msg,
int isget)
{
p80211itemd_t *mibitem = (p80211itemd_t *) mib_msg->mibattribute.data;
p80211pstrd_t *pstr = (p80211pstrd_t*) mibitem->data;
UINT8 *key = mibitem->data + sizeof(p80211pstrd_t);
DBFENTER;
switch (mibitem->did) {
case DIDmib_dot11smt_p80211Table_p80211_ifstate: {
UINT32 *data = (UINT32 *) mibitem->data;
if (isget)
switch (wlandev->msdstate) {
case WLAN_MSD_HWPRESENT:
*data = P80211ENUM_ifstate_disable;
break;
case WLAN_MSD_FWLOAD:
*data = P80211ENUM_ifstate_fwload;
break;
case WLAN_MSD_RUNNING:
*data = P80211ENUM_ifstate_enable;
break;
default:
*data = P80211ENUM_ifstate_enable;
}
break;
}
case DIDmib_dot11phy_dot11PhyOperationTable_dot11ShortPreambleEnabled: {
UINT32 *data = (UINT32 *) mibitem->data;
if (isget)
*data = wlandev->shortpreamble;
else
wlandev->shortpreamble = *data;
break;
}
case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey0: {
if (!isget)
wep_change_key(wlandev, 0, key, pstr->len);
break;
}
case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey1: {
if (!isget)
wep_change_key(wlandev, 1, key, pstr->len);
break;
}
case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey2: {
if (!isget)
wep_change_key(wlandev, 2, key, pstr->len);
break;
}
case DIDmib_dot11smt_dot11WEPDefaultKeysTable_dot11WEPDefaultKey3: {
if (!isget)
wep_change_key(wlandev, 3, key, pstr->len);
break;
}
case DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID: {
UINT32 *data = (UINT32 *) mibitem->data;
if (isget) {
*data = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
} else {
wlandev->hostwep &= ~(HOSTWEP_DEFAULTKEY_MASK);
wlandev->hostwep |= (*data & HOSTWEP_DEFAULTKEY_MASK);
}
break;
}
case DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked: {
UINT32 *data = (UINT32 *) mibitem->data;
if (isget) {
if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
*data = P80211ENUM_truth_true;
else
*data = P80211ENUM_truth_false;
} else {
wlandev->hostwep &= ~(HOSTWEP_PRIVACYINVOKED);
if (*data == P80211ENUM_truth_true)
wlandev->hostwep |= HOSTWEP_PRIVACYINVOKED;
}
break;
}
case DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted: {
UINT32 *data = (UINT32 *) mibitem->data;
if (isget) {
if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
*data = P80211ENUM_truth_true;
else
*data = P80211ENUM_truth_false;
} else {
wlandev->hostwep &= ~(HOSTWEP_EXCLUDEUNENCRYPTED);
if (*data == P80211ENUM_truth_true)
wlandev->hostwep |= HOSTWEP_EXCLUDEUNENCRYPTED;
}
break;
}
default:
// XXXX do nothing!
;
}
DBFEXIT;
return 0;
}

View File

@ -0,0 +1,68 @@
/* p80211req.h
*
* Request handling functions
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
#ifndef _LINUX_P80211REQ_H
#define _LINUX_P80211REQ_H
/*================================================================*/
/* Constants */
/*================================================================*/
/* Macros */
/*================================================================*/
/* Types */
/*================================================================*/
/* Externs */
/*================================================================*/
/* Function Declarations */
int p80211req_dorequest(wlandevice_t *wlandev, UINT8 *msgbuf);
#endif

View File

@ -0,0 +1,675 @@
/* p80211types.h
*
* Macros, constants, types, and funcs for p80211 data types
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file declares some of the constants and types used in various
* parts of the linux-wlan system.
*
* Notes:
* - Constant values are always in HOST byte order.
*
* All functions and statics declared here are implemented in p80211types.c
* --------------------------------------------------------------------
*/
#ifndef _P80211TYPES_H
#define _P80211TYPES_H
/*================================================================*/
/* System Includes */
/*================================================================*/
/*================================================================*/
/* Project Includes */
/*================================================================*/
#ifndef _WLAN_COMPAT_H
#include "wlan_compat.h"
#endif
/*================================================================*/
/* Constants */
/*================================================================*/
/*----------------------------------------------------------------*/
/* p80211 data type codes used for MIB items and message */
/* arguments. The various metadata structures provide additional */
/* information about these types. */
#define P80211_TYPE_OCTETSTR 1 /* pascal array of bytes */
#define P80211_TYPE_DISPLAYSTR 2 /* pascal array of bytes containing ascii */
#define P80211_TYPE_INT 4 /* UINT32 min and max limited by 32 bits */
#define P80211_TYPE_ENUMINT 5 /* UINT32 holding a numeric
code that can be mapped
to a textual name */
#define P80211_TYPE_UNKDATA 6 /* Data item containing an
unknown data type */
#define P80211_TYPE_INTARRAY 7 /* Array of 32-bit integers. */
#define P80211_TYPE_BITARRAY 8 /* Array of bits. */
#define P80211_TYPE_MACARRAY 9 /* Array of MAC addresses. */
/*----------------------------------------------------------------*/
/* The following constants are indexes into the Mib Category List */
/* and the Message Category List */
/* Mib Category List */
#define P80211_MIB_CAT_DOT11SMT 1
#define P80211_MIB_CAT_DOT11MAC 2
#define P80211_MIB_CAT_DOT11PHY 3
#define P80211SEC_DOT11SMT P80211_MIB_CAT_DOT11SMT
#define P80211SEC_DOT11MAC P80211_MIB_CAT_DOT11MAC
#define P80211SEC_DOT11PHY P80211_MIB_CAT_DOT11PHY
/* Message Category List */
#define P80211_MSG_CAT_DOT11REQ 1
#define P80211_MSG_CAT_DOT11IND 2
/* #define P80211_MSG_CAT_DOT11CFM 3 (doesn't exist at this time) */
#define P80211SEC_DOT11REQ P80211_MSG_CAT_DOT11REQ
#define P80211SEC_DOT11IND P80211_MSG_CAT_DOT11IND
/* #define P80211SEC_DOT11CFM P80211_MSG_CAT_DOT11CFM (doesn't exist at this time */
/*----------------------------------------------------------------*/
/* p80211 DID field codes that represent access type and */
/* is_table status. */
#define P80211DID_ACCESS_READ 0x10000000
#define P80211DID_ACCESS_WRITE 0x08000000
#define P80211DID_WRITEONLY 0x00000001
#define P80211DID_READONLY 0x00000002
#define P80211DID_READWRITE 0x00000003
#define P80211DID_ISTABLE_FALSE 0
#define P80211DID_ISTABLE_TRUE 1
/*----------------------------------------------------------------*/
/* p80211 enumeration constants. The value to text mappings for */
/* these is in p80211types.c. These defines were generated */
/* from the mappings. */
/* error codes for lookups */
#define P80211ENUM_BAD 0xffffffffUL
#define P80211ENUM_BADSTR "P80211ENUM_BAD"
#define P80211ENUM_truth_false 0
#define P80211ENUM_truth_true 1
#define P80211ENUM_ifstate_disable 0
#define P80211ENUM_ifstate_fwload 1
#define P80211ENUM_ifstate_enable 2
#define P80211ENUM_powermgmt_active 1
#define P80211ENUM_powermgmt_powersave 2
#define P80211ENUM_bsstype_infrastructure 1
#define P80211ENUM_bsstype_independent 2
#define P80211ENUM_bsstype_any 3
#define P80211ENUM_authalg_opensystem 1
#define P80211ENUM_authalg_sharedkey 2
#define P80211ENUM_phytype_fhss 1
#define P80211ENUM_phytype_dsss 2
#define P80211ENUM_phytype_irbaseband 3
#define P80211ENUM_temptype_commercial 1
#define P80211ENUM_temptype_industrial 2
#define P80211ENUM_regdomain_fcc 16
#define P80211ENUM_regdomain_doc 32
#define P80211ENUM_regdomain_etsi 48
#define P80211ENUM_regdomain_spain 49
#define P80211ENUM_regdomain_france 50
#define P80211ENUM_regdomain_mkk 64
#define P80211ENUM_ccamode_edonly 1
#define P80211ENUM_ccamode_csonly 2
#define P80211ENUM_ccamode_edandcs 4
#define P80211ENUM_ccamode_cswithtimer 8
#define P80211ENUM_ccamode_hrcsanded 16
#define P80211ENUM_diversity_fixedlist 1
#define P80211ENUM_diversity_notsupported 2
#define P80211ENUM_diversity_dynamic 3
#define P80211ENUM_scantype_active 1
#define P80211ENUM_scantype_passive 2
#define P80211ENUM_scantype_both 3
#define P80211ENUM_resultcode_success 1
#define P80211ENUM_resultcode_invalid_parameters 2
#define P80211ENUM_resultcode_not_supported 3
#define P80211ENUM_resultcode_timeout 4
#define P80211ENUM_resultcode_too_many_req 5
#define P80211ENUM_resultcode_refused 6
#define P80211ENUM_resultcode_bss_already 7
#define P80211ENUM_resultcode_invalid_access 8
#define P80211ENUM_resultcode_invalid_mibattribute 9
#define P80211ENUM_resultcode_cant_set_readonly_mib 10
#define P80211ENUM_resultcode_implementation_failure 11
#define P80211ENUM_resultcode_cant_get_writeonly_mib 12
#define P80211ENUM_reason_unspec_reason 1
#define P80211ENUM_reason_auth_not_valid 2
#define P80211ENUM_reason_deauth_lv_ss 3
#define P80211ENUM_reason_inactivity 4
#define P80211ENUM_reason_ap_overload 5
#define P80211ENUM_reason_class23_err 6
#define P80211ENUM_reason_class3_err 7
#define P80211ENUM_reason_disas_lv_ss 8
#define P80211ENUM_reason_asoc_not_auth 9
#define P80211ENUM_status_successful 0
#define P80211ENUM_status_unspec_failure 1
#define P80211ENUM_status_unsup_cap 10
#define P80211ENUM_status_reasoc_no_asoc 11
#define P80211ENUM_status_fail_other 12
#define P80211ENUM_status_unspt_alg 13
#define P80211ENUM_status_auth_seq_fail 14
#define P80211ENUM_status_chlng_fail 15
#define P80211ENUM_status_auth_timeout 16
#define P80211ENUM_status_ap_full 17
#define P80211ENUM_status_unsup_rate 18
#define P80211ENUM_status_unsup_shortpreamble 19
#define P80211ENUM_status_unsup_pbcc 20
#define P80211ENUM_status_unsup_agility 21
#define P80211ENUM_msgitem_status_data_ok 0
#define P80211ENUM_msgitem_status_no_value 1
#define P80211ENUM_msgitem_status_invalid_itemname 2
#define P80211ENUM_msgitem_status_invalid_itemdata 3
#define P80211ENUM_msgitem_status_missing_itemdata 4
#define P80211ENUM_msgitem_status_incomplete_itemdata 5
#define P80211ENUM_msgitem_status_invalid_msg_did 6
#define P80211ENUM_msgitem_status_invalid_mib_did 7
#define P80211ENUM_msgitem_status_missing_conv_func 8
#define P80211ENUM_msgitem_status_string_too_long 9
#define P80211ENUM_msgitem_status_data_out_of_range 10
#define P80211ENUM_msgitem_status_string_too_short 11
#define P80211ENUM_msgitem_status_missing_valid_func 12
#define P80211ENUM_msgitem_status_unknown 13
#define P80211ENUM_msgitem_status_invalid_did 14
#define P80211ENUM_msgitem_status_missing_print_func 15
#define P80211ENUM_lnxroam_reason_unknown 0
#define P80211ENUM_lnxroam_reason_beacon 1
#define P80211ENUM_lnxroam_reason_signal 2
#define P80211ENUM_lnxroam_reason_txretry 3
#define P80211ENUM_lnxroam_reason_notjoined 4
#define P80211ENUM_p2preamble_long 0
#define P80211ENUM_p2preamble_short 2
#define P80211ENUM_p2preamble_mixed 3
/*----------------------------------------------------------------*/
/* p80211 max length constants for the different pascal strings. */
#define MAXLEN_PSTR6 (6) /* pascal array of 6 bytes */
#define MAXLEN_PSTR14 (14) /* pascal array of 14 bytes */
#define MAXLEN_PSTR32 (32) /* pascal array of 32 bytes */
#define MAXLEN_PSTR255 (255) /* pascal array of 255 bytes */
#define MAXLEN_MIBATTRIBUTE (392) /* maximum mibattribute */
/* where the size of the DATA itself */
/* is a DID-LEN-DATA triple */
/* with a max size of 4+4+384 */
#define P80211_SET_INT(item, value) do { \
(item).data = (value); \
(item).status = P80211ENUM_msgitem_status_data_ok; \
} while(0)
/*----------------------------------------------------------------*/
/* string constants */
#define NOT_SET "NOT_SET"
#define NOT_SUPPORTED "NOT_SUPPORTED"
#define UNKNOWN_DATA "UNKNOWN_DATA"
/*--------------------------------------------------------------------*/
/* Metadata flags */
/* MSM: Do these belong in p80211meta.h? I'm not sure. */
#define ISREQUIRED (0x80000000UL)
#define ISREQUEST (0x40000000UL)
#define ISCONFIRM (0x20000000UL)
/*================================================================*/
/* Macros */
/*--------------------------------------------------------------------*/
/* The following macros are used to manipulate the 'flags' field in */
/* the metadata. These are only used when the metadata is for */
/* command arguments to determine if the data item is required, and */
/* whether the metadata item is for a request command, confirm */
/* command or both. */
/*--------------------------------------------------------------------*/
/* MSM: Do these belong in p80211meta.h? I'm not sure */
#define P80211ITEM_SETFLAGS(q, r, c) ( q | r | c )
#define P80211ITEM_ISREQUIRED(flags) (((UINT32)(flags & ISREQUIRED)) >> 31 )
#define P80211ITEM_ISREQUEST(flags) (((UINT32)(flags & ISREQUEST)) >> 30 )
#define P80211ITEM_ISCONFIRM(flags) (((UINT32)(flags & ISCONFIRM)) >> 29 )
/*----------------------------------------------------------------*/
/* The following macro creates a name for an enum */
#define MKENUMNAME(name) p80211enum_ ## name
/*----------------------------------------------------------------
* The following constants and macros are used to construct and
* deconstruct the Data ID codes. The coding is as follows:
*
* ...rwtnnnnnnnniiiiiiggggggssssss s - Section
* g - Group
* i - Item
* n - Index
* t - Table flag
* w - Write flag
* r - Read flag
* . - Unused
*/
#define P80211DID_INVALID 0xffffffffUL
#define P80211DID_VALID 0x00000000UL
#define P80211DID_LSB_SECTION (0)
#define P80211DID_LSB_GROUP (6)
#define P80211DID_LSB_ITEM (12)
#define P80211DID_LSB_INDEX (18)
#define P80211DID_LSB_ISTABLE (26)
#define P80211DID_LSB_ACCESS (27)
#define P80211DID_MASK_SECTION (0x0000003fUL)
#define P80211DID_MASK_GROUP (0x0000003fUL)
#define P80211DID_MASK_ITEM (0x0000003fUL)
#define P80211DID_MASK_INDEX (0x000000ffUL)
#define P80211DID_MASK_ISTABLE (0x00000001UL)
#define P80211DID_MASK_ACCESS (0x00000003UL)
#define P80211DID_MK(a,m,l) ((((UINT32)(a)) & (m)) << (l))
#define P80211DID_MKSECTION(a) P80211DID_MK(a, \
P80211DID_MASK_SECTION, \
P80211DID_LSB_SECTION )
#define P80211DID_MKGROUP(a) P80211DID_MK(a, \
P80211DID_MASK_GROUP, \
P80211DID_LSB_GROUP )
#define P80211DID_MKITEM(a) P80211DID_MK(a, \
P80211DID_MASK_ITEM, \
P80211DID_LSB_ITEM )
#define P80211DID_MKINDEX(a) P80211DID_MK(a, \
P80211DID_MASK_INDEX, \
P80211DID_LSB_INDEX )
#define P80211DID_MKISTABLE(a) P80211DID_MK(a, \
P80211DID_MASK_ISTABLE, \
P80211DID_LSB_ISTABLE )
#define P80211DID_MKID(s,g,i,n,t,a) (P80211DID_MKSECTION(s) | \
P80211DID_MKGROUP(g) | \
P80211DID_MKITEM(i) | \
P80211DID_MKINDEX(n) | \
P80211DID_MKISTABLE(t) | \
(a) )
#define P80211DID_GET(a,m,l) ((((UINT32)(a)) >> (l)) & (m))
#define P80211DID_SECTION(a) P80211DID_GET(a, \
P80211DID_MASK_SECTION, \
P80211DID_LSB_SECTION)
#define P80211DID_GROUP(a) P80211DID_GET(a, \
P80211DID_MASK_GROUP, \
P80211DID_LSB_GROUP)
#define P80211DID_ITEM(a) P80211DID_GET(a, \
P80211DID_MASK_ITEM, \
P80211DID_LSB_ITEM)
#define P80211DID_INDEX(a) P80211DID_GET(a, \
P80211DID_MASK_INDEX, \
P80211DID_LSB_INDEX)
#define P80211DID_ISTABLE(a) P80211DID_GET(a, \
P80211DID_MASK_ISTABLE, \
P80211DID_LSB_ISTABLE)
#define P80211DID_ACCESS(a) P80211DID_GET(a, \
P80211DID_MASK_ACCESS, \
P80211DID_LSB_ACCESS)
/*================================================================*/
/* Types */
/*----------------------------------------------------------------*/
/* The following structure types are used for the represenation */
/* of ENUMINT type metadata. */
typedef struct p80211enumpair
{
UINT32 val;
char *name;
} p80211enumpair_t;
typedef struct p80211enum
{
INT nitems;
p80211enumpair_t *list;
} p80211enum_t;
/*----------------------------------------------------------------*/
/* The following structure types are used to store data items in */
/* messages. */
/* Template pascal string */
typedef struct p80211pstr
{
UINT8 len;
} __WLAN_ATTRIB_PACK__ p80211pstr_t;
typedef struct p80211pstrd
{
UINT8 len;
UINT8 data[0];
} __WLAN_ATTRIB_PACK__ p80211pstrd_t;
/* Maximum pascal string */
typedef struct p80211pstr255
{
UINT8 len;
UINT8 data[MAXLEN_PSTR255];
} __WLAN_ATTRIB_PACK__ p80211pstr255_t;
/* pascal string for macaddress and bssid */
typedef struct p80211pstr6
{
UINT8 len;
UINT8 data[MAXLEN_PSTR6];
} __WLAN_ATTRIB_PACK__ p80211pstr6_t;
/* pascal string for channel list */
typedef struct p80211pstr14
{
UINT8 len;
UINT8 data[MAXLEN_PSTR14];
} __WLAN_ATTRIB_PACK__ p80211pstr14_t;
/* pascal string for ssid */
typedef struct p80211pstr32
{
UINT8 len;
UINT8 data[MAXLEN_PSTR32];
} __WLAN_ATTRIB_PACK__ p80211pstr32_t;
/* MAC address array */
typedef struct p80211macarray
{
UINT32 cnt;
UINT8 data[1][MAXLEN_PSTR6];
} __WLAN_ATTRIB_PACK__ p80211macarray_t;
/* prototype template */
typedef struct p80211item
{
UINT32 did;
UINT16 status;
UINT16 len;
} __WLAN_ATTRIB_PACK__ p80211item_t;
/* prototype template w/ data item */
typedef struct p80211itemd
{
UINT32 did;
UINT16 status;
UINT16 len;
UINT8 data[0];
} __WLAN_ATTRIB_PACK__ p80211itemd_t;
/* message data item for INT, BOUNDEDINT, ENUMINT */
typedef struct p80211item_uint32
{
UINT32 did;
UINT16 status;
UINT16 len;
UINT32 data;
} __WLAN_ATTRIB_PACK__ p80211item_uint32_t;
/* message data item for OCTETSTR, DISPLAYSTR */
typedef struct p80211item_pstr6
{
UINT32 did;
UINT16 status;
UINT16 len;
p80211pstr6_t data;
} __WLAN_ATTRIB_PACK__ p80211item_pstr6_t;
/* message data item for OCTETSTR, DISPLAYSTR */
typedef struct p80211item_pstr14
{
UINT32 did;
UINT16 status;
UINT16 len;
p80211pstr14_t data;
} __WLAN_ATTRIB_PACK__ p80211item_pstr14_t;
/* message data item for OCTETSTR, DISPLAYSTR */
typedef struct p80211item_pstr32
{
UINT32 did;
UINT16 status;
UINT16 len;
p80211pstr32_t data;
} __WLAN_ATTRIB_PACK__ p80211item_pstr32_t;
/* message data item for OCTETSTR, DISPLAYSTR */
typedef struct p80211item_pstr255
{
UINT32 did;
UINT16 status;
UINT16 len;
p80211pstr255_t data;
} __WLAN_ATTRIB_PACK__ p80211item_pstr255_t;
/* message data item for UNK 392, namely mib items */
typedef struct p80211item_unk392
{
UINT32 did;
UINT16 status;
UINT16 len;
UINT8 data[MAXLEN_MIBATTRIBUTE];
} __WLAN_ATTRIB_PACK__ p80211item_unk392_t;
/* message data item for UNK 1025, namely p2 pdas */
typedef struct p80211item_unk1024
{
UINT32 did;
UINT16 status;
UINT16 len;
UINT8 data[1024];
} __WLAN_ATTRIB_PACK__ p80211item_unk1024_t;
/* message data item for UNK 4096, namely p2 download chunks */
typedef struct p80211item_unk4096
{
UINT32 did;
UINT16 status;
UINT16 len;
UINT8 data[4096];
} __WLAN_ATTRIB_PACK__ p80211item_unk4096_t;
struct catlistitem;
/*----------------------------------------------------------------*/
/* The following structure type is used to represent all of the */
/* metadata items. Some components may choose to use more, */
/* less or different metadata items. */
typedef void (*p80211_totext_t)( struct catlistitem *, UINT32 did, UINT8* itembuf, char *textbuf);
typedef void (*p80211_fromtext_t)( struct catlistitem *, UINT32 did, UINT8* itembuf, char *textbuf);
typedef UINT32 (*p80211_valid_t)( struct catlistitem *, UINT32 did, UINT8* itembuf);
/*================================================================*/
/* Extern Declarations */
/*----------------------------------------------------------------*/
/* Enumeration Lists */
/* The following are the external declarations */
/* for all enumerations */
extern p80211enum_t MKENUMNAME(truth);
extern p80211enum_t MKENUMNAME(ifstate);
extern p80211enum_t MKENUMNAME(powermgmt);
extern p80211enum_t MKENUMNAME(bsstype);
extern p80211enum_t MKENUMNAME(authalg);
extern p80211enum_t MKENUMNAME(phytype);
extern p80211enum_t MKENUMNAME(temptype);
extern p80211enum_t MKENUMNAME(regdomain);
extern p80211enum_t MKENUMNAME(ccamode);
extern p80211enum_t MKENUMNAME(diversity);
extern p80211enum_t MKENUMNAME(scantype);
extern p80211enum_t MKENUMNAME(resultcode);
extern p80211enum_t MKENUMNAME(reason);
extern p80211enum_t MKENUMNAME(status);
extern p80211enum_t MKENUMNAME(msgcode);
extern p80211enum_t MKENUMNAME(msgitem_status);
extern p80211enum_t MKENUMNAME(lnxroam_reason);
extern p80211enum_t MKENUMNAME(p2preamble);
/*================================================================*/
/* Function Declarations */
/*----------------------------------------------------------------*/
/* The following declare some utility functions for use with the */
/* p80211enum_t type. */
UINT32 p80211enum_text2int(p80211enum_t *ep, char *text);
UINT32 p80211enum_int2text(p80211enum_t *ep, UINT32 val, char *text);
void p80211_error2text(int err_code, char *err_str);
/*----------------------------------------------------------------*/
/* The following declare some utility functions for use with the */
/* p80211item_t and p80211meta_t types. */
/*----------------------------------------------------------------*/
/* The following declare functions that perform validation and */
/* text to binary conversions based on the metadata for interface */
/* and MIB data items. */
/*----------------------------------------------------------------*/
/*-- DISPLAYSTR ------------------------------------------------------*/
/* pstr ==> cstr */
void p80211_totext_displaystr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* cstr ==> pstr */
void p80211_fromtext_displaystr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of a displaystr binary value */
UINT32 p80211_isvalid_displaystr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- OCTETSTR --------------------------------------------------------*/
/* pstr ==> "xx:xx:...." */
void p80211_totext_octetstr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* "xx:xx:...." ==> pstr */
void p80211_fromtext_octetstr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of an octetstr binary value */
UINT32 p80211_isvalid_octetstr( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- INT -------------------------------------------------------------*/
/* UINT32 ==> %d */
void p80211_totext_int( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* %d ==> UINT32 */
void p80211_fromtext_int( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of an int's binary value (always successful) */
UINT32 p80211_isvalid_int( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- ENUMINT ---------------------------------------------------------*/
/* UINT32 ==> <valuename> */
void p80211_totext_enumint( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* <valuename> ==> UINT32 */
void p80211_fromtext_enumint( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of an enum's binary value */
UINT32 p80211_isvalid_enumint( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- INTARRAY --------------------------------------------------------*/
/* UINT32[] => %d,%d,%d,... */
void p80211_totext_intarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* %d,%d,%d,... ==> UINT32[] */
void p80211_fromtext_intarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of an integer array's value */
UINT32 p80211_isvalid_intarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- BITARRAY --------------------------------------------------------*/
/* UINT32 ==> %d,%d,%d,... */
void p80211_totext_bitarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* %d,%d,%d,... ==> UINT32 */
void p80211_fromtext_bitarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of a bit array's value */
UINT32 p80211_isvalid_bitarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- MACARRAY --------------------------------------------------------*/
void p80211_totext_macarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
void p80211_fromtext_macarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of a MAC address array's value */
UINT32 p80211_isvalid_macarray( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
/*-- MIBATTRIUBTE ------------------------------------------------------*/
/* <mibvalue> ==> <textual representation identified in MIB metadata> */
void p80211_totext_getmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
void p80211_totext_setmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* <textual representation identified in MIB metadata> ==> <mibvalue> */
void p80211_fromtext_getmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
void p80211_fromtext_setmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf, char *textbuf );
/* function that checks validity of a mibitem's binary value */
UINT32 p80211_isvalid_getmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
UINT32 p80211_isvalid_setmibattribute( struct catlistitem *metalist, UINT32 did, UINT8 *itembuf );
#endif /* _P80211TYPES_H */

View File

@ -0,0 +1,317 @@
/* src/p80211/p80211wep.c
*
* WEP encode/decode for P80211.
*
* Copyright (C) 2002 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
/*================================================================*/
/* System Includes */
#include <linux/version.h>
#include <linux/netdevice.h>
#include <linux/wireless.h>
#include <linux/slab.h>
#include <linux/random.h>
#include "version.h"
#include "wlan_compat.h"
// #define WEP_DEBUG
/*================================================================*/
/* Project Includes */
#include "version.h"
#include "p80211hdr.h"
#include "p80211types.h"
#include "p80211msg.h"
#include "p80211conv.h"
#include "p80211netdev.h"
/*================================================================*/
/* Local Constants */
#define SSWAP(a,b) {UINT8 tmp = s[a]; s[a] = s[b]; s[b] = tmp;}
#define WEP_KEY(x) (((x) & 0xC0) >> 6)
/*================================================================*/
/* Local Macros */
/*================================================================*/
/* Local Types */
/*================================================================*/
/* Local Static Definitions */
static const UINT32 wep_crc32_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
/*================================================================*/
/* Local Function Declarations */
/*================================================================*/
/* Function Definitions */
/* keylen in bytes! */
int wep_change_key(wlandevice_t *wlandev, int keynum, UINT8* key, int keylen)
{
if (keylen < 0) return -1;
if (keylen >= MAX_KEYLEN) return -1;
if (key == NULL) return -1;
if (keynum < 0) return -1;
if (keynum >= NUM_WEPKEYS) return -1;
#ifdef WEP_DEBUG
printk(KERN_DEBUG "WEP key %d len %d = %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n", keynum, keylen, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
#endif
wlandev->wep_keylens[keynum] = keylen;
memcpy(wlandev->wep_keys[keynum], key, keylen);
return 0;
}
/*
4-byte IV at start of buffer, 4-byte ICV at end of buffer.
if successful, buf start is payload begin, length -= 8;
*/
int wep_decrypt(wlandevice_t *wlandev, UINT8 *buf, UINT32 len, int key_override, UINT8 *iv, UINT8 *icv)
{
UINT32 i, j, k, crc, keylen;
UINT8 s[256], key[64], c_crc[4];
UINT8 keyidx;
/* Needs to be at least 8 bytes of payload */
if (len <= 0) return -1;
/* initialize the first bytes of the key from the IV */
key[0] = iv[0];
key[1] = iv[1];
key[2] = iv[2];
keyidx = WEP_KEY(iv[3]);
if (key_override >= 0)
keyidx = key_override;
if (keyidx >= NUM_WEPKEYS) return -2;
keylen = wlandev->wep_keylens[keyidx];
if (keylen == 0) return -3;
/* copy the rest of the key over from the designated key */
memcpy(key+3, wlandev->wep_keys[keyidx], keylen);
keylen+=3; /* add in IV bytes */
#ifdef WEP_DEBUG
printk(KERN_DEBUG "D %d: %02x %02x %02x (%d %d) %02x:%02x:%02x:%02x:%02x\n", len, key[0], key[1], key[2], keyidx, keylen, key[3], key[4], key[5], key[6], key[7]);
#endif
/* set up the RC4 state */
for (i = 0; i < 256; i++)
s[i] = i;
j = 0;
for (i = 0; i < 256; i++) {
j = (j + s[i] + key[i % keylen]) & 0xff;
SSWAP(i,j);
}
/* Apply the RC4 to the data, update the CRC32 */
crc = ~0;
i = j = 0;
for (k = 0; k < len; k++) {
i = (i+1) & 0xff;
j = (j+s[i]) & 0xff;
SSWAP(i,j);
buf[k] ^= s[(s[i] + s[j]) & 0xff];
crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
}
crc = ~crc;
/* now let's check the crc */
c_crc[0] = crc;
c_crc[1] = crc >> 8;
c_crc[2] = crc >> 16;
c_crc[3] = crc >> 24;
for (k = 0; k < 4; k++) {
i = (i + 1) & 0xff;
j = (j+s[i]) & 0xff;
SSWAP(i,j);
if ((c_crc[k] ^ s[(s[i] + s[j]) & 0xff]) != icv[k])
return -(4 | (k << 4)) ; /* ICV mismatch */
}
return 0;
}
/* encrypts in-place. */
int wep_encrypt(wlandevice_t *wlandev, UINT8 *buf, UINT8 *dst, UINT32 len, int keynum, UINT8 *iv, UINT8 *icv)
{
UINT32 i, j, k, crc, keylen;
UINT8 s[256], key[64];
/* no point in WEPping an empty frame */
if (len <= 0) return -1;
/* we need to have a real key.. */
if (keynum >= NUM_WEPKEYS) return -2;
keylen = wlandev->wep_keylens[keynum];
if (keylen <= 0) return -3;
/* use a random IV. And skip known weak ones. */
get_random_bytes(iv, 3);
while ((iv[1] == 0xff) && (iv[0] >= 3) && (iv[0] < keylen))
get_random_bytes(iv, 3);
iv[3] = (keynum & 0x03) << 6;
key[0] = iv[0];
key[1] = iv[1];
key[2] = iv[2];
/* copy the rest of the key over from the designated key */
memcpy(key+3, wlandev->wep_keys[keynum], keylen);
keylen+=3; /* add in IV bytes */
#ifdef WEP_DEBUG
printk(KERN_DEBUG "E %d (%d/%d %d) %02x %02x %02x %02x:%02x:%02x:%02x:%02x\n", len, iv[3], keynum, keylen, key[0], key[1], key[2], key[3], key[4], key[5], key[6], key[7]);
#endif
/* set up the RC4 state */
for (i = 0; i < 256; i++)
s[i] = i;
j = 0;
for (i = 0; i < 256; i++) {
j = (j + s[i] + key[i % keylen]) & 0xff;
SSWAP(i,j);
}
/* Update CRC32 then apply RC4 to the data */
crc = ~0;
i = j = 0;
for (k = 0; k < len; k++) {
crc = wep_crc32_table[(crc ^ buf[k]) & 0xff] ^ (crc >> 8);
i = (i+1) & 0xff;
j = (j+s[i]) & 0xff;
SSWAP(i,j);
dst[k] = buf[k] ^ s[(s[i] + s[j]) & 0xff];
}
crc = ~crc;
/* now let's encrypt the crc */
icv[0] = crc;
icv[1] = crc >> 8;
icv[2] = crc >> 16;
icv[3] = crc >> 24;
for (k = 0; k < 4; k++) {
i = (i + 1) & 0xff;
j = (j+s[i]) & 0xff;
SSWAP(i,j);
icv[k] ^= s[(s[i] + s[j]) & 0xff];
}
return 0;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,332 @@
#define WLAN_HOSTIF WLAN_PCI
#include "hfa384x.c"
#include "prism2mgmt.c"
#include "prism2mib.c"
#include "prism2sta.c"
#define PCI_SIZE 0x1000 /* Memory size - 4K bytes */
/* ISL3874A 11Mb/s WLAN controller */
#define PCIVENDOR_INTERSIL 0x1260UL
#define PCIDEVICE_ISL3874 0x3873UL /* [MSM] yeah I know...the ID says
3873. Trust me, it's a 3874. */
/* Samsung SWL-2210P 11Mb/s WLAN controller (uses ISL3874A) */
#define PCIVENDOR_SAMSUNG 0x167dUL
#define PCIDEVICE_SWL_2210P 0xa000UL
#define PCIVENDOR_NETGEAR 0x1385UL /* for MA311 */
/* PCI Class & Sub-Class code, Network-'Other controller' */
#define PCI_CLASS_NETWORK_OTHERS 0x280
/*----------------------------------------------------------------
* prism2sta_probe_pci
*
* Probe routine called when a PCI device w/ matching ID is found.
* The ISL3874 implementation uses the following map:
* BAR0: Prism2.x registers memory mapped, size=4k
* Here's the sequence:
* - Allocate the PCI resources.
* - Read the PCMCIA attribute memory to make sure we have a WLAN card
* - Reset the MAC
* - Initialize the netdev and wlan data
* - Initialize the MAC
*
* Arguments:
* pdev ptr to pci device structure containing info about
* pci configuration.
* id ptr to the device id entry that matched this device.
*
* Returns:
* zero - success
* negative - failed
*
* Side effects:
*
*
* Call context:
* process thread
*
----------------------------------------------------------------*/
static int __devinit
prism2sta_probe_pci(
struct pci_dev *pdev,
const struct pci_device_id *id)
{
int result;
phys_t phymem = 0;
void __iomem *mem = NULL;
wlandevice_t *wlandev = NULL;
hfa384x_t *hw = NULL;
DBFENTER;
/* Enable the pci device */
if (pci_enable_device(pdev)) {
WLAN_LOG_ERROR("%s: pci_enable_device() failed.\n", dev_info);
result = -EIO;
goto fail;
}
/* Figure out our resources */
phymem = pci_resource_start(pdev, 0);
if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) {
printk(KERN_ERR "prism2: Cannot reserve PCI memory region\n");
result = -EIO;
goto fail;
}
mem = ioremap(phymem, PCI_SIZE);
if ( mem == 0 ) {
WLAN_LOG_ERROR("%s: ioremap() failed.\n", dev_info);
result = -EIO;
goto fail;
}
/* Log the device */
WLAN_LOG_INFO("A Prism2.5 PCI device found, "
"phymem:0x%llx, irq:%d, mem:0x%p\n",
(unsigned long long)phymem, pdev->irq, mem);
if ((wlandev = create_wlan()) == NULL) {
WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
result = -EIO;
goto fail;
}
hw = wlandev->priv;
if ( wlan_setup(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);
result = -EIO;
goto fail;
}
/* Setup netdevice's ability to report resources
* Note: the netdevice was allocated by wlan_setup()
*/
wlandev->netdev->irq = pdev->irq;
wlandev->netdev->mem_start = (unsigned long) mem;
wlandev->netdev->mem_end = wlandev->netdev->mem_start +
pci_resource_len(pdev, 0);
/* Initialize the hw data */
hfa384x_create(hw, wlandev->netdev->irq, 0, mem);
hw->wlandev = wlandev;
/* Register the wlandev, this gets us a name and registers the
* linux netdevice.
*/
SET_MODULE_OWNER(wlandev->netdev);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
SET_NETDEV_DEV(wlandev->netdev, &(pdev->dev));
#endif
if ( register_wlandev(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
result = -EIO;
goto fail;
}
#if 0
/* TODO: Move this and an irq test into an hfa384x_testif() routine.
*/
outw(PRISM2STA_MAGIC, HFA384x_SWSUPPORT(wlandev->netdev->base_addr));
reg=inw( HFA384x_SWSUPPORT(wlandev->netdev->base_addr));
if ( reg != PRISM2STA_MAGIC ) {
WLAN_LOG_ERROR("MAC register access test failed!\n");
result = -EIO;
goto fail;
}
#endif
/* Do a chip-level reset on the MAC */
if (prism2_doreset) {
result = hfa384x_corereset(hw,
prism2_reset_holdtime,
prism2_reset_settletime, 0);
if (result != 0) {
WLAN_LOG_ERROR(
"%s: hfa384x_corereset() failed.\n",
dev_info);
unregister_wlandev(wlandev);
hfa384x_destroy(hw);
result = -EIO;
goto fail;
}
}
pci_set_drvdata(pdev, wlandev);
/* Shouldn't actually hook up the IRQ until we
* _know_ things are alright. A test routine would help.
*/
request_irq(wlandev->netdev->irq, hfa384x_interrupt,
SA_SHIRQ, wlandev->name, wlandev);
wlandev->msdstate = WLAN_MSD_HWPRESENT;
result = 0;
goto done;
fail:
pci_set_drvdata(pdev, NULL);
if (wlandev) kfree(wlandev);
if (hw) kfree(hw);
if (mem) iounmap(mem);
pci_release_regions(pdev);
pci_disable_device(pdev);
done:
DBFEXIT;
return result;
}
static void __devexit prism2sta_remove_pci(struct pci_dev *pdev)
{
wlandevice_t *wlandev;
hfa384x_t *hw;
wlandev = (wlandevice_t *) pci_get_drvdata(pdev);
hw = wlandev->priv;
p80211netdev_hwremoved(wlandev);
/* reset hardware */
prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
if (pdev->irq)
free_irq(pdev->irq, wlandev);
unregister_wlandev(wlandev);
/* free local stuff */
if (hw) {
hfa384x_destroy(hw);
kfree(hw);
}
iounmap((void __iomem *)wlandev->netdev->mem_start);
wlan_unsetup(wlandev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
kfree(wlandev);
}
static struct pci_device_id pci_id_tbl[] = {
{
PCIVENDOR_INTERSIL, PCIDEVICE_ISL3874,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller"
},
{
PCIVENDOR_INTERSIL, 0x3872,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Intersil Prism2.5 ISL3872 11Mb/s WLAN Controller"
},
{
PCIVENDOR_SAMSUNG, PCIDEVICE_SWL_2210P,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Samsung MagicLAN SWL-2210P 11Mb/s WLAN Controller"
},
{ /* for NetGear MA311 */
PCIVENDOR_NETGEAR, 0x3872,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Netgear MA311 WLAN Controller"
},
{
0, 0, 0, 0, 0, 0, 0
}
};
MODULE_DEVICE_TABLE(pci, pci_id_tbl);
/* Function declared here because of ptr reference below */
static int __devinit prism2sta_probe_pci(struct pci_dev *pdev,
const struct pci_device_id *id);
static void __devexit prism2sta_remove_pci(struct pci_dev *pdev);
static struct pci_driver prism2_pci_drv_id = {
.name = "prism2_pci",
.id_table = pci_id_tbl,
.probe = prism2sta_probe_pci,
.remove = prism2sta_remove_pci,
#ifdef CONFIG_PM
.suspend = prism2sta_suspend_pci,
.resume = prism2sta_resume_pci,
#endif
};
#ifdef MODULE
static int __init prism2pci_init(void)
{
WLAN_LOG_NOTICE("%s Loaded\n", version);
return pci_module_init(&prism2_pci_drv_id);
};
static void __exit prism2pci_cleanup(void)
{
pci_unregister_driver(&prism2_pci_drv_id);
};
module_init(prism2pci_init);
module_exit(prism2pci_cleanup);
#endif
int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis)
{
int result = 0;
unsigned long timeout;
UINT16 reg;
DBFENTER;
/* Assert reset and wait awhile
* (note: these delays are _really_ long, but they appear to be
* necessary.)
*/
hfa384x_setreg(hw, 0xc5, HFA384x_PCICOR);
timeout = jiffies + HZ/4;
while(time_before(jiffies, timeout)) udelay(5);
if (genesis) {
hfa384x_setreg(hw, genesis, HFA384x_PCIHCR);
timeout = jiffies + HZ/4;
while(time_before(jiffies, timeout)) udelay(5);
}
/* Clear the reset and wait some more
*/
hfa384x_setreg(hw, 0x45, HFA384x_PCICOR);
timeout = jiffies + HZ/2;
while(time_before(jiffies, timeout)) udelay(5);
/* Wait for f/w to complete initialization (CMD:BUSY == 0)
*/
timeout = jiffies + 2*HZ;
reg = hfa384x_getreg(hw, HFA384x_CMD);
while ( HFA384x_CMD_ISBUSY(reg) && time_before( jiffies, timeout) ) {
reg = hfa384x_getreg(hw, HFA384x_CMD);
udelay(10);
}
if (HFA384x_CMD_ISBUSY(reg)) {
WLAN_LOG_WARNING("corereset: Timed out waiting for cmd register.\n");
result=1;
}
DBFEXIT;
return result;
}

View File

@ -0,0 +1,472 @@
#define WLAN_HOSTIF WLAN_PLX
#include "hfa384x.c"
#include "prism2mgmt.c"
#include "prism2mib.c"
#include "prism2sta.c"
#define PLX_ATTR_SIZE 0x1000 /* Attribute memory size - 4K bytes */
#define COR_OFFSET 0x3e0 /* COR attribute offset of Prism2 PC card */
#define COR_VALUE 0x41 /* Enable PC card with irq in level trigger */
#define PLX_INTCSR 0x4c /* Interrupt Control and Status Register */
#define PLX_INTCSR_INTEN (1<<6) /* Interrupt Enable bit */
#define PLX_MIN_ATTR_LEN 512 /* at least 2 x 256 is needed for CIS */
/* 3Com 3CRW777A (PLX) board ID */
#define PCIVENDOR_3COM 0x10B7
#define PCIDEVICE_AIRCONNECT 0x7770
/* Eumitcom PCI WL11000 PCI Adapter (PLX) board device+vendor ID */
#define PCIVENDOR_EUMITCOM 0x1638UL
#define PCIDEVICE_WL11000 0x1100UL
/* Global Sun Tech GL24110P PCI Adapter (PLX) board device+vendor ID */
#define PCIVENDOR_GLOBALSUN 0x16abUL
#define PCIDEVICE_GL24110P 0x1101UL
#define PCIDEVICE_GL24110P_ALT 0x1102UL
/* Netgear MA301 PCI Adapter (PLX) board device+vendor ID */
#define PCIVENDOR_NETGEAR 0x1385UL
#define PCIDEVICE_MA301 0x4100UL
/* US Robotics USR2410 PCI Adapter (PLX) board device+vendor ID */
#define PCIVENDOR_USROBOTICS 0x16ecUL
#define PCIDEVICE_USR2410 0x3685UL
/* Linksys WPC11 card with the WDT11 adapter (PLX) board device+vendor ID */
#define PCIVENDOR_Linksys 0x16abUL
#define PCIDEVICE_Wpc11Wdt11 0x1102UL
/* National Datacomm Corp SOHOware Netblaster II PCI */
#define PCIVENDOR_NDC 0x15e8UL
#define PCIDEVICE_NCP130_PLX 0x0130UL
#define PCIDEVICE_NCP130_ASIC 0x0131UL
/* NDC NCP130_PLX is also sold by Corega. Their name is CGWLPCIA11 */
#define PCIVENDOR_COREGA PCIVENDOR_NDC
#define PCIDEVICE_CGWLPCIA11 PCIDEVICE_NCP130_PLX
/* PCI Class & Sub-Class code, Network-'Other controller' */
#define PCI_CLASS_NETWORK_OTHERS 0x280
/*----------------------------------------------------------------
* prism2sta_probe_plx
*
* Probe routine called when a PCI device w/ matching ID is found.
* This PLX implementation uses the following map:
* BAR0: Unused
* BAR1: ????
* BAR2: PCMCIA attribute memory
* BAR3: PCMCIA i/o space
* Here's the sequence:
* - Allocate the PCI resources.
* - Read the PCMCIA attribute memory to make sure we have a WLAN card
* - Reset the MAC using the PCMCIA COR
* - Initialize the netdev and wlan data
* - Initialize the MAC
*
* Arguments:
* pdev ptr to pci device structure containing info about
* pci configuration.
* id ptr to the device id entry that matched this device.
*
* Returns:
* zero - success
* negative - failed
*
* Side effects:
*
*
* Call context:
* process thread
*
----------------------------------------------------------------*/
static int __devinit
prism2sta_probe_plx(
struct pci_dev *pdev,
const struct pci_device_id *id)
{
int result;
phys_t pccard_ioaddr;
phys_t pccard_attr_mem;
unsigned int pccard_attr_len;
void __iomem *attr_mem = NULL;
UINT32 plx_addr;
wlandevice_t *wlandev = NULL;
hfa384x_t *hw = NULL;
int reg;
u32 regic;
if (pci_enable_device(pdev))
return -EIO;
/* TMC7160 boards are special */
if ((pdev->vendor == PCIVENDOR_NDC) &&
(pdev->device == PCIDEVICE_NCP130_ASIC)) {
unsigned long delay;
pccard_attr_mem = 0;
pccard_ioaddr = pci_resource_start(pdev, 1);
outb(0x45, pccard_ioaddr);
delay = jiffies + 1*HZ;
while (time_before(jiffies, delay));
if (inb(pccard_ioaddr) != 0x45) {
WLAN_LOG_ERROR("Initialize the TMC7160 failed. (0x%x)\n", inb(pccard_ioaddr));
return -EIO;
}
pccard_ioaddr = pci_resource_start(pdev, 2);
prism2_doreset = 0;
WLAN_LOG_INFO("NDC NCP130 with TMC716(ASIC) PCI interface device found at io:0x%x, irq:%d\n", pccard_ioaddr, pdev->irq);
goto init;
}
/* Collect the resource requirements */
pccard_attr_mem = pci_resource_start(pdev, 2);
pccard_attr_len = pci_resource_len(pdev, 2);
if (pccard_attr_len < PLX_MIN_ATTR_LEN)
return -EIO;
pccard_ioaddr = pci_resource_start(pdev, 3);
/* bjoern: We need to tell the card to enable interrupts, in
* case the serial eprom didn't do this already. See the
* PLX9052 data book, p8-1 and 8-24 for reference.
* [MSM]: This bit of code came from the orinoco_cs driver.
*/
plx_addr = pci_resource_start(pdev, 1);
regic = 0;
regic = inl(plx_addr+PLX_INTCSR);
if(regic & PLX_INTCSR_INTEN) {
WLAN_LOG_DEBUG(1,
"%s: Local Interrupt already enabled\n", dev_info);
} else {
regic |= PLX_INTCSR_INTEN;
outl(regic, plx_addr+PLX_INTCSR);
regic = inl(plx_addr+PLX_INTCSR);
if(!(regic & PLX_INTCSR_INTEN)) {
WLAN_LOG_ERROR(
"%s: Couldn't enable Local Interrupts\n",
dev_info);
return -EIO;
}
}
/* These assignments are here in case of future mappings for
* io space and irq that might be similar to ioremap
*/
if (!request_mem_region(pccard_attr_mem, pci_resource_len(pdev, 2), "Prism2")) {
WLAN_LOG_ERROR("%s: Couldn't reserve PCI memory region\n", dev_info);
return -EIO;
}
attr_mem = ioremap(pccard_attr_mem, pccard_attr_len);
WLAN_LOG_INFO("A PLX PCI/PCMCIA interface device found, "
"phymem:0x%llx, phyio=0x%x, irq:%d, "
"mem: 0x%lx\n",
(unsigned long long)pccard_attr_mem, pccard_ioaddr, pdev->irq,
(unsigned long)attr_mem);
/* Verify whether PC card is present.
* [MSM] This needs improvement, the right thing to do is
* probably to walk the CIS looking for the vendor and product
* IDs. It would be nice if this could be tied in with the
* etc/pcmcia/wlan-ng.conf file. Any volunteers? ;-)
*/
if (
readb(attr_mem + 0) != 0x01 || readb(attr_mem + 2) != 0x03 ||
readb(attr_mem + 4) != 0x00 || readb(attr_mem + 6) != 0x00 ||
readb(attr_mem + 8) != 0xFF || readb(attr_mem + 10) != 0x17 ||
readb(attr_mem + 12) != 0x04 || readb(attr_mem + 14) != 0x67) {
WLAN_LOG_ERROR("Prism2 PC card CIS is invalid.\n");
return -EIO;
}
WLAN_LOG_INFO("A PCMCIA WLAN adapter was found.\n");
/* Write COR to enable PC card */
writeb(COR_VALUE, attr_mem + COR_OFFSET);
reg = readb(attr_mem + COR_OFFSET);
init:
/*
* Now do everything the same as a PCI device
* [MSM] TODO: We could probably factor this out of pcmcia/pci/plx
* and perhaps usb. Perhaps a task for another day.......
*/
if ((wlandev = create_wlan()) == NULL) {
WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
result = -EIO;
goto failed;
}
hw = wlandev->priv;
if ( wlan_setup(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);
result = -EIO;
goto failed;
}
/* Setup netdevice's ability to report resources
* Note: the netdevice was allocated by wlan_setup()
*/
wlandev->netdev->irq = pdev->irq;
wlandev->netdev->base_addr = pccard_ioaddr;
wlandev->netdev->mem_start = (unsigned long)attr_mem;
wlandev->netdev->mem_end = (unsigned long)attr_mem + pci_resource_len(pdev, 0);
/* Initialize the hw data */
hfa384x_create(hw, wlandev->netdev->irq, pccard_ioaddr, attr_mem);
hw->wlandev = wlandev;
/* Register the wlandev, this gets us a name and registers the
* linux netdevice.
*/
SET_MODULE_OWNER(wlandev->netdev);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
SET_NETDEV_DEV(wlandev->netdev, &(pdev->dev));
#endif
if ( register_wlandev(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
result = -EIO;
goto failed;
}
#if 0
/* TODO: Move this and an irq test into an hfa384x_testif() routine.
*/
outw(PRISM2STA_MAGIC, HFA384x_SWSUPPORT(wlandev->netdev->base_addr));
reg=inw( HFA384x_SWSUPPORT(wlandev->netdev->base_addr));
if ( reg != PRISM2STA_MAGIC ) {
WLAN_LOG_ERROR("MAC register access test failed!\n");
result = -EIO;
goto failed;
}
#endif
/* Do a chip-level reset on the MAC */
if (prism2_doreset) {
result = hfa384x_corereset(hw,
prism2_reset_holdtime,
prism2_reset_settletime, 0);
if (result != 0) {
unregister_wlandev(wlandev);
hfa384x_destroy(hw);
WLAN_LOG_ERROR(
"%s: hfa384x_corereset() failed.\n",
dev_info);
result = -EIO;
goto failed;
}
}
pci_set_drvdata(pdev, wlandev);
/* Shouldn't actually hook up the IRQ until we
* _know_ things are alright. A test routine would help.
*/
request_irq(wlandev->netdev->irq, hfa384x_interrupt,
SA_SHIRQ, wlandev->name, wlandev);
wlandev->msdstate = WLAN_MSD_HWPRESENT;
result = 0;
goto done;
failed:
pci_set_drvdata(pdev, NULL);
if (wlandev) kfree(wlandev);
if (hw) kfree(hw);
if (attr_mem) iounmap(attr_mem);
pci_release_regions(pdev);
pci_disable_device(pdev);
done:
DBFEXIT;
return result;
}
static void __devexit prism2sta_remove_plx(struct pci_dev *pdev)
{
wlandevice_t *wlandev;
hfa384x_t *hw;
wlandev = (wlandevice_t *) pci_get_drvdata(pdev);
hw = wlandev->priv;
p80211netdev_hwremoved(wlandev);
/* reset hardware */
prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
if (pdev->irq)
free_irq(pdev->irq, wlandev);
unregister_wlandev(wlandev);
/* free local stuff */
if (hw) {
hfa384x_destroy(hw);
kfree(hw);
}
iounmap((void __iomem *)wlandev->netdev->mem_start);
wlan_unsetup(wlandev);
pci_release_regions(pdev);
pci_disable_device(pdev);
pci_set_drvdata(pdev, NULL);
kfree(wlandev);
}
static struct pci_device_id plx_id_tbl[] = {
{
PCIVENDOR_EUMITCOM, PCIDEVICE_WL11000,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Eumitcom WL11000 PCI(PLX) card"
},
{
PCIVENDOR_GLOBALSUN, PCIDEVICE_GL24110P,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"
},
{
PCIVENDOR_GLOBALSUN, PCIDEVICE_GL24110P_ALT,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"
},
{
PCIVENDOR_NETGEAR, PCIDEVICE_MA301,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Global Sun Tech GL24110P PCI(PLX) card"
},
{
PCIVENDOR_USROBOTICS, PCIDEVICE_USR2410,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"US Robotics USR2410 PCI(PLX) card"
},
{
PCIVENDOR_Linksys, PCIDEVICE_Wpc11Wdt11,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"Linksys WPC11 with WDT11 PCI(PLX) adapter"
},
{
PCIVENDOR_NDC, PCIDEVICE_NCP130_PLX,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"NDC Netblaster II PCI(PLX)"
},
{
PCIVENDOR_NDC, PCIDEVICE_NCP130_ASIC,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"NDC Netblaster II PCI(TMC7160)"
},
{
PCIVENDOR_3COM, PCIDEVICE_AIRCONNECT,
PCI_ANY_ID, PCI_ANY_ID,
0, 0,
/* Driver data, we just put the name here */
(unsigned long)"3Com AirConnect PCI 802.11b 11Mb/s WLAN Controller"
},
{
0, 0, 0, 0, 0, 0, 0
}
};
MODULE_DEVICE_TABLE(pci, plx_id_tbl);
/* Function declared here because of ptr reference below */
static int __devinit prism2sta_probe_plx(struct pci_dev *pdev,
const struct pci_device_id *);
static void __devexit prism2sta_remove_plx(struct pci_dev *pdev);
static struct pci_driver prism2_plx_drv_id = {
.name = "prism2_plx",
.id_table = plx_id_tbl,
.probe = prism2sta_probe_plx,
.remove = prism2sta_remove_plx,
#ifdef CONFIG_PM
.suspend = prism2sta_suspend_pci,
.resume = prism2sta_resume_pci,
#endif
};
#ifdef MODULE
static int __init prism2plx_init(void)
{
WLAN_LOG_NOTICE("%s Loaded\n", version);
return pci_module_init(&prism2_plx_drv_id);
};
static void __exit prism2plx_cleanup(void)
{
pci_unregister_driver(&prism2_plx_drv_id);
};
module_init(prism2plx_init);
module_exit(prism2plx_cleanup);
#endif // MODULE
int hfa384x_corereset(hfa384x_t *hw, int holdtime, int settletime, int genesis)
{
int result = 0;
#define COR_OFFSET 0x3e0 /* COR attribute offset of Prism2 PC card */
#define COR_VALUE 0x41 /* Enable PC card with irq in level trigger */
#define HCR_OFFSET 0x3e2 /* HCR attribute offset of Prism2 PC card */
UINT8 corsave;
DBFENTER;
WLAN_LOG_DEBUG(3, "Doing reset via direct COR access.\n");
/* Collect COR */
corsave = readb(hw->membase + COR_OFFSET);
/* Write reset bit (BIT7) */
writeb(corsave | BIT7, hw->membase + COR_OFFSET);
/* Hold for holdtime */
mdelay(holdtime);
if (genesis) {
writeb(genesis, hw->membase + HCR_OFFSET);
/* Hold for holdtime */
mdelay(holdtime);
}
/* Clear reset bit */
writeb(corsave & ~BIT7, hw->membase + COR_OFFSET);
/* Wait for settletime */
mdelay(settletime);
/* Set non-reset bits back what they were */
writeb(corsave, hw->membase + COR_OFFSET);
DBFEXIT;
return result;
}

View File

@ -0,0 +1,361 @@
#define WLAN_HOSTIF WLAN_USB
#include "hfa384x_usb.c"
#include "prism2mgmt.c"
#include "prism2mib.c"
#include "prism2sta.c"
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
#error "prism2_usb requires at least a 2.4.x kernel!"
#endif
#define PRISM_USB_DEVICE(vid, pid, name) \
USB_DEVICE(vid, pid), \
.driver_info = (unsigned long) name
static struct usb_device_id usb_prism_tbl[] = {
{PRISM_USB_DEVICE(0x04bb, 0x0922, "IOData AirPort WN-B11/USBS")},
{PRISM_USB_DEVICE(0x07aa, 0x0012, "Corega Wireless LAN USB Stick-11")},
{PRISM_USB_DEVICE(0x09aa, 0x3642, "Prism2.x 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x1668, 0x0408, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x1668, 0x0421, "Actiontec Prism2.5 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x1915, 0x2236, "Linksys WUSB11v3.0 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x066b, 0x2212, "Linksys WUSB11v2.5 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x066b, 0x2213, "Linksys WUSB12v1.1 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x067c, 0x1022, "Siemens SpeedStream 1022 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x049f, 0x0033, "Compaq/Intel W100 PRO/Wireless 11Mbps multiport WLAN Adapter")},
{PRISM_USB_DEVICE(0x0411, 0x0016, "Melco WLI-USB-S11 11Mbps WLAN Adapter")},
{PRISM_USB_DEVICE(0x08de, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
{PRISM_USB_DEVICE(0x8086, 0x1111, "Intel PRO/Wireless 2011B LAN USB Adapter")},
{PRISM_USB_DEVICE(0x0d8e, 0x7a01, "PRISM25 IEEE 802.11 Mini USB Adapter")},
{PRISM_USB_DEVICE(0x045e, 0x006e, "Microsoft MN510 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x0967, 0x0204, "Acer Warplink USB Adapter")},
{PRISM_USB_DEVICE(0x0cde, 0x0002, "Z-Com 725/726 Prism2.5 USB/USB Integrated")},
{PRISM_USB_DEVICE(0x0cde, 0x0005, "Z-Com Xl735 Wireless 802.11b USB Adapter")},
{PRISM_USB_DEVICE(0x413c, 0x8100, "Dell TrueMobile 1180 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x0b3b, 0x1601, "ALLNET 0193 11Mbps WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x0b3b, 0x1602, "ZyXEL ZyAIR B200 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x0baf, 0x00eb, "USRobotics USR1120 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x0411, 0x0027, "Melco WLI-USB-KS11G 11Mbps WLAN Adapter")},
{PRISM_USB_DEVICE(0x04f1, 0x3009, "JVC MP-XP7250 Builtin USB WLAN Adapter")},
{PRISM_USB_DEVICE(0x0846, 0x4110, "NetGear MA111")},
{PRISM_USB_DEVICE(0x03f3, 0x0020, "Adaptec AWN-8020 USB WLAN Adapter")},
// {PRISM_USB_DEVICE(0x0ace, 0x1201, "ZyDAS ZD1201 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x2821, 0x3300, "ASUS-WL140 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x2001, 0x3700, "DWL-122 Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x2001, 0x3702, "DWL-120 Rev F Wireless USB Adapter")},
{PRISM_USB_DEVICE(0x50c2, 0x4013, "Averatec USB WLAN Adapter")},
{PRISM_USB_DEVICE(0x2c02, 0x14ea, "Planex GW-US11H WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x124a, 0x168b, "Airvast PRISM3 WLAN USB Adapter")},
{PRISM_USB_DEVICE(0x083a, 0x3503, "T-Sinus 111 USB WLAN Adapter")},
{PRISM_USB_DEVICE(0x2821, 0x3300, "Hawking HighDB USB Adapter")},
{PRISM_USB_DEVICE(0x0411, 0x0044, "Melco WLI-USB-KB11 11Mbps WLAN Adapter")},
{PRISM_USB_DEVICE(0x1668, 0x6106, "ROPEX FreeLan 802.11b USB Adapter")},
{PRISM_USB_DEVICE(0x124a, 0x4017, "Pheenet WL-503IA 802.11b USB Adapter")},
{PRISM_USB_DEVICE(0x0bb2, 0x0302, "Ambit Microsystems Corp.")},
{PRISM_USB_DEVICE(0x9016, 0x182d, "Sitecom WL-022 802.11b USB Adapter")},
{PRISM_USB_DEVICE(0x0543, 0x0f01, "ViewSonic Airsync USB Adapter 11Mbps (Prism2.5)")},
{ /* terminator */ }
};
MODULE_DEVICE_TABLE(usb, usb_prism_tbl);
/*----------------------------------------------------------------
* prism2sta_probe_usb
*
* Probe routine called by the USB subsystem.
*
* Arguments:
* dev ptr to the usb_device struct
* ifnum interface number being offered
*
* Returns:
* NULL - we're not claiming the device+interface
* non-NULL - we are claiming the device+interface and
* this is a ptr to the data we want back
* when disconnect is called.
*
* Side effects:
*
* Call context:
* I'm not sure, assume it's interrupt.
*
----------------------------------------------------------------*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
static void __devinit *prism2sta_probe_usb(
struct usb_device *dev,
unsigned int ifnum,
const struct usb_device_id *id)
#else
static int prism2sta_probe_usb(
struct usb_interface *interface,
const struct usb_device_id *id)
#endif
{
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
struct usb_interface *interface;
#else
struct usb_device *dev;
#endif
wlandevice_t *wlandev = NULL;
hfa384x_t *hw = NULL;
int result = 0;
DBFENTER;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
interface = &dev->actconfig->interface[ifnum];
#else
dev = interface_to_usbdev(interface);
#endif
if ((wlandev = create_wlan()) == NULL) {
WLAN_LOG_ERROR("%s: Memory allocation failure.\n", dev_info);
result = -EIO;
goto failed;
}
hw = wlandev->priv;
if ( wlan_setup(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: wlan_setup() failed.\n", dev_info);
result = -EIO;
goto failed;
}
/* Initialize the hw data */
hfa384x_create(hw, dev);
hw->wlandev = wlandev;
/* Register the wlandev, this gets us a name and registers the
* linux netdevice.
*/
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
SET_NETDEV_DEV(wlandev->netdev, &(interface->dev));
#endif
if ( register_wlandev(wlandev) != 0 ) {
WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
result = -EIO;
goto failed;
}
/* Do a chip-level reset on the MAC */
if (prism2_doreset) {
result = hfa384x_corereset(hw,
prism2_reset_holdtime,
prism2_reset_settletime, 0);
if (result != 0) {
unregister_wlandev(wlandev);
hfa384x_destroy(hw);
result = -EIO;
WLAN_LOG_ERROR(
"%s: hfa384x_corereset() failed.\n",
dev_info);
goto failed;
}
}
#ifndef NEW_MODULE_CODE
usb_inc_dev_use(dev);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
usb_get_dev(dev);
#endif
wlandev->msdstate = WLAN_MSD_HWPRESENT;
goto done;
failed:
if (wlandev) kfree(wlandev);
if (hw) kfree(hw);
wlandev = NULL;
done:
DBFEXIT;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
return wlandev;
#else
usb_set_intfdata(interface, wlandev);
return result;
#endif
}
/*----------------------------------------------------------------
* prism2sta_disconnect_usb
*
* Called when a device previously claimed by probe is removed
* from the USB.
*
* Arguments:
* dev ptr to the usb_device struct
* ptr ptr returned by probe() when the device
* was claimed.
*
* Returns:
* Nothing
*
* Side effects:
*
* Call context:
* process
----------------------------------------------------------------*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
static void __devexit
prism2sta_disconnect_usb(struct usb_device *dev, void *ptr)
#else
static void
prism2sta_disconnect_usb(struct usb_interface *interface)
#endif
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
wlandevice_t *wlandev;
#else
wlandevice_t *wlandev = (wlandevice_t*)ptr;
#endif
DBFENTER;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
wlandev = (wlandevice_t *) usb_get_intfdata(interface);
#endif
if ( wlandev != NULL ) {
LIST_HEAD(cleanlist);
struct list_head *entry;
struct list_head *temp;
unsigned long flags;
hfa384x_t *hw = wlandev->priv;
if (!hw)
goto exit;
spin_lock_irqsave(&hw->ctlxq.lock, flags);
p80211netdev_hwremoved(wlandev);
list_splice_init(&hw->ctlxq.reapable, &cleanlist);
list_splice_init(&hw->ctlxq.completing, &cleanlist);
list_splice_init(&hw->ctlxq.pending, &cleanlist);
list_splice_init(&hw->ctlxq.active, &cleanlist);
spin_unlock_irqrestore(&hw->ctlxq.lock, flags);
/* There's no hardware to shutdown, but the driver
* might have some tasks or tasklets that must be
* stopped before we can tear everything down.
*/
prism2sta_ifstate(wlandev, P80211ENUM_ifstate_disable);
del_singleshot_timer_sync(&hw->throttle);
del_singleshot_timer_sync(&hw->reqtimer);
del_singleshot_timer_sync(&hw->resptimer);
/* Unlink all the URBs. This "removes the wheels"
* from the entire CTLX handling mechanism.
*/
usb_kill_urb(&hw->rx_urb);
usb_kill_urb(&hw->tx_urb);
usb_kill_urb(&hw->ctlx_urb);
tasklet_kill(&hw->completion_bh);
tasklet_kill(&hw->reaper_bh);
flush_scheduled_work();
/* Now we complete any outstanding commands
* and tell everyone who is waiting for their
* responses that we have shut down.
*/
list_for_each(entry, &cleanlist) {
hfa384x_usbctlx_t *ctlx;
ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
complete(&ctlx->done);
}
/* Give any outstanding synchronous commands
* a chance to complete. All they need to do
* is "wake up", so that's easy.
* (I'd like a better way to do this, really.)
*/
msleep(100);
/* Now delete the CTLXs, because no-one else can now. */
list_for_each_safe(entry, temp, &cleanlist) {
hfa384x_usbctlx_t *ctlx;
ctlx = list_entry(entry, hfa384x_usbctlx_t, list);
kfree(ctlx);
}
/* Unhook the wlandev */
unregister_wlandev(wlandev);
wlan_unsetup(wlandev);
#ifndef NEW_MODULE_CODE
usb_dec_dev_use(hw->usb);
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
usb_put_dev(hw->usb);
#endif
hfa384x_destroy(hw);
kfree(hw);
kfree(wlandev);
}
exit:
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
usb_set_intfdata(interface, NULL);
#endif
DBFEXIT;
}
static struct usb_driver prism2_usb_driver = {
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,4,19)) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16))
.owner = THIS_MODULE,
#endif
.name = "prism2_usb",
.probe = prism2sta_probe_usb,
.disconnect = prism2sta_disconnect_usb,
.id_table = usb_prism_tbl,
/* fops, minor? */
};
#ifdef MODULE
static int __init prism2usb_init(void)
{
DBFENTER;
WLAN_LOG_NOTICE("%s Loaded\n", version);
WLAN_LOG_NOTICE("dev_info is: %s\n", dev_info);
/* This call will result in calls to prism2sta_probe_usb. */
return usb_register(&prism2_usb_driver);
DBFEXIT;
};
static void __exit prism2usb_cleanup(void)
{
DBFENTER;
usb_deregister(&prism2_usb_driver);
printk(KERN_NOTICE "%s Unloaded\n", version);
DBFEXIT;
};
module_init(prism2usb_init);
module_exit(prism2usb_cleanup);
#endif // module

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,182 @@
/* prism2mgmt.h
*
* Declares the mgmt command handler functions
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*
* This file contains the constants and data structures for interaction
* with the hfa384x Wireless LAN (WLAN) Media Access Contoller (MAC).
* The hfa384x is a portion of the Harris PRISM(tm) WLAN chipset.
*
* [Implementation and usage notes]
*
* [References]
* CW10 Programmer's Manual v1.5
* IEEE 802.11 D10.0
*
* --------------------------------------------------------------------
*/
#ifndef _PRISM2MGMT_H
#define _PRISM2MGMT_H
/*=============================================================*/
/*------ Constants --------------------------------------------*/
/*=============================================================*/
/*------ Macros -----------------------------------------------*/
/*=============================================================*/
/*------ Types and their related constants --------------------*/
/*=============================================================*/
/*------ Static variable externs ------------------------------*/
#if (WLAN_HOSTIF != WLAN_USB)
extern int prism2_bap_timeout;
extern int prism2_irq_evread_max;
#endif
extern int prism2_debug;
extern int prism2_reset_holdtime;
extern int prism2_reset_settletime;
/*=============================================================*/
/*--- Function Declarations -----------------------------------*/
/*=============================================================*/
UINT32
prism2sta_ifstate(wlandevice_t *wlandev, UINT32 ifstate);
void
prism2sta_ev_dtim(wlandevice_t *wlandev);
void
prism2sta_ev_infdrop(wlandevice_t *wlandev);
void
prism2sta_ev_info(wlandevice_t *wlandev, hfa384x_InfFrame_t *inf);
void
prism2sta_ev_txexc(wlandevice_t *wlandev, UINT16 status);
void
prism2sta_ev_tx(wlandevice_t *wlandev, UINT16 status);
void
prism2sta_ev_rx(wlandevice_t *wlandev, struct sk_buff *skb);
void
prism2sta_ev_alloc(wlandevice_t *wlandev);
int prism2mgmt_mibset_mibget(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_powermgmt(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_scan(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_scan_results(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_join(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_p2_join(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_authenticate(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_deauthenticate(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_associate(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_reassociate(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_disassociate(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_reset(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_start(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_wlansniff(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_readpda(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_readcis(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_auxport_state(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_auxport_read(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_auxport_write(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_low_level(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_test_command(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_mmi_read(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_mmi_write(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_ramdl_state(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_ramdl_write(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_flashdl_state(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_flashdl_write(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_mm_state(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_dump_state(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_enable(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_channel_info(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_channel_info_results(wlandevice_t *wlandev, void *msgp);
int prism2mgmt_autojoin(wlandevice_t *wlandev, void *msgp);
/*---------------------------------------------------------------
* conversion functions going between wlan message data types and
* Prism2 data types
---------------------------------------------------------------*/
/* byte area conversion functions*/
void prism2mgmt_pstr2bytearea(UINT8 *bytearea, p80211pstrd_t *pstr);
void prism2mgmt_bytearea2pstr(UINT8 *bytearea, p80211pstrd_t *pstr, int len);
/* byte string conversion functions*/
void prism2mgmt_pstr2bytestr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr);
void prism2mgmt_bytestr2pstr(hfa384x_bytestr_t *bytestr, p80211pstrd_t *pstr);
/* integer conversion functions */
void prism2mgmt_prism2int2p80211int(UINT16 *prism2int, UINT32 *wlanint);
void prism2mgmt_p80211int2prism2int(UINT16 *prism2int, UINT32 *wlanint);
/* enumerated integer conversion functions */
void prism2mgmt_prism2enum2p80211enum(UINT16 *prism2enum, UINT32 *wlanenum, UINT16 rid);
void prism2mgmt_p80211enum2prism2enum(UINT16 *prism2enum, UINT32 *wlanenum, UINT16 rid);
/* functions to convert a bit area to/from an Operational Rate Set */
void prism2mgmt_get_oprateset(UINT16 *rate, p80211pstrd_t *pstr);
void prism2mgmt_set_oprateset(UINT16 *rate, p80211pstrd_t *pstr);
/* functions to convert Group Addresses */
void prism2mgmt_get_grpaddr(UINT32 did,
p80211pstrd_t *pstr, hfa384x_t *priv );
int prism2mgmt_set_grpaddr(UINT32 did,
UINT8 *prism2buf, p80211pstrd_t *pstr, hfa384x_t *priv );
int prism2mgmt_get_grpaddr_index( UINT32 did );
void prism2sta_processing_defer(struct work_struct *data);
void prism2sta_commsqual_defer(struct work_struct *data);
void prism2sta_commsqual_timer(unsigned long data);
/*=============================================================*/
/*--- Inline Function Definitions (if supported) --------------*/
/*=============================================================*/
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,64 @@
/* src/include/wlan/version.h
*
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
#ifndef _WLAN_VERSION_H
#define _WLAN_VERSION_H
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
/* WLAN_HOSTIF (generally set on the command line, not detected) */
#define WLAN_NONE 0
#define WLAN_PCMCIA 1
#define WLAN_ISA 2
#define WLAN_PCI 3
#define WLAN_USB 4
#define WLAN_PLX 5
#define WLAN_SLAVE 6
#define WLAN_RELEASE "0.2.8"
#define WLAN_RELEASE_CODE 0x000208
#define WLAN_BUILD_DATE "Thu Oct 2 11:04:42 PDT 2008"
#endif

View File

@ -0,0 +1,757 @@
/* wlan_compat.h
*
* Types and macros to aid in portability
*
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
* --------------------------------------------------------------------
*
* linux-wlan
*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License version 2 (the "GPL"), in which
* case the provisions of the GPL are applicable instead of the
* above. If you wish to allow the use of your version of this file
* only under the terms of the GPL and not to allow others to use
* your version of this file under the MPL, indicate your decision
* by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL. If you do not delete
* the provisions above, a recipient may use your version of this
* file under either the MPL or the GPL.
*
* --------------------------------------------------------------------
*
* Inquiries regarding the linux-wlan Open Source project can be
* made directly to:
*
* AbsoluteValue Systems Inc.
* info@linux-wlan.com
* http://www.linux-wlan.com
*
* --------------------------------------------------------------------
*
* Portions of the development of this software were funded by
* Intersil Corporation as part of PRISM(R) chipset product development.
*
* --------------------------------------------------------------------
*/
#ifndef _WLAN_COMPAT_H
#define _WLAN_COMPAT_H
/*=============================================================*/
/*------ Establish Platform Identity --------------------------*/
/*=============================================================*/
/* Key macros: */
/* WLAN_CPU_FAMILY */
#define WLAN_Ix86 1
#define WLAN_PPC 2
#define WLAN_Ix96 3
#define WLAN_ARM 4
#define WLAN_ALPHA 5
#define WLAN_MIPS 6
#define WLAN_HPPA 7
#define WLAN_SPARC 8
#define WLAN_SH 9
#define WLAN_x86_64 10
/* WLAN_SYSARCH */
#define WLAN_PCAT 1
#define WLAN_MBX 2
#define WLAN_RPX 3
#define WLAN_LWARCH 4
#define WLAN_PMAC 5
#define WLAN_SKIFF 6
#define WLAN_BITSY 7
#define WLAN_ALPHAARCH 7
#define WLAN_MIPSARCH 9
#define WLAN_HPPAARCH 10
#define WLAN_SPARCARCH 11
#define WLAN_SHARCH 12
/* Note: the PLX HOSTIF above refers to some vendors implementations for */
/* PCI. It's a PLX chip that is a PCI to PCMCIA adapter, but it */
/* isn't a real PCMCIA host interface adapter providing all the */
/* card&socket services. */
#if (defined(CONFIG_PPC) || defined(CONFIG_8xx) || defined(__powerpc__))
#ifndef __ppc__
#define __ppc__
#endif
#endif
#if defined(__KERNEL__)
#ifndef AUTOCONF_INCLUDED
#include <linux/config.h>
#endif
#if defined(__x86_64__)
#define WLAN_CPU_FAMILY WLAN_x86_64
#define WLAN_SYSARCH WLAN_PCAT
#elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
#define WLAN_CPU_FAMILY WLAN_Ix86
#define WLAN_SYSARCH WLAN_PCAT
#elif defined(__ppc__)
#define WLAN_CPU_FAMILY WLAN_PPC
#if defined(CONFIG_MBX)
#define WLAN_SYSARCH WLAN_MBX
#elif defined(CONFIG_RPXLITE)
#define WLAN_SYSARCH WLAN_RPX
#elif defined(CONFIG_RPXCLASSIC)
#define WLAN_SYSARCH WLAN_RPX
#else
#define WLAN_SYSARCH WLAN_PMAC
#endif
#elif defined(__arm__)
#define WLAN_CPU_FAMILY WLAN_ARM
#define WLAN_SYSARCH WLAN_SKIFF
#elif defined(__alpha__)
#define WLAN_CPU_FAMILY WLAN_ALPHA
#define WLAN_SYSARCH WLAN_ALPHAARCH
#elif defined(__mips__)
#define WLAN_CPU_FAMILY WLAN_MIPS
#define WLAN_SYSARCH WLAN_MIPSARCH
#elif defined(__hppa__)
#define WLAN_CPU_FAMILY WLAN_HPPA
#define WLAN_SYSARCH WLAN_HPPAARCH
#elif defined(__sparc__)
#define WLAN_CPU_FAMILY WLAN_SPARC
#define WLAN_SYSARCH WLAN_SPARC
#elif defined(__sh__)
#define WLAN_CPU_FAMILY WLAN_SH
#define WLAN_SYSARCH WLAN_SHARCH
#ifndef __LITTLE_ENDIAN__
#define __LITTLE_ENDIAN__
#endif
#else
#error "No CPU identified!"
#endif
#endif /* __KERNEL__ */
/*
Some big endian machines implicitly do all I/O in little endian mode.
In particular:
Linux/PPC on PowerMacs (PCI)
Arm/Intel Xscale (PCI)
This may also affect PLX boards and other BE &| PPC platforms;
as new ones are discovered, add them below.
*/
#if defined(WLAN_HOSTIF)
#if ((WLAN_HOSTIF == WLAN_PCI) || (WLAN_HOSTIF == WLAN_PLX))
#if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC) || (WLAN_SYSARCH == WLAN_SPARC))
#define REVERSE_ENDIAN
#endif
#endif
#endif
/*=============================================================*/
/*------ Bit settings -----------------------------------------*/
/*=============================================================*/
#define BIT0 0x00000001
#define BIT1 0x00000002
#define BIT2 0x00000004
#define BIT3 0x00000008
#define BIT4 0x00000010
#define BIT5 0x00000020
#define BIT6 0x00000040
#define BIT7 0x00000080
#define BIT8 0x00000100
#define BIT9 0x00000200
#define BIT10 0x00000400
#define BIT11 0x00000800
#define BIT12 0x00001000
#define BIT13 0x00002000
#define BIT14 0x00004000
#define BIT15 0x00008000
#define BIT16 0x00010000
#define BIT17 0x00020000
#define BIT18 0x00040000
#define BIT19 0x00080000
#define BIT20 0x00100000
#define BIT21 0x00200000
#define BIT22 0x00400000
#define BIT23 0x00800000
#define BIT24 0x01000000
#define BIT25 0x02000000
#define BIT26 0x04000000
#define BIT27 0x08000000
#define BIT28 0x10000000
#define BIT29 0x20000000
#define BIT30 0x40000000
#define BIT31 0x80000000
#include <linux/types.h>
typedef u_int8_t UINT8;
typedef u_int16_t UINT16;
typedef u_int32_t UINT32;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
typedef unsigned int UINT;
typedef signed int INT;
typedef u_int64_t UINT64;
typedef int64_t INT64;
#define UINT8_MAX (0xffUL)
#define UINT16_MAX (0xffffUL)
#define UINT32_MAX (0xffffffffUL)
#define INT8_MAX (0x7fL)
#define INT16_MAX (0x7fffL)
#define INT32_MAX (0x7fffffffL)
/*=============================================================*/
/*------ Compiler Portability Macros --------------------------*/
/*=============================================================*/
#define __WLAN_ATTRIB_PACK__ __attribute__ ((packed))
/*=============================================================*/
/*------ OS Portability Macros --------------------------------*/
/*=============================================================*/
#ifndef WLAN_DBVAR
#define WLAN_DBVAR wlan_debug
#endif
#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
# if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8))
# include <linux/hardirq.h>
# else
# include <asm/hardirq.h>
# endif
#elif defined(__KERNEL__)
# define PREEMPT_MASK (0x000000FFUL)
# define preempt_count() (0UL)
#endif
#define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __FUNCTION__ , ##args);
#define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __FUNCTION__ , ##args);
#define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __FUNCTION__ , ##args);
#define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
#if defined(WLAN_INCLUDE_DEBUG)
#define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
WLAN_LOG_DEBUG(1, "Assertion failure!\n"); }
#define WLAN_HEX_DUMP( l, x, p, n) if( WLAN_DBVAR >= (l) ){ \
int __i__; \
printk(KERN_DEBUG x ":"); \
for( __i__=0; __i__ < (n); __i__++) \
printk( " %02x", ((UINT8*)(p))[__i__]); \
printk("\n"); }
#define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
#define DBFEXIT { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
#define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x , __FUNCTION__, (preempt_count() & PREEMPT_MASK), ##args );
#else
#define WLAN_ASSERT(c)
#define WLAN_HEX_DUMP( l, s, p, n)
#define DBFENTER
#define DBFEXIT
#define WLAN_LOG_DEBUG(l, s, args...)
#endif
#ifdef CONFIG_SMP
#define __SMP__ 1
#endif
#if defined(__KERNEL__)
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)))
#define URB_ONLY_CALLBACK
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19))
#define PT_REGS , struct pt_regs *regs
#else
#define PT_REGS
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
# define del_singleshot_timer_sync(a) del_timer_sync(a)
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
#define CONFIG_NETLINK 1
#endif
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
#define kfree_s(a, b) kfree((a))
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
#ifndef init_waitqueue_head
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
#define init_waitqueue_head(p) (*(p) = NULL)
#else
#define init_waitqueue_head(p) init_waitqueue(p)
#endif
typedef struct wait_queue *wait_queue_head_t;
typedef struct wait_queue wait_queue_t;
#define set_current_state(b) { current->state = (b); mb(); }
#define init_waitqueue_entry(a, b) { (a)->task = current; }
#endif
#endif
#ifndef wait_event_interruptible_timeout
// retval == 0; signal met; we're good.
// retval < 0; interrupted by signal.
// retval > 0; timed out.
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) // fixme?
#define __wait_event_interruptible_timeout(wq, condition, ret) \
do { \
wait_queue_t __wait; \
init_waitqueue_entry(&__wait, current); \
\
add_wait_queue(&wq, &__wait); \
for (;;) { \
set_current_state(TASK_INTERRUPTIBLE); \
if (condition) \
break; \
if (!signal_pending(current)) { \
ret = schedule_timeout(ret) ; \
if (!ret) \
break; \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
set_current_state(TASK_RUNNING); \
remove_wait_queue(&wq, &__wait); \
} while (0)
#else // 2.2
#define __wait_event_interruptible_timeout(wq, condition, ret) \
do { \
struct wait_queue __wait; \
\
__wait.task = current; \
add_wait_queue(&wq, &__wait); \
for (;;) { \
current->state = TASK_INTERRUPTIBLE; \
if (condition) \
break; \
if (!signal_pending(current)) { \
ret = schedule_timeout(ret); \
if (!ret) \
break; \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
current->state = TASK_RUNNING; \
remove_wait_queue(&wq, &__wait); \
} while (0)
#endif // version >= 2.4
#define wait_event_interruptible_timeout(wq, condition, timeout) \
({ \
long __ret = timeout; \
if (!(condition)) \
__wait_event_interruptible_timeout(wq, condition, __ret); \
__ret; \
})
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
#ifdef _LINUX_LIST_H
static inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
list_add_tail(list, head);
}
static inline void __list_splice(struct list_head *list,
struct list_head *head)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
static inline void list_move(struct list_head *list, struct list_head *head)
{
__list_del(list->prev, list->next);
list_add(list, head);
}
static inline void list_splice_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head);
INIT_LIST_HEAD(list);
}
}
#endif // LIST_H
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
#define spin_lock(l) do { } while (0)
#define spin_unlock(l) do { } while (0)
#define spin_lock_irqsave(l,f) do { save_flags(f); cli(); } while (0)
#define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
#define spin_lock_init(s) do { } while (0)
#define spin_trylock(l) (1)
typedef int spinlock_t;
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) // XXX ???
#define spin_lock_bh spin_lock
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
#ifdef CONFIG_SMP
#define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0)
#else
#define spin_is_locked(l) (0)
#endif
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28))
#define __user
#define __iomem
#endif
#ifdef _LINUX_PROC_FS_H
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,25))
extern inline struct proc_dir_entry *
create_proc_read_entry(const char *name, mode_t mode,
struct proc_dir_entry *base,
read_proc_t *read_proc, void *data)
{
struct proc_dir_entry *res = create_proc_entry(name, mode, base);
if (res) {
res->read_proc = read_proc;
res->data = data;
}
return res;
}
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,29))
#ifndef proc_mkdir
#define proc_mkdir(name, root) create_proc_entry(name, S_IFDIR, root)
#endif
#endif
#endif /* _LINUX_PROC_FS_H */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
#ifndef INIT_TQUEUE
#define PREPARE_TQUEUE(_tq, _routine, _data) \
do { \
(_tq)->routine = _routine; \
(_tq)->data = _data; \
} while (0)
#define INIT_TQUEUE(_tq, _routine, _data) \
do { \
INIT_LIST_HEAD(&(_tq)->list); \
(_tq)->sync = 0; \
PREPARE_TQUEUE((_tq), (_routine), (_data)); \
} while (0)
#endif
#ifndef container_of
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#endif
#ifndef INIT_WORK
#define work_struct tq_struct
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
#define schedule_work(a) queue_task(a, &tq_scheduler)
#else
#define schedule_work(a) schedule_task(a)
#endif
#define flush_scheduled_work flush_scheduled_tasks
#define INIT_WORK2(_wq, _routine) INIT_TQUEUE(_wq, (void (*)(void *))_routine, _wq)
#endif
#else // >= 2.5 kernel
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
#define INIT_WORK2(_wq, _routine) INIT_WORK(_wq, (void (*)(void *))_routine, _wq)
#else
#define INIT_WORK2(_wq, _routine) INIT_WORK(_wq, _routine)
#endif
#endif // >= 2.5 kernel
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
typedef struct device netdevice_t;
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
typedef struct net_device netdevice_t;
#else
#undef netdevice_t
typedef struct net_device netdevice_t;
#endif
#ifdef WIRELESS_EXT
#if (WIRELESS_EXT < 13)
struct iw_request_info
{
__u16 cmd; /* Wireless Extension command */
__u16 flags; /* More to come ;-) */
};
#endif
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
#define MODULE_PARM(a,b) extern int __bogus_decl
#define MODULE_AUTHOR(a) extern int __bogus_decl
#define MODULE_DESCRIPTION(a) extern int __bogus_decl
#define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
#undef GET_USE_COUNT
#define GET_USE_COUNT(m) mod_use_count_
#endif
#ifndef MODULE_OWNER
#define MODULE_OWNER(a) extern int __bogus_decl
#define ANCIENT_MODULE_CODE
#endif
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(m) extern int __bogus_decl
#endif
/* TODO: Do we care about this? */
#ifndef MODULE_DEVICE_TABLE
#define MODULE_DEVICE_TABLE(foo,bar)
#endif
#define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec * 60))
#define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))
#define NEW_MODULE_CODE
#ifdef ANCIENT_MODULE_CODE
#undef ANCIENT_MODULE_CODE
#endif
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25))
#define module_param(name, type, perm) \
static inline void *__check_existence_##name(void) { return &name; } \
MODULE_PARM(name, _MODULE_PARM_STRING_ ## type)
#define _MODULE_PARM_STRING_byte "b"
#define _MODULE_PARM_STRING_short "h"
#define _MODULE_PARM_STRING_ushort "h"
#define _MODULE_PARM_STRING_int "i"
#define _MODULE_PARM_STRING_uint "i"
#define _MODULE_PARM_STRING_long "l"
#define _MODULE_PARM_STRING_ulong "l"
#define _MODULE_PARM_STRING_bool "i"
#endif
/* linux < 2.5.69 */
#ifndef IRQ_NONE
typedef void irqreturn_t;
#define IRQ_NONE
#define IRQ_HANDLED
#define IRQ_RETVAL(x)
#endif
#ifndef in_atomic
#define in_atomic() 0
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13))
#define URB_ASYNC_UNLINK 0
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
#define URB_ASYNC_UNLINK USB_ASYNC_UNLINK
#define usb_fill_bulk_urb FILL_BULK_URB
#define usb_kill_urb usb_unlink_urb
#else
#define USB_QUEUE_BULK 0
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11))
typedef u32 pm_message_t;
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9))
#define hotplug_path "/etc/hotplug/wlan.agent"
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
#define free_netdev(x) kfree(x)
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
#define eth_hdr(x) (x)->mac.ethernet
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
#define del_timer_sync(a) del_timer(a)
#endif
#ifndef might_sleep
#define might_sleep(a) do { } while (0)
#endif
/* Apparently 2.4.2 ethtool is quite different, maybe newer too? */
#if (defined(SIOETHTOOL) && !defined(ETHTOOL_GDRVINFO))
#undef SIOETHTOOL
#endif
// pcmcia-cs stuff
#if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && \
!defined(pcmcia_access_configuration_register))
#define pcmcia_access_configuration_register(handle, reg) \
CardServices(AccessConfigurationRegister, handle, reg)
#define pcmcia_register_client(handle, reg) \
CardServices(RegisterClient, handle, reg)
#define pcmcia_deregister_client(handle) \
CardServices(DeregisterClient, handle)
#define pcmcia_get_first_tuple(handle, tuple) \
CardServices(GetFirstTuple, handle, tuple)
#define pcmcia_get_next_tuple(handle, tuple) \
CardServices(GetNextTuple, handle, tuple)
#define pcmcia_get_tuple_data(handle, tuple) \
CardServices(GetTupleData, handle, tuple)
#define pcmcia_parse_tuple(handle, tuple, parse) \
CardServices(ParseTuple, handle, tuple, parse)
#define pcmcia_get_configuration_info(handle, config) \
CardServices(GetConfigurationInfo, handle, config)
#define pcmcia_request_io(handle, req) \
CardServices(RequestIO, handle, req)
#define pcmcia_request_irq(handle, req) \
CardServices(RequestIRQ, handle, req)
#define pcmcia_request_configuration(handle, req) \
CardServices(RequestConfiguration, handle, req)
#define pcmcia_release_configuration(handle) \
CardServices(ReleaseConfiguration, handle)
#define pcmcia_release_io(handle, req) \
CardServices(ReleaseIO, handle, req)
#define pcmcia_release_irq(handle, req) \
CardServices(ReleaseIRQ, handle, req)
#define pcmcia_release_window(win) \
CardServices(ReleaseWindow, win)
#define pcmcia_get_card_services_info(info) \
CardServices(GetCardServicesInfo, info)
#define pcmcia_report_error(handle, err) \
CardServices(ReportError, handle, err)
#endif
#endif /* __KERNEL__ */
/*=============================================================*/
/*------ Hardware Portability Macros --------------------------*/
/*=============================================================*/
#define ieee2host16(n) __le16_to_cpu(n)
#define ieee2host32(n) __le32_to_cpu(n)
#define host2ieee16(n) __cpu_to_le16(n)
#define host2ieee32(n) __cpu_to_le32(n)
#if (WLAN_CPU_FAMILY != WLAN_MIPS)
typedef UINT32 phys_t;
#endif
#if (WLAN_CPU_FAMILY == WLAN_PPC)
#define wlan_inw(a) in_be16((unsigned short *)((a)+_IO_BASE))
#define wlan_inw_le16_to_cpu(a) inw((a))
#define wlan_outw(v,a) out_be16((unsigned short *)((a)+_IO_BASE), (v))
#define wlan_outw_cpu_to_le16(v,a) outw((v),(a))
#else
#define wlan_inw(a) inw((a))
#define wlan_inw_le16_to_cpu(a) __cpu_to_le16(inw((a)))
#define wlan_outw(v,a) outw((v),(a))
#define wlan_outw_cpu_to_le16(v,a) outw(__cpu_to_le16((v)),(a))
#endif
/*=============================================================*/
/*--- General Macros ------------------------------------------*/
/*=============================================================*/
#define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
#define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
#define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
/* Create a string of printable chars from something that might not be */
/* It's recommended that the str be 4*len + 1 bytes long */
#define wlan_mkprintstr(buf, buflen, str, strlen) \
{ \
int i = 0; \
int j = 0; \
memset(str, 0, (strlen)); \
for (i = 0; i < (buflen); i++) { \
if ( wlan_isprint((buf)[i]) ) { \
(str)[j] = (buf)[i]; \
j++; \
} else { \
(str)[j] = '\\'; \
(str)[j+1] = 'x'; \
(str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
(str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
j += 4; \
} \
} \
}
/*=============================================================*/
/*--- Variables -----------------------------------------------*/
/*=============================================================*/
#ifdef WLAN_INCLUDE_DEBUG
extern int wlan_debug;
#endif
extern int wlan_ethconv; /* What's the default ethconv? */
/*=============================================================*/
/*--- Functions -----------------------------------------------*/
/*=============================================================*/
#endif /* _WLAN_COMPAT_H */