Lines Matching refs:wpa_s
39 static void sme_stop_sa_query(struct wpa_supplicant *wpa_s);
56 static int sme_set_sae_group(struct wpa_supplicant *wpa_s)
58 int *groups = wpa_s->conf->sae_groups;
65 if (!index_within_array(groups, wpa_s->sme.sae_group_index))
69 int group = groups[wpa_s->sme.sae_group_index];
72 if (sae_set_group(&wpa_s->sme.sae, group) == 0) {
73 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected SAE group %d",
74 wpa_s->sme.sae.group);
77 wpa_s->sme.sae_group_index++;
84 static struct wpabuf * sme_auth_build_sae_commit(struct wpa_supplicant *wpa_s,
96 if (sme_set_sae_group(wpa_s) < 0) {
101 if (sae_prepare_commit(wpa_s->own_addr, bssid,
104 &wpa_s->sme.sae) < 0) {
109 len = wpa_s->sme.sae_token ? wpabuf_len(wpa_s->sme.sae_token) : 0;
116 sae_write_commit(&wpa_s->sme.sae, buf, wpa_s->sme.sae_token);
122 static struct wpabuf * sme_auth_build_sae_confirm(struct wpa_supplicant *wpa_s)
132 sae_write_confirm(&wpa_s->sme.sae, buf);
142 * @wpa_s: Pointer to wpa_supplicant data
145 static void sme_auth_handle_rrm(struct wpa_supplicant *wpa_s,
152 wpa_s->rrm.rrm_used = 0;
156 wpa_s->drv_rrm_flags);
164 if (!(wpa_s->drv_rrm_flags &
166 !(wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_QUIET)) {
172 if (sizeof(wpa_s->sme.assoc_req_ie) <
173 wpa_s->sme.assoc_req_ie_len + rrm_ie_len + 2) {
180 pos = wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len;
186 if (wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_TX_POWER_INSERTION)
189 wpa_s->sme.assoc_req_ie_len += rrm_ie_len + 2;
190 wpa_s->rrm.rrm_used = 1;
194 static void sme_send_authentication(struct wpa_supplicant *wpa_s,
216 wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for "
218 wpas_connect_work_done(wpa_s);
222 skip_auth = wpa_s->conf->reassoc_same_bss_optim &&
223 wpa_s->reassoc_same_bss;
224 wpa_s->current_bss = bss;
227 wpa_s->reassociate = 0;
235 if (wpa_s->sme.ssid_len != params.ssid_len ||
236 os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0)
237 wpa_s->sme.prev_bssid_set = 0;
239 wpa_s->sme.freq = params.freq;
240 os_memcpy(wpa_s->sme.ssid, params.ssid, params.ssid_len);
241 wpa_s->sme.ssid_len = params.ssid_len;
254 wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x",
258 wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: "
262 wpa_s->sme.sae_pmksa_caching = 0;
269 wpa_dbg(wpa_s, MSG_DEBUG,
273 wpa_dbg(wpa_s, MSG_DEBUG, "Using SAE auth_alg");
276 wpa_dbg(wpa_s, MSG_DEBUG,
289 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
290 os_memset(wpa_s->bssid, 0, ETH_ALEN);
291 os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
293 wpas_notify_bssid_changed(wpa_s);
300 wpa_s->conf->okc :
303 if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
304 wpa_s->current_ssid,
306 eapol_sm_notify_pmkid_attempt(wpa_s->eapol);
307 wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
308 if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
309 wpa_s->sme.assoc_req_ie,
310 &wpa_s->sme.assoc_req_ie_len)) {
311 wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
313 wpas_connect_work_done(wpa_s);
323 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
324 wpa_s->sme.assoc_req_ie_len = 0;
326 wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
327 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
328 wpa_s->sme.assoc_req_ie,
329 &wpa_s->sme.assoc_req_ie_len)) {
330 wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
333 wpas_connect_work_done(wpa_s);
341 sizeof(wpa_s->sme.assoc_req_ie)) {
342 wpa_s->sme.assoc_req_ie_len = wpabuf_len(wps_ie);
343 os_memcpy(wpa_s->sme.assoc_req_ie, wpabuf_head(wps_ie),
344 wpa_s->sme.assoc_req_ie_len);
346 wpa_s->sme.assoc_req_ie_len = 0;
348 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
351 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
352 wpa_s->sme.assoc_req_ie_len = 0;
359 wpa_sm_set_ft_params(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0);
362 wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
366 if (wpa_s->sme.assoc_req_ie_len + 5 <
367 sizeof(wpa_s->sme.assoc_req_ie)) {
369 u8 *pos = wpa_s->sme.assoc_req_ie +
370 wpa_s->sme.assoc_req_ie_len;
377 wpa_s->sme.assoc_req_ie_len += 5;
380 if (wpa_s->sme.ft_used &&
381 os_memcmp(md, wpa_s->sme.mobility_domain, 2) == 0 &&
382 wpa_sm_has_ptk(wpa_s->wpa)) {
383 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying to use FT "
386 params.ie = wpa_s->sme.ft_ies;
387 params.ie_len = wpa_s->sme.ft_ies_len;
393 wpa_s->sme.mfp = wpas_get_ssid_pmf(wpa_s, ssid);
394 if (wpa_s->sme.mfp != NO_MGMT_FRAME_PROTECTION) {
400 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected AP supports "
402 wpa_s->sme.mfp = MGMT_FRAME_PROTECTION_REQUIRED;
408 if (wpa_s->global->p2p) {
412 pos = wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len;
413 len = sizeof(wpa_s->sme.assoc_req_ie) -
414 wpa_s->sme.assoc_req_ie_len;
415 res = wpas_p2p_assoc_req_ie(wpa_s, bss, pos, len,
418 wpa_s->sme.assoc_req_ie_len += res;
423 if (wpa_s->fst_ies) {
424 int fst_ies_len = wpabuf_len(wpa_s->fst_ies);
426 if (wpa_s->sme.assoc_req_ie_len + fst_ies_len <=
427 sizeof(wpa_s->sme.assoc_req_ie)) {
428 os_memcpy(wpa_s->sme.assoc_req_ie +
429 wpa_s->sme.assoc_req_ie_len,
430 wpabuf_head(wpa_s->fst_ies),
432 wpa_s->sme.assoc_req_ie_len += fst_ies_len;
437 sme_auth_handle_rrm(wpa_s, bss);
445 wpa_s, bss->freq,
446 wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
447 sizeof(wpa_s->sme.assoc_req_ie) -
448 wpa_s->sme.assoc_req_ie_len);
450 wpa_s->sme.assoc_req_ie_len += len;
454 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
457 u8 *pos = wpa_s->sme.assoc_req_ie;
458 if (wpa_s->sme.assoc_req_ie_len > 0 && pos[0] == WLAN_EID_RSN)
461 wpa_s->sme.assoc_req_ie_len -
462 (pos - wpa_s->sme.assoc_req_ie));
463 wpa_s->sme.assoc_req_ie_len += ext_capab_len;
468 if (is_hs20_network(wpa_s, ssid, bss)) {
473 int pps_mo_id = hs20_get_pps_mo_id(wpa_s, ssid);
477 len = sizeof(wpa_s->sme.assoc_req_ie) -
478 wpa_s->sme.assoc_req_ie_len;
480 os_memcpy(wpa_s->sme.assoc_req_ie +
481 wpa_s->sme.assoc_req_ie_len,
483 wpa_s->sme.assoc_req_ie_len += wpabuf_len(hs20);
490 if (wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ]) {
491 struct wpabuf *buf = wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ];
494 len = sizeof(wpa_s->sme.assoc_req_ie) -
495 wpa_s->sme.assoc_req_ie_len;
497 os_memcpy(wpa_s->sme.assoc_req_ie +
498 wpa_s->sme.assoc_req_ie_len,
500 wpa_s->sme.assoc_req_ie_len += wpabuf_len(buf);
508 len = wpas_mbo_ie(wpa_s, wpa_s->sme.assoc_req_ie +
509 wpa_s->sme.assoc_req_ie_len,
510 sizeof(wpa_s->sme.assoc_req_ie) -
511 wpa_s->sme.assoc_req_ie_len);
513 wpa_s->sme.assoc_req_ie_len += len;
519 pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid, ssid, 0) == 0)
521 wpa_dbg(wpa_s, MSG_DEBUG,
524 wpa_s->sme.sae_pmksa_caching = 1;
529 resp = sme_auth_build_sae_commit(wpa_s, ssid,
532 resp = sme_auth_build_sae_confirm(wpa_s);
534 wpas_connection_failed(wpa_s, bss->bssid);
539 wpa_s->sme.sae.state = start ? SAE_COMMITTED : SAE_CONFIRMED;
543 wpa_supplicant_cancel_sched_scan(wpa_s);
544 wpa_supplicant_cancel_scan(wpa_s);
546 wpa_msg(wpa_s, MSG_INFO, "SME: Trying to authenticate with " MACSTR
550 wpa_clear_keys(wpa_s, bss->bssid);
551 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
552 old_ssid = wpa_s->current_ssid;
553 wpa_s->current_ssid = ssid;
554 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
555 wpa_supplicant_initiate_eapol(wpa_s);
556 if (old_ssid != wpa_s->current_ssid)
557 wpas_notify_network_changed(wpa_s);
565 if (wpa_s->num_multichan_concurrent < 2) {
567 num = get_shared_radio_freqs(wpa_s, &freq, 1);
572 if (wpas_p2p_handle_frequency_conflicts(wpa_s,
575 wpas_connection_failed(wpa_s, bss->bssid);
576 wpa_supplicant_mark_disassoc(wpa_s);
578 wpas_connect_work_done(wpa_s);
586 wpa_msg(wpa_s, MSG_DEBUG,
589 sme_associate(wpa_s, ssid->mode, bss->bssid, WLAN_AUTH_OPEN);
594 wpa_s->sme.auth_alg = params.auth_alg;
595 if (wpa_drv_authenticate(wpa_s, ¶ms) < 0) {
596 wpa_msg(wpa_s, MSG_INFO, "SME: Authentication request to the "
598 wpas_connection_failed(wpa_s, bss->bssid);
599 wpa_supplicant_mark_disassoc(wpa_s);
601 wpas_connect_work_done(wpa_s);
605 eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
620 struct wpa_supplicant *wpa_s = work->wpa_s;
624 wpa_s->connect_work = NULL;
630 wpa_s->connect_work = work;
633 !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid) ||
634 wpas_network_disabled(wpa_s, cwork->ssid)) {
635 wpa_dbg(wpa_s, MSG_DEBUG, "SME: BSS/SSID entry for authentication not valid anymore - drop connection attempt");
636 wpas_connect_work_done(wpa_s);
640 sme_send_authentication(wpa_s, cwork->bss, cwork->ssid, 1);
644 void sme_authenticate(struct wpa_supplicant *wpa_s,
651 if (wpa_s->connect_work) {
652 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reject sme_authenticate() call since connect_work exist");
656 if (radio_work_pending(wpa_s, "sme-connect")) {
662 wpa_dbg(wpa_s, MSG_DEBUG,
664 radio_remove_works(wpa_s, "sme-connect", 0);
667 wpas_abort_ongoing_scan(wpa_s);
677 wpa_s->sme.sae.state = SAE_NOTHING;
678 wpa_s->sme.sae.send_confirm = 0;
679 wpa_s->sme.sae_group_index = 0;
682 if (radio_add_work(wpa_s, bss->freq, "sme-connect", 1,
690 static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
695 wpa_dbg(wpa_s, MSG_DEBUG, "SME: SAE authentication transaction %u "
700 wpa_s->sme.sae.state == SAE_COMMITTED &&
701 wpa_s->current_bss && wpa_s->current_ssid) {
705 groups = wpa_s->conf->sae_groups;
710 wpa_dbg(wpa_s, MSG_DEBUG,
715 wpa_dbg(wpa_s, MSG_DEBUG,
718 if (sae_group_allowed(&wpa_s->sme.sae, groups, group) !=
720 wpa_dbg(wpa_s, MSG_ERROR,
725 wpabuf_free(wpa_s->sme.sae_token);
726 wpa_s->sme.sae_token = wpabuf_alloc_copy(data + sizeof(le16),
728 sme_send_authentication(wpa_s, wpa_s->current_bss,
729 wpa_s->current_ssid, 1);
735 wpa_s->sme.sae.state == SAE_COMMITTED &&
736 wpa_s->current_bss && wpa_s->current_ssid) {
737 wpa_dbg(wpa_s, MSG_DEBUG, "SME: SAE group not supported");
738 wpa_s->sme.sae_group_index++;
739 if (sme_set_sae_group(wpa_s) < 0)
741 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Try next enabled SAE group");
742 sme_send_authentication(wpa_s, wpa_s->current_bss,
743 wpa_s->current_ssid, 1);
753 groups = wpa_s->conf->sae_groups;
755 wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE commit");
756 if (wpa_s->current_bss == NULL ||
757 wpa_s->current_ssid == NULL)
759 if (wpa_s->sme.sae.state != SAE_COMMITTED)
763 res = sae_parse_commit(&wpa_s->sme.sae, data, len, NULL, NULL,
773 if (sae_process_commit(&wpa_s->sme.sae) < 0) {
779 wpabuf_free(wpa_s->sme.sae_token);
780 wpa_s->sme.sae_token = NULL;
781 sme_send_authentication(wpa_s, wpa_s->current_bss,
782 wpa_s->current_ssid, 0);
785 wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE confirm");
786 if (wpa_s->sme.sae.state != SAE_CONFIRMED)
788 if (sae_check_confirm(&wpa_s->sme.sae, data, len) < 0)
790 wpa_s->sme.sae.state = SAE_ACCEPTED;
791 sae_clear_temp_data(&wpa_s->sme.sae);
800 void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
802 struct wpa_ssid *ssid = wpa_s->current_ssid;
805 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
810 if (wpa_s->wpa_state != WPA_AUTHENTICATING) {
811 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
816 if (os_memcmp(wpa_s->pending_bssid, data->auth.peer, ETH_ALEN) != 0) {
817 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication with "
823 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication response: peer=" MACSTR
830 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
835 res = sme_sae_auth(wpa_s, data->auth.auth_transaction,
839 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
840 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
848 wpa_sm_set_pmk(wpa_s->wpa, wpa_s->sme.sae.pmk, PMK_LEN,
849 wpa_s->sme.sae.pmkid, wpa_s->pending_bssid);
864 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AUTH_REJECT MACSTR
873 wpa_s->sme.auth_alg == data->auth.auth_type ||
874 wpa_s->current_ssid->auth_alg == WPA_AUTH_ALG_LEAP) {
875 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
876 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
880 wpas_connect_work_done(wpa_s);
884 wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_SHARED;
886 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying SHARED auth");
887 wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
888 wpa_s->current_ssid);
892 wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_LEAP;
894 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying LEAP auth");
895 wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
896 wpa_s->current_ssid);
906 if (wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
909 wpa_dbg(wpa_s, MSG_DEBUG,
911 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
914 MAC2STR(wpa_s->pending_bssid),
916 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
917 wpa_supplicant_mark_disassoc(wpa_s);
923 sme_associate(wpa_s, ssid->mode, data->auth.peer,
928 void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
944 params.ssid = wpa_s->sme.ssid;
945 params.ssid_len = wpa_s->sme.ssid_len;
946 params.freq.freq = wpa_s->sme.freq;
947 params.bg_scan_period = wpa_s->current_ssid ?
948 wpa_s->current_ssid->bg_scan_period : -1;
949 params.wpa_ie = wpa_s->sme.assoc_req_ie_len ?
950 wpa_s->sme.assoc_req_ie : NULL;
951 params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len;
952 params.pairwise_suite = wpa_s->pairwise_cipher;
953 params.group_suite = wpa_s->group_cipher;
954 params.key_mgmt_suite = wpa_s->key_mgmt;
955 params.wpa_proto = wpa_s->wpa_proto;
961 wpa_supplicant_apply_ht_overrides(wpa_s, wpa_s->current_ssid, ¶ms);
968 wpa_supplicant_apply_vht_overrides(wpa_s, wpa_s->current_ssid, ¶ms);
971 if (auth_type == WLAN_AUTH_FT && wpa_s->sme.ft_ies) {
972 params.wpa_ie = wpa_s->sme.ft_ies;
973 params.wpa_ie_len = wpa_s->sme.ft_ies_len;
977 params.mgmt_frame_protection = wpa_s->sme.mfp;
978 params.rrm_used = wpa_s->rrm.rrm_used;
979 if (wpa_s->sme.prev_bssid_set)
980 params.prev_bssid = wpa_s->sme.prev_bssid;
982 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
987 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
992 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Could not parse own IEs?!");
997 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.rsn_ie - 2,
1001 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.wpa_ie - 2,
1005 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.osen - 2,
1008 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1009 if (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group)
1012 if (wpa_s->p2pdev->set_sta_uapsd)
1013 params.uapsd = wpa_s->p2pdev->sta_uapsd;
1017 if (wpa_drv_associate(wpa_s, ¶ms) < 0) {
1018 wpa_msg(wpa_s, MSG_INFO, "SME: Association request to the "
1020 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
1021 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1022 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1026 eloop_register_timeout(SME_ASSOC_TIMEOUT, 0, sme_assoc_timer, wpa_s,
1031 int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
1035 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Remove mobility domain");
1036 os_free(wpa_s->sme.ft_ies);
1037 wpa_s->sme.ft_ies = NULL;
1038 wpa_s->sme.ft_ies_len = 0;
1039 wpa_s->sme.ft_used = 0;
1043 os_memcpy(wpa_s->sme.mobility_domain, md, MOBILITY_DOMAIN_ID_LEN);
1045 os_free(wpa_s->sme.ft_ies);
1046 wpa_s->sme.ft_ies = os_malloc(ies_len);
1047 if (wpa_s->sme.ft_ies == NULL)
1049 os_memcpy(wpa_s->sme.ft_ies, ies, ies_len);
1050 wpa_s->sme.ft_ies_len = ies_len;
1055 static void sme_deauth(struct wpa_supplicant *wpa_s)
1059 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
1061 if (wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid,
1063 wpa_msg(wpa_s, MSG_INFO, "SME: Deauth request to the driver "
1066 wpa_s->sme.prev_bssid_set = 0;
1068 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
1069 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1070 os_memset(wpa_s->bssid, 0, ETH_ALEN);
1071 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1073 wpas_notify_bssid_changed(wpa_s);
1077 void sme_event_assoc_reject(struct wpa_supplicant *wpa_s,
1080 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association with " MACSTR " failed: "
1081 "status code %d", MAC2STR(wpa_s->pending_bssid),
1084 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
1087 if (wpa_s->sme.sae_pmksa_caching && wpa_s->current_ssid &&
1088 wpa_key_mgmt_sae(wpa_s->current_ssid->key_mgmt)) {
1089 wpa_dbg(wpa_s, MSG_DEBUG,
1091 wpa_sm_aborted_cached(wpa_s->wpa);
1092 wpa_sm_pmksa_cache_flush(wpa_s->wpa, wpa_s->current_ssid);
1093 if (wpa_s->current_bss) {
1094 struct wpa_bss *bss = wpa_s->current_bss;
1095 struct wpa_ssid *ssid = wpa_s->current_ssid;
1097 wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid,
1099 wpas_connect_work_done(wpa_s);
1100 wpa_supplicant_mark_disassoc(wpa_s);
1101 wpa_supplicant_connect(wpa_s, bss, ssid);
1114 sme_deauth(wpa_s);
1118 void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s,
1121 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication timed out");
1122 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
1123 wpa_supplicant_mark_disassoc(wpa_s);
1127 void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
1130 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association timed out");
1131 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
1132 wpa_s);
1136 void sme_event_disassoc(struct wpa_supplicant *wpa_s,
1139 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Disassociation event received");
1140 if (wpa_s->sme.prev_bssid_set) {
1147 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Deauthenticate to clear "
1149 wpa_drv_deauthenticate(wpa_s, wpa_s->sme.prev_bssid,
1157 struct wpa_supplicant *wpa_s = eloop_ctx;
1158 if (wpa_s->wpa_state == WPA_AUTHENTICATING) {
1159 wpa_msg(wpa_s, MSG_DEBUG, "SME: Authentication timeout");
1160 sme_deauth(wpa_s);
1167 struct wpa_supplicant *wpa_s = eloop_ctx;
1168 if (wpa_s->wpa_state == WPA_ASSOCIATING) {
1169 wpa_msg(wpa_s, MSG_DEBUG, "SME: Association timeout");
1170 sme_deauth(wpa_s);
1175 void sme_state_changed(struct wpa_supplicant *wpa_s)
1178 if (wpa_s->wpa_state != WPA_ASSOCIATING)
1179 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
1180 if (wpa_s->wpa_state != WPA_AUTHENTICATING)
1181 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
1185 void sme_disassoc_while_authenticating(struct wpa_supplicant *wpa_s,
1193 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Allow pending authentication "
1195 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
1196 os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN);
1201 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
1202 eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
1207 void sme_clear_on_disassoc(struct wpa_supplicant *wpa_s)
1209 wpa_s->sme.prev_bssid_set = 0;
1211 wpabuf_free(wpa_s->sme.sae_token);
1212 wpa_s->sme.sae_token = NULL;
1213 sae_clear_data(&wpa_s->sme.sae);
1216 if (wpa_s->sme.ft_ies)
1217 sme_update_ft_ies(wpa_s, NULL, NULL, 0);
1222 void sme_deinit(struct wpa_supplicant *wpa_s)
1224 os_free(wpa_s->sme.ft_ies);
1225 wpa_s->sme.ft_ies = NULL;
1226 wpa_s->sme.ft_ies_len = 0;
1228 sme_stop_sa_query(wpa_s);
1230 sme_clear_on_disassoc(wpa_s);
1232 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
1233 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
1234 eloop_cancel_timeout(sme_obss_scan_timeout, wpa_s, NULL);
1238 static void sme_send_2040_bss_coex(struct wpa_supplicant *wpa_s,
1248 MAC2STR(wpa_s->bssid), num_channels, num_intol);
1277 if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
1278 wpa_s->own_addr, wpa_s->bssid,
1280 wpa_msg(wpa_s, MSG_INFO,
1288 int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
1296 if (!wpa_s->sme.sched_obss_scan)
1299 wpa_s->sme.sched_obss_scan = 0;
1300 if (!wpa_s->current_bss || wpa_s->wpa_state != WPA_COMPLETED)
1316 ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_COUNTRY);
1322 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1352 sme_send_2040_bss_coex(wpa_s, chan_list, num_channels, num_intol);
1357 static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s,
1365 mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
1373 if (wpa_s->sme.ht_sec_chan == HT_SEC_CHAN_UNKNOWN &&
1374 wpa_s->current_bss) {
1377 ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_HT_OPERATION);
1383 wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_ABOVE;
1385 wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_BELOW;
1389 start = wpa_s->assoc_freq - 10;
1390 end = wpa_s->assoc_freq + 10;
1391 switch (wpa_s->sme.ht_sec_chan) {
1394 if (wpa_s->assoc_freq <= 2452)
1397 if (wpa_s->assoc_freq >= 2432)
1409 wpa_s->assoc_freq, start, end);
1429 struct wpa_supplicant *wpa_s = eloop_ctx;
1432 if (!wpa_s->current_bss) {
1438 wpa_obss_scan_freqs_list(wpa_s, ¶ms);
1442 if (wpa_supplicant_trigger_scan(wpa_s, ¶ms))
1445 wpa_s->sme.sched_obss_scan = 1;
1448 eloop_register_timeout(wpa_s->sme.obss_scan_int, 0,
1449 sme_obss_scan_timeout, wpa_s, NULL);
1453 void sme_sched_obss_scan(struct wpa_supplicant *wpa_s, int enable)
1456 struct wpa_bss *bss = wpa_s->current_bss;
1457 struct wpa_ssid *ssid = wpa_s->current_ssid;
1461 eloop_cancel_timeout(sme_obss_scan_timeout, wpa_s, NULL);
1462 wpa_s->sme.sched_obss_scan = 0;
1463 wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_UNKNOWN;
1471 if (!((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) ||
1472 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OBSS_SCAN)) ||
1476 if (!wpa_s->hw.modes)
1480 for (i = 0; i < wpa_s->hw.num_modes; i++) {
1481 hw_mode = &wpa_s->hw.modes[i];
1487 if (i == wpa_s->hw.num_modes || !hw_mode ||
1495 ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_HT_CAP);
1500 ie = wpa_bss_get_ie(wpa_s->current_bss,
1505 wpa_s->sme.obss_scan_int = WPA_GET_LE16(ie + 6);
1506 if (wpa_s->sme.obss_scan_int < 10) {
1509 wpa_s->sme.obss_scan_int);
1510 wpa_s->sme.obss_scan_int = 10;
1513 wpa_s->sme.obss_scan_int);
1514 eloop_register_timeout(wpa_s->sme.obss_scan_int, 0,
1515 sme_obss_scan_timeout, wpa_s, NULL);
1524 static int sme_check_sa_query_timeout(struct wpa_supplicant *wpa_s)
1529 os_reltime_sub(&now, &wpa_s->sme.sa_query_start, &passed);
1532 wpa_dbg(wpa_s, MSG_DEBUG, "SME: SA Query timed out");
1533 sme_stop_sa_query(wpa_s);
1535 wpa_s, WLAN_REASON_PREV_AUTH_NOT_VALID);
1543 static void sme_send_sa_query_req(struct wpa_supplicant *wpa_s,
1547 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Sending SA Query Request to "
1548 MACSTR, MAC2STR(wpa_s->bssid));
1554 if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
1555 wpa_s->own_addr, wpa_s->bssid,
1557 wpa_msg(wpa_s, MSG_INFO, "SME: Failed to send SA Query "
1564 struct wpa_supplicant *wpa_s = eloop_ctx;
1568 if (wpa_s->sme.sa_query_count > 0 &&
1569 sme_check_sa_query_timeout(wpa_s))
1572 nbuf = os_realloc_array(wpa_s->sme.sa_query_trans_id,
1573 wpa_s->sme.sa_query_count + 1,
1577 if (wpa_s->sme.sa_query_count == 0) {
1579 os_get_reltime(&wpa_s->sme.sa_query_start);
1581 trans_id = nbuf + wpa_s->sme.sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
1582 wpa_s->sme.sa_query_trans_id = nbuf;
1583 wpa_s->sme.sa_query_count++;
1593 eloop_register_timeout(sec, usec, sme_sa_query_timer, wpa_s, NULL);
1595 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association SA Query attempt %d",
1596 wpa_s->sme.sa_query_count);
1598 sme_send_sa_query_req(wpa_s, trans_id);
1602 static void sme_start_sa_query(struct wpa_supplicant *wpa_s)
1604 sme_sa_query_timer(wpa_s, NULL);
1608 static void sme_stop_sa_query(struct wpa_supplicant *wpa_s)
1610 eloop_cancel_timeout(sme_sa_query_timer, wpa_s, NULL);
1611 os_free(wpa_s->sme.sa_query_trans_id);
1612 wpa_s->sme.sa_query_trans_id = NULL;
1613 wpa_s->sme.sa_query_count = 0;
1617 void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa,
1623 if (wpa_s->wpa_state != WPA_COMPLETED)
1625 ssid = wpa_s->current_ssid;
1626 if (wpas_get_ssid_pmf(wpa_s, ssid) == NO_MGMT_FRAME_PROTECTION)
1628 if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
1633 if (wpa_s->sme.sa_query_count > 0)
1637 if (wpa_s->sme.last_unprot_disconnect.sec &&
1638 !os_reltime_expired(&now, &wpa_s->sme.last_unprot_disconnect, 10))
1640 wpa_s->sme.last_unprot_disconnect = now;
1642 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Unprotected disconnect dropped - "
1644 sme_start_sa_query(wpa_s);
1648 void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa,
1653 if (wpa_s->sme.sa_query_trans_id == NULL ||
1657 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Received SA Query response from "
1660 if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
1663 for (i = 0; i < wpa_s->sme.sa_query_count; i++) {
1664 if (os_memcmp(wpa_s->sme.sa_query_trans_id +
1670 if (i >= wpa_s->sme.sa_query_count) {
1671 wpa_dbg(wpa_s, MSG_DEBUG, "SME: No matching SA Query "
1676 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reply to pending SA Query received "
1678 sme_stop_sa_query(wpa_s);