2 * Original code based Host AP (software wireless LAN access point) driver
3 * for Intersil Prism2/2.5/3 - hostap.o module, common routines
5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8 * Copyright (c) 2004, Intel Corporation
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
14 ******************************************************************************
16 Few modifications for Realtek's Wi-Fi drivers by
17 Andrea Merello <andreamrl@tiscali.it>
19 A special thanks goes to Realtek for their support !
21 ******************************************************************************/
24 #include <linux/compiler.h>
25 //#include <linux/config.h>
26 #include <linux/errno.h>
27 #include <linux/if_arp.h>
28 #include <linux/in6.h>
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/netdevice.h>
34 #include <linux/pci.h>
35 #include <linux/proc_fs.h>
36 #include <linux/skbuff.h>
37 #include <linux/slab.h>
38 #include <linux/tcp.h>
39 #include <linux/types.h>
40 #include <linux/version.h>
41 #include <linux/wireless.h>
42 #include <linux/etherdevice.h>
43 #include <asm/uaccess.h>
44 #include <linux/ctype.h>
46 #include "ieee80211.h"
50 static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
52 struct ieee80211_rx_stats *rx_stats)
54 struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data;
55 u16 fc = le16_to_cpu(hdr->frame_ctl);
58 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
59 skb_reset_mac_header(skb);
61 skb->mac.raw = skb->data;
64 skb_pull(skb, ieee80211_get_hdrlen(fc));
65 skb->pkt_type = PACKET_OTHERHOST;
66 skb->protocol = __constant_htons(ETH_P_80211_RAW);
67 memset(skb->cb, 0, sizeof(skb->cb));
72 /* Called only as a tasklet (software IRQ) */
73 static struct ieee80211_frag_entry *
74 ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
75 unsigned int frag, u8 tid,u8 *src, u8 *dst)
77 struct ieee80211_frag_entry *entry;
80 for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) {
81 entry = &ieee->frag_cache[tid][i];
82 if (entry->skb != NULL &&
83 time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
85 "expiring fragment cache entry "
86 "seq=%u last_frag=%u\n",
87 entry->seq, entry->last_frag);
88 dev_kfree_skb_any(entry->skb);
92 if (entry->skb != NULL && entry->seq == seq &&
93 (entry->last_frag + 1 == frag || frag == -1) &&
94 memcmp(entry->src_addr, src, ETH_ALEN) == 0 &&
95 memcmp(entry->dst_addr, dst, ETH_ALEN) == 0)
102 /* Called only as a tasklet (software IRQ) */
103 static struct sk_buff *
104 ieee80211_frag_cache_get(struct ieee80211_device *ieee,
105 struct ieee80211_hdr_4addr *hdr)
107 struct sk_buff *skb = NULL;
108 u16 fc = le16_to_cpu(hdr->frame_ctl);
109 u16 sc = le16_to_cpu(hdr->seq_ctl);
110 unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
111 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
112 struct ieee80211_frag_entry *entry;
113 struct ieee80211_hdr_3addrqos *hdr_3addrqos;
114 struct ieee80211_hdr_4addrqos *hdr_4addrqos;
117 if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
118 hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
119 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
122 } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
123 hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
124 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
132 /* Reserve enough space to fit maximum frame length */
133 skb = dev_alloc_skb(ieee->dev->mtu +
134 sizeof(struct ieee80211_hdr_4addr) +
139 (IEEE80211_QOS_HAS_SEQ(fc)?2:0) /* QOS Control */);
143 entry = &ieee->frag_cache[tid][ieee->frag_next_idx[tid]];
144 ieee->frag_next_idx[tid]++;
145 if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN)
146 ieee->frag_next_idx[tid] = 0;
148 if (entry->skb != NULL)
149 dev_kfree_skb_any(entry->skb);
151 entry->first_frag_time = jiffies;
153 entry->last_frag = frag;
155 memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
156 memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
158 /* received a fragment of a frame for which the head fragment
159 * should have already been received */
160 entry = ieee80211_frag_cache_find(ieee, seq, frag, tid,hdr->addr2,
163 entry->last_frag = frag;
172 /* Called only as a tasklet (software IRQ) */
173 static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
174 struct ieee80211_hdr_4addr *hdr)
176 u16 fc = le16_to_cpu(hdr->frame_ctl);
177 u16 sc = le16_to_cpu(hdr->seq_ctl);
178 unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
179 struct ieee80211_frag_entry *entry;
180 struct ieee80211_hdr_3addrqos *hdr_3addrqos;
181 struct ieee80211_hdr_4addrqos *hdr_4addrqos;
184 if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
185 hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
186 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
189 } else if (IEEE80211_QOS_HAS_SEQ(fc)) {
190 hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
191 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
198 entry = ieee80211_frag_cache_find(ieee, seq, -1, tid,hdr->addr2,
202 IEEE80211_DEBUG_FRAG(
203 "could not invalidate fragment cache "
204 "entry (seq=%u)\n", seq);
214 /* ieee80211_rx_frame_mgtmt
216 * Responsible for handling management control frames
218 * Called by ieee80211_rx */
220 ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
221 struct ieee80211_rx_stats *rx_stats, u16 type,
224 /* On the struct stats definition there is written that
225 * this is not mandatory.... but seems that the probe
226 * response parser uses it
228 struct ieee80211_hdr_3addr * hdr = (struct ieee80211_hdr_3addr *)skb->data;
230 rx_stats->len = skb->len;
231 ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
232 //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
233 if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))//use ADDR1 to perform address matching for Management frames
235 dev_kfree_skb_any(skb);
239 ieee80211_rx_frame_softmac(ieee, skb, rx_stats, type, stype);
241 dev_kfree_skb_any(skb);
246 if (ieee->iw_mode == IW_MODE_MASTER) {
247 printk(KERN_DEBUG "%s: Master mode not yet suppported.\n",
251 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
255 if (ieee->hostapd && type == IEEE80211_TYPE_MGMT) {
256 if (stype == WLAN_FC_STYPE_BEACON &&
257 ieee->iw_mode == IW_MODE_MASTER) {
258 struct sk_buff *skb2;
259 /* Process beacon frames also in kernel driver to
260 * update STA(AP) table statistics */
261 skb2 = skb_clone(skb, GFP_ATOMIC);
263 hostap_rx(skb2->dev, skb2, rx_stats);
266 /* send management frames to the user space daemon for
268 ieee->apdevstats.rx_packets++;
269 ieee->apdevstats.rx_bytes += skb->len;
270 prism2_rx_80211(ieee->apdev, skb, rx_stats, PRISM2_RX_MGMT);
274 if (ieee->iw_mode == IW_MODE_MASTER) {
275 if (type != WLAN_FC_TYPE_MGMT && type != WLAN_FC_TYPE_CTRL) {
276 printk(KERN_DEBUG "%s: unknown management frame "
277 "(type=0x%02x, stype=0x%02x) dropped\n",
278 skb->dev->name, type, stype);
282 hostap_rx(skb->dev, skb, rx_stats);
286 printk(KERN_DEBUG "%s: hostap_rx_frame_mgmt: management frame "
287 "received in non-Host AP mode\n", skb->dev->name);
294 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
295 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
296 static unsigned char rfc1042_header[] =
297 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
298 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
299 static unsigned char bridge_tunnel_header[] =
300 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
301 /* No encapsulation header if EtherType < 0x600 (=length) */
303 /* Called by ieee80211_rx_frame_decrypt */
304 static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
305 struct sk_buff *skb, size_t hdrlen)
307 struct net_device *dev = ieee->dev;
309 struct ieee80211_hdr_4addr *hdr;
315 hdr = (struct ieee80211_hdr_4addr *) skb->data;
316 fc = le16_to_cpu(hdr->frame_ctl);
318 /* check that the frame is unicast frame to us */
319 if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
320 IEEE80211_FCTL_TODS &&
321 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0 &&
322 memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0) {
323 /* ToDS frame with own addr BSSID and DA */
324 } else if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
325 IEEE80211_FCTL_FROMDS &&
326 memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) == 0) {
327 /* FromDS frame with own addr as DA */
331 if (skb->len < 24 + 8)
334 /* check for port access entity Ethernet type */
335 // pos = skb->data + 24;
336 pos = skb->data + hdrlen;
337 ethertype = (pos[6] << 8) | pos[7];
338 if (ethertype == ETH_P_PAE)
344 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
346 ieee80211_rx_frame_decrypt(struct ieee80211_device* ieee, struct sk_buff *skb,
347 struct ieee80211_crypt_data *crypt)
349 struct ieee80211_hdr_4addr *hdr;
352 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
355 if (ieee->hwsec_active)
357 cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
358 tcb_desc->bHwSec = 1;
361 hdr = (struct ieee80211_hdr_4addr *) skb->data;
362 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
364 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
365 if (ieee->tkip_countermeasures &&
366 strcmp(crypt->ops->name, "TKIP") == 0) {
367 if (net_ratelimit()) {
368 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
369 "received packet from " MAC_FMT "\n",
370 ieee->dev->name, MAC_ARG(hdr->addr2));
376 atomic_inc(&crypt->refcnt);
377 res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
378 atomic_dec(&crypt->refcnt);
380 IEEE80211_DEBUG_DROP(
381 "decryption failed (SA=" MAC_FMT
382 ") res=%d\n", MAC_ARG(hdr->addr2), res);
384 IEEE80211_DEBUG_DROP("Decryption failed ICV "
385 "mismatch (key %d)\n",
386 skb->data[hdrlen + 3] >> 6);
387 ieee->ieee_stats.rx_discards_undecryptable++;
395 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
397 ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device* ieee, struct sk_buff *skb,
398 int keyidx, struct ieee80211_crypt_data *crypt)
400 struct ieee80211_hdr_4addr *hdr;
403 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
405 if (ieee->hwsec_active)
407 cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
408 tcb_desc->bHwSec = 1;
411 hdr = (struct ieee80211_hdr_4addr *) skb->data;
412 hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
414 atomic_inc(&crypt->refcnt);
415 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
416 atomic_dec(&crypt->refcnt);
418 printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed"
419 " (SA=" MAC_FMT " keyidx=%d)\n",
420 ieee->dev->name, MAC_ARG(hdr->addr2), keyidx);
428 /* this function is stolen from ipw2200 driver*/
429 #define IEEE_PACKET_RETRY_TIME (5*HZ)
430 static int is_duplicate_packet(struct ieee80211_device *ieee,
431 struct ieee80211_hdr_4addr *header)
433 u16 fc = le16_to_cpu(header->frame_ctl);
434 u16 sc = le16_to_cpu(header->seq_ctl);
435 u16 seq = WLAN_GET_SEQ_SEQ(sc);
436 u16 frag = WLAN_GET_SEQ_FRAG(sc);
437 u16 *last_seq, *last_frag;
438 unsigned long *last_time;
439 struct ieee80211_hdr_3addrqos *hdr_3addrqos;
440 struct ieee80211_hdr_4addrqos *hdr_4addrqos;
445 if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
446 hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header;
447 tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
450 } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS
451 hdr_3addrqos = (struct ieee80211_hdr_3addrqos*)header;
452 tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
459 switch (ieee->iw_mode) {
463 struct ieee_ibss_seq *entry = NULL;
464 u8 *mac = header->addr2;
465 int index = mac[5] % IEEE_IBSS_MAC_HASH_SIZE;
466 //for (pos = (head)->next; pos != (head); pos = pos->next)
467 //__list_for_each(p, &ieee->ibss_mac_hash[index]) {
468 list_for_each(p, &ieee->ibss_mac_hash[index]) {
469 entry = list_entry(p, struct ieee_ibss_seq, list);
470 if (!memcmp(entry->mac, mac, ETH_ALEN))
473 // if (memcmp(entry->mac, mac, ETH_ALEN)){
474 if (p == &ieee->ibss_mac_hash[index]) {
475 entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
477 printk(KERN_WARNING "Cannot malloc new mac entry\n");
480 memcpy(entry->mac, mac, ETH_ALEN);
481 entry->seq_num[tid] = seq;
482 entry->frag_num[tid] = frag;
483 entry->packet_time[tid] = jiffies;
484 list_add(&entry->list, &ieee->ibss_mac_hash[index]);
487 last_seq = &entry->seq_num[tid];
488 last_frag = &entry->frag_num[tid];
489 last_time = &entry->packet_time[tid];
494 last_seq = &ieee->last_rxseq_num[tid];
495 last_frag = &ieee->last_rxfrag_num[tid];
496 last_time = &ieee->last_packet_time[tid];
504 // printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
506 if ((*last_seq == seq) &&
507 time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) {
508 if (*last_frag == frag){
509 //printk(KERN_WARNING "[1] go drop!\n");
513 if (*last_frag + 1 != frag)
514 /* out-of-order fragment */
515 //printk(KERN_WARNING "[2] go drop!\n");
521 *last_time = jiffies;
525 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
533 PRX_REORDER_ENTRY pReorderEntry
536 struct list_head *pList = &pTS->RxPendingPktList;
538 while(pList->next != &pTS->RxPendingPktList)
540 if( SN_LESS(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
544 else if( SN_EQUAL(pReorderEntry->SeqNum, ((PRX_REORDER_ENTRY)list_entry(pList->next,RX_REORDER_ENTRY,List))->SeqNum) )
554 pReorderEntry->List.next = pList->next;
555 pReorderEntry->List.next->prev = &pReorderEntry->List;
556 pReorderEntry->List.prev = pList;
557 pList->next = &pReorderEntry->List;
562 void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb** prxbIndicateArray,u8 index)
567 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index);
568 for(j = 0; j<index; j++)
570 //added by amy for reorder
571 struct ieee80211_rxb* prxb = prxbIndicateArray[j];
572 for(i = 0; i<prxb->nr_subframes; i++) {
573 struct sk_buff *sub_skb = prxb->subframes[i];
575 /* convert hdr + possible LLC headers into Ethernet header */
576 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
577 if (sub_skb->len >= 8 &&
578 ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
579 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
580 memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
581 /* remove RFC1042 or Bridge-Tunnel encapsulation and
582 * replace EtherType */
583 skb_pull(sub_skb, SNAP_SIZE);
584 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
585 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
588 /* Leave Ethernet header part of hdr and full payload */
589 len = htons(sub_skb->len);
590 memcpy(skb_push(sub_skb, 2), &len, 2);
591 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->src, ETH_ALEN);
592 memcpy(skb_push(sub_skb, ETH_ALEN), prxb->dst, ETH_ALEN);
594 //stats->rx_packets++;
595 //stats->rx_bytes += sub_skb->len;
597 /* Indicat the packets to upper layer */
599 //printk("0skb_len(%d)\n", skb->len);
600 sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
601 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
602 sub_skb->dev = ieee->dev;
603 sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
604 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
605 ieee->last_rx_ps_time = jiffies;
606 //printk("1skb_len(%d)\n", skb->len);
616 void RxReorderIndicatePacket( struct ieee80211_device *ieee,
617 struct ieee80211_rxb* prxb,
621 PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
622 PRX_REORDER_ENTRY pReorderEntry = NULL;
623 struct ieee80211_rxb* prxbIndicateArray[REORDER_WIN_SIZE];
624 u8 WinSize = pHTInfo->RxReorderWinSize;
625 u16 WinEnd = (pTS->RxIndicateSeq + WinSize -1)%4096;
627 bool bMatchWinStart = false, bPktInBuf = false;
628 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__,SeqNum,pTS->RxIndicateSeq,WinSize);
630 if(!list_empty(&ieee->RxReorder_Unused_List))
631 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): ieee->RxReorder_Unused_List is nut NULL\n");
633 /* Rx Reorder initialize condition.*/
634 if(pTS->RxIndicateSeq == 0xffff) {
635 pTS->RxIndicateSeq = SeqNum;
638 /* Drop out the packet which SeqNum is smaller than WinStart */
639 if(SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
640 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
641 pTS->RxIndicateSeq, SeqNum);
642 pHTInfo->RxReorderDropCounter++;
645 for(i =0; i < prxb->nr_subframes; i++) {
646 dev_kfree_skb(prxb->subframes[i]);
655 * Sliding window manipulation. Conditions includes:
656 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
657 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
659 if(SN_EQUAL(SeqNum, pTS->RxIndicateSeq)) {
660 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
661 bMatchWinStart = true;
662 } else if(SN_LESS(WinEnd, SeqNum)) {
663 if(SeqNum >= (WinSize - 1)) {
664 pTS->RxIndicateSeq = SeqNum + 1 -WinSize;
666 pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum +1)) + 1;
668 IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
672 * Indication process.
673 * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
674 * with the SeqNum smaller than latest WinStart and buffer other packets.
676 /* For Rx Reorder condition:
677 * 1. All packets with SeqNum smaller than WinStart => Indicate
678 * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
681 /* Current packet is going to be indicated.*/
682 IEEE80211_DEBUG(IEEE80211_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
683 pTS->RxIndicateSeq, SeqNum);
684 prxbIndicateArray[0] = prxb;
685 // printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,SeqNum);
688 /* Current packet is going to be inserted into pending list.*/
689 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
690 if(!list_empty(&ieee->RxReorder_Unused_List)) {
691 pReorderEntry = (PRX_REORDER_ENTRY)list_entry(ieee->RxReorder_Unused_List.next,RX_REORDER_ENTRY,List);
692 list_del_init(&pReorderEntry->List);
694 /* Make a reorder entry and insert into a the packet list.*/
695 pReorderEntry->SeqNum = SeqNum;
696 pReorderEntry->prxb = prxb;
697 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
700 if(!AddReorderEntry(pTS, pReorderEntry)) {
701 IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
702 __FUNCTION__, pTS->RxIndicateSeq, SeqNum);
703 list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
706 for(i =0; i < prxb->nr_subframes; i++) {
707 dev_kfree_skb(prxb->subframes[i]);
713 IEEE80211_DEBUG(IEEE80211_DL_REORDER,
714 "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
720 * Packets are dropped if there is not enough reorder entries.
721 * This part shall be modified!! We can just indicate all the
722 * packets in buffer and get reorder entries.
724 IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
727 for(i =0; i < prxb->nr_subframes; i++) {
728 dev_kfree_skb(prxb->subframes[i]);
736 /* Check if there is any packet need indicate.*/
737 while(!list_empty(&pTS->RxPendingPktList)) {
738 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): start RREORDER indicate\n",__FUNCTION__);
740 pReorderEntry = (PRX_REORDER_ENTRY)list_entry(pTS->RxPendingPktList.prev,RX_REORDER_ENTRY,List);
741 if( SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
742 SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
744 /* This protect buffer from overflow. */
745 if(index >= REORDER_WIN_SIZE) {
746 IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!! \n");
751 list_del_init(&pReorderEntry->List);
753 if(SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
754 pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
756 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS->RxIndicateSeq, SeqNum);
757 prxbIndicateArray[index] = pReorderEntry->prxb;
758 // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
761 list_add_tail(&pReorderEntry->List,&ieee->RxReorder_Unused_List);
769 /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
771 // Cancel previous pending timer.
772 if (timer_pending(&pTS->RxPktPendingTimer))
773 del_timer_sync(&pTS->RxPktPendingTimer);
774 pTS->RxTimeoutIndicateSeq = 0xffff;
777 if(index>REORDER_WIN_SIZE){
778 IEEE80211_DEBUG(IEEE80211_DL_ERR, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
781 ieee80211_indicate_packets(ieee, prxbIndicateArray, index);
786 if(bPktInBuf && pTS->RxTimeoutIndicateSeq==0xffff) {
787 // Set new pending timer.
788 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): SET rx timeout timer\n", __FUNCTION__);
789 pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
791 if(timer_pending(&pTS->RxPktPendingTimer))
792 del_timer_sync(&pTS->RxPktPendingTimer);
793 pTS->RxPktPendingTimer.expires = jiffies + MSECS(pHTInfo->RxReorderPendingTime);
794 add_timer(&pTS->RxPktPendingTimer);
796 mod_timer(&pTS->RxPktPendingTimer, jiffies + MSECS(pHTInfo->RxReorderPendingTime));
802 u8 parse_subframe(struct sk_buff *skb,
803 struct ieee80211_rx_stats *rx_stats,
804 struct ieee80211_rxb *rxb,u8* src,u8* dst)
806 struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr* )skb->data;
807 u16 fc = le16_to_cpu(hdr->frame_ctl);
809 u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr);
811 bool bIsAggregateFrame = false;
812 u16 nSubframe_Length;
813 u8 nPadding_Length = 0;
816 struct sk_buff *sub_skb;
818 /* just for debug purpose */
819 SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl));
821 if((IEEE80211_QOS_HAS_SEQ(fc))&&\
822 (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) {
823 bIsAggregateFrame = true;
826 if(IEEE80211_QOS_HAS_SEQ(fc)) {
830 if(rx_stats->bContainHTC) {
831 LLCOffset += sHTCLng;
833 //printk("ChkLength = %d\n", LLCOffset);
834 // Null packet, don't indicate it to upper layer
835 ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
837 if( skb->len <= ChkLength ) {
841 skb_pull(skb, LLCOffset);
843 if(!bIsAggregateFrame) {
844 rxb->nr_subframes = 1;
846 rxb->subframes[0] = skb;
848 rxb->subframes[0] = skb_copy(skb, GFP_ATOMIC);
851 memcpy(rxb->src,src,ETH_ALEN);
852 memcpy(rxb->dst,dst,ETH_ALEN);
853 //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
856 rxb->nr_subframes = 0;
857 memcpy(rxb->src,src,ETH_ALEN);
858 memcpy(rxb->dst,dst,ETH_ALEN);
859 while(skb->len > ETHERNET_HEADER_SIZE) {
860 /* Offset 12 denote 2 mac address */
861 nSubframe_Length = *((u16*)(skb->data + 12));
862 //==m==>change the length order
863 nSubframe_Length = (nSubframe_Length>>8) + (nSubframe_Length<<8);
865 if(skb->len<(ETHERNET_HEADER_SIZE + nSubframe_Length)) {
868 (nRemain_Length>=(ETHERNET_HEADER_SIZE + nSubframe_Length)),
869 ("ParseSubframe(): A-MSDU subframe parse error!! Subframe Length: %d\n", nSubframe_Length) );
871 printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
872 __FUNCTION__,rxb->nr_subframes);
873 printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__, nSubframe_Length);
874 printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb->len,nSubframe_Length);
875 printk("The Packet SeqNum is %d\n",SeqNum);
879 /* move the data point to data content */
880 skb_pull(skb, ETHERNET_HEADER_SIZE);
883 sub_skb = skb_clone(skb, GFP_ATOMIC);
884 sub_skb->len = nSubframe_Length;
885 sub_skb->tail = sub_skb->data + nSubframe_Length;
887 /* Allocate new skb for releasing to upper layer */
888 sub_skb = dev_alloc_skb(nSubframe_Length + 12);
889 skb_reserve(sub_skb, 12);
890 data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length);
891 memcpy(data_ptr,skb->data,nSubframe_Length);
893 rxb->subframes[rxb->nr_subframes++] = sub_skb;
894 if(rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
895 IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
898 skb_pull(skb,nSubframe_Length);
901 nPadding_Length = 4 - ((nSubframe_Length + ETHERNET_HEADER_SIZE) % 4);
902 if(nPadding_Length == 4) {
906 if(skb->len < nPadding_Length) {
910 skb_pull(skb,nPadding_Length);
916 //{just for debug added by david
917 //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
919 return rxb->nr_subframes;
923 /* All received frames are sent to this function. @skb contains the frame in
924 * IEEE 802.11 format, i.e., in the format it was sent over air.
925 * This function is called only as a tasklet (software IRQ). */
926 int ieee80211_rtl_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
927 struct ieee80211_rx_stats *rx_stats)
929 struct net_device *dev = ieee->dev;
930 struct ieee80211_hdr_4addr *hdr;
931 //struct ieee80211_hdr_3addrqos *hdr;
934 u16 fc, type, stype, sc;
935 struct net_device_stats *stats;
939 //added by amy for reorder
942 PRX_TS_RECORD pTS = NULL;
943 //bool bIsAggregateFrame = false;
944 //added by amy for reorder
946 struct net_device *wds = NULL;
947 struct sk_buff *skb2 = NULL;
948 struct net_device *wds = NULL;
949 int frame_authorized = 0;
950 int from_assoc_ap = 0;
957 struct ieee80211_crypt_data *crypt = NULL;
961 struct ieee80211_rxb* rxb = NULL;
962 // cheat the the hdr type
963 hdr = (struct ieee80211_hdr_4addr *)skb->data;
964 stats = &ieee->stats;
967 printk(KERN_INFO "%s: SKB length < 10\n",
972 fc = le16_to_cpu(hdr->frame_ctl);
973 type = WLAN_FC_GET_TYPE(fc);
974 stype = WLAN_FC_GET_STYPE(fc);
975 sc = le16_to_cpu(hdr->seq_ctl);
977 frag = WLAN_GET_SEQ_FRAG(sc);
978 hdrlen = ieee80211_get_hdrlen(fc);
980 if(HTCCheck(ieee, skb->data))
983 printk("find HTCControl\n");
985 rx_stats->bContainHTC = 1;
988 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
990 #if WIRELESS_EXT > 15
991 /* Put this code here so that we avoid duplicating it in all
992 * Rx paths. - Jean II */
993 #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
994 /* If spy monitoring on */
995 if (iface->spy_data.spy_number > 0) {
996 struct iw_quality wstats;
997 wstats.level = rx_stats->rssi;
998 wstats.noise = rx_stats->noise;
999 wstats.updated = 6; /* No qual value */
1000 /* Update spy records */
1001 wireless_spy_update(dev, hdr->addr2, &wstats);
1003 #endif /* IW_WIRELESS_SPY */
1004 #endif /* WIRELESS_EXT > 15 */
1005 hostap_update_rx_stats(local->ap, hdr, rx_stats);
1008 #if WIRELESS_EXT > 15
1009 if (ieee->iw_mode == IW_MODE_MONITOR) {
1010 ieee80211_monitor_rx(ieee, skb, rx_stats);
1011 stats->rx_packets++;
1012 stats->rx_bytes += skb->len;
1016 if (ieee->host_decrypt) {
1018 if (skb->len >= hdrlen + 3)
1019 idx = skb->data[hdrlen + 3] >> 6;
1020 crypt = ieee->crypt[idx];
1024 /* Use station specific key to override default keys if the
1025 * receiver address is a unicast address ("individual RA"). If
1026 * bcrx_sta_key parameter is set, station specific key is used
1027 * even with broad/multicast targets (this is against IEEE
1028 * 802.11, but makes it easier to use different keys with
1029 * stations that do not support WEP key mapping). */
1031 if (!(hdr->addr1[0] & 0x01) || local->bcrx_sta_key)
1032 (void) hostap_handle_sta_crypto(local, hdr, &crypt,
1036 /* allow NULL decrypt to indicate an station specific override
1037 * for default encryption */
1038 if (crypt && (crypt->ops == NULL ||
1039 crypt->ops->decrypt_mpdu == NULL))
1042 if (!crypt && (fc & IEEE80211_FCTL_WEP)) {
1043 /* This seems to be triggered by some (multicast?)
1044 * frames from other than current BSS, so just drop the
1045 * frames silently instead of filling system log with
1047 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
1048 " (SA=" MAC_FMT ")\n",
1049 MAC_ARG(hdr->addr2));
1050 ieee->ieee_stats.rx_discards_undecryptable++;
1055 if (skb->len < IEEE80211_DATA_HDR3_LEN)
1058 // if QoS enabled, should check the sequence for each of the AC
1059 if( (ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)){
1060 if (is_duplicate_packet(ieee, hdr))
1066 PRX_TS_RECORD pRxTS = NULL;
1068 struct ieee80211_hdr_3addr *hdr;
1070 hdr = (struct ieee80211_hdr_3addr *)skb->data;
1071 fc = le16_to_cpu(hdr->frame_ctl);
1072 u8 tmp = (fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS);
1074 u8 tid = (*((u8*)skb->data + (((fc& IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS))?30:24)))&0xf;
1075 printk("====================>fc:%x, tid:%d, tmp:%d\n", fc, tid, tmp);
1076 //u8 tid = (u8)((frameqos*)(buf + ((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24))->field.tid;
1078 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid);
1082 (PTS_COMMON_INFO*) &pRxTS,
1084 (u8)Frame_QoSTID((u8*)(skb->data)),
1089 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
1090 if( (fc & (1<<11)) &&
1091 (frag == pRxTS->RxLastFragNum) &&
1092 (WLAN_GET_SEQ_SEQ(sc) == pRxTS->RxLastSeqNum) )
1098 pRxTS->RxLastFragNum = frag;
1099 pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
1104 IEEE80211_DEBUG(IEEE80211_DL_ERR, "%s(): No TS!! Skip the check!!\n",__FUNCTION__);
1109 if (type == IEEE80211_FTYPE_MGMT) {
1112 if ( stype == IEEE80211_STYPE_AUTH &&
1113 fc & IEEE80211_FCTL_WEP && ieee->host_decrypt &&
1114 (keyidx = hostap_rx_frame_decrypt(ieee, skb, crypt)) < 0)
1116 printk(KERN_DEBUG "%s: failed to decrypt mgmt::auth "
1117 "from " MAC_FMT "\n", dev->name,
1118 MAC_ARG(hdr->addr2));
1119 /* TODO: could inform hostapd about this so that it
1120 * could send auth failure report */
1125 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1126 if (ieee80211_rx_frame_mgmt(ieee, skb, rx_stats, type, stype))
1132 /* Data frame - extract src/dst addresses */
1133 switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
1134 case IEEE80211_FCTL_FROMDS:
1135 memcpy(dst, hdr->addr1, ETH_ALEN);
1136 memcpy(src, hdr->addr3, ETH_ALEN);
1137 memcpy(bssid, hdr->addr2, ETH_ALEN);
1139 case IEEE80211_FCTL_TODS:
1140 memcpy(dst, hdr->addr3, ETH_ALEN);
1141 memcpy(src, hdr->addr2, ETH_ALEN);
1142 memcpy(bssid, hdr->addr1, ETH_ALEN);
1144 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
1145 if (skb->len < IEEE80211_DATA_HDR4_LEN)
1147 memcpy(dst, hdr->addr3, ETH_ALEN);
1148 memcpy(src, hdr->addr4, ETH_ALEN);
1149 memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
1152 memcpy(dst, hdr->addr1, ETH_ALEN);
1153 memcpy(src, hdr->addr2, ETH_ALEN);
1154 memcpy(bssid, hdr->addr3, ETH_ALEN);
1159 if (hostap_rx_frame_wds(ieee, hdr, fc, &wds))
1162 skb->dev = dev = wds;
1163 stats = hostap_get_stats(dev);
1166 if (ieee->iw_mode == IW_MODE_MASTER && !wds &&
1167 (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS &&
1169 memcmp(hdr->addr2, ieee->assoc_ap_addr, ETH_ALEN) == 0) {
1170 /* Frame from BSSID of the AP for which we are a client */
1171 skb->dev = dev = ieee->stadev;
1172 stats = hostap_get_stats(dev);
1177 dev->last_rx = jiffies;
1180 if ((ieee->iw_mode == IW_MODE_MASTER ||
1181 ieee->iw_mode == IW_MODE_REPEAT) &&
1183 switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats,
1185 case AP_RX_CONTINUE_NOT_AUTHORIZED:
1186 frame_authorized = 0;
1188 case AP_RX_CONTINUE:
1189 frame_authorized = 1;
1198 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1199 /* Nullfunc frames may have PS-bit set, so they must be passed to
1200 * hostap_handle_sta_rx() before being dropped here. */
1201 if (stype != IEEE80211_STYPE_DATA &&
1202 stype != IEEE80211_STYPE_DATA_CFACK &&
1203 stype != IEEE80211_STYPE_DATA_CFPOLL &&
1204 stype != IEEE80211_STYPE_DATA_CFACKPOLL&&
1205 stype != IEEE80211_STYPE_QOS_DATA//add by David,2006.8.4
1207 if (stype != IEEE80211_STYPE_NULLFUNC)
1208 IEEE80211_DEBUG_DROP(
1209 "RX: dropped data frame "
1210 "with no data (type=0x%02x, "
1211 "subtype=0x%02x, len=%d)\n",
1212 type, stype, skb->len);
1215 if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
1218 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
1220 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1221 (keyidx = ieee80211_rx_frame_decrypt(ieee, skb, crypt)) < 0)
1223 printk("decrypt frame error\n");
1228 hdr = (struct ieee80211_hdr_4addr *) skb->data;
1230 /* skb: hdr + (possibly fragmented) plaintext payload */
1231 // PR: FIXME: hostap has additional conditions in the "if" below:
1232 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1233 if ((frag != 0 || (fc & IEEE80211_FCTL_MOREFRAGS))) {
1235 struct sk_buff *frag_skb = ieee80211_frag_cache_get(ieee, hdr);
1236 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
1239 IEEE80211_DEBUG(IEEE80211_DL_RX | IEEE80211_DL_FRAG,
1240 "Rx cannot get skb from fragment "
1241 "cache (morefrag=%d seq=%u frag=%u)\n",
1242 (fc & IEEE80211_FCTL_MOREFRAGS) != 0,
1243 WLAN_GET_SEQ_SEQ(sc), frag);
1250 if (frag_skb->tail + flen > frag_skb->end) {
1251 printk(KERN_WARNING "%s: host decrypted and "
1252 "reassembled frame did not fit skb\n",
1254 ieee80211_frag_cache_invalidate(ieee, hdr);
1259 /* copy first fragment (including full headers) into
1260 * beginning of the fragment cache skb */
1261 memcpy(skb_put(frag_skb, flen), skb->data, flen);
1263 /* append frame payload to the end of the fragment
1265 memcpy(skb_put(frag_skb, flen), skb->data + hdrlen,
1268 dev_kfree_skb_any(skb);
1271 if (fc & IEEE80211_FCTL_MOREFRAGS) {
1272 /* more fragments expected - leave the skb in fragment
1273 * cache for now; it will be delivered to upper layers
1274 * after all fragments have been received */
1278 /* this was the last fragment and the frame will be
1279 * delivered, so remove skb from fragment cache */
1281 hdr = (struct ieee80211_hdr_4addr *) skb->data;
1282 ieee80211_frag_cache_invalidate(ieee, hdr);
1285 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1286 * encrypted/authenticated */
1287 if (ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1288 ieee80211_rx_frame_decrypt_msdu(ieee, skb, keyidx, crypt))
1290 printk("==>decrypt msdu error\n");
1294 //added by amy for AP roaming
1295 ieee->LinkDetectInfo.NumRecvDataInPeriod++;
1296 ieee->LinkDetectInfo.NumRxOkInPeriod++;
1298 hdr = (struct ieee80211_hdr_4addr *) skb->data;
1299 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
1300 if (/*ieee->ieee802_1x &&*/
1301 ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1303 #ifdef CONFIG_IEEE80211_DEBUG
1304 /* pass unencrypted EAPOL frames even if encryption is
1306 struct eapol *eap = (struct eapol *)(skb->data +
1308 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1309 eap_get_type(eap->type));
1312 IEEE80211_DEBUG_DROP(
1313 "encryption configured, but RX "
1314 "frame not encrypted (SA=" MAC_FMT ")\n",
1315 MAC_ARG(hdr->addr2));
1320 #ifdef CONFIG_IEEE80211_DEBUG
1321 if (crypt && !(fc & IEEE80211_FCTL_WEP) &&
1322 ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1323 struct eapol *eap = (struct eapol *)(skb->data +
1325 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1326 eap_get_type(eap->type));
1330 if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep &&
1331 !ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1332 IEEE80211_DEBUG_DROP(
1333 "dropped unencrypted RX data "
1334 "frame from " MAC_FMT
1335 " (drop_unencrypted=1)\n",
1336 MAC_ARG(hdr->addr2));
1340 if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1341 printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
1344 //added by amy for reorder
1346 if(ieee->current_network.qos_data.active && IsQoSDataFrame(skb->data)
1347 && !is_multicast_ether_addr(hdr->addr1) && !is_broadcast_ether_addr(hdr->addr1))
1349 TID = Frame_QoSTID(skb->data);
1350 SeqNum = WLAN_GET_SEQ_SEQ(sc);
1351 GetTs(ieee,(PTS_COMMON_INFO*) &pTS,hdr->addr2,TID,RX_DIR,true);
1352 if(TID !=0 && TID !=3)
1354 ieee->bis_any_nonbepkts = true;
1358 //added by amy for reorder
1359 /* skb: hdr + (possible reassembled) full plaintext payload */
1360 payload = skb->data + hdrlen;
1361 //ethertype = (payload[6] << 8) | payload[7];
1362 rxb = (struct ieee80211_rxb*)kmalloc(sizeof(struct ieee80211_rxb),GFP_ATOMIC);
1365 IEEE80211_DEBUG(IEEE80211_DL_ERR,"%s(): kmalloc rxb error\n",__FUNCTION__);
1368 /* to parse amsdu packets */
1369 /* qos data packets & reserved bit is 1 */
1370 if(parse_subframe(skb,rx_stats,rxb,src,dst) == 0) {
1371 /* only to free rxb, and not submit the packets to upper layer */
1372 for(i =0; i < rxb->nr_subframes; i++) {
1373 dev_kfree_skb(rxb->subframes[i]);
1380 ieee->last_rx_ps_time = jiffies;
1381 //added by amy for reorder
1382 if(ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL){
1383 //added by amy for reorder
1384 for(i = 0; i<rxb->nr_subframes; i++) {
1385 struct sk_buff *sub_skb = rxb->subframes[i];
1388 /* convert hdr + possible LLC headers into Ethernet header */
1389 ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
1390 if (sub_skb->len >= 8 &&
1391 ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
1392 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1393 memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
1394 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1395 * replace EtherType */
1396 skb_pull(sub_skb, SNAP_SIZE);
1397 memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
1398 memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
1401 /* Leave Ethernet header part of hdr and full payload */
1402 len = htons(sub_skb->len);
1403 memcpy(skb_push(sub_skb, 2), &len, 2);
1404 memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
1405 memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
1408 stats->rx_packets++;
1409 stats->rx_bytes += sub_skb->len;
1410 if(is_multicast_ether_addr(dst)) {
1414 /* Indicat the packets to upper layer */
1415 //printk("0skb_len(%d)\n", skb->len);
1416 sub_skb->protocol = eth_type_trans(sub_skb, dev);
1417 memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
1419 sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
1420 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
1421 //printk("1skb_len(%d)\n", skb->len);
1431 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__);
1432 RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
1441 hostap_handle_sta_release(sta);
1451 stats->rx_dropped++;
1453 /* Returning 0 indicates to caller that we have not handled the SKB--
1454 * so it is still allocated and can be used again by underlying
1455 * hardware as a DMA target */
1459 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
1461 static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
1464 * Make ther structure we read from the beacon packet has
1467 static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
1468 *info_element, int sub_type)
1471 if (info_element->qui_subtype != sub_type)
1473 if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN))
1475 if (info_element->qui_type != QOS_OUI_TYPE)
1477 if (info_element->version != QOS_VERSION_1)
1485 * Parse a QoS parameter element
1487 static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
1488 *element_param, struct ieee80211_info_element
1492 u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2;
1494 if ((info_element == NULL) || (element_param == NULL))
1497 if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) {
1498 memcpy(element_param->info_element.qui, info_element->data,
1500 element_param->info_element.elementID = info_element->id;
1501 element_param->info_element.length = info_element->len;
1505 ret = ieee80211_verify_qos_info(&element_param->info_element,
1506 QOS_OUI_PARAM_SUB_TYPE);
1511 * Parse a QoS information element
1513 static int ieee80211_read_qos_info_element(struct
1514 ieee80211_qos_information_element
1515 *element_info, struct ieee80211_info_element
1519 u16 size = sizeof(struct ieee80211_qos_information_element) - 2;
1521 if (element_info == NULL)
1523 if (info_element == NULL)
1526 if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
1527 memcpy(element_info->qui, info_element->data,
1529 element_info->elementID = info_element->id;
1530 element_info->length = info_element->len;
1535 ret = ieee80211_verify_qos_info(element_info,
1536 QOS_OUI_INFO_SUB_TYPE);
1542 * Write QoS parameters from the ac parameters.
1544 static int ieee80211_qos_convert_ac_to_parameters(struct
1545 ieee80211_qos_parameter_info
1547 ieee80211_qos_parameters
1552 struct ieee80211_qos_ac_parameter *ac_params;
1557 for (i = 0; i < QOS_QUEUE_NUM; i++) {
1558 ac_params = &(param_elm->ac_params_record[i]);
1560 aci = (ac_params->aci_aifsn & 0x60) >> 5;
1562 if(aci >= QOS_QUEUE_NUM)
1564 qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
1566 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1567 qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2:qos_param->aifs[aci];
1569 qos_param->cw_min[aci] = ac_params->ecw_min_max & 0x0F;
1571 qos_param->cw_max[aci] = (ac_params->ecw_min_max & 0xF0) >> 4;
1573 qos_param->flag[aci] =
1574 (ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
1575 qos_param->tx_op_limit[aci] = le16_to_cpu(ac_params->tx_op_limit);
1581 * we have a generic data element which it may contain QoS information or
1582 * parameters element. check the information element length to decide
1583 * which type to read
1585 static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1587 struct ieee80211_network *network)
1590 struct ieee80211_qos_parameters *qos_param = NULL;
1591 struct ieee80211_qos_information_element qos_info_element;
1593 rc = ieee80211_read_qos_info_element(&qos_info_element, info_element);
1596 network->qos_data.param_count = qos_info_element.ac_info & 0x0F;
1597 network->flags |= NETWORK_HAS_QOS_INFORMATION;
1599 struct ieee80211_qos_parameter_info param_element;
1601 rc = ieee80211_read_qos_param_element(¶m_element,
1604 qos_param = &(network->qos_data.parameters);
1605 ieee80211_qos_convert_ac_to_parameters(¶m_element,
1607 network->flags |= NETWORK_HAS_QOS_PARAMETERS;
1608 network->qos_data.param_count =
1609 param_element.info_element.ac_info & 0x0F;
1614 IEEE80211_DEBUG_QOS("QoS is supported\n");
1615 network->qos_data.supported = 1;
1620 #ifdef CONFIG_IEEE80211_DEBUG
1621 #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1623 static const char *get_info_element_string(u16 id)
1628 MFIE_STRING(FH_SET);
1629 MFIE_STRING(DS_SET);
1630 MFIE_STRING(CF_SET);
1632 MFIE_STRING(IBSS_SET);
1633 MFIE_STRING(COUNTRY);
1634 MFIE_STRING(HOP_PARAMS);
1635 MFIE_STRING(HOP_TABLE);
1636 MFIE_STRING(REQUEST);
1637 MFIE_STRING(CHALLENGE);
1638 MFIE_STRING(POWER_CONSTRAINT);
1639 MFIE_STRING(POWER_CAPABILITY);
1640 MFIE_STRING(TPC_REQUEST);
1641 MFIE_STRING(TPC_REPORT);
1642 MFIE_STRING(SUPP_CHANNELS);
1644 MFIE_STRING(MEASURE_REQUEST);
1645 MFIE_STRING(MEASURE_REPORT);
1647 MFIE_STRING(IBSS_DFS);
1648 // MFIE_STRING(ERP_INFO);
1650 MFIE_STRING(RATES_EX);
1651 MFIE_STRING(GENERIC);
1652 MFIE_STRING(QOS_PARAMETER);
1659 #ifdef ENABLE_DOT11D
1660 static inline void ieee80211_extract_country_ie(
1661 struct ieee80211_device *ieee,
1662 struct ieee80211_info_element *info_element,
1663 struct ieee80211_network *network,
1667 if(IS_DOT11D_ENABLE(ieee))
1669 if(info_element->len!= 0)
1671 memcpy(network->CountryIeBuf, info_element->data, info_element->len);
1672 network->CountryIeLen = info_element->len;
1674 if(!IS_COUNTRY_IE_VALID(ieee))
1676 Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
1681 // 070305, rcnjko: I update country IE watch dog here because
1682 // some AP (e.g. Cisco 1242) don't include country IE in their
1683 // probe response frame.
1685 if(IS_EQUAL_CIE_SRC(ieee, addr2) )
1687 UPDATE_CIE_WATCHDOG(ieee);
1694 int ieee80211_parse_info_param(struct ieee80211_device *ieee,
1695 struct ieee80211_info_element *info_element,
1697 struct ieee80211_network *network,
1698 struct ieee80211_rx_stats *stats)
1702 u16 tmp_htcap_len=0;
1703 u16 tmp_htinfo_len=0;
1704 u16 ht_realtek_agg_len=0;
1705 u8 ht_realtek_agg_buf[MAX_IE_LEN];
1706 // u16 broadcom_len = 0;
1707 #ifdef CONFIG_IEEE80211_DEBUG
1712 while (length >= sizeof(*info_element)) {
1713 if (sizeof(*info_element) + info_element->len > length) {
1714 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1715 "info_element->len + 2 > left : "
1716 "info_element->len+2=%zd left=%d, id=%d.\n",
1718 sizeof(*info_element),
1719 length, info_element->id);
1720 /* We stop processing but don't return an error here
1721 * because some misbehaviour APs break this rule. ie.
1722 * Orinoco AP1000. */
1726 switch (info_element->id) {
1727 case MFIE_TYPE_SSID:
1728 if (ieee80211_is_empty_essid(info_element->data,
1729 info_element->len)) {
1730 network->flags |= NETWORK_EMPTY_ESSID;
1734 network->ssid_len = min(info_element->len,
1735 (u8) IW_ESSID_MAX_SIZE);
1736 memcpy(network->ssid, info_element->data, network->ssid_len);
1737 if (network->ssid_len < IW_ESSID_MAX_SIZE)
1738 memset(network->ssid + network->ssid_len, 0,
1739 IW_ESSID_MAX_SIZE - network->ssid_len);
1741 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
1742 network->ssid, network->ssid_len);
1745 case MFIE_TYPE_RATES:
1746 #ifdef CONFIG_IEEE80211_DEBUG
1749 network->rates_len = min(info_element->len,
1751 for (i = 0; i < network->rates_len; i++) {
1752 network->rates[i] = info_element->data[i];
1753 #ifdef CONFIG_IEEE80211_DEBUG
1754 p += snprintf(p, sizeof(rates_str) -
1755 (p - rates_str), "%02X ",
1758 if (ieee80211_is_ofdm_rate
1759 (info_element->data[i])) {
1760 network->flags |= NETWORK_HAS_OFDM;
1761 if (info_element->data[i] &
1762 IEEE80211_BASIC_RATE_MASK)
1768 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
1769 rates_str, network->rates_len);
1772 case MFIE_TYPE_RATES_EX:
1773 #ifdef CONFIG_IEEE80211_DEBUG
1776 network->rates_ex_len = min(info_element->len,
1777 MAX_RATES_EX_LENGTH);
1778 for (i = 0; i < network->rates_ex_len; i++) {
1779 network->rates_ex[i] = info_element->data[i];
1780 #ifdef CONFIG_IEEE80211_DEBUG
1781 p += snprintf(p, sizeof(rates_str) -
1782 (p - rates_str), "%02X ",
1785 if (ieee80211_is_ofdm_rate
1786 (info_element->data[i])) {
1787 network->flags |= NETWORK_HAS_OFDM;
1788 if (info_element->data[i] &
1789 IEEE80211_BASIC_RATE_MASK)
1795 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
1796 rates_str, network->rates_ex_len);
1799 case MFIE_TYPE_DS_SET:
1800 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
1801 info_element->data[0]);
1802 network->channel = info_element->data[0];
1805 case MFIE_TYPE_FH_SET:
1806 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
1809 case MFIE_TYPE_CF_SET:
1810 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
1814 if(info_element->len < 4)
1817 network->tim.tim_count = info_element->data[0];
1818 network->tim.tim_period = info_element->data[1];
1820 network->dtim_period = info_element->data[1];
1821 if(ieee->state != IEEE80211_LINKED)
1824 network->last_dtim_sta_time[0] = stats->mac_time[0];
1826 //we use jiffies for legacy Power save
1827 network->last_dtim_sta_time[0] = jiffies;
1829 network->last_dtim_sta_time[1] = stats->mac_time[1];
1831 network->dtim_data = IEEE80211_DTIM_VALID;
1833 if(info_element->data[0] != 0)
1836 if(info_element->data[2] & 1)
1837 network->dtim_data |= IEEE80211_DTIM_MBCAST;
1839 offset = (info_element->data[2] >> 1)*2;
1841 //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
1843 if(ieee->assoc_id < 8*offset ||
1844 ieee->assoc_id > 8*(offset + info_element->len -3))
1848 offset = (ieee->assoc_id / 8) - offset;// + ((aid % 8)? 0 : 1) ;
1850 if(info_element->data[3+offset] & (1<<(ieee->assoc_id%8)))
1851 network->dtim_data |= IEEE80211_DTIM_UCAST;
1853 //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
1857 network->erp_value = info_element->data[0];
1858 network->flags |= NETWORK_HAS_ERP_VALUE;
1859 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1860 network->erp_value);
1862 case MFIE_TYPE_IBSS_SET:
1863 network->atim_window = info_element->data[0];
1864 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1865 network->atim_window);
1868 case MFIE_TYPE_CHALLENGE:
1869 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
1872 case MFIE_TYPE_GENERIC:
1873 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
1875 if (!ieee80211_parse_qos_info_param_IE(info_element,
1879 if (info_element->len >= 4 &&
1880 info_element->data[0] == 0x00 &&
1881 info_element->data[1] == 0x50 &&
1882 info_element->data[2] == 0xf2 &&
1883 info_element->data[3] == 0x01) {
1884 network->wpa_ie_len = min(info_element->len + 2,
1886 memcpy(network->wpa_ie, info_element,
1887 network->wpa_ie_len);
1892 if (info_element->len == 7 &&
1893 info_element->data[0] == 0x00 &&
1894 info_element->data[1] == 0xe0 &&
1895 info_element->data[2] == 0x4c &&
1896 info_element->data[3] == 0x01 &&
1897 info_element->data[4] == 0x02) {
1898 network->Turbo_Enable = 1;
1902 //for HTcap and HTinfo parameters
1903 if(tmp_htcap_len == 0){
1904 if(info_element->len >= 4 &&
1905 info_element->data[0] == 0x00 &&
1906 info_element->data[1] == 0x90 &&
1907 info_element->data[2] == 0x4c &&
1908 info_element->data[3] == 0x033){
1910 tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
1911 if(tmp_htcap_len != 0){
1912 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1913 network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
1914 sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
1915 memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
1918 if(tmp_htcap_len != 0)
1919 network->bssht.bdSupportHT = true;
1921 network->bssht.bdSupportHT = false;
1925 if(tmp_htinfo_len == 0){
1926 if(info_element->len >= 4 &&
1927 info_element->data[0] == 0x00 &&
1928 info_element->data[1] == 0x90 &&
1929 info_element->data[2] == 0x4c &&
1930 info_element->data[3] == 0x034){
1932 tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
1933 if(tmp_htinfo_len != 0){
1934 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
1936 network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
1937 sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
1938 memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
1946 if(ieee->aggregation){
1947 if(network->bssht.bdSupportHT){
1948 if(info_element->len >= 4 &&
1949 info_element->data[0] == 0x00 &&
1950 info_element->data[1] == 0xe0 &&
1951 info_element->data[2] == 0x4c &&
1952 info_element->data[3] == 0x02){
1954 ht_realtek_agg_len = min(info_element->len,(u8)MAX_IE_LEN);
1955 memcpy(ht_realtek_agg_buf,info_element->data,info_element->len);
1958 if(ht_realtek_agg_len >= 5){
1959 network->bssht.bdRT2RTAggregation = true;
1961 if((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02))
1962 network->bssht.bdRT2RTLongSlotTime = true;
1968 //if(tmp_htcap_len !=0 || tmp_htinfo_len != 0)
1970 if((info_element->len >= 3 &&
1971 info_element->data[0] == 0x00 &&
1972 info_element->data[1] == 0x05 &&
1973 info_element->data[2] == 0xb5) ||
1974 (info_element->len >= 3 &&
1975 info_element->data[0] == 0x00 &&
1976 info_element->data[1] == 0x0a &&
1977 info_element->data[2] == 0xf7) ||
1978 (info_element->len >= 3 &&
1979 info_element->data[0] == 0x00 &&
1980 info_element->data[1] == 0x10 &&
1981 info_element->data[2] == 0x18)){
1983 network->broadcom_cap_exist = true;
1988 if (tmp_htcap_len !=0)
1990 u16 cap_ext = ((PHT_CAPABILITY_ELE)&info_element->data[0])->ExtHTCapInfo;
1991 if ((cap_ext & 0x0c00) == 0x0c00)
1993 network->ralink_cap_exist = true;
1997 if(info_element->len >= 3 &&
1998 info_element->data[0] == 0x00 &&
1999 info_element->data[1] == 0x0c &&
2000 info_element->data[2] == 0x43)
2002 network->ralink_cap_exist = true;
2005 network->ralink_cap_exist = false;
2006 //added by amy for atheros AP
2007 if((info_element->len >= 3 &&
2008 info_element->data[0] == 0x00 &&
2009 info_element->data[1] == 0x03 &&
2010 info_element->data[2] == 0x7f) ||
2011 (info_element->len >= 3 &&
2012 info_element->data[0] == 0x00 &&
2013 info_element->data[1] == 0x13 &&
2014 info_element->data[2] == 0x74))
2016 printk("========>%s(): athros AP is exist\n",__FUNCTION__);
2017 network->atheros_cap_exist = true;
2020 network->atheros_cap_exist = false;
2022 if(info_element->len >= 3 &&
2023 info_element->data[0] == 0x00 &&
2024 info_element->data[1] == 0x40 &&
2025 info_element->data[2] == 0x96)
2027 network->cisco_cap_exist = true;
2030 network->cisco_cap_exist = false;
2031 //added by amy for LEAP of cisco
2032 if(info_element->len > 4 &&
2033 info_element->data[0] == 0x00 &&
2034 info_element->data[1] == 0x40 &&
2035 info_element->data[2] == 0x96 &&
2036 info_element->data[3] == 0x01)
2038 if(info_element->len == 6)
2040 memcpy(network->CcxRmState, &info_element[4], 2);
2041 if(network->CcxRmState[0] != 0)
2043 network->bCcxRmEnable = true;
2046 network->bCcxRmEnable = false;
2048 // CCXv4 Table 59-1 MBSSID Masks.
2050 network->MBssidMask = network->CcxRmState[1] & 0x07;
2051 if(network->MBssidMask != 0)
2053 network->bMBssidValid = true;
2054 network->MBssidMask = 0xff << (network->MBssidMask);
2055 cpMacAddr(network->MBssid, network->bssid);
2056 network->MBssid[5] &= network->MBssidMask;
2060 network->bMBssidValid = false;
2065 network->bCcxRmEnable = false;
2068 if(info_element->len > 4 &&
2069 info_element->data[0] == 0x00 &&
2070 info_element->data[1] == 0x40 &&
2071 info_element->data[2] == 0x96 &&
2072 info_element->data[3] == 0x03)
2074 if(info_element->len == 5)
2076 network->bWithCcxVerNum = true;
2077 network->BssCcxVerNumber = info_element->data[4];
2081 network->bWithCcxVerNum = false;
2082 network->BssCcxVerNumber = 0;
2088 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
2090 network->rsn_ie_len = min(info_element->len + 2,
2092 memcpy(network->rsn_ie, info_element,
2093 network->rsn_ie_len);
2096 //HT related element.
2097 case MFIE_TYPE_HT_CAP:
2098 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
2100 tmp_htcap_len = min(info_element->len,(u8)MAX_IE_LEN);
2101 if(tmp_htcap_len != 0){
2102 network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
2103 network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf)?\
2104 sizeof(network->bssht.bdHTCapBuf):tmp_htcap_len;
2105 memcpy(network->bssht.bdHTCapBuf,info_element->data,network->bssht.bdHTCapLen);
2107 //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
2108 // windows driver will update WMM parameters each beacon received once connected
2109 // Linux driver is a bit different.
2110 network->bssht.bdSupportHT = true;
2113 network->bssht.bdSupportHT = false;
2117 case MFIE_TYPE_HT_INFO:
2118 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
2120 tmp_htinfo_len = min(info_element->len,(u8)MAX_IE_LEN);
2122 network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
2123 network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf)?\
2124 sizeof(network->bssht.bdHTInfoBuf):tmp_htinfo_len;
2125 memcpy(network->bssht.bdHTInfoBuf,info_element->data,network->bssht.bdHTInfoLen);
2129 case MFIE_TYPE_AIRONET:
2130 IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
2132 if(info_element->len >IE_CISCO_FLAG_POSITION)
2134 network->bWithAironetIE = true;
2136 // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
2137 // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
2138 // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
2139 if( (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_MIC) ||
2140 (info_element->data[IE_CISCO_FLAG_POSITION]&SUPPORT_CKIP_PK) )
2142 network->bCkipSupported = true;
2146 network->bCkipSupported = false;
2151 network->bWithAironetIE = false;
2152 network->bCkipSupported = false;
2155 case MFIE_TYPE_QOS_PARAMETER:
2157 "QoS Error need to parse QOS_PARAMETER IE\n");
2160 #ifdef ENABLE_DOT11D
2161 case MFIE_TYPE_COUNTRY:
2162 IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
2164 //printk("=====>Receive <%s> Country IE\n",network->ssid);
2165 ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP
2171 case MFIE_TYPE_POWER_CONSTRAINT:
2172 network->power_constraint = info_element->data[0];
2173 network->flags |= NETWORK_HAS_POWER_CONSTRAINT;
2177 network->power_constraint = info_element->data[0];
2178 network->flags |= NETWORK_HAS_CSA;
2181 case MFIE_TYPE_QUIET:
2182 network->quiet.count = info_element->data[0];
2183 network->quiet.period = info_element->data[1];
2184 network->quiet.duration = info_element->data[2];
2185 network->quiet.offset = info_element->data[3];
2186 network->flags |= NETWORK_HAS_QUIET;
2189 case MFIE_TYPE_IBSS_DFS:
2190 if (network->ibss_dfs)
2192 network->ibss_dfs = kmemdup(info_element->data,
2195 if (!network->ibss_dfs)
2197 network->flags |= NETWORK_HAS_IBSS_DFS;
2200 case MFIE_TYPE_TPC_REPORT:
2201 network->tpc_report.transmit_power =
2202 info_element->data[0];
2203 network->tpc_report.link_margin = info_element->data[1];
2204 network->flags |= NETWORK_HAS_TPC_REPORT;
2208 IEEE80211_DEBUG_MGMT
2209 ("Unsupported info element: %s (%d)\n",
2210 get_info_element_string(info_element->id),
2215 length -= sizeof(*info_element) + info_element->len;
2217 (struct ieee80211_info_element *)&info_element->
2218 data[info_element->len];
2221 if(!network->atheros_cap_exist && !network->broadcom_cap_exist &&
2222 !network->cisco_cap_exist && !network->ralink_cap_exist && !network->bssht.bdRT2RTAggregation)
2224 network->unknown_cap_exist = true;
2228 network->unknown_cap_exist = false;
2233 static inline u8 ieee80211_SignalStrengthTranslate(
2239 // Step 1. Scale mapping.
2240 if(CurrSS >= 71 && CurrSS <= 100)
2242 RetSS = 90 + ((CurrSS - 70) / 3);
2244 else if(CurrSS >= 41 && CurrSS <= 70)
2246 RetSS = 78 + ((CurrSS - 40) / 3);
2248 else if(CurrSS >= 31 && CurrSS <= 40)
2250 RetSS = 66 + (CurrSS - 30);
2252 else if(CurrSS >= 21 && CurrSS <= 30)
2254 RetSS = 54 + (CurrSS - 20);
2256 else if(CurrSS >= 5 && CurrSS <= 20)
2258 RetSS = 42 + (((CurrSS - 5) * 2) / 3);
2260 else if(CurrSS == 4)
2264 else if(CurrSS == 3)
2268 else if(CurrSS == 2)
2272 else if(CurrSS == 1)
2280 //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2282 // Step 2. Smoothing.
2284 //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2289 long ieee80211_translate_todbm(u8 signal_strength_index )// 0-100 index.
2291 long signal_power; // in dBm.
2293 // Translate to dBm (x=0.5y-95).
2294 signal_power = (long)((signal_strength_index + 1) >> 1);
2297 return signal_power;
2300 static inline int ieee80211_network_init(
2301 struct ieee80211_device *ieee,
2302 struct ieee80211_probe_response *beacon,
2303 struct ieee80211_network *network,
2304 struct ieee80211_rx_stats *stats)
2306 #ifdef CONFIG_IEEE80211_DEBUG
2307 //char rates_str[64];
2311 network->qos_data.active = 0;
2312 network->qos_data.supported = 0;
2313 network->qos_data.param_count = 0;
2314 network->qos_data.old_param_count = 0;
2316 /* Pull out fixed field data */
2317 memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
2318 network->capability = le16_to_cpu(beacon->capability);
2319 network->last_scanned = jiffies;
2320 network->time_stamp[0] = le32_to_cpu(beacon->time_stamp[0]);
2321 network->time_stamp[1] = le32_to_cpu(beacon->time_stamp[1]);
2322 network->beacon_interval = le32_to_cpu(beacon->beacon_interval);
2323 /* Where to pull this? beacon->listen_interval;*/
2324 network->listen_interval = 0x0A;
2325 network->rates_len = network->rates_ex_len = 0;
2326 network->last_associate = 0;
2327 network->ssid_len = 0;
2329 network->atim_window = 0;
2330 network->erp_value = (network->capability & WLAN_CAPABILITY_IBSS) ?
2332 network->berp_info_valid = false;
2333 network->broadcom_cap_exist = false;
2334 network->ralink_cap_exist = false;
2335 network->atheros_cap_exist = false;
2336 network->cisco_cap_exist = false;
2337 network->unknown_cap_exist = false;
2339 network->Turbo_Enable = 0;
2341 #ifdef ENABLE_DOT11D
2342 network->CountryIeLen = 0;
2343 memset(network->CountryIeBuf, 0, MAX_IE_LEN);
2345 //Initialize HT parameters
2346 //ieee80211_ht_initialize(&network->bssht);
2347 HTInitializeBssDesc(&network->bssht);
2348 if (stats->freq == IEEE80211_52GHZ_BAND) {
2349 /* for A band (No DS info) */
2350 network->channel = stats->received_channel;
2352 network->flags |= NETWORK_HAS_CCK;
2354 network->wpa_ie_len = 0;
2355 network->rsn_ie_len = 0;
2357 if (ieee80211_parse_info_param
2358 (ieee,beacon->info_element, stats->len - sizeof(*beacon), network, stats))
2362 if (stats->freq == IEEE80211_52GHZ_BAND)
2363 network->mode = IEEE_A;
2365 if (network->flags & NETWORK_HAS_OFDM)
2366 network->mode |= IEEE_G;
2367 if (network->flags & NETWORK_HAS_CCK)
2368 network->mode |= IEEE_B;
2371 if (network->mode == 0) {
2372 IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT ")' "
2374 escape_essid(network->ssid,
2376 MAC_ARG(network->bssid));
2380 if(network->bssht.bdSupportHT){
2381 if(network->mode == IEEE_A)
2382 network->mode = IEEE_N_5G;
2383 else if(network->mode & (IEEE_G | IEEE_B))
2384 network->mode = IEEE_N_24G;
2386 if (ieee80211_is_empty_essid(network->ssid, network->ssid_len))
2387 network->flags |= NETWORK_EMPTY_ESSID;
2390 stats->signal = 30 + (stats->SignalStrength * 70) / 100;
2391 //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
2392 stats->noise = ieee80211_translate_todbm((u8)(100-stats->signal)) -25;
2395 memcpy(&network->stats, stats, sizeof(network->stats));
2400 static inline int is_same_network(struct ieee80211_network *src,
2401 struct ieee80211_network *dst, struct ieee80211_device* ieee)
2403 /* A network is only a duplicate if the channel, BSSID, ESSID
2404 * and the capability field (in particular IBSS and BSS) all match.
2405 * We treat all <hidden> with the same BSSID and channel
2407 return //((src->ssid_len == dst->ssid_len) &&
2408 (((src->ssid_len == dst->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
2409 (src->channel == dst->channel) &&
2410 !memcmp(src->bssid, dst->bssid, ETH_ALEN) &&
2411 //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
2412 (!memcmp(src->ssid, dst->ssid, src->ssid_len) || (ieee->iw_mode == IW_MODE_INFRA)) &&
2413 ((src->capability & WLAN_CAPABILITY_IBSS) ==
2414 (dst->capability & WLAN_CAPABILITY_IBSS)) &&
2415 ((src->capability & WLAN_CAPABILITY_BSS) ==
2416 (dst->capability & WLAN_CAPABILITY_BSS)));
2419 static inline void update_network(struct ieee80211_network *dst,
2420 struct ieee80211_network *src)
2425 memcpy(&dst->stats, &src->stats, sizeof(struct ieee80211_rx_stats));
2426 dst->capability = src->capability;
2427 memcpy(dst->rates, src->rates, src->rates_len);
2428 dst->rates_len = src->rates_len;
2429 memcpy(dst->rates_ex, src->rates_ex, src->rates_ex_len);
2430 dst->rates_ex_len = src->rates_ex_len;
2431 if(src->ssid_len > 0)
2433 memset(dst->ssid, 0, dst->ssid_len);
2434 dst->ssid_len = src->ssid_len;
2435 memcpy(dst->ssid, src->ssid, src->ssid_len);
2437 dst->mode = src->mode;
2438 dst->flags = src->flags;
2439 dst->time_stamp[0] = src->time_stamp[0];
2440 dst->time_stamp[1] = src->time_stamp[1];
2441 if (src->flags & NETWORK_HAS_ERP_VALUE)
2443 dst->erp_value = src->erp_value;
2444 dst->berp_info_valid = src->berp_info_valid = true;
2446 dst->beacon_interval = src->beacon_interval;
2447 dst->listen_interval = src->listen_interval;
2448 dst->atim_window = src->atim_window;
2449 dst->dtim_period = src->dtim_period;
2450 dst->dtim_data = src->dtim_data;
2451 dst->last_dtim_sta_time[0] = src->last_dtim_sta_time[0];
2452 dst->last_dtim_sta_time[1] = src->last_dtim_sta_time[1];
2453 memcpy(&dst->tim, &src->tim, sizeof(struct ieee80211_tim_parameters));
2455 dst->bssht.bdSupportHT = src->bssht.bdSupportHT;
2456 dst->bssht.bdRT2RTAggregation = src->bssht.bdRT2RTAggregation;
2457 dst->bssht.bdHTCapLen= src->bssht.bdHTCapLen;
2458 memcpy(dst->bssht.bdHTCapBuf,src->bssht.bdHTCapBuf,src->bssht.bdHTCapLen);
2459 dst->bssht.bdHTInfoLen= src->bssht.bdHTInfoLen;
2460 memcpy(dst->bssht.bdHTInfoBuf,src->bssht.bdHTInfoBuf,src->bssht.bdHTInfoLen);
2461 dst->bssht.bdHTSpecVer = src->bssht.bdHTSpecVer;
2462 dst->bssht.bdRT2RTLongSlotTime = src->bssht.bdRT2RTLongSlotTime;
2463 dst->broadcom_cap_exist = src->broadcom_cap_exist;
2464 dst->ralink_cap_exist = src->ralink_cap_exist;
2465 dst->atheros_cap_exist = src->atheros_cap_exist;
2466 dst->cisco_cap_exist = src->cisco_cap_exist;
2467 dst->unknown_cap_exist = src->unknown_cap_exist;
2468 memcpy(dst->wpa_ie, src->wpa_ie, src->wpa_ie_len);
2469 dst->wpa_ie_len = src->wpa_ie_len;
2470 memcpy(dst->rsn_ie, src->rsn_ie, src->rsn_ie_len);
2471 dst->rsn_ie_len = src->rsn_ie_len;
2473 dst->last_scanned = jiffies;
2474 /* qos related parameters */
2475 //qos_active = src->qos_data.active;
2476 qos_active = dst->qos_data.active;
2477 //old_param = dst->qos_data.old_param_count;
2478 old_param = dst->qos_data.param_count;
2479 if(dst->flags & NETWORK_HAS_QOS_MASK){
2480 //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
2481 // printk("====>%s(), aifs:%x, %x\n", __FUNCTION__, dst->qos_data.parameters.aifs[0], src->qos_data.parameters.aifs[0]);
2482 // memcpy(&dst->qos_data, &src->qos_data,
2483 // sizeof(struct ieee80211_qos_data));
2486 dst->qos_data.supported = src->qos_data.supported;
2487 dst->qos_data.param_count = src->qos_data.param_count;
2490 if(dst->qos_data.supported == 1) {
2491 dst->QoS_Enable = 1;
2494 ("QoS the network %s is QoS supported\n",
2498 ("QoS the network is QoS supported\n");
2500 dst->qos_data.active = qos_active;
2501 dst->qos_data.old_param_count = old_param;
2503 /* dst->last_associate is not overwritten */
2505 dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
2506 if(src->wmm_param[0].ac_aci_acm_aifsn|| \
2507 src->wmm_param[1].ac_aci_acm_aifsn|| \
2508 src->wmm_param[2].ac_aci_acm_aifsn|| \
2509 src->wmm_param[1].ac_aci_acm_aifsn) {
2510 memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
2512 //dst->QoS_Enable = src->QoS_Enable;
2514 dst->QoS_Enable = 1;//for Rtl8187 simulation
2517 dst->Turbo_Enable = src->Turbo_Enable;
2520 #ifdef ENABLE_DOT11D
2521 dst->CountryIeLen = src->CountryIeLen;
2522 memcpy(dst->CountryIeBuf, src->CountryIeBuf, src->CountryIeLen);
2525 //added by amy for LEAP
2526 dst->bWithAironetIE = src->bWithAironetIE;
2527 dst->bCkipSupported = src->bCkipSupported;
2528 memcpy(dst->CcxRmState,src->CcxRmState,2);
2529 dst->bCcxRmEnable = src->bCcxRmEnable;
2530 dst->MBssidMask = src->MBssidMask;
2531 dst->bMBssidValid = src->bMBssidValid;
2532 memcpy(dst->MBssid,src->MBssid,6);
2533 dst->bWithCcxVerNum = src->bWithCcxVerNum;
2534 dst->BssCcxVerNumber = src->BssCcxVerNumber;
2538 static inline int is_beacon(__le16 fc)
2540 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == IEEE80211_STYPE_BEACON);
2543 static inline void ieee80211_process_probe_response(
2544 struct ieee80211_device *ieee,
2545 struct ieee80211_probe_response *beacon,
2546 struct ieee80211_rx_stats *stats)
2548 struct ieee80211_network network;
2549 struct ieee80211_network *target;
2550 struct ieee80211_network *oldest = NULL;
2551 #ifdef CONFIG_IEEE80211_DEBUG
2552 struct ieee80211_info_element *info_element = &beacon->info_element[0];
2554 unsigned long flags;
2558 memset(&network, 0, sizeof(struct ieee80211_network));
2559 IEEE80211_DEBUG_SCAN(
2560 "'%s' (" MAC_FMT "): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2561 escape_essid(info_element->data, info_element->len),
2562 MAC_ARG(beacon->header.addr3),
2563 (beacon->capability & (1<<0xf)) ? '1' : '0',
2564 (beacon->capability & (1<<0xe)) ? '1' : '0',
2565 (beacon->capability & (1<<0xd)) ? '1' : '0',
2566 (beacon->capability & (1<<0xc)) ? '1' : '0',
2567 (beacon->capability & (1<<0xb)) ? '1' : '0',
2568 (beacon->capability & (1<<0xa)) ? '1' : '0',
2569 (beacon->capability & (1<<0x9)) ? '1' : '0',
2570 (beacon->capability & (1<<0x8)) ? '1' : '0',
2571 (beacon->capability & (1<<0x7)) ? '1' : '0',
2572 (beacon->capability & (1<<0x6)) ? '1' : '0',
2573 (beacon->capability & (1<<0x5)) ? '1' : '0',
2574 (beacon->capability & (1<<0x4)) ? '1' : '0',
2575 (beacon->capability & (1<<0x3)) ? '1' : '0',
2576 (beacon->capability & (1<<0x2)) ? '1' : '0',
2577 (beacon->capability & (1<<0x1)) ? '1' : '0',
2578 (beacon->capability & (1<<0x0)) ? '1' : '0');
2580 if (ieee80211_network_init(ieee, beacon, &network, stats)) {
2581 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT ") via %s.\n",
2582 escape_essid(info_element->data,
2584 MAC_ARG(beacon->header.addr3),
2585 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
2586 IEEE80211_STYPE_PROBE_RESP ?
2587 "PROBE RESPONSE" : "BEACON");
2591 #ifdef ENABLE_DOT11D
2592 // For Asus EeePc request,
2593 // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
2594 // wireless adapter should follow the country code.
2595 // (2) If there is no any country code in beacon,
2596 // then wireless adapter should do active scan from ch1~11 and
2597 // passive scan from ch12~14
2599 if( !IsLegalChannel(ieee, network.channel) )
2601 if(ieee->bGlobalDomain)
2603 if (WLAN_FC_GET_STYPE(beacon->header.frame_ctl) == IEEE80211_STYPE_PROBE_RESP)
2605 // Case 1: Country code
2606 if(IS_COUNTRY_IE_VALID(ieee) )
2608 if( !IsLegalChannel(ieee, network.channel) )
2610 printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network.channel);
2614 // Case 2: No any country code.
2617 // Filter over channel ch12~14
2618 if(network.channel > 11)
2620 printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network.channel);
2627 // Case 1: Country code
2628 if(IS_COUNTRY_IE_VALID(ieee) )
2630 if( !IsLegalChannel(ieee, network.channel) )
2632 printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network.channel);
2636 // Case 2: No any country code.
2639 // Filter over channel ch12~14
2640 if(network.channel > 14)
2642 printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network.channel);
2650 /* The network parsed correctly -- so now we scan our known networks
2651 * to see if we can find it in our list.
2653 * NOTE: This search is definitely not optimized. Once its doing
2654 * the "right thing" we'll optimize it for efficiency if
2657 /* Search for this entry in the list and update it if it is
2660 spin_lock_irqsave(&ieee->lock, flags);
2662 if(is_same_network(&ieee->current_network, &network, ieee)) {
2663 update_network(&ieee->current_network, &network);
2664 if((ieee->current_network.mode == IEEE_N_24G || ieee->current_network.mode == IEEE_G)
2665 && ieee->current_network.berp_info_valid){
2666 if(ieee->current_network.erp_value& ERP_UseProtection)
2667 ieee->current_network.buseprotection = true;
2669 ieee->current_network.buseprotection = false;
2671 if(is_beacon(beacon->header.frame_ctl))
2673 if(ieee->state == IEEE80211_LINKED)
2674 ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
2677 network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & ieee->current_network.flags);
2680 list_for_each_entry(target, &ieee->network_list, list) {
2681 if (is_same_network(target, &network, ieee))
2683 if ((oldest == NULL) ||
2684 (target->last_scanned < oldest->last_scanned))
2688 /* If we didn't find a match, then get a new network slot to initialize
2689 * with this beacon's information */
2690 if (&target->list == &ieee->network_list) {
2691 if (list_empty(&ieee->network_free_list)) {
2692 /* If there are no more slots, expire the oldest */
2693 list_del(&oldest->list);
2695 IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT ") from "
2697 escape_essid(target->ssid,
2699 MAC_ARG(target->bssid));
2701 /* Otherwise just pull from the free list */
2702 target = list_entry(ieee->network_free_list.next,
2703 struct ieee80211_network, list);
2704 list_del(ieee->network_free_list.next);
2708 #ifdef CONFIG_IEEE80211_DEBUG
2709 IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT ") via %s.\n",
2710 escape_essid(network.ssid,
2712 MAC_ARG(network.bssid),
2713 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
2714 IEEE80211_STYPE_PROBE_RESP ?
2715 "PROBE RESPONSE" : "BEACON");
2717 memcpy(target, &network, sizeof(*target));
2718 list_add_tail(&target->list, &ieee->network_list);
2719 if(ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
2720 ieee80211_softmac_new_net(ieee,&network);
2722 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT ") via %s.\n",
2723 escape_essid(target->ssid,
2725 MAC_ARG(target->bssid),
2726 WLAN_FC_GET_STYPE(beacon->header.frame_ctl) ==
2727 IEEE80211_STYPE_PROBE_RESP ?
2728 "PROBE RESPONSE" : "BEACON");
2730 /* we have an entry and we are going to update it. But this entry may
2731 * be already expired. In this case we do the same as we found a new
2732 * net and call the new_net handler
2734 renew = !time_after(target->last_scanned + ieee->scan_age, jiffies);
2735 //YJ,add,080819,for hidden ap
2736 if(is_beacon(beacon->header.frame_ctl) == 0)
2737 network.flags = (~NETWORK_EMPTY_ESSID & network.flags)|(NETWORK_EMPTY_ESSID & target->flags);
2738 //if(strncmp(network.ssid, "linksys-c",9) == 0)
2739 // printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
2740 if(((network.flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \
2741 && (((network.ssid_len > 0) && (strncmp(target->ssid, network.ssid, network.ssid_len)))\
2742 ||((ieee->current_network.ssid_len == network.ssid_len)&&(strncmp(ieee->current_network.ssid, network.ssid, network.ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK))))
2744 //YJ,add,080819,for hidden ap,end
2746 update_network(target, &network);
2747 if(renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
2748 ieee80211_softmac_new_net(ieee,&network);
2751 spin_unlock_irqrestore(&ieee->lock, flags);
2752 if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, &network, ieee)&&\
2753 (ieee->state == IEEE80211_LINKED)) {
2754 if(ieee->handle_beacon != NULL) {
2755 ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network);
2760 void ieee80211_rx_mgt(struct ieee80211_device *ieee,
2761 struct ieee80211_hdr_4addr *header,
2762 struct ieee80211_rx_stats *stats)
2764 if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED &&
2765 ieee->iw_mode == IW_MODE_INFRA &&
2766 ieee->state == IEEE80211_LINKED))
2768 tasklet_schedule(&ieee->ps_task);
2771 if(WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_PROBE_RESP &&
2772 WLAN_FC_GET_STYPE(header->frame_ctl) != IEEE80211_STYPE_BEACON)
2773 ieee->last_rx_ps_time = jiffies;
2775 switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
2777 case IEEE80211_STYPE_BEACON:
2778 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
2779 WLAN_FC_GET_STYPE(header->frame_ctl));
2780 IEEE80211_DEBUG_SCAN("Beacon\n");
2781 ieee80211_process_probe_response(
2782 ieee, (struct ieee80211_probe_response *)header, stats);
2785 case IEEE80211_STYPE_PROBE_RESP:
2786 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
2787 WLAN_FC_GET_STYPE(header->frame_ctl));
2788 IEEE80211_DEBUG_SCAN("Probe response\n");
2789 ieee80211_process_probe_response(
2790 ieee, (struct ieee80211_probe_response *)header, stats);
2796 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
2797 //EXPORT_SYMBOL(ieee80211_rx_mgt);
2798 //EXPORT_SYMBOL(ieee80211_rx);
2800 EXPORT_SYMBOL_NOVERS(ieee80211_rx_mgt);
2801 EXPORT_SYMBOL_NOVERS(ieee80211_rx);