Home | History | Annotate | Download | only in ap

Lines Matching defs:sta

34 				       struct sta_info *sta);
41 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta);
44 int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
48 struct sta_info *sta;
50 for (sta = hapd->sta_list; sta; sta = sta->next) {
51 if (cb(hapd, sta, ctx))
59 struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
63 s = hapd->sta_hash[STA_HASH(sta)];
64 while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
70 static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
74 if (hapd->sta_list == sta) {
75 hapd->sta_list = sta->next;
80 while (tmp != NULL && tmp->next != sta)
83 wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from "
84 "list.", MAC2STR(sta->addr));
86 tmp->next = sta->next;
90 void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta)
92 sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
93 hapd->sta_hash[STA_HASH(sta->addr)] = sta;
97 static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
101 s = hapd->sta_hash[STA_HASH(sta->addr)];
103 if (os_memcmp(s->addr, sta->addr, 6) == 0) {
104 hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
109 os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
114 wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
115 " from hash table", MAC2STR(sta->addr));
119 void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
123 accounting_sta_stop(hapd, sta);
126 ap_sta_set_authorized(hapd, sta, 0);
128 if (sta->flags & WLAN_STA_WDS)
129 hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0);
131 if (!(sta->flags & WLAN_STA_PREAUTH))
132 hostapd_drv_sta_remove(hapd, sta->addr);
134 ap_sta_hash_del(hapd, sta);
135 ap_sta_list_del(hapd, sta);
137 if (sta->aid > 0)
138 hapd->sta_aid[(sta->aid - 1) / 32] &=
139 ~BIT((sta->aid - 1) % 32);
142 if (sta->nonerp_set) {
143 sta->nonerp_set = 0;
149 if (sta->no_short_slot_time_set) {
150 sta->no_short_slot_time_set = 0;
157 if (sta->no_short_preamble_set) {
158 sta->no_short_preamble_set = 0;
165 if (sta->no_ht_gf_set) {
166 sta->no_ht_gf_set = 0;
170 if (sta->no_ht_set) {
171 sta->no_ht_set = 0;
175 if (sta->ht_20mhz_set) {
176 sta->ht_20mhz_set = 0;
181 if (sta->no_p2p_set) {
182 sta->no_p2p_set = 0;
197 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
198 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
199 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
200 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
202 ieee802_1x_free_station(sta);
203 wpa_auth_sta_deinit(sta->wpa_sm);
204 rsn_preauth_free_station(hapd, sta);
206 radius_client_flush_auth(hapd->radius, sta->addr);
209 os_free(sta->last_assoc_req);
210 os_free(sta->challenge);
213 os_free(sta->sa_query_trans_id);
214 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
218 p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
221 wpabuf_free(sta->wps_ie);
222 wpabuf_free(sta->p2p_ie);
224 os_free(sta->ht_capabilities);
225 os_free(sta->psk);
227 os_free(sta);
233 struct sta_info *sta, *prev;
235 sta = hapd->sta_list;
237 while (sta) {
238 prev = sta;
239 if (sta->flags & WLAN_STA_AUTH) {
241 hapd, sta, WLAN_REASON_UNSPECIFIED);
243 sta = sta->next;
252 * ap_handle_timer - Per STA timer handler
262 struct sta_info *sta = timeout_ctx;
265 if (sta->timeout_next == STA_REMOVE) {
266 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
269 ap_free_sta(hapd, sta);
273 if ((sta->flags & WLAN_STA_ASSOC) &&
274 (sta->timeout_next == STA_NULLFUNC ||
275 sta->timeout_next == STA_DISASSOC)) {
277 inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
282 MACSTR, MAC2STR(sta->addr));
290 sta->flags & WLAN_STA_ASSOC) {
294 MAC2STR(sta->addr), inactive_sec);
295 sta->timeout_next = STA_NULLFUNC;
302 MAC2STR(sta->addr), inactive_sec,
306 sta->timeout_next = STA_DISASSOC;
310 if ((sta->flags & WLAN_STA_ASSOC) &&
311 sta->timeout_next == STA_DISASSOC &&
312 !(sta->flags & WLAN_STA_PENDING_POLL) &&
315 " has ACKed data poll", MAC2STR(sta->addr));
318 sta->timeout_next = STA_NULLFUNC;
324 sta);
328 if (sta->timeout_next == STA_NULLFUNC &&
329 (sta->flags & WLAN_STA_ASSOC)) {
330 wpa_printf(MSG_DEBUG, " Polling STA");
331 sta->flags |= WLAN_STA_PENDING_POLL;
332 hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr,
333 sta->flags & WLAN_STA_WMM);
334 } else if (sta->timeout_next != STA_REMOVE) {
335 int deauth = sta->timeout_next == STA_DEAUTH;
338 "Timeout, sending %s info to STA " MACSTR,
340 MAC2STR(sta->addr));
344 hapd, sta->addr,
348 hapd, sta->addr,
353 switch (sta->timeout_next) {
355 sta->timeout_next = STA_DISASSOC;
357 hapd, sta);
360 ap_sta_set_authorized(hapd, sta, 0);
361 sta->flags &= ~WLAN_STA_ASSOC;
362 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
363 if (!sta->acct_terminate_cause)
364 sta->acct_terminate_cause =
366 accounting_sta_stop(hapd, sta);
367 ieee802_1x_free_station(sta);
368 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
371 sta->timeout_next = STA_DEAUTH;
373 hapd, sta);
375 hapd, sta, WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
379 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
382 if (!sta->acct_terminate_cause)
383 sta->acct_terminate_cause =
386 hapd, sta,
388 ap_free_sta(hapd, sta);
397 struct sta_info *sta = timeout_ctx;
400 if (!(sta->flags & WLAN_STA_AUTH))
403 mlme_deauthenticate_indication(hapd, sta,
405 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
408 sta->acct_terminate_cause =
410 os_memcpy(addr, sta->addr, ETH_ALEN);
411 ap_free_sta(hapd, sta);
416 void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
419 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
422 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
424 hapd, sta);
428 void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
430 eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
436 struct sta_info *sta;
438 sta = ap_get_sta(hapd, addr);
439 if (sta)
440 return sta;
442 wpa_printf(MSG_DEBUG, " New STA");
450 sta = os_zalloc(sizeof(struct sta_info));
451 if (sta == NULL) {
455 sta->acct_interim_interval = hapd->conf->acct_interim_interval;
457 /* initialize STA info data */
459 ap_handle_timer, hapd, sta);
460 os_memcpy(sta->addr, addr, ETH_ALEN);
461 sta->next = hapd->sta_list;
462 hapd->sta_list = sta;
464 ap_sta_hash_add(hapd, sta);
465 sta->ssid = &hapd->conf->ssid;
466 ap_sta_remove_in_other_bss(hapd, sta);
468 return sta;
472 static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
474 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
476 wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
477 MAC2STR(sta->addr));
478 if (hostapd_drv_sta_remove(hapd, sta->addr) &&
479 sta->flags & WLAN_STA_ASSOC) {
481 " from kernel driver.", MAC2STR(sta->addr));
489 struct sta_info *sta)
498 * NULL during reconfiguration. Assume the STA is not
503 sta2 = ap_get_sta(bss, sta->addr);
516 struct sta_info *sta = timeout_ctx;
518 ap_sta_remove(hapd, sta);
519 mlme_disassociate_indication(hapd, sta, sta->disassoc_reason);
523 void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
526 wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
527 hapd->conf->iface, MAC2STR(sta->addr));
528 sta->flags &= ~WLAN_STA_ASSOC;
529 ap_sta_set_authorized(hapd, sta, 0);
530 sta->timeout_next = STA_DEAUTH;
531 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
533 ap_handle_timer, hapd, sta);
534 accounting_sta_stop(hapd, sta);
535 ieee802_1x_free_station(sta);
537 sta->disassoc_reason = reason;
538 sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
539 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
542 ap_sta_disassoc_cb_timeout, hapd, sta);
549 struct sta_info *sta = timeout_ctx;
551 ap_sta_remove(hapd, sta);
552 mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason);
556 void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
559 wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
560 hapd->conf->iface, MAC2STR(sta->addr));
561 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
562 ap_sta_set_authorized(hapd, sta, 0);
563 sta->timeout_next = STA_REMOVE;
564 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
566 ap_handle_timer, hapd, sta);
567 accounting_sta_stop(hapd, sta);
568 ieee802_1x_free_station(sta);
570 sta->deauth_reason = reason;
571 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
572 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
575 ap_sta_deauth_cb_timeout, hapd, sta);
579 int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
591 if (sta->vlan_id == old_vlanid)
602 if (sta->ssid->vlan[0])
603 iface = sta->ssid->vlan;
605 if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
606 sta->vlan_id = 0;
607 else if (sta->vlan_id > 0) {
610 if (vlan->vlan_id == sta->vlan_id ||
619 if (sta->vlan_id > 0 && vlan == NULL) {
620 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
623 sta->vlan_id);
625 } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
626 vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
628 hostapd_logger(hapd, sta->addr,
632 sta->vlan_id);
637 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
638 hostapd_logger(hapd, sta->addr,
643 sta->vlan_id);
646 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
649 } else if (vlan && vlan->vlan_id == sta->vlan_id) {
650 if (sta->vlan_id > 0) {
652 hostapd_logger(hapd, sta->addr,
664 if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
665 hostapd_logger(hapd, sta->addr,
670 sta->vlan_id);
674 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
678 if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
681 ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
683 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
684 HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
685 "entry to vlan_id=%d", sta->vlan_id);
696 int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
701 os_time_sub(&now, &sta->sa_query_start, &passed);
704 hostapd_logger(hapd, sta->addr,
708 sta->sa_query_timed_out = 1;
709 os_free(sta->sa_query_trans_id);
710 sta->sa_query_trans_id = NULL;
711 sta->sa_query_count = 0;
712 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
723 struct sta_info *sta = timeout_ctx;
727 if (sta->sa_query_count > 0 &&
728 ap_check_sa_query_timeout(hapd, sta))
731 nbuf = os_realloc(sta->sa_query_trans_id,
732 (sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
735 if (sta->sa_query_count == 0) {
737 os_get_time(&sta->sa_query_start);
739 trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
740 sta->sa_query_trans_id = nbuf;
741 sta->sa_query_count++;
748 eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
750 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
752 "association SA Query attempt %d", sta->sa_query_count);
755 ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
760 void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
762 ap_sa_query_timer(hapd, sta);
766 void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
768 eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
769 os_free(sta->sa_query_trans_id);
770 sta->sa_query_trans_id = NULL;
771 sta->sa_query_count = 0;
777 void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
781 if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
785 dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr);
792 MAC2STR(sta->addr), MAC2STR(dev_addr));
795 MACSTR, MAC2STR(sta->addr));
801 MAC2STR(sta->addr), MAC2STR(dev_addr));
805 AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
807 sta->flags |= WLAN_STA_AUTHORIZED;
812 MAC2STR(sta->addr), MAC2STR(dev_addr));
815 MACSTR, MAC2STR(sta->addr));
820 MACSTR, MAC2STR(sta->addr), MAC2STR(dev_addr));
825 MAC2STR(sta->addr));
826 sta->flags &= ~WLAN_STA_AUTHORIZED;
831 sta->addr, authorized, dev_addr);
835 void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
839 if (sta == NULL && addr)
840 sta = ap_get_sta(hapd, addr);
845 if (sta == NULL)
847 ap_sta_set_authorized(hapd, sta, 0);
848 wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
849 ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
850 sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
851 eloop_cancel_timeout(ap_handle_timer, hapd, sta);
853 ap_handle_timer, hapd, sta);
854 sta->timeout_next = STA_REMOVE;
856 sta->deauth_reason = reason;
857 sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
858 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
861 ap_sta_deauth_cb_timeout, hapd, sta);
865 void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta)
867 if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) {
871 sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB;
872 eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
873 ap_sta_deauth_cb_timeout(hapd, sta);
877 void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta)
879 if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) {
883 sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB;
884 eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
885 ap_sta_disassoc_cb_timeout(hapd, sta);