2005-05-13 02:48:20 +00:00
|
|
|
/*
|
|
|
|
* Original code based Host AP (software wireless LAN access point) driver
|
|
|
|
* for Intersil Prism2/2.5/3 - hostap.o module, common routines
|
|
|
|
*
|
|
|
|
* Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
|
2007-03-25 00:15:30 +00:00
|
|
|
* <j@w1.fi>
|
|
|
|
* Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
|
2005-09-21 16:58:43 +00:00
|
|
|
* Copyright (c) 2004-2005, Intel Corporation
|
2005-05-13 02:48:20 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation. See README and COPYING for
|
|
|
|
* more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/in6.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/gfp.h>
|
2005-05-13 02:48:20 +00:00
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/tcp.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/wireless.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
|
2008-09-24 22:13:14 +00:00
|
|
|
#include <net/lib80211.h>
|
2009-02-12 17:32:55 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
#include "libipw.h"
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static void libipw_monitor_rx(struct libipw_device *ieee,
|
2005-05-13 02:48:20 +00:00
|
|
|
struct sk_buff *skb,
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_rx_stats *rx_stats)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
|
|
|
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
|
2008-10-01 01:43:03 +00:00
|
|
|
u16 fc = le16_to_cpu(hdr->frame_control);
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
skb->dev = ieee->dev;
|
2007-03-19 22:30:44 +00:00
|
|
|
skb_reset_mac_header(skb);
|
2009-08-20 18:48:03 +00:00
|
|
|
skb_pull(skb, libipw_get_hdrlen(fc));
|
2005-05-13 02:48:20 +00:00
|
|
|
skb->pkt_type = PACKET_OTHERHOST;
|
2007-12-11 18:52:26 +00:00
|
|
|
skb->protocol = htons(ETH_P_80211_RAW);
|
2005-05-13 02:48:20 +00:00
|
|
|
memset(skb->cb, 0, sizeof(skb->cb));
|
|
|
|
netif_rx(skb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called only as a tasklet (software IRQ) */
|
2009-08-20 18:48:03 +00:00
|
|
|
static struct libipw_frag_entry *libipw_frag_cache_find(struct
|
|
|
|
libipw_device
|
2005-09-07 04:48:31 +00:00
|
|
|
*ieee,
|
|
|
|
unsigned int seq,
|
|
|
|
unsigned int frag,
|
|
|
|
u8 * src,
|
|
|
|
u8 * dst)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_frag_entry *entry;
|
2005-05-13 02:48:20 +00:00
|
|
|
int i;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
for (i = 0; i < LIBIPW_FRAG_CACHE_LEN; i++) {
|
2005-05-13 02:48:20 +00:00
|
|
|
entry = &ieee->frag_cache[i];
|
|
|
|
if (entry->skb != NULL &&
|
|
|
|
time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_FRAG("expiring fragment cache entry "
|
2005-09-07 04:48:31 +00:00
|
|
|
"seq=%u last_frag=%u\n",
|
|
|
|
entry->seq, entry->last_frag);
|
2005-05-13 02:48:20 +00:00
|
|
|
dev_kfree_skb_any(entry->skb);
|
|
|
|
entry->skb = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry->skb != NULL && entry->seq == seq &&
|
|
|
|
(entry->last_frag + 1 == frag || frag == -1) &&
|
2006-01-10 00:01:43 +00:00
|
|
|
!compare_ether_addr(entry->src_addr, src) &&
|
|
|
|
!compare_ether_addr(entry->dst_addr, dst))
|
2005-05-13 02:48:20 +00:00
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called only as a tasklet (software IRQ) */
|
2009-08-20 18:48:03 +00:00
|
|
|
static struct sk_buff *libipw_frag_cache_get(struct libipw_device *ieee,
|
|
|
|
struct libipw_hdr_4addr *hdr)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
u16 sc;
|
|
|
|
unsigned int frag, seq;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_frag_entry *entry;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
sc = le16_to_cpu(hdr->seq_ctl);
|
|
|
|
frag = WLAN_GET_SEQ_FRAG(sc);
|
|
|
|
seq = WLAN_GET_SEQ_SEQ(sc);
|
|
|
|
|
|
|
|
if (frag == 0) {
|
|
|
|
/* Reserve enough space to fit maximum frame length */
|
|
|
|
skb = dev_alloc_skb(ieee->dev->mtu +
|
2009-08-20 18:48:03 +00:00
|
|
|
sizeof(struct libipw_hdr_4addr) +
|
2005-09-07 04:48:31 +00:00
|
|
|
8 /* LLC */ +
|
|
|
|
2 /* alignment */ +
|
|
|
|
8 /* WEP */ + ETH_ALEN /* WDS */ );
|
2005-05-13 02:48:20 +00:00
|
|
|
if (skb == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
entry = &ieee->frag_cache[ieee->frag_next_idx];
|
|
|
|
ieee->frag_next_idx++;
|
2009-08-20 18:48:03 +00:00
|
|
|
if (ieee->frag_next_idx >= LIBIPW_FRAG_CACHE_LEN)
|
2005-05-13 02:48:20 +00:00
|
|
|
ieee->frag_next_idx = 0;
|
|
|
|
|
|
|
|
if (entry->skb != NULL)
|
|
|
|
dev_kfree_skb_any(entry->skb);
|
|
|
|
|
|
|
|
entry->first_frag_time = jiffies;
|
|
|
|
entry->seq = seq;
|
|
|
|
entry->last_frag = frag;
|
|
|
|
entry->skb = skb;
|
|
|
|
memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
|
|
|
|
memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
|
|
|
|
} else {
|
|
|
|
/* received a fragment of a frame for which the head fragment
|
|
|
|
* should have already been received */
|
2009-08-20 18:48:03 +00:00
|
|
|
entry = libipw_frag_cache_find(ieee, seq, frag, hdr->addr2,
|
2005-05-13 02:48:20 +00:00
|
|
|
hdr->addr1);
|
|
|
|
if (entry != NULL) {
|
|
|
|
entry->last_frag = frag;
|
|
|
|
skb = entry->skb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return skb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Called only as a tasklet (software IRQ) */
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_frag_cache_invalidate(struct libipw_device *ieee,
|
|
|
|
struct libipw_hdr_4addr *hdr)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
|
|
|
u16 sc;
|
|
|
|
unsigned int seq;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_frag_entry *entry;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
sc = le16_to_cpu(hdr->seq_ctl);
|
|
|
|
seq = WLAN_GET_SEQ_SEQ(sc);
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
entry = libipw_frag_cache_find(ieee, seq, -1, hdr->addr2,
|
2005-05-13 02:48:20 +00:00
|
|
|
hdr->addr1);
|
|
|
|
|
|
|
|
if (entry == NULL) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_FRAG("could not invalidate fragment cache "
|
2005-09-07 04:48:31 +00:00
|
|
|
"entry (seq=%u)\n", seq);
|
2005-05-13 02:48:20 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry->skb = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOT_YET
|
2009-08-20 18:48:03 +00:00
|
|
|
/* libipw_rx_frame_mgtmt
|
2005-05-13 02:48:20 +00:00
|
|
|
*
|
|
|
|
* Responsible for handling management control frames
|
|
|
|
*
|
2009-08-20 18:48:03 +00:00
|
|
|
* Called by libipw_rx */
|
2006-01-14 21:20:43 +00:00
|
|
|
static int
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_rx_frame_mgmt(struct libipw_device *ieee, struct sk_buff *skb,
|
|
|
|
struct libipw_rx_stats *rx_stats, u16 type,
|
2005-05-13 02:48:20 +00:00
|
|
|
u16 stype)
|
|
|
|
{
|
|
|
|
if (ieee->iw_mode == IW_MODE_MASTER) {
|
|
|
|
printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
|
|
|
|
ieee->dev->name);
|
|
|
|
return 0;
|
|
|
|
/*
|
2009-08-20 18:48:03 +00:00
|
|
|
hostap_update_sta_ps(ieee, (struct hostap_libipw_hdr_4addr *)
|
2005-05-13 02:48:20 +00:00
|
|
|
skb->data);*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
|
|
|
|
if (stype == WLAN_FC_STYPE_BEACON &&
|
|
|
|
ieee->iw_mode == IW_MODE_MASTER) {
|
|
|
|
struct sk_buff *skb2;
|
|
|
|
/* Process beacon frames also in kernel driver to
|
|
|
|
* update STA(AP) table statistics */
|
|
|
|
skb2 = skb_clone(skb, GFP_ATOMIC);
|
|
|
|
if (skb2)
|
|
|
|
hostap_rx(skb2->dev, skb2, rx_stats);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send management frames to the user space daemon for
|
|
|
|
* processing */
|
|
|
|
ieee->apdevstats.rx_packets++;
|
|
|
|
ieee->apdevstats.rx_bytes += skb->len;
|
|
|
|
prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-09-07 04:48:31 +00:00
|
|
|
if (ieee->iw_mode == IW_MODE_MASTER) {
|
2005-05-13 02:48:20 +00:00
|
|
|
if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
|
|
|
|
printk(KERN_DEBUG "%s: unknown management frame "
|
|
|
|
"(type=0x%02x, stype=0x%02x) dropped\n",
|
|
|
|
skb->dev->name, type, stype);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
hostap_rx(skb->dev, skb, rx_stats);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
|
|
|
|
"received in non-Host AP mode\n", skb->dev->name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
|
|
|
|
/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
|
2009-08-20 18:48:03 +00:00
|
|
|
static unsigned char libipw_rfc1042_header[] =
|
|
|
|
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
|
2005-09-07 04:48:31 +00:00
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
|
2009-08-20 18:48:03 +00:00
|
|
|
static unsigned char libipw_bridge_tunnel_header[] =
|
2005-09-07 04:48:31 +00:00
|
|
|
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
|
2005-05-13 02:48:20 +00:00
|
|
|
/* No encapsulation header if EtherType < 0x600 (=length) */
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
/* Called by libipw_rx_frame_decrypt */
|
|
|
|
static int libipw_is_eapol_frame(struct libipw_device *ieee,
|
2005-05-13 02:48:20 +00:00
|
|
|
struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct net_device *dev = ieee->dev;
|
|
|
|
u16 fc, ethertype;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_hdr_3addr *hdr;
|
2005-05-13 02:48:20 +00:00
|
|
|
u8 *pos;
|
|
|
|
|
|
|
|
if (skb->len < 24)
|
|
|
|
return 0;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_3addr *)skb->data;
|
2005-05-13 02:48:20 +00:00
|
|
|
fc = le16_to_cpu(hdr->frame_ctl);
|
|
|
|
|
|
|
|
/* check that the frame is unicast frame to us */
|
|
|
|
if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
|
|
|
|
IEEE80211_FCTL_TODS &&
|
2006-01-10 00:01:43 +00:00
|
|
|
!compare_ether_addr(hdr->addr1, dev->dev_addr) &&
|
|
|
|
!compare_ether_addr(hdr->addr3, dev->dev_addr)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* ToDS frame with own addr BSSID and DA */
|
|
|
|
} else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
|
|
|
|
IEEE80211_FCTL_FROMDS &&
|
2006-01-10 00:01:43 +00:00
|
|
|
!compare_ether_addr(hdr->addr1, dev->dev_addr)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* FromDS frame with own addr as DA */
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (skb->len < 24 + 8)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* check for port access entity Ethernet type */
|
|
|
|
pos = skb->data + 24;
|
|
|
|
ethertype = (pos[6] << 8) | pos[7];
|
|
|
|
if (ethertype == ETH_P_PAE)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
/* Called only as a tasklet (software IRQ), by libipw_rx */
|
2006-01-14 21:20:43 +00:00
|
|
|
static int
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_rx_frame_decrypt(struct libipw_device *ieee, struct sk_buff *skb,
|
2008-10-29 15:35:05 +00:00
|
|
|
struct lib80211_crypt_data *crypt)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_hdr_3addr *hdr;
|
2005-05-13 02:48:20 +00:00
|
|
|
int res, hdrlen;
|
|
|
|
|
|
|
|
if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_3addr *)skb->data;
|
|
|
|
hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
atomic_inc(&crypt->refcnt);
|
|
|
|
res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
|
|
|
|
atomic_dec(&crypt->refcnt);
|
|
|
|
if (res < 0) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP("decryption failed (SA=%pM) res=%d\n",
|
2008-10-27 22:59:26 +00:00
|
|
|
hdr->addr2, res);
|
2005-05-13 02:48:20 +00:00
|
|
|
if (res == -2)
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP("Decryption failed ICV "
|
2005-05-13 02:48:20 +00:00
|
|
|
"mismatch (key %d)\n",
|
|
|
|
skb->data[hdrlen + 3] >> 6);
|
|
|
|
ieee->ieee_stats.rx_discards_undecryptable++;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
/* Called only as a tasklet (software IRQ), by libipw_rx */
|
2006-01-14 21:20:43 +00:00
|
|
|
static int
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_rx_frame_decrypt_msdu(struct libipw_device *ieee,
|
2005-09-07 04:48:31 +00:00
|
|
|
struct sk_buff *skb, int keyidx,
|
2008-10-29 15:35:05 +00:00
|
|
|
struct lib80211_crypt_data *crypt)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_hdr_3addr *hdr;
|
2005-05-13 02:48:20 +00:00
|
|
|
int res, hdrlen;
|
|
|
|
|
|
|
|
if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_3addr *)skb->data;
|
|
|
|
hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
atomic_inc(&crypt->refcnt);
|
|
|
|
res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
|
|
|
|
atomic_dec(&crypt->refcnt);
|
|
|
|
if (res < 0) {
|
|
|
|
printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
|
2008-10-27 22:59:26 +00:00
|
|
|
" (SA=%pM keyidx=%d)\n", ieee->dev->name, hdr->addr2,
|
2008-04-08 23:50:44 +00:00
|
|
|
keyidx);
|
2005-05-13 02:48:20 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All received frames are sent to this function. @skb contains the frame in
|
|
|
|
* IEEE 802.11 format, i.e., in the format it was sent over air.
|
|
|
|
* This function is called only as a tasklet (software IRQ). */
|
2009-08-20 18:48:03 +00:00
|
|
|
int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
|
|
|
|
struct libipw_rx_stats *rx_stats)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
|
|
|
struct net_device *dev = ieee->dev;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_hdr_4addr *hdr;
|
2005-05-13 02:48:20 +00:00
|
|
|
size_t hdrlen;
|
|
|
|
u16 fc, type, stype, sc;
|
|
|
|
unsigned int frag;
|
|
|
|
u8 *payload;
|
|
|
|
u16 ethertype;
|
|
|
|
#ifdef NOT_YET
|
|
|
|
struct net_device *wds = NULL;
|
|
|
|
struct sk_buff *skb2 = NULL;
|
|
|
|
struct net_device *wds = NULL;
|
|
|
|
int frame_authorized = 0;
|
|
|
|
int from_assoc_ap = 0;
|
|
|
|
void *sta = NULL;
|
|
|
|
#endif
|
|
|
|
u8 dst[ETH_ALEN];
|
|
|
|
u8 src[ETH_ALEN];
|
2008-10-29 15:35:05 +00:00
|
|
|
struct lib80211_crypt_data *crypt = NULL;
|
2005-05-13 02:48:20 +00:00
|
|
|
int keyidx = 0;
|
2006-01-19 08:20:42 +00:00
|
|
|
int can_be_decrypted = 0;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_4addr *)skb->data;
|
2005-05-13 02:48:20 +00:00
|
|
|
if (skb->len < 10) {
|
2005-09-07 04:48:31 +00:00
|
|
|
printk(KERN_INFO "%s: SKB length < 10\n", dev->name);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
|
|
|
fc = le16_to_cpu(hdr->frame_ctl);
|
|
|
|
type = WLAN_FC_GET_TYPE(fc);
|
|
|
|
stype = WLAN_FC_GET_STYPE(fc);
|
|
|
|
sc = le16_to_cpu(hdr->seq_ctl);
|
|
|
|
frag = WLAN_GET_SEQ_FRAG(sc);
|
2009-08-20 18:48:03 +00:00
|
|
|
hdrlen = libipw_get_hdrlen(fc);
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2007-10-02 04:03:54 +00:00
|
|
|
if (skb->len < hdrlen) {
|
|
|
|
printk(KERN_INFO "%s: invalid SKB length %d\n",
|
|
|
|
dev->name, skb->len);
|
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Put this code here so that we avoid duplicating it in all
|
|
|
|
* Rx paths. - Jean II */
|
2006-06-26 08:44:38 +00:00
|
|
|
#ifdef CONFIG_WIRELESS_EXT
|
2005-05-13 02:48:20 +00:00
|
|
|
#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
|
|
|
|
/* If spy monitoring on */
|
2005-09-13 22:35:21 +00:00
|
|
|
if (ieee->spy_data.spy_number > 0) {
|
2005-05-13 02:48:20 +00:00
|
|
|
struct iw_quality wstats;
|
2005-09-13 22:35:21 +00:00
|
|
|
|
|
|
|
wstats.updated = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
if (rx_stats->mask & LIBIPW_STATMASK_RSSI) {
|
2008-05-08 17:15:40 +00:00
|
|
|
wstats.level = rx_stats->signal;
|
2005-09-13 22:35:21 +00:00
|
|
|
wstats.updated |= IW_QUAL_LEVEL_UPDATED;
|
|
|
|
} else
|
|
|
|
wstats.updated |= IW_QUAL_LEVEL_INVALID;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (rx_stats->mask & LIBIPW_STATMASK_NOISE) {
|
2005-09-13 22:35:21 +00:00
|
|
|
wstats.noise = rx_stats->noise;
|
|
|
|
wstats.updated |= IW_QUAL_NOISE_UPDATED;
|
|
|
|
} else
|
|
|
|
wstats.updated |= IW_QUAL_NOISE_INVALID;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (rx_stats->mask & LIBIPW_STATMASK_SIGNAL) {
|
2005-09-13 22:35:21 +00:00
|
|
|
wstats.qual = rx_stats->signal;
|
|
|
|
wstats.updated |= IW_QUAL_QUAL_UPDATED;
|
|
|
|
} else
|
|
|
|
wstats.updated |= IW_QUAL_QUAL_INVALID;
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Update spy records */
|
2005-09-13 22:35:21 +00:00
|
|
|
wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
2005-09-07 04:48:31 +00:00
|
|
|
#endif /* IW_WIRELESS_SPY */
|
2006-06-26 08:44:38 +00:00
|
|
|
#endif /* CONFIG_WIRELESS_EXT */
|
2005-09-13 22:35:21 +00:00
|
|
|
|
|
|
|
#ifdef NOT_YET
|
2005-05-13 02:48:20 +00:00
|
|
|
hostap_update_rx_stats(local->ap, hdr, rx_stats);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR) {
|
2009-03-20 19:36:38 +00:00
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += skb->len;
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_monitor_rx(ieee, skb, rx_stats);
|
2005-05-13 02:48:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-01-19 08:20:42 +00:00
|
|
|
can_be_decrypted = (is_multicast_ether_addr(hdr->addr1) ||
|
|
|
|
is_broadcast_ether_addr(hdr->addr2)) ?
|
|
|
|
ieee->host_mc_decrypt : ieee->host_decrypt;
|
|
|
|
|
|
|
|
if (can_be_decrypted) {
|
|
|
|
if (skb->len >= hdrlen + 3) {
|
|
|
|
/* Top two-bits of byte 3 are the key index */
|
2006-09-27 02:50:31 +00:00
|
|
|
keyidx = skb->data[hdrlen + 3] >> 6;
|
2006-01-19 08:20:42 +00:00
|
|
|
}
|
|
|
|
|
2006-09-27 02:50:31 +00:00
|
|
|
/* ieee->crypt[] is WEP_KEY (4) in length. Given that keyidx
|
|
|
|
* is only allowed 2-bits of storage, no value of keyidx can
|
|
|
|
* be provided via above code that would result in keyidx
|
2006-01-19 08:20:42 +00:00
|
|
|
* being out of range */
|
2008-10-29 15:35:05 +00:00
|
|
|
crypt = ieee->crypt_info.crypt[keyidx];
|
2006-01-19 08:20:42 +00:00
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
#ifdef NOT_YET
|
|
|
|
sta = NULL;
|
|
|
|
|
|
|
|
/* Use station specific key to override default keys if the
|
|
|
|
* receiver address is a unicast address ("individual RA"). If
|
|
|
|
* bcrx_sta_key parameter is set, station specific key is used
|
|
|
|
* even with broad/multicast targets (this is against IEEE
|
|
|
|
* 802.11, but makes it easier to use different keys with
|
|
|
|
* stations that do not support WEP key mapping). */
|
|
|
|
|
2011-07-04 00:00:22 +00:00
|
|
|
if (is_unicast_ether_addr(hdr->addr1) || local->bcrx_sta_key)
|
2005-09-07 04:48:31 +00:00
|
|
|
(void)hostap_handle_sta_crypto(local, hdr, &crypt,
|
|
|
|
&sta);
|
2005-05-13 02:48:20 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* allow NULL decrypt to indicate an station specific override
|
|
|
|
* for default encryption */
|
|
|
|
if (crypt && (crypt->ops == NULL ||
|
|
|
|
crypt->ops->decrypt_mpdu == NULL))
|
|
|
|
crypt = NULL;
|
|
|
|
|
2005-08-26 00:11:46 +00:00
|
|
|
if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* This seems to be triggered by some (multicast?)
|
|
|
|
* frames from other than current BSS, so just drop the
|
|
|
|
* frames silently instead of filling system log with
|
|
|
|
* these reports. */
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP("Decryption failed (not set)"
|
2008-10-27 22:59:26 +00:00
|
|
|
" (SA=%pM)\n", hdr->addr2);
|
2005-05-13 02:48:20 +00:00
|
|
|
ieee->ieee_stats.rx_discards_undecryptable++;
|
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef NOT_YET
|
|
|
|
if (type != WLAN_FC_TYPE_DATA) {
|
|
|
|
if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
|
2005-08-26 00:11:46 +00:00
|
|
|
fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
|
2005-09-07 04:48:31 +00:00
|
|
|
(keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) {
|
2005-05-13 02:48:20 +00:00
|
|
|
printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
|
2008-10-27 22:59:26 +00:00
|
|
|
"from %pM\n", dev->name, hdr->addr2);
|
2005-05-13 02:48:20 +00:00
|
|
|
/* TODO: could inform hostapd about this so that it
|
|
|
|
* could send auth failure report */
|
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
else
|
|
|
|
goto rx_exit;
|
|
|
|
}
|
|
|
|
#endif
|
2006-10-03 23:49:32 +00:00
|
|
|
/* drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.29) */
|
|
|
|
if (sc == ieee->prev_seq_ctl)
|
|
|
|
goto rx_dropped;
|
|
|
|
else
|
|
|
|
ieee->prev_seq_ctl = sc;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
/* Data frame - extract src/dst addresses */
|
2009-08-20 18:48:03 +00:00
|
|
|
if (skb->len < LIBIPW_3ADDR_LEN)
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
|
|
|
|
switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
|
|
|
|
case IEEE80211_FCTL_FROMDS:
|
|
|
|
memcpy(dst, hdr->addr1, ETH_ALEN);
|
|
|
|
memcpy(src, hdr->addr3, ETH_ALEN);
|
|
|
|
break;
|
|
|
|
case IEEE80211_FCTL_TODS:
|
|
|
|
memcpy(dst, hdr->addr3, ETH_ALEN);
|
|
|
|
memcpy(src, hdr->addr2, ETH_ALEN);
|
|
|
|
break;
|
|
|
|
case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
|
2009-08-20 18:48:03 +00:00
|
|
|
if (skb->len < LIBIPW_4ADDR_LEN)
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
memcpy(dst, hdr->addr3, ETH_ALEN);
|
|
|
|
memcpy(src, hdr->addr4, ETH_ALEN);
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
memcpy(dst, hdr->addr1, ETH_ALEN);
|
|
|
|
memcpy(src, hdr->addr2, ETH_ALEN);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOT_YET
|
|
|
|
if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
|
|
|
|
goto rx_dropped;
|
|
|
|
if (wds) {
|
|
|
|
skb->dev = dev = wds;
|
|
|
|
stats = hostap_get_stats(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
|
2005-09-07 04:48:31 +00:00
|
|
|
(fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
|
|
|
|
IEEE80211_FCTL_FROMDS && ieee->stadev
|
2006-01-10 00:01:43 +00:00
|
|
|
&& !compare_ether_addr(hdr->addr2, ieee->assoc_ap_addr)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Frame from BSSID of the AP for which we are a client */
|
|
|
|
skb->dev = dev = ieee->stadev;
|
|
|
|
stats = hostap_get_stats(dev);
|
|
|
|
from_assoc_ap = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NOT_YET
|
|
|
|
if ((ieee->iw_mode == IW_MODE_MASTER ||
|
2005-09-07 04:48:31 +00:00
|
|
|
ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) {
|
2005-05-13 02:48:20 +00:00
|
|
|
switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
|
|
|
|
wds != NULL)) {
|
|
|
|
case AP_RX_CONTINUE_NOT_AUTHORIZED:
|
|
|
|
frame_authorized = 0;
|
|
|
|
break;
|
|
|
|
case AP_RX_CONTINUE:
|
|
|
|
frame_authorized = 1;
|
|
|
|
break;
|
|
|
|
case AP_RX_DROP:
|
|
|
|
goto rx_dropped;
|
|
|
|
case AP_RX_EXIT:
|
|
|
|
goto rx_exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Nullfunc frames may have PS-bit set, so they must be passed to
|
|
|
|
* hostap_handle_sta_rx() before being dropped here. */
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
stype &= ~IEEE80211_STYPE_QOS_DATA;
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
if (stype != IEEE80211_STYPE_DATA &&
|
|
|
|
stype != IEEE80211_STYPE_DATA_CFACK &&
|
|
|
|
stype != IEEE80211_STYPE_DATA_CFPOLL &&
|
|
|
|
stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
|
|
|
|
if (stype != IEEE80211_STYPE_NULLFUNC)
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP("RX: dropped data frame "
|
2005-09-07 04:48:31 +00:00
|
|
|
"with no data (type=0x%02x, "
|
|
|
|
"subtype=0x%02x, len=%d)\n",
|
|
|
|
type, stype, skb->len);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* skb: hdr + (possibly fragmented, possibly encrypted) payload */
|
|
|
|
|
2006-01-19 08:20:42 +00:00
|
|
|
if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
|
2009-08-20 18:48:03 +00:00
|
|
|
(keyidx = libipw_rx_frame_decrypt(ieee, skb, crypt)) < 0)
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_4addr *)skb->data;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
/* skb: hdr + (possibly fragmented) plaintext payload */
|
|
|
|
// PR: FIXME: hostap has additional conditions in the "if" below:
|
2005-08-26 00:11:46 +00:00
|
|
|
// ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
|
2006-01-22 11:57:10 +00:00
|
|
|
if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
int flen;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct sk_buff *frag_skb = libipw_frag_cache_get(ieee, hdr);
|
|
|
|
LIBIPW_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
if (!frag_skb) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG(LIBIPW_DL_RX | LIBIPW_DL_FRAG,
|
2005-05-13 02:48:20 +00:00
|
|
|
"Rx cannot get skb from fragment "
|
|
|
|
"cache (morefrag=%d seq=%u frag=%u)\n",
|
|
|
|
(fc & IEEE80211_FCTL_MOREFRAGS) != 0,
|
|
|
|
WLAN_GET_SEQ_SEQ(sc), frag);
|
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
|
|
|
flen = skb->len;
|
|
|
|
if (frag != 0)
|
|
|
|
flen -= hdrlen;
|
|
|
|
|
2007-04-20 03:43:29 +00:00
|
|
|
if (frag_skb->tail + flen > frag_skb->end) {
|
2005-05-13 02:48:20 +00:00
|
|
|
printk(KERN_WARNING "%s: host decrypted and "
|
|
|
|
"reassembled frame did not fit skb\n",
|
|
|
|
dev->name);
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_frag_cache_invalidate(ieee, hdr);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frag == 0) {
|
|
|
|
/* copy first fragment (including full headers) into
|
|
|
|
* beginning of the fragment cache skb */
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(skb, skb_put(frag_skb, flen), flen);
|
2005-05-13 02:48:20 +00:00
|
|
|
} else {
|
|
|
|
/* append frame payload to the end of the fragment
|
|
|
|
* cache skb */
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data_offset(skb, hdrlen,
|
|
|
|
skb_put(frag_skb, flen), flen);
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
skb = NULL;
|
|
|
|
|
|
|
|
if (fc & IEEE80211_FCTL_MOREFRAGS) {
|
|
|
|
/* more fragments expected - leave the skb in fragment
|
|
|
|
* cache for now; it will be delivered to upper layers
|
|
|
|
* after all fragments have been received */
|
|
|
|
goto rx_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this was the last fragment and the frame will be
|
|
|
|
* delivered, so remove skb from fragment cache */
|
|
|
|
skb = frag_skb;
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_4addr *)skb->data;
|
|
|
|
libipw_frag_cache_invalidate(ieee, hdr);
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* skb: hdr + (possible reassembled) full MSDU payload; possibly still
|
|
|
|
* encrypted/authenticated */
|
2006-01-19 08:20:42 +00:00
|
|
|
if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_4addr *)skb->data;
|
2005-08-26 00:11:46 +00:00
|
|
|
if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
|
2005-09-07 04:48:31 +00:00
|
|
|
if ( /*ieee->ieee802_1x && */
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_is_eapol_frame(ieee, skb)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* pass unencrypted EAPOL frames even if encryption is
|
|
|
|
* configured */
|
|
|
|
} else {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP("encryption configured, but RX "
|
2008-10-27 22:59:26 +00:00
|
|
|
"frame not encrypted (SA=%pM)\n",
|
|
|
|
hdr->addr2);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-26 00:11:46 +00:00
|
|
|
if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
|
2009-08-20 18:48:03 +00:00
|
|
|
!libipw_is_eapol_frame(ieee, skb)) {
|
|
|
|
LIBIPW_DEBUG_DROP("dropped unencrypted RX data "
|
2008-10-27 22:59:26 +00:00
|
|
|
"frame from %pM (drop_unencrypted=1)\n",
|
|
|
|
hdr->addr2);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
2006-09-27 02:50:31 +00:00
|
|
|
/* If the frame was decrypted in hardware, we may need to strip off
|
|
|
|
* any security data (IV, ICV, etc) that was left behind */
|
|
|
|
if (!can_be_decrypted && (fc & IEEE80211_FCTL_PROTECTED) &&
|
|
|
|
ieee->host_strip_iv_icv) {
|
2007-02-09 14:24:46 +00:00
|
|
|
int trimlen = 0;
|
2006-09-27 02:50:31 +00:00
|
|
|
|
|
|
|
/* Top two-bits of byte 3 are the key index */
|
|
|
|
if (skb->len >= hdrlen + 3)
|
|
|
|
keyidx = skb->data[hdrlen + 3] >> 6;
|
|
|
|
|
|
|
|
/* To strip off any security data which appears before the
|
|
|
|
* payload, we simply increase hdrlen (as the header gets
|
|
|
|
* chopped off immediately below). For the security data which
|
|
|
|
* appears after the payload, we use skb_trim. */
|
|
|
|
|
|
|
|
switch (ieee->sec.encode_alg[keyidx]) {
|
|
|
|
case SEC_ALG_WEP:
|
|
|
|
/* 4 byte IV */
|
|
|
|
hdrlen += 4;
|
|
|
|
/* 4 byte ICV */
|
|
|
|
trimlen = 4;
|
|
|
|
break;
|
|
|
|
case SEC_ALG_TKIP:
|
|
|
|
/* 4 byte IV, 4 byte ExtIV */
|
|
|
|
hdrlen += 8;
|
|
|
|
/* 8 byte MIC, 4 byte ICV */
|
|
|
|
trimlen = 12;
|
|
|
|
break;
|
|
|
|
case SEC_ALG_CCMP:
|
|
|
|
/* 8 byte CCMP header */
|
|
|
|
hdrlen += 8;
|
|
|
|
/* 8 byte MIC */
|
|
|
|
trimlen = 8;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb->len < trimlen)
|
|
|
|
goto rx_dropped;
|
|
|
|
|
|
|
|
__skb_trim(skb, skb->len - trimlen);
|
|
|
|
|
|
|
|
if (skb->len < hdrlen)
|
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
/* skb: hdr + (possible reassembled) full plaintext payload */
|
|
|
|
|
|
|
|
payload = skb->data + hdrlen;
|
|
|
|
ethertype = (payload[6] << 8) | payload[7];
|
|
|
|
|
|
|
|
#ifdef NOT_YET
|
|
|
|
/* If IEEE 802.1X is used, check whether the port is authorized to send
|
|
|
|
* the received frame. */
|
|
|
|
if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
|
|
|
|
if (ethertype == ETH_P_PAE) {
|
|
|
|
printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
|
|
|
|
dev->name);
|
|
|
|
if (ieee->hostapd && ieee->apdev) {
|
|
|
|
/* Send IEEE 802.1X frames to the user
|
|
|
|
* space daemon for processing */
|
|
|
|
prism2_rx_80211(ieee->apdev, skb, rx_stats,
|
|
|
|
PRISM2_RX_MGMT);
|
|
|
|
ieee->apdevstats.rx_packets++;
|
|
|
|
ieee->apdevstats.rx_bytes += skb->len;
|
|
|
|
goto rx_exit;
|
|
|
|
}
|
|
|
|
} else if (!frame_authorized) {
|
|
|
|
printk(KERN_DEBUG "%s: dropped frame from "
|
|
|
|
"unauthorized port (IEEE 802.1X): "
|
2005-09-07 04:48:31 +00:00
|
|
|
"ethertype=0x%04x\n", dev->name, ethertype);
|
2005-05-13 02:48:20 +00:00
|
|
|
goto rx_dropped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* convert hdr + possible LLC headers into Ethernet header */
|
|
|
|
if (skb->len - hdrlen >= 8 &&
|
2009-08-20 18:48:03 +00:00
|
|
|
((memcmp(payload, libipw_rfc1042_header, SNAP_SIZE) == 0 &&
|
2005-05-13 02:48:20 +00:00
|
|
|
ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
|
2009-08-20 18:48:03 +00:00
|
|
|
memcmp(payload, libipw_bridge_tunnel_header, SNAP_SIZE) == 0)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* remove RFC1042 or Bridge-Tunnel encapsulation and
|
|
|
|
* replace EtherType */
|
|
|
|
skb_pull(skb, hdrlen + SNAP_SIZE);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
|
|
|
|
} else {
|
2007-12-29 10:01:07 +00:00
|
|
|
__be16 len;
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Leave Ethernet header part of hdr and full payload */
|
|
|
|
skb_pull(skb, hdrlen);
|
|
|
|
len = htons(skb->len);
|
|
|
|
memcpy(skb_push(skb, 2), &len, 2);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
|
|
|
|
memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NOT_YET
|
|
|
|
if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
|
2005-09-07 04:48:31 +00:00
|
|
|
IEEE80211_FCTL_TODS) && skb->len >= ETH_HLEN + ETH_ALEN) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* Non-standard frame: get addr4 from its bogus location after
|
|
|
|
* the payload */
|
2007-03-31 14:55:19 +00:00
|
|
|
skb_copy_to_linear_data_offset(skb, ETH_ALEN,
|
|
|
|
skb->data + skb->len - ETH_ALEN,
|
|
|
|
ETH_ALEN);
|
2005-05-13 02:48:20 +00:00
|
|
|
skb_trim(skb, skb->len - ETH_ALEN);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-03-20 19:36:38 +00:00
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += skb->len;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
#ifdef NOT_YET
|
2005-09-07 04:48:31 +00:00
|
|
|
if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) {
|
2011-07-04 00:00:22 +00:00
|
|
|
if (is_multicast_ether_addr(dst)) {
|
2005-05-13 02:48:20 +00:00
|
|
|
/* copy multicast frame both to the higher layers and
|
|
|
|
* to the wireless media */
|
|
|
|
ieee->ap->bridged_multicast++;
|
|
|
|
skb2 = skb_clone(skb, GFP_ATOMIC);
|
|
|
|
if (skb2 == NULL)
|
|
|
|
printk(KERN_DEBUG "%s: skb_clone failed for "
|
|
|
|
"multicast frame\n", dev->name);
|
|
|
|
} else if (hostap_is_sta_assoc(ieee->ap, dst)) {
|
|
|
|
/* send frame directly to the associated STA using
|
|
|
|
* wireless media and not passing to higher layers */
|
|
|
|
ieee->ap->bridged_unicast++;
|
|
|
|
skb2 = skb;
|
|
|
|
skb = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb2 != NULL) {
|
|
|
|
/* send to wireless media */
|
2007-03-19 22:30:44 +00:00
|
|
|
skb2->dev = dev;
|
2007-12-11 18:52:26 +00:00
|
|
|
skb2->protocol = htons(ETH_P_802_3);
|
2007-03-19 22:30:44 +00:00
|
|
|
skb_reset_mac_header(skb2);
|
2007-04-11 03:45:18 +00:00
|
|
|
skb_reset_network_header(skb2);
|
2007-04-11 04:21:55 +00:00
|
|
|
/* skb2->network_header += ETH_HLEN; */
|
2005-05-13 02:48:20 +00:00
|
|
|
dev_queue_xmit(skb2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (skb) {
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
memset(skb->cb, 0, sizeof(skb->cb));
|
2005-09-07 04:48:31 +00:00
|
|
|
skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
|
2006-01-19 08:20:49 +00:00
|
|
|
if (netif_rx(skb) == NET_RX_DROP) {
|
|
|
|
/* netif_rx always succeeds, but it might drop
|
|
|
|
* the packet. If it drops the packet, we log that
|
|
|
|
* in our stats. */
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_DROP
|
2006-01-19 08:20:49 +00:00
|
|
|
("RX: netif_rx dropped the packet\n");
|
2009-03-20 19:36:38 +00:00
|
|
|
dev->stats.rx_dropped++;
|
2006-01-19 08:20:49 +00:00
|
|
|
}
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
|
2005-09-07 04:48:31 +00:00
|
|
|
rx_exit:
|
2005-05-13 02:48:20 +00:00
|
|
|
#ifdef NOT_YET
|
|
|
|
if (sta)
|
|
|
|
hostap_handle_sta_release(sta);
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
|
2005-09-07 04:48:31 +00:00
|
|
|
rx_dropped:
|
2009-03-20 19:36:38 +00:00
|
|
|
dev->stats.rx_dropped++;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
/* Returning 0 indicates to caller that we have not handled the SKB--
|
|
|
|
* so it is still allocated and can be used again by underlying
|
|
|
|
* hardware as a DMA target */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
/* Filter out unrelated packets, call libipw_rx[_mgt]
|
2006-07-18 20:38:05 +00:00
|
|
|
* This function takes over the skb, it should not be used again after calling
|
|
|
|
* this function. */
|
2009-08-20 18:48:03 +00:00
|
|
|
void libipw_rx_any(struct libipw_device *ieee,
|
|
|
|
struct sk_buff *skb, struct libipw_rx_stats *stats)
|
2006-01-24 14:57:11 +00:00
|
|
|
{
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_hdr_4addr *hdr;
|
2006-01-24 14:57:11 +00:00
|
|
|
int is_packet_for_us;
|
|
|
|
u16 fc;
|
|
|
|
|
2006-07-18 20:38:05 +00:00
|
|
|
if (ieee->iw_mode == IW_MODE_MONITOR) {
|
2009-08-20 18:48:03 +00:00
|
|
|
if (!libipw_rx(ieee, skb, stats))
|
2006-07-18 20:38:05 +00:00
|
|
|
dev_kfree_skb_irq(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb->len < sizeof(struct ieee80211_hdr))
|
|
|
|
goto drop_free;
|
2006-01-24 14:57:11 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
hdr = (struct libipw_hdr_4addr *)skb->data;
|
2006-01-24 14:57:11 +00:00
|
|
|
fc = le16_to_cpu(hdr->frame_ctl);
|
|
|
|
|
|
|
|
if ((fc & IEEE80211_FCTL_VERS) != 0)
|
2006-07-18 20:38:05 +00:00
|
|
|
goto drop_free;
|
2007-02-09 14:24:46 +00:00
|
|
|
|
2006-01-24 14:57:11 +00:00
|
|
|
switch (fc & IEEE80211_FCTL_FTYPE) {
|
|
|
|
case IEEE80211_FTYPE_MGMT:
|
2009-08-20 18:48:03 +00:00
|
|
|
if (skb->len < sizeof(struct libipw_hdr_3addr))
|
2006-07-18 20:38:05 +00:00
|
|
|
goto drop_free;
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_rx_mgt(ieee, hdr, stats);
|
2006-07-18 20:38:05 +00:00
|
|
|
dev_kfree_skb_irq(skb);
|
|
|
|
return;
|
2006-01-24 14:57:11 +00:00
|
|
|
case IEEE80211_FTYPE_DATA:
|
|
|
|
break;
|
|
|
|
case IEEE80211_FTYPE_CTL:
|
2006-07-18 20:38:05 +00:00
|
|
|
return;
|
2006-01-24 14:57:11 +00:00
|
|
|
default:
|
2006-07-18 20:38:05 +00:00
|
|
|
return;
|
2006-01-24 14:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
is_packet_for_us = 0;
|
|
|
|
switch (ieee->iw_mode) {
|
|
|
|
case IW_MODE_ADHOC:
|
|
|
|
/* our BSS and not from/to DS */
|
|
|
|
if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0)
|
|
|
|
if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
|
|
|
|
/* promisc: get all */
|
|
|
|
if (ieee->dev->flags & IFF_PROMISC)
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
/* to us */
|
|
|
|
else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
/* mcast */
|
|
|
|
else if (is_multicast_ether_addr(hdr->addr1))
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case IW_MODE_INFRA:
|
|
|
|
/* our BSS (== from our AP) and from DS */
|
|
|
|
if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0)
|
|
|
|
if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
|
|
|
|
/* promisc: get all */
|
|
|
|
if (ieee->dev->flags & IFF_PROMISC)
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
/* to us */
|
|
|
|
else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
/* mcast */
|
|
|
|
else if (is_multicast_ether_addr(hdr->addr1)) {
|
|
|
|
/* not our own packet bcasted from AP */
|
|
|
|
if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN))
|
|
|
|
is_packet_for_us = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ? */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_packet_for_us)
|
2009-08-20 18:48:03 +00:00
|
|
|
if (!libipw_rx(ieee, skb, stats))
|
2006-07-18 20:38:05 +00:00
|
|
|
dev_kfree_skb_irq(skb);
|
|
|
|
return;
|
|
|
|
|
|
|
|
drop_free:
|
|
|
|
dev_kfree_skb_irq(skb);
|
2009-03-20 19:36:38 +00:00
|
|
|
ieee->dev->stats.rx_dropped++;
|
2006-01-24 14:57:11 +00:00
|
|
|
}
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
|
|
|
|
|
2005-09-21 16:56:33 +00:00
|
|
|
static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
|
|
|
|
|
|
|
|
/*
|
2011-03-31 01:57:33 +00:00
|
|
|
* Make the structure we read from the beacon packet to have
|
2005-09-21 16:56:33 +00:00
|
|
|
* the right values
|
|
|
|
*/
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_verify_qos_info(struct libipw_qos_information_element
|
2005-09-21 16:56:33 +00:00
|
|
|
*info_element, int sub_type)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (info_element->qui_subtype != sub_type)
|
|
|
|
return -1;
|
|
|
|
if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
|
|
|
|
return -1;
|
|
|
|
if (info_element->qui_type != QOS_OUI_TYPE)
|
|
|
|
return -1;
|
|
|
|
if (info_element->version != QOS_VERSION_1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse a QoS parameter element
|
|
|
|
*/
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_read_qos_param_element(struct libipw_qos_parameter_info
|
|
|
|
*element_param, struct libipw_info_element
|
2005-09-21 16:56:33 +00:00
|
|
|
*info_element)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
u16 size = sizeof(struct libipw_qos_parameter_info) - 2;
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
if ((info_element == NULL) || (element_param == NULL))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
|
|
|
|
memcpy(element_param->info_element.qui, info_element->data,
|
|
|
|
info_element->len);
|
|
|
|
element_param->info_element.elementID = info_element->id;
|
|
|
|
element_param->info_element.length = info_element->len;
|
|
|
|
} else
|
|
|
|
ret = -1;
|
|
|
|
if (ret == 0)
|
2009-08-20 18:48:03 +00:00
|
|
|
ret = libipw_verify_qos_info(&element_param->info_element,
|
2005-09-21 16:56:33 +00:00
|
|
|
QOS_OUI_PARAM_SUB_TYPE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse a QoS information element
|
|
|
|
*/
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_read_qos_info_element(struct
|
|
|
|
libipw_qos_information_element
|
|
|
|
*element_info, struct libipw_info_element
|
2005-09-21 16:56:33 +00:00
|
|
|
*info_element)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
u16 size = sizeof(struct libipw_qos_information_element) - 2;
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
if (element_info == NULL)
|
|
|
|
return -1;
|
|
|
|
if (info_element == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
|
|
|
|
memcpy(element_info->qui, info_element->data,
|
|
|
|
info_element->len);
|
|
|
|
element_info->elementID = info_element->id;
|
|
|
|
element_info->length = info_element->len;
|
|
|
|
} else
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
if (ret == 0)
|
2009-08-20 18:48:03 +00:00
|
|
|
ret = libipw_verify_qos_info(element_info,
|
2005-09-21 16:56:33 +00:00
|
|
|
QOS_OUI_INFO_SUB_TYPE);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write QoS parameters from the ac parameters.
|
|
|
|
*/
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_qos_convert_ac_to_parameters(struct
|
|
|
|
libipw_qos_parameter_info
|
2005-09-21 16:56:33 +00:00
|
|
|
*param_elm, struct
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_qos_parameters
|
2005-09-21 16:56:33 +00:00
|
|
|
*qos_param)
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
int i;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_qos_ac_parameter *ac_params;
|
2005-09-21 16:56:33 +00:00
|
|
|
u32 txop;
|
|
|
|
u8 cw_min;
|
|
|
|
u8 cw_max;
|
|
|
|
|
|
|
|
for (i = 0; i < QOS_QUEUE_NUM; i++) {
|
|
|
|
ac_params = &(param_elm->ac_params_record[i]);
|
|
|
|
|
|
|
|
qos_param->aifs[i] = (ac_params->aci_aifsn) & 0x0F;
|
|
|
|
qos_param->aifs[i] -= (qos_param->aifs[i] < 2) ? 0 : 2;
|
|
|
|
|
|
|
|
cw_min = ac_params->ecw_min_max & 0x0F;
|
2007-12-27 06:25:40 +00:00
|
|
|
qos_param->cw_min[i] = cpu_to_le16((1 << cw_min) - 1);
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
cw_max = (ac_params->ecw_min_max & 0xF0) >> 4;
|
2007-12-27 06:25:40 +00:00
|
|
|
qos_param->cw_max[i] = cpu_to_le16((1 << cw_max) - 1);
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
qos_param->flag[i] =
|
|
|
|
(ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
|
|
|
|
|
|
|
|
txop = le16_to_cpu(ac_params->tx_op_limit) * 32;
|
2007-12-27 06:25:40 +00:00
|
|
|
qos_param->tx_op_limit[i] = cpu_to_le16(txop);
|
2005-09-21 16:56:33 +00:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we have a generic data element which it may contain QoS information or
|
|
|
|
* parameters element. check the information element length to decide
|
|
|
|
* which type to read
|
|
|
|
*/
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_parse_qos_info_param_IE(struct libipw_info_element
|
2005-09-21 16:56:33 +00:00
|
|
|
*info_element,
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network *network)
|
2005-09-21 16:56:33 +00:00
|
|
|
{
|
|
|
|
int rc = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_qos_parameters *qos_param = NULL;
|
|
|
|
struct libipw_qos_information_element qos_info_element;
|
2005-09-21 16:56:33 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
rc = libipw_read_qos_info_element(&qos_info_element, info_element);
|
2005-09-21 16:56:33 +00:00
|
|
|
|
|
|
|
if (rc == 0) {
|
|
|
|
network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
|
|
|
|
network->flags |= NETWORK_HAS_QOS_INFORMATION;
|
|
|
|
} else {
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_qos_parameter_info param_element;
|
2005-09-21 16:56:33 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
rc = libipw_read_qos_param_element(¶m_element,
|
2005-09-21 16:56:33 +00:00
|
|
|
info_element);
|
|
|
|
if (rc == 0) {
|
|
|
|
qos_param = &(network->qos_data.parameters);
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_qos_convert_ac_to_parameters(¶m_element,
|
2005-09-21 16:56:33 +00:00
|
|
|
qos_param);
|
|
|
|
network->flags |= NETWORK_HAS_QOS_PARAMETERS;
|
|
|
|
network->qos_data.param_count =
|
|
|
|
param_element.info_element.ac_info & 0x0F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rc == 0) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_QOS("QoS is supported\n");
|
2005-09-21 16:56:33 +00:00
|
|
|
network->qos_data.supported = 1;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2009-03-06 14:32:26 +00:00
|
|
|
#define MFIE_STRING(x) case WLAN_EID_ ##x: return #x
|
2006-01-19 08:22:15 +00:00
|
|
|
|
|
|
|
static const char *get_info_element_string(u16 id)
|
|
|
|
{
|
|
|
|
switch (id) {
|
|
|
|
MFIE_STRING(SSID);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(SUPP_RATES);
|
|
|
|
MFIE_STRING(FH_PARAMS);
|
|
|
|
MFIE_STRING(DS_PARAMS);
|
|
|
|
MFIE_STRING(CF_PARAMS);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(TIM);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(IBSS_PARAMS);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(COUNTRY);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(HP_PARAMS);
|
|
|
|
MFIE_STRING(HP_TABLE);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(REQUEST);
|
|
|
|
MFIE_STRING(CHALLENGE);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(PWR_CONSTRAINT);
|
|
|
|
MFIE_STRING(PWR_CAPABILITY);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(TPC_REQUEST);
|
|
|
|
MFIE_STRING(TPC_REPORT);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(SUPPORTED_CHANNELS);
|
|
|
|
MFIE_STRING(CHANNEL_SWITCH);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(MEASURE_REQUEST);
|
|
|
|
MFIE_STRING(MEASURE_REPORT);
|
|
|
|
MFIE_STRING(QUIET);
|
|
|
|
MFIE_STRING(IBSS_DFS);
|
|
|
|
MFIE_STRING(ERP_INFO);
|
|
|
|
MFIE_STRING(RSN);
|
2009-03-06 14:32:26 +00:00
|
|
|
MFIE_STRING(EXT_SUPP_RATES);
|
2006-01-19 08:22:15 +00:00
|
|
|
MFIE_STRING(GENERIC);
|
|
|
|
MFIE_STRING(QOS_PARAMETER);
|
|
|
|
default:
|
|
|
|
return "UNKNOWN";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_parse_info_param(struct libipw_info_element
|
2005-10-03 15:23:42 +00:00
|
|
|
*info_element, u16 length,
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network *network)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
2005-10-03 15:19:25 +00:00
|
|
|
u8 i;
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2005-05-13 02:48:20 +00:00
|
|
|
char rates_str[64];
|
|
|
|
char *p;
|
|
|
|
#endif
|
|
|
|
|
2005-10-03 15:19:25 +00:00
|
|
|
while (length >= sizeof(*info_element)) {
|
|
|
|
if (sizeof(*info_element) + info_element->len > length) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("Info elem: parse failed: "
|
2006-10-18 17:34:40 +00:00
|
|
|
"info_element->len + 2 > left : "
|
|
|
|
"info_element->len+2=%zd left=%d, id=%d.\n",
|
|
|
|
info_element->len +
|
|
|
|
sizeof(*info_element),
|
|
|
|
length, info_element->id);
|
2006-08-21 03:34:19 +00:00
|
|
|
/* We stop processing but don't return an error here
|
|
|
|
* because some misbehaviour APs break this rule. ie.
|
|
|
|
* Orinoco AP1000. */
|
|
|
|
break;
|
2005-09-07 04:48:31 +00:00
|
|
|
}
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
switch (info_element->id) {
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_SSID:
|
2005-05-13 02:48:20 +00:00
|
|
|
network->ssid_len = min(info_element->len,
|
2005-09-07 04:48:31 +00:00
|
|
|
(u8) IW_ESSID_MAX_SIZE);
|
|
|
|
memcpy(network->ssid, info_element->data,
|
|
|
|
network->ssid_len);
|
|
|
|
if (network->ssid_len < IW_ESSID_MAX_SIZE)
|
|
|
|
memset(network->ssid + network->ssid_len, 0,
|
2005-05-13 02:48:20 +00:00
|
|
|
IW_ESSID_MAX_SIZE - network->ssid_len);
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_SSID: '%s' len=%d.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, network->ssid,
|
|
|
|
network->ssid_len),
|
2008-09-30 21:17:26 +00:00
|
|
|
network->ssid_len);
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_SUPP_RATES:
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2005-05-13 02:48:20 +00:00
|
|
|
p = rates_str;
|
|
|
|
#endif
|
2005-09-21 16:56:33 +00:00
|
|
|
network->rates_len = min(info_element->len,
|
|
|
|
MAX_RATES_LENGTH);
|
2005-05-13 02:48:20 +00:00
|
|
|
for (i = 0; i < network->rates_len; i++) {
|
|
|
|
network->rates[i] = info_element->data[i];
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2005-09-21 16:56:33 +00:00
|
|
|
p += snprintf(p, sizeof(rates_str) -
|
|
|
|
(p - rates_str), "%02X ",
|
|
|
|
network->rates[i]);
|
2005-05-13 02:48:20 +00:00
|
|
|
#endif
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_is_ofdm_rate
|
2005-09-07 04:48:31 +00:00
|
|
|
(info_element->data[i])) {
|
2005-05-13 02:48:20 +00:00
|
|
|
network->flags |= NETWORK_HAS_OFDM;
|
|
|
|
if (info_element->data[i] &
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_BASIC_RATE_MASK)
|
2005-05-13 02:48:20 +00:00
|
|
|
network->flags &=
|
2005-09-07 04:48:31 +00:00
|
|
|
~NETWORK_HAS_CCK;
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_SUPP_RATES: '%s' (%d)\n",
|
2005-05-13 02:48:20 +00:00
|
|
|
rates_str, network->rates_len);
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_EXT_SUPP_RATES:
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2005-05-13 02:48:20 +00:00
|
|
|
p = rates_str;
|
|
|
|
#endif
|
2005-09-21 16:56:33 +00:00
|
|
|
network->rates_ex_len = min(info_element->len,
|
|
|
|
MAX_RATES_EX_LENGTH);
|
2005-05-13 02:48:20 +00:00
|
|
|
for (i = 0; i < network->rates_ex_len; i++) {
|
|
|
|
network->rates_ex[i] = info_element->data[i];
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2005-09-21 16:56:33 +00:00
|
|
|
p += snprintf(p, sizeof(rates_str) -
|
|
|
|
(p - rates_str), "%02X ",
|
|
|
|
network->rates[i]);
|
2005-05-13 02:48:20 +00:00
|
|
|
#endif
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_is_ofdm_rate
|
2005-09-07 04:48:31 +00:00
|
|
|
(info_element->data[i])) {
|
2005-05-13 02:48:20 +00:00
|
|
|
network->flags |= NETWORK_HAS_OFDM;
|
|
|
|
if (info_element->data[i] &
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_BASIC_RATE_MASK)
|
2005-05-13 02:48:20 +00:00
|
|
|
network->flags &=
|
2005-09-07 04:48:31 +00:00
|
|
|
~NETWORK_HAS_CCK;
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_EXT_SUPP_RATES: '%s' (%d)\n",
|
2005-05-13 02:48:20 +00:00
|
|
|
rates_str, network->rates_ex_len);
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_DS_PARAMS:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_DS_PARAMS: %d\n",
|
2005-05-13 02:48:20 +00:00
|
|
|
info_element->data[0]);
|
2005-10-03 15:19:25 +00:00
|
|
|
network->channel = info_element->data[0];
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_FH_PARAMS:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_FH_PARAMS: ignored\n");
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_CF_PARAMS:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_CF_PARAMS: ignored\n");
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_TIM:
|
2006-01-19 08:22:23 +00:00
|
|
|
network->tim.tim_count = info_element->data[0];
|
|
|
|
network->tim.tim_period = info_element->data[1];
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_TIM: partially ignored\n");
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_ERP_INFO:
|
2005-09-21 16:58:29 +00:00
|
|
|
network->erp_value = info_element->data[0];
|
2006-07-18 20:30:34 +00:00
|
|
|
network->flags |= NETWORK_HAS_ERP_VALUE;
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
|
2005-09-21 16:58:29 +00:00
|
|
|
network->erp_value);
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_IBSS_PARAMS:
|
2005-09-21 16:58:29 +00:00
|
|
|
network->atim_window = info_element->data[0];
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_IBSS_PARAMS: %d\n",
|
2005-09-21 16:58:29 +00:00
|
|
|
network->atim_window);
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_CHALLENGE:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_CHALLENGE: ignored\n");
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_GENERIC:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_GENERIC: %d bytes\n",
|
2005-05-13 02:48:20 +00:00
|
|
|
info_element->len);
|
2009-08-20 18:48:03 +00:00
|
|
|
if (!libipw_parse_qos_info_param_IE(info_element,
|
2005-09-21 16:56:33 +00:00
|
|
|
network))
|
|
|
|
break;
|
|
|
|
|
2005-09-07 04:48:31 +00:00
|
|
|
if (info_element->len >= 4 &&
|
2005-05-13 02:48:20 +00:00
|
|
|
info_element->data[0] == 0x00 &&
|
|
|
|
info_element->data[1] == 0x50 &&
|
|
|
|
info_element->data[2] == 0xf2 &&
|
|
|
|
info_element->data[3] == 0x01) {
|
|
|
|
network->wpa_ie_len = min(info_element->len + 2,
|
2005-09-07 04:48:31 +00:00
|
|
|
MAX_WPA_IE_LEN);
|
2005-05-13 02:48:20 +00:00
|
|
|
memcpy(network->wpa_ie, info_element,
|
|
|
|
network->wpa_ie_len);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_RSN:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("WLAN_EID_RSN: %d bytes\n",
|
2005-05-13 02:48:20 +00:00
|
|
|
info_element->len);
|
|
|
|
network->rsn_ie_len = min(info_element->len + 2,
|
2005-09-07 04:48:31 +00:00
|
|
|
MAX_WPA_IE_LEN);
|
2005-05-13 02:48:20 +00:00
|
|
|
memcpy(network->rsn_ie, info_element,
|
|
|
|
network->rsn_ie_len);
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_QOS_PARAMETER:
|
2005-10-03 15:23:42 +00:00
|
|
|
printk(KERN_ERR
|
|
|
|
"QoS Error need to parse QOS_PARAMETER IE\n");
|
2005-09-21 16:56:33 +00:00
|
|
|
break;
|
2006-01-19 08:22:15 +00:00
|
|
|
/* 802.11h */
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_PWR_CONSTRAINT:
|
2006-01-19 08:22:15 +00:00
|
|
|
network->power_constraint = info_element->data[0];
|
|
|
|
network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_CHANNEL_SWITCH:
|
2006-01-19 08:22:15 +00:00
|
|
|
network->power_constraint = info_element->data[0];
|
|
|
|
network->flags |= NETWORK_HAS_CSA;
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_QUIET:
|
2006-01-19 08:22:15 +00:00
|
|
|
network->quiet.count = info_element->data[0];
|
|
|
|
network->quiet.period = info_element->data[1];
|
|
|
|
network->quiet.duration = info_element->data[2];
|
|
|
|
network->quiet.offset = info_element->data[3];
|
|
|
|
network->flags |= NETWORK_HAS_QUIET;
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_IBSS_DFS:
|
2006-01-19 08:22:15 +00:00
|
|
|
if (network->ibss_dfs)
|
|
|
|
break;
|
2006-11-21 03:26:49 +00:00
|
|
|
network->ibss_dfs = kmemdup(info_element->data,
|
|
|
|
info_element->len,
|
|
|
|
GFP_ATOMIC);
|
2006-01-19 08:22:15 +00:00
|
|
|
if (!network->ibss_dfs)
|
|
|
|
return 1;
|
|
|
|
network->flags |= NETWORK_HAS_IBSS_DFS;
|
|
|
|
break;
|
|
|
|
|
2009-03-06 14:32:26 +00:00
|
|
|
case WLAN_EID_TPC_REPORT:
|
2006-01-19 08:22:15 +00:00
|
|
|
network->tpc_report.transmit_power =
|
|
|
|
info_element->data[0];
|
|
|
|
network->tpc_report.link_margin = info_element->data[1];
|
|
|
|
network->flags |= NETWORK_HAS_TPC_REPORT;
|
|
|
|
break;
|
2005-09-21 16:56:33 +00:00
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
default:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT
|
2006-01-19 08:22:15 +00:00
|
|
|
("Unsupported info element: %s (%d)\n",
|
|
|
|
get_info_element_string(info_element->id),
|
|
|
|
info_element->id);
|
2005-09-07 04:48:31 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2005-10-03 15:19:25 +00:00
|
|
|
length -= sizeof(*info_element) + info_element->len;
|
2005-10-03 15:23:42 +00:00
|
|
|
info_element =
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_info_element *)&info_element->
|
2005-10-03 15:23:42 +00:00
|
|
|
data[info_element->len];
|
2005-09-07 04:48:31 +00:00
|
|
|
}
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2005-10-03 15:19:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_handle_assoc_resp(struct libipw_device *ieee, struct libipw_assoc_response
|
|
|
|
*frame, struct libipw_rx_stats *stats)
|
2005-10-03 15:19:25 +00:00
|
|
|
{
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network network_resp = {
|
2006-01-19 08:22:15 +00:00
|
|
|
.ibss_dfs = NULL,
|
|
|
|
};
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network *network = &network_resp;
|
2005-10-03 15:19:25 +00:00
|
|
|
struct net_device *dev = ieee->dev;
|
|
|
|
|
|
|
|
network->flags = 0;
|
|
|
|
network->qos_data.active = 0;
|
|
|
|
network->qos_data.supported = 0;
|
|
|
|
network->qos_data.param_count = 0;
|
|
|
|
network->qos_data.old_param_count = 0;
|
|
|
|
|
|
|
|
//network->atim_window = le16_to_cpu(frame->aid) & (0x3FFF);
|
|
|
|
network->atim_window = le16_to_cpu(frame->aid);
|
|
|
|
network->listen_interval = le16_to_cpu(frame->status);
|
2005-10-03 15:20:47 +00:00
|
|
|
memcpy(network->bssid, frame->header.addr3, ETH_ALEN);
|
|
|
|
network->capability = le16_to_cpu(frame->capability);
|
|
|
|
network->last_scanned = jiffies;
|
|
|
|
network->rates_len = network->rates_ex_len = 0;
|
|
|
|
network->last_associate = 0;
|
|
|
|
network->ssid_len = 0;
|
2005-10-03 15:23:42 +00:00
|
|
|
network->erp_value =
|
|
|
|
(network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
|
2005-10-03 15:20:47 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (stats->freq == LIBIPW_52GHZ_BAND) {
|
2005-10-03 15:20:47 +00:00
|
|
|
/* for A band (No DS info) */
|
|
|
|
network->channel = stats->received_channel;
|
|
|
|
} else
|
|
|
|
network->flags |= NETWORK_HAS_CCK;
|
|
|
|
|
|
|
|
network->wpa_ie_len = 0;
|
|
|
|
network->rsn_ie_len = 0;
|
2005-10-03 15:19:25 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_parse_info_param
|
2005-10-03 15:23:42 +00:00
|
|
|
(frame->info_element, stats->len - sizeof(*frame), network))
|
2005-10-03 15:19:25 +00:00
|
|
|
return 1;
|
|
|
|
|
2005-10-03 15:20:47 +00:00
|
|
|
network->mode = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
if (stats->freq == LIBIPW_52GHZ_BAND)
|
2005-10-03 15:20:47 +00:00
|
|
|
network->mode = IEEE_A;
|
|
|
|
else {
|
|
|
|
if (network->flags & NETWORK_HAS_OFDM)
|
|
|
|
network->mode |= IEEE_G;
|
|
|
|
if (network->flags & NETWORK_HAS_CCK)
|
|
|
|
network->mode |= IEEE_B;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&network->stats, stats, sizeof(network->stats));
|
|
|
|
|
2005-10-03 15:19:25 +00:00
|
|
|
if (ieee->handle_assoc_response != NULL)
|
|
|
|
ieee->handle_assoc_response(dev, frame, network);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***************************************************/
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static int libipw_network_init(struct libipw_device *ieee, struct libipw_probe_response
|
2005-10-03 15:19:25 +00:00
|
|
|
*beacon,
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network *network,
|
|
|
|
struct libipw_rx_stats *stats)
|
2005-10-03 15:19:25 +00:00
|
|
|
{
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
|
|
|
|
2005-10-03 15:19:25 +00:00
|
|
|
network->qos_data.active = 0;
|
|
|
|
network->qos_data.supported = 0;
|
|
|
|
network->qos_data.param_count = 0;
|
2005-10-03 15:20:47 +00:00
|
|
|
network->qos_data.old_param_count = 0;
|
2005-10-03 15:19:25 +00:00
|
|
|
|
|
|
|
/* Pull out fixed field data */
|
|
|
|
memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
|
|
|
|
network->capability = le16_to_cpu(beacon->capability);
|
|
|
|
network->last_scanned = jiffies;
|
|
|
|
network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
|
|
|
|
network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
|
|
|
|
network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
|
|
|
|
/* Where to pull this? beacon->listen_interval; */
|
|
|
|
network->listen_interval = 0x0A;
|
|
|
|
network->rates_len = network->rates_ex_len = 0;
|
|
|
|
network->last_associate = 0;
|
|
|
|
network->ssid_len = 0;
|
|
|
|
network->flags = 0;
|
|
|
|
network->atim_window = 0;
|
|
|
|
network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
|
|
|
|
0x3 : 0x0;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (stats->freq == LIBIPW_52GHZ_BAND) {
|
2005-10-03 15:19:25 +00:00
|
|
|
/* for A band (No DS info) */
|
|
|
|
network->channel = stats->received_channel;
|
|
|
|
} else
|
|
|
|
network->flags |= NETWORK_HAS_CCK;
|
|
|
|
|
|
|
|
network->wpa_ie_len = 0;
|
|
|
|
network->rsn_ie_len = 0;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_parse_info_param
|
2005-10-03 15:23:42 +00:00
|
|
|
(beacon->info_element, stats->len - sizeof(*beacon), network))
|
2005-10-03 15:19:25 +00:00
|
|
|
return 1;
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
network->mode = 0;
|
2009-08-20 18:48:03 +00:00
|
|
|
if (stats->freq == LIBIPW_52GHZ_BAND)
|
2005-05-13 02:48:20 +00:00
|
|
|
network->mode = IEEE_A;
|
|
|
|
else {
|
|
|
|
if (network->flags & NETWORK_HAS_OFDM)
|
|
|
|
network->mode |= IEEE_G;
|
|
|
|
if (network->flags & NETWORK_HAS_CCK)
|
|
|
|
network->mode |= IEEE_B;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (network->mode == 0) {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Filtered out '%s (%pM)' "
|
2005-05-13 02:48:20 +00:00
|
|
|
"network.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, network->ssid,
|
2008-09-24 22:13:14 +00:00
|
|
|
network->ssid_len),
|
2008-10-27 22:59:26 +00:00
|
|
|
network->bssid);
|
2005-05-13 02:48:20 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(&network->stats, stats, sizeof(network->stats));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static inline int is_same_network(struct libipw_network *src,
|
|
|
|
struct libipw_network *dst)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
|
|
|
/* A network is only a duplicate if the channel, BSSID, and ESSID
|
|
|
|
* all match. We treat all <hidden> with the same BSSID and channel
|
|
|
|
* as one network */
|
|
|
|
return ((src->ssid_len == dst->ssid_len) &&
|
|
|
|
(src->channel == dst->channel) &&
|
2006-01-10 00:01:43 +00:00
|
|
|
!compare_ether_addr(src->bssid, dst->bssid) &&
|
2005-05-13 02:48:20 +00:00
|
|
|
!memcmp(src->ssid, dst->ssid, src->ssid_len));
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static void update_network(struct libipw_network *dst,
|
|
|
|
struct libipw_network *src)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2005-09-21 16:56:33 +00:00
|
|
|
int qos_active;
|
|
|
|
u8 old_param;
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_network_reset(dst);
|
2006-01-19 08:22:15 +00:00
|
|
|
dst->ibss_dfs = src->ibss_dfs;
|
|
|
|
|
2006-03-08 19:14:45 +00:00
|
|
|
/* We only update the statistics if they were created by receiving
|
|
|
|
* the network information on the actual channel the network is on.
|
2007-02-09 14:24:46 +00:00
|
|
|
*
|
2006-03-08 19:14:45 +00:00
|
|
|
* This keeps beacons received on neighbor channels from bringing
|
|
|
|
* down the signal level of an AP. */
|
|
|
|
if (dst->channel == src->stats.received_channel)
|
|
|
|
memcpy(&dst->stats, &src->stats,
|
2009-08-20 18:48:03 +00:00
|
|
|
sizeof(struct libipw_rx_stats));
|
2006-03-08 19:14:45 +00:00
|
|
|
else
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Network %pM info received "
|
2008-10-27 22:59:26 +00:00
|
|
|
"off channel (%d vs. %d)\n", src->bssid,
|
2006-03-08 19:14:45 +00:00
|
|
|
dst->channel, src->stats.received_channel);
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
dst->capability = src->capability;
|
|
|
|
memcpy(dst->rates, src->rates, src->rates_len);
|
|
|
|
dst->rates_len = src->rates_len;
|
|
|
|
memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
|
|
|
|
dst->rates_ex_len = src->rates_ex_len;
|
|
|
|
|
|
|
|
dst->mode = src->mode;
|
|
|
|
dst->flags = src->flags;
|
|
|
|
dst->time_stamp[0] = src->time_stamp[0];
|
|
|
|
dst->time_stamp[1] = src->time_stamp[1];
|
|
|
|
|
|
|
|
dst->beacon_interval = src->beacon_interval;
|
|
|
|
dst->listen_interval = src->listen_interval;
|
|
|
|
dst->atim_window = src->atim_window;
|
2005-09-21 16:58:29 +00:00
|
|
|
dst->erp_value = src->erp_value;
|
2006-01-19 08:22:23 +00:00
|
|
|
dst->tim = src->tim;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
|
|
|
memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
|
|
|
|
dst->wpa_ie_len = src->wpa_ie_len;
|
|
|
|
memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
|
|
|
|
dst->rsn_ie_len = src->rsn_ie_len;
|
|
|
|
|
|
|
|
dst->last_scanned = jiffies;
|
2005-09-21 16:56:33 +00:00
|
|
|
qos_active = src->qos_data.active;
|
|
|
|
old_param = dst->qos_data.old_param_count;
|
|
|
|
if (dst->flags & NETWORK_HAS_QOS_MASK)
|
|
|
|
memcpy(&dst->qos_data, &src->qos_data,
|
2009-08-20 18:48:03 +00:00
|
|
|
sizeof(struct libipw_qos_data));
|
2005-09-21 16:56:33 +00:00
|
|
|
else {
|
|
|
|
dst->qos_data.supported = src->qos_data.supported;
|
|
|
|
dst->qos_data.param_count = src->qos_data.param_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dst->qos_data.supported == 1) {
|
|
|
|
if (dst->ssid_len)
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_QOS
|
2005-09-21 16:56:33 +00:00
|
|
|
("QoS the network %s is QoS supported\n",
|
|
|
|
dst->ssid);
|
|
|
|
else
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_QOS
|
2005-09-21 16:56:33 +00:00
|
|
|
("QoS the network is QoS supported\n");
|
|
|
|
}
|
|
|
|
dst->qos_data.active = qos_active;
|
|
|
|
dst->qos_data.old_param_count = old_param;
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
/* dst->last_associate is not overwritten */
|
|
|
|
}
|
|
|
|
|
2006-02-27 07:43:20 +00:00
|
|
|
static inline int is_beacon(__le16 fc)
|
2005-09-21 16:54:47 +00:00
|
|
|
{
|
|
|
|
return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
static void libipw_process_probe_response(struct libipw_device
|
2005-09-13 22:35:21 +00:00
|
|
|
*ieee, struct
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_probe_response
|
|
|
|
*beacon, struct libipw_rx_stats
|
2005-09-07 04:48:31 +00:00
|
|
|
*stats)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2005-09-21 16:54:47 +00:00
|
|
|
struct net_device *dev = ieee->dev;
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network network = {
|
2006-01-19 08:22:15 +00:00
|
|
|
.ibss_dfs = NULL,
|
|
|
|
};
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network *target;
|
|
|
|
struct libipw_network *oldest = NULL;
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_info_element *info_element = beacon->info_element;
|
2005-05-13 02:48:20 +00:00
|
|
|
#endif
|
|
|
|
unsigned long flags;
|
2008-10-01 00:59:05 +00:00
|
|
|
DECLARE_SSID_BUF(ssid);
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("'%s' (%pM"
|
2007-12-29 10:03:35 +00:00
|
|
|
"): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, info_element->data, info_element->len),
|
2008-10-27 22:59:26 +00:00
|
|
|
beacon->header.addr3,
|
2007-12-29 10:03:35 +00:00
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xd)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xc)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xb)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0xa)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x9)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x8)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x7)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x6)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x5)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x4)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x3)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x2)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x1)) ? '1' : '0',
|
|
|
|
(beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0');
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
if (libipw_network_init(ieee, beacon, &network, stats)) {
|
|
|
|
LIBIPW_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, info_element->data,
|
2008-09-24 22:13:14 +00:00
|
|
|
info_element->len),
|
2008-10-27 22:59:26 +00:00
|
|
|
beacon->header.addr3,
|
2006-02-27 07:43:20 +00:00
|
|
|
is_beacon(beacon->header.frame_ctl) ?
|
2005-09-21 16:54:47 +00:00
|
|
|
"BEACON" : "PROBE RESPONSE");
|
2005-05-13 02:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The network parsed correctly -- so now we scan our known networks
|
|
|
|
* to see if we can find it in our list.
|
|
|
|
*
|
|
|
|
* NOTE: This search is definitely not optimized. Once its doing
|
|
|
|
* the "right thing" we'll optimize it for efficiency if
|
|
|
|
* necessary */
|
|
|
|
|
|
|
|
/* Search for this entry in the list and update it if it is
|
|
|
|
* already there. */
|
|
|
|
|
|
|
|
spin_lock_irqsave(&ieee->lock, flags);
|
|
|
|
|
|
|
|
list_for_each_entry(target, &ieee->network_list, list) {
|
|
|
|
if (is_same_network(target, &network))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ((oldest == NULL) ||
|
2009-02-11 18:26:06 +00:00
|
|
|
time_before(target->last_scanned, oldest->last_scanned))
|
2005-05-13 02:48:20 +00:00
|
|
|
oldest = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we didn't find a match, then get a new network slot to initialize
|
|
|
|
* with this beacon's information */
|
|
|
|
if (&target->list == &ieee->network_list) {
|
|
|
|
if (list_empty(&ieee->network_free_list)) {
|
|
|
|
/* If there are no more slots, expire the oldest */
|
|
|
|
list_del(&oldest->list);
|
|
|
|
target = oldest;
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Expired '%s' (%pM) from "
|
2005-05-13 02:48:20 +00:00
|
|
|
"network list.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, target->ssid,
|
2008-09-24 22:13:14 +00:00
|
|
|
target->ssid_len),
|
2008-10-27 22:59:26 +00:00
|
|
|
target->bssid);
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_network_reset(target);
|
2005-05-13 02:48:20 +00:00
|
|
|
} else {
|
|
|
|
/* Otherwise just pull from the free list */
|
|
|
|
target = list_entry(ieee->network_free_list.next,
|
2009-08-20 18:48:03 +00:00
|
|
|
struct libipw_network, list);
|
2005-05-13 02:48:20 +00:00
|
|
|
list_del(ieee->network_free_list.next);
|
|
|
|
}
|
|
|
|
|
2009-03-06 11:02:25 +00:00
|
|
|
#ifdef CONFIG_LIBIPW_DEBUG
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, network.ssid,
|
2008-09-24 22:13:14 +00:00
|
|
|
network.ssid_len),
|
2008-10-27 22:59:26 +00:00
|
|
|
network.bssid,
|
2006-02-27 07:43:20 +00:00
|
|
|
is_beacon(beacon->header.frame_ctl) ?
|
2005-09-21 16:54:47 +00:00
|
|
|
"BEACON" : "PROBE RESPONSE");
|
2005-05-13 02:48:20 +00:00
|
|
|
#endif
|
|
|
|
memcpy(target, &network, sizeof(*target));
|
2006-01-19 08:22:15 +00:00
|
|
|
network.ibss_dfs = NULL;
|
2005-05-13 02:48:20 +00:00
|
|
|
list_add_tail(&target->list, &ieee->network_list);
|
|
|
|
} else {
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
|
2008-10-01 00:59:05 +00:00
|
|
|
print_ssid(ssid, target->ssid,
|
2008-09-24 22:13:14 +00:00
|
|
|
target->ssid_len),
|
2008-10-27 22:59:26 +00:00
|
|
|
target->bssid,
|
2006-02-27 07:43:20 +00:00
|
|
|
is_beacon(beacon->header.frame_ctl) ?
|
2005-09-21 16:54:47 +00:00
|
|
|
"BEACON" : "PROBE RESPONSE");
|
2005-05-13 02:48:20 +00:00
|
|
|
update_network(target, &network);
|
2006-01-19 08:22:15 +00:00
|
|
|
network.ibss_dfs = NULL;
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&ieee->lock, flags);
|
2005-09-21 16:54:47 +00:00
|
|
|
|
2006-02-27 07:43:20 +00:00
|
|
|
if (is_beacon(beacon->header.frame_ctl)) {
|
2005-09-21 16:54:47 +00:00
|
|
|
if (ieee->handle_beacon != NULL)
|
2006-03-08 02:50:20 +00:00
|
|
|
ieee->handle_beacon(dev, beacon, target);
|
2005-09-21 16:54:47 +00:00
|
|
|
} else {
|
|
|
|
if (ieee->handle_probe_response != NULL)
|
2006-03-08 02:50:20 +00:00
|
|
|
ieee->handle_probe_response(dev, beacon, target);
|
2005-09-21 16:54:47 +00:00
|
|
|
}
|
2005-05-13 02:48:20 +00:00
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
void libipw_rx_mgt(struct libipw_device *ieee,
|
|
|
|
struct libipw_hdr_4addr *header,
|
|
|
|
struct libipw_rx_stats *stats)
|
2005-05-13 02:48:20 +00:00
|
|
|
{
|
2005-09-13 22:25:51 +00:00
|
|
|
switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
|
2005-05-13 02:48:20 +00:00
|
|
|
case IEEE80211_STYPE_ASSOC_RESP:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
|
2005-09-13 22:25:51 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_handle_assoc_resp(ieee,
|
|
|
|
(struct libipw_assoc_response *)
|
2005-09-21 16:56:33 +00:00
|
|
|
header, stats);
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE80211_STYPE_REASSOC_RESP:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
|
2005-09-13 22:25:51 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
2005-09-21 16:58:29 +00:00
|
|
|
case IEEE80211_STYPE_PROBE_REQ:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received auth (%d)\n",
|
2005-09-21 16:58:29 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
|
|
|
|
|
|
|
if (ieee->handle_probe_request != NULL)
|
|
|
|
ieee->handle_probe_request(ieee->dev,
|
|
|
|
(struct
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_probe_request *)
|
2005-09-21 16:58:29 +00:00
|
|
|
header, stats);
|
|
|
|
break;
|
|
|
|
|
2005-05-13 02:48:20 +00:00
|
|
|
case IEEE80211_STYPE_PROBE_RESP:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
|
2005-09-13 22:25:51 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Probe response\n");
|
|
|
|
libipw_process_probe_response(ieee,
|
2005-09-07 04:48:31 +00:00
|
|
|
(struct
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_probe_response *)
|
2005-09-07 04:48:31 +00:00
|
|
|
header, stats);
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE80211_STYPE_BEACON:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received BEACON (%d)\n",
|
2005-09-13 22:25:51 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_SCAN("Beacon\n");
|
|
|
|
libipw_process_probe_response(ieee,
|
2005-09-07 04:48:31 +00:00
|
|
|
(struct
|
2009-08-20 18:48:03 +00:00
|
|
|
libipw_probe_response *)
|
2005-09-07 04:48:31 +00:00
|
|
|
header, stats);
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
2005-09-21 16:54:47 +00:00
|
|
|
case IEEE80211_STYPE_AUTH:
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received auth (%d)\n",
|
2005-09-21 16:54:47 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
|
|
|
|
|
|
|
if (ieee->handle_auth != NULL)
|
|
|
|
ieee->handle_auth(ieee->dev,
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_auth *)header);
|
2005-09-21 16:54:47 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE80211_STYPE_DISASSOC:
|
|
|
|
if (ieee->handle_disassoc != NULL)
|
|
|
|
ieee->handle_disassoc(ieee->dev,
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_disassoc *)
|
2005-09-21 16:54:47 +00:00
|
|
|
header);
|
|
|
|
break;
|
2005-05-13 02:48:20 +00:00
|
|
|
|
2006-01-19 08:22:15 +00:00
|
|
|
case IEEE80211_STYPE_ACTION:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("ACTION\n");
|
2006-01-19 08:22:15 +00:00
|
|
|
if (ieee->handle_action)
|
|
|
|
ieee->handle_action(ieee->dev,
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_action *)
|
2006-01-19 08:22:15 +00:00
|
|
|
header, stats);
|
|
|
|
break;
|
|
|
|
|
2006-01-31 05:25:10 +00:00
|
|
|
case IEEE80211_STYPE_REASSOC_REQ:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received reassoc (%d)\n",
|
2006-01-31 05:25:10 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("%s: LIBIPW_REASSOC_REQ received\n",
|
2006-04-13 09:17:47 +00:00
|
|
|
ieee->dev->name);
|
2006-01-31 05:25:10 +00:00
|
|
|
if (ieee->handle_reassoc_request != NULL)
|
|
|
|
ieee->handle_reassoc_request(ieee->dev,
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_reassoc_request *)
|
2006-01-31 05:25:10 +00:00
|
|
|
header);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IEEE80211_STYPE_ASSOC_REQ:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received assoc (%d)\n",
|
2006-01-31 05:25:10 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("%s: LIBIPW_ASSOC_REQ received\n",
|
2006-04-13 09:17:47 +00:00
|
|
|
ieee->dev->name);
|
2006-01-31 05:25:10 +00:00
|
|
|
if (ieee->handle_assoc_request != NULL)
|
|
|
|
ieee->handle_assoc_request(ieee->dev);
|
|
|
|
break;
|
|
|
|
|
2005-09-21 16:58:49 +00:00
|
|
|
case IEEE80211_STYPE_DEAUTH:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("DEAUTH\n");
|
2005-09-21 16:58:49 +00:00
|
|
|
if (ieee->handle_deauth != NULL)
|
2006-01-19 08:22:15 +00:00
|
|
|
ieee->handle_deauth(ieee->dev,
|
2009-08-20 18:48:03 +00:00
|
|
|
(struct libipw_deauth *)
|
2005-09-21 16:58:49 +00:00
|
|
|
header);
|
|
|
|
break;
|
2005-05-13 02:48:20 +00:00
|
|
|
default:
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("received UNKNOWN (%d)\n",
|
2005-09-13 22:25:51 +00:00
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2009-08-20 18:48:03 +00:00
|
|
|
LIBIPW_DEBUG_MGMT("%s: Unknown management packet: %d\n",
|
2006-04-13 09:17:47 +00:00
|
|
|
ieee->dev->name,
|
|
|
|
WLAN_FC_GET_STYPE(le16_to_cpu
|
|
|
|
(header->frame_ctl)));
|
2005-05-13 02:48:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-20 18:48:03 +00:00
|
|
|
EXPORT_SYMBOL_GPL(libipw_rx_any);
|
|
|
|
EXPORT_SYMBOL(libipw_rx_mgt);
|
|
|
|
EXPORT_SYMBOL(libipw_rx);
|