2 * Original code based Host AP (software wireless LAN access point) driver
3 * for Intersil Prism2/2.5/3 - hostap.o module, common routines
5 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
7 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
8 * Copyright (c) 2004, Intel Corporation
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. See README and COPYING for
14 ******************************************************************************
16 Few modifications for Realtek's Wi-Fi drivers by
17 Andrea Merello <andreamrl@tiscali.it>
19 A special thanks goes to Realtek for their support !
21 ******************************************************************************/
24 #include <linux/compiler.h>
25 //#include <linux/config.h>
26 #include <linux/errno.h>
27 #include <linux/if_arp.h>
28 #include <linux/in6.h>
31 #include <linux/kernel.h>
32 #include <linux/module.h>
33 #include <linux/netdevice.h>
34 #include <linux/pci.h>
35 #include <linux/proc_fs.h>
36 #include <linux/skbuff.h>
37 #include <linux/slab.h>
38 #include <linux/tcp.h>
39 #include <linux/types.h>
40 #include <linux/wireless.h>
41 #include <linux/etherdevice.h>
42 #include <asm/uaccess.h>
43 #include <linux/ctype.h>
45 #include "ieee80211.h"
47 static inline void ieee80211_monitor_rx(struct ieee80211_device
*ieee
,
49 struct ieee80211_rx_stats
*rx_stats
)
51 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*)skb
->data
;
52 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
55 skb_reset_mac_header(skb
);
57 skb_pull(skb
, ieee80211_get_hdrlen(fc
));
58 skb
->pkt_type
= PACKET_OTHERHOST
;
59 skb
->protocol
= __constant_htons(ETH_P_80211_RAW
);
60 memset(skb
->cb
, 0, sizeof(skb
->cb
));
65 /* Called only as a tasklet (software IRQ) */
66 static struct ieee80211_frag_entry
*
67 ieee80211_frag_cache_find(struct ieee80211_device
*ieee
, unsigned int seq
,
68 unsigned int frag
, u8 tid
,u8
*src
, u8
*dst
)
70 struct ieee80211_frag_entry
*entry
;
73 for (i
= 0; i
< IEEE80211_FRAG_CACHE_LEN
; i
++) {
74 entry
= &ieee
->frag_cache
[tid
][i
];
75 if (entry
->skb
!= NULL
&&
76 time_after(jiffies
, entry
->first_frag_time
+ 2 * HZ
)) {
78 "expiring fragment cache entry "
79 "seq=%u last_frag=%u\n",
80 entry
->seq
, entry
->last_frag
);
81 dev_kfree_skb_any(entry
->skb
);
85 if (entry
->skb
!= NULL
&& entry
->seq
== seq
&&
86 (entry
->last_frag
+ 1 == frag
|| frag
== -1) &&
87 memcmp(entry
->src_addr
, src
, ETH_ALEN
) == 0 &&
88 memcmp(entry
->dst_addr
, dst
, ETH_ALEN
) == 0)
95 /* Called only as a tasklet (software IRQ) */
96 static struct sk_buff
*
97 ieee80211_frag_cache_get(struct ieee80211_device
*ieee
,
98 struct ieee80211_hdr_4addr
*hdr
)
100 struct sk_buff
*skb
= NULL
;
101 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
102 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
103 unsigned int frag
= WLAN_GET_SEQ_FRAG(sc
);
104 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
105 struct ieee80211_frag_entry
*entry
;
106 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
107 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
110 if (((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
111 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)hdr
;
112 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
115 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
116 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)hdr
;
117 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
125 /* Reserve enough space to fit maximum frame length */
126 skb
= dev_alloc_skb(ieee
->dev
->mtu
+
127 sizeof(struct ieee80211_hdr_4addr
) +
132 (IEEE80211_QOS_HAS_SEQ(fc
)?2:0) /* QOS Control */);
136 entry
= &ieee
->frag_cache
[tid
][ieee
->frag_next_idx
[tid
]];
137 ieee
->frag_next_idx
[tid
]++;
138 if (ieee
->frag_next_idx
[tid
] >= IEEE80211_FRAG_CACHE_LEN
)
139 ieee
->frag_next_idx
[tid
] = 0;
141 if (entry
->skb
!= NULL
)
142 dev_kfree_skb_any(entry
->skb
);
144 entry
->first_frag_time
= jiffies
;
146 entry
->last_frag
= frag
;
148 memcpy(entry
->src_addr
, hdr
->addr2
, ETH_ALEN
);
149 memcpy(entry
->dst_addr
, hdr
->addr1
, ETH_ALEN
);
151 /* received a fragment of a frame for which the head fragment
152 * should have already been received */
153 entry
= ieee80211_frag_cache_find(ieee
, seq
, frag
, tid
,hdr
->addr2
,
156 entry
->last_frag
= frag
;
165 /* Called only as a tasklet (software IRQ) */
166 static int ieee80211_frag_cache_invalidate(struct ieee80211_device
*ieee
,
167 struct ieee80211_hdr_4addr
*hdr
)
169 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
170 u16 sc
= le16_to_cpu(hdr
->seq_ctl
);
171 unsigned int seq
= WLAN_GET_SEQ_SEQ(sc
);
172 struct ieee80211_frag_entry
*entry
;
173 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
174 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
177 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
178 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)hdr
;
179 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
182 } else if (IEEE80211_QOS_HAS_SEQ(fc
)) {
183 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)hdr
;
184 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
191 entry
= ieee80211_frag_cache_find(ieee
, seq
, -1, tid
,hdr
->addr2
,
195 IEEE80211_DEBUG_FRAG(
196 "could not invalidate fragment cache "
197 "entry (seq=%u)\n", seq
);
207 /* ieee80211_rx_frame_mgtmt
209 * Responsible for handling management control frames
211 * Called by ieee80211_rtl_rx */
213 ieee80211_rx_frame_mgmt(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
214 struct ieee80211_rx_stats
*rx_stats
, u16 type
,
217 /* On the struct stats definition there is written that
218 * this is not mandatory.... but seems that the probe
219 * response parser uses it
221 struct ieee80211_hdr_3addr
* hdr
= (struct ieee80211_hdr_3addr
*)skb
->data
;
223 rx_stats
->len
= skb
->len
;
224 ieee80211_rx_mgt(ieee
,(struct ieee80211_hdr_4addr
*)skb
->data
,rx_stats
);
225 //if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN)))
226 if ((memcmp(hdr
->addr1
, ieee
->dev
->dev_addr
, ETH_ALEN
)))//use ADDR1 to perform address matching for Management frames
228 dev_kfree_skb_any(skb
);
232 ieee80211_rx_frame_softmac(ieee
, skb
, rx_stats
, type
, stype
);
234 dev_kfree_skb_any(skb
);
242 /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */
243 /* Ethernet-II snap header (RFC1042 for most EtherTypes) */
244 static unsigned char rfc1042_header
[] =
245 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
246 /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */
247 static unsigned char bridge_tunnel_header
[] =
248 { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
249 /* No encapsulation header if EtherType < 0x600 (=length) */
251 /* Called by ieee80211_rx_frame_decrypt */
252 static int ieee80211_is_eapol_frame(struct ieee80211_device
*ieee
,
253 struct sk_buff
*skb
, size_t hdrlen
)
255 struct net_device
*dev
= ieee
->dev
;
257 struct ieee80211_hdr_4addr
*hdr
;
263 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
264 fc
= le16_to_cpu(hdr
->frame_ctl
);
266 /* check that the frame is unicast frame to us */
267 if ((fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) ==
268 IEEE80211_FCTL_TODS
&&
269 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0 &&
270 memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
) == 0) {
271 /* ToDS frame with own addr BSSID and DA */
272 } else if ((fc
& (IEEE80211_FCTL_TODS
| IEEE80211_FCTL_FROMDS
)) ==
273 IEEE80211_FCTL_FROMDS
&&
274 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
275 /* FromDS frame with own addr as DA */
279 if (skb
->len
< 24 + 8)
282 /* check for port access entity Ethernet type */
283 // pos = skb->data + 24;
284 pos
= skb
->data
+ hdrlen
;
285 ethertype
= (pos
[6] << 8) | pos
[7];
286 if (ethertype
== ETH_P_PAE
)
292 /* Called only as a tasklet (software IRQ), by ieee80211_rtl_rx */
294 ieee80211_rx_frame_decrypt(struct ieee80211_device
* ieee
, struct sk_buff
*skb
,
295 struct ieee80211_crypt_data
*crypt
)
297 struct ieee80211_hdr_4addr
*hdr
;
300 if (crypt
== NULL
|| crypt
->ops
->decrypt_mpdu
== NULL
)
303 if (ieee
->hwsec_active
)
305 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
306 tcb_desc
->bHwSec
= 1;
309 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
310 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
312 #ifdef CONFIG_IEEE80211_CRYPT_TKIP
313 if (ieee
->tkip_countermeasures
&&
314 strcmp(crypt
->ops
->name
, "TKIP") == 0) {
315 if (net_ratelimit()) {
316 printk(KERN_DEBUG
"%s: TKIP countermeasures: dropped "
317 "received packet from " MAC_FMT
"\n",
318 ieee
->dev
->name
, MAC_ARG(hdr
->addr2
));
324 atomic_inc(&crypt
->refcnt
);
325 res
= crypt
->ops
->decrypt_mpdu(skb
, hdrlen
, crypt
->priv
);
326 atomic_dec(&crypt
->refcnt
);
328 IEEE80211_DEBUG_DROP(
329 "decryption failed (SA=" MAC_FMT
330 ") res=%d\n", MAC_ARG(hdr
->addr2
), res
);
332 IEEE80211_DEBUG_DROP("Decryption failed ICV "
333 "mismatch (key %d)\n",
334 skb
->data
[hdrlen
+ 3] >> 6);
335 ieee
->ieee_stats
.rx_discards_undecryptable
++;
343 /* Called only as a tasklet (software IRQ), by ieee80211_rx */
345 ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device
* ieee
, struct sk_buff
*skb
,
346 int keyidx
, struct ieee80211_crypt_data
*crypt
)
348 struct ieee80211_hdr_4addr
*hdr
;
351 if (crypt
== NULL
|| crypt
->ops
->decrypt_msdu
== NULL
)
353 if (ieee
->hwsec_active
)
355 cb_desc
*tcb_desc
= (cb_desc
*)(skb
->cb
+ MAX_DEV_ADDR_SIZE
);
356 tcb_desc
->bHwSec
= 1;
359 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
360 hdrlen
= ieee80211_get_hdrlen(le16_to_cpu(hdr
->frame_ctl
));
362 atomic_inc(&crypt
->refcnt
);
363 res
= crypt
->ops
->decrypt_msdu(skb
, keyidx
, hdrlen
, crypt
->priv
);
364 atomic_dec(&crypt
->refcnt
);
366 printk(KERN_DEBUG
"%s: MSDU decryption/MIC verification failed"
367 " (SA=" MAC_FMT
" keyidx=%d)\n",
368 ieee
->dev
->name
, MAC_ARG(hdr
->addr2
), keyidx
);
376 /* this function is stolen from ipw2200 driver*/
377 #define IEEE_PACKET_RETRY_TIME (5*HZ)
378 static int is_duplicate_packet(struct ieee80211_device
*ieee
,
379 struct ieee80211_hdr_4addr
*header
)
381 u16 fc
= le16_to_cpu(header
->frame_ctl
);
382 u16 sc
= le16_to_cpu(header
->seq_ctl
);
383 u16 seq
= WLAN_GET_SEQ_SEQ(sc
);
384 u16 frag
= WLAN_GET_SEQ_FRAG(sc
);
385 u16
*last_seq
, *last_frag
;
386 unsigned long *last_time
;
387 struct ieee80211_hdr_3addrqos
*hdr_3addrqos
;
388 struct ieee80211_hdr_4addrqos
*hdr_4addrqos
;
393 if(((fc
& IEEE80211_FCTL_DSTODS
) == IEEE80211_FCTL_DSTODS
)&&IEEE80211_QOS_HAS_SEQ(fc
)) {
394 hdr_4addrqos
= (struct ieee80211_hdr_4addrqos
*)header
;
395 tid
= le16_to_cpu(hdr_4addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
398 } else if(IEEE80211_QOS_HAS_SEQ(fc
)) { //QoS
399 hdr_3addrqos
= (struct ieee80211_hdr_3addrqos
*)header
;
400 tid
= le16_to_cpu(hdr_3addrqos
->qos_ctl
) & IEEE80211_QCTL_TID
;
407 switch (ieee
->iw_mode
) {
411 struct ieee_ibss_seq
*entry
= NULL
;
412 u8
*mac
= header
->addr2
;
413 int index
= mac
[5] % IEEE_IBSS_MAC_HASH_SIZE
;
414 //for (pos = (head)->next; pos != (head); pos = pos->next)
415 //__list_for_each(p, &ieee->ibss_mac_hash[index]) {
416 list_for_each(p
, &ieee
->ibss_mac_hash
[index
]) {
417 entry
= list_entry(p
, struct ieee_ibss_seq
, list
);
418 if (!memcmp(entry
->mac
, mac
, ETH_ALEN
))
421 // if (memcmp(entry->mac, mac, ETH_ALEN)){
422 if (p
== &ieee
->ibss_mac_hash
[index
]) {
423 entry
= kmalloc(sizeof(struct ieee_ibss_seq
), GFP_ATOMIC
);
425 printk(KERN_WARNING
"Cannot malloc new mac entry\n");
428 memcpy(entry
->mac
, mac
, ETH_ALEN
);
429 entry
->seq_num
[tid
] = seq
;
430 entry
->frag_num
[tid
] = frag
;
431 entry
->packet_time
[tid
] = jiffies
;
432 list_add(&entry
->list
, &ieee
->ibss_mac_hash
[index
]);
435 last_seq
= &entry
->seq_num
[tid
];
436 last_frag
= &entry
->frag_num
[tid
];
437 last_time
= &entry
->packet_time
[tid
];
442 last_seq
= &ieee
->last_rxseq_num
[tid
];
443 last_frag
= &ieee
->last_rxfrag_num
[tid
];
444 last_time
= &ieee
->last_packet_time
[tid
];
452 // printk(KERN_WARNING ":)))))))))))%x %x %x, fc(%x)\n", tid, *last_seq, seq, header->frame_ctl);
454 if ((*last_seq
== seq
) &&
455 time_after(*last_time
+ IEEE_PACKET_RETRY_TIME
, jiffies
)) {
456 if (*last_frag
== frag
){
457 //printk(KERN_WARNING "[1] go drop!\n");
461 if (*last_frag
+ 1 != frag
)
462 /* out-of-order fragment */
463 //printk(KERN_WARNING "[2] go drop!\n");
469 *last_time
= jiffies
;
473 // BUG_ON(!(fc & IEEE80211_FCTL_RETRY));
481 PRX_REORDER_ENTRY pReorderEntry
484 struct list_head
*pList
= &pTS
->RxPendingPktList
;
486 while(pList
->next
!= &pTS
->RxPendingPktList
)
488 if( SN_LESS(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
492 else if( SN_EQUAL(pReorderEntry
->SeqNum
, ((PRX_REORDER_ENTRY
)list_entry(pList
->next
,RX_REORDER_ENTRY
,List
))->SeqNum
) )
502 pReorderEntry
->List
.next
= pList
->next
;
503 pReorderEntry
->List
.next
->prev
= &pReorderEntry
->List
;
504 pReorderEntry
->List
.prev
= pList
;
505 pList
->next
= &pReorderEntry
->List
;
510 void ieee80211_indicate_packets(struct ieee80211_device
*ieee
, struct ieee80211_rxb
** prxbIndicateArray
,u8 index
)
515 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): hahahahhhh, We indicate packet from reorder list, index is %u\n",__FUNCTION__,index);
516 for(j
= 0; j
<index
; j
++)
518 //added by amy for reorder
519 struct ieee80211_rxb
* prxb
= prxbIndicateArray
[j
];
520 for(i
= 0; i
<prxb
->nr_subframes
; i
++) {
521 struct sk_buff
*sub_skb
= prxb
->subframes
[i
];
523 /* convert hdr + possible LLC headers into Ethernet header */
524 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
525 if (sub_skb
->len
>= 8 &&
526 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
527 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
528 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
529 /* remove RFC1042 or Bridge-Tunnel encapsulation and
530 * replace EtherType */
531 skb_pull(sub_skb
, SNAP_SIZE
);
532 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->src
, ETH_ALEN
);
533 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->dst
, ETH_ALEN
);
536 /* Leave Ethernet header part of hdr and full payload */
537 len
= htons(sub_skb
->len
);
538 memcpy(skb_push(sub_skb
, 2), &len
, 2);
539 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->src
, ETH_ALEN
);
540 memcpy(skb_push(sub_skb
, ETH_ALEN
), prxb
->dst
, ETH_ALEN
);
542 //stats->rx_packets++;
543 //stats->rx_bytes += sub_skb->len;
545 /* Indicat the packets to upper layer */
547 //printk("0skb_len(%d)\n", skb->len);
548 sub_skb
->protocol
= eth_type_trans(sub_skb
, ieee
->dev
);
549 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
550 sub_skb
->dev
= ieee
->dev
;
551 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
552 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
553 ieee
->last_rx_ps_time
= jiffies
;
554 //printk("1skb_len(%d)\n", skb->len);
564 void RxReorderIndicatePacket( struct ieee80211_device
*ieee
,
565 struct ieee80211_rxb
* prxb
,
569 PRT_HIGH_THROUGHPUT pHTInfo
= ieee
->pHTInfo
;
570 PRX_REORDER_ENTRY pReorderEntry
= NULL
;
571 struct ieee80211_rxb
* prxbIndicateArray
[REORDER_WIN_SIZE
];
572 u8 WinSize
= pHTInfo
->RxReorderWinSize
;
573 u16 WinEnd
= (pTS
->RxIndicateSeq
+ WinSize
-1)%4096;
575 bool bMatchWinStart
= false, bPktInBuf
= false;
576 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__FUNCTION__
,SeqNum
,pTS
->RxIndicateSeq
,WinSize
);
577 /* Rx Reorder initialize condition.*/
578 if(pTS
->RxIndicateSeq
== 0xffff) {
579 pTS
->RxIndicateSeq
= SeqNum
;
582 /* Drop out the packet which SeqNum is smaller than WinStart */
583 if(SN_LESS(SeqNum
, pTS
->RxIndicateSeq
)) {
584 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
585 pTS
->RxIndicateSeq
, SeqNum
);
586 pHTInfo
->RxReorderDropCounter
++;
589 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
590 dev_kfree_skb(prxb
->subframes
[i
]);
599 * Sliding window manipulation. Conditions includes:
600 * 1. Incoming SeqNum is equal to WinStart =>Window shift 1
601 * 2. Incoming SeqNum is larger than the WinEnd => Window shift N
603 if(SN_EQUAL(SeqNum
, pTS
->RxIndicateSeq
)) {
604 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
605 bMatchWinStart
= true;
606 } else if(SN_LESS(WinEnd
, SeqNum
)) {
607 if(SeqNum
>= (WinSize
- 1)) {
608 pTS
->RxIndicateSeq
= SeqNum
+ 1 -WinSize
;
610 pTS
->RxIndicateSeq
= 4095 - (WinSize
- (SeqNum
+1)) + 1;
612 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Window Shift! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
616 * Indication process.
617 * After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets
618 * with the SeqNum smaller than latest WinStart and buffer other packets.
620 /* For Rx Reorder condition:
621 * 1. All packets with SeqNum smaller than WinStart => Indicate
622 * 2. All packets with SeqNum larger than or equal to WinStart => Buffer it.
625 /* Current packet is going to be indicated.*/
626 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",\
627 pTS
->RxIndicateSeq
, SeqNum
);
628 prxbIndicateArray
[0] = prxb
;
629 // printk("========================>%s(): SeqNum is %d\n",__FUNCTION__,SeqNum);
632 /* Current packet is going to be inserted into pending list.*/
633 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): We RX no ordered packed, insert to orderd list\n",__FUNCTION__);
634 if(!list_empty(&ieee
->RxReorder_Unused_List
)) {
635 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(ieee
->RxReorder_Unused_List
.next
,RX_REORDER_ENTRY
,List
);
636 list_del_init(&pReorderEntry
->List
);
638 /* Make a reorder entry and insert into a the packet list.*/
639 pReorderEntry
->SeqNum
= SeqNum
;
640 pReorderEntry
->prxb
= prxb
;
641 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pREorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
644 if(!AddReorderEntry(pTS
, pReorderEntry
)) {
645 IEEE80211_DEBUG(IEEE80211_DL_REORDER
, "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
646 __FUNCTION__
, pTS
->RxIndicateSeq
, SeqNum
);
647 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
650 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
651 dev_kfree_skb(prxb
->subframes
[i
]);
657 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,
658 "Pkt insert into buffer!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
664 * Packets are dropped if there is not enough reorder entries.
665 * This part shall be modified!! We can just indicate all the
666 * packets in buffer and get reorder entries.
668 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
671 for(i
=0; i
< prxb
->nr_subframes
; i
++) {
672 dev_kfree_skb(prxb
->subframes
[i
]);
680 /* Check if there is any packet need indicate.*/
681 while(!list_empty(&pTS
->RxPendingPktList
)) {
682 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): start RREORDER indicate\n",__FUNCTION__
);
684 pReorderEntry
= (PRX_REORDER_ENTRY
)list_entry(pTS
->RxPendingPktList
.prev
,RX_REORDER_ENTRY
,List
);
685 if( SN_LESS(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
) ||
686 SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
688 /* This protect buffer from overflow. */
689 if(index
>= REORDER_WIN_SIZE
) {
690 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Buffer overflow!! \n");
695 list_del_init(&pReorderEntry
->List
);
697 if(SN_EQUAL(pReorderEntry
->SeqNum
, pTS
->RxIndicateSeq
))
698 pTS
->RxIndicateSeq
= (pTS
->RxIndicateSeq
+ 1) % 4096;
700 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"Packets indication!! IndicateSeq: %d, NewSeq: %d\n",pTS
->RxIndicateSeq
, SeqNum
);
701 prxbIndicateArray
[index
] = pReorderEntry
->prxb
;
702 // printk("========================>%s(): pReorderEntry->SeqNum is %d\n",__FUNCTION__,pReorderEntry->SeqNum);
705 list_add_tail(&pReorderEntry
->List
,&ieee
->RxReorder_Unused_List
);
713 /* Handling pending timer. Set this timer to prevent from long time Rx buffering.*/
715 // Cancel previous pending timer.
716 if(timer_pending(&pTS
->RxPktPendingTimer
))
718 del_timer_sync(&pTS
->RxPktPendingTimer
);
720 // del_timer_sync(&pTS->RxPktPendingTimer);
721 pTS
->RxTimeoutIndicateSeq
= 0xffff;
724 if(index
>REORDER_WIN_SIZE
){
725 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "RxReorderIndicatePacket(): Rx Reorer buffer full!! \n");
728 ieee80211_indicate_packets(ieee
, prxbIndicateArray
, index
);
733 if(bPktInBuf
&& pTS
->RxTimeoutIndicateSeq
==0xffff) {
734 // Set new pending timer.
735 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): SET rx timeout timer\n", __FUNCTION__
);
736 pTS
->RxTimeoutIndicateSeq
= pTS
->RxIndicateSeq
;
737 mod_timer(&pTS
->RxPktPendingTimer
, jiffies
+ MSECS(pHTInfo
->RxReorderPendingTime
));
742 u8
parse_subframe(struct sk_buff
*skb
,
743 struct ieee80211_rx_stats
*rx_stats
,
744 struct ieee80211_rxb
*rxb
,u8
* src
,u8
* dst
)
746 struct ieee80211_hdr_3addr
*hdr
= (struct ieee80211_hdr_3addr
* )skb
->data
;
747 u16 fc
= le16_to_cpu(hdr
->frame_ctl
);
749 u16 LLCOffset
= sizeof(struct ieee80211_hdr_3addr
);
751 bool bIsAggregateFrame
= false;
752 u16 nSubframe_Length
;
753 u8 nPadding_Length
= 0;
756 struct sk_buff
*sub_skb
;
758 /* just for debug purpose */
759 SeqNum
= WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr
->seq_ctl
));
761 if((IEEE80211_QOS_HAS_SEQ(fc
))&&\
762 (((frameqos
*)(skb
->data
+ IEEE80211_3ADDR_LEN
))->field
.reserved
)) {
763 bIsAggregateFrame
= true;
766 if(IEEE80211_QOS_HAS_SEQ(fc
)) {
770 if(rx_stats
->bContainHTC
) {
771 LLCOffset
+= sHTCLng
;
773 //printk("ChkLength = %d\n", LLCOffset);
774 // Null packet, don't indicate it to upper layer
775 ChkLength
= LLCOffset
;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/
777 if( skb
->len
<= ChkLength
) {
781 skb_pull(skb
, LLCOffset
);
783 if(!bIsAggregateFrame
) {
784 rxb
->nr_subframes
= 1;
786 rxb
->subframes
[0] = skb
;
788 rxb
->subframes
[0] = skb_copy(skb
, GFP_ATOMIC
);
791 memcpy(rxb
->src
,src
,ETH_ALEN
);
792 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
793 //IEEE80211_DEBUG_DATA(IEEE80211_DL_RX,skb->data,skb->len);
796 rxb
->nr_subframes
= 0;
797 memcpy(rxb
->src
,src
,ETH_ALEN
);
798 memcpy(rxb
->dst
,dst
,ETH_ALEN
);
799 while(skb
->len
> ETHERNET_HEADER_SIZE
) {
800 /* Offset 12 denote 2 mac address */
801 nSubframe_Length
= *((u16
*)(skb
->data
+ 12));
802 //==m==>change the length order
803 nSubframe_Length
= (nSubframe_Length
>>8) + (nSubframe_Length
<<8);
805 if(skb
->len
<(ETHERNET_HEADER_SIZE
+ nSubframe_Length
)) {
806 printk("%s: A-MSDU parse error!! pRfd->nTotalSubframe : %d\n",\
807 __FUNCTION__
,rxb
->nr_subframes
);
808 printk("%s: A-MSDU parse error!! Subframe Length: %d\n",__FUNCTION__
, nSubframe_Length
);
809 printk("nRemain_Length is %d and nSubframe_Length is : %d\n",skb
->len
,nSubframe_Length
);
810 printk("The Packet SeqNum is %d\n",SeqNum
);
814 /* move the data point to data content */
815 skb_pull(skb
, ETHERNET_HEADER_SIZE
);
818 sub_skb
= skb_clone(skb
, GFP_ATOMIC
);
819 sub_skb
->len
= nSubframe_Length
;
820 sub_skb
->tail
= sub_skb
->data
+ nSubframe_Length
;
822 /* Allocate new skb for releasing to upper layer */
823 sub_skb
= dev_alloc_skb(nSubframe_Length
+ 12);
824 skb_reserve(sub_skb
, 12);
825 data_ptr
= (u8
*)skb_put(sub_skb
, nSubframe_Length
);
826 memcpy(data_ptr
,skb
->data
,nSubframe_Length
);
828 rxb
->subframes
[rxb
->nr_subframes
++] = sub_skb
;
829 if(rxb
->nr_subframes
>= MAX_SUBFRAME_COUNT
) {
830 IEEE80211_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
833 skb_pull(skb
,nSubframe_Length
);
836 nPadding_Length
= 4 - ((nSubframe_Length
+ ETHERNET_HEADER_SIZE
) % 4);
837 if(nPadding_Length
== 4) {
841 if(skb
->len
< nPadding_Length
) {
845 skb_pull(skb
,nPadding_Length
);
851 //{just for debug added by david
852 //printk("AMSDU::rxb->nr_subframes = %d\n",rxb->nr_subframes);
854 return rxb
->nr_subframes
;
858 /* All received frames are sent to this function. @skb contains the frame in
859 * IEEE 802.11 format, i.e., in the format it was sent over air.
860 * This function is called only as a tasklet (software IRQ). */
861 int ieee80211_rtl_rx(struct ieee80211_device
*ieee
, struct sk_buff
*skb
,
862 struct ieee80211_rx_stats
*rx_stats
)
864 struct net_device
*dev
= ieee
->dev
;
865 struct ieee80211_hdr_4addr
*hdr
;
866 //struct ieee80211_hdr_3addrqos *hdr;
869 u16 fc
, type
, stype
, sc
;
870 struct net_device_stats
*stats
;
874 //added by amy for reorder
877 PRX_TS_RECORD pTS
= NULL
;
878 //bool bIsAggregateFrame = false;
879 //added by amy for reorder
884 struct ieee80211_crypt_data
*crypt
= NULL
;
888 struct ieee80211_rxb
* rxb
= NULL
;
889 // cheat the the hdr type
890 hdr
= (struct ieee80211_hdr_4addr
*)skb
->data
;
891 stats
= &ieee
->stats
;
894 printk(KERN_INFO
"%s: SKB length < 10\n",
899 fc
= le16_to_cpu(hdr
->frame_ctl
);
900 type
= WLAN_FC_GET_TYPE(fc
);
901 stype
= WLAN_FC_GET_STYPE(fc
);
902 sc
= le16_to_cpu(hdr
->seq_ctl
);
904 frag
= WLAN_GET_SEQ_FRAG(sc
);
905 hdrlen
= ieee80211_get_hdrlen(fc
);
907 if(HTCCheck(ieee
, skb
->data
))
910 printk("find HTCControl\n");
912 rx_stats
->bContainHTC
= 1;
915 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
917 if (ieee
->iw_mode
== IW_MODE_MONITOR
) {
918 ieee80211_monitor_rx(ieee
, skb
, rx_stats
);
920 stats
->rx_bytes
+= skb
->len
;
924 if (ieee
->host_decrypt
) {
926 if (skb
->len
>= hdrlen
+ 3)
927 idx
= skb
->data
[hdrlen
+ 3] >> 6;
928 crypt
= ieee
->crypt
[idx
];
930 /* allow NULL decrypt to indicate an station specific override
931 * for default encryption */
932 if (crypt
&& (crypt
->ops
== NULL
||
933 crypt
->ops
->decrypt_mpdu
== NULL
))
936 if (!crypt
&& (fc
& IEEE80211_FCTL_WEP
)) {
937 /* This seems to be triggered by some (multicast?)
938 * frames from other than current BSS, so just drop the
939 * frames silently instead of filling system log with
941 IEEE80211_DEBUG_DROP("Decryption failed (not set)"
942 " (SA=" MAC_FMT
")\n",
943 MAC_ARG(hdr
->addr2
));
944 ieee
->ieee_stats
.rx_discards_undecryptable
++;
949 if (skb
->len
< IEEE80211_DATA_HDR3_LEN
)
952 // if QoS enabled, should check the sequence for each of the AC
953 if( (ieee
->pHTInfo
->bCurRxReorderEnable
== false) || !ieee
->current_network
.qos_data
.active
|| !IsDataFrame(skb
->data
) || IsLegacyDataFrame(skb
->data
)){
954 if (is_duplicate_packet(ieee
, hdr
))
960 PRX_TS_RECORD pRxTS
= NULL
;
961 //IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): QOS ENABLE AND RECEIVE QOS DATA , we will get Ts, tid:%d\n",__FUNCTION__, tid);
965 (PTS_COMMON_INFO
*) &pRxTS
,
967 (u8
)Frame_QoSTID((u8
*)(skb
->data
)),
972 // IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): pRxTS->RxLastFragNum is %d,frag is %d,pRxTS->RxLastSeqNum is %d,seq is %d\n",__FUNCTION__,pRxTS->RxLastFragNum,frag,pRxTS->RxLastSeqNum,WLAN_GET_SEQ_SEQ(sc));
973 if( (fc
& (1<<11)) &&
974 (frag
== pRxTS
->RxLastFragNum
) &&
975 (WLAN_GET_SEQ_SEQ(sc
) == pRxTS
->RxLastSeqNum
) )
981 pRxTS
->RxLastFragNum
= frag
;
982 pRxTS
->RxLastSeqNum
= WLAN_GET_SEQ_SEQ(sc
);
987 IEEE80211_DEBUG(IEEE80211_DL_ERR
, "%s(): No TS!! Skip the check!!\n",__FUNCTION__
);
992 if (type
== IEEE80211_FTYPE_MGMT
) {
994 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
995 if (ieee80211_rx_frame_mgmt(ieee
, skb
, rx_stats
, type
, stype
))
1001 /* Data frame - extract src/dst addresses */
1002 switch (fc
& (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
1003 case IEEE80211_FCTL_FROMDS
:
1004 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1005 memcpy(src
, hdr
->addr3
, ETH_ALEN
);
1006 memcpy(bssid
, hdr
->addr2
, ETH_ALEN
);
1008 case IEEE80211_FCTL_TODS
:
1009 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1010 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1011 memcpy(bssid
, hdr
->addr1
, ETH_ALEN
);
1013 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
1014 if (skb
->len
< IEEE80211_DATA_HDR4_LEN
)
1016 memcpy(dst
, hdr
->addr3
, ETH_ALEN
);
1017 memcpy(src
, hdr
->addr4
, ETH_ALEN
);
1018 memcpy(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
);
1021 memcpy(dst
, hdr
->addr1
, ETH_ALEN
);
1022 memcpy(src
, hdr
->addr2
, ETH_ALEN
);
1023 memcpy(bssid
, hdr
->addr3
, ETH_ALEN
);
1028 dev
->last_rx
= jiffies
;
1030 //IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA, skb->data, skb->len);
1031 /* Nullfunc frames may have PS-bit set, so they must be passed to
1032 * hostap_handle_sta_rx() before being dropped here. */
1033 if (stype
!= IEEE80211_STYPE_DATA
&&
1034 stype
!= IEEE80211_STYPE_DATA_CFACK
&&
1035 stype
!= IEEE80211_STYPE_DATA_CFPOLL
&&
1036 stype
!= IEEE80211_STYPE_DATA_CFACKPOLL
&&
1037 stype
!= IEEE80211_STYPE_QOS_DATA
//add by David,2006.8.4
1039 if (stype
!= IEEE80211_STYPE_NULLFUNC
)
1040 IEEE80211_DEBUG_DROP(
1041 "RX: dropped data frame "
1042 "with no data (type=0x%02x, "
1043 "subtype=0x%02x, len=%d)\n",
1044 type
, stype
, skb
->len
);
1047 if (memcmp(bssid
, ieee
->current_network
.bssid
, ETH_ALEN
))
1050 /* skb: hdr + (possibly fragmented, possibly encrypted) payload */
1052 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1053 (keyidx
= ieee80211_rx_frame_decrypt(ieee
, skb
, crypt
)) < 0)
1055 printk("decrypt frame error\n");
1060 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1062 /* skb: hdr + (possibly fragmented) plaintext payload */
1063 // PR: FIXME: hostap has additional conditions in the "if" below:
1064 // ieee->host_decrypt && (fc & IEEE80211_FCTL_WEP) &&
1065 if ((frag
!= 0 || (fc
& IEEE80211_FCTL_MOREFRAGS
))) {
1067 struct sk_buff
*frag_skb
= ieee80211_frag_cache_get(ieee
, hdr
);
1068 IEEE80211_DEBUG_FRAG("Rx Fragment received (%u)\n", frag
);
1071 IEEE80211_DEBUG(IEEE80211_DL_RX
| IEEE80211_DL_FRAG
,
1072 "Rx cannot get skb from fragment "
1073 "cache (morefrag=%d seq=%u frag=%u)\n",
1074 (fc
& IEEE80211_FCTL_MOREFRAGS
) != 0,
1075 WLAN_GET_SEQ_SEQ(sc
), frag
);
1082 if (frag_skb
->tail
+ flen
> frag_skb
->end
) {
1083 printk(KERN_WARNING
"%s: host decrypted and "
1084 "reassembled frame did not fit skb\n",
1086 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1091 /* copy first fragment (including full headers) into
1092 * beginning of the fragment cache skb */
1093 memcpy(skb_put(frag_skb
, flen
), skb
->data
, flen
);
1095 /* append frame payload to the end of the fragment
1097 memcpy(skb_put(frag_skb
, flen
), skb
->data
+ hdrlen
,
1100 dev_kfree_skb_any(skb
);
1103 if (fc
& IEEE80211_FCTL_MOREFRAGS
) {
1104 /* more fragments expected - leave the skb in fragment
1105 * cache for now; it will be delivered to upper layers
1106 * after all fragments have been received */
1110 /* this was the last fragment and the frame will be
1111 * delivered, so remove skb from fragment cache */
1113 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1114 ieee80211_frag_cache_invalidate(ieee
, hdr
);
1117 /* skb: hdr + (possible reassembled) full MSDU payload; possibly still
1118 * encrypted/authenticated */
1119 if (ieee
->host_decrypt
&& (fc
& IEEE80211_FCTL_WEP
) &&
1120 ieee80211_rx_frame_decrypt_msdu(ieee
, skb
, keyidx
, crypt
))
1122 printk("==>decrypt msdu error\n");
1126 //added by amy for AP roaming
1127 ieee
->LinkDetectInfo
.NumRecvDataInPeriod
++;
1128 ieee
->LinkDetectInfo
.NumRxOkInPeriod
++;
1130 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1131 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
) {
1132 if (/*ieee->ieee802_1x &&*/
1133 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1135 #ifdef CONFIG_IEEE80211_DEBUG
1136 /* pass unencrypted EAPOL frames even if encryption is
1138 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1140 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1141 eap_get_type(eap
->type
));
1144 IEEE80211_DEBUG_DROP(
1145 "encryption configured, but RX "
1146 "frame not encrypted (SA=" MAC_FMT
")\n",
1147 MAC_ARG(hdr
->addr2
));
1152 #ifdef CONFIG_IEEE80211_DEBUG
1153 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) &&
1154 ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1155 struct eapol
*eap
= (struct eapol
*)(skb
->data
+
1157 IEEE80211_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
1158 eap_get_type(eap
->type
));
1162 if (crypt
&& !(fc
& IEEE80211_FCTL_WEP
) && !ieee
->open_wep
&&
1163 !ieee80211_is_eapol_frame(ieee
, skb
, hdrlen
)) {
1164 IEEE80211_DEBUG_DROP(
1165 "dropped unencrypted RX data "
1166 "frame from " MAC_FMT
1167 " (drop_unencrypted=1)\n",
1168 MAC_ARG(hdr
->addr2
));
1172 if(ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
1173 printk(KERN_WARNING "RX: IEEE802.1X EPAOL frame!\n");
1176 //added by amy for reorder
1178 if(ieee
->current_network
.qos_data
.active
&& IsQoSDataFrame(skb
->data
)
1179 && !is_multicast_ether_addr(hdr
->addr1
) && !is_broadcast_ether_addr(hdr
->addr1
))
1181 TID
= Frame_QoSTID(skb
->data
);
1182 SeqNum
= WLAN_GET_SEQ_SEQ(sc
);
1183 GetTs(ieee
,(PTS_COMMON_INFO
*) &pTS
,hdr
->addr2
,TID
,RX_DIR
,true);
1184 if(TID
!=0 && TID
!=3)
1186 ieee
->bis_any_nonbepkts
= true;
1190 //added by amy for reorder
1191 /* skb: hdr + (possible reassembled) full plaintext payload */
1192 payload
= skb
->data
+ hdrlen
;
1193 //ethertype = (payload[6] << 8) | payload[7];
1194 rxb
= (struct ieee80211_rxb
*)kmalloc(sizeof(struct ieee80211_rxb
),GFP_ATOMIC
);
1197 IEEE80211_DEBUG(IEEE80211_DL_ERR
,"%s(): kmalloc rxb error\n",__FUNCTION__
);
1200 /* to parse amsdu packets */
1201 /* qos data packets & reserved bit is 1 */
1202 if(parse_subframe(skb
,rx_stats
,rxb
,src
,dst
) == 0) {
1203 /* only to free rxb, and not submit the packets to upper layer */
1204 for(i
=0; i
< rxb
->nr_subframes
; i
++) {
1205 dev_kfree_skb(rxb
->subframes
[i
]);
1212 ieee
->last_rx_ps_time
= jiffies
;
1213 //added by amy for reorder
1214 if(ieee
->pHTInfo
->bCurRxReorderEnable
== false ||pTS
== NULL
){
1215 //added by amy for reorder
1216 for(i
= 0; i
<rxb
->nr_subframes
; i
++) {
1217 struct sk_buff
*sub_skb
= rxb
->subframes
[i
];
1220 /* convert hdr + possible LLC headers into Ethernet header */
1221 ethertype
= (sub_skb
->data
[6] << 8) | sub_skb
->data
[7];
1222 if (sub_skb
->len
>= 8 &&
1223 ((memcmp(sub_skb
->data
, rfc1042_header
, SNAP_SIZE
) == 0 &&
1224 ethertype
!= ETH_P_AARP
&& ethertype
!= ETH_P_IPX
) ||
1225 memcmp(sub_skb
->data
, bridge_tunnel_header
, SNAP_SIZE
) == 0)) {
1226 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1227 * replace EtherType */
1228 skb_pull(sub_skb
, SNAP_SIZE
);
1229 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1230 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1233 /* Leave Ethernet header part of hdr and full payload */
1234 len
= htons(sub_skb
->len
);
1235 memcpy(skb_push(sub_skb
, 2), &len
, 2);
1236 memcpy(skb_push(sub_skb
, ETH_ALEN
), src
, ETH_ALEN
);
1237 memcpy(skb_push(sub_skb
, ETH_ALEN
), dst
, ETH_ALEN
);
1240 stats
->rx_packets
++;
1241 stats
->rx_bytes
+= sub_skb
->len
;
1242 if(is_multicast_ether_addr(dst
)) {
1246 /* Indicat the packets to upper layer */
1247 //printk("0skb_len(%d)\n", skb->len);
1248 sub_skb
->protocol
= eth_type_trans(sub_skb
, dev
);
1249 memset(sub_skb
->cb
, 0, sizeof(sub_skb
->cb
));
1251 sub_skb
->ip_summed
= CHECKSUM_NONE
; /* 802.11 crc not sufficient */
1252 //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */
1253 //printk("1skb_len(%d)\n", skb->len);
1263 IEEE80211_DEBUG(IEEE80211_DL_REORDER
,"%s(): REORDER ENABLE AND PTS not NULL, and we will enter RxReorderIndicatePacket()\n",__FUNCTION__
);
1264 RxReorderIndicatePacket(ieee
, rxb
, pTS
, SeqNum
);
1279 stats
->rx_dropped
++;
1281 /* Returning 0 indicates to caller that we have not handled the SKB--
1282 * so it is still allocated and can be used again by underlying
1283 * hardware as a DMA target */
1287 #define MGMT_FRAME_FIXED_PART_LENGTH 0x24
1289 static u8 qos_oui
[QOS_OUI_LEN
] = { 0x00, 0x50, 0xF2 };
1292 * Make ther structure we read from the beacon packet has
1295 static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element
1296 *info_element
, int sub_type
)
1299 if (info_element
->qui_subtype
!= sub_type
)
1301 if (memcmp(info_element
->qui
, qos_oui
, QOS_OUI_LEN
))
1303 if (info_element
->qui_type
!= QOS_OUI_TYPE
)
1305 if (info_element
->version
!= QOS_VERSION_1
)
1313 * Parse a QoS parameter element
1315 static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info
1316 *element_param
, struct ieee80211_info_element
1320 u16 size
= sizeof(struct ieee80211_qos_parameter_info
) - 2;
1322 if ((info_element
== NULL
) || (element_param
== NULL
))
1325 if (info_element
->id
== QOS_ELEMENT_ID
&& info_element
->len
== size
) {
1326 memcpy(element_param
->info_element
.qui
, info_element
->data
,
1328 element_param
->info_element
.elementID
= info_element
->id
;
1329 element_param
->info_element
.length
= info_element
->len
;
1333 ret
= ieee80211_verify_qos_info(&element_param
->info_element
,
1334 QOS_OUI_PARAM_SUB_TYPE
);
1339 * Parse a QoS information element
1341 static int ieee80211_read_qos_info_element(struct
1342 ieee80211_qos_information_element
1343 *element_info
, struct ieee80211_info_element
1347 u16 size
= sizeof(struct ieee80211_qos_information_element
) - 2;
1349 if (element_info
== NULL
)
1351 if (info_element
== NULL
)
1354 if ((info_element
->id
== QOS_ELEMENT_ID
) && (info_element
->len
== size
)) {
1355 memcpy(element_info
->qui
, info_element
->data
,
1357 element_info
->elementID
= info_element
->id
;
1358 element_info
->length
= info_element
->len
;
1363 ret
= ieee80211_verify_qos_info(element_info
,
1364 QOS_OUI_INFO_SUB_TYPE
);
1370 * Write QoS parameters from the ac parameters.
1372 static int ieee80211_qos_convert_ac_to_parameters(struct
1373 ieee80211_qos_parameter_info
1375 ieee80211_qos_parameters
1380 struct ieee80211_qos_ac_parameter
*ac_params
;
1385 for (i
= 0; i
< QOS_QUEUE_NUM
; i
++) {
1386 ac_params
= &(param_elm
->ac_params_record
[i
]);
1388 aci
= (ac_params
->aci_aifsn
& 0x60) >> 5;
1390 if(aci
>= QOS_QUEUE_NUM
)
1392 qos_param
->aifs
[aci
] = (ac_params
->aci_aifsn
) & 0x0f;
1394 /* WMM spec P.11: The minimum value for AIFSN shall be 2 */
1395 qos_param
->aifs
[aci
] = (qos_param
->aifs
[aci
] < 2) ? 2:qos_param
->aifs
[aci
];
1397 qos_param
->cw_min
[aci
] = ac_params
->ecw_min_max
& 0x0F;
1399 qos_param
->cw_max
[aci
] = (ac_params
->ecw_min_max
& 0xF0) >> 4;
1401 qos_param
->flag
[aci
] =
1402 (ac_params
->aci_aifsn
& 0x10) ? 0x01 : 0x00;
1403 qos_param
->tx_op_limit
[aci
] = le16_to_cpu(ac_params
->tx_op_limit
);
1409 * we have a generic data element which it may contain QoS information or
1410 * parameters element. check the information element length to decide
1411 * which type to read
1413 static int ieee80211_parse_qos_info_param_IE(struct ieee80211_info_element
1415 struct ieee80211_network
*network
)
1418 struct ieee80211_qos_parameters
*qos_param
= NULL
;
1419 struct ieee80211_qos_information_element qos_info_element
;
1421 rc
= ieee80211_read_qos_info_element(&qos_info_element
, info_element
);
1424 network
->qos_data
.param_count
= qos_info_element
.ac_info
& 0x0F;
1425 network
->flags
|= NETWORK_HAS_QOS_INFORMATION
;
1427 struct ieee80211_qos_parameter_info param_element
;
1429 rc
= ieee80211_read_qos_param_element(¶m_element
,
1432 qos_param
= &(network
->qos_data
.parameters
);
1433 ieee80211_qos_convert_ac_to_parameters(¶m_element
,
1435 network
->flags
|= NETWORK_HAS_QOS_PARAMETERS
;
1436 network
->qos_data
.param_count
=
1437 param_element
.info_element
.ac_info
& 0x0F;
1442 IEEE80211_DEBUG_QOS("QoS is supported\n");
1443 network
->qos_data
.supported
= 1;
1448 #ifdef CONFIG_IEEE80211_DEBUG
1449 #define MFIE_STRING(x) case MFIE_TYPE_ ##x: return #x
1451 static const char *get_info_element_string(u16 id
)
1456 MFIE_STRING(FH_SET
);
1457 MFIE_STRING(DS_SET
);
1458 MFIE_STRING(CF_SET
);
1460 MFIE_STRING(IBSS_SET
);
1461 MFIE_STRING(COUNTRY
);
1462 MFIE_STRING(HOP_PARAMS
);
1463 MFIE_STRING(HOP_TABLE
);
1464 MFIE_STRING(REQUEST
);
1465 MFIE_STRING(CHALLENGE
);
1466 MFIE_STRING(POWER_CONSTRAINT
);
1467 MFIE_STRING(POWER_CAPABILITY
);
1468 MFIE_STRING(TPC_REQUEST
);
1469 MFIE_STRING(TPC_REPORT
);
1470 MFIE_STRING(SUPP_CHANNELS
);
1472 MFIE_STRING(MEASURE_REQUEST
);
1473 MFIE_STRING(MEASURE_REPORT
);
1475 MFIE_STRING(IBSS_DFS
);
1476 // MFIE_STRING(ERP_INFO);
1478 MFIE_STRING(RATES_EX
);
1479 MFIE_STRING(GENERIC
);
1480 MFIE_STRING(QOS_PARAMETER
);
1487 static inline void ieee80211_extract_country_ie(
1488 struct ieee80211_device
*ieee
,
1489 struct ieee80211_info_element
*info_element
,
1490 struct ieee80211_network
*network
,
1494 if(IS_DOT11D_ENABLE(ieee
))
1496 if(info_element
->len
!= 0)
1498 memcpy(network
->CountryIeBuf
, info_element
->data
, info_element
->len
);
1499 network
->CountryIeLen
= info_element
->len
;
1501 if(!IS_COUNTRY_IE_VALID(ieee
))
1503 Dot11d_UpdateCountryIe(ieee
, addr2
, info_element
->len
, info_element
->data
);
1508 // 070305, rcnjko: I update country IE watch dog here because
1509 // some AP (e.g. Cisco 1242) don't include country IE in their
1510 // probe response frame.
1512 if(IS_EQUAL_CIE_SRC(ieee
, addr2
) )
1514 UPDATE_CIE_WATCHDOG(ieee
);
1520 int ieee80211_parse_info_param(struct ieee80211_device
*ieee
,
1521 struct ieee80211_info_element
*info_element
,
1523 struct ieee80211_network
*network
,
1524 struct ieee80211_rx_stats
*stats
)
1528 u16 tmp_htcap_len
=0;
1529 u16 tmp_htinfo_len
=0;
1530 u16 ht_realtek_agg_len
=0;
1531 u8 ht_realtek_agg_buf
[MAX_IE_LEN
];
1532 // u16 broadcom_len = 0;
1533 #ifdef CONFIG_IEEE80211_DEBUG
1538 while (length
>= sizeof(*info_element
)) {
1539 if (sizeof(*info_element
) + info_element
->len
> length
) {
1540 IEEE80211_DEBUG_MGMT("Info elem: parse failed: "
1541 "info_element->len + 2 > left : "
1542 "info_element->len+2=%zd left=%d, id=%d.\n",
1544 sizeof(*info_element
),
1545 length
, info_element
->id
);
1546 /* We stop processing but don't return an error here
1547 * because some misbehaviour APs break this rule. ie.
1548 * Orinoco AP1000. */
1552 switch (info_element
->id
) {
1553 case MFIE_TYPE_SSID
:
1554 if (ieee80211_is_empty_essid(info_element
->data
,
1555 info_element
->len
)) {
1556 network
->flags
|= NETWORK_EMPTY_ESSID
;
1560 network
->ssid_len
= min(info_element
->len
,
1561 (u8
) IW_ESSID_MAX_SIZE
);
1562 memcpy(network
->ssid
, info_element
->data
, network
->ssid_len
);
1563 if (network
->ssid_len
< IW_ESSID_MAX_SIZE
)
1564 memset(network
->ssid
+ network
->ssid_len
, 0,
1565 IW_ESSID_MAX_SIZE
- network
->ssid_len
);
1567 IEEE80211_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
1568 network
->ssid
, network
->ssid_len
);
1571 case MFIE_TYPE_RATES
:
1572 #ifdef CONFIG_IEEE80211_DEBUG
1575 network
->rates_len
= min(info_element
->len
,
1577 for (i
= 0; i
< network
->rates_len
; i
++) {
1578 network
->rates
[i
] = info_element
->data
[i
];
1579 #ifdef CONFIG_IEEE80211_DEBUG
1580 p
+= snprintf(p
, sizeof(rates_str
) -
1581 (p
- rates_str
), "%02X ",
1584 if (ieee80211_is_ofdm_rate
1585 (info_element
->data
[i
])) {
1586 network
->flags
|= NETWORK_HAS_OFDM
;
1587 if (info_element
->data
[i
] &
1588 IEEE80211_BASIC_RATE_MASK
)
1594 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
1595 rates_str
, network
->rates_len
);
1598 case MFIE_TYPE_RATES_EX
:
1599 #ifdef CONFIG_IEEE80211_DEBUG
1602 network
->rates_ex_len
= min(info_element
->len
,
1603 MAX_RATES_EX_LENGTH
);
1604 for (i
= 0; i
< network
->rates_ex_len
; i
++) {
1605 network
->rates_ex
[i
] = info_element
->data
[i
];
1606 #ifdef CONFIG_IEEE80211_DEBUG
1607 p
+= snprintf(p
, sizeof(rates_str
) -
1608 (p
- rates_str
), "%02X ",
1611 if (ieee80211_is_ofdm_rate
1612 (info_element
->data
[i
])) {
1613 network
->flags
|= NETWORK_HAS_OFDM
;
1614 if (info_element
->data
[i
] &
1615 IEEE80211_BASIC_RATE_MASK
)
1621 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
1622 rates_str
, network
->rates_ex_len
);
1625 case MFIE_TYPE_DS_SET
:
1626 IEEE80211_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
1627 info_element
->data
[0]);
1628 network
->channel
= info_element
->data
[0];
1631 case MFIE_TYPE_FH_SET
:
1632 IEEE80211_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
1635 case MFIE_TYPE_CF_SET
:
1636 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
1640 if(info_element
->len
< 4)
1643 network
->tim
.tim_count
= info_element
->data
[0];
1644 network
->tim
.tim_period
= info_element
->data
[1];
1646 network
->dtim_period
= info_element
->data
[1];
1647 if(ieee
->state
!= IEEE80211_LINKED
)
1649 //we use jiffies for legacy Power save
1650 network
->last_dtim_sta_time
[0] = jiffies
;
1651 network
->last_dtim_sta_time
[1] = stats
->mac_time
[1];
1653 network
->dtim_data
= IEEE80211_DTIM_VALID
;
1655 if(info_element
->data
[0] != 0)
1658 if(info_element
->data
[2] & 1)
1659 network
->dtim_data
|= IEEE80211_DTIM_MBCAST
;
1661 offset
= (info_element
->data
[2] >> 1)*2;
1663 //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id);
1665 if(ieee
->assoc_id
< 8*offset
||
1666 ieee
->assoc_id
> 8*(offset
+ info_element
->len
-3))
1670 offset
= (ieee
->assoc_id
/ 8) - offset
;// + ((aid % 8)? 0 : 1) ;
1672 if(info_element
->data
[3+offset
] & (1<<(ieee
->assoc_id
%8)))
1673 network
->dtim_data
|= IEEE80211_DTIM_UCAST
;
1675 //IEEE80211_DEBUG_MGMT("MFIE_TYPE_TIM: partially ignored\n");
1679 network
->erp_value
= info_element
->data
[0];
1680 network
->flags
|= NETWORK_HAS_ERP_VALUE
;
1681 IEEE80211_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
1682 network
->erp_value
);
1684 case MFIE_TYPE_IBSS_SET
:
1685 network
->atim_window
= info_element
->data
[0];
1686 IEEE80211_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
1687 network
->atim_window
);
1690 case MFIE_TYPE_CHALLENGE
:
1691 IEEE80211_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
1694 case MFIE_TYPE_GENERIC
:
1695 IEEE80211_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
1697 if (!ieee80211_parse_qos_info_param_IE(info_element
,
1701 if (info_element
->len
>= 4 &&
1702 info_element
->data
[0] == 0x00 &&
1703 info_element
->data
[1] == 0x50 &&
1704 info_element
->data
[2] == 0xf2 &&
1705 info_element
->data
[3] == 0x01) {
1706 network
->wpa_ie_len
= min(info_element
->len
+ 2,
1708 memcpy(network
->wpa_ie
, info_element
,
1709 network
->wpa_ie_len
);
1713 if (info_element
->len
== 7 &&
1714 info_element
->data
[0] == 0x00 &&
1715 info_element
->data
[1] == 0xe0 &&
1716 info_element
->data
[2] == 0x4c &&
1717 info_element
->data
[3] == 0x01 &&
1718 info_element
->data
[4] == 0x02) {
1719 network
->Turbo_Enable
= 1;
1722 //for HTcap and HTinfo parameters
1723 if(tmp_htcap_len
== 0){
1724 if(info_element
->len
>= 4 &&
1725 info_element
->data
[0] == 0x00 &&
1726 info_element
->data
[1] == 0x90 &&
1727 info_element
->data
[2] == 0x4c &&
1728 info_element
->data
[3] == 0x033){
1730 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1731 if(tmp_htcap_len
!= 0){
1732 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1733 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
1734 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
1735 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
1738 if(tmp_htcap_len
!= 0){
1739 network
->bssht
.bdSupportHT
= true;
1740 network
->bssht
.bdHT1R
= ((((PHT_CAPABILITY_ELE
)(network
->bssht
.bdHTCapBuf
))->MCS
[1]) == 0);
1742 network
->bssht
.bdSupportHT
= false;
1743 network
->bssht
.bdHT1R
= false;
1748 if(tmp_htinfo_len
== 0){
1749 if(info_element
->len
>= 4 &&
1750 info_element
->data
[0] == 0x00 &&
1751 info_element
->data
[1] == 0x90 &&
1752 info_element
->data
[2] == 0x4c &&
1753 info_element
->data
[3] == 0x034){
1755 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1756 if(tmp_htinfo_len
!= 0){
1757 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1759 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
1760 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
1761 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
1769 if(ieee
->aggregation
){
1770 if(network
->bssht
.bdSupportHT
){
1771 if(info_element
->len
>= 4 &&
1772 info_element
->data
[0] == 0x00 &&
1773 info_element
->data
[1] == 0xe0 &&
1774 info_element
->data
[2] == 0x4c &&
1775 info_element
->data
[3] == 0x02){
1777 ht_realtek_agg_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1778 memcpy(ht_realtek_agg_buf
,info_element
->data
,info_element
->len
);
1781 if(ht_realtek_agg_len
>= 5){
1782 network
->realtek_cap_exit
= true;
1783 network
->bssht
.bdRT2RTAggregation
= true;
1785 if((ht_realtek_agg_buf
[4] == 1) && (ht_realtek_agg_buf
[5] & 0x02))
1786 network
->bssht
.bdRT2RTLongSlotTime
= true;
1788 if((ht_realtek_agg_buf
[4]==1) && (ht_realtek_agg_buf
[5] & RT_HT_CAP_USE_92SE
))
1790 network
->bssht
.RT2RT_HT_Mode
|= RT_HT_CAP_USE_92SE
;
1791 //bssDesc->Vender = HT_IOT_PEER_REALTEK_92SE;
1798 //if(tmp_htcap_len !=0 || tmp_htinfo_len != 0)
1800 if((info_element
->len
>= 3 &&
1801 info_element
->data
[0] == 0x00 &&
1802 info_element
->data
[1] == 0x05 &&
1803 info_element
->data
[2] == 0xb5) ||
1804 (info_element
->len
>= 3 &&
1805 info_element
->data
[0] == 0x00 &&
1806 info_element
->data
[1] == 0x0a &&
1807 info_element
->data
[2] == 0xf7) ||
1808 (info_element
->len
>= 3 &&
1809 info_element
->data
[0] == 0x00 &&
1810 info_element
->data
[1] == 0x10 &&
1811 info_element
->data
[2] == 0x18)){
1813 network
->broadcom_cap_exist
= true;
1817 if(info_element
->len
>= 3 &&
1818 info_element
->data
[0] == 0x00 &&
1819 info_element
->data
[1] == 0x0c &&
1820 info_element
->data
[2] == 0x43)
1822 network
->ralink_cap_exist
= true;
1825 network
->ralink_cap_exist
= false;
1826 //added by amy for atheros AP
1827 if((info_element
->len
>= 3 &&
1828 info_element
->data
[0] == 0x00 &&
1829 info_element
->data
[1] == 0x03 &&
1830 info_element
->data
[2] == 0x7f) ||
1831 (info_element
->len
>= 3 &&
1832 info_element
->data
[0] == 0x00 &&
1833 info_element
->data
[1] == 0x13 &&
1834 info_element
->data
[2] == 0x74))
1836 // printk("========>%s(): athros AP is exist\n",__FUNCTION__);
1837 network
->atheros_cap_exist
= true;
1840 network
->atheros_cap_exist
= false;
1842 if ((info_element
->len
>= 3 &&
1843 info_element
->data
[0] == 0x00 &&
1844 info_element
->data
[1] == 0x50 &&
1845 info_element
->data
[2] == 0x43) )
1847 network
->marvell_cap_exist
= true;
1850 network
->marvell_cap_exist
= false;
1852 if(info_element
->len
>= 3 &&
1853 info_element
->data
[0] == 0x00 &&
1854 info_element
->data
[1] == 0x40 &&
1855 info_element
->data
[2] == 0x96)
1857 network
->cisco_cap_exist
= true;
1860 network
->cisco_cap_exist
= false;
1861 //added by amy for LEAP of cisco
1862 if(info_element
->len
> 4 &&
1863 info_element
->data
[0] == 0x00 &&
1864 info_element
->data
[1] == 0x40 &&
1865 info_element
->data
[2] == 0x96 &&
1866 info_element
->data
[3] == 0x01)
1868 if(info_element
->len
== 6)
1870 memcpy(network
->CcxRmState
, &info_element
[4], 2);
1871 if(network
->CcxRmState
[0] != 0)
1873 network
->bCcxRmEnable
= true;
1876 network
->bCcxRmEnable
= false;
1878 // CCXv4 Table 59-1 MBSSID Masks.
1880 network
->MBssidMask
= network
->CcxRmState
[1] & 0x07;
1881 if(network
->MBssidMask
!= 0)
1883 network
->bMBssidValid
= true;
1884 network
->MBssidMask
= 0xff << (network
->MBssidMask
);
1885 cpMacAddr(network
->MBssid
, network
->bssid
);
1886 network
->MBssid
[5] &= network
->MBssidMask
;
1890 network
->bMBssidValid
= false;
1895 network
->bCcxRmEnable
= false;
1898 if(info_element
->len
> 4 &&
1899 info_element
->data
[0] == 0x00 &&
1900 info_element
->data
[1] == 0x40 &&
1901 info_element
->data
[2] == 0x96 &&
1902 info_element
->data
[3] == 0x03)
1904 if(info_element
->len
== 5)
1906 network
->bWithCcxVerNum
= true;
1907 network
->BssCcxVerNumber
= info_element
->data
[4];
1911 network
->bWithCcxVerNum
= false;
1912 network
->BssCcxVerNumber
= 0;
1918 IEEE80211_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
1920 network
->rsn_ie_len
= min(info_element
->len
+ 2,
1922 memcpy(network
->rsn_ie
, info_element
,
1923 network
->rsn_ie_len
);
1926 //HT related element.
1927 case MFIE_TYPE_HT_CAP
:
1928 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
1930 tmp_htcap_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1931 if(tmp_htcap_len
!= 0){
1932 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_EWC
;
1933 network
->bssht
.bdHTCapLen
= tmp_htcap_len
> sizeof(network
->bssht
.bdHTCapBuf
)?\
1934 sizeof(network
->bssht
.bdHTCapBuf
):tmp_htcap_len
;
1935 memcpy(network
->bssht
.bdHTCapBuf
,info_element
->data
,network
->bssht
.bdHTCapLen
);
1937 //If peer is HT, but not WMM, call QosSetLegacyWMMParamWithHT()
1938 // windows driver will update WMM parameters each beacon received once connected
1939 // Linux driver is a bit different.
1940 network
->bssht
.bdSupportHT
= true;
1941 network
->bssht
.bdHT1R
= ((((PHT_CAPABILITY_ELE
)(network
->bssht
.bdHTCapBuf
))->MCS
[1]) == 0);
1944 network
->bssht
.bdSupportHT
= false;
1945 network
->bssht
.bdHT1R
= false;
1950 case MFIE_TYPE_HT_INFO
:
1951 IEEE80211_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
1953 tmp_htinfo_len
= min(info_element
->len
,(u8
)MAX_IE_LEN
);
1955 network
->bssht
.bdHTSpecVer
= HT_SPEC_VER_IEEE
;
1956 network
->bssht
.bdHTInfoLen
= tmp_htinfo_len
> sizeof(network
->bssht
.bdHTInfoBuf
)?\
1957 sizeof(network
->bssht
.bdHTInfoBuf
):tmp_htinfo_len
;
1958 memcpy(network
->bssht
.bdHTInfoBuf
,info_element
->data
,network
->bssht
.bdHTInfoLen
);
1962 case MFIE_TYPE_AIRONET
:
1963 IEEE80211_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
1965 if(info_element
->len
>IE_CISCO_FLAG_POSITION
)
1967 network
->bWithAironetIE
= true;
1969 // CCX 1 spec v1.13, A01.1 CKIP Negotiation (page23):
1970 // "A Cisco access point advertises support for CKIP in beacon and probe response packets,
1971 // by adding an Aironet element and setting one or both of the CKIP negotiation bits."
1972 if( (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_MIC
) ||
1973 (info_element
->data
[IE_CISCO_FLAG_POSITION
]&SUPPORT_CKIP_PK
) )
1975 network
->bCkipSupported
= true;
1979 network
->bCkipSupported
= false;
1984 network
->bWithAironetIE
= false;
1985 network
->bCkipSupported
= false;
1988 case MFIE_TYPE_QOS_PARAMETER
:
1990 "QoS Error need to parse QOS_PARAMETER IE\n");
1993 case MFIE_TYPE_COUNTRY
:
1994 IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
1996 //printk("=====>Receive <%s> Country IE\n",network->ssid);
1997 ieee80211_extract_country_ie(ieee
, info_element
, network
, network
->bssid
);//addr2 is same as addr3 when from an AP
2000 IEEE80211_DEBUG_MGMT
2001 ("Unsupported info element: %s (%d)\n",
2002 get_info_element_string(info_element
->id
),
2007 length
-= sizeof(*info_element
) + info_element
->len
;
2009 (struct ieee80211_info_element
*)&info_element
->
2010 data
[info_element
->len
];
2013 if(!network
->atheros_cap_exist
&& !network
->broadcom_cap_exist
&&
2014 !network
->cisco_cap_exist
&& !network
->ralink_cap_exist
&& !network
->bssht
.bdRT2RTAggregation
)
2016 network
->unknown_cap_exist
= true;
2020 network
->unknown_cap_exist
= false;
2025 static inline u8
ieee80211_SignalStrengthTranslate(
2031 // Step 1. Scale mapping.
2032 if(CurrSS
>= 71 && CurrSS
<= 100)
2034 RetSS
= 90 + ((CurrSS
- 70) / 3);
2036 else if(CurrSS
>= 41 && CurrSS
<= 70)
2038 RetSS
= 78 + ((CurrSS
- 40) / 3);
2040 else if(CurrSS
>= 31 && CurrSS
<= 40)
2042 RetSS
= 66 + (CurrSS
- 30);
2044 else if(CurrSS
>= 21 && CurrSS
<= 30)
2046 RetSS
= 54 + (CurrSS
- 20);
2048 else if(CurrSS
>= 5 && CurrSS
<= 20)
2050 RetSS
= 42 + (((CurrSS
- 5) * 2) / 3);
2052 else if(CurrSS
== 4)
2056 else if(CurrSS
== 3)
2060 else if(CurrSS
== 2)
2064 else if(CurrSS
== 1)
2072 //RT_TRACE(COMP_DBG, DBG_LOUD, ("##### After Mapping: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2074 // Step 2. Smoothing.
2076 //RT_TRACE(COMP_DBG, DBG_LOUD, ("$$$$$ After Smoothing: LastSS: %d, CurrSS: %d, RetSS: %d\n", LastSS, CurrSS, RetSS));
2081 long ieee80211_translate_todbm(u8 signal_strength_index
)// 0-100 index.
2083 long signal_power
; // in dBm.
2085 // Translate to dBm (x=0.5y-95).
2086 signal_power
= (long)((signal_strength_index
+ 1) >> 1);
2089 return signal_power
;
2092 static inline int ieee80211_network_init(
2093 struct ieee80211_device
*ieee
,
2094 struct ieee80211_probe_response
*beacon
,
2095 struct ieee80211_network
*network
,
2096 struct ieee80211_rx_stats
*stats
)
2098 #ifdef CONFIG_IEEE80211_DEBUG
2099 //char rates_str[64];
2103 network
->qos_data
.active
= 0;
2104 network
->qos_data
.supported
= 0;
2105 network
->qos_data
.param_count
= 0;
2106 network
->qos_data
.old_param_count
= 0;
2108 /* Pull out fixed field data */
2109 memcpy(network
->bssid
, beacon
->header
.addr3
, ETH_ALEN
);
2110 network
->capability
= le16_to_cpu(beacon
->capability
);
2111 network
->last_scanned
= jiffies
;
2112 network
->time_stamp
[0] = le32_to_cpu(beacon
->time_stamp
[0]);
2113 network
->time_stamp
[1] = le32_to_cpu(beacon
->time_stamp
[1]);
2114 network
->beacon_interval
= le32_to_cpu(beacon
->beacon_interval
);
2115 /* Where to pull this? beacon->listen_interval;*/
2116 network
->listen_interval
= 0x0A;
2117 network
->rates_len
= network
->rates_ex_len
= 0;
2118 network
->last_associate
= 0;
2119 network
->ssid_len
= 0;
2121 network
->atim_window
= 0;
2122 network
->erp_value
= (network
->capability
& WLAN_CAPABILITY_IBSS
) ?
2124 network
->berp_info_valid
= false;
2125 network
->broadcom_cap_exist
= false;
2126 network
->ralink_cap_exist
= false;
2127 network
->atheros_cap_exist
= false;
2128 network
->cisco_cap_exist
= false;
2129 network
->unknown_cap_exist
= false;
2130 network
->realtek_cap_exit
= false;
2131 network
->marvell_cap_exist
= false;
2132 network
->Turbo_Enable
= 0;
2133 network
->CountryIeLen
= 0;
2134 memset(network
->CountryIeBuf
, 0, MAX_IE_LEN
);
2135 //Initialize HT parameters
2136 //ieee80211_ht_initialize(&network->bssht);
2137 HTInitializeBssDesc(&network
->bssht
);
2138 if (stats
->freq
== IEEE80211_52GHZ_BAND
) {
2139 /* for A band (No DS info) */
2140 network
->channel
= stats
->received_channel
;
2142 network
->flags
|= NETWORK_HAS_CCK
;
2144 network
->wpa_ie_len
= 0;
2145 network
->rsn_ie_len
= 0;
2147 if (ieee80211_parse_info_param
2148 (ieee
,beacon
->info_element
, stats
->len
- sizeof(*beacon
), network
, stats
))
2152 if (stats
->freq
== IEEE80211_52GHZ_BAND
)
2153 network
->mode
= IEEE_A
;
2155 if (network
->flags
& NETWORK_HAS_OFDM
)
2156 network
->mode
|= IEEE_G
;
2157 if (network
->flags
& NETWORK_HAS_CCK
)
2158 network
->mode
|= IEEE_B
;
2161 if (network
->mode
== 0) {
2162 IEEE80211_DEBUG_SCAN("Filtered out '%s (" MAC_FMT
")' "
2164 escape_essid(network
->ssid
,
2166 MAC_ARG(network
->bssid
));
2170 if(network
->bssht
.bdSupportHT
){
2171 if(network
->mode
== IEEE_A
)
2172 network
->mode
= IEEE_N_5G
;
2173 else if(network
->mode
& (IEEE_G
| IEEE_B
))
2174 network
->mode
= IEEE_N_24G
;
2176 if (ieee80211_is_empty_essid(network
->ssid
, network
->ssid_len
))
2177 network
->flags
|= NETWORK_EMPTY_ESSID
;
2180 stats
->signal
= 30 + (stats
->SignalStrength
* 70) / 100;
2181 //stats->signal = ieee80211_SignalStrengthTranslate(stats->signal);
2182 stats
->noise
= ieee80211_translate_todbm((u8
)(100-stats
->signal
)) -25;
2185 memcpy(&network
->stats
, stats
, sizeof(network
->stats
));
2190 static inline int is_same_network(struct ieee80211_network
*src
,
2191 struct ieee80211_network
*dst
, struct ieee80211_device
* ieee
)
2193 /* A network is only a duplicate if the channel, BSSID, ESSID
2194 * and the capability field (in particular IBSS and BSS) all match.
2195 * We treat all <hidden> with the same BSSID and channel
2197 return //((src->ssid_len == dst->ssid_len) &&
2198 (((src
->ssid_len
== dst
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2199 (src
->channel
== dst
->channel
) &&
2200 !memcmp(src
->bssid
, dst
->bssid
, ETH_ALEN
) &&
2201 //!memcmp(src->ssid, dst->ssid, src->ssid_len) &&
2202 (!memcmp(src
->ssid
, dst
->ssid
, src
->ssid_len
) || (ieee
->iw_mode
== IW_MODE_INFRA
)) &&
2203 ((src
->capability
& WLAN_CAPABILITY_IBSS
) ==
2204 (dst
->capability
& WLAN_CAPABILITY_IBSS
)) &&
2205 ((src
->capability
& WLAN_CAPABILITY_BSS
) ==
2206 (dst
->capability
& WLAN_CAPABILITY_BSS
)));
2209 static inline void update_network(struct ieee80211_network
*dst
,
2210 struct ieee80211_network
*src
)
2215 memcpy(&dst
->stats
, &src
->stats
, sizeof(struct ieee80211_rx_stats
));
2216 dst
->capability
= src
->capability
;
2217 memcpy(dst
->rates
, src
->rates
, src
->rates_len
);
2218 dst
->rates_len
= src
->rates_len
;
2219 memcpy(dst
->rates_ex
, src
->rates_ex
, src
->rates_ex_len
);
2220 dst
->rates_ex_len
= src
->rates_ex_len
;
2221 if(src
->ssid_len
> 0)
2223 memset(dst
->ssid
, 0, dst
->ssid_len
);
2224 dst
->ssid_len
= src
->ssid_len
;
2225 memcpy(dst
->ssid
, src
->ssid
, src
->ssid_len
);
2227 dst
->mode
= src
->mode
;
2228 dst
->flags
= src
->flags
;
2229 dst
->time_stamp
[0] = src
->time_stamp
[0];
2230 dst
->time_stamp
[1] = src
->time_stamp
[1];
2231 if (src
->flags
& NETWORK_HAS_ERP_VALUE
)
2233 dst
->erp_value
= src
->erp_value
;
2234 dst
->berp_info_valid
= src
->berp_info_valid
= true;
2236 dst
->beacon_interval
= src
->beacon_interval
;
2237 dst
->listen_interval
= src
->listen_interval
;
2238 dst
->atim_window
= src
->atim_window
;
2239 dst
->dtim_period
= src
->dtim_period
;
2240 dst
->dtim_data
= src
->dtim_data
;
2241 dst
->last_dtim_sta_time
[0] = src
->last_dtim_sta_time
[0];
2242 dst
->last_dtim_sta_time
[1] = src
->last_dtim_sta_time
[1];
2243 memcpy(&dst
->tim
, &src
->tim
, sizeof(struct ieee80211_tim_parameters
));
2245 dst
->bssht
.bdSupportHT
= src
->bssht
.bdSupportHT
;
2246 dst
->bssht
.bdRT2RTAggregation
= src
->bssht
.bdRT2RTAggregation
;
2247 dst
->bssht
.bdHTCapLen
= src
->bssht
.bdHTCapLen
;
2248 memcpy(dst
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapBuf
,src
->bssht
.bdHTCapLen
);
2249 dst
->bssht
.bdHTInfoLen
= src
->bssht
.bdHTInfoLen
;
2250 memcpy(dst
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoBuf
,src
->bssht
.bdHTInfoLen
);
2251 dst
->bssht
.bdHTSpecVer
= src
->bssht
.bdHTSpecVer
;
2252 dst
->bssht
.bdRT2RTLongSlotTime
= src
->bssht
.bdRT2RTLongSlotTime
;
2253 dst
->broadcom_cap_exist
= src
->broadcom_cap_exist
;
2254 dst
->ralink_cap_exist
= src
->ralink_cap_exist
;
2255 dst
->atheros_cap_exist
= src
->atheros_cap_exist
;
2256 dst
->realtek_cap_exit
= src
->realtek_cap_exit
;
2257 dst
->marvell_cap_exist
= src
->marvell_cap_exist
;
2258 dst
->cisco_cap_exist
= src
->cisco_cap_exist
;
2259 dst
->unknown_cap_exist
= src
->unknown_cap_exist
;
2260 memcpy(dst
->wpa_ie
, src
->wpa_ie
, src
->wpa_ie_len
);
2261 dst
->wpa_ie_len
= src
->wpa_ie_len
;
2262 memcpy(dst
->rsn_ie
, src
->rsn_ie
, src
->rsn_ie_len
);
2263 dst
->rsn_ie_len
= src
->rsn_ie_len
;
2265 dst
->last_scanned
= jiffies
;
2266 /* qos related parameters */
2267 //qos_active = src->qos_data.active;
2268 qos_active
= dst
->qos_data
.active
;
2269 //old_param = dst->qos_data.old_param_count;
2270 old_param
= dst
->qos_data
.param_count
;
2271 if(dst
->flags
& NETWORK_HAS_QOS_MASK
){
2272 //not update QOS paramter in beacon, as most AP will set all these parameter to 0.//WB
2273 // printk("====>%s(), aifs:%x, %x\n", __FUNCTION__, dst->qos_data.parameters.aifs[0], src->qos_data.parameters.aifs[0]);
2274 // memcpy(&dst->qos_data, &src->qos_data,
2275 // sizeof(struct ieee80211_qos_data));
2278 dst
->qos_data
.supported
= src
->qos_data
.supported
;
2279 dst
->qos_data
.param_count
= src
->qos_data
.param_count
;
2282 if(dst
->qos_data
.supported
== 1) {
2283 dst
->QoS_Enable
= 1;
2286 ("QoS the network %s is QoS supported\n",
2290 ("QoS the network is QoS supported\n");
2292 dst
->qos_data
.active
= qos_active
;
2293 dst
->qos_data
.old_param_count
= old_param
;
2295 /* dst->last_associate is not overwritten */
2297 dst
->wmm_info
= src
->wmm_info
; //sure to exist in beacon or probe response frame.
2298 if(src
->wmm_param
[0].ac_aci_acm_aifsn
|| \
2299 src
->wmm_param
[1].ac_aci_acm_aifsn
|| \
2300 src
->wmm_param
[2].ac_aci_acm_aifsn
|| \
2301 src
->wmm_param
[1].ac_aci_acm_aifsn
) {
2302 memcpy(dst
->wmm_param
, src
->wmm_param
, WME_AC_PRAM_LEN
);
2304 //dst->QoS_Enable = src->QoS_Enable;
2306 dst
->QoS_Enable
= 1;//for Rtl8187 simulation
2308 dst
->Turbo_Enable
= src
->Turbo_Enable
;
2310 dst
->CountryIeLen
= src
->CountryIeLen
;
2311 memcpy(dst
->CountryIeBuf
, src
->CountryIeBuf
, src
->CountryIeLen
);
2313 //added by amy for LEAP
2314 dst
->bWithAironetIE
= src
->bWithAironetIE
;
2315 dst
->bCkipSupported
= src
->bCkipSupported
;
2316 memcpy(dst
->CcxRmState
,src
->CcxRmState
,2);
2317 dst
->bCcxRmEnable
= src
->bCcxRmEnable
;
2318 dst
->MBssidMask
= src
->MBssidMask
;
2319 dst
->bMBssidValid
= src
->bMBssidValid
;
2320 memcpy(dst
->MBssid
,src
->MBssid
,6);
2321 dst
->bWithCcxVerNum
= src
->bWithCcxVerNum
;
2322 dst
->BssCcxVerNumber
= src
->BssCcxVerNumber
;
2326 static inline int is_beacon(__le16 fc
)
2328 return (WLAN_FC_GET_STYPE(le16_to_cpu(fc
)) == IEEE80211_STYPE_BEACON
);
2331 static inline void ieee80211_process_probe_response(
2332 struct ieee80211_device
*ieee
,
2333 struct ieee80211_probe_response
*beacon
,
2334 struct ieee80211_rx_stats
*stats
)
2336 struct ieee80211_network network
;
2337 struct ieee80211_network
*target
;
2338 struct ieee80211_network
*oldest
= NULL
;
2339 #ifdef CONFIG_IEEE80211_DEBUG
2340 struct ieee80211_info_element
*info_element
= &beacon
->info_element
[0];
2342 unsigned long flags
;
2346 memset(&network
, 0, sizeof(struct ieee80211_network
));
2347 IEEE80211_DEBUG_SCAN(
2348 "'%s' (" MAC_FMT
"): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
2349 escape_essid(info_element
->data
, info_element
->len
),
2350 MAC_ARG(beacon
->header
.addr3
),
2351 (beacon
->capability
& (1<<0xf)) ? '1' : '0',
2352 (beacon
->capability
& (1<<0xe)) ? '1' : '0',
2353 (beacon
->capability
& (1<<0xd)) ? '1' : '0',
2354 (beacon
->capability
& (1<<0xc)) ? '1' : '0',
2355 (beacon
->capability
& (1<<0xb)) ? '1' : '0',
2356 (beacon
->capability
& (1<<0xa)) ? '1' : '0',
2357 (beacon
->capability
& (1<<0x9)) ? '1' : '0',
2358 (beacon
->capability
& (1<<0x8)) ? '1' : '0',
2359 (beacon
->capability
& (1<<0x7)) ? '1' : '0',
2360 (beacon
->capability
& (1<<0x6)) ? '1' : '0',
2361 (beacon
->capability
& (1<<0x5)) ? '1' : '0',
2362 (beacon
->capability
& (1<<0x4)) ? '1' : '0',
2363 (beacon
->capability
& (1<<0x3)) ? '1' : '0',
2364 (beacon
->capability
& (1<<0x2)) ? '1' : '0',
2365 (beacon
->capability
& (1<<0x1)) ? '1' : '0',
2366 (beacon
->capability
& (1<<0x0)) ? '1' : '0');
2368 if (ieee80211_network_init(ieee
, beacon
, &network
, stats
)) {
2369 IEEE80211_DEBUG_SCAN("Dropped '%s' (" MAC_FMT
") via %s.\n",
2370 escape_essid(info_element
->data
,
2372 MAC_ARG(beacon
->header
.addr3
),
2373 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2374 IEEE80211_STYPE_PROBE_RESP
?
2375 "PROBE RESPONSE" : "BEACON");
2379 // For Asus EeePc request,
2380 // (1) if wireless adapter receive get any 802.11d country code in AP beacon,
2381 // wireless adapter should follow the country code.
2382 // (2) If there is no any country code in beacon,
2383 // then wireless adapter should do active scan from ch1~11 and
2384 // passive scan from ch12~14
2386 if( !IsLegalChannel(ieee
, network
.channel
) )
2388 if(ieee
->bGlobalDomain
)
2390 if (WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) == IEEE80211_STYPE_PROBE_RESP
)
2392 // Case 1: Country code
2393 if(IS_COUNTRY_IE_VALID(ieee
) )
2395 if( !IsLegalChannel(ieee
, network
.channel
) )
2397 printk("GetScanInfo(): For Country code, filter probe response at channel(%d).\n", network
.channel
);
2401 // Case 2: No any country code.
2404 // Filter over channel ch12~14
2405 if(network
.channel
> 11)
2407 printk("GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n", network
.channel
);
2414 // Case 1: Country code
2415 if(IS_COUNTRY_IE_VALID(ieee
) )
2417 if( !IsLegalChannel(ieee
, network
.channel
) )
2419 printk("GetScanInfo(): For Country code, filter beacon at channel(%d).\n",network
.channel
);
2423 // Case 2: No any country code.
2426 // Filter over channel ch12~14
2427 if(network
.channel
> 14)
2429 printk("GetScanInfo(): For Global Domain, filter beacon at channel(%d).\n",network
.channel
);
2436 /* The network parsed correctly -- so now we scan our known networks
2437 * to see if we can find it in our list.
2439 * NOTE: This search is definitely not optimized. Once its doing
2440 * the "right thing" we'll optimize it for efficiency if
2443 /* Search for this entry in the list and update it if it is
2446 spin_lock_irqsave(&ieee
->lock
, flags
);
2448 if(is_same_network(&ieee
->current_network
, &network
, ieee
)) {
2449 update_network(&ieee
->current_network
, &network
);
2450 if((ieee
->current_network
.mode
== IEEE_N_24G
|| ieee
->current_network
.mode
== IEEE_G
)
2451 && ieee
->current_network
.berp_info_valid
){
2452 if(ieee
->current_network
.erp_value
& ERP_UseProtection
)
2453 ieee
->current_network
.buseprotection
= true;
2455 ieee
->current_network
.buseprotection
= false;
2457 if(is_beacon(beacon
->header
.frame_ctl
))
2459 if(ieee
->state
== IEEE80211_LINKED
)
2460 ieee
->LinkDetectInfo
.NumRecvBcnInPeriod
++;
2463 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& ieee
->current_network
.flags
);
2466 list_for_each_entry(target
, &ieee
->network_list
, list
) {
2467 if (is_same_network(target
, &network
, ieee
))
2469 if ((oldest
== NULL
) ||
2470 (target
->last_scanned
< oldest
->last_scanned
))
2474 /* If we didn't find a match, then get a new network slot to initialize
2475 * with this beacon's information */
2476 if (&target
->list
== &ieee
->network_list
) {
2477 if (list_empty(&ieee
->network_free_list
)) {
2478 /* If there are no more slots, expire the oldest */
2479 list_del(&oldest
->list
);
2481 IEEE80211_DEBUG_SCAN("Expired '%s' (" MAC_FMT
") from "
2483 escape_essid(target
->ssid
,
2485 MAC_ARG(target
->bssid
));
2487 /* Otherwise just pull from the free list */
2488 target
= list_entry(ieee
->network_free_list
.next
,
2489 struct ieee80211_network
, list
);
2490 list_del(ieee
->network_free_list
.next
);
2494 #ifdef CONFIG_IEEE80211_DEBUG
2495 IEEE80211_DEBUG_SCAN("Adding '%s' (" MAC_FMT
") via %s.\n",
2496 escape_essid(network
.ssid
,
2498 MAC_ARG(network
.bssid
),
2499 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2500 IEEE80211_STYPE_PROBE_RESP
?
2501 "PROBE RESPONSE" : "BEACON");
2503 memcpy(target
, &network
, sizeof(*target
));
2504 list_add_tail(&target
->list
, &ieee
->network_list
);
2505 if(ieee
->softmac_features
& IEEE_SOFTMAC_ASSOCIATE
)
2506 ieee80211_softmac_new_net(ieee
,&network
);
2508 IEEE80211_DEBUG_SCAN("Updating '%s' (" MAC_FMT
") via %s.\n",
2509 escape_essid(target
->ssid
,
2511 MAC_ARG(target
->bssid
),
2512 WLAN_FC_GET_STYPE(beacon
->header
.frame_ctl
) ==
2513 IEEE80211_STYPE_PROBE_RESP
?
2514 "PROBE RESPONSE" : "BEACON");
2516 /* we have an entry and we are going to update it. But this entry may
2517 * be already expired. In this case we do the same as we found a new
2518 * net and call the new_net handler
2520 renew
= !time_after(target
->last_scanned
+ ieee
->scan_age
, jiffies
);
2521 //YJ,add,080819,for hidden ap
2522 if(is_beacon(beacon
->header
.frame_ctl
) == 0)
2523 network
.flags
= (~NETWORK_EMPTY_ESSID
& network
.flags
)|(NETWORK_EMPTY_ESSID
& target
->flags
);
2524 //if(strncmp(network.ssid, "linksys-c",9) == 0)
2525 // printk("====>2 network.ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network.ssid, network.flags, target->ssid, target->flags);
2526 if(((network
.flags
& NETWORK_EMPTY_ESSID
) == NETWORK_EMPTY_ESSID
) \
2527 && (((network
.ssid_len
> 0) && (strncmp(target
->ssid
, network
.ssid
, network
.ssid_len
)))\
2528 ||((ieee
->current_network
.ssid_len
== network
.ssid_len
)&&(strncmp(ieee
->current_network
.ssid
, network
.ssid
, network
.ssid_len
) == 0)&&(ieee
->state
== IEEE80211_NOLINK
))))
2530 //YJ,add,080819,for hidden ap,end
2532 update_network(target
, &network
);
2533 if(renew
&& (ieee
->softmac_features
& IEEE_SOFTMAC_ASSOCIATE
))
2534 ieee80211_softmac_new_net(ieee
,&network
);
2537 spin_unlock_irqrestore(&ieee
->lock
, flags
);
2538 if (is_beacon(beacon
->header
.frame_ctl
)&&is_same_network(&ieee
->current_network
, &network
, ieee
)&&\
2539 (ieee
->state
== IEEE80211_LINKED
)) {
2540 if(ieee
->handle_beacon
!= NULL
) {
2541 ieee
->handle_beacon(ieee
->dev
,beacon
,&ieee
->current_network
);
2546 void ieee80211_rx_mgt(struct ieee80211_device
*ieee
,
2547 struct ieee80211_hdr_4addr
*header
,
2548 struct ieee80211_rx_stats
*stats
)
2550 if(ieee
->sta_sleep
|| (ieee
->ps
!= IEEE80211_PS_DISABLED
&&
2551 ieee
->iw_mode
== IW_MODE_INFRA
&&
2552 ieee
->state
== IEEE80211_LINKED
))
2554 tasklet_schedule(&ieee
->ps_task
);
2557 if(WLAN_FC_GET_STYPE(header
->frame_ctl
) != IEEE80211_STYPE_PROBE_RESP
&&
2558 WLAN_FC_GET_STYPE(header
->frame_ctl
) != IEEE80211_STYPE_BEACON
)
2559 ieee
->last_rx_ps_time
= jiffies
;
2561 switch (WLAN_FC_GET_STYPE(header
->frame_ctl
)) {
2563 case IEEE80211_STYPE_BEACON
:
2564 IEEE80211_DEBUG_MGMT("received BEACON (%d)\n",
2565 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2566 IEEE80211_DEBUG_SCAN("Beacon\n");
2567 ieee80211_process_probe_response(
2568 ieee
, (struct ieee80211_probe_response
*)header
, stats
);
2571 case IEEE80211_STYPE_PROBE_RESP
:
2572 IEEE80211_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
2573 WLAN_FC_GET_STYPE(header
->frame_ctl
));
2574 IEEE80211_DEBUG_SCAN("Probe response\n");
2575 ieee80211_process_probe_response(
2576 ieee
, (struct ieee80211_probe_response
*)header
, stats
);