Lines Matching refs:wpa_s
36 static void sme_stop_sa_query(struct wpa_supplicant *wpa_s);
40 void sme_authenticate(struct wpa_supplicant *wpa_s,
54 wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for "
59 wpa_s->current_bss = bss;
62 wpa_s->reassociate = 0;
70 if (wpa_s->sme.ssid_len != params.ssid_len ||
71 os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0)
72 wpa_s->sme.prev_bssid_set = 0;
74 wpa_s->sme.freq = params.freq;
75 os_memcpy(wpa_s->sme.ssid, params.ssid, params.ssid_len);
76 wpa_s->sme.ssid_len = params.ssid_len;
89 wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x",
93 wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: "
104 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
105 os_memset(wpa_s->bssid, 0, ETH_ALEN);
106 os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
108 wpas_notify_bssid_changed(wpa_s);
116 if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
117 wpa_s->current_ssid,
119 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
120 wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
121 if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
122 wpa_s->sme.assoc_req_ie,
123 &wpa_s->sme.assoc_req_ie_len)) {
124 wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
129 wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
130 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
131 wpa_s->sme.assoc_req_ie,
132 &wpa_s->sme.assoc_req_ie_len)) {
133 wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
143 sizeof(wpa_s->sme.assoc_req_ie)) {
144 wpa_s->sme.assoc_req_ie_len = wpabuf_len(wps_ie);
145 os_memcpy(wpa_s->sme.assoc_req_ie, wpabuf_head(wps_ie),
146 wpa_s->sme.assoc_req_ie_len);
148 wpa_s->sme.assoc_req_ie_len = 0;
150 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
153 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
154 wpa_s->sme.assoc_req_ie_len = 0;
161 wpa_sm_set_ft_params(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0);
164 wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
168 if (wpa_s->sme.assoc_req_ie_len + 5 <
169 sizeof(wpa_s->sme.assoc_req_ie)) {
171 u8 *pos = wpa_s->sme.assoc_req_ie +
172 wpa_s->sme.assoc_req_ie_len;
179 wpa_s->sme.assoc_req_ie_len += 5;
182 if (wpa_s->sme.ft_used &&
183 os_memcmp(md, wpa_s->sme.mobility_domain, 2) == 0 &&
184 wpa_sm_has_ptk(wpa_s->wpa)) {
185 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying to use FT "
188 params.ie = wpa_s->sme.ft_ies;
189 params.ie_len = wpa_s->sme.ft_ies_len;
195 wpa_s->sme.mfp = ssid->ieee80211w;
202 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected AP supports "
204 wpa_s->sme.mfp = MGMT_FRAME_PROTECTION_REQUIRED;
210 if (wpa_s->global->p2p) {
214 pos = wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len;
215 len = sizeof(wpa_s->sme.assoc_req_ie) -
216 wpa_s->sme.assoc_req_ie_len;
217 res = wpas_p2p_assoc_req_ie(wpa_s, bss, pos, len,
220 wpa_s->sme.assoc_req_ie_len += res;
225 if (wpa_s->conf->interworking) {
226 u8 *pos = wpa_s->sme.assoc_req_ie;
227 if (wpa_s->sme.assoc_req_ie_len > 0 && pos[0] == WLAN_EID_RSN)
230 wpa_s->sme.assoc_req_ie_len -
231 (pos - wpa_s->sme.assoc_req_ie));
232 wpa_s->sme.assoc_req_ie_len += 6;
242 wpa_supplicant_cancel_sched_scan(wpa_s);
243 wpa_supplicant_cancel_scan(wpa_s);
245 wpa_msg(wpa_s, MSG_INFO, "SME: Trying to authenticate with " MACSTR
249 wpa_clear_keys(wpa_s, bss->bssid);
250 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
251 old_ssid = wpa_s->current_ssid;
252 wpa_s->current_ssid = ssid;
253 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
254 wpa_supplicant_initiate_eapol(wpa_s);
255 if (old_ssid != wpa_s->current_ssid)
256 wpas_notify_network_changed(wpa_s);
258 wpa_s->sme.auth_alg = params.auth_alg;
259 if (wpa_drv_authenticate(wpa_s, ¶ms) < 0) {
260 wpa_msg(wpa_s, MSG_INFO, "SME: Authentication request to the "
262 wpas_connection_failed(wpa_s, bss->bssid);
263 wpa_supplicant_mark_disassoc(wpa_s);
267 eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
277 void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
279 struct wpa_ssid *ssid = wpa_s->current_ssid;
282 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
287 if (wpa_s->wpa_state != WPA_AUTHENTICATING) {
288 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
293 if (os_memcmp(wpa_s->pending_bssid, data->auth.peer, ETH_ALEN) != 0) {
294 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication with "
300 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication response: peer=" MACSTR
307 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
310 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication failed (status "
315 wpa_s->sme.auth_alg == data->auth.auth_type ||
316 wpa_s->current_ssid->auth_alg == WPA_AUTH_ALG_LEAP) {
317 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
323 wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_SHARED;
325 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying SHARED auth");
326 wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
327 wpa_s->current_ssid);
331 wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_LEAP;
333 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying LEAP auth");
334 wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
335 wpa_s->current_ssid);
350 wpa_supplicant_event(wpa_s, EVENT_FT_RESPONSE, &edata);
354 sme_associate(wpa_s, ssid->mode, data->auth.peer,
359 void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
371 params.ssid = wpa_s->sme.ssid;
372 params.ssid_len = wpa_s->sme.ssid_len;
373 params.freq = wpa_s->sme.freq;
374 params.wpa_ie = wpa_s->sme.assoc_req_ie_len ?
375 wpa_s->sme.assoc_req_ie : NULL;
376 params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len;
377 params.pairwise_suite = cipher_suite2driver(wpa_s->pairwise_cipher);
378 params.group_suite = cipher_suite2driver(wpa_s->group_cipher);
384 wpa_supplicant_apply_ht_overrides(wpa_s, wpa_s->current_ssid, ¶ms);
387 if (auth_type == WLAN_AUTH_FT && wpa_s->sme.ft_ies) {
388 params.wpa_ie = wpa_s->sme.ft_ies;
389 params.wpa_ie_len = wpa_s->sme.ft_ies_len;
393 params.mgmt_frame_protection = wpa_s->sme.mfp;
394 if (wpa_s->sme.prev_bssid_set)
395 params.prev_bssid = wpa_s->sme.prev_bssid;
397 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
402 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
407 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Could not parse own IEs?!");
412 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.rsn_ie - 2,
416 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.wpa_ie - 2,
419 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
420 if (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group)
423 if (wpa_s->parent->set_sta_uapsd)
424 params.uapsd = wpa_s->parent->sta_uapsd;
428 if (wpa_drv_associate(wpa_s, ¶ms) < 0) {
429 wpa_msg(wpa_s, MSG_INFO, "SME: Association request to the "
431 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
432 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
436 eloop_register_timeout(SME_ASSOC_TIMEOUT, 0, sme_assoc_timer, wpa_s,
441 int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
445 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Remove mobility domain");
446 os_free(wpa_s->sme.ft_ies);
447 wpa_s->sme.ft_ies = NULL;
448 wpa_s->sme.ft_ies_len = 0;
449 wpa_s->sme.ft_used = 0;
453 os_memcpy(wpa_s->sme.mobility_domain, md, MOBILITY_DOMAIN_ID_LEN);
455 os_free(wpa_s->sme.ft_ies);
456 wpa_s->sme.ft_ies = os_malloc(ies_len);
457 if (wpa_s->sme.ft_ies == NULL)
459 os_memcpy(wpa_s->sme.ft_ies, ies, ies_len);
460 wpa_s->sme.ft_ies_len = ies_len;
465 static void sme_deauth(struct wpa_supplicant *wpa_s)
469 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
471 if (wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid,
473 wpa_msg(wpa_s, MSG_INFO, "SME: Deauth request to the driver "
476 wpa_s->sme.prev_bssid_set = 0;
478 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
479 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
480 os_memset(wpa_s->bssid, 0, ETH_ALEN);
481 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
483 wpas_notify_bssid_changed(wpa_s);
487 void sme_event_assoc_reject(struct wpa_supplicant *wpa_s,
490 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association with " MACSTR " failed: "
491 "status code %d", MAC2STR(wpa_s->pending_bssid),
494 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
503 sme_deauth(wpa_s);
507 void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s,
510 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication timed out");
511 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
512 wpa_supplicant_mark_disassoc(wpa_s);
516 void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
519 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association timed out");
520 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
521 wpa_supplicant_mark_disassoc(wpa_s);
525 void sme_event_disassoc(struct wpa_supplicant *wpa_s,
528 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Disassociation event received");
529 if (wpa_s->sme.prev_bssid_set) {
536 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Deauthenticate to clear "
538 wpa_drv_deauthenticate(wpa_s, wpa_s
546 struct wpa_supplicant *wpa_s = eloop_ctx;
547 if (wpa_s->wpa_state == WPA_AUTHENTICATING) {
548 wpa_msg(wpa_s, MSG_DEBUG, "SME: Authentication timeout");
549 sme_deauth(wpa_s);
556 struct wpa_supplicant *wpa_s = eloop_ctx;
557 if (wpa_s->wpa_state == WPA_ASSOCIATING) {
558 wpa_msg(wpa_s, MSG_DEBUG, "SME: Association timeout");
559 sme_deauth(wpa_s);
564 void sme_state_changed(struct wpa_supplicant *wpa_s)
567 if (wpa_s->wpa_state != WPA_ASSOCIATING)
568 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
569 if (wpa_s->wpa_state != WPA_AUTHENTICATING)
570 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
574 void sme_disassoc_while_authenticating(struct wpa_supplicant *wpa_s,
582 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Allow pending authentication "
584 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
585 os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN);
590 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
591 eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
596 void sme_deinit(struct wpa_supplicant *wpa_s)
598 os_free(wpa_s->sme.ft_ies);
599 wpa_s->sme.ft_ies = NULL;
600 wpa_s->sme.ft_ies_len = 0;
602 sme_stop_sa_query(wpa_s);
605 eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
606 eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
615 static int sme_check_sa_query_timeout(struct wpa_supplicant *wpa_s)
620 os_time_sub(&now, &wpa_s->sme.sa_query_start, &passed);
623 wpa_dbg(wpa_s, MSG_DEBUG, "SME: SA Query timed out");
624 sme_stop_sa_query(wpa_s);
626 wpa_s, WLAN_REASON_PREV_AUTH_NOT_VALID);
634 static void sme_send_sa_query_req(struct wpa_supplicant *wpa_s,
638 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Sending SA Query Request to "
639 MACSTR, MAC2STR(wpa_s->bssid));
645 if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
646 wpa_s->own_addr, wpa_s->bssid,
648 wpa_msg(wpa_s, MSG_INFO, "SME: Failed to send SA Query "
655 struct wpa_supplicant *wpa_s = eloop_ctx;
659 if (wpa_s->sme.sa_query_count > 0 &&
660 sme_check_sa_query_timeout(wpa_s))
663 nbuf = os_realloc(wpa_s->sme.sa_query_trans_id,
664 (wpa_s->sme.sa_query_count + 1) *
668 if (wpa_s->sme.sa_query_count == 0) {
670 os_get_time(&wpa_s->sme.sa_query_start);
672 trans_id = nbuf + wpa_s->sme.sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
673 wpa_s->sme.sa_query_trans_id = nbuf;
674 wpa_s->sme.sa_query_count++;
681 eloop_register_timeout(sec, usec, sme_sa_query_timer, wpa_s, NULL);
683 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association SA Query attempt %d",
684 wpa_s->sme.sa_query_count);
686 sme_send_sa_query_req(wpa_s, trans_id);
690 static void sme_start_sa_query(struct wpa_supplicant *wpa_s)
692 sme_sa_query_timer(wpa_s, NULL);
696 static void sme_stop_sa_query(struct wpa_supplicant *wpa_s)
698 eloop_cancel_timeout(sme_sa_query_timer, wpa_s, NULL);
699 os_free(wpa_s->sme.sa_query_trans_id);
700 wpa_s->sme.sa_query_trans_id = NULL;
701 wpa_s->sme.sa_query_count = 0;
705 void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa,
710 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME))
712 if (wpa_s->wpa_state != WPA_COMPLETED)
714 ssid = wpa_s->current_ssid;
717 if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
722 if (wpa_s->sme.sa_query_count > 0)
725 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Unprotected disconnect dropped - "
727 sme_start_sa_query(wpa_s);
731 void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa,
736 if (wpa_s->sme.sa_query_trans_id == NULL ||
740 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Received SA Query response from "
743 if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
746 for (i = 0; i < wpa_s->sme.sa_query_count; i++) {
747 if (os_memcmp(wpa_s->sme.sa_query_trans_id +
753 if (i >= wpa_s->sme.sa_query_count) {
754 wpa_dbg(wpa_s, MSG_DEBUG, "SME: No matching SA Query "
759 wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reply to pending SA Query received "
761 sme_stop_sa_query(wpa_s);