blob: 1e3f87c8c012b9120f307ab5c4108b1dfdaa70f7 [file] [log] [blame]
Jeff Garzikb4538722005-05-12 22:48:20 -04001/*
2 * Original code based Host AP (software wireless LAN access point) driver
3 * for Intersil Prism2/2.5/3 - hostap.o module, common routines
4 *
5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
Jouni Malinen85d32e72007-03-24 17:15:30 -07006 * <j@w1.fi>
7 * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
James Ketrenosebeaddc2005-09-21 11:58:43 -05008 * Copyright (c) 2004-2005, Intel Corporation
Jeff Garzikb4538722005-05-12 22:48:20 -04009 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. See README and COPYING for
13 * more details.
14 */
15
16#include <linux/compiler.h>
Jeff Garzikb4538722005-05-12 22:48:20 -040017#include <linux/errno.h>
18#include <linux/if_arp.h>
19#include <linux/in6.h>
20#include <linux/in.h>
21#include <linux/ip.h>
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/netdevice.h>
Jeff Garzikb4538722005-05-12 22:48:20 -040025#include <linux/proc_fs.h>
26#include <linux/skbuff.h>
27#include <linux/slab.h>
28#include <linux/tcp.h>
29#include <linux/types.h>
Jeff Garzikb4538722005-05-12 22:48:20 -040030#include <linux/wireless.h>
31#include <linux/etherdevice.h>
32#include <asm/uaccess.h>
33#include <linux/ctype.h>
34
35#include <net/ieee80211.h>
36
Arjan van de Ven858119e2006-01-14 13:20:43 -080037static void ieee80211_monitor_rx(struct ieee80211_device *ieee,
Jeff Garzikb4538722005-05-12 22:48:20 -040038 struct sk_buff *skb,
39 struct ieee80211_rx_stats *rx_stats)
40{
41 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
42 u16 fc = le16_to_cpu(hdr->frame_ctl);
43
44 skb->dev = ieee->dev;
Arnaldo Carvalho de Melo459a98e2007-03-19 15:30:44 -070045 skb_reset_mac_header(skb);
Jeff Garzikb4538722005-05-12 22:48:20 -040046 skb_pull(skb, ieee80211_get_hdrlen(fc));
47 skb->pkt_type = PACKET_OTHERHOST;
YOSHIFUJI Hideaki4e394302007-12-12 03:52:26 +090048 skb->protocol = htons(ETH_P_80211_RAW);
Jeff Garzikb4538722005-05-12 22:48:20 -040049 memset(skb->cb, 0, sizeof(skb->cb));
50 netif_rx(skb);
51}
52
Jeff Garzikb4538722005-05-12 22:48:20 -040053/* Called only as a tasklet (software IRQ) */
Jeff Garzik0edd5b42005-09-07 00:48:31 -040054static struct ieee80211_frag_entry *ieee80211_frag_cache_find(struct
55 ieee80211_device
56 *ieee,
57 unsigned int seq,
58 unsigned int frag,
59 u8 * src,
60 u8 * dst)
Jeff Garzikb4538722005-05-12 22:48:20 -040061{
62 struct ieee80211_frag_entry *entry;
63 int i;
64
65 for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
66 entry = &ieee->frag_cache[i];
67 if (entry->skb != NULL &&
68 time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
Jeff Garzik0edd5b42005-09-07 00:48:31 -040069 IEEE80211_DEBUG_FRAG("expiring fragment cache entry "
70 "seq=%u last_frag=%u\n",
71 entry->seq, entry->last_frag);
Jeff Garzikb4538722005-05-12 22:48:20 -040072 dev_kfree_skb_any(entry->skb);
73 entry->skb = NULL;
74 }
75
76 if (entry->skb != NULL && entry->seq == seq &&
77 (entry->last_frag + 1 == frag || frag == -1) &&
Kris Katterjohnd3f4a682006-01-09 16:01:43 -080078 !compare_ether_addr(entry->src_addr, src) &&
79 !compare_ether_addr(entry->dst_addr, dst))
Jeff Garzikb4538722005-05-12 22:48:20 -040080 return entry;
81 }
82
83 return NULL;
84}
85
86/* Called only as a tasklet (software IRQ) */
Jeff Garzik0edd5b42005-09-07 00:48:31 -040087static struct sk_buff *ieee80211_frag_cache_get(struct ieee80211_device *ieee,
James Ketrenosee34af32005-09-21 11:54:36 -050088 struct ieee80211_hdr_4addr *hdr)
Jeff Garzikb4538722005-05-12 22:48:20 -040089{
90 struct sk_buff *skb = NULL;
91 u16 sc;
92 unsigned int frag, seq;
93 struct ieee80211_frag_entry *entry;
94
95 sc = le16_to_cpu(hdr->seq_ctl);
96 frag = WLAN_GET_SEQ_FRAG(sc);
97 seq = WLAN_GET_SEQ_SEQ(sc);
98
99 if (frag == 0) {
100 /* Reserve enough space to fit maximum frame length */
101 skb = dev_alloc_skb(ieee->dev->mtu +
James Ketrenosee34af32005-09-21 11:54:36 -0500102 sizeof(struct ieee80211_hdr_4addr) +
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400103 8 /* LLC */ +
104 2 /* alignment */ +
105 8 /* WEP */ + ETH_ALEN /* WDS */ );
Jeff Garzikb4538722005-05-12 22:48:20 -0400106 if (skb == NULL)
107 return NULL;
108
109 entry = &ieee->frag_cache[ieee->frag_next_idx];
110 ieee->frag_next_idx++;
111 if (ieee->frag_next_idx >= IEEE80211_FRAG_CACHE_LEN)
112 ieee->frag_next_idx = 0;
113
114 if (entry->skb != NULL)
115 dev_kfree_skb_any(entry->skb);
116
117 entry->first_frag_time = jiffies;
118 entry->seq = seq;
119 entry->last_frag = frag;
120 entry->skb = skb;
121 memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
122 memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
123 } else {
124 /* received a fragment of a frame for which the head fragment
125 * should have already been received */
126 entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
127 hdr->addr1);
128 if (entry != NULL) {
129 entry->last_frag = frag;
130 skb = entry->skb;
131 }
132 }
133
134 return skb;
135}
136
Jeff Garzikb4538722005-05-12 22:48:20 -0400137/* Called only as a tasklet (software IRQ) */
138static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
James Ketrenosee34af32005-09-21 11:54:36 -0500139 struct ieee80211_hdr_4addr *hdr)
Jeff Garzikb4538722005-05-12 22:48:20 -0400140{
141 u16 sc;
142 unsigned int seq;
143 struct ieee80211_frag_entry *entry;
144
145 sc = le16_to_cpu(hdr->seq_ctl);
146 seq = WLAN_GET_SEQ_SEQ(sc);
147
148 entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,
149 hdr->addr1);
150
151 if (entry == NULL) {
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400152 IEEE80211_DEBUG_FRAG("could not invalidate fragment cache "
153 "entry (seq=%u)\n", seq);
Jeff Garzikb4538722005-05-12 22:48:20 -0400154 return -1;
155 }
156
157 entry->skb = NULL;
158 return 0;
159}
160
Jeff Garzikb4538722005-05-12 22:48:20 -0400161#ifdef NOT_YET
162/* ieee80211_rx_frame_mgtmt
163 *
164 * Responsible for handling management control frames
165 *
166 * Called by ieee80211_rx */
Arjan van de Ven858119e2006-01-14 13:20:43 -0800167static int
Jeff Garzikb4538722005-05-12 22:48:20 -0400168ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
169 struct ieee80211_rx_stats *rx_stats, u16 type,
170 u16 stype)
171{
172 if (ieee->iw_mode == IW_MODE_MASTER) {
173 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
174 ieee->dev->name);
175 return 0;
176/*
James Ketrenosee34af32005-09-21 11:54:36 -0500177 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
Jeff Garzikb4538722005-05-12 22:48:20 -0400178 skb->data);*/
179 }
180
181 if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
182 if (stype == WLAN_FC_STYPE_BEACON &&
183 ieee->iw_mode == IW_MODE_MASTER) {
184 struct sk_buff *skb2;
185 /* Process beacon frames also in kernel driver to
186 * update STA(AP) table statistics */
187 skb2 = skb_clone(skb, GFP_ATOMIC);
188 if (skb2)
189 hostap_rx(skb2->dev, skb2, rx_stats);
190 }
191
192 /* send management frames to the user space daemon for
193 * processing */
194 ieee->apdevstats.rx_packets++;
195 ieee->apdevstats.rx_bytes += skb->len;
196 prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
197 return 0;
198 }
199
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400200 if (ieee->iw_mode == IW_MODE_MASTER) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400201 if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
202 printk(KERN_DEBUG "%s: unknown management frame "
203 "(type=0x%02x, stype=0x%02x) dropped\n",
204 skb->dev->name, type, stype);
205 return -1;
206 }
207
208 hostap_rx(skb->dev, skb, rx_stats);
209 return 0;
210 }
211
212 printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
213 "received in non-Host AP mode\n", skb->dev->name);
214 return -1;
215}
216#endif
217
Jeff Garzikb4538722005-05-12 22:48:20 -0400218/* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
219/* Ethernet-II snap header (RFC1042 for most EtherTypes) */
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400220static unsigned char rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
221
Jeff Garzikb4538722005-05-12 22:48:20 -0400222/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
223static unsigned char bridge_tunnel_header[] =
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400224 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
Jeff Garzikb4538722005-05-12 22:48:20 -0400225/* No encapsulation header if EtherType < 0x600 (=length) */
226
227/* Called by ieee80211_rx_frame_decrypt */
228static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
229 struct sk_buff *skb)
230{
231 struct net_device *dev = ieee->dev;
232 u16 fc, ethertype;
James Ketrenosee34af32005-09-21 11:54:36 -0500233 struct ieee80211_hdr_3addr *hdr;
Jeff Garzikb4538722005-05-12 22:48:20 -0400234 u8 *pos;
235
236 if (skb->len < 24)
237 return 0;
238
James Ketrenosee34af32005-09-21 11:54:36 -0500239 hdr = (struct ieee80211_hdr_3addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400240 fc = le16_to_cpu(hdr->frame_ctl);
241
242 /* check that the frame is unicast frame to us */
243 if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
244 IEEE80211_FCTL_TODS &&
Kris Katterjohnd3f4a682006-01-09 16:01:43 -0800245 !compare_ether_addr(hdr->addr1, dev->dev_addr) &&
246 !compare_ether_addr(hdr->addr3, dev->dev_addr)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400247 /* ToDS frame with own addr BSSID and DA */
248 } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
249 IEEE80211_FCTL_FROMDS &&
Kris Katterjohnd3f4a682006-01-09 16:01:43 -0800250 !compare_ether_addr(hdr->addr1, dev->dev_addr)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400251 /* FromDS frame with own addr as DA */
252 } else
253 return 0;
254
255 if (skb->len < 24 + 8)
256 return 0;
257
258 /* check for port access entity Ethernet type */
259 pos = skb->data + 24;
260 ethertype = (pos[6] << 8) | pos[7];
261 if (ethertype == ETH_P_PAE)
262 return 1;
263
264 return 0;
265}
266
267/* Called only as a tasklet (software IRQ), by ieee80211_rx */
Arjan van de Ven858119e2006-01-14 13:20:43 -0800268static int
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400269ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
Jeff Garzikb4538722005-05-12 22:48:20 -0400270 struct ieee80211_crypt_data *crypt)
271{
James Ketrenosee34af32005-09-21 11:54:36 -0500272 struct ieee80211_hdr_3addr *hdr;
Jeff Garzikb4538722005-05-12 22:48:20 -0400273 int res, hdrlen;
Joe Perches0795af52007-10-03 17:59:30 -0700274 DECLARE_MAC_BUF(mac);
Jeff Garzikb4538722005-05-12 22:48:20 -0400275
276 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
277 return 0;
278
James Ketrenosee34af32005-09-21 11:54:36 -0500279 hdr = (struct ieee80211_hdr_3addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400280 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
281
Jeff Garzikb4538722005-05-12 22:48:20 -0400282 atomic_inc(&crypt->refcnt);
283 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
284 atomic_dec(&crypt->refcnt);
285 if (res < 0) {
Joe Perches0795af52007-10-03 17:59:30 -0700286 IEEE80211_DEBUG_DROP("decryption failed (SA=%s"
287 ") res=%d\n", print_mac(mac, hdr->addr2), res);
Jeff Garzikb4538722005-05-12 22:48:20 -0400288 if (res == -2)
289 IEEE80211_DEBUG_DROP("Decryption failed ICV "
290 "mismatch (key %d)\n",
291 skb->data[hdrlen + 3] >> 6);
292 ieee->ieee_stats.rx_discards_undecryptable++;
293 return -1;
294 }
295
296 return res;
297}
298
Jeff Garzikb4538722005-05-12 22:48:20 -0400299/* Called only as a tasklet (software IRQ), by ieee80211_rx */
Arjan van de Ven858119e2006-01-14 13:20:43 -0800300static int
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400301ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee,
302 struct sk_buff *skb, int keyidx,
303 struct ieee80211_crypt_data *crypt)
Jeff Garzikb4538722005-05-12 22:48:20 -0400304{
James Ketrenosee34af32005-09-21 11:54:36 -0500305 struct ieee80211_hdr_3addr *hdr;
Jeff Garzikb4538722005-05-12 22:48:20 -0400306 int res, hdrlen;
Joe Perches0795af52007-10-03 17:59:30 -0700307 DECLARE_MAC_BUF(mac);
Jeff Garzikb4538722005-05-12 22:48:20 -0400308
309 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
310 return 0;
311
James Ketrenosee34af32005-09-21 11:54:36 -0500312 hdr = (struct ieee80211_hdr_3addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400313 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
314
315 atomic_inc(&crypt->refcnt);
316 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
317 atomic_dec(&crypt->refcnt);
318 if (res < 0) {
319 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
Joe Perches0795af52007-10-03 17:59:30 -0700320 " (SA=%s keyidx=%d)\n",
321 ieee->dev->name, print_mac(mac, hdr->addr2), keyidx);
Jeff Garzikb4538722005-05-12 22:48:20 -0400322 return -1;
323 }
324
325 return 0;
326}
327
Jeff Garzikb4538722005-05-12 22:48:20 -0400328/* All received frames are sent to this function. @skb contains the frame in
329 * IEEE 802.11 format, i.e., in the format it was sent over air.
330 * This function is called only as a tasklet (software IRQ). */
331int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
332 struct ieee80211_rx_stats *rx_stats)
333{
334 struct net_device *dev = ieee->dev;
James Ketrenosee34af32005-09-21 11:54:36 -0500335 struct ieee80211_hdr_4addr *hdr;
Jeff Garzikb4538722005-05-12 22:48:20 -0400336 size_t hdrlen;
337 u16 fc, type, stype, sc;
338 struct net_device_stats *stats;
339 unsigned int frag;
340 u8 *payload;
341 u16 ethertype;
342#ifdef NOT_YET
343 struct net_device *wds = NULL;
344 struct sk_buff *skb2 = NULL;
345 struct net_device *wds = NULL;
346 int frame_authorized = 0;
347 int from_assoc_ap = 0;
348 void *sta = NULL;
349#endif
350 u8 dst[ETH_ALEN];
351 u8 src[ETH_ALEN];
352 struct ieee80211_crypt_data *crypt = NULL;
353 int keyidx = 0;
Zhu Yib6daa252006-01-19 16:20:42 +0800354 int can_be_decrypted = 0;
Joe Perches0795af52007-10-03 17:59:30 -0700355 DECLARE_MAC_BUF(mac);
Jeff Garzikb4538722005-05-12 22:48:20 -0400356
James Ketrenosee34af32005-09-21 11:54:36 -0500357 hdr = (struct ieee80211_hdr_4addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400358 stats = &ieee->stats;
359
360 if (skb->len < 10) {
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400361 printk(KERN_INFO "%s: SKB length < 10\n", dev->name);
Jeff Garzikb4538722005-05-12 22:48:20 -0400362 goto rx_dropped;
363 }
364
365 fc = le16_to_cpu(hdr->frame_ctl);
366 type = WLAN_FC_GET_TYPE(fc);
367 stype = WLAN_FC_GET_STYPE(fc);
368 sc = le16_to_cpu(hdr->seq_ctl);
369 frag = WLAN_GET_SEQ_FRAG(sc);
370 hdrlen = ieee80211_get_hdrlen(fc);
371
John W. Linville04045f92007-10-01 21:03:54 -0700372 if (skb->len < hdrlen) {
373 printk(KERN_INFO "%s: invalid SKB length %d\n",
374 dev->name, skb->len);
375 goto rx_dropped;
376 }
377
Jeff Garzikb4538722005-05-12 22:48:20 -0400378 /* Put this code here so that we avoid duplicating it in all
379 * Rx paths. - Jean II */
Horms8f7eb4072006-06-26 17:44:38 +0900380#ifdef CONFIG_WIRELESS_EXT
Jeff Garzikb4538722005-05-12 22:48:20 -0400381#ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
382 /* If spy monitoring on */
James Ketrenos74079fd2005-09-13 17:35:21 -0500383 if (ieee->spy_data.spy_number > 0) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400384 struct iw_quality wstats;
James Ketrenos74079fd2005-09-13 17:35:21 -0500385
386 wstats.updated = 0;
387 if (rx_stats->mask & IEEE80211_STATMASK_RSSI) {
388 wstats.level = rx_stats->rssi;
389 wstats.updated |= IW_QUAL_LEVEL_UPDATED;
390 } else
391 wstats.updated |= IW_QUAL_LEVEL_INVALID;
392
393 if (rx_stats->mask & IEEE80211_STATMASK_NOISE) {
394 wstats.noise = rx_stats->noise;
395 wstats.updated |= IW_QUAL_NOISE_UPDATED;
396 } else
397 wstats.updated |= IW_QUAL_NOISE_INVALID;
398
399 if (rx_stats->mask & IEEE80211_STATMASK_SIGNAL) {
400 wstats.qual = rx_stats->signal;
401 wstats.updated |= IW_QUAL_QUAL_UPDATED;
402 } else
403 wstats.updated |= IW_QUAL_QUAL_INVALID;
404
Jeff Garzikb4538722005-05-12 22:48:20 -0400405 /* Update spy records */
James Ketrenos74079fd2005-09-13 17:35:21 -0500406 wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
Jeff Garzikb4538722005-05-12 22:48:20 -0400407 }
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400408#endif /* IW_WIRELESS_SPY */
Horms8f7eb4072006-06-26 17:44:38 +0900409#endif /* CONFIG_WIRELESS_EXT */
James Ketrenos74079fd2005-09-13 17:35:21 -0500410
411#ifdef NOT_YET
Jeff Garzikb4538722005-05-12 22:48:20 -0400412 hostap_update_rx_stats(local->ap, hdr, rx_stats);
413#endif
414
Jeff Garzikb4538722005-05-12 22:48:20 -0400415 if (ieee->iw_mode == IW_MODE_MONITOR) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400416 stats->rx_packets++;
417 stats->rx_bytes += skb->len;
Eric Sesterhenn60d48f12006-06-21 21:05:58 +0200418 ieee80211_monitor_rx(ieee, skb, rx_stats);
Jeff Garzikb4538722005-05-12 22:48:20 -0400419 return 1;
420 }
Jeff Garzikb4538722005-05-12 22:48:20 -0400421
Zhu Yib6daa252006-01-19 16:20:42 +0800422 can_be_decrypted = (is_multicast_ether_addr(hdr->addr1) ||
423 is_broadcast_ether_addr(hdr->addr2)) ?
424 ieee->host_mc_decrypt : ieee->host_decrypt;
425
426 if (can_be_decrypted) {
Zhu Yib6daa252006-01-19 16:20:42 +0800427 if (skb->len >= hdrlen + 3) {
428 /* Top two-bits of byte 3 are the key index */
Daniel Drakec9308b02006-09-27 03:50:31 +0100429 keyidx = skb->data[hdrlen + 3] >> 6;
Zhu Yib6daa252006-01-19 16:20:42 +0800430 }
431
Daniel Drakec9308b02006-09-27 03:50:31 +0100432 /* ieee->crypt[] is WEP_KEY (4) in length. Given that keyidx
433 * is only allowed 2-bits of storage, no value of keyidx can
434 * be provided via above code that would result in keyidx
Zhu Yib6daa252006-01-19 16:20:42 +0800435 * being out of range */
Daniel Drakec9308b02006-09-27 03:50:31 +0100436 crypt = ieee->crypt[keyidx];
Zhu Yib6daa252006-01-19 16:20:42 +0800437
Jeff Garzikb4538722005-05-12 22:48:20 -0400438#ifdef NOT_YET
439 sta = NULL;
440
441 /* Use station specific key to override default keys if the
442 * receiver address is a unicast address ("individual RA"). If
443 * bcrx_sta_key parameter is set, station specific key is used
444 * even with broad/multicast targets (this is against IEEE
445 * 802.11, but makes it easier to use different keys with
446 * stations that do not support WEP key mapping). */
447
448 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400449 (void)hostap_handle_sta_crypto(local, hdr, &crypt,
450 &sta);
Jeff Garzikb4538722005-05-12 22:48:20 -0400451#endif
452
453 /* allow NULL decrypt to indicate an station specific override
454 * for default encryption */
455 if (crypt && (crypt->ops == NULL ||
456 crypt->ops->decrypt_mpdu == NULL))
457 crypt = NULL;
458
Jiri Bencf13baae2005-08-25 20:11:46 -0400459 if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400460 /* This seems to be triggered by some (multicast?)
461 * frames from other than current BSS, so just drop the
462 * frames silently instead of filling system log with
463 * these reports. */
464 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
Joe Perches0795af52007-10-03 17:59:30 -0700465 " (SA=%s)\n",
466 print_mac(mac, hdr->addr2));
Jeff Garzikb4538722005-05-12 22:48:20 -0400467 ieee->ieee_stats.rx_discards_undecryptable++;
468 goto rx_dropped;
469 }
470 }
Jeff Garzikb4538722005-05-12 22:48:20 -0400471#ifdef NOT_YET
472 if (type != WLAN_FC_TYPE_DATA) {
473 if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
Jiri Bencf13baae2005-08-25 20:11:46 -0400474 fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400475 (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400476 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
Joe Perches0795af52007-10-03 17:59:30 -0700477 "from %s\n", dev->name,
478 print_mac(mac, hdr->addr2));
Jeff Garzikb4538722005-05-12 22:48:20 -0400479 /* TODO: could inform hostapd about this so that it
480 * could send auth failure report */
481 goto rx_dropped;
482 }
483
484 if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
485 goto rx_dropped;
486 else
487 goto rx_exit;
488 }
489#endif
Larry Finger837925d2006-10-03 18:49:32 -0500490 /* drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.29) */
491 if (sc == ieee->prev_seq_ctl)
492 goto rx_dropped;
493 else
494 ieee->prev_seq_ctl = sc;
Jeff Garzikb4538722005-05-12 22:48:20 -0400495
496 /* Data frame - extract src/dst addresses */
Jiri Benc286d9742005-05-24 15:10:18 +0200497 if (skb->len < IEEE80211_3ADDR_LEN)
Jeff Garzikb4538722005-05-12 22:48:20 -0400498 goto rx_dropped;
499
500 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
501 case IEEE80211_FCTL_FROMDS:
502 memcpy(dst, hdr->addr1, ETH_ALEN);
503 memcpy(src, hdr->addr3, ETH_ALEN);
504 break;
505 case IEEE80211_FCTL_TODS:
506 memcpy(dst, hdr->addr3, ETH_ALEN);
507 memcpy(src, hdr->addr2, ETH_ALEN);
508 break;
509 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
Jiri Benc286d9742005-05-24 15:10:18 +0200510 if (skb->len < IEEE80211_4ADDR_LEN)
Jeff Garzikb4538722005-05-12 22:48:20 -0400511 goto rx_dropped;
512 memcpy(dst, hdr->addr3, ETH_ALEN);
513 memcpy(src, hdr->addr4, ETH_ALEN);
514 break;
515 case 0:
516 memcpy(dst, hdr->addr1, ETH_ALEN);
517 memcpy(src, hdr->addr2, ETH_ALEN);
518 break;
519 }
520
521#ifdef NOT_YET
522 if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
523 goto rx_dropped;
524 if (wds) {
525 skb->dev = dev = wds;
526 stats = hostap_get_stats(dev);
527 }
528
529 if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400530 (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
531 IEEE80211_FCTL_FROMDS && ieee->stadev
Kris Katterjohnd3f4a682006-01-09 16:01:43 -0800532 && !compare_ether_addr(hdr->addr2, ieee->assoc_ap_addr)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400533 /* Frame from BSSID of the AP for which we are a client */
534 skb->dev = dev = ieee->stadev;
535 stats = hostap_get_stats(dev);
536 from_assoc_ap = 1;
537 }
538#endif
539
540 dev->last_rx = jiffies;
541
542#ifdef NOT_YET
543 if ((ieee->iw_mode == IW_MODE_MASTER ||
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400544 ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400545 switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
546 wds != NULL)) {
547 case AP_RX_CONTINUE_NOT_AUTHORIZED:
548 frame_authorized = 0;
549 break;
550 case AP_RX_CONTINUE:
551 frame_authorized = 1;
552 break;
553 case AP_RX_DROP:
554 goto rx_dropped;
555 case AP_RX_EXIT:
556 goto rx_exit;
557 }
558 }
559#endif
560
561 /* Nullfunc frames may have PS-bit set, so they must be passed to
562 * hostap_handle_sta_rx() before being dropped here. */
James Ketrenos9e8571a2005-09-21 11:56:33 -0500563
564 stype &= ~IEEE80211_STYPE_QOS_DATA;
565
Jeff Garzikb4538722005-05-12 22:48:20 -0400566 if (stype != IEEE80211_STYPE_DATA &&
567 stype != IEEE80211_STYPE_DATA_CFACK &&
568 stype != IEEE80211_STYPE_DATA_CFPOLL &&
569 stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
570 if (stype != IEEE80211_STYPE_NULLFUNC)
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400571 IEEE80211_DEBUG_DROP("RX: dropped data frame "
572 "with no data (type=0x%02x, "
573 "subtype=0x%02x, len=%d)\n",
574 type, stype, skb->len);
Jeff Garzikb4538722005-05-12 22:48:20 -0400575 goto rx_dropped;
576 }
577
578 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
579
Zhu Yib6daa252006-01-19 16:20:42 +0800580 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
Jeff Garzikb4538722005-05-12 22:48:20 -0400581 (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
582 goto rx_dropped;
583
James Ketrenosee34af32005-09-21 11:54:36 -0500584 hdr = (struct ieee80211_hdr_4addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400585
586 /* skb: hdr + (possibly fragmented) plaintext payload */
587 // PR: FIXME: hostap has additional conditions in the "if" below:
Jiri Bencf13baae2005-08-25 20:11:46 -0400588 // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
Denis Vlasenko9eafe762006-01-22 13:57:10 +0200589 if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400590 int flen;
591 struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
592 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
593
594 if (!frag_skb) {
595 IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
596 "Rx cannot get skb from fragment "
597 "cache (morefrag=%d seq=%u frag=%u)\n",
598 (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
599 WLAN_GET_SEQ_SEQ(sc), frag);
600 goto rx_dropped;
601 }
602
603 flen = skb->len;
604 if (frag != 0)
605 flen -= hdrlen;
606
Arnaldo Carvalho de Melo4305b542007-04-19 20:43:29 -0700607 if (frag_skb->tail + flen > frag_skb->end) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400608 printk(KERN_WARNING "%s: host decrypted and "
609 "reassembled frame did not fit skb\n",
610 dev->name);
611 ieee80211_frag_cache_invalidate(ieee, hdr);
612 goto rx_dropped;
613 }
614
615 if (frag == 0) {
616 /* copy first fragment (including full headers) into
617 * beginning of the fragment cache skb */
Arnaldo Carvalho de Melod626f622007-03-27 18:55:52 -0300618 skb_copy_from_linear_data(skb, skb_put(frag_skb, flen), flen);
Jeff Garzikb4538722005-05-12 22:48:20 -0400619 } else {
620 /* append frame payload to the end of the fragment
621 * cache skb */
Arnaldo Carvalho de Melod626f622007-03-27 18:55:52 -0300622 skb_copy_from_linear_data_offset(skb, hdrlen,
623 skb_put(frag_skb, flen), flen);
Jeff Garzikb4538722005-05-12 22:48:20 -0400624 }
625 dev_kfree_skb_any(skb);
626 skb = NULL;
627
628 if (fc & IEEE80211_FCTL_MOREFRAGS) {
629 /* more fragments expected - leave the skb in fragment
630 * cache for now; it will be delivered to upper layers
631 * after all fragments have been received */
632 goto rx_exit;
633 }
634
635 /* this was the last fragment and the frame will be
636 * delivered, so remove skb from fragment cache */
637 skb = frag_skb;
James Ketrenosee34af32005-09-21 11:54:36 -0500638 hdr = (struct ieee80211_hdr_4addr *)skb->data;
Jeff Garzikb4538722005-05-12 22:48:20 -0400639 ieee80211_frag_cache_invalidate(ieee, hdr);
640 }
641
642 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
643 * encrypted/authenticated */
Zhu Yib6daa252006-01-19 16:20:42 +0800644 if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
Jeff Garzikb4538722005-05-12 22:48:20 -0400645 ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
646 goto rx_dropped;
647
James Ketrenosee34af32005-09-21 11:54:36 -0500648 hdr = (struct ieee80211_hdr_4addr *)skb->data;
Jiri Bencf13baae2005-08-25 20:11:46 -0400649 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400650 if ( /*ieee->ieee802_1x && */
651 ieee80211_is_eapol_frame(ieee, skb)) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400652 /* pass unencrypted EAPOL frames even if encryption is
653 * configured */
Jeff Garzikb4538722005-05-12 22:48:20 -0400654 } else {
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400655 IEEE80211_DEBUG_DROP("encryption configured, but RX "
Joe Perches0795af52007-10-03 17:59:30 -0700656 "frame not encrypted (SA=%s"
657 ")\n", print_mac(mac, hdr->addr2));
Jeff Garzikb4538722005-05-12 22:48:20 -0400658 goto rx_dropped;
659 }
660 }
661
Jiri Bencf13baae2005-08-25 20:11:46 -0400662 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
Jeff Garzikb4538722005-05-12 22:48:20 -0400663 !ieee80211_is_eapol_frame(ieee, skb)) {
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400664 IEEE80211_DEBUG_DROP("dropped unencrypted RX data "
Joe Perches0795af52007-10-03 17:59:30 -0700665 "frame from %s"
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400666 " (drop_unencrypted=1)\n",
Joe Perches0795af52007-10-03 17:59:30 -0700667 print_mac(mac, hdr->addr2));
Jeff Garzikb4538722005-05-12 22:48:20 -0400668 goto rx_dropped;
669 }
670
Daniel Drakec9308b02006-09-27 03:50:31 +0100671 /* If the frame was decrypted in hardware, we may need to strip off
672 * any security data (IV, ICV, etc) that was left behind */
673 if (!can_be_decrypted && (fc & IEEE80211_FCTL_PROTECTED) &&
674 ieee->host_strip_iv_icv) {
YOSHIFUJI Hideaki64265652007-02-09 23:24:46 +0900675 int trimlen = 0;
Daniel Drakec9308b02006-09-27 03:50:31 +0100676
677 /* Top two-bits of byte 3 are the key index */
678 if (skb->len >= hdrlen + 3)
679 keyidx = skb->data[hdrlen + 3] >> 6;
680
681 /* To strip off any security data which appears before the
682 * payload, we simply increase hdrlen (as the header gets
683 * chopped off immediately below). For the security data which
684 * appears after the payload, we use skb_trim. */
685
686 switch (ieee->sec.encode_alg[keyidx]) {
687 case SEC_ALG_WEP:
688 /* 4 byte IV */
689 hdrlen += 4;
690 /* 4 byte ICV */
691 trimlen = 4;
692 break;
693 case SEC_ALG_TKIP:
694 /* 4 byte IV, 4 byte ExtIV */
695 hdrlen += 8;
696 /* 8 byte MIC, 4 byte ICV */
697 trimlen = 12;
698 break;
699 case SEC_ALG_CCMP:
700 /* 8 byte CCMP header */
701 hdrlen += 8;
702 /* 8 byte MIC */
703 trimlen = 8;
704 break;
705 }
706
707 if (skb->len < trimlen)
708 goto rx_dropped;
709
710 __skb_trim(skb, skb->len - trimlen);
711
712 if (skb->len < hdrlen)
713 goto rx_dropped;
714 }
715
Jeff Garzikb4538722005-05-12 22:48:20 -0400716 /* skb: hdr + (possible reassembled) full plaintext payload */
717
718 payload = skb->data + hdrlen;
719 ethertype = (payload[6] << 8) | payload[7];
720
721#ifdef NOT_YET
722 /* If IEEE 802.1X is used, check whether the port is authorized to send
723 * the received frame. */
724 if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
725 if (ethertype == ETH_P_PAE) {
726 printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
727 dev->name);
728 if (ieee->hostapd && ieee->apdev) {
729 /* Send IEEE 802.1X frames to the user
730 * space daemon for processing */
731 prism2_rx_80211(ieee->apdev, skb, rx_stats,
732 PRISM2_RX_MGMT);
733 ieee->apdevstats.rx_packets++;
734 ieee->apdevstats.rx_bytes += skb->len;
735 goto rx_exit;
736 }
737 } else if (!frame_authorized) {
738 printk(KERN_DEBUG "%s: dropped frame from "
739 "unauthorized port (IEEE 802.1X): "
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400740 "ethertype=0x%04x\n", dev->name, ethertype);
Jeff Garzikb4538722005-05-12 22:48:20 -0400741 goto rx_dropped;
742 }
743 }
744#endif
745
746 /* convert hdr + possible LLC headers into Ethernet header */
747 if (skb->len - hdrlen >= 8 &&
748 ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
749 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
750 memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
751 /* remove RFC1042 or Bridge-Tunnel encapsulation and
752 * replace EtherType */
753 skb_pull(skb, hdrlen + SNAP_SIZE);
754 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
755 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
756 } else {
Al Virod9e94d52007-12-29 05:01:07 -0500757 __be16 len;
Jeff Garzikb4538722005-05-12 22:48:20 -0400758 /* Leave Ethernet header part of hdr and full payload */
759 skb_pull(skb, hdrlen);
760 len = htons(skb->len);
761 memcpy(skb_push(skb, 2), &len, 2);
762 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
763 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
764 }
765
766#ifdef NOT_YET
767 if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400768 IEEE80211_FCTL_TODS) && skb->len >= ETH_HLEN + ETH_ALEN) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400769 /* Non-standard frame: get addr4 from its bogus location after
770 * the payload */
Arnaldo Carvalho de Melo27d7ff42007-03-31 11:55:19 -0300771 skb_copy_to_linear_data_offset(skb, ETH_ALEN,
772 skb->data + skb->len - ETH_ALEN,
773 ETH_ALEN);
Jeff Garzikb4538722005-05-12 22:48:20 -0400774 skb_trim(skb, skb->len - ETH_ALEN);
775 }
776#endif
777
778 stats->rx_packets++;
779 stats->rx_bytes += skb->len;
780
781#ifdef NOT_YET
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400782 if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) {
Jeff Garzikb4538722005-05-12 22:48:20 -0400783 if (dst[0] & 0x01) {
784 /* copy multicast frame both to the higher layers and
785 * to the wireless media */
786 ieee->ap->bridged_multicast++;
787 skb2 = skb_clone(skb, GFP_ATOMIC);
788 if (skb2 == NULL)
789 printk(KERN_DEBUG "%s: skb_clone failed for "
790 "multicast frame\n", dev->name);
791 } else if (hostap_is_sta_assoc(ieee->ap, dst)) {
792 /* send frame directly to the associated STA using
793 * wireless media and not passing to higher layers */
794 ieee->ap->bridged_unicast++;
795 skb2 = skb;
796 skb = NULL;
797 }
798 }
799
800 if (skb2 != NULL) {
801 /* send to wireless media */
Jeff Garzikb4538722005-05-12 22:48:20 -0400802 skb2->dev = dev;
YOSHIFUJI Hideaki4e394302007-12-12 03:52:26 +0900803 skb2->protocol = htons(ETH_P_802_3);
Arnaldo Carvalho de Melo459a98e2007-03-19 15:30:44 -0700804 skb_reset_mac_header(skb2);
Arnaldo Carvalho de Meloc1d2bbe2007-04-10 20:45:18 -0700805 skb_reset_network_header(skb2);
Arnaldo Carvalho de Melob0e380b2007-04-10 21:21:55 -0700806 /* skb2->network_header += ETH_HLEN; */
Jeff Garzikb4538722005-05-12 22:48:20 -0400807 dev_queue_xmit(skb2);
808 }
Jeff Garzikb4538722005-05-12 22:48:20 -0400809#endif
810
811 if (skb) {
812 skb->protocol = eth_type_trans(skb, dev);
813 memset(skb->cb, 0, sizeof(skb->cb));
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400814 skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
Zhu Yid6529232006-01-19 16:20:49 +0800815 if (netif_rx(skb) == NET_RX_DROP) {
816 /* netif_rx always succeeds, but it might drop
817 * the packet. If it drops the packet, we log that
818 * in our stats. */
819 IEEE80211_DEBUG_DROP
820 ("RX: netif_rx dropped the packet\n");
821 stats->rx_dropped++;
822 }
Jeff Garzikb4538722005-05-12 22:48:20 -0400823 }
824
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400825 rx_exit:
Jeff Garzikb4538722005-05-12 22:48:20 -0400826#ifdef NOT_YET
827 if (sta)
828 hostap_handle_sta_release(sta);
829#endif
830 return 1;
831
Jeff Garzik0edd5b42005-09-07 00:48:31 -0400832 rx_dropped:
Jeff Garzikb4538722005-05-12 22:48:20 -0400833 stats->rx_dropped++;
834
835 /* Returning 0 indicates to caller that we have not handled the SKB--
836 * so it is still allocated and can be used again by underlying
837 * hardware as a DMA target */
838 return 0;
839}
840
Daniel Drakef2060f032006-07-18 21:38:05 +0100841/* Filter out unrelated packets, call ieee80211_rx[_mgt]
842 * This function takes over the skb, it should not be used again after calling
843 * this function. */
844void ieee80211_rx_any(struct ieee80211_device *ieee,
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200845 struct sk_buff *skb, struct ieee80211_rx_stats *stats)
846{
847 struct ieee80211_hdr_4addr *hdr;
848 int is_packet_for_us;
849 u16 fc;
850
Daniel Drakef2060f032006-07-18 21:38:05 +0100851 if (ieee->iw_mode == IW_MODE_MONITOR) {
852 if (!ieee80211_rx(ieee, skb, stats))
853 dev_kfree_skb_irq(skb);
854 return;
855 }
856
857 if (skb->len < sizeof(struct ieee80211_hdr))
858 goto drop_free;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200859
860 hdr = (struct ieee80211_hdr_4addr *)skb->data;
861 fc = le16_to_cpu(hdr->frame_ctl);
862
863 if ((fc & IEEE80211_FCTL_VERS) != 0)
Daniel Drakef2060f032006-07-18 21:38:05 +0100864 goto drop_free;
YOSHIFUJI Hideaki64265652007-02-09 23:24:46 +0900865
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200866 switch (fc & IEEE80211_FCTL_FTYPE) {
867 case IEEE80211_FTYPE_MGMT:
Daniel Drakef2060f032006-07-18 21:38:05 +0100868 if (skb->len < sizeof(struct ieee80211_hdr_3addr))
869 goto drop_free;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200870 ieee80211_rx_mgt(ieee, hdr, stats);
Daniel Drakef2060f032006-07-18 21:38:05 +0100871 dev_kfree_skb_irq(skb);
872 return;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200873 case IEEE80211_FTYPE_DATA:
874 break;
875 case IEEE80211_FTYPE_CTL:
Daniel Drakef2060f032006-07-18 21:38:05 +0100876 return;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200877 default:
Daniel Drakef2060f032006-07-18 21:38:05 +0100878 return;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200879 }
880
881 is_packet_for_us = 0;
882 switch (ieee->iw_mode) {
883 case IW_MODE_ADHOC:
884 /* our BSS and not from/to DS */
885 if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0)
886 if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
887 /* promisc: get all */
888 if (ieee->dev->flags & IFF_PROMISC)
889 is_packet_for_us = 1;
890 /* to us */
891 else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
892 is_packet_for_us = 1;
893 /* mcast */
894 else if (is_multicast_ether_addr(hdr->addr1))
895 is_packet_for_us = 1;
896 }
897 break;
898 case IW_MODE_INFRA:
899 /* our BSS (== from our AP) and from DS */
900 if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0)
901 if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
902 /* promisc: get all */
903 if (ieee->dev->flags & IFF_PROMISC)
904 is_packet_for_us = 1;
905 /* to us */
906 else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
907 is_packet_for_us = 1;
908 /* mcast */
909 else if (is_multicast_ether_addr(hdr->addr1)) {
910 /* not our own packet bcasted from AP */
911 if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN))
912 is_packet_for_us = 1;
913 }
914 }
915 break;
916 default:
917 /* ? */
918 break;
919 }
920
921 if (is_packet_for_us)
Daniel Drakef2060f032006-07-18 21:38:05 +0100922 if (!ieee80211_rx(ieee, skb, stats))
923 dev_kfree_skb_irq(skb);
924 return;
925
926drop_free:
927 dev_kfree_skb_irq(skb);
928 ieee->stats.rx_dropped++;
929 return;
Denis Vlasenko1a995b452006-01-24 16:57:11 +0200930}
931
Jeff Garzikb4538722005-05-12 22:48:20 -0400932#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
933
James Ketrenos9e8571a2005-09-21 11:56:33 -0500934static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
935
936/*
937* Make ther structure we read from the beacon packet has
938* the right values
939*/
940static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
941 *info_element, int sub_type)
942{
943
944 if (info_element->qui_subtype != sub_type)
945 return -1;
946 if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
947 return -1;
948 if (info_element->qui_type != QOS_OUI_TYPE)
949 return -1;
950 if (info_element->version != QOS_VERSION_1)
951 return -1;
952
953 return 0;
954}
955
956/*
957 * Parse a QoS parameter element
958 */
959static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
960 *element_param, struct ieee80211_info_element
961 *info_element)
962{
963 int ret = 0;
964 u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
965
966 if ((info_element == NULL) || (element_param == NULL))
967 return -1;
968
969 if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
970 memcpy(element_param->info_element.qui, info_element->data,
971 info_element->len);
972 element_param->info_element.elementID = info_element->id;
973 element_param->info_element.length = info_element->len;
974 } else
975 ret = -1;
976 if (ret == 0)
977 ret = ieee80211_verify_qos_info(&element_param->info_element,
978 QOS_OUI_PARAM_SUB_TYPE);
979 return ret;
980}
981
982/*
983 * Parse a QoS information element
984 */
985static int ieee80211_read_qos_info_element(struct
986 ieee80211_qos_information_element
987 *element_info, struct ieee80211_info_element
988 *info_element)
989{
990 int ret = 0;
991 u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
992
993 if (element_info == NULL)
994 return -1;
995 if (info_element == NULL)
996 return -1;
997
998 if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
999 memcpy(element_info->qui, info_element->data,
1000 info_element->len);
1001 element_info->elementID = info_element->id;
1002 element_info->length = info_element->len;
1003 } else
1004 ret = -1;
1005
1006 if (ret == 0)
1007 ret = ieee80211_verify_qos_info(element_info,
1008 QOS_OUI_INFO_SUB_TYPE);
1009 return ret;
1010}
1011
1012/*
1013 * Write QoS parameters from the ac parameters.
1014 */
1015static int ieee80211_qos_convert_ac_to_parameters(struct
1016 ieee80211_qos_parameter_info
1017 *param_elm, struct
1018 ieee80211_qos_parameters
1019 *qos_param)
1020{
1021 int rc = 0;
1022 int i;
1023 struct ieee80211_qos_ac_parameter *ac_params;
1024 u32 txop;
1025 u8 cw_min;
1026 u8 cw_max;
1027
1028 for (i = 0; i < QOS_QUEUE_NUM; i++) {
1029 ac_params = &(param_elm->ac_params_record[i]);
1030
1031 qos_param->aifs[i] = (ac_params->aci_aifsn) & 0x0F;
1032 qos_param->aifs[i] -= (qos_param->aifs[i] < 2) ? 0 : 2;
1033
1034 cw_min = ac_params->ecw_min_max & 0x0F;
Al Viro8fffc152007-12-27 01:25:40 -05001035 qos_param->cw_min[i] = cpu_to_le16((1 << cw_min) - 1);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001036
1037 cw_max = (ac_params->ecw_min_max & 0xF0) >> 4;
Al Viro8fffc152007-12-27 01:25:40 -05001038 qos_param->cw_max[i] = cpu_to_le16((1 << cw_max) - 1);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001039
1040 qos_param->flag[i] =
1041 (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
1042
1043 txop = le16_to_cpu(ac_params->tx_op_limit) * 32;
Al Viro8fffc152007-12-27 01:25:40 -05001044 qos_param->tx_op_limit[i] = cpu_to_le16(txop);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001045 }
1046 return rc;
1047}
1048
1049/*
1050 * we have a generic data element which it may contain QoS information or
1051 * parameters element. check the information element length to decide
1052 * which type to read
1053 */
1054static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1055 *info_element,
1056 struct ieee80211_network *network)
1057{
1058 int rc = 0;
1059 struct ieee80211_qos_parameters *qos_param = NULL;
1060 struct ieee80211_qos_information_element qos_info_element;
1061
1062 rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
1063
1064 if (rc == 0) {
1065 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1066 network->flags |= NETWORK_HAS_QOS_INFORMATION;
1067 } else {
1068 struct ieee80211_qos_parameter_info param_element;
1069
1070 rc = ieee80211_read_qos_param_element(&param_element,
1071 info_element);
1072 if (rc == 0) {
1073 qos_param = &(network->qos_data.parameters);
1074 ieee80211_qos_convert_ac_to_parameters(&param_element,
1075 qos_param);
1076 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1077 network->qos_data.param_count =
1078 param_element.info_element.ac_info & 0x0F;
1079 }
1080 }
1081
1082 if (rc == 0) {
1083 IEEE80211_DEBUG_QOS("QoS is supported\n");
1084 network->qos_data.supported = 1;
1085 }
1086 return rc;
1087}
1088
Zhu Yid1b46b02006-01-19 16:22:15 +08001089#ifdef CONFIG_IEEE80211_DEBUG
1090#define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1091
1092static const char *get_info_element_string(u16 id)
1093{
1094 switch (id) {
1095 MFIE_STRING(SSID);
1096 MFIE_STRING(RATES);
1097 MFIE_STRING(FH_SET);
1098 MFIE_STRING(DS_SET);
1099 MFIE_STRING(CF_SET);
1100 MFIE_STRING(TIM);
1101 MFIE_STRING(IBSS_SET);
1102 MFIE_STRING(COUNTRY);
1103 MFIE_STRING(HOP_PARAMS);
1104 MFIE_STRING(HOP_TABLE);
1105 MFIE_STRING(REQUEST);
1106 MFIE_STRING(CHALLENGE);
1107 MFIE_STRING(POWER_CONSTRAINT);
1108 MFIE_STRING(POWER_CAPABILITY);
1109 MFIE_STRING(TPC_REQUEST);
1110 MFIE_STRING(TPC_REPORT);
1111 MFIE_STRING(SUPP_CHANNELS);
1112 MFIE_STRING(CSA);
1113 MFIE_STRING(MEASURE_REQUEST);
1114 MFIE_STRING(MEASURE_REPORT);
1115 MFIE_STRING(QUIET);
1116 MFIE_STRING(IBSS_DFS);
1117 MFIE_STRING(ERP_INFO);
1118 MFIE_STRING(RSN);
1119 MFIE_STRING(RATES_EX);
1120 MFIE_STRING(GENERIC);
1121 MFIE_STRING(QOS_PARAMETER);
1122 default:
1123 return "UNKNOWN";
1124 }
1125}
1126#endif
1127
James Ketrenosff0037b2005-10-03 10:23:42 -05001128static int ieee80211_parse_info_param(struct ieee80211_info_element
1129 *info_element, u16 length,
1130 struct ieee80211_network *network)
James Ketrenos9e8571a2005-09-21 11:56:33 -05001131{
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001132 u8 i;
1133#ifdef CONFIG_IEEE80211_DEBUG
1134 char rates_str[64];
1135 char *p;
1136#endif
James Ketrenos9e8571a2005-09-21 11:56:33 -05001137
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001138 while (length >= sizeof(*info_element)) {
1139 if (sizeof(*info_element) + info_element->len > length) {
Jiri Bencaec41a02006-10-18 19:34:40 +02001140 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1141 "info_element->len + 2 > left : "
1142 "info_element->len+2=%zd left=%d, id=%d.\n",
1143 info_element->len +
1144 sizeof(*info_element),
1145 length, info_element->id);
Zhu Yif09fc442006-08-21 11:34:19 +08001146 /* We stop processing but don't return an error here
1147 * because some misbehaviour APs break this rule. ie.
1148 * Orinoco AP1000. */
1149 break;
James Ketrenos9e8571a2005-09-21 11:56:33 -05001150 }
1151
1152 switch (info_element->id) {
1153 case MFIE_TYPE_SSID:
1154 if (ieee80211_is_empty_essid(info_element->data,
1155 info_element->len)) {
1156 network->flags |= NETWORK_EMPTY_ESSID;
1157 break;
1158 }
1159
1160 network->ssid_len = min(info_element->len,
1161 (u8) IW_ESSID_MAX_SIZE);
1162 memcpy(network->ssid, info_element->data,
1163 network->ssid_len);
1164 if (network->ssid_len < IW_ESSID_MAX_SIZE)
1165 memset(network->ssid + network->ssid_len, 0,
1166 IW_ESSID_MAX_SIZE - network->ssid_len);
1167
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001168 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
James Ketrenosff0037b2005-10-03 10:23:42 -05001169 network->ssid, network->ssid_len);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001170 break;
1171
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001172 case MFIE_TYPE_RATES:
1173#ifdef CONFIG_IEEE80211_DEBUG
1174 p = rates_str;
1175#endif
1176 network->rates_len = min(info_element->len,
1177 MAX_RATES_LENGTH);
1178 for (i = 0; i < network->rates_len; i++) {
1179 network->rates[i] = info_element->data[i];
1180#ifdef CONFIG_IEEE80211_DEBUG
1181 p += snprintf(p, sizeof(rates_str) -
1182 (p - rates_str), "%02X ",
1183 network->rates[i]);
1184#endif
1185 if (ieee80211_is_ofdm_rate
1186 (info_element->data[i])) {
1187 network->flags |= NETWORK_HAS_OFDM;
1188 if (info_element->data[i] &
1189 IEEE80211_BASIC_RATE_MASK)
1190 network->flags &=
1191 ~NETWORK_HAS_CCK;
1192 }
1193 }
1194
1195 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
1196 rates_str, network->rates_len);
1197 break;
1198
1199 case MFIE_TYPE_RATES_EX:
1200#ifdef CONFIG_IEEE80211_DEBUG
1201 p = rates_str;
1202#endif
1203 network->rates_ex_len = min(info_element->len,
1204 MAX_RATES_EX_LENGTH);
1205 for (i = 0; i < network->rates_ex_len; i++) {
1206 network->rates_ex[i] = info_element->data[i];
1207#ifdef CONFIG_IEEE80211_DEBUG
1208 p += snprintf(p, sizeof(rates_str) -
1209 (p - rates_str), "%02X ",
1210 network->rates[i]);
1211#endif
1212 if (ieee80211_is_ofdm_rate
1213 (info_element->data[i])) {
1214 network->flags |= NETWORK_HAS_OFDM;
1215 if (info_element->data[i] &
1216 IEEE80211_BASIC_RATE_MASK)
1217 network->flags &=
1218 ~NETWORK_HAS_CCK;
1219 }
1220 }
1221
1222 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
1223 rates_str, network->rates_ex_len);
1224 break;
1225
1226 case MFIE_TYPE_DS_SET:
1227 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
1228 info_element->data[0]);
1229 network->channel = info_element->data[0];
1230 break;
1231
1232 case MFIE_TYPE_FH_SET:
1233 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
1234 break;
1235
1236 case MFIE_TYPE_CF_SET:
1237 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
1238 break;
1239
James Ketrenos9e8571a2005-09-21 11:56:33 -05001240 case MFIE_TYPE_TIM:
Zhu Yi41a25c62006-01-19 16:22:23 +08001241 network->tim.tim_count = info_element->data[0];
1242 network->tim.tim_period = info_element->data[1];
1243 IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001244 break;
1245
1246 case MFIE_TYPE_ERP_INFO:
1247 network->erp_value = info_element->data[0];
Daniel Draked8e2be92006-07-18 21:30:34 +01001248 network->flags |= NETWORK_HAS_ERP_VALUE;
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001249 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1250 network->erp_value);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001251 break;
1252
1253 case MFIE_TYPE_IBSS_SET:
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001254 network->atim_window = info_element->data[0];
1255 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1256 network->atim_window);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001257 break;
1258
1259 case MFIE_TYPE_CHALLENGE:
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001260 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
James Ketrenos9e8571a2005-09-21 11:56:33 -05001261 break;
1262
1263 case MFIE_TYPE_GENERIC:
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001264 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
1265 info_element->len);
1266 if (!ieee80211_parse_qos_info_param_IE(info_element,
1267 network))
1268 break;
1269
1270 if (info_element->len >= 4 &&
1271 info_element->data[0] == 0x00 &&
1272 info_element->data[1] == 0x50 &&
1273 info_element->data[2] == 0xf2 &&
1274 info_element->data[3] == 0x01) {
1275 network->wpa_ie_len = min(info_element->len + 2,
1276 MAX_WPA_IE_LEN);
1277 memcpy(network->wpa_ie, info_element,
1278 network->wpa_ie_len);
1279 }
James Ketrenos9e8571a2005-09-21 11:56:33 -05001280 break;
1281
1282 case MFIE_TYPE_RSN:
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001283 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
1284 info_element->len);
1285 network->rsn_ie_len = min(info_element->len + 2,
1286 MAX_WPA_IE_LEN);
1287 memcpy(network->rsn_ie, info_element,
1288 network->rsn_ie_len);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001289 break;
1290
1291 case MFIE_TYPE_QOS_PARAMETER:
James Ketrenosff0037b2005-10-03 10:23:42 -05001292 printk(KERN_ERR
1293 "QoS Error need to parse QOS_PARAMETER IE\n");
James Ketrenos9e8571a2005-09-21 11:56:33 -05001294 break;
Zhu Yid1b46b02006-01-19 16:22:15 +08001295 /* 802.11h */
1296 case MFIE_TYPE_POWER_CONSTRAINT:
1297 network->power_constraint = info_element->data[0];
1298 network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
1299 break;
1300
1301 case MFIE_TYPE_CSA:
1302 network->power_constraint = info_element->data[0];
1303 network->flags |= NETWORK_HAS_CSA;
1304 break;
1305
1306 case MFIE_TYPE_QUIET:
1307 network->quiet.count = info_element->data[0];
1308 network->quiet.period = info_element->data[1];
1309 network->quiet.duration = info_element->data[2];
1310 network->quiet.offset = info_element->data[3];
1311 network->flags |= NETWORK_HAS_QUIET;
1312 break;
1313
1314 case MFIE_TYPE_IBSS_DFS:
1315 if (network->ibss_dfs)
1316 break;
Arnaldo Carvalho de Melo571d6ee2006-11-21 01:26:49 -02001317 network->ibss_dfs = kmemdup(info_element->data,
1318 info_element->len,
1319 GFP_ATOMIC);
Zhu Yid1b46b02006-01-19 16:22:15 +08001320 if (!network->ibss_dfs)
1321 return 1;
Zhu Yid1b46b02006-01-19 16:22:15 +08001322 network->flags |= NETWORK_HAS_IBSS_DFS;
1323 break;
1324
1325 case MFIE_TYPE_TPC_REPORT:
1326 network->tpc_report.transmit_power =
1327 info_element->data[0];
1328 network->tpc_report.link_margin = info_element->data[1];
1329 network->flags |= NETWORK_HAS_TPC_REPORT;
1330 break;
James Ketrenos9e8571a2005-09-21 11:56:33 -05001331
1332 default:
Zhu Yid1b46b02006-01-19 16:22:15 +08001333 IEEE80211_DEBUG_MGMT
1334 ("Unsupported info element: %s (%d)\n",
1335 get_info_element_string(info_element->id),
1336 info_element->id);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001337 break;
1338 }
1339
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001340 length -= sizeof(*info_element) + info_element->len;
James Ketrenosff0037b2005-10-03 10:23:42 -05001341 info_element =
1342 (struct ieee80211_info_element *)&info_element->
1343 data[info_element->len];
James Ketrenos9e8571a2005-09-21 11:56:33 -05001344 }
1345
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001346 return 0;
1347}
1348
1349static int ieee80211_handle_assoc_resp(struct ieee80211_device *ieee, struct ieee80211_assoc_response
1350 *frame, struct ieee80211_rx_stats *stats)
1351{
Zhu Yid1b46b02006-01-19 16:22:15 +08001352 struct ieee80211_network network_resp = {
1353 .ibss_dfs = NULL,
1354 };
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001355 struct ieee80211_network *network = &network_resp;
1356 struct net_device *dev = ieee->dev;
1357
1358 network->flags = 0;
1359 network->qos_data.active = 0;
1360 network->qos_data.supported = 0;
1361 network->qos_data.param_count = 0;
1362 network->qos_data.old_param_count = 0;
1363
1364 //network->atim_window = le16_to_cpu(frame->aid) & (0x3FFF);
1365 network->atim_window = le16_to_cpu(frame->aid);
1366 network->listen_interval = le16_to_cpu(frame->status);
Ivo van Doornc1bda442005-10-03 10:20:47 -05001367 memcpy(network->bssid, frame->header.addr3, ETH_ALEN);
1368 network->capability = le16_to_cpu(frame->capability);
1369 network->last_scanned = jiffies;
1370 network->rates_len = network->rates_ex_len = 0;
1371 network->last_associate = 0;
1372 network->ssid_len = 0;
James Ketrenosff0037b2005-10-03 10:23:42 -05001373 network->erp_value =
1374 (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
Ivo van Doornc1bda442005-10-03 10:20:47 -05001375
1376 if (stats->freq == IEEE80211_52GHZ_BAND) {
1377 /* for A band (No DS info) */
1378 network->channel = stats->received_channel;
1379 } else
1380 network->flags |= NETWORK_HAS_CCK;
1381
1382 network->wpa_ie_len = 0;
1383 network->rsn_ie_len = 0;
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001384
James Ketrenosff0037b2005-10-03 10:23:42 -05001385 if (ieee80211_parse_info_param
1386 (frame->info_element, stats->len - sizeof(*frame), network))
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001387 return 1;
1388
Ivo van Doornc1bda442005-10-03 10:20:47 -05001389 network->mode = 0;
1390 if (stats->freq == IEEE80211_52GHZ_BAND)
1391 network->mode = IEEE_A;
1392 else {
1393 if (network->flags & NETWORK_HAS_OFDM)
1394 network->mode |= IEEE_G;
1395 if (network->flags & NETWORK_HAS_CCK)
1396 network->mode |= IEEE_B;
1397 }
1398
1399 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
1400 network->flags |= NETWORK_EMPTY_ESSID;
1401
1402 memcpy(&network->stats, stats, sizeof(network->stats));
1403
James Ketrenos9e8571a2005-09-21 11:56:33 -05001404 if (ieee->handle_assoc_response != NULL)
1405 ieee->handle_assoc_response(dev, frame, network);
1406
1407 return 0;
1408}
1409
1410/***************************************************/
1411
Arjan van de Ven858119e2006-01-14 13:20:43 -08001412static int ieee80211_network_init(struct ieee80211_device *ieee, struct ieee80211_probe_response
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001413 *beacon,
1414 struct ieee80211_network *network,
1415 struct ieee80211_rx_stats *stats)
Jeff Garzikb4538722005-05-12 22:48:20 -04001416{
Joe Perches0795af52007-10-03 17:59:30 -07001417 DECLARE_MAC_BUF(mac);
1418
James Ketrenos9e8571a2005-09-21 11:56:33 -05001419 network->qos_data.active = 0;
1420 network->qos_data.supported = 0;
1421 network->qos_data.param_count = 0;
Ivo van Doornc1bda442005-10-03 10:20:47 -05001422 network->qos_data.old_param_count = 0;
Jeff Garzikb4538722005-05-12 22:48:20 -04001423
1424 /* Pull out fixed field data */
1425 memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
James Ketrenosfd278172005-09-13 17:25:51 -05001426 network->capability = le16_to_cpu(beacon->capability);
Jeff Garzikb4538722005-05-12 22:48:20 -04001427 network->last_scanned = jiffies;
James Ketrenosfd278172005-09-13 17:25:51 -05001428 network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
1429 network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
1430 network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001431 /* Where to pull this? beacon->listen_interval; */
Jeff Garzikb4538722005-05-12 22:48:20 -04001432 network->listen_interval = 0x0A;
1433 network->rates_len = network->rates_ex_len = 0;
1434 network->last_associate = 0;
1435 network->ssid_len = 0;
1436 network->flags = 0;
1437 network->atim_window = 0;
James Ketrenos42c94e42005-09-21 11:58:29 -05001438 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
James Ketrenosccd0fda2005-09-21 11:58:32 -05001439 0x3 : 0x0;
Jeff Garzikb4538722005-05-12 22:48:20 -04001440
1441 if (stats->freq == IEEE80211_52GHZ_BAND) {
1442 /* for A band (No DS info) */
1443 network->channel = stats->received_channel;
1444 } else
1445 network->flags |= NETWORK_HAS_CCK;
1446
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001447 network->wpa_ie_len = 0;
1448 network->rsn_ie_len = 0;
Jeff Garzikb4538722005-05-12 22:48:20 -04001449
James Ketrenosff0037b2005-10-03 10:23:42 -05001450 if (ieee80211_parse_info_param
1451 (beacon->info_element, stats->len - sizeof(*beacon), network))
Ivo van Doornff9e00f2005-10-03 10:19:25 -05001452 return 1;
Jeff Garzikb4538722005-05-12 22:48:20 -04001453
1454 network->mode = 0;
1455 if (stats->freq == IEEE80211_52GHZ_BAND)
1456 network->mode = IEEE_A;
1457 else {
1458 if (network->flags & NETWORK_HAS_OFDM)
1459 network->mode |= IEEE_G;
1460 if (network->flags & NETWORK_HAS_CCK)
1461 network->mode |= IEEE_B;
1462 }
1463
1464 if (network->mode == 0) {
Joe Perches0795af52007-10-03 17:59:30 -07001465 IEEE80211_DEBUG_SCAN("Filtered out '%s (%s)' "
Jeff Garzikb4538722005-05-12 22:48:20 -04001466 "network.\n",
1467 escape_essid(network->ssid,
1468 network->ssid_len),
Joe Perches0795af52007-10-03 17:59:30 -07001469 print_mac(mac, network->bssid));
Jeff Garzikb4538722005-05-12 22:48:20 -04001470 return 1;
1471 }
1472
1473 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
1474 network->flags |= NETWORK_EMPTY_ESSID;
1475
1476 memcpy(&network->stats, stats, sizeof(network->stats));
1477
1478 return 0;
1479}
1480
1481static inline int is_same_network(struct ieee80211_network *src,
1482 struct ieee80211_network *dst)
1483{
1484 /* A network is only a duplicate if the channel, BSSID, and ESSID
1485 * all match. We treat all <hidden> with the same BSSID and channel
1486 * as one network */
1487 return ((src->ssid_len == dst->ssid_len) &&
1488 (src->channel == dst->channel) &&
Kris Katterjohnd3f4a682006-01-09 16:01:43 -08001489 !compare_ether_addr(src->bssid, dst->bssid) &&
Jeff Garzikb4538722005-05-12 22:48:20 -04001490 !memcmp(src->ssid, dst->ssid, src->ssid_len));
1491}
1492
Arjan van de Ven858119e2006-01-14 13:20:43 -08001493static void update_network(struct ieee80211_network *dst,
Jeff Garzikb4538722005-05-12 22:48:20 -04001494 struct ieee80211_network *src)
1495{
James Ketrenos9e8571a2005-09-21 11:56:33 -05001496 int qos_active;
1497 u8 old_param;
Joe Perches0795af52007-10-03 17:59:30 -07001498 DECLARE_MAC_BUF(mac);
James Ketrenos9e8571a2005-09-21 11:56:33 -05001499
Zhu Yid1b46b02006-01-19 16:22:15 +08001500 ieee80211_network_reset(dst);
1501 dst->ibss_dfs = src->ibss_dfs;
1502
James Ketrenosf44349f2006-03-08 13:14:45 -06001503 /* We only update the statistics if they were created by receiving
1504 * the network information on the actual channel the network is on.
YOSHIFUJI Hideaki64265652007-02-09 23:24:46 +09001505 *
James Ketrenosf44349f2006-03-08 13:14:45 -06001506 * This keeps beacons received on neighbor channels from bringing
1507 * down the signal level of an AP. */
1508 if (dst->channel == src->stats.received_channel)
1509 memcpy(&dst->stats, &src->stats,
1510 sizeof(struct ieee80211_rx_stats));
1511 else
Joe Perches0795af52007-10-03 17:59:30 -07001512 IEEE80211_DEBUG_SCAN("Network %s info received "
1513 "off channel (%d vs. %d)\n", print_mac(mac, src->bssid),
James Ketrenosf44349f2006-03-08 13:14:45 -06001514 dst->channel, src->stats.received_channel);
1515
Jeff Garzikb4538722005-05-12 22:48:20 -04001516 dst->capability = src->capability;
1517 memcpy(dst->rates, src->rates, src->rates_len);
1518 dst->rates_len = src->rates_len;
1519 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
1520 dst->rates_ex_len = src->rates_ex_len;
1521
1522 dst->mode = src->mode;
1523 dst->flags = src->flags;
1524 dst->time_stamp[0] = src->time_stamp[0];
1525 dst->time_stamp[1] = src->time_stamp[1];
1526
1527 dst->beacon_interval = src->beacon_interval;
1528 dst->listen_interval = src->listen_interval;
1529 dst->atim_window = src->atim_window;
James Ketrenos42c94e42005-09-21 11:58:29 -05001530 dst->erp_value = src->erp_value;
Zhu Yi41a25c62006-01-19 16:22:23 +08001531 dst->tim = src->tim;
Jeff Garzikb4538722005-05-12 22:48:20 -04001532
1533 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
1534 dst->wpa_ie_len = src->wpa_ie_len;
1535 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
1536 dst->rsn_ie_len = src->rsn_ie_len;
1537
1538 dst->last_scanned = jiffies;
James Ketrenos9e8571a2005-09-21 11:56:33 -05001539 qos_active = src->qos_data.active;
1540 old_param = dst->qos_data.old_param_count;
1541 if (dst->flags & NETWORK_HAS_QOS_MASK)
1542 memcpy(&dst->qos_data, &src->qos_data,
1543 sizeof(struct ieee80211_qos_data));
1544 else {
1545 dst->qos_data.supported = src->qos_data.supported;
1546 dst->qos_data.param_count = src->qos_data.param_count;
1547 }
1548
1549 if (dst->qos_data.supported == 1) {
1550 if (dst->ssid_len)
1551 IEEE80211_DEBUG_QOS
1552 ("QoS the network %s is QoS supported\n",
1553 dst->ssid);
1554 else
1555 IEEE80211_DEBUG_QOS
1556 ("QoS the network is QoS supported\n");
1557 }
1558 dst->qos_data.active = qos_active;
1559 dst->qos_data.old_param_count = old_param;
1560
Jeff Garzikb4538722005-05-12 22:48:20 -04001561 /* dst->last_associate is not overwritten */
1562}
1563
Pete Zaitcev48328432006-02-26 23:43:20 -08001564static inline int is_beacon(__le16 fc)
James Ketrenos3f552bb2005-09-21 11:54:47 -05001565{
1566 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
1567}
1568
Arjan van de Ven858119e2006-01-14 13:20:43 -08001569static void ieee80211_process_probe_response(struct ieee80211_device
James Ketrenos74079fd2005-09-13 17:35:21 -05001570 *ieee, struct
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001571 ieee80211_probe_response
James Ketrenos74079fd2005-09-13 17:35:21 -05001572 *beacon, struct ieee80211_rx_stats
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001573 *stats)
Jeff Garzikb4538722005-05-12 22:48:20 -04001574{
James Ketrenos3f552bb2005-09-21 11:54:47 -05001575 struct net_device *dev = ieee->dev;
Zhu Yid1b46b02006-01-19 16:22:15 +08001576 struct ieee80211_network network = {
1577 .ibss_dfs = NULL,
1578 };
Jeff Garzikb4538722005-05-12 22:48:20 -04001579 struct ieee80211_network *target;
1580 struct ieee80211_network *oldest = NULL;
1581#ifdef CONFIG_IEEE80211_DEBUG
James Ketrenos68e4e032005-09-13 17:37:22 -05001582 struct ieee80211_info_element *info_element = beacon->info_element;
Jeff Garzikb4538722005-05-12 22:48:20 -04001583#endif
1584 unsigned long flags;
Joe Perches0795af52007-10-03 17:59:30 -07001585 DECLARE_MAC_BUF(mac);
Jeff Garzikb4538722005-05-12 22:48:20 -04001586
Joe Perches0795af52007-10-03 17:59:30 -07001587 IEEE80211_DEBUG_SCAN("'%s' (%s"
Al Viro8524f592007-12-29 05:03:35 -05001588 "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
1589 escape_essid(info_element->data, info_element->len),
1590 print_mac(mac, beacon->header.addr3),
1591 (beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
1592 (beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
1593 (beacon->capability & cpu_to_le16(1 << 0xd)) ? '1' : '0',
1594 (beacon->capability & cpu_to_le16(1 << 0xc)) ? '1' : '0',
1595 (beacon->capability & cpu_to_le16(1 << 0xb)) ? '1' : '0',
1596 (beacon->capability & cpu_to_le16(1 << 0xa)) ? '1' : '0',
1597 (beacon->capability & cpu_to_le16(1 << 0x9)) ? '1' : '0',
1598 (beacon->capability & cpu_to_le16(1 << 0x8)) ? '1' : '0',
1599 (beacon->capability & cpu_to_le16(1 << 0x7)) ? '1' : '0',
1600 (beacon->capability & cpu_to_le16(1 << 0x6)) ? '1' : '0',
1601 (beacon->capability & cpu_to_le16(1 << 0x5)) ? '1' : '0',
1602 (beacon->capability & cpu_to_le16(1 << 0x4)) ? '1' : '0',
1603 (beacon->capability & cpu_to_le16(1 << 0x3)) ? '1' : '0',
1604 (beacon->capability & cpu_to_le16(1 << 0x2)) ? '1' : '0',
1605 (beacon->capability & cpu_to_le16(1 << 0x1)) ? '1' : '0',
1606 (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0');
Jeff Garzikb4538722005-05-12 22:48:20 -04001607
1608 if (ieee80211_network_init(ieee, beacon, &network, stats)) {
Joe Perches0795af52007-10-03 17:59:30 -07001609 IEEE80211_DEBUG_SCAN("Dropped '%s' (%s) via %s.\n",
Jeff Garzikb4538722005-05-12 22:48:20 -04001610 escape_essid(info_element->data,
1611 info_element->len),
Joe Perches0795af52007-10-03 17:59:30 -07001612 print_mac(mac, beacon->header.addr3),
Pete Zaitcev48328432006-02-26 23:43:20 -08001613 is_beacon(beacon->header.frame_ctl) ?
James Ketrenos3f552bb2005-09-21 11:54:47 -05001614 "BEACON" : "PROBE RESPONSE");
Jeff Garzikb4538722005-05-12 22:48:20 -04001615 return;
1616 }
1617
1618 /* The network parsed correctly -- so now we scan our known networks
1619 * to see if we can find it in our list.
1620 *
1621 * NOTE: This search is definitely not optimized. Once its doing
1622 * the "right thing" we'll optimize it for efficiency if
1623 * necessary */
1624
1625 /* Search for this entry in the list and update it if it is
1626 * already there. */
1627
1628 spin_lock_irqsave(&ieee->lock, flags);
1629
1630 list_for_each_entry(target, &ieee->network_list, list) {
1631 if (is_same_network(target, &network))
1632 break;
1633
1634 if ((oldest == NULL) ||
1635 (target->last_scanned < oldest->last_scanned))
1636 oldest = target;
1637 }
1638
1639 /* If we didn't find a match, then get a new network slot to initialize
1640 * with this beacon's information */
1641 if (&target->list == &ieee->network_list) {
1642 if (list_empty(&ieee->network_free_list)) {
1643 /* If there are no more slots, expire the oldest */
1644 list_del(&oldest->list);
1645 target = oldest;
Joe Perches0795af52007-10-03 17:59:30 -07001646 IEEE80211_DEBUG_SCAN("Expired '%s' (%s) from "
Jeff Garzikb4538722005-05-12 22:48:20 -04001647 "network list.\n",
1648 escape_essid(target->ssid,
1649 target->ssid_len),
Joe Perches0795af52007-10-03 17:59:30 -07001650 print_mac(mac, target->bssid));
Zhu Yid1b46b02006-01-19 16:22:15 +08001651 ieee80211_network_reset(target);
Jeff Garzikb4538722005-05-12 22:48:20 -04001652 } else {
1653 /* Otherwise just pull from the free list */
1654 target = list_entry(ieee->network_free_list.next,
1655 struct ieee80211_network, list);
1656 list_del(ieee->network_free_list.next);
1657 }
1658
Jeff Garzikb4538722005-05-12 22:48:20 -04001659#ifdef CONFIG_IEEE80211_DEBUG
Joe Perches0795af52007-10-03 17:59:30 -07001660 IEEE80211_DEBUG_SCAN("Adding '%s' (%s) via %s.\n",
Jeff Garzikb4538722005-05-12 22:48:20 -04001661 escape_essid(network.ssid,
1662 network.ssid_len),
Joe Perches0795af52007-10-03 17:59:30 -07001663 print_mac(mac, network.bssid),
Pete Zaitcev48328432006-02-26 23:43:20 -08001664 is_beacon(beacon->header.frame_ctl) ?
James Ketrenos3f552bb2005-09-21 11:54:47 -05001665 "BEACON" : "PROBE RESPONSE");
Jeff Garzikb4538722005-05-12 22:48:20 -04001666#endif
1667 memcpy(target, &network, sizeof(*target));
Zhu Yid1b46b02006-01-19 16:22:15 +08001668 network.ibss_dfs = NULL;
Jeff Garzikb4538722005-05-12 22:48:20 -04001669 list_add_tail(&target->list, &ieee->network_list);
1670 } else {
Joe Perches0795af52007-10-03 17:59:30 -07001671 IEEE80211_DEBUG_SCAN("Updating '%s' (%s) via %s.\n",
Jeff Garzikb4538722005-05-12 22:48:20 -04001672 escape_essid(target->ssid,
1673 target->ssid_len),
Joe Perches0795af52007-10-03 17:59:30 -07001674 print_mac(mac, target->bssid),
Pete Zaitcev48328432006-02-26 23:43:20 -08001675 is_beacon(beacon->header.frame_ctl) ?
James Ketrenos3f552bb2005-09-21 11:54:47 -05001676 "BEACON" : "PROBE RESPONSE");
Jeff Garzikb4538722005-05-12 22:48:20 -04001677 update_network(target, &network);
Zhu Yid1b46b02006-01-19 16:22:15 +08001678 network.ibss_dfs = NULL;
Jeff Garzikb4538722005-05-12 22:48:20 -04001679 }
1680
1681 spin_unlock_irqrestore(&ieee->lock, flags);
James Ketrenos3f552bb2005-09-21 11:54:47 -05001682
Pete Zaitcev48328432006-02-26 23:43:20 -08001683 if (is_beacon(beacon->header.frame_ctl)) {
James Ketrenos3f552bb2005-09-21 11:54:47 -05001684 if (ieee->handle_beacon != NULL)
Hong Liu72df16f2006-03-08 10:50:20 +08001685 ieee->handle_beacon(dev, beacon, target);
James Ketrenos3f552bb2005-09-21 11:54:47 -05001686 } else {
1687 if (ieee->handle_probe_response != NULL)
Hong Liu72df16f2006-03-08 10:50:20 +08001688 ieee->handle_probe_response(dev, beacon, target);
James Ketrenos3f552bb2005-09-21 11:54:47 -05001689 }
Jeff Garzikb4538722005-05-12 22:48:20 -04001690}
1691
1692void ieee80211_rx_mgt(struct ieee80211_device *ieee,
James Ketrenosee34af32005-09-21 11:54:36 -05001693 struct ieee80211_hdr_4addr *header,
Jeff Garzikb4538722005-05-12 22:48:20 -04001694 struct ieee80211_rx_stats *stats)
1695{
James Ketrenosfd278172005-09-13 17:25:51 -05001696 switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
Jeff Garzikb4538722005-05-12 22:48:20 -04001697 case IEEE80211_STYPE_ASSOC_RESP:
1698 IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
James Ketrenosfd278172005-09-13 17:25:51 -05001699 WLAN_FC_GET_STYPE(le16_to_cpu
1700 (header->frame_ctl)));
James Ketrenos9e8571a2005-09-21 11:56:33 -05001701 ieee80211_handle_assoc_resp(ieee,
1702 (struct ieee80211_assoc_response *)
1703 header, stats);
Jeff Garzikb4538722005-05-12 22:48:20 -04001704 break;
1705
1706 case IEEE80211_STYPE_REASSOC_RESP:
1707 IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
James Ketrenosfd278172005-09-13 17:25:51 -05001708 WLAN_FC_GET_STYPE(le16_to_cpu
1709 (header->frame_ctl)));
Jeff Garzikb4538722005-05-12 22:48:20 -04001710 break;
1711
James Ketrenos42c94e42005-09-21 11:58:29 -05001712 case IEEE80211_STYPE_PROBE_REQ:
Larry Finger1a1fedf2006-01-30 09:42:24 -06001713 IEEE80211_DEBUG_MGMT("received auth (%d)\n",
James Ketrenos42c94e42005-09-21 11:58:29 -05001714 WLAN_FC_GET_STYPE(le16_to_cpu
1715 (header->frame_ctl)));
1716
1717 if (ieee->handle_probe_request != NULL)
1718 ieee->handle_probe_request(ieee->dev,
1719 (struct
1720 ieee80211_probe_request *)
1721 header, stats);
1722 break;
1723
Jeff Garzikb4538722005-05-12 22:48:20 -04001724 case IEEE80211_STYPE_PROBE_RESP:
1725 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
James Ketrenosfd278172005-09-13 17:25:51 -05001726 WLAN_FC_GET_STYPE(le16_to_cpu
1727 (header->frame_ctl)));
Jeff Garzikb4538722005-05-12 22:48:20 -04001728 IEEE80211_DEBUG_SCAN("Probe response\n");
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001729 ieee80211_process_probe_response(ieee,
1730 (struct
1731 ieee80211_probe_response *)
1732 header, stats);
Jeff Garzikb4538722005-05-12 22:48:20 -04001733 break;
1734
1735 case IEEE80211_STYPE_BEACON:
1736 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
James Ketrenosfd278172005-09-13 17:25:51 -05001737 WLAN_FC_GET_STYPE(le16_to_cpu
1738 (header->frame_ctl)));
Jeff Garzikb4538722005-05-12 22:48:20 -04001739 IEEE80211_DEBUG_SCAN("Beacon\n");
Jeff Garzik0edd5b42005-09-07 00:48:31 -04001740 ieee80211_process_probe_response(ieee,
1741 (struct
1742 ieee80211_probe_response *)
1743 header, stats);
Jeff Garzikb4538722005-05-12 22:48:20 -04001744 break;
James Ketrenos3f552bb2005-09-21 11:54:47 -05001745 case IEEE80211_STYPE_AUTH:
1746
Larry Finger1a1fedf2006-01-30 09:42:24 -06001747 IEEE80211_DEBUG_MGMT("received auth (%d)\n",
James Ketrenos3f552bb2005-09-21 11:54:47 -05001748 WLAN_FC_GET_STYPE(le16_to_cpu
1749 (header->frame_ctl)));
1750
1751 if (ieee->handle_auth != NULL)
1752 ieee->handle_auth(ieee->dev,
1753 (struct ieee80211_auth *)header);
1754 break;
1755
1756 case IEEE80211_STYPE_DISASSOC:
1757 if (ieee->handle_disassoc != NULL)
1758 ieee->handle_disassoc(ieee->dev,
1759 (struct ieee80211_disassoc *)
1760 header);
1761 break;
Jeff Garzikb4538722005-05-12 22:48:20 -04001762
Zhu Yid1b46b02006-01-19 16:22:15 +08001763 case IEEE80211_STYPE_ACTION:
1764 IEEE80211_DEBUG_MGMT("ACTION\n");
1765 if (ieee->handle_action)
1766 ieee->handle_action(ieee->dev,
1767 (struct ieee80211_action *)
1768 header, stats);
1769 break;
1770
Larry Finger2f633db2006-01-30 23:25:10 -06001771 case IEEE80211_STYPE_REASSOC_REQ:
1772 IEEE80211_DEBUG_MGMT("received reassoc (%d)\n",
1773 WLAN_FC_GET_STYPE(le16_to_cpu
1774 (header->frame_ctl)));
1775
Zhu Yi7736b5b2006-04-13 17:17:47 +08001776 IEEE80211_DEBUG_MGMT("%s: IEEE80211_REASSOC_REQ received\n",
1777 ieee->dev->name);
Larry Finger2f633db2006-01-30 23:25:10 -06001778 if (ieee->handle_reassoc_request != NULL)
1779 ieee->handle_reassoc_request(ieee->dev,
1780 (struct ieee80211_reassoc_request *)
1781 header);
1782 break;
1783
1784 case IEEE80211_STYPE_ASSOC_REQ:
1785 IEEE80211_DEBUG_MGMT("received assoc (%d)\n",
1786 WLAN_FC_GET_STYPE(le16_to_cpu
1787 (header->frame_ctl)));
1788
Zhu Yi7736b5b2006-04-13 17:17:47 +08001789 IEEE80211_DEBUG_MGMT("%s: IEEE80211_ASSOC_REQ received\n",
1790 ieee->dev->name);
Larry Finger2f633db2006-01-30 23:25:10 -06001791 if (ieee->handle_assoc_request != NULL)
1792 ieee->handle_assoc_request(ieee->dev);
1793 break;
1794
James Ketrenos31b59ea2005-09-21 11:58:49 -05001795 case IEEE80211_STYPE_DEAUTH:
Zhu Yid1b46b02006-01-19 16:22:15 +08001796 IEEE80211_DEBUG_MGMT("DEAUTH\n");
James Ketrenos31b59ea2005-09-21 11:58:49 -05001797 if (ieee->handle_deauth != NULL)
Zhu Yid1b46b02006-01-19 16:22:15 +08001798 ieee->handle_deauth(ieee->dev,
1799 (struct ieee80211_deauth *)
James Ketrenos31b59ea2005-09-21 11:58:49 -05001800 header);
1801 break;
Jeff Garzikb4538722005-05-12 22:48:20 -04001802 default:
1803 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n",
James Ketrenosfd278172005-09-13 17:25:51 -05001804 WLAN_FC_GET_STYPE(le16_to_cpu
1805 (header->frame_ctl)));
Zhu Yi7736b5b2006-04-13 17:17:47 +08001806 IEEE80211_DEBUG_MGMT("%s: Unknown management packet: %d\n",
1807 ieee->dev->name,
1808 WLAN_FC_GET_STYPE(le16_to_cpu
1809 (header->frame_ctl)));
Jeff Garzikb4538722005-05-12 22:48:20 -04001810 break;
1811 }
1812}
1813
Daniel Drakef2060f032006-07-18 21:38:05 +01001814EXPORT_SYMBOL_GPL(ieee80211_rx_any);
Jeff Garzikb4538722005-05-12 22:48:20 -04001815EXPORT_SYMBOL(ieee80211_rx_mgt);
1816EXPORT_SYMBOL(ieee80211_rx);