Lines Matching refs:sta

36 				       struct sta_info *sta);
43 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta);
46 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
50 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)
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)];
105 if (os_memcmp(s->addr, sta->addr, 6) == 0) {
106 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
111 os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
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);
139 if (sta->aid > 0)
140 hapd->sta_aid[(sta->aid - 1) / 32] &=
141 ~BIT((sta->aid - 1) % 32);
144 if (sta->nonerp_set) {
145 sta->nonerp_set = 0;
151 if (sta->no_short_slot_time_set) {
152 sta->no_short_slot_time_set = 0;
159 if (sta->no_short_preamble_set) {
160 sta->no_short_preamble_set = 0;
167 if (sta->no_ht_gf_set) {
168 sta->no_ht_gf_set = 0;
172 if (sta->no_ht_set) {
173 sta->no_ht_set = 0;
177 if (sta->ht_20mhz_set) {
178 sta->ht_20mhz_set = 0;
183 if (sta->no_p2p_set) {
184 sta->no_p2p_set = 0;
200 __func__, MAC2STR(sta->addr));
201 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
202 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
203 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
204 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
206 ieee802_1x_free_station(sta);
207 wpa_auth_sta_deinit(sta->wpa_sm);
208 rsn_preauth_free_station(hapd, sta);
210 radius_client_flush_auth(hapd->radius, sta->addr);
213 os_free(sta->last_assoc_req);
214 os_free(sta->challenge);
217 os_free(sta->sa_query_trans_id);
218 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
222 p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
226 if (sta->gas_dialog) {
229 gas_serv_dialog_clear(&sta->gas_dialog[i]);
230 os_free(sta->gas_dialog);
234 wpabuf_free(sta->wps_ie);
235 wpabuf_free(sta->p2p_ie);
236 wpabuf_free(sta->hs20_ie);
238 os_free(sta->ht_capabilities);
239 hostapd_free_psk_list(sta->psk);
240 os_free(sta->identity);
241 os_free(sta->radius_cui);
243 os_free(sta);
249 struct sta_info *sta, *prev;
251 sta = hapd->sta_list;
253 while (sta) {
254 prev = sta;
255 if (sta->flags & WLAN_STA_AUTH) {
257 hapd, sta, WLAN_REASON_UNSPECIFIED);
259 sta = sta->next;
278 struct sta_info *sta = timeout_ctx;
282 __func__, MAC2STR(sta->addr), sta->flags,
283 sta->timeout_next);
284 if (sta->timeout_next == STA_REMOVE) {
285 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
288 ap_free_sta(hapd, sta);
292 if ((sta->flags & WLAN_STA_ASSOC) &&
293 (sta->timeout_next == STA_NULLFUNC ||
294 sta->timeout_next == STA_DISASSOC)) {
302 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
307 MACSTR, MAC2STR(sta->addr));
315 sta->flags & WLAN_STA_ASSOC) {
319 MAC2STR(sta->addr), inactive_sec);
320 sta->timeout_next = STA_NULLFUNC;
327 MAC2STR(sta->addr), inactive_sec,
331 sta->timeout_next = STA_DISASSOC;
335 if ((sta->flags & WLAN_STA_ASSOC) &&
336 sta->timeout_next == STA_DISASSOC &&
337 !(sta->flags & WLAN_STA_PENDING_POLL) &&
340 " has ACKed data poll", MAC2STR(sta->addr));
343 sta->timeout_next = STA_NULLFUNC;
350 __func__, MAC2STR(sta->addr), next_time);
352 sta);
356 if (sta->timeout_next == STA_NULLFUNC &&
357 (sta->flags & WLAN_STA_ASSOC)) {
359 sta->flags |= WLAN_STA_PENDING_POLL;
360 hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr,
361 sta->flags & WLAN_STA_WMM);
362 } else if (sta->timeout_next != STA_REMOVE) {
363 int deauth = sta->timeout_next == STA_DEAUTH;
368 MAC2STR(sta->addr));
372 hapd, sta->addr,
376 hapd, sta->addr,
381 switch (sta->timeout_next) {
383 sta->timeout_next = STA_DISASSOC;
386 __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY);
388 hapd, sta);
391 ap_sta_set_authorized(hapd, sta, 0);
392 sta->flags &= ~WLAN_STA_ASSOC;
393 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
394 if (!sta->acct_terminate_cause)
395 sta->acct_terminate_cause =
397 accounting_sta_stop(hapd, sta);
398 ieee802_1x_free_station(sta);
399 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
402 sta->timeout_next = STA_DEAUTH;
405 __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY);
407 hapd, sta);
409 hapd, sta, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
413 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
416 if (!sta->acct_terminate_cause)
417 sta->acct_terminate_cause =
420 hapd, sta,
422 ap_free_sta(hapd, sta);
431 struct sta_info *sta = timeout_ctx;
434 if (!(sta->flags & WLAN_STA_AUTH)) {
435 if (sta->flags & WLAN_STA_GAS) {
437 "entry " MACSTR, MAC2STR(sta->addr));
438 ap_free_sta(hapd, sta);
443 mlme_deauthenticate_indication(hapd, sta,
445 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
448 sta->acct_terminate_cause =
450 os_memcpy(addr, sta->addr, ETH_ALEN);
451 ap_free_sta(hapd, sta);
456 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
459 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
462 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
464 hapd, sta);
468 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
470 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
476 struct sta_info *sta;
478 sta = ap_get_sta(hapd, addr);
479 if (sta)
480 return sta;
490 sta = os_zalloc(sizeof(struct sta_info));
491 if (sta == NULL) {
495 sta->acct_interim_interval = hapd->conf->acct_interim_interval;
496 accounting_sta_get_id(hapd, sta);
504 ap_handle_timer, hapd, sta);
505 os_memcpy(sta->addr, addr, ETH_ALEN);
506 sta->next = hapd->sta_list;
507 hapd->sta_list = sta;
509 ap_sta_hash_add(hapd, sta);
510 sta->ssid = &hapd->conf->ssid;
511 ap_sta_remove_in_other_bss(hapd, sta);
513 return sta;
517 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
519 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
522 MAC2STR(sta->addr));
523 if (hostapd_drv_sta_remove(hapd, sta->addr) &&
524 sta->flags & WLAN_STA_ASSOC) {
526 " from kernel driver.", MAC2STR(sta->addr));
534 struct sta_info *sta)
548 sta2 = ap_get_sta(bss, sta->addr);
561 struct sta_info *sta = timeout_ctx;
563 ap_sta_remove(hapd, sta);
564 mlme_disassociate_indication(hapd, sta, sta->disassoc_reason);
568 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
572 hapd->conf->iface, MAC2STR(sta->addr));
573 sta->flags &= ~WLAN_STA_ASSOC;
574 ap_sta_set_authorized(hapd, sta, 0);
575 sta->timeout_next = STA_DEAUTH;
579 __func__, MAC2STR(sta->addr),
581 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
583 ap_handle_timer, hapd, sta);
584 accounting_sta_stop(hapd, sta);
585 ieee802_1x_free_station(sta);
587 sta->disassoc_reason = reason;
588 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
589 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
592 ap_sta_disassoc_cb_timeout, hapd, sta);
599 struct sta_info *sta = timeout_ctx;
601 ap_sta_remove(hapd, sta);
602 mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason);
606 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
610 hapd->conf->iface, MAC2STR(sta->addr));
611 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
612 ap_sta_set_authorized(hapd, sta, 0);
613 sta->timeout_next = STA_REMOVE;
617 __func__, MAC2STR(sta->addr),
619 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
621 ap_handle_timer, hapd, sta);
622 accounting_sta_stop(hapd, sta);
623 ieee802_1x_free_station(sta);
625 sta->deauth_reason = reason;
626 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
627 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
630 ap_sta_deauth_cb_timeout, hapd, sta);
636 struct sta_info *sta, void *ctx)
638 if (sta && (sta->flags & WLAN_STA_WPS)) {
639 ap_sta_deauthenticate(hapd, sta,
641 wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR,
642 __func__, MAC2STR(sta->addr));
651 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
663 if (sta->vlan_id == old_vlanid)
674 if (sta->ssid->vlan[0])
675 iface = sta->ssid->vlan;
677 if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
678 sta->vlan_id = 0;
679 else if (sta->vlan_id > 0) {
682 if (vlan->vlan_id == sta->vlan_id ||
691 if (sta->vlan_id > 0 && vlan == NULL) {
692 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
695 sta->vlan_id);
697 } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
698 vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
700 hostapd_logger(hapd, sta->addr,
704 sta->vlan_id);
709 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
710 hostapd_logger(hapd, sta->addr,
715 sta->vlan_id);
718 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
721 } else if (vlan && vlan->vlan_id == sta->vlan_id) {
722 if (sta->vlan_id > 0) {
724 hostapd_logger(hapd, sta->addr,
736 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
737 hostapd_logger(hapd, sta->addr,
742 sta->vlan_id);
746 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
750 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
753 ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
755 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
757 "entry to vlan_id=%d", sta->vlan_id);
768 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
773 os_time_sub(&now, &sta->sa_query_start, &passed);
776 hostapd_logger(hapd, sta->addr,
780 sta->sa_query_timed_out = 1;
781 os_free(sta->sa_query_trans_id);
782 sta->sa_query_trans_id = NULL;
783 sta->sa_query_count = 0;
784 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
795 struct sta_info *sta = timeout_ctx;
799 if (sta->sa_query_count > 0 &&
800 ap_check_sa_query_timeout(hapd, sta))
803 nbuf = os_realloc_array(sta->sa_query_trans_id,
804 sta->sa_query_count + 1,
808 if (sta->sa_query_count == 0) {
810 os_get_time(&sta->sa_query_start);
812 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
813 sta->sa_query_trans_id = nbuf;
814 sta->sa_query_count++;
821 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
823 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
825 "association SA Query attempt %d", sta->sa_query_count);
827 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
831 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
833 ap_sa_query_timer(hapd, sta);
837 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
839 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
840 os_free(sta->sa_query_trans_id);
841 sta->sa_query_trans_id = NULL;
842 sta->sa_query_count = 0;
848 void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
856 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
861 if (sta->p2p_ie != NULL &&
862 p2p_parse_dev_addr_in_p2p_ie(sta->p2p_ie, addr) == 0)
865 dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr);
872 MAC2STR(sta->addr), MAC2STR(dev_addr));
875 MACSTR, MAC2STR(sta->addr));
881 MAC2STR(sta->addr), MAC2STR(dev_addr));
885 AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
887 sta->flags |= WLAN_STA_AUTHORIZED;
892 MAC2STR(sta->addr), MAC2STR(dev_addr));
895 MACSTR, MAC2STR(sta->addr));
900 MACSTR, MAC2STR(sta->addr), MAC2STR(dev_addr));
905 MAC2STR(sta->addr));
906 sta->flags &= ~WLAN_STA_AUTHORIZED;
911 sta->addr, authorized, dev_addr);
915 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
919 if (sta == NULL && addr)
920 sta = ap_get_sta(hapd, addr);
925 if (sta == NULL)
927 ap_sta_set_authorized(hapd, sta, 0);
928 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
929 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
930 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
934 __func__, MAC2STR(sta->addr),
936 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
938 ap_handle_timer, hapd, sta);
939 sta->timeout_next = STA_REMOVE;
941 sta->deauth_reason = reason;
942 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
943 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
946 ap_sta_deauth_cb_timeout, hapd, sta);
950 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta)
952 if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) {
956 sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB;
957 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
958 ap_sta_deauth_cb_timeout(hapd, sta);
962 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta)
964 if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) {
968 sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB;
969 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
970 ap_sta_disassoc_cb_timeout(hapd, sta);