Lines Matching refs:sta

37 				       struct sta_info *sta);
45 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta);
48 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
52 struct sta_info *sta;
54 for (sta = hapd->sta_list; sta; sta = sta->next) {
55 if (cb(hapd, sta, ctx))
63 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
67 s = hapd->sta_hash[STA_HASH(sta)];
68 while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
77 struct sta_info *sta;
79 for (sta = hapd->sta_list; sta; sta = sta->next) {
82 if (sta->p2p_ie == NULL)
85 p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie);
90 return sta;
98 static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
102 if (hapd->sta_list == sta) {
103 hapd->sta_list = sta->next;
108 while (tmp != NULL && tmp->next != sta)
112 "list.", MAC2STR(sta->addr));
114 tmp->next = sta->next;
118 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta)
120 sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
121 hapd->sta_hash[STA_HASH(sta->addr)] = sta;
125 static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
129 s = hapd->sta_hash[STA_HASH(sta->addr)];
131 if (os_memcmp(s->addr, sta->addr, 6) == 0) {
132 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
137 os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
143 " from hash table", MAC2STR(sta->addr));
147 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
151 accounting_sta_stop(hapd, sta);
154 ap_sta_set_authorized(hapd, sta, 0);
156 if (sta->flags & WLAN_STA_WDS)
157 hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0);
160 !(sta->flags & WLAN_STA_PREAUTH))
161 hostapd_drv_sta_remove(hapd, sta->addr);
163 ap_sta_hash_del(hapd, sta);
164 ap_sta_list_del(hapd, sta);
166 if (sta->aid > 0)
167 hapd->sta_aid[(sta->aid - 1) / 32] &=
168 ~BIT((sta->aid - 1) % 32);
171 if (sta->nonerp_set) {
172 sta->nonerp_set = 0;
178 if (sta->no_short_slot_time_set) {
179 sta->no_short_slot_time_set = 0;
186 if (sta->no_short_preamble_set) {
187 sta->no_short_preamble_set = 0;
194 if (sta->no_ht_gf_set) {
195 sta->no_ht_gf_set = 0;
199 if (sta->no_ht_set) {
200 sta->no_ht_set = 0;
204 if (sta->ht_20mhz_set) {
205 sta->ht_20mhz_set = 0;
210 ht40_intolerant_remove(hapd->iface, sta);
214 if (sta->no_p2p_set) {
215 sta->no_p2p_set = 0;
231 __func__, MAC2STR(sta->addr));
232 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
233 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
234 eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
235 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
236 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
238 ieee802_1x_free_station(sta);
239 wpa_auth_sta_deinit(sta->wpa_sm);
240 rsn_preauth_free_station(hapd, sta);
243 radius_client_flush_auth(hapd->radius, sta->addr);
246 os_free(sta->challenge);
249 os_free(sta->sa_query_trans_id);
250 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
254 p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
258 if (sta->gas_dialog) {
261 gas_serv_dialog_clear(&sta->gas_dialog[i]);
262 os_free(sta->gas_dialog);
266 wpabuf_free(sta->wps_ie);
267 wpabuf_free(sta->p2p_ie);
268 wpabuf_free(sta->hs20_ie);
270 os_free(sta->ht_capabilities);
271 os_free(sta->vht_capabilities);
272 hostapd_free_psk_list(sta->psk);
273 os_free(sta->identity);
274 os_free(sta->radius_cui);
275 os_free(sta->remediation_url);
276 wpabuf_free(sta->hs20_deauth_req);
277 os_free(sta->hs20_session_info_url);
280 sae_clear_data(sta->sae);
281 os_free(sta->sae);
284 os_free(sta);
290 struct sta_info *sta, *prev;
292 sta = hapd->sta_list;
294 while (sta) {
295 prev = sta;
296 if (sta->flags & WLAN_STA_AUTH) {
298 hapd, sta, WLAN_REASON_UNSPECIFIED);
300 sta = sta->next;
319 struct sta_info *sta = timeout_ctx;
324 __func__, MAC2STR(sta->addr), sta->flags,
325 sta->timeout_next);
326 if (sta->timeout_next == STA_REMOVE) {
327 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
330 ap_free_sta(hapd, sta);
334 if ((sta->flags & WLAN_STA_ASSOC) &&
335 (sta->timeout_next == STA_NULLFUNC ||
336 sta->timeout_next == STA_DISASSOC)) {
344 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
349 MACSTR, MAC2STR(sta->addr));
357 sta->flags & WLAN_STA_ASSOC) {
361 MAC2STR(sta->addr), inactive_sec);
362 sta->timeout_next = STA_NULLFUNC;
369 MAC2STR(sta->addr), inactive_sec,
373 sta->timeout_next = STA_DISASSOC;
377 if ((sta->flags & WLAN_STA_ASSOC) &&
378 sta->timeout_next == STA_DISASSOC &&
379 !(sta->flags & WLAN_STA_PENDING_POLL) &&
382 " has ACKed data poll", MAC2STR(sta->addr));
385 sta->timeout_next = STA_NULLFUNC;
392 __func__, MAC2STR(sta->addr), next_time);
394 sta);
398 if (sta->timeout_next == STA_NULLFUNC &&
399 (sta->flags & WLAN_STA_ASSOC)) {
401 sta->flags |= WLAN_STA_PENDING_POLL;
402 hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr,
403 sta->flags & WLAN_STA_WMM);
404 } else if (sta->timeout_next != STA_REMOVE) {
405 int deauth = sta->timeout_next == STA_DEAUTH;
410 MAC2STR(sta->addr));
414 hapd, sta->addr,
417 reason = (sta->timeout_next == STA_DISASSOC) ?
421 hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
425 switch (sta->timeout_next) {
427 sta->timeout_next = STA_DISASSOC;
430 __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY);
432 hapd, sta);
436 ap_sta_set_authorized(hapd, sta, 0);
437 sta->flags &= ~WLAN_STA_ASSOC;
438 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
439 if (!sta->acct_terminate_cause)
440 sta->acct_terminate_cause =
442 accounting_sta_stop(hapd, sta);
443 ieee802_1x_free_station(sta);
444 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
447 reason = (sta->timeout_next == STA_DISASSOC) ?
450 sta->timeout_next = STA_DEAUTH;
453 __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY);
455 hapd, sta);
456 mlme_disassociate_indication(hapd, sta, reason);
460 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
463 if (!sta->acct_terminate_cause)
464 sta->acct_terminate_cause =
467 hapd, sta,
469 ap_free_sta(hapd, sta);
478 struct sta_info *sta = timeout_ctx;
480 if (!(sta->flags & WLAN_STA_AUTH)) {
481 if (sta->flags & WLAN_STA_GAS) {
483 "entry " MACSTR, MAC2STR(sta->addr));
484 ap_free_sta(hapd, sta);
489 hostapd_drv_sta_deauth(hapd, sta->addr,
491 mlme_deauthenticate_indication(hapd, sta,
493 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
496 sta->acct_terminate_cause =
498 ap_free_sta(hapd, sta);
502 void ap_sta_replenish_timeout(struct hostapd_data *hapd, struct sta_info *sta,
506 ap_handle_session_timer, hapd, sta) == 1) {
507 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
514 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
517 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
520 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
522 hapd, sta);
526 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
528 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
536 struct sta_info *sta = timeout_ctx;
539 MAC2STR(sta->addr));
540 if (sta->hs20_session_info_url == NULL)
543 wnm_send_ess_disassoc_imminent(hapd, sta, sta->hs20_session_info_url,
544 sta->hs20_disassoc_timer);
550 struct sta_info *sta, int warning_time)
552 eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
554 hapd, sta);
560 struct sta_info *sta;
562 sta = ap_get_sta(hapd, addr);
563 if (sta)
564 return sta;
574 sta = os_zalloc(sizeof(struct sta_info));
575 if (sta == NULL) {
579 sta->acct_interim_interval = hapd->conf->acct_interim_interval;
580 accounting_sta_get_id(hapd, sta);
588 ap_handle_timer, hapd, sta);
592 os_memcpy(sta->addr, addr, ETH_ALEN);
593 sta->next = hapd->sta_list;
594 hapd->sta_list = sta;
596 ap_sta_hash_add(hapd, sta);
597 sta->ssid = &hapd->conf->ssid;
598 ap_sta_remove_in_other_bss(hapd, sta);
600 return sta;
604 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
606 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
609 MAC2STR(sta->addr));
610 if (hostapd_drv_sta_remove(hapd, sta->addr) &&
611 sta->flags & WLAN_STA_ASSOC) {
613 " from kernel driver.", MAC2STR(sta->addr));
621 struct sta_info *sta)
635 sta2 = ap_get_sta(bss, sta->addr);
648 struct sta_info *sta = timeout_ctx;
650 ap_sta_remove(hapd, sta);
651 mlme_disassociate_indication(hapd, sta, sta->disassoc_reason);
655 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
659 hapd->conf->iface, MAC2STR(sta->addr));
660 sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
661 ap_sta_set_authorized(hapd, sta, 0);
662 sta->timeout_next = STA_DEAUTH;
666 __func__, MAC2STR(sta->addr),
668 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
670 ap_handle_timer, hapd, sta);
671 accounting_sta_stop(hapd, sta);
672 ieee802_1x_free_station(sta);
674 sta->disassoc_reason = reason;
675 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
676 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
679 ap_sta_disassoc_cb_timeout, hapd, sta);
686 struct sta_info *sta = timeout_ctx;
688 ap_sta_remove(hapd, sta);
689 mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason);
693 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
697 hapd->conf->iface, MAC2STR(sta->addr));
698 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
699 ap_sta_set_authorized(hapd, sta, 0);
700 sta->timeout_next = STA_REMOVE;
704 __func__, MAC2STR(sta->addr),
706 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
708 ap_handle_timer, hapd, sta);
709 accounting_sta_stop(hapd, sta);
710 ieee802_1x_free_station(sta);
712 sta->deauth_reason = reason;
713 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
714 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
717 ap_sta_deauth_cb_timeout, hapd, sta);
723 struct sta_info *sta, void *ctx)
725 if (sta && (sta->flags & WLAN_STA_WPS)) {
726 ap_sta_deauthenticate(hapd, sta,
728 wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR,
729 __func__, MAC2STR(sta->addr));
738 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
750 if (sta->vlan_id == old_vlanid)
761 if (sta->ssid->vlan[0])
762 iface = sta->ssid->vlan;
764 if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
765 sta->vlan_id = 0;
766 else if (sta->vlan_id > 0) {
770 if (vlan->vlan_id == sta->vlan_id)
782 if (sta->vlan_id > 0 && vlan == NULL) {
783 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
786 sta->vlan_id);
788 } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
789 vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
791 hostapd_logger(hapd, sta->addr,
795 sta->vlan_id);
800 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
801 hostapd_logger(hapd, sta->addr,
806 sta->vlan_id);
809 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
812 } else if (vlan && vlan->vlan_id == sta->vlan_id) {
813 if (sta->vlan_id > 0) {
815 hostapd_logger(hapd, sta->addr,
827 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
828 hostapd_logger(hapd, sta->addr,
833 sta->vlan_id);
837 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
841 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
844 ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
846 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
848 "entry to vlan_id=%d", sta->vlan_id);
859 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
864 os_reltime_sub(&now, &sta->sa_query_start, &passed);
867 hostapd_logger(hapd, sta->addr,
871 sta->sa_query_timed_out = 1;
872 os_free(sta->sa_query_trans_id);
873 sta->sa_query_trans_id = NULL;
874 sta->sa_query_count = 0;
875 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
886 struct sta_info *sta = timeout_ctx;
890 if (sta->sa_query_count > 0 &&
891 ap_check_sa_query_timeout(hapd, sta))
894 nbuf = os_realloc_array(sta->sa_query_trans_id,
895 sta->sa_query_count + 1,
899 if (sta->sa_query_count == 0) {
901 os_get_reltime(&sta->sa_query_start);
903 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
904 sta->sa_query_trans_id = nbuf;
905 sta->sa_query_count++;
912 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
914 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
916 "association SA Query attempt %d", sta->sa_query_count);
918 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
922 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
924 ap_sa_query_timer(hapd, sta);
928 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
930 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
931 os_free(sta->sa_query_trans_id);
932 sta->sa_query_trans_id = NULL;
933 sta->sa_query_count = 0;
939 void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
949 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
954 if (sta->p2p_ie != NULL &&
955 p2p_parse_dev_addr_in_p2p_ie(sta->p2p_ie, addr) == 0)
958 dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr);
962 MAC2STR(sta->addr), MAC2STR(dev_addr));
965 os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
971 if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
988 sta->flags |= WLAN_STA_AUTHORIZED;
997 sta->flags &= ~WLAN_STA_AUTHORIZED;
1002 sta->addr, authorized, dev_addr);
1006 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
1010 if (sta == NULL && addr)
1011 sta = ap_get_sta(hapd, addr);
1016 if (sta == NULL)
1018 ap_sta_set_authorized(hapd, sta, 0);
1019 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
1020 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
1021 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
1025 __func__, MAC2STR(sta->addr),
1027 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
1029 ap_handle_timer, hapd, sta);
1030 sta->timeout_next = STA_REMOVE;
1032 sta->deauth_reason = reason;
1033 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
1034 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
1037 ap_sta_deauth_cb_timeout, hapd, sta);
1041 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta)
1043 if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) {
1047 sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB;
1048 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
1049 ap_sta_deauth_cb_timeout(hapd, sta);
1053 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta)
1055 if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) {
1059 sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB;
1060 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
1061 ap_sta_disassoc_cb_timeout(hapd, sta);