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-2003, Jouni Malinen <jkmaline@cc.hut.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 static int other_ap_policy
[MAX_PARM_DEVICES
] = { AP_OTHER_AP_SKIP_ALL
,
21 module_param_array(other_ap_policy
, int, NULL
, 0444);
22 MODULE_PARM_DESC(other_ap_policy
, "Other AP beacon monitoring policy (0-3)");
24 static int ap_max_inactivity
[MAX_PARM_DEVICES
] = { AP_MAX_INACTIVITY_SEC
,
26 module_param_array(ap_max_inactivity
, int, NULL
, 0444);
27 MODULE_PARM_DESC(ap_max_inactivity
, "AP timeout (in seconds) for station "
30 static int ap_bridge_packets
[MAX_PARM_DEVICES
] = { 1, DEF_INTS
};
31 module_param_array(ap_bridge_packets
, int, NULL
, 0444);
32 MODULE_PARM_DESC(ap_bridge_packets
, "Bridge packets directly between "
35 static int autom_ap_wds
[MAX_PARM_DEVICES
] = { 0, DEF_INTS
};
36 module_param_array(autom_ap_wds
, int, NULL
, 0444);
37 MODULE_PARM_DESC(autom_ap_wds
, "Add WDS connections to other APs "
41 static struct sta_info
* ap_get_sta(struct ap_data
*ap
, u8
*sta
);
42 static void hostap_event_expired_sta(struct net_device
*dev
,
43 struct sta_info
*sta
);
44 static void handle_add_proc_queue(void *data
);
46 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
47 static void handle_wds_oper_queue(void *data
);
48 static void prism2_send_mgmt(struct net_device
*dev
,
49 int type
, int subtype
, char *body
,
50 int body_len
, u8
*addr
, u16 tx_cb_idx
);
51 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
54 #ifndef PRISM2_NO_PROCFS_DEBUG
55 static int ap_debug_proc_read(char *page
, char **start
, off_t off
,
56 int count
, int *eof
, void *data
)
59 struct ap_data
*ap
= (struct ap_data
*) data
;
66 p
+= sprintf(p
, "BridgedUnicastFrames=%u\n", ap
->bridged_unicast
);
67 p
+= sprintf(p
, "BridgedMulticastFrames=%u\n", ap
->bridged_multicast
);
68 p
+= sprintf(p
, "max_inactivity=%u\n", ap
->max_inactivity
/ HZ
);
69 p
+= sprintf(p
, "bridge_packets=%u\n", ap
->bridge_packets
);
70 p
+= sprintf(p
, "nullfunc_ack=%u\n", ap
->nullfunc_ack
);
71 p
+= sprintf(p
, "autom_ap_wds=%u\n", ap
->autom_ap_wds
);
72 p
+= sprintf(p
, "auth_algs=%u\n", ap
->local
->auth_algs
);
73 p
+= sprintf(p
, "tx_drop_nonassoc=%u\n", ap
->tx_drop_nonassoc
);
77 #endif /* PRISM2_NO_PROCFS_DEBUG */
80 static void ap_sta_hash_add(struct ap_data
*ap
, struct sta_info
*sta
)
82 sta
->hnext
= ap
->sta_hash
[STA_HASH(sta
->addr
)];
83 ap
->sta_hash
[STA_HASH(sta
->addr
)] = sta
;
86 static void ap_sta_hash_del(struct ap_data
*ap
, struct sta_info
*sta
)
90 s
= ap
->sta_hash
[STA_HASH(sta
->addr
)];
91 if (s
== NULL
) return;
92 if (memcmp(s
->addr
, sta
->addr
, ETH_ALEN
) == 0) {
93 ap
->sta_hash
[STA_HASH(sta
->addr
)] = s
->hnext
;
97 while (s
->hnext
!= NULL
&& memcmp(s
->hnext
->addr
, sta
->addr
, ETH_ALEN
)
100 if (s
->hnext
!= NULL
)
101 s
->hnext
= s
->hnext
->hnext
;
103 printk("AP: could not remove STA " MACSTR
" from hash table\n",
107 static void ap_free_sta(struct ap_data
*ap
, struct sta_info
*sta
)
109 if (sta
->ap
&& sta
->local
)
110 hostap_event_expired_sta(sta
->local
->dev
, sta
);
112 if (ap
->proc
!= NULL
) {
114 sprintf(name
, MACSTR
, MAC2STR(sta
->addr
));
115 remove_proc_entry(name
, ap
->proc
);
119 sta
->crypt
->ops
->deinit(sta
->crypt
->priv
);
124 skb_queue_purge(&sta
->tx_buf
);
127 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
129 ap
->sta_aid
[sta
->aid
- 1] = NULL
;
131 if (!sta
->ap
&& sta
->u
.sta
.challenge
)
132 kfree(sta
->u
.sta
.challenge
);
133 del_timer(&sta
->timer
);
134 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
140 static void hostap_set_tim(local_info_t
*local
, int aid
, int set
)
142 if (local
->func
->set_tim
)
143 local
->func
->set_tim(local
->dev
, aid
, set
);
147 static void hostap_event_new_sta(struct net_device
*dev
, struct sta_info
*sta
)
149 union iwreq_data wrqu
;
150 memset(&wrqu
, 0, sizeof(wrqu
));
151 memcpy(wrqu
.addr
.sa_data
, sta
->addr
, ETH_ALEN
);
152 wrqu
.addr
.sa_family
= ARPHRD_ETHER
;
153 wireless_send_event(dev
, IWEVREGISTERED
, &wrqu
, NULL
);
157 static void hostap_event_expired_sta(struct net_device
*dev
,
158 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
, IWEVEXPIRED
, &wrqu
, NULL
);
168 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
170 static void ap_handle_timer(unsigned long data
)
172 struct sta_info
*sta
= (struct sta_info
*) data
;
175 unsigned long next_time
= 0;
178 if (sta
== NULL
|| sta
->local
== NULL
|| sta
->local
->ap
== NULL
) {
179 PDEBUG(DEBUG_AP
, "ap_handle_timer() called with NULL data\n");
185 was_assoc
= sta
->flags
& WLAN_STA_ASSOC
;
187 if (atomic_read(&sta
->users
) != 0)
188 next_time
= jiffies
+ HZ
;
189 else if ((sta
->flags
& WLAN_STA_PERM
) && !(sta
->flags
& WLAN_STA_AUTH
))
190 next_time
= jiffies
+ ap
->max_inactivity
;
192 if (time_before(jiffies
, sta
->last_rx
+ ap
->max_inactivity
)) {
193 /* station activity detected; reset timeout state */
194 sta
->timeout_next
= STA_NULLFUNC
;
195 next_time
= sta
->last_rx
+ ap
->max_inactivity
;
196 } else if (sta
->timeout_next
== STA_DISASSOC
&&
197 !(sta
->flags
& WLAN_STA_PENDING_POLL
)) {
198 /* STA ACKed data nullfunc frame poll */
199 sta
->timeout_next
= STA_NULLFUNC
;
200 next_time
= jiffies
+ ap
->max_inactivity
;
204 sta
->timer
.expires
= next_time
;
205 add_timer(&sta
->timer
);
210 sta
->timeout_next
= STA_DEAUTH
;
212 if (sta
->timeout_next
== STA_DEAUTH
&& !(sta
->flags
& WLAN_STA_PERM
)) {
213 spin_lock(&ap
->sta_table_lock
);
214 ap_sta_hash_del(ap
, sta
);
215 list_del(&sta
->list
);
216 spin_unlock(&ap
->sta_table_lock
);
217 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
218 } else if (sta
->timeout_next
== STA_DISASSOC
)
219 sta
->flags
&= ~WLAN_STA_ASSOC
;
221 if (was_assoc
&& !(sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
222 hostap_event_expired_sta(local
->dev
, sta
);
224 if (sta
->timeout_next
== STA_DEAUTH
&& sta
->aid
> 0 &&
225 !skb_queue_empty(&sta
->tx_buf
)) {
226 hostap_set_tim(local
, sta
->aid
, 0);
227 sta
->flags
&= ~WLAN_STA_TIM
;
231 if (ap
->autom_ap_wds
) {
232 PDEBUG(DEBUG_AP
, "%s: removing automatic WDS "
233 "connection to AP " MACSTR
"\n",
234 local
->dev
->name
, MAC2STR(sta
->addr
));
235 hostap_wds_link_oper(local
, sta
->addr
, WDS_DEL
);
237 } else if (sta
->timeout_next
== STA_NULLFUNC
) {
238 /* send data frame to poll STA and check whether this frame
240 /* FIX: WLAN_FC_STYPE_NULLFUNC would be more appropriate, but
241 * it is apparently not retried so TX Exc events are not
243 sta
->flags
|= WLAN_STA_PENDING_POLL
;
244 prism2_send_mgmt(local
->dev
, WLAN_FC_TYPE_DATA
,
245 WLAN_FC_STYPE_DATA
, NULL
, 0,
246 sta
->addr
, ap
->tx_callback_poll
);
248 int deauth
= sta
->timeout_next
== STA_DEAUTH
;
250 PDEBUG(DEBUG_AP
, "%s: sending %s info to STA " MACSTR
251 "(last=%lu, jiffies=%lu)\n",
253 deauth
? "deauthentication" : "disassociation",
254 MAC2STR(sta
->addr
), sta
->last_rx
, jiffies
);
256 resp
= cpu_to_le16(deauth
? WLAN_REASON_PREV_AUTH_NOT_VALID
:
257 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
);
258 prism2_send_mgmt(local
->dev
, WLAN_FC_TYPE_MGMT
,
259 (deauth
? WLAN_FC_STYPE_DEAUTH
:
260 WLAN_FC_STYPE_DISASSOC
),
261 (char *) &resp
, 2, sta
->addr
, 0);
264 if (sta
->timeout_next
== STA_DEAUTH
) {
265 if (sta
->flags
& WLAN_STA_PERM
) {
266 PDEBUG(DEBUG_AP
, "%s: STA " MACSTR
" would have been "
267 "removed, but it has 'perm' flag\n",
268 local
->dev
->name
, MAC2STR(sta
->addr
));
270 ap_free_sta(ap
, sta
);
274 if (sta
->timeout_next
== STA_NULLFUNC
) {
275 sta
->timeout_next
= STA_DISASSOC
;
276 sta
->timer
.expires
= jiffies
+ AP_DISASSOC_DELAY
;
278 sta
->timeout_next
= STA_DEAUTH
;
279 sta
->timer
.expires
= jiffies
+ AP_DEAUTH_DELAY
;
282 add_timer(&sta
->timer
);
286 void hostap_deauth_all_stas(struct net_device
*dev
, struct ap_data
*ap
,
293 PDEBUG(DEBUG_AP
, "%s: Deauthenticate all stations\n", dev
->name
);
294 memset(addr
, 0xff, ETH_ALEN
);
296 resp
= __constant_cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID
);
298 /* deauth message sent; try to resend it few times; the message is
299 * broadcast, so it may be delayed until next DTIM; there is not much
300 * else we can do at this point since the driver is going to be shut
302 for (i
= 0; i
< 5; i
++) {
303 prism2_send_mgmt(dev
, WLAN_FC_TYPE_MGMT
, WLAN_FC_STYPE_DEAUTH
,
304 (char *) &resp
, 2, addr
, 0);
306 if (!resend
|| ap
->num_sta
<= 0)
314 static int ap_control_proc_read(char *page
, char **start
, off_t off
,
315 int count
, int *eof
, void *data
)
318 struct ap_data
*ap
= (struct ap_data
*) data
;
320 struct list_head
*ptr
;
321 struct mac_entry
*entry
;
328 switch (ap
->mac_restrictions
.policy
) {
329 case MAC_POLICY_OPEN
:
332 case MAC_POLICY_ALLOW
:
333 policy_txt
= "allow";
335 case MAC_POLICY_DENY
:
339 policy_txt
= "unknown";
342 p
+= sprintf(p
, "MAC policy: %s\n", policy_txt
);
343 p
+= sprintf(p
, "MAC entries: %u\n", ap
->mac_restrictions
.entries
);
344 p
+= sprintf(p
, "MAC list:\n");
345 spin_lock_bh(&ap
->mac_restrictions
.lock
);
346 for (ptr
= ap
->mac_restrictions
.mac_list
.next
;
347 ptr
!= &ap
->mac_restrictions
.mac_list
; ptr
= ptr
->next
) {
348 if (p
- page
> PAGE_SIZE
- 80) {
349 p
+= sprintf(p
, "All entries did not fit one page.\n");
353 entry
= list_entry(ptr
, struct mac_entry
, list
);
354 p
+= sprintf(p
, MACSTR
"\n", MAC2STR(entry
->addr
));
356 spin_unlock_bh(&ap
->mac_restrictions
.lock
);
362 static int ap_control_add_mac(struct mac_restrictions
*mac_restrictions
,
365 struct mac_entry
*entry
;
367 entry
= kmalloc(sizeof(struct mac_entry
), GFP_KERNEL
);
371 memcpy(entry
->addr
, mac
, ETH_ALEN
);
373 spin_lock_bh(&mac_restrictions
->lock
);
374 list_add_tail(&entry
->list
, &mac_restrictions
->mac_list
);
375 mac_restrictions
->entries
++;
376 spin_unlock_bh(&mac_restrictions
->lock
);
382 static int ap_control_del_mac(struct mac_restrictions
*mac_restrictions
,
385 struct list_head
*ptr
;
386 struct mac_entry
*entry
;
388 spin_lock_bh(&mac_restrictions
->lock
);
389 for (ptr
= mac_restrictions
->mac_list
.next
;
390 ptr
!= &mac_restrictions
->mac_list
; ptr
= ptr
->next
) {
391 entry
= list_entry(ptr
, struct mac_entry
, list
);
393 if (memcmp(entry
->addr
, mac
, ETH_ALEN
) == 0) {
396 mac_restrictions
->entries
--;
397 spin_unlock_bh(&mac_restrictions
->lock
);
401 spin_unlock_bh(&mac_restrictions
->lock
);
406 static int ap_control_mac_deny(struct mac_restrictions
*mac_restrictions
,
409 struct list_head
*ptr
;
410 struct mac_entry
*entry
;
413 if (mac_restrictions
->policy
== MAC_POLICY_OPEN
)
416 spin_lock_bh(&mac_restrictions
->lock
);
417 for (ptr
= mac_restrictions
->mac_list
.next
;
418 ptr
!= &mac_restrictions
->mac_list
; ptr
= ptr
->next
) {
419 entry
= list_entry(ptr
, struct mac_entry
, list
);
421 if (memcmp(entry
->addr
, mac
, ETH_ALEN
) == 0) {
426 spin_unlock_bh(&mac_restrictions
->lock
);
428 if (mac_restrictions
->policy
== MAC_POLICY_ALLOW
)
435 static void ap_control_flush_macs(struct mac_restrictions
*mac_restrictions
)
437 struct list_head
*ptr
, *n
;
438 struct mac_entry
*entry
;
440 if (mac_restrictions
->entries
== 0)
443 spin_lock_bh(&mac_restrictions
->lock
);
444 for (ptr
= mac_restrictions
->mac_list
.next
, n
= ptr
->next
;
445 ptr
!= &mac_restrictions
->mac_list
;
446 ptr
= n
, n
= ptr
->next
) {
447 entry
= list_entry(ptr
, struct mac_entry
, list
);
451 mac_restrictions
->entries
= 0;
452 spin_unlock_bh(&mac_restrictions
->lock
);
456 static int ap_control_kick_mac(struct ap_data
*ap
, struct net_device
*dev
,
459 struct sta_info
*sta
;
462 spin_lock_bh(&ap
->sta_table_lock
);
463 sta
= ap_get_sta(ap
, mac
);
465 ap_sta_hash_del(ap
, sta
);
466 list_del(&sta
->list
);
468 spin_unlock_bh(&ap
->sta_table_lock
);
473 resp
= cpu_to_le16(WLAN_REASON_PREV_AUTH_NOT_VALID
);
474 prism2_send_mgmt(dev
, WLAN_FC_TYPE_MGMT
, WLAN_FC_STYPE_DEAUTH
,
475 (char *) &resp
, 2, sta
->addr
, 0);
477 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
478 hostap_event_expired_sta(dev
, sta
);
480 ap_free_sta(ap
, sta
);
485 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
488 static void ap_control_kickall(struct ap_data
*ap
)
490 struct list_head
*ptr
, *n
;
491 struct sta_info
*sta
;
493 spin_lock_bh(&ap
->sta_table_lock
);
494 for (ptr
= ap
->sta_list
.next
, n
= ptr
->next
; ptr
!= &ap
->sta_list
;
495 ptr
= n
, n
= ptr
->next
) {
496 sta
= list_entry(ptr
, struct sta_info
, list
);
497 ap_sta_hash_del(ap
, sta
);
498 list_del(&sta
->list
);
499 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
500 hostap_event_expired_sta(sta
->local
->dev
, sta
);
501 ap_free_sta(ap
, sta
);
503 spin_unlock_bh(&ap
->sta_table_lock
);
507 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
509 #define PROC_LIMIT (PAGE_SIZE - 80)
511 static int prism2_ap_proc_read(char *page
, char **start
, off_t off
,
512 int count
, int *eof
, void *data
)
515 struct ap_data
*ap
= (struct ap_data
*) data
;
516 struct list_head
*ptr
;
519 if (off
> PROC_LIMIT
) {
524 p
+= sprintf(p
, "# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
525 spin_lock_bh(&ap
->sta_table_lock
);
526 for (ptr
= ap
->sta_list
.next
; ptr
!= &ap
->sta_list
; ptr
= ptr
->next
) {
527 struct sta_info
*sta
= (struct sta_info
*) ptr
;
532 p
+= sprintf(p
, MACSTR
" %d %d %d %d '", MAC2STR(sta
->addr
),
533 sta
->u
.ap
.channel
, sta
->last_rx_signal
,
534 sta
->last_rx_silence
, sta
->last_rx_rate
);
535 for (i
= 0; i
< sta
->u
.ap
.ssid_len
; i
++)
536 p
+= sprintf(p
, ((sta
->u
.ap
.ssid
[i
] >= 32 &&
537 sta
->u
.ap
.ssid
[i
] < 127) ?
540 p
+= sprintf(p
, "'");
541 if (sta
->capability
& WLAN_CAPABILITY_ESS
)
542 p
+= sprintf(p
, " [ESS]");
543 if (sta
->capability
& WLAN_CAPABILITY_IBSS
)
544 p
+= sprintf(p
, " [IBSS]");
545 if (sta
->capability
& WLAN_CAPABILITY_PRIVACY
)
546 p
+= sprintf(p
, " [WEP]");
547 p
+= sprintf(p
, "\n");
549 if ((p
- page
) > PROC_LIMIT
) {
550 printk(KERN_DEBUG
"hostap: ap proc did not fit\n");
554 spin_unlock_bh(&ap
->sta_table_lock
);
556 if ((p
- page
) <= off
) {
563 return (p
- page
- off
);
565 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
568 void hostap_check_sta_fw_version(struct ap_data
*ap
, int sta_fw_ver
)
573 if (sta_fw_ver
== PRISM2_FW_VER(0,8,0)) {
574 PDEBUG(DEBUG_AP
, "Using data::nullfunc ACK workaround - "
575 "firmware upgrade recommended\n");
576 ap
->nullfunc_ack
= 1;
578 ap
->nullfunc_ack
= 0;
580 if (sta_fw_ver
== PRISM2_FW_VER(1,4,2)) {
581 printk(KERN_WARNING
"%s: Warning: secondary station firmware "
582 "version 1.4.2 does not seem to work in Host AP mode\n",
583 ap
->local
->dev
->name
);
588 /* Called only as a tasklet (software IRQ) */
589 static void hostap_ap_tx_cb(struct sk_buff
*skb
, int ok
, void *data
)
591 struct ap_data
*ap
= data
;
593 struct hostap_ieee80211_hdr
*hdr
;
595 if (!ap
->local
->hostapd
|| !ap
->local
->apdev
) {
600 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
601 fc
= le16_to_cpu(hdr
->frame_control
);
603 /* Pass the TX callback frame to the hostapd; use 802.11 header version
604 * 1 to indicate failure (no ACK) and 2 success (frame ACKed) */
607 fc
|= ok
? BIT(1) : BIT(0);
608 hdr
->frame_control
= cpu_to_le16(fc
);
610 skb
->dev
= ap
->local
->apdev
;
611 skb_pull(skb
, hostap_80211_get_hdrlen(fc
));
612 skb
->pkt_type
= PACKET_OTHERHOST
;
613 skb
->protocol
= __constant_htons(ETH_P_802_2
);
614 memset(skb
->cb
, 0, sizeof(skb
->cb
));
619 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
620 /* Called only as a tasklet (software IRQ) */
621 static void hostap_ap_tx_cb_auth(struct sk_buff
*skb
, int ok
, void *data
)
623 struct ap_data
*ap
= data
;
624 struct net_device
*dev
= ap
->local
->dev
;
625 struct hostap_ieee80211_hdr
*hdr
;
626 u16 fc
, *pos
, auth_alg
, auth_transaction
, status
;
627 struct sta_info
*sta
= NULL
;
630 if (ap
->local
->hostapd
) {
635 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
636 fc
= le16_to_cpu(hdr
->frame_control
);
637 if (WLAN_FC_GET_TYPE(fc
) != WLAN_FC_TYPE_MGMT
||
638 WLAN_FC_GET_STYPE(fc
) != WLAN_FC_STYPE_AUTH
||
639 skb
->len
< IEEE80211_MGMT_HDR_LEN
+ 6) {
640 printk(KERN_DEBUG
"%s: hostap_ap_tx_cb_auth received invalid "
641 "frame\n", dev
->name
);
646 pos
= (u16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
647 auth_alg
= le16_to_cpu(*pos
++);
648 auth_transaction
= le16_to_cpu(*pos
++);
649 status
= le16_to_cpu(*pos
++);
652 txt
= "frame was not ACKed";
656 spin_lock(&ap
->sta_table_lock
);
657 sta
= ap_get_sta(ap
, hdr
->addr1
);
659 atomic_inc(&sta
->users
);
660 spin_unlock(&ap
->sta_table_lock
);
663 txt
= "STA not found";
667 if (status
== WLAN_STATUS_SUCCESS
&&
668 ((auth_alg
== WLAN_AUTH_OPEN
&& auth_transaction
== 2) ||
669 (auth_alg
== WLAN_AUTH_SHARED_KEY
&& auth_transaction
== 4))) {
670 txt
= "STA authenticated";
671 sta
->flags
|= WLAN_STA_AUTH
;
672 sta
->last_auth
= jiffies
;
673 } else if (status
!= WLAN_STATUS_SUCCESS
)
674 txt
= "authentication failed";
678 atomic_dec(&sta
->users
);
680 PDEBUG(DEBUG_AP
, "%s: " MACSTR
" auth_cb - alg=%d trans#=%d "
682 dev
->name
, MAC2STR(hdr
->addr1
), auth_alg
,
683 auth_transaction
, status
, txt
);
689 /* Called only as a tasklet (software IRQ) */
690 static void hostap_ap_tx_cb_assoc(struct sk_buff
*skb
, int ok
, void *data
)
692 struct ap_data
*ap
= data
;
693 struct net_device
*dev
= ap
->local
->dev
;
694 struct hostap_ieee80211_hdr
*hdr
;
695 u16 fc
, *pos
, status
;
696 struct sta_info
*sta
= NULL
;
699 if (ap
->local
->hostapd
) {
704 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
705 fc
= le16_to_cpu(hdr
->frame_control
);
706 if (WLAN_FC_GET_TYPE(fc
) != WLAN_FC_TYPE_MGMT
||
707 (WLAN_FC_GET_STYPE(fc
) != WLAN_FC_STYPE_ASSOC_RESP
&&
708 WLAN_FC_GET_STYPE(fc
) != WLAN_FC_STYPE_REASSOC_RESP
) ||
709 skb
->len
< IEEE80211_MGMT_HDR_LEN
+ 4) {
710 printk(KERN_DEBUG
"%s: hostap_ap_tx_cb_assoc received invalid "
711 "frame\n", dev
->name
);
717 txt
= "frame was not ACKed";
721 spin_lock(&ap
->sta_table_lock
);
722 sta
= ap_get_sta(ap
, hdr
->addr1
);
724 atomic_inc(&sta
->users
);
725 spin_unlock(&ap
->sta_table_lock
);
728 txt
= "STA not found";
732 pos
= (u16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
734 status
= le16_to_cpu(*pos
++);
735 if (status
== WLAN_STATUS_SUCCESS
) {
736 if (!(sta
->flags
& WLAN_STA_ASSOC
))
737 hostap_event_new_sta(dev
, sta
);
738 txt
= "STA associated";
739 sta
->flags
|= WLAN_STA_ASSOC
;
740 sta
->last_assoc
= jiffies
;
742 txt
= "association failed";
746 atomic_dec(&sta
->users
);
748 PDEBUG(DEBUG_AP
, "%s: " MACSTR
" assoc_cb - %s\n",
749 dev
->name
, MAC2STR(hdr
->addr1
), txt
);
754 /* Called only as a tasklet (software IRQ); TX callback for poll frames used
755 * in verifying whether the STA is still present. */
756 static void hostap_ap_tx_cb_poll(struct sk_buff
*skb
, int ok
, void *data
)
758 struct ap_data
*ap
= data
;
759 struct hostap_ieee80211_hdr
*hdr
;
760 struct sta_info
*sta
;
764 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
766 spin_lock(&ap
->sta_table_lock
);
767 sta
= ap_get_sta(ap
, hdr
->addr1
);
769 sta
->flags
&= ~WLAN_STA_PENDING_POLL
;
770 spin_unlock(&ap
->sta_table_lock
);
772 PDEBUG(DEBUG_AP
, "%s: STA " MACSTR
" did not ACK activity "
773 "poll frame\n", ap
->local
->dev
->name
,
774 MAC2STR(hdr
->addr1
));
780 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
783 void hostap_init_data(local_info_t
*local
)
785 struct ap_data
*ap
= local
->ap
;
788 printk(KERN_WARNING
"hostap_init_data: ap == NULL\n");
791 memset(ap
, 0, sizeof(struct ap_data
));
794 ap
->ap_policy
= GET_INT_PARM(other_ap_policy
, local
->card_idx
);
795 ap
->bridge_packets
= GET_INT_PARM(ap_bridge_packets
, local
->card_idx
);
797 GET_INT_PARM(ap_max_inactivity
, local
->card_idx
) * HZ
;
798 ap
->autom_ap_wds
= GET_INT_PARM(autom_ap_wds
, local
->card_idx
);
800 spin_lock_init(&ap
->sta_table_lock
);
801 INIT_LIST_HEAD(&ap
->sta_list
);
803 /* Initialize task queue structure for AP management */
804 INIT_WORK(&local
->ap
->add_sta_proc_queue
, handle_add_proc_queue
, ap
);
806 ap
->tx_callback_idx
=
807 hostap_tx_callback_register(local
, hostap_ap_tx_cb
, ap
);
808 if (ap
->tx_callback_idx
== 0)
809 printk(KERN_WARNING
"%s: failed to register TX callback for "
810 "AP\n", local
->dev
->name
);
811 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
812 INIT_WORK(&local
->ap
->wds_oper_queue
, handle_wds_oper_queue
, local
);
814 ap
->tx_callback_auth
=
815 hostap_tx_callback_register(local
, hostap_ap_tx_cb_auth
, ap
);
816 ap
->tx_callback_assoc
=
817 hostap_tx_callback_register(local
, hostap_ap_tx_cb_assoc
, ap
);
818 ap
->tx_callback_poll
=
819 hostap_tx_callback_register(local
, hostap_ap_tx_cb_poll
, ap
);
820 if (ap
->tx_callback_auth
== 0 || ap
->tx_callback_assoc
== 0 ||
821 ap
->tx_callback_poll
== 0)
822 printk(KERN_WARNING
"%s: failed to register TX callback for "
823 "AP\n", local
->dev
->name
);
825 spin_lock_init(&ap
->mac_restrictions
.lock
);
826 INIT_LIST_HEAD(&ap
->mac_restrictions
.mac_list
);
827 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
833 void hostap_init_ap_proc(local_info_t
*local
)
835 struct ap_data
*ap
= local
->ap
;
837 ap
->proc
= local
->proc
;
838 if (ap
->proc
== NULL
)
841 #ifndef PRISM2_NO_PROCFS_DEBUG
842 create_proc_read_entry("ap_debug", 0, ap
->proc
,
843 ap_debug_proc_read
, ap
);
844 #endif /* PRISM2_NO_PROCFS_DEBUG */
846 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
847 create_proc_read_entry("ap_control", 0, ap
->proc
,
848 ap_control_proc_read
, ap
);
849 create_proc_read_entry("ap", 0, ap
->proc
,
850 prism2_ap_proc_read
, ap
);
851 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
856 void hostap_free_data(struct ap_data
*ap
)
858 struct list_head
*n
, *ptr
;
860 if (ap
== NULL
|| !ap
->initialized
) {
861 printk(KERN_DEBUG
"hostap_free_data: ap has not yet been "
862 "initialized - skip resource freeing\n");
866 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
868 ap
->crypt
->deinit(ap
->crypt_priv
);
869 ap
->crypt
= ap
->crypt_priv
= NULL
;
870 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
872 list_for_each_safe(ptr
, n
, &ap
->sta_list
) {
873 struct sta_info
*sta
= list_entry(ptr
, struct sta_info
, list
);
874 ap_sta_hash_del(ap
, sta
);
875 list_del(&sta
->list
);
876 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
877 hostap_event_expired_sta(sta
->local
->dev
, sta
);
878 ap_free_sta(ap
, sta
);
881 #ifndef PRISM2_NO_PROCFS_DEBUG
882 if (ap
->proc
!= NULL
) {
883 remove_proc_entry("ap_debug", ap
->proc
);
885 #endif /* PRISM2_NO_PROCFS_DEBUG */
887 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
888 if (ap
->proc
!= NULL
) {
889 remove_proc_entry("ap", ap
->proc
);
890 remove_proc_entry("ap_control", ap
->proc
);
892 ap_control_flush_macs(&ap
->mac_restrictions
);
893 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
899 /* caller should have mutex for AP STA list handling */
900 static struct sta_info
* ap_get_sta(struct ap_data
*ap
, u8
*sta
)
904 s
= ap
->sta_hash
[STA_HASH(sta
)];
905 while (s
!= NULL
&& memcmp(s
->addr
, sta
, ETH_ALEN
) != 0)
911 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
913 /* Called from timer handler and from scheduled AP queue handlers */
914 static void prism2_send_mgmt(struct net_device
*dev
,
915 int type
, int subtype
, char *body
,
916 int body_len
, u8
*addr
, u16 tx_cb_idx
)
918 struct hostap_interface
*iface
;
920 struct hostap_ieee80211_hdr
*hdr
;
923 struct hostap_skb_tx_data
*meta
;
926 iface
= netdev_priv(dev
);
927 local
= iface
->local
;
928 dev
= local
->dev
; /* always use master radio device */
929 iface
= netdev_priv(dev
);
931 if (!(dev
->flags
& IFF_UP
)) {
932 PDEBUG(DEBUG_AP
, "%s: prism2_send_mgmt - device is not UP - "
933 "cannot send frame\n", dev
->name
);
937 skb
= dev_alloc_skb(sizeof(*hdr
) + body_len
);
939 PDEBUG(DEBUG_AP
, "%s: prism2_send_mgmt failed to allocate "
944 fc
= (type
<< 2) | (subtype
<< 4);
945 hdrlen
= hostap_80211_get_hdrlen(fc
);
946 hdr
= (struct hostap_ieee80211_hdr
*) skb_put(skb
, hdrlen
);
948 memcpy(skb_put(skb
, body_len
), body
, body_len
);
950 memset(hdr
, 0, hdrlen
);
952 /* FIX: ctrl::ack sending used special HFA384X_TX_CTRL_802_11
953 * tx_control instead of using local->tx_control */
956 memcpy(hdr
->addr1
, addr
, ETH_ALEN
); /* DA / RA */
957 if (type
== WLAN_FC_TYPE_DATA
) {
958 fc
|= WLAN_FC_FROMDS
;
959 memcpy(hdr
->addr2
, dev
->dev_addr
, ETH_ALEN
); /* BSSID */
960 memcpy(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
); /* SA */
961 } else if (type
== WLAN_FC_TYPE_CTRL
) {
962 /* control:ACK does not have addr2 or addr3 */
963 memset(hdr
->addr2
, 0, ETH_ALEN
);
964 memset(hdr
->addr3
, 0, ETH_ALEN
);
966 memcpy(hdr
->addr2
, dev
->dev_addr
, ETH_ALEN
); /* SA */
967 memcpy(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
); /* BSSID */
970 hdr
->frame_control
= cpu_to_le16(fc
);
972 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
973 memset(meta
, 0, sizeof(*meta
));
974 meta
->magic
= HOSTAP_SKB_TX_DATA_MAGIC
;
976 meta
->tx_cb_idx
= tx_cb_idx
;
979 skb
->mac
.raw
= skb
->nh
.raw
= skb
->data
;
982 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
985 static int prism2_sta_proc_read(char *page
, char **start
, off_t off
,
986 int count
, int *eof
, void *data
)
989 struct sta_info
*sta
= (struct sta_info
*) data
;
992 /* FIX: possible race condition.. the STA data could have just expired,
993 * but proc entry was still here so that the read could have started;
994 * some locking should be done here.. */
1001 p
+= sprintf(p
, "%s=" MACSTR
"\nusers=%d\naid=%d\n"
1002 "flags=0x%04x%s%s%s%s%s%s%s\n"
1003 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
1004 sta
->ap
? "AP" : "STA",
1005 MAC2STR(sta
->addr
), atomic_read(&sta
->users
), sta
->aid
,
1007 sta
->flags
& WLAN_STA_AUTH
? " AUTH" : "",
1008 sta
->flags
& WLAN_STA_ASSOC
? " ASSOC" : "",
1009 sta
->flags
& WLAN_STA_PS
? " PS" : "",
1010 sta
->flags
& WLAN_STA_TIM
? " TIM" : "",
1011 sta
->flags
& WLAN_STA_PERM
? " PERM" : "",
1012 sta
->flags
& WLAN_STA_AUTHORIZED
? " AUTHORIZED" : "",
1013 sta
->flags
& WLAN_STA_PENDING_POLL
? " POLL" : "",
1014 sta
->capability
, sta
->listen_interval
);
1015 /* supported_rates: 500 kbit/s units with msb ignored */
1016 for (i
= 0; i
< sizeof(sta
->supported_rates
); i
++)
1017 if (sta
->supported_rates
[i
] != 0)
1018 p
+= sprintf(p
, "%d%sMbps ",
1019 (sta
->supported_rates
[i
] & 0x7f) / 2,
1020 sta
->supported_rates
[i
] & 1 ? ".5" : "");
1021 p
+= sprintf(p
, "\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
1022 "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
1024 "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
1025 "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
1026 "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
1028 "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n",
1029 jiffies
, sta
->last_auth
, sta
->last_assoc
, sta
->last_rx
,
1031 sta
->rx_packets
, sta
->tx_packets
, sta
->rx_bytes
,
1032 sta
->tx_bytes
, skb_queue_len(&sta
->tx_buf
),
1033 sta
->last_rx_silence
,
1034 sta
->last_rx_signal
, sta
->last_rx_rate
/ 10,
1035 sta
->last_rx_rate
% 10 ? ".5" : "",
1036 sta
->tx_rate
, sta
->tx_count
[0], sta
->tx_count
[1],
1037 sta
->tx_count
[2], sta
->tx_count
[3], sta
->rx_count
[0],
1038 sta
->rx_count
[1], sta
->rx_count
[2], sta
->rx_count
[3]);
1039 if (sta
->crypt
&& sta
->crypt
->ops
&& sta
->crypt
->ops
->print_stats
)
1040 p
= sta
->crypt
->ops
->print_stats(p
, sta
->crypt
->priv
);
1041 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1043 if (sta
->u
.ap
.channel
>= 0)
1044 p
+= sprintf(p
, "channel=%d\n", sta
->u
.ap
.channel
);
1045 p
+= sprintf(p
, "ssid=");
1046 for (i
= 0; i
< sta
->u
.ap
.ssid_len
; i
++)
1047 p
+= sprintf(p
, ((sta
->u
.ap
.ssid
[i
] >= 32 &&
1048 sta
->u
.ap
.ssid
[i
] < 127) ?
1051 p
+= sprintf(p
, "\n");
1053 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1059 static void handle_add_proc_queue(void *data
)
1061 struct ap_data
*ap
= (struct ap_data
*) data
;
1062 struct sta_info
*sta
;
1064 struct add_sta_proc_data
*entry
, *prev
;
1066 entry
= ap
->add_sta_proc_entries
;
1067 ap
->add_sta_proc_entries
= NULL
;
1070 spin_lock_bh(&ap
->sta_table_lock
);
1071 sta
= ap_get_sta(ap
, entry
->addr
);
1073 atomic_inc(&sta
->users
);
1074 spin_unlock_bh(&ap
->sta_table_lock
);
1077 sprintf(name
, MACSTR
, MAC2STR(sta
->addr
));
1078 sta
->proc
= create_proc_read_entry(
1080 prism2_sta_proc_read
, sta
);
1082 atomic_dec(&sta
->users
);
1086 entry
= entry
->next
;
1092 static struct sta_info
* ap_add_sta(struct ap_data
*ap
, u8
*addr
)
1094 struct sta_info
*sta
;
1096 sta
= (struct sta_info
*)
1097 kmalloc(sizeof(struct sta_info
), GFP_ATOMIC
);
1099 PDEBUG(DEBUG_AP
, "AP: kmalloc failed\n");
1103 /* initialize STA info data */
1104 memset(sta
, 0, sizeof(struct sta_info
));
1105 sta
->local
= ap
->local
;
1106 skb_queue_head_init(&sta
->tx_buf
);
1107 memcpy(sta
->addr
, addr
, ETH_ALEN
);
1109 atomic_inc(&sta
->users
);
1110 spin_lock_bh(&ap
->sta_table_lock
);
1111 list_add(&sta
->list
, &ap
->sta_list
);
1113 ap_sta_hash_add(ap
, sta
);
1114 spin_unlock_bh(&ap
->sta_table_lock
);
1117 struct add_sta_proc_data
*entry
;
1118 /* schedule a non-interrupt context process to add a procfs
1119 * entry for the STA since procfs code use GFP_KERNEL */
1120 entry
= kmalloc(sizeof(*entry
), GFP_ATOMIC
);
1122 memcpy(entry
->addr
, sta
->addr
, ETH_ALEN
);
1123 entry
->next
= ap
->add_sta_proc_entries
;
1124 ap
->add_sta_proc_entries
= entry
;
1125 schedule_work(&ap
->add_sta_proc_queue
);
1127 printk(KERN_DEBUG
"Failed to add STA proc data\n");
1130 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1131 init_timer(&sta
->timer
);
1132 sta
->timer
.expires
= jiffies
+ ap
->max_inactivity
;
1133 sta
->timer
.data
= (unsigned long) sta
;
1134 sta
->timer
.function
= ap_handle_timer
;
1135 if (!ap
->local
->hostapd
)
1136 add_timer(&sta
->timer
);
1137 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1143 static int ap_tx_rate_ok(int rateidx
, struct sta_info
*sta
,
1144 local_info_t
*local
)
1146 if (rateidx
> sta
->tx_max_rate
||
1147 !(sta
->tx_supp_rates
& (1 << rateidx
)))
1150 if (local
->tx_rate_control
!= 0 &&
1151 !(local
->tx_rate_control
& (1 << rateidx
)))
1158 static void prism2_check_tx_rates(struct sta_info
*sta
)
1162 sta
->tx_supp_rates
= 0;
1163 for (i
= 0; i
< sizeof(sta
->supported_rates
); i
++) {
1164 if ((sta
->supported_rates
[i
] & 0x7f) == 2)
1165 sta
->tx_supp_rates
|= WLAN_RATE_1M
;
1166 if ((sta
->supported_rates
[i
] & 0x7f) == 4)
1167 sta
->tx_supp_rates
|= WLAN_RATE_2M
;
1168 if ((sta
->supported_rates
[i
] & 0x7f) == 11)
1169 sta
->tx_supp_rates
|= WLAN_RATE_5M5
;
1170 if ((sta
->supported_rates
[i
] & 0x7f) == 22)
1171 sta
->tx_supp_rates
|= WLAN_RATE_11M
;
1173 sta
->tx_max_rate
= sta
->tx_rate
= sta
->tx_rate_idx
= 0;
1174 if (sta
->tx_supp_rates
& WLAN_RATE_1M
) {
1175 sta
->tx_max_rate
= 0;
1176 if (ap_tx_rate_ok(0, sta
, sta
->local
)) {
1178 sta
->tx_rate_idx
= 0;
1181 if (sta
->tx_supp_rates
& WLAN_RATE_2M
) {
1182 sta
->tx_max_rate
= 1;
1183 if (ap_tx_rate_ok(1, sta
, sta
->local
)) {
1185 sta
->tx_rate_idx
= 1;
1188 if (sta
->tx_supp_rates
& WLAN_RATE_5M5
) {
1189 sta
->tx_max_rate
= 2;
1190 if (ap_tx_rate_ok(2, sta
, sta
->local
)) {
1192 sta
->tx_rate_idx
= 2;
1195 if (sta
->tx_supp_rates
& WLAN_RATE_11M
) {
1196 sta
->tx_max_rate
= 3;
1197 if (ap_tx_rate_ok(3, sta
, sta
->local
)) {
1199 sta
->tx_rate_idx
= 3;
1205 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1207 static void ap_crypt_init(struct ap_data
*ap
)
1209 ap
->crypt
= hostap_get_crypto_ops("WEP");
1212 if (ap
->crypt
->init
) {
1213 ap
->crypt_priv
= ap
->crypt
->init(0);
1214 if (ap
->crypt_priv
== NULL
)
1217 u8 key
[WEP_KEY_LEN
];
1218 get_random_bytes(key
, WEP_KEY_LEN
);
1219 ap
->crypt
->set_key(key
, WEP_KEY_LEN
, NULL
,
1225 if (ap
->crypt
== NULL
) {
1226 printk(KERN_WARNING
"AP could not initialize WEP: load module "
1227 "hostap_crypt_wep.o\n");
1232 /* Generate challenge data for shared key authentication. IEEE 802.11 specifies
1233 * that WEP algorithm is used for generating challange. This should be unique,
1234 * but otherwise there is not really need for randomness etc. Initialize WEP
1235 * with pseudo random key and then use increasing IV to get unique challenge
1238 * Called only as a scheduled task for pending AP frames.
1240 static char * ap_auth_make_challenge(struct ap_data
*ap
)
1243 struct sk_buff
*skb
;
1245 if (ap
->crypt
== NULL
) {
1247 if (ap
->crypt
== NULL
)
1251 tmpbuf
= (char *) kmalloc(WLAN_AUTH_CHALLENGE_LEN
, GFP_ATOMIC
);
1252 if (tmpbuf
== NULL
) {
1253 PDEBUG(DEBUG_AP
, "AP: kmalloc failed for challenge\n");
1257 skb
= dev_alloc_skb(WLAN_AUTH_CHALLENGE_LEN
+
1258 ap
->crypt
->extra_prefix_len
+
1259 ap
->crypt
->extra_postfix_len
);
1265 skb_reserve(skb
, ap
->crypt
->extra_prefix_len
);
1266 memset(skb_put(skb
, WLAN_AUTH_CHALLENGE_LEN
), 0,
1267 WLAN_AUTH_CHALLENGE_LEN
);
1268 if (ap
->crypt
->encrypt_mpdu(skb
, 0, ap
->crypt_priv
)) {
1274 memcpy(tmpbuf
, skb
->data
+ ap
->crypt
->extra_prefix_len
,
1275 WLAN_AUTH_CHALLENGE_LEN
);
1282 /* Called only as a scheduled task for pending AP frames. */
1283 static void handle_authen(local_info_t
*local
, struct sk_buff
*skb
,
1284 struct hostap_80211_rx_status
*rx_stats
)
1286 struct net_device
*dev
= local
->dev
;
1287 struct hostap_ieee80211_hdr
*hdr
=
1288 (struct hostap_ieee80211_hdr
*) skb
->data
;
1290 struct ap_data
*ap
= local
->ap
;
1291 char body
[8 + WLAN_AUTH_CHALLENGE_LEN
], *challenge
= NULL
;
1293 u16 auth_alg
, auth_transaction
, status_code
, *pos
;
1294 u16 resp
= WLAN_STATUS_SUCCESS
, fc
;
1295 struct sta_info
*sta
= NULL
;
1296 struct prism2_crypt_data
*crypt
;
1299 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1301 fc
= le16_to_cpu(hdr
->frame_control
);
1302 hdrlen
= hostap_80211_get_hdrlen(fc
);
1305 PDEBUG(DEBUG_AP
, "%s: handle_authen - too short payload "
1306 "(len=%d) from " MACSTR
"\n", dev
->name
, len
,
1307 MAC2STR(hdr
->addr2
));
1311 spin_lock_bh(&local
->ap
->sta_table_lock
);
1312 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1314 atomic_inc(&sta
->users
);
1315 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1317 if (sta
&& sta
->crypt
)
1321 if (skb
->len
>= hdrlen
+ 3)
1322 idx
= skb
->data
[hdrlen
+ 3] >> 6;
1323 crypt
= local
->crypt
[idx
];
1326 pos
= (u16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1327 auth_alg
= __le16_to_cpu(*pos
);
1329 auth_transaction
= __le16_to_cpu(*pos
);
1331 status_code
= __le16_to_cpu(*pos
);
1334 if (memcmp(dev
->dev_addr
, hdr
->addr2
, ETH_ALEN
) == 0 ||
1335 ap_control_mac_deny(&ap
->mac_restrictions
, hdr
->addr2
)) {
1336 txt
= "authentication denied";
1337 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1341 if (((local
->auth_algs
& PRISM2_AUTH_OPEN
) &&
1342 auth_alg
== WLAN_AUTH_OPEN
) ||
1343 ((local
->auth_algs
& PRISM2_AUTH_SHARED_KEY
) &&
1344 crypt
&& auth_alg
== WLAN_AUTH_SHARED_KEY
)) {
1346 txt
= "unsupported algorithm";
1347 resp
= WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG
;
1353 if (*u
== WLAN_EID_CHALLENGE
) {
1354 if (*(u
+ 1) != WLAN_AUTH_CHALLENGE_LEN
) {
1355 txt
= "invalid challenge len";
1356 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1359 if (len
- 8 < WLAN_AUTH_CHALLENGE_LEN
) {
1360 txt
= "challenge underflow";
1361 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1364 challenge
= (char *) (u
+ 2);
1368 if (sta
&& sta
->ap
) {
1369 if (time_after(jiffies
, sta
->u
.ap
.last_beacon
+
1370 (10 * sta
->listen_interval
* HZ
) / 1024)) {
1371 PDEBUG(DEBUG_AP
, "%s: no beacons received for a while,"
1372 " assuming AP " MACSTR
" is now STA\n",
1373 dev
->name
, MAC2STR(sta
->addr
));
1376 sta
->u
.sta
.challenge
= NULL
;
1378 txt
= "AP trying to authenticate?";
1379 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1384 if ((auth_alg
== WLAN_AUTH_OPEN
&& auth_transaction
== 1) ||
1385 (auth_alg
== WLAN_AUTH_SHARED_KEY
&&
1386 (auth_transaction
== 1 ||
1387 (auth_transaction
== 3 && sta
!= NULL
&&
1388 sta
->u
.sta
.challenge
!= NULL
)))) {
1390 txt
= "unknown authentication transaction number";
1391 resp
= WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION
;
1398 if (local
->ap
->num_sta
>= MAX_STA_COUNT
) {
1399 /* FIX: might try to remove some old STAs first? */
1400 txt
= "no more room for new STAs";
1401 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1405 sta
= ap_add_sta(local
->ap
, hdr
->addr2
);
1407 txt
= "ap_add_sta failed";
1408 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1414 case WLAN_AUTH_OPEN
:
1416 /* IEEE 802.11 standard is not completely clear about
1417 * whether STA is considered authenticated after
1418 * authentication OK frame has been send or after it
1419 * has been ACKed. In order to reduce interoperability
1420 * issues, mark the STA authenticated before ACK. */
1421 sta
->flags
|= WLAN_STA_AUTH
;
1424 case WLAN_AUTH_SHARED_KEY
:
1425 if (auth_transaction
== 1) {
1426 if (sta
->u
.sta
.challenge
== NULL
) {
1427 sta
->u
.sta
.challenge
=
1428 ap_auth_make_challenge(local
->ap
);
1429 if (sta
->u
.sta
.challenge
== NULL
) {
1430 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1435 if (sta
->u
.sta
.challenge
== NULL
||
1436 challenge
== NULL
||
1437 memcmp(sta
->u
.sta
.challenge
, challenge
,
1438 WLAN_AUTH_CHALLENGE_LEN
) != 0 ||
1439 !(fc
& WLAN_FC_ISWEP
)) {
1440 txt
= "challenge response incorrect";
1441 resp
= WLAN_STATUS_CHALLENGE_FAIL
;
1445 txt
= "challenge OK - authOK";
1446 /* IEEE 802.11 standard is not completely clear about
1447 * whether STA is considered authenticated after
1448 * authentication OK frame has been send or after it
1449 * has been ACKed. In order to reduce interoperability
1450 * issues, mark the STA authenticated before ACK. */
1451 sta
->flags
|= WLAN_STA_AUTH
;
1452 kfree(sta
->u
.sta
.challenge
);
1453 sta
->u
.sta
.challenge
= NULL
;
1460 *pos
= cpu_to_le16(auth_alg
);
1462 *pos
= cpu_to_le16(auth_transaction
+ 1);
1464 *pos
= cpu_to_le16(resp
); /* status_code */
1468 if (resp
== WLAN_STATUS_SUCCESS
&& sta
!= NULL
&&
1469 sta
->u
.sta
.challenge
!= NULL
&&
1470 auth_alg
== WLAN_AUTH_SHARED_KEY
&& auth_transaction
== 1) {
1471 u8
*tmp
= (u8
*) pos
;
1472 *tmp
++ = WLAN_EID_CHALLENGE
;
1473 *tmp
++ = WLAN_AUTH_CHALLENGE_LEN
;
1475 memcpy(pos
, sta
->u
.sta
.challenge
, WLAN_AUTH_CHALLENGE_LEN
);
1476 olen
+= 2 + WLAN_AUTH_CHALLENGE_LEN
;
1479 prism2_send_mgmt(dev
, WLAN_FC_TYPE_MGMT
, WLAN_FC_STYPE_AUTH
,
1480 body
, olen
, hdr
->addr2
, ap
->tx_callback_auth
);
1483 sta
->last_rx
= jiffies
;
1484 atomic_dec(&sta
->users
);
1488 PDEBUG(DEBUG_AP
, "%s: " MACSTR
" auth (alg=%d trans#=%d "
1489 "stat=%d len=%d fc=%04x) ==> %d (%s)\n",
1490 dev
->name
, MAC2STR(hdr
->addr2
), auth_alg
,
1491 auth_transaction
, status_code
, len
, fc
, resp
, txt
);
1496 /* Called only as a scheduled task for pending AP frames. */
1497 static void handle_assoc(local_info_t
*local
, struct sk_buff
*skb
,
1498 struct hostap_80211_rx_status
*rx_stats
, int reassoc
)
1500 struct net_device
*dev
= local
->dev
;
1501 struct hostap_ieee80211_hdr
*hdr
=
1502 (struct hostap_ieee80211_hdr
*) skb
->data
;
1503 char body
[12], *p
, *lpos
;
1506 u16 resp
= WLAN_STATUS_SUCCESS
;
1507 struct sta_info
*sta
= NULL
;
1508 int send_deauth
= 0;
1510 u8 prev_ap
[ETH_ALEN
];
1512 left
= len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1514 if (len
< (reassoc
? 10 : 4)) {
1515 PDEBUG(DEBUG_AP
, "%s: handle_assoc - too short payload "
1516 "(len=%d, reassoc=%d) from " MACSTR
"\n",
1517 dev
->name
, len
, reassoc
, MAC2STR(hdr
->addr2
));
1521 spin_lock_bh(&local
->ap
->sta_table_lock
);
1522 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1523 if (sta
== NULL
|| (sta
->flags
& WLAN_STA_AUTH
) == 0) {
1524 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1525 txt
= "trying to associate before authentication";
1527 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1528 sta
= NULL
; /* do not decrement sta->users */
1531 atomic_inc(&sta
->users
);
1532 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1534 pos
= (u16
*) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1535 sta
->capability
= __le16_to_cpu(*pos
);
1537 sta
->listen_interval
= __le16_to_cpu(*pos
);
1541 memcpy(prev_ap
, pos
, ETH_ALEN
);
1542 pos
++; pos
++; pos
++; left
-= 6;
1544 memset(prev_ap
, 0, ETH_ALEN
);
1548 unsigned char *u
= (unsigned char *) pos
;
1550 if (*u
== WLAN_EID_SSID
) {
1555 if (ileft
> left
|| ileft
> MAX_SSID_LEN
) {
1556 txt
= "SSID overflow";
1557 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1561 if (ileft
!= strlen(local
->essid
) ||
1562 memcmp(local
->essid
, u
, ileft
) != 0) {
1563 txt
= "not our SSID";
1564 resp
= WLAN_STATUS_ASSOC_DENIED_UNSPEC
;
1572 if (left
>= 2 && *u
== WLAN_EID_SUPP_RATES
) {
1577 if (ileft
> left
|| ileft
== 0 ||
1578 ileft
> WLAN_SUPP_RATES_MAX
) {
1579 txt
= "SUPP_RATES len error";
1580 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1584 memset(sta
->supported_rates
, 0,
1585 sizeof(sta
->supported_rates
));
1586 memcpy(sta
->supported_rates
, u
, ileft
);
1587 prism2_check_tx_rates(sta
);
1594 PDEBUG(DEBUG_AP
, "%s: assoc from " MACSTR
" with extra"
1595 " data (%d bytes) [",
1596 dev
->name
, MAC2STR(hdr
->addr2
), left
);
1598 PDEBUG2(DEBUG_AP
, "<%02x>", *u
);
1601 PDEBUG2(DEBUG_AP
, "]\n");
1604 txt
= "frame underflow";
1605 resp
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1609 /* get a unique AID */
1611 txt
= "OK, old AID";
1613 spin_lock_bh(&local
->ap
->sta_table_lock
);
1614 for (sta
->aid
= 1; sta
->aid
<= MAX_AID_TABLE_SIZE
; sta
->aid
++)
1615 if (local
->ap
->sta_aid
[sta
->aid
- 1] == NULL
)
1617 if (sta
->aid
> MAX_AID_TABLE_SIZE
) {
1619 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1620 resp
= WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA
;
1621 txt
= "no room for more AIDs";
1623 local
->ap
->sta_aid
[sta
->aid
- 1] = sta
;
1624 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1625 txt
= "OK, new AID";
1633 *pos
= __constant_cpu_to_le16(
1634 WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH
);
1637 /* FIX: CF-Pollable and CF-PollReq should be set to match the
1638 * values in beacons/probe responses */
1639 /* FIX: how about privacy and WEP? */
1641 *pos
= __constant_cpu_to_le16(WLAN_CAPABILITY_ESS
);
1645 *pos
= __cpu_to_le16(resp
);
1648 *pos
= __cpu_to_le16((sta
&& sta
->aid
> 0 ? sta
->aid
: 0) |
1649 BIT(14) | BIT(15)); /* AID */
1652 /* Supported rates (Information element) */
1654 *p
++ = WLAN_EID_SUPP_RATES
;
1657 if (local
->tx_rate_control
& WLAN_RATE_1M
) {
1658 *p
++ = local
->basic_rates
& WLAN_RATE_1M
? 0x82 : 0x02;
1661 if (local
->tx_rate_control
& WLAN_RATE_2M
) {
1662 *p
++ = local
->basic_rates
& WLAN_RATE_2M
? 0x84 : 0x04;
1665 if (local
->tx_rate_control
& WLAN_RATE_5M5
) {
1666 *p
++ = local
->basic_rates
& WLAN_RATE_5M5
?
1670 if (local
->tx_rate_control
& WLAN_RATE_11M
) {
1671 *p
++ = local
->basic_rates
& WLAN_RATE_11M
?
1678 prism2_send_mgmt(dev
, WLAN_FC_TYPE_MGMT
,
1679 (send_deauth
? WLAN_FC_STYPE_DEAUTH
:
1680 (reassoc
? WLAN_FC_STYPE_REASSOC_RESP
:
1681 WLAN_FC_STYPE_ASSOC_RESP
)),
1682 body
, (u8
*) pos
- (u8
*) body
,
1684 send_deauth
? 0 : local
->ap
->tx_callback_assoc
);
1687 if (resp
== WLAN_STATUS_SUCCESS
) {
1688 sta
->last_rx
= jiffies
;
1689 /* STA will be marked associated from TX callback, if
1690 * AssocResp is ACKed */
1692 atomic_dec(&sta
->users
);
1696 PDEBUG(DEBUG_AP
, "%s: " MACSTR
" %sassoc (len=%d prev_ap=" MACSTR
1697 ") => %d(%d) (%s)\n",
1698 dev
->name
, MAC2STR(hdr
->addr2
), reassoc
? "re" : "", len
,
1699 MAC2STR(prev_ap
), resp
, send_deauth
, txt
);
1704 /* Called only as a scheduled task for pending AP frames. */
1705 static void handle_deauth(local_info_t
*local
, struct sk_buff
*skb
,
1706 struct hostap_80211_rx_status
*rx_stats
)
1708 struct net_device
*dev
= local
->dev
;
1709 struct hostap_ieee80211_hdr
*hdr
=
1710 (struct hostap_ieee80211_hdr
*) skb
->data
;
1711 char *body
= (char *) (skb
->data
+ IEEE80211_MGMT_HDR_LEN
);
1713 u16 reason_code
, *pos
;
1714 struct sta_info
*sta
= NULL
;
1716 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1719 printk("handle_deauth - too short payload (len=%d)\n", len
);
1724 reason_code
= __le16_to_cpu(*pos
);
1726 PDEBUG(DEBUG_AP
, "%s: deauthentication: " MACSTR
" len=%d, "
1727 "reason_code=%d\n", dev
->name
, MAC2STR(hdr
->addr2
), len
,
1730 spin_lock_bh(&local
->ap
->sta_table_lock
);
1731 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1733 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
1734 hostap_event_expired_sta(local
->dev
, sta
);
1735 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
1737 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1739 printk("%s: deauthentication from " MACSTR
", "
1740 "reason_code=%d, but STA not authenticated\n", dev
->name
,
1741 MAC2STR(hdr
->addr2
), reason_code
);
1746 /* Called only as a scheduled task for pending AP frames. */
1747 static void handle_disassoc(local_info_t
*local
, struct sk_buff
*skb
,
1748 struct hostap_80211_rx_status
*rx_stats
)
1750 struct net_device
*dev
= local
->dev
;
1751 struct hostap_ieee80211_hdr
*hdr
=
1752 (struct hostap_ieee80211_hdr
*) skb
->data
;
1753 char *body
= skb
->data
+ IEEE80211_MGMT_HDR_LEN
;
1755 u16 reason_code
, *pos
;
1756 struct sta_info
*sta
= NULL
;
1758 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1761 printk("handle_disassoc - too short payload (len=%d)\n", len
);
1766 reason_code
= __le16_to_cpu(*pos
);
1768 PDEBUG(DEBUG_AP
, "%s: disassociation: " MACSTR
" len=%d, "
1769 "reason_code=%d\n", dev
->name
, MAC2STR(hdr
->addr2
), len
,
1772 spin_lock_bh(&local
->ap
->sta_table_lock
);
1773 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1775 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
1776 hostap_event_expired_sta(local
->dev
, sta
);
1777 sta
->flags
&= ~WLAN_STA_ASSOC
;
1779 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1781 printk("%s: disassociation from " MACSTR
", "
1782 "reason_code=%d, but STA not authenticated\n",
1783 dev
->name
, MAC2STR(hdr
->addr2
), reason_code
);
1788 /* Called only as a scheduled task for pending AP frames. */
1789 static void ap_handle_data_nullfunc(local_info_t
*local
,
1790 struct hostap_ieee80211_hdr
*hdr
)
1792 struct net_device
*dev
= local
->dev
;
1794 /* some STA f/w's seem to require control::ACK frame for
1795 * data::nullfunc, but at least Prism2 station f/w version 0.8.0 does
1797 * send control::ACK for the data::nullfunc */
1799 printk(KERN_DEBUG
"Sending control::ACK for data::nullfunc\n");
1800 prism2_send_mgmt(dev
, WLAN_FC_TYPE_CTRL
, WLAN_FC_STYPE_ACK
,
1801 NULL
, 0, hdr
->addr2
, 0);
1805 /* Called only as a scheduled task for pending AP frames. */
1806 static void ap_handle_dropped_data(local_info_t
*local
,
1807 struct hostap_ieee80211_hdr
*hdr
)
1809 struct net_device
*dev
= local
->dev
;
1810 struct sta_info
*sta
;
1813 spin_lock_bh(&local
->ap
->sta_table_lock
);
1814 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1816 atomic_inc(&sta
->users
);
1817 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1819 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
)) {
1820 PDEBUG(DEBUG_AP
, "ap_handle_dropped_data: STA is now okay?\n");
1821 atomic_dec(&sta
->users
);
1825 reason
= __constant_cpu_to_le16(
1826 WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA
);
1827 prism2_send_mgmt(dev
, WLAN_FC_TYPE_MGMT
,
1828 ((sta
== NULL
|| !(sta
->flags
& WLAN_STA_ASSOC
)) ?
1829 WLAN_FC_STYPE_DEAUTH
: WLAN_FC_STYPE_DISASSOC
),
1830 (char *) &reason
, sizeof(reason
), hdr
->addr2
, 0);
1833 atomic_dec(&sta
->users
);
1836 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
1839 /* Called only as a scheduled task for pending AP frames. */
1840 static void pspoll_send_buffered(local_info_t
*local
, struct sta_info
*sta
,
1841 struct sk_buff
*skb
)
1843 if (!(sta
->flags
& WLAN_STA_PS
)) {
1844 /* Station has moved to non-PS mode, so send all buffered
1845 * frames using normal device queue. */
1846 dev_queue_xmit(skb
);
1850 /* add a flag for hostap_handle_sta_tx() to know that this skb should
1851 * be passed through even though STA is using PS */
1852 memcpy(skb
->cb
, AP_SKB_CB_MAGIC
, AP_SKB_CB_MAGIC_LEN
);
1853 skb
->cb
[AP_SKB_CB_MAGIC_LEN
] = AP_SKB_CB_BUFFERED_FRAME
;
1854 if (!skb_queue_empty(&sta
->tx_buf
)) {
1855 /* indicate to STA that more frames follow */
1856 skb
->cb
[AP_SKB_CB_MAGIC_LEN
] |= AP_SKB_CB_ADD_MOREDATA
;
1858 dev_queue_xmit(skb
);
1862 /* Called only as a scheduled task for pending AP frames. */
1863 static void handle_pspoll(local_info_t
*local
,
1864 struct hostap_ieee80211_hdr
*hdr
,
1865 struct hostap_80211_rx_status
*rx_stats
)
1867 struct net_device
*dev
= local
->dev
;
1868 struct sta_info
*sta
;
1870 struct sk_buff
*skb
;
1872 PDEBUG(DEBUG_PS2
, "handle_pspoll: BSSID=" MACSTR
", TA=" MACSTR
1874 MAC2STR(hdr
->addr1
), MAC2STR(hdr
->addr2
),
1875 !!(le16_to_cpu(hdr
->frame_control
) & WLAN_FC_PWRMGT
));
1877 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
1878 PDEBUG(DEBUG_AP
, "handle_pspoll - addr1(BSSID)=" MACSTR
1879 " not own MAC\n", MAC2STR(hdr
->addr1
));
1883 aid
= __le16_to_cpu(hdr
->duration_id
);
1884 if ((aid
& (BIT(15) | BIT(14))) != (BIT(15) | BIT(14))) {
1885 PDEBUG(DEBUG_PS
, " PSPOLL and AID[15:14] not set\n");
1888 aid
&= ~BIT(15) & ~BIT(14);
1889 if (aid
== 0 || aid
> MAX_AID_TABLE_SIZE
) {
1890 PDEBUG(DEBUG_PS
, " invalid aid=%d\n", aid
);
1893 PDEBUG(DEBUG_PS2
, " aid=%d\n", aid
);
1895 spin_lock_bh(&local
->ap
->sta_table_lock
);
1896 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
1898 atomic_inc(&sta
->users
);
1899 spin_unlock_bh(&local
->ap
->sta_table_lock
);
1902 PDEBUG(DEBUG_PS
, " STA not found\n");
1905 if (sta
->aid
!= aid
) {
1906 PDEBUG(DEBUG_PS
, " received aid=%i does not match with "
1907 "assoc.aid=%d\n", aid
, sta
->aid
);
1912 * - add timeout for buffering (clear aid in TIM vector if buffer timed
1913 * out (expiry time must be longer than ListenInterval for
1914 * the corresponding STA; "8802-11: 11.2.1.9 AP aging function"
1915 * - what to do, if buffered, pspolled, and sent frame is not ACKed by
1916 * sta; store buffer for later use and leave TIM aid bit set? use
1917 * TX event to check whether frame was ACKed?
1920 while ((skb
= skb_dequeue(&sta
->tx_buf
)) != NULL
) {
1921 /* send buffered frame .. */
1922 PDEBUG(DEBUG_PS2
, "Sending buffered frame to STA after PS POLL"
1923 " (buffer_count=%d)\n", skb_queue_len(&sta
->tx_buf
));
1925 pspoll_send_buffered(local
, sta
, skb
);
1927 if (sta
->flags
& WLAN_STA_PS
) {
1928 /* send only one buffered packet per PS Poll */
1929 /* FIX: should ignore further PS Polls until the
1930 * buffered packet that was just sent is acknowledged
1931 * (Tx or TxExc event) */
1936 if (skb_queue_empty(&sta
->tx_buf
)) {
1937 /* try to clear aid from TIM */
1938 if (!(sta
->flags
& WLAN_STA_TIM
))
1939 PDEBUG(DEBUG_PS2
, "Re-unsetting TIM for aid %d\n",
1941 hostap_set_tim(local
, aid
, 0);
1942 sta
->flags
&= ~WLAN_STA_TIM
;
1945 atomic_dec(&sta
->users
);
1949 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1951 static void handle_wds_oper_queue(void *data
)
1953 local_info_t
*local
= data
;
1954 struct wds_oper_data
*entry
, *prev
;
1956 spin_lock_bh(&local
->lock
);
1957 entry
= local
->ap
->wds_oper_entries
;
1958 local
->ap
->wds_oper_entries
= NULL
;
1959 spin_unlock_bh(&local
->lock
);
1962 PDEBUG(DEBUG_AP
, "%s: %s automatic WDS connection "
1963 "to AP " MACSTR
"\n",
1965 entry
->type
== WDS_ADD
? "adding" : "removing",
1966 MAC2STR(entry
->addr
));
1967 if (entry
->type
== WDS_ADD
)
1968 prism2_wds_add(local
, entry
->addr
, 0);
1969 else if (entry
->type
== WDS_DEL
)
1970 prism2_wds_del(local
, entry
->addr
, 0, 1);
1973 entry
= entry
->next
;
1979 /* Called only as a scheduled task for pending AP frames. */
1980 static void handle_beacon(local_info_t
*local
, struct sk_buff
*skb
,
1981 struct hostap_80211_rx_status
*rx_stats
)
1983 struct hostap_ieee80211_hdr
*hdr
=
1984 (struct hostap_ieee80211_hdr
*) skb
->data
;
1985 char *body
= skb
->data
+ IEEE80211_MGMT_HDR_LEN
;
1987 u16
*pos
, beacon_int
, capability
;
1989 unsigned char *supp_rates
= NULL
;
1990 int ssid_len
= 0, supp_rates_len
= 0;
1991 struct sta_info
*sta
= NULL
;
1992 int new_sta
= 0, channel
= -1;
1994 len
= skb
->len
- IEEE80211_MGMT_HDR_LEN
;
1996 if (len
< 8 + 2 + 2) {
1997 printk(KERN_DEBUG
"handle_beacon - too short payload "
2005 /* Timestamp (8 octets) */
2006 pos
+= 4; left
-= 8;
2007 /* Beacon interval (2 octets) */
2008 beacon_int
= __le16_to_cpu(*pos
);
2010 /* Capability information (2 octets) */
2011 capability
= __le16_to_cpu(*pos
);
2014 if (local
->ap
->ap_policy
!= AP_OTHER_AP_EVEN_IBSS
&&
2015 capability
& WLAN_CAPABILITY_IBSS
)
2020 unsigned char *u
= (unsigned char *) pos
;
2022 if (*u
== WLAN_EID_SSID
) {
2027 if (ileft
> left
|| ileft
> MAX_SSID_LEN
) {
2028 PDEBUG(DEBUG_AP
, "SSID: overflow\n");
2032 if (local
->ap
->ap_policy
== AP_OTHER_AP_SAME_SSID
&&
2033 (ileft
!= strlen(local
->essid
) ||
2034 memcmp(local
->essid
, u
, ileft
) != 0)) {
2046 if (*u
== WLAN_EID_SUPP_RATES
) {
2051 if (ileft
> left
|| ileft
== 0 || ileft
> 8) {
2052 PDEBUG(DEBUG_AP
, " - SUPP_RATES len error\n");
2057 supp_rates_len
= ileft
;
2063 if (*u
== WLAN_EID_DS_PARAMS
) {
2068 if (ileft
> left
|| ileft
!= 1) {
2069 PDEBUG(DEBUG_AP
, " - DS_PARAMS len error\n");
2080 spin_lock_bh(&local
->ap
->sta_table_lock
);
2081 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2083 atomic_inc(&sta
->users
);
2084 spin_unlock_bh(&local
->ap
->sta_table_lock
);
2089 sta
= ap_add_sta(local
->ap
, hdr
->addr2
);
2091 printk(KERN_INFO
"prism2: kmalloc failed for AP "
2092 "data structure\n");
2095 hostap_event_new_sta(local
->dev
, sta
);
2097 /* mark APs authentication and associated for pseudo ad-hoc
2098 * style communication */
2099 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
2101 if (local
->ap
->autom_ap_wds
) {
2102 hostap_wds_link_oper(local
, sta
->addr
, WDS_ADD
);
2108 sta
->u
.ap
.ssid_len
= ssid_len
;
2109 memcpy(sta
->u
.ap
.ssid
, ssid
, ssid_len
);
2110 sta
->u
.ap
.ssid
[ssid_len
] = '\0';
2112 sta
->u
.ap
.ssid_len
= 0;
2113 sta
->u
.ap
.ssid
[0] = '\0';
2115 sta
->u
.ap
.channel
= channel
;
2117 sta
->rx_bytes
+= len
;
2118 sta
->u
.ap
.last_beacon
= sta
->last_rx
= jiffies
;
2119 sta
->capability
= capability
;
2120 sta
->listen_interval
= beacon_int
;
2122 atomic_dec(&sta
->users
);
2125 memset(sta
->supported_rates
, 0, sizeof(sta
->supported_rates
));
2126 memcpy(sta
->supported_rates
, supp_rates
, supp_rates_len
);
2127 prism2_check_tx_rates(sta
);
2131 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2134 /* Called only as a tasklet. */
2135 static void handle_ap_item(local_info_t
*local
, struct sk_buff
*skb
,
2136 struct hostap_80211_rx_status
*rx_stats
)
2138 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2139 struct net_device
*dev
= local
->dev
;
2140 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2141 u16 fc
, type
, stype
;
2142 struct hostap_ieee80211_hdr
*hdr
;
2144 /* FIX: should give skb->len to handler functions and check that the
2145 * buffer is long enough */
2146 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
2147 fc
= le16_to_cpu(hdr
->frame_control
);
2148 type
= WLAN_FC_GET_TYPE(fc
);
2149 stype
= WLAN_FC_GET_STYPE(fc
);
2151 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2152 if (!local
->hostapd
&& type
== WLAN_FC_TYPE_DATA
) {
2153 PDEBUG(DEBUG_AP
, "handle_ap_item - data frame\n");
2155 if (!(fc
& WLAN_FC_TODS
) || (fc
& WLAN_FC_FROMDS
)) {
2156 if (stype
== WLAN_FC_STYPE_NULLFUNC
) {
2157 /* no ToDS nullfunc seems to be used to check
2158 * AP association; so send reject message to
2159 * speed up re-association */
2160 ap_handle_dropped_data(local
, hdr
);
2163 PDEBUG(DEBUG_AP
, " not ToDS frame (fc=0x%04x)\n",
2168 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
2169 PDEBUG(DEBUG_AP
, "handle_ap_item - addr1(BSSID)="
2170 MACSTR
" not own MAC\n",
2171 MAC2STR(hdr
->addr1
));
2175 if (local
->ap
->nullfunc_ack
&& stype
== WLAN_FC_STYPE_NULLFUNC
)
2176 ap_handle_data_nullfunc(local
, hdr
);
2178 ap_handle_dropped_data(local
, hdr
);
2182 if (type
== WLAN_FC_TYPE_MGMT
&& stype
== WLAN_FC_STYPE_BEACON
) {
2183 handle_beacon(local
, skb
, rx_stats
);
2186 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2188 if (type
== WLAN_FC_TYPE_CTRL
&& stype
== WLAN_FC_STYPE_PSPOLL
) {
2189 handle_pspoll(local
, hdr
, rx_stats
);
2193 if (local
->hostapd
) {
2194 PDEBUG(DEBUG_AP
, "Unknown frame in AP queue: type=0x%02x "
2195 "subtype=0x%02x\n", type
, stype
);
2199 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2200 if (type
!= WLAN_FC_TYPE_MGMT
) {
2201 PDEBUG(DEBUG_AP
, "handle_ap_item - not a management frame?\n");
2205 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
)) {
2206 PDEBUG(DEBUG_AP
, "handle_ap_item - addr1(DA)=" MACSTR
2207 " not own MAC\n", MAC2STR(hdr
->addr1
));
2211 if (memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
)) {
2212 PDEBUG(DEBUG_AP
, "handle_ap_item - addr3(BSSID)=" MACSTR
2213 " not own MAC\n", MAC2STR(hdr
->addr3
));
2218 case WLAN_FC_STYPE_ASSOC_REQ
:
2219 handle_assoc(local
, skb
, rx_stats
, 0);
2221 case WLAN_FC_STYPE_ASSOC_RESP
:
2222 PDEBUG(DEBUG_AP
, "==> ASSOC RESP (ignored)\n");
2224 case WLAN_FC_STYPE_REASSOC_REQ
:
2225 handle_assoc(local
, skb
, rx_stats
, 1);
2227 case WLAN_FC_STYPE_REASSOC_RESP
:
2228 PDEBUG(DEBUG_AP
, "==> REASSOC RESP (ignored)\n");
2230 case WLAN_FC_STYPE_ATIM
:
2231 PDEBUG(DEBUG_AP
, "==> ATIM (ignored)\n");
2233 case WLAN_FC_STYPE_DISASSOC
:
2234 handle_disassoc(local
, skb
, rx_stats
);
2236 case WLAN_FC_STYPE_AUTH
:
2237 handle_authen(local
, skb
, rx_stats
);
2239 case WLAN_FC_STYPE_DEAUTH
:
2240 handle_deauth(local
, skb
, rx_stats
);
2243 PDEBUG(DEBUG_AP
, "Unknown mgmt frame subtype 0x%02x\n", stype
);
2246 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2253 /* Called only as a tasklet (software IRQ) */
2254 void hostap_rx(struct net_device
*dev
, struct sk_buff
*skb
,
2255 struct hostap_80211_rx_status
*rx_stats
)
2257 struct hostap_interface
*iface
;
2258 local_info_t
*local
;
2260 struct hostap_ieee80211_hdr
*hdr
;
2262 iface
= netdev_priv(dev
);
2263 local
= iface
->local
;
2268 local
->stats
.rx_packets
++;
2270 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
2271 fc
= le16_to_cpu(hdr
->frame_control
);
2273 if (local
->ap
->ap_policy
== AP_OTHER_AP_SKIP_ALL
&&
2274 WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
2275 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_BEACON
)
2278 skb
->protocol
= __constant_htons(ETH_P_HOSTAP
);
2279 handle_ap_item(local
, skb
, rx_stats
);
2287 /* Called only as a tasklet (software IRQ) */
2288 static void schedule_packet_send(local_info_t
*local
, struct sta_info
*sta
)
2290 struct sk_buff
*skb
;
2291 struct hostap_ieee80211_hdr
*hdr
;
2292 struct hostap_80211_rx_status rx_stats
;
2294 if (skb_queue_empty(&sta
->tx_buf
))
2297 skb
= dev_alloc_skb(16);
2299 printk(KERN_DEBUG
"%s: schedule_packet_send: skb alloc "
2300 "failed\n", local
->dev
->name
);
2304 hdr
= (struct hostap_ieee80211_hdr
*) skb_put(skb
, 16);
2306 /* Generate a fake pspoll frame to start packet delivery */
2307 hdr
->frame_control
= __constant_cpu_to_le16(
2308 (WLAN_FC_TYPE_CTRL
<< 2) | (WLAN_FC_STYPE_PSPOLL
<< 4));
2309 memcpy(hdr
->addr1
, local
->dev
->dev_addr
, ETH_ALEN
);
2310 memcpy(hdr
->addr2
, sta
->addr
, ETH_ALEN
);
2311 hdr
->duration_id
= cpu_to_le16(sta
->aid
| BIT(15) | BIT(14));
2313 PDEBUG(DEBUG_PS2
, "%s: Scheduling buffered packet delivery for "
2314 "STA " MACSTR
"\n", local
->dev
->name
, MAC2STR(sta
->addr
));
2316 skb
->dev
= local
->dev
;
2318 memset(&rx_stats
, 0, sizeof(rx_stats
));
2319 hostap_rx(local
->dev
, skb
, &rx_stats
);
2323 static int prism2_ap_get_sta_qual(local_info_t
*local
, struct sockaddr addr
[],
2324 struct iw_quality qual
[], int buf_size
,
2327 struct ap_data
*ap
= local
->ap
;
2328 struct list_head
*ptr
;
2331 spin_lock_bh(&ap
->sta_table_lock
);
2333 for (ptr
= ap
->sta_list
.next
; ptr
!= NULL
&& ptr
!= &ap
->sta_list
;
2335 struct sta_info
*sta
= (struct sta_info
*) ptr
;
2337 if (aplist
&& !sta
->ap
)
2339 addr
[count
].sa_family
= ARPHRD_ETHER
;
2340 memcpy(addr
[count
].sa_data
, sta
->addr
, ETH_ALEN
);
2341 if (sta
->last_rx_silence
== 0)
2342 qual
[count
].qual
= sta
->last_rx_signal
< 27 ?
2343 0 : (sta
->last_rx_signal
- 27) * 92 / 127;
2345 qual
[count
].qual
= sta
->last_rx_signal
-
2346 sta
->last_rx_silence
- 35;
2347 qual
[count
].level
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_signal
);
2348 qual
[count
].noise
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_silence
);
2349 qual
[count
].updated
= sta
->last_rx_updated
;
2351 sta
->last_rx_updated
= 0;
2354 if (count
>= buf_size
)
2357 spin_unlock_bh(&ap
->sta_table_lock
);
2363 /* Translate our list of Access Points & Stations to a card independant
2364 * format that the Wireless Tools will understand - Jean II */
2365 static int prism2_ap_translate_scan(struct net_device
*dev
, char *buffer
)
2367 struct hostap_interface
*iface
;
2368 local_info_t
*local
;
2370 struct list_head
*ptr
;
2371 struct iw_event iwe
;
2372 char *current_ev
= buffer
;
2373 char *end_buf
= buffer
+ IW_SCAN_MAX_DATA
;
2374 #if !defined(PRISM2_NO_KERNEL_IEEE80211_MGMT)
2378 iface
= netdev_priv(dev
);
2379 local
= iface
->local
;
2382 spin_lock_bh(&ap
->sta_table_lock
);
2384 for (ptr
= ap
->sta_list
.next
; ptr
!= NULL
&& ptr
!= &ap
->sta_list
;
2386 struct sta_info
*sta
= (struct sta_info
*) ptr
;
2388 /* First entry *MUST* be the AP MAC address */
2389 memset(&iwe
, 0, sizeof(iwe
));
2390 iwe
.cmd
= SIOCGIWAP
;
2391 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
2392 memcpy(iwe
.u
.ap_addr
.sa_data
, sta
->addr
, ETH_ALEN
);
2393 iwe
.len
= IW_EV_ADDR_LEN
;
2394 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2397 /* Use the mode to indicate if it's a station or
2398 * an Access Point */
2399 memset(&iwe
, 0, sizeof(iwe
));
2400 iwe
.cmd
= SIOCGIWMODE
;
2402 iwe
.u
.mode
= IW_MODE_MASTER
;
2404 iwe
.u
.mode
= IW_MODE_INFRA
;
2405 iwe
.len
= IW_EV_UINT_LEN
;
2406 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2410 memset(&iwe
, 0, sizeof(iwe
));
2412 if (sta
->last_rx_silence
== 0)
2413 iwe
.u
.qual
.qual
= sta
->last_rx_signal
< 27 ?
2414 0 : (sta
->last_rx_signal
- 27) * 92 / 127;
2416 iwe
.u
.qual
.qual
= sta
->last_rx_signal
-
2417 sta
->last_rx_silence
- 35;
2418 iwe
.u
.qual
.level
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_signal
);
2419 iwe
.u
.qual
.noise
= HFA384X_LEVEL_TO_dBm(sta
->last_rx_silence
);
2420 iwe
.u
.qual
.updated
= sta
->last_rx_updated
;
2421 iwe
.len
= IW_EV_QUAL_LEN
;
2422 current_ev
= iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
2425 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2427 memset(&iwe
, 0, sizeof(iwe
));
2428 iwe
.cmd
= SIOCGIWESSID
;
2429 iwe
.u
.data
.length
= sta
->u
.ap
.ssid_len
;
2430 iwe
.u
.data
.flags
= 1;
2431 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2435 memset(&iwe
, 0, sizeof(iwe
));
2436 iwe
.cmd
= SIOCGIWENCODE
;
2437 if (sta
->capability
& WLAN_CAPABILITY_PRIVACY
)
2439 IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
2441 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
2442 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2445 /* 0 byte memcpy */);
2447 if (sta
->u
.ap
.channel
> 0 &&
2448 sta
->u
.ap
.channel
<= FREQ_COUNT
) {
2449 memset(&iwe
, 0, sizeof(iwe
));
2450 iwe
.cmd
= SIOCGIWFREQ
;
2451 iwe
.u
.freq
.m
= freq_list
[sta
->u
.ap
.channel
- 1]
2454 current_ev
= iwe_stream_add_event(
2455 current_ev
, end_buf
, &iwe
,
2459 memset(&iwe
, 0, sizeof(iwe
));
2460 iwe
.cmd
= IWEVCUSTOM
;
2461 sprintf(buf
, "beacon_interval=%d",
2462 sta
->listen_interval
);
2463 iwe
.u
.data
.length
= strlen(buf
);
2464 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
2467 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2469 sta
->last_rx_updated
= 0;
2471 /* To be continued, we should make good use of IWEVCUSTOM */
2474 spin_unlock_bh(&ap
->sta_table_lock
);
2476 return current_ev
- buffer
;
2480 static int prism2_hostapd_add_sta(struct ap_data
*ap
,
2481 struct prism2_hostapd_param
*param
)
2483 struct sta_info
*sta
;
2485 spin_lock_bh(&ap
->sta_table_lock
);
2486 sta
= ap_get_sta(ap
, param
->sta_addr
);
2488 atomic_inc(&sta
->users
);
2489 spin_unlock_bh(&ap
->sta_table_lock
);
2492 sta
= ap_add_sta(ap
, param
->sta_addr
);
2497 if (!(sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
2498 hostap_event_new_sta(sta
->local
->dev
, sta
);
2500 sta
->flags
|= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
2501 sta
->last_rx
= jiffies
;
2502 sta
->aid
= param
->u
.add_sta
.aid
;
2503 sta
->capability
= param
->u
.add_sta
.capability
;
2504 sta
->tx_supp_rates
= param
->u
.add_sta
.tx_supp_rates
;
2505 if (sta
->tx_supp_rates
& WLAN_RATE_1M
)
2506 sta
->supported_rates
[0] = 2;
2507 if (sta
->tx_supp_rates
& WLAN_RATE_2M
)
2508 sta
->supported_rates
[1] = 4;
2509 if (sta
->tx_supp_rates
& WLAN_RATE_5M5
)
2510 sta
->supported_rates
[2] = 11;
2511 if (sta
->tx_supp_rates
& WLAN_RATE_11M
)
2512 sta
->supported_rates
[3] = 22;
2513 prism2_check_tx_rates(sta
);
2514 atomic_dec(&sta
->users
);
2519 static int prism2_hostapd_remove_sta(struct ap_data
*ap
,
2520 struct prism2_hostapd_param
*param
)
2522 struct sta_info
*sta
;
2524 spin_lock_bh(&ap
->sta_table_lock
);
2525 sta
= ap_get_sta(ap
, param
->sta_addr
);
2527 ap_sta_hash_del(ap
, sta
);
2528 list_del(&sta
->list
);
2530 spin_unlock_bh(&ap
->sta_table_lock
);
2535 if ((sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&& sta
->local
)
2536 hostap_event_expired_sta(sta
->local
->dev
, sta
);
2537 ap_free_sta(ap
, sta
);
2543 static int prism2_hostapd_get_info_sta(struct ap_data
*ap
,
2544 struct prism2_hostapd_param
*param
)
2546 struct sta_info
*sta
;
2548 spin_lock_bh(&ap
->sta_table_lock
);
2549 sta
= ap_get_sta(ap
, param
->sta_addr
);
2551 atomic_inc(&sta
->users
);
2552 spin_unlock_bh(&ap
->sta_table_lock
);
2557 param
->u
.get_info_sta
.inactive_sec
= (jiffies
- sta
->last_rx
) / HZ
;
2559 atomic_dec(&sta
->users
);
2565 static int prism2_hostapd_set_flags_sta(struct ap_data
*ap
,
2566 struct prism2_hostapd_param
*param
)
2568 struct sta_info
*sta
;
2570 spin_lock_bh(&ap
->sta_table_lock
);
2571 sta
= ap_get_sta(ap
, param
->sta_addr
);
2573 sta
->flags
|= param
->u
.set_flags_sta
.flags_or
;
2574 sta
->flags
&= param
->u
.set_flags_sta
.flags_and
;
2576 spin_unlock_bh(&ap
->sta_table_lock
);
2585 static int prism2_hostapd_sta_clear_stats(struct ap_data
*ap
,
2586 struct prism2_hostapd_param
*param
)
2588 struct sta_info
*sta
;
2591 spin_lock_bh(&ap
->sta_table_lock
);
2592 sta
= ap_get_sta(ap
, param
->sta_addr
);
2594 sta
->rx_packets
= sta
->tx_packets
= 0;
2595 sta
->rx_bytes
= sta
->tx_bytes
= 0;
2596 for (rate
= 0; rate
< WLAN_RATE_COUNT
; rate
++) {
2597 sta
->tx_count
[rate
] = 0;
2598 sta
->rx_count
[rate
] = 0;
2601 spin_unlock_bh(&ap
->sta_table_lock
);
2610 static int prism2_hostapd(struct ap_data
*ap
,
2611 struct prism2_hostapd_param
*param
)
2613 switch (param
->cmd
) {
2614 case PRISM2_HOSTAPD_FLUSH
:
2615 ap_control_kickall(ap
);
2617 case PRISM2_HOSTAPD_ADD_STA
:
2618 return prism2_hostapd_add_sta(ap
, param
);
2619 case PRISM2_HOSTAPD_REMOVE_STA
:
2620 return prism2_hostapd_remove_sta(ap
, param
);
2621 case PRISM2_HOSTAPD_GET_INFO_STA
:
2622 return prism2_hostapd_get_info_sta(ap
, param
);
2623 case PRISM2_HOSTAPD_SET_FLAGS_STA
:
2624 return prism2_hostapd_set_flags_sta(ap
, param
);
2625 case PRISM2_HOSTAPD_STA_CLEAR_STATS
:
2626 return prism2_hostapd_sta_clear_stats(ap
, param
);
2628 printk(KERN_WARNING
"prism2_hostapd: unknown cmd=%d\n",
2635 /* Update station info for host-based TX rate control and return current
2637 static int ap_update_sta_tx_rate(struct sta_info
*sta
, struct net_device
*dev
)
2639 int ret
= sta
->tx_rate
;
2640 struct hostap_interface
*iface
;
2641 local_info_t
*local
;
2643 iface
= netdev_priv(dev
);
2644 local
= iface
->local
;
2646 sta
->tx_count
[sta
->tx_rate_idx
]++;
2647 sta
->tx_since_last_failure
++;
2648 sta
->tx_consecutive_exc
= 0;
2649 if (sta
->tx_since_last_failure
>= WLAN_RATE_UPDATE_COUNT
&&
2650 sta
->tx_rate_idx
< sta
->tx_max_rate
) {
2651 /* use next higher rate */
2652 int old_rate
, new_rate
;
2653 old_rate
= new_rate
= sta
->tx_rate_idx
;
2654 while (new_rate
< sta
->tx_max_rate
) {
2656 if (ap_tx_rate_ok(new_rate
, sta
, local
)) {
2657 sta
->tx_rate_idx
= new_rate
;
2661 if (old_rate
!= sta
->tx_rate_idx
) {
2662 switch (sta
->tx_rate_idx
) {
2663 case 0: sta
->tx_rate
= 10; break;
2664 case 1: sta
->tx_rate
= 20; break;
2665 case 2: sta
->tx_rate
= 55; break;
2666 case 3: sta
->tx_rate
= 110; break;
2667 default: sta
->tx_rate
= 0; break;
2669 PDEBUG(DEBUG_AP
, "%s: STA " MACSTR
" TX rate raised to"
2670 " %d\n", dev
->name
, MAC2STR(sta
->addr
),
2673 sta
->tx_since_last_failure
= 0;
2680 /* Called only from software IRQ. Called for each TX frame prior possible
2681 * encryption and transmit. */
2682 ap_tx_ret
hostap_handle_sta_tx(local_info_t
*local
, struct hostap_tx_data
*tx
)
2684 struct sta_info
*sta
= NULL
;
2685 struct sk_buff
*skb
= tx
->skb
;
2687 struct hostap_ieee80211_hdr
*hdr
;
2688 struct hostap_skb_tx_data
*meta
;
2690 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
2691 ret
= AP_TX_CONTINUE
;
2692 if (local
->ap
== NULL
|| skb
->len
< 10 ||
2693 meta
->iface
->type
== HOSTAP_INTERFACE_STA
)
2696 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
2698 if (hdr
->addr1
[0] & 0x01) {
2699 /* broadcast/multicast frame - no AP related processing */
2703 /* unicast packet - check whether destination STA is associated */
2704 spin_lock(&local
->ap
->sta_table_lock
);
2705 sta
= ap_get_sta(local
->ap
, hdr
->addr1
);
2707 atomic_inc(&sta
->users
);
2708 spin_unlock(&local
->ap
->sta_table_lock
);
2710 if (local
->iw_mode
== IW_MODE_MASTER
&& sta
== NULL
&& !meta
->wds
&&
2711 meta
->iface
->type
!= HOSTAP_INTERFACE_MASTER
&&
2712 meta
->iface
->type
!= HOSTAP_INTERFACE_AP
) {
2714 /* This can happen, e.g., when wlan0 is added to a bridge and
2715 * bridging code does not know which port is the correct target
2716 * for a unicast frame. In this case, the packet is send to all
2717 * ports of the bridge. Since this is a valid scenario, do not
2718 * print out any errors here. */
2719 if (net_ratelimit()) {
2720 printk(KERN_DEBUG
"AP: drop packet to non-associated "
2721 "STA " MACSTR
"\n", MAC2STR(hdr
->addr1
));
2724 local
->ap
->tx_drop_nonassoc
++;
2732 if (!(sta
->flags
& WLAN_STA_AUTHORIZED
))
2733 ret
= AP_TX_CONTINUE_NOT_AUTHORIZED
;
2735 /* Set tx_rate if using host-based TX rate control */
2736 if (!local
->fw_tx_rate_control
)
2737 local
->ap
->last_tx_rate
= meta
->rate
=
2738 ap_update_sta_tx_rate(sta
, local
->dev
);
2740 if (local
->iw_mode
!= IW_MODE_MASTER
)
2743 if (!(sta
->flags
& WLAN_STA_PS
))
2746 if (memcmp(skb
->cb
, AP_SKB_CB_MAGIC
, AP_SKB_CB_MAGIC_LEN
) == 0) {
2747 if (skb
->cb
[AP_SKB_CB_MAGIC_LEN
] & AP_SKB_CB_ADD_MOREDATA
) {
2748 /* indicate to STA that more frames follow */
2749 hdr
->frame_control
|=
2750 __constant_cpu_to_le16(WLAN_FC_MOREDATA
);
2753 if (skb
->cb
[AP_SKB_CB_MAGIC_LEN
] & AP_SKB_CB_BUFFERED_FRAME
) {
2754 /* packet was already buffered and now send due to
2755 * PS poll, so do not rebuffer it */
2760 if (skb_queue_len(&sta
->tx_buf
) >= STA_MAX_TX_BUFFER
) {
2761 PDEBUG(DEBUG_PS
, "%s: No more space in STA (" MACSTR
")'s PS "
2762 "mode buffer\n", local
->dev
->name
, MAC2STR(sta
->addr
));
2763 /* Make sure that TIM is set for the station (it might not be
2764 * after AP wlan hw reset). */
2765 /* FIX: should fix hw reset to restore bits based on STA
2767 hostap_set_tim(local
, sta
->aid
, 1);
2768 sta
->flags
|= WLAN_STA_TIM
;
2773 /* STA in PS mode, buffer frame for later delivery */
2774 set_tim
= skb_queue_empty(&sta
->tx_buf
);
2775 skb_queue_tail(&sta
->tx_buf
, skb
);
2776 /* FIX: could save RX time to skb and expire buffered frames after
2777 * some time if STA does not poll for them */
2780 if (sta
->flags
& WLAN_STA_TIM
)
2781 PDEBUG(DEBUG_PS2
, "Re-setting TIM for aid %d\n",
2783 hostap_set_tim(local
, sta
->aid
, 1);
2784 sta
->flags
|= WLAN_STA_TIM
;
2787 ret
= AP_TX_BUFFERED
;
2791 if (ret
== AP_TX_CONTINUE
||
2792 ret
== AP_TX_CONTINUE_NOT_AUTHORIZED
) {
2794 sta
->tx_bytes
+= skb
->len
;
2795 sta
->last_tx
= jiffies
;
2798 if ((ret
== AP_TX_CONTINUE
||
2799 ret
== AP_TX_CONTINUE_NOT_AUTHORIZED
) &&
2800 sta
->crypt
&& tx
->host_encrypt
) {
2801 tx
->crypt
= sta
->crypt
;
2802 tx
->sta_ptr
= sta
; /* hostap_handle_sta_release() will
2803 * be called to release sta info
2806 atomic_dec(&sta
->users
);
2813 void hostap_handle_sta_release(void *ptr
)
2815 struct sta_info
*sta
= ptr
;
2816 atomic_dec(&sta
->users
);
2820 /* Called only as a tasklet (software IRQ) */
2821 void hostap_handle_sta_tx_exc(local_info_t
*local
, struct sk_buff
*skb
)
2823 struct sta_info
*sta
;
2824 struct hostap_ieee80211_hdr
*hdr
;
2825 struct hostap_skb_tx_data
*meta
;
2827 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
2828 meta
= (struct hostap_skb_tx_data
*) skb
->cb
;
2830 spin_lock(&local
->ap
->sta_table_lock
);
2831 sta
= ap_get_sta(local
->ap
, hdr
->addr1
);
2833 spin_unlock(&local
->ap
->sta_table_lock
);
2834 PDEBUG(DEBUG_AP
, "%s: Could not find STA " MACSTR
" for this "
2835 "TX error (@%lu)\n",
2836 local
->dev
->name
, MAC2STR(hdr
->addr1
), jiffies
);
2840 sta
->tx_since_last_failure
= 0;
2841 sta
->tx_consecutive_exc
++;
2843 if (sta
->tx_consecutive_exc
>= WLAN_RATE_DECREASE_THRESHOLD
&&
2844 sta
->tx_rate_idx
> 0 && meta
->rate
<= sta
->tx_rate
) {
2845 /* use next lower rate */
2847 old
= rate
= sta
->tx_rate_idx
;
2850 if (ap_tx_rate_ok(rate
, sta
, local
)) {
2851 sta
->tx_rate_idx
= rate
;
2855 if (old
!= sta
->tx_rate_idx
) {
2856 switch (sta
->tx_rate_idx
) {
2857 case 0: sta
->tx_rate
= 10; break;
2858 case 1: sta
->tx_rate
= 20; break;
2859 case 2: sta
->tx_rate
= 55; break;
2860 case 3: sta
->tx_rate
= 110; break;
2861 default: sta
->tx_rate
= 0; break;
2863 PDEBUG(DEBUG_AP
, "%s: STA " MACSTR
" TX rate lowered "
2864 "to %d\n", local
->dev
->name
, MAC2STR(sta
->addr
),
2867 sta
->tx_consecutive_exc
= 0;
2869 spin_unlock(&local
->ap
->sta_table_lock
);
2873 static void hostap_update_sta_ps2(local_info_t
*local
, struct sta_info
*sta
,
2874 int pwrmgt
, int type
, int stype
)
2876 if (pwrmgt
&& !(sta
->flags
& WLAN_STA_PS
)) {
2877 sta
->flags
|= WLAN_STA_PS
;
2878 PDEBUG(DEBUG_PS2
, "STA " MACSTR
" changed to use PS "
2879 "mode (type=0x%02X, stype=0x%02X)\n",
2880 MAC2STR(sta
->addr
), type
, stype
);
2881 } else if (!pwrmgt
&& (sta
->flags
& WLAN_STA_PS
)) {
2882 sta
->flags
&= ~WLAN_STA_PS
;
2883 PDEBUG(DEBUG_PS2
, "STA " MACSTR
" changed to not use "
2884 "PS mode (type=0x%02X, stype=0x%02X)\n",
2885 MAC2STR(sta
->addr
), type
, stype
);
2886 if (type
!= WLAN_FC_TYPE_CTRL
|| stype
!= WLAN_FC_STYPE_PSPOLL
)
2887 schedule_packet_send(local
, sta
);
2892 /* Called only as a tasklet (software IRQ). Called for each RX frame to update
2893 * STA power saving state. pwrmgt is a flag from 802.11 frame_control field. */
2894 int hostap_update_sta_ps(local_info_t
*local
, struct hostap_ieee80211_hdr
*hdr
)
2896 struct sta_info
*sta
;
2899 spin_lock(&local
->ap
->sta_table_lock
);
2900 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2902 atomic_inc(&sta
->users
);
2903 spin_unlock(&local
->ap
->sta_table_lock
);
2908 fc
= le16_to_cpu(hdr
->frame_control
);
2909 hostap_update_sta_ps2(local
, sta
, fc
& WLAN_FC_PWRMGT
,
2910 WLAN_FC_GET_TYPE(fc
), WLAN_FC_GET_STYPE(fc
));
2912 atomic_dec(&sta
->users
);
2917 /* Called only as a tasklet (software IRQ). Called for each RX frame after
2918 * getting RX header and payload from hardware. */
2919 ap_rx_ret
hostap_handle_sta_rx(local_info_t
*local
, struct net_device
*dev
,
2920 struct sk_buff
*skb
,
2921 struct hostap_80211_rx_status
*rx_stats
,
2925 struct sta_info
*sta
;
2926 u16 fc
, type
, stype
;
2927 struct hostap_ieee80211_hdr
*hdr
;
2929 if (local
->ap
== NULL
)
2930 return AP_RX_CONTINUE
;
2932 hdr
= (struct hostap_ieee80211_hdr
*) skb
->data
;
2934 fc
= le16_to_cpu(hdr
->frame_control
);
2935 type
= WLAN_FC_GET_TYPE(fc
);
2936 stype
= WLAN_FC_GET_STYPE(fc
);
2938 spin_lock(&local
->ap
->sta_table_lock
);
2939 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
2941 atomic_inc(&sta
->users
);
2942 spin_unlock(&local
->ap
->sta_table_lock
);
2944 if (sta
&& !(sta
->flags
& WLAN_STA_AUTHORIZED
))
2945 ret
= AP_RX_CONTINUE_NOT_AUTHORIZED
;
2947 ret
= AP_RX_CONTINUE
;
2950 if (fc
& WLAN_FC_TODS
) {
2951 if (!wds
&& (sta
== NULL
|| !(sta
->flags
& WLAN_STA_ASSOC
))) {
2952 if (local
->hostapd
) {
2953 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
2954 PRISM2_RX_NON_ASSOC
);
2955 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2957 printk(KERN_DEBUG
"%s: dropped received packet"
2958 " from non-associated STA " MACSTR
2959 " (type=0x%02x, subtype=0x%02x)\n",
2960 dev
->name
, MAC2STR(hdr
->addr2
), type
,
2962 hostap_rx(dev
, skb
, rx_stats
);
2963 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
2968 } else if (fc
& WLAN_FC_FROMDS
) {
2970 /* FromDS frame - not for us; probably
2971 * broadcast/multicast in another BSS - drop */
2972 if (memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
2973 printk(KERN_DEBUG
"Odd.. FromDS packet "
2974 "received with own BSSID\n");
2975 hostap_dump_rx_80211(dev
->name
, skb
, rx_stats
);
2980 } else if (stype
== WLAN_FC_STYPE_NULLFUNC
&& sta
== NULL
&&
2981 memcmp(hdr
->addr1
, dev
->dev_addr
, ETH_ALEN
) == 0) {
2983 if (local
->hostapd
) {
2984 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
2985 PRISM2_RX_NON_ASSOC
);
2986 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2988 /* At least Lucent f/w seems to send data::nullfunc
2989 * frames with no ToDS flag when the current AP returns
2990 * after being unavailable for some time. Speed up
2991 * re-association by informing the station about it not
2992 * being associated. */
2993 printk(KERN_DEBUG
"%s: rejected received nullfunc "
2994 "frame without ToDS from not associated STA "
2996 dev
->name
, MAC2STR(hdr
->addr2
));
2997 hostap_rx(dev
, skb
, rx_stats
);
2998 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3002 } else if (stype
== WLAN_FC_STYPE_NULLFUNC
) {
3003 /* At least Lucent cards seem to send periodic nullfunc
3004 * frames with ToDS. Let these through to update SQ
3005 * stats and PS state. Nullfunc frames do not contain
3006 * any data and they will be dropped below. */
3008 /* If BSSID (Addr3) is foreign, this frame is a normal
3009 * broadcast frame from an IBSS network. Drop it silently.
3010 * If BSSID is own, report the dropping of this frame. */
3011 if (memcmp(hdr
->addr3
, dev
->dev_addr
, ETH_ALEN
) == 0) {
3012 printk(KERN_DEBUG
"%s: dropped received packet from "
3013 MACSTR
" with no ToDS flag (type=0x%02x, "
3014 "subtype=0x%02x)\n", dev
->name
,
3015 MAC2STR(hdr
->addr2
), type
, stype
);
3016 hostap_dump_rx_80211(dev
->name
, skb
, rx_stats
);
3023 hostap_update_sta_ps2(local
, sta
, fc
& WLAN_FC_PWRMGT
,
3027 sta
->rx_bytes
+= skb
->len
;
3028 sta
->last_rx
= jiffies
;
3031 if (local
->ap
->nullfunc_ack
&& stype
== WLAN_FC_STYPE_NULLFUNC
&&
3032 fc
& WLAN_FC_TODS
) {
3033 if (local
->hostapd
) {
3034 prism2_rx_80211(local
->apdev
, skb
, rx_stats
,
3035 PRISM2_RX_NULLFUNC_ACK
);
3036 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3038 /* some STA f/w's seem to require control::ACK frame
3039 * for data::nullfunc, but Prism2 f/w 0.8.0 (at least
3040 * from Compaq) does not send this.. Try to generate
3041 * ACK for these frames from the host driver to make
3042 * power saving work with, e.g., Lucent WaveLAN f/w */
3043 hostap_rx(dev
, skb
, rx_stats
);
3044 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3052 atomic_dec(&sta
->users
);
3058 /* Called only as a tasklet (software IRQ) */
3059 int hostap_handle_sta_crypto(local_info_t
*local
,
3060 struct hostap_ieee80211_hdr
*hdr
,
3061 struct prism2_crypt_data
**crypt
, void **sta_ptr
)
3063 struct sta_info
*sta
;
3065 spin_lock(&local
->ap
->sta_table_lock
);
3066 sta
= ap_get_sta(local
->ap
, hdr
->addr2
);
3068 atomic_inc(&sta
->users
);
3069 spin_unlock(&local
->ap
->sta_table_lock
);
3075 *crypt
= sta
->crypt
;
3077 /* hostap_handle_sta_release() will be called to release STA
3080 atomic_dec(&sta
->users
);
3086 /* Called only as a tasklet (software IRQ) */
3087 int hostap_is_sta_assoc(struct ap_data
*ap
, u8
*sta_addr
)
3089 struct sta_info
*sta
;
3092 spin_lock(&ap
->sta_table_lock
);
3093 sta
= ap_get_sta(ap
, sta_addr
);
3094 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
)
3096 spin_unlock(&ap
->sta_table_lock
);
3102 /* Called only as a tasklet (software IRQ) */
3103 int hostap_is_sta_authorized(struct ap_data
*ap
, u8
*sta_addr
)
3105 struct sta_info
*sta
;
3108 spin_lock(&ap
->sta_table_lock
);
3109 sta
= ap_get_sta(ap
, sta_addr
);
3110 if (sta
!= NULL
&& (sta
->flags
& WLAN_STA_ASSOC
) && !sta
->ap
&&
3111 ((sta
->flags
& WLAN_STA_AUTHORIZED
) ||
3112 ap
->local
->ieee_802_1x
== 0))
3114 spin_unlock(&ap
->sta_table_lock
);
3120 /* Called only as a tasklet (software IRQ) */
3121 int hostap_add_sta(struct ap_data
*ap
, u8
*sta_addr
)
3123 struct sta_info
*sta
;
3129 spin_lock(&ap
->sta_table_lock
);
3130 sta
= ap_get_sta(ap
, sta_addr
);
3133 spin_unlock(&ap
->sta_table_lock
);
3136 sta
= ap_add_sta(ap
, sta_addr
);
3139 sta
->flags
= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
3141 memset(sta
->supported_rates
, 0, sizeof(sta
->supported_rates
));
3142 /* No way of knowing which rates are supported since we did not
3143 * get supported rates element from beacon/assoc req. Assume
3144 * that remote end supports all 802.11b rates. */
3145 sta
->supported_rates
[0] = 0x82;
3146 sta
->supported_rates
[1] = 0x84;
3147 sta
->supported_rates
[2] = 0x0b;
3148 sta
->supported_rates
[3] = 0x16;
3149 sta
->tx_supp_rates
= WLAN_RATE_1M
| WLAN_RATE_2M
|
3150 WLAN_RATE_5M5
| WLAN_RATE_11M
;
3152 sta
->tx_max_rate
= sta
->tx_rate_idx
= 3;
3159 /* Called only as a tasklet (software IRQ) */
3160 int hostap_update_rx_stats(struct ap_data
*ap
,
3161 struct hostap_ieee80211_hdr
*hdr
,
3162 struct hostap_80211_rx_status
*rx_stats
)
3164 struct sta_info
*sta
;
3169 spin_lock(&ap
->sta_table_lock
);
3170 sta
= ap_get_sta(ap
, hdr
->addr2
);
3172 sta
->last_rx_silence
= rx_stats
->noise
;
3173 sta
->last_rx_signal
= rx_stats
->signal
;
3174 sta
->last_rx_rate
= rx_stats
->rate
;
3175 sta
->last_rx_updated
= 7;
3176 if (rx_stats
->rate
== 10)
3178 else if (rx_stats
->rate
== 20)
3180 else if (rx_stats
->rate
== 55)
3182 else if (rx_stats
->rate
== 110)
3185 spin_unlock(&ap
->sta_table_lock
);
3187 return sta
? 0 : -1;
3191 void hostap_update_rates(local_info_t
*local
)
3193 struct list_head
*ptr
;
3194 struct ap_data
*ap
= local
->ap
;
3199 spin_lock_bh(&ap
->sta_table_lock
);
3200 for (ptr
= ap
->sta_list
.next
; ptr
!= &ap
->sta_list
; ptr
= ptr
->next
) {
3201 struct sta_info
*sta
= (struct sta_info
*) ptr
;
3202 prism2_check_tx_rates(sta
);
3204 spin_unlock_bh(&ap
->sta_table_lock
);
3208 static void * ap_crypt_get_ptrs(struct ap_data
*ap
, u8
*addr
, int permanent
,
3209 struct prism2_crypt_data
***crypt
)
3211 struct sta_info
*sta
;
3213 spin_lock_bh(&ap
->sta_table_lock
);
3214 sta
= ap_get_sta(ap
, addr
);
3216 atomic_inc(&sta
->users
);
3217 spin_unlock_bh(&ap
->sta_table_lock
);
3219 if (!sta
&& permanent
)
3220 sta
= ap_add_sta(ap
, addr
);
3226 sta
->flags
|= WLAN_STA_PERM
;
3228 *crypt
= &sta
->crypt
;
3234 void hostap_add_wds_links(local_info_t
*local
)
3236 struct ap_data
*ap
= local
->ap
;
3237 struct list_head
*ptr
;
3239 spin_lock_bh(&ap
->sta_table_lock
);
3240 list_for_each(ptr
, &ap
->sta_list
) {
3241 struct sta_info
*sta
= list_entry(ptr
, struct sta_info
, list
);
3243 hostap_wds_link_oper(local
, sta
->addr
, WDS_ADD
);
3245 spin_unlock_bh(&ap
->sta_table_lock
);
3247 schedule_work(&local
->ap
->wds_oper_queue
);
3251 void hostap_wds_link_oper(local_info_t
*local
, u8
*addr
, wds_oper_type type
)
3253 struct wds_oper_data
*entry
;
3255 entry
= kmalloc(sizeof(*entry
), GFP_ATOMIC
);
3258 memcpy(entry
->addr
, addr
, ETH_ALEN
);
3260 spin_lock_bh(&local
->lock
);
3261 entry
->next
= local
->ap
->wds_oper_entries
;
3262 local
->ap
->wds_oper_entries
= entry
;
3263 spin_unlock_bh(&local
->lock
);
3265 schedule_work(&local
->ap
->wds_oper_queue
);
3269 EXPORT_SYMBOL(hostap_init_data
);
3270 EXPORT_SYMBOL(hostap_init_ap_proc
);
3271 EXPORT_SYMBOL(hostap_free_data
);
3272 EXPORT_SYMBOL(hostap_check_sta_fw_version
);
3273 EXPORT_SYMBOL(hostap_handle_sta_tx
);
3274 EXPORT_SYMBOL(hostap_handle_sta_release
);
3275 EXPORT_SYMBOL(hostap_handle_sta_tx_exc
);
3276 EXPORT_SYMBOL(hostap_update_sta_ps
);
3277 EXPORT_SYMBOL(hostap_handle_sta_rx
);
3278 EXPORT_SYMBOL(hostap_is_sta_assoc
);
3279 EXPORT_SYMBOL(hostap_is_sta_authorized
);
3280 EXPORT_SYMBOL(hostap_add_sta
);
3281 EXPORT_SYMBOL(hostap_update_rates
);
3282 EXPORT_SYMBOL(hostap_add_wds_links
);
3283 EXPORT_SYMBOL(hostap_wds_link_oper
);
3284 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3285 EXPORT_SYMBOL(hostap_deauth_all_stas
);
3286 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */