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"
24 #include "accounting.h"
25 #include "ieee802_1x.h"
26 #include "ieee802_11.h"
28 #include "preauth_auth.h"
29 #include "ap_config.h"
32 #include "vlan_init.h"
35 static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
36 struct sta_info *sta);
37 static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx);
38 #ifdef CONFIG_IEEE80211W
39 static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx);
40 #endif /* CONFIG_IEEE80211W */
42 int ap_for_each_sta(struct hostapd_data *hapd,
43 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
49 for (sta = hapd->sta_list; sta; sta = sta->next) {
50 if (cb(hapd, sta, ctx))
58 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
62 s = hapd->sta_hash[STA_HASH(sta)];
63 while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
69 static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
73 if (hapd->sta_list == sta) {
74 hapd->sta_list = sta->next;
79 while (tmp != NULL && tmp->next != sta)
82 wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from "
83 "list.", MAC2STR(sta->addr));
85 tmp->next = sta->next;
89 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta)
91 sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
92 hapd->sta_hash[STA_HASH(sta->addr)] = sta;
96 static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
100 s = hapd->sta_hash[STA_HASH(sta->addr)];
101 if (s == NULL) return;
102 if (os_memcmp(s->addr, sta->addr, 6) == 0) {
103 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
107 while (s->hnext != NULL &&
108 os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
110 if (s->hnext != NULL)
111 s->hnext = s->hnext->hnext;
113 wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
114 " from hash table", MAC2STR(sta->addr));
118 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
122 accounting_sta_stop(hapd, sta);
124 if (sta->flags & WLAN_STA_WDS)
125 hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0);
127 if (!(sta->flags & WLAN_STA_PREAUTH))
128 hapd->drv.sta_remove(hapd, sta->addr);
130 ap_sta_hash_del(hapd, sta);
131 ap_sta_list_del(hapd, sta);
134 hapd->sta_aid[(sta->aid - 1) / 32] &=
135 ~BIT((sta->aid - 1) % 32);
138 if (sta->nonerp_set) {
140 hapd->iface->num_sta_non_erp--;
141 if (hapd->iface->num_sta_non_erp == 0)
145 if (sta->no_short_slot_time_set) {
146 sta->no_short_slot_time_set = 0;
147 hapd->iface->num_sta_no_short_slot_time--;
148 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
149 && hapd->iface->num_sta_no_short_slot_time == 0)
153 if (sta->no_short_preamble_set) {
154 sta->no_short_preamble_set = 0;
155 hapd->iface->num_sta_no_short_preamble--;
156 if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
157 && hapd->iface->num_sta_no_short_preamble == 0)
161 if (sta->no_ht_gf_set) {
162 sta->no_ht_gf_set = 0;
163 hapd->iface->num_sta_ht_no_gf--;
166 if (sta->no_ht_set) {
168 hapd->iface->num_sta_no_ht--;
171 if (sta->ht_20mhz_set) {
172 sta->ht_20mhz_set = 0;
173 hapd->iface->num_sta_ht_20mhz--;
176 #if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N)
177 if (hostapd_ht_operation_update(hapd->iface) > 0)
179 #endif /* NEED_AP_MLME && CONFIG_IEEE80211N */
182 ieee802_11_set_beacons(hapd->iface);
184 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
185 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
187 ieee802_1x_free_station(sta);
188 wpa_auth_sta_deinit(sta->wpa_sm);
189 rsn_preauth_free_station(hapd, sta);
190 #ifndef CONFIG_NO_RADIUS
191 radius_client_flush_auth(hapd->radius, sta->addr);
192 #endif /* CONFIG_NO_RADIUS */
194 os_free(sta->last_assoc_req);
195 os_free(sta->challenge);
197 #ifdef CONFIG_IEEE80211W
198 os_free(sta->sa_query_trans_id);
199 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
200 #endif /* CONFIG_IEEE80211W */
202 wpabuf_free(sta->wps_ie);
203 wpabuf_free(sta->p2p_ie);
205 os_free(sta->ht_capabilities);
211 void hostapd_free_stas(struct hostapd_data *hapd)
213 struct sta_info *sta, *prev;
215 sta = hapd->sta_list;
219 if (sta->flags & WLAN_STA_AUTH) {
220 mlme_deauthenticate_indication(
221 hapd, sta, WLAN_REASON_UNSPECIFIED);
224 wpa_printf(MSG_DEBUG, "Removing station " MACSTR,
225 MAC2STR(prev->addr));
226 ap_free_sta(hapd, prev);
232 * ap_handle_timer - Per STA timer handler
233 * @eloop_ctx: struct hostapd_data *
234 * @timeout_ctx: struct sta_info *
236 * This function is called to check station activity and to remove inactive
239 void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
241 struct hostapd_data *hapd = eloop_ctx;
242 struct sta_info *sta = timeout_ctx;
243 unsigned long next_time = 0;
245 if (sta->timeout_next == STA_REMOVE) {
246 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
247 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
248 "local deauth request");
249 ap_free_sta(hapd, sta);
253 if ((sta->flags & WLAN_STA_ASSOC) &&
254 (sta->timeout_next == STA_NULLFUNC ||
255 sta->timeout_next == STA_DISASSOC)) {
257 wpa_printf(MSG_DEBUG, "Checking STA " MACSTR " inactivity:",
259 inactive_sec = hapd->drv.get_inact_sec(hapd, sta->addr);
260 if (inactive_sec == -1) {
261 wpa_printf(MSG_DEBUG, "Could not get station info "
262 "from kernel driver for " MACSTR ".",
264 } else if (inactive_sec < hapd->conf->ap_max_inactivity &&
265 sta->flags & WLAN_STA_ASSOC) {
266 /* station activity detected; reset timeout state */
267 wpa_printf(MSG_DEBUG, " Station has been active");
268 sta->timeout_next = STA_NULLFUNC;
269 next_time = hapd->conf->ap_max_inactivity -
274 if ((sta->flags & WLAN_STA_ASSOC) &&
275 sta->timeout_next == STA_DISASSOC &&
276 !(sta->flags & WLAN_STA_PENDING_POLL)) {
277 wpa_printf(MSG_DEBUG, " Station has ACKed data poll");
278 /* data nullfunc frame poll did not produce TX errors; assume
279 * station ACKed it */
280 sta->timeout_next = STA_NULLFUNC;
281 next_time = hapd->conf->ap_max_inactivity;
285 eloop_register_timeout(next_time, 0, ap_handle_timer, hapd,
290 if (sta->timeout_next == STA_NULLFUNC &&
291 (sta->flags & WLAN_STA_ASSOC)) {
292 #ifndef CONFIG_NATIVE_WINDOWS
293 /* send data frame to poll STA and check whether this frame
295 struct ieee80211_hdr hdr;
297 wpa_printf(MSG_DEBUG, " Polling STA with data frame");
298 sta->flags |= WLAN_STA_PENDING_POLL;
300 os_memset(&hdr, 0, sizeof(hdr));
302 os_strcmp(hapd->driver->name, "hostap") == 0) {
304 * WLAN_FC_STYPE_NULLFUNC would be more appropriate,
305 * but it is apparently not retried so TX Exc events
306 * are not received for it.
309 IEEE80211_FC(WLAN_FC_TYPE_DATA,
313 IEEE80211_FC(WLAN_FC_TYPE_DATA,
314 WLAN_FC_STYPE_NULLFUNC);
317 hdr.frame_control |= host_to_le16(WLAN_FC_FROMDS);
318 os_memcpy(hdr.IEEE80211_DA_FROMDS, sta->addr, ETH_ALEN);
319 os_memcpy(hdr.IEEE80211_BSSID_FROMDS, hapd->own_addr,
321 os_memcpy(hdr.IEEE80211_SA_FROMDS, hapd->own_addr, ETH_ALEN);
323 if (hapd->drv.send_mgmt_frame(hapd, &hdr, sizeof(hdr)) < 0)
324 perror("ap_handle_timer: send");
325 #endif /* CONFIG_NATIVE_WINDOWS */
326 } else if (sta->timeout_next != STA_REMOVE) {
327 int deauth = sta->timeout_next == STA_DEAUTH;
329 wpa_printf(MSG_DEBUG, "Sending %s info to STA " MACSTR,
330 deauth ? "deauthentication" : "disassociation",
334 hapd->drv.sta_deauth(hapd, sta->addr,
335 WLAN_REASON_PREV_AUTH_NOT_VALID);
337 hapd->drv.sta_disassoc(
339 WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
343 switch (sta->timeout_next) {
345 sta->timeout_next = STA_DISASSOC;
346 eloop_register_timeout(AP_DISASSOC_DELAY, 0, ap_handle_timer,
350 sta->flags &= ~WLAN_STA_ASSOC;
351 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
352 if (!sta->acct_terminate_cause)
353 sta->acct_terminate_cause =
354 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
355 accounting_sta_stop(hapd, sta);
356 ieee802_1x_free_station(sta);
357 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
358 HOSTAPD_LEVEL_INFO, "disassociated due to "
360 sta->timeout_next = STA_DEAUTH;
361 eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
363 mlme_disassociate_indication(
364 hapd, sta, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
368 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
369 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
371 if (!sta->acct_terminate_cause)
372 sta->acct_terminate_cause =
373 RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
374 mlme_deauthenticate_indication(
376 WLAN_REASON_PREV_AUTH_NOT_VALID);
377 ap_free_sta(hapd, sta);
383 static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
385 struct hostapd_data *hapd = eloop_ctx;
386 struct sta_info *sta = timeout_ctx;
389 if (!(sta->flags & WLAN_STA_AUTH))
392 mlme_deauthenticate_indication(hapd, sta,
393 WLAN_REASON_PREV_AUTH_NOT_VALID);
394 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
395 HOSTAPD_LEVEL_INFO, "deauthenticated due to "
397 sta->acct_terminate_cause =
398 RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
399 os_memcpy(addr, sta->addr, ETH_ALEN);
400 ap_free_sta(hapd, sta);
401 hapd->drv.sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
405 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
408 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
409 HOSTAPD_LEVEL_DEBUG, "setting session timeout to %d "
410 "seconds", session_timeout);
411 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
412 eloop_register_timeout(session_timeout, 0, ap_handle_session_timer,
417 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
419 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
423 struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
425 struct sta_info *sta;
427 sta = ap_get_sta(hapd, addr);
431 wpa_printf(MSG_DEBUG, " New STA");
432 if (hapd->num_sta >= hapd->conf->max_num_sta) {
433 /* FIX: might try to remove some old STAs first? */
434 wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)",
435 hapd->num_sta, hapd->conf->max_num_sta);
439 sta = os_zalloc(sizeof(struct sta_info));
441 wpa_printf(MSG_ERROR, "malloc failed");
444 sta->acct_interim_interval = hapd->conf->acct_interim_interval;
446 /* initialize STA info data */
447 eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
448 ap_handle_timer, hapd, sta);
449 os_memcpy(sta->addr, addr, ETH_ALEN);
450 sta->next = hapd->sta_list;
451 hapd->sta_list = sta;
453 ap_sta_hash_add(hapd, sta);
454 sta->ssid = &hapd->conf->ssid;
455 ap_sta_remove_in_other_bss(hapd, sta);
461 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
463 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
465 wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
467 if (hapd->drv.sta_remove(hapd, sta->addr) &&
468 sta->flags & WLAN_STA_ASSOC) {
469 wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
470 " from kernel driver.", MAC2STR(sta->addr));
477 static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
478 struct sta_info *sta)
480 struct hostapd_iface *iface = hapd->iface;
483 for (i = 0; i < iface->num_bss; i++) {
484 struct hostapd_data *bss = iface->bss[i];
485 struct sta_info *sta2;
486 /* bss should always be set during operation, but it may be
487 * NULL during reconfiguration. Assume the STA is not
488 * associated to another BSS in that case to avoid NULL pointer
490 if (bss == hapd || bss == NULL)
492 sta2 = ap_get_sta(bss, sta->addr);
496 ap_sta_disconnect(bss, sta2, sta2->addr,
497 WLAN_REASON_PREV_AUTH_NOT_VALID);
502 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
505 wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
506 hapd->conf->iface, MAC2STR(sta->addr));
507 sta->flags &= ~WLAN_STA_ASSOC;
508 ap_sta_remove(hapd, sta);
509 sta->timeout_next = STA_DEAUTH;
510 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
511 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0,
512 ap_handle_timer, hapd, sta);
513 accounting_sta_stop(hapd, sta);
514 ieee802_1x_free_station(sta);
516 mlme_disassociate_indication(hapd, sta, reason);
520 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
523 wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
524 hapd->conf->iface, MAC2STR(sta->addr));
525 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
526 ap_sta_remove(hapd, sta);
527 sta->timeout_next = STA_REMOVE;
528 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
529 eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,
530 ap_handle_timer, hapd, sta);
531 accounting_sta_stop(hapd, sta);
532 ieee802_1x_free_station(sta);
534 mlme_deauthenticate_indication(hapd, sta, reason);
538 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
541 #ifndef CONFIG_NO_VLAN
543 struct hostapd_vlan *vlan = NULL;
547 * Do not proceed furthur if the vlan id remains same. We do not want
548 * duplicate dynamic vlan entries.
550 if (sta->vlan_id == old_vlanid)
554 * During 1x reauth, if the vlan id changes, then remove the old id and
555 * proceed furthur to add the new one.
558 vlan_remove_dynamic(hapd, old_vlanid);
560 iface = hapd->conf->iface;
561 if (sta->ssid->vlan[0])
562 iface = sta->ssid->vlan;
564 if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
566 else if (sta->vlan_id > 0) {
567 vlan = hapd->conf->vlan;
569 if (vlan->vlan_id == sta->vlan_id ||
570 vlan->vlan_id == VLAN_ID_WILDCARD) {
571 iface = vlan->ifname;
578 if (sta->vlan_id > 0 && vlan == NULL) {
579 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
580 HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
581 "binding station to (vlan_id=%d)",
584 } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
585 vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
587 hostapd_logger(hapd, sta->addr,
588 HOSTAPD_MODULE_IEEE80211,
589 HOSTAPD_LEVEL_DEBUG, "could not add "
590 "dynamic VLAN interface for vlan_id=%d",
595 iface = vlan->ifname;
596 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
597 hostapd_logger(hapd, sta->addr,
598 HOSTAPD_MODULE_IEEE80211,
599 HOSTAPD_LEVEL_DEBUG, "could not "
600 "configure encryption for dynamic VLAN "
601 "interface for vlan_id=%d",
605 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
606 HOSTAPD_LEVEL_DEBUG, "added new dynamic VLAN "
607 "interface '%s'", iface);
608 } else if (vlan && vlan->vlan_id == sta->vlan_id) {
609 if (sta->vlan_id > 0) {
610 vlan->dynamic_vlan++;
611 hostapd_logger(hapd, sta->addr,
612 HOSTAPD_MODULE_IEEE80211,
613 HOSTAPD_LEVEL_DEBUG, "updated existing "
614 "dynamic VLAN interface '%s'", iface);
618 * Update encryption configuration for statically generated
619 * VLAN interface. This is only used for static WEP
620 * configuration for the case where hostapd did not yet know
621 * which keys are to be used when the interface was added.
623 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
624 hostapd_logger(hapd, sta->addr,
625 HOSTAPD_MODULE_IEEE80211,
626 HOSTAPD_LEVEL_DEBUG, "could not "
627 "configure encryption for VLAN "
628 "interface for vlan_id=%d",
633 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
634 HOSTAPD_LEVEL_DEBUG, "binding station to interface "
637 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
638 wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
640 ret = hapd->drv.set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
642 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
643 HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
644 "entry to vlan_id=%d", sta->vlan_id);
647 #else /* CONFIG_NO_VLAN */
649 #endif /* CONFIG_NO_VLAN */
653 #ifdef CONFIG_IEEE80211W
655 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
658 struct os_time now, passed;
660 os_time_sub(&now, &sta->sa_query_start, &passed);
661 tu = (passed.sec * 1000000 + passed.usec) / 1024;
662 if (hapd->conf->assoc_sa_query_max_timeout < tu) {
663 hostapd_logger(hapd, sta->addr,
664 HOSTAPD_MODULE_IEEE80211,
666 "association SA Query timed out");
667 sta->sa_query_timed_out = 1;
668 os_free(sta->sa_query_trans_id);
669 sta->sa_query_trans_id = NULL;
670 sta->sa_query_count = 0;
671 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
679 static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
681 struct hostapd_data *hapd = eloop_ctx;
682 struct sta_info *sta = timeout_ctx;
683 unsigned int timeout, sec, usec;
686 if (sta->sa_query_count > 0 &&
687 ap_check_sa_query_timeout(hapd, sta))
690 nbuf = os_realloc(sta->sa_query_trans_id,
691 (sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
694 if (sta->sa_query_count == 0) {
695 /* Starting a new SA Query procedure */
696 os_get_time(&sta->sa_query_start);
698 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
699 sta->sa_query_trans_id = nbuf;
700 sta->sa_query_count++;
702 os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
704 timeout = hapd->conf->assoc_sa_query_retry_timeout;
705 sec = ((timeout / 1000) * 1024) / 1000;
706 usec = (timeout % 1000) * 1024;
707 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
709 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
711 "association SA Query attempt %d", sta->sa_query_count);
714 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
715 #endif /* NEED_AP_MLME */
719 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
721 ap_sa_query_timer(hapd, sta);
725 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
727 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
728 os_free(sta->sa_query_trans_id);
729 sta->sa_query_trans_id = NULL;
730 sta->sa_query_count = 0;
733 #endif /* CONFIG_IEEE80211W */
736 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
737 const u8 *addr, u16 reason)
740 if (sta == NULL && addr)
741 sta = ap_get_sta(hapd, addr);
744 hapd->drv.sta_deauth(hapd, addr, reason);
748 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | WLAN_STA_AUTHORIZED);
749 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
750 eloop_register_timeout(0, 0, ap_handle_timer, hapd, sta);
751 sta->timeout_next = STA_REMOVE;