Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Original code based Host AP (software wireless LAN access point) driver
0004  * for Intersil Prism2/2.5/3 - hostap.o module, common routines
0005  *
0006  * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
0007  * <j@w1.fi>
0008  * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
0009  * Copyright (c) 2004-2005, Intel Corporation
0010  */
0011 
0012 #include <linux/compiler.h>
0013 #include <linux/errno.h>
0014 #include <linux/if_arp.h>
0015 #include <linux/in6.h>
0016 #include <linux/gfp.h>
0017 #include <linux/in.h>
0018 #include <linux/ip.h>
0019 #include <linux/kernel.h>
0020 #include <linux/module.h>
0021 #include <linux/netdevice.h>
0022 #include <linux/proc_fs.h>
0023 #include <linux/skbuff.h>
0024 #include <linux/tcp.h>
0025 #include <linux/types.h>
0026 #include <linux/wireless.h>
0027 #include <linux/etherdevice.h>
0028 #include <linux/uaccess.h>
0029 #include <linux/ctype.h>
0030 
0031 #include <net/lib80211.h>
0032 
0033 #include "libipw.h"
0034 
0035 static void libipw_monitor_rx(struct libipw_device *ieee,
0036                     struct sk_buff *skb,
0037                     struct libipw_rx_stats *rx_stats)
0038 {
0039     struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
0040     u16 fc = le16_to_cpu(hdr->frame_control);
0041 
0042     skb->dev = ieee->dev;
0043     skb_reset_mac_header(skb);
0044     skb_pull(skb, libipw_get_hdrlen(fc));
0045     skb->pkt_type = PACKET_OTHERHOST;
0046     skb->protocol = htons(ETH_P_80211_RAW);
0047     memset(skb->cb, 0, sizeof(skb->cb));
0048     netif_rx(skb);
0049 }
0050 
0051 /* Called only as a tasklet (software IRQ) */
0052 static struct libipw_frag_entry *libipw_frag_cache_find(struct
0053                                   libipw_device
0054                                   *ieee,
0055                                   unsigned int seq,
0056                                   unsigned int frag,
0057                                   u8 * src,
0058                                   u8 * dst)
0059 {
0060     struct libipw_frag_entry *entry;
0061     int i;
0062 
0063     for (i = 0; i < LIBIPW_FRAG_CACHE_LEN; i++) {
0064         entry = &ieee->frag_cache[i];
0065         if (entry->skb != NULL &&
0066             time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
0067             LIBIPW_DEBUG_FRAG("expiring fragment cache entry "
0068                          "seq=%u last_frag=%u\n",
0069                          entry->seq, entry->last_frag);
0070             dev_kfree_skb_any(entry->skb);
0071             entry->skb = NULL;
0072         }
0073 
0074         if (entry->skb != NULL && entry->seq == seq &&
0075             (entry->last_frag + 1 == frag || frag == -1) &&
0076             ether_addr_equal(entry->src_addr, src) &&
0077             ether_addr_equal(entry->dst_addr, dst))
0078             return entry;
0079     }
0080 
0081     return NULL;
0082 }
0083 
0084 /* Called only as a tasklet (software IRQ) */
0085 static struct sk_buff *libipw_frag_cache_get(struct libipw_device *ieee,
0086                         struct libipw_hdr_4addr *hdr)
0087 {
0088     struct sk_buff *skb = NULL;
0089     u16 sc;
0090     unsigned int frag, seq;
0091     struct libipw_frag_entry *entry;
0092 
0093     sc = le16_to_cpu(hdr->seq_ctl);
0094     frag = WLAN_GET_SEQ_FRAG(sc);
0095     seq = WLAN_GET_SEQ_SEQ(sc);
0096 
0097     if (frag == 0) {
0098         /* Reserve enough space to fit maximum frame length */
0099         skb = dev_alloc_skb(ieee->dev->mtu +
0100                     sizeof(struct libipw_hdr_4addr) +
0101                     8 /* LLC */  +
0102                     2 /* alignment */  +
0103                     8 /* WEP */  + ETH_ALEN /* WDS */ );
0104         if (skb == NULL)
0105             return NULL;
0106 
0107         entry = &ieee->frag_cache[ieee->frag_next_idx];
0108         ieee->frag_next_idx++;
0109         if (ieee->frag_next_idx >= LIBIPW_FRAG_CACHE_LEN)
0110             ieee->frag_next_idx = 0;
0111 
0112         if (entry->skb != NULL)
0113             dev_kfree_skb_any(entry->skb);
0114 
0115         entry->first_frag_time = jiffies;
0116         entry->seq = seq;
0117         entry->last_frag = frag;
0118         entry->skb = skb;
0119         memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
0120         memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
0121     } else {
0122         /* received a fragment of a frame for which the head fragment
0123          * should have already been received */
0124         entry = libipw_frag_cache_find(ieee, seq, frag, hdr->addr2,
0125                           hdr->addr1);
0126         if (entry != NULL) {
0127             entry->last_frag = frag;
0128             skb = entry->skb;
0129         }
0130     }
0131 
0132     return skb;
0133 }
0134 
0135 /* Called only as a tasklet (software IRQ) */
0136 static int libipw_frag_cache_invalidate(struct libipw_device *ieee,
0137                        struct libipw_hdr_4addr *hdr)
0138 {
0139     u16 sc;
0140     unsigned int seq;
0141     struct libipw_frag_entry *entry;
0142 
0143     sc = le16_to_cpu(hdr->seq_ctl);
0144     seq = WLAN_GET_SEQ_SEQ(sc);
0145 
0146     entry = libipw_frag_cache_find(ieee, seq, -1, hdr->addr2,
0147                       hdr->addr1);
0148 
0149     if (entry == NULL) {
0150         LIBIPW_DEBUG_FRAG("could not invalidate fragment cache "
0151                      "entry (seq=%u)\n", seq);
0152         return -1;
0153     }
0154 
0155     entry->skb = NULL;
0156     return 0;
0157 }
0158 
0159 #ifdef NOT_YET
0160 /* libipw_rx_frame_mgtmt
0161  *
0162  * Responsible for handling management control frames
0163  *
0164  * Called by libipw_rx */
0165 static int
0166 libipw_rx_frame_mgmt(struct libipw_device *ieee, struct sk_buff *skb,
0167             struct libipw_rx_stats *rx_stats, u16 type,
0168             u16 stype)
0169 {
0170     if (ieee->iw_mode == IW_MODE_MASTER) {
0171         printk(KERN_DEBUG "%s: Master mode not yet supported.\n",
0172                ieee->dev->name);
0173         return 0;
0174 /*
0175   hostap_update_sta_ps(ieee, (struct hostap_libipw_hdr_4addr *)
0176   skb->data);*/
0177     }
0178 
0179     if (ieee->hostapd && type == WLAN_FC_TYPE_MGMT) {
0180         if (stype == WLAN_FC_STYPE_BEACON &&
0181             ieee->iw_mode == IW_MODE_MASTER) {
0182             struct sk_buff *skb2;
0183             /* Process beacon frames also in kernel driver to
0184              * update STA(AP) table statistics */
0185             skb2 = skb_clone(skb, GFP_ATOMIC);
0186             if (skb2)
0187                 hostap_rx(skb2->dev, skb2, rx_stats);
0188         }
0189 
0190         /* send management frames to the user space daemon for
0191          * processing */
0192         ieee->apdevstats.rx_packets++;
0193         ieee->apdevstats.rx_bytes += skb->len;
0194         prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
0195         return 0;
0196     }
0197 
0198     if (ieee->iw_mode == IW_MODE_MASTER) {
0199         if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
0200             printk(KERN_DEBUG "%s: unknown management frame "
0201                    "(type=0x%02x, stype=0x%02x) dropped\n",
0202                    skb->dev->name, type, stype);
0203             return -1;
0204         }
0205 
0206         hostap_rx(skb->dev, skb, rx_stats);
0207         return 0;
0208     }
0209 
0210     printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
0211            "received in non-Host AP mode\n", skb->dev->name);
0212     return -1;
0213 }
0214 #endif
0215 
0216 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
0217 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
0218 static unsigned char libipw_rfc1042_header[] =
0219     { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
0220 
0221 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
0222 static unsigned char libipw_bridge_tunnel_header[] =
0223     { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
0224 /* No encapsulation header if EtherType < 0x600 (=length) */
0225 
0226 /* Called by libipw_rx_frame_decrypt */
0227 static int libipw_is_eapol_frame(struct libipw_device *ieee,
0228                     struct sk_buff *skb)
0229 {
0230     struct net_device *dev = ieee->dev;
0231     u16 fc, ethertype;
0232     struct libipw_hdr_3addr *hdr;
0233     u8 *pos;
0234 
0235     if (skb->len < 24)
0236         return 0;
0237 
0238     hdr = (struct libipw_hdr_3addr *)skb->data;
0239     fc = le16_to_cpu(hdr->frame_ctl);
0240 
0241     /* check that the frame is unicast frame to us */
0242     if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
0243         IEEE80211_FCTL_TODS &&
0244         ether_addr_equal(hdr->addr1, dev->dev_addr) &&
0245         ether_addr_equal(hdr->addr3, dev->dev_addr)) {
0246         /* ToDS frame with own addr BSSID and DA */
0247     } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
0248            IEEE80211_FCTL_FROMDS &&
0249            ether_addr_equal(hdr->addr1, dev->dev_addr)) {
0250         /* FromDS frame with own addr as DA */
0251     } else
0252         return 0;
0253 
0254     if (skb->len < 24 + 8)
0255         return 0;
0256 
0257     /* check for port access entity Ethernet type */
0258     pos = skb->data + 24;
0259     ethertype = (pos[6] << 8) | pos[7];
0260     if (ethertype == ETH_P_PAE)
0261         return 1;
0262 
0263     return 0;
0264 }
0265 
0266 /* Called only as a tasklet (software IRQ), by libipw_rx */
0267 static int
0268 libipw_rx_frame_decrypt(struct libipw_device *ieee, struct sk_buff *skb,
0269                struct lib80211_crypt_data *crypt)
0270 {
0271     struct libipw_hdr_3addr *hdr;
0272     int res, hdrlen;
0273 
0274     if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
0275         return 0;
0276 
0277     hdr = (struct libipw_hdr_3addr *)skb->data;
0278     hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
0279 
0280     atomic_inc(&crypt->refcnt);
0281     res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
0282     atomic_dec(&crypt->refcnt);
0283     if (res < 0) {
0284         LIBIPW_DEBUG_DROP("decryption failed (SA=%pM) res=%d\n",
0285                      hdr->addr2, res);
0286         if (res == -2)
0287             LIBIPW_DEBUG_DROP("Decryption failed ICV "
0288                          "mismatch (key %d)\n",
0289                          skb->data[hdrlen + 3] >> 6);
0290         ieee->ieee_stats.rx_discards_undecryptable++;
0291         return -1;
0292     }
0293 
0294     return res;
0295 }
0296 
0297 /* Called only as a tasklet (software IRQ), by libipw_rx */
0298 static int
0299 libipw_rx_frame_decrypt_msdu(struct libipw_device *ieee,
0300                 struct sk_buff *skb, int keyidx,
0301                 struct lib80211_crypt_data *crypt)
0302 {
0303     struct libipw_hdr_3addr *hdr;
0304     int res, hdrlen;
0305 
0306     if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
0307         return 0;
0308 
0309     hdr = (struct libipw_hdr_3addr *)skb->data;
0310     hdrlen = libipw_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
0311 
0312     atomic_inc(&crypt->refcnt);
0313     res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
0314     atomic_dec(&crypt->refcnt);
0315     if (res < 0) {
0316         printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
0317                " (SA=%pM keyidx=%d)\n", ieee->dev->name, hdr->addr2,
0318                keyidx);
0319         return -1;
0320     }
0321 
0322     return 0;
0323 }
0324 
0325 /* All received frames are sent to this function. @skb contains the frame in
0326  * IEEE 802.11 format, i.e., in the format it was sent over air.
0327  * This function is called only as a tasklet (software IRQ). */
0328 int libipw_rx(struct libipw_device *ieee, struct sk_buff *skb,
0329          struct libipw_rx_stats *rx_stats)
0330 {
0331     struct net_device *dev = ieee->dev;
0332     struct libipw_hdr_4addr *hdr;
0333     size_t hdrlen;
0334     u16 fc, type, stype, sc;
0335     unsigned int frag;
0336     u8 *payload;
0337     u16 ethertype;
0338 #ifdef NOT_YET
0339     struct net_device *wds = NULL;
0340     struct sk_buff *skb2 = NULL;
0341     struct net_device *wds = NULL;
0342     int frame_authorized = 0;
0343     int from_assoc_ap = 0;
0344     void *sta = NULL;
0345 #endif
0346     u8 dst[ETH_ALEN];
0347     u8 src[ETH_ALEN];
0348     struct lib80211_crypt_data *crypt = NULL;
0349     int keyidx = 0;
0350     int can_be_decrypted = 0;
0351 
0352     hdr = (struct libipw_hdr_4addr *)skb->data;
0353     if (skb->len < 10) {
0354         printk(KERN_INFO "%s: SKB length < 10\n", dev->name);
0355         goto rx_dropped;
0356     }
0357 
0358     fc = le16_to_cpu(hdr->frame_ctl);
0359     type = WLAN_FC_GET_TYPE(fc);
0360     stype = WLAN_FC_GET_STYPE(fc);
0361     sc = le16_to_cpu(hdr->seq_ctl);
0362     frag = WLAN_GET_SEQ_FRAG(sc);
0363     hdrlen = libipw_get_hdrlen(fc);
0364 
0365     if (skb->len < hdrlen) {
0366         printk(KERN_INFO "%s: invalid SKB length %d\n",
0367             dev->name, skb->len);
0368         goto rx_dropped;
0369     }
0370 
0371     /* Put this code here so that we avoid duplicating it in all
0372      * Rx paths. - Jean II */
0373 #ifdef CONFIG_WIRELESS_EXT
0374 #ifdef IW_WIRELESS_SPY      /* defined in iw_handler.h */
0375     /* If spy monitoring on */
0376     if (ieee->spy_data.spy_number > 0) {
0377         struct iw_quality wstats;
0378 
0379         wstats.updated = 0;
0380         if (rx_stats->mask & LIBIPW_STATMASK_RSSI) {
0381             wstats.level = rx_stats->signal;
0382             wstats.updated |= IW_QUAL_LEVEL_UPDATED;
0383         } else
0384             wstats.updated |= IW_QUAL_LEVEL_INVALID;
0385 
0386         if (rx_stats->mask & LIBIPW_STATMASK_NOISE) {
0387             wstats.noise = rx_stats->noise;
0388             wstats.updated |= IW_QUAL_NOISE_UPDATED;
0389         } else
0390             wstats.updated |= IW_QUAL_NOISE_INVALID;
0391 
0392         if (rx_stats->mask & LIBIPW_STATMASK_SIGNAL) {
0393             wstats.qual = rx_stats->signal;
0394             wstats.updated |= IW_QUAL_QUAL_UPDATED;
0395         } else
0396             wstats.updated |= IW_QUAL_QUAL_INVALID;
0397 
0398         /* Update spy records */
0399         wireless_spy_update(ieee->dev, hdr->addr2, &wstats);
0400     }
0401 #endif              /* IW_WIRELESS_SPY */
0402 #endif              /* CONFIG_WIRELESS_EXT */
0403 
0404 #ifdef NOT_YET
0405     hostap_update_rx_stats(local->ap, hdr, rx_stats);
0406 #endif
0407 
0408     if (ieee->iw_mode == IW_MODE_MONITOR) {
0409         dev->stats.rx_packets++;
0410         dev->stats.rx_bytes += skb->len;
0411         libipw_monitor_rx(ieee, skb, rx_stats);
0412         return 1;
0413     }
0414 
0415     can_be_decrypted = (is_multicast_ether_addr(hdr->addr1) ||
0416                 is_broadcast_ether_addr(hdr->addr2)) ?
0417         ieee->host_mc_decrypt : ieee->host_decrypt;
0418 
0419     if (can_be_decrypted) {
0420         if (skb->len >= hdrlen + 3) {
0421             /* Top two-bits of byte 3 are the key index */
0422             keyidx = skb->data[hdrlen + 3] >> 6;
0423         }
0424 
0425         /* ieee->crypt[] is WEP_KEY (4) in length.  Given that keyidx
0426          * is only allowed 2-bits of storage, no value of keyidx can
0427          * be provided via above code that would result in keyidx
0428          * being out of range */
0429         crypt = ieee->crypt_info.crypt[keyidx];
0430 
0431 #ifdef NOT_YET
0432         sta = NULL;
0433 
0434         /* Use station specific key to override default keys if the
0435          * receiver address is a unicast address ("individual RA"). If
0436          * bcrx_sta_key parameter is set, station specific key is used
0437          * even with broad/multicast targets (this is against IEEE
0438          * 802.11, but makes it easier to use different keys with
0439          * stations that do not support WEP key mapping). */
0440 
0441         if (is_unicast_ether_addr(hdr->addr1) || local->bcrx_sta_key)
0442             (void)hostap_handle_sta_crypto(local, hdr, &crypt,
0443                                &sta);
0444 #endif
0445 
0446         /* allow NULL decrypt to indicate an station specific override
0447          * for default encryption */
0448         if (crypt && (crypt->ops == NULL ||
0449                   crypt->ops->decrypt_mpdu == NULL))
0450             crypt = NULL;
0451 
0452         if (!crypt && (fc & IEEE80211_FCTL_PROTECTED)) {
0453             /* This seems to be triggered by some (multicast?)
0454              * frames from other than current BSS, so just drop the
0455              * frames silently instead of filling system log with
0456              * these reports. */
0457             LIBIPW_DEBUG_DROP("Decryption failed (not set)"
0458                          " (SA=%pM)\n", hdr->addr2);
0459             ieee->ieee_stats.rx_discards_undecryptable++;
0460             goto rx_dropped;
0461         }
0462     }
0463 #ifdef NOT_YET
0464     if (type != WLAN_FC_TYPE_DATA) {
0465         if (type == WLAN_FC_TYPE_MGMT && stype == WLAN_FC_STYPE_AUTH &&
0466             fc & IEEE80211_FCTL_PROTECTED && ieee->host_decrypt &&
0467             (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0) {
0468             printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
0469                    "from %pM\n", dev->name, hdr->addr2);
0470             /* TODO: could inform hostapd about this so that it
0471              * could send auth failure report */
0472             goto rx_dropped;
0473         }
0474 
0475         if (libipw_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
0476             goto rx_dropped;
0477         else
0478             goto rx_exit;
0479     }
0480 #endif
0481     /* drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.29) */
0482     if (sc == ieee->prev_seq_ctl)
0483         goto rx_dropped;
0484     else
0485         ieee->prev_seq_ctl = sc;
0486 
0487     /* Data frame - extract src/dst addresses */
0488     if (skb->len < LIBIPW_3ADDR_LEN)
0489         goto rx_dropped;
0490 
0491     switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
0492     case IEEE80211_FCTL_FROMDS:
0493         memcpy(dst, hdr->addr1, ETH_ALEN);
0494         memcpy(src, hdr->addr3, ETH_ALEN);
0495         break;
0496     case IEEE80211_FCTL_TODS:
0497         memcpy(dst, hdr->addr3, ETH_ALEN);
0498         memcpy(src, hdr->addr2, ETH_ALEN);
0499         break;
0500     case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
0501         if (skb->len < LIBIPW_4ADDR_LEN)
0502             goto rx_dropped;
0503         memcpy(dst, hdr->addr3, ETH_ALEN);
0504         memcpy(src, hdr->addr4, ETH_ALEN);
0505         break;
0506     default:
0507         memcpy(dst, hdr->addr1, ETH_ALEN);
0508         memcpy(src, hdr->addr2, ETH_ALEN);
0509         break;
0510     }
0511 
0512 #ifdef NOT_YET
0513     if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
0514         goto rx_dropped;
0515     if (wds) {
0516         skb->dev = dev = wds;
0517         stats = hostap_get_stats(dev);
0518     }
0519 
0520     if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
0521         (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
0522         IEEE80211_FCTL_FROMDS && ieee->stadev &&
0523         ether_addr_equal(hdr->addr2, ieee->assoc_ap_addr)) {
0524         /* Frame from BSSID of the AP for which we are a client */
0525         skb->dev = dev = ieee->stadev;
0526         stats = hostap_get_stats(dev);
0527         from_assoc_ap = 1;
0528     }
0529 #endif
0530 
0531 #ifdef NOT_YET
0532     if ((ieee->iw_mode == IW_MODE_MASTER ||
0533          ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) {
0534         switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
0535                          wds != NULL)) {
0536         case AP_RX_CONTINUE_NOT_AUTHORIZED:
0537             frame_authorized = 0;
0538             break;
0539         case AP_RX_CONTINUE:
0540             frame_authorized = 1;
0541             break;
0542         case AP_RX_DROP:
0543             goto rx_dropped;
0544         case AP_RX_EXIT:
0545             goto rx_exit;
0546         }
0547     }
0548 #endif
0549 
0550     /* Nullfunc frames may have PS-bit set, so they must be passed to
0551      * hostap_handle_sta_rx() before being dropped here. */
0552 
0553     stype &= ~IEEE80211_STYPE_QOS_DATA;
0554 
0555     if (stype != IEEE80211_STYPE_DATA &&
0556         stype != IEEE80211_STYPE_DATA_CFACK &&
0557         stype != IEEE80211_STYPE_DATA_CFPOLL &&
0558         stype != IEEE80211_STYPE_DATA_CFACKPOLL) {
0559         if (stype != IEEE80211_STYPE_NULLFUNC)
0560             LIBIPW_DEBUG_DROP("RX: dropped data frame "
0561                          "with no data (type=0x%02x, "
0562                          "subtype=0x%02x, len=%d)\n",
0563                          type, stype, skb->len);
0564         goto rx_dropped;
0565     }
0566 
0567     /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
0568 
0569     if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
0570         (keyidx = libipw_rx_frame_decrypt(ieee, skb, crypt)) < 0)
0571         goto rx_dropped;
0572 
0573     hdr = (struct libipw_hdr_4addr *)skb->data;
0574 
0575     /* skb: hdr + (possibly fragmented) plaintext payload */
0576     // PR: FIXME: hostap has additional conditions in the "if" below:
0577     // ieee->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) &&
0578     if ((frag != 0) || (fc & IEEE80211_FCTL_MOREFRAGS)) {
0579         int flen;
0580         struct sk_buff *frag_skb = libipw_frag_cache_get(ieee, hdr);
0581         LIBIPW_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
0582 
0583         if (!frag_skb) {
0584             LIBIPW_DEBUG(LIBIPW_DL_RX | LIBIPW_DL_FRAG,
0585                     "Rx cannot get skb from fragment "
0586                     "cache (morefrag=%d seq=%u frag=%u)\n",
0587                     (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
0588                     WLAN_GET_SEQ_SEQ(sc), frag);
0589             goto rx_dropped;
0590         }
0591 
0592         flen = skb->len;
0593         if (frag != 0)
0594             flen -= hdrlen;
0595 
0596         if (frag_skb->tail + flen > frag_skb->end) {
0597             printk(KERN_WARNING "%s: host decrypted and "
0598                    "reassembled frame did not fit skb\n",
0599                    dev->name);
0600             libipw_frag_cache_invalidate(ieee, hdr);
0601             goto rx_dropped;
0602         }
0603 
0604         if (frag == 0) {
0605             /* copy first fragment (including full headers) into
0606              * beginning of the fragment cache skb */
0607             skb_copy_from_linear_data(skb, skb_put(frag_skb, flen), flen);
0608         } else {
0609             /* append frame payload to the end of the fragment
0610              * cache skb */
0611             skb_copy_from_linear_data_offset(skb, hdrlen,
0612                       skb_put(frag_skb, flen), flen);
0613         }
0614         dev_kfree_skb_any(skb);
0615         skb = NULL;
0616 
0617         if (fc & IEEE80211_FCTL_MOREFRAGS) {
0618             /* more fragments expected - leave the skb in fragment
0619              * cache for now; it will be delivered to upper layers
0620              * after all fragments have been received */
0621             goto rx_exit;
0622         }
0623 
0624         /* this was the last fragment and the frame will be
0625          * delivered, so remove skb from fragment cache */
0626         skb = frag_skb;
0627         hdr = (struct libipw_hdr_4addr *)skb->data;
0628         libipw_frag_cache_invalidate(ieee, hdr);
0629     }
0630 
0631     /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
0632      * encrypted/authenticated */
0633     if ((fc & IEEE80211_FCTL_PROTECTED) && can_be_decrypted &&
0634         libipw_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
0635         goto rx_dropped;
0636 
0637     hdr = (struct libipw_hdr_4addr *)skb->data;
0638     if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep) {
0639         if (        /*ieee->ieee802_1x && */
0640                libipw_is_eapol_frame(ieee, skb)) {
0641             /* pass unencrypted EAPOL frames even if encryption is
0642              * configured */
0643         } else {
0644             LIBIPW_DEBUG_DROP("encryption configured, but RX "
0645                          "frame not encrypted (SA=%pM)\n",
0646                          hdr->addr2);
0647             goto rx_dropped;
0648         }
0649     }
0650 
0651     if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !ieee->open_wep &&
0652         !libipw_is_eapol_frame(ieee, skb)) {
0653         LIBIPW_DEBUG_DROP("dropped unencrypted RX data "
0654                      "frame from %pM (drop_unencrypted=1)\n",
0655                      hdr->addr2);
0656         goto rx_dropped;
0657     }
0658 
0659     /* If the frame was decrypted in hardware, we may need to strip off
0660      * any security data (IV, ICV, etc) that was left behind */
0661     if (!can_be_decrypted && (fc & IEEE80211_FCTL_PROTECTED) &&
0662         ieee->host_strip_iv_icv) {
0663         int trimlen = 0;
0664 
0665         /* Top two-bits of byte 3 are the key index */
0666         if (skb->len >= hdrlen + 3)
0667             keyidx = skb->data[hdrlen + 3] >> 6;
0668 
0669         /* To strip off any security data which appears before the
0670          * payload, we simply increase hdrlen (as the header gets
0671          * chopped off immediately below). For the security data which
0672          * appears after the payload, we use skb_trim. */
0673 
0674         switch (ieee->sec.encode_alg[keyidx]) {
0675         case SEC_ALG_WEP:
0676             /* 4 byte IV */
0677             hdrlen += 4;
0678             /* 4 byte ICV */
0679             trimlen = 4;
0680             break;
0681         case SEC_ALG_TKIP:
0682             /* 4 byte IV, 4 byte ExtIV */
0683             hdrlen += 8;
0684             /* 8 byte MIC, 4 byte ICV */
0685             trimlen = 12;
0686             break;
0687         case SEC_ALG_CCMP:
0688             /* 8 byte CCMP header */
0689             hdrlen += 8;
0690             /* 8 byte MIC */
0691             trimlen = 8;
0692             break;
0693         }
0694 
0695         if (skb->len < trimlen)
0696             goto rx_dropped;
0697 
0698         __skb_trim(skb, skb->len - trimlen);
0699 
0700         if (skb->len < hdrlen)
0701             goto rx_dropped;
0702     }
0703 
0704     /* skb: hdr + (possible reassembled) full plaintext payload */
0705 
0706     payload = skb->data + hdrlen;
0707     ethertype = (payload[6] << 8) | payload[7];
0708 
0709 #ifdef NOT_YET
0710     /* If IEEE 802.1X is used, check whether the port is authorized to send
0711      * the received frame. */
0712     if (ieee->ieee802_1x && ieee->iw_mode == IW_MODE_MASTER) {
0713         if (ethertype == ETH_P_PAE) {
0714             printk(KERN_DEBUG "%s: RX: IEEE 802.1X frame\n",
0715                    dev->name);
0716             if (ieee->hostapd && ieee->apdev) {
0717                 /* Send IEEE 802.1X frames to the user
0718                  * space daemon for processing */
0719                 prism2_rx_80211(ieee->apdev, skb, rx_stats,
0720                         PRISM2_RX_MGMT);
0721                 ieee->apdevstats.rx_packets++;
0722                 ieee->apdevstats.rx_bytes += skb->len;
0723                 goto rx_exit;
0724             }
0725         } else if (!frame_authorized) {
0726             printk(KERN_DEBUG "%s: dropped frame from "
0727                    "unauthorized port (IEEE 802.1X): "
0728                    "ethertype=0x%04x\n", dev->name, ethertype);
0729             goto rx_dropped;
0730         }
0731     }
0732 #endif
0733 
0734     /* convert hdr + possible LLC headers into Ethernet header */
0735     if (skb->len - hdrlen >= 8 &&
0736         ((memcmp(payload, libipw_rfc1042_header, SNAP_SIZE) == 0 &&
0737           ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
0738          memcmp(payload, libipw_bridge_tunnel_header, SNAP_SIZE) == 0)) {
0739         /* remove RFC1042 or Bridge-Tunnel encapsulation and
0740          * replace EtherType */
0741         skb_pull(skb, hdrlen + SNAP_SIZE);
0742         memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
0743         memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
0744     } else {
0745         __be16 len;
0746         /* Leave Ethernet header part of hdr and full payload */
0747         skb_pull(skb, hdrlen);
0748         len = htons(skb->len);
0749         memcpy(skb_push(skb, 2), &len, 2);
0750         memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
0751         memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
0752     }
0753 
0754 #ifdef NOT_YET
0755     if (wds && ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
0756             IEEE80211_FCTL_TODS) && skb->len >= ETH_HLEN + ETH_ALEN) {
0757         /* Non-standard frame: get addr4 from its bogus location after
0758          * the payload */
0759         skb_copy_to_linear_data_offset(skb, ETH_ALEN,
0760                            skb->data + skb->len - ETH_ALEN,
0761                            ETH_ALEN);
0762         skb_trim(skb, skb->len - ETH_ALEN);
0763     }
0764 #endif
0765 
0766     dev->stats.rx_packets++;
0767     dev->stats.rx_bytes += skb->len;
0768 
0769 #ifdef NOT_YET
0770     if (ieee->iw_mode == IW_MODE_MASTER && !wds && ieee->ap->bridge_packets) {
0771         if (is_multicast_ether_addr(dst)) {
0772             /* copy multicast frame both to the higher layers and
0773              * to the wireless media */
0774             ieee->ap->bridged_multicast++;
0775             skb2 = skb_clone(skb, GFP_ATOMIC);
0776             if (skb2 == NULL)
0777                 printk(KERN_DEBUG "%s: skb_clone failed for "
0778                        "multicast frame\n", dev->name);
0779         } else if (hostap_is_sta_assoc(ieee->ap, dst)) {
0780             /* send frame directly to the associated STA using
0781              * wireless media and not passing to higher layers */
0782             ieee->ap->bridged_unicast++;
0783             skb2 = skb;
0784             skb = NULL;
0785         }
0786     }
0787 
0788     if (skb2 != NULL) {
0789         /* send to wireless media */
0790         skb2->dev = dev;
0791         skb2->protocol = htons(ETH_P_802_3);
0792         skb_reset_mac_header(skb2);
0793         skb_reset_network_header(skb2);
0794         /* skb2->network_header += ETH_HLEN; */
0795         dev_queue_xmit(skb2);
0796     }
0797 #endif
0798 
0799     if (skb) {
0800         skb->protocol = eth_type_trans(skb, dev);
0801         memset(skb->cb, 0, sizeof(skb->cb));
0802         skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
0803         if (netif_rx(skb) == NET_RX_DROP) {
0804             /* netif_rx always succeeds, but it might drop
0805              * the packet.  If it drops the packet, we log that
0806              * in our stats. */
0807             LIBIPW_DEBUG_DROP
0808                 ("RX: netif_rx dropped the packet\n");
0809             dev->stats.rx_dropped++;
0810         }
0811     }
0812 
0813       rx_exit:
0814 #ifdef NOT_YET
0815     if (sta)
0816         hostap_handle_sta_release(sta);
0817 #endif
0818     return 1;
0819 
0820       rx_dropped:
0821     dev->stats.rx_dropped++;
0822 
0823     /* Returning 0 indicates to caller that we have not handled the SKB--
0824      * so it is still allocated and can be used again by underlying
0825      * hardware as a DMA target */
0826     return 0;
0827 }
0828 
0829 /* Filter out unrelated packets, call libipw_rx[_mgt]
0830  * This function takes over the skb, it should not be used again after calling
0831  * this function. */
0832 void libipw_rx_any(struct libipw_device *ieee,
0833              struct sk_buff *skb, struct libipw_rx_stats *stats)
0834 {
0835     struct libipw_hdr_4addr *hdr;
0836     int is_packet_for_us;
0837     u16 fc;
0838 
0839     if (ieee->iw_mode == IW_MODE_MONITOR) {
0840         if (!libipw_rx(ieee, skb, stats))
0841             dev_kfree_skb_irq(skb);
0842         return;
0843     }
0844 
0845     if (skb->len < sizeof(struct ieee80211_hdr))
0846         goto drop_free;
0847 
0848     hdr = (struct libipw_hdr_4addr *)skb->data;
0849     fc = le16_to_cpu(hdr->frame_ctl);
0850 
0851     if ((fc & IEEE80211_FCTL_VERS) != 0)
0852         goto drop_free;
0853 
0854     switch (fc & IEEE80211_FCTL_FTYPE) {
0855     case IEEE80211_FTYPE_MGMT:
0856         if (skb->len < sizeof(struct libipw_hdr_3addr))
0857             goto drop_free;
0858         libipw_rx_mgt(ieee, hdr, stats);
0859         dev_kfree_skb_irq(skb);
0860         return;
0861     case IEEE80211_FTYPE_DATA:
0862         break;
0863     case IEEE80211_FTYPE_CTL:
0864         return;
0865     default:
0866         return;
0867     }
0868 
0869     is_packet_for_us = 0;
0870     switch (ieee->iw_mode) {
0871     case IW_MODE_ADHOC:
0872         /* our BSS and not from/to DS */
0873         if (ether_addr_equal(hdr->addr3, ieee->bssid))
0874         if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
0875             /* promisc: get all */
0876             if (ieee->dev->flags & IFF_PROMISC)
0877                 is_packet_for_us = 1;
0878             /* to us */
0879             else if (ether_addr_equal(hdr->addr1, ieee->dev->dev_addr))
0880                 is_packet_for_us = 1;
0881             /* mcast */
0882             else if (is_multicast_ether_addr(hdr->addr1))
0883                 is_packet_for_us = 1;
0884         }
0885         break;
0886     case IW_MODE_INFRA:
0887         /* our BSS (== from our AP) and from DS */
0888         if (ether_addr_equal(hdr->addr2, ieee->bssid))
0889         if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
0890             /* promisc: get all */
0891             if (ieee->dev->flags & IFF_PROMISC)
0892                 is_packet_for_us = 1;
0893             /* to us */
0894             else if (ether_addr_equal(hdr->addr1, ieee->dev->dev_addr))
0895                 is_packet_for_us = 1;
0896             /* mcast */
0897             else if (is_multicast_ether_addr(hdr->addr1)) {
0898                 /* not our own packet bcasted from AP */
0899                 if (!ether_addr_equal(hdr->addr3, ieee->dev->dev_addr))
0900                     is_packet_for_us = 1;
0901             }
0902         }
0903         break;
0904     default:
0905         /* ? */
0906         break;
0907     }
0908 
0909     if (is_packet_for_us)
0910         if (!libipw_rx(ieee, skb, stats))
0911             dev_kfree_skb_irq(skb);
0912     return;
0913 
0914 drop_free:
0915     dev_kfree_skb_irq(skb);
0916     ieee->dev->stats.rx_dropped++;
0917 }
0918 
0919 #define MGMT_FRAME_FIXED_PART_LENGTH        0x24
0920 
0921 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
0922 
0923 /*
0924 * Make the structure we read from the beacon packet to have
0925 * the right values
0926 */
0927 static int libipw_verify_qos_info(struct libipw_qos_information_element
0928                      *info_element, int sub_type)
0929 {
0930     if (info_element->elementID != QOS_ELEMENT_ID)
0931         return -1;
0932     if (info_element->qui_subtype != sub_type)
0933         return -1;
0934     if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
0935         return -1;
0936     if (info_element->qui_type != QOS_OUI_TYPE)
0937         return -1;
0938     if (info_element->version != QOS_VERSION_1)
0939         return -1;
0940 
0941     return 0;
0942 }
0943 
0944 /*
0945  * Parse a QoS parameter element
0946  */
0947 static int libipw_read_qos_param_element(
0948             struct libipw_qos_parameter_info *element_param,
0949             struct libipw_info_element *info_element)
0950 {
0951     size_t size = sizeof(*element_param);
0952 
0953     if (!element_param || !info_element || info_element->len != size - 2)
0954         return -1;
0955 
0956     memcpy(element_param, info_element, size);
0957     return libipw_verify_qos_info(&element_param->info_element,
0958                       QOS_OUI_PARAM_SUB_TYPE);
0959 }
0960 
0961 /*
0962  * Parse a QoS information element
0963  */
0964 static int libipw_read_qos_info_element(
0965             struct libipw_qos_information_element *element_info,
0966             struct libipw_info_element *info_element)
0967 {
0968     size_t size = sizeof(struct libipw_qos_information_element) - 2;
0969 
0970     if (!element_info || !info_element || info_element->len != size - 2)
0971         return -1;
0972 
0973     memcpy(element_info, info_element, size);
0974     return libipw_verify_qos_info(element_info, QOS_OUI_INFO_SUB_TYPE);
0975 }
0976 
0977 /*
0978  * Write QoS parameters from the ac parameters.
0979  */
0980 static void libipw_qos_convert_ac_to_parameters(struct
0981                           libipw_qos_parameter_info
0982                           *param_elm, struct
0983                           libipw_qos_parameters
0984                           *qos_param)
0985 {
0986     int i;
0987     struct libipw_qos_ac_parameter *ac_params;
0988     u32 txop;
0989     u8 cw_min;
0990     u8 cw_max;
0991 
0992     for (i = 0; i < QOS_QUEUE_NUM; i++) {
0993         ac_params = &(param_elm->ac_params_record[i]);
0994 
0995         qos_param->aifs[i] = (ac_params->aci_aifsn) & 0x0F;
0996         qos_param->aifs[i] -= (qos_param->aifs[i] < 2) ? 0 : 2;
0997 
0998         cw_min = ac_params->ecw_min_max & 0x0F;
0999         qos_param->cw_min[i] = cpu_to_le16((1 << cw_min) - 1);
1000 
1001         cw_max = (ac_params->ecw_min_max & 0xF0) >> 4;
1002         qos_param->cw_max[i] = cpu_to_le16((1 << cw_max) - 1);
1003 
1004         qos_param->flag[i] =
1005             (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
1006 
1007         txop = le16_to_cpu(ac_params->tx_op_limit) * 32;
1008         qos_param->tx_op_limit[i] = cpu_to_le16(txop);
1009     }
1010 }
1011 
1012 /*
1013  * we have a generic data element which it may contain QoS information or
1014  * parameters element. check the information element length to decide
1015  * which type to read
1016  */
1017 static int libipw_parse_qos_info_param_IE(struct libipw_info_element
1018                          *info_element,
1019                          struct libipw_network *network)
1020 {
1021     int rc = 0;
1022     struct libipw_qos_parameters *qos_param = NULL;
1023     struct libipw_qos_information_element qos_info_element;
1024 
1025     rc = libipw_read_qos_info_element(&qos_info_element, info_element);
1026 
1027     if (rc == 0) {
1028         network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1029         network->flags |= NETWORK_HAS_QOS_INFORMATION;
1030     } else {
1031         struct libipw_qos_parameter_info param_element;
1032 
1033         rc = libipw_read_qos_param_element(&param_element,
1034                               info_element);
1035         if (rc == 0) {
1036             qos_param = &(network->qos_data.parameters);
1037             libipw_qos_convert_ac_to_parameters(&param_element,
1038                                    qos_param);
1039             network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1040             network->qos_data.param_count =
1041                 param_element.info_element.ac_info & 0x0F;
1042         }
1043     }
1044 
1045     if (rc == 0) {
1046         LIBIPW_DEBUG_QOS("QoS is supported\n");
1047         network->qos_data.supported = 1;
1048     }
1049     return rc;
1050 }
1051 
1052 #ifdef CONFIG_LIBIPW_DEBUG
1053 #define MFIE_STRING(x) case WLAN_EID_ ##x: return #x
1054 
1055 static const char *get_info_element_string(u16 id)
1056 {
1057     switch (id) {
1058         MFIE_STRING(SSID);
1059         MFIE_STRING(SUPP_RATES);
1060         MFIE_STRING(FH_PARAMS);
1061         MFIE_STRING(DS_PARAMS);
1062         MFIE_STRING(CF_PARAMS);
1063         MFIE_STRING(TIM);
1064         MFIE_STRING(IBSS_PARAMS);
1065         MFIE_STRING(COUNTRY);
1066         MFIE_STRING(REQUEST);
1067         MFIE_STRING(CHALLENGE);
1068         MFIE_STRING(PWR_CONSTRAINT);
1069         MFIE_STRING(PWR_CAPABILITY);
1070         MFIE_STRING(TPC_REQUEST);
1071         MFIE_STRING(TPC_REPORT);
1072         MFIE_STRING(SUPPORTED_CHANNELS);
1073         MFIE_STRING(CHANNEL_SWITCH);
1074         MFIE_STRING(MEASURE_REQUEST);
1075         MFIE_STRING(MEASURE_REPORT);
1076         MFIE_STRING(QUIET);
1077         MFIE_STRING(IBSS_DFS);
1078         MFIE_STRING(ERP_INFO);
1079         MFIE_STRING(RSN);
1080         MFIE_STRING(EXT_SUPP_RATES);
1081         MFIE_STRING(VENDOR_SPECIFIC);
1082         MFIE_STRING(QOS_PARAMETER);
1083     default:
1084         return "UNKNOWN";
1085     }
1086 }
1087 #endif
1088 
1089 static int libipw_parse_info_param(struct libipw_info_element
1090                       *info_element, u16 length,
1091                       struct libipw_network *network)
1092 {
1093     u8 i;
1094 #ifdef CONFIG_LIBIPW_DEBUG
1095     char rates_str[64];
1096     char *p;
1097 #endif
1098 
1099     while (length >= sizeof(*info_element)) {
1100         if (sizeof(*info_element) + info_element->len > length) {
1101             LIBIPW_DEBUG_MGMT("Info elem: parse failed: "
1102                          "info_element->len + 2 > left : "
1103                          "info_element->len+2=%zd left=%d, id=%d.\n",
1104                          info_element->len +
1105                          sizeof(*info_element),
1106                          length, info_element->id);
1107             /* We stop processing but don't return an error here
1108              * because some misbehaviour APs break this rule. ie.
1109              * Orinoco AP1000. */
1110             break;
1111         }
1112 
1113         switch (info_element->id) {
1114         case WLAN_EID_SSID:
1115             network->ssid_len = min(info_element->len,
1116                         (u8) IW_ESSID_MAX_SIZE);
1117             memcpy(network->ssid, info_element->data,
1118                    network->ssid_len);
1119             if (network->ssid_len < IW_ESSID_MAX_SIZE)
1120                 memset(network->ssid + network->ssid_len, 0,
1121                        IW_ESSID_MAX_SIZE - network->ssid_len);
1122 
1123             LIBIPW_DEBUG_MGMT("WLAN_EID_SSID: '%*pE' len=%d.\n",
1124                       network->ssid_len, network->ssid,
1125                       network->ssid_len);
1126             break;
1127 
1128         case WLAN_EID_SUPP_RATES:
1129 #ifdef CONFIG_LIBIPW_DEBUG
1130             p = rates_str;
1131 #endif
1132             network->rates_len = min(info_element->len,
1133                          MAX_RATES_LENGTH);
1134             for (i = 0; i < network->rates_len; i++) {
1135                 network->rates[i] = info_element->data[i];
1136 #ifdef CONFIG_LIBIPW_DEBUG
1137                 p += scnprintf(p, sizeof(rates_str) -
1138                           (p - rates_str), "%02X ",
1139                           network->rates[i]);
1140 #endif
1141                 if (libipw_is_ofdm_rate
1142                     (info_element->data[i])) {
1143                     network->flags |= NETWORK_HAS_OFDM;
1144                     if (info_element->data[i] &
1145                         LIBIPW_BASIC_RATE_MASK)
1146                         network->flags &=
1147                             ~NETWORK_HAS_CCK;
1148                 }
1149             }
1150 
1151             LIBIPW_DEBUG_MGMT("WLAN_EID_SUPP_RATES: '%s' (%d)\n",
1152                          rates_str, network->rates_len);
1153             break;
1154 
1155         case WLAN_EID_EXT_SUPP_RATES:
1156 #ifdef CONFIG_LIBIPW_DEBUG
1157             p = rates_str;
1158 #endif
1159             network->rates_ex_len = min(info_element->len,
1160                             MAX_RATES_EX_LENGTH);
1161             for (i = 0; i < network->rates_ex_len; i++) {
1162                 network->rates_ex[i] = info_element->data[i];
1163 #ifdef CONFIG_LIBIPW_DEBUG
1164                 p += scnprintf(p, sizeof(rates_str) -
1165                           (p - rates_str), "%02X ",
1166                           network->rates_ex[i]);
1167 #endif
1168                 if (libipw_is_ofdm_rate
1169                     (info_element->data[i])) {
1170                     network->flags |= NETWORK_HAS_OFDM;
1171                     if (info_element->data[i] &
1172                         LIBIPW_BASIC_RATE_MASK)
1173                         network->flags &=
1174                             ~NETWORK_HAS_CCK;
1175                 }
1176             }
1177 
1178             LIBIPW_DEBUG_MGMT("WLAN_EID_EXT_SUPP_RATES: '%s' (%d)\n",
1179                          rates_str, network->rates_ex_len);
1180             break;
1181 
1182         case WLAN_EID_DS_PARAMS:
1183             LIBIPW_DEBUG_MGMT("WLAN_EID_DS_PARAMS: %d\n",
1184                          info_element->data[0]);
1185             network->channel = info_element->data[0];
1186             break;
1187 
1188         case WLAN_EID_FH_PARAMS:
1189             LIBIPW_DEBUG_MGMT("WLAN_EID_FH_PARAMS: ignored\n");
1190             break;
1191 
1192         case WLAN_EID_CF_PARAMS:
1193             LIBIPW_DEBUG_MGMT("WLAN_EID_CF_PARAMS: ignored\n");
1194             break;
1195 
1196         case WLAN_EID_TIM:
1197             network->tim.tim_count = info_element->data[0];
1198             network->tim.tim_period = info_element->data[1];
1199             LIBIPW_DEBUG_MGMT("WLAN_EID_TIM: partially ignored\n");
1200             break;
1201 
1202         case WLAN_EID_ERP_INFO:
1203             network->erp_value = info_element->data[0];
1204             network->flags |= NETWORK_HAS_ERP_VALUE;
1205             LIBIPW_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1206                          network->erp_value);
1207             break;
1208 
1209         case WLAN_EID_IBSS_PARAMS:
1210             network->atim_window = info_element->data[0];
1211             LIBIPW_DEBUG_MGMT("WLAN_EID_IBSS_PARAMS: %d\n",
1212                          network->atim_window);
1213             break;
1214 
1215         case WLAN_EID_CHALLENGE:
1216             LIBIPW_DEBUG_MGMT("WLAN_EID_CHALLENGE: ignored\n");
1217             break;
1218 
1219         case WLAN_EID_VENDOR_SPECIFIC:
1220             LIBIPW_DEBUG_MGMT("WLAN_EID_VENDOR_SPECIFIC: %d bytes\n",
1221                          info_element->len);
1222             if (!libipw_parse_qos_info_param_IE(info_element,
1223                                    network))
1224                 break;
1225 
1226             if (info_element->len >= 4 &&
1227                 info_element->data[0] == 0x00 &&
1228                 info_element->data[1] == 0x50 &&
1229                 info_element->data[2] == 0xf2 &&
1230                 info_element->data[3] == 0x01) {
1231                 network->wpa_ie_len = min(info_element->len + 2,
1232                               MAX_WPA_IE_LEN);
1233                 memcpy(network->wpa_ie, info_element,
1234                        network->wpa_ie_len);
1235             }
1236             break;
1237 
1238         case WLAN_EID_RSN:
1239             LIBIPW_DEBUG_MGMT("WLAN_EID_RSN: %d bytes\n",
1240                          info_element->len);
1241             network->rsn_ie_len = min(info_element->len + 2,
1242                           MAX_WPA_IE_LEN);
1243             memcpy(network->rsn_ie, info_element,
1244                    network->rsn_ie_len);
1245             break;
1246 
1247         case WLAN_EID_QOS_PARAMETER:
1248             printk(KERN_ERR
1249                    "QoS Error need to parse QOS_PARAMETER IE\n");
1250             break;
1251             /* 802.11h */
1252         case WLAN_EID_PWR_CONSTRAINT:
1253             network->power_constraint = info_element->data[0];
1254             network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
1255             break;
1256 
1257         case WLAN_EID_CHANNEL_SWITCH:
1258             network->power_constraint = info_element->data[0];
1259             network->flags |= NETWORK_HAS_CSA;
1260             break;
1261 
1262         case WLAN_EID_QUIET:
1263             network->quiet.count = info_element->data[0];
1264             network->quiet.period = info_element->data[1];
1265             network->quiet.duration = info_element->data[2];
1266             network->quiet.offset = info_element->data[3];
1267             network->flags |= NETWORK_HAS_QUIET;
1268             break;
1269 
1270         case WLAN_EID_IBSS_DFS:
1271             network->flags |= NETWORK_HAS_IBSS_DFS;
1272             break;
1273 
1274         case WLAN_EID_TPC_REPORT:
1275             network->tpc_report.transmit_power =
1276                 info_element->data[0];
1277             network->tpc_report.link_margin = info_element->data[1];
1278             network->flags |= NETWORK_HAS_TPC_REPORT;
1279             break;
1280 
1281         default:
1282             LIBIPW_DEBUG_MGMT
1283                 ("Unsupported info element: %s (%d)\n",
1284                  get_info_element_string(info_element->id),
1285                  info_element->id);
1286             break;
1287         }
1288 
1289         length -= sizeof(*info_element) + info_element->len;
1290         info_element =
1291             (struct libipw_info_element *)&info_element->
1292             data[info_element->len];
1293     }
1294 
1295     return 0;
1296 }
1297 
1298 static int libipw_handle_assoc_resp(struct libipw_device *ieee, struct libipw_assoc_response
1299                        *frame, struct libipw_rx_stats *stats)
1300 {
1301     struct libipw_network network_resp = { };
1302     struct libipw_network *network = &network_resp;
1303     struct net_device *dev = ieee->dev;
1304 
1305     network->flags = 0;
1306     network->qos_data.active = 0;
1307     network->qos_data.supported = 0;
1308     network->qos_data.param_count = 0;
1309     network->qos_data.old_param_count = 0;
1310 
1311     //network->atim_window = le16_to_cpu(frame->aid) & (0x3FFF);
1312     network->atim_window = le16_to_cpu(frame->aid);
1313     network->listen_interval = le16_to_cpu(frame->status);
1314     memcpy(network->bssid, frame->header.addr3, ETH_ALEN);
1315     network->capability = le16_to_cpu(frame->capability);
1316     network->last_scanned = jiffies;
1317     network->rates_len = network->rates_ex_len = 0;
1318     network->last_associate = 0;
1319     network->ssid_len = 0;
1320     network->erp_value =
1321         (network->capability & WLAN_CAPABILITY_IBSS) ? 0x3 : 0x0;
1322 
1323     if (stats->freq == LIBIPW_52GHZ_BAND) {
1324         /* for A band (No DS info) */
1325         network->channel = stats->received_channel;
1326     } else
1327         network->flags |= NETWORK_HAS_CCK;
1328 
1329     network->wpa_ie_len = 0;
1330     network->rsn_ie_len = 0;
1331 
1332     if (libipw_parse_info_param
1333         (frame->info_element, stats->len - sizeof(*frame), network))
1334         return 1;
1335 
1336     network->mode = 0;
1337     if (stats->freq == LIBIPW_52GHZ_BAND)
1338         network->mode = IEEE_A;
1339     else {
1340         if (network->flags & NETWORK_HAS_OFDM)
1341             network->mode |= IEEE_G;
1342         if (network->flags & NETWORK_HAS_CCK)
1343             network->mode |= IEEE_B;
1344     }
1345 
1346     memcpy(&network->stats, stats, sizeof(network->stats));
1347 
1348     if (ieee->handle_assoc_response != NULL)
1349         ieee->handle_assoc_response(dev, frame, network);
1350 
1351     return 0;
1352 }
1353 
1354 /***************************************************/
1355 
1356 static int libipw_network_init(struct libipw_device *ieee, struct libipw_probe_response
1357                      *beacon,
1358                      struct libipw_network *network,
1359                      struct libipw_rx_stats *stats)
1360 {
1361     network->qos_data.active = 0;
1362     network->qos_data.supported = 0;
1363     network->qos_data.param_count = 0;
1364     network->qos_data.old_param_count = 0;
1365 
1366     /* Pull out fixed field data */
1367     memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
1368     network->capability = le16_to_cpu(beacon->capability);
1369     network->last_scanned = jiffies;
1370     network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
1371     network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
1372     network->beacon_interval = le16_to_cpu(beacon->beacon_interval);
1373     /* Where to pull this? beacon->listen_interval; */
1374     network->listen_interval = 0x0A;
1375     network->rates_len = network->rates_ex_len = 0;
1376     network->last_associate = 0;
1377     network->ssid_len = 0;
1378     network->flags = 0;
1379     network->atim_window = 0;
1380     network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
1381         0x3 : 0x0;
1382 
1383     if (stats->freq == LIBIPW_52GHZ_BAND) {
1384         /* for A band (No DS info) */
1385         network->channel = stats->received_channel;
1386     } else
1387         network->flags |= NETWORK_HAS_CCK;
1388 
1389     network->wpa_ie_len = 0;
1390     network->rsn_ie_len = 0;
1391 
1392     if (libipw_parse_info_param
1393         (beacon->info_element, stats->len - sizeof(*beacon), network))
1394         return 1;
1395 
1396     network->mode = 0;
1397     if (stats->freq == LIBIPW_52GHZ_BAND)
1398         network->mode = IEEE_A;
1399     else {
1400         if (network->flags & NETWORK_HAS_OFDM)
1401             network->mode |= IEEE_G;
1402         if (network->flags & NETWORK_HAS_CCK)
1403             network->mode |= IEEE_B;
1404     }
1405 
1406     if (network->mode == 0) {
1407         LIBIPW_DEBUG_SCAN("Filtered out '%*pE (%pM)' network.\n",
1408                   network->ssid_len, network->ssid,
1409                   network->bssid);
1410         return 1;
1411     }
1412 
1413     memcpy(&network->stats, stats, sizeof(network->stats));
1414 
1415     return 0;
1416 }
1417 
1418 static inline int is_same_network(struct libipw_network *src,
1419                   struct libipw_network *dst)
1420 {
1421     /* A network is only a duplicate if the channel, BSSID, and ESSID
1422      * all match.  We treat all <hidden> with the same BSSID and channel
1423      * as one network */
1424     return ((src->ssid_len == dst->ssid_len) &&
1425         (src->channel == dst->channel) &&
1426         ether_addr_equal_64bits(src->bssid, dst->bssid) &&
1427         !memcmp(src->ssid, dst->ssid, src->ssid_len));
1428 }
1429 
1430 static void update_network(struct libipw_network *dst,
1431                   struct libipw_network *src)
1432 {
1433     int qos_active;
1434     u8 old_param;
1435 
1436     /* We only update the statistics if they were created by receiving
1437      * the network information on the actual channel the network is on.
1438      *
1439      * This keeps beacons received on neighbor channels from bringing
1440      * down the signal level of an AP. */
1441     if (dst->channel == src->stats.received_channel)
1442         memcpy(&dst->stats, &src->stats,
1443                sizeof(struct libipw_rx_stats));
1444     else
1445         LIBIPW_DEBUG_SCAN("Network %pM info received "
1446             "off channel (%d vs. %d)\n", src->bssid,
1447             dst->channel, src->stats.received_channel);
1448 
1449     dst->capability = src->capability;
1450     memcpy(dst->rates, src->rates, src->rates_len);
1451     dst->rates_len = src->rates_len;
1452     memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
1453     dst->rates_ex_len = src->rates_ex_len;
1454 
1455     dst->mode = src->mode;
1456     dst->flags = src->flags;
1457     dst->time_stamp[0] = src->time_stamp[0];
1458     dst->time_stamp[1] = src->time_stamp[1];
1459 
1460     dst->beacon_interval = src->beacon_interval;
1461     dst->listen_interval = src->listen_interval;
1462     dst->atim_window = src->atim_window;
1463     dst->erp_value = src->erp_value;
1464     dst->tim = src->tim;
1465 
1466     memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
1467     dst->wpa_ie_len = src->wpa_ie_len;
1468     memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
1469     dst->rsn_ie_len = src->rsn_ie_len;
1470 
1471     dst->last_scanned = jiffies;
1472     qos_active = src->qos_data.active;
1473     old_param = dst->qos_data.old_param_count;
1474     if (dst->flags & NETWORK_HAS_QOS_MASK)
1475         memcpy(&dst->qos_data, &src->qos_data,
1476                sizeof(struct libipw_qos_data));
1477     else {
1478         dst->qos_data.supported = src->qos_data.supported;
1479         dst->qos_data.param_count = src->qos_data.param_count;
1480     }
1481 
1482     if (dst->qos_data.supported == 1) {
1483         if (dst->ssid_len)
1484             LIBIPW_DEBUG_QOS
1485                 ("QoS the network %s is QoS supported\n",
1486                  dst->ssid);
1487         else
1488             LIBIPW_DEBUG_QOS
1489                 ("QoS the network is QoS supported\n");
1490     }
1491     dst->qos_data.active = qos_active;
1492     dst->qos_data.old_param_count = old_param;
1493 
1494     /* dst->last_associate is not overwritten */
1495 }
1496 
1497 static inline int is_beacon(__le16 fc)
1498 {
1499     return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
1500 }
1501 
1502 static void libipw_process_probe_response(struct libipw_device
1503                             *ieee, struct
1504                             libipw_probe_response
1505                             *beacon, struct libipw_rx_stats
1506                             *stats)
1507 {
1508     struct net_device *dev = ieee->dev;
1509     struct libipw_network network = { };
1510     struct libipw_network *target;
1511     struct libipw_network *oldest = NULL;
1512 #ifdef CONFIG_LIBIPW_DEBUG
1513     struct libipw_info_element *info_element = beacon->info_element;
1514 #endif
1515     unsigned long flags;
1516 
1517     LIBIPW_DEBUG_SCAN("'%*pE' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
1518              info_element->len, info_element->data,
1519              beacon->header.addr3,
1520              (beacon->capability & cpu_to_le16(1 << 0xf)) ? '1' : '0',
1521              (beacon->capability & cpu_to_le16(1 << 0xe)) ? '1' : '0',
1522              (beacon->capability & cpu_to_le16(1 << 0xd)) ? '1' : '0',
1523              (beacon->capability & cpu_to_le16(1 << 0xc)) ? '1' : '0',
1524              (beacon->capability & cpu_to_le16(1 << 0xb)) ? '1' : '0',
1525              (beacon->capability & cpu_to_le16(1 << 0xa)) ? '1' : '0',
1526              (beacon->capability & cpu_to_le16(1 << 0x9)) ? '1' : '0',
1527              (beacon->capability & cpu_to_le16(1 << 0x8)) ? '1' : '0',
1528              (beacon->capability & cpu_to_le16(1 << 0x7)) ? '1' : '0',
1529              (beacon->capability & cpu_to_le16(1 << 0x6)) ? '1' : '0',
1530              (beacon->capability & cpu_to_le16(1 << 0x5)) ? '1' : '0',
1531              (beacon->capability & cpu_to_le16(1 << 0x4)) ? '1' : '0',
1532              (beacon->capability & cpu_to_le16(1 << 0x3)) ? '1' : '0',
1533              (beacon->capability & cpu_to_le16(1 << 0x2)) ? '1' : '0',
1534              (beacon->capability & cpu_to_le16(1 << 0x1)) ? '1' : '0',
1535              (beacon->capability & cpu_to_le16(1 << 0x0)) ? '1' : '0');
1536 
1537     if (libipw_network_init(ieee, beacon, &network, stats)) {
1538         LIBIPW_DEBUG_SCAN("Dropped '%*pE' (%pM) via %s.\n",
1539                   info_element->len, info_element->data,
1540                   beacon->header.addr3,
1541                   is_beacon(beacon->header.frame_ctl) ?
1542                   "BEACON" : "PROBE RESPONSE");
1543         return;
1544     }
1545 
1546     /* The network parsed correctly -- so now we scan our known networks
1547      * to see if we can find it in our list.
1548      *
1549      * NOTE:  This search is definitely not optimized.  Once its doing
1550      *        the "right thing" we'll optimize it for efficiency if
1551      *        necessary */
1552 
1553     /* Search for this entry in the list and update it if it is
1554      * already there. */
1555 
1556     spin_lock_irqsave(&ieee->lock, flags);
1557 
1558     list_for_each_entry(target, &ieee->network_list, list) {
1559         if (is_same_network(target, &network))
1560             break;
1561 
1562         if ((oldest == NULL) ||
1563             time_before(target->last_scanned, oldest->last_scanned))
1564             oldest = target;
1565     }
1566 
1567     /* If we didn't find a match, then get a new network slot to initialize
1568      * with this beacon's information */
1569     if (&target->list == &ieee->network_list) {
1570         if (list_empty(&ieee->network_free_list)) {
1571             /* If there are no more slots, expire the oldest */
1572             list_del(&oldest->list);
1573             target = oldest;
1574             LIBIPW_DEBUG_SCAN("Expired '%*pE' (%pM) from network list.\n",
1575                       target->ssid_len, target->ssid,
1576                       target->bssid);
1577         } else {
1578             /* Otherwise just pull from the free list */
1579             target = list_entry(ieee->network_free_list.next,
1580                         struct libipw_network, list);
1581             list_del(ieee->network_free_list.next);
1582         }
1583 
1584 #ifdef CONFIG_LIBIPW_DEBUG
1585         LIBIPW_DEBUG_SCAN("Adding '%*pE' (%pM) via %s.\n",
1586                   network.ssid_len, network.ssid,
1587                   network.bssid,
1588                   is_beacon(beacon->header.frame_ctl) ?
1589                   "BEACON" : "PROBE RESPONSE");
1590 #endif
1591         memcpy(target, &network, sizeof(*target));
1592         list_add_tail(&target->list, &ieee->network_list);
1593     } else {
1594         LIBIPW_DEBUG_SCAN("Updating '%*pE' (%pM) via %s.\n",
1595                   target->ssid_len, target->ssid,
1596                   target->bssid,
1597                   is_beacon(beacon->header.frame_ctl) ?
1598                   "BEACON" : "PROBE RESPONSE");
1599         update_network(target, &network);
1600     }
1601 
1602     spin_unlock_irqrestore(&ieee->lock, flags);
1603 
1604     if (is_beacon(beacon->header.frame_ctl)) {
1605         if (ieee->handle_beacon != NULL)
1606             ieee->handle_beacon(dev, beacon, target);
1607     } else {
1608         if (ieee->handle_probe_response != NULL)
1609             ieee->handle_probe_response(dev, beacon, target);
1610     }
1611 }
1612 
1613 void libipw_rx_mgt(struct libipw_device *ieee,
1614               struct libipw_hdr_4addr *header,
1615               struct libipw_rx_stats *stats)
1616 {
1617     switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
1618     case IEEE80211_STYPE_ASSOC_RESP:
1619         LIBIPW_DEBUG_MGMT("received ASSOCIATION RESPONSE (%d)\n",
1620                      WLAN_FC_GET_STYPE(le16_to_cpu
1621                                (header->frame_ctl)));
1622         libipw_handle_assoc_resp(ieee,
1623                         (struct libipw_assoc_response *)
1624                         header, stats);
1625         break;
1626 
1627     case IEEE80211_STYPE_REASSOC_RESP:
1628         LIBIPW_DEBUG_MGMT("received REASSOCIATION RESPONSE (%d)\n",
1629                      WLAN_FC_GET_STYPE(le16_to_cpu
1630                                (header->frame_ctl)));
1631         break;
1632 
1633     case IEEE80211_STYPE_PROBE_REQ:
1634         LIBIPW_DEBUG_MGMT("received auth (%d)\n",
1635                      WLAN_FC_GET_STYPE(le16_to_cpu
1636                                (header->frame_ctl)));
1637 
1638         if (ieee->handle_probe_request != NULL)
1639             ieee->handle_probe_request(ieee->dev,
1640                            (struct
1641                             libipw_probe_request *)
1642                            header, stats);
1643         break;
1644 
1645     case IEEE80211_STYPE_PROBE_RESP:
1646         LIBIPW_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
1647                      WLAN_FC_GET_STYPE(le16_to_cpu
1648                                (header->frame_ctl)));
1649         LIBIPW_DEBUG_SCAN("Probe response\n");
1650         libipw_process_probe_response(ieee,
1651                          (struct
1652                           libipw_probe_response *)
1653                          header, stats);
1654         break;
1655 
1656     case IEEE80211_STYPE_BEACON:
1657         LIBIPW_DEBUG_MGMT("received BEACON (%d)\n",
1658                      WLAN_FC_GET_STYPE(le16_to_cpu
1659                                (header->frame_ctl)));
1660         LIBIPW_DEBUG_SCAN("Beacon\n");
1661         libipw_process_probe_response(ieee,
1662                          (struct
1663                           libipw_probe_response *)
1664                          header, stats);
1665         break;
1666     case IEEE80211_STYPE_AUTH:
1667 
1668         LIBIPW_DEBUG_MGMT("received auth (%d)\n",
1669                      WLAN_FC_GET_STYPE(le16_to_cpu
1670                                (header->frame_ctl)));
1671 
1672         if (ieee->handle_auth != NULL)
1673             ieee->handle_auth(ieee->dev,
1674                       (struct libipw_auth *)header);
1675         break;
1676 
1677     case IEEE80211_STYPE_DISASSOC:
1678         if (ieee->handle_disassoc != NULL)
1679             ieee->handle_disassoc(ieee->dev,
1680                           (struct libipw_disassoc *)
1681                           header);
1682         break;
1683 
1684     case IEEE80211_STYPE_ACTION:
1685         LIBIPW_DEBUG_MGMT("ACTION\n");
1686         if (ieee->handle_action)
1687             ieee->handle_action(ieee->dev,
1688                         (struct libipw_action *)
1689                         header, stats);
1690         break;
1691 
1692     case IEEE80211_STYPE_REASSOC_REQ:
1693         LIBIPW_DEBUG_MGMT("received reassoc (%d)\n",
1694                      WLAN_FC_GET_STYPE(le16_to_cpu
1695                                (header->frame_ctl)));
1696 
1697         LIBIPW_DEBUG_MGMT("%s: LIBIPW_REASSOC_REQ received\n",
1698                      ieee->dev->name);
1699         if (ieee->handle_reassoc_request != NULL)
1700             ieee->handle_reassoc_request(ieee->dev,
1701                             (struct libipw_reassoc_request *)
1702                              header);
1703         break;
1704 
1705     case IEEE80211_STYPE_ASSOC_REQ:
1706         LIBIPW_DEBUG_MGMT("received assoc (%d)\n",
1707                      WLAN_FC_GET_STYPE(le16_to_cpu
1708                                (header->frame_ctl)));
1709 
1710         LIBIPW_DEBUG_MGMT("%s: LIBIPW_ASSOC_REQ received\n",
1711                      ieee->dev->name);
1712         if (ieee->handle_assoc_request != NULL)
1713             ieee->handle_assoc_request(ieee->dev);
1714         break;
1715 
1716     case IEEE80211_STYPE_DEAUTH:
1717         LIBIPW_DEBUG_MGMT("DEAUTH\n");
1718         if (ieee->handle_deauth != NULL)
1719             ieee->handle_deauth(ieee->dev,
1720                         (struct libipw_deauth *)
1721                         header);
1722         break;
1723     default:
1724         LIBIPW_DEBUG_MGMT("received UNKNOWN (%d)\n",
1725                      WLAN_FC_GET_STYPE(le16_to_cpu
1726                                (header->frame_ctl)));
1727         LIBIPW_DEBUG_MGMT("%s: Unknown management packet: %d\n",
1728                      ieee->dev->name,
1729                      WLAN_FC_GET_STYPE(le16_to_cpu
1730                                (header->frame_ctl)));
1731         break;
1732     }
1733 }
1734 
1735 EXPORT_SYMBOL_GPL(libipw_rx_any);
1736 EXPORT_SYMBOL(libipw_rx_mgt);
1737 EXPORT_SYMBOL(libipw_rx);