2 * hostapd / Station table
3 * Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
21 #include "accounting.h"
22 #include "ieee802_1x.h"
23 #include "ieee802_11.h"
24 #include "radius/radius.h"
27 #include "radius/radius_client.h"
30 #include "hw_features.h"
32 #include "vlan_init.h"
34 static int ap_sta_in_other_bss(struct hostapd_data
*hapd
,
35 struct sta_info
*sta
, u32 flags
);
36 static void ap_handle_session_timer(void *eloop_ctx
, void *timeout_ctx
);
37 #ifdef CONFIG_IEEE80211W
38 static void ap_sa_query_timer(void *eloop_ctx
, void *timeout_ctx
);
39 #endif /* CONFIG_IEEE80211W */
41 int ap_for_each_sta(struct hostapd_data
*hapd
,
42 int (*cb
)(struct hostapd_data
*hapd
, struct sta_info
*sta
,
48 for (sta
= hapd
->sta_list
; sta
; sta
= sta
->next
) {
49 if (cb(hapd
, sta
, ctx
))
57 struct sta_info
* ap_get_sta(struct hostapd_data
*hapd
, const u8
*sta
)
61 s
= hapd
->sta_hash
[STA_HASH(sta
)];
62 while (s
!= NULL
&& os_memcmp(s
->addr
, sta
, 6) != 0)
68 static void ap_sta_list_del(struct hostapd_data
*hapd
, struct sta_info
*sta
)
72 if (hapd
->sta_list
== sta
) {
73 hapd
->sta_list
= sta
->next
;
78 while (tmp
!= NULL
&& tmp
->next
!= sta
)
81 wpa_printf(MSG_DEBUG
, "Could not remove STA " MACSTR
" from "
82 "list.", MAC2STR(sta
->addr
));
84 tmp
->next
= sta
->next
;
88 void ap_sta_hash_add(struct hostapd_data
*hapd
, struct sta_info
*sta
)
90 sta
->hnext
= hapd
->sta_hash
[STA_HASH(sta
->addr
)];
91 hapd
->sta_hash
[STA_HASH(sta
->addr
)] = sta
;
95 static void ap_sta_hash_del(struct hostapd_data
*hapd
, struct sta_info
*sta
)
99 s
= hapd
->sta_hash
[STA_HASH(sta
->addr
)];
100 if (s
== NULL
) return;
101 if (os_memcmp(s
->addr
, sta
->addr
, 6) == 0) {
102 hapd
->sta_hash
[STA_HASH(sta
->addr
)] = s
->hnext
;
106 while (s
->hnext
!= NULL
&&
107 os_memcmp(s
->hnext
->addr
, sta
->addr
, ETH_ALEN
) != 0)
109 if (s
->hnext
!= NULL
)
110 s
->hnext
= s
->hnext
->hnext
;
112 wpa_printf(MSG_DEBUG
, "AP: could not remove STA " MACSTR
113 " from hash table", MAC2STR(sta
->addr
));
117 void ap_free_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
)
121 accounting_sta_stop(hapd
, sta
);
123 if (!ap_sta_in_other_bss(hapd
, sta
, WLAN_STA_ASSOC
) &&
124 !(sta
->flags
& WLAN_STA_PREAUTH
))
125 hostapd_sta_remove(hapd
, sta
->addr
);
127 ap_sta_hash_del(hapd
, sta
);
128 ap_sta_list_del(hapd
, sta
);
131 hapd
->sta_aid
[(sta
->aid
- 1) / 32] &=
132 ~BIT((sta
->aid
- 1) % 32);
135 if (sta
->nonerp_set
) {
137 hapd
->iface
->num_sta_non_erp
--;
138 if (hapd
->iface
->num_sta_non_erp
== 0)
142 if (sta
->no_short_slot_time_set
) {
143 sta
->no_short_slot_time_set
= 0;
144 hapd
->iface
->num_sta_no_short_slot_time
--;
145 if (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
146 && hapd
->iface
->num_sta_no_short_slot_time
== 0)
150 if (sta
->no_short_preamble_set
) {
151 sta
->no_short_preamble_set
= 0;
152 hapd
->iface
->num_sta_no_short_preamble
--;
153 if (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
154 && hapd
->iface
->num_sta_no_short_preamble
== 0)
158 if (sta
->no_ht_gf_set
) {
159 sta
->no_ht_gf_set
= 0;
160 hapd
->iface
->num_sta_ht_no_gf
--;
163 if (sta
->no_ht_set
) {
165 hapd
->iface
->num_sta_no_ht
--;
168 if (sta
->ht_20mhz_set
) {
169 sta
->ht_20mhz_set
= 0;
170 hapd
->iface
->num_sta_ht_20mhz
--;
173 #if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N)
174 if (hostapd_ht_operation_update(hapd
->iface
) > 0)
176 #endif /* NEED_AP_MLME && CONFIG_IEEE80211N */
179 ieee802_11_set_beacons(hapd
->iface
);
181 eloop_cancel_timeout(ap_handle_timer
, hapd
, sta
);
182 eloop_cancel_timeout(ap_handle_session_timer
, hapd
, sta
);
184 ieee802_1x_free_station(sta
);
185 wpa_auth_sta_deinit(sta
->wpa_sm
);
186 rsn_preauth_free_station(hapd
, sta
);
187 #ifndef CONFIG_NO_RADIUS
188 radius_client_flush_auth(hapd
->radius
, sta
->addr
);
189 #endif /* CONFIG_NO_RADIUS */
191 os_free(sta
->last_assoc_req
);
192 os_free(sta
->challenge
);
194 #ifdef CONFIG_IEEE80211W
195 os_free(sta
->sa_query_trans_id
);
196 eloop_cancel_timeout(ap_sa_query_timer
, hapd
, sta
);
197 #endif /* CONFIG_IEEE80211W */
199 wpabuf_free(sta
->wps_ie
);
201 os_free(sta
->ht_capabilities
);
207 void hostapd_free_stas(struct hostapd_data
*hapd
)
209 struct sta_info
*sta
, *prev
;
211 sta
= hapd
->sta_list
;
215 if (sta
->flags
& WLAN_STA_AUTH
) {
216 mlme_deauthenticate_indication(
217 hapd
, sta
, WLAN_REASON_UNSPECIFIED
);
220 wpa_printf(MSG_DEBUG
, "Removing station " MACSTR
,
221 MAC2STR(prev
->addr
));
222 ap_free_sta(hapd
, prev
);
228 * ap_handle_timer - Per STA timer handler
229 * @eloop_ctx: struct hostapd_data *
230 * @timeout_ctx: struct sta_info *
232 * This function is called to check station activity and to remove inactive
235 void ap_handle_timer(void *eloop_ctx
, void *timeout_ctx
)
237 struct hostapd_data
*hapd
= eloop_ctx
;
238 struct sta_info
*sta
= timeout_ctx
;
239 unsigned long next_time
= 0;
241 if (sta
->timeout_next
== STA_REMOVE
) {
242 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
243 HOSTAPD_LEVEL_INFO
, "deauthenticated due to "
244 "local deauth request");
245 ap_free_sta(hapd
, sta
);
249 if ((sta
->flags
& WLAN_STA_ASSOC
) &&
250 (sta
->timeout_next
== STA_NULLFUNC
||
251 sta
->timeout_next
== STA_DISASSOC
)) {
253 wpa_printf(MSG_DEBUG
, "Checking STA " MACSTR
" inactivity:",
255 inactive_sec
= hostapd_get_inact_sec(hapd
, sta
->addr
);
256 if (inactive_sec
== -1) {
257 wpa_printf(MSG_DEBUG
, "Could not get station info "
258 "from kernel driver for " MACSTR
".",
260 } else if (inactive_sec
< hapd
->conf
->ap_max_inactivity
&&
261 sta
->flags
& WLAN_STA_ASSOC
) {
262 /* station activity detected; reset timeout state */
263 wpa_printf(MSG_DEBUG
, " Station has been active");
264 sta
->timeout_next
= STA_NULLFUNC
;
265 next_time
= hapd
->conf
->ap_max_inactivity
-
270 if ((sta
->flags
& WLAN_STA_ASSOC
) &&
271 sta
->timeout_next
== STA_DISASSOC
&&
272 !(sta
->flags
& WLAN_STA_PENDING_POLL
)) {
273 wpa_printf(MSG_DEBUG
, " Station has ACKed data poll");
274 /* data nullfunc frame poll did not produce TX errors; assume
275 * station ACKed it */
276 sta
->timeout_next
= STA_NULLFUNC
;
277 next_time
= hapd
->conf
->ap_max_inactivity
;
281 eloop_register_timeout(next_time
, 0, ap_handle_timer
, hapd
,
286 if (sta
->timeout_next
== STA_NULLFUNC
&&
287 (sta
->flags
& WLAN_STA_ASSOC
)) {
288 /* send data frame to poll STA and check whether this frame
290 struct ieee80211_hdr hdr
;
292 wpa_printf(MSG_DEBUG
, " Polling STA with data frame");
293 sta
->flags
|= WLAN_STA_PENDING_POLL
;
295 #ifndef CONFIG_NATIVE_WINDOWS
296 os_memset(&hdr
, 0, sizeof(hdr
));
298 os_strcmp(hapd
->driver
->name
, "hostap") == 0) {
300 * WLAN_FC_STYPE_NULLFUNC would be more appropriate,
301 * but it is apparently not retried so TX Exc events
302 * are not received for it.
305 IEEE80211_FC(WLAN_FC_TYPE_DATA
,
309 IEEE80211_FC(WLAN_FC_TYPE_DATA
,
310 WLAN_FC_STYPE_NULLFUNC
);
313 hdr
.frame_control
|= host_to_le16(WLAN_FC_FROMDS
);
314 os_memcpy(hdr
.IEEE80211_DA_FROMDS
, sta
->addr
, ETH_ALEN
);
315 os_memcpy(hdr
.IEEE80211_BSSID_FROMDS
, hapd
->own_addr
,
317 os_memcpy(hdr
.IEEE80211_SA_FROMDS
, hapd
->own_addr
, ETH_ALEN
);
319 if (hostapd_send_mgmt_frame(hapd
, &hdr
, sizeof(hdr
)) < 0)
320 perror("ap_handle_timer: send");
321 #endif /* CONFIG_NATIVE_WINDOWS */
322 } else if (sta
->timeout_next
!= STA_REMOVE
) {
323 int deauth
= sta
->timeout_next
== STA_DEAUTH
;
325 wpa_printf(MSG_DEBUG
, "Sending %s info to STA " MACSTR
,
326 deauth
? "deauthentication" : "disassociation",
330 hostapd_sta_deauth(hapd
, sta
->addr
,
331 WLAN_REASON_PREV_AUTH_NOT_VALID
);
333 hostapd_sta_disassoc(
335 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
);
339 switch (sta
->timeout_next
) {
341 sta
->timeout_next
= STA_DISASSOC
;
342 eloop_register_timeout(AP_DISASSOC_DELAY
, 0, ap_handle_timer
,
346 sta
->flags
&= ~WLAN_STA_ASSOC
;
347 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, 0);
348 if (!sta
->acct_terminate_cause
)
349 sta
->acct_terminate_cause
=
350 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT
;
351 accounting_sta_stop(hapd
, sta
);
352 ieee802_1x_free_station(sta
);
353 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
354 HOSTAPD_LEVEL_INFO
, "disassociated due to "
356 sta
->timeout_next
= STA_DEAUTH
;
357 eloop_register_timeout(AP_DEAUTH_DELAY
, 0, ap_handle_timer
,
359 mlme_disassociate_indication(
360 hapd
, sta
, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY
);
364 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
365 HOSTAPD_LEVEL_INFO
, "deauthenticated due to "
367 if (!sta
->acct_terminate_cause
)
368 sta
->acct_terminate_cause
=
369 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT
;
370 mlme_deauthenticate_indication(
372 WLAN_REASON_PREV_AUTH_NOT_VALID
);
373 ap_free_sta(hapd
, sta
);
379 static void ap_handle_session_timer(void *eloop_ctx
, void *timeout_ctx
)
381 struct hostapd_data
*hapd
= eloop_ctx
;
382 struct sta_info
*sta
= timeout_ctx
;
385 if (!(sta
->flags
& WLAN_STA_AUTH
))
388 mlme_deauthenticate_indication(hapd
, sta
,
389 WLAN_REASON_PREV_AUTH_NOT_VALID
);
390 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
391 HOSTAPD_LEVEL_INFO
, "deauthenticated due to "
393 sta
->acct_terminate_cause
=
394 RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT
;
395 os_memcpy(addr
, sta
->addr
, ETH_ALEN
);
396 ap_free_sta(hapd
, sta
);
397 hostapd_sta_deauth(hapd
, addr
, WLAN_REASON_PREV_AUTH_NOT_VALID
);
401 void ap_sta_session_timeout(struct hostapd_data
*hapd
, struct sta_info
*sta
,
404 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
405 HOSTAPD_LEVEL_DEBUG
, "setting session timeout to %d "
406 "seconds", session_timeout
);
407 eloop_cancel_timeout(ap_handle_session_timer
, hapd
, sta
);
408 eloop_register_timeout(session_timeout
, 0, ap_handle_session_timer
,
413 void ap_sta_no_session_timeout(struct hostapd_data
*hapd
, struct sta_info
*sta
)
415 eloop_cancel_timeout(ap_handle_session_timer
, hapd
, sta
);
419 struct sta_info
* ap_sta_add(struct hostapd_data
*hapd
, const u8
*addr
)
421 struct sta_info
*sta
;
423 sta
= ap_get_sta(hapd
, addr
);
427 wpa_printf(MSG_DEBUG
, " New STA");
428 if (hapd
->num_sta
>= hapd
->conf
->max_num_sta
) {
429 /* FIX: might try to remove some old STAs first? */
430 wpa_printf(MSG_DEBUG
, "no more room for new STAs (%d/%d)",
431 hapd
->num_sta
, hapd
->conf
->max_num_sta
);
435 sta
= os_zalloc(sizeof(struct sta_info
));
437 wpa_printf(MSG_ERROR
, "malloc failed");
440 sta
->acct_interim_interval
= hapd
->conf
->acct_interim_interval
;
442 /* initialize STA info data */
443 eloop_register_timeout(hapd
->conf
->ap_max_inactivity
, 0,
444 ap_handle_timer
, hapd
, sta
);
445 os_memcpy(sta
->addr
, addr
, ETH_ALEN
);
446 sta
->next
= hapd
->sta_list
;
447 hapd
->sta_list
= sta
;
449 ap_sta_hash_add(hapd
, sta
);
450 sta
->ssid
= &hapd
->conf
->ssid
;
456 static int ap_sta_remove(struct hostapd_data
*hapd
, struct sta_info
*sta
)
458 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, 0);
460 wpa_printf(MSG_DEBUG
, "Removing STA " MACSTR
" from kernel driver",
462 if (hostapd_sta_remove(hapd
, sta
->addr
) &&
463 sta
->flags
& WLAN_STA_ASSOC
) {
464 wpa_printf(MSG_DEBUG
, "Could not remove station " MACSTR
465 " from kernel driver.", MAC2STR(sta
->addr
));
472 static int ap_sta_in_other_bss(struct hostapd_data
*hapd
,
473 struct sta_info
*sta
, u32 flags
)
475 struct hostapd_iface
*iface
= hapd
->iface
;
478 for (i
= 0; i
< iface
->num_bss
; i
++) {
479 struct hostapd_data
*bss
= iface
->bss
[i
];
480 struct sta_info
*sta2
;
481 /* bss should always be set during operation, but it may be
482 * NULL during reconfiguration. Assume the STA is not
483 * associated to another BSS in that case to avoid NULL pointer
485 if (bss
== hapd
|| bss
== NULL
)
487 sta2
= ap_get_sta(bss
, sta
->addr
);
488 if (sta2
&& ((sta2
->flags
& flags
) == flags
))
496 void ap_sta_disassociate(struct hostapd_data
*hapd
, struct sta_info
*sta
,
499 wpa_printf(MSG_DEBUG
, "%s: disassociate STA " MACSTR
,
500 hapd
->conf
->iface
, MAC2STR(sta
->addr
));
501 sta
->flags
&= ~WLAN_STA_ASSOC
;
502 if (!ap_sta_in_other_bss(hapd
, sta
, WLAN_STA_ASSOC
))
503 ap_sta_remove(hapd
, sta
);
504 sta
->timeout_next
= STA_DEAUTH
;
505 eloop_cancel_timeout(ap_handle_timer
, hapd
, sta
);
506 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC
, 0,
507 ap_handle_timer
, hapd
, sta
);
508 accounting_sta_stop(hapd
, sta
);
509 ieee802_1x_free_station(sta
);
511 mlme_disassociate_indication(hapd
, sta
, reason
);
515 void ap_sta_deauthenticate(struct hostapd_data
*hapd
, struct sta_info
*sta
,
518 wpa_printf(MSG_DEBUG
, "%s: deauthenticate STA " MACSTR
,
519 hapd
->conf
->iface
, MAC2STR(sta
->addr
));
520 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
521 if (!ap_sta_in_other_bss(hapd
, sta
, WLAN_STA_ASSOC
))
522 ap_sta_remove(hapd
, sta
);
523 sta
->timeout_next
= STA_REMOVE
;
524 eloop_cancel_timeout(ap_handle_timer
, hapd
, sta
);
525 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH
, 0,
526 ap_handle_timer
, hapd
, sta
);
527 accounting_sta_stop(hapd
, sta
);
528 ieee802_1x_free_station(sta
);
530 mlme_deauthenticate_indication(hapd
, sta
, reason
);
534 int ap_sta_bind_vlan(struct hostapd_data
*hapd
, struct sta_info
*sta
,
537 #ifndef CONFIG_NO_VLAN
539 struct hostapd_vlan
*vlan
= NULL
;
542 * Do not proceed furthur if the vlan id remains same. We do not want
543 * duplicate dynamic vlan entries.
545 if (sta
->vlan_id
== old_vlanid
)
549 * During 1x reauth, if the vlan id changes, then remove the old id and
550 * proceed furthur to add the new one.
553 vlan_remove_dynamic(hapd
, old_vlanid
);
555 iface
= hapd
->conf
->iface
;
556 if (sta
->ssid
->vlan
[0])
557 iface
= sta
->ssid
->vlan
;
559 if (sta
->ssid
->dynamic_vlan
== DYNAMIC_VLAN_DISABLED
)
561 else if (sta
->vlan_id
> 0) {
562 vlan
= hapd
->conf
->vlan
;
564 if (vlan
->vlan_id
== sta
->vlan_id
||
565 vlan
->vlan_id
== VLAN_ID_WILDCARD
) {
566 iface
= vlan
->ifname
;
573 if (sta
->vlan_id
> 0 && vlan
== NULL
) {
574 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
575 HOSTAPD_LEVEL_DEBUG
, "could not find VLAN for "
576 "binding station to (vlan_id=%d)",
579 } else if (sta
->vlan_id
> 0 && vlan
->vlan_id
== VLAN_ID_WILDCARD
) {
580 vlan
= vlan_add_dynamic(hapd
, vlan
, sta
->vlan_id
);
582 hostapd_logger(hapd
, sta
->addr
,
583 HOSTAPD_MODULE_IEEE80211
,
584 HOSTAPD_LEVEL_DEBUG
, "could not add "
585 "dynamic VLAN interface for vlan_id=%d",
590 iface
= vlan
->ifname
;
591 if (vlan_setup_encryption_dyn(hapd
, sta
->ssid
, iface
) != 0) {
592 hostapd_logger(hapd
, sta
->addr
,
593 HOSTAPD_MODULE_IEEE80211
,
594 HOSTAPD_LEVEL_DEBUG
, "could not "
595 "configure encryption for dynamic VLAN "
596 "interface for vlan_id=%d",
600 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
601 HOSTAPD_LEVEL_DEBUG
, "added new dynamic VLAN "
602 "interface '%s'", iface
);
603 } else if (vlan
&& vlan
->vlan_id
== sta
->vlan_id
) {
604 if (sta
->vlan_id
> 0) {
605 vlan
->dynamic_vlan
++;
606 hostapd_logger(hapd
, sta
->addr
,
607 HOSTAPD_MODULE_IEEE80211
,
608 HOSTAPD_LEVEL_DEBUG
, "updated existing "
609 "dynamic VLAN interface '%s'", iface
);
613 * Update encryption configuration for statically generated
614 * VLAN interface. This is only used for static WEP
615 * configuration for the case where hostapd did not yet know
616 * which keys are to be used when the interface was added.
618 if (vlan_setup_encryption_dyn(hapd
, sta
->ssid
, iface
) != 0) {
619 hostapd_logger(hapd
, sta
->addr
,
620 HOSTAPD_MODULE_IEEE80211
,
621 HOSTAPD_LEVEL_DEBUG
, "could not "
622 "configure encryption for VLAN "
623 "interface for vlan_id=%d",
628 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
629 HOSTAPD_LEVEL_DEBUG
, "binding station to interface "
632 if (wpa_auth_sta_set_vlan(sta
->wpa_sm
, sta
->vlan_id
) < 0)
633 wpa_printf(MSG_INFO
, "Failed to update VLAN-ID for WPA");
635 return hostapd_set_sta_vlan(iface
, hapd
, sta
->addr
, sta
->vlan_id
);
636 #else /* CONFIG_NO_VLAN */
638 #endif /* CONFIG_NO_VLAN */
642 #ifdef CONFIG_IEEE80211W
644 int ap_check_sa_query_timeout(struct hostapd_data
*hapd
, struct sta_info
*sta
)
647 struct os_time now
, passed
;
649 os_time_sub(&now
, &sta
->sa_query_start
, &passed
);
650 tu
= (passed
.sec
* 1000000 + passed
.usec
) / 1024;
651 if (hapd
->conf
->assoc_sa_query_max_timeout
< tu
) {
652 hostapd_logger(hapd
, sta
->addr
,
653 HOSTAPD_MODULE_IEEE80211
,
655 "association SA Query timed out");
656 sta
->sa_query_timed_out
= 1;
657 os_free(sta
->sa_query_trans_id
);
658 sta
->sa_query_trans_id
= NULL
;
659 sta
->sa_query_count
= 0;
660 eloop_cancel_timeout(ap_sa_query_timer
, hapd
, sta
);
668 static void ap_sa_query_timer(void *eloop_ctx
, void *timeout_ctx
)
670 struct hostapd_data
*hapd
= eloop_ctx
;
671 struct sta_info
*sta
= timeout_ctx
;
672 unsigned int timeout
, sec
, usec
;
675 if (sta
->sa_query_count
> 0 &&
676 ap_check_sa_query_timeout(hapd
, sta
))
679 nbuf
= os_realloc(sta
->sa_query_trans_id
,
680 (sta
->sa_query_count
+ 1) * WLAN_SA_QUERY_TR_ID_LEN
);
683 if (sta
->sa_query_count
== 0) {
684 /* Starting a new SA Query procedure */
685 os_get_time(&sta
->sa_query_start
);
687 trans_id
= nbuf
+ sta
->sa_query_count
* WLAN_SA_QUERY_TR_ID_LEN
;
688 sta
->sa_query_trans_id
= nbuf
;
689 sta
->sa_query_count
++;
691 os_get_random(trans_id
, WLAN_SA_QUERY_TR_ID_LEN
);
693 timeout
= hapd
->conf
->assoc_sa_query_retry_timeout
;
694 sec
= ((timeout
/ 1000) * 1024) / 1000;
695 usec
= (timeout
% 1000) * 1024;
696 eloop_register_timeout(sec
, usec
, ap_sa_query_timer
, hapd
, sta
);
698 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
700 "association SA Query attempt %d", sta
->sa_query_count
);
703 ieee802_11_send_sa_query_req(hapd
, sta
->addr
, trans_id
);
704 #endif /* NEED_AP_MLME */
708 void ap_sta_start_sa_query(struct hostapd_data
*hapd
, struct sta_info
*sta
)
710 ap_sa_query_timer(hapd
, sta
);
714 void ap_sta_stop_sa_query(struct hostapd_data
*hapd
, struct sta_info
*sta
)
716 eloop_cancel_timeout(ap_sa_query_timer
, hapd
, sta
);
717 os_free(sta
->sa_query_trans_id
);
718 sta
->sa_query_trans_id
= NULL
;
719 sta
->sa_query_count
= 0;
722 #endif /* CONFIG_IEEE80211W */