2 * hostapd / Station table
3 * Copyright (c) 2002-2009, 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.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "utils/eloop.h"
19 #include "common/ieee802_11_defs.h"
20 #include "radius/radius.h"
21 #include "radius/radius_client.h"
22 #include "drivers/driver.h"
25 #include "accounting.h"
26 #include "ieee802_1x.h"
27 #include "ieee802_11.h"
29 #include "preauth_auth.h"
30 #include "ap_config.h"
33 #include "vlan_init.h"
34 #include "p2p_hostapd.h"
35 #include "ap_drv_ops.h"
38 static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
39 struct sta_info *sta);
40 static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx);
41 #ifdef CONFIG_IEEE80211W
42 static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx);
43 #endif /* CONFIG_IEEE80211W */
45 int ap_for_each_sta(struct hostapd_data *hapd,
46 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
52 for (sta = hapd->sta_list; sta; sta = sta->next) {
53 if (cb(hapd, sta, ctx))
61 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
65 s = hapd->sta_hash[STA_HASH(sta)];
66 while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
72 static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
76 if (hapd->sta_list == sta) {
77 hapd->sta_list = sta->next;
82 while (tmp != NULL && tmp->next != sta)
85 wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from "
86 "list.", MAC2STR(sta->addr));
88 tmp->next = sta->next;
92 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta)
94 sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
95 hapd->sta_hash[STA_HASH(sta->addr)] = sta;
99 static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
103 s = hapd->sta_hash[STA_HASH(sta->addr)];
104 if (s == NULL) return;
105 if (os_memcmp(s->addr, sta->addr, 6) == 0) {
106 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
110 while (s->hnext != NULL &&
111 os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
113 if (s->hnext != NULL)
114 s->hnext = s->hnext->hnext;
116 wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
117 " from hash table", MAC2STR(sta->addr));
121 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
125 accounting_sta_stop(hapd, sta);
128 ap_sta_set_authorized(hapd, sta, 0);
130 if (sta->flags & WLAN_STA_WDS)
131 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0);
133 if (!(sta->flags & WLAN_STA_PREAUTH))
134 hostapd_drv_sta_remove(hapd, sta->addr);
136 ap_sta_hash_del(hapd, sta);
137 ap_sta_list_del(hapd, sta);
140 hapd->sta_aid[(sta->aid - 1) / 32] &=
141 ~BIT((sta->aid - 1) % 32);
144 if (sta->nonerp_set) {
146 hapd->iface->num_sta_non_erp--;
147 if (hapd->iface->num_sta_non_erp == 0)
151 if (sta->no_short_slot_time_set) {
152 sta->no_short_slot_time_set = 0;
153 hapd->iface->num_sta_no_short_slot_time--;
154 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
155 && hapd->iface->num_sta_no_short_slot_time == 0)
159 if (sta->no_short_preamble_set) {
160 sta->no_short_preamble_set = 0;
161 hapd->iface->num_sta_no_short_preamble--;
162 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
163 && hapd->iface->num_sta_no_short_preamble == 0)
167 if (sta->no_ht_gf_set) {
168 sta->no_ht_gf_set = 0;
169 hapd->iface->num_sta_ht_no_gf--;
172 if (sta->no_ht_set) {
174 hapd->iface->num_sta_no_ht--;
177 if (sta->ht_20mhz_set) {
178 sta->ht_20mhz_set = 0;
179 hapd->iface->num_sta_ht_20mhz--;
183 if (sta->no_p2p_set) {
185 hapd->num_sta_no_p2p--;
186 if (hapd->num_sta_no_p2p == 0)
187 hostapd_p2p_non_p2p_sta_disconnected(hapd);
189 #endif /* CONFIG_P2P */
191 #if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N)
192 if (hostapd_ht_operation_update(hapd->iface) > 0)
194 #endif /* NEED_AP_MLME && CONFIG_IEEE80211N */
197 ieee802_11_set_beacons(hapd->iface);
199 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
200 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
202 ieee802_1x_free_station(sta);
203 wpa_auth_sta_deinit(sta->wpa_sm);
204 rsn_preauth_free_station(hapd, sta);
205 #ifndef CONFIG_NO_RADIUS
206 radius_client_flush_auth(hapd->radius, sta->addr);
207 #endif /* CONFIG_NO_RADIUS */
209 os_free(sta->last_assoc_req);
210 os_free(sta->challenge);
212 #ifdef CONFIG_IEEE80211W
213 os_free(sta->sa_query_trans_id);
214 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
215 #endif /* CONFIG_IEEE80211W */
218 p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
219 #endif /* CONFIG_P2P */
221 wpabuf_free(sta->wps_ie);
222 wpabuf_free(sta->p2p_ie);
224 os_free(sta->ht_capabilities);
230 void hostapd_free_stas(struct hostapd_data *hapd)
232 struct sta_info *sta, *prev;
234 sta = hapd->sta_list;
238 if (sta->flags & WLAN_STA_AUTH) {
239 mlme_deauthenticate_indication(
240 hapd, sta, WLAN_REASON_UNSPECIFIED);
243 wpa_printf(MSG_DEBUG, "Removing station " MACSTR,
244 MAC2STR(prev->addr));
245 ap_free_sta(hapd, prev);
251 * ap_handle_timer - Per STA timer handler
252 * @eloop_ctx: struct hostapd_data *
253 * @timeout_ctx: struct sta_info *
255 * This function is called to check station activity and to remove inactive
258 void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
260 struct hostapd_data *hapd = eloop_ctx;
261 struct sta_info *sta = timeout_ctx;
262 unsigned long next_time = 0;
264 if (sta->timeout_next == STA_REMOVE) {
265 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
266 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
267 "local deauth request");
268 ap_free_sta(hapd, sta);
272 if ((sta->flags & WLAN_STA_ASSOC) &&
273 (sta->timeout_next == STA_NULLFUNC ||
274 sta->timeout_next == STA_DISASSOC)) {
276 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
277 if (inactive_sec == -1) {
278 wpa_msg(hapd, MSG_DEBUG, "Check inactivity: Could not "
279 "get station info rom kernel driver for "
280 MACSTR, MAC2STR(sta->addr));
281 } else if (inactive_sec < hapd->conf->ap_max_inactivity &&
282 sta->flags & WLAN_STA_ASSOC) {
283 /* station activity detected; reset timeout state */
284 wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has been "
286 MAC2STR(sta->addr), inactive_sec);
287 sta->timeout_next = STA_NULLFUNC;
288 next_time = hapd->conf->ap_max_inactivity -
291 wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has been "
292 "inactive too long: %d sec, max allowed: %d",
293 MAC2STR(sta->addr), inactive_sec,
294 hapd->conf->ap_max_inactivity);
298 if ((sta->flags & WLAN_STA_ASSOC) &&
299 sta->timeout_next == STA_DISASSOC &&
300 !(sta->flags & WLAN_STA_PENDING_POLL)) {
301 wpa_msg(hapd, MSG_DEBUG, "Station " MACSTR " has ACKed data "
302 "poll", MAC2STR(sta->addr));
303 /* data nullfunc frame poll did not produce TX errors; assume
304 * station ACKed it */
305 sta->timeout_next = STA_NULLFUNC;
306 next_time = hapd->conf->ap_max_inactivity;
310 eloop_register_timeout(next_time, 0, ap_handle_timer, hapd,
315 if (sta->timeout_next == STA_NULLFUNC &&
316 (sta->flags & WLAN_STA_ASSOC)) {
317 #ifndef CONFIG_NATIVE_WINDOWS
318 /* send data frame to poll STA and check whether this frame
320 struct ieee80211_hdr hdr;
322 wpa_printf(MSG_DEBUG, " Polling STA with data frame");
323 sta->flags |= WLAN_STA_PENDING_POLL;
325 os_memset(&hdr, 0, sizeof(hdr));
327 os_strcmp(hapd->driver->name, "hostap") == 0) {
329 * WLAN_FC_STYPE_NULLFUNC would be more appropriate,
330 * but it is apparently not retried so TX Exc events
331 * are not received for it.
334 IEEE80211_FC(WLAN_FC_TYPE_DATA,
338 IEEE80211_FC(WLAN_FC_TYPE_DATA,
339 WLAN_FC_STYPE_NULLFUNC);
342 hdr.frame_control |= host_to_le16(WLAN_FC_FROMDS);
343 os_memcpy(hdr.IEEE80211_DA_FROMDS, sta->addr, ETH_ALEN);
344 os_memcpy(hdr.IEEE80211_BSSID_FROMDS, hapd->own_addr,
346 os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
348 if (hostapd_drv_send_mlme(hapd, &hdr, sizeof(hdr)) < 0)
349 perror("ap_handle_timer: send");
350 #endif /* CONFIG_NATIVE_WINDOWS */
351 } else if (sta->timeout_next != STA_REMOVE) {
352 int deauth = sta->timeout_next == STA_DEAUTH;
354 wpa_printf(MSG_DEBUG, "Sending %s info to STA " MACSTR,
355 deauth ? "deauthentication" : "disassociation",
359 hostapd_drv_sta_deauth(
361 WLAN_REASON_PREV_AUTH_NOT_VALID);
363 hostapd_drv_sta_disassoc(
365 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
369 switch (sta->timeout_next) {
371 sta->timeout_next = STA_DISASSOC;
372 eloop_register_timeout(AP_DISASSOC_DELAY, 0, ap_handle_timer,
376 sta->flags &= ~WLAN_STA_ASSOC;
377 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
378 if (!sta->acct_terminate_cause)
379 sta->acct_terminate_cause =
380 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
381 accounting_sta_stop(hapd, sta);
382 ieee802_1x_free_station(sta);
383 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
384 HOSTAPD_LEVEL_INFO, "disassociated due to "
386 sta->timeout_next = STA_DEAUTH;
387 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
389 mlme_disassociate_indication(
390 hapd, sta, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
394 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
395 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
397 if (!sta->acct_terminate_cause)
398 sta->acct_terminate_cause =
399 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
400 mlme_deauthenticate_indication(
402 WLAN_REASON_PREV_AUTH_NOT_VALID);
403 ap_free_sta(hapd, sta);
409 static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
411 struct hostapd_data *hapd = eloop_ctx;
412 struct sta_info *sta = timeout_ctx;
415 if (!(sta->flags & WLAN_STA_AUTH))
418 mlme_deauthenticate_indication(hapd, sta,
419 WLAN_REASON_PREV_AUTH_NOT_VALID);
420 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
421 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
423 sta->acct_terminate_cause =
424 RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
425 os_memcpy(addr, sta->addr, ETH_ALEN);
426 ap_free_sta(hapd, sta);
427 hostapd_drv_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
431 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
434 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
435 HOSTAPD_LEVEL_DEBUG, "setting session timeout to %d "
436 "seconds", session_timeout);
437 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
438 eloop_register_timeout(session_timeout, 0, ap_handle_session_timer,
443 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
445 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
449 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
451 struct sta_info *sta;
453 sta = ap_get_sta(hapd, addr);
457 wpa_printf(MSG_DEBUG, " New STA");
458 if (hapd->num_sta >= hapd->conf->max_num_sta) {
459 /* FIX: might try to remove some old STAs first? */
460 wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)",
461 hapd->num_sta, hapd->conf->max_num_sta);
465 sta = os_zalloc(sizeof(struct sta_info));
467 wpa_printf(MSG_ERROR, "malloc failed");
470 sta->acct_interim_interval = hapd->conf->acct_interim_interval;
472 /* initialize STA info data */
473 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
474 ap_handle_timer, hapd, sta);
475 os_memcpy(sta->addr, addr, ETH_ALEN);
476 sta->next = hapd->sta_list;
477 hapd->sta_list = sta;
479 ap_sta_hash_add(hapd, sta);
480 sta->ssid = &hapd->conf->ssid;
481 ap_sta_remove_in_other_bss(hapd, sta);
487 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
489 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
491 wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
493 if (hostapd_drv_sta_remove(hapd, sta->addr) &&
494 sta->flags & WLAN_STA_ASSOC) {
495 wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
496 " from kernel driver.", MAC2STR(sta->addr));
503 static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
504 struct sta_info *sta)
506 struct hostapd_iface *iface = hapd->iface;
509 for (i = 0; i < iface->num_bss; i++) {
510 struct hostapd_data *bss = iface->bss[i];
511 struct sta_info *sta2;
512 /* bss should always be set during operation, but it may be
513 * NULL during reconfiguration. Assume the STA is not
514 * associated to another BSS in that case to avoid NULL pointer
516 if (bss == hapd || bss == NULL)
518 sta2 = ap_get_sta(bss, sta->addr);
522 ap_sta_disconnect(bss, sta2, sta2->addr,
523 WLAN_REASON_PREV_AUTH_NOT_VALID);
528 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
531 wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
532 hapd->conf->iface, MAC2STR(sta->addr));
533 sta->flags &= ~WLAN_STA_ASSOC;
534 ap_sta_remove(hapd, sta);
535 sta->timeout_next = STA_DEAUTH;
536 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
537 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0,
538 ap_handle_timer, hapd, sta);
539 accounting_sta_stop(hapd, sta);
540 ieee802_1x_free_station(sta);
542 mlme_disassociate_indication(hapd, sta, reason);
546 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
549 wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
550 hapd->conf->iface, MAC2STR(sta->addr));
551 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
552 ap_sta_remove(hapd, sta);
553 sta->timeout_next = STA_REMOVE;
554 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
555 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,
556 ap_handle_timer, hapd, sta);
557 accounting_sta_stop(hapd, sta);
558 ieee802_1x_free_station(sta);
560 mlme_deauthenticate_indication(hapd, sta, reason);
564 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
567 #ifndef CONFIG_NO_VLAN
569 struct hostapd_vlan *vlan = NULL;
573 * Do not proceed furthur if the vlan id remains same. We do not want
574 * duplicate dynamic vlan entries.
576 if (sta->vlan_id == old_vlanid)
580 * During 1x reauth, if the vlan id changes, then remove the old id and
581 * proceed furthur to add the new one.
584 vlan_remove_dynamic(hapd, old_vlanid);
586 iface = hapd->conf->iface;
587 if (sta->ssid->vlan[0])
588 iface = sta->ssid->vlan;
590 if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
592 else if (sta->vlan_id > 0) {
593 vlan = hapd->conf->vlan;
595 if (vlan->vlan_id == sta->vlan_id ||
596 vlan->vlan_id == VLAN_ID_WILDCARD) {
597 iface = vlan->ifname;
604 if (sta->vlan_id > 0 && vlan == NULL) {
605 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
606 HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
607 "binding station to (vlan_id=%d)",
610 } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
611 vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
613 hostapd_logger(hapd, sta->addr,
614 HOSTAPD_MODULE_IEEE80211,
615 HOSTAPD_LEVEL_DEBUG, "could not add "
616 "dynamic VLAN interface for vlan_id=%d",
621 iface = vlan->ifname;
622 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
623 hostapd_logger(hapd, sta->addr,
624 HOSTAPD_MODULE_IEEE80211,
625 HOSTAPD_LEVEL_DEBUG, "could not "
626 "configure encryption for dynamic VLAN "
627 "interface for vlan_id=%d",
631 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
632 HOSTAPD_LEVEL_DEBUG, "added new dynamic VLAN "
633 "interface '%s'", iface);
634 } else if (vlan && vlan->vlan_id == sta->vlan_id) {
635 if (sta->vlan_id > 0) {
636 vlan->dynamic_vlan++;
637 hostapd_logger(hapd, sta->addr,
638 HOSTAPD_MODULE_IEEE80211,
639 HOSTAPD_LEVEL_DEBUG, "updated existing "
640 "dynamic VLAN interface '%s'", iface);
644 * Update encryption configuration for statically generated
645 * VLAN interface. This is only used for static WEP
646 * configuration for the case where hostapd did not yet know
647 * which keys are to be used when the interface was added.
649 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
650 hostapd_logger(hapd, sta->addr,
651 HOSTAPD_MODULE_IEEE80211,
652 HOSTAPD_LEVEL_DEBUG, "could not "
653 "configure encryption for VLAN "
654 "interface for vlan_id=%d",
659 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
660 HOSTAPD_LEVEL_DEBUG, "binding station to interface "
663 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
664 wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
666 ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
668 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
669 HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
670 "entry to vlan_id=%d", sta->vlan_id);
673 #else /* CONFIG_NO_VLAN */
675 #endif /* CONFIG_NO_VLAN */
679 #ifdef CONFIG_IEEE80211W
681 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
684 struct os_time now, passed;
686 os_time_sub(&now, &sta->sa_query_start, &passed);
687 tu = (passed.sec * 1000000 + passed.usec) / 1024;
688 if (hapd->conf->assoc_sa_query_max_timeout < tu) {
689 hostapd_logger(hapd, sta->addr,
690 HOSTAPD_MODULE_IEEE80211,
692 "association SA Query timed out");
693 sta->sa_query_timed_out = 1;
694 os_free(sta->sa_query_trans_id);
695 sta->sa_query_trans_id = NULL;
696 sta->sa_query_count = 0;
697 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
705 static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
707 struct hostapd_data *hapd = eloop_ctx;
708 struct sta_info *sta = timeout_ctx;
709 unsigned int timeout, sec, usec;
712 if (sta->sa_query_count > 0 &&
713 ap_check_sa_query_timeout(hapd, sta))
716 nbuf = os_realloc(sta->sa_query_trans_id,
717 (sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
720 if (sta->sa_query_count == 0) {
721 /* Starting a new SA Query procedure */
722 os_get_time(&sta->sa_query_start);
724 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
725 sta->sa_query_trans_id = nbuf;
726 sta->sa_query_count++;
728 os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
730 timeout = hapd->conf->assoc_sa_query_retry_timeout;
731 sec = ((timeout / 1000) * 1024) / 1000;
732 usec = (timeout % 1000) * 1024;
733 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
735 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
737 "association SA Query attempt %d", sta->sa_query_count);
740 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
741 #endif /* NEED_AP_MLME */
745 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
747 ap_sa_query_timer(hapd, sta);
751 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
753 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
754 os_free(sta->sa_query_trans_id);
755 sta->sa_query_trans_id = NULL;
756 sta->sa_query_count = 0;
759 #endif /* CONFIG_IEEE80211W */
762 void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
765 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
769 sta->flags |= WLAN_STA_AUTHORIZED;
771 sta->flags &= ~WLAN_STA_AUTHORIZED;
773 if (hapd->sta_authorized_cb)
774 hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
775 sta->addr, authorized);
779 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
780 const u8 *addr, u16 reason)
783 if (sta == NULL && addr)
784 sta = ap_get_sta(hapd, addr);
787 hostapd_drv_sta_deauth(hapd, addr, reason);
791 ap_sta_set_authorized(hapd, sta, 0);
792 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
793 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
794 eloop_register_timeout(0, 0, ap_handle_timer, hapd, sta);
795 sta->timeout_next = STA_REMOVE;