Fedora kernel-2.6.17-1.2142_FC4
[linux-2.6.git] / drivers / net / wireless / ieee80211 / ieee80211_rx.c
1 /*
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
6  * <jkmaline@cc.hut.fi>
7  * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8  * Copyright (c) 2004, Intel Corporation
9  *
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>
17 #include <linux/config.h>
18 #include <linux/errno.h>
19 #include <linux/if_arp.h>
20 #include <linux/in6.h>
21 #include <linux/in.h>
22 #include <linux/ip.h>
23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/netdevice.h>
26 #include <linux/pci.h>
27 #include <linux/proc_fs.h>
28 #include <linux/skbuff.h>
29 #include <linux/slab.h>
30 #include <linux/tcp.h>
31 #include <linux/types.h>
32 #include <linux/version.h>
33 #include <linux/wireless.h>
34 #include <linux/etherdevice.h>
35 #include <asm/uaccess.h>
36 #include <linux/ctype.h>
37
38 #include "ieee80211.h"
39
40 static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, 
41                                         struct sk_buff *skb, 
42                                         struct ieee80211_rx_stats *rx_stats)
43 {
44         struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
45         u16 fc = le16_to_cpu(hdr->frame_ctl);
46
47         skb->dev = ieee->dev;
48         skb->mac.raw = skb->data;
49         skb_pull(skb, ieee80211_get_hdrlen(fc));
50         skb->pkt_type = PACKET_OTHERHOST;
51         skb->protocol = __constant_htons(ETH_P_80211_RAW);
52         memset(skb->cb, 0, sizeof(skb->cb));
53         netif_rx(skb);
54 }
55
56
57 /* Called only as a tasklet (software IRQ) */
58 static struct ieee80211_frag_entry *
59 ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
60                           unsigned int frag, u8 *src, u8 *dst)
61 {
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)) {
69                         printk(KERN_DEBUG "%s: expiring fragment cache entry "
70                                "seq=%u last_frag=%u\n",
71                                ieee->dev->name, entry->seq, entry->last_frag);
72                         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) &&
78                     memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
79                     memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
80                         return entry;
81         }
82
83         return NULL;
84 }
85
86 /* Called only as a tasklet (software IRQ) */
87 static struct sk_buff *
88 ieee80211_frag_cache_get(struct ieee80211_device *ieee, 
89                          struct ieee80211_hdr *hdr)
90 {
91         struct sk_buff *skb = NULL;
92         u16 sc;
93         unsigned int frag, seq;
94         struct ieee80211_frag_entry *entry;
95         
96         sc = le16_to_cpu(hdr->seq_ctl);
97         frag = WLAN_GET_SEQ_FRAG(sc);
98         seq = WLAN_GET_SEQ_SEQ(sc);
99
100         if (frag == 0) {
101                 /* Reserve enough space to fit maximum frame length */
102                 skb = dev_alloc_skb(ieee->dev->mtu +
103                                     sizeof(struct ieee80211_hdr) +
104                                     8 /* LLC */ +
105                                     2 /* alignment */ +
106                                     8 /* WEP */ + ETH_ALEN /* WDS */);
107                 if (skb == NULL)
108                         return NULL;
109
110                 entry = &ieee->frag_cache[ieee->frag_next_idx];
111                 ieee->frag_next_idx++;
112                 if (ieee->frag_next_idx >= IEEE80211_FRAG_CACHE_LEN)
113                         ieee->frag_next_idx = 0;
114
115                 if (entry->skb != NULL)
116                         dev_kfree_skb_any(entry->skb);
117
118                 entry->first_frag_time = jiffies;
119                 entry->seq = seq;
120                 entry->last_frag = frag;
121                 entry->skb = skb;
122                 memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
123                 memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
124         } else {
125                 /* received a fragment of a frame for which the head fragment
126                  * should have already been received */
127                 entry = ieee80211_frag_cache_find(ieee, seq, frag, hdr->addr2,
128                                                   hdr->addr1);
129                 if (entry != NULL) {
130                         entry->last_frag = frag;
131                         skb = entry->skb;
132                 }
133         }
134
135         return skb;
136 }
137
138
139 /* Called only as a tasklet (software IRQ) */
140 static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
141                                            struct ieee80211_hdr *hdr)
142 {
143         u16 sc;
144         unsigned int seq;
145         struct ieee80211_frag_entry *entry;
146
147         sc = le16_to_cpu(hdr->seq_ctl);
148         seq = WLAN_GET_SEQ_SEQ(sc);
149
150         entry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2, 
151                                           hdr->addr1);
152
153         if (entry == NULL) {
154                 printk(KERN_DEBUG "%s: could not invalidate fragment cache "
155                        "entry (seq=%u)\n",
156                        ieee->dev->name, seq);
157                 return -1;
158         }
159
160         entry->skb = NULL;
161         return 0;
162 }
163  
164
165 #ifdef NOT_YET
166 /* ieee80211_rx_frame_mgtmt
167  *
168  * Responsible for handling management control frames
169  * 
170  * Called by ieee80211_rx */
171 static inline int
172 ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
173                         struct ieee80211_rx_stats *rx_stats, u16 type,
174                         u16 stype)
175 {
176         if (ieee->iw_mode == IW_MODE_MASTER) {
177                 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
178                        ieee->dev->name);
179                 return 0;
180 /*
181   hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr *)
182   skb->data);*/
183         }
184
185         if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
186                 if (stype == WLAN_FC_STYPE_BEACON &&
187                     ieee->iw_mode == IW_MODE_MASTER) {
188                         struct sk_buff *skb2;
189                         /* Process beacon frames also in kernel driver to
190                          * update STA(AP) table statistics */
191                         skb2 = skb_clone(skb, GFP_ATOMIC);
192                         if (skb2)
193                                 hostap_rx(skb2->dev, skb2, rx_stats);
194                 }
195
196                 /* send management frames to the user space daemon for
197                  * processing */
198                 ieee->apdevstats.rx_packets++;
199                 ieee->apdevstats.rx_bytes += skb->len;
200                 prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
201                 return 0;
202         }
203             
204             if (ieee->iw_mode == IW_MODE_MASTER) {
205                 if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
206                         printk(KERN_DEBUG "%s: unknown management frame "
207                                "(type=0x%02x, stype=0x%02x) dropped\n",
208                                skb->dev->name, type, stype);
209                         return -1;
210                 }
211
212                 hostap_rx(skb->dev, skb, rx_stats);
213                 return 0;
214         } 
215
216         printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
217                "received in non-Host AP mode\n", skb->dev->name);
218         return -1;
219 }
220 #endif
221
222
223 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
224 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
225 static unsigned char rfc1042_header[] =
226 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
227 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
228 static unsigned char bridge_tunnel_header[] =
229 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
230 /* No encapsulation header if EtherType < 0x600 (=length) */
231
232 #ifdef CONFIG_IEEE80211_CRYPT
233 /* Called by ieee80211_rx_frame_decrypt */
234 static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, 
235                                     struct sk_buff *skb)
236 {
237         struct net_device *dev = ieee->dev;
238         u16 fc, ethertype;
239         struct ieee80211_hdr *hdr;
240         u8 *pos;
241
242         if (skb->len < 24)
243                 return 0;
244
245         hdr = (struct ieee80211_hdr *) skb->data;
246         fc = le16_to_cpu(hdr->frame_ctl);
247
248         /* check that the frame is unicast frame to us */
249         if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == 
250             IEEE80211_FCTL_TODS &&
251             memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
252             memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
253                 /* ToDS frame with own addr BSSID and DA */
254         } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == 
255                    IEEE80211_FCTL_FROMDS &&
256                    memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
257                 /* FromDS frame with own addr as DA */
258         } else
259                 return 0;
260
261         if (skb->len < 24 + 8)
262                 return 0;
263
264         /* check for port access entity Ethernet type */
265         pos = skb->data + 24;
266         ethertype = (pos[6] << 8) | pos[7];
267         if (ethertype == ETH_P_PAE)
268                 return 1;
269
270         return 0;
271 }
272
273 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
274 static inline int
275 ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
276                            struct ieee80211_crypt_data *crypt)
277 {
278         struct ieee80211_hdr *hdr;
279         int res, hdrlen;
280
281         if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
282                 return 0;
283
284         hdr = (struct ieee80211_hdr *) skb->data;
285         hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
286
287 #ifdef CONFIG_IEEE80211_WPA
288         if (ieee->tkip_countermeasures &&
289             strcmp(crypt->ops->name, "TKIP") == 0) {
290                 if (net_ratelimit()) {
291                         printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
292                                "received packet from " MAC_FMT "\n",
293                                ieee->dev->name, MAC_ARG(hdr->addr2));
294                 }
295                 return -1;
296         }
297 #endif
298
299         atomic_inc(&crypt->refcnt);
300         res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
301         atomic_dec(&crypt->refcnt);
302         if (res < 0) {
303                 printk(KERN_DEBUG "%s: decryption failed (SA=" MAC_FMT
304                        ") res=%d\n",
305                        ieee->dev->name, MAC_ARG(hdr->addr2), res);
306                 if (res == -2)
307                         printk(KERN_DEBUG "%s: WEP decryption failed ICV "
308                                "mismatch (key %d)\n",
309                                ieee->dev->name, skb->data[hdrlen + 3] >> 6);
310                 ieee->ieee_stats.rx_discards_wep_undecryptable++;
311                 return -1;
312         }
313
314         return res;
315 }
316
317
318 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
319 static inline int
320 ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
321                              int keyidx, struct ieee80211_crypt_data *crypt)
322 {
323         struct ieee80211_hdr *hdr;
324         int res, hdrlen;
325
326         if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
327                 return 0;
328
329         hdr = (struct ieee80211_hdr *) skb->data;
330         hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
331
332         atomic_inc(&crypt->refcnt);
333         res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
334         atomic_dec(&crypt->refcnt);
335         if (res < 0) {
336                 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
337                        " (SA=" MAC_FMT " keyidx=%d)\n",
338                        ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
339                 return -1;
340         }
341
342         return 0;
343 }
344 #endif /* CONFIG_IEEE80211_CRYPT */
345
346
347 /* All received frames are sent to this function. @skb contains the frame in
348  * IEEE 802.11 format, i.e., in the format it was sent over air.
349  * This function is called only as a tasklet (software IRQ). */
350 int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
351                  struct ieee80211_rx_stats *rx_stats)
352 {
353         struct net_device *dev = ieee->dev;
354         struct ieee80211_hdr *hdr;
355         size_t hdrlen;
356         u16 fc, type, stype, sc;
357         struct net_device_stats *stats;
358         unsigned int frag;
359         u8 *payload;
360         u16 ethertype;
361 #ifdef NOT_YET
362         struct net_device *wds = NULL;
363         struct sk_buff *skb2 = NULL;
364         struct net_device *wds = NULL;
365         int frame_authorized = 0;
366         int from_assoc_ap = 0;
367         void *sta = NULL;
368 #endif
369         u8 dst[ETH_ALEN];
370         u8 src[ETH_ALEN];
371 #ifdef CONFIG_IEEE80211_CRYPT
372         struct ieee80211_crypt_data *crypt = NULL;
373         int keyidx = 0;
374 #endif
375
376         hdr = (struct ieee80211_hdr *)skb->data;
377         stats = &ieee->stats;
378
379         if (skb->len < 10) {
380                 printk(KERN_INFO "%s: SKB length < 10\n",
381                        dev->name);
382                 goto rx_dropped;
383         }
384         
385         fc = le16_to_cpu(hdr->frame_ctl);
386         type = WLAN_FC_GET_TYPE(fc);
387         stype = WLAN_FC_GET_STYPE(fc);
388         sc = le16_to_cpu(hdr->seq_ctl);
389         frag = WLAN_GET_SEQ_FRAG(sc);
390         hdrlen = ieee80211_get_hdrlen(fc);
391
392 #ifdef NOT_YET
393 #if WIRELESS_EXT > 15
394         /* Put this code here so that we avoid duplicating it in all
395          * Rx paths. - Jean II */
396 #ifdef IW_WIRELESS_SPY          /* defined in iw_handler.h */
397         /* If spy monitoring on */
398         if (iface->spy_data.spy_number > 0) {
399                 struct iw_quality wstats;
400                 wstats.level = rx_stats->signal;
401                 wstats.noise = rx_stats->noise;
402                 wstats.updated = 6;     /* No qual value */
403                 /* Update spy records */
404                 wireless_spy_update(dev, hdr->addr2, &wstats);
405         }
406 #endif /* IW_WIRELESS_SPY */
407 #endif /* WIRELESS_EXT > 15 */
408         hostap_update_rx_stats(local->ap, hdr, rx_stats);
409 #endif
410
411 #if WIRELESS_EXT > 15
412         if (ieee->iw_mode == IW_MODE_MONITOR) {
413                 ieee80211_monitor_rx(ieee, skb, rx_stats);
414                 stats->rx_packets++;
415                 stats->rx_bytes += skb->len;
416                 return 1;
417         }
418 #endif
419
420 #ifdef CONFIG_IEEE80211_CRYPT
421         if (ieee->host_decrypt) {
422                 int idx = 0;
423                 if (skb->len >= hdrlen + 3)
424                         idx = skb->data[hdrlen + 3] >> 6;
425                 crypt = ieee->crypt[idx];
426 #ifdef NOT_YET
427                 sta = NULL;
428
429                 /* Use station specific key to override default keys if the
430                  * receiver address is a unicast address ("individual RA"). If
431                  * bcrx_sta_key parameter is set, station specific key is used
432                  * even with broad/multicast targets (this is against IEEE
433                  * 802.11, but makes it easier to use different keys with
434                  * stations that do not support WEP key mapping). */
435
436                 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
437                         (void) hostap_handle_sta_crypto(local, hdr, &crypt,
438                                                         &sta);
439 #endif
440
441                 /* allow NULL decrypt to indicate an station specific override
442                  * for default encryption */
443                 if (crypt && (crypt->ops == NULL ||
444                               crypt->ops->decrypt_mpdu == NULL))
445                         crypt = NULL;
446
447                 if (!crypt && (fc & IEEE80211_FCTL_WEP)) {
448 #if 0
449                         /* This seems to be triggered by some (multicast?)
450                          * frames from other than current BSS, so just drop the
451                          * frames silently instead of filling system log with
452                          * these reports. */
453                         printk(KERN_DEBUG "%s: WEP decryption failed (not set)"
454                                " (SA=" MAC_FMT ")\n",
455                                ieee->dev->name, MAC_ARG(hdr->addr2));
456 #endif
457                         ieee->ieee_stats.rx_discards_wep_undecryptable++;
458                         goto rx_dropped;
459                 }
460         }
461 #endif /* CONFIG_IEEE80211_CRYPT */
462
463 #ifdef NOT_YET
464         if (type != WLAN_FC_TYPE_DATA) {
465                 if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
466                     fc & IEEE80211_FCTL_WEP && ieee->host_decrypt &&
467                     (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0)
468                 {
469                         printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
470                                "from " MAC_FMT "\n", dev->name,
471                                MAC_ARG(hdr->addr2));
472                         /* TODO: could inform hostapd about this so that it
473                          * could send auth failure report */
474                         goto rx_dropped;
475                 }
476
477                 if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
478                         goto rx_dropped;
479                 else
480                         goto rx_exit;
481         }
482 #endif
483
484         /* Data frame - extract src/dst addresses */
485         if (skb->len < IEEE80211_DATA_HDR3_LEN)
486                 goto rx_dropped;
487
488         switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
489         case IEEE80211_FCTL_FROMDS:
490                 memcpy(dst, hdr->addr1, ETH_ALEN);
491                 memcpy(src, hdr->addr3, ETH_ALEN);
492                 break;
493         case IEEE80211_FCTL_TODS:
494                 memcpy(dst, hdr->addr3, ETH_ALEN);
495                 memcpy(src, hdr->addr2, ETH_ALEN);
496                 break;
497         case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
498                 if (skb->len < IEEE80211_DATA_HDR4_LEN)
499                         goto rx_dropped;
500                 memcpy(dst, hdr->addr3, ETH_ALEN);
501                 memcpy(src, hdr->addr4, ETH_ALEN);
502                 break;
503         case 0:
504                 memcpy(dst, hdr->addr1, ETH_ALEN);
505                 memcpy(src, hdr->addr2, ETH_ALEN);
506                 break;
507         }
508
509 #ifdef NOT_YET
510         if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
511                 goto rx_dropped;
512         if (wds) {
513                 skb->dev = dev = wds;
514                 stats = hostap_get_stats(dev);
515         }
516
517         if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
518             (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS &&
519             ieee->stadev &&
520             memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
521                 /* Frame from BSSID of the AP for which we are a client */
522                 skb->dev = dev = ieee->stadev;
523                 stats = hostap_get_stats(dev);
524                 from_assoc_ap = 1;
525         }
526 #endif
527
528         dev->last_rx = jiffies;
529
530 #ifdef NOT_YET
531         if ((ieee->iw_mode == IW_MODE_MASTER ||
532              ieee->iw_mode == IW_MODE_REPEAT) &&
533             !from_assoc_ap) {
534                 switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
535                                              wds != NULL)) {
536                 case AP_RX_CONTINUE_NOT_AUTHORIZED:
537                         frame_authorized = 0;
538                         break;
539                 case AP_RX_CONTINUE:
540                         frame_authorized = 1;
541                         break;
542                 case AP_RX_DROP:
543                         goto rx_dropped;
544                 case AP_RX_EXIT:
545                         goto rx_exit;
546                 }
547         }
548 #endif
549
550         /* Nullfunc frames may have PS-bit set, so they must be passed to
551          * hostap_handle_sta_rx() before being dropped here. */
552         if (stype != IEEE80211_STYPE_DATA &&
553             stype != IEEE80211_STYPE_DATA_CFACK &&
554             stype != IEEE80211_STYPE_DATA_CFPOLL &&
555             stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
556                 if (stype != IEEE80211_STYPE_NULLFUNC)
557                         printk(KERN_DEBUG "%s: RX: dropped data frame "
558                                "with no data (type=0x%02x, subtype=0x%02x, len=%d)\n",
559                                dev->name, type, stype, skb->len);
560                 goto rx_dropped;
561         }
562
563         /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
564
565 #ifdef CONFIG_IEEE80211_CRYPT
566         if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
567             (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
568                 goto rx_dropped;
569 #endif
570         hdr = (struct ieee80211_hdr *) skb->data;
571
572         /* skb: hdr + (possibly fragmented) plaintext payload */
573         // PR: FIXME: hostap has additional conditions in the "if" below:
574         // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
575         if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
576                 int flen;
577                 struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
578                 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
579
580                 if (!frag_skb) {
581                         IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
582                                         "Rx cannot get skb from fragment "
583                                         "cache (morefrag=%d seq=%u frag=%u)\n",
584                                         (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
585                                         WLAN_GET_SEQ_SEQ(sc), frag);
586                         goto rx_dropped;
587                 }
588
589                 flen = skb->len;
590                 if (frag != 0)
591                         flen -= hdrlen;
592
593                 if (frag_skb->tail + flen > frag_skb->end) {
594                         printk(KERN_WARNING "%s: host decrypted and "
595                                "reassembled frame did not fit skb\n",
596                                dev->name);
597                         ieee80211_frag_cache_invalidate(ieee, hdr);
598                         goto rx_dropped;
599                 }
600
601                 if (frag == 0) {
602                         /* copy first fragment (including full headers) into
603                          * beginning of the fragment cache skb */
604                         memcpy(skb_put(frag_skb, flen), skb->data, flen);
605                 } else {
606                         /* append frame payload to the end of the fragment
607                          * cache skb */
608                         memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
609                                flen);
610                 }
611                 dev_kfree_skb_any(skb);
612                 skb = NULL;
613
614                 if (fc & IEEE80211_FCTL_MOREFRAGS) {
615                         /* more fragments expected - leave the skb in fragment
616                          * cache for now; it will be delivered to upper layers
617                          * after all fragments have been received */
618                         goto rx_exit;
619                 }
620
621                 /* this was the last fragment and the frame will be
622                  * delivered, so remove skb from fragment cache */
623                 skb = frag_skb;
624                 hdr = (struct ieee80211_hdr *) skb->data;
625                 ieee80211_frag_cache_invalidate(ieee, hdr);
626         }
627
628         /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
629          * encrypted/authenticated */
630 #ifdef CONFIG_IEEE80211_CRYPT
631         if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
632             ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
633                 goto rx_dropped;
634
635         hdr = (struct ieee80211_hdr *) skb->data;
636         if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
637                 if (/*ieee->ieee802_1x &&*/
638                     ieee80211_is_eapol_frame(ieee, skb)) {
639 #ifdef CONFIG_IEEE80211_DEBUG
640                         /* pass unencrypted EAPOL frames even if encryption is
641                          * configured */
642                         struct eapol *eap = (struct eapol *)(skb->data + 
643                                 24);
644                         IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
645                                                 eap_get_type(eap->type));
646 #endif
647                 } else {
648                         printk(KERN_DEBUG "%s: encryption configured, but RX "
649                                "frame not encrypted (SA=" MAC_FMT ")\n",
650                                ieee->dev->name, MAC_ARG(hdr->addr2));
651                         goto rx_dropped;
652                 }
653         }
654
655 #ifdef CONFIG_IEEE80211_DEBUG
656         if (crypt && !(fc & IEEE80211_FCTL_WEP) && 
657             ieee80211_is_eapol_frame(ieee, skb)) {
658                         struct eapol *eap = (struct eapol *)(skb->data + 
659                                 24);
660                         IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
661                                                 eap_get_type(eap->type));
662         }
663 #endif
664
665         if (/*ieee->drop_unencrypted*/ crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
666             !ieee80211_is_eapol_frame(ieee, skb)) {
667                 if (net_ratelimit()) {
668                         printk(KERN_DEBUG "%s: dropped unencrypted RX data "
669                                "frame from " MAC_FMT " (drop_unencrypted=1)\n",
670                                dev->name, MAC_ARG(hdr->addr2));
671                 }
672                 goto rx_dropped;
673         }
674 #endif /* CONFIG_IEEE80211_CRYPT */
675
676         /* skb: hdr + (possible reassembled) full plaintext payload */
677
678         payload = skb->data + hdrlen;
679         ethertype = (payload[6] << 8) | payload[7];
680
681 #ifdef NOT_YET
682         /* If IEEE 802.1X is used, check whether the port is authorized to send
683          * the received frame. */
684         if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
685                 if (ethertype == ETH_P_PAE) {
686                         printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
687                                dev->name);
688                         if (ieee->hostapd && ieee->apdev) {
689                                 /* Send IEEE 802.1X frames to the user
690                                  * space daemon for processing */
691                                 prism2_rx_80211(ieee->apdev, skb, rx_stats,
692                                                 PRISM2_RX_MGMT);
693                                 ieee->apdevstats.rx_packets++;
694                                 ieee->apdevstats.rx_bytes += skb->len;
695                                 goto rx_exit;
696                         }
697                 } else if (!frame_authorized) {
698                         printk(KERN_DEBUG "%s: dropped frame from "
699                                "unauthorized port (IEEE 802.1X): "
700                                "ethertype=0x%04x\n",
701                                dev->name, ethertype);
702                         goto rx_dropped;
703                 }
704         }
705 #endif
706
707         /* convert hdr + possible LLC headers into Ethernet header */
708         if (skb->len - hdrlen >= 8 &&
709             ((memcmp(payload, rfc1042_header, SNAP_SIZE) == 0 &&
710               ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
711              memcmp(payload, bridge_tunnel_header, SNAP_SIZE) == 0)) {
712                 /* remove RFC1042 or Bridge-Tunnel encapsulation and
713                  * replace EtherType */
714                 skb_pull(skb, hdrlen + SNAP_SIZE);
715                 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
716                 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
717         } else {
718                 u16 len;
719                 /* Leave Ethernet header part of hdr and full payload */
720                 skb_pull(skb, hdrlen);
721                 len = htons(skb->len);
722                 memcpy(skb_push(skb, 2), &len, 2);
723                 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
724                 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
725         }
726
727 #ifdef NOT_YET
728         if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == 
729                     IEEE80211_FCTL_TODS) &&
730             skb->len >= ETH_HLEN + ETH_ALEN) {
731                 /* Non-standard frame: get addr4 from its bogus location after
732                  * the payload */
733                 memcpy(skb->data + ETH_ALEN,
734                        skb->data + skb->len - ETH_ALEN, ETH_ALEN);
735                 skb_trim(skb, skb->len - ETH_ALEN);
736         }
737 #endif
738
739         stats->rx_packets++;
740         stats->rx_bytes += skb->len;
741
742 #ifdef NOT_YET
743         if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
744             ieee->ap->bridge_packets) {
745                 if (dst[0] & 0x01) {
746                         /* copy multicast frame both to the higher layers and
747                          * to the wireless media */
748                         ieee->ap->bridged_multicast++;
749                         skb2 = skb_clone(skb, GFP_ATOMIC);
750                         if (skb2 == NULL)
751                                 printk(KERN_DEBUG "%s: skb_clone failed for "
752                                        "multicast frame\n", dev->name);
753                 } else if (hostap_is_sta_assoc(ieee->ap, dst)) {
754                         /* send frame directly to the associated STA using
755                          * wireless media and not passing to higher layers */
756                         ieee->ap->bridged_unicast++;
757                         skb2 = skb;
758                         skb = NULL;
759                 }
760         }
761
762         if (skb2 != NULL) {
763                 /* send to wireless media */
764                 skb2->protocol = __constant_htons(ETH_P_802_3);
765                 skb2->mac.raw = skb2->nh.raw = skb2->data;
766                 /* skb2->nh.raw = skb2->data + ETH_HLEN; */
767                 skb2->dev = dev;
768                 dev_queue_xmit(skb2);
769         }
770
771 #endif
772
773         if (skb) {
774                 skb->protocol = eth_type_trans(skb, dev);
775                 memset(skb->cb, 0, sizeof(skb->cb));
776                 skb->dev = dev;
777                 skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
778                 netif_rx(skb);
779         }
780
781  rx_exit:
782 #ifdef NOT_YET
783         if (sta)
784                 hostap_handle_sta_release(sta);
785 #endif
786         return 1;
787
788  rx_dropped:
789         stats->rx_dropped++;
790
791         /* Returning 0 indicates to caller that we have not handled the SKB--
792          * so it is still allocated and can be used again by underlying
793          * hardware as a DMA target */
794         return 0;
795 }
796
797 #define MGMT_FRAME_FIXED_PART_LENGTH            0x24
798
799 static inline int ieee80211_is_ofdm_rate(u8 rate)
800 {
801         switch (rate & ~IEEE80211_BASIC_RATE_MASK) {
802         case IEEE80211_OFDM_RATE_6MB:
803         case IEEE80211_OFDM_RATE_9MB:
804         case IEEE80211_OFDM_RATE_12MB:
805         case IEEE80211_OFDM_RATE_18MB:
806         case IEEE80211_OFDM_RATE_24MB:
807         case IEEE80211_OFDM_RATE_36MB:
808         case IEEE80211_OFDM_RATE_48MB:
809         case IEEE80211_OFDM_RATE_54MB:
810                 return 1;
811         }
812         return 0;
813 }
814
815
816 static inline int ieee80211_network_init(
817         struct ieee80211_device *ieee,
818         struct ieee80211_probe_response *beacon,
819         struct ieee80211_network *network,
820         struct ieee80211_rx_stats *stats)
821 {
822         struct ieee80211_info_element *info_element;
823         u16 left;
824         u8 i;
825
826         /* Pull out fixed field data */
827         memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
828         network->capability = beacon->capability;
829         network->last_scanned = jiffies;
830         network->time_stamp[0] = beacon->time_stamp[0];
831         network->time_stamp[1] = beacon->time_stamp[1];
832         network->beacon_interval = beacon->beacon_interval;
833         /* Where to pull this? beacon->listen_interval;*/
834         network->listen_interval = 0x0A; 
835         network->rates_len = network->rates_ex_len = 0;
836         network->last_associate = 0;
837         network->ssid_len = 0;
838         network->flags = 0;
839         network->atim_window = 0;
840
841         if (stats->freq == IEEE80211_52GHZ_BAND) {
842                 /* for A band (No DS info) */
843                 network->channel = stats->received_channel;
844         } else
845                 network->flags |= NETWORK_HAS_CCK;
846
847 #ifdef CONFIG_IEEE80211_WPA             
848         network->wpa_ie_len = 0;
849         network->rsn_ie_len = 0;
850 #endif /* CONFIG_IEEE80211_WPA */               
851
852         info_element = &beacon->info_element;
853         left = stats->len - ((void *)info_element - (void *)beacon);
854         while (left >= sizeof(struct ieee80211_info_element_hdr)) {
855                 if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) {
856                         IEEE80211_DEBUG_SCAN("SCAN: parse failed: info_element->len + 2 > left : info_element->len+2=%d left=%d.\n",
857                                              info_element->len + sizeof(struct ieee80211_info_element),
858                                              left);
859                         return 1;
860                 }
861                 
862                 switch (info_element->id) {
863                 case MFIE_TYPE_SSID:
864                         if (ieee80211_is_empty_essid(info_element->data,
865                                                      info_element->len)) {
866                                 network->flags |= NETWORK_EMPTY_ESSID;
867                                 break;
868                         }
869
870                         network->ssid_len = min(info_element->len, 
871                                                 (u8)IW_ESSID_MAX_SIZE);
872                         memcpy(network->ssid, info_element->data, network->ssid_len);
873                         if (network->ssid_len < IW_ESSID_MAX_SIZE)
874                                 memset(network->ssid + network->ssid_len, 0,
875                                        IW_ESSID_MAX_SIZE - network->ssid_len);
876                         
877                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_SSID: '%s' len=%d.\n", 
878                                              network->ssid, network->ssid_len);
879                         break;
880
881                 case MFIE_TYPE_RATES:
882                         network->rates_len = min(info_element->len, MAX_RATES_LENGTH);
883                         for (i = 0; i < network->rates_len; i++) {
884                                 network->rates[i] = info_element->data[i];
885                                 if (ieee80211_is_ofdm_rate(info_element->data[i])) {
886                                         network->flags |= NETWORK_HAS_OFDM;
887                                         if (info_element->data[i] & 
888                                             IEEE80211_BASIC_RATE_MASK)
889                                                 network->flags &= 
890                                                         ~NETWORK_HAS_CCK;
891                                 }
892                         }
893                         break;
894
895                 case MFIE_TYPE_RATES_EX:
896                         network->rates_ex_len = min(info_element->len, MAX_RATES_EX_LENGTH);
897                         for (i = 0; i < network->rates_ex_len; i++) {
898                                 network->rates_ex[i] = info_element->data[i];
899                                 if (ieee80211_is_ofdm_rate(info_element->data[i])) {
900                                         network->flags |= NETWORK_HAS_OFDM;
901                                         if (info_element->data[i] & 
902                                             IEEE80211_BASIC_RATE_MASK)
903                                                 network->flags &= 
904                                                         ~NETWORK_HAS_CCK;
905                                 }
906                         }
907                         break;
908
909                 case MFIE_TYPE_DS_SET:
910                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_DS_SET: %d\n",
911                                              info_element->data[0]);
912                         if (stats->freq == IEEE80211_24GHZ_BAND)
913                                 network->channel = info_element->data[0];
914                         break;
915
916                 case MFIE_TYPE_FH_SET:
917                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_FH_SET: ignored\n");
918                         break;
919
920                 case MFIE_TYPE_CF_SET:
921                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_CF_SET: ignored\n");
922                         break;
923
924                 case MFIE_TYPE_TIM:
925                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_TIM: ignored\n");
926                         break;
927
928                 case MFIE_TYPE_IBSS_SET:
929                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_IBSS_SET: ignored\n");
930                         break;
931
932                 case MFIE_TYPE_CHALLENGE:
933                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_CHALLENGE: ignored\n");
934                         break;
935
936 #ifdef CONFIG_IEEE80211_WPA             
937                 case MFIE_TYPE_GENERIC:
938                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n",
939                                              info_element->len);
940                         if (info_element->len >= 4  &&
941                             info_element->data[0] == 0x00 &&
942                             info_element->data[1] == 0x50 &&
943                             info_element->data[2] == 0xf2 &&
944                             info_element->data[3] == 0x01) {
945                                 network->wpa_ie_len = min(info_element->len + 2,
946                                                          MAX_WPA_IE_LEN);
947                                 memcpy(network->wpa_ie, info_element, 
948                                        network->wpa_ie_len);
949                         }
950                         break;
951                         
952                 case MFIE_TYPE_RSN:
953                         IEEE80211_DEBUG_SCAN("MFIE_TYPE_RSN: %d bytes\n",
954                                              info_element->len);
955                         network->rsn_ie_len = min(info_element->len + 2,
956                                                  MAX_WPA_IE_LEN);
957                         memcpy(network->rsn_ie, info_element, 
958                                network->rsn_ie_len);
959                         break;
960 #endif
961
962                 default:
963                         IEEE80211_DEBUG_SCAN("unsupported IE %d\n", 
964                                              info_element->id);
965                         break;
966                 }
967
968                 left -= sizeof(struct ieee80211_info_element_hdr) + 
969                         info_element->len;
970                 info_element = (struct ieee80211_info_element *)
971                         &info_element->data[info_element->len];
972         }
973         
974         network->mode = 0;
975         if (stats->freq == IEEE80211_52GHZ_BAND) {
976                 network->mode = IEEE_A;
977         } else {
978                 if (network->flags & NETWORK_HAS_OFDM)
979                         network->mode |= IEEE_G;
980                 if (network->flags & NETWORK_HAS_CCK)
981                         network->mode |= IEEE_B;
982         }
983
984         if (network->mode == 0) {
985                 IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' "
986                                      "network.\n",
987                                      escape_essid(network->ssid, 
988                                                   network->ssid_len),
989                                      MAC_ARG(network->bssid));
990                 return 1;
991         }
992         
993         if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
994                 network->flags |= NETWORK_EMPTY_ESSID;
995
996         memcpy(&network->stats, stats, sizeof(network->stats));
997
998         return 0;
999 }
1000
1001 static inline int is_same_network(struct ieee80211_network *src,
1002                                   struct ieee80211_network *dst)
1003 {
1004         /* A network is only a duplicate if the channel, BSSID, and ESSID
1005          * all match.  We treat all <hidden> with the same BSSID and channel
1006          * as one network */
1007         return ((src->ssid_len == dst->ssid_len) &&
1008                 (src->channel == dst->channel) &&
1009                 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
1010                 !memcmp(src->ssid, dst->ssid, src->ssid_len));
1011 }
1012
1013 static inline void update_network(struct ieee80211_network *dst,
1014                                   struct ieee80211_network *src)
1015 {
1016         memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
1017         dst->capability = src->capability;
1018         memcpy(dst->rates, src->rates, src->rates_len);
1019         dst->rates_len = src->rates_len;
1020         memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
1021         dst->rates_ex_len = src->rates_ex_len;
1022
1023         dst->mode = src->mode;
1024         dst->flags = src->flags;
1025         dst->time_stamp[0] = src->time_stamp[0];
1026         dst->time_stamp[1] = src->time_stamp[1];
1027
1028         dst->beacon_interval = src->beacon_interval;
1029         dst->listen_interval = src->listen_interval;
1030         dst->atim_window = src->atim_window;
1031
1032 #ifdef CONFIG_IEEE80211_WPA             
1033         memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
1034         dst->wpa_ie_len = src->wpa_ie_len;
1035         memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
1036         dst->rsn_ie_len = src->rsn_ie_len;
1037 #endif /* CONFIG_IEEE80211_WPA */       
1038
1039         dst->last_scanned = jiffies;
1040         /* dst->last_associate is not overwritten */
1041 }
1042
1043 static inline void ieee80211_process_probe_response(
1044         struct ieee80211_device *ieee,
1045         struct ieee80211_probe_response *beacon,
1046         struct ieee80211_rx_stats *stats)
1047 {
1048         struct ieee80211_network network;
1049         struct ieee80211_network *target;
1050         struct ieee80211_network *oldest = NULL;
1051 #ifdef CONFIG_IEEE80211_DEBUG
1052         struct ieee80211_info_element *info_element = &beacon->info_element;
1053 #endif
1054
1055         IEEE80211_DEBUG_SCAN(
1056                 "'%s' (" MAC_FMT "): %c%c%c%c-%c%c%c%c\n",
1057                 escape_essid(info_element->data, info_element->len),
1058                 MAC_ARG(beacon->header.addr3),
1059                 (beacon->capability & BIT(7)) ? '1' : '0',
1060                 (beacon->capability & BIT(6)) ? '1' : '0',
1061                 (beacon->capability & BIT(5)) ? '1' : '0',
1062                 (beacon->capability & BIT(4)) ? '1' : '0',
1063                 (beacon->capability & BIT(3)) ? '1' : '0',
1064                 (beacon->capability & BIT(2)) ? '1' : '0',
1065                 (beacon->capability & BIT(1)) ? '1' : '0',
1066                 (beacon->capability & BIT(0)) ? '1' : '0');
1067
1068         if (ieee80211_network_init(ieee, beacon, &network, stats)) {
1069                 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
1070                                      escape_essid(info_element->data, 
1071                                                   info_element->len),
1072                                      MAC_ARG(beacon->header.addr3),
1073                                      WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
1074                                      IEEE80211_STYPE_PROBE_RESP ? 
1075                                      "PROBE RESPONSE" : "BEACON");
1076                 return;
1077         }
1078
1079         /* The network parsed correctly -- so now we scan our known networks
1080          * to see if we can find it in our list.
1081          *  
1082          * NOTE:  This search is definitely not optimized.  Once its doing
1083          *        the "right thing" we'll optimize it for efficiency if 
1084          *        necessary */
1085         
1086         /* Search for this entry in the list and update it if it is 
1087          * already there. */
1088         list_for_each_entry(target, &ieee->network_list, list) {
1089                 if (is_same_network(target, &network))
1090                         break;
1091
1092                 if ((oldest == NULL) || 
1093                     (target->last_scanned < oldest->last_scanned))
1094                         oldest = target;
1095         }
1096
1097         /* If we didn't find a match, then get a new network slot to initialize
1098          * with this beacon's information */
1099         if (&target->list == &ieee->network_list) {
1100                 if (list_empty(&ieee->network_free_list)) {
1101                         /* If there are no more slots, expire the oldest */
1102                         list_del(&oldest->list);
1103                         target = oldest;
1104                         IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from "
1105                                              "network list.\n", 
1106                                              escape_essid(target->ssid, 
1107                                                           target->ssid_len),
1108                                              MAC_ARG(target->bssid));
1109                 } else {
1110                         /* Otherwise just pull from the free list */
1111                         target = list_entry(ieee->network_free_list.next, 
1112                                             struct ieee80211_network, list);
1113                         list_del(ieee->network_free_list.next);
1114                 }
1115
1116                 
1117 #ifdef CONFIG_IEEE80211_DEBUG
1118                 IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n",
1119                                      escape_essid(network.ssid, 
1120                                                   network.ssid_len),
1121                                      MAC_ARG(network.bssid),
1122                                      WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
1123                                      IEEE80211_STYPE_PROBE_RESP ? 
1124                                      "PROBE RESPONSE" : "BEACON");
1125 #endif
1126                 memcpy(target, &network, sizeof(*target));
1127                 list_add_tail(&target->list, &ieee->network_list);
1128         } else {
1129                 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
1130                                      escape_essid(target->ssid, 
1131                                                   target->ssid_len),
1132                                      MAC_ARG(target->bssid),
1133                                      WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
1134                                      IEEE80211_STYPE_PROBE_RESP ? 
1135                                      "PROBE RESPONSE" : "BEACON");
1136                 update_network(target, &network);
1137         }
1138 }
1139         
1140 void ieee80211_rx_mgt(struct ieee80211_device *ieee,
1141                       struct ieee80211_hdr *header,
1142                       struct ieee80211_rx_stats *stats)
1143 {
1144         switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
1145         case IEEE80211_STYPE_ASSOC_RESP:
1146                 IEEE80211_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
1147                                      WLAN_FC_GET_STYPE(header->frame_ctl));
1148                 break;
1149
1150         case IEEE80211_STYPE_REASSOC_RESP:
1151                 IEEE80211_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
1152                                      WLAN_FC_GET_STYPE(header->frame_ctl));
1153                 break;
1154
1155         case IEEE80211_STYPE_PROBE_RESP:
1156                 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
1157                                      WLAN_FC_GET_STYPE(header->frame_ctl));
1158                 IEEE80211_DEBUG_SCAN("Probe response\n");
1159                 ieee80211_process_probe_response(
1160                         ieee, (struct ieee80211_probe_response *)header, stats);
1161                 break;
1162
1163         case IEEE80211_STYPE_BEACON:
1164                 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n", 
1165                                      WLAN_FC_GET_STYPE(header->frame_ctl));
1166                 IEEE80211_DEBUG_SCAN("Beacon\n");
1167                 ieee80211_process_probe_response(
1168                         ieee, (struct ieee80211_probe_response *)header, stats);
1169                 break;
1170
1171         default:
1172                 IEEE80211_DEBUG_MGMT("received UNKNOWN (%d)\n", 
1173                                      WLAN_FC_GET_STYPE(header->frame_ctl));
1174                 IEEE80211_WARNING("%s: Unknown management packet: %d\n",
1175                                   ieee->dev->name, 
1176                                   WLAN_FC_GET_STYPE(header->frame_ctl));
1177                 break;
1178         }
1179 }
1180
1181
1182 EXPORT_SYMBOL(ieee80211_rx_mgt);
1183 EXPORT_SYMBOL(ieee80211_rx);