blob: 9cd59ecbcd674ddefd4cf6c3da13d3651bd6cfa6 [file] [log] [blame]
Johannes Berg571ecf62007-07-27 15:43:22 +02001/*
2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005-2006, Devicescape Software, Inc.
4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
5 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/kernel.h>
13#include <linux/skbuff.h>
14#include <linux/netdevice.h>
15#include <linux/etherdevice.h>
Johannes Bergd4e46a32007-09-14 11:10:24 -040016#include <linux/rcupdate.h>
Johannes Berg571ecf62007-07-27 15:43:22 +020017#include <net/mac80211.h>
18#include <net/ieee80211_radiotap.h>
19
20#include "ieee80211_i.h"
21#include "ieee80211_led.h"
Johannes Berg571ecf62007-07-27 15:43:22 +020022#include "wep.h"
23#include "wpa.h"
24#include "tkip.h"
25#include "wme.h"
26
Johannes Bergb2e77712007-09-26 15:19:39 +020027/*
28 * monitor mode reception
29 *
30 * This function cleans up the SKB, i.e. it removes all the stuff
31 * only useful for monitoring.
32 */
33static struct sk_buff *remove_monitor_info(struct ieee80211_local *local,
34 struct sk_buff *skb,
35 int rtap_len)
36{
37 skb_pull(skb, rtap_len);
38
39 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) {
40 if (likely(skb->len > FCS_LEN))
41 skb_trim(skb, skb->len - FCS_LEN);
42 else {
43 /* driver bug */
44 WARN_ON(1);
45 dev_kfree_skb(skb);
46 skb = NULL;
47 }
48 }
49
50 return skb;
51}
52
53static inline int should_drop_frame(struct ieee80211_rx_status *status,
54 struct sk_buff *skb,
55 int present_fcs_len,
56 int radiotap_len)
57{
58 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
59
60 if (status->flag & (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
61 return 1;
62 if (unlikely(skb->len < 16 + present_fcs_len + radiotap_len))
63 return 1;
64 if ((hdr->frame_control & cpu_to_le16(IEEE80211_FCTL_FTYPE)) ==
65 cpu_to_le16(IEEE80211_FTYPE_CTL))
66 return 1;
67 return 0;
68}
69
70/*
71 * This function copies a received frame to all monitor interfaces and
72 * returns a cleaned-up SKB that no longer includes the FCS nor the
73 * radiotap header the driver might have added.
74 */
75static struct sk_buff *
76ieee80211_rx_monitor(struct ieee80211_local *local, struct sk_buff *origskb,
77 struct ieee80211_rx_status *status)
78{
79 struct ieee80211_sub_if_data *sdata;
80 struct ieee80211_rate *rate;
81 int needed_headroom = 0;
Johannes Bergc49e5ea2007-12-11 21:33:42 +010082 struct ieee80211_radiotap_header *rthdr;
83 __le64 *rttsft = NULL;
84 struct ieee80211_rtap_fixed_data {
Johannes Bergb2e77712007-09-26 15:19:39 +020085 u8 flags;
86 u8 rate;
87 __le16 chan_freq;
88 __le16 chan_flags;
89 u8 antsignal;
90 u8 padding_for_rxflags;
91 __le16 rx_flags;
Johannes Bergc49e5ea2007-12-11 21:33:42 +010092 } __attribute__ ((packed)) *rtfixed;
Johannes Bergb2e77712007-09-26 15:19:39 +020093 struct sk_buff *skb, *skb2;
94 struct net_device *prev_dev = NULL;
95 int present_fcs_len = 0;
96 int rtap_len = 0;
97
98 /*
99 * First, we may need to make a copy of the skb because
100 * (1) we need to modify it for radiotap (if not present), and
101 * (2) the other RX handlers will modify the skb we got.
102 *
103 * We don't need to, of course, if we aren't going to return
104 * the SKB because it has a bad FCS/PLCP checksum.
105 */
106 if (status->flag & RX_FLAG_RADIOTAP)
107 rtap_len = ieee80211_get_radiotap_len(origskb->data);
108 else
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100109 /* room for radiotap header, always present fields and TSFT */
110 needed_headroom = sizeof(*rthdr) + sizeof(*rtfixed) + 8;
Johannes Bergb2e77712007-09-26 15:19:39 +0200111
112 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
113 present_fcs_len = FCS_LEN;
114
115 if (!local->monitors) {
116 if (should_drop_frame(status, origskb, present_fcs_len,
117 rtap_len)) {
118 dev_kfree_skb(origskb);
119 return NULL;
120 }
121
122 return remove_monitor_info(local, origskb, rtap_len);
123 }
124
125 if (should_drop_frame(status, origskb, present_fcs_len, rtap_len)) {
126 /* only need to expand headroom if necessary */
127 skb = origskb;
128 origskb = NULL;
129
130 /*
131 * This shouldn't trigger often because most devices have an
132 * RX header they pull before we get here, and that should
133 * be big enough for our radiotap information. We should
134 * probably export the length to drivers so that we can have
135 * them allocate enough headroom to start with.
136 */
137 if (skb_headroom(skb) < needed_headroom &&
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100138 pskb_expand_head(skb, needed_headroom, 0, GFP_ATOMIC)) {
Johannes Bergb2e77712007-09-26 15:19:39 +0200139 dev_kfree_skb(skb);
140 return NULL;
141 }
142 } else {
143 /*
144 * Need to make a copy and possibly remove radiotap header
145 * and FCS from the original.
146 */
147 skb = skb_copy_expand(origskb, needed_headroom, 0, GFP_ATOMIC);
148
149 origskb = remove_monitor_info(local, origskb, rtap_len);
150
151 if (!skb)
152 return origskb;
153 }
154
155 /* if necessary, prepend radiotap information */
156 if (!(status->flag & RX_FLAG_RADIOTAP)) {
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100157 rtfixed = (void *) skb_push(skb, sizeof(*rtfixed));
158 rtap_len = sizeof(*rthdr) + sizeof(*rtfixed);
159 if (status->flag & RX_FLAG_TSFT) {
160 rttsft = (void *) skb_push(skb, sizeof(*rttsft));
161 rtap_len += 8;
162 }
Johannes Bergb2e77712007-09-26 15:19:39 +0200163 rthdr = (void *) skb_push(skb, sizeof(*rthdr));
164 memset(rthdr, 0, sizeof(*rthdr));
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100165 memset(rtfixed, 0, sizeof(*rtfixed));
166 rthdr->it_present =
Johannes Bergb2e77712007-09-26 15:19:39 +0200167 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
168 (1 << IEEE80211_RADIOTAP_RATE) |
169 (1 << IEEE80211_RADIOTAP_CHANNEL) |
170 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) |
171 (1 << IEEE80211_RADIOTAP_RX_FLAGS));
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100172 rtfixed->flags = 0;
173 if (local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS)
174 rtfixed->flags |= IEEE80211_RADIOTAP_F_FCS;
175
176 if (rttsft) {
177 *rttsft = cpu_to_le64(status->mactime);
178 rthdr->it_present |=
179 cpu_to_le32(1 << IEEE80211_RADIOTAP_TSFT);
180 }
Johannes Bergb2e77712007-09-26 15:19:39 +0200181
182 /* FIXME: when radiotap gets a 'bad PLCP' flag use it here */
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100183 rtfixed->rx_flags = 0;
Johannes Bergb2e77712007-09-26 15:19:39 +0200184 if (status->flag &
185 (RX_FLAG_FAILED_FCS_CRC | RX_FLAG_FAILED_PLCP_CRC))
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100186 rtfixed->rx_flags |=
Johannes Bergb2e77712007-09-26 15:19:39 +0200187 cpu_to_le16(IEEE80211_RADIOTAP_F_RX_BADFCS);
188
189 rate = ieee80211_get_rate(local, status->phymode,
190 status->rate);
191 if (rate)
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100192 rtfixed->rate = rate->rate / 5;
Johannes Bergb2e77712007-09-26 15:19:39 +0200193
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100194 rtfixed->chan_freq = cpu_to_le16(status->freq);
Johannes Bergb2e77712007-09-26 15:19:39 +0200195
196 if (status->phymode == MODE_IEEE80211A)
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100197 rtfixed->chan_flags =
Johannes Bergb2e77712007-09-26 15:19:39 +0200198 cpu_to_le16(IEEE80211_CHAN_OFDM |
199 IEEE80211_CHAN_5GHZ);
200 else
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100201 rtfixed->chan_flags =
Johannes Bergb2e77712007-09-26 15:19:39 +0200202 cpu_to_le16(IEEE80211_CHAN_DYN |
203 IEEE80211_CHAN_2GHZ);
204
Johannes Bergc49e5ea2007-12-11 21:33:42 +0100205 rtfixed->antsignal = status->ssi;
206 rthdr->it_len = cpu_to_le16(rtap_len);
Johannes Bergb2e77712007-09-26 15:19:39 +0200207 }
208
209 skb_set_mac_header(skb, 0);
210 skb->ip_summed = CHECKSUM_UNNECESSARY;
211 skb->pkt_type = PACKET_OTHERHOST;
212 skb->protocol = htons(ETH_P_802_2);
213
214 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
215 if (!netif_running(sdata->dev))
216 continue;
217
218 if (sdata->type != IEEE80211_IF_TYPE_MNTR)
219 continue;
220
221 if (prev_dev) {
222 skb2 = skb_clone(skb, GFP_ATOMIC);
223 if (skb2) {
224 skb2->dev = prev_dev;
225 netif_rx(skb2);
226 }
227 }
228
229 prev_dev = sdata->dev;
230 sdata->dev->stats.rx_packets++;
231 sdata->dev->stats.rx_bytes += skb->len;
232 }
233
234 if (prev_dev) {
235 skb->dev = prev_dev;
236 netif_rx(skb);
237 } else
238 dev_kfree_skb(skb);
239
240 return origskb;
241}
242
243
Johannes Berg571ecf62007-07-27 15:43:22 +0200244/* pre-rx handlers
245 *
246 * these don't have dev/sdata fields in the rx data
Johannes Berg52865df2007-07-27 15:43:22 +0200247 * The sta value should also not be used because it may
248 * be NULL even though a STA (in IBSS mode) will be added.
Johannes Berg571ecf62007-07-27 15:43:22 +0200249 */
250
251static ieee80211_txrx_result
Johannes Berg6e0d1142007-07-27 15:43:22 +0200252ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx)
253{
254 u8 *data = rx->skb->data;
255 int tid;
256
257 /* does the frame have a qos control field? */
258 if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
259 u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
260 /* frame has qos control */
261 tid = qc[0] & QOS_CONTROL_TID_MASK;
Ron Rindjunskyfd4c7f22007-11-26 16:14:33 +0200262 if (qc[0] & IEEE80211_QOS_CONTROL_A_MSDU_PRESENT)
Ron Rindjunsky64bd4b62007-11-29 10:35:53 +0200263 rx->flags |= IEEE80211_TXRXD_RX_AMSDU;
Ron Rindjunskyfd4c7f22007-11-26 16:14:33 +0200264 else
Ron Rindjunsky64bd4b62007-11-29 10:35:53 +0200265 rx->flags &= ~IEEE80211_TXRXD_RX_AMSDU;
Johannes Berg6e0d1142007-07-27 15:43:22 +0200266 } else {
267 if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
268 /* Separate TID for management frames */
269 tid = NUM_RX_DATA_QUEUES - 1;
270 } else {
271 /* no qos control present */
272 tid = 0; /* 802.1d - Best Effort */
273 }
274 }
Johannes Berg52865df2007-07-27 15:43:22 +0200275
Johannes Berg6e0d1142007-07-27 15:43:22 +0200276 I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
Johannes Berg52865df2007-07-27 15:43:22 +0200277 /* only a debug counter, sta might not be assigned properly yet */
278 if (rx->sta)
Johannes Berg6e0d1142007-07-27 15:43:22 +0200279 I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
Johannes Berg6e0d1142007-07-27 15:43:22 +0200280
281 rx->u.rx.queue = tid;
282 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
283 * For now, set skb->priority to 0 for other cases. */
284 rx->skb->priority = (tid > 7) ? 0 : tid;
285
286 return TXRX_CONTINUE;
287}
288
289static ieee80211_txrx_result
Johannes Berg571ecf62007-07-27 15:43:22 +0200290ieee80211_rx_h_load_stats(struct ieee80211_txrx_data *rx)
291{
292 struct ieee80211_local *local = rx->local;
293 struct sk_buff *skb = rx->skb;
294 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
295 u32 load = 0, hdrtime;
296 struct ieee80211_rate *rate;
297 struct ieee80211_hw_mode *mode = local->hw.conf.mode;
298 int i;
299
300 /* Estimate total channel use caused by this frame */
301
302 if (unlikely(mode->num_rates < 0))
303 return TXRX_CONTINUE;
304
305 rate = &mode->rates[0];
306 for (i = 0; i < mode->num_rates; i++) {
307 if (mode->rates[i].val == rx->u.rx.status->rate) {
308 rate = &mode->rates[i];
309 break;
310 }
311 }
312
313 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
314 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
315
316 if (mode->mode == MODE_IEEE80211A ||
Johannes Berg571ecf62007-07-27 15:43:22 +0200317 (mode->mode == MODE_IEEE80211G &&
318 rate->flags & IEEE80211_RATE_ERP))
319 hdrtime = CHAN_UTIL_HDR_SHORT;
320 else
321 hdrtime = CHAN_UTIL_HDR_LONG;
322
323 load = hdrtime;
324 if (!is_multicast_ether_addr(hdr->addr1))
325 load += hdrtime;
326
327 load += skb->len * rate->rate_inv;
328
329 /* Divide channel_use by 8 to avoid wrapping around the counter */
330 load >>= CHAN_UTIL_SHIFT;
331 local->channel_use_raw += load;
Johannes Berg571ecf62007-07-27 15:43:22 +0200332 rx->u.rx.load = load;
333
334 return TXRX_CONTINUE;
335}
336
337ieee80211_rx_handler ieee80211_rx_pre_handlers[] =
338{
339 ieee80211_rx_h_parse_qos,
340 ieee80211_rx_h_load_stats,
341 NULL
342};
343
344/* rx handlers */
345
346static ieee80211_txrx_result
347ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx)
348{
Johannes Berg52865df2007-07-27 15:43:22 +0200349 if (rx->sta)
350 rx->sta->channel_use_raw += rx->u.rx.load;
Johannes Berg571ecf62007-07-27 15:43:22 +0200351 rx->sdata->channel_use_raw += rx->u.rx.load;
352 return TXRX_CONTINUE;
353}
354
Johannes Berg571ecf62007-07-27 15:43:22 +0200355static ieee80211_txrx_result
356ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
357{
358 struct ieee80211_local *local = rx->local;
359 struct sk_buff *skb = rx->skb;
360
Zhu Yiece8edd2007-11-22 10:53:21 +0800361 if (unlikely(local->sta_hw_scanning))
362 return ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status);
363
364 if (unlikely(local->sta_sw_scanning)) {
365 /* drop all the other packets during a software scan anyway */
366 if (ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status)
367 != TXRX_QUEUED)
368 dev_kfree_skb(skb);
Johannes Berg571ecf62007-07-27 15:43:22 +0200369 return TXRX_QUEUED;
370 }
371
Jiri Slabybadffb72007-08-28 17:01:54 -0400372 if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200373 /* scanning finished during invoking of handlers */
374 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
375 return TXRX_DROP;
376 }
377
378 return TXRX_CONTINUE;
379}
380
381static ieee80211_txrx_result
382ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
383{
384 struct ieee80211_hdr *hdr;
Johannes Berg571ecf62007-07-27 15:43:22 +0200385 hdr = (struct ieee80211_hdr *) rx->skb->data;
386
387 /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
388 if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
389 if (unlikely(rx->fc & IEEE80211_FCTL_RETRY &&
390 rx->sta->last_seq_ctrl[rx->u.rx.queue] ==
391 hdr->seq_ctrl)) {
Jiri Slabybadffb72007-08-28 17:01:54 -0400392 if (rx->flags & IEEE80211_TXRXD_RXRA_MATCH) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200393 rx->local->dot11FrameDuplicateCount++;
394 rx->sta->num_duplicates++;
395 }
396 return TXRX_DROP;
397 } else
398 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl;
399 }
400
Johannes Berg571ecf62007-07-27 15:43:22 +0200401 if (unlikely(rx->skb->len < 16)) {
402 I802_DEBUG_INC(rx->local->rx_handlers_drop_short);
403 return TXRX_DROP;
404 }
405
Jiri Slabybadffb72007-08-28 17:01:54 -0400406 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +0200407 rx->skb->pkt_type = PACKET_OTHERHOST;
408 else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 0)
409 rx->skb->pkt_type = PACKET_HOST;
410 else if (is_multicast_ether_addr(hdr->addr1)) {
411 if (is_broadcast_ether_addr(hdr->addr1))
412 rx->skb->pkt_type = PACKET_BROADCAST;
413 else
414 rx->skb->pkt_type = PACKET_MULTICAST;
415 } else
416 rx->skb->pkt_type = PACKET_OTHERHOST;
417
418 /* Drop disallowed frame classes based on STA auth/assoc state;
419 * IEEE 802.11, Chap 5.5.
420 *
421 * 80211.o does filtering only based on association state, i.e., it
422 * drops Class 3 frames from not associated stations. hostapd sends
423 * deauth/disassoc frames when needed. In addition, hostapd is
424 * responsible for filtering on both auth and assoc states.
425 */
426 if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
427 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
428 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
429 rx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
430 (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
431 if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
432 !(rx->fc & IEEE80211_FCTL_TODS) &&
433 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
Jiri Slabybadffb72007-08-28 17:01:54 -0400434 || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200435 /* Drop IBSS frames and frames for other hosts
436 * silently. */
437 return TXRX_DROP;
438 }
439
Johannes Bergf9d540e2007-09-28 14:02:09 +0200440 return TXRX_DROP;
Johannes Berg571ecf62007-07-27 15:43:22 +0200441 }
442
Johannes Berg570bd532007-07-27 15:43:22 +0200443 return TXRX_CONTINUE;
444}
445
446
447static ieee80211_txrx_result
Johannes Berg1990af82007-09-26 17:53:15 +0200448ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)
Johannes Berg570bd532007-07-27 15:43:22 +0200449{
450 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
Johannes Berg3017b802007-08-28 17:01:53 -0400451 int keyidx;
452 int hdrlen;
Mattias Nisslere2f036d2007-10-07 16:35:31 +0200453 ieee80211_txrx_result result = TXRX_DROP;
Johannes Bergd4e46a32007-09-14 11:10:24 -0400454 struct ieee80211_key *stakey = NULL;
Johannes Berg570bd532007-07-27 15:43:22 +0200455
Johannes Berg3017b802007-08-28 17:01:53 -0400456 /*
457 * Key selection 101
458 *
459 * There are three types of keys:
460 * - GTK (group keys)
461 * - PTK (pairwise keys)
462 * - STK (station-to-station pairwise keys)
463 *
464 * When selecting a key, we have to distinguish between multicast
465 * (including broadcast) and unicast frames, the latter can only
466 * use PTKs and STKs while the former always use GTKs. Unless, of
467 * course, actual WEP keys ("pre-RSNA") are used, then unicast
468 * frames can also use key indizes like GTKs. Hence, if we don't
469 * have a PTK/STK we check the key index for a WEP key.
470 *
Johannes Berg8dc06a12007-08-28 17:01:55 -0400471 * Note that in a regular BSS, multicast frames are sent by the
472 * AP only, associated stations unicast the frame to the AP first
473 * which then multicasts it on their behalf.
474 *
Johannes Berg3017b802007-08-28 17:01:53 -0400475 * There is also a slight problem in IBSS mode: GTKs are negotiated
476 * with each station, that is something we don't currently handle.
Johannes Berg8dc06a12007-08-28 17:01:55 -0400477 * The spec seems to expect that one negotiates the same key with
478 * every station but there's no such requirement; VLANs could be
479 * possible.
Johannes Berg3017b802007-08-28 17:01:53 -0400480 */
Johannes Berg571ecf62007-07-27 15:43:22 +0200481
Johannes Berg3017b802007-08-28 17:01:53 -0400482 if (!(rx->fc & IEEE80211_FCTL_PROTECTED))
483 return TXRX_CONTINUE;
484
485 /*
Johannes Berg1990af82007-09-26 17:53:15 +0200486 * No point in finding a key and decrypting if the frame is neither
Johannes Berg3017b802007-08-28 17:01:53 -0400487 * addressed to us nor a multicast frame.
488 */
Jiri Slabybadffb72007-08-28 17:01:54 -0400489 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg3017b802007-08-28 17:01:53 -0400490 return TXRX_CONTINUE;
491
Johannes Bergd4e46a32007-09-14 11:10:24 -0400492 if (rx->sta)
493 stakey = rcu_dereference(rx->sta->key);
494
495 if (!is_multicast_ether_addr(hdr->addr1) && stakey) {
496 rx->key = stakey;
Johannes Berg571ecf62007-07-27 15:43:22 +0200497 } else {
Johannes Berg3017b802007-08-28 17:01:53 -0400498 /*
499 * The device doesn't give us the IV so we won't be
500 * able to look up the key. That's ok though, we
501 * don't need to decrypt the frame, we just won't
502 * be able to keep statistics accurate.
503 * Except for key threshold notifications, should
504 * we somehow allow the driver to tell us which key
505 * the hardware used if this flag is set?
506 */
Johannes Berg7848ba72007-09-14 11:10:25 -0400507 if ((rx->u.rx.status->flag & RX_FLAG_DECRYPTED) &&
508 (rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED))
Johannes Berg3017b802007-08-28 17:01:53 -0400509 return TXRX_CONTINUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200510
Johannes Berg3017b802007-08-28 17:01:53 -0400511 hdrlen = ieee80211_get_hdrlen(rx->fc);
Johannes Berg571ecf62007-07-27 15:43:22 +0200512
Johannes Berg3017b802007-08-28 17:01:53 -0400513 if (rx->skb->len < 8 + hdrlen)
514 return TXRX_DROP; /* TODO: count this? */
Johannes Berg571ecf62007-07-27 15:43:22 +0200515
Johannes Berg3017b802007-08-28 17:01:53 -0400516 /*
517 * no need to call ieee80211_wep_get_keyidx,
518 * it verifies a bunch of things we've done already
519 */
520 keyidx = rx->skb->data[hdrlen + 3] >> 6;
521
Johannes Bergd4e46a32007-09-14 11:10:24 -0400522 rx->key = rcu_dereference(rx->sdata->keys[keyidx]);
Johannes Berg3017b802007-08-28 17:01:53 -0400523
524 /*
525 * RSNA-protected unicast frames should always be sent with
526 * pairwise or station-to-station keys, but for WEP we allow
527 * using a key index as well.
528 */
Johannes Berg8f20fc22007-08-28 17:01:54 -0400529 if (rx->key && rx->key->conf.alg != ALG_WEP &&
Johannes Berg3017b802007-08-28 17:01:53 -0400530 !is_multicast_ether_addr(hdr->addr1))
531 rx->key = NULL;
Johannes Berg571ecf62007-07-27 15:43:22 +0200532 }
533
Johannes Berg3017b802007-08-28 17:01:53 -0400534 if (rx->key) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200535 rx->key->tx_rx_count++;
Johannes Berg011bfcc2007-09-17 01:29:25 -0400536 /* TODO: add threshold stuff again */
Johannes Berg1990af82007-09-26 17:53:15 +0200537 } else {
John W. Linville7f3ad892007-11-06 17:12:31 -0500538#ifdef CONFIG_MAC80211_DEBUG
Johannes Berg70f08762007-09-26 17:53:14 +0200539 if (net_ratelimit())
540 printk(KERN_DEBUG "%s: RX protected frame,"
541 " but have no key\n", rx->dev->name);
John W. Linville7f3ad892007-11-06 17:12:31 -0500542#endif /* CONFIG_MAC80211_DEBUG */
Johannes Berg70f08762007-09-26 17:53:14 +0200543 return TXRX_DROP;
544 }
545
Johannes Berg1990af82007-09-26 17:53:15 +0200546 /* Check for weak IVs if possible */
547 if (rx->sta && rx->key->conf.alg == ALG_WEP &&
548 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
549 (!(rx->u.rx.status->flag & RX_FLAG_IV_STRIPPED) ||
550 !(rx->u.rx.status->flag & RX_FLAG_DECRYPTED)) &&
551 ieee80211_wep_is_weak_iv(rx->skb, rx->key))
552 rx->sta->wep_weak_iv_count++;
553
Johannes Berg70f08762007-09-26 17:53:14 +0200554 switch (rx->key->conf.alg) {
555 case ALG_WEP:
Mattias Nisslere2f036d2007-10-07 16:35:31 +0200556 result = ieee80211_crypto_wep_decrypt(rx);
557 break;
Johannes Berg70f08762007-09-26 17:53:14 +0200558 case ALG_TKIP:
Mattias Nisslere2f036d2007-10-07 16:35:31 +0200559 result = ieee80211_crypto_tkip_decrypt(rx);
560 break;
Johannes Berg70f08762007-09-26 17:53:14 +0200561 case ALG_CCMP:
Mattias Nisslere2f036d2007-10-07 16:35:31 +0200562 result = ieee80211_crypto_ccmp_decrypt(rx);
563 break;
Johannes Berg70f08762007-09-26 17:53:14 +0200564 }
565
Mattias Nisslere2f036d2007-10-07 16:35:31 +0200566 /* either the frame has been decrypted or will be dropped */
567 rx->u.rx.status->flag |= RX_FLAG_DECRYPTED;
568
569 return result;
Johannes Berg70f08762007-09-26 17:53:14 +0200570}
571
Johannes Berg571ecf62007-07-27 15:43:22 +0200572static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)
573{
574 struct ieee80211_sub_if_data *sdata;
Joe Perches0795af52007-10-03 17:59:30 -0700575 DECLARE_MAC_BUF(mac);
576
Johannes Berg571ecf62007-07-27 15:43:22 +0200577 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
578
579 if (sdata->bss)
580 atomic_inc(&sdata->bss->num_sta_ps);
581 sta->flags |= WLAN_STA_PS;
582 sta->pspoll = 0;
583#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
Joe Perches0795af52007-10-03 17:59:30 -0700584 printk(KERN_DEBUG "%s: STA %s aid %d enters power save mode\n",
585 dev->name, print_mac(mac, sta->addr), sta->aid);
Johannes Berg571ecf62007-07-27 15:43:22 +0200586#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
587}
588
589static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
590{
591 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
592 struct sk_buff *skb;
593 int sent = 0;
594 struct ieee80211_sub_if_data *sdata;
595 struct ieee80211_tx_packet_data *pkt_data;
Joe Perches0795af52007-10-03 17:59:30 -0700596 DECLARE_MAC_BUF(mac);
Johannes Berg571ecf62007-07-27 15:43:22 +0200597
598 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
599 if (sdata->bss)
600 atomic_dec(&sdata->bss->num_sta_ps);
601 sta->flags &= ~(WLAN_STA_PS | WLAN_STA_TIM);
602 sta->pspoll = 0;
603 if (!skb_queue_empty(&sta->ps_tx_buf)) {
604 if (local->ops->set_tim)
605 local->ops->set_tim(local_to_hw(local), sta->aid, 0);
606 if (sdata->bss)
607 bss_tim_clear(local, sdata->bss, sta->aid);
608 }
609#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
Joe Perches0795af52007-10-03 17:59:30 -0700610 printk(KERN_DEBUG "%s: STA %s aid %d exits power save mode\n",
611 dev->name, print_mac(mac, sta->addr), sta->aid);
Johannes Berg571ecf62007-07-27 15:43:22 +0200612#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
613 /* Send all buffered frames to the station */
614 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
615 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
616 sent++;
Jiri Slabye8bf9642007-08-28 17:01:54 -0400617 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200618 dev_queue_xmit(skb);
619 }
620 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
621 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
622 local->total_ps_buffered--;
623 sent++;
624#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
Joe Perches0795af52007-10-03 17:59:30 -0700625 printk(KERN_DEBUG "%s: STA %s aid %d send PS frame "
Johannes Berg571ecf62007-07-27 15:43:22 +0200626 "since STA not sleeping anymore\n", dev->name,
Joe Perches0795af52007-10-03 17:59:30 -0700627 print_mac(mac, sta->addr), sta->aid);
Johannes Berg571ecf62007-07-27 15:43:22 +0200628#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
Jiri Slabye8bf9642007-08-28 17:01:54 -0400629 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200630 dev_queue_xmit(skb);
631 }
632
633 return sent;
634}
635
636static ieee80211_txrx_result
637ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx)
638{
639 struct sta_info *sta = rx->sta;
640 struct net_device *dev = rx->dev;
641 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
642
643 if (!sta)
644 return TXRX_CONTINUE;
645
646 /* Update last_rx only for IBSS packets which are for the current
647 * BSSID to avoid keeping the current IBSS network alive in cases where
648 * other STAs are using different BSSID. */
649 if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
650 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
651 if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
652 sta->last_rx = jiffies;
653 } else
654 if (!is_multicast_ether_addr(hdr->addr1) ||
655 rx->sdata->type == IEEE80211_IF_TYPE_STA) {
656 /* Update last_rx only for unicast frames in order to prevent
657 * the Probe Request frames (the only broadcast frames from a
658 * STA in infrastructure mode) from keeping a connection alive.
659 */
660 sta->last_rx = jiffies;
661 }
662
Jiri Slabybadffb72007-08-28 17:01:54 -0400663 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +0200664 return TXRX_CONTINUE;
665
666 sta->rx_fragments++;
667 sta->rx_bytes += rx->skb->len;
Larry Finger6c55aa92007-08-28 17:01:55 -0400668 sta->last_rssi = rx->u.rx.status->ssi;
669 sta->last_signal = rx->u.rx.status->signal;
670 sta->last_noise = rx->u.rx.status->noise;
Johannes Berg571ecf62007-07-27 15:43:22 +0200671
672 if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
673 /* Change STA power saving mode only in the end of a frame
674 * exchange sequence */
675 if ((sta->flags & WLAN_STA_PS) && !(rx->fc & IEEE80211_FCTL_PM))
676 rx->u.rx.sent_ps_buffered += ap_sta_ps_end(dev, sta);
677 else if (!(sta->flags & WLAN_STA_PS) &&
678 (rx->fc & IEEE80211_FCTL_PM))
679 ap_sta_ps_start(dev, sta);
680 }
681
682 /* Drop data::nullfunc frames silently, since they are used only to
683 * control station power saving mode. */
684 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
685 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) {
686 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
687 /* Update counter and free packet here to avoid counting this
688 * as a dropped packed. */
689 sta->rx_packets++;
690 dev_kfree_skb(rx->skb);
691 return TXRX_QUEUED;
692 }
693
694 return TXRX_CONTINUE;
695} /* ieee80211_rx_h_sta_process */
696
Johannes Berg571ecf62007-07-27 15:43:22 +0200697static inline struct ieee80211_fragment_entry *
698ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
699 unsigned int frag, unsigned int seq, int rx_queue,
700 struct sk_buff **skb)
701{
702 struct ieee80211_fragment_entry *entry;
703 int idx;
704
705 idx = sdata->fragment_next;
706 entry = &sdata->fragments[sdata->fragment_next++];
707 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
708 sdata->fragment_next = 0;
709
710 if (!skb_queue_empty(&entry->skb_list)) {
711#ifdef CONFIG_MAC80211_DEBUG
712 struct ieee80211_hdr *hdr =
713 (struct ieee80211_hdr *) entry->skb_list.next->data;
Joe Perches0795af52007-10-03 17:59:30 -0700714 DECLARE_MAC_BUF(mac);
715 DECLARE_MAC_BUF(mac2);
Johannes Berg571ecf62007-07-27 15:43:22 +0200716 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
717 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
Joe Perches0795af52007-10-03 17:59:30 -0700718 "addr1=%s addr2=%s\n",
Johannes Berg571ecf62007-07-27 15:43:22 +0200719 sdata->dev->name, idx,
720 jiffies - entry->first_frag_time, entry->seq,
Joe Perches0795af52007-10-03 17:59:30 -0700721 entry->last_frag, print_mac(mac, hdr->addr1),
722 print_mac(mac2, hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +0200723#endif /* CONFIG_MAC80211_DEBUG */
724 __skb_queue_purge(&entry->skb_list);
725 }
726
727 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */
728 *skb = NULL;
729 entry->first_frag_time = jiffies;
730 entry->seq = seq;
731 entry->rx_queue = rx_queue;
732 entry->last_frag = frag;
733 entry->ccmp = 0;
734 entry->extra_len = 0;
735
736 return entry;
737}
738
739static inline struct ieee80211_fragment_entry *
740ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
741 u16 fc, unsigned int frag, unsigned int seq,
742 int rx_queue, struct ieee80211_hdr *hdr)
743{
744 struct ieee80211_fragment_entry *entry;
745 int i, idx;
746
747 idx = sdata->fragment_next;
748 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
749 struct ieee80211_hdr *f_hdr;
750 u16 f_fc;
751
752 idx--;
753 if (idx < 0)
754 idx = IEEE80211_FRAGMENT_MAX - 1;
755
756 entry = &sdata->fragments[idx];
757 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq ||
758 entry->rx_queue != rx_queue ||
759 entry->last_frag + 1 != frag)
760 continue;
761
762 f_hdr = (struct ieee80211_hdr *) entry->skb_list.next->data;
763 f_fc = le16_to_cpu(f_hdr->frame_control);
764
765 if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
766 compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
767 compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
768 continue;
769
770 if (entry->first_frag_time + 2 * HZ < jiffies) {
771 __skb_queue_purge(&entry->skb_list);
772 continue;
773 }
774 return entry;
775 }
776
777 return NULL;
778}
779
780static ieee80211_txrx_result
781ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
782{
783 struct ieee80211_hdr *hdr;
784 u16 sc;
785 unsigned int frag, seq;
786 struct ieee80211_fragment_entry *entry;
787 struct sk_buff *skb;
Joe Perches0795af52007-10-03 17:59:30 -0700788 DECLARE_MAC_BUF(mac);
Johannes Berg571ecf62007-07-27 15:43:22 +0200789
790 hdr = (struct ieee80211_hdr *) rx->skb->data;
791 sc = le16_to_cpu(hdr->seq_ctrl);
792 frag = sc & IEEE80211_SCTL_FRAG;
793
794 if (likely((!(rx->fc & IEEE80211_FCTL_MOREFRAGS) && frag == 0) ||
795 (rx->skb)->len < 24 ||
796 is_multicast_ether_addr(hdr->addr1))) {
797 /* not fragmented */
798 goto out;
799 }
800 I802_DEBUG_INC(rx->local->rx_handlers_fragments);
801
802 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
803
804 if (frag == 0) {
805 /* This is the first fragment of a new frame. */
806 entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
807 rx->u.rx.queue, &(rx->skb));
Johannes Berg8f20fc22007-08-28 17:01:54 -0400808 if (rx->key && rx->key->conf.alg == ALG_CCMP &&
Johannes Berg571ecf62007-07-27 15:43:22 +0200809 (rx->fc & IEEE80211_FCTL_PROTECTED)) {
810 /* Store CCMP PN so that we can verify that the next
811 * fragment has a sequential PN value. */
812 entry->ccmp = 1;
813 memcpy(entry->last_pn,
814 rx->key->u.ccmp.rx_pn[rx->u.rx.queue],
815 CCMP_PN_LEN);
816 }
817 return TXRX_QUEUED;
818 }
819
820 /* This is a fragment for a frame that should already be pending in
821 * fragment cache. Add this fragment to the end of the pending entry.
822 */
823 entry = ieee80211_reassemble_find(rx->sdata, rx->fc, frag, seq,
824 rx->u.rx.queue, hdr);
825 if (!entry) {
826 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
827 return TXRX_DROP;
828 }
829
830 /* Verify that MPDUs within one MSDU have sequential PN values.
831 * (IEEE 802.11i, 8.3.3.4.5) */
832 if (entry->ccmp) {
833 int i;
834 u8 pn[CCMP_PN_LEN], *rpn;
Johannes Berg8f20fc22007-08-28 17:01:54 -0400835 if (!rx->key || rx->key->conf.alg != ALG_CCMP)
Johannes Berg571ecf62007-07-27 15:43:22 +0200836 return TXRX_DROP;
837 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
838 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
839 pn[i]++;
840 if (pn[i])
841 break;
842 }
843 rpn = rx->key->u.ccmp.rx_pn[rx->u.rx.queue];
844 if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400845 if (net_ratelimit())
846 printk(KERN_DEBUG "%s: defrag: CCMP PN not "
Joe Perches0795af52007-10-03 17:59:30 -0700847 "sequential A2=%s"
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400848 " PN=%02x%02x%02x%02x%02x%02x "
849 "(expected %02x%02x%02x%02x%02x%02x)\n",
Joe Perches0795af52007-10-03 17:59:30 -0700850 rx->dev->name, print_mac(mac, hdr->addr2),
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400851 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4],
852 rpn[5], pn[0], pn[1], pn[2], pn[3],
853 pn[4], pn[5]);
Johannes Berg571ecf62007-07-27 15:43:22 +0200854 return TXRX_DROP;
855 }
856 memcpy(entry->last_pn, pn, CCMP_PN_LEN);
857 }
858
859 skb_pull(rx->skb, ieee80211_get_hdrlen(rx->fc));
860 __skb_queue_tail(&entry->skb_list, rx->skb);
861 entry->last_frag = frag;
862 entry->extra_len += rx->skb->len;
863 if (rx->fc & IEEE80211_FCTL_MOREFRAGS) {
864 rx->skb = NULL;
865 return TXRX_QUEUED;
866 }
867
868 rx->skb = __skb_dequeue(&entry->skb_list);
869 if (skb_tailroom(rx->skb) < entry->extra_len) {
870 I802_DEBUG_INC(rx->local->rx_expand_skb_head2);
871 if (unlikely(pskb_expand_head(rx->skb, 0, entry->extra_len,
872 GFP_ATOMIC))) {
873 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
874 __skb_queue_purge(&entry->skb_list);
875 return TXRX_DROP;
876 }
877 }
878 while ((skb = __skb_dequeue(&entry->skb_list))) {
879 memcpy(skb_put(rx->skb, skb->len), skb->data, skb->len);
880 dev_kfree_skb(skb);
881 }
882
883 /* Complete frame has been reassembled - process it now */
Jiri Slabybadffb72007-08-28 17:01:54 -0400884 rx->flags |= IEEE80211_TXRXD_FRAGMENTED;
Johannes Berg571ecf62007-07-27 15:43:22 +0200885
886 out:
887 if (rx->sta)
888 rx->sta->rx_packets++;
889 if (is_multicast_ether_addr(hdr->addr1))
890 rx->local->dot11MulticastReceivedFrameCount++;
891 else
892 ieee80211_led_rx(rx->local);
893 return TXRX_CONTINUE;
894}
895
896static ieee80211_txrx_result
897ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
898{
899 struct sk_buff *skb;
900 int no_pending_pkts;
Joe Perches0795af52007-10-03 17:59:30 -0700901 DECLARE_MAC_BUF(mac);
Johannes Berg571ecf62007-07-27 15:43:22 +0200902
903 if (likely(!rx->sta ||
904 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL ||
905 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL ||
Jiri Slabybadffb72007-08-28 17:01:54 -0400906 !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)))
Johannes Berg571ecf62007-07-27 15:43:22 +0200907 return TXRX_CONTINUE;
908
909 skb = skb_dequeue(&rx->sta->tx_filtered);
910 if (!skb) {
911 skb = skb_dequeue(&rx->sta->ps_tx_buf);
912 if (skb)
913 rx->local->total_ps_buffered--;
914 }
915 no_pending_pkts = skb_queue_empty(&rx->sta->tx_filtered) &&
916 skb_queue_empty(&rx->sta->ps_tx_buf);
917
918 if (skb) {
919 struct ieee80211_hdr *hdr =
920 (struct ieee80211_hdr *) skb->data;
921
922 /* tell TX path to send one frame even though the STA may
923 * still remain is PS mode after this frame exchange */
924 rx->sta->pspoll = 1;
925
926#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
Joe Perches0795af52007-10-03 17:59:30 -0700927 printk(KERN_DEBUG "STA %s aid %d: PS Poll (entries after %d)\n",
928 print_mac(mac, rx->sta->addr), rx->sta->aid,
Johannes Berg571ecf62007-07-27 15:43:22 +0200929 skb_queue_len(&rx->sta->ps_tx_buf));
930#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
931
932 /* Use MoreData flag to indicate whether there are more
933 * buffered frames for this STA */
934 if (no_pending_pkts) {
935 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
936 rx->sta->flags &= ~WLAN_STA_TIM;
937 } else
938 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
939
940 dev_queue_xmit(skb);
941
942 if (no_pending_pkts) {
943 if (rx->local->ops->set_tim)
944 rx->local->ops->set_tim(local_to_hw(rx->local),
945 rx->sta->aid, 0);
946 if (rx->sdata->bss)
947 bss_tim_clear(rx->local, rx->sdata->bss, rx->sta->aid);
948 }
949#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
950 } else if (!rx->u.rx.sent_ps_buffered) {
Joe Perches0795af52007-10-03 17:59:30 -0700951 printk(KERN_DEBUG "%s: STA %s sent PS Poll even "
Johannes Berg571ecf62007-07-27 15:43:22 +0200952 "though there is no buffered frames for it\n",
Joe Perches0795af52007-10-03 17:59:30 -0700953 rx->dev->name, print_mac(mac, rx->sta->addr));
Johannes Berg571ecf62007-07-27 15:43:22 +0200954#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
955
956 }
957
958 /* Free PS Poll skb here instead of returning TXRX_DROP that would
959 * count as an dropped frame. */
960 dev_kfree_skb(rx->skb);
961
962 return TXRX_QUEUED;
963}
964
965static ieee80211_txrx_result
Johannes Berg6e0d1142007-07-27 15:43:22 +0200966ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
967{
968 u16 fc = rx->fc;
969 u8 *data = rx->skb->data;
970 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
971
972 if (!WLAN_FC_IS_QOS_DATA(fc))
973 return TXRX_CONTINUE;
974
975 /* remove the qos control field, update frame type and meta-data */
976 memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
977 hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
978 /* change frame type to non QOS */
979 rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
980 hdr->frame_control = cpu_to_le16(fc);
981
982 return TXRX_CONTINUE;
983}
984
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +0200985static int
986ieee80211_drop_802_1x_pae(struct ieee80211_txrx_data *rx, int hdrlen)
Johannes Berg571ecf62007-07-27 15:43:22 +0200987{
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +0200988 if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb, hdrlen) &&
Jiri Slabybadffb72007-08-28 17:01:54 -0400989 rx->sdata->type != IEEE80211_IF_TYPE_STA &&
Johannes Bergf9d540e2007-09-28 14:02:09 +0200990 (rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +0200991 return 0;
Johannes Berg571ecf62007-07-27 15:43:22 +0200992
993 if (unlikely(rx->sdata->ieee802_1x &&
994 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
995 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
996 (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)) &&
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +0200997 !ieee80211_is_eapol(rx->skb, hdrlen))) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200998#ifdef CONFIG_MAC80211_DEBUG
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +0200999 printk(KERN_DEBUG "%s: dropped frame "
1000 "(unauthorized port)\n", rx->dev->name);
Johannes Berg571ecf62007-07-27 15:43:22 +02001001#endif /* CONFIG_MAC80211_DEBUG */
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001002 return -EACCES;
Johannes Berg571ecf62007-07-27 15:43:22 +02001003 }
1004
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001005 return 0;
Johannes Berg571ecf62007-07-27 15:43:22 +02001006}
1007
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001008static int
1009ieee80211_drop_unencrypted(struct ieee80211_txrx_data *rx, int hdrlen)
Johannes Berg571ecf62007-07-27 15:43:22 +02001010{
Johannes Berg3017b802007-08-28 17:01:53 -04001011 /*
Johannes Berg7848ba72007-09-14 11:10:25 -04001012 * Pass through unencrypted frames if the hardware has
1013 * decrypted them already.
Johannes Berg3017b802007-08-28 17:01:53 -04001014 */
Johannes Berg7848ba72007-09-14 11:10:25 -04001015 if (rx->u.rx.status->flag & RX_FLAG_DECRYPTED)
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001016 return 0;
Johannes Berg571ecf62007-07-27 15:43:22 +02001017
1018 /* Drop unencrypted frames if key is set. */
1019 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
1020 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
1021 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
Johannes Berg83125122007-11-28 11:07:57 +01001022 (rx->key || rx->sdata->drop_unencrypted) &&
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001023 (rx->sdata->eapol == 0 ||
1024 !ieee80211_is_eapol(rx->skb, hdrlen)))) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001025 if (net_ratelimit())
1026 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
1027 "encryption\n", rx->dev->name);
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001028 return -EACCES;
Johannes Berg571ecf62007-07-27 15:43:22 +02001029 }
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001030 return 0;
Johannes Berg571ecf62007-07-27 15:43:22 +02001031}
1032
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001033static int
1034ieee80211_data_to_8023(struct ieee80211_txrx_data *rx)
Johannes Berg571ecf62007-07-27 15:43:22 +02001035{
1036 struct net_device *dev = rx->dev;
Johannes Berg571ecf62007-07-27 15:43:22 +02001037 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
1038 u16 fc, hdrlen, ethertype;
1039 u8 *payload;
1040 u8 dst[ETH_ALEN];
1041 u8 src[ETH_ALEN];
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001042 struct sk_buff *skb = rx->skb;
Johannes Berg571ecf62007-07-27 15:43:22 +02001043 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Joe Perches0795af52007-10-03 17:59:30 -07001044 DECLARE_MAC_BUF(mac);
1045 DECLARE_MAC_BUF(mac2);
1046 DECLARE_MAC_BUF(mac3);
1047 DECLARE_MAC_BUF(mac4);
Johannes Berg571ecf62007-07-27 15:43:22 +02001048
1049 fc = rx->fc;
Johannes Berg571ecf62007-07-27 15:43:22 +02001050
1051 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001052 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001053
1054 hdrlen = ieee80211_get_hdrlen(fc);
1055
1056 /* convert IEEE 802.11 header + possible LLC headers into Ethernet
1057 * header
1058 * IEEE 802.11 address fields:
1059 * ToDS FromDS Addr1 Addr2 Addr3 Addr4
1060 * 0 0 DA SA BSSID n/a
1061 * 0 1 DA BSSID SA n/a
1062 * 1 0 BSSID SA DA n/a
1063 * 1 1 RA TA DA SA
1064 */
1065
1066 switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
1067 case IEEE80211_FCTL_TODS:
1068 /* BSSID SA DA */
1069 memcpy(dst, hdr->addr3, ETH_ALEN);
1070 memcpy(src, hdr->addr2, ETH_ALEN);
1071
1072 if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP &&
1073 sdata->type != IEEE80211_IF_TYPE_VLAN)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001074 if (net_ratelimit())
1075 printk(KERN_DEBUG "%s: dropped ToDS frame "
Joe Perches0795af52007-10-03 17:59:30 -07001076 "(BSSID=%s SA=%s DA=%s)\n",
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001077 dev->name,
Joe Perches0795af52007-10-03 17:59:30 -07001078 print_mac(mac, hdr->addr1),
1079 print_mac(mac2, hdr->addr2),
1080 print_mac(mac3, hdr->addr3));
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001081 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001082 }
1083 break;
1084 case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
1085 /* RA TA DA SA */
1086 memcpy(dst, hdr->addr3, ETH_ALEN);
1087 memcpy(src, hdr->addr4, ETH_ALEN);
1088
1089 if (unlikely(sdata->type != IEEE80211_IF_TYPE_WDS)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001090 if (net_ratelimit())
1091 printk(KERN_DEBUG "%s: dropped FromDS&ToDS "
Joe Perches0795af52007-10-03 17:59:30 -07001092 "frame (RA=%s TA=%s DA=%s SA=%s)\n",
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001093 rx->dev->name,
Joe Perches0795af52007-10-03 17:59:30 -07001094 print_mac(mac, hdr->addr1),
1095 print_mac(mac2, hdr->addr2),
1096 print_mac(mac3, hdr->addr3),
1097 print_mac(mac4, hdr->addr4));
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001098 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001099 }
1100 break;
1101 case IEEE80211_FCTL_FROMDS:
1102 /* DA BSSID SA */
1103 memcpy(dst, hdr->addr1, ETH_ALEN);
1104 memcpy(src, hdr->addr3, ETH_ALEN);
1105
John W. Linvilleb3316152007-08-28 17:01:55 -04001106 if (sdata->type != IEEE80211_IF_TYPE_STA ||
1107 (is_multicast_ether_addr(dst) &&
1108 !compare_ether_addr(src, dev->dev_addr)))
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001109 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001110 break;
1111 case 0:
1112 /* DA SA BSSID */
1113 memcpy(dst, hdr->addr1, ETH_ALEN);
1114 memcpy(src, hdr->addr2, ETH_ALEN);
1115
1116 if (sdata->type != IEEE80211_IF_TYPE_IBSS) {
1117 if (net_ratelimit()) {
Joe Perches0795af52007-10-03 17:59:30 -07001118 printk(KERN_DEBUG "%s: dropped IBSS frame "
1119 "(DA=%s SA=%s BSSID=%s)\n",
1120 dev->name,
1121 print_mac(mac, hdr->addr1),
1122 print_mac(mac2, hdr->addr2),
1123 print_mac(mac3, hdr->addr3));
Johannes Berg571ecf62007-07-27 15:43:22 +02001124 }
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001125 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001126 }
1127 break;
1128 }
1129
Johannes Berg571ecf62007-07-27 15:43:22 +02001130 if (unlikely(skb->len - hdrlen < 8)) {
1131 if (net_ratelimit()) {
1132 printk(KERN_DEBUG "%s: RX too short data frame "
1133 "payload\n", dev->name);
1134 }
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001135 return -1;
Johannes Berg571ecf62007-07-27 15:43:22 +02001136 }
1137
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001138 payload = skb->data + hdrlen;
Johannes Berg571ecf62007-07-27 15:43:22 +02001139 ethertype = (payload[6] << 8) | payload[7];
1140
1141 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
1142 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1143 compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
1144 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1145 * replace EtherType */
1146 skb_pull(skb, hdrlen + 6);
1147 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
1148 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
1149 } else {
1150 struct ethhdr *ehdr;
1151 __be16 len;
1152 skb_pull(skb, hdrlen);
1153 len = htons(skb->len);
1154 ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
1155 memcpy(ehdr->h_dest, dst, ETH_ALEN);
1156 memcpy(ehdr->h_source, src, ETH_ALEN);
1157 ehdr->h_proto = len;
1158 }
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001159 return 0;
1160}
Johannes Berg571ecf62007-07-27 15:43:22 +02001161
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001162static void
1163ieee80211_deliver_skb(struct ieee80211_txrx_data *rx)
1164{
1165 struct net_device *dev = rx->dev;
1166 struct ieee80211_local *local = rx->local;
1167 struct sk_buff *skb, *xmit_skb;
1168 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
Johannes Berg571ecf62007-07-27 15:43:22 +02001169
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001170 skb = rx->skb;
1171 xmit_skb = NULL;
Johannes Berg571ecf62007-07-27 15:43:22 +02001172
1173 if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP
Jiri Slabybadffb72007-08-28 17:01:54 -04001174 || sdata->type == IEEE80211_IF_TYPE_VLAN) &&
1175 (rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
Johannes Berg571ecf62007-07-27 15:43:22 +02001176 if (is_multicast_ether_addr(skb->data)) {
1177 /* send multicast frames both to higher layers in
1178 * local net stack and back to the wireless media */
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001179 xmit_skb = skb_copy(skb, GFP_ATOMIC);
1180 if (!xmit_skb && net_ratelimit())
Johannes Berg571ecf62007-07-27 15:43:22 +02001181 printk(KERN_DEBUG "%s: failed to clone "
1182 "multicast frame\n", dev->name);
1183 } else {
1184 struct sta_info *dsta;
1185 dsta = sta_info_get(local, skb->data);
1186 if (dsta && !dsta->dev) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001187 if (net_ratelimit())
1188 printk(KERN_DEBUG "Station with null "
1189 "dev structure!\n");
Johannes Berg571ecf62007-07-27 15:43:22 +02001190 } else if (dsta && dsta->dev == dev) {
1191 /* Destination station is associated to this
1192 * AP, so send the frame directly to it and
1193 * do not pass the frame to local net stack.
1194 */
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001195 xmit_skb = skb;
Johannes Berg571ecf62007-07-27 15:43:22 +02001196 skb = NULL;
1197 }
1198 if (dsta)
1199 sta_info_put(dsta);
1200 }
1201 }
1202
1203 if (skb) {
1204 /* deliver to local stack */
1205 skb->protocol = eth_type_trans(skb, dev);
1206 memset(skb->cb, 0, sizeof(skb->cb));
1207 netif_rx(skb);
1208 }
1209
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001210 if (xmit_skb) {
Johannes Berg571ecf62007-07-27 15:43:22 +02001211 /* send to wireless media */
YOSHIFUJI Hideakif831e902007-12-12 03:54:23 +09001212 xmit_skb->protocol = htons(ETH_P_802_3);
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001213 skb_set_network_header(xmit_skb, 0);
1214 skb_set_mac_header(xmit_skb, 0);
1215 dev_queue_xmit(xmit_skb);
Johannes Berg571ecf62007-07-27 15:43:22 +02001216 }
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001217}
1218
1219static ieee80211_txrx_result
Ron Rindjunskyfd4c7f22007-11-26 16:14:33 +02001220ieee80211_rx_h_amsdu(struct ieee80211_txrx_data *rx)
1221{
1222 struct net_device *dev = rx->dev;
1223 struct ieee80211_local *local = rx->local;
1224 u16 fc, ethertype;
1225 u8 *payload;
1226 struct sk_buff *skb = rx->skb, *frame = NULL;
1227 const struct ethhdr *eth;
1228 int remaining, err;
1229 u8 dst[ETH_ALEN];
1230 u8 src[ETH_ALEN];
1231 DECLARE_MAC_BUF(mac);
1232
1233 fc = rx->fc;
1234 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
1235 return TXRX_CONTINUE;
1236
1237 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1238 return TXRX_DROP;
1239
Ron Rindjunsky64bd4b62007-11-29 10:35:53 +02001240 if (!(rx->flags & IEEE80211_TXRXD_RX_AMSDU))
Ron Rindjunskyfd4c7f22007-11-26 16:14:33 +02001241 return TXRX_CONTINUE;
1242
1243 err = ieee80211_data_to_8023(rx);
1244 if (unlikely(err))
1245 return TXRX_DROP;
1246
1247 skb->dev = dev;
1248
1249 dev->stats.rx_packets++;
1250 dev->stats.rx_bytes += skb->len;
1251
1252 /* skip the wrapping header */
1253 eth = (struct ethhdr *) skb_pull(skb, sizeof(struct ethhdr));
1254 if (!eth)
1255 return TXRX_DROP;
1256
1257 while (skb != frame) {
1258 u8 padding;
1259 __be16 len = eth->h_proto;
1260 unsigned int subframe_len = sizeof(struct ethhdr) + ntohs(len);
1261
1262 remaining = skb->len;
1263 memcpy(dst, eth->h_dest, ETH_ALEN);
1264 memcpy(src, eth->h_source, ETH_ALEN);
1265
1266 padding = ((4 - subframe_len) & 0x3);
1267 /* the last MSDU has no padding */
1268 if (subframe_len > remaining) {
1269 printk(KERN_DEBUG "%s: wrong buffer size", dev->name);
1270 return TXRX_DROP;
1271 }
1272
1273 skb_pull(skb, sizeof(struct ethhdr));
1274 /* if last subframe reuse skb */
1275 if (remaining <= subframe_len + padding)
1276 frame = skb;
1277 else {
1278 frame = dev_alloc_skb(local->hw.extra_tx_headroom +
1279 subframe_len);
1280
1281 if (frame == NULL)
1282 return TXRX_DROP;
1283
1284 skb_reserve(frame, local->hw.extra_tx_headroom +
1285 sizeof(struct ethhdr));
1286 memcpy(skb_put(frame, ntohs(len)), skb->data,
1287 ntohs(len));
1288
1289 eth = (struct ethhdr *) skb_pull(skb, ntohs(len) +
1290 padding);
1291 if (!eth) {
1292 printk(KERN_DEBUG "%s: wrong buffer size ",
1293 dev->name);
1294 dev_kfree_skb(frame);
1295 return TXRX_DROP;
1296 }
1297 }
1298
1299 skb_set_network_header(frame, 0);
1300 frame->dev = dev;
1301 frame->priority = skb->priority;
1302 rx->skb = frame;
1303
1304 if ((ieee80211_drop_802_1x_pae(rx, 0)) ||
1305 (ieee80211_drop_unencrypted(rx, 0))) {
1306 if (skb == frame) /* last frame */
1307 return TXRX_DROP;
1308 dev_kfree_skb(frame);
1309 continue;
1310 }
1311
1312 payload = frame->data;
1313 ethertype = (payload[6] << 8) | payload[7];
1314
1315 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
1316 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1317 compare_ether_addr(payload,
1318 bridge_tunnel_header) == 0)) {
1319 /* remove RFC1042 or Bridge-Tunnel
1320 * encapsulation and replace EtherType */
1321 skb_pull(frame, 6);
1322 memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
1323 memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
1324 } else {
1325 memcpy(skb_push(frame, sizeof(__be16)), &len,
1326 sizeof(__be16));
1327 memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
1328 memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
1329 }
1330
1331
1332 ieee80211_deliver_skb(rx);
1333 }
1334
1335 return TXRX_QUEUED;
1336}
1337
1338static ieee80211_txrx_result
Ron Rindjunsky76ee65b2007-11-22 19:49:12 +02001339ieee80211_rx_h_data(struct ieee80211_txrx_data *rx)
1340{
1341 struct net_device *dev = rx->dev;
1342 u16 fc;
1343 int err, hdrlen;
1344
1345 fc = rx->fc;
1346 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
1347 return TXRX_CONTINUE;
1348
1349 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
1350 return TXRX_DROP;
1351
1352 hdrlen = ieee80211_get_hdrlen(fc);
1353
1354 if ((ieee80211_drop_802_1x_pae(rx, hdrlen)) ||
1355 (ieee80211_drop_unencrypted(rx, hdrlen)))
1356 return TXRX_DROP;
1357
1358 err = ieee80211_data_to_8023(rx);
1359 if (unlikely(err))
1360 return TXRX_DROP;
1361
1362 rx->skb->dev = dev;
1363
1364 dev->stats.rx_packets++;
1365 dev->stats.rx_bytes += rx->skb->len;
1366
1367 ieee80211_deliver_skb(rx);
Johannes Berg571ecf62007-07-27 15:43:22 +02001368
1369 return TXRX_QUEUED;
1370}
1371
1372static ieee80211_txrx_result
1373ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
1374{
1375 struct ieee80211_sub_if_data *sdata;
1376
Jiri Slabybadffb72007-08-28 17:01:54 -04001377 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +02001378 return TXRX_DROP;
1379
1380 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1381 if ((sdata->type == IEEE80211_IF_TYPE_STA ||
1382 sdata->type == IEEE80211_IF_TYPE_IBSS) &&
Johannes Bergddd3d2b2007-09-26 17:53:20 +02001383 !(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
Johannes Berg571ecf62007-07-27 15:43:22 +02001384 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
Johannes Bergf9d540e2007-09-28 14:02:09 +02001385 else
1386 return TXRX_DROP;
1387
Johannes Berg571ecf62007-07-27 15:43:22 +02001388 return TXRX_QUEUED;
1389}
1390
1391static inline ieee80211_txrx_result __ieee80211_invoke_rx_handlers(
1392 struct ieee80211_local *local,
1393 ieee80211_rx_handler *handlers,
1394 struct ieee80211_txrx_data *rx,
1395 struct sta_info *sta)
1396{
1397 ieee80211_rx_handler *handler;
1398 ieee80211_txrx_result res = TXRX_DROP;
1399
1400 for (handler = handlers; *handler != NULL; handler++) {
1401 res = (*handler)(rx);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001402
1403 switch (res) {
1404 case TXRX_CONTINUE:
1405 continue;
1406 case TXRX_DROP:
1407 I802_DEBUG_INC(local->rx_handlers_drop);
1408 if (sta)
1409 sta->rx_dropped++;
1410 break;
1411 case TXRX_QUEUED:
1412 I802_DEBUG_INC(local->rx_handlers_queued);
Johannes Berg571ecf62007-07-27 15:43:22 +02001413 break;
1414 }
Johannes Berg8e6f0032007-07-27 15:43:22 +02001415 break;
Johannes Berg571ecf62007-07-27 15:43:22 +02001416 }
1417
Johannes Berg8e6f0032007-07-27 15:43:22 +02001418 if (res == TXRX_DROP)
Johannes Berg571ecf62007-07-27 15:43:22 +02001419 dev_kfree_skb(rx->skb);
Johannes Berg571ecf62007-07-27 15:43:22 +02001420 return res;
1421}
1422
1423static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local *local,
1424 ieee80211_rx_handler *handlers,
1425 struct ieee80211_txrx_data *rx,
1426 struct sta_info *sta)
1427{
1428 if (__ieee80211_invoke_rx_handlers(local, handlers, rx, sta) ==
1429 TXRX_CONTINUE)
1430 dev_kfree_skb(rx->skb);
1431}
1432
1433static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1434 struct ieee80211_hdr *hdr,
1435 struct sta_info *sta,
1436 struct ieee80211_txrx_data *rx)
1437{
1438 int keyidx, hdrlen;
Joe Perches0795af52007-10-03 17:59:30 -07001439 DECLARE_MAC_BUF(mac);
1440 DECLARE_MAC_BUF(mac2);
Johannes Berg571ecf62007-07-27 15:43:22 +02001441
1442 hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb);
1443 if (rx->skb->len >= hdrlen + 4)
1444 keyidx = rx->skb->data[hdrlen + 3] >> 6;
1445 else
1446 keyidx = -1;
1447
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001448 if (net_ratelimit())
1449 printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC "
Joe Perches0795af52007-10-03 17:59:30 -07001450 "failure from %s to %s keyidx=%d\n",
1451 dev->name, print_mac(mac, hdr->addr2),
1452 print_mac(mac2, hdr->addr1), keyidx);
Johannes Berg571ecf62007-07-27 15:43:22 +02001453
1454 if (!sta) {
Johannes Bergaa0daf02007-09-10 14:15:25 +02001455 /*
1456 * Some hardware seem to generate incorrect Michael MIC
1457 * reports; ignore them to avoid triggering countermeasures.
1458 */
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001459 if (net_ratelimit())
1460 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
Joe Perches0795af52007-10-03 17:59:30 -07001461 "error for unknown address %s\n",
1462 dev->name, print_mac(mac, hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001463 goto ignore;
1464 }
1465
1466 if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001467 if (net_ratelimit())
1468 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
Johannes Bergaa0daf02007-09-10 14:15:25 +02001469 "error for a frame with no PROTECTED flag (src "
Joe Perches0795af52007-10-03 17:59:30 -07001470 "%s)\n", dev->name, print_mac(mac, hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001471 goto ignore;
1472 }
1473
Johannes Berg7848ba72007-09-14 11:10:25 -04001474 if (rx->sdata->type == IEEE80211_IF_TYPE_AP && keyidx) {
Johannes Bergaa0daf02007-09-10 14:15:25 +02001475 /*
1476 * APs with pairwise keys should never receive Michael MIC
1477 * errors for non-zero keyidx because these are reserved for
1478 * group keys and only the AP is sending real multicast
1479 * frames in the BSS.
1480 */
Johannes Bergeb063c12007-08-28 17:01:53 -04001481 if (net_ratelimit())
1482 printk(KERN_DEBUG "%s: ignored Michael MIC error for "
1483 "a frame with non-zero keyidx (%d)"
Joe Perches0795af52007-10-03 17:59:30 -07001484 " (src %s)\n", dev->name, keyidx,
1485 print_mac(mac, hdr->addr2));
Johannes Bergeb063c12007-08-28 17:01:53 -04001486 goto ignore;
Johannes Berg571ecf62007-07-27 15:43:22 +02001487 }
1488
1489 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
1490 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
1491 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001492 if (net_ratelimit())
1493 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1494 "error for a frame that cannot be encrypted "
Joe Perches0795af52007-10-03 17:59:30 -07001495 "(fc=0x%04x) (src %s)\n",
1496 dev->name, rx->fc, print_mac(mac, hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001497 goto ignore;
1498 }
1499
Johannes Bergeb063c12007-08-28 17:01:53 -04001500 mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr);
Johannes Berg571ecf62007-07-27 15:43:22 +02001501 ignore:
1502 dev_kfree_skb(rx->skb);
1503 rx->skb = NULL;
1504}
1505
1506ieee80211_rx_handler ieee80211_rx_handlers[] =
1507{
1508 ieee80211_rx_h_if_stats,
Johannes Berg571ecf62007-07-27 15:43:22 +02001509 ieee80211_rx_h_passive_scan,
1510 ieee80211_rx_h_check,
Johannes Berg4f0d18e2007-09-26 15:19:40 +02001511 ieee80211_rx_h_decrypt,
Johannes Berg70f08762007-09-26 17:53:14 +02001512 ieee80211_rx_h_sta_process,
Johannes Berg571ecf62007-07-27 15:43:22 +02001513 ieee80211_rx_h_defragment,
1514 ieee80211_rx_h_ps_poll,
1515 ieee80211_rx_h_michael_mic_verify,
1516 /* this must be after decryption - so header is counted in MPDU mic
1517 * must be before pae and data, so QOS_DATA format frames
1518 * are not passed to user space by these functions
1519 */
1520 ieee80211_rx_h_remove_qos_control,
Ron Rindjunskyfd4c7f22007-11-26 16:14:33 +02001521 ieee80211_rx_h_amsdu,
Johannes Berg571ecf62007-07-27 15:43:22 +02001522 ieee80211_rx_h_data,
1523 ieee80211_rx_h_mgmt,
1524 NULL
1525};
1526
1527/* main receive path */
1528
Johannes Berg23a24de2007-07-27 15:43:22 +02001529static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
1530 u8 *bssid, struct ieee80211_txrx_data *rx,
1531 struct ieee80211_hdr *hdr)
1532{
1533 int multicast = is_multicast_ether_addr(hdr->addr1);
1534
1535 switch (sdata->type) {
1536 case IEEE80211_IF_TYPE_STA:
1537 if (!bssid)
1538 return 0;
1539 if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001540 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001541 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001542 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001543 } else if (!multicast &&
1544 compare_ether_addr(sdata->dev->dev_addr,
1545 hdr->addr1) != 0) {
Johannes Berg4150c572007-09-17 01:29:23 -04001546 if (!(sdata->dev->flags & IFF_PROMISC))
Johannes Berg23a24de2007-07-27 15:43:22 +02001547 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001548 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001549 }
1550 break;
1551 case IEEE80211_IF_TYPE_IBSS:
1552 if (!bssid)
1553 return 0;
1554 if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001555 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001556 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001557 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001558 } else if (!multicast &&
1559 compare_ether_addr(sdata->dev->dev_addr,
1560 hdr->addr1) != 0) {
Johannes Berg4150c572007-09-17 01:29:23 -04001561 if (!(sdata->dev->flags & IFF_PROMISC))
Johannes Berg23a24de2007-07-27 15:43:22 +02001562 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001563 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001564 } else if (!rx->sta)
1565 rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb,
1566 bssid, hdr->addr2);
1567 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +02001568 case IEEE80211_IF_TYPE_VLAN:
Johannes Berg23a24de2007-07-27 15:43:22 +02001569 case IEEE80211_IF_TYPE_AP:
1570 if (!bssid) {
1571 if (compare_ether_addr(sdata->dev->dev_addr,
1572 hdr->addr1))
1573 return 0;
1574 } else if (!ieee80211_bssid_match(bssid,
1575 sdata->dev->dev_addr)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001576 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001577 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001578 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001579 }
Jiri Slabybadffb72007-08-28 17:01:54 -04001580 if (sdata->dev == sdata->local->mdev &&
1581 !(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001582 /* do not receive anything via
1583 * master device when not scanning */
1584 return 0;
1585 break;
1586 case IEEE80211_IF_TYPE_WDS:
1587 if (bssid ||
1588 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
1589 return 0;
1590 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
1591 return 0;
1592 break;
Johannes Bergfb1c1cd2007-09-26 15:19:43 +02001593 case IEEE80211_IF_TYPE_MNTR:
1594 /* take everything */
1595 break;
Johannes Berga2897552007-09-28 14:01:25 +02001596 case IEEE80211_IF_TYPE_INVALID:
Johannes Bergfb1c1cd2007-09-26 15:19:43 +02001597 /* should never get here */
1598 WARN_ON(1);
1599 break;
Johannes Berg23a24de2007-07-27 15:43:22 +02001600 }
1601
1602 return 1;
1603}
1604
Johannes Berg571ecf62007-07-27 15:43:22 +02001605/*
1606 * This is the receive path handler. It is called by a low level driver when an
1607 * 802.11 MPDU is received from the hardware.
1608 */
1609void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
1610 struct ieee80211_rx_status *status)
1611{
1612 struct ieee80211_local *local = hw_to_local(hw);
1613 struct ieee80211_sub_if_data *sdata;
1614 struct sta_info *sta;
1615 struct ieee80211_hdr *hdr;
1616 struct ieee80211_txrx_data rx;
1617 u16 type;
Johannes Bergb2e77712007-09-26 15:19:39 +02001618 int prepres;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001619 struct ieee80211_sub_if_data *prev = NULL;
1620 struct sk_buff *skb_new;
1621 u8 *bssid;
David S. Millerd10f2152008-01-24 16:57:39 -08001622 int hdrlen;
Johannes Berg571ecf62007-07-27 15:43:22 +02001623
Johannes Bergd4e46a32007-09-14 11:10:24 -04001624 /*
Johannes Berg79010422007-09-18 17:29:21 -04001625 * key references and virtual interfaces are protected using RCU
1626 * and this requires that we are in a read-side RCU section during
1627 * receive processing
Johannes Bergd4e46a32007-09-14 11:10:24 -04001628 */
1629 rcu_read_lock();
1630
Johannes Bergb2e77712007-09-26 15:19:39 +02001631 /*
1632 * Frames with failed FCS/PLCP checksum are not returned,
1633 * all other frames are returned without radiotap header
1634 * if it was previously present.
1635 * Also, frames with less than 16 bytes are dropped.
1636 */
1637 skb = ieee80211_rx_monitor(local, skb, status);
1638 if (!skb) {
1639 rcu_read_unlock();
1640 return;
1641 }
1642
Johannes Berg571ecf62007-07-27 15:43:22 +02001643 hdr = (struct ieee80211_hdr *) skb->data;
1644 memset(&rx, 0, sizeof(rx));
1645 rx.skb = skb;
1646 rx.local = local;
1647
1648 rx.u.rx.status = status;
Johannes Bergb2e77712007-09-26 15:19:39 +02001649 rx.fc = le16_to_cpu(hdr->frame_control);
Johannes Berg571ecf62007-07-27 15:43:22 +02001650 type = rx.fc & IEEE80211_FCTL_FTYPE;
Johannes Berg72abd812007-09-17 01:29:22 -04001651
David S. Millerd10f2152008-01-24 16:57:39 -08001652 /*
1653 * Drivers are required to align the payload data to a four-byte
1654 * boundary, so the last two bits of the address where it starts
1655 * may not be set. The header is required to be directly before
1656 * the payload data, padding like atheros hardware adds which is
1657 * inbetween the 802.11 header and the payload is not supported,
1658 * the driver is required to move the 802.11 header further back
1659 * in that case.
1660 */
1661 hdrlen = ieee80211_get_hdrlen(rx.fc);
1662 WARN_ON_ONCE(((unsigned long)(skb->data + hdrlen)) & 3);
1663
Johannes Bergb2e77712007-09-26 15:19:39 +02001664 if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
Johannes Berg571ecf62007-07-27 15:43:22 +02001665 local->dot11ReceivedFragmentCount++;
Johannes Berg571ecf62007-07-27 15:43:22 +02001666
Johannes Bergb2e77712007-09-26 15:19:39 +02001667 sta = rx.sta = sta_info_get(local, hdr->addr2);
1668 if (sta) {
1669 rx.dev = rx.sta->dev;
1670 rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
1671 }
Johannes Berg571ecf62007-07-27 15:43:22 +02001672
Johannes Berg571ecf62007-07-27 15:43:22 +02001673 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
1674 ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx);
1675 goto end;
1676 }
1677
Zhu Yiece8edd2007-11-22 10:53:21 +08001678 if (unlikely(local->sta_sw_scanning || local->sta_hw_scanning))
Jiri Slabybadffb72007-08-28 17:01:54 -04001679 rx.flags |= IEEE80211_TXRXD_RXIN_SCAN;
Johannes Berg571ecf62007-07-27 15:43:22 +02001680
1681 if (__ieee80211_invoke_rx_handlers(local, local->rx_pre_handlers, &rx,
1682 sta) != TXRX_CONTINUE)
1683 goto end;
1684 skb = rx.skb;
1685
Johannes Bergc9ee23d2007-08-28 17:01:55 -04001686 if (sta && !(sta->flags & (WLAN_STA_WDS | WLAN_STA_ASSOC_AP)) &&
Johannes Berg53918992007-09-26 15:19:47 +02001687 !atomic_read(&local->iff_promiscs) &&
1688 !is_multicast_ether_addr(hdr->addr1)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001689 rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg571ecf62007-07-27 15:43:22 +02001690 ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx,
Johannes Berg23a24de2007-07-27 15:43:22 +02001691 rx.sta);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001692 sta_info_put(sta);
Johannes Bergd4e46a32007-09-14 11:10:24 -04001693 rcu_read_unlock();
Johannes Berg8e6f0032007-07-27 15:43:22 +02001694 return;
1695 }
Johannes Berg571ecf62007-07-27 15:43:22 +02001696
Johannes Bergb2e77712007-09-26 15:19:39 +02001697 bssid = ieee80211_get_bssid(hdr, skb->len);
Johannes Berg571ecf62007-07-27 15:43:22 +02001698
Johannes Berg79010422007-09-18 17:29:21 -04001699 list_for_each_entry_rcu(sdata, &local->interfaces, list) {
Johannes Berg2a8a9a82007-08-28 17:01:52 -04001700 if (!netif_running(sdata->dev))
1701 continue;
1702
Johannes Bergb2e77712007-09-26 15:19:39 +02001703 if (sdata->type == IEEE80211_IF_TYPE_MNTR)
1704 continue;
1705
1706 rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001707 prepres = prepare_for_handlers(sdata, bssid, &rx, hdr);
1708 /* prepare_for_handlers can change sta */
1709 sta = rx.sta;
1710
1711 if (!prepres)
1712 continue;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001713
Johannes Berg340e11f2007-07-27 15:43:22 +02001714 /*
1715 * frame is destined for this interface, but if it's not
1716 * also for the previous one we handle that after the
1717 * loop to avoid copying the SKB once too much
1718 */
1719
1720 if (!prev) {
1721 prev = sdata;
1722 continue;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001723 }
Johannes Berg340e11f2007-07-27 15:43:22 +02001724
1725 /*
1726 * frame was destined for the previous interface
1727 * so invoke RX handlers for it
1728 */
1729
1730 skb_new = skb_copy(skb, GFP_ATOMIC);
1731 if (!skb_new) {
1732 if (net_ratelimit())
1733 printk(KERN_DEBUG "%s: failed to copy "
1734 "multicast frame for %s",
Johannes Bergdd1cd4c2007-09-18 17:29:20 -04001735 wiphy_name(local->hw.wiphy),
1736 prev->dev->name);
Johannes Berg340e11f2007-07-27 15:43:22 +02001737 continue;
1738 }
1739 rx.skb = skb_new;
1740 rx.dev = prev->dev;
1741 rx.sdata = prev;
1742 ieee80211_invoke_rx_handlers(local, local->rx_handlers,
1743 &rx, sta);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001744 prev = sdata;
Johannes Berg571ecf62007-07-27 15:43:22 +02001745 }
Johannes Berg8e6f0032007-07-27 15:43:22 +02001746 if (prev) {
1747 rx.skb = skb;
1748 rx.dev = prev->dev;
1749 rx.sdata = prev;
1750 ieee80211_invoke_rx_handlers(local, local->rx_handlers,
1751 &rx, sta);
1752 } else
1753 dev_kfree_skb(skb);
Johannes Berg571ecf62007-07-27 15:43:22 +02001754
Johannes Berg8e6f0032007-07-27 15:43:22 +02001755 end:
Johannes Bergd4e46a32007-09-14 11:10:24 -04001756 rcu_read_unlock();
1757
Johannes Berg571ecf62007-07-27 15:43:22 +02001758 if (sta)
1759 sta_info_put(sta);
1760}
1761EXPORT_SYMBOL(__ieee80211_rx);
1762
1763/* This is a version of the rx handler that can be called from hard irq
1764 * context. Post the skb on the queue and schedule the tasklet */
1765void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb,
1766 struct ieee80211_rx_status *status)
1767{
1768 struct ieee80211_local *local = hw_to_local(hw);
1769
1770 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
1771
1772 skb->dev = local->mdev;
1773 /* copy status into skb->cb for use by tasklet */
1774 memcpy(skb->cb, status, sizeof(*status));
1775 skb->pkt_type = IEEE80211_RX_MSG;
1776 skb_queue_tail(&local->skb_queue, skb);
1777 tasklet_schedule(&local->tasklet);
1778}
1779EXPORT_SYMBOL(ieee80211_rx_irqsafe);