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 <andrea.merello@gmail.com>
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/wireless.h>
40 #include <linux/etherdevice.h>
41 #include <linux/uaccess.h>
42 #include <linux/ctype.h>
44 #include "ieee80211.h"
46 static inline void ieee80211_monitor_rx(struct ieee80211_device
*ieee
,
48 struct ieee80211_rx_stats
*rx_stats
)
50 struct rtl_80211_hdr_4addr
*hdr
= (struct rtl_80211_hdr_4addr
*)skb
->data
;
51 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
54 skb_reset_mac_header(skb
);
56 skb_pull(skb
, ieee80211_get_hdrlen(fc
));
57 skb
->pkt_type
= PACKET_OTHERHOST
;
58 skb
->protocol
= htons(ETH_P_80211_RAW
);
59 memset(skb
->cb
, 0, sizeof(skb
->cb
));
64 /* Called only as a tasklet (software IRQ) */
65 static struct ieee80211_frag_entry
*
66 ieee80211_frag_cache_find(struct ieee80211_device
*ieee
, unsigned int seq
,
67 unsigned int frag
, u8 tid
, u8
*src
, u8
*dst
)
69 struct ieee80211_frag_entry
*entry
;
72 for (i
= 0; i
< IEEE80211_FRAG_CACHE_LEN
; i
++) {
73 entry
= &ieee
->frag_cache
[tid
][i
];
74 if (entry
->skb
!= NULL
&&
75 time_after(jiffies
, entry
->first_frag_time
+ 2 * HZ
)) {
77 "expiring fragment cache entry "
78 "seq=%u last_frag=%u\n",
79 entry
->seq
, entry
->last_frag
);
80 dev_kfree_skb_any(entry
->skb
);
84 if (entry
->skb
!= NULL
&& entry
->seq
== seq
&&
85 (entry
->last_frag
+ 1 == frag
|| frag
== -1) &&
86 memcmp(entry
->src_addr
, src
, ETH_ALEN
) == 0 &&
87 memcmp(entry
->dst_addr
, dst
, ETH_ALEN
) == 0)
94 /* Called only as a tasklet (software IRQ) */
95 static struct sk_buff
*
96 ieee80211_frag_cache_get(struct ieee80211_device
*ieee
,
97 struct rtl_80211_hdr_4addr
*hdr
)
99 struct sk_buff
*skb
= NULL
;
100 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
101 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
102 unsigned int frag
= WLAN_GET_SEQ_FRAG(sc
);
103 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
104 struct ieee80211_frag_entry
*entry
;
105 struct rtl_80211_hdr_3addrqos
*hdr_3addrqos
;
106 struct rtl_80211_hdr_4addrqos
*hdr_4addrqos
;
109 if (((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
110 hdr_4addrqos
= (struct rtl_80211_hdr_4addrqos
*)hdr
;
111 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
114 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
115 hdr_3addrqos
= (struct rtl_80211_hdr_3addrqos
*)hdr
;
116 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
124 /* Reserve enough space to fit maximum frame length */
125 skb
= dev_alloc_skb(ieee
->dev
->mtu
+
126 sizeof(struct rtl_80211_hdr_4addr
) +
131 (IEEE80211_QOS_HAS_SEQ(fc
)?2:0) /* QOS Control */);
135 entry
= &ieee
->frag_cache
[tid
][ieee
->frag_next_idx
[tid
]];
136 ieee
->frag_next_idx
[tid
]++;
137 if (ieee
->frag_next_idx
[tid
] >= IEEE80211_FRAG_CACHE_LEN
)
138 ieee
->frag_next_idx
[tid
] = 0;
140 if (entry
->skb
!= NULL
)
141 dev_kfree_skb_any(entry
->skb
);
143 entry
->first_frag_time
= jiffies
;
145 entry
->last_frag
= frag
;
147 memcpy(entry
->src_addr
, hdr
->addr2
, ETH_ALEN
);
148 memcpy(entry
->dst_addr
, hdr
->addr1
, ETH_ALEN
);
150 /* received a fragment of a frame for which the head fragment
151 * should have already been received */
152 entry
= ieee80211_frag_cache_find(ieee
, seq
, frag
, tid
,hdr
->addr2
,
155 entry
->last_frag
= frag
;
164 /* Called only as a tasklet (software IRQ) */
165 static int ieee80211_frag_cache_invalidate(struct ieee80211_device
*ieee
,
166 struct rtl_80211_hdr_4addr
*hdr
)
168 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
169 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
170 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
171 struct ieee80211_frag_entry
*entry
;
172 struct rtl_80211_hdr_3addrqos
*hdr_3addrqos
;
173 struct rtl_80211_hdr_4addrqos
*hdr_4addrqos
;
176 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
177 hdr_4addrqos
= (struct rtl_80211_hdr_4addrqos
*)hdr
;
178 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
181 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
182 hdr_3addrqos
= (struct rtl_80211_hdr_3addrqos
*)hdr
;
183 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
190 entry
= ieee80211_frag_cache_find(ieee
, seq
, -1, tid
, hdr
->addr2
,
194 IEEE80211_DEBUG_FRAG(
195 "could not invalidate fragment cache "
196 "entry (seq=%u)\n", seq
);
206 /* ieee80211_rx_frame_mgtmt
208 * Responsible for handling management control frames
210 * Called by ieee80211_rx */
212 ieee80211_rx_frame_mgmt(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
213 struct ieee80211_rx_stats
*rx_stats
, u16 type
,
216 /* On the struct stats definition there is written that
217 * this is not mandatory.... but seems that the probe
218 * response parser uses it
220 struct rtl_80211_hdr_3addr
*hdr
= (struct rtl_80211_hdr_3addr
*)skb
->data
;
222 rx_stats
->len
= skb
->len
;
223 ieee80211_rx_mgt(ieee
,(struct rtl_80211_hdr_4addr
*)skb
->data
,rx_stats
);
224 /* if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) */
225 if ((memcmp(hdr
->addr1
, ieee
->dev
->dev_addr
, ETH_ALEN
)))/* use ADDR1 to perform address matching for Management frames */
227 dev_kfree_skb_any(skb
);
231 ieee80211_rx_frame_softmac(ieee
, skb
, rx_stats
, type
, stype
);
233 dev_kfree_skb_any(skb
);
238 if (ieee
->iw_mode
== IW_MODE_MASTER
) {
239 printk(KERN_DEBUG
"%s: Master mode not yet supported.\n",
243 hostap_update_sta_ps(ieee, (struct hostap_ieee80211_hdr_4addr *)
247 if (ieee
->hostapd
&& type
== IEEE80211_TYPE_MGMT
) {
248 if (stype
== WLAN_FC_STYPE_BEACON
&&
249 ieee
->iw_mode
== IW_MODE_MASTER
) {
250 struct sk_buff
*skb2
;
251 /* Process beacon frames also in kernel driver to
252 * update STA(AP) table statistics */
253 skb2
= skb_clone(skb
, GFP_ATOMIC
);
255 hostap_rx(skb2
->dev
, skb2
, rx_stats
);
258 /* send management frames to the user space daemon for
260 ieee
->apdevstats
.rx_packets
++;
261 ieee
->apdevstats
.rx_bytes
+= skb
->len
;
262 prism2_rx_80211(ieee
->apdev
, skb
, rx_stats
, PRISM2_RX_MGMT
);
266 if (ieee
->iw_mode
== IW_MODE_MASTER
) {
267 if (type
!= WLAN_FC_TYPE_MGMT
&& type
!= WLAN_FC_TYPE_CTRL
) {
268 printk(KERN_DEBUG
"%s: unknown management frame "
269 "(type=0x%02x, stype=0x%02x) dropped\n",
270 skb
->dev
->name
, type
, stype
);
274 hostap_rx(skb
->dev
, skb
, rx_stats
);
278 printk(KERN_DEBUG
"%s: hostap_rx_frame_mgmt: management frame "
279 "received in non-Host AP mode\n", skb
->dev
->name
);
286 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
287 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
288 static unsigned char rfc1042_header
[] =
289 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
290 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
291 static unsigned char bridge_tunnel_header
[] =
292 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
293 /* No encapsulation header if EtherType < 0x600 (=length) */
295 /* Called by ieee80211_rx_frame_decrypt */
296 static int ieee80211_is_eapol_frame(struct ieee80211_device
*ieee
,
297 struct sk_buff
*skb
, size_t hdrlen
)
299 struct net_device
*dev
= ieee
->dev
;
301 struct rtl_80211_hdr_4addr
*hdr
;
307 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
308 fc
= le16_to_cpu(hdr
->frame_ctl
);
310 /* check that the frame is unicast frame to us */
311 if ((fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) ==
312 IEEE80211_FCTL_TODS
&&
313 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0 &&
314 memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
) == 0) {
315 /* ToDS frame with own addr BSSID and DA */
316 } else if ((fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) ==
317 IEEE80211_FCTL_FROMDS
&&
318 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
319 /* FromDS frame with own addr as DA */
323 if (skb
->len
< 24 + 8)
326 /* check for port access entity Ethernet type */
327 // pos = skb->data + 24;
328 pos
= skb
->data
+ hdrlen
;
329 ethertype
= (pos
[6] << 8) | pos
[7];
330 if (ethertype
== ETH_P_PAE
)
336 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
338 ieee80211_rx_frame_decrypt(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
339 struct ieee80211_crypt_data
*crypt
)
341 struct rtl_80211_hdr_4addr
*hdr
;
344 if (crypt
== NULL
|| crypt
->ops
->decrypt_mpdu
== NULL
)
346 if (ieee
->hwsec_active
)
348 struct cb_desc
*tcb_desc
= (struct cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
349 tcb_desc
->bHwSec
= 1;
351 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
352 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
354 if (ieee
->tkip_countermeasures
&&
355 strcmp(crypt
->ops
->name
, "TKIP") == 0) {
356 if (net_ratelimit()) {
357 printk(KERN_DEBUG
"%s: TKIP countermeasures: dropped "
358 "received packet from %pM\n",
359 ieee
->dev
->name
, hdr
->addr2
);
364 atomic_inc(&crypt
->refcnt
);
365 res
= crypt
->ops
->decrypt_mpdu(skb
, hdrlen
, crypt
->priv
);
366 atomic_dec(&crypt
->refcnt
);
368 IEEE80211_DEBUG_DROP(
369 "decryption failed (SA=%pM"
370 ") res=%d\n", hdr
->addr2
, res
);
372 IEEE80211_DEBUG_DROP("Decryption failed ICV "
373 "mismatch (key %d)\n",
374 skb
->data
[hdrlen
+ 3] >> 6);
375 ieee
->ieee_stats
.rx_discards_undecryptable
++;
383 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
385 ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
386 int keyidx
, struct ieee80211_crypt_data
*crypt
)
388 struct rtl_80211_hdr_4addr
*hdr
;
391 if (crypt
== NULL
|| crypt
->ops
->decrypt_msdu
== NULL
)
393 if (ieee
->hwsec_active
)
395 struct cb_desc
*tcb_desc
= (struct cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
396 tcb_desc
->bHwSec
= 1;
399 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
400 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
402 atomic_inc(&crypt
->refcnt
);
403 res
= crypt
->ops
->decrypt_msdu(skb
, keyidx
, hdrlen
, crypt
->priv
);
404 atomic_dec(&crypt
->refcnt
);
406 printk(KERN_DEBUG
"%s: MSDU decryption/MIC verification failed"
407 " (SA=%pM keyidx=%d)\n",
408 ieee
->dev
->name
, hdr
->addr2
, keyidx
);
416 /* this function is stolen from ipw2200 driver*/
417 #define IEEE_PACKET_RETRY_TIME (5*HZ)
418 static int is_duplicate_packet(struct ieee80211_device
*ieee
,
419 struct rtl_80211_hdr_4addr
*header
)
421 u16 fc
= le16_to_cpu(header
->frame_ctl
);
422 u16 sc
= le16_to_cpu(header
->seq_ctl
);
423 u16 seq
= WLAN_GET_SEQ_SEQ(sc
);
424 u16 frag
= WLAN_GET_SEQ_FRAG(sc
);
425 u16
*last_seq
, *last_frag
;
426 unsigned long *last_time
;
427 struct rtl_80211_hdr_3addrqos
*hdr_3addrqos
;
428 struct rtl_80211_hdr_4addrqos
*hdr_4addrqos
;
433 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
434 hdr_4addrqos
= (struct rtl_80211_hdr_4addrqos
*)header
;
435 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
438 } else if(IEEE80211_QOS_HAS_SEQ(fc
)) { //QoS
439 hdr_3addrqos
= (struct rtl_80211_hdr_3addrqos
*)header
;
440 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
447 switch (ieee
->iw_mode
) {
451 struct ieee_ibss_seq
*entry
= NULL
;
452 u8
*mac
= header
->addr2
;
453 int index
= mac
[5] % IEEE_IBSS_MAC_HASH_SIZE
;
455 list_for_each(p
, &ieee
->ibss_mac_hash
[index
]) {
456 entry
= list_entry(p
, struct ieee_ibss_seq
, list
);
457 if (!memcmp(entry
->mac
, mac
, ETH_ALEN
))
460 // if (memcmp(entry->mac, mac, ETH_ALEN)){
461 if (p
== &ieee
->ibss_mac_hash
[index
]) {
462 entry
= kmalloc(sizeof(struct ieee_ibss_seq
), GFP_ATOMIC
);
465 memcpy(entry
->mac
, mac
, ETH_ALEN
);
466 entry
->seq_num
[tid
] = seq
;
467 entry
->frag_num
[tid
] = frag
;
468 entry
->packet_time
[tid
] = jiffies
;
469 list_add(&entry
->list
, &ieee
->ibss_mac_hash
[index
]);
472 last_seq
= &entry
->seq_num
[tid
];
473 last_frag
= &entry
->frag_num
[tid
];
474 last_time
= &entry
->packet_time
[tid
];
479 last_seq
= &ieee
->last_rxseq_num
[tid
];
480 last_frag
= &ieee
->last_rxfrag_num
[tid
];
481 last_time
= &ieee
->last_packet_time
[tid
];
489 // printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
491 if ((*last_seq
== seq
) &&
492 time_after(*last_time
+ IEEE_PACKET_RETRY_TIME
, jiffies
)) {
493 if (*last_frag
== frag
)
495 if (*last_frag
+ 1 != frag
)
496 /* out-of-order fragment */
502 *last_time
= jiffies
;
506 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
511 static bool AddReorderEntry(PRX_TS_RECORD pTS
, PRX_REORDER_ENTRY pReorderEntry
)
513 struct list_head
*pList
= &pTS
->RxPendingPktList
;
514 while(pList
->next
!= &pTS
->RxPendingPktList
)
516 if( SN_LESS(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
520 else if( SN_EQUAL(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
529 pReorderEntry
->List
.next
= pList
->next
;
530 pReorderEntry
->List
.next
->prev
= &pReorderEntry
->List
;
531 pReorderEntry
->List
.prev
= pList
;
532 pList
->next
= &pReorderEntry
->List
;
537 void ieee80211_indicate_packets(struct ieee80211_device
*ieee
, struct ieee80211_rxb
**prxbIndicateArray
,u8 index
)
542 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__func__,index);
543 for(j
= 0; j
<index
; j
++)
545 //added by amy for reorder
546 struct ieee80211_rxb
*prxb
= prxbIndicateArray
[j
];
547 for(i
= 0; i
<prxb
->nr_subframes
; i
++) {
548 struct sk_buff
*sub_skb
= prxb
->subframes
[i
];
550 /* convert hdr + possible LLC headers into Ethernet header */
551 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
552 if (sub_skb
->len
>= 8 &&
553 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
554 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
555 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
556 /* remove RFC1042 or Bridge-Tunnel encapsulation and
557 * replace EtherType */
558 skb_pull(sub_skb
, SNAP_SIZE
);
559 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->src
, ETH_ALEN
);
560 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->dst
, ETH_ALEN
);
563 /* Leave Ethernet header part of hdr and full payload */
564 len
= htons(sub_skb
->len
);
565 memcpy(skb_push(sub_skb
, 2), &len
, 2);
566 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->src
, ETH_ALEN
);
567 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->dst
, ETH_ALEN
);
569 //stats->rx_packets++;
570 //stats->rx_bytes += sub_skb->len;
572 /* Indicat the packets to upper layer */
574 sub_skb
->protocol
= eth_type_trans(sub_skb
, ieee
->dev
);
575 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
576 sub_skb
->dev
= ieee
->dev
;
577 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
578 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
579 ieee
->last_rx_ps_time
= jiffies
;
589 static void RxReorderIndicatePacket(struct ieee80211_device
*ieee
,
590 struct ieee80211_rxb
*prxb
,
591 PRX_TS_RECORD pTS
, u16 SeqNum
)
593 PRT_HIGH_THROUGHPUT pHTInfo
= ieee
->pHTInfo
;
594 PRX_REORDER_ENTRY pReorderEntry
= NULL
;
595 struct ieee80211_rxb
**prxbIndicateArray
;
596 u8 WinSize
= pHTInfo
->RxReorderWinSize
;
597 u16 WinEnd
= (pTS
->RxIndicateSeq
+ WinSize
-1)%4096;
599 bool bMatchWinStart
= false, bPktInBuf
= false;
600 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__
,SeqNum
,pTS
->RxIndicateSeq
,WinSize
);
602 prxbIndicateArray
= kmalloc(sizeof(struct ieee80211_rxb
*) *
603 REORDER_WIN_SIZE
, GFP_KERNEL
);
604 if (!prxbIndicateArray
)
607 /* Rx Reorder initialize condition.*/
608 if (pTS
->RxIndicateSeq
== 0xffff) {
609 pTS
->RxIndicateSeq
= SeqNum
;
612 /* Drop out the packet which SeqNum is smaller than WinStart */
613 if (SN_LESS(SeqNum
, pTS
->RxIndicateSeq
)) {
614 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
615 pTS
->RxIndicateSeq
, SeqNum
);
616 pHTInfo
->RxReorderDropCounter
++;
619 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
620 dev_kfree_skb(prxb
->subframes
[i
]);
626 kfree(prxbIndicateArray
);
631 * Sliding window manipulation. Conditions includes:
632 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
633 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
635 if(SN_EQUAL(SeqNum
, pTS
->RxIndicateSeq
)) {
636 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
637 bMatchWinStart
= true;
638 } else if(SN_LESS(WinEnd
, SeqNum
)) {
639 if(SeqNum
>= (WinSize
- 1)) {
640 pTS
->RxIndicateSeq
= SeqNum
+ 1 -WinSize
;
642 pTS
->RxIndicateSeq
= 4095 - (WinSize
- (SeqNum
+1)) + 1;
644 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
648 * Indication process.
649 * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
650 * with the SeqNum smaller than latest WinStart and buffer other packets.
652 /* For Rx Reorder condition:
653 * 1. All packets with SeqNum smaller than WinStart => Indicate
654 * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
657 /* Current packet is going to be indicated.*/
658 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
659 pTS
->RxIndicateSeq
, SeqNum
);
660 prxbIndicateArray
[0] = prxb
;
661 // printk("========================>%s(): SeqNum is %d\n",__func__,SeqNum);
664 /* Current packet is going to be inserted into pending list.*/
665 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to ordered list\n",__func__);
666 if(!list_empty(&ieee
->RxReorder_Unused_List
)) {
667 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(ieee
->RxReorder_Unused_List
.next
,RX_REORDER_ENTRY
,List
);
668 list_del_init(&pReorderEntry
->List
);
670 /* Make a reorder entry and insert into a the packet list.*/
671 pReorderEntry
->SeqNum
= SeqNum
;
672 pReorderEntry
->prxb
= prxb
;
673 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__func__,pReorderEntry->SeqNum);
675 if(!AddReorderEntry(pTS
, pReorderEntry
)) {
676 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
677 __func__
, pTS
->RxIndicateSeq
, SeqNum
);
678 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
681 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
682 dev_kfree_skb(prxb
->subframes
[i
]);
688 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,
689 "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
694 * Packets are dropped if there is not enough reorder entries.
695 * This part shall be modified!! We can just indicate all the
696 * packets in buffer and get reorder entries.
698 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
701 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
702 dev_kfree_skb(prxb
->subframes
[i
]);
710 /* Check if there is any packet need indicate.*/
711 while(!list_empty(&pTS
->RxPendingPktList
)) {
712 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): start RREORDER indicate\n",__func__
);
713 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(pTS
->RxPendingPktList
.prev
,RX_REORDER_ENTRY
,List
);
714 if (SN_LESS(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
) ||
715 SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
717 /* This protect buffer from overflow. */
718 if (index
>= REORDER_WIN_SIZE
) {
719 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Buffer overflow!! \n");
724 list_del_init(&pReorderEntry
->List
);
726 if(SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
727 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
729 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
730 prxbIndicateArray
[index
] = pReorderEntry
->prxb
;
731 // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__func__,pReorderEntry->SeqNum);
734 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
741 /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
743 // Cancel previous pending timer.
744 // del_timer_sync(&pTS->RxPktPendingTimer);
745 pTS
->RxTimeoutIndicateSeq
= 0xffff;
748 if(index
>REORDER_WIN_SIZE
){
749 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Rx Reorder buffer full!! \n");
750 kfree(prxbIndicateArray
);
753 ieee80211_indicate_packets(ieee
, prxbIndicateArray
, index
);
756 if (bPktInBuf
&& pTS
->RxTimeoutIndicateSeq
==0xffff) {
757 // Set new pending timer.
758 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): SET rx timeout timer\n", __func__
);
759 pTS
->RxTimeoutIndicateSeq
= pTS
->RxIndicateSeq
;
760 if(timer_pending(&pTS
->RxPktPendingTimer
))
761 del_timer_sync(&pTS
->RxPktPendingTimer
);
762 pTS
->RxPktPendingTimer
.expires
= jiffies
+
763 msecs_to_jiffies(pHTInfo
->RxReorderPendingTime
);
764 add_timer(&pTS
->RxPktPendingTimer
);
767 kfree(prxbIndicateArray
);
770 static u8
parse_subframe(struct sk_buff
*skb
,
771 struct ieee80211_rx_stats
*rx_stats
,
772 struct ieee80211_rxb
*rxb
, u8
*src
, u8
*dst
)
774 struct rtl_80211_hdr_3addr
*hdr
= (struct rtl_80211_hdr_3addr
*)skb
->data
;
775 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
777 u16 LLCOffset
= sizeof(struct rtl_80211_hdr_3addr
);
779 bool bIsAggregateFrame
= false;
780 u16 nSubframe_Length
;
781 u8 nPadding_Length
= 0;
784 struct sk_buff
*sub_skb
;
786 /* just for debug purpose */
787 SeqNum
= WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr
->seq_ctl
));
789 if ((IEEE80211_QOS_HAS_SEQ(fc
))&&\
790 (((frameqos
*)(skb
->data
+ IEEE80211_3ADDR_LEN
))->field
.reserved
)) {
791 bIsAggregateFrame
= true;
794 if (IEEE80211_QOS_HAS_SEQ(fc
)) {
798 if (rx_stats
->bContainHTC
) {
799 LLCOffset
+= sHTCLng
;
801 // Null packet, don't indicate it to upper layer
802 ChkLength
= LLCOffset
;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
804 if (skb
->len
<= ChkLength
)
807 skb_pull(skb
, LLCOffset
);
809 if(!bIsAggregateFrame
) {
810 rxb
->nr_subframes
= 1;
812 rxb
->subframes
[0] = skb
;
814 rxb
->subframes
[0] = skb_copy(skb
, GFP_ATOMIC
);
817 memcpy(rxb
->src
,src
,ETH_ALEN
);
818 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
819 //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
822 rxb
->nr_subframes
= 0;
823 memcpy(rxb
->src
,src
,ETH_ALEN
);
824 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
825 while(skb
->len
> ETHERNET_HEADER_SIZE
) {
826 /* Offset 12 denote 2 mac address */
827 nSubframe_Length
= *((u16
*)(skb
->data
+ 12));
828 //==m==>change the length order
829 nSubframe_Length
= (nSubframe_Length
>>8) + (nSubframe_Length
<<8);
831 if (skb
->len
<(ETHERNET_HEADER_SIZE
+ nSubframe_Length
)) {
832 printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
833 __func__
, rxb
->nr_subframes
);
834 printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__func__
, nSubframe_Length
);
835 printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb
->len
,nSubframe_Length
);
836 printk("The Packet SeqNum is %d\n",SeqNum
);
840 /* move the data point to data content */
841 skb_pull(skb
, ETHERNET_HEADER_SIZE
);
844 sub_skb
= skb_clone(skb
, GFP_ATOMIC
);
845 sub_skb
->len
= nSubframe_Length
;
846 sub_skb
->tail
= sub_skb
->data
+ nSubframe_Length
;
848 /* Allocate new skb for releasing to upper layer */
849 sub_skb
= dev_alloc_skb(nSubframe_Length
+ 12);
852 skb_reserve(sub_skb
, 12);
853 data_ptr
= (u8
*)skb_put(sub_skb
, nSubframe_Length
);
854 memcpy(data_ptr
, skb
->data
, nSubframe_Length
);
856 rxb
->subframes
[rxb
->nr_subframes
++] = sub_skb
;
857 if (rxb
->nr_subframes
>= MAX_SUBFRAME_COUNT
) {
858 IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
861 skb_pull(skb
, nSubframe_Length
);
864 nPadding_Length
= 4 - ((nSubframe_Length
+ ETHERNET_HEADER_SIZE
) % 4);
865 if (nPadding_Length
== 4) {
869 if (skb
->len
< nPadding_Length
) {
873 skb_pull(skb
, nPadding_Length
);
879 //{just for debug added by david
880 //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
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_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 rtl_80211_hdr_4addr
*hdr
;
894 //struct rtl_80211_hdr_3addrqos *hdr;
897 u16 fc
, type
, stype
, sc
;
898 struct net_device_stats
*stats
;
902 //added by amy for reorder
905 PRX_TS_RECORD pTS
= NULL
;
906 //bool bIsAggregateFrame = false;
907 //added by amy for reorder
909 struct net_device
*wds
= NULL
;
910 struct net_device
*wds
= NULL
;
911 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 rtl_80211_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
= true;
949 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
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 hostap_update_rx_stats(local
->ap
, hdr
, rx_stats
);
967 if (ieee
->iw_mode
== IW_MODE_MONITOR
) {
968 ieee80211_monitor_rx(ieee
, skb
, rx_stats
);
970 stats
->rx_bytes
+= skb
->len
;
974 if (ieee
->host_decrypt
) {
976 if (skb
->len
>= hdrlen
+ 3)
977 idx
= skb
->data
[hdrlen
+ 3] >> 6;
978 crypt
= ieee
->crypt
[idx
];
982 /* Use station specific key to override default keys if the
983 * receiver address is a unicast address ("individual RA"). If
984 * bcrx_sta_key parameter is set, station specific key is used
985 * even with broad/multicast targets (this is against IEEE
986 * 802.11, but makes it easier to use different keys with
987 * stations that do not support WEP key mapping). */
989 if (!(hdr
->addr1
[0] & 0x01) || local
->bcrx_sta_key
)
990 (void) hostap_handle_sta_crypto(local
, hdr
, &crypt
,
994 /* allow NULL decrypt to indicate an station specific override
995 * for default encryption */
996 if (crypt
&& (crypt
->ops
== NULL
||
997 crypt
->ops
->decrypt_mpdu
== NULL
))
1000 if (!crypt
&& (fc
& IEEE80211_FCTL_WEP
)) {
1001 /* This seems to be triggered by some (multicast?)
1002 * frames from other than current BSS, so just drop the
1003 * frames silently instead of filling system log with
1005 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
1008 ieee
->ieee_stats
.rx_discards_undecryptable
++;
1013 if (skb
->len
< IEEE80211_DATA_HDR3_LEN
)
1016 // if QoS enabled, should check the sequence for each of the AC
1017 if ((!ieee
->pHTInfo
->bCurRxReorderEnable
) || !ieee
->current_network
.qos_data
.active
|| !IsDataFrame(skb
->data
) || IsLegacyDataFrame(skb
->data
)) {
1018 if (is_duplicate_packet(ieee
, hdr
))
1024 PRX_TS_RECORD pRxTS
= NULL
;
1025 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__func__, tid);
1028 (PTS_COMMON_INFO
*) &pRxTS
,
1030 Frame_QoSTID((u8
*)(skb
->data
)),
1035 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__func__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
1036 if ((fc
& (1<<11)) &&
1037 (frag
== pRxTS
->RxLastFragNum
) &&
1038 (WLAN_GET_SEQ_SEQ(sc
) == pRxTS
->RxLastSeqNum
)) {
1043 pRxTS
->RxLastFragNum
= frag
;
1044 pRxTS
->RxLastSeqNum
= WLAN_GET_SEQ_SEQ(sc
);
1049 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "%s(): No TS!! Skip the check!!\n",__func__
);
1053 if (type
== IEEE80211_FTYPE_MGMT
) {
1056 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1057 if (ieee80211_rx_frame_mgmt(ieee
, skb
, rx_stats
, type
, stype
))
1063 /* Data frame - extract src/dst addresses */
1064 switch (fc
& (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
1065 case IEEE80211_FCTL_FROMDS
:
1066 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1067 memcpy(src
, hdr
->addr3
, ETH_ALEN
);
1068 memcpy(bssid
, hdr
->addr2
, ETH_ALEN
);
1070 case IEEE80211_FCTL_TODS
:
1071 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1072 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1073 memcpy(bssid
, hdr
->addr1
, ETH_ALEN
);
1075 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
1076 if (skb
->len
< IEEE80211_DATA_HDR4_LEN
)
1078 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1079 memcpy(src
, hdr
->addr4
, ETH_ALEN
);
1080 memcpy(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
);
1083 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1084 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1085 memcpy(bssid
, hdr
->addr3
, ETH_ALEN
);
1090 if (hostap_rx_frame_wds(ieee
, hdr
, fc
, &wds
))
1093 skb
->dev
= dev
= wds
;
1094 stats
= hostap_get_stats(dev
);
1097 if (ieee
->iw_mode
== IW_MODE_MASTER
&& !wds
&&
1098 (fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) == IEEE80211_FCTL_FROMDS
&&
1100 memcmp(hdr
->addr2
, ieee
->assoc_ap_addr
, ETH_ALEN
) == 0) {
1101 /* Frame from BSSID of the AP for which we are a client */
1102 skb
->dev
= dev
= ieee
->stadev
;
1103 stats
= hostap_get_stats(dev
);
1107 if ((ieee
->iw_mode
== IW_MODE_MASTER
||
1108 ieee
->iw_mode
== IW_MODE_REPEAT
) &&
1110 switch (hostap_handle_sta_rx(ieee
, dev
, skb
, rx_stats
,
1112 case AP_RX_CONTINUE_NOT_AUTHORIZED
:
1113 case AP_RX_CONTINUE
:
1122 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1123 /* Nullfunc frames may have PS-bit set, so they must be passed to
1124 * hostap_handle_sta_rx() before being dropped here. */
1125 if (stype
!= IEEE80211_STYPE_DATA
&&
1126 stype
!= IEEE80211_STYPE_DATA_CFACK
&&
1127 stype
!= IEEE80211_STYPE_DATA_CFPOLL
&&
1128 stype
!= IEEE80211_STYPE_DATA_CFACKPOLL
&&
1129 stype
!= IEEE80211_STYPE_QOS_DATA
//add by David,2006.8.4
1131 if (stype
!= IEEE80211_STYPE_NULLFUNC
)
1132 IEEE80211_DEBUG_DROP(
1133 "RX: dropped data frame "
1134 "with no data (type=0x%02x, "
1135 "subtype=0x%02x, len=%d)\n",
1136 type
, stype
, skb
->len
);
1139 if (memcmp(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
))
1142 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
1144 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1145 (keyidx
= ieee80211_rx_frame_decrypt(ieee
, skb
, crypt
)) < 0)
1147 printk("decrypt frame error\n");
1152 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
1154 /* skb: hdr + (possibly fragmented) plaintext payload */
1155 // PR: FIXME: hostap has additional conditions in the "if" below:
1156 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1157 if ((frag
!= 0 || (fc
& IEEE80211_FCTL_MOREFRAGS
))) {
1159 struct sk_buff
*frag_skb
= ieee80211_frag_cache_get(ieee
, hdr
);
1160 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag
);
1163 IEEE80211_DEBUG(IEEE80211_DL_RX
| IEEE80211_DL_FRAG
,
1164 "Rx cannot get skb from fragment "
1165 "cache (morefrag=%d seq=%u frag=%u)\n",
1166 (fc
& IEEE80211_FCTL_MOREFRAGS
) != 0,
1167 WLAN_GET_SEQ_SEQ(sc
), frag
);
1174 if (frag_skb
->tail
+ flen
> frag_skb
->end
) {
1175 printk(KERN_WARNING
"%s: host decrypted and "
1176 "reassembled frame did not fit skb\n",
1178 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1183 /* copy first fragment (including full headers) into
1184 * beginning of the fragment cache skb */
1185 memcpy(skb_put(frag_skb
, flen
), skb
->data
, flen
);
1187 /* append frame payload to the end of the fragment
1189 memcpy(skb_put(frag_skb
, flen
), skb
->data
+ hdrlen
,
1192 dev_kfree_skb_any(skb
);
1195 if (fc
& IEEE80211_FCTL_MOREFRAGS
) {
1196 /* more fragments expected - leave the skb in fragment
1197 * cache for now; it will be delivered to upper layers
1198 * after all fragments have been received */
1202 /* this was the last fragment and the frame will be
1203 * delivered, so remove skb from fragment cache */
1205 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
1206 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1209 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1210 * encrypted/authenticated */
1211 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1212 ieee80211_rx_frame_decrypt_msdu(ieee
, skb
, keyidx
, crypt
))
1214 printk("==>decrypt msdu error\n");
1218 //added by amy for AP roaming
1219 ieee
->LinkDetectInfo
.NumRecvDataInPeriod
++;
1220 ieee
->LinkDetectInfo
.NumRxOkInPeriod
++;
1222 hdr
= (struct rtl_80211_hdr_4addr
*) skb
->data
;
1223 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
) {
1224 if (/*ieee->ieee802_1x &&*/
1225 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1227 #ifdef CONFIG_IEEE80211_DEBUG
1228 /* pass unencrypted EAPOL frames even if encryption is
1230 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1232 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1233 eap_get_type(eap
->type
));
1236 IEEE80211_DEBUG_DROP(
1237 "encryption configured, but RX "
1238 "frame not encrypted (SA=%pM)\n",
1244 #ifdef CONFIG_IEEE80211_DEBUG
1245 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) &&
1246 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1247 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1249 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1250 eap_get_type(eap
->type
));
1254 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
&&
1255 !ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1256 IEEE80211_DEBUG_DROP(
1257 "dropped unencrypted RX data "
1259 " (drop_unencrypted=1)\n",
1264 if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1265 printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
1268 //added by amy for reorder
1269 if (ieee
->current_network
.qos_data
.active
&& IsQoSDataFrame(skb
->data
)
1270 && !is_multicast_ether_addr(hdr
->addr1
))
1272 TID
= Frame_QoSTID(skb
->data
);
1273 SeqNum
= WLAN_GET_SEQ_SEQ(sc
);
1274 GetTs(ieee
,(PTS_COMMON_INFO
*) &pTS
,hdr
->addr2
,TID
,RX_DIR
,true);
1275 if (TID
!=0 && TID
!=3)
1277 ieee
->bis_any_nonbepkts
= true;
1280 //added by amy for reorder
1281 /* skb: hdr + (possible reassembled) full plaintext payload */
1282 payload
= skb
->data
+ hdrlen
;
1283 //ethertype = (payload[6] << 8) | payload[7];
1284 rxb
= kmalloc(sizeof(struct ieee80211_rxb
), GFP_ATOMIC
);
1287 /* to parse amsdu packets */
1288 /* qos data packets & reserved bit is 1 */
1289 if (parse_subframe(skb
, rx_stats
, rxb
, src
, dst
) == 0) {
1290 /* only to free rxb, and not submit the packets to upper layer */
1291 for(i
=0; i
< rxb
->nr_subframes
; i
++) {
1292 dev_kfree_skb(rxb
->subframes
[i
]);
1299 //added by amy for reorder
1300 if (!ieee
->pHTInfo
->bCurRxReorderEnable
|| pTS
== NULL
){
1301 //added by amy for reorder
1302 for(i
= 0; i
<rxb
->nr_subframes
; i
++) {
1303 struct sk_buff
*sub_skb
= rxb
->subframes
[i
];
1306 /* convert hdr + possible LLC headers into Ethernet header */
1307 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
1308 if (sub_skb
->len
>= 8 &&
1309 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
1310 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
1311 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
1312 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1313 * replace EtherType */
1314 skb_pull(sub_skb
, SNAP_SIZE
);
1315 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1316 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1319 /* Leave Ethernet header part of hdr and full payload */
1320 len
= htons(sub_skb
->len
);
1321 memcpy(skb_push(sub_skb
, 2), &len
, 2);
1322 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1323 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1326 stats
->rx_packets
++;
1327 stats
->rx_bytes
+= sub_skb
->len
;
1328 if (is_multicast_ether_addr(dst
)) {
1332 /* Indicat the packets to upper layer */
1333 sub_skb
->protocol
= eth_type_trans(sub_skb
, dev
);
1334 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
1336 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
1337 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
1338 ieee
->last_rx_ps_time
= jiffies
;
1348 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__func__
);
1349 RxReorderIndicatePacket(ieee
, rxb
, pTS
, SeqNum
);
1358 hostap_handle_sta_release(sta
);
1365 stats
->rx_dropped
++;
1367 /* Returning 0 indicates to caller that we have not handled the SKB--
1368 * so it is still allocated and can be used again by underlying
1369 * hardware as a DMA target */
1372 EXPORT_SYMBOL(ieee80211_rx
);
1374 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
1376 static u8 qos_oui
[QOS_OUI_LEN
] = { 0x00, 0x50, 0xF2 };
1379 * Make the structure we read from the beacon packet to have
1382 static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
1383 *info_element
, int sub_type
)
1386 if (info_element
->qui_subtype
!= sub_type
)
1388 if (memcmp(info_element
->qui
, qos_oui
, QOS_OUI_LEN
))
1390 if (info_element
->qui_type
!= QOS_OUI_TYPE
)
1392 if (info_element
->version
!= QOS_VERSION_1
)
1400 * Parse a QoS parameter element
1402 static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
1403 *element_param
, struct ieee80211_info_element
1407 u16 size
= sizeof(struct ieee80211_qos_parameter_info
) - 2;
1409 if ((info_element
== NULL
) || (element_param
== NULL
))
1412 if (info_element
->id
== QOS_ELEMENT_ID
&& info_element
->len
== size
) {
1413 memcpy(element_param
->info_element
.qui
, info_element
->data
,
1415 element_param
->info_element
.elementID
= info_element
->id
;
1416 element_param
->info_element
.length
= info_element
->len
;
1420 ret
= ieee80211_verify_qos_info(&element_param
->info_element
,
1421 QOS_OUI_PARAM_SUB_TYPE
);
1426 * Parse a QoS information element
1428 static int ieee80211_read_qos_info_element(struct
1429 ieee80211_qos_information_element
1430 *element_info
, struct ieee80211_info_element
1434 u16 size
= sizeof(struct ieee80211_qos_information_element
) - 2;
1436 if (element_info
== NULL
)
1438 if (info_element
== NULL
)
1441 if ((info_element
->id
== QOS_ELEMENT_ID
) && (info_element
->len
== size
)) {
1442 memcpy(element_info
->qui
, info_element
->data
,
1444 element_info
->elementID
= info_element
->id
;
1445 element_info
->length
= info_element
->len
;
1450 ret
= ieee80211_verify_qos_info(element_info
,
1451 QOS_OUI_INFO_SUB_TYPE
);
1457 * Write QoS parameters from the ac parameters.
1459 static int ieee80211_qos_convert_ac_to_parameters(struct
1460 ieee80211_qos_parameter_info
1462 ieee80211_qos_parameters
1466 struct ieee80211_qos_ac_parameter
*ac_params
;
1471 for (i
= 0; i
< QOS_QUEUE_NUM
; i
++) {
1472 ac_params
= &(param_elm
->ac_params_record
[i
]);
1474 aci
= (ac_params
->aci_aifsn
& 0x60) >> 5;
1476 if(aci
>= QOS_QUEUE_NUM
)
1478 qos_param
->aifs
[aci
] = (ac_params
->aci_aifsn
) & 0x0f;
1480 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1481 qos_param
->aifs
[aci
] = (qos_param
->aifs
[aci
] < 2) ? 2:qos_param
->aifs
[aci
];
1483 qos_param
->cw_min
[aci
] = ac_params
->ecw_min_max
& 0x0F;
1485 qos_param
->cw_max
[aci
] = (ac_params
->ecw_min_max
& 0xF0) >> 4;
1487 qos_param
->flag
[aci
] =
1488 (ac_params
->aci_aifsn
& 0x10) ? 0x01 : 0x00;
1489 qos_param
->tx_op_limit
[aci
] = le16_to_cpu(ac_params
->tx_op_limit
);
1495 * we have a generic data element which it may contain QoS information or
1496 * parameters element. check the information element length to decide
1497 * which type to read
1499 static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1501 struct ieee80211_network
*network
)
1504 struct ieee80211_qos_parameters
*qos_param
= NULL
;
1505 struct ieee80211_qos_information_element qos_info_element
;
1507 rc
= ieee80211_read_qos_info_element(&qos_info_element
, info_element
);
1510 network
->qos_data
.param_count
= qos_info_element
.ac_info
& 0x0F;
1511 network
->flags
|= NETWORK_HAS_QOS_INFORMATION
;
1513 struct ieee80211_qos_parameter_info param_element
;
1515 rc
= ieee80211_read_qos_param_element(¶m_element
,
1518 qos_param
= &(network
->qos_data
.parameters
);
1519 ieee80211_qos_convert_ac_to_parameters(¶m_element
,
1521 network
->flags
|= NETWORK_HAS_QOS_PARAMETERS
;
1522 network
->qos_data
.param_count
=
1523 param_element
.info_element
.ac_info
& 0x0F;
1528 IEEE80211_DEBUG_QOS("QoS is supported\n");
1529 network
->qos_data
.supported
= 1;
1534 #ifdef CONFIG_IEEE80211_DEBUG
1535 #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1537 static const char *get_info_element_string(u16 id
)
1542 MFIE_STRING(FH_SET
);
1543 MFIE_STRING(DS_SET
);
1544 MFIE_STRING(CF_SET
);
1546 MFIE_STRING(IBSS_SET
);
1547 MFIE_STRING(COUNTRY
);
1548 MFIE_STRING(HOP_PARAMS
);
1549 MFIE_STRING(HOP_TABLE
);
1550 MFIE_STRING(REQUEST
);
1551 MFIE_STRING(CHALLENGE
);
1552 MFIE_STRING(POWER_CONSTRAINT
);
1553 MFIE_STRING(POWER_CAPABILITY
);
1554 MFIE_STRING(TPC_REQUEST
);
1555 MFIE_STRING(TPC_REPORT
);
1556 MFIE_STRING(SUPP_CHANNELS
);
1558 MFIE_STRING(MEASURE_REQUEST
);
1559 MFIE_STRING(MEASURE_REPORT
);
1561 MFIE_STRING(IBSS_DFS
);
1562 // MFIE_STRING(ERP_INFO);
1564 MFIE_STRING(RATES_EX
);
1565 MFIE_STRING(GENERIC
);
1566 MFIE_STRING(QOS_PARAMETER
);
1573 static inline void ieee80211_extract_country_ie(
1574 struct ieee80211_device
*ieee
,
1575 struct ieee80211_info_element
*info_element
,
1576 struct ieee80211_network
*network
,
1580 if (IS_DOT11D_ENABLE(ieee
))
1582 if (info_element
->len
!= 0)
1584 memcpy(network
->CountryIeBuf
, info_element
->data
, info_element
->len
);
1585 network
->CountryIeLen
= info_element
->len
;
1587 if (!IS_COUNTRY_IE_VALID(ieee
))
1589 Dot11d_UpdateCountryIe(ieee
, addr2
, info_element
->len
, info_element
->data
);
1594 // 070305, rcnjko: I update country IE watch dog here because
1595 // some AP (e.g. Cisco 1242) don't include country IE in their
1596 // probe response frame.
1598 if (IS_EQUAL_CIE_SRC(ieee
, addr2
) )
1600 UPDATE_CIE_WATCHDOG(ieee
);
1606 int ieee80211_parse_info_param(struct ieee80211_device
*ieee
,
1607 struct ieee80211_info_element
*info_element
,
1609 struct ieee80211_network
*network
,
1610 struct ieee80211_rx_stats
*stats
)
1614 u16 tmp_htcap_len
=0;
1615 u16 tmp_htinfo_len
=0;
1616 u16 ht_realtek_agg_len
=0;
1617 u8 ht_realtek_agg_buf
[MAX_IE_LEN
];
1618 // u16 broadcom_len = 0;
1619 #ifdef CONFIG_IEEE80211_DEBUG
1624 while (length
>= sizeof(*info_element
)) {
1625 if (sizeof(*info_element
) + info_element
->len
> length
) {
1626 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1627 "info_element->len + 2 > left : "
1628 "info_element->len+2=%zd left=%d, id=%d.\n",
1630 sizeof(*info_element
),
1631 length
, info_element
->id
);
1632 /* We stop processing but don't return an error here
1633 * because some misbehaviour APs break this rule. ie.
1634 * Orinoco AP1000. */
1638 switch (info_element
->id
) {
1639 case MFIE_TYPE_SSID
:
1640 if (ieee80211_is_empty_essid(info_element
->data
,
1641 info_element
->len
)) {
1642 network
->flags
|= NETWORK_EMPTY_ESSID
;
1646 network
->ssid_len
= min(info_element
->len
,
1647 (u8
) IW_ESSID_MAX_SIZE
);
1648 memcpy(network
->ssid
, info_element
->data
, network
->ssid_len
);
1649 if (network
->ssid_len
< IW_ESSID_MAX_SIZE
)
1650 memset(network
->ssid
+ network
->ssid_len
, 0,
1651 IW_ESSID_MAX_SIZE
- network
->ssid_len
);
1653 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
1654 network
->ssid
, network
->ssid_len
);
1657 case MFIE_TYPE_RATES
:
1658 #ifdef CONFIG_IEEE80211_DEBUG
1661 network
->rates_len
= min(info_element
->len
,
1663 for (i
= 0; i
< network
->rates_len
; i
++) {
1664 network
->rates
[i
] = info_element
->data
[i
];
1665 #ifdef CONFIG_IEEE80211_DEBUG
1666 p
+= snprintf(p
, sizeof(rates_str
) -
1667 (p
- rates_str
), "%02X ",
1670 if (ieee80211_is_ofdm_rate
1671 (info_element
->data
[i
])) {
1672 network
->flags
|= NETWORK_HAS_OFDM
;
1673 if (info_element
->data
[i
] &
1674 IEEE80211_BASIC_RATE_MASK
)
1680 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
1681 rates_str
, network
->rates_len
);
1684 case MFIE_TYPE_RATES_EX
:
1685 #ifdef CONFIG_IEEE80211_DEBUG
1688 network
->rates_ex_len
= min(info_element
->len
,
1689 MAX_RATES_EX_LENGTH
);
1690 for (i
= 0; i
< network
->rates_ex_len
; i
++) {
1691 network
->rates_ex
[i
] = info_element
->data
[i
];
1692 #ifdef CONFIG_IEEE80211_DEBUG
1693 p
+= snprintf(p
, sizeof(rates_str
) -
1694 (p
- rates_str
), "%02X ",
1695 network
->rates_ex
[i
]);
1697 if (ieee80211_is_ofdm_rate
1698 (info_element
->data
[i
])) {
1699 network
->flags
|= NETWORK_HAS_OFDM
;
1700 if (info_element
->data
[i
] &
1701 IEEE80211_BASIC_RATE_MASK
)
1707 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
1708 rates_str
, network
->rates_ex_len
);
1711 case MFIE_TYPE_DS_SET
:
1712 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
1713 info_element
->data
[0]);
1714 network
->channel
= info_element
->data
[0];
1717 case MFIE_TYPE_FH_SET
:
1718 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
1721 case MFIE_TYPE_CF_SET
:
1722 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
1726 if(info_element
->len
< 4)
1729 network
->tim
.tim_count
= info_element
->data
[0];
1730 network
->tim
.tim_period
= info_element
->data
[1];
1732 network
->dtim_period
= info_element
->data
[1];
1733 if(ieee
->state
!= IEEE80211_LINKED
)
1736 network
->last_dtim_sta_time
[0] = stats
->mac_time
[0];
1737 network
->last_dtim_sta_time
[1] = stats
->mac_time
[1];
1739 network
->dtim_data
= IEEE80211_DTIM_VALID
;
1741 if(info_element
->data
[0] != 0)
1744 if(info_element
->data
[2] & 1)
1745 network
->dtim_data
|= IEEE80211_DTIM_MBCAST
;
1747 offset
= (info_element
->data
[2] >> 1)*2;
1749 if(ieee
->assoc_id
< 8*offset
||
1750 ieee
->assoc_id
> 8*(offset
+ info_element
->len
-3))
1754 offset
= (ieee
->assoc_id
/ 8) - offset
;// + ((aid % 8)? 0 : 1) ;
1756 if(info_element
->data
[3+offset
] & (1<<(ieee
->assoc_id
%8)))
1757 network
->dtim_data
|= IEEE80211_DTIM_UCAST
;
1759 //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
1763 network
->erp_value
= info_element
->data
[0];
1764 network
->flags
|= NETWORK_HAS_ERP_VALUE
;
1765 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1766 network
->erp_value
);
1768 case MFIE_TYPE_IBSS_SET
:
1769 network
->atim_window
= info_element
->data
[0];
1770 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1771 network
->atim_window
);
1774 case MFIE_TYPE_CHALLENGE
:
1775 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
1778 case MFIE_TYPE_GENERIC
:
1779 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
1781 if (!ieee80211_parse_qos_info_param_IE(info_element
,
1785 if (info_element
->len
>= 4 &&
1786 info_element
->data
[0] == 0x00 &&
1787 info_element
->data
[1] == 0x50 &&
1788 info_element
->data
[2] == 0xf2 &&
1789 info_element
->data
[3] == 0x01) {
1790 network
->wpa_ie_len
= min(info_element
->len
+ 2,
1792 memcpy(network
->wpa_ie
, info_element
,
1793 network
->wpa_ie_len
);
1798 if (info_element
->len
== 7 &&
1799 info_element
->data
[0] == 0x00 &&
1800 info_element
->data
[1] == 0xe0 &&
1801 info_element
->data
[2] == 0x4c &&
1802 info_element
->data
[3] == 0x01 &&
1803 info_element
->data
[4] == 0x02) {
1804 network
->Turbo_Enable
= 1;
1808 //for HTcap and HTinfo parameters
1809 if(tmp_htcap_len
== 0){
1810 if(info_element
->len
>= 4 &&
1811 info_element
->data
[0] == 0x00 &&
1812 info_element
->data
[1] == 0x90 &&
1813 info_element
->data
[2] == 0x4c &&
1814 info_element
->data
[3] == 0x033){
1816 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1817 if(tmp_htcap_len
!= 0){
1818 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1819 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
1820 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
1821 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
1824 if(tmp_htcap_len
!= 0)
1825 network
->bssht
.bdSupportHT
= true;
1827 network
->bssht
.bdSupportHT
= false;
1831 if(tmp_htinfo_len
== 0){
1832 if(info_element
->len
>= 4 &&
1833 info_element
->data
[0] == 0x00 &&
1834 info_element
->data
[1] == 0x90 &&
1835 info_element
->data
[2] == 0x4c &&
1836 info_element
->data
[3] == 0x034){
1838 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1839 if(tmp_htinfo_len
!= 0){
1840 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1842 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
1843 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
1844 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
1852 if(ieee
->aggregation
){
1853 if(network
->bssht
.bdSupportHT
){
1854 if(info_element
->len
>= 4 &&
1855 info_element
->data
[0] == 0x00 &&
1856 info_element
->data
[1] == 0xe0 &&
1857 info_element
->data
[2] == 0x4c &&
1858 info_element
->data
[3] == 0x02){
1860 ht_realtek_agg_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1861 memcpy(ht_realtek_agg_buf
,info_element
->data
,info_element
->len
);
1864 if(ht_realtek_agg_len
>= 5){
1865 network
->bssht
.bdRT2RTAggregation
= true;
1867 if((ht_realtek_agg_buf
[4] == 1) && (ht_realtek_agg_buf
[5] & 0x02))
1868 network
->bssht
.bdRT2RTLongSlotTime
= true;
1874 //if(tmp_htcap_len !=0 || tmp_htinfo_len != 0)
1876 if ((info_element
->len
>= 3 &&
1877 info_element
->data
[0] == 0x00 &&
1878 info_element
->data
[1] == 0x05 &&
1879 info_element
->data
[2] == 0xb5) ||
1880 (info_element
->len
>= 3 &&
1881 info_element
->data
[0] == 0x00 &&
1882 info_element
->data
[1] == 0x0a &&
1883 info_element
->data
[2] == 0xf7) ||
1884 (info_element
->len
>= 3 &&
1885 info_element
->data
[0] == 0x00 &&
1886 info_element
->data
[1] == 0x10 &&
1887 info_element
->data
[2] == 0x18)){
1889 network
->broadcom_cap_exist
= true;
1893 if(info_element
->len
>= 3 &&
1894 info_element
->data
[0] == 0x00 &&
1895 info_element
->data
[1] == 0x0c &&
1896 info_element
->data
[2] == 0x43)
1898 network
->ralink_cap_exist
= true;
1901 network
->ralink_cap_exist
= false;
1902 //added by amy for atheros AP
1903 if((info_element
->len
>= 3 &&
1904 info_element
->data
[0] == 0x00 &&
1905 info_element
->data
[1] == 0x03 &&
1906 info_element
->data
[2] == 0x7f) ||
1907 (info_element
->len
>= 3 &&
1908 info_element
->data
[0] == 0x00 &&
1909 info_element
->data
[1] == 0x13 &&
1910 info_element
->data
[2] == 0x74))
1912 printk("========>%s(): athros AP is exist\n",__func__
);
1913 network
->atheros_cap_exist
= true;
1916 network
->atheros_cap_exist
= false;
1918 if(info_element
->len
>= 3 &&
1919 info_element
->data
[0] == 0x00 &&
1920 info_element
->data
[1] == 0x40 &&
1921 info_element
->data
[2] == 0x96)
1923 network
->cisco_cap_exist
= true;
1926 network
->cisco_cap_exist
= false;
1927 //added by amy for LEAP of cisco
1928 if (info_element
->len
> 4 &&
1929 info_element
->data
[0] == 0x00 &&
1930 info_element
->data
[1] == 0x40 &&
1931 info_element
->data
[2] == 0x96 &&
1932 info_element
->data
[3] == 0x01)
1934 if(info_element
->len
== 6)
1936 memcpy(network
->CcxRmState
, &info_element
[4], 2);
1937 if(network
->CcxRmState
[0] != 0)
1939 network
->bCcxRmEnable
= true;
1942 network
->bCcxRmEnable
= false;
1944 // CCXv4 Table 59-1 MBSSID Masks.
1946 network
->MBssidMask
= network
->CcxRmState
[1] & 0x07;
1947 if(network
->MBssidMask
!= 0)
1949 network
->bMBssidValid
= true;
1950 network
->MBssidMask
= 0xff << (network
->MBssidMask
);
1951 cpMacAddr(network
->MBssid
, network
->bssid
);
1952 network
->MBssid
[5] &= network
->MBssidMask
;
1956 network
->bMBssidValid
= false;
1961 network
->bCcxRmEnable
= false;
1964 if (info_element
->len
> 4 &&
1965 info_element
->data
[0] == 0x00 &&
1966 info_element
->data
[1] == 0x40 &&
1967 info_element
->data
[2] == 0x96 &&
1968 info_element
->data
[3] == 0x03)
1970 if(info_element
->len
== 5)
1972 network
->bWithCcxVerNum
= true;
1973 network
->BssCcxVerNumber
= info_element
->data
[4];
1977 network
->bWithCcxVerNum
= false;
1978 network
->BssCcxVerNumber
= 0;
1984 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
1986 network
->rsn_ie_len
= min(info_element
->len
+ 2,
1988 memcpy(network
->rsn_ie
, info_element
,
1989 network
->rsn_ie_len
);
1992 //HT related element.
1993 case MFIE_TYPE_HT_CAP
:
1994 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
1996 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1997 if(tmp_htcap_len
!= 0){
1998 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1999 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
2000 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
2001 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
2003 //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
2004 // windows driver will update WMM parameters each beacon received once connected
2005 // Linux driver is a bit different.
2006 network
->bssht
.bdSupportHT
= true;
2009 network
->bssht
.bdSupportHT
= false;
2013 case MFIE_TYPE_HT_INFO
:
2014 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
2016 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
2018 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_IEEE
;
2019 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
2020 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
2021 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
2025 case MFIE_TYPE_AIRONET
:
2026 IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
2028 if(info_element
->len
>IE_CISCO_FLAG_POSITION
)
2030 network
->bWithAironetIE
= true;
2032 // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
2033 // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
2034 // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
2035 if( (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_MIC
) ||
2036 (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_PK
) )
2038 network
->bCkipSupported
= true;
2042 network
->bCkipSupported
= false;
2047 network
->bWithAironetIE
= false;
2048 network
->bCkipSupported
= false;
2051 case MFIE_TYPE_QOS_PARAMETER
:
2053 "QoS Error need to parse QOS_PARAMETER IE\n");
2056 case MFIE_TYPE_COUNTRY
:
2057 IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
2059 ieee80211_extract_country_ie(ieee
, info_element
, network
, network
->bssid
);//addr2 is same as addr3 when from an AP
2063 IEEE80211_DEBUG_MGMT
2064 ("Unsupported info element: %s (%d)\n",
2065 get_info_element_string(info_element
->id
),
2070 length
-= sizeof(*info_element
) + info_element
->len
;
2072 (struct ieee80211_info_element
*)&info_element
->
2073 data
[info_element
->len
];
2076 if(!network
->atheros_cap_exist
&& !network
->broadcom_cap_exist
&&
2077 !network
->cisco_cap_exist
&& !network
->ralink_cap_exist
&& !network
->bssht
.bdRT2RTAggregation
)
2079 network
->unknown_cap_exist
= true;
2083 network
->unknown_cap_exist
= false;
2088 static inline u8
ieee80211_SignalStrengthTranslate(
2094 // Step 1. Scale mapping.
2095 if(CurrSS
>= 71 && CurrSS
<= 100)
2097 RetSS
= 90 + ((CurrSS
- 70) / 3);
2099 else if(CurrSS
>= 41 && CurrSS
<= 70)
2101 RetSS
= 78 + ((CurrSS
- 40) / 3);
2103 else if(CurrSS
>= 31 && CurrSS
<= 40)
2105 RetSS
= 66 + (CurrSS
- 30);
2107 else if(CurrSS
>= 21 && CurrSS
<= 30)
2109 RetSS
= 54 + (CurrSS
- 20);
2111 else if(CurrSS
>= 5 && CurrSS
<= 20)
2113 RetSS
= 42 + (((CurrSS
- 5) * 2) / 3);
2115 else if(CurrSS
== 4)
2119 else if(CurrSS
== 3)
2123 else if(CurrSS
== 2)
2127 else if(CurrSS
== 1)
2135 //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2137 // Step 2. Smoothing.
2139 //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2145 static long ieee80211_translate_todbm(u8 signal_strength_index
)
2147 long signal_power
; // in dBm.
2149 // Translate to dBm (x=0.5y-95).
2150 signal_power
= (long)((signal_strength_index
+ 1) >> 1);
2153 return signal_power
;
2156 static inline int ieee80211_network_init(
2157 struct ieee80211_device
*ieee
,
2158 struct ieee80211_probe_response
*beacon
,
2159 struct ieee80211_network
*network
,
2160 struct ieee80211_rx_stats
*stats
)
2162 #ifdef CONFIG_IEEE80211_DEBUG
2163 //char rates_str[64];
2167 network
->qos_data
.active
= 0;
2168 network
->qos_data
.supported
= 0;
2169 network
->qos_data
.param_count
= 0;
2170 network
->qos_data
.old_param_count
= 0;
2172 /* Pull out fixed field data */
2173 memcpy(network
->bssid
, beacon
->header
.addr3
, ETH_ALEN
);
2174 network
->capability
= le16_to_cpu(beacon
->capability
);
2175 network
->last_scanned
= jiffies
;
2176 network
->time_stamp
[0] = le32_to_cpu(beacon
->time_stamp
[0]);
2177 network
->time_stamp
[1] = le32_to_cpu(beacon
->time_stamp
[1]);
2178 network
->beacon_interval
= le16_to_cpu(beacon
->beacon_interval
);
2179 /* Where to pull this? beacon->listen_interval;*/
2180 network
->listen_interval
= 0x0A;
2181 network
->rates_len
= network
->rates_ex_len
= 0;
2182 network
->last_associate
= 0;
2183 network
->ssid_len
= 0;
2185 network
->atim_window
= 0;
2186 network
->erp_value
= (network
->capability
& WLAN_CAPABILITY_IBSS
) ?
2188 network
->berp_info_valid
= false;
2189 network
->broadcom_cap_exist
= false;
2190 network
->ralink_cap_exist
= false;
2191 network
->atheros_cap_exist
= false;
2192 network
->cisco_cap_exist
= false;
2193 network
->unknown_cap_exist
= false;
2195 network
->Turbo_Enable
= 0;
2197 network
->CountryIeLen
= 0;
2198 memset(network
->CountryIeBuf
, 0, MAX_IE_LEN
);
2199 //Initialize HT parameters
2200 //ieee80211_ht_initialize(&network->bssht);
2201 HTInitializeBssDesc(&network
->bssht
);
2202 if (stats
->freq
== IEEE80211_52GHZ_BAND
) {
2203 /* for A band (No DS info) */
2204 network
->channel
= stats
->received_channel
;
2206 network
->flags
|= NETWORK_HAS_CCK
;
2208 network
->wpa_ie_len
= 0;
2209 network
->rsn_ie_len
= 0;
2211 if (ieee80211_parse_info_param
2212 (ieee
,beacon
->info_element
, stats
->len
- sizeof(*beacon
), network
, stats
))
2216 if (stats
->freq
== IEEE80211_52GHZ_BAND
)
2217 network
->mode
= IEEE_A
;
2219 if (network
->flags
& NETWORK_HAS_OFDM
)
2220 network
->mode
|= IEEE_G
;
2221 if (network
->flags
& NETWORK_HAS_CCK
)
2222 network
->mode
|= IEEE_B
;
2225 if (network
->mode
== 0) {
2226 IEEE80211_DEBUG_SCAN("Filtered out '%s (%pM)' "
2228 escape_essid(network
->ssid
,
2234 if(network
->bssht
.bdSupportHT
){
2235 if(network
->mode
== IEEE_A
)
2236 network
->mode
= IEEE_N_5G
;
2237 else if(network
->mode
& (IEEE_G
| IEEE_B
))
2238 network
->mode
= IEEE_N_24G
;
2240 if (ieee80211_is_empty_essid(network
->ssid
, network
->ssid_len
))
2241 network
->flags
|= NETWORK_EMPTY_ESSID
;
2243 stats
->signal
= 30 + (stats
->SignalStrength
* 70) / 100;
2244 //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
2245 stats
->noise
= ieee80211_translate_todbm((u8
)(100-stats
->signal
)) -25;
2247 memcpy(&network
->stats
, stats
, sizeof(network
->stats
));
2252 static inline int is_same_network(struct ieee80211_network
*src
,
2253 struct ieee80211_network
*dst
, struct ieee80211_device
*ieee
)
2255 /* A network is only a duplicate if the channel, BSSID, ESSID
2256 * and the capability field (in particular IBSS and BSS) all match.
2257 * We treat all <hidden> with the same BSSID and channel
2259 return //((src->ssid_len == dst->ssid_len) &&
2260 (((src
->ssid_len
== dst
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2261 (src
->channel
== dst
->channel
) &&
2262 !memcmp(src
->bssid
, dst
->bssid
, ETH_ALEN
) &&
2263 //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
2264 (!memcmp(src
->ssid
, dst
->ssid
, src
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2265 ((src
->capability
& WLAN_CAPABILITY_IBSS
) ==
2266 (dst
->capability
& WLAN_CAPABILITY_IBSS
)) &&
2267 ((src
->capability
& WLAN_CAPABILITY_BSS
) ==
2268 (dst
->capability
& WLAN_CAPABILITY_BSS
)));
2271 static inline void update_network(struct ieee80211_network
*dst
,
2272 struct ieee80211_network
*src
)
2277 memcpy(&dst
->stats
, &src
->stats
, sizeof(struct ieee80211_rx_stats
));
2278 dst
->capability
= src
->capability
;
2279 memcpy(dst
->rates
, src
->rates
, src
->rates_len
);
2280 dst
->rates_len
= src
->rates_len
;
2281 memcpy(dst
->rates_ex
, src
->rates_ex
, src
->rates_ex_len
);
2282 dst
->rates_ex_len
= src
->rates_ex_len
;
2283 if (src
->ssid_len
> 0)
2285 memset(dst
->ssid
, 0, dst
->ssid_len
);
2286 dst
->ssid_len
= src
->ssid_len
;
2287 memcpy(dst
->ssid
, src
->ssid
, src
->ssid_len
);
2289 dst
->mode
= src
->mode
;
2290 dst
->flags
= src
->flags
;
2291 dst
->time_stamp
[0] = src
->time_stamp
[0];
2292 dst
->time_stamp
[1] = src
->time_stamp
[1];
2293 if (src
->flags
& NETWORK_HAS_ERP_VALUE
)
2295 dst
->erp_value
= src
->erp_value
;
2296 dst
->berp_info_valid
= src
->berp_info_valid
= true;
2298 dst
->beacon_interval
= src
->beacon_interval
;
2299 dst
->listen_interval
= src
->listen_interval
;
2300 dst
->atim_window
= src
->atim_window
;
2301 dst
->dtim_period
= src
->dtim_period
;
2302 dst
->dtim_data
= src
->dtim_data
;
2303 dst
->last_dtim_sta_time
[0] = src
->last_dtim_sta_time
[0];
2304 dst
->last_dtim_sta_time
[1] = src
->last_dtim_sta_time
[1];
2305 memcpy(&dst
->tim
, &src
->tim
, sizeof(struct ieee80211_tim_parameters
));
2307 dst
->bssht
.bdSupportHT
= src
->bssht
.bdSupportHT
;
2308 dst
->bssht
.bdRT2RTAggregation
= src
->bssht
.bdRT2RTAggregation
;
2309 dst
->bssht
.bdHTCapLen
= src
->bssht
.bdHTCapLen
;
2310 memcpy(dst
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapLen
);
2311 dst
->bssht
.bdHTInfoLen
= src
->bssht
.bdHTInfoLen
;
2312 memcpy(dst
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoLen
);
2313 dst
->bssht
.bdHTSpecVer
= src
->bssht
.bdHTSpecVer
;
2314 dst
->bssht
.bdRT2RTLongSlotTime
= src
->bssht
.bdRT2RTLongSlotTime
;
2315 dst
->broadcom_cap_exist
= src
->broadcom_cap_exist
;
2316 dst
->ralink_cap_exist
= src
->ralink_cap_exist
;
2317 dst
->atheros_cap_exist
= src
->atheros_cap_exist
;
2318 dst
->cisco_cap_exist
= src
->cisco_cap_exist
;
2319 dst
->unknown_cap_exist
= src
->unknown_cap_exist
;
2320 memcpy(dst
->wpa_ie
, src
->wpa_ie
, src
->wpa_ie_len
);
2321 dst
->wpa_ie_len
= src
->wpa_ie_len
;
2322 memcpy(dst
->rsn_ie
, src
->rsn_ie
, src
->rsn_ie_len
);
2323 dst
->rsn_ie_len
= src
->rsn_ie_len
;
2325 dst
->last_scanned
= jiffies
;
2326 /* qos related parameters */
2327 //qos_active = src->qos_data.active;
2328 qos_active
= dst
->qos_data
.active
;
2329 //old_param = dst->qos_data.old_param_count;
2330 old_param
= dst
->qos_data
.param_count
;
2331 if(dst
->flags
& NETWORK_HAS_QOS_MASK
)
2332 memcpy(&dst
->qos_data
, &src
->qos_data
,
2333 sizeof(struct ieee80211_qos_data
));
2335 dst
->qos_data
.supported
= src
->qos_data
.supported
;
2336 dst
->qos_data
.param_count
= src
->qos_data
.param_count
;
2339 if (dst
->qos_data
.supported
== 1) {
2340 dst
->QoS_Enable
= 1;
2343 ("QoS the network %s is QoS supported\n",
2347 ("QoS the network is QoS supported\n");
2349 dst
->qos_data
.active
= qos_active
;
2350 dst
->qos_data
.old_param_count
= old_param
;
2352 /* dst->last_associate is not overwritten */
2353 dst
->wmm_info
= src
->wmm_info
; //sure to exist in beacon or probe response frame.
2354 if (src
->wmm_param
[0].aci_aifsn
|| \
2355 src
->wmm_param
[1].aci_aifsn
|| \
2356 src
->wmm_param
[2].aci_aifsn
|| \
2357 src
->wmm_param
[3].aci_aifsn
) {
2358 memcpy(dst
->wmm_param
, src
->wmm_param
, WME_AC_PRAM_LEN
);
2360 //dst->QoS_Enable = src->QoS_Enable;
2362 dst
->Turbo_Enable
= src
->Turbo_Enable
;
2365 dst
->CountryIeLen
= src
->CountryIeLen
;
2366 memcpy(dst
->CountryIeBuf
, src
->CountryIeBuf
, src
->CountryIeLen
);
2368 //added by amy for LEAP
2369 dst
->bWithAironetIE
= src
->bWithAironetIE
;
2370 dst
->bCkipSupported
= src
->bCkipSupported
;
2371 memcpy(dst
->CcxRmState
, src
->CcxRmState
, 2);
2372 dst
->bCcxRmEnable
= src
->bCcxRmEnable
;
2373 dst
->MBssidMask
= src
->MBssidMask
;
2374 dst
->bMBssidValid
= src
->bMBssidValid
;
2375 memcpy(dst
->MBssid
, src
->MBssid
, 6);
2376 dst
->bWithCcxVerNum
= src
->bWithCcxVerNum
;
2377 dst
->BssCcxVerNumber
= src
->BssCcxVerNumber
;
2381 static inline int is_beacon(__le16 fc
)
2383 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc
)) == IEEE80211_STYPE_BEACON
);
2386 static inline void ieee80211_process_probe_response(
2387 struct ieee80211_device
*ieee
,
2388 struct ieee80211_probe_response
*beacon
,
2389 struct ieee80211_rx_stats
*stats
)
2391 struct ieee80211_network network
;
2392 struct ieee80211_network
*target
;
2393 struct ieee80211_network
*oldest
= NULL
;
2394 #ifdef CONFIG_IEEE80211_DEBUG
2395 struct ieee80211_info_element
*info_element
= &beacon
->info_element
[0];
2397 unsigned long flags
;
2401 memset(&network
, 0, sizeof(struct ieee80211_network
));
2402 IEEE80211_DEBUG_SCAN(
2403 "'%s' (%pM): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2404 escape_essid(info_element
->data
, info_element
->len
),
2405 beacon
->header
.addr3
,
2406 (beacon
->capability
& (1<<0xf)) ? '1' : '0',
2407 (beacon
->capability
& (1<<0xe)) ? '1' : '0',
2408 (beacon
->capability
& (1<<0xd)) ? '1' : '0',
2409 (beacon
->capability
& (1<<0xc)) ? '1' : '0',
2410 (beacon
->capability
& (1<<0xb)) ? '1' : '0',
2411 (beacon
->capability
& (1<<0xa)) ? '1' : '0',
2412 (beacon
->capability
& (1<<0x9)) ? '1' : '0',
2413 (beacon
->capability
& (1<<0x8)) ? '1' : '0',
2414 (beacon
->capability
& (1<<0x7)) ? '1' : '0',
2415 (beacon
->capability
& (1<<0x6)) ? '1' : '0',
2416 (beacon
->capability
& (1<<0x5)) ? '1' : '0',
2417 (beacon
->capability
& (1<<0x4)) ? '1' : '0',
2418 (beacon
->capability
& (1<<0x3)) ? '1' : '0',
2419 (beacon
->capability
& (1<<0x2)) ? '1' : '0',
2420 (beacon
->capability
& (1<<0x1)) ? '1' : '0',
2421 (beacon
->capability
& (1<<0x0)) ? '1' : '0');
2423 if (ieee80211_network_init(ieee
, beacon
, &network
, stats
)) {
2424 IEEE80211_DEBUG_SCAN("Dropped '%s' (%pM) via %s.\n",
2425 escape_essid(info_element
->data
,
2427 beacon
->header
.addr3
,
2428 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2429 IEEE80211_STYPE_PROBE_RESP
?
2430 "PROBE RESPONSE" : "BEACON");
2434 // For Asus EeePc request,
2435 // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
2436 // wireless adapter should follow the country code.
2437 // (2) If there is no any country code in beacon,
2438 // then wireless adapter should do active scan from ch1~11 and
2439 // passive scan from ch12~14
2441 if (!IsLegalChannel(ieee
, network
.channel
))
2443 if (ieee
->bGlobalDomain
)
2445 if (WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) == IEEE80211_STYPE_PROBE_RESP
)
2447 // Case 1: Country code
2448 if(IS_COUNTRY_IE_VALID(ieee
) )
2450 if (!IsLegalChannel(ieee
, network
.channel
)) {
2451 printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network
.channel
);
2455 // Case 2: No any country code.
2458 // Filter over channel ch12~14
2459 if (network
.channel
> 11)
2461 printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network
.channel
);
2468 // Case 1: Country code
2469 if(IS_COUNTRY_IE_VALID(ieee
) )
2471 if (!IsLegalChannel(ieee
, network
.channel
)) {
2472 printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network
.channel
);
2476 // Case 2: No any country code.
2479 // Filter over channel ch12~14
2480 if (network
.channel
> 14)
2482 printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network
.channel
);
2489 /* The network parsed correctly -- so now we scan our known networks
2490 * to see if we can find it in our list.
2492 * NOTE: This search is definitely not optimized. Once its doing
2493 * the "right thing" we'll optimize it for efficiency if
2496 /* Search for this entry in the list and update it if it is
2499 spin_lock_irqsave(&ieee
->lock
, flags
);
2501 if (is_same_network(&ieee
->current_network
, &network
, ieee
)) {
2502 update_network(&ieee
->current_network
, &network
);
2503 if ((ieee
->current_network
.mode
== IEEE_N_24G
|| ieee
->current_network
.mode
== IEEE_G
)
2504 && ieee
->current_network
.berp_info_valid
){
2505 if(ieee
->current_network
.erp_value
& ERP_UseProtection
)
2506 ieee
->current_network
.buseprotection
= true;
2508 ieee
->current_network
.buseprotection
= false;
2510 if(is_beacon(beacon
->header
.frame_ctl
))
2512 if(ieee
->state
== IEEE80211_LINKED
)
2513 ieee
->LinkDetectInfo
.NumRecvBcnInPeriod
++;
2516 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& ieee
->current_network
.flags
);
2519 list_for_each_entry(target
, &ieee
->network_list
, list
) {
2520 if (is_same_network(target
, &network
, ieee
))
2522 if ((oldest
== NULL
) ||
2523 (target
->last_scanned
< oldest
->last_scanned
))
2527 /* If we didn't find a match, then get a new network slot to initialize
2528 * with this beacon's information */
2529 if (&target
->list
== &ieee
->network_list
) {
2530 if (list_empty(&ieee
->network_free_list
)) {
2531 /* If there are no more slots, expire the oldest */
2532 list_del(&oldest
->list
);
2534 IEEE80211_DEBUG_SCAN("Expired '%s' (%pM) from "
2536 escape_essid(target
->ssid
,
2540 /* Otherwise just pull from the free list */
2541 target
= list_entry(ieee
->network_free_list
.next
,
2542 struct ieee80211_network
, list
);
2543 list_del(ieee
->network_free_list
.next
);
2547 #ifdef CONFIG_IEEE80211_DEBUG
2548 IEEE80211_DEBUG_SCAN("Adding '%s' (%pM) via %s.\n",
2549 escape_essid(network
.ssid
,
2552 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2553 IEEE80211_STYPE_PROBE_RESP
?
2554 "PROBE RESPONSE" : "BEACON");
2556 memcpy(target
, &network
, sizeof(*target
));
2557 list_add_tail(&target
->list
, &ieee
->network_list
);
2558 if(ieee
->softmac_features
& IEEE_SOFTMAC_ASSOCIATE
)
2559 ieee80211_softmac_new_net(ieee
,&network
);
2561 IEEE80211_DEBUG_SCAN("Updating '%s' (%pM) via %s.\n",
2562 escape_essid(target
->ssid
,
2565 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2566 IEEE80211_STYPE_PROBE_RESP
?
2567 "PROBE RESPONSE" : "BEACON");
2569 /* we have an entry and we are going to update it. But this entry may
2570 * be already expired. In this case we do the same as we found a new
2571 * net and call the new_net handler
2573 renew
= !time_after(target
->last_scanned
+ ieee
->scan_age
, jiffies
);
2574 //YJ,add,080819,for hidden ap
2575 if(is_beacon(beacon
->header
.frame_ctl
) == 0)
2576 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& target
->flags
);
2577 //if(strncmp(network.ssid, "linksys-c",9) == 0)
2578 // printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
2579 if(((network
.flags
& NETWORK_EMPTY_ESSID
) == NETWORK_EMPTY_ESSID
) \
2580 && (((network
.ssid_len
> 0) && (strncmp(target
->ssid
, network
.ssid
, network
.ssid_len
)))\
2581 ||((ieee
->current_network
.ssid_len
== network
.ssid_len
)&&(strncmp(ieee
->current_network
.ssid
, network
.ssid
, network
.ssid_len
) == 0)&&(ieee
->state
== IEEE80211_NOLINK
))))
2583 //YJ,add,080819,for hidden ap,end
2585 update_network(target
, &network
);
2586 if(renew
&& (ieee
->softmac_features
& IEEE_SOFTMAC_ASSOCIATE
))
2587 ieee80211_softmac_new_net(ieee
,&network
);
2590 spin_unlock_irqrestore(&ieee
->lock
, flags
);
2591 if (is_beacon(beacon
->header
.frame_ctl
)&&is_same_network(&ieee
->current_network
, &network
, ieee
)&&\
2592 (ieee
->state
== IEEE80211_LINKED
)) {
2593 if (ieee
->handle_beacon
!= NULL
) {
2594 ieee
->handle_beacon(ieee
->dev
,beacon
,&ieee
->current_network
);
2599 void ieee80211_rx_mgt(struct ieee80211_device
*ieee
,
2600 struct rtl_80211_hdr_4addr
*header
,
2601 struct ieee80211_rx_stats
*stats
)
2603 switch (WLAN_FC_GET_STYPE(header
->frame_ctl
)) {
2605 case IEEE80211_STYPE_BEACON
:
2606 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
2607 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2608 IEEE80211_DEBUG_SCAN("Beacon\n");
2609 ieee80211_process_probe_response(
2610 ieee
, (struct ieee80211_probe_response
*)header
, stats
);
2613 case IEEE80211_STYPE_PROBE_RESP
:
2614 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
2615 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2616 IEEE80211_DEBUG_SCAN("Probe response\n");
2617 ieee80211_process_probe_response(
2618 ieee
, (struct ieee80211_probe_response
*)header
, stats
);
2623 EXPORT_SYMBOL(ieee80211_rx_mgt
);