blob: af94fb597415f8254bf2e32b81bc0ece4089bce0 [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 Berg571ecf62007-07-27 15:43:22 +020016#include <net/mac80211.h>
17#include <net/ieee80211_radiotap.h>
18
19#include "ieee80211_i.h"
20#include "ieee80211_led.h"
21#include "ieee80211_common.h"
22#include "wep.h"
23#include "wpa.h"
24#include "tkip.h"
25#include "wme.h"
26
27/* pre-rx handlers
28 *
29 * these don't have dev/sdata fields in the rx data
Johannes Berg52865df2007-07-27 15:43:22 +020030 * The sta value should also not be used because it may
31 * be NULL even though a STA (in IBSS mode) will be added.
Johannes Berg571ecf62007-07-27 15:43:22 +020032 */
33
34static ieee80211_txrx_result
Johannes Berg6e0d1142007-07-27 15:43:22 +020035ieee80211_rx_h_parse_qos(struct ieee80211_txrx_data *rx)
36{
37 u8 *data = rx->skb->data;
38 int tid;
39
40 /* does the frame have a qos control field? */
41 if (WLAN_FC_IS_QOS_DATA(rx->fc)) {
42 u8 *qc = data + ieee80211_get_hdrlen(rx->fc) - QOS_CONTROL_LEN;
43 /* frame has qos control */
44 tid = qc[0] & QOS_CONTROL_TID_MASK;
45 } else {
46 if (unlikely((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT)) {
47 /* Separate TID for management frames */
48 tid = NUM_RX_DATA_QUEUES - 1;
49 } else {
50 /* no qos control present */
51 tid = 0; /* 802.1d - Best Effort */
52 }
53 }
Johannes Berg52865df2007-07-27 15:43:22 +020054
Johannes Berg6e0d1142007-07-27 15:43:22 +020055 I802_DEBUG_INC(rx->local->wme_rx_queue[tid]);
Johannes Berg52865df2007-07-27 15:43:22 +020056 /* only a debug counter, sta might not be assigned properly yet */
57 if (rx->sta)
Johannes Berg6e0d1142007-07-27 15:43:22 +020058 I802_DEBUG_INC(rx->sta->wme_rx_queue[tid]);
Johannes Berg6e0d1142007-07-27 15:43:22 +020059
60 rx->u.rx.queue = tid;
61 /* Set skb->priority to 1d tag if highest order bit of TID is not set.
62 * For now, set skb->priority to 0 for other cases. */
63 rx->skb->priority = (tid > 7) ? 0 : tid;
64
65 return TXRX_CONTINUE;
66}
67
68static ieee80211_txrx_result
Johannes Berg571ecf62007-07-27 15:43:22 +020069ieee80211_rx_h_load_stats(struct ieee80211_txrx_data *rx)
70{
71 struct ieee80211_local *local = rx->local;
72 struct sk_buff *skb = rx->skb;
73 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
74 u32 load = 0, hdrtime;
75 struct ieee80211_rate *rate;
76 struct ieee80211_hw_mode *mode = local->hw.conf.mode;
77 int i;
78
79 /* Estimate total channel use caused by this frame */
80
81 if (unlikely(mode->num_rates < 0))
82 return TXRX_CONTINUE;
83
84 rate = &mode->rates[0];
85 for (i = 0; i < mode->num_rates; i++) {
86 if (mode->rates[i].val == rx->u.rx.status->rate) {
87 rate = &mode->rates[i];
88 break;
89 }
90 }
91
92 /* 1 bit at 1 Mbit/s takes 1 usec; in channel_use values,
93 * 1 usec = 1/8 * (1080 / 10) = 13.5 */
94
95 if (mode->mode == MODE_IEEE80211A ||
96 mode->mode == MODE_ATHEROS_TURBO ||
97 mode->mode == MODE_ATHEROS_TURBOG ||
98 (mode->mode == MODE_IEEE80211G &&
99 rate->flags & IEEE80211_RATE_ERP))
100 hdrtime = CHAN_UTIL_HDR_SHORT;
101 else
102 hdrtime = CHAN_UTIL_HDR_LONG;
103
104 load = hdrtime;
105 if (!is_multicast_ether_addr(hdr->addr1))
106 load += hdrtime;
107
108 load += skb->len * rate->rate_inv;
109
110 /* Divide channel_use by 8 to avoid wrapping around the counter */
111 load >>= CHAN_UTIL_SHIFT;
112 local->channel_use_raw += load;
Johannes Berg571ecf62007-07-27 15:43:22 +0200113 rx->u.rx.load = load;
114
115 return TXRX_CONTINUE;
116}
117
118ieee80211_rx_handler ieee80211_rx_pre_handlers[] =
119{
120 ieee80211_rx_h_parse_qos,
121 ieee80211_rx_h_load_stats,
122 NULL
123};
124
125/* rx handlers */
126
127static ieee80211_txrx_result
128ieee80211_rx_h_if_stats(struct ieee80211_txrx_data *rx)
129{
Johannes Berg52865df2007-07-27 15:43:22 +0200130 if (rx->sta)
131 rx->sta->channel_use_raw += rx->u.rx.load;
Johannes Berg571ecf62007-07-27 15:43:22 +0200132 rx->sdata->channel_use_raw += rx->u.rx.load;
133 return TXRX_CONTINUE;
134}
135
136static void
137ieee80211_rx_monitor(struct net_device *dev, struct sk_buff *skb,
138 struct ieee80211_rx_status *status)
139{
140 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
141 struct ieee80211_sub_if_data *sdata;
142 struct ieee80211_rate *rate;
143 struct ieee80211_rtap_hdr {
144 struct ieee80211_radiotap_header hdr;
145 u8 flags;
146 u8 rate;
147 __le16 chan_freq;
148 __le16 chan_flags;
149 u8 antsignal;
150 } __attribute__ ((packed)) *rthdr;
151
152 skb->dev = dev;
153
154 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
155
156 if (status->flag & RX_FLAG_RADIOTAP)
157 goto out;
158
159 if (skb_headroom(skb) < sizeof(*rthdr)) {
160 I802_DEBUG_INC(local->rx_expand_skb_head);
161 if (pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) {
162 dev_kfree_skb(skb);
163 return;
164 }
165 }
166
167 rthdr = (struct ieee80211_rtap_hdr *) skb_push(skb, sizeof(*rthdr));
168 memset(rthdr, 0, sizeof(*rthdr));
169 rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr));
170 rthdr->hdr.it_present =
171 cpu_to_le32((1 << IEEE80211_RADIOTAP_FLAGS) |
172 (1 << IEEE80211_RADIOTAP_RATE) |
173 (1 << IEEE80211_RADIOTAP_CHANNEL) |
174 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL));
175 rthdr->flags = local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS ?
176 IEEE80211_RADIOTAP_F_FCS : 0;
177 rate = ieee80211_get_rate(local, status->phymode, status->rate);
178 if (rate)
179 rthdr->rate = rate->rate / 5;
180 rthdr->chan_freq = cpu_to_le16(status->freq);
181 rthdr->chan_flags =
182 status->phymode == MODE_IEEE80211A ?
183 cpu_to_le16(IEEE80211_CHAN_OFDM | IEEE80211_CHAN_5GHZ) :
184 cpu_to_le16(IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ);
185 rthdr->antsignal = status->ssi;
186
187 out:
188 sdata->stats.rx_packets++;
189 sdata->stats.rx_bytes += skb->len;
190
191 skb_set_mac_header(skb, 0);
192 skb->ip_summed = CHECKSUM_UNNECESSARY;
193 skb->pkt_type = PACKET_OTHERHOST;
194 skb->protocol = htons(ETH_P_802_2);
195 memset(skb->cb, 0, sizeof(skb->cb));
196 netif_rx(skb);
197}
198
199static ieee80211_txrx_result
200ieee80211_rx_h_monitor(struct ieee80211_txrx_data *rx)
201{
202 if (rx->sdata->type == IEEE80211_IF_TYPE_MNTR) {
203 ieee80211_rx_monitor(rx->dev, rx->skb, rx->u.rx.status);
204 return TXRX_QUEUED;
205 }
206
207 if (rx->u.rx.status->flag & RX_FLAG_RADIOTAP)
208 skb_pull(rx->skb, ieee80211_get_radiotap_len(rx->skb->data));
209
210 return TXRX_CONTINUE;
211}
212
213static ieee80211_txrx_result
214ieee80211_rx_h_passive_scan(struct ieee80211_txrx_data *rx)
215{
216 struct ieee80211_local *local = rx->local;
217 struct sk_buff *skb = rx->skb;
218
219 if (unlikely(local->sta_scanning != 0)) {
220 ieee80211_sta_rx_scan(rx->dev, skb, rx->u.rx.status);
221 return TXRX_QUEUED;
222 }
223
Jiri Slabybadffb72007-08-28 17:01:54 -0400224 if (unlikely(rx->flags & IEEE80211_TXRXD_RXIN_SCAN)) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200225 /* scanning finished during invoking of handlers */
226 I802_DEBUG_INC(local->rx_handlers_drop_passive_scan);
227 return TXRX_DROP;
228 }
229
230 return TXRX_CONTINUE;
231}
232
233static ieee80211_txrx_result
234ieee80211_rx_h_check(struct ieee80211_txrx_data *rx)
235{
236 struct ieee80211_hdr *hdr;
Johannes Berg571ecf62007-07-27 15:43:22 +0200237 hdr = (struct ieee80211_hdr *) rx->skb->data;
238
239 /* Drop duplicate 802.11 retransmissions (IEEE 802.11 Chap. 9.2.9) */
240 if (rx->sta && !is_multicast_ether_addr(hdr->addr1)) {
241 if (unlikely(rx->fc & IEEE80211_FCTL_RETRY &&
242 rx->sta->last_seq_ctrl[rx->u.rx.queue] ==
243 hdr->seq_ctrl)) {
Jiri Slabybadffb72007-08-28 17:01:54 -0400244 if (rx->flags & IEEE80211_TXRXD_RXRA_MATCH) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200245 rx->local->dot11FrameDuplicateCount++;
246 rx->sta->num_duplicates++;
247 }
248 return TXRX_DROP;
249 } else
250 rx->sta->last_seq_ctrl[rx->u.rx.queue] = hdr->seq_ctrl;
251 }
252
253 if ((rx->local->hw.flags & IEEE80211_HW_RX_INCLUDES_FCS) &&
254 rx->skb->len > FCS_LEN)
255 skb_trim(rx->skb, rx->skb->len - FCS_LEN);
256
257 if (unlikely(rx->skb->len < 16)) {
258 I802_DEBUG_INC(rx->local->rx_handlers_drop_short);
259 return TXRX_DROP;
260 }
261
Jiri Slabybadffb72007-08-28 17:01:54 -0400262 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +0200263 rx->skb->pkt_type = PACKET_OTHERHOST;
264 else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 0)
265 rx->skb->pkt_type = PACKET_HOST;
266 else if (is_multicast_ether_addr(hdr->addr1)) {
267 if (is_broadcast_ether_addr(hdr->addr1))
268 rx->skb->pkt_type = PACKET_BROADCAST;
269 else
270 rx->skb->pkt_type = PACKET_MULTICAST;
271 } else
272 rx->skb->pkt_type = PACKET_OTHERHOST;
273
274 /* Drop disallowed frame classes based on STA auth/assoc state;
275 * IEEE 802.11, Chap 5.5.
276 *
277 * 80211.o does filtering only based on association state, i.e., it
278 * drops Class 3 frames from not associated stations. hostapd sends
279 * deauth/disassoc frames when needed. In addition, hostapd is
280 * responsible for filtering on both auth and assoc states.
281 */
282 if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
283 ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
284 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
285 rx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
286 (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
287 if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
288 !(rx->fc & IEEE80211_FCTL_TODS) &&
289 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)
Jiri Slabybadffb72007-08-28 17:01:54 -0400290 || !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200291 /* Drop IBSS frames and frames for other hosts
292 * silently. */
293 return TXRX_DROP;
294 }
295
296 if (!rx->local->apdev)
297 return TXRX_DROP;
298
299 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
300 ieee80211_msg_sta_not_assoc);
301 return TXRX_QUEUED;
302 }
303
Johannes Berg570bd532007-07-27 15:43:22 +0200304 return TXRX_CONTINUE;
305}
306
307
308static ieee80211_txrx_result
309ieee80211_rx_h_load_key(struct ieee80211_txrx_data *rx)
310{
311 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
Johannes Berg3017b802007-08-28 17:01:53 -0400312 int keyidx;
313 int hdrlen;
Johannes Berg570bd532007-07-27 15:43:22 +0200314
Johannes Berg3017b802007-08-28 17:01:53 -0400315 /*
316 * Key selection 101
317 *
318 * There are three types of keys:
319 * - GTK (group keys)
320 * - PTK (pairwise keys)
321 * - STK (station-to-station pairwise keys)
322 *
323 * When selecting a key, we have to distinguish between multicast
324 * (including broadcast) and unicast frames, the latter can only
325 * use PTKs and STKs while the former always use GTKs. Unless, of
326 * course, actual WEP keys ("pre-RSNA") are used, then unicast
327 * frames can also use key indizes like GTKs. Hence, if we don't
328 * have a PTK/STK we check the key index for a WEP key.
329 *
330 * There is also a slight problem in IBSS mode: GTKs are negotiated
331 * with each station, that is something we don't currently handle.
332 */
Johannes Berg571ecf62007-07-27 15:43:22 +0200333
Johannes Berg3017b802007-08-28 17:01:53 -0400334 if (!(rx->fc & IEEE80211_FCTL_PROTECTED))
335 return TXRX_CONTINUE;
336
337 /*
338 * No point in finding a key if the frame is neither
339 * addressed to us nor a multicast frame.
340 */
Jiri Slabybadffb72007-08-28 17:01:54 -0400341 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg3017b802007-08-28 17:01:53 -0400342 return TXRX_CONTINUE;
343
344 if (!is_multicast_ether_addr(hdr->addr1) && rx->sta && rx->sta->key) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200345 rx->key = rx->sta->key;
346 } else {
Johannes Berg3017b802007-08-28 17:01:53 -0400347 /*
348 * The device doesn't give us the IV so we won't be
349 * able to look up the key. That's ok though, we
350 * don't need to decrypt the frame, we just won't
351 * be able to keep statistics accurate.
352 * Except for key threshold notifications, should
353 * we somehow allow the driver to tell us which key
354 * the hardware used if this flag is set?
355 */
356 if (!(rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV))
357 return TXRX_CONTINUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200358
Johannes Berg3017b802007-08-28 17:01:53 -0400359 hdrlen = ieee80211_get_hdrlen(rx->fc);
Johannes Berg571ecf62007-07-27 15:43:22 +0200360
Johannes Berg3017b802007-08-28 17:01:53 -0400361 if (rx->skb->len < 8 + hdrlen)
362 return TXRX_DROP; /* TODO: count this? */
Johannes Berg571ecf62007-07-27 15:43:22 +0200363
Johannes Berg3017b802007-08-28 17:01:53 -0400364 /*
365 * no need to call ieee80211_wep_get_keyidx,
366 * it verifies a bunch of things we've done already
367 */
368 keyidx = rx->skb->data[hdrlen + 3] >> 6;
369
370 rx->key = rx->sdata->keys[keyidx];
371
372 /*
373 * RSNA-protected unicast frames should always be sent with
374 * pairwise or station-to-station keys, but for WEP we allow
375 * using a key index as well.
376 */
377 if (rx->key && rx->key->alg != ALG_WEP &&
378 !is_multicast_ether_addr(hdr->addr1))
379 rx->key = NULL;
Johannes Berg571ecf62007-07-27 15:43:22 +0200380 }
381
Johannes Berg3017b802007-08-28 17:01:53 -0400382 if (rx->key) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200383 rx->key->tx_rx_count++;
384 if (unlikely(rx->local->key_tx_rx_threshold &&
385 rx->key->tx_rx_count >
386 rx->local->key_tx_rx_threshold)) {
387 ieee80211_key_threshold_notify(rx->dev, rx->key,
388 rx->sta);
389 }
390 }
391
392 return TXRX_CONTINUE;
393}
394
395static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)
396{
397 struct ieee80211_sub_if_data *sdata;
398 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
399
400 if (sdata->bss)
401 atomic_inc(&sdata->bss->num_sta_ps);
402 sta->flags |= WLAN_STA_PS;
403 sta->pspoll = 0;
404#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
405 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d enters power "
406 "save mode\n", dev->name, MAC_ARG(sta->addr), sta->aid);
407#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
408}
409
410static int ap_sta_ps_end(struct net_device *dev, struct sta_info *sta)
411{
412 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
413 struct sk_buff *skb;
414 int sent = 0;
415 struct ieee80211_sub_if_data *sdata;
416 struct ieee80211_tx_packet_data *pkt_data;
417
418 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
419 if (sdata->bss)
420 atomic_dec(&sdata->bss->num_sta_ps);
421 sta->flags &= ~(WLAN_STA_PS | WLAN_STA_TIM);
422 sta->pspoll = 0;
423 if (!skb_queue_empty(&sta->ps_tx_buf)) {
424 if (local->ops->set_tim)
425 local->ops->set_tim(local_to_hw(local), sta->aid, 0);
426 if (sdata->bss)
427 bss_tim_clear(local, sdata->bss, sta->aid);
428 }
429#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
430 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d exits power "
431 "save mode\n", dev->name, MAC_ARG(sta->addr), sta->aid);
432#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
433 /* Send all buffered frames to the station */
434 while ((skb = skb_dequeue(&sta->tx_filtered)) != NULL) {
435 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
436 sent++;
Jiri Slabye8bf9642007-08-28 17:01:54 -0400437 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200438 dev_queue_xmit(skb);
439 }
440 while ((skb = skb_dequeue(&sta->ps_tx_buf)) != NULL) {
441 pkt_data = (struct ieee80211_tx_packet_data *) skb->cb;
442 local->total_ps_buffered--;
443 sent++;
444#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
445 printk(KERN_DEBUG "%s: STA " MAC_FMT " aid %d send PS frame "
446 "since STA not sleeping anymore\n", dev->name,
447 MAC_ARG(sta->addr), sta->aid);
448#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
Jiri Slabye8bf9642007-08-28 17:01:54 -0400449 pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
Johannes Berg571ecf62007-07-27 15:43:22 +0200450 dev_queue_xmit(skb);
451 }
452
453 return sent;
454}
455
456static ieee80211_txrx_result
457ieee80211_rx_h_sta_process(struct ieee80211_txrx_data *rx)
458{
459 struct sta_info *sta = rx->sta;
460 struct net_device *dev = rx->dev;
461 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
462
463 if (!sta)
464 return TXRX_CONTINUE;
465
466 /* Update last_rx only for IBSS packets which are for the current
467 * BSSID to avoid keeping the current IBSS network alive in cases where
468 * other STAs are using different BSSID. */
469 if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
470 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
471 if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
472 sta->last_rx = jiffies;
473 } else
474 if (!is_multicast_ether_addr(hdr->addr1) ||
475 rx->sdata->type == IEEE80211_IF_TYPE_STA) {
476 /* Update last_rx only for unicast frames in order to prevent
477 * the Probe Request frames (the only broadcast frames from a
478 * STA in infrastructure mode) from keeping a connection alive.
479 */
480 sta->last_rx = jiffies;
481 }
482
Jiri Slabybadffb72007-08-28 17:01:54 -0400483 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +0200484 return TXRX_CONTINUE;
485
486 sta->rx_fragments++;
487 sta->rx_bytes += rx->skb->len;
488 sta->last_rssi = (sta->last_rssi * 15 +
489 rx->u.rx.status->ssi) / 16;
490 sta->last_signal = (sta->last_signal * 15 +
491 rx->u.rx.status->signal) / 16;
492 sta->last_noise = (sta->last_noise * 15 +
493 rx->u.rx.status->noise) / 16;
494
495 if (!(rx->fc & IEEE80211_FCTL_MOREFRAGS)) {
496 /* Change STA power saving mode only in the end of a frame
497 * exchange sequence */
498 if ((sta->flags & WLAN_STA_PS) && !(rx->fc & IEEE80211_FCTL_PM))
499 rx->u.rx.sent_ps_buffered += ap_sta_ps_end(dev, sta);
500 else if (!(sta->flags & WLAN_STA_PS) &&
501 (rx->fc & IEEE80211_FCTL_PM))
502 ap_sta_ps_start(dev, sta);
503 }
504
505 /* Drop data::nullfunc frames silently, since they are used only to
506 * control station power saving mode. */
507 if ((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
508 (rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_NULLFUNC) {
509 I802_DEBUG_INC(rx->local->rx_handlers_drop_nullfunc);
510 /* Update counter and free packet here to avoid counting this
511 * as a dropped packed. */
512 sta->rx_packets++;
513 dev_kfree_skb(rx->skb);
514 return TXRX_QUEUED;
515 }
516
517 return TXRX_CONTINUE;
518} /* ieee80211_rx_h_sta_process */
519
520static ieee80211_txrx_result
521ieee80211_rx_h_wep_weak_iv_detection(struct ieee80211_txrx_data *rx)
522{
523 if (!rx->sta || !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
524 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
Jiri Slabybadffb72007-08-28 17:01:54 -0400525 !rx->key || rx->key->alg != ALG_WEP ||
526 !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +0200527 return TXRX_CONTINUE;
528
529 /* Check for weak IVs, if hwaccel did not remove IV from the frame */
530 if ((rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) ||
531 rx->key->force_sw_encrypt) {
532 u8 *iv = ieee80211_wep_is_weak_iv(rx->skb, rx->key);
533 if (iv) {
534 rx->sta->wep_weak_iv_count++;
535 }
536 }
537
538 return TXRX_CONTINUE;
539}
540
541static ieee80211_txrx_result
542ieee80211_rx_h_wep_decrypt(struct ieee80211_txrx_data *rx)
543{
Johannes Berg571ecf62007-07-27 15:43:22 +0200544 if ((rx->key && rx->key->alg != ALG_WEP) ||
545 !(rx->fc & IEEE80211_FCTL_PROTECTED) ||
546 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
547 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
548 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)))
549 return TXRX_CONTINUE;
550
551 if (!rx->key) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400552 if (net_ratelimit())
553 printk(KERN_DEBUG "%s: RX WEP frame, but no key set\n",
554 rx->dev->name);
Johannes Berg571ecf62007-07-27 15:43:22 +0200555 return TXRX_DROP;
556 }
557
558 if (!(rx->u.rx.status->flag & RX_FLAG_DECRYPTED) ||
559 rx->key->force_sw_encrypt) {
560 if (ieee80211_wep_decrypt(rx->local, rx->skb, rx->key)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400561 if (net_ratelimit())
562 printk(KERN_DEBUG "%s: RX WEP frame, decrypt "
563 "failed\n", rx->dev->name);
Johannes Berg571ecf62007-07-27 15:43:22 +0200564 return TXRX_DROP;
565 }
566 } else if (rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) {
567 ieee80211_wep_remove_iv(rx->local, rx->skb, rx->key);
568 /* remove ICV */
569 skb_trim(rx->skb, rx->skb->len - 4);
570 }
571
572 return TXRX_CONTINUE;
573}
574
575static inline struct ieee80211_fragment_entry *
576ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
577 unsigned int frag, unsigned int seq, int rx_queue,
578 struct sk_buff **skb)
579{
580 struct ieee80211_fragment_entry *entry;
581 int idx;
582
583 idx = sdata->fragment_next;
584 entry = &sdata->fragments[sdata->fragment_next++];
585 if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
586 sdata->fragment_next = 0;
587
588 if (!skb_queue_empty(&entry->skb_list)) {
589#ifdef CONFIG_MAC80211_DEBUG
590 struct ieee80211_hdr *hdr =
591 (struct ieee80211_hdr *) entry->skb_list.next->data;
592 printk(KERN_DEBUG "%s: RX reassembly removed oldest "
593 "fragment entry (idx=%d age=%lu seq=%d last_frag=%d "
594 "addr1=" MAC_FMT " addr2=" MAC_FMT "\n",
595 sdata->dev->name, idx,
596 jiffies - entry->first_frag_time, entry->seq,
597 entry->last_frag, MAC_ARG(hdr->addr1),
598 MAC_ARG(hdr->addr2));
599#endif /* CONFIG_MAC80211_DEBUG */
600 __skb_queue_purge(&entry->skb_list);
601 }
602
603 __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */
604 *skb = NULL;
605 entry->first_frag_time = jiffies;
606 entry->seq = seq;
607 entry->rx_queue = rx_queue;
608 entry->last_frag = frag;
609 entry->ccmp = 0;
610 entry->extra_len = 0;
611
612 return entry;
613}
614
615static inline struct ieee80211_fragment_entry *
616ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
617 u16 fc, unsigned int frag, unsigned int seq,
618 int rx_queue, struct ieee80211_hdr *hdr)
619{
620 struct ieee80211_fragment_entry *entry;
621 int i, idx;
622
623 idx = sdata->fragment_next;
624 for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
625 struct ieee80211_hdr *f_hdr;
626 u16 f_fc;
627
628 idx--;
629 if (idx < 0)
630 idx = IEEE80211_FRAGMENT_MAX - 1;
631
632 entry = &sdata->fragments[idx];
633 if (skb_queue_empty(&entry->skb_list) || entry->seq != seq ||
634 entry->rx_queue != rx_queue ||
635 entry->last_frag + 1 != frag)
636 continue;
637
638 f_hdr = (struct ieee80211_hdr *) entry->skb_list.next->data;
639 f_fc = le16_to_cpu(f_hdr->frame_control);
640
641 if ((fc & IEEE80211_FCTL_FTYPE) != (f_fc & IEEE80211_FCTL_FTYPE) ||
642 compare_ether_addr(hdr->addr1, f_hdr->addr1) != 0 ||
643 compare_ether_addr(hdr->addr2, f_hdr->addr2) != 0)
644 continue;
645
646 if (entry->first_frag_time + 2 * HZ < jiffies) {
647 __skb_queue_purge(&entry->skb_list);
648 continue;
649 }
650 return entry;
651 }
652
653 return NULL;
654}
655
656static ieee80211_txrx_result
657ieee80211_rx_h_defragment(struct ieee80211_txrx_data *rx)
658{
659 struct ieee80211_hdr *hdr;
660 u16 sc;
661 unsigned int frag, seq;
662 struct ieee80211_fragment_entry *entry;
663 struct sk_buff *skb;
664
665 hdr = (struct ieee80211_hdr *) rx->skb->data;
666 sc = le16_to_cpu(hdr->seq_ctrl);
667 frag = sc & IEEE80211_SCTL_FRAG;
668
669 if (likely((!(rx->fc & IEEE80211_FCTL_MOREFRAGS) && frag == 0) ||
670 (rx->skb)->len < 24 ||
671 is_multicast_ether_addr(hdr->addr1))) {
672 /* not fragmented */
673 goto out;
674 }
675 I802_DEBUG_INC(rx->local->rx_handlers_fragments);
676
677 seq = (sc & IEEE80211_SCTL_SEQ) >> 4;
678
679 if (frag == 0) {
680 /* This is the first fragment of a new frame. */
681 entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
682 rx->u.rx.queue, &(rx->skb));
683 if (rx->key && rx->key->alg == ALG_CCMP &&
684 (rx->fc & IEEE80211_FCTL_PROTECTED)) {
685 /* Store CCMP PN so that we can verify that the next
686 * fragment has a sequential PN value. */
687 entry->ccmp = 1;
688 memcpy(entry->last_pn,
689 rx->key->u.ccmp.rx_pn[rx->u.rx.queue],
690 CCMP_PN_LEN);
691 }
692 return TXRX_QUEUED;
693 }
694
695 /* This is a fragment for a frame that should already be pending in
696 * fragment cache. Add this fragment to the end of the pending entry.
697 */
698 entry = ieee80211_reassemble_find(rx->sdata, rx->fc, frag, seq,
699 rx->u.rx.queue, hdr);
700 if (!entry) {
701 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
702 return TXRX_DROP;
703 }
704
705 /* Verify that MPDUs within one MSDU have sequential PN values.
706 * (IEEE 802.11i, 8.3.3.4.5) */
707 if (entry->ccmp) {
708 int i;
709 u8 pn[CCMP_PN_LEN], *rpn;
710 if (!rx->key || rx->key->alg != ALG_CCMP)
711 return TXRX_DROP;
712 memcpy(pn, entry->last_pn, CCMP_PN_LEN);
713 for (i = CCMP_PN_LEN - 1; i >= 0; i--) {
714 pn[i]++;
715 if (pn[i])
716 break;
717 }
718 rpn = rx->key->u.ccmp.rx_pn[rx->u.rx.queue];
719 if (memcmp(pn, rpn, CCMP_PN_LEN) != 0) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400720 if (net_ratelimit())
721 printk(KERN_DEBUG "%s: defrag: CCMP PN not "
722 "sequential A2=" MAC_FMT
723 " PN=%02x%02x%02x%02x%02x%02x "
724 "(expected %02x%02x%02x%02x%02x%02x)\n",
725 rx->dev->name, MAC_ARG(hdr->addr2),
726 rpn[0], rpn[1], rpn[2], rpn[3], rpn[4],
727 rpn[5], pn[0], pn[1], pn[2], pn[3],
728 pn[4], pn[5]);
Johannes Berg571ecf62007-07-27 15:43:22 +0200729 return TXRX_DROP;
730 }
731 memcpy(entry->last_pn, pn, CCMP_PN_LEN);
732 }
733
734 skb_pull(rx->skb, ieee80211_get_hdrlen(rx->fc));
735 __skb_queue_tail(&entry->skb_list, rx->skb);
736 entry->last_frag = frag;
737 entry->extra_len += rx->skb->len;
738 if (rx->fc & IEEE80211_FCTL_MOREFRAGS) {
739 rx->skb = NULL;
740 return TXRX_QUEUED;
741 }
742
743 rx->skb = __skb_dequeue(&entry->skb_list);
744 if (skb_tailroom(rx->skb) < entry->extra_len) {
745 I802_DEBUG_INC(rx->local->rx_expand_skb_head2);
746 if (unlikely(pskb_expand_head(rx->skb, 0, entry->extra_len,
747 GFP_ATOMIC))) {
748 I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
749 __skb_queue_purge(&entry->skb_list);
750 return TXRX_DROP;
751 }
752 }
753 while ((skb = __skb_dequeue(&entry->skb_list))) {
754 memcpy(skb_put(rx->skb, skb->len), skb->data, skb->len);
755 dev_kfree_skb(skb);
756 }
757
758 /* Complete frame has been reassembled - process it now */
Jiri Slabybadffb72007-08-28 17:01:54 -0400759 rx->flags |= IEEE80211_TXRXD_FRAGMENTED;
Johannes Berg571ecf62007-07-27 15:43:22 +0200760
761 out:
762 if (rx->sta)
763 rx->sta->rx_packets++;
764 if (is_multicast_ether_addr(hdr->addr1))
765 rx->local->dot11MulticastReceivedFrameCount++;
766 else
767 ieee80211_led_rx(rx->local);
768 return TXRX_CONTINUE;
769}
770
771static ieee80211_txrx_result
772ieee80211_rx_h_ps_poll(struct ieee80211_txrx_data *rx)
773{
774 struct sk_buff *skb;
775 int no_pending_pkts;
776
777 if (likely(!rx->sta ||
778 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_CTL ||
779 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_PSPOLL ||
Jiri Slabybadffb72007-08-28 17:01:54 -0400780 !(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)))
Johannes Berg571ecf62007-07-27 15:43:22 +0200781 return TXRX_CONTINUE;
782
783 skb = skb_dequeue(&rx->sta->tx_filtered);
784 if (!skb) {
785 skb = skb_dequeue(&rx->sta->ps_tx_buf);
786 if (skb)
787 rx->local->total_ps_buffered--;
788 }
789 no_pending_pkts = skb_queue_empty(&rx->sta->tx_filtered) &&
790 skb_queue_empty(&rx->sta->ps_tx_buf);
791
792 if (skb) {
793 struct ieee80211_hdr *hdr =
794 (struct ieee80211_hdr *) skb->data;
795
796 /* tell TX path to send one frame even though the STA may
797 * still remain is PS mode after this frame exchange */
798 rx->sta->pspoll = 1;
799
800#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
801 printk(KERN_DEBUG "STA " MAC_FMT " aid %d: PS Poll (entries "
802 "after %d)\n",
803 MAC_ARG(rx->sta->addr), rx->sta->aid,
804 skb_queue_len(&rx->sta->ps_tx_buf));
805#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
806
807 /* Use MoreData flag to indicate whether there are more
808 * buffered frames for this STA */
809 if (no_pending_pkts) {
810 hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_MOREDATA);
811 rx->sta->flags &= ~WLAN_STA_TIM;
812 } else
813 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
814
815 dev_queue_xmit(skb);
816
817 if (no_pending_pkts) {
818 if (rx->local->ops->set_tim)
819 rx->local->ops->set_tim(local_to_hw(rx->local),
820 rx->sta->aid, 0);
821 if (rx->sdata->bss)
822 bss_tim_clear(rx->local, rx->sdata->bss, rx->sta->aid);
823 }
824#ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG
825 } else if (!rx->u.rx.sent_ps_buffered) {
826 printk(KERN_DEBUG "%s: STA " MAC_FMT " sent PS Poll even "
827 "though there is no buffered frames for it\n",
828 rx->dev->name, MAC_ARG(rx->sta->addr));
829#endif /* CONFIG_MAC80211_VERBOSE_PS_DEBUG */
830
831 }
832
833 /* Free PS Poll skb here instead of returning TXRX_DROP that would
834 * count as an dropped frame. */
835 dev_kfree_skb(rx->skb);
836
837 return TXRX_QUEUED;
838}
839
840static ieee80211_txrx_result
Johannes Berg6e0d1142007-07-27 15:43:22 +0200841ieee80211_rx_h_remove_qos_control(struct ieee80211_txrx_data *rx)
842{
843 u16 fc = rx->fc;
844 u8 *data = rx->skb->data;
845 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) data;
846
847 if (!WLAN_FC_IS_QOS_DATA(fc))
848 return TXRX_CONTINUE;
849
850 /* remove the qos control field, update frame type and meta-data */
851 memmove(data + 2, data, ieee80211_get_hdrlen(fc) - 2);
852 hdr = (struct ieee80211_hdr *) skb_pull(rx->skb, 2);
853 /* change frame type to non QOS */
854 rx->fc = fc &= ~IEEE80211_STYPE_QOS_DATA;
855 hdr->frame_control = cpu_to_le16(fc);
856
857 return TXRX_CONTINUE;
858}
859
860static ieee80211_txrx_result
Johannes Berg571ecf62007-07-27 15:43:22 +0200861ieee80211_rx_h_802_1x_pae(struct ieee80211_txrx_data *rx)
862{
863 if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb) &&
Jiri Slabybadffb72007-08-28 17:01:54 -0400864 rx->sdata->type != IEEE80211_IF_TYPE_STA &&
865 (rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
Johannes Berg571ecf62007-07-27 15:43:22 +0200866 /* Pass both encrypted and unencrypted EAPOL frames to user
867 * space for processing. */
868 if (!rx->local->apdev)
869 return TXRX_DROP;
870 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
871 ieee80211_msg_normal);
872 return TXRX_QUEUED;
873 }
874
875 if (unlikely(rx->sdata->ieee802_1x &&
876 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
877 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
878 (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)) &&
879 !ieee80211_is_eapol(rx->skb))) {
880#ifdef CONFIG_MAC80211_DEBUG
881 struct ieee80211_hdr *hdr =
882 (struct ieee80211_hdr *) rx->skb->data;
883 printk(KERN_DEBUG "%s: dropped frame from " MAC_FMT
884 " (unauthorized port)\n", rx->dev->name,
885 MAC_ARG(hdr->addr2));
886#endif /* CONFIG_MAC80211_DEBUG */
887 return TXRX_DROP;
888 }
889
890 return TXRX_CONTINUE;
891}
892
893static ieee80211_txrx_result
894ieee80211_rx_h_drop_unencrypted(struct ieee80211_txrx_data *rx)
895{
Johannes Berg3017b802007-08-28 17:01:53 -0400896 /*
897 * Pass through unencrypted frames if the hardware might have
898 * decrypted them already without telling us, but that can only
899 * be true if we either didn't find a key or the found key is
900 * uploaded to the hardware.
901 */
902 if ((rx->local->hw.flags & IEEE80211_HW_DEVICE_HIDES_WEP) &&
903 (!rx->key || !rx->key->force_sw_encrypt))
Johannes Berg571ecf62007-07-27 15:43:22 +0200904 return TXRX_CONTINUE;
905
906 /* Drop unencrypted frames if key is set. */
907 if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
908 (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
909 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
910 (rx->key || rx->sdata->drop_unencrypted) &&
911 (rx->sdata->eapol == 0 ||
912 !ieee80211_is_eapol(rx->skb)))) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400913 if (net_ratelimit())
914 printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
915 "encryption\n", rx->dev->name);
Johannes Berg571ecf62007-07-27 15:43:22 +0200916 return TXRX_DROP;
917 }
918 return TXRX_CONTINUE;
919}
920
921static ieee80211_txrx_result
922ieee80211_rx_h_data(struct ieee80211_txrx_data *rx)
923{
924 struct net_device *dev = rx->dev;
925 struct ieee80211_local *local = rx->local;
926 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;
927 u16 fc, hdrlen, ethertype;
928 u8 *payload;
929 u8 dst[ETH_ALEN];
930 u8 src[ETH_ALEN];
931 struct sk_buff *skb = rx->skb, *skb2;
932 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
933
934 fc = rx->fc;
935 if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
936 return TXRX_CONTINUE;
937
938 if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
939 return TXRX_DROP;
940
941 hdrlen = ieee80211_get_hdrlen(fc);
942
943 /* convert IEEE 802.11 header + possible LLC headers into Ethernet
944 * header
945 * IEEE 802.11 address fields:
946 * ToDS FromDS Addr1 Addr2 Addr3 Addr4
947 * 0 0 DA SA BSSID n/a
948 * 0 1 DA BSSID SA n/a
949 * 1 0 BSSID SA DA n/a
950 * 1 1 RA TA DA SA
951 */
952
953 switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) {
954 case IEEE80211_FCTL_TODS:
955 /* BSSID SA DA */
956 memcpy(dst, hdr->addr3, ETH_ALEN);
957 memcpy(src, hdr->addr2, ETH_ALEN);
958
959 if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP &&
960 sdata->type != IEEE80211_IF_TYPE_VLAN)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400961 if (net_ratelimit())
962 printk(KERN_DEBUG "%s: dropped ToDS frame "
963 "(BSSID=" MAC_FMT
964 " SA=" MAC_FMT
965 " DA=" MAC_FMT ")\n",
966 dev->name,
967 MAC_ARG(hdr->addr1),
968 MAC_ARG(hdr->addr2),
969 MAC_ARG(hdr->addr3));
Johannes Berg571ecf62007-07-27 15:43:22 +0200970 return TXRX_DROP;
971 }
972 break;
973 case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS):
974 /* RA TA DA SA */
975 memcpy(dst, hdr->addr3, ETH_ALEN);
976 memcpy(src, hdr->addr4, ETH_ALEN);
977
978 if (unlikely(sdata->type != IEEE80211_IF_TYPE_WDS)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -0400979 if (net_ratelimit())
980 printk(KERN_DEBUG "%s: dropped FromDS&ToDS "
981 "frame (RA=" MAC_FMT
982 " TA=" MAC_FMT " DA=" MAC_FMT
983 " SA=" MAC_FMT ")\n",
984 rx->dev->name,
985 MAC_ARG(hdr->addr1),
986 MAC_ARG(hdr->addr2),
987 MAC_ARG(hdr->addr3),
988 MAC_ARG(hdr->addr4));
Johannes Berg571ecf62007-07-27 15:43:22 +0200989 return TXRX_DROP;
990 }
991 break;
992 case IEEE80211_FCTL_FROMDS:
993 /* DA BSSID SA */
994 memcpy(dst, hdr->addr1, ETH_ALEN);
995 memcpy(src, hdr->addr3, ETH_ALEN);
996
997 if (sdata->type != IEEE80211_IF_TYPE_STA) {
998 return TXRX_DROP;
999 }
1000 break;
1001 case 0:
1002 /* DA SA BSSID */
1003 memcpy(dst, hdr->addr1, ETH_ALEN);
1004 memcpy(src, hdr->addr2, ETH_ALEN);
1005
1006 if (sdata->type != IEEE80211_IF_TYPE_IBSS) {
1007 if (net_ratelimit()) {
1008 printk(KERN_DEBUG "%s: dropped IBSS frame (DA="
1009 MAC_FMT " SA=" MAC_FMT " BSSID=" MAC_FMT
1010 ")\n",
1011 dev->name, MAC_ARG(hdr->addr1),
1012 MAC_ARG(hdr->addr2),
1013 MAC_ARG(hdr->addr3));
1014 }
1015 return TXRX_DROP;
1016 }
1017 break;
1018 }
1019
1020 payload = skb->data + hdrlen;
1021
1022 if (unlikely(skb->len - hdrlen < 8)) {
1023 if (net_ratelimit()) {
1024 printk(KERN_DEBUG "%s: RX too short data frame "
1025 "payload\n", dev->name);
1026 }
1027 return TXRX_DROP;
1028 }
1029
1030 ethertype = (payload[6] << 8) | payload[7];
1031
1032 if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
1033 ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
1034 compare_ether_addr(payload, bridge_tunnel_header) == 0)) {
1035 /* remove RFC1042 or Bridge-Tunnel encapsulation and
1036 * replace EtherType */
1037 skb_pull(skb, hdrlen + 6);
1038 memcpy(skb_push(skb, ETH_ALEN), src, ETH_ALEN);
1039 memcpy(skb_push(skb, ETH_ALEN), dst, ETH_ALEN);
1040 } else {
1041 struct ethhdr *ehdr;
1042 __be16 len;
1043 skb_pull(skb, hdrlen);
1044 len = htons(skb->len);
1045 ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
1046 memcpy(ehdr->h_dest, dst, ETH_ALEN);
1047 memcpy(ehdr->h_source, src, ETH_ALEN);
1048 ehdr->h_proto = len;
1049 }
1050 skb->dev = dev;
1051
1052 skb2 = NULL;
1053
1054 sdata->stats.rx_packets++;
1055 sdata->stats.rx_bytes += skb->len;
1056
1057 if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP
Jiri Slabybadffb72007-08-28 17:01:54 -04001058 || sdata->type == IEEE80211_IF_TYPE_VLAN) &&
1059 (rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
Johannes Berg571ecf62007-07-27 15:43:22 +02001060 if (is_multicast_ether_addr(skb->data)) {
1061 /* send multicast frames both to higher layers in
1062 * local net stack and back to the wireless media */
1063 skb2 = skb_copy(skb, GFP_ATOMIC);
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001064 if (!skb2 && net_ratelimit())
Johannes Berg571ecf62007-07-27 15:43:22 +02001065 printk(KERN_DEBUG "%s: failed to clone "
1066 "multicast frame\n", dev->name);
1067 } else {
1068 struct sta_info *dsta;
1069 dsta = sta_info_get(local, skb->data);
1070 if (dsta && !dsta->dev) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001071 if (net_ratelimit())
1072 printk(KERN_DEBUG "Station with null "
1073 "dev structure!\n");
Johannes Berg571ecf62007-07-27 15:43:22 +02001074 } else if (dsta && dsta->dev == dev) {
1075 /* Destination station is associated to this
1076 * AP, so send the frame directly to it and
1077 * do not pass the frame to local net stack.
1078 */
1079 skb2 = skb;
1080 skb = NULL;
1081 }
1082 if (dsta)
1083 sta_info_put(dsta);
1084 }
1085 }
1086
1087 if (skb) {
1088 /* deliver to local stack */
1089 skb->protocol = eth_type_trans(skb, dev);
1090 memset(skb->cb, 0, sizeof(skb->cb));
1091 netif_rx(skb);
1092 }
1093
1094 if (skb2) {
1095 /* send to wireless media */
1096 skb2->protocol = __constant_htons(ETH_P_802_3);
1097 skb_set_network_header(skb2, 0);
1098 skb_set_mac_header(skb2, 0);
1099 dev_queue_xmit(skb2);
1100 }
1101
1102 return TXRX_QUEUED;
1103}
1104
1105static ieee80211_txrx_result
1106ieee80211_rx_h_mgmt(struct ieee80211_txrx_data *rx)
1107{
1108 struct ieee80211_sub_if_data *sdata;
1109
Jiri Slabybadffb72007-08-28 17:01:54 -04001110 if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
Johannes Berg571ecf62007-07-27 15:43:22 +02001111 return TXRX_DROP;
1112
1113 sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
1114 if ((sdata->type == IEEE80211_IF_TYPE_STA ||
1115 sdata->type == IEEE80211_IF_TYPE_IBSS) &&
1116 !rx->local->user_space_mlme) {
1117 ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
1118 } else {
1119 /* Management frames are sent to hostapd for processing */
1120 if (!rx->local->apdev)
1121 return TXRX_DROP;
1122 ieee80211_rx_mgmt(rx->local, rx->skb, rx->u.rx.status,
1123 ieee80211_msg_normal);
1124 }
1125 return TXRX_QUEUED;
1126}
1127
1128static inline ieee80211_txrx_result __ieee80211_invoke_rx_handlers(
1129 struct ieee80211_local *local,
1130 ieee80211_rx_handler *handlers,
1131 struct ieee80211_txrx_data *rx,
1132 struct sta_info *sta)
1133{
1134 ieee80211_rx_handler *handler;
1135 ieee80211_txrx_result res = TXRX_DROP;
1136
1137 for (handler = handlers; *handler != NULL; handler++) {
1138 res = (*handler)(rx);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001139
1140 switch (res) {
1141 case TXRX_CONTINUE:
1142 continue;
1143 case TXRX_DROP:
1144 I802_DEBUG_INC(local->rx_handlers_drop);
1145 if (sta)
1146 sta->rx_dropped++;
1147 break;
1148 case TXRX_QUEUED:
1149 I802_DEBUG_INC(local->rx_handlers_queued);
Johannes Berg571ecf62007-07-27 15:43:22 +02001150 break;
1151 }
Johannes Berg8e6f0032007-07-27 15:43:22 +02001152 break;
Johannes Berg571ecf62007-07-27 15:43:22 +02001153 }
1154
Johannes Berg8e6f0032007-07-27 15:43:22 +02001155 if (res == TXRX_DROP)
Johannes Berg571ecf62007-07-27 15:43:22 +02001156 dev_kfree_skb(rx->skb);
Johannes Berg571ecf62007-07-27 15:43:22 +02001157 return res;
1158}
1159
1160static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local *local,
1161 ieee80211_rx_handler *handlers,
1162 struct ieee80211_txrx_data *rx,
1163 struct sta_info *sta)
1164{
1165 if (__ieee80211_invoke_rx_handlers(local, handlers, rx, sta) ==
1166 TXRX_CONTINUE)
1167 dev_kfree_skb(rx->skb);
1168}
1169
1170static void ieee80211_rx_michael_mic_report(struct net_device *dev,
1171 struct ieee80211_hdr *hdr,
1172 struct sta_info *sta,
1173 struct ieee80211_txrx_data *rx)
1174{
1175 int keyidx, hdrlen;
1176
1177 hdrlen = ieee80211_get_hdrlen_from_skb(rx->skb);
1178 if (rx->skb->len >= hdrlen + 4)
1179 keyidx = rx->skb->data[hdrlen + 3] >> 6;
1180 else
1181 keyidx = -1;
1182
1183 /* TODO: verify that this is not triggered by fragmented
1184 * frames (hw does not verify MIC for them). */
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001185 if (net_ratelimit())
1186 printk(KERN_DEBUG "%s: TKIP hwaccel reported Michael MIC "
1187 "failure from " MAC_FMT " to " MAC_FMT " keyidx=%d\n",
1188 dev->name, MAC_ARG(hdr->addr2), MAC_ARG(hdr->addr1),
1189 keyidx);
Johannes Berg571ecf62007-07-27 15:43:22 +02001190
1191 if (!sta) {
1192 /* Some hardware versions seem to generate incorrect
1193 * Michael MIC reports; ignore them to avoid triggering
1194 * countermeasures. */
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001195 if (net_ratelimit())
1196 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1197 "error for unknown address " MAC_FMT "\n",
1198 dev->name, MAC_ARG(hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001199 goto ignore;
1200 }
1201
1202 if (!(rx->fc & IEEE80211_FCTL_PROTECTED)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001203 if (net_ratelimit())
1204 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1205 "error for a frame with no ISWEP flag (src "
1206 MAC_FMT ")\n", dev->name, MAC_ARG(hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001207 goto ignore;
1208 }
1209
1210 if ((rx->local->hw.flags & IEEE80211_HW_WEP_INCLUDE_IV) &&
Johannes Bergeb063c12007-08-28 17:01:53 -04001211 rx->sdata->type == IEEE80211_IF_TYPE_AP && keyidx) {
Johannes Berg571ecf62007-07-27 15:43:22 +02001212 /* AP with Pairwise keys support should never receive Michael
1213 * MIC errors for non-zero keyidx because these are reserved
1214 * for group keys and only the AP is sending real multicast
1215 * frames in BSS. */
Johannes Bergeb063c12007-08-28 17:01:53 -04001216 if (net_ratelimit())
1217 printk(KERN_DEBUG "%s: ignored Michael MIC error for "
1218 "a frame with non-zero keyidx (%d)"
1219 " (src " MAC_FMT ")\n", dev->name, keyidx,
1220 MAC_ARG(hdr->addr2));
1221 goto ignore;
Johannes Berg571ecf62007-07-27 15:43:22 +02001222 }
1223
1224 if ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA &&
1225 ((rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_MGMT ||
1226 (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_AUTH)) {
Johannes Berg1a84f3f2007-08-28 17:01:52 -04001227 if (net_ratelimit())
1228 printk(KERN_DEBUG "%s: ignored spurious Michael MIC "
1229 "error for a frame that cannot be encrypted "
1230 "(fc=0x%04x) (src " MAC_FMT ")\n",
1231 dev->name, rx->fc, MAC_ARG(hdr->addr2));
Johannes Berg571ecf62007-07-27 15:43:22 +02001232 goto ignore;
1233 }
1234
Johannes Berg571ecf62007-07-27 15:43:22 +02001235 /* TODO: consider verifying the MIC error report with software
1236 * implementation if we get too many spurious reports from the
1237 * hardware. */
Johannes Berg571ecf62007-07-27 15:43:22 +02001238
Johannes Bergeb063c12007-08-28 17:01:53 -04001239 mac80211_ev_michael_mic_failure(rx->dev, keyidx, hdr);
Johannes Berg571ecf62007-07-27 15:43:22 +02001240 ignore:
1241 dev_kfree_skb(rx->skb);
1242 rx->skb = NULL;
1243}
1244
1245ieee80211_rx_handler ieee80211_rx_handlers[] =
1246{
1247 ieee80211_rx_h_if_stats,
1248 ieee80211_rx_h_monitor,
1249 ieee80211_rx_h_passive_scan,
1250 ieee80211_rx_h_check,
Johannes Berg570bd532007-07-27 15:43:22 +02001251 ieee80211_rx_h_load_key,
Johannes Berg571ecf62007-07-27 15:43:22 +02001252 ieee80211_rx_h_sta_process,
1253 ieee80211_rx_h_ccmp_decrypt,
1254 ieee80211_rx_h_tkip_decrypt,
1255 ieee80211_rx_h_wep_weak_iv_detection,
1256 ieee80211_rx_h_wep_decrypt,
1257 ieee80211_rx_h_defragment,
1258 ieee80211_rx_h_ps_poll,
1259 ieee80211_rx_h_michael_mic_verify,
1260 /* this must be after decryption - so header is counted in MPDU mic
1261 * must be before pae and data, so QOS_DATA format frames
1262 * are not passed to user space by these functions
1263 */
1264 ieee80211_rx_h_remove_qos_control,
1265 ieee80211_rx_h_802_1x_pae,
1266 ieee80211_rx_h_drop_unencrypted,
1267 ieee80211_rx_h_data,
1268 ieee80211_rx_h_mgmt,
1269 NULL
1270};
1271
1272/* main receive path */
1273
Johannes Berg23a24de2007-07-27 15:43:22 +02001274static int prepare_for_handlers(struct ieee80211_sub_if_data *sdata,
1275 u8 *bssid, struct ieee80211_txrx_data *rx,
1276 struct ieee80211_hdr *hdr)
1277{
1278 int multicast = is_multicast_ether_addr(hdr->addr1);
1279
1280 switch (sdata->type) {
1281 case IEEE80211_IF_TYPE_STA:
1282 if (!bssid)
1283 return 0;
1284 if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001285 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001286 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001287 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001288 } else if (!multicast &&
1289 compare_ether_addr(sdata->dev->dev_addr,
1290 hdr->addr1) != 0) {
1291 if (!sdata->promisc)
1292 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001293 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001294 }
1295 break;
1296 case IEEE80211_IF_TYPE_IBSS:
1297 if (!bssid)
1298 return 0;
1299 if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001300 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001301 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001302 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001303 } else if (!multicast &&
1304 compare_ether_addr(sdata->dev->dev_addr,
1305 hdr->addr1) != 0) {
1306 if (!sdata->promisc)
1307 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001308 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001309 } else if (!rx->sta)
1310 rx->sta = ieee80211_ibss_add_sta(sdata->dev, rx->skb,
1311 bssid, hdr->addr2);
1312 break;
1313 case IEEE80211_IF_TYPE_AP:
1314 if (!bssid) {
1315 if (compare_ether_addr(sdata->dev->dev_addr,
1316 hdr->addr1))
1317 return 0;
1318 } else if (!ieee80211_bssid_match(bssid,
1319 sdata->dev->dev_addr)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001320 if (!(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001321 return 0;
Jiri Slabybadffb72007-08-28 17:01:54 -04001322 rx->flags &= ~IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001323 }
Jiri Slabybadffb72007-08-28 17:01:54 -04001324 if (sdata->dev == sdata->local->mdev &&
1325 !(rx->flags & IEEE80211_TXRXD_RXIN_SCAN))
Johannes Berg23a24de2007-07-27 15:43:22 +02001326 /* do not receive anything via
1327 * master device when not scanning */
1328 return 0;
1329 break;
1330 case IEEE80211_IF_TYPE_WDS:
1331 if (bssid ||
1332 (rx->fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA)
1333 return 0;
1334 if (compare_ether_addr(sdata->u.wds.remote_addr, hdr->addr2))
1335 return 0;
1336 break;
1337 }
1338
1339 return 1;
1340}
1341
Johannes Berg571ecf62007-07-27 15:43:22 +02001342/*
1343 * This is the receive path handler. It is called by a low level driver when an
1344 * 802.11 MPDU is received from the hardware.
1345 */
1346void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
1347 struct ieee80211_rx_status *status)
1348{
1349 struct ieee80211_local *local = hw_to_local(hw);
1350 struct ieee80211_sub_if_data *sdata;
1351 struct sta_info *sta;
1352 struct ieee80211_hdr *hdr;
1353 struct ieee80211_txrx_data rx;
1354 u16 type;
Johannes Berg23a24de2007-07-27 15:43:22 +02001355 int radiotap_len = 0, prepres;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001356 struct ieee80211_sub_if_data *prev = NULL;
1357 struct sk_buff *skb_new;
1358 u8 *bssid;
Johannes Berg571ecf62007-07-27 15:43:22 +02001359
1360 if (status->flag & RX_FLAG_RADIOTAP) {
1361 radiotap_len = ieee80211_get_radiotap_len(skb->data);
1362 skb_pull(skb, radiotap_len);
1363 }
1364
1365 hdr = (struct ieee80211_hdr *) skb->data;
1366 memset(&rx, 0, sizeof(rx));
1367 rx.skb = skb;
1368 rx.local = local;
1369
1370 rx.u.rx.status = status;
1371 rx.fc = skb->len >= 2 ? le16_to_cpu(hdr->frame_control) : 0;
1372 type = rx.fc & IEEE80211_FCTL_FTYPE;
1373 if (type == IEEE80211_FTYPE_DATA || type == IEEE80211_FTYPE_MGMT)
1374 local->dot11ReceivedFragmentCount++;
Johannes Berg571ecf62007-07-27 15:43:22 +02001375
Johannes Berg23a24de2007-07-27 15:43:22 +02001376 if (skb->len >= 16) {
Johannes Berg571ecf62007-07-27 15:43:22 +02001377 sta = rx.sta = sta_info_get(local, hdr->addr2);
Johannes Berg23a24de2007-07-27 15:43:22 +02001378 if (sta) {
1379 rx.dev = rx.sta->dev;
1380 rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
1381 }
1382 } else
Johannes Berg571ecf62007-07-27 15:43:22 +02001383 sta = rx.sta = NULL;
1384
Johannes Berg571ecf62007-07-27 15:43:22 +02001385 if ((status->flag & RX_FLAG_MMIC_ERROR)) {
1386 ieee80211_rx_michael_mic_report(local->mdev, hdr, sta, &rx);
1387 goto end;
1388 }
1389
1390 if (unlikely(local->sta_scanning))
Jiri Slabybadffb72007-08-28 17:01:54 -04001391 rx.flags |= IEEE80211_TXRXD_RXIN_SCAN;
Johannes Berg571ecf62007-07-27 15:43:22 +02001392
1393 if (__ieee80211_invoke_rx_handlers(local, local->rx_pre_handlers, &rx,
1394 sta) != TXRX_CONTINUE)
1395 goto end;
1396 skb = rx.skb;
1397
1398 skb_push(skb, radiotap_len);
1399 if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) &&
Johannes Berg23a24de2007-07-27 15:43:22 +02001400 !local->iff_promiscs && !is_multicast_ether_addr(hdr->addr1)) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001401 rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg571ecf62007-07-27 15:43:22 +02001402 ieee80211_invoke_rx_handlers(local, local->rx_handlers, &rx,
Johannes Berg23a24de2007-07-27 15:43:22 +02001403 rx.sta);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001404 sta_info_put(sta);
1405 return;
1406 }
Johannes Berg571ecf62007-07-27 15:43:22 +02001407
Johannes Berg8e6f0032007-07-27 15:43:22 +02001408 bssid = ieee80211_get_bssid(hdr, skb->len - radiotap_len);
Johannes Berg571ecf62007-07-27 15:43:22 +02001409
Johannes Berg8e6f0032007-07-27 15:43:22 +02001410 read_lock(&local->sub_if_lock);
1411 list_for_each_entry(sdata, &local->sub_if_list, list) {
Jiri Slabybadffb72007-08-28 17:01:54 -04001412 rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
Johannes Berg23a24de2007-07-27 15:43:22 +02001413
Johannes Berg2a8a9a82007-08-28 17:01:52 -04001414 if (!netif_running(sdata->dev))
1415 continue;
1416
Johannes Berg23a24de2007-07-27 15:43:22 +02001417 prepres = prepare_for_handlers(sdata, bssid, &rx, hdr);
1418 /* prepare_for_handlers can change sta */
1419 sta = rx.sta;
1420
1421 if (!prepres)
1422 continue;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001423
Johannes Berg340e11f2007-07-27 15:43:22 +02001424 /*
1425 * frame is destined for this interface, but if it's not
1426 * also for the previous one we handle that after the
1427 * loop to avoid copying the SKB once too much
1428 */
1429
1430 if (!prev) {
1431 prev = sdata;
1432 continue;
Johannes Berg8e6f0032007-07-27 15:43:22 +02001433 }
Johannes Berg340e11f2007-07-27 15:43:22 +02001434
1435 /*
1436 * frame was destined for the previous interface
1437 * so invoke RX handlers for it
1438 */
1439
1440 skb_new = skb_copy(skb, GFP_ATOMIC);
1441 if (!skb_new) {
1442 if (net_ratelimit())
1443 printk(KERN_DEBUG "%s: failed to copy "
1444 "multicast frame for %s",
1445 local->mdev->name, prev->dev->name);
1446 continue;
1447 }
1448 rx.skb = skb_new;
1449 rx.dev = prev->dev;
1450 rx.sdata = prev;
1451 ieee80211_invoke_rx_handlers(local, local->rx_handlers,
1452 &rx, sta);
Johannes Berg8e6f0032007-07-27 15:43:22 +02001453 prev = sdata;
Johannes Berg571ecf62007-07-27 15:43:22 +02001454 }
Johannes Berg8e6f0032007-07-27 15:43:22 +02001455 if (prev) {
1456 rx.skb = skb;
1457 rx.dev = prev->dev;
1458 rx.sdata = prev;
1459 ieee80211_invoke_rx_handlers(local, local->rx_handlers,
1460 &rx, sta);
1461 } else
1462 dev_kfree_skb(skb);
1463 read_unlock(&local->sub_if_lock);
Johannes Berg571ecf62007-07-27 15:43:22 +02001464
Johannes Berg8e6f0032007-07-27 15:43:22 +02001465 end:
Johannes Berg571ecf62007-07-27 15:43:22 +02001466 if (sta)
1467 sta_info_put(sta);
1468}
1469EXPORT_SYMBOL(__ieee80211_rx);
1470
1471/* This is a version of the rx handler that can be called from hard irq
1472 * context. Post the skb on the queue and schedule the tasklet */
1473void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb,
1474 struct ieee80211_rx_status *status)
1475{
1476 struct ieee80211_local *local = hw_to_local(hw);
1477
1478 BUILD_BUG_ON(sizeof(struct ieee80211_rx_status) > sizeof(skb->cb));
1479
1480 skb->dev = local->mdev;
1481 /* copy status into skb->cb for use by tasklet */
1482 memcpy(skb->cb, status, sizeof(*status));
1483 skb->pkt_type = IEEE80211_RX_MSG;
1484 skb_queue_tail(&local->skb_queue, skb);
1485 tasklet_schedule(&local->tasklet);
1486}
1487EXPORT_SYMBOL(ieee80211_rx_irqsafe);