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/errno.h>
26 #include <linux/if_arp.h>
27 #include <linux/in6.h>
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/netdevice.h>
33 #include <linux/pci.h>
34 #include <linux/proc_fs.h>
35 #include <linux/skbuff.h>
36 #include <linux/slab.h>
37 #include <linux/tcp.h>
38 #include <linux/types.h>
39 #include <linux/version.h>
40 #include <linux/wireless.h>
41 #include <linux/etherdevice.h>
42 #include <asm/uaccess.h>
43 #include <linux/ctype.h>
45 #include "ieee80211.h"
49 static inline void ieee80211_monitor_rx(struct ieee80211_device
*ieee
,
51 struct ieee80211_rx_stats
*rx_stats
)
53 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*)skb
->data
;
54 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
57 skb_reset_mac_header(skb
);
59 skb_pull(skb
, ieee80211_get_hdrlen(fc
));
60 skb
->pkt_type
= PACKET_OTHERHOST
;
61 skb
->protocol
= __constant_htons(ETH_P_80211_RAW
);
62 memset(skb
->cb
, 0, sizeof(skb
->cb
));
67 /* Called only as a tasklet (software IRQ) */
68 static struct ieee80211_frag_entry
*
69 ieee80211_frag_cache_find(struct ieee80211_device
*ieee
, unsigned int seq
,
70 unsigned int frag
, u8 tid
,u8
*src
, u8
*dst
)
72 struct ieee80211_frag_entry
*entry
;
75 for (i
= 0; i
< IEEE80211_FRAG_CACHE_LEN
; i
++) {
76 entry
= &ieee
->frag_cache
[tid
][i
];
77 if (entry
->skb
!= NULL
&&
78 time_after(jiffies
, entry
->first_frag_time
+ 2 * HZ
)) {
80 "expiring fragment cache entry "
81 "seq=%u last_frag=%u\n",
82 entry
->seq
, entry
->last_frag
);
83 dev_kfree_skb_any(entry
->skb
);
87 if (entry
->skb
!= NULL
&& entry
->seq
== seq
&&
88 (entry
->last_frag
+ 1 == frag
|| frag
== -1) &&
89 memcmp(entry
->src_addr
, src
, ETH_ALEN
) == 0 &&
90 memcmp(entry
->dst_addr
, dst
, ETH_ALEN
) == 0)
97 /* Called only as a tasklet (software IRQ) */
98 static struct sk_buff
*
99 ieee80211_frag_cache_get(struct ieee80211_device
*ieee
,
100 struct ieee80211_hdr_4addr
*hdr
)
102 struct sk_buff
*skb
= NULL
;
103 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
104 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
105 unsigned int frag
= WLAN_GET_SEQ_FRAG(sc
);
106 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
107 struct ieee80211_frag_entry
*entry
;
108 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
109 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
112 if (((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
113 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)hdr
;
114 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
117 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
118 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)hdr
;
119 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
127 /* Reserve enough space to fit maximum frame length */
128 skb
= dev_alloc_skb(ieee
->dev
->mtu
+
129 sizeof(struct ieee80211_hdr_4addr
) +
134 (IEEE80211_QOS_HAS_SEQ(fc
)?2:0) /* QOS Control */);
138 entry
= &ieee
->frag_cache
[tid
][ieee
->frag_next_idx
[tid
]];
139 ieee
->frag_next_idx
[tid
]++;
140 if (ieee
->frag_next_idx
[tid
] >= IEEE80211_FRAG_CACHE_LEN
)
141 ieee
->frag_next_idx
[tid
] = 0;
143 if (entry
->skb
!= NULL
)
144 dev_kfree_skb_any(entry
->skb
);
146 entry
->first_frag_time
= jiffies
;
148 entry
->last_frag
= frag
;
150 memcpy(entry
->src_addr
, hdr
->addr2
, ETH_ALEN
);
151 memcpy(entry
->dst_addr
, hdr
->addr1
, ETH_ALEN
);
153 /* received a fragment of a frame for which the head fragment
154 * should have already been received */
155 entry
= ieee80211_frag_cache_find(ieee
, seq
, frag
, tid
,hdr
->addr2
,
158 entry
->last_frag
= frag
;
167 /* Called only as a tasklet (software IRQ) */
168 static int ieee80211_frag_cache_invalidate(struct ieee80211_device
*ieee
,
169 struct ieee80211_hdr_4addr
*hdr
)
171 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
172 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
173 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
174 struct ieee80211_frag_entry
*entry
;
175 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
176 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
179 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
180 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)hdr
;
181 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
184 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
185 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)hdr
;
186 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
193 entry
= ieee80211_frag_cache_find(ieee
, seq
, -1, tid
,hdr
->addr2
,
197 IEEE80211_DEBUG_FRAG(
198 "could not invalidate fragment cache "
199 "entry (seq=%u)\n", seq
);
209 /* ieee80211_rx_frame_mgtmt
211 * Responsible for handling management control frames
213 * Called by ieee80211_rx */
215 ieee80211_rx_frame_mgmt(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
216 struct ieee80211_rx_stats
*rx_stats
, u16 type
,
219 /* On the struct stats definition there is written that
220 * this is not mandatory.... but seems that the probe
221 * response parser uses it
223 struct ieee80211_hdr_3addr
* hdr
= (struct ieee80211_hdr_3addr
*)skb
->data
;
225 rx_stats
->len
= skb
->len
;
226 ieee80211_rx_mgt(ieee
,(struct ieee80211_hdr_4addr
*)skb
->data
,rx_stats
);
227 if ((memcmp(hdr
->addr1
, ieee
->dev
->dev_addr
, ETH_ALEN
)))//use ADDR1 to perform address matching for Management frames
229 dev_kfree_skb_any(skb
);
233 ieee80211_rx_frame_softmac(ieee
, skb
, rx_stats
, type
, stype
);
235 dev_kfree_skb_any(skb
);
240 if (ieee
->iw_mode
== IW_MODE_MASTER
) {
241 printk(KERN_DEBUG
"%s: Master mode not yet suppported.\n",
246 if (ieee
->hostapd
&& type
== IEEE80211_TYPE_MGMT
) {
247 if (stype
== WLAN_FC_STYPE_BEACON
&&
248 ieee
->iw_mode
== IW_MODE_MASTER
) {
249 struct sk_buff
*skb2
;
250 /* Process beacon frames also in kernel driver to
251 * update STA(AP) table statistics */
252 skb2
= skb_clone(skb
, GFP_ATOMIC
);
254 hostap_rx(skb2
->dev
, skb2
, rx_stats
);
257 /* send management frames to the user space daemon for
259 ieee
->apdevstats
.rx_packets
++;
260 ieee
->apdevstats
.rx_bytes
+= skb
->len
;
261 prism2_rx_80211(ieee
->apdev
, skb
, rx_stats
, PRISM2_RX_MGMT
);
265 if (ieee
->iw_mode
== IW_MODE_MASTER
) {
266 if (type
!= WLAN_FC_TYPE_MGMT
&& type
!= WLAN_FC_TYPE_CTRL
) {
267 printk(KERN_DEBUG
"%s: unknown management frame "
268 "(type=0x%02x, stype=0x%02x) dropped\n",
269 skb
->dev
->name
, type
, stype
);
273 hostap_rx(skb
->dev
, skb
, rx_stats
);
277 printk(KERN_DEBUG
"%s: hostap_rx_frame_mgmt: management frame "
278 "received in non-Host AP mode\n", skb
->dev
->name
);
285 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
286 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
287 static unsigned char rfc1042_header
[] =
288 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
289 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
290 static unsigned char bridge_tunnel_header
[] =
291 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
292 /* No encapsulation header if EtherType < 0x600 (=length) */
294 /* Called by ieee80211_rx_frame_decrypt */
295 static int ieee80211_is_eapol_frame(struct ieee80211_device
*ieee
,
296 struct sk_buff
*skb
, size_t hdrlen
)
298 struct net_device
*dev
= ieee
->dev
;
300 struct ieee80211_hdr_4addr
*hdr
;
306 if (ieee
->hwsec_active
)
308 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
309 tcb_desc
->bHwSec
= 1;
311 if(ieee
->need_sw_enc
)
312 tcb_desc
->bHwSec
= 0;
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
+ hdrlen
;
336 ethertype
= (pos
[6] << 8) | pos
[7];
337 if (ethertype
== ETH_P_PAE
)
343 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
345 ieee80211_rx_frame_decrypt(struct ieee80211_device
* ieee
, struct sk_buff
*skb
,
346 struct ieee80211_crypt_data
*crypt
)
348 struct ieee80211_hdr_4addr
*hdr
;
351 if (crypt
== NULL
|| crypt
->ops
->decrypt_mpdu
== NULL
)
354 if (ieee
->hwsec_active
)
356 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
357 tcb_desc
->bHwSec
= 1;
360 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
361 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
363 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
364 if (ieee
->tkip_countermeasures
&&
365 strcmp(crypt
->ops
->name
, "TKIP") == 0) {
366 if (net_ratelimit()) {
367 printk(KERN_DEBUG
"%s: TKIP countermeasures: dropped "
368 "received packet from %pM\n",
369 ieee
->dev
->name
, hdr
->addr2
);
375 atomic_inc(&crypt
->refcnt
);
376 res
= crypt
->ops
->decrypt_mpdu(skb
, hdrlen
, crypt
->priv
);
377 atomic_dec(&crypt
->refcnt
);
379 IEEE80211_DEBUG_DROP(
380 "decryption failed (SA=%pM"
381 ") res=%d\n", hdr
->addr2
, res
);
383 IEEE80211_DEBUG_DROP("Decryption failed ICV "
384 "mismatch (key %d)\n",
385 skb
->data
[hdrlen
+ 3] >> 6);
386 ieee
->ieee_stats
.rx_discards_undecryptable
++;
394 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
396 ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device
* ieee
, struct sk_buff
*skb
,
397 int keyidx
, struct ieee80211_crypt_data
*crypt
)
399 struct ieee80211_hdr_4addr
*hdr
;
402 if (crypt
== NULL
|| crypt
->ops
->decrypt_msdu
== NULL
)
404 if (ieee
->hwsec_active
)
406 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
407 tcb_desc
->bHwSec
= 1;
409 if(ieee
->need_sw_enc
)
410 tcb_desc
->bHwSec
= 0;
414 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
415 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
417 atomic_inc(&crypt
->refcnt
);
418 res
= crypt
->ops
->decrypt_msdu(skb
, keyidx
, hdrlen
, crypt
->priv
);
419 atomic_dec(&crypt
->refcnt
);
421 printk(KERN_DEBUG
"%s: MSDU decryption/MIC verification failed"
422 " (SA=%pM keyidx=%d)\n",
423 ieee
->dev
->name
, hdr
->addr2
, keyidx
);
431 /* this function is stolen from ipw2200 driver*/
432 #define IEEE_PACKET_RETRY_TIME (5*HZ)
433 static int is_duplicate_packet(struct ieee80211_device
*ieee
,
434 struct ieee80211_hdr_4addr
*header
)
436 u16 fc
= le16_to_cpu(header
->frame_ctl
);
437 u16 sc
= le16_to_cpu(header
->seq_ctl
);
438 u16 seq
= WLAN_GET_SEQ_SEQ(sc
);
439 u16 frag
= WLAN_GET_SEQ_FRAG(sc
);
440 u16
*last_seq
, *last_frag
;
441 unsigned long *last_time
;
442 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
443 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
448 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
449 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)header
;
450 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
453 } else if(IEEE80211_QOS_HAS_SEQ(fc
)) { //QoS
454 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)header
;
455 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
462 switch (ieee
->iw_mode
) {
466 struct ieee_ibss_seq
*entry
= NULL
;
467 u8
*mac
= header
->addr2
;
468 int index
= mac
[5] % IEEE_IBSS_MAC_HASH_SIZE
;
470 list_for_each(p
, &ieee
->ibss_mac_hash
[index
]) {
471 entry
= list_entry(p
, struct ieee_ibss_seq
, list
);
472 if (!memcmp(entry
->mac
, mac
, ETH_ALEN
))
476 if (p
== &ieee
->ibss_mac_hash
[index
]) {
477 entry
= kmalloc(sizeof(struct ieee_ibss_seq
), GFP_ATOMIC
);
479 printk(KERN_WARNING
"Cannot malloc new mac entry\n");
482 memcpy(entry
->mac
, mac
, ETH_ALEN
);
483 entry
->seq_num
[tid
] = seq
;
484 entry
->frag_num
[tid
] = frag
;
485 entry
->packet_time
[tid
] = jiffies
;
486 list_add(&entry
->list
, &ieee
->ibss_mac_hash
[index
]);
489 last_seq
= &entry
->seq_num
[tid
];
490 last_frag
= &entry
->frag_num
[tid
];
491 last_time
= &entry
->packet_time
[tid
];
496 last_seq
= &ieee
->last_rxseq_num
[tid
];
497 last_frag
= &ieee
->last_rxfrag_num
[tid
];
498 last_time
= &ieee
->last_packet_time
[tid
];
505 if ((*last_seq
== seq
) &&
506 time_after(*last_time
+ IEEE_PACKET_RETRY_TIME
, jiffies
)) {
507 if (*last_frag
== frag
){
511 if (*last_frag
+ 1 != frag
)
512 /* out-of-order fragment */
518 *last_time
= jiffies
;
527 PRX_REORDER_ENTRY pReorderEntry
530 struct list_head
*pList
= &pTS
->RxPendingPktList
;
532 while(pList
->next
!= &pTS
->RxPendingPktList
)
534 if( SN_LESS(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
538 else if( SN_EQUAL(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
548 pReorderEntry
->List
.next
= pList
->next
;
549 pReorderEntry
->List
.next
->prev
= &pReorderEntry
->List
;
550 pReorderEntry
->List
.prev
= pList
;
551 pList
->next
= &pReorderEntry
->List
;
556 void ieee80211_indicate_packets(struct ieee80211_device
*ieee
, struct ieee80211_rxb
** prxbIndicateArray
,u8 index
)
561 for(j
= 0; j
<index
; j
++)
563 //added by amy for reorder
564 struct ieee80211_rxb
* prxb
= prxbIndicateArray
[j
];
565 for(i
= 0; i
<prxb
->nr_subframes
; i
++) {
566 struct sk_buff
*sub_skb
= prxb
->subframes
[i
];
568 /* convert hdr + possible LLC headers into Ethernet header */
569 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
570 if (sub_skb
->len
>= 8 &&
571 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
572 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
573 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
574 /* remove RFC1042 or Bridge-Tunnel encapsulation and
575 * replace EtherType */
576 skb_pull(sub_skb
, SNAP_SIZE
);
577 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->src
, ETH_ALEN
);
578 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->dst
, ETH_ALEN
);
581 /* Leave Ethernet header part of hdr and full payload */
582 len
= htons(sub_skb
->len
);
583 memcpy(skb_push(sub_skb
, 2), &len
, 2);
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 /* Indicat the packets to upper layer */
590 sub_skb
->protocol
= eth_type_trans(sub_skb
, ieee
->dev
);
591 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
592 sub_skb
->dev
= ieee
->dev
;
593 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
594 ieee
->last_rx_ps_time
= jiffies
;
604 void RxReorderIndicatePacket( struct ieee80211_device
*ieee
,
605 struct ieee80211_rxb
* prxb
,
609 PRT_HIGH_THROUGHPUT pHTInfo
= ieee
->pHTInfo
;
610 PRX_REORDER_ENTRY pReorderEntry
= NULL
;
611 struct ieee80211_rxb
* prxbIndicateArray
[REORDER_WIN_SIZE
];
612 u8 WinSize
= pHTInfo
->RxReorderWinSize
;
613 u16 WinEnd
= (pTS
->RxIndicateSeq
+ WinSize
-1)%4096;
615 bool bMatchWinStart
= false, bPktInBuf
= false;
616 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__
,SeqNum
,pTS
->RxIndicateSeq
,WinSize
);
618 /* Rx Reorder initialize condition.*/
619 if(pTS
->RxIndicateSeq
== 0xffff) {
620 pTS
->RxIndicateSeq
= SeqNum
;
623 /* Drop out the packet which SeqNum is smaller than WinStart */
624 if(SN_LESS(SeqNum
, pTS
->RxIndicateSeq
)) {
625 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
626 pTS
->RxIndicateSeq
, SeqNum
);
627 pHTInfo
->RxReorderDropCounter
++;
630 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
631 dev_kfree_skb(prxb
->subframes
[i
]);
640 * Sliding window manipulation. Conditions includes:
641 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
642 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
644 if(SN_EQUAL(SeqNum
, pTS
->RxIndicateSeq
)) {
645 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
646 bMatchWinStart
= true;
647 } else if(SN_LESS(WinEnd
, SeqNum
)) {
648 if(SeqNum
>= (WinSize
- 1)) {
649 pTS
->RxIndicateSeq
= SeqNum
+ 1 -WinSize
;
651 pTS
->RxIndicateSeq
= 4095 - (WinSize
- (SeqNum
+1)) + 1;
653 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
657 * Indication process.
658 * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
659 * with the SeqNum smaller than latest WinStart and buffer other packets.
661 /* For Rx Reorder condition:
662 * 1. All packets with SeqNum smaller than WinStart => Indicate
663 * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
666 /* Current packet is going to be indicated.*/
667 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
668 pTS
->RxIndicateSeq
, SeqNum
);
669 prxbIndicateArray
[0] = prxb
;
672 /* Current packet is going to be inserted into pending list.*/
673 if(!list_empty(&ieee
->RxReorder_Unused_List
)) {
674 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(ieee
->RxReorder_Unused_List
.next
,RX_REORDER_ENTRY
,List
);
675 list_del_init(&pReorderEntry
->List
);
677 /* Make a reorder entry and insert into a the packet list.*/
678 pReorderEntry
->SeqNum
= SeqNum
;
679 pReorderEntry
->prxb
= prxb
;
681 if(!AddReorderEntry(pTS
, pReorderEntry
)) {
682 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
683 __FUNCTION__
, pTS
->RxIndicateSeq
, SeqNum
);
684 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
687 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
688 dev_kfree_skb(prxb
->subframes
[i
]);
694 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,
695 "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
700 * Packets are dropped if there is not enough reorder entries.
701 * This part shall be modified!! We can just indicate all the
702 * packets in buffer and get reorder entries.
704 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
707 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
708 dev_kfree_skb(prxb
->subframes
[i
]);
716 /* Check if there is any packet need indicate.*/
717 while(!list_empty(&pTS
->RxPendingPktList
)) {
718 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): start RREORDER indicate\n",__FUNCTION__
);
720 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(pTS
->RxPendingPktList
.prev
,RX_REORDER_ENTRY
,List
);
721 if( SN_LESS(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
) ||
722 SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
724 /* This protect buffer from overflow. */
725 if(index
>= REORDER_WIN_SIZE
) {
726 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Buffer overflow!! \n");
731 list_del_init(&pReorderEntry
->List
);
733 if(SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
734 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
736 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
737 prxbIndicateArray
[index
] = pReorderEntry
->prxb
;
740 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
748 /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
750 // Cancel previous pending timer.
751 if (timer_pending(&pTS
->RxPktPendingTimer
))
752 del_timer_sync(&pTS
->RxPktPendingTimer
);
753 pTS
->RxTimeoutIndicateSeq
= 0xffff;
756 if(index
>REORDER_WIN_SIZE
){
757 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
760 ieee80211_indicate_packets(ieee
, prxbIndicateArray
, index
);
764 if(bPktInBuf
&& pTS
->RxTimeoutIndicateSeq
==0xffff) {
765 // Set new pending timer.
766 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): SET rx timeout timer\n", __FUNCTION__
);
767 pTS
->RxTimeoutIndicateSeq
= pTS
->RxIndicateSeq
;
769 mod_timer(&pTS
->RxPktPendingTimer
, jiffies
+ MSECS(pHTInfo
->RxReorderPendingTime
));
773 u8
parse_subframe(struct ieee80211_device
* ieee
,struct sk_buff
*skb
,
774 struct ieee80211_rx_stats
*rx_stats
,
775 struct ieee80211_rxb
*rxb
,u8
* src
,u8
* dst
)
777 struct ieee80211_hdr_3addr
*hdr
= (struct ieee80211_hdr_3addr
* )skb
->data
;
778 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
780 u16 LLCOffset
= sizeof(struct ieee80211_hdr_3addr
);
782 bool bIsAggregateFrame
= false;
783 u16 nSubframe_Length
;
784 u8 nPadding_Length
= 0;
787 struct sk_buff
*sub_skb
;
789 /* just for debug purpose */
790 SeqNum
= WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr
->seq_ctl
));
792 if((IEEE80211_QOS_HAS_SEQ(fc
))&&\
793 (((frameqos
*)(skb
->data
+ IEEE80211_3ADDR_LEN
))->field
.reserved
)) {
794 bIsAggregateFrame
= true;
797 if(IEEE80211_QOS_HAS_SEQ(fc
)) {
801 if(rx_stats
->bContainHTC
) {
802 LLCOffset
+= sHTCLng
;
804 // Null packet, don't indicate it to upper layer
805 ChkLength
= LLCOffset
;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
807 if( skb
->len
<= ChkLength
) {
811 skb_pull(skb
, LLCOffset
);
812 ieee
->bIsAggregateFrame
= bIsAggregateFrame
;//added by amy for Leisure PS
814 if(!bIsAggregateFrame
) {
815 rxb
->nr_subframes
= 1;
817 rxb
->subframes
[0] = skb
;
819 rxb
->subframes
[0] = skb_copy(skb
, GFP_ATOMIC
);
822 memcpy(rxb
->src
,src
,ETH_ALEN
);
823 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
824 //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
827 rxb
->nr_subframes
= 0;
828 memcpy(rxb
->src
,src
,ETH_ALEN
);
829 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
830 while(skb
->len
> ETHERNET_HEADER_SIZE
) {
831 /* Offset 12 denote 2 mac address */
832 nSubframe_Length
= *((u16
*)(skb
->data
+ 12));
833 //==m==>change the length order
834 nSubframe_Length
= (nSubframe_Length
>>8) + (nSubframe_Length
<<8);
836 if(skb
->len
<(ETHERNET_HEADER_SIZE
+ nSubframe_Length
)) {
837 printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
838 __FUNCTION__
,rxb
->nr_subframes
);
839 printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__
, nSubframe_Length
);
840 printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb
->len
,nSubframe_Length
);
841 printk("The Packet SeqNum is %d\n",SeqNum
);
845 /* move the data point to data content */
846 skb_pull(skb
, ETHERNET_HEADER_SIZE
);
849 sub_skb
= skb_clone(skb
, GFP_ATOMIC
);
850 sub_skb
->len
= nSubframe_Length
;
851 sub_skb
->tail
= sub_skb
->data
+ nSubframe_Length
;
853 /* Allocate new skb for releasing to upper layer */
854 sub_skb
= dev_alloc_skb(nSubframe_Length
+ 12);
855 skb_reserve(sub_skb
, 12);
856 data_ptr
= (u8
*)skb_put(sub_skb
, nSubframe_Length
);
857 memcpy(data_ptr
,skb
->data
,nSubframe_Length
);
859 rxb
->subframes
[rxb
->nr_subframes
++] = sub_skb
;
860 if(rxb
->nr_subframes
>= MAX_SUBFRAME_COUNT
) {
861 IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
864 skb_pull(skb
,nSubframe_Length
);
867 nPadding_Length
= 4 - ((nSubframe_Length
+ ETHERNET_HEADER_SIZE
) % 4);
868 if(nPadding_Length
== 4) {
872 if(skb
->len
< nPadding_Length
) {
876 skb_pull(skb
,nPadding_Length
);
882 return rxb
->nr_subframes
;
886 /* All received frames are sent to this function. @skb contains the frame in
887 * IEEE 802.11 format, i.e., in the format it was sent over air.
888 * This function is called only as a tasklet (software IRQ). */
889 int ieee80211_rtl_rx(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
890 struct ieee80211_rx_stats
*rx_stats
)
892 struct net_device
*dev
= ieee
->dev
;
893 struct ieee80211_hdr_4addr
*hdr
;
896 u16 fc
, type
, stype
, sc
;
897 struct net_device_stats
*stats
;
901 //added by amy for reorder
904 PRX_TS_RECORD pTS
= NULL
;
905 bool unicast_packet
= false;
906 //added by amy for reorder
908 struct net_device
*wds
= NULL
;
909 struct sk_buff
*skb2
= NULL
;
910 struct net_device
*wds
= NULL
;
911 int frame_authorized
= 0;
912 int from_assoc_ap
= 0;
918 struct ieee80211_crypt_data
*crypt
= NULL
;
922 struct ieee80211_rxb
* rxb
= NULL
;
923 // cheat the the hdr type
924 hdr
= (struct ieee80211_hdr_4addr
*)skb
->data
;
925 stats
= &ieee
->stats
;
928 printk(KERN_INFO
"%s: SKB length < 10\n",
933 fc
= le16_to_cpu(hdr
->frame_ctl
);
934 type
= WLAN_FC_GET_TYPE(fc
);
935 stype
= WLAN_FC_GET_STYPE(fc
);
936 sc
= le16_to_cpu(hdr
->seq_ctl
);
938 frag
= WLAN_GET_SEQ_FRAG(sc
);
939 hdrlen
= ieee80211_get_hdrlen(fc
);
941 if(HTCCheck(ieee
, skb
->data
))
944 printk("find HTCControl\n");
946 rx_stats
->bContainHTC
= 1;
950 #if WIRELESS_EXT > 15
951 /* Put this code here so that we avoid duplicating it in all
952 * Rx paths. - Jean II */
953 #ifdef IW_WIRELESS_SPY /* defined in iw_handler.h */
954 /* If spy monitoring on */
955 if (iface
->spy_data
.spy_number
> 0) {
956 struct iw_quality wstats
;
957 wstats
.level
= rx_stats
->rssi
;
958 wstats
.noise
= rx_stats
->noise
;
959 wstats
.updated
= 6; /* No qual value */
960 /* Update spy records */
961 wireless_spy_update(dev
, hdr
->addr2
, &wstats
);
963 #endif /* IW_WIRELESS_SPY */
964 #endif /* WIRELESS_EXT > 15 */
965 hostap_update_rx_stats(local
->ap
, hdr
, rx_stats
);
968 #if WIRELESS_EXT > 15
969 if (ieee
->iw_mode
== IW_MODE_MONITOR
) {
970 ieee80211_monitor_rx(ieee
, skb
, rx_stats
);
972 stats
->rx_bytes
+= skb
->len
;
976 if (ieee
->host_decrypt
) {
978 if (skb
->len
>= hdrlen
+ 3)
979 idx
= skb
->data
[hdrlen
+ 3] >> 6;
980 crypt
= ieee
->crypt
[idx
];
984 /* Use station specific key to override default keys if the
985 * receiver address is a unicast address ("individual RA"). If
986 * bcrx_sta_key parameter is set, station specific key is used
987 * even with broad/multicast targets (this is against IEEE
988 * 802.11, but makes it easier to use different keys with
989 * stations that do not support WEP key mapping). */
991 if (!(hdr
->addr1
[0] & 0x01) || local
->bcrx_sta_key
)
992 (void) hostap_handle_sta_crypto(local
, hdr
, &crypt
,
996 /* allow NULL decrypt to indicate an station specific override
997 * for default encryption */
998 if (crypt
&& (crypt
->ops
== NULL
||
999 crypt
->ops
->decrypt_mpdu
== NULL
))
1002 if (!crypt
&& (fc
& IEEE80211_FCTL_WEP
)) {
1003 /* This seems to be triggered by some (multicast?)
1004 * frames from other than current BSS, so just drop the
1005 * frames silently instead of filling system log with
1007 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
1010 ieee
->ieee_stats
.rx_discards_undecryptable
++;
1015 if (skb
->len
< IEEE80211_DATA_HDR3_LEN
)
1018 // if QoS enabled, should check the sequence for each of the AC
1019 if( (ieee
->pHTInfo
->bCurRxReorderEnable
== false) || !ieee
->current_network
.qos_data
.active
|| !IsDataFrame(skb
->data
) || IsLegacyDataFrame(skb
->data
)){
1020 if (is_duplicate_packet(ieee
, hdr
))
1026 PRX_TS_RECORD pRxTS
= NULL
;
1030 (PTS_COMMON_INFO
*) &pRxTS
,
1032 (u8
)Frame_QoSTID((u8
*)(skb
->data
)),
1037 if( (fc
& (1<<11)) &&
1038 (frag
== pRxTS
->RxLastFragNum
) &&
1039 (WLAN_GET_SEQ_SEQ(sc
) == pRxTS
->RxLastSeqNum
) )
1045 pRxTS
->RxLastFragNum
= frag
;
1046 pRxTS
->RxLastSeqNum
= WLAN_GET_SEQ_SEQ(sc
);
1051 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "%s(): No TS!! Skip the check!!\n",__FUNCTION__
);
1056 if (type
== IEEE80211_FTYPE_MGMT
) {
1058 if (ieee80211_rx_frame_mgmt(ieee
, skb
, rx_stats
, type
, stype
))
1064 /* Data frame - extract src/dst addresses */
1065 switch (fc
& (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
1066 case IEEE80211_FCTL_FROMDS
:
1067 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1068 memcpy(src
, hdr
->addr3
, ETH_ALEN
);
1069 memcpy(bssid
, hdr
->addr2
, ETH_ALEN
);
1071 case IEEE80211_FCTL_TODS
:
1072 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1073 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1074 memcpy(bssid
, hdr
->addr1
, ETH_ALEN
);
1076 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
1077 if (skb
->len
< IEEE80211_DATA_HDR4_LEN
)
1079 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1080 memcpy(src
, hdr
->addr4
, ETH_ALEN
);
1081 memcpy(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
);
1084 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1085 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1086 memcpy(bssid
, hdr
->addr3
, ETH_ALEN
);
1091 if (hostap_rx_frame_wds(ieee
, hdr
, fc
, &wds
))
1094 skb
->dev
= dev
= wds
;
1095 stats
= hostap_get_stats(dev
);
1098 if (ieee
->iw_mode
== IW_MODE_MASTER
&& !wds
&&
1099 (fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) == IEEE80211_FCTL_FROMDS
&&
1101 memcmp(hdr
->addr2
, ieee
->assoc_ap_addr
, ETH_ALEN
) == 0) {
1102 /* Frame from BSSID of the AP for which we are a client */
1103 skb
->dev
= dev
= ieee
->stadev
;
1104 stats
= hostap_get_stats(dev
);
1109 dev
->last_rx
= jiffies
;
1112 if ((ieee
->iw_mode
== IW_MODE_MASTER
||
1113 ieee
->iw_mode
== IW_MODE_REPEAT
) &&
1115 switch (hostap_handle_sta_rx(ieee
, dev
, skb
, rx_stats
,
1117 case AP_RX_CONTINUE_NOT_AUTHORIZED
:
1118 frame_authorized
= 0;
1120 case AP_RX_CONTINUE
:
1121 frame_authorized
= 1;
1130 /* Nullfunc frames may have PS-bit set, so they must be passed to
1131 * hostap_handle_sta_rx() before being dropped here. */
1132 if (stype
!= IEEE80211_STYPE_DATA
&&
1133 stype
!= IEEE80211_STYPE_DATA_CFACK
&&
1134 stype
!= IEEE80211_STYPE_DATA_CFPOLL
&&
1135 stype
!= IEEE80211_STYPE_DATA_CFACKPOLL
&&
1136 stype
!= IEEE80211_STYPE_QOS_DATA
//add by David,2006.8.4
1138 if (stype
!= IEEE80211_STYPE_NULLFUNC
)
1139 IEEE80211_DEBUG_DROP(
1140 "RX: dropped data frame "
1141 "with no data (type=0x%02x, "
1142 "subtype=0x%02x, len=%d)\n",
1143 type
, stype
, skb
->len
);
1146 if (memcmp(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
))
1150 if ((ieee
->iw_mode
== IW_MODE_INFRA
) && (ieee
->sta_sleep
== 1)
1151 && (ieee
->polling
)) {
1152 if (WLAN_FC_MORE_DATA(fc
)) {
1153 /* more data bit is set, let's request a new frame from the AP */
1154 ieee80211_sta_ps_send_pspoll_frame(ieee
);
1156 ieee
->polling
= false;
1161 ieee
->need_sw_enc
= 0;
1163 if((!rx_stats
->Decrypted
)){
1164 ieee
->need_sw_enc
= 1;
1167 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
1169 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1170 (keyidx
= ieee80211_rx_frame_decrypt(ieee
, skb
, crypt
)) < 0)
1172 printk("decrypt frame error\n");
1177 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1179 /* skb: hdr + (possibly fragmented) plaintext payload */
1180 // PR: FIXME: hostap has additional conditions in the "if" below:
1181 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1182 if ((frag
!= 0 || (fc
& IEEE80211_FCTL_MOREFRAGS
))) {
1184 struct sk_buff
*frag_skb
= ieee80211_frag_cache_get(ieee
, hdr
);
1185 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag
);
1188 IEEE80211_DEBUG(IEEE80211_DL_RX
| IEEE80211_DL_FRAG
,
1189 "Rx cannot get skb from fragment "
1190 "cache (morefrag=%d seq=%u frag=%u)\n",
1191 (fc
& IEEE80211_FCTL_MOREFRAGS
) != 0,
1192 WLAN_GET_SEQ_SEQ(sc
), frag
);
1199 if (frag_skb
->tail
+ flen
> frag_skb
->end
) {
1200 printk(KERN_WARNING
"%s: host decrypted and "
1201 "reassembled frame did not fit skb\n",
1203 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1208 /* copy first fragment (including full headers) into
1209 * beginning of the fragment cache skb */
1210 memcpy(skb_put(frag_skb
, flen
), skb
->data
, flen
);
1212 /* append frame payload to the end of the fragment
1214 memcpy(skb_put(frag_skb
, flen
), skb
->data
+ hdrlen
,
1217 dev_kfree_skb_any(skb
);
1220 if (fc
& IEEE80211_FCTL_MOREFRAGS
) {
1221 /* more fragments expected - leave the skb in fragment
1222 * cache for now; it will be delivered to upper layers
1223 * after all fragments have been received */
1227 /* this was the last fragment and the frame will be
1228 * delivered, so remove skb from fragment cache */
1230 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1231 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1234 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1235 * encrypted/authenticated */
1236 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1237 ieee80211_rx_frame_decrypt_msdu(ieee
, skb
, keyidx
, crypt
))
1239 printk("==>decrypt msdu error\n");
1243 //added by amy for AP roaming
1244 ieee
->LinkDetectInfo
.NumRecvDataInPeriod
++;
1245 ieee
->LinkDetectInfo
.NumRxOkInPeriod
++;
1247 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1248 if((!is_multicast_ether_addr(hdr
->addr1
)) && (!is_broadcast_ether_addr(hdr
->addr1
)))
1249 unicast_packet
= true;
1251 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
) {
1252 if (/*ieee->ieee802_1x &&*/
1253 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1255 #ifdef CONFIG_IEEE80211_DEBUG
1256 /* pass unencrypted EAPOL frames even if encryption is
1258 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1260 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1261 eap_get_type(eap
->type
));
1264 IEEE80211_DEBUG_DROP(
1265 "encryption configured, but RX "
1266 "frame not encrypted (SA=%pM)\n",
1272 #ifdef CONFIG_IEEE80211_DEBUG
1273 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) &&
1274 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1275 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1277 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1278 eap_get_type(eap
->type
));
1282 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
&&
1283 !ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1284 IEEE80211_DEBUG_DROP(
1285 "dropped unencrypted RX data "
1287 " (drop_unencrypted=1)\n",
1291 //added by amy for reorder
1292 if(ieee
->current_network
.qos_data
.active
&& IsQoSDataFrame(skb
->data
)
1293 && !is_multicast_ether_addr(hdr
->addr1
) && !is_broadcast_ether_addr(hdr
->addr1
))
1295 TID
= Frame_QoSTID(skb
->data
);
1296 SeqNum
= WLAN_GET_SEQ_SEQ(sc
);
1297 GetTs(ieee
,(PTS_COMMON_INFO
*) &pTS
,hdr
->addr2
,TID
,RX_DIR
,true);
1298 if(TID
!=0 && TID
!=3)
1300 ieee
->bis_any_nonbepkts
= true;
1304 //added by amy for reorder
1305 /* skb: hdr + (possible reassembled) full plaintext payload */
1306 payload
= skb
->data
+ hdrlen
;
1308 rxb
= kmalloc(sizeof(struct ieee80211_rxb
), GFP_ATOMIC
);
1311 IEEE80211_DEBUG(IEEE80211_DL_ERR
,"%s(): kmalloc rxb error\n",__FUNCTION__
);
1314 /* to parse amsdu packets */
1315 /* qos data packets & reserved bit is 1 */
1316 if(parse_subframe(ieee
, skb
,rx_stats
,rxb
,src
,dst
) == 0) {
1317 /* only to free rxb, and not submit the packets to upper layer */
1318 for(i
=0; i
< rxb
->nr_subframes
; i
++) {
1319 dev_kfree_skb(rxb
->subframes
[i
]);
1329 if (type
== IEEE80211_FTYPE_DATA
)
1332 if(ieee
->bIsAggregateFrame
)
1333 ieee
->LinkDetectInfo
.NumRxUnicastOkInPeriod
+=rxb
->nr_subframes
;
1335 ieee
->LinkDetectInfo
.NumRxUnicastOkInPeriod
++;
1337 // 2009.03.03 Leave DC mode immediately when detect high traffic
1338 if((ieee
->state
== IEEE80211_LINKED
) /*&& !MgntInitAdapterInProgress(pMgntInfo)*/)
1340 if( ((ieee
->LinkDetectInfo
.NumRxUnicastOkInPeriod
+ieee
->LinkDetectInfo
.NumTxOkInPeriod
) > 8 ) ||
1341 (ieee
->LinkDetectInfo
.NumRxUnicastOkInPeriod
> 2) )
1343 if(ieee
->LeisurePSLeave
)
1344 ieee
->LeisurePSLeave(ieee
);
1351 ieee
->last_rx_ps_time
= jiffies
;
1352 //added by amy for reorder
1353 if(ieee
->pHTInfo
->bCurRxReorderEnable
== false ||pTS
== NULL
){
1354 //added by amy for reorder
1355 for(i
= 0; i
<rxb
->nr_subframes
; i
++) {
1356 struct sk_buff
*sub_skb
= rxb
->subframes
[i
];
1359 /* convert hdr + possible LLC headers into Ethernet header */
1360 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
1361 if (sub_skb
->len
>= 8 &&
1362 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
1363 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
1364 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
1365 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1366 * replace EtherType */
1367 skb_pull(sub_skb
, SNAP_SIZE
);
1368 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1369 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1372 /* Leave Ethernet header part of hdr and full payload */
1373 len
= htons(sub_skb
->len
);
1374 memcpy(skb_push(sub_skb
, 2), &len
, 2);
1375 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1376 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1379 stats
->rx_packets
++;
1380 stats
->rx_bytes
+= sub_skb
->len
;
1381 if(is_multicast_ether_addr(dst
)) {
1385 /* Indicat the packets to upper layer */
1386 sub_skb
->protocol
= eth_type_trans(sub_skb
, dev
);
1387 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
1389 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
1399 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__
);
1400 RxReorderIndicatePacket(ieee
, rxb
, pTS
, SeqNum
);
1409 hostap_handle_sta_release(sta
);
1416 stats
->rx_dropped
++;
1418 /* Returning 0 indicates to caller that we have not handled the SKB--
1419 * so it is still allocated and can be used again by underlying
1420 * hardware as a DMA target */
1424 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
1426 static u8 qos_oui
[QOS_OUI_LEN
] = { 0x00, 0x50, 0xF2 };
1429 * Make the structure we read from the beacon packet to have
1432 static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
1433 *info_element
, int sub_type
)
1436 if (info_element
->qui_subtype
!= sub_type
)
1438 if (memcmp(info_element
->qui
, qos_oui
, QOS_OUI_LEN
))
1440 if (info_element
->qui_type
!= QOS_OUI_TYPE
)
1442 if (info_element
->version
!= QOS_VERSION_1
)
1450 * Parse a QoS parameter element
1452 static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
1453 *element_param
, struct ieee80211_info_element
1457 u16 size
= sizeof(struct ieee80211_qos_parameter_info
) - 2;
1459 if ((info_element
== NULL
) || (element_param
== NULL
))
1462 if (info_element
->id
== QOS_ELEMENT_ID
&& info_element
->len
== size
) {
1463 memcpy(element_param
->info_element
.qui
, info_element
->data
,
1465 element_param
->info_element
.elementID
= info_element
->id
;
1466 element_param
->info_element
.length
= info_element
->len
;
1470 ret
= ieee80211_verify_qos_info(&element_param
->info_element
,
1471 QOS_OUI_PARAM_SUB_TYPE
);
1476 * Parse a QoS information element
1478 static int ieee80211_read_qos_info_element(struct
1479 ieee80211_qos_information_element
1480 *element_info
, struct ieee80211_info_element
1484 u16 size
= sizeof(struct ieee80211_qos_information_element
) - 2;
1486 if (element_info
== NULL
)
1488 if (info_element
== NULL
)
1491 if ((info_element
->id
== QOS_ELEMENT_ID
) && (info_element
->len
== size
)) {
1492 memcpy(element_info
->qui
, info_element
->data
,
1494 element_info
->elementID
= info_element
->id
;
1495 element_info
->length
= info_element
->len
;
1500 ret
= ieee80211_verify_qos_info(element_info
,
1501 QOS_OUI_INFO_SUB_TYPE
);
1507 * Write QoS parameters from the ac parameters.
1509 static int ieee80211_qos_convert_ac_to_parameters(struct
1510 ieee80211_qos_parameter_info
1512 ieee80211_qos_parameters
1517 struct ieee80211_qos_ac_parameter
*ac_params
;
1520 for (i
= 0; i
< QOS_QUEUE_NUM
; i
++) {
1521 ac_params
= &(param_elm
->ac_params_record
[i
]);
1523 aci
= (ac_params
->aci_aifsn
& 0x60) >> 5;
1525 if(aci
>= QOS_QUEUE_NUM
)
1527 qos_param
->aifs
[aci
] = (ac_params
->aci_aifsn
) & 0x0f;
1529 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1530 qos_param
->aifs
[aci
] = (qos_param
->aifs
[aci
] < 2) ? 2:qos_param
->aifs
[aci
];
1532 qos_param
->cw_min
[aci
] = ac_params
->ecw_min_max
& 0x0F;
1534 qos_param
->cw_max
[aci
] = (ac_params
->ecw_min_max
& 0xF0) >> 4;
1536 qos_param
->flag
[aci
] =
1537 (ac_params
->aci_aifsn
& 0x10) ? 0x01 : 0x00;
1538 qos_param
->tx_op_limit
[aci
] = le16_to_cpu(ac_params
->tx_op_limit
);
1544 * we have a generic data element which it may contain QoS information or
1545 * parameters element. check the information element length to decide
1546 * which type to read
1548 static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1550 struct ieee80211_network
*network
)
1553 struct ieee80211_qos_parameters
*qos_param
= NULL
;
1554 struct ieee80211_qos_information_element qos_info_element
;
1556 rc
= ieee80211_read_qos_info_element(&qos_info_element
, info_element
);
1559 network
->qos_data
.param_count
= qos_info_element
.ac_info
& 0x0F;
1560 network
->flags
|= NETWORK_HAS_QOS_INFORMATION
;
1562 struct ieee80211_qos_parameter_info param_element
;
1564 rc
= ieee80211_read_qos_param_element(¶m_element
,
1567 qos_param
= &(network
->qos_data
.parameters
);
1568 ieee80211_qos_convert_ac_to_parameters(¶m_element
,
1570 network
->flags
|= NETWORK_HAS_QOS_PARAMETERS
;
1571 network
->qos_data
.param_count
=
1572 param_element
.info_element
.ac_info
& 0x0F;
1577 IEEE80211_DEBUG_QOS("QoS is supported\n");
1578 network
->qos_data
.supported
= 1;
1583 #ifdef CONFIG_IEEE80211_DEBUG
1584 #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1586 static const char *get_info_element_string(u16 id
)
1591 MFIE_STRING(FH_SET
);
1592 MFIE_STRING(DS_SET
);
1593 MFIE_STRING(CF_SET
);
1595 MFIE_STRING(IBSS_SET
);
1596 MFIE_STRING(COUNTRY
);
1597 MFIE_STRING(HOP_PARAMS
);
1598 MFIE_STRING(HOP_TABLE
);
1599 MFIE_STRING(REQUEST
);
1600 MFIE_STRING(CHALLENGE
);
1601 MFIE_STRING(POWER_CONSTRAINT
);
1602 MFIE_STRING(POWER_CAPABILITY
);
1603 MFIE_STRING(TPC_REQUEST
);
1604 MFIE_STRING(TPC_REPORT
);
1605 MFIE_STRING(SUPP_CHANNELS
);
1607 MFIE_STRING(MEASURE_REQUEST
);
1608 MFIE_STRING(MEASURE_REPORT
);
1610 MFIE_STRING(IBSS_DFS
);
1611 // MFIE_STRING(ERP_INFO);
1613 MFIE_STRING(RATES_EX
);
1614 MFIE_STRING(GENERIC
);
1615 MFIE_STRING(QOS_PARAMETER
);
1622 #ifdef ENABLE_DOT11D
1623 static inline void ieee80211_extract_country_ie(
1624 struct ieee80211_device
*ieee
,
1625 struct ieee80211_info_element
*info_element
,
1626 struct ieee80211_network
*network
,
1630 if(IS_DOT11D_ENABLE(ieee
))
1632 if(info_element
->len
!= 0)
1634 memcpy(network
->CountryIeBuf
, info_element
->data
, info_element
->len
);
1635 network
->CountryIeLen
= info_element
->len
;
1637 if(!IS_COUNTRY_IE_VALID(ieee
))
1639 Dot11d_UpdateCountryIe(ieee
, addr2
, info_element
->len
, info_element
->data
);
1644 // 070305, rcnjko: I update country IE watch dog here because
1645 // some AP (e.g. Cisco 1242) don't include country IE in their
1646 // probe response frame.
1648 if(IS_EQUAL_CIE_SRC(ieee
, addr2
) )
1650 UPDATE_CIE_WATCHDOG(ieee
);
1657 int ieee80211_parse_info_param(struct ieee80211_device
*ieee
,
1658 struct ieee80211_info_element
*info_element
,
1660 struct ieee80211_network
*network
,
1661 struct ieee80211_rx_stats
*stats
)
1665 u16 tmp_htcap_len
=0;
1666 u16 tmp_htinfo_len
=0;
1667 u16 ht_realtek_agg_len
=0;
1668 u8 ht_realtek_agg_buf
[MAX_IE_LEN
];
1669 #ifdef CONFIG_IEEE80211_DEBUG
1674 while (length
>= sizeof(*info_element
)) {
1675 if (sizeof(*info_element
) + info_element
->len
> length
) {
1676 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1677 "info_element->len + 2 > left : "
1678 "info_element->len+2=%zd left=%d, id=%d.\n",
1680 sizeof(*info_element
),
1681 length
, info_element
->id
);
1682 /* We stop processing but don't return an error here
1683 * because some misbehaviour APs break this rule. ie.
1684 * Orinoco AP1000. */
1688 switch (info_element
->id
) {
1689 case MFIE_TYPE_SSID
:
1690 if (ieee80211_is_empty_essid(info_element
->data
,
1691 info_element
->len
)) {
1692 network
->flags
|= NETWORK_EMPTY_ESSID
;
1696 network
->ssid_len
= min(info_element
->len
,
1697 (u8
) IW_ESSID_MAX_SIZE
);
1698 memcpy(network
->ssid
, info_element
->data
, network
->ssid_len
);
1699 if (network
->ssid_len
< IW_ESSID_MAX_SIZE
)
1700 memset(network
->ssid
+ network
->ssid_len
, 0,
1701 IW_ESSID_MAX_SIZE
- network
->ssid_len
);
1703 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
1704 network
->ssid
, network
->ssid_len
);
1707 case MFIE_TYPE_RATES
:
1708 #ifdef CONFIG_IEEE80211_DEBUG
1711 network
->rates_len
= min(info_element
->len
,
1713 for (i
= 0; i
< network
->rates_len
; i
++) {
1714 network
->rates
[i
] = info_element
->data
[i
];
1715 #ifdef CONFIG_IEEE80211_DEBUG
1716 p
+= snprintf(p
, sizeof(rates_str
) -
1717 (p
- rates_str
), "%02X ",
1720 if (ieee80211_is_ofdm_rate
1721 (info_element
->data
[i
])) {
1722 network
->flags
|= NETWORK_HAS_OFDM
;
1723 if (info_element
->data
[i
] &
1724 IEEE80211_BASIC_RATE_MASK
)
1730 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
1731 rates_str
, network
->rates_len
);
1734 case MFIE_TYPE_RATES_EX
:
1735 #ifdef CONFIG_IEEE80211_DEBUG
1738 network
->rates_ex_len
= min(info_element
->len
,
1739 MAX_RATES_EX_LENGTH
);
1740 for (i
= 0; i
< network
->rates_ex_len
; i
++) {
1741 network
->rates_ex
[i
] = info_element
->data
[i
];
1742 #ifdef CONFIG_IEEE80211_DEBUG
1743 p
+= snprintf(p
, sizeof(rates_str
) -
1744 (p
- rates_str
), "%02X ",
1747 if (ieee80211_is_ofdm_rate
1748 (info_element
->data
[i
])) {
1749 network
->flags
|= NETWORK_HAS_OFDM
;
1750 if (info_element
->data
[i
] &
1751 IEEE80211_BASIC_RATE_MASK
)
1757 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
1758 rates_str
, network
->rates_ex_len
);
1761 case MFIE_TYPE_DS_SET
:
1762 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
1763 info_element
->data
[0]);
1764 network
->channel
= info_element
->data
[0];
1767 case MFIE_TYPE_FH_SET
:
1768 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
1771 case MFIE_TYPE_CF_SET
:
1772 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
1776 if(info_element
->len
< 4)
1779 network
->tim
.tim_count
= info_element
->data
[0];
1780 network
->tim
.tim_period
= info_element
->data
[1];
1782 network
->dtim_period
= info_element
->data
[1];
1783 if(ieee
->state
!= IEEE80211_LINKED
)
1785 //we use jiffies for legacy Power save
1786 network
->last_dtim_sta_time
[0] = jiffies
;
1787 network
->last_dtim_sta_time
[1] = stats
->mac_time
[1];
1789 network
->dtim_data
= IEEE80211_DTIM_VALID
;
1791 if(info_element
->data
[0] != 0)
1794 if(info_element
->data
[2] & 1)
1795 network
->dtim_data
|= IEEE80211_DTIM_MBCAST
;
1797 offset
= (info_element
->data
[2] >> 1)*2;
1799 if(ieee
->assoc_id
< 8*offset
||
1800 ieee
->assoc_id
> 8*(offset
+ info_element
->len
-3))
1804 offset
= (ieee
->assoc_id
/ 8) - offset
;// + ((aid % 8)? 0 : 1) ;
1806 if(info_element
->data
[3+offset
] & (1<<(ieee
->assoc_id
%8)))
1807 network
->dtim_data
|= IEEE80211_DTIM_UCAST
;
1812 network
->erp_value
= info_element
->data
[0];
1813 network
->flags
|= NETWORK_HAS_ERP_VALUE
;
1814 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1815 network
->erp_value
);
1817 case MFIE_TYPE_IBSS_SET
:
1818 network
->atim_window
= info_element
->data
[0];
1819 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1820 network
->atim_window
);
1823 case MFIE_TYPE_CHALLENGE
:
1824 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
1827 case MFIE_TYPE_GENERIC
:
1828 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
1830 if (!ieee80211_parse_qos_info_param_IE(info_element
,
1834 if (info_element
->len
>= 4 &&
1835 info_element
->data
[0] == 0x00 &&
1836 info_element
->data
[1] == 0x50 &&
1837 info_element
->data
[2] == 0xf2 &&
1838 info_element
->data
[3] == 0x01) {
1839 network
->wpa_ie_len
= min(info_element
->len
+ 2,
1841 memcpy(network
->wpa_ie
, info_element
,
1842 network
->wpa_ie_len
);
1847 if (info_element
->len
== 7 &&
1848 info_element
->data
[0] == 0x00 &&
1849 info_element
->data
[1] == 0xe0 &&
1850 info_element
->data
[2] == 0x4c &&
1851 info_element
->data
[3] == 0x01 &&
1852 info_element
->data
[4] == 0x02) {
1853 network
->Turbo_Enable
= 1;
1857 //for HTcap and HTinfo parameters
1858 if(tmp_htcap_len
== 0){
1859 if(info_element
->len
>= 4 &&
1860 info_element
->data
[0] == 0x00 &&
1861 info_element
->data
[1] == 0x90 &&
1862 info_element
->data
[2] == 0x4c &&
1863 info_element
->data
[3] == 0x033){
1865 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1866 if(tmp_htcap_len
!= 0){
1867 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1868 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
1869 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
1870 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
1873 if(tmp_htcap_len
!= 0)
1874 network
->bssht
.bdSupportHT
= true;
1876 network
->bssht
.bdSupportHT
= false;
1880 if(tmp_htinfo_len
== 0){
1881 if(info_element
->len
>= 4 &&
1882 info_element
->data
[0] == 0x00 &&
1883 info_element
->data
[1] == 0x90 &&
1884 info_element
->data
[2] == 0x4c &&
1885 info_element
->data
[3] == 0x034){
1887 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1888 if(tmp_htinfo_len
!= 0){
1889 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1891 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
1892 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
1893 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
1901 if(ieee
->aggregation
){
1902 if(network
->bssht
.bdSupportHT
){
1903 if(info_element
->len
>= 4 &&
1904 info_element
->data
[0] == 0x00 &&
1905 info_element
->data
[1] == 0xe0 &&
1906 info_element
->data
[2] == 0x4c &&
1907 info_element
->data
[3] == 0x02){
1909 ht_realtek_agg_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1910 memcpy(ht_realtek_agg_buf
,info_element
->data
,info_element
->len
);
1913 if(ht_realtek_agg_len
>= 5){
1914 network
->bssht
.bdRT2RTAggregation
= true;
1916 if((ht_realtek_agg_buf
[4] == 1) && (ht_realtek_agg_buf
[5] & 0x02))
1917 network
->bssht
.bdRT2RTLongSlotTime
= true;
1923 if((info_element
->len
>= 3 &&
1924 info_element
->data
[0] == 0x00 &&
1925 info_element
->data
[1] == 0x05 &&
1926 info_element
->data
[2] == 0xb5) ||
1927 (info_element
->len
>= 3 &&
1928 info_element
->data
[0] == 0x00 &&
1929 info_element
->data
[1] == 0x0a &&
1930 info_element
->data
[2] == 0xf7) ||
1931 (info_element
->len
>= 3 &&
1932 info_element
->data
[0] == 0x00 &&
1933 info_element
->data
[1] == 0x10 &&
1934 info_element
->data
[2] == 0x18)){
1936 network
->broadcom_cap_exist
= true;
1940 if(info_element
->len
>= 3 &&
1941 info_element
->data
[0] == 0x00 &&
1942 info_element
->data
[1] == 0x0c &&
1943 info_element
->data
[2] == 0x43)
1945 network
->ralink_cap_exist
= true;
1948 network
->ralink_cap_exist
= false;
1949 //added by amy for atheros AP
1950 if((info_element
->len
>= 3 &&
1951 info_element
->data
[0] == 0x00 &&
1952 info_element
->data
[1] == 0x03 &&
1953 info_element
->data
[2] == 0x7f) ||
1954 (info_element
->len
>= 3 &&
1955 info_element
->data
[0] == 0x00 &&
1956 info_element
->data
[1] == 0x13 &&
1957 info_element
->data
[2] == 0x74))
1959 network
->atheros_cap_exist
= true;
1962 network
->atheros_cap_exist
= false;
1964 if ((info_element
->len
>= 3 &&
1965 info_element
->data
[0] == 0x00 &&
1966 info_element
->data
[1] == 0x50 &&
1967 info_element
->data
[2] == 0x43) )
1969 network
->marvell_cap_exist
= true;
1973 if(info_element
->len
>= 3 &&
1974 info_element
->data
[0] == 0x00 &&
1975 info_element
->data
[1] == 0x40 &&
1976 info_element
->data
[2] == 0x96)
1978 network
->cisco_cap_exist
= true;
1981 network
->cisco_cap_exist
= false;
1982 //added by amy for LEAP of cisco
1983 if(info_element
->len
> 4 &&
1984 info_element
->data
[0] == 0x00 &&
1985 info_element
->data
[1] == 0x40 &&
1986 info_element
->data
[2] == 0x96 &&
1987 info_element
->data
[3] == 0x01)
1989 if(info_element
->len
== 6)
1991 memcpy(network
->CcxRmState
, &info_element
[4], 2);
1992 if(network
->CcxRmState
[0] != 0)
1994 network
->bCcxRmEnable
= true;
1997 network
->bCcxRmEnable
= false;
1999 // CCXv4 Table 59-1 MBSSID Masks.
2001 network
->MBssidMask
= network
->CcxRmState
[1] & 0x07;
2002 if(network
->MBssidMask
!= 0)
2004 network
->bMBssidValid
= true;
2005 network
->MBssidMask
= 0xff << (network
->MBssidMask
);
2006 cpMacAddr(network
->MBssid
, network
->bssid
);
2007 network
->MBssid
[5] &= network
->MBssidMask
;
2011 network
->bMBssidValid
= false;
2016 network
->bCcxRmEnable
= false;
2019 if(info_element
->len
> 4 &&
2020 info_element
->data
[0] == 0x00 &&
2021 info_element
->data
[1] == 0x40 &&
2022 info_element
->data
[2] == 0x96 &&
2023 info_element
->data
[3] == 0x03)
2025 if(info_element
->len
== 5)
2027 network
->bWithCcxVerNum
= true;
2028 network
->BssCcxVerNumber
= info_element
->data
[4];
2032 network
->bWithCcxVerNum
= false;
2033 network
->BssCcxVerNumber
= 0;
2039 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
2041 network
->rsn_ie_len
= min(info_element
->len
+ 2,
2043 memcpy(network
->rsn_ie
, info_element
,
2044 network
->rsn_ie_len
);
2047 //HT related element.
2048 case MFIE_TYPE_HT_CAP
:
2049 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
2051 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
2052 if(tmp_htcap_len
!= 0){
2053 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
2054 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
2055 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
2056 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
2058 //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
2059 // windows driver will update WMM parameters each beacon received once connected
2060 // Linux driver is a bit different.
2061 network
->bssht
.bdSupportHT
= true;
2064 network
->bssht
.bdSupportHT
= false;
2068 case MFIE_TYPE_HT_INFO
:
2069 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
2071 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
2073 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_IEEE
;
2074 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
2075 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
2076 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
2080 case MFIE_TYPE_AIRONET
:
2081 IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
2083 if(info_element
->len
>IE_CISCO_FLAG_POSITION
)
2085 network
->bWithAironetIE
= true;
2087 // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
2088 // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
2089 // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
2090 if( (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_MIC
) ||
2091 (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_PK
) )
2093 network
->bCkipSupported
= true;
2097 network
->bCkipSupported
= false;
2102 network
->bWithAironetIE
= false;
2103 network
->bCkipSupported
= false;
2106 case MFIE_TYPE_QOS_PARAMETER
:
2108 "QoS Error need to parse QOS_PARAMETER IE\n");
2111 #ifdef ENABLE_DOT11D
2112 case MFIE_TYPE_COUNTRY
:
2113 IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
2115 ieee80211_extract_country_ie(ieee
, info_element
, network
, network
->bssid
);//addr2 is same as addr3 when from an AP
2120 IEEE80211_DEBUG_MGMT
2121 ("Unsupported info element: %s (%d)\n",
2122 get_info_element_string(info_element
->id
),
2127 length
-= sizeof(*info_element
) + info_element
->len
;
2129 (struct ieee80211_info_element
*)&info_element
->
2130 data
[info_element
->len
];
2133 if(!network
->atheros_cap_exist
&& !network
->broadcom_cap_exist
&&
2134 !network
->cisco_cap_exist
&& !network
->ralink_cap_exist
&& !network
->bssht
.bdRT2RTAggregation
&&
2135 !network
->marvell_cap_exist
)
2137 network
->unknown_cap_exist
= true;
2141 network
->unknown_cap_exist
= false;
2146 static inline u8
ieee80211_SignalStrengthTranslate(
2152 // Step 1. Scale mapping.
2153 if(CurrSS
>= 71 && CurrSS
<= 100)
2155 RetSS
= 90 + ((CurrSS
- 70) / 3);
2157 else if(CurrSS
>= 41 && CurrSS
<= 70)
2159 RetSS
= 78 + ((CurrSS
- 40) / 3);
2161 else if(CurrSS
>= 31 && CurrSS
<= 40)
2163 RetSS
= 66 + (CurrSS
- 30);
2165 else if(CurrSS
>= 21 && CurrSS
<= 30)
2167 RetSS
= 54 + (CurrSS
- 20);
2169 else if(CurrSS
>= 5 && CurrSS
<= 20)
2171 RetSS
= 42 + (((CurrSS
- 5) * 2) / 3);
2173 else if(CurrSS
== 4)
2177 else if(CurrSS
== 3)
2181 else if(CurrSS
== 2)
2185 else if(CurrSS
== 1)
2197 long ieee80211_translate_todbm(u8 signal_strength_index
)// 0-100 index.
2199 long signal_power
; // in dBm.
2201 // Translate to dBm (x=0.5y-95).
2202 signal_power
= (long)((signal_strength_index
+ 1) >> 1);
2205 return signal_power
;
2208 static inline int ieee80211_network_init(
2209 struct ieee80211_device
*ieee
,
2210 struct ieee80211_probe_response
*beacon
,
2211 struct ieee80211_network
*network
,
2212 struct ieee80211_rx_stats
*stats
)
2214 network
->qos_data
.active
= 0;
2215 network
->qos_data
.supported
= 0;
2216 network
->qos_data
.param_count
= 0;
2217 network
->qos_data
.old_param_count
= 0;
2219 /* Pull out fixed field data */
2220 memcpy(network
->bssid
, beacon
->header
.addr3
, ETH_ALEN
);
2221 network
->capability
= le16_to_cpu(beacon
->capability
);
2222 network
->last_scanned
= jiffies
;
2223 network
->time_stamp
[0] = le32_to_cpu(beacon
->time_stamp
[0]);
2224 network
->time_stamp
[1] = le32_to_cpu(beacon
->time_stamp
[1]);
2225 network
->beacon_interval
= le32_to_cpu(beacon
->beacon_interval
);
2226 /* Where to pull this? beacon->listen_interval;*/
2227 network
->listen_interval
= 0x0A;
2228 network
->rates_len
= network
->rates_ex_len
= 0;
2229 network
->last_associate
= 0;
2230 network
->ssid_len
= 0;
2232 network
->atim_window
= 0;
2233 network
->erp_value
= (network
->capability
& WLAN_CAPABILITY_IBSS
) ?
2235 network
->berp_info_valid
= false;
2236 network
->broadcom_cap_exist
= false;
2237 network
->ralink_cap_exist
= false;
2238 network
->atheros_cap_exist
= false;
2239 network
->marvell_cap_exist
= false;
2240 network
->cisco_cap_exist
= false;
2241 network
->unknown_cap_exist
= false;
2243 network
->Turbo_Enable
= 0;
2245 #ifdef ENABLE_DOT11D
2246 network
->CountryIeLen
= 0;
2247 memset(network
->CountryIeBuf
, 0, MAX_IE_LEN
);
2249 //Initialize HT parameters
2250 HTInitializeBssDesc(&network
->bssht
);
2251 if (stats
->freq
== IEEE80211_52GHZ_BAND
) {
2252 /* for A band (No DS info) */
2253 network
->channel
= stats
->received_channel
;
2255 network
->flags
|= NETWORK_HAS_CCK
;
2257 network
->wpa_ie_len
= 0;
2258 network
->rsn_ie_len
= 0;
2260 if (ieee80211_parse_info_param
2261 (ieee
,beacon
->info_element
, stats
->len
- sizeof(*beacon
), network
, stats
))
2265 if (stats
->freq
== IEEE80211_52GHZ_BAND
)
2266 network
->mode
= IEEE_A
;
2268 if (network
->flags
& NETWORK_HAS_OFDM
)
2269 network
->mode
|= IEEE_G
;
2270 if (network
->flags
& NETWORK_HAS_CCK
)
2271 network
->mode
|= IEEE_B
;
2274 if (network
->mode
== 0) {
2275 IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' "
2277 escape_essid(network
->ssid
,
2283 if(network
->bssht
.bdSupportHT
){
2284 if(network
->mode
== IEEE_A
)
2285 network
->mode
= IEEE_N_5G
;
2286 else if(network
->mode
& (IEEE_G
| IEEE_B
))
2287 network
->mode
= IEEE_N_24G
;
2289 if (ieee80211_is_empty_essid(network
->ssid
, network
->ssid_len
))
2290 network
->flags
|= NETWORK_EMPTY_ESSID
;
2292 stats
->signal
= 30 + (stats
->SignalStrength
* 70) / 100;
2293 stats
->noise
= ieee80211_translate_todbm((u8
)(100-stats
->signal
)) -25;
2295 memcpy(&network
->stats
, stats
, sizeof(network
->stats
));
2300 static inline int is_same_network(struct ieee80211_network
*src
,
2301 struct ieee80211_network
*dst
, struct ieee80211_device
* ieee
)
2303 /* A network is only a duplicate if the channel, BSSID, ESSID
2304 * and the capability field (in particular IBSS and BSS) all match.
2305 * We treat all <hidden> with the same BSSID and channel
2307 return (((src
->ssid_len
== dst
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2308 (src
->channel
== dst
->channel
) &&
2309 !memcmp(src
->bssid
, dst
->bssid
, ETH_ALEN
) &&
2310 (!memcmp(src
->ssid
, dst
->ssid
, src
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2311 ((src
->capability
& WLAN_CAPABILITY_IBSS
) ==
2312 (dst
->capability
& WLAN_CAPABILITY_IBSS
)) &&
2313 ((src
->capability
& WLAN_CAPABILITY_BSS
) ==
2314 (dst
->capability
& WLAN_CAPABILITY_BSS
)));
2317 static inline void update_network(struct ieee80211_network
*dst
,
2318 struct ieee80211_network
*src
)
2323 memcpy(&dst
->stats
, &src
->stats
, sizeof(struct ieee80211_rx_stats
));
2324 dst
->capability
= src
->capability
;
2325 memcpy(dst
->rates
, src
->rates
, src
->rates_len
);
2326 dst
->rates_len
= src
->rates_len
;
2327 memcpy(dst
->rates_ex
, src
->rates_ex
, src
->rates_ex_len
);
2328 dst
->rates_ex_len
= src
->rates_ex_len
;
2329 if(src
->ssid_len
> 0)
2331 memset(dst
->ssid
, 0, dst
->ssid_len
);
2332 dst
->ssid_len
= src
->ssid_len
;
2333 memcpy(dst
->ssid
, src
->ssid
, src
->ssid_len
);
2335 dst
->mode
= src
->mode
;
2336 dst
->flags
= src
->flags
;
2337 dst
->time_stamp
[0] = src
->time_stamp
[0];
2338 dst
->time_stamp
[1] = src
->time_stamp
[1];
2339 if (src
->flags
& NETWORK_HAS_ERP_VALUE
)
2341 dst
->erp_value
= src
->erp_value
;
2342 dst
->berp_info_valid
= src
->berp_info_valid
= true;
2344 dst
->beacon_interval
= src
->beacon_interval
;
2345 dst
->listen_interval
= src
->listen_interval
;
2346 dst
->atim_window
= src
->atim_window
;
2347 dst
->dtim_period
= src
->dtim_period
;
2348 dst
->dtim_data
= src
->dtim_data
;
2349 dst
->last_dtim_sta_time
[0] = src
->last_dtim_sta_time
[0];
2350 dst
->last_dtim_sta_time
[1] = src
->last_dtim_sta_time
[1];
2351 memcpy(&dst
->tim
, &src
->tim
, sizeof(struct ieee80211_tim_parameters
));
2353 dst
->bssht
.bdSupportHT
= src
->bssht
.bdSupportHT
;
2354 dst
->bssht
.bdRT2RTAggregation
= src
->bssht
.bdRT2RTAggregation
;
2355 dst
->bssht
.bdHTCapLen
= src
->bssht
.bdHTCapLen
;
2356 memcpy(dst
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapLen
);
2357 dst
->bssht
.bdHTInfoLen
= src
->bssht
.bdHTInfoLen
;
2358 memcpy(dst
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoLen
);
2359 dst
->bssht
.bdHTSpecVer
= src
->bssht
.bdHTSpecVer
;
2360 dst
->bssht
.bdRT2RTLongSlotTime
= src
->bssht
.bdRT2RTLongSlotTime
;
2361 dst
->broadcom_cap_exist
= src
->broadcom_cap_exist
;
2362 dst
->ralink_cap_exist
= src
->ralink_cap_exist
;
2363 dst
->atheros_cap_exist
= src
->atheros_cap_exist
;
2364 dst
->marvell_cap_exist
= src
->marvell_cap_exist
;
2365 dst
->cisco_cap_exist
= src
->cisco_cap_exist
;
2366 dst
->unknown_cap_exist
= src
->unknown_cap_exist
;
2367 memcpy(dst
->wpa_ie
, src
->wpa_ie
, src
->wpa_ie_len
);
2368 dst
->wpa_ie_len
= src
->wpa_ie_len
;
2369 memcpy(dst
->rsn_ie
, src
->rsn_ie
, src
->rsn_ie_len
);
2370 dst
->rsn_ie_len
= src
->rsn_ie_len
;
2372 dst
->last_scanned
= jiffies
;
2373 /* qos related parameters */
2374 qos_active
= dst
->qos_data
.active
;
2375 old_param
= dst
->qos_data
.param_count
;
2376 if(dst
->flags
& NETWORK_HAS_QOS_MASK
){
2377 //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
2380 dst
->qos_data
.supported
= src
->qos_data
.supported
;
2381 dst
->qos_data
.param_count
= src
->qos_data
.param_count
;
2384 if(dst
->qos_data
.supported
== 1) {
2385 dst
->QoS_Enable
= 1;
2388 ("QoS the network %s is QoS supported\n",
2392 ("QoS the network is QoS supported\n");
2394 dst
->qos_data
.active
= qos_active
;
2395 dst
->qos_data
.old_param_count
= old_param
;
2397 /* dst->last_associate is not overwritten */
2398 dst
->wmm_info
= src
->wmm_info
; //sure to exist in beacon or probe response frame.
2399 if(src
->wmm_param
[0].ac_aci_acm_aifsn
|| \
2400 src
->wmm_param
[1].ac_aci_acm_aifsn
|| \
2401 src
->wmm_param
[2].ac_aci_acm_aifsn
|| \
2402 src
->wmm_param
[3].ac_aci_acm_aifsn
) {
2403 memcpy(dst
->wmm_param
, src
->wmm_param
, WME_AC_PRAM_LEN
);
2406 dst
->Turbo_Enable
= src
->Turbo_Enable
;
2409 #ifdef ENABLE_DOT11D
2410 dst
->CountryIeLen
= src
->CountryIeLen
;
2411 memcpy(dst
->CountryIeBuf
, src
->CountryIeBuf
, src
->CountryIeLen
);
2414 //added by amy for LEAP
2415 dst
->bWithAironetIE
= src
->bWithAironetIE
;
2416 dst
->bCkipSupported
= src
->bCkipSupported
;
2417 memcpy(dst
->CcxRmState
,src
->CcxRmState
,2);
2418 dst
->bCcxRmEnable
= src
->bCcxRmEnable
;
2419 dst
->MBssidMask
= src
->MBssidMask
;
2420 dst
->bMBssidValid
= src
->bMBssidValid
;
2421 memcpy(dst
->MBssid
,src
->MBssid
,6);
2422 dst
->bWithCcxVerNum
= src
->bWithCcxVerNum
;
2423 dst
->BssCcxVerNumber
= src
->BssCcxVerNumber
;
2427 static inline int is_beacon(__le16 fc
)
2429 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc
)) == IEEE80211_STYPE_BEACON
);
2432 static inline void ieee80211_process_probe_response(
2433 struct ieee80211_device
*ieee
,
2434 struct ieee80211_probe_response
*beacon
,
2435 struct ieee80211_rx_stats
*stats
)
2437 struct ieee80211_network network
;
2438 struct ieee80211_network
*target
;
2439 struct ieee80211_network
*oldest
= NULL
;
2440 #ifdef CONFIG_IEEE80211_DEBUG
2441 struct ieee80211_info_element
*info_element
= &beacon
->info_element
[0];
2443 unsigned long flags
;
2446 memset(&network
, 0, sizeof(struct ieee80211_network
));
2447 IEEE80211_DEBUG_SCAN(
2448 "'%s' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2449 escape_essid(info_element
->data
, info_element
->len
),
2450 beacon
->header
.addr3
,
2451 (beacon
->capability
& (1<<0xf)) ? '1' : '0',
2452 (beacon
->capability
& (1<<0xe)) ? '1' : '0',
2453 (beacon
->capability
& (1<<0xd)) ? '1' : '0',
2454 (beacon
->capability
& (1<<0xc)) ? '1' : '0',
2455 (beacon
->capability
& (1<<0xb)) ? '1' : '0',
2456 (beacon
->capability
& (1<<0xa)) ? '1' : '0',
2457 (beacon
->capability
& (1<<0x9)) ? '1' : '0',
2458 (beacon
->capability
& (1<<0x8)) ? '1' : '0',
2459 (beacon
->capability
& (1<<0x7)) ? '1' : '0',
2460 (beacon
->capability
& (1<<0x6)) ? '1' : '0',
2461 (beacon
->capability
& (1<<0x5)) ? '1' : '0',
2462 (beacon
->capability
& (1<<0x4)) ? '1' : '0',
2463 (beacon
->capability
& (1<<0x3)) ? '1' : '0',
2464 (beacon
->capability
& (1<<0x2)) ? '1' : '0',
2465 (beacon
->capability
& (1<<0x1)) ? '1' : '0',
2466 (beacon
->capability
& (1<<0x0)) ? '1' : '0');
2468 if (ieee80211_network_init(ieee
, beacon
, &network
, stats
)) {
2469 IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
2470 escape_essid(info_element
->data
,
2472 beacon
->header
.addr3
,
2473 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2474 IEEE80211_STYPE_PROBE_RESP
?
2475 "PROBE RESPONSE" : "BEACON");
2479 #ifdef ENABLE_DOT11D
2480 // For Asus EeePc request,
2481 // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
2482 // wireless adapter should follow the country code.
2483 // (2) If there is no any country code in beacon,
2484 // then wireless adapter should do active scan from ch1~11 and
2485 // passive scan from ch12~14
2487 if( !IsLegalChannel(ieee
, network
.channel
) )
2489 if(ieee
->bGlobalDomain
)
2491 if (WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) == IEEE80211_STYPE_PROBE_RESP
)
2493 // Case 1: Country code
2494 if(IS_COUNTRY_IE_VALID(ieee
) )
2496 if( !IsLegalChannel(ieee
, network
.channel
) )
2498 printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network
.channel
);
2502 // Case 2: No any country code.
2505 // Filter over channel ch12~14
2506 if(network
.channel
> 11)
2508 printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network
.channel
);
2515 // Case 1: Country code
2516 if(IS_COUNTRY_IE_VALID(ieee
) )
2518 if( !IsLegalChannel(ieee
, network
.channel
) )
2520 printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network
.channel
);
2524 // Case 2: No any country code.
2527 // Filter over channel ch12~14
2528 if(network
.channel
> 14)
2530 printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network
.channel
);
2538 /* The network parsed correctly -- so now we scan our known networks
2539 * to see if we can find it in our list.
2541 * NOTE: This search is definitely not optimized. Once its doing
2542 * the "right thing" we'll optimize it for efficiency if
2545 /* Search for this entry in the list and update it if it is
2548 spin_lock_irqsave(&ieee
->lock
, flags
);
2550 if(is_same_network(&ieee
->current_network
, &network
, ieee
)) {
2551 update_network(&ieee
->current_network
, &network
);
2552 if((ieee
->current_network
.mode
== IEEE_N_24G
|| ieee
->current_network
.mode
== IEEE_G
)
2553 && ieee
->current_network
.berp_info_valid
){
2554 if(ieee
->current_network
.erp_value
& ERP_UseProtection
)
2555 ieee
->current_network
.buseprotection
= true;
2557 ieee
->current_network
.buseprotection
= false;
2559 if(is_beacon(beacon
->header
.frame_ctl
))
2561 if(ieee
->state
== IEEE80211_LINKED
)
2562 ieee
->LinkDetectInfo
.NumRecvBcnInPeriod
++;
2565 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& ieee
->current_network
.flags
);
2568 list_for_each_entry(target
, &ieee
->network_list
, list
) {
2569 if (is_same_network(target
, &network
, ieee
))
2571 if ((oldest
== NULL
) ||
2572 (target
->last_scanned
< oldest
->last_scanned
))
2576 /* If we didn't find a match, then get a new network slot to initialize
2577 * with this beacon's information */
2578 if (&target
->list
== &ieee
->network_list
) {
2579 if (list_empty(&ieee
->network_free_list
)) {
2580 /* If there are no more slots, expire the oldest */
2581 list_del(&oldest
->list
);
2583 IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from "
2585 escape_essid(target
->ssid
,
2589 /* Otherwise just pull from the free list */
2590 target
= list_entry(ieee
->network_free_list
.next
,
2591 struct ieee80211_network
, list
);
2592 list_del(ieee
->network_free_list
.next
);
2596 #ifdef CONFIG_IEEE80211_DEBUG
2597 IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
2598 escape_essid(network
.ssid
,
2601 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2602 IEEE80211_STYPE_PROBE_RESP
?
2603 "PROBE RESPONSE" : "BEACON");
2605 memcpy(target
, &network
, sizeof(*target
));
2606 list_add_tail(&target
->list
, &ieee
->network_list
);
2608 IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
2609 escape_essid(target
->ssid
,
2612 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2613 IEEE80211_STYPE_PROBE_RESP
?
2614 "PROBE RESPONSE" : "BEACON");
2616 /* we have an entry and we are going to update it. But this entry may
2617 * be already expired. In this case we do the same as we found a new
2618 * net and call the new_net handler
2620 renew
= !time_after(target
->last_scanned
+ ieee
->scan_age
, jiffies
);
2621 //YJ,add,080819,for hidden ap
2622 if(is_beacon(beacon
->header
.frame_ctl
) == 0)
2623 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& target
->flags
);
2624 if(((network
.flags
& NETWORK_EMPTY_ESSID
) == NETWORK_EMPTY_ESSID
) \
2625 && (((network
.ssid_len
> 0) && (strncmp(target
->ssid
, network
.ssid
, network
.ssid_len
)))\
2626 ||((ieee
->current_network
.ssid_len
== network
.ssid_len
)&&(strncmp(ieee
->current_network
.ssid
, network
.ssid
, network
.ssid_len
) == 0)&&(ieee
->state
== IEEE80211_NOLINK
))))
2628 //YJ,add,080819,for hidden ap,end
2630 update_network(target
, &network
);
2633 spin_unlock_irqrestore(&ieee
->lock
, flags
);
2634 if (is_beacon(beacon
->header
.frame_ctl
)&&is_same_network(&ieee
->current_network
, &network
, ieee
)&&\
2635 (ieee
->state
== IEEE80211_LINKED
)) {
2636 if(ieee
->handle_beacon
!= NULL
) {
2637 ieee
->handle_beacon(ieee
, beacon
, &ieee
->current_network
);
2642 void ieee80211_rx_mgt(struct ieee80211_device
*ieee
,
2643 struct ieee80211_hdr_4addr
*header
,
2644 struct ieee80211_rx_stats
*stats
)
2646 if(WLAN_FC_GET_STYPE(header
->frame_ctl
) != IEEE80211_STYPE_PROBE_RESP
&&
2647 WLAN_FC_GET_STYPE(header
->frame_ctl
) != IEEE80211_STYPE_BEACON
)
2648 ieee
->last_rx_ps_time
= jiffies
;
2650 switch (WLAN_FC_GET_STYPE(header
->frame_ctl
)) {
2652 case IEEE80211_STYPE_BEACON
:
2653 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
2654 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2655 IEEE80211_DEBUG_SCAN("Beacon\n");
2656 ieee80211_process_probe_response(
2657 ieee
, (struct ieee80211_probe_response
*)header
, stats
);
2659 if(ieee
->sta_sleep
|| (ieee
->ps
!= IEEE80211_PS_DISABLED
&&
2660 ieee
->iw_mode
== IW_MODE_INFRA
&&
2661 ieee
->state
== IEEE80211_LINKED
))
2663 tasklet_schedule(&ieee
->ps_task
);
2668 case IEEE80211_STYPE_PROBE_RESP
:
2669 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
2670 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2671 IEEE80211_DEBUG_SCAN("Probe response\n");
2672 ieee80211_process_probe_response(
2673 ieee
, (struct ieee80211_probe_response
*)header
, stats
);