2 * Intersil Prism2 driver with Host AP (software access point) support
3 * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
5 * Copyright (c) 2002-2005, Jouni Malinen <j@w1.fi>
7 * This file is to be included into hostap.c when S/W AP functionality is
11 * - if unicast Class 2 (assoc,reassoc,disassoc) frame received from
12 * unauthenticated STA, send deauth. frame (8802.11: 5.5)
13 * - if unicast Class 3 (data with to/from DS,deauth,pspoll) frame received
14 * from authenticated, but unassoc STA, send disassoc frame (8802.11: 5.5)
15 * - if unicast Class 3 received from unauthenticated STA, send deauth. frame
19 #include <linux/proc_fs.h>
20 #include <linux/delay.h>
21 #include <linux/random.h>
23 #include "hostap_wlan.h"
25 #include "hostap_ap.h"
27 static int other_ap_policy
[MAX_PARM_DEVICES
] = { AP_OTHER_AP_SKIP_ALL
,
29 module_param_array(other_ap_policy
, int, NULL
, 0444);
30 MODULE_PARM_DESC(other_ap_policy
, "Other AP beacon monitoring policy (0-3)");
32 static int ap_max_inactivity
[MAX_PARM_DEVICES
] = { AP_MAX_INACTIVITY_SEC
,
34 module_param_array(ap_max_inactivity
, int, NULL
, 0444);
35 MODULE_PARM_DESC(ap_max_inactivity
, "AP timeout (in seconds) for station "
38 static int ap_bridge_packets
[MAX_PARM_DEVICES
] = { 1, DEF_INTS
};
39 module_param_array(ap_bridge_packets
, int, NULL
, 0444);
40 MODULE_PARM_DESC(ap_bridge_packets
, "Bridge packets directly between "
43 static int autom_ap_wds
[MAX_PARM_DEVICES
] = { 0, DEF_INTS
};
44 module_param_array(autom_ap_wds
, int, NULL
, 0444);
45 MODULE_PARM_DESC(autom_ap_wds
, "Add WDS connections to other APs "
49 static struct sta_info
* ap_get_sta(struct ap_data
*ap
, u8
*sta
);
50 static void hostap_event_expired_sta(struct net_device
*dev
,
51 struct sta_info
*sta
);
52 static void handle_add_proc_queue(struct work_struct
*work
);
54 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
55 static void handle_wds_oper_queue(struct work_struct
*work
);
56 static void prism2_send_mgmt(struct net_device
*dev
,
57 u16 type_subtype
, char *body
,
58 int body_len
, u8
*addr
, u16 tx_cb_idx
);
59 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
62 #ifndef PRISM2_NO_PROCFS_DEBUG
63 static int ap_debug_proc_read(char *page
, char **start
, off_t off
,
64 int count
, int *eof
, void *data
)
67 struct ap_data
*ap
= (struct ap_data
*) data
;
74 p
+= sprintf(p
, "BridgedUnicastFrames=%u\n", ap
->bridged_unicast
);
75 p
+= sprintf(p
, "BridgedMulticastFrames=%u\n", ap
->bridged_multicast
);
76 p
+= sprintf(p
, "max_inactivity=%u\n", ap
->max_inactivity
/ HZ
);
77 p
+= sprintf(p
, "bridge_packets=%u\n", ap
->bridge_packets
);
78 p
+= sprintf(p
, "nullfunc_ack=%u\n", ap
->nullfunc_ack
);
79 p
+= sprintf(p
, "autom_ap_wds=%u\n", ap
->autom_ap_wds
);
80 p
+= sprintf(p
, "auth_algs=%u\n", ap
->local
->auth_algs
);
81 p
+= sprintf(p
, "tx_drop_nonassoc=%u\n", ap
->tx_drop_nonassoc
);
85 #endif /* PRISM2_NO_PROCFS_DEBUG */
88 static void ap_sta_hash_add(struct ap_data
*ap
, struct sta_info
*sta
)
90 sta
->hnext
= ap
->sta_hash
[STA_HASH(sta
->addr
)];
91 ap
->sta_hash
[STA_HASH(sta
->addr
)] = sta
;
94 static void ap_sta_hash_del(struct ap_data
*ap
, struct sta_info
*sta
)
99 s
= ap
->sta_hash
[STA_HASH(sta
->addr
)];
100 if (s
== NULL
) return;
101 if (memcmp(s
->addr
, sta
->addr
, ETH_ALEN
) == 0) {
102 ap
->sta_hash
[STA_HASH(sta
->addr
)] = s
->hnext
;
106 while (s
->hnext
!= NULL
&& memcmp(s
->hnext
->addr
, sta
->addr
, ETH_ALEN
)
109 if (s
->hnext
!= NULL
)
110 s
->hnext
= s
->hnext
->hnext
;
112 printk("AP: could not remove STA %s"
113 " from hash table\n",
114 print_mac(mac
, sta
->addr
));
117 static void ap_free_sta(struct ap_data
*ap
, struct sta_info
*sta
)
119 DECLARE_MAC_BUF(mac
);
120 if (sta
->ap
&& sta
->local
)
121 hostap_event_expired_sta(sta
->local
->dev
, sta
);
123 if (ap
->proc
!= NULL
) {
125 sprintf(name
, "%s", print_mac(mac
, sta
->addr
));
126 remove_proc_entry(name
, ap
->proc
);
130 sta
->crypt
->ops
->deinit(sta
->crypt
->priv
);
135 skb_queue_purge(&sta
->tx_buf
);
138 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
140 ap
->sta_aid
[sta
->aid
- 1] = NULL
;
142 if (!sta
->ap
&& sta
->u
.sta
.challenge
)
143 kfree(sta
->u
.sta
.challenge
);
144 del_timer(&sta
->timer
);
145 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
151 static void hostap_set_tim(local_info_t
*local
, int aid
, int set
)
153 if (local
->func
->set_tim
)
154 local
->func
->set_tim(local
->dev
, aid
, set
);
158 static void hostap_event_new_sta(struct net_device
*dev
, struct sta_info
*sta
)
160 union iwreq_data wrqu
;
161 memset(&wrqu
, 0, sizeof(wrqu
));
162 memcpy(wrqu
.addr
.sa_data
, sta
->addr
, ETH_ALEN
);
163 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
164 wireless_send_event(dev
, IWEVREGISTERED
, &wrqu
, NULL
);
168 static void hostap_event_expired_sta(struct net_device
*dev
,
169 struct sta_info
*sta
)
171 union iwreq_data wrqu
;
172 memset(&wrqu
, 0, sizeof(wrqu
));
173 memcpy(wrqu
.addr
.sa_data
, sta
->addr
, ETH_ALEN
);
174 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
175 wireless_send_event(dev
, IWEVEXPIRED
, &wrqu
, NULL
);
179 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
181 static void ap_handle_timer(unsigned long data
)
183 struct sta_info
*sta
= (struct sta_info
*) data
;
186 unsigned long next_time
= 0;
188 DECLARE_MAC_BUF(mac
);
190 if (sta
== NULL
|| sta
->local
== NULL
|| sta
->local
->ap
== NULL
) {
191 PDEBUG(DEBUG_AP
, "ap_handle_timer() called with NULL data\n");
197 was_assoc
= sta
->flags
& WLAN_STA_ASSOC
;
199 if (atomic_read(&sta
->users
) != 0)
200 next_time
= jiffies
+ HZ
;
201 else if ((sta
->flags
& WLAN_STA_PERM
) && !(sta
->flags
& WLAN_STA_AUTH
))
202 next_time
= jiffies
+ ap
->max_inactivity
;
204 if (time_before(jiffies
, sta
->last_rx
+ ap
->max_inactivity
)) {
205 /* station activity detected; reset timeout state */
206 sta
->timeout_next
= STA_NULLFUNC
;
207 next_time
= sta
->last_rx
+ ap
->max_inactivity
;
208 } else if (sta
->timeout_next
== STA_DISASSOC
&&
209 !(sta
->flags
& WLAN_STA_PENDING_POLL
)) {
210 /* STA ACKed data nullfunc frame poll */
211 sta
->timeout_next
= STA_NULLFUNC
;
212 next_time
= jiffies
+ ap
->max_inactivity
;
216 sta
->timer
.expires
= next_time
;
217 add_timer(&sta
->timer
);
222 sta
->timeout_next
= STA_DEAUTH
;
224 if (sta
->timeout_next
== STA_DEAUTH
&& !(sta
->flags
& WLAN_STA_PERM
)) {
225 spin_lock(&ap
->sta_table_lock
);
226 ap_sta_hash_del(ap
, sta
);
227 list_del(&sta
->list
);
228 spin_unlock(&ap
->sta_table_lock
);
229 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
230 } else if (sta
->timeout_next
== STA_DISASSOC
)
231 sta
->flags
&= ~WLAN_STA_ASSOC
;
233 if (was_assoc
&& !(sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
234 hostap_event_expired_sta(local
->dev
, sta
);
236 if (sta
->timeout_next
== STA_DEAUTH
&& sta
->aid
> 0 &&
237 !skb_queue_empty(&sta
->tx_buf
)) {
238 hostap_set_tim(local
, sta
->aid
, 0);
239 sta
->flags
&= ~WLAN_STA_TIM
;
243 if (ap
->autom_ap_wds
) {
244 PDEBUG(DEBUG_AP
, "%s: removing automatic WDS "
245 "connection to AP %s\n",
246 local
->dev
->name
, print_mac(mac
, sta
->addr
));
247 hostap_wds_link_oper(local
, sta
->addr
, WDS_DEL
);
249 } else if (sta
->timeout_next
== STA_NULLFUNC
) {
250 /* send data frame to poll STA and check whether this frame
252 /* FIX: IEEE80211_STYPE_NULLFUNC would be more appropriate, but
253 * it is apparently not retried so TX Exc events are not
255 sta
->flags
|= WLAN_STA_PENDING_POLL
;
256 prism2_send_mgmt(local
->dev
, IEEE80211_FTYPE_DATA
|
257 IEEE80211_STYPE_DATA
, NULL
, 0,
258 sta
->addr
, ap
->tx_callback_poll
);
260 int deauth
= sta
->timeout_next
== STA_DEAUTH
;
262 PDEBUG(DEBUG_AP
, "%s: sending %s info to STA %s"
263 "(last=%lu, jiffies=%lu)\n",
265 deauth
? "deauthentication" : "disassociation",
266 print_mac(mac
, sta
->addr
), sta
->last_rx
, jiffies
);
268 resp
= cpu_to_le16(deauth
? WLAN_REASON_PREV_AUTH_NOT_VALID
:
269 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
);
270 prism2_send_mgmt(local
->dev
, IEEE80211_FTYPE_MGMT
|
271 (deauth
? IEEE80211_STYPE_DEAUTH
:
272 IEEE80211_STYPE_DISASSOC
),
273 (char *) &resp
, 2, sta
->addr
, 0);
276 if (sta
->timeout_next
== STA_DEAUTH
) {
277 if (sta
->flags
& WLAN_STA_PERM
) {
278 PDEBUG(DEBUG_AP
, "%s: STA %s"
279 " would have been removed, "
280 "but it has 'perm' flag\n",
281 local
->dev
->name
, print_mac(mac
, sta
->addr
));
283 ap_free_sta(ap
, sta
);
287 if (sta
->timeout_next
== STA_NULLFUNC
) {
288 sta
->timeout_next
= STA_DISASSOC
;
289 sta
->timer
.expires
= jiffies
+ AP_DISASSOC_DELAY
;
291 sta
->timeout_next
= STA_DEAUTH
;
292 sta
->timer
.expires
= jiffies
+ AP_DEAUTH_DELAY
;
295 add_timer(&sta
->timer
);
299 void hostap_deauth_all_stas(struct net_device
*dev
, struct ap_data
*ap
,
306 PDEBUG(DEBUG_AP
, "%s: Deauthenticate all stations\n", dev
->name
);
307 memset(addr
, 0xff, ETH_ALEN
);
309 resp
= cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID
);
311 /* deauth message sent; try to resend it few times; the message is
312 * broadcast, so it may be delayed until next DTIM; there is not much
313 * else we can do at this point since the driver is going to be shut
315 for (i
= 0; i
< 5; i
++) {
316 prism2_send_mgmt(dev
, IEEE80211_FTYPE_MGMT
|
317 IEEE80211_STYPE_DEAUTH
,
318 (char *) &resp
, 2, addr
, 0);
320 if (!resend
|| ap
->num_sta
<= 0)
328 static int ap_control_proc_read(char *page
, char **start
, off_t off
,
329 int count
, int *eof
, void *data
)
332 struct ap_data
*ap
= (struct ap_data
*) data
;
334 struct mac_entry
*entry
;
335 DECLARE_MAC_BUF(mac
);
342 switch (ap
->mac_restrictions
.policy
) {
343 case MAC_POLICY_OPEN
:
346 case MAC_POLICY_ALLOW
:
347 policy_txt
= "allow";
349 case MAC_POLICY_DENY
:
353 policy_txt
= "unknown";
356 p
+= sprintf(p
, "MAC policy: %s\n", policy_txt
);
357 p
+= sprintf(p
, "MAC entries: %u\n", ap
->mac_restrictions
.entries
);
358 p
+= sprintf(p
, "MAC list:\n");
359 spin_lock_bh(&ap
->mac_restrictions
.lock
);
360 list_for_each_entry(entry
, &ap
->mac_restrictions
.mac_list
, list
) {
361 if (p
- page
> PAGE_SIZE
- 80) {
362 p
+= sprintf(p
, "All entries did not fit one page.\n");
366 p
+= sprintf(p
, "%s\n", print_mac(mac
, entry
->addr
));
368 spin_unlock_bh(&ap
->mac_restrictions
.lock
);
374 int ap_control_add_mac(struct mac_restrictions
*mac_restrictions
, u8
*mac
)
376 struct mac_entry
*entry
;
378 entry
= kmalloc(sizeof(struct mac_entry
), GFP_KERNEL
);
382 memcpy(entry
->addr
, mac
, ETH_ALEN
);
384 spin_lock_bh(&mac_restrictions
->lock
);
385 list_add_tail(&entry
->list
, &mac_restrictions
->mac_list
);
386 mac_restrictions
->entries
++;
387 spin_unlock_bh(&mac_restrictions
->lock
);
393 int ap_control_del_mac(struct mac_restrictions
*mac_restrictions
, u8
*mac
)
395 struct list_head
*ptr
;
396 struct mac_entry
*entry
;
398 spin_lock_bh(&mac_restrictions
->lock
);
399 for (ptr
= mac_restrictions
->mac_list
.next
;
400 ptr
!= &mac_restrictions
->mac_list
; ptr
= ptr
->next
) {
401 entry
= list_entry(ptr
, struct mac_entry
, list
);
403 if (memcmp(entry
->addr
, mac
, ETH_ALEN
) == 0) {
406 mac_restrictions
->entries
--;
407 spin_unlock_bh(&mac_restrictions
->lock
);
411 spin_unlock_bh(&mac_restrictions
->lock
);
416 static int ap_control_mac_deny(struct mac_restrictions
*mac_restrictions
,
419 struct mac_entry
*entry
;
422 if (mac_restrictions
->policy
== MAC_POLICY_OPEN
)
425 spin_lock_bh(&mac_restrictions
->lock
);
426 list_for_each_entry(entry
, &mac_restrictions
->mac_list
, list
) {
427 if (memcmp(entry
->addr
, mac
, ETH_ALEN
) == 0) {
432 spin_unlock_bh(&mac_restrictions
->lock
);
434 if (mac_restrictions
->policy
== MAC_POLICY_ALLOW
)
441 void ap_control_flush_macs(struct mac_restrictions
*mac_restrictions
)
443 struct list_head
*ptr
, *n
;
444 struct mac_entry
*entry
;
446 if (mac_restrictions
->entries
== 0)
449 spin_lock_bh(&mac_restrictions
->lock
);
450 for (ptr
= mac_restrictions
->mac_list
.next
, n
= ptr
->next
;
451 ptr
!= &mac_restrictions
->mac_list
;
452 ptr
= n
, n
= ptr
->next
) {
453 entry
= list_entry(ptr
, struct mac_entry
, list
);
457 mac_restrictions
->entries
= 0;
458 spin_unlock_bh(&mac_restrictions
->lock
);
462 int ap_control_kick_mac(struct ap_data
*ap
, struct net_device
*dev
, u8
*mac
)
464 struct sta_info
*sta
;
467 spin_lock_bh(&ap
->sta_table_lock
);
468 sta
= ap_get_sta(ap
, mac
);
470 ap_sta_hash_del(ap
, sta
);
471 list_del(&sta
->list
);
473 spin_unlock_bh(&ap
->sta_table_lock
);
478 resp
= cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID
);
479 prism2_send_mgmt(dev
, IEEE80211_FTYPE_MGMT
| IEEE80211_STYPE_DEAUTH
,
480 (char *) &resp
, 2, sta
->addr
, 0);
482 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
483 hostap_event_expired_sta(dev
, sta
);
485 ap_free_sta(ap
, sta
);
490 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
493 void ap_control_kickall(struct ap_data
*ap
)
495 struct list_head
*ptr
, *n
;
496 struct sta_info
*sta
;
498 spin_lock_bh(&ap
->sta_table_lock
);
499 for (ptr
= ap
->sta_list
.next
, n
= ptr
->next
; ptr
!= &ap
->sta_list
;
500 ptr
= n
, n
= ptr
->next
) {
501 sta
= list_entry(ptr
, struct sta_info
, list
);
502 ap_sta_hash_del(ap
, sta
);
503 list_del(&sta
->list
);
504 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
505 hostap_event_expired_sta(sta
->local
->dev
, sta
);
506 ap_free_sta(ap
, sta
);
508 spin_unlock_bh(&ap
->sta_table_lock
);
512 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
514 #define PROC_LIMIT (PAGE_SIZE - 80)
516 static int prism2_ap_proc_read(char *page
, char **start
, off_t off
,
517 int count
, int *eof
, void *data
)
520 struct ap_data
*ap
= (struct ap_data
*) data
;
521 struct sta_info
*sta
;
523 DECLARE_MAC_BUF(mac
);
525 if (off
> PROC_LIMIT
) {
530 p
+= sprintf(p
, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
531 spin_lock_bh(&ap
->sta_table_lock
);
532 list_for_each_entry(sta
, &ap
->sta_list
, list
) {
536 p
+= sprintf(p
, "%s %d %d %d %d '",
537 print_mac(mac
, sta
->addr
),
538 sta
->u
.ap
.channel
, sta
->last_rx_signal
,
539 sta
->last_rx_silence
, sta
->last_rx_rate
);
540 for (i
= 0; i
< sta
->u
.ap
.ssid_len
; i
++)
541 p
+= sprintf(p
, ((sta
->u
.ap
.ssid
[i
] >= 32 &&
542 sta
->u
.ap
.ssid
[i
] < 127) ?
545 p
+= sprintf(p
, "'");
546 if (sta
->capability
& WLAN_CAPABILITY_ESS
)
547 p
+= sprintf(p
, " [ESS]");
548 if (sta
->capability
& WLAN_CAPABILITY_IBSS
)
549 p
+= sprintf(p
, " [IBSS]");
550 if (sta
->capability
& WLAN_CAPABILITY_PRIVACY
)
551 p
+= sprintf(p
, " [WEP]");
552 p
+= sprintf(p
, "\n");
554 if ((p
- page
) > PROC_LIMIT
) {
555 printk(KERN_DEBUG
"hostap: ap proc did not fit\n");
559 spin_unlock_bh(&ap
->sta_table_lock
);
561 if ((p
- page
) <= off
) {
568 return (p
- page
- off
);
570 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
573 void hostap_check_sta_fw_version(struct ap_data
*ap
, int sta_fw_ver
)
578 if (sta_fw_ver
== PRISM2_FW_VER(0,8,0)) {
579 PDEBUG(DEBUG_AP
, "Using data::nullfunc ACK workaround - "
580 "firmware upgrade recommended\n");
581 ap
->nullfunc_ack
= 1;
583 ap
->nullfunc_ack
= 0;
585 if (sta_fw_ver
== PRISM2_FW_VER(1,4,2)) {
586 printk(KERN_WARNING
"%s: Warning: secondary station firmware "
587 "version 1.4.2 does not seem to work in Host AP mode\n",
588 ap
->local
->dev
->name
);
593 /* Called only as a tasklet (software IRQ) */
594 static void hostap_ap_tx_cb(struct sk_buff
*skb
, int ok
, void *data
)
596 struct ap_data
*ap
= data
;
598 struct ieee80211_hdr_4addr
*hdr
;
600 if (!ap
->local
->hostapd
|| !ap
->local
->apdev
) {
605 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
606 fc
= le16_to_cpu(hdr
->frame_ctl
);
608 /* Pass the TX callback frame to the hostapd; use 802.11 header version
609 * 1 to indicate failure (no ACK) and 2 success (frame ACKed) */
611 fc
&= ~IEEE80211_FCTL_VERS
;
612 fc
|= ok
? BIT(1) : BIT(0);
613 hdr
->frame_ctl
= cpu_to_le16(fc
);
615 skb
->dev
= ap
->local
->apdev
;
616 skb_pull(skb
, hostap_80211_get_hdrlen(fc
));
617 skb
->pkt_type
= PACKET_OTHERHOST
;
618 skb
->protocol
= __constant_htons(ETH_P_802_2
);
619 memset(skb
->cb
, 0, sizeof(skb
->cb
));
624 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
625 /* Called only as a tasklet (software IRQ) */
626 static void hostap_ap_tx_cb_auth(struct sk_buff
*skb
, int ok
, void *data
)
628 struct ap_data
*ap
= data
;
629 struct net_device
*dev
= ap
->local
->dev
;
630 struct ieee80211_hdr_4addr
*hdr
;
631 u16 fc
, auth_alg
, auth_transaction
, status
;
633 struct sta_info
*sta
= NULL
;
635 DECLARE_MAC_BUF(mac
);
637 if (ap
->local
->hostapd
) {
642 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
643 fc
= le16_to_cpu(hdr
->frame_ctl
);
644 if (WLAN_FC_GET_TYPE(fc
) != IEEE80211_FTYPE_MGMT
||
645 WLAN_FC_GET_STYPE(fc
) != IEEE80211_STYPE_AUTH
||
646 skb
->len
< IEEE80211_MGMT_HDR_LEN
+ 6) {
647 printk(KERN_DEBUG
"%s: hostap_ap_tx_cb_auth received invalid "
648 "frame\n", dev
->name
);
653 pos
= (__le16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
654 auth_alg
= le16_to_cpu(*pos
++);
655 auth_transaction
= le16_to_cpu(*pos
++);
656 status
= le16_to_cpu(*pos
++);
659 txt
= "frame was not ACKed";
663 spin_lock(&ap
->sta_table_lock
);
664 sta
= ap_get_sta(ap
, hdr
->addr1
);
666 atomic_inc(&sta
->users
);
667 spin_unlock(&ap
->sta_table_lock
);
670 txt
= "STA not found";
674 if (status
== WLAN_STATUS_SUCCESS
&&
675 ((auth_alg
== WLAN_AUTH_OPEN
&& auth_transaction
== 2) ||
676 (auth_alg
== WLAN_AUTH_SHARED_KEY
&& auth_transaction
== 4))) {
677 txt
= "STA authenticated";
678 sta
->flags
|= WLAN_STA_AUTH
;
679 sta
->last_auth
= jiffies
;
680 } else if (status
!= WLAN_STATUS_SUCCESS
)
681 txt
= "authentication failed";
685 atomic_dec(&sta
->users
);
687 PDEBUG(DEBUG_AP
, "%s: %s auth_cb - alg=%d "
688 "trans#=%d status=%d - %s\n",
689 dev
->name
, print_mac(mac
, hdr
->addr1
), auth_alg
,
690 auth_transaction
, status
, txt
);
696 /* Called only as a tasklet (software IRQ) */
697 static void hostap_ap_tx_cb_assoc(struct sk_buff
*skb
, int ok
, void *data
)
699 struct ap_data
*ap
= data
;
700 struct net_device
*dev
= ap
->local
->dev
;
701 struct ieee80211_hdr_4addr
*hdr
;
704 struct sta_info
*sta
= NULL
;
706 DECLARE_MAC_BUF(mac
);
708 if (ap
->local
->hostapd
) {
713 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
714 fc
= le16_to_cpu(hdr
->frame_ctl
);
715 if (WLAN_FC_GET_TYPE(fc
) != IEEE80211_FTYPE_MGMT
||
716 (WLAN_FC_GET_STYPE(fc
) != IEEE80211_STYPE_ASSOC_RESP
&&
717 WLAN_FC_GET_STYPE(fc
) != IEEE80211_STYPE_REASSOC_RESP
) ||
718 skb
->len
< IEEE80211_MGMT_HDR_LEN
+ 4) {
719 printk(KERN_DEBUG
"%s: hostap_ap_tx_cb_assoc received invalid "
720 "frame\n", dev
->name
);
726 txt
= "frame was not ACKed";
730 spin_lock(&ap
->sta_table_lock
);
731 sta
= ap_get_sta(ap
, hdr
->addr1
);
733 atomic_inc(&sta
->users
);
734 spin_unlock(&ap
->sta_table_lock
);
737 txt
= "STA not found";
741 pos
= (__le16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
743 status
= le16_to_cpu(*pos
++);
744 if (status
== WLAN_STATUS_SUCCESS
) {
745 if (!(sta
->flags
& WLAN_STA_ASSOC
))
746 hostap_event_new_sta(dev
, sta
);
747 txt
= "STA associated";
748 sta
->flags
|= WLAN_STA_ASSOC
;
749 sta
->last_assoc
= jiffies
;
751 txt
= "association failed";
755 atomic_dec(&sta
->users
);
757 PDEBUG(DEBUG_AP
, "%s: %s assoc_cb - %s\n",
758 dev
->name
, print_mac(mac
, hdr
->addr1
), txt
);
763 /* Called only as a tasklet (software IRQ); TX callback for poll frames used
764 * in verifying whether the STA is still present. */
765 static void hostap_ap_tx_cb_poll(struct sk_buff
*skb
, int ok
, void *data
)
767 struct ap_data
*ap
= data
;
768 struct ieee80211_hdr_4addr
*hdr
;
769 struct sta_info
*sta
;
770 DECLARE_MAC_BUF(mac
);
774 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
776 spin_lock(&ap
->sta_table_lock
);
777 sta
= ap_get_sta(ap
, hdr
->addr1
);
779 sta
->flags
&= ~WLAN_STA_PENDING_POLL
;
780 spin_unlock(&ap
->sta_table_lock
);
782 PDEBUG(DEBUG_AP
, "%s: STA %s"
783 " did not ACK activity poll frame\n",
784 ap
->local
->dev
->name
, print_mac(mac
, hdr
->addr1
));
790 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
793 void hostap_init_data(local_info_t
*local
)
795 struct ap_data
*ap
= local
->ap
;
798 printk(KERN_WARNING
"hostap_init_data: ap == NULL\n");
801 memset(ap
, 0, sizeof(struct ap_data
));
804 ap
->ap_policy
= GET_INT_PARM(other_ap_policy
, local
->card_idx
);
805 ap
->bridge_packets
= GET_INT_PARM(ap_bridge_packets
, local
->card_idx
);
807 GET_INT_PARM(ap_max_inactivity
, local
->card_idx
) * HZ
;
808 ap
->autom_ap_wds
= GET_INT_PARM(autom_ap_wds
, local
->card_idx
);
810 spin_lock_init(&ap
->sta_table_lock
);
811 INIT_LIST_HEAD(&ap
->sta_list
);
813 /* Initialize task queue structure for AP management */
814 INIT_WORK(&local
->ap
->add_sta_proc_queue
, handle_add_proc_queue
);
816 ap
->tx_callback_idx
=
817 hostap_tx_callback_register(local
, hostap_ap_tx_cb
, ap
);
818 if (ap
->tx_callback_idx
== 0)
819 printk(KERN_WARNING
"%s: failed to register TX callback for "
820 "AP\n", local
->dev
->name
);
821 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
822 INIT_WORK(&local
->ap
->wds_oper_queue
, handle_wds_oper_queue
);
824 ap
->tx_callback_auth
=
825 hostap_tx_callback_register(local
, hostap_ap_tx_cb_auth
, ap
);
826 ap
->tx_callback_assoc
=
827 hostap_tx_callback_register(local
, hostap_ap_tx_cb_assoc
, ap
);
828 ap
->tx_callback_poll
=
829 hostap_tx_callback_register(local
, hostap_ap_tx_cb_poll
, ap
);
830 if (ap
->tx_callback_auth
== 0 || ap
->tx_callback_assoc
== 0 ||
831 ap
->tx_callback_poll
== 0)
832 printk(KERN_WARNING
"%s: failed to register TX callback for "
833 "AP\n", local
->dev
->name
);
835 spin_lock_init(&ap
->mac_restrictions
.lock
);
836 INIT_LIST_HEAD(&ap
->mac_restrictions
.mac_list
);
837 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
843 void hostap_init_ap_proc(local_info_t
*local
)
845 struct ap_data
*ap
= local
->ap
;
847 ap
->proc
= local
->proc
;
848 if (ap
->proc
== NULL
)
851 #ifndef PRISM2_NO_PROCFS_DEBUG
852 create_proc_read_entry("ap_debug", 0, ap
->proc
,
853 ap_debug_proc_read
, ap
);
854 #endif /* PRISM2_NO_PROCFS_DEBUG */
856 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
857 create_proc_read_entry("ap_control", 0, ap
->proc
,
858 ap_control_proc_read
, ap
);
859 create_proc_read_entry("ap", 0, ap
->proc
,
860 prism2_ap_proc_read
, ap
);
861 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
866 void hostap_free_data(struct ap_data
*ap
)
868 struct sta_info
*n
, *sta
;
870 if (ap
== NULL
|| !ap
->initialized
) {
871 printk(KERN_DEBUG
"hostap_free_data: ap has not yet been "
872 "initialized - skip resource freeing\n");
876 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
878 ap
->crypt
->deinit(ap
->crypt_priv
);
879 ap
->crypt
= ap
->crypt_priv
= NULL
;
880 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
882 list_for_each_entry_safe(sta
, n
, &ap
->sta_list
, list
) {
883 ap_sta_hash_del(ap
, sta
);
884 list_del(&sta
->list
);
885 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
886 hostap_event_expired_sta(sta
->local
->dev
, sta
);
887 ap_free_sta(ap
, sta
);
890 #ifndef PRISM2_NO_PROCFS_DEBUG
891 if (ap
->proc
!= NULL
) {
892 remove_proc_entry("ap_debug", ap
->proc
);
894 #endif /* PRISM2_NO_PROCFS_DEBUG */
896 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
897 if (ap
->proc
!= NULL
) {
898 remove_proc_entry("ap", ap
->proc
);
899 remove_proc_entry("ap_control", ap
->proc
);
901 ap_control_flush_macs(&ap
->mac_restrictions
);
902 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
908 /* caller should have mutex for AP STA list handling */
909 static struct sta_info
* ap_get_sta(struct ap_data
*ap
, u8
*sta
)
913 s
= ap
->sta_hash
[STA_HASH(sta
)];
914 while (s
!= NULL
&& memcmp(s
->addr
, sta
, ETH_ALEN
) != 0)
920 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
922 /* Called from timer handler and from scheduled AP queue handlers */
923 static void prism2_send_mgmt(struct net_device
*dev
,
924 u16 type_subtype
, char *body
,
925 int body_len
, u8
*addr
, u16 tx_cb_idx
)
927 struct hostap_interface
*iface
;
929 struct ieee80211_hdr_4addr
*hdr
;
932 struct hostap_skb_tx_data
*meta
;
935 iface
= netdev_priv(dev
);
936 local
= iface
->local
;
937 dev
= local
->dev
; /* always use master radio device */
938 iface
= netdev_priv(dev
);
940 if (!(dev
->flags
& IFF_UP
)) {
941 PDEBUG(DEBUG_AP
, "%s: prism2_send_mgmt - device is not UP - "
942 "cannot send frame\n", dev
->name
);
946 skb
= dev_alloc_skb(sizeof(*hdr
) + body_len
);
948 PDEBUG(DEBUG_AP
, "%s: prism2_send_mgmt failed to allocate "
954 hdrlen
= hostap_80211_get_hdrlen(fc
);
955 hdr
= (struct ieee80211_hdr_4addr
*) skb_put(skb
, hdrlen
);
957 memcpy(skb_put(skb
, body_len
), body
, body_len
);
959 memset(hdr
, 0, hdrlen
);
961 /* FIX: ctrl::ack sending used special HFA384X_TX_CTRL_802_11
962 * tx_control instead of using local->tx_control */
965 memcpy(hdr
->addr1
, addr
, ETH_ALEN
); /* DA / RA */
966 if (WLAN_FC_GET_TYPE(fc
) == IEEE80211_FTYPE_DATA
) {
967 fc
|= IEEE80211_FCTL_FROMDS
;
968 memcpy(hdr
->addr2
, dev
->dev_addr
, ETH_ALEN
); /* BSSID */
969 memcpy(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
); /* SA */
970 } else if (WLAN_FC_GET_TYPE(fc
) == IEEE80211_FTYPE_CTL
) {
971 /* control:ACK does not have addr2 or addr3 */
972 memset(hdr
->addr2
, 0, ETH_ALEN
);
973 memset(hdr
->addr3
, 0, ETH_ALEN
);
975 memcpy(hdr
->addr2
, dev
->dev_addr
, ETH_ALEN
); /* SA */
976 memcpy(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
); /* BSSID */
979 hdr
->frame_ctl
= cpu_to_le16(fc
);
981 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
982 memset(meta
, 0, sizeof(*meta
));
983 meta
->magic
= HOSTAP_SKB_TX_DATA_MAGIC
;
985 meta
->tx_cb_idx
= tx_cb_idx
;
988 skb_reset_mac_header(skb
);
989 skb_reset_network_header(skb
);
992 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
995 static int prism2_sta_proc_read(char *page
, char **start
, off_t off
,
996 int count
, int *eof
, void *data
)
999 struct sta_info
*sta
= (struct sta_info
*) data
;
1001 DECLARE_MAC_BUF(mac
);
1003 /* FIX: possible race condition.. the STA data could have just expired,
1004 * but proc entry was still here so that the read could have started;
1005 * some locking should be done here.. */
1012 p
+= sprintf(p
, "%s=%s\nusers=%d\naid=%d\n"
1013 "flags=0x%04x%s%s%s%s%s%s%s\n"
1014 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
1015 sta
->ap
? "AP" : "STA",
1016 print_mac(mac
, sta
->addr
), atomic_read(&sta
->users
), sta
->aid
,
1018 sta
->flags
& WLAN_STA_AUTH
? " AUTH" : "",
1019 sta
->flags
& WLAN_STA_ASSOC
? " ASSOC" : "",
1020 sta
->flags
& WLAN_STA_PS
? " PS" : "",
1021 sta
->flags
& WLAN_STA_TIM
? " TIM" : "",
1022 sta
->flags
& WLAN_STA_PERM
? " PERM" : "",
1023 sta
->flags
& WLAN_STA_AUTHORIZED
? " AUTHORIZED" : "",
1024 sta
->flags
& WLAN_STA_PENDING_POLL
? " POLL" : "",
1025 sta
->capability
, sta
->listen_interval
);
1026 /* supported_rates: 500 kbit/s units with msb ignored */
1027 for (i
= 0; i
< sizeof(sta
->supported_rates
); i
++)
1028 if (sta
->supported_rates
[i
] != 0)
1029 p
+= sprintf(p
, "%d%sMbps ",
1030 (sta
->supported_rates
[i
] & 0x7f) / 2,
1031 sta
->supported_rates
[i
] & 1 ? ".5" : "");
1032 p
+= sprintf(p
, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
1033 "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
1035 "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
1036 "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
1037 "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
1039 "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n",
1040 jiffies
, sta
->last_auth
, sta
->last_assoc
, sta
->last_rx
,
1042 sta
->rx_packets
, sta
->tx_packets
, sta
->rx_bytes
,
1043 sta
->tx_bytes
, skb_queue_len(&sta
->tx_buf
),
1044 sta
->last_rx_silence
,
1045 sta
->last_rx_signal
, sta
->last_rx_rate
/ 10,
1046 sta
->last_rx_rate
% 10 ? ".5" : "",
1047 sta
->tx_rate
, sta
->tx_count
[0], sta
->tx_count
[1],
1048 sta
->tx_count
[2], sta
->tx_count
[3], sta
->rx_count
[0],
1049 sta
->rx_count
[1], sta
->rx_count
[2], sta
->rx_count
[3]);
1050 if (sta
->crypt
&& sta
->crypt
->ops
&& sta
->crypt
->ops
->print_stats
)
1051 p
= sta
->crypt
->ops
->print_stats(p
, sta
->crypt
->priv
);
1052 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1054 if (sta
->u
.ap
.channel
>= 0)
1055 p
+= sprintf(p
, "channel=%d\n", sta
->u
.ap
.channel
);
1056 p
+= sprintf(p
, "ssid=");
1057 for (i
= 0; i
< sta
->u
.ap
.ssid_len
; i
++)
1058 p
+= sprintf(p
, ((sta
->u
.ap
.ssid
[i
] >= 32 &&
1059 sta
->u
.ap
.ssid
[i
] < 127) ?
1062 p
+= sprintf(p
, "\n");
1064 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1070 static void handle_add_proc_queue(struct work_struct
*work
)
1072 struct ap_data
*ap
= container_of(work
, struct ap_data
,
1073 add_sta_proc_queue
);
1074 struct sta_info
*sta
;
1076 struct add_sta_proc_data
*entry
, *prev
;
1077 DECLARE_MAC_BUF(mac
);
1079 entry
= ap
->add_sta_proc_entries
;
1080 ap
->add_sta_proc_entries
= NULL
;
1083 spin_lock_bh(&ap
->sta_table_lock
);
1084 sta
= ap_get_sta(ap
, entry
->addr
);
1086 atomic_inc(&sta
->users
);
1087 spin_unlock_bh(&ap
->sta_table_lock
);
1090 sprintf(name
, "%s", print_mac(mac
, sta
->addr
));
1091 sta
->proc
= create_proc_read_entry(
1093 prism2_sta_proc_read
, sta
);
1095 atomic_dec(&sta
->users
);
1099 entry
= entry
->next
;
1105 static struct sta_info
* ap_add_sta(struct ap_data
*ap
, u8
*addr
)
1107 struct sta_info
*sta
;
1109 sta
= kzalloc(sizeof(struct sta_info
), GFP_ATOMIC
);
1111 PDEBUG(DEBUG_AP
, "AP: kmalloc failed\n");
1115 /* initialize STA info data */
1116 sta
->local
= ap
->local
;
1117 skb_queue_head_init(&sta
->tx_buf
);
1118 memcpy(sta
->addr
, addr
, ETH_ALEN
);
1120 atomic_inc(&sta
->users
);
1121 spin_lock_bh(&ap
->sta_table_lock
);
1122 list_add(&sta
->list
, &ap
->sta_list
);
1124 ap_sta_hash_add(ap
, sta
);
1125 spin_unlock_bh(&ap
->sta_table_lock
);
1128 struct add_sta_proc_data
*entry
;
1129 /* schedule a non-interrupt context process to add a procfs
1130 * entry for the STA since procfs code use GFP_KERNEL */
1131 entry
= kmalloc(sizeof(*entry
), GFP_ATOMIC
);
1133 memcpy(entry
->addr
, sta
->addr
, ETH_ALEN
);
1134 entry
->next
= ap
->add_sta_proc_entries
;
1135 ap
->add_sta_proc_entries
= entry
;
1136 schedule_work(&ap
->add_sta_proc_queue
);
1138 printk(KERN_DEBUG
"Failed to add STA proc data\n");
1141 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1142 init_timer(&sta
->timer
);
1143 sta
->timer
.expires
= jiffies
+ ap
->max_inactivity
;
1144 sta
->timer
.data
= (unsigned long) sta
;
1145 sta
->timer
.function
= ap_handle_timer
;
1146 if (!ap
->local
->hostapd
)
1147 add_timer(&sta
->timer
);
1148 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1154 static int ap_tx_rate_ok(int rateidx
, struct sta_info
*sta
,
1155 local_info_t
*local
)
1157 if (rateidx
> sta
->tx_max_rate
||
1158 !(sta
->tx_supp_rates
& (1 << rateidx
)))
1161 if (local
->tx_rate_control
!= 0 &&
1162 !(local
->tx_rate_control
& (1 << rateidx
)))
1169 static void prism2_check_tx_rates(struct sta_info
*sta
)
1173 sta
->tx_supp_rates
= 0;
1174 for (i
= 0; i
< sizeof(sta
->supported_rates
); i
++) {
1175 if ((sta
->supported_rates
[i
] & 0x7f) == 2)
1176 sta
->tx_supp_rates
|= WLAN_RATE_1M
;
1177 if ((sta
->supported_rates
[i
] & 0x7f) == 4)
1178 sta
->tx_supp_rates
|= WLAN_RATE_2M
;
1179 if ((sta
->supported_rates
[i
] & 0x7f) == 11)
1180 sta
->tx_supp_rates
|= WLAN_RATE_5M5
;
1181 if ((sta
->supported_rates
[i
] & 0x7f) == 22)
1182 sta
->tx_supp_rates
|= WLAN_RATE_11M
;
1184 sta
->tx_max_rate
= sta
->tx_rate
= sta
->tx_rate_idx
= 0;
1185 if (sta
->tx_supp_rates
& WLAN_RATE_1M
) {
1186 sta
->tx_max_rate
= 0;
1187 if (ap_tx_rate_ok(0, sta
, sta
->local
)) {
1189 sta
->tx_rate_idx
= 0;
1192 if (sta
->tx_supp_rates
& WLAN_RATE_2M
) {
1193 sta
->tx_max_rate
= 1;
1194 if (ap_tx_rate_ok(1, sta
, sta
->local
)) {
1196 sta
->tx_rate_idx
= 1;
1199 if (sta
->tx_supp_rates
& WLAN_RATE_5M5
) {
1200 sta
->tx_max_rate
= 2;
1201 if (ap_tx_rate_ok(2, sta
, sta
->local
)) {
1203 sta
->tx_rate_idx
= 2;
1206 if (sta
->tx_supp_rates
& WLAN_RATE_11M
) {
1207 sta
->tx_max_rate
= 3;
1208 if (ap_tx_rate_ok(3, sta
, sta
->local
)) {
1210 sta
->tx_rate_idx
= 3;
1216 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1218 static void ap_crypt_init(struct ap_data
*ap
)
1220 ap
->crypt
= ieee80211_get_crypto_ops("WEP");
1223 if (ap
->crypt
->init
) {
1224 ap
->crypt_priv
= ap
->crypt
->init(0);
1225 if (ap
->crypt_priv
== NULL
)
1228 u8 key
[WEP_KEY_LEN
];
1229 get_random_bytes(key
, WEP_KEY_LEN
);
1230 ap
->crypt
->set_key(key
, WEP_KEY_LEN
, NULL
,
1236 if (ap
->crypt
== NULL
) {
1237 printk(KERN_WARNING
"AP could not initialize WEP: load module "
1238 "ieee80211_crypt_wep.ko\n");
1243 /* Generate challenge data for shared key authentication. IEEE 802.11 specifies
1244 * that WEP algorithm is used for generating challange. This should be unique,
1245 * but otherwise there is not really need for randomness etc. Initialize WEP
1246 * with pseudo random key and then use increasing IV to get unique challenge
1249 * Called only as a scheduled task for pending AP frames.
1251 static char * ap_auth_make_challenge(struct ap_data
*ap
)
1254 struct sk_buff
*skb
;
1256 if (ap
->crypt
== NULL
) {
1258 if (ap
->crypt
== NULL
)
1262 tmpbuf
= kmalloc(WLAN_AUTH_CHALLENGE_LEN
, GFP_ATOMIC
);
1263 if (tmpbuf
== NULL
) {
1264 PDEBUG(DEBUG_AP
, "AP: kmalloc failed for challenge\n");
1268 skb
= dev_alloc_skb(WLAN_AUTH_CHALLENGE_LEN
+
1269 ap
->crypt
->extra_mpdu_prefix_len
+
1270 ap
->crypt
->extra_mpdu_postfix_len
);
1276 skb_reserve(skb
, ap
->crypt
->extra_mpdu_prefix_len
);
1277 memset(skb_put(skb
, WLAN_AUTH_CHALLENGE_LEN
), 0,
1278 WLAN_AUTH_CHALLENGE_LEN
);
1279 if (ap
->crypt
->encrypt_mpdu(skb
, 0, ap
->crypt_priv
)) {
1285 skb_copy_from_linear_data_offset(skb
, ap
->crypt
->extra_mpdu_prefix_len
,
1286 tmpbuf
, WLAN_AUTH_CHALLENGE_LEN
);
1293 /* Called only as a scheduled task for pending AP frames. */
1294 static void handle_authen(local_info_t
*local
, struct sk_buff
*skb
,
1295 struct hostap_80211_rx_status
*rx_stats
)
1297 struct net_device
*dev
= local
->dev
;
1298 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1300 struct ap_data
*ap
= local
->ap
;
1301 char body
[8 + WLAN_AUTH_CHALLENGE_LEN
], *challenge
= NULL
;
1303 u16 auth_alg
, auth_transaction
, status_code
;
1305 u16 resp
= WLAN_STATUS_SUCCESS
, fc
;
1306 struct sta_info
*sta
= NULL
;
1307 struct ieee80211_crypt_data
*crypt
;
1309 DECLARE_MAC_BUF(mac
);
1311 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1313 fc
= le16_to_cpu(hdr
->frame_ctl
);
1314 hdrlen
= hostap_80211_get_hdrlen(fc
);
1317 PDEBUG(DEBUG_AP
, "%s: handle_authen - too short payload "
1318 "(len=%d) from %s\n", dev
->name
, len
,
1319 print_mac(mac
, hdr
->addr2
));
1323 spin_lock_bh(&local
->ap
->sta_table_lock
);
1324 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1326 atomic_inc(&sta
->users
);
1327 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1329 if (sta
&& sta
->crypt
)
1333 if (skb
->len
>= hdrlen
+ 3)
1334 idx
= skb
->data
[hdrlen
+ 3] >> 6;
1335 crypt
= local
->crypt
[idx
];
1338 pos
= (__le16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1339 auth_alg
= __le16_to_cpu(*pos
);
1341 auth_transaction
= __le16_to_cpu(*pos
);
1343 status_code
= __le16_to_cpu(*pos
);
1346 if (memcmp(dev
->dev_addr
, hdr
->addr2
, ETH_ALEN
) == 0 ||
1347 ap_control_mac_deny(&ap
->mac_restrictions
, hdr
->addr2
)) {
1348 txt
= "authentication denied";
1349 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1353 if (((local
->auth_algs
& PRISM2_AUTH_OPEN
) &&
1354 auth_alg
== WLAN_AUTH_OPEN
) ||
1355 ((local
->auth_algs
& PRISM2_AUTH_SHARED_KEY
) &&
1356 crypt
&& auth_alg
== WLAN_AUTH_SHARED_KEY
)) {
1358 txt
= "unsupported algorithm";
1359 resp
= WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG
;
1365 if (*u
== WLAN_EID_CHALLENGE
) {
1366 if (*(u
+ 1) != WLAN_AUTH_CHALLENGE_LEN
) {
1367 txt
= "invalid challenge len";
1368 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1371 if (len
- 8 < WLAN_AUTH_CHALLENGE_LEN
) {
1372 txt
= "challenge underflow";
1373 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1376 challenge
= (char *) (u
+ 2);
1380 if (sta
&& sta
->ap
) {
1381 if (time_after(jiffies
, sta
->u
.ap
.last_beacon
+
1382 (10 * sta
->listen_interval
* HZ
) / 1024)) {
1383 PDEBUG(DEBUG_AP
, "%s: no beacons received for a while,"
1384 " assuming AP %s is now STA\n",
1385 dev
->name
, print_mac(mac
, sta
->addr
));
1388 sta
->u
.sta
.challenge
= NULL
;
1390 txt
= "AP trying to authenticate?";
1391 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1396 if ((auth_alg
== WLAN_AUTH_OPEN
&& auth_transaction
== 1) ||
1397 (auth_alg
== WLAN_AUTH_SHARED_KEY
&&
1398 (auth_transaction
== 1 ||
1399 (auth_transaction
== 3 && sta
!= NULL
&&
1400 sta
->u
.sta
.challenge
!= NULL
)))) {
1402 txt
= "unknown authentication transaction number";
1403 resp
= WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION
;
1410 if (local
->ap
->num_sta
>= MAX_STA_COUNT
) {
1411 /* FIX: might try to remove some old STAs first? */
1412 txt
= "no more room for new STAs";
1413 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1417 sta
= ap_add_sta(local
->ap
, hdr
->addr2
);
1419 txt
= "ap_add_sta failed";
1420 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1426 case WLAN_AUTH_OPEN
:
1428 /* IEEE 802.11 standard is not completely clear about
1429 * whether STA is considered authenticated after
1430 * authentication OK frame has been send or after it
1431 * has been ACKed. In order to reduce interoperability
1432 * issues, mark the STA authenticated before ACK. */
1433 sta
->flags
|= WLAN_STA_AUTH
;
1436 case WLAN_AUTH_SHARED_KEY
:
1437 if (auth_transaction
== 1) {
1438 if (sta
->u
.sta
.challenge
== NULL
) {
1439 sta
->u
.sta
.challenge
=
1440 ap_auth_make_challenge(local
->ap
);
1441 if (sta
->u
.sta
.challenge
== NULL
) {
1442 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1447 if (sta
->u
.sta
.challenge
== NULL
||
1448 challenge
== NULL
||
1449 memcmp(sta
->u
.sta
.challenge
, challenge
,
1450 WLAN_AUTH_CHALLENGE_LEN
) != 0 ||
1451 !(fc
& IEEE80211_FCTL_PROTECTED
)) {
1452 txt
= "challenge response incorrect";
1453 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1457 txt
= "challenge OK - authOK";
1458 /* IEEE 802.11 standard is not completely clear about
1459 * whether STA is considered authenticated after
1460 * authentication OK frame has been send or after it
1461 * has been ACKed. In order to reduce interoperability
1462 * issues, mark the STA authenticated before ACK. */
1463 sta
->flags
|= WLAN_STA_AUTH
;
1464 kfree(sta
->u
.sta
.challenge
);
1465 sta
->u
.sta
.challenge
= NULL
;
1471 pos
= (__le16
*) body
;
1472 *pos
= cpu_to_le16(auth_alg
);
1474 *pos
= cpu_to_le16(auth_transaction
+ 1);
1476 *pos
= cpu_to_le16(resp
); /* status_code */
1480 if (resp
== WLAN_STATUS_SUCCESS
&& sta
!= NULL
&&
1481 sta
->u
.sta
.challenge
!= NULL
&&
1482 auth_alg
== WLAN_AUTH_SHARED_KEY
&& auth_transaction
== 1) {
1483 u8
*tmp
= (u8
*) pos
;
1484 *tmp
++ = WLAN_EID_CHALLENGE
;
1485 *tmp
++ = WLAN_AUTH_CHALLENGE_LEN
;
1487 memcpy(pos
, sta
->u
.sta
.challenge
, WLAN_AUTH_CHALLENGE_LEN
);
1488 olen
+= 2 + WLAN_AUTH_CHALLENGE_LEN
;
1491 prism2_send_mgmt(dev
, IEEE80211_FTYPE_MGMT
| IEEE80211_STYPE_AUTH
,
1492 body
, olen
, hdr
->addr2
, ap
->tx_callback_auth
);
1495 sta
->last_rx
= jiffies
;
1496 atomic_dec(&sta
->users
);
1500 PDEBUG(DEBUG_AP
, "%s: %s auth (alg=%d "
1501 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n",
1502 dev
->name
, print_mac(mac
, hdr
->addr2
), auth_alg
,
1503 auth_transaction
, status_code
, len
, fc
, resp
, txt
);
1508 /* Called only as a scheduled task for pending AP frames. */
1509 static void handle_assoc(local_info_t
*local
, struct sk_buff
*skb
,
1510 struct hostap_80211_rx_status
*rx_stats
, int reassoc
)
1512 struct net_device
*dev
= local
->dev
;
1513 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1514 char body
[12], *p
, *lpos
;
1517 u16 resp
= WLAN_STATUS_SUCCESS
;
1518 struct sta_info
*sta
= NULL
;
1519 int send_deauth
= 0;
1521 u8 prev_ap
[ETH_ALEN
];
1522 DECLARE_MAC_BUF(mac
);
1524 left
= len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1526 if (len
< (reassoc
? 10 : 4)) {
1527 PDEBUG(DEBUG_AP
, "%s: handle_assoc - too short payload "
1528 "(len=%d, reassoc=%d) from %s\n",
1529 dev
->name
, len
, reassoc
, print_mac(mac
, hdr
->addr2
));
1533 spin_lock_bh(&local
->ap
->sta_table_lock
);
1534 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1535 if (sta
== NULL
|| (sta
->flags
& WLAN_STA_AUTH
) == 0) {
1536 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1537 txt
= "trying to associate before authentication";
1539 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1540 sta
= NULL
; /* do not decrement sta->users */
1543 atomic_inc(&sta
->users
);
1544 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1546 pos
= (__le16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1547 sta
->capability
= __le16_to_cpu(*pos
);
1549 sta
->listen_interval
= __le16_to_cpu(*pos
);
1553 memcpy(prev_ap
, pos
, ETH_ALEN
);
1554 pos
++; pos
++; pos
++; left
-= 6;
1556 memset(prev_ap
, 0, ETH_ALEN
);
1560 unsigned char *u
= (unsigned char *) pos
;
1562 if (*u
== WLAN_EID_SSID
) {
1567 if (ileft
> left
|| ileft
> MAX_SSID_LEN
) {
1568 txt
= "SSID overflow";
1569 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1573 if (ileft
!= strlen(local
->essid
) ||
1574 memcmp(local
->essid
, u
, ileft
) != 0) {
1575 txt
= "not our SSID";
1576 resp
= WLAN_STATUS_ASSOC_DENIED_UNSPEC
;
1584 if (left
>= 2 && *u
== WLAN_EID_SUPP_RATES
) {
1589 if (ileft
> left
|| ileft
== 0 ||
1590 ileft
> WLAN_SUPP_RATES_MAX
) {
1591 txt
= "SUPP_RATES len error";
1592 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1596 memset(sta
->supported_rates
, 0,
1597 sizeof(sta
->supported_rates
));
1598 memcpy(sta
->supported_rates
, u
, ileft
);
1599 prism2_check_tx_rates(sta
);
1606 PDEBUG(DEBUG_AP
, "%s: assoc from %s"
1607 " with extra data (%d bytes) [",
1608 dev
->name
, print_mac(mac
, hdr
->addr2
), left
);
1610 PDEBUG2(DEBUG_AP
, "<%02x>", *u
);
1613 PDEBUG2(DEBUG_AP
, "]\n");
1616 txt
= "frame underflow";
1617 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1621 /* get a unique AID */
1623 txt
= "OK, old AID";
1625 spin_lock_bh(&local
->ap
->sta_table_lock
);
1626 for (sta
->aid
= 1; sta
->aid
<= MAX_AID_TABLE_SIZE
; sta
->aid
++)
1627 if (local
->ap
->sta_aid
[sta
->aid
- 1] == NULL
)
1629 if (sta
->aid
> MAX_AID_TABLE_SIZE
) {
1631 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1632 resp
= WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA
;
1633 txt
= "no room for more AIDs";
1635 local
->ap
->sta_aid
[sta
->aid
- 1] = sta
;
1636 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1637 txt
= "OK, new AID";
1642 pos
= (__le16
*) body
;
1645 *pos
= cpu_to_le16(WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH
);
1648 /* FIX: CF-Pollable and CF-PollReq should be set to match the
1649 * values in beacons/probe responses */
1650 /* FIX: how about privacy and WEP? */
1652 *pos
= cpu_to_le16(WLAN_CAPABILITY_ESS
);
1656 *pos
= cpu_to_le16(resp
);
1659 *pos
= cpu_to_le16((sta
&& sta
->aid
> 0 ? sta
->aid
: 0) |
1660 BIT(14) | BIT(15)); /* AID */
1663 /* Supported rates (Information element) */
1665 *p
++ = WLAN_EID_SUPP_RATES
;
1668 if (local
->tx_rate_control
& WLAN_RATE_1M
) {
1669 *p
++ = local
->basic_rates
& WLAN_RATE_1M
? 0x82 : 0x02;
1672 if (local
->tx_rate_control
& WLAN_RATE_2M
) {
1673 *p
++ = local
->basic_rates
& WLAN_RATE_2M
? 0x84 : 0x04;
1676 if (local
->tx_rate_control
& WLAN_RATE_5M5
) {
1677 *p
++ = local
->basic_rates
& WLAN_RATE_5M5
?
1681 if (local
->tx_rate_control
& WLAN_RATE_11M
) {
1682 *p
++ = local
->basic_rates
& WLAN_RATE_11M
?
1689 prism2_send_mgmt(dev
, IEEE80211_FTYPE_MGMT
|
1690 (send_deauth
? IEEE80211_STYPE_DEAUTH
:
1691 (reassoc
? IEEE80211_STYPE_REASSOC_RESP
:
1692 IEEE80211_STYPE_ASSOC_RESP
)),
1693 body
, (u8
*) pos
- (u8
*) body
,
1695 send_deauth
? 0 : local
->ap
->tx_callback_assoc
);
1698 if (resp
== WLAN_STATUS_SUCCESS
) {
1699 sta
->last_rx
= jiffies
;
1700 /* STA will be marked associated from TX callback, if
1701 * AssocResp is ACKed */
1703 atomic_dec(&sta
->users
);
1707 PDEBUG(DEBUG_AP
, "%s: %s %sassoc (len=%d "
1708 "prev_ap=%s) => %d(%d) (%s)\n",
1709 dev
->name
, print_mac(mac
, hdr
->addr2
), reassoc
? "re" : "", len
,
1710 print_mac(mac
, prev_ap
), resp
, send_deauth
, txt
);
1715 /* Called only as a scheduled task for pending AP frames. */
1716 static void handle_deauth(local_info_t
*local
, struct sk_buff
*skb
,
1717 struct hostap_80211_rx_status
*rx_stats
)
1719 struct net_device
*dev
= local
->dev
;
1720 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1721 char *body
= (char *) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1725 struct sta_info
*sta
= NULL
;
1726 DECLARE_MAC_BUF(mac
);
1728 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1731 printk("handle_deauth - too short payload (len=%d)\n", len
);
1735 pos
= (__le16
*) body
;
1736 reason_code
= le16_to_cpu(*pos
);
1738 PDEBUG(DEBUG_AP
, "%s: deauthentication: %s len=%d, "
1739 "reason_code=%d\n", dev
->name
, print_mac(mac
, hdr
->addr2
), len
,
1742 spin_lock_bh(&local
->ap
->sta_table_lock
);
1743 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1745 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
1746 hostap_event_expired_sta(local
->dev
, sta
);
1747 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
1749 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1751 printk("%s: deauthentication from %s, "
1752 "reason_code=%d, but STA not authenticated\n", dev
->name
,
1753 print_mac(mac
, hdr
->addr2
), reason_code
);
1758 /* Called only as a scheduled task for pending AP frames. */
1759 static void handle_disassoc(local_info_t
*local
, struct sk_buff
*skb
,
1760 struct hostap_80211_rx_status
*rx_stats
)
1762 struct net_device
*dev
= local
->dev
;
1763 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
1764 char *body
= skb
->data
+ IEEE80211_MGMT_HDR_LEN
;
1768 struct sta_info
*sta
= NULL
;
1769 DECLARE_MAC_BUF(mac
);
1771 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1774 printk("handle_disassoc - too short payload (len=%d)\n", len
);
1778 pos
= (__le16
*) body
;
1779 reason_code
= le16_to_cpu(*pos
);
1781 PDEBUG(DEBUG_AP
, "%s: disassociation: %s len=%d, "
1782 "reason_code=%d\n", dev
->name
, print_mac(mac
, hdr
->addr2
), len
,
1785 spin_lock_bh(&local
->ap
->sta_table_lock
);
1786 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1788 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
1789 hostap_event_expired_sta(local
->dev
, sta
);
1790 sta
->flags
&= ~WLAN_STA_ASSOC
;
1792 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1794 printk("%s: disassociation from %s, "
1795 "reason_code=%d, but STA not authenticated\n",
1796 dev
->name
, print_mac(mac
, hdr
->addr2
), reason_code
);
1801 /* Called only as a scheduled task for pending AP frames. */
1802 static void ap_handle_data_nullfunc(local_info_t
*local
,
1803 struct ieee80211_hdr_4addr
*hdr
)
1805 struct net_device
*dev
= local
->dev
;
1807 /* some STA f/w's seem to require control::ACK frame for
1808 * data::nullfunc, but at least Prism2 station f/w version 0.8.0 does
1810 * send control::ACK for the data::nullfunc */
1812 printk(KERN_DEBUG
"Sending control::ACK for data::nullfunc\n");
1813 prism2_send_mgmt(dev
, IEEE80211_FTYPE_CTL
| IEEE80211_STYPE_ACK
,
1814 NULL
, 0, hdr
->addr2
, 0);
1818 /* Called only as a scheduled task for pending AP frames. */
1819 static void ap_handle_dropped_data(local_info_t
*local
,
1820 struct ieee80211_hdr_4addr
*hdr
)
1822 struct net_device
*dev
= local
->dev
;
1823 struct sta_info
*sta
;
1826 spin_lock_bh(&local
->ap
->sta_table_lock
);
1827 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1829 atomic_inc(&sta
->users
);
1830 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1832 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
)) {
1833 PDEBUG(DEBUG_AP
, "ap_handle_dropped_data: STA is now okay?\n");
1834 atomic_dec(&sta
->users
);
1838 reason
= cpu_to_le16(WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA
);
1839 prism2_send_mgmt(dev
, IEEE80211_FTYPE_MGMT
|
1840 ((sta
== NULL
|| !(sta
->flags
& WLAN_STA_ASSOC
)) ?
1841 IEEE80211_STYPE_DEAUTH
: IEEE80211_STYPE_DISASSOC
),
1842 (char *) &reason
, sizeof(reason
), hdr
->addr2
, 0);
1845 atomic_dec(&sta
->users
);
1848 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1851 /* Called only as a scheduled task for pending AP frames. */
1852 static void pspoll_send_buffered(local_info_t
*local
, struct sta_info
*sta
,
1853 struct sk_buff
*skb
)
1855 struct hostap_skb_tx_data
*meta
;
1857 if (!(sta
->flags
& WLAN_STA_PS
)) {
1858 /* Station has moved to non-PS mode, so send all buffered
1859 * frames using normal device queue. */
1860 dev_queue_xmit(skb
);
1864 /* add a flag for hostap_handle_sta_tx() to know that this skb should
1865 * be passed through even though STA is using PS */
1866 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
1867 meta
->flags
|= HOSTAP_TX_FLAGS_BUFFERED_FRAME
;
1868 if (!skb_queue_empty(&sta
->tx_buf
)) {
1869 /* indicate to STA that more frames follow */
1870 meta
->flags
|= HOSTAP_TX_FLAGS_ADD_MOREDATA
;
1872 dev_queue_xmit(skb
);
1876 /* Called only as a scheduled task for pending AP frames. */
1877 static void handle_pspoll(local_info_t
*local
,
1878 struct ieee80211_hdr_4addr
*hdr
,
1879 struct hostap_80211_rx_status
*rx_stats
)
1881 struct net_device
*dev
= local
->dev
;
1882 struct sta_info
*sta
;
1884 struct sk_buff
*skb
;
1885 DECLARE_MAC_BUF(mac
);
1887 PDEBUG(DEBUG_PS2
, "handle_pspoll: BSSID=%s"
1888 ", TA=%s PWRMGT=%d\n",
1889 print_mac(mac
, hdr
->addr1
), print_mac(mac
, hdr
->addr2
),
1890 !!(le16_to_cpu(hdr
->frame_ctl
) & IEEE80211_FCTL_PM
));
1892 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
1893 PDEBUG(DEBUG_AP
, "handle_pspoll - addr1(BSSID)=%s"
1894 " not own MAC\n", print_mac(mac
, hdr
->addr1
));
1898 aid
= le16_to_cpu(hdr
->duration_id
);
1899 if ((aid
& (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) {
1900 PDEBUG(DEBUG_PS
, " PSPOLL and AID[15:14] not set\n");
1903 aid
&= ~BIT(15) & ~BIT(14);
1904 if (aid
== 0 || aid
> MAX_AID_TABLE_SIZE
) {
1905 PDEBUG(DEBUG_PS
, " invalid aid=%d\n", aid
);
1908 PDEBUG(DEBUG_PS2
, " aid=%d\n", aid
);
1910 spin_lock_bh(&local
->ap
->sta_table_lock
);
1911 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1913 atomic_inc(&sta
->users
);
1914 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1917 PDEBUG(DEBUG_PS
, " STA not found\n");
1920 if (sta
->aid
!= aid
) {
1921 PDEBUG(DEBUG_PS
, " received aid=%i does not match with "
1922 "assoc.aid=%d\n", aid
, sta
->aid
);
1927 * - add timeout for buffering (clear aid in TIM vector if buffer timed
1928 * out (expiry time must be longer than ListenInterval for
1929 * the corresponding STA; "8802-11: 11.2.1.9 AP aging function"
1930 * - what to do, if buffered, pspolled, and sent frame is not ACKed by
1931 * sta; store buffer for later use and leave TIM aid bit set? use
1932 * TX event to check whether frame was ACKed?
1935 while ((skb
= skb_dequeue(&sta
->tx_buf
)) != NULL
) {
1936 /* send buffered frame .. */
1937 PDEBUG(DEBUG_PS2
, "Sending buffered frame to STA after PS POLL"
1938 " (buffer_count=%d)\n", skb_queue_len(&sta
->tx_buf
));
1940 pspoll_send_buffered(local
, sta
, skb
);
1942 if (sta
->flags
& WLAN_STA_PS
) {
1943 /* send only one buffered packet per PS Poll */
1944 /* FIX: should ignore further PS Polls until the
1945 * buffered packet that was just sent is acknowledged
1946 * (Tx or TxExc event) */
1951 if (skb_queue_empty(&sta
->tx_buf
)) {
1952 /* try to clear aid from TIM */
1953 if (!(sta
->flags
& WLAN_STA_TIM
))
1954 PDEBUG(DEBUG_PS2
, "Re-unsetting TIM for aid %d\n",
1956 hostap_set_tim(local
, aid
, 0);
1957 sta
->flags
&= ~WLAN_STA_TIM
;
1960 atomic_dec(&sta
->users
);
1964 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1966 static void handle_wds_oper_queue(struct work_struct
*work
)
1968 struct ap_data
*ap
= container_of(work
, struct ap_data
,
1970 local_info_t
*local
= ap
->local
;
1971 struct wds_oper_data
*entry
, *prev
;
1972 DECLARE_MAC_BUF(mac
);
1974 spin_lock_bh(&local
->lock
);
1975 entry
= local
->ap
->wds_oper_entries
;
1976 local
->ap
->wds_oper_entries
= NULL
;
1977 spin_unlock_bh(&local
->lock
);
1980 PDEBUG(DEBUG_AP
, "%s: %s automatic WDS connection "
1983 entry
->type
== WDS_ADD
? "adding" : "removing",
1984 print_mac(mac
, entry
->addr
));
1985 if (entry
->type
== WDS_ADD
)
1986 prism2_wds_add(local
, entry
->addr
, 0);
1987 else if (entry
->type
== WDS_DEL
)
1988 prism2_wds_del(local
, entry
->addr
, 0, 1);
1991 entry
= entry
->next
;
1997 /* Called only as a scheduled task for pending AP frames. */
1998 static void handle_beacon(local_info_t
*local
, struct sk_buff
*skb
,
1999 struct hostap_80211_rx_status
*rx_stats
)
2001 struct ieee80211_hdr_4addr
*hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2002 char *body
= skb
->data
+ IEEE80211_MGMT_HDR_LEN
;
2004 u16 beacon_int
, capability
;
2007 unsigned char *supp_rates
= NULL
;
2008 int ssid_len
= 0, supp_rates_len
= 0;
2009 struct sta_info
*sta
= NULL
;
2010 int new_sta
= 0, channel
= -1;
2012 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
2014 if (len
< 8 + 2 + 2) {
2015 printk(KERN_DEBUG
"handle_beacon - too short payload "
2020 pos
= (__le16
*) body
;
2023 /* Timestamp (8 octets) */
2024 pos
+= 4; left
-= 8;
2025 /* Beacon interval (2 octets) */
2026 beacon_int
= le16_to_cpu(*pos
);
2028 /* Capability information (2 octets) */
2029 capability
= le16_to_cpu(*pos
);
2032 if (local
->ap
->ap_policy
!= AP_OTHER_AP_EVEN_IBSS
&&
2033 capability
& WLAN_CAPABILITY_IBSS
)
2038 unsigned char *u
= (unsigned char *) pos
;
2040 if (*u
== WLAN_EID_SSID
) {
2045 if (ileft
> left
|| ileft
> MAX_SSID_LEN
) {
2046 PDEBUG(DEBUG_AP
, "SSID: overflow\n");
2050 if (local
->ap
->ap_policy
== AP_OTHER_AP_SAME_SSID
&&
2051 (ileft
!= strlen(local
->essid
) ||
2052 memcmp(local
->essid
, u
, ileft
) != 0)) {
2064 if (*u
== WLAN_EID_SUPP_RATES
) {
2069 if (ileft
> left
|| ileft
== 0 || ileft
> 8) {
2070 PDEBUG(DEBUG_AP
, " - SUPP_RATES len error\n");
2075 supp_rates_len
= ileft
;
2081 if (*u
== WLAN_EID_DS_PARAMS
) {
2086 if (ileft
> left
|| ileft
!= 1) {
2087 PDEBUG(DEBUG_AP
, " - DS_PARAMS len error\n");
2098 spin_lock_bh(&local
->ap
->sta_table_lock
);
2099 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2101 atomic_inc(&sta
->users
);
2102 spin_unlock_bh(&local
->ap
->sta_table_lock
);
2107 sta
= ap_add_sta(local
->ap
, hdr
->addr2
);
2109 printk(KERN_INFO
"prism2: kmalloc failed for AP "
2110 "data structure\n");
2113 hostap_event_new_sta(local
->dev
, sta
);
2115 /* mark APs authentication and associated for pseudo ad-hoc
2116 * style communication */
2117 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
2119 if (local
->ap
->autom_ap_wds
) {
2120 hostap_wds_link_oper(local
, sta
->addr
, WDS_ADD
);
2126 sta
->u
.ap
.ssid_len
= ssid_len
;
2127 memcpy(sta
->u
.ap
.ssid
, ssid
, ssid_len
);
2128 sta
->u
.ap
.ssid
[ssid_len
] = '\0';
2130 sta
->u
.ap
.ssid_len
= 0;
2131 sta
->u
.ap
.ssid
[0] = '\0';
2133 sta
->u
.ap
.channel
= channel
;
2135 sta
->rx_bytes
+= len
;
2136 sta
->u
.ap
.last_beacon
= sta
->last_rx
= jiffies
;
2137 sta
->capability
= capability
;
2138 sta
->listen_interval
= beacon_int
;
2140 atomic_dec(&sta
->users
);
2143 memset(sta
->supported_rates
, 0, sizeof(sta
->supported_rates
));
2144 memcpy(sta
->supported_rates
, supp_rates
, supp_rates_len
);
2145 prism2_check_tx_rates(sta
);
2149 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2152 /* Called only as a tasklet. */
2153 static void handle_ap_item(local_info_t
*local
, struct sk_buff
*skb
,
2154 struct hostap_80211_rx_status
*rx_stats
)
2156 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2157 struct net_device
*dev
= local
->dev
;
2158 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2159 u16 fc
, type
, stype
;
2160 struct ieee80211_hdr_4addr
*hdr
;
2161 DECLARE_MAC_BUF(mac
);
2163 /* FIX: should give skb->len to handler functions and check that the
2164 * buffer is long enough */
2165 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2166 fc
= le16_to_cpu(hdr
->frame_ctl
);
2167 type
= WLAN_FC_GET_TYPE(fc
);
2168 stype
= WLAN_FC_GET_STYPE(fc
);
2170 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2171 if (!local
->hostapd
&& type
== IEEE80211_FTYPE_DATA
) {
2172 PDEBUG(DEBUG_AP
, "handle_ap_item - data frame\n");
2174 if (!(fc
& IEEE80211_FCTL_TODS
) ||
2175 (fc
& IEEE80211_FCTL_FROMDS
)) {
2176 if (stype
== IEEE80211_STYPE_NULLFUNC
) {
2177 /* no ToDS nullfunc seems to be used to check
2178 * AP association; so send reject message to
2179 * speed up re-association */
2180 ap_handle_dropped_data(local
, hdr
);
2183 PDEBUG(DEBUG_AP
, " not ToDS frame (fc=0x%04x)\n",
2188 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
2189 PDEBUG(DEBUG_AP
, "handle_ap_item - addr1(BSSID)="
2191 print_mac(mac
, hdr
->addr1
));
2195 if (local
->ap
->nullfunc_ack
&&
2196 stype
== IEEE80211_STYPE_NULLFUNC
)
2197 ap_handle_data_nullfunc(local
, hdr
);
2199 ap_handle_dropped_data(local
, hdr
);
2203 if (type
== IEEE80211_FTYPE_MGMT
&& stype
== IEEE80211_STYPE_BEACON
) {
2204 handle_beacon(local
, skb
, rx_stats
);
2207 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2209 if (type
== IEEE80211_FTYPE_CTL
&& stype
== IEEE80211_STYPE_PSPOLL
) {
2210 handle_pspoll(local
, hdr
, rx_stats
);
2214 if (local
->hostapd
) {
2215 PDEBUG(DEBUG_AP
, "Unknown frame in AP queue: type=0x%02x "
2216 "subtype=0x%02x\n", type
, stype
);
2220 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2221 if (type
!= IEEE80211_FTYPE_MGMT
) {
2222 PDEBUG(DEBUG_AP
, "handle_ap_item - not a management frame?\n");
2226 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
2227 PDEBUG(DEBUG_AP
, "handle_ap_item - addr1(DA)=%s"
2228 " not own MAC\n", print_mac(mac
, hdr
->addr1
));
2232 if (memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
)) {
2233 PDEBUG(DEBUG_AP
, "handle_ap_item - addr3(BSSID)=%s"
2234 " not own MAC\n", print_mac(mac
, hdr
->addr3
));
2239 case IEEE80211_STYPE_ASSOC_REQ
:
2240 handle_assoc(local
, skb
, rx_stats
, 0);
2242 case IEEE80211_STYPE_ASSOC_RESP
:
2243 PDEBUG(DEBUG_AP
, "==> ASSOC RESP (ignored)\n");
2245 case IEEE80211_STYPE_REASSOC_REQ
:
2246 handle_assoc(local
, skb
, rx_stats
, 1);
2248 case IEEE80211_STYPE_REASSOC_RESP
:
2249 PDEBUG(DEBUG_AP
, "==> REASSOC RESP (ignored)\n");
2251 case IEEE80211_STYPE_ATIM
:
2252 PDEBUG(DEBUG_AP
, "==> ATIM (ignored)\n");
2254 case IEEE80211_STYPE_DISASSOC
:
2255 handle_disassoc(local
, skb
, rx_stats
);
2257 case IEEE80211_STYPE_AUTH
:
2258 handle_authen(local
, skb
, rx_stats
);
2260 case IEEE80211_STYPE_DEAUTH
:
2261 handle_deauth(local
, skb
, rx_stats
);
2264 PDEBUG(DEBUG_AP
, "Unknown mgmt frame subtype 0x%02x\n",
2268 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2275 /* Called only as a tasklet (software IRQ) */
2276 void hostap_rx(struct net_device
*dev
, struct sk_buff
*skb
,
2277 struct hostap_80211_rx_status
*rx_stats
)
2279 struct hostap_interface
*iface
;
2280 local_info_t
*local
;
2282 struct ieee80211_hdr_4addr
*hdr
;
2284 iface
= netdev_priv(dev
);
2285 local
= iface
->local
;
2290 local
->stats
.rx_packets
++;
2292 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2293 fc
= le16_to_cpu(hdr
->frame_ctl
);
2295 if (local
->ap
->ap_policy
== AP_OTHER_AP_SKIP_ALL
&&
2296 WLAN_FC_GET_TYPE(fc
) == IEEE80211_FTYPE_MGMT
&&
2297 WLAN_FC_GET_STYPE(fc
) == IEEE80211_STYPE_BEACON
)
2300 skb
->protocol
= __constant_htons(ETH_P_HOSTAP
);
2301 handle_ap_item(local
, skb
, rx_stats
);
2309 /* Called only as a tasklet (software IRQ) */
2310 static void schedule_packet_send(local_info_t
*local
, struct sta_info
*sta
)
2312 struct sk_buff
*skb
;
2313 struct ieee80211_hdr_4addr
*hdr
;
2314 struct hostap_80211_rx_status rx_stats
;
2315 DECLARE_MAC_BUF(mac
);
2317 if (skb_queue_empty(&sta
->tx_buf
))
2320 skb
= dev_alloc_skb(16);
2322 printk(KERN_DEBUG
"%s: schedule_packet_send: skb alloc "
2323 "failed\n", local
->dev
->name
);
2327 hdr
= (struct ieee80211_hdr_4addr
*) skb_put(skb
, 16);
2329 /* Generate a fake pspoll frame to start packet delivery */
2330 hdr
->frame_ctl
= __constant_cpu_to_le16(
2331 IEEE80211_FTYPE_CTL
| IEEE80211_STYPE_PSPOLL
);
2332 memcpy(hdr
->addr1
, local
->dev
->dev_addr
, ETH_ALEN
);
2333 memcpy(hdr
->addr2
, sta
->addr
, ETH_ALEN
);
2334 hdr
->duration_id
= cpu_to_le16(sta
->aid
| BIT(15) | BIT(14));
2336 PDEBUG(DEBUG_PS2
, "%s: Scheduling buffered packet delivery for STA "
2337 "%s\n", local
->dev
->name
, print_mac(mac
, sta
->addr
));
2339 skb
->dev
= local
->dev
;
2341 memset(&rx_stats
, 0, sizeof(rx_stats
));
2342 hostap_rx(local
->dev
, skb
, &rx_stats
);
2346 int prism2_ap_get_sta_qual(local_info_t
*local
, struct sockaddr addr
[],
2347 struct iw_quality qual
[], int buf_size
,
2350 struct ap_data
*ap
= local
->ap
;
2351 struct list_head
*ptr
;
2354 spin_lock_bh(&ap
->sta_table_lock
);
2356 for (ptr
= ap
->sta_list
.next
; ptr
!= NULL
&& ptr
!= &ap
->sta_list
;
2358 struct sta_info
*sta
= (struct sta_info
*) ptr
;
2360 if (aplist
&& !sta
->ap
)
2362 addr
[count
].sa_family
= ARPHRD_ETHER
;
2363 memcpy(addr
[count
].sa_data
, sta
->addr
, ETH_ALEN
);
2364 if (sta
->last_rx_silence
== 0)
2365 qual
[count
].qual
= sta
->last_rx_signal
< 27 ?
2366 0 : (sta
->last_rx_signal
- 27) * 92 / 127;
2368 qual
[count
].qual
= sta
->last_rx_signal
-
2369 sta
->last_rx_silence
- 35;
2370 qual
[count
].level
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_signal
);
2371 qual
[count
].noise
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_silence
);
2372 qual
[count
].updated
= sta
->last_rx_updated
;
2374 sta
->last_rx_updated
= IW_QUAL_DBM
;
2377 if (count
>= buf_size
)
2380 spin_unlock_bh(&ap
->sta_table_lock
);
2386 /* Translate our list of Access Points & Stations to a card independant
2387 * format that the Wireless Tools will understand - Jean II */
2388 int prism2_ap_translate_scan(struct net_device
*dev
, char *buffer
)
2390 struct hostap_interface
*iface
;
2391 local_info_t
*local
;
2393 struct list_head
*ptr
;
2394 struct iw_event iwe
;
2395 char *current_ev
= buffer
;
2396 char *end_buf
= buffer
+ IW_SCAN_MAX_DATA
;
2397 #if !defined(PRISM2_NO_KERNEL_IEEE80211_MGMT)
2401 iface
= netdev_priv(dev
);
2402 local
= iface
->local
;
2405 spin_lock_bh(&ap
->sta_table_lock
);
2407 for (ptr
= ap
->sta_list
.next
; ptr
!= NULL
&& ptr
!= &ap
->sta_list
;
2409 struct sta_info
*sta
= (struct sta_info
*) ptr
;
2411 /* First entry *MUST* be the AP MAC address */
2412 memset(&iwe
, 0, sizeof(iwe
));
2413 iwe
.cmd
= SIOCGIWAP
;
2414 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
2415 memcpy(iwe
.u
.ap_addr
.sa_data
, sta
->addr
, ETH_ALEN
);
2416 iwe
.len
= IW_EV_ADDR_LEN
;
2417 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2420 /* Use the mode to indicate if it's a station or
2421 * an Access Point */
2422 memset(&iwe
, 0, sizeof(iwe
));
2423 iwe
.cmd
= SIOCGIWMODE
;
2425 iwe
.u
.mode
= IW_MODE_MASTER
;
2427 iwe
.u
.mode
= IW_MODE_INFRA
;
2428 iwe
.len
= IW_EV_UINT_LEN
;
2429 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2433 memset(&iwe
, 0, sizeof(iwe
));
2435 if (sta
->last_rx_silence
== 0)
2436 iwe
.u
.qual
.qual
= sta
->last_rx_signal
< 27 ?
2437 0 : (sta
->last_rx_signal
- 27) * 92 / 127;
2439 iwe
.u
.qual
.qual
= sta
->last_rx_signal
-
2440 sta
->last_rx_silence
- 35;
2441 iwe
.u
.qual
.level
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_signal
);
2442 iwe
.u
.qual
.noise
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_silence
);
2443 iwe
.u
.qual
.updated
= sta
->last_rx_updated
;
2444 iwe
.len
= IW_EV_QUAL_LEN
;
2445 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2448 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2450 memset(&iwe
, 0, sizeof(iwe
));
2451 iwe
.cmd
= SIOCGIWESSID
;
2452 iwe
.u
.data
.length
= sta
->u
.ap
.ssid_len
;
2453 iwe
.u
.data
.flags
= 1;
2454 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2458 memset(&iwe
, 0, sizeof(iwe
));
2459 iwe
.cmd
= SIOCGIWENCODE
;
2460 if (sta
->capability
& WLAN_CAPABILITY_PRIVACY
)
2462 IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
2464 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
2465 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2468 /* 0 byte memcpy */);
2470 if (sta
->u
.ap
.channel
> 0 &&
2471 sta
->u
.ap
.channel
<= FREQ_COUNT
) {
2472 memset(&iwe
, 0, sizeof(iwe
));
2473 iwe
.cmd
= SIOCGIWFREQ
;
2474 iwe
.u
.freq
.m
= freq_list
[sta
->u
.ap
.channel
- 1]
2477 current_ev
= iwe_stream_add_event(
2478 current_ev
, end_buf
, &iwe
,
2482 memset(&iwe
, 0, sizeof(iwe
));
2483 iwe
.cmd
= IWEVCUSTOM
;
2484 sprintf(buf
, "beacon_interval=%d",
2485 sta
->listen_interval
);
2486 iwe
.u
.data
.length
= strlen(buf
);
2487 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2490 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2492 sta
->last_rx_updated
= IW_QUAL_DBM
;
2494 /* To be continued, we should make good use of IWEVCUSTOM */
2497 spin_unlock_bh(&ap
->sta_table_lock
);
2499 return current_ev
- buffer
;
2503 static int prism2_hostapd_add_sta(struct ap_data
*ap
,
2504 struct prism2_hostapd_param
*param
)
2506 struct sta_info
*sta
;
2508 spin_lock_bh(&ap
->sta_table_lock
);
2509 sta
= ap_get_sta(ap
, param
->sta_addr
);
2511 atomic_inc(&sta
->users
);
2512 spin_unlock_bh(&ap
->sta_table_lock
);
2515 sta
= ap_add_sta(ap
, param
->sta_addr
);
2520 if (!(sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
2521 hostap_event_new_sta(sta
->local
->dev
, sta
);
2523 sta
->flags
|= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
2524 sta
->last_rx
= jiffies
;
2525 sta
->aid
= param
->u
.add_sta
.aid
;
2526 sta
->capability
= param
->u
.add_sta
.capability
;
2527 sta
->tx_supp_rates
= param
->u
.add_sta
.tx_supp_rates
;
2528 if (sta
->tx_supp_rates
& WLAN_RATE_1M
)
2529 sta
->supported_rates
[0] = 2;
2530 if (sta
->tx_supp_rates
& WLAN_RATE_2M
)
2531 sta
->supported_rates
[1] = 4;
2532 if (sta
->tx_supp_rates
& WLAN_RATE_5M5
)
2533 sta
->supported_rates
[2] = 11;
2534 if (sta
->tx_supp_rates
& WLAN_RATE_11M
)
2535 sta
->supported_rates
[3] = 22;
2536 prism2_check_tx_rates(sta
);
2537 atomic_dec(&sta
->users
);
2542 static int prism2_hostapd_remove_sta(struct ap_data
*ap
,
2543 struct prism2_hostapd_param
*param
)
2545 struct sta_info
*sta
;
2547 spin_lock_bh(&ap
->sta_table_lock
);
2548 sta
= ap_get_sta(ap
, param
->sta_addr
);
2550 ap_sta_hash_del(ap
, sta
);
2551 list_del(&sta
->list
);
2553 spin_unlock_bh(&ap
->sta_table_lock
);
2558 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
2559 hostap_event_expired_sta(sta
->local
->dev
, sta
);
2560 ap_free_sta(ap
, sta
);
2566 static int prism2_hostapd_get_info_sta(struct ap_data
*ap
,
2567 struct prism2_hostapd_param
*param
)
2569 struct sta_info
*sta
;
2571 spin_lock_bh(&ap
->sta_table_lock
);
2572 sta
= ap_get_sta(ap
, param
->sta_addr
);
2574 atomic_inc(&sta
->users
);
2575 spin_unlock_bh(&ap
->sta_table_lock
);
2580 param
->u
.get_info_sta
.inactive_sec
= (jiffies
- sta
->last_rx
) / HZ
;
2582 atomic_dec(&sta
->users
);
2588 static int prism2_hostapd_set_flags_sta(struct ap_data
*ap
,
2589 struct prism2_hostapd_param
*param
)
2591 struct sta_info
*sta
;
2593 spin_lock_bh(&ap
->sta_table_lock
);
2594 sta
= ap_get_sta(ap
, param
->sta_addr
);
2596 sta
->flags
|= param
->u
.set_flags_sta
.flags_or
;
2597 sta
->flags
&= param
->u
.set_flags_sta
.flags_and
;
2599 spin_unlock_bh(&ap
->sta_table_lock
);
2608 static int prism2_hostapd_sta_clear_stats(struct ap_data
*ap
,
2609 struct prism2_hostapd_param
*param
)
2611 struct sta_info
*sta
;
2614 spin_lock_bh(&ap
->sta_table_lock
);
2615 sta
= ap_get_sta(ap
, param
->sta_addr
);
2617 sta
->rx_packets
= sta
->tx_packets
= 0;
2618 sta
->rx_bytes
= sta
->tx_bytes
= 0;
2619 for (rate
= 0; rate
< WLAN_RATE_COUNT
; rate
++) {
2620 sta
->tx_count
[rate
] = 0;
2621 sta
->rx_count
[rate
] = 0;
2624 spin_unlock_bh(&ap
->sta_table_lock
);
2633 int prism2_hostapd(struct ap_data
*ap
, struct prism2_hostapd_param
*param
)
2635 switch (param
->cmd
) {
2636 case PRISM2_HOSTAPD_FLUSH
:
2637 ap_control_kickall(ap
);
2639 case PRISM2_HOSTAPD_ADD_STA
:
2640 return prism2_hostapd_add_sta(ap
, param
);
2641 case PRISM2_HOSTAPD_REMOVE_STA
:
2642 return prism2_hostapd_remove_sta(ap
, param
);
2643 case PRISM2_HOSTAPD_GET_INFO_STA
:
2644 return prism2_hostapd_get_info_sta(ap
, param
);
2645 case PRISM2_HOSTAPD_SET_FLAGS_STA
:
2646 return prism2_hostapd_set_flags_sta(ap
, param
);
2647 case PRISM2_HOSTAPD_STA_CLEAR_STATS
:
2648 return prism2_hostapd_sta_clear_stats(ap
, param
);
2650 printk(KERN_WARNING
"prism2_hostapd: unknown cmd=%d\n",
2657 /* Update station info for host-based TX rate control and return current
2659 static int ap_update_sta_tx_rate(struct sta_info
*sta
, struct net_device
*dev
)
2661 int ret
= sta
->tx_rate
;
2662 struct hostap_interface
*iface
;
2663 local_info_t
*local
;
2664 DECLARE_MAC_BUF(mac
);
2666 iface
= netdev_priv(dev
);
2667 local
= iface
->local
;
2669 sta
->tx_count
[sta
->tx_rate_idx
]++;
2670 sta
->tx_since_last_failure
++;
2671 sta
->tx_consecutive_exc
= 0;
2672 if (sta
->tx_since_last_failure
>= WLAN_RATE_UPDATE_COUNT
&&
2673 sta
->tx_rate_idx
< sta
->tx_max_rate
) {
2674 /* use next higher rate */
2675 int old_rate
, new_rate
;
2676 old_rate
= new_rate
= sta
->tx_rate_idx
;
2677 while (new_rate
< sta
->tx_max_rate
) {
2679 if (ap_tx_rate_ok(new_rate
, sta
, local
)) {
2680 sta
->tx_rate_idx
= new_rate
;
2684 if (old_rate
!= sta
->tx_rate_idx
) {
2685 switch (sta
->tx_rate_idx
) {
2686 case 0: sta
->tx_rate
= 10; break;
2687 case 1: sta
->tx_rate
= 20; break;
2688 case 2: sta
->tx_rate
= 55; break;
2689 case 3: sta
->tx_rate
= 110; break;
2690 default: sta
->tx_rate
= 0; break;
2692 PDEBUG(DEBUG_AP
, "%s: STA %s"
2693 " TX rate raised to %d\n",
2694 dev
->name
, print_mac(mac
, sta
->addr
), sta
->tx_rate
);
2696 sta
->tx_since_last_failure
= 0;
2703 /* Called only from software IRQ. Called for each TX frame prior possible
2704 * encryption and transmit. */
2705 ap_tx_ret
hostap_handle_sta_tx(local_info_t
*local
, struct hostap_tx_data
*tx
)
2707 struct sta_info
*sta
= NULL
;
2708 struct sk_buff
*skb
= tx
->skb
;
2710 struct ieee80211_hdr_4addr
*hdr
;
2711 struct hostap_skb_tx_data
*meta
;
2712 DECLARE_MAC_BUF(mac
);
2714 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
2715 ret
= AP_TX_CONTINUE
;
2716 if (local
->ap
== NULL
|| skb
->len
< 10 ||
2717 meta
->iface
->type
== HOSTAP_INTERFACE_STA
)
2720 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2722 if (hdr
->addr1
[0] & 0x01) {
2723 /* broadcast/multicast frame - no AP related processing */
2724 if (local
->ap
->num_sta
<= 0)
2729 /* unicast packet - check whether destination STA is associated */
2730 spin_lock(&local
->ap
->sta_table_lock
);
2731 sta
= ap_get_sta(local
->ap
, hdr
->addr1
);
2733 atomic_inc(&sta
->users
);
2734 spin_unlock(&local
->ap
->sta_table_lock
);
2736 if (local
->iw_mode
== IW_MODE_MASTER
&& sta
== NULL
&&
2737 !(meta
->flags
& HOSTAP_TX_FLAGS_WDS
) &&
2738 meta
->iface
->type
!= HOSTAP_INTERFACE_MASTER
&&
2739 meta
->iface
->type
!= HOSTAP_INTERFACE_AP
) {
2741 /* This can happen, e.g., when wlan0 is added to a bridge and
2742 * bridging code does not know which port is the correct target
2743 * for a unicast frame. In this case, the packet is send to all
2744 * ports of the bridge. Since this is a valid scenario, do not
2745 * print out any errors here. */
2746 if (net_ratelimit()) {
2747 printk(KERN_DEBUG
"AP: drop packet to non-associated "
2749 print_mac(mac
, hdr
->addr1
));
2752 local
->ap
->tx_drop_nonassoc
++;
2760 if (!(sta
->flags
& WLAN_STA_AUTHORIZED
))
2761 ret
= AP_TX_CONTINUE_NOT_AUTHORIZED
;
2763 /* Set tx_rate if using host-based TX rate control */
2764 if (!local
->fw_tx_rate_control
)
2765 local
->ap
->last_tx_rate
= meta
->rate
=
2766 ap_update_sta_tx_rate(sta
, local
->dev
);
2768 if (local
->iw_mode
!= IW_MODE_MASTER
)
2771 if (!(sta
->flags
& WLAN_STA_PS
))
2774 if (meta
->flags
& HOSTAP_TX_FLAGS_ADD_MOREDATA
) {
2775 /* indicate to STA that more frames follow */
2777 __constant_cpu_to_le16(IEEE80211_FCTL_MOREDATA
);
2780 if (meta
->flags
& HOSTAP_TX_FLAGS_BUFFERED_FRAME
) {
2781 /* packet was already buffered and now send due to
2782 * PS poll, so do not rebuffer it */
2786 if (skb_queue_len(&sta
->tx_buf
) >= STA_MAX_TX_BUFFER
) {
2787 PDEBUG(DEBUG_PS
, "%s: No more space in STA (%s"
2788 ")'s PS mode buffer\n",
2789 local
->dev
->name
, print_mac(mac
, sta
->addr
));
2790 /* Make sure that TIM is set for the station (it might not be
2791 * after AP wlan hw reset). */
2792 /* FIX: should fix hw reset to restore bits based on STA
2794 hostap_set_tim(local
, sta
->aid
, 1);
2795 sta
->flags
|= WLAN_STA_TIM
;
2800 /* STA in PS mode, buffer frame for later delivery */
2801 set_tim
= skb_queue_empty(&sta
->tx_buf
);
2802 skb_queue_tail(&sta
->tx_buf
, skb
);
2803 /* FIX: could save RX time to skb and expire buffered frames after
2804 * some time if STA does not poll for them */
2807 if (sta
->flags
& WLAN_STA_TIM
)
2808 PDEBUG(DEBUG_PS2
, "Re-setting TIM for aid %d\n",
2810 hostap_set_tim(local
, sta
->aid
, 1);
2811 sta
->flags
|= WLAN_STA_TIM
;
2814 ret
= AP_TX_BUFFERED
;
2818 if (ret
== AP_TX_CONTINUE
||
2819 ret
== AP_TX_CONTINUE_NOT_AUTHORIZED
) {
2821 sta
->tx_bytes
+= skb
->len
;
2822 sta
->last_tx
= jiffies
;
2825 if ((ret
== AP_TX_CONTINUE
||
2826 ret
== AP_TX_CONTINUE_NOT_AUTHORIZED
) &&
2827 sta
->crypt
&& tx
->host_encrypt
) {
2828 tx
->crypt
= sta
->crypt
;
2829 tx
->sta_ptr
= sta
; /* hostap_handle_sta_release() will
2830 * be called to release sta info
2833 atomic_dec(&sta
->users
);
2840 void hostap_handle_sta_release(void *ptr
)
2842 struct sta_info
*sta
= ptr
;
2843 atomic_dec(&sta
->users
);
2847 /* Called only as a tasklet (software IRQ) */
2848 void hostap_handle_sta_tx_exc(local_info_t
*local
, struct sk_buff
*skb
)
2850 struct sta_info
*sta
;
2851 struct ieee80211_hdr_4addr
*hdr
;
2852 struct hostap_skb_tx_data
*meta
;
2853 DECLARE_MAC_BUF(mac
);
2855 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2856 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
2858 spin_lock(&local
->ap
->sta_table_lock
);
2859 sta
= ap_get_sta(local
->ap
, hdr
->addr1
);
2861 spin_unlock(&local
->ap
->sta_table_lock
);
2862 PDEBUG(DEBUG_AP
, "%s: Could not find STA %s"
2863 " for this TX error (@%lu)\n",
2864 local
->dev
->name
, print_mac(mac
, hdr
->addr1
), jiffies
);
2868 sta
->tx_since_last_failure
= 0;
2869 sta
->tx_consecutive_exc
++;
2871 if (sta
->tx_consecutive_exc
>= WLAN_RATE_DECREASE_THRESHOLD
&&
2872 sta
->tx_rate_idx
> 0 && meta
->rate
<= sta
->tx_rate
) {
2873 /* use next lower rate */
2875 old
= rate
= sta
->tx_rate_idx
;
2878 if (ap_tx_rate_ok(rate
, sta
, local
)) {
2879 sta
->tx_rate_idx
= rate
;
2883 if (old
!= sta
->tx_rate_idx
) {
2884 switch (sta
->tx_rate_idx
) {
2885 case 0: sta
->tx_rate
= 10; break;
2886 case 1: sta
->tx_rate
= 20; break;
2887 case 2: sta
->tx_rate
= 55; break;
2888 case 3: sta
->tx_rate
= 110; break;
2889 default: sta
->tx_rate
= 0; break;
2891 PDEBUG(DEBUG_AP
, "%s: STA %s"
2892 " TX rate lowered to %d\n",
2893 local
->dev
->name
, print_mac(mac
, sta
->addr
),
2896 sta
->tx_consecutive_exc
= 0;
2898 spin_unlock(&local
->ap
->sta_table_lock
);
2902 static void hostap_update_sta_ps2(local_info_t
*local
, struct sta_info
*sta
,
2903 int pwrmgt
, int type
, int stype
)
2905 DECLARE_MAC_BUF(mac
);
2906 if (pwrmgt
&& !(sta
->flags
& WLAN_STA_PS
)) {
2907 sta
->flags
|= WLAN_STA_PS
;
2908 PDEBUG(DEBUG_PS2
, "STA %s changed to use PS "
2909 "mode (type=0x%02X, stype=0x%02X)\n",
2910 print_mac(mac
, sta
->addr
), type
>> 2, stype
>> 4);
2911 } else if (!pwrmgt
&& (sta
->flags
& WLAN_STA_PS
)) {
2912 sta
->flags
&= ~WLAN_STA_PS
;
2913 PDEBUG(DEBUG_PS2
, "STA %s changed to not use "
2914 "PS mode (type=0x%02X, stype=0x%02X)\n",
2915 print_mac(mac
, sta
->addr
), type
>> 2, stype
>> 4);
2916 if (type
!= IEEE80211_FTYPE_CTL
||
2917 stype
!= IEEE80211_STYPE_PSPOLL
)
2918 schedule_packet_send(local
, sta
);
2923 /* Called only as a tasklet (software IRQ). Called for each RX frame to update
2924 * STA power saving state. pwrmgt is a flag from 802.11 frame_ctl field. */
2925 int hostap_update_sta_ps(local_info_t
*local
, struct ieee80211_hdr_4addr
*hdr
)
2927 struct sta_info
*sta
;
2930 spin_lock(&local
->ap
->sta_table_lock
);
2931 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2933 atomic_inc(&sta
->users
);
2934 spin_unlock(&local
->ap
->sta_table_lock
);
2939 fc
= le16_to_cpu(hdr
->frame_ctl
);
2940 hostap_update_sta_ps2(local
, sta
, fc
& IEEE80211_FCTL_PM
,
2941 WLAN_FC_GET_TYPE(fc
), WLAN_FC_GET_STYPE(fc
));
2943 atomic_dec(&sta
->users
);
2948 /* Called only as a tasklet (software IRQ). Called for each RX frame after
2949 * getting RX header and payload from hardware. */
2950 ap_rx_ret
hostap_handle_sta_rx(local_info_t
*local
, struct net_device
*dev
,
2951 struct sk_buff
*skb
,
2952 struct hostap_80211_rx_status
*rx_stats
,
2956 struct sta_info
*sta
;
2957 u16 fc
, type
, stype
;
2958 struct ieee80211_hdr_4addr
*hdr
;
2959 DECLARE_MAC_BUF(mac
);
2961 if (local
->ap
== NULL
)
2962 return AP_RX_CONTINUE
;
2964 hdr
= (struct ieee80211_hdr_4addr
*) skb
->data
;
2966 fc
= le16_to_cpu(hdr
->frame_ctl
);
2967 type
= WLAN_FC_GET_TYPE(fc
);
2968 stype
= WLAN_FC_GET_STYPE(fc
);
2970 spin_lock(&local
->ap
->sta_table_lock
);
2971 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2973 atomic_inc(&sta
->users
);
2974 spin_unlock(&local
->ap
->sta_table_lock
);
2976 if (sta
&& !(sta
->flags
& WLAN_STA_AUTHORIZED
))
2977 ret
= AP_RX_CONTINUE_NOT_AUTHORIZED
;
2979 ret
= AP_RX_CONTINUE
;
2982 if (fc
& IEEE80211_FCTL_TODS
) {
2983 if (!wds
&& (sta
== NULL
|| !(sta
->flags
& WLAN_STA_ASSOC
))) {
2984 if (local
->hostapd
) {
2985 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
2986 PRISM2_RX_NON_ASSOC
);
2987 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2989 printk(KERN_DEBUG
"%s: dropped received packet"
2990 " from non-associated STA "
2992 " (type=0x%02x, subtype=0x%02x)\n",
2993 dev
->name
, print_mac(mac
, hdr
->addr2
),
2994 type
>> 2, stype
>> 4);
2995 hostap_rx(dev
, skb
, rx_stats
);
2996 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3001 } else if (fc
& IEEE80211_FCTL_FROMDS
) {
3003 /* FromDS frame - not for us; probably
3004 * broadcast/multicast in another BSS - drop */
3005 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
3006 printk(KERN_DEBUG
"Odd.. FromDS packet "
3007 "received with own BSSID\n");
3008 hostap_dump_rx_80211(dev
->name
, skb
, rx_stats
);
3013 } else if (stype
== IEEE80211_STYPE_NULLFUNC
&& sta
== NULL
&&
3014 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
3016 if (local
->hostapd
) {
3017 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
3018 PRISM2_RX_NON_ASSOC
);
3019 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3021 /* At least Lucent f/w seems to send data::nullfunc
3022 * frames with no ToDS flag when the current AP returns
3023 * after being unavailable for some time. Speed up
3024 * re-association by informing the station about it not
3025 * being associated. */
3026 printk(KERN_DEBUG
"%s: rejected received nullfunc "
3027 "frame without ToDS from not associated STA "
3029 dev
->name
, print_mac(mac
, hdr
->addr2
));
3030 hostap_rx(dev
, skb
, rx_stats
);
3031 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3035 } else if (stype
== IEEE80211_STYPE_NULLFUNC
) {
3036 /* At least Lucent cards seem to send periodic nullfunc
3037 * frames with ToDS. Let these through to update SQ
3038 * stats and PS state. Nullfunc frames do not contain
3039 * any data and they will be dropped below. */
3041 /* If BSSID (Addr3) is foreign, this frame is a normal
3042 * broadcast frame from an IBSS network. Drop it silently.
3043 * If BSSID is own, report the dropping of this frame. */
3044 if (memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
) == 0) {
3045 printk(KERN_DEBUG
"%s: dropped received packet from "
3046 "%s with no ToDS flag "
3047 "(type=0x%02x, subtype=0x%02x)\n", dev
->name
,
3048 print_mac(mac
, hdr
->addr2
), type
>> 2, stype
>> 4);
3049 hostap_dump_rx_80211(dev
->name
, skb
, rx_stats
);
3056 hostap_update_sta_ps2(local
, sta
, fc
& IEEE80211_FCTL_PM
,
3060 sta
->rx_bytes
+= skb
->len
;
3061 sta
->last_rx
= jiffies
;
3064 if (local
->ap
->nullfunc_ack
&& stype
== IEEE80211_STYPE_NULLFUNC
&&
3065 fc
& IEEE80211_FCTL_TODS
) {
3066 if (local
->hostapd
) {
3067 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
3068 PRISM2_RX_NULLFUNC_ACK
);
3069 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3071 /* some STA f/w's seem to require control::ACK frame
3072 * for data::nullfunc, but Prism2 f/w 0.8.0 (at least
3073 * from Compaq) does not send this.. Try to generate
3074 * ACK for these frames from the host driver to make
3075 * power saving work with, e.g., Lucent WaveLAN f/w */
3076 hostap_rx(dev
, skb
, rx_stats
);
3077 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3085 atomic_dec(&sta
->users
);
3091 /* Called only as a tasklet (software IRQ) */
3092 int hostap_handle_sta_crypto(local_info_t
*local
,
3093 struct ieee80211_hdr_4addr
*hdr
,
3094 struct ieee80211_crypt_data
**crypt
,
3097 struct sta_info
*sta
;
3099 spin_lock(&local
->ap
->sta_table_lock
);
3100 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
3102 atomic_inc(&sta
->users
);
3103 spin_unlock(&local
->ap
->sta_table_lock
);
3109 *crypt
= sta
->crypt
;
3111 /* hostap_handle_sta_release() will be called to release STA
3114 atomic_dec(&sta
->users
);
3120 /* Called only as a tasklet (software IRQ) */
3121 int hostap_is_sta_assoc(struct ap_data
*ap
, u8
*sta_addr
)
3123 struct sta_info
*sta
;
3126 spin_lock(&ap
->sta_table_lock
);
3127 sta
= ap_get_sta(ap
, sta_addr
);
3128 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
3130 spin_unlock(&ap
->sta_table_lock
);
3136 /* Called only as a tasklet (software IRQ) */
3137 int hostap_is_sta_authorized(struct ap_data
*ap
, u8
*sta_addr
)
3139 struct sta_info
*sta
;
3142 spin_lock(&ap
->sta_table_lock
);
3143 sta
= ap_get_sta(ap
, sta_addr
);
3144 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&&
3145 ((sta
->flags
& WLAN_STA_AUTHORIZED
) ||
3146 ap
->local
->ieee_802_1x
== 0))
3148 spin_unlock(&ap
->sta_table_lock
);
3154 /* Called only as a tasklet (software IRQ) */
3155 int hostap_add_sta(struct ap_data
*ap
, u8
*sta_addr
)
3157 struct sta_info
*sta
;
3163 spin_lock(&ap
->sta_table_lock
);
3164 sta
= ap_get_sta(ap
, sta_addr
);
3167 spin_unlock(&ap
->sta_table_lock
);
3170 sta
= ap_add_sta(ap
, sta_addr
);
3173 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
3175 memset(sta
->supported_rates
, 0, sizeof(sta
->supported_rates
));
3176 /* No way of knowing which rates are supported since we did not
3177 * get supported rates element from beacon/assoc req. Assume
3178 * that remote end supports all 802.11b rates. */
3179 sta
->supported_rates
[0] = 0x82;
3180 sta
->supported_rates
[1] = 0x84;
3181 sta
->supported_rates
[2] = 0x0b;
3182 sta
->supported_rates
[3] = 0x16;
3183 sta
->tx_supp_rates
= WLAN_RATE_1M
| WLAN_RATE_2M
|
3184 WLAN_RATE_5M5
| WLAN_RATE_11M
;
3186 sta
->tx_max_rate
= sta
->tx_rate_idx
= 3;
3193 /* Called only as a tasklet (software IRQ) */
3194 int hostap_update_rx_stats(struct ap_data
*ap
,
3195 struct ieee80211_hdr_4addr
*hdr
,
3196 struct hostap_80211_rx_status
*rx_stats
)
3198 struct sta_info
*sta
;
3203 spin_lock(&ap
->sta_table_lock
);
3204 sta
= ap_get_sta(ap
, hdr
->addr2
);
3206 sta
->last_rx_silence
= rx_stats
->noise
;
3207 sta
->last_rx_signal
= rx_stats
->signal
;
3208 sta
->last_rx_rate
= rx_stats
->rate
;
3209 sta
->last_rx_updated
= IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
3210 if (rx_stats
->rate
== 10)
3212 else if (rx_stats
->rate
== 20)
3214 else if (rx_stats
->rate
== 55)
3216 else if (rx_stats
->rate
== 110)
3219 spin_unlock(&ap
->sta_table_lock
);
3221 return sta
? 0 : -1;
3225 void hostap_update_rates(local_info_t
*local
)
3227 struct sta_info
*sta
;
3228 struct ap_data
*ap
= local
->ap
;
3233 spin_lock_bh(&ap
->sta_table_lock
);
3234 list_for_each_entry(sta
, &ap
->sta_list
, list
) {
3235 prism2_check_tx_rates(sta
);
3237 spin_unlock_bh(&ap
->sta_table_lock
);
3241 void * ap_crypt_get_ptrs(struct ap_data
*ap
, u8
*addr
, int permanent
,
3242 struct ieee80211_crypt_data
***crypt
)
3244 struct sta_info
*sta
;
3246 spin_lock_bh(&ap
->sta_table_lock
);
3247 sta
= ap_get_sta(ap
, addr
);
3249 atomic_inc(&sta
->users
);
3250 spin_unlock_bh(&ap
->sta_table_lock
);
3252 if (!sta
&& permanent
)
3253 sta
= ap_add_sta(ap
, addr
);
3259 sta
->flags
|= WLAN_STA_PERM
;
3261 *crypt
= &sta
->crypt
;
3267 void hostap_add_wds_links(local_info_t
*local
)
3269 struct ap_data
*ap
= local
->ap
;
3270 struct sta_info
*sta
;
3272 spin_lock_bh(&ap
->sta_table_lock
);
3273 list_for_each_entry(sta
, &ap
->sta_list
, list
) {
3275 hostap_wds_link_oper(local
, sta
->addr
, WDS_ADD
);
3277 spin_unlock_bh(&ap
->sta_table_lock
);
3279 schedule_work(&local
->ap
->wds_oper_queue
);
3283 void hostap_wds_link_oper(local_info_t
*local
, u8
*addr
, wds_oper_type type
)
3285 struct wds_oper_data
*entry
;
3287 entry
= kmalloc(sizeof(*entry
), GFP_ATOMIC
);
3290 memcpy(entry
->addr
, addr
, ETH_ALEN
);
3292 spin_lock_bh(&local
->lock
);
3293 entry
->next
= local
->ap
->wds_oper_entries
;
3294 local
->ap
->wds_oper_entries
= entry
;
3295 spin_unlock_bh(&local
->lock
);
3297 schedule_work(&local
->ap
->wds_oper_queue
);
3301 EXPORT_SYMBOL(hostap_init_data
);
3302 EXPORT_SYMBOL(hostap_init_ap_proc
);
3303 EXPORT_SYMBOL(hostap_free_data
);
3304 EXPORT_SYMBOL(hostap_check_sta_fw_version
);
3305 EXPORT_SYMBOL(hostap_handle_sta_tx_exc
);
3306 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3307 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */