Lines Matching refs:wpa_s
116 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
125 wpa_drv_set_key(wpa_s, WPA_ALG_WEP, NULL,
134 int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
147 wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid mode %d (not "
153 wpa_msg(wpa_s, MSG_INFO, "WPA: No PSK configured for "
158 switch (wpa_s->group_cipher) {
177 wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid group cipher %d for "
178 "WPA-None", wpa_s->group_cipher);
185 ret = wpa_drv_set_key(wpa_s, alg, NULL, 0, 1, seq, 6, key, keylen);
193 struct wpa_supplicant *wpa_s = eloop_ctx;
194 const u8 *bssid = wpa_s->bssid;
196 bssid = wpa_s->pending_bssid;
197 wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
199 wpa_blacklist_add(wpa_s, bssid);
200 wpa_sm_notify_disassoc(wpa_s->wpa);
201 wpa_supplicant_deauthenticate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
202 wpa_s->reassociate = 1;
208 wpa_supplicant_req_scan(wpa_s, 1, 0);
214 * @wpa_s: Pointer to wpa_supplicant data
221 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
224 if (wpa_s->conf->ap_scan == 0 &&
225 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED))
228 wpa_dbg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec "
230 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
231 eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL);
237 * @wpa_s: Pointer to wpa_supplicant data
243 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s)
245 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling authentication timeout");
246 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
247 wpa_blacklist_del(wpa_s, wpa_s->bssid);
253 * @wpa_s: Pointer to wpa_supplicant data
258 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s)
262 struct wpa_ssid *ssid = wpa_s->current_ssid;
266 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
267 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE) {
272 eapol_sm_notify_portControl(wpa_s->eapol, ForceAuthorized);
273 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
274 eapol_sm_notify_eap_fail(wpa_s->eapol, FALSE);
279 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
280 eapol_sm_notify_eap_fail(wpa_s->eapol, FALSE);
282 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
283 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
284 eapol_sm_notify_portControl(wpa_s->eapol, ForceAuthorized);
286 eapol_sm_notify_portControl(wpa_s->eapol, Auto);
289 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
300 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED)
303 eapol_conf.fast_reauth = wpa_s->conf->fast_reauth;
306 !wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) &&
307 wpa_s->key_mgmt != WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
308 wpa_s->key_mgmt != WPA_KEY_MGMT_WPS;
309 eapol_conf.external_sim = wpa_s->conf->external_sim;
312 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
314 if (wpa_s->current_bss) {
316 ie = wpa_bss_get_vendor_ie_multi(wpa_s->current_bss,
328 eapol_sm_notify_config(wpa_s->eapol, &ssid->eap, &eapol_conf);
330 ieee802_1x_alloc_kay_sm(wpa_s, ssid);
337 * @wpa_s: Pointer to wpa_supplicant data
344 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
350 wpa_s->key_mgmt = WPA_KEY_MGMT_WPS;
352 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
354 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
355 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
356 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
357 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
358 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
359 wpa_s->group_cipher = WPA_CIPHER_NONE;
360 wpa_s->mgmt_group_cipher = 0;
364 wpa_s->pairwise_cipher = WPA_CIPHER_WEP104;
365 wpa_s->group_cipher = WPA_CIPHER_WEP104;
368 wpa_s->pairwise_cipher = WPA_CIPHER_WEP40;
369 wpa_s->group_cipher = WPA_CIPHER_WEP40;
374 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED, 0);
375 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
376 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
377 wpa_s->pairwise_cipher);
378 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
380 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
381 wpa_s->mgmt_group_cipher);
384 pmksa_cache_clear_current(wpa_s->wpa);
388 void free_hw_features(struct wpa_supplicant *wpa_s)
391 if (wpa_s->hw.modes == NULL)
394 for (i = 0; i < wpa_s->hw.num_modes; i++) {
395 os_free(wpa_s->hw.modes[i].channels);
396 os_free(wpa_s->hw.modes[i].rates);
399 os_free(wpa_s->hw.modes);
400 wpa_s->hw.modes = NULL;
404 static void free_bss_tmp_disallowed(struct wpa_supplicant *wpa_s)
408 dl_list_for_each_safe(bss, prev, &wpa_s->bss_tmp_disallowed,
416 static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
420 bgscan_deinit(wpa_s);
421 autoscan_deinit(wpa_s);
422 scard_deinit(wpa_s->scard);
423 wpa_s->scard = NULL;
424 wpa_sm_set_scard_ctx(wpa_s->wpa, NULL);
425 eapol_sm_register_scard_ctx(wpa_s->eapol, NULL);
426 l2_packet_deinit(wpa_s->l2);
427 wpa_s->l2 = NULL;
428 if (wpa_s->l2_br) {
429 l2_packet_deinit(wpa_s->l2_br);
430 wpa_s->l2_br = NULL;
433 l2_packet_deinit(wpa_s->l2_test);
434 wpa_s->l2_test = NULL;
437 if (wpa_s->conf != NULL) {
439 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
440 wpas_notify_network_removed(wpa_s, ssid);
443 os_free(wpa_s->confname);
444 wpa_s->confname = NULL;
446 os_free(wpa_s->confanother);
447 wpa_s->confanother = NULL;
449 wpa_sm_set_eapol(wpa_s->wpa, NULL);
450 eapol_sm_deinit(wpa_s->eapol);
451 wpa_s->eapol = NULL;
453 rsn_preauth_deinit(wpa_s->wpa);
456 wpa_tdls_deinit(wpa_s->wpa);
459 wmm_ac_clear_saved_tspecs(wpa_s);
460 pmksa_candidate_free(wpa_s->wpa);
461 wpa_sm_deinit(wpa_s->wpa);
462 wpa_s->wpa = NULL;
463 wpa_blacklist_clear(wpa_s);
465 wpa_bss_deinit(wpa_s);
467 wpa_supplicant_cancel_delayed_sched_scan(wpa_s);
468 wpa_supplicant_cancel_scan(wpa_s);
469 wpa_supplicant_cancel_auth_timeout(wpa_s);
470 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, wpa_s, NULL);
473 wpa_s, NULL);
476 eloop_cancel_timeout(wpas_network_reenabled, wpa_s, NULL);
478 wpas_wps_deinit(wpa_s);
480 wpabuf_free(wpa_s->pending_eapol_rx);
481 wpa_s->pending_eapol_rx = NULL;
484 ibss_rsn_deinit(wpa_s->ibss_rsn);
485 wpa_s->ibss_rsn = NULL;
488 sme_deinit(wpa_s);
491 wpa_supplicant_ap_deinit(wpa_s);
494 wpas_p2p_deinit(wpa_s);
497 offchannel_deinit(wpa_s);
500 wpa_supplicant_cancel_sched_scan(wpa_s);
502 os_free(wpa_s->next_scan_freqs);
503 wpa_s->next_scan_freqs = NULL;
505 os_free(wpa_s->manual_scan_freqs);
506 wpa_s->manual_scan_freqs = NULL;
508 os_free(wpa_s->manual_sched_scan_freqs);
509 wpa_s->manual_sched_scan_freqs = NULL;
511 wpas_mac_addr_rand_scan_clear(wpa_s, MAC_ADDR_RAND_ALL);
521 if (wpa_s->radio)
522 radio_remove_works(wpa_s, "gas-query", 0);
523 gas_query_deinit(wpa_s->gas);
524 wpa_s->gas = NULL;
526 free_hw_features(wpa_s);
528 ieee802_1x_dealloc_kay_sm(wpa_s);
530 os_free(wpa_s->bssid_filter);
531 wpa_s->bssid_filter = NULL;
533 os_free(wpa_s->disallow_aps_bssid);
534 wpa_s->disallow_aps_bssid = NULL;
535 os_free(wpa_s->disallow_aps_ssid);
536 wpa_s->disallow_aps_ssid = NULL;
538 wnm_bss_keep_alive_deinit(wpa_s);
540 wnm_deallocate_memory(wpa_s);
543 ext_password_deinit(wpa_s->ext_pw);
544 wpa_s->ext_pw = NULL;
546 wpabuf_free(wpa_s->last_gas_resp);
547 wpa_s->last_gas_resp = NULL;
548 wpabuf_free(wpa_s->prev_gas_resp);
549 wpa_s->prev_gas_resp = NULL;
551 os_free(wpa_s->last_scan_res);
552 wpa_s->last_scan_res = NULL;
555 hs20_deinit(wpa_s);
559 wpabuf_free(wpa_s->vendor_elem[i]);
560 wpa_s
563 wmm_ac_notify_disassoc(wpa_s);
565 wpa_s->sched_scan_plans_num = 0;
566 os_free(wpa_s->sched_scan_plans);
567 wpa_s->sched_scan_plans = NULL;
570 wpa_s->non_pref_chan_num = 0;
571 os_free(wpa_s->non_pref_chan);
572 wpa_s->non_pref_chan = NULL;
575 free_bss_tmp_disallowed(wpa_s);
581 * @wpa_s: Pointer to wpa_supplicant data
587 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr)
599 if (wpa_s->keys_cleared & BIT(i))
601 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, i, 0, NULL, 0,
604 if (!(wpa_s->keys_cleared & BIT(0)) && addr &&
606 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, addr, 0, 0, NULL, 0, NULL,
610 wpa_s, addr,
614 wpa_s->keys_cleared = (u32) -1;
654 static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
658 if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan)
659 name = wpa_s->current_ssid->bgscan;
661 name = wpa_s->conf->bgscan;
664 if (wpas_driver_bss_selection(wpa_s))
666 if (wpa_s->current_ssid == wpa_s->bgscan_ssid)
669 if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE)
673 bgscan_deinit(wpa_s);
674 if (wpa_s->current_ssid) {
675 if (bgscan_init(wpa_s, wpa_s->current_ssid, name)) {
676 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
685 wpa_s->bgscan_ssid = wpa_s->current_ssid;
686 scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL,
689 bgscan_notify_scan(wpa_s, scan_res);
694 wpa_s->bgscan_ssid = NULL;
698 static void wpa_supplicant_stop_bgscan(struct wpa_supplicant *wpa_s)
700 if (wpa_s->bgscan_ssid != NULL) {
701 bgscan_deinit(wpa_s);
702 wpa_s->bgscan_ssid = NULL;
709 static void wpa_supplicant_start_autoscan(struct wpa_supplicant *wpa_s)
711 if (autoscan_init(wpa_s, 0))
712 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize autoscan");
716 static void wpa_supplicant_stop_autoscan(struct wpa_supplicant *wpa_s)
718 autoscan_deinit(wpa_s);
722 void wpa_supplicant_reinit_autoscan(struct wpa_supplicant *wpa_s)
724 if (wpa_s->wpa_state == WPA_DISCONNECTED ||
725 wpa_s->wpa_state == WPA_SCANNING) {
726 autoscan_deinit(wpa_s);
727 wpa_supplicant_start_autoscan(wpa_s);
734 * @wpa_s: Pointer to wpa_supplicant data
740 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
743 enum wpa_states old_state = wpa_s->wpa_state;
745 wpa_dbg(wpa_s, MSG_DEBUG, "State: %s -> %s",
746 wpa_supplicant_state_txt(wpa_s->wpa_state),
751 wpa_s->normal_scans = 0;
755 wpas_connect_work_done(wpa_s);
757 wpa_s->normal_scans = 0;
767 if (wpa_s->conf->p2p_cli_probe && wpa_s->current_ssid &&
768 wpa_s->current_ssid->mode == WPAS_MODE_INFRA &&
769 wpa_s->current_ssid->p2p_group) {
770 if (state == WPA_COMPLETED && !wpa_s->p2p_cli_probe) {
771 wpa_dbg(wpa_s, MSG_DEBUG,
773 wpa_s->p2p_cli_probe =
774 wpa_drv_probe_req_report(wpa_s, 1) >= 0;
775 } else if (state != WPA_COMPLETED && wpa_s->p2p_cli_probe) {
776 wpa_dbg(wpa_s, MSG_DEBUG,
778 wpa_s->p2p_cli_probe = 0;
779 wpa_drv_probe_req_report(wpa_s, 0);
785 wpa_supplicant_notify_scanning(wpa_s, 0);
787 if (state == WPA_COMPLETED && wpa_s->new_connection) {
788 struct wpa_ssid *ssid = wpa_s->current_ssid;
790 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_CONNECTED "- Connection to "
792 MAC2STR(wpa_s->bssid),
796 wpas_clear_temp_disabled(wpa_s, ssid, 1);
797 wpa_blacklist_clear(wpa_s);
798 wpa_s->extra_blacklist_count = 0;
799 wpa_s->new_connection = 0;
800 wpa_drv_set_operstate(wpa_s, 1);
802 wpa_drv_set_supp_port(wpa_s, 1);
804 wpa_s->after_wps = 0;
805 wpa_s->known_wps_freq = 0;
806 wpas_p2p_completed(wpa_s);
808 sme_sched_obss_scan(wpa_s, 1);
811 wpa_s->new_connection = 1;
812 wpa_drv_set_operstate(wpa_s, 0);
814 wpa_drv_set_supp_port(wpa_s, 0);
816 sme_sched_obss_scan(wpa_s, 0);
818 wpa_s->wpa_state = state;
822 wpa_supplicant_start_bgscan(wpa_s);
824 wpa_supplicant_stop_bgscan(wpa_s);
828 wpa_supplicant_stop_autoscan(wpa_s);
831 wpa_supplicant_start_autoscan(wpa_s);
833 if (old_state >= WPA_ASSOCIATED && wpa_s->wpa_state < WPA_ASSOCIATED)
834 wmm_ac_notify_disassoc(wpa_s);
836 if (wpa_s->wpa_state != old_state) {
837 wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
843 wpas_p2p_indicate_state_change(wpa_s);
845 if (wpa_s->wpa_state == WPA_COMPLETED ||
847 wpas_notify_auth_changed(wpa_s);
856 struct wpa_supplicant *wpa_s = global->ifaces;
857 while (wpa_s) {
858 struct wpa_supplicant *next = wpa_s->next;
859 if (wpas_wps_terminate_pending(wpa_s) == 1)
862 if (wpa_s->p2p_group_interface != NOT_P2P_GROUP_INTERFACE ||
863 (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group))
864 wpas_p2p_disconnect(wpa_s);
866 wpa_s = next;
882 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
884 enum wpa_states old_state = wpa_s->wpa_state;
886 wpa_s->pairwise_cipher = 0;
887 wpa_s->group_cipher = 0;
888 wpa_s->mgmt_group_cipher = 0;
889 wpa_s->key_mgmt = 0;
890 if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED)
891 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
893 if (wpa_s->wpa_state != old_state)
894 wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
900 * @wpa_s: Pointer to wpa_supplicant data
909 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
915 if (wpa_s->confname == NULL)
917 conf = wpa_config_read(wpa_s->confname, NULL);
919 wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
920 "file '%s' - exiting", wpa_s->confname);
923 wpa_config_read(wpa_s->confanother, conf);
927 reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
928 || (conf->ctrl_interface && wpa_s->conf->ctrl_interface &&
930 wpa_s->conf->ctrl_interface) != 0);
932 if (reconf_ctrl && wpa_s->ctrl_iface) {
933 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
934 wpa_s->ctrl_iface = NULL;
937 eapol_sm_invalidate_cached_session(wpa_s->eapol);
938 if (wpa_s->current_ssid) {
939 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
940 wpa_s->own_disconnect_req = 1;
941 wpa_supplicant_deauthenticate(wpa_s,
949 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
954 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
956 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
957 wpa_sm_set_config(wpa_s->wpa, NULL);
958 wpa_sm_pmksa_cache_flush(wpa_s->wpa, NULL);
959 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
960 rsn_preauth_deinit(wpa_s->wpa);
962 old_ap_scan = wpa_s->conf->ap_scan;
963 wpa_config_free(wpa_s->conf);
964 wpa_s->conf = conf;
965 if (old_ap_scan != wpa_s->conf->ap_scan)
966 wpas_notify_ap_scan_changed(wpa_s);
969 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
971 wpa_supplicant_update_config(wpa_s);
973 wpa_supplicant_clear_status(wpa_s);
974 if (wpa_supplicant_enabled_networks(wpa_s)) {
975 wpa_s->reassociate = 1;
976 wpa_supplicant_req_scan(wpa_s, 0, 0);
978 wpa_dbg(wpa_s, MSG_DEBUG, "Reconfiguration completed");
986 struct wpa_supplicant *wpa_s;
987 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
988 wpa_dbg(wpa_s, MSG_DEBUG, "Signal %d received - reconfiguring",
990 if (wpa_supplicant_reload_configuration(wpa_s) < 0) {
1002 static int wpa_supplicant_suites_from_ai(struct wpa_supplicant *wpa_s,
1006 int ret = wpa_sm_parse_own_wpa_ie(wpa_s->wpa, ie);
1009 wpa_msg(wpa_s, MSG_INFO, "WPA: Failed to parse WPA IE "
1015 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Using WPA IE from AssocReq to set "
1018 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled group "
1024 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled pairwise "
1030 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled key "
1038 wpas_get_ssid_pmf(wpa_s, ssid) == MGMT_FRAME_PROTECTION_REQUIRED) {
1039 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver associated with an AP "
1052 * @wpa_s: Pointer to wpa_supplicant data
1064 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
1084 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: using IEEE 802.11i/D9.0");
1091 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using IEEE 802.11i/D3.0");
1095 wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: using OSEN");
1104 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select WPA/RSN");
1105 wpa_dbg(wpa_s, MSG_DEBUG,
1109 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: BSS " MACSTR " ssid='%s'%s%s%s",
1118 wpa_dbg(wpa_s, MSG_DEBUG,
1121 wpa_dbg(wpa_s, MSG_DEBUG,
1130 wpa_dbg(wpa_s, MSG_DEBUG,
1133 wpa_dbg(wpa_s, MSG_DEBUG,
1147 if (wpa_supplicant_suites_from_ai(wpa_s, ssid, &ie) < 0) {
1157 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Set cipher suites "
1163 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected cipher suites: group %d "
1168 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected mgmt group cipher %d",
1173 wpa_s->wpa_proto = proto;
1174 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, proto);
1175 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED,
1178 if (bss || !wpa_s->ap_ies_from_associnfo) {
1179 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
1181 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
1187 wpa_s->group_cipher = WPA_CIPHER_NONE;
1188 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
1191 wpa_s->group_cipher = wpa_pick_group_cipher(sel);
1192 if (wpa_s->group_cipher < 0) {
1193 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select group "
1197 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK %s",
1198 wpa_cipher_txt(wpa_s->group_cipher));
1201 wpa_s->pairwise_cipher = wpa_pick_pairwise_cipher(sel, 1);
1202 if (wpa_s->pairwise_cipher < 0) {
1203 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select pairwise "
1207 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK %s",
1208 wpa_cipher_txt(wpa_s->pairwise_cipher));
1213 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_SAE))
1219 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SUITE_B_192;
1220 wpa_dbg(wpa_s, MSG_DEBUG,
1225 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SUITE_B;
1226 wpa_dbg(wpa_s, MSG_DEBUG,
1231 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_IEEE8021X;
1232 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/802.1X");
1234 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_PSK;
1235 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/PSK");
1239 wpa_s->key_mgmt = WPA_KEY_MGMT_SAE;
1240 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: using KEY_MGMT SAE");
1242 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_SAE;
1243 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: using KEY_MGMT FT/SAE");
1247 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SHA256;
1248 wpa_dbg(wpa_s, MSG_DEBUG,
1251 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK_SHA256;
1252 wpa_dbg(wpa_s, MSG_DEBUG,
1256 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
1257 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X");
1259 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
1260 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-PSK");
1262 wpa_s->key_mgmt = WPA_KEY_MGMT_WPA_NONE;
1263 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-NONE");
1266 wpa_s->key_mgmt = WPA_KEY_MGMT_OSEN;
1267 wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: using KEY_MGMT OSEN");
1270 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select "
1275 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
1276 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
1277 wpa_s->pairwise_cipher);
1278 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
1282 if (wpas_get_ssid_pmf(wpa_s, ssid) == NO_MGMT_FRAME_PROTECTION ||
1286 wpa_s->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC;
1287 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
1290 wpa_s->mgmt_group_cipher = WPA_CIPHER_BIP_GMAC_128;
1291 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
1294 wpa_s->mgmt_group_cipher = WPA_CIPHER_BIP_GMAC_256;
1295 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
1298 wpa_s->mgmt_group_cipher = WPA_CIPHER_BIP_CMAC_256;
1299 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
1302 wpa_s->mgmt_group_cipher = 0;
1303 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher");
1305 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
1306 wpa_s->mgmt_group_cipher);
1307 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MFP,
1308 wpas_get_ssid_pmf(wpa_s, ssid));
1311 if (wpa_sm_set_assoc_wpa_ie_default(wpa_s->wpa, wpa_ie, wpa_ie_len)) {
1312 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to generate WPA IE");
1320 wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN, NULL,
1332 wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL, NULL);
1339 struct wpabuf *pw = ext_password_get(wpa_s->ext_pw,
1345 wpa_msg(wpa_s, MSG_INFO, "EXT PW: No PSK "
1351 wpa_msg(wpa_s, MSG_INFO, "EXT PW: Unexpected "
1370 wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL,
1378 wpa_msg(wpa_s, MSG_INFO, "EXT PW: "
1384 wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN, NULL,
1389 wpa_msg(wpa_s, MSG_INFO, "EXT PW: No suitable "
1402 wpa_msg(wpa_s, MSG_INFO,
1407 wpa_sm_set_pmk_from_pmksa(wpa_s->wpa);
1413 static void wpas_ext_capab_byte(struct wpa_supplicant *wpa_s, u8 *pos, int idx)
1433 if (wpa_s->conf->interworking)
1439 if (wpa_s->drv_flags / WPA_DRIVER_FLAGS_QOS_MAPPING)
1445 if (wpa_s->conf->hs20)
1458 int wpas_build_ext_capab(struct wpa_supplicant *wpa_s, u8 *buf, size_t buflen)
1463 if (len < wpa_s->extended_capa_len)
1464 len = wpa_s->extended_capa_len;
1474 wpas_ext_capab_byte(wpa_s, pos, i);
1476 if (i < wpa_s->extended_capa_len) {
1477 *pos &= ~wpa_s->extended_capa_mask[i];
1478 *pos |= wpa_s->extended_capa[i];
1493 static int wpas_valid_bss(struct wpa_supplicant *wpa_s,
1498 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
1507 static int wpas_valid_ssid(struct wpa_supplicant *wpa_s,
1512 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
1521 int wpas_valid_bss_ssid(struct wpa_supplicant *wpa_s, struct wpa_bss *test_bss,
1524 if (test_bss && !wpas_valid_bss(wpa_s, test_bss))
1527 return test_ssid == NULL || wpas_valid_ssid(wpa_s, test_ssid);
1539 void wpas_connect_work_done(struct wpa_supplicant *wpa_s)
1542 struct wpa_radio_work *work = wpa_s->connect_work;
1547 wpa_s->connect_work = NULL;
1555 int wpas_update_random_addr(struct wpa_supplicant *wpa_s, int style)
1561 if (wpa_s->last_mac_addr_style == style &&
1562 wpa_s->last_mac_addr_change.sec != 0 &&
1563 !os_reltime_expired(&now, &wpa_s->last_mac_addr_change,
1564 wpa_s->conf->rand_addr_lifetime)) {
1565 wpa_msg(wpa_s, MSG_DEBUG,
1576 os_memcpy(addr, wpa_s->perm_addr, ETH_ALEN);
1584 if (wpa_drv_set_mac_addr(wpa_s, addr) < 0) {
1585 wpa_msg(wpa_s, MSG_INFO,
1590 os_get_reltime(&wpa_s->last_mac_addr_change);
1591 wpa_s->mac_addr_changed = 1;
1592 wpa_s->last_mac_addr_style = style;
1594 if (wpa_supplicant_update_mac_addr(wpa_s) < 0) {
1595 wpa_msg(wpa_s, MSG_INFO,
1600 wpa_msg(wpa_s, MSG_DEBUG, "Using random MAC address " MACSTR,
1607 int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s)
1609 if (wpa_s->wpa_state >= WPA_AUTHENTICATING ||
1610 !wpa_s->conf->preassoc_mac_addr)
1613 return wpas_update_random_addr(wpa_s, wpa_s->conf->preassoc_mac_addr);
1621 * @wpa_s: Pointer to wpa_supplicant data
1627 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
1633 wpa_s->own_disconnect_req = 0;
1639 wpabuf_free(wpa_s->pending_eapol_rx);
1640 wpa_s->pending_eapol_rx = NULL;
1643 rand_style = wpa_s->conf->mac_addr;
1647 wmm_ac_clear_saved_tspecs(wpa_s);
1648 wpa_s->reassoc_same_bss = 0;
1649 wpa_s->reassoc_same_ess = 0;
1651 if (wpa_s->last_ssid == ssid) {
1652 wpa_dbg(wpa_s, MSG_DEBUG, "Re-association to the same ESS");
1653 wpa_s->reassoc_same_ess = 1;
1654 if (wpa_s->current_bss && wpa_s->current_bss == bss) {
1655 wmm_ac_save_tspecs(wpa_s);
1656 wpa_s->reassoc_same_bss = 1;
1659 if (wpas_update_random_addr(wpa_s, rand_style) < 0)
1661 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
1662 } else if (wpa_s->mac_addr_changed) {
1663 if (wpa_drv_set_mac_addr(wpa_s, NULL) < 0) {
1664 wpa_msg(wpa_s, MSG_INFO,
1668 wpa_s->mac_addr_changed = 0;
1669 if (wpa_supplicant_update_mac_addr(wpa_s) < 0) {
1670 wpa_msg(wpa_s, MSG_INFO,
1674 wpa_msg(wpa_s, MSG_DEBUG, "Using permanent MAC address");
1676 wpa_s->last_ssid = ssid;
1679 ibss_rsn_deinit(wpa_s->ibss_rsn);
1680 wpa_s->ibss_rsn = NULL;
1686 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP)) {
1687 wpa_msg(wpa_s, MSG_INFO, "Driver does not support AP "
1691 if (wpa_supplicant_create_ap(wpa_s, ssid) < 0) {
1692 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
1694 wpas_p2p_ap_setup_failed(wpa_s);
1697 wpa_s->current_bss = bss;
1699 wpa_msg(wpa_s, MSG_ERROR, "AP mode support not included in "
1707 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_MESH)) {
1708 wpa_msg(wpa_s, MSG_INFO,
1714 if (wpa_supplicant_join_mesh(wpa_s, ssid) < 0) {
1715 wpa_msg(wpa_s, MSG_ERROR, "Could not join mesh");
1718 wpa_s->current_bss = bss;
1719 wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_STARTED "ssid=\"%s\" id=%d",
1723 wpa_msg(wpa_s, MSG_ERROR,
1731 wpa_tdls_ap_ies(wpa_s->wpa, (const u8 *) (bss + 1),
1735 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
1737 sme_authenticate(wpa_s, bss, ssid);
1741 if (wpa_s->connect_work) {
1742 wpa_dbg(wpa_s, MSG_DEBUG, "Reject wpa_supplicant_associate() call since connect_work exist");
1746 if (radio_work_pending(wpa_s, "connect")) {
1747 wpa_dbg(wpa_s, MSG_DEBUG, "Reject wpa_supplicant_associate() call since pending work exist");
1751 wpas_abort_ongoing_scan(wpa_s);
1760 if (radio_add_work(wpa_s, bss ? bss->freq : 0, "connect", 1,
1774 static int drv_supports_vht(struct wpa_supplicant *wpa_s,
1790 for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) {
1791 if (wpa_s->hw.modes[i].mode == hw_mode) {
1792 mode = &wpa_s->hw.modes[i];
1804 void ibss_mesh_setup_freq(struct wpa_supplicant *wpa_s,
1823 for (j = 0; j < wpa_s->last_scan_res_used; j++) {
1824 struct wpa_bss *bss = wpa_s->last_scan_res[j];
1849 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_HT_IBSS))
1852 if (wpa_s->group_cipher == WPA_CIPHER_WEP40 ||
1853 wpa_s->group_cipher == WPA_CIPHER_WEP104 ||
1854 wpa_s->pairwise_cipher == WPA_CIPHER_TKIP) {
1861 for (i = 0; wpa_s->hw.modes && i < wpa_s->hw.num_modes; i++) {
1862 if (wpa_s->hw.modes[i].mode == hw_mode) {
1863 mode = &wpa_s->hw.modes[i];
1934 scan_res = wpa_supplicant_get_scan_results(wpa_s, NULL, 0);
1969 if (!drv_supports_vht(wpa_s, ssid))
1974 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_VHT_IBSS))
2058 struct wpa_supplicant *wpa_s = work->wpa_s;
2083 wpa_s->connect_work = NULL;
2086 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s,
2093 wpa_s->connect_work = work;
2095 if (cwork->bss_removed || !wpas_valid_bss_ssid(wpa_s, bss, ssid) ||
2096 wpas_network_disabled(wpa_s, ssid)) {
2097 wpa_dbg(wpa_s, MSG_DEBUG, "BSS/SSID entry for association not valid anymore - drop connection attempt");
2098 wpas_connect_work_done(wpa_s);
2102 os_memcpy(prev_bssid, wpa_s->bssid, ETH_ALEN);
2104 wpa_s->reassociate = 0;
2105 wpa_s->eap_expected_failure = 0;
2107 (!wpas_driver_bss_selection(wpa_s) || wpas_wps_searching(wpa_s))) {
2111 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
2114 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
2115 os_memset(wpa_s->bssid, 0, ETH_ALEN);
2116 os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
2118 wpas_notify_bssid_changed(wpa_s);
2123 wpa_sm_set_ft_params(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0);
2126 wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
2131 wpa_s->conf->ap_scan == 2 &&
2135 wpas_connect_work_done(wpa_s);
2136 wpa_s->scan_req = MANUAL_SCAN_REQ;
2137 wpa_s->reassociate = 1;
2138 wpa_supplicant_req_scan(wpa_s, 0, 0);
2142 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with SSID '%s'",
2144 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
2146 if (!wpa_s->pno)
2147 wpa_supplicant_cancel_sched_scan(wpa_s);
2149 wpa_supplicant_cancel_scan(wpa_s);
2153 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
2165 wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x", algs);
2168 wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: "
2177 wpa_s->conf->okc :
2180 if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
2182 eapol_sm_notify_pmkid_attempt(wpa_s->eapol);
2184 if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
2186 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA "
2188 wpas_connect_work_done(wpa_s);
2198 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
2200 wpa_s->wpa_proto = 0;
2203 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
2205 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA "
2208 wpas_connect_work_done(wpa_s);
2221 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
2226 wpa_s->wpa_proto = 0;
2229 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
2231 wpa_s->wpa_proto = 0;
2235 if (wpa_s->global->p2p) {
2241 res = wpas_p2p_assoc_req_ie(wpa_s, bss, pos, len,
2247 wpa_s->cross_connect_disallowed = 0;
2252 wpa_s->cross_connect_disallowed =
2255 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: WLAN AP %s cross "
2257 wpa_s->cross_connect_disallowed ?
2262 os_memset(wpa_s->p2p_ip_addr_info, 0, sizeof(wpa_s->p2p_ip_addr_info));
2271 len = wpas_mbo_supp_op_class_ie(wpa_s, bss->freq,
2292 ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
2306 if (is_hs20_network(wpa_s, ssid, bss)) {
2311 int pps_mo_id = hs20_get_pps_mo_id(wpa_s, ssid);
2326 if (wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ]) {
2327 struct wpabuf *buf = wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ];
2339 if (wpa_s->fst_ies) {
2340 int fst_ies_len = wpabuf_len(wpa_s->fst_ies);
2344 wpabuf_head(wpa_s->fst_ies), fst_ies_len);
2354 len = wpas_mbo_ie(wpa_s, wpa_ie + wpa_ie_len,
2361 wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
2363 cipher_pairwise = wpa_s->pairwise_cipher;
2364 cipher_group = wpa_s->group_cipher;
2365 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
2366 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
2367 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE)
2369 if (wpa_set_wep_keys(wpa_s, ssid)) {
2374 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)
2378 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
2393 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2395 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
2398 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
2402 if (!wpas_driver_bss_selection(wpa_s) || ssid->bssid_set) {
2421 wpa_s->conf->ap_scan == 2) {
2429 ibss_mesh_setup_freq(wpa_s, ssid, ¶ms.freq);
2436 params.beacon_int = wpa_s->conf->beacon_int;
2443 params.key_mgmt_suite = wpa_s->key_mgmt;
2444 params.wpa_proto = wpa_s->wpa_proto;
2455 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
2463 if (wpa_s->conf->key_mgmt_offload) {
2470 wpa_s->conf->okc : ssid->proactive_key_caching;
2484 params.mgmt_frame_protection = wpas_get_ssid_pmf(wpa_s, ssid);
2491 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected AP supports "
2501 if (wpa_s->p2pdev->set_sta_uapsd)
2502 params.uapsd = wpa_s->p2pdev->sta_uapsd;
2511 wpa_supplicant_apply_ht_overrides(wpa_s, ssid, ¶ms);
2518 wpa_supplicant_apply_vht_overrides(wpa_s, ssid, ¶ms);
2527 if (wpa_s->num_multichan_concurrent < 2) {
2529 num = get_shared_radio_freqs(wpa_s, &freq, 1);
2535 wpa_s, params.freq.freq, ssid) < 0) {
2536 wpas_connect_work_done(wpa_s);
2543 if (wpa_s->reassoc_same_ess && !is_zero_ether_addr(prev_bssid) &&
2544 wpa_s->current_ssid)
2547 ret = wpa_drv_associate(wpa_s, ¶ms);
2549 wpa_msg(wpa_s, MSG_INFO, "Association request to the driver "
2551 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SANE_ERROR_CODES) {
2557 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
2558 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
2559 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
2567 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
2570 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
2573 wpa_supplicant_cancel_auth_timeout(wpa_s);
2574 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
2577 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
2578 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE) {
2583 wpa_supplicant_cancel_auth_timeout(wpa_s);
2592 } else if (wpa_s->conf->ap_scan == 1) {
2596 wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
2600 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC)) {
2602 wpa_set_wep_keys(wpa_s, ssid);
2605 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid) {
2610 eapol_sm_invalidate_cached_session(wpa_s->eapol);
2612 old_ssid = wpa_s->current_ssid;
2613 wpa_s->current_ssid = ssid;
2614 if (!wpas_driver_bss_selection(wpa_s) || ssid->bssid_set)
2615 wpa_s->current_bss = bss;
2616 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
2617 wpa_supplicant_initiate_eapol(wpa_s);
2618 if (old_ssid != wpa_s->current_ssid)
2619 wpas_notify_network_changed(wpa_s);
2623 static void wpa_supplicant_clear_connection(struct wpa_supplicant *wpa_s,
2628 wpas_connect_work_done(wpa_s);
2629 wpa_clear_keys(wpa_s, addr);
2630 old_ssid = wpa_s->current_ssid;
2631 wpa_supplicant_mark_disassoc(wpa_s);
2632 wpa_sm_set_config(wpa_s->wpa, NULL);
2633 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
2634 if (old_ssid != wpa_s->current_ssid)
2635 wpas_notify_network_changed(wpa_s);
2636 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
2642 * @wpa_s: Pointer to wpa_supplicant data
2648 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
2655 wpa_dbg(wpa_s, MSG_DEBUG, "Request to deauthenticate - bssid=" MACSTR
2657 MAC2STR(wpa_s->bssid), MAC2STR(wpa_s->pending_bssid),
2658 reason_code, wpa_supplicant_state_txt(wpa_s->wpa_state));
2660 if (!is_zero_ether_addr(wpa_s->bssid))
2661 addr = wpa_s->bssid;
2662 else if (!is_zero_ether_addr(wpa_s->pending_bssid) &&
2663 (wpa_s->wpa_state == WPA_AUTHENTICATING ||
2664 wpa_s->wpa_state == WPA_ASSOCIATING))
2665 addr = wpa_s->pending_bssid;
2666 else if (wpa_s->wpa_state == WPA_ASSOCIATING) {
2673 addr = wpa_s->bssid;
2678 wpa_tdls_teardown_peers(wpa_s->wpa);
2682 if (wpa_s->ifmsh) {
2683 wpa_msg(wpa_s, MSG_INFO, MESH_GROUP_REMOVED "%s",
2684 wpa_s->ifname);
2685 wpa_supplicant_leave_mesh(wpa_s);
2690 wpa_drv_deauthenticate(wpa_s, addr, reason_code);
2694 wpa_supplicant_event(wpa_s, EVENT_DEAUTH, &event);
2699 wpa_supplicant_clear_connection(wpa_s, addr);
2702 static void wpa_supplicant_enable_one_network(struct wpa_supplicant *wpa_s,
2709 wpas_clear_temp_disabled(wpa_s, ssid, 1);
2710 wpas_notify_network_enabled_changed(wpa_s, ssid);
2716 if (!wpa_s->current_ssid && !wpa_s->disconnected)
2717 wpa_s->reassociate = 1;
2723 * @wpa_s: wpa_supplicant structure for a network interface
2728 void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
2732 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
2733 wpa_supplicant_enable_one_network(wpa_s, ssid);
2735 wpa_supplicant_enable_one_network(wpa_s, ssid);
2737 if (wpa_s->reassociate && !wpa_s->disconnected &&
2738 (!wpa_s->current_ssid ||
2739 wpa_s->wpa_state == WPA_DISCONNECTED ||
2740 wpa_s->wpa_state == WPA_SCANNING)) {
2741 if (wpa_s->sched_scanning) {
2744 wpa_supplicant_cancel_sched_scan(wpa_s);
2747 if (wpa_supplicant_fast_associate(wpa_s) != 1) {
2748 wpa_s->scan_req = NORMAL_SCAN_REQ;
2749 wpa_supplicant_req_scan(wpa_s, 0, 0);
2757 * @wpa_s: wpa_supplicant structure for a network interface
2762 void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
2769 if (wpa_s->sched_scanning)
2770 wpa_supplicant_cancel_sched_scan(wpa_s);
2772 for (other_ssid = wpa_s->conf->ssid; other_ssid;
2783 wpa_s, other_ssid);
2785 if (wpa_s->current_ssid)
2787 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2789 if (ssid == wpa_s->current_ssid)
2791 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2798 wpas_notify_network_enabled_changed(wpa_s, ssid);
2799 if (wpa_s->sched_scanning) {
2802 wpa_supplicant_cancel_sched_scan(wpa_s);
2803 wpa_supplicant_req_scan(wpa_s, 0, 0);
2812 * @wpa_s: wpa_supplicant structure for a network interface
2815 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
2822 if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) {
2823 if (wpa_s->wpa_state >= WPA_AUTHENTICATING)
2824 wpa_s->own_disconnect_req = 1;
2826 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
2831 wpas_clear_temp_disabled(wpa_s, ssid, 1);
2837 for (other_ssid = wpa_s->conf->ssid; other_ssid;
2845 wpas_clear_temp_disabled(wpa_s, other_ssid, 0);
2848 wpas_notify_network_enabled_changed(wpa_s, other_ssid);
2851 if (ssid && ssid == wpa_s->current_ssid && wpa_s->current_ssid &&
2852 wpa_s->wpa_state >= WPA_AUTHENTICATING) {
2860 wpa_s->current_ssid = ssid;
2861 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
2862 wpa_s->connect_without_scan =
2869 os_free(wpa_s->next_scan_freqs);
2870 wpa_s->next_scan_freqs = NULL;
2872 wpa_s->connect_without_scan = NULL;
2875 wpa_s->disconnected = 0;
2876 wpa_s->reassociate = 1;
2878 if (wpa_s->connect_without_scan ||
2879 wpa_supplicant_fast_associate(wpa_s) != 1) {
2880 wpa_s->scan_req = NORMAL_SCAN_REQ;
2881 wpa_supplicant_req_scan(wpa_s
2885 wpas_notify_network_selected(wpa_s, ssid);
2891 * @wpa_s: wpa_supplicant structure for a network interface
2900 int wpas_set_pkcs11_engine_and_module_path(struct wpa_supplicant *wpa_s,
2920 os_free(wpa_s->conf->pkcs11_engine_path);
2921 os_free(wpa_s->conf->pkcs11_module_path);
2922 wpa_s->conf->pkcs11_engine_path = pkcs11_engine_path_copy;
2923 wpa_s->conf->pkcs11_module_path = pkcs11_module_path_copy;
2925 wpa_sm_set_eapol(wpa_s->wpa, NULL);
2926 eapol_sm_deinit(wpa_s->eapol);
2927 wpa_s->eapol = NULL;
2928 if (wpa_supplicant_init_eapol(wpa_s)) {
2931 wpas_set_pkcs11_engine_and_module_path(wpa_s, NULL,
2936 wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
2944 * @wpa_s: wpa_supplicant structure for a network interface
2949 int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s, int ap_scan)
2957 if (ap_scan == 2 && os_strcmp(wpa_s->driver->name, "nl80211") == 0) {
2963 if (ap_scan == 2 && ap_scan != wpa_s->conf->ap_scan &&
2964 wpa_s->wpa_state >= WPA_ASSOCIATING &&
2965 wpa_s->wpa_state < WPA_COMPLETED) {
2967 "associating", wpa_s->conf->ap_scan, ap_scan);
2972 old_ap_scan = wpa_s->conf->ap_scan;
2973 wpa_s->conf->ap_scan = ap_scan;
2975 if (old_ap_scan != wpa_s->conf->ap_scan)
2976 wpas_notify_ap_scan_changed(wpa_s);
2984 * @wpa_s: wpa_supplicant structure for a network interface
2989 int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
2993 wpa_msg(wpa_s, MSG_ERROR, "Invalid bss expiration age %u",
2997 wpa_msg(wpa_s, MSG_DEBUG, "Setting bss expiration age: %d sec",
2999 wpa_s->conf->bss_expiration_age = bss_expire_age;
3007 * @wpa_s: wpa_supplicant structure for a network interface
3012 int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
3016 wpa_msg(wpa_s, MSG_ERROR, "Invalid bss expiration count %u",
3020 wpa_msg(wpa_s, MSG_DEBUG, "Setting bss expiration scan count: %u",
3022 wpa_s->conf->bss_expiration_scan_count = bss_expire_count;
3030 * @wpa_s: wpa_supplicant structure for a network interface
3035 int wpa_supplicant_set_scan_interval(struct wpa_supplicant *wpa_s,
3039 wpa_msg(wpa_s, MSG_ERROR, "Invalid scan interval %d",
3043 wpa_msg(wpa_s, MSG_DEBUG, "Setting scan interval: %d sec",
3045 wpa_supplicant_update_scan_int(wpa_s, scan_interval);
3095 * @wpa_s: Pointer to wpa_supplicant data
3098 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
3107 res = wpa_drv_get_ssid(wpa_s, ssid);
3109 wpa_msg(wpa_s, MSG_WARNING, "Could not read SSID from "
3115 if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
3116 wpa_msg(wpa_s, MSG_WARNING, "Could not read BSSID from "
3121 wired = wpa_s->conf->ap_scan == 0 &&
3122 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED);
3124 entry = wpa_s->conf->ssid;
3126 if (!wpas_network_disabled(wpa_s, entry) &&
3133 if (!wpas_network_disabled(wpa_s, entry) &&
3141 if (!wpas_network_disabled(wpa_s, entry) && entry->bssid_set &&
3153 static int select_driver(struct wpa_supplicant *wpa_s, int i)
3155 struct wpa_global *global = wpa_s->global;
3166 wpa_s->driver = wpa_drivers[i];
3167 wpa_s->global_drv_priv = global->drv_priv[i];
3173 static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
3180 if (wpa_s == NULL)
3184 wpa_msg(wpa_s, MSG_ERROR, "No driver interfaces build into "
3191 return select_driver(wpa_s, 0);
3206 if (select_driver(wpa_s, i) == 0)
3214 wpa_msg(wpa_s, MSG_ERROR, "Unsupported driver '%s'", name);
3221 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
3236 struct wpa_supplicant *wpa_s = ctx;
3238 wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
3242 if (wpa_s->wpa_state > WPA_ASSOCIATED && wpa_s->current_ssid &&
3243 wpa_s->current_ssid->peerkey &&
3244 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
3245 wpa_sm_rx_eapol_peerkey(wpa_s->wpa, src_addr, buf, len) == 1) {
3246 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: Processed PeerKey EAPOL-Key");
3251 if (wpa_s->wpa_state < WPA_ASSOCIATED ||
3252 (wpa_s->last_eapol_matches_bssid &&
3254 !wpa_s->ap_iface &&
3256 os_memcmp(src_addr, wpa_s->bssid, ETH_ALEN) != 0)) {
3269 wpa_dbg(wpa_s, MSG_DEBUG, "Not associated - Delay processing "
3271 wpa_supplicant_state_txt(wpa_s->wpa_state),
3272 MAC2STR(wpa_s->bssid));
3273 wpabuf_free(wpa_s->pending_eapol_rx);
3274 wpa_s->pending_eapol_rx = wpabuf_alloc_copy(buf, len);
3275 if (wpa_s->pending_eapol_rx) {
3276 os_get_reltime(&wpa_s->pending_eapol_rx_time);
3277 os_memcpy(wpa_s->pending_eapol_rx_src, src_addr,
3283 wpa_s->last_eapol_matches_bssid =
3284 os_memcmp(src_addr, wpa_s->bssid, ETH_ALEN) == 0;
3287 if (wpa_s->ap_iface) {
3288 wpa_supplicant_ap_rx_eapol(wpa_s, src_addr, buf, len);
3293 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
3294 wpa_dbg(wpa_s, MSG_DEBUG, "Ignored received EAPOL frame since "
3299 if (wpa_s->eapol_received == 0 &&
3300 (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) ||
3301 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
3302 wpa_s->wpa_state != WPA_COMPLETED) &&
3303 (wpa_s->current_ssid == NULL ||
3304 wpa_s->current_ssid->mode != IEEE80211_MODE_IBSS)) {
3308 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
3309 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA ||
3310 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) {
3316 if (wpa_s->current_ssid && wpa_s->current_bss &&
3317 (wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
3318 eap_is_wps_pin_enrollee(&wpa_s->current_ssid->eap)) {
3327 wpa_s->current_bss, WPS_IE_VENDOR_TYPE);
3329 !wps_is_addr_authorized(wps_ie, wpa_s->own_addr, 1))
3335 wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
3337 wpa_s->eapol_received++;
3339 if (wpa_s->countermeasures) {
3340 wpa_msg(wpa_s, MSG_INFO, "WPA: Countermeasures - dropped "
3346 if (wpa_s->current_ssid &&
3347 wpa_s->current_ssid->mode == WPAS_MODE_IBSS) {
3348 ibss_rsn_rx_eapol(wpa_s->ibss_rsn, src_addr, buf, len);
3359 os_memcpy(wpa_s->last_eapol_src, src_addr, ETH_ALEN);
3360 if (!wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) &&
3361 eapol_sm_rx_eapol(wpa_s->eapol, src_addr, buf, len) > 0)
3363 wpa_drv_poll(wpa_s);
3364 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
3365 wpa_sm_rx_eapol(wpa_s->wpa, src_addr, buf, len);
3366 else if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
3373 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
3378 int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
3380 if ((!wpa_s->p2p_mgmt ||
3381 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)) &&
3382 !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_DEDICATED_INTERFACE)) {
3383 l2_packet_deinit(wpa_s->l2);
3384 wpa_s->l2 = l2_packet_init(wpa_s->ifname,
3385 wpa_drv_get_mac_addr(wpa_s),
3387 wpa_supplicant_rx_eapol, wpa_s, 0);
3388 if (wpa_s->l2 == NULL)
3391 const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
3393 os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
3396 if (wpa_s->l2 && l2_packet_get_own_addr(wpa_s->l2, wpa_s->own_addr)) {
3397 wpa_msg(wpa_s, MSG_ERROR, "Failed to get own L2 address");
3401 wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
3410 struct wpa_supplicant *wpa_s = ctx;
3417 if (os_memcmp(eth->h_dest, wpa_s->own_addr, ETH_ALEN) != 0 &&
3419 wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR " to " MACSTR
3425 wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR " to " MACSTR
3427 wpa_supplicant_rx_eapol(wpa_s, src_addr, buf + sizeof(*eth),
3434 * @wpa_s: Pointer to wpa_supplicant data
3441 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
3445 if (wpa_supplicant_update_mac_addr(wpa_s) < 0)
3448 wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR,
3449 MAC2STR(wpa_s->own_addr));
3450 os_memcpy(wpa_s->perm_addr, wpa_s->own_addr, ETH_ALEN);
3451 wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
3453 if (wpa_s->bridge_ifname[0]) {
3454 wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge "
3455 "interface '%s'", wpa_s->bridge_ifname);
3456 wpa_s->l2_br = l2_packet_init_bridge(
3457 wpa_s->bridge_ifname, wpa_s->ifname, wpa_s->own_addr,
3458 ETH_P_EAPOL, wpa_supplicant_rx_eapol_bridge, wpa_s, 1);
3459 if (wpa_s->l2_br == NULL) {
3460 wpa_msg(wpa_s, MSG_ERROR, "Failed to open l2_packet "
3462 wpa_s->bridge_ifname);
3467 if (wpa_s->conf->ap_scan == 2 &&
3468 os_strcmp(wpa_s->driver->name, "nl80211") == 0) {
3473 wpa_clear_keys(wpa_s, NULL);
3477 wpa_drv_set_countermeasures(wpa_s, 0);
3479 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: flushing PMKID list in the driver");
3480 wpa_drv_flush_pmkid(wpa_s);
3482 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
3483 wpa_s->prev_scan_wildcard = 0;
3485 if (wpa_supplicant_enabled_networks(wpa_s)) {
3486 if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
3487 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
3491 if (!wpa_s->p2p_mgmt &&
3492 wpa_supplicant_delayed_sched_scan(wpa_s,
3495 wpa_supplicant_req_scan(wpa_s, interface_count % 3,
3500 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
3516 struct wpa_supplicant *wpa_s;
3518 wpa_s = os_zalloc(sizeof(*wpa_s));
3519 if (wpa_s == NULL)
3521 wpa_s->scan_req = INITIAL_SCAN_REQ;
3522 wpa_s->scan_interval = 5;
3523 wpa_s->new_connection = 1;
3524 wpa_s->parent = parent ? parent : wpa_s;
3525 wpa_s->p2pdev = wpa_s->parent;
3526 wpa_s->sched_scanning = 0;
3528 dl_list_init(&wpa_s->bss_tmp_disallowed);
3530 return wpa_s;
3536 static int wpa_set_htcap_mcs(struct wpa_supplicant *wpa_s,
3553 wpa_msg(wpa_s, MSG_DEBUG, "set_htcap, ht_mcs -:%s:-", ht_mcs);
3559 wpa_msg(wpa_s, MSG_DEBUG,
3568 wpa_msg(wpa_s, MSG_ERROR,
3590 static int wpa_disable_max_amsdu(struct wpa_supplicant *wpa_s,
3597 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_max_amsdu: %d", disabled);
3613 static int wpa_set_ampdu_factor(struct wpa_supplicant *wpa_s,
3618 wpa_msg(wpa_s, MSG_DEBUG, "set_ampdu_factor: %d", factor);
3624 wpa_msg(wpa_s, MSG_ERROR, "ampdu_factor: %d out of range. "
3637 static int wpa_set_ampdu_density(struct wpa_supplicant *wpa_s,
3642 wpa_msg(wpa_s, MSG_DEBUG, "set_ampdu_density: %d", density);
3648 wpa_msg(wpa_s, MSG_ERROR,
3662 static int wpa_set_disable_ht40(struct wpa_supplicant *wpa_s,
3671 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_ht40: %d", disabled);
3684 static int wpa_set_disable_sgi(struct wpa_supplicant *wpa_s,
3693 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_sgi: %d", disabled);
3706 static int wpa_set_disable_ldpc(struct wpa_supplicant *wpa_s,
3714 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_ldpc: %d", disabled);
3728 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
3743 wpa_set_htcap_mcs(wpa_s, htcaps, htcaps_mask, ssid->ht_mcs);
3744 wpa_disable_max_amsdu(wpa_s, htcaps, htcaps_mask,
3746 wpa_set_ampdu_factor(wpa_s, htcaps, htcaps_mask, ssid->ampdu_factor);
3747 wpa_set_ampdu_density(wpa_s, htcaps, htcaps_mask, ssid->ampdu_density);
3748 wpa_set_disable_ht40(wpa_s, htcaps, htcaps_mask, ssid->disable_ht40);
3749 wpa_set_disable_sgi(wpa_s, htcaps, htcaps_mask, ssid->disable_sgi);
3750 wpa_set_disable_ldpc(wpa_s, htcaps, htcaps_mask, ssid->disable_ldpc);
3764 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
3794 wpa_set_ampdu_factor(wpa_s,
3827 static int pcsc_reader_init(struct wpa_supplicant *wpa_s)
3832 if (!wpa_s->conf->pcsc_reader)
3835 wpa_s->scard = scard_init(wpa_s->conf->pcsc_reader);
3836 if (!wpa_s->scard)
3839 if (wpa_s->conf->pcsc_pin &&
3840 scard_set_pin(wpa_s->scard, wpa_s->conf->pcsc_pin) < 0) {
3841 scard_deinit(wpa_s->scard);
3842 wpa_s->scard = NULL;
3843 wpa_msg(wpa_s, MSG_ERROR, "PC/SC PIN validation failed");
3847 len = sizeof(wpa_s->imsi) - 1;
3848 if (scard_get_imsi(wpa_s->scard, wpa_s->imsi, &len)) {
3849 scard_deinit(wpa_s->scard);
3850 wpa_s->scard = NULL;
3851 wpa_msg(wpa_s, MSG_ERROR, "Could not read IMSI");
3854 wpa_s->imsi[len] = '\0';
3856 wpa_s->mnc_len = scard_get_mnc_len(wpa_s->scard);
3859 wpa_s->imsi, wpa_s->mnc_len);
3861 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
3862 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
3869 int wpas_init_ext_pw(struct wpa_supplicant *wpa_s)
3873 ext_password_deinit(wpa_s->ext_pw);
3874 wpa_s->ext_pw = NULL;
3875 eapol_sm_set_ext_pw_ctx(wpa_s->eapol, NULL);
3877 if (!wpa_s->conf->ext_password_backend)
3880 val = os_strdup(wpa_s->conf->ext_password_backend);
3889 wpa_s->ext_pw = ext_password_init(val, pos);
3891 if (wpa_s->ext_pw == NULL) {
3895 eapol_sm_set_ext_pw_ctx(wpa_s->eapol, wpa_s->ext_pw);
3905 struct wpa_supplicant *wpa_s = ctx;
3907 return (is_zero_ether_addr(wpa_s->bssid) ||
3908 wpa_s->wpa_state != WPA_COMPLETED) ? NULL : wpa_s->bssid;
3916 struct wpa_supplicant *wpa_s = ctx;
3918 if (wpa_s->current_bss) {
3919 *hw_mode = ieee80211_freq_to_chan(wpa_s->current_bss->freq,
3921 } else if (wpa_s->hw.num_modes) {
3922 *hw_mode = wpa_s->hw.modes[0].mode;
3932 struct wpa_supplicant *wpa_s = ctx;
3934 *modes = wpa_s->hw.modes;
3935 return wpa_s->hw.num_modes;
3941 struct wpa_supplicant *wpa_s = ctx;
3944 wpa_s->fst_ies = fst_ies;
3950 struct wpa_supplicant *wpa_s = ctx;
3952 WPA_ASSERT(os_memcmp(wpa_s->bssid, da, ETH_ALEN) == 0);
3953 return wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
3954 wpa_s->own_addr, wpa_s->bssid,
3962 struct wpa_supplicant *wpa_s = ctx;
3964 WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
3965 return wpa_s->received_mb_ies;
3972 struct wpa_supplicant *wpa_s = ctx;
3975 WPA_ASSERT(os_memcmp(wpa_s->bssid, addr, ETH_ALEN) == 0);
3978 wpabuf_free(wpa_s->received_mb_ies);
3979 wpa_s->received_mb_ies = mb_ies_by_info(&info);
3987 struct wpa_supplicant *wpa_s = ctx;
3990 if (!is_zero_ether_addr(wpa_s->bssid))
3991 return (wpa_s->received_mb_ies || !mb_only) ?
3992 wpa_s->bssid : NULL;
4003 void fst_wpa_supplicant_fill_iface_obj(struct wpa_supplicant *wpa_s,
4006 iface_obj->ctx = wpa_s;
4019 static int wpas_set_wowlan_triggers(struct wpa_supplicant *wpa_s,
4025 if (!wpa_s->conf->wowlan_triggers)
4028 triggers = wpa_get_wowlan_triggers(wpa_s->conf->wowlan_triggers, capa);
4030 ret = wpa_drv_wowlan(wpa_s, triggers);
4047 unsigned int wpas_get_bands(struct wpa_supplicant *wpa_s, const int *freqs)
4061 for (i = 0; i < wpa_s->hw.num_modes; i++) {
4062 if (wpa_s->hw.modes[i].num_channels != 0) {
4063 if (wpa_s->hw.modes[i].mode ==
4065 wpa_s->hw.modes[i].mode ==
4068 else if (wpa_s->hw.modes[i].mode ==
4071 else if (wpa_s->hw.modes[i].mode ==
4074 else if (wpa_s->hw.modes[i].mode ==
4086 wpa_s,
4089 struct wpa_supplicant *iface = wpa_s->global->ifaces;
4096 wpa_s->ifname, rn);
4097 dl_list_add(&radio->ifaces, &wpa_s->radio_list);
4105 wpa_s->ifname, rn ? rn : "N/A");
4114 dl_list_add(&radio->ifaces, &wpa_s->radio_list);
4122 if (work->wpa_s->scan_work == work) {
4124 wpa_dbg(work->wpa_s, MSG_INFO, "Freeing radio work '%s'@%p (started=%d) that is marked as scan_work",
4126 work->wpa_s->scan_work = NULL;
4130 if (work->wpa_s->p2p_scan_work == work) {
4132 wpa_dbg(work->wpa_s, MSG_INFO, "Freeing radio work '%s'@%p (started=%d) that is marked as p2p_scan_work",
4134 work->wpa_s->p2p_scan_work = NULL;
4139 work->wpa_s->radio->num_active_works--;
4140 wpa_dbg(work->wpa_s, MSG_DEBUG,
4143 work->wpa_s->radio->num_active_works);
4173 tmp->wpa_s->clear_driver_scan_cache))
4186 wpa_dbg(active_work->wpa_s, MSG_DEBUG,
4220 tmp->wpa_s->clear_driver_scan_cache))
4223 wpa_dbg(active_work->wpa_s, MSG_DEBUG,
4240 struct wpa_supplicant *wpa_s;
4248 wpa_s = dl_list_first(&radio->ifaces, struct wpa_supplicant,
4251 if (!(wpa_s &&
4252 wpa_s->drv_flags & WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS)) {
4256 if (wpa_s && wpa_s->radio->external_scan_running) {
4270 wpa_s = work->wpa_s;
4273 wpa_dbg(wpa_s, MSG_DEBUG,
4282 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS) &&
4284 radio_work_check_next(wpa_s);
4294 * @wpa_s: wpa_supplicant data
4299 void radio_remove_works(struct wpa_supplicant *wpa_s,
4303 struct wpa_radio *radio = wpa_s->radio;
4311 if (!remove_all && work->wpa_s != wpa_s)
4314 wpa_dbg(wpa_s, MSG_DEBUG, "Remove radio work '%s'@%p%s",
4321 radio_work_check_next(wpa_s);
4325 static void radio_remove_interface(struct wpa_supplicant *wpa_s)
4327 struct wpa_radio *radio = wpa_s->radio;
4333 wpa_s->ifname, radio->name);
4334 dl_list_del(&wpa_s->radio_list);
4335 radio_remove_works(wpa_s, NULL, 0);
4336 wpa_s->radio = NULL;
4346 void radio_work_check_next(struct wpa_supplicant *wpa_s)
4348 struct wpa_radio *radio = wpa_s->radio;
4352 if (wpa_s->ext_work_in_progress) {
4364 * @wpa_s: Pointer to wpa_supplicant data
4387 int radio_add_work(struct wpa_supplicant *wpa_s, unsigned int freq,
4392 struct wpa_radio *radio = wpa_s->radio;
4399 wpa_dbg(wpa_s, MSG_DEBUG, "Add radio work '%s'@%p", type, work);
4403 work->wpa_s = wpa_s;
4411 work->bands = wpas_get_bands(wpa_s,
4415 work->bands = wpas_get_bands(wpa_s, NULL);
4417 was_empty = dl_list_empty(&wpa_s->radio->work);
4419 dl_list_add(&wpa_s->radio->work, &work->list);
4421 dl_list_add_tail(&wpa_s->radio->work, &work->list);
4423 wpa_dbg(wpa_s, MSG_DEBUG, "First radio work item in the queue - schedule start immediately");
4424 radio_work_check_next(wpa_s);
4425 } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_OFFCHANNEL_SIMULTANEOUS)
4427 wpa_dbg(wpa_s, MSG_DEBUG,
4430 radio_work_check_next(wpa_s);
4446 struct wpa_supplicant *wpa_s = work->wpa_s;
4452 wpa_dbg(wpa_s, MSG_DEBUG, "Radio work '%s'@%p %s in %ld.%06ld seconds",
4457 radio_work_check_next(wpa_s);
4462 radio_work_pending(struct wpa_supplicant *wpa_s, const char *type)
4465 struct wpa_radio *radio = wpa_s->radio;
4468 if (work->wpa_s == wpa_s && os_strcmp(work->type, type) == 0)
4476 static int wpas_init_driver(struct wpa_supplicant *wpa_s,
4483 if (wpa_supplicant_set_driver(wpa_s, driver) < 0)
4486 wpa_s->drv_priv = wpa_drv_init(wpa_s, wpa_s->ifname);
4487 if (wpa_s->drv_priv == NULL) {
4491 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
4496 wpa_msg(wpa_s, MSG_ERROR, "Failed to initialize driver "
4500 if (wpa_drv_set_param(wpa_s, wpa_s->conf->driver_param) < 0) {
4501 wpa_msg(wpa_s, MSG_ERROR, "Driver interface rejected "
4502 "driver_param '%s'", wpa_s->conf->driver_param);
4506 ifname = wpa_drv_get_ifname(wpa_s);
4507 if (ifname && os_strcmp(ifname, wpa_s->ifname) != 0) {
4508 wpa_dbg(wpa_s, MSG_DEBUG, "Driver interface replaced "
4510 os_strlcpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
4513 rn = wpa_driver_get_radio_name(wpa_s);
4517 wpa_s->radio = radio_add_interface(wpa_s, rn);
4518 if (wpa_s->radio == NULL)
4525 static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
4540 wpa_s->confname = os_rel2abs_path(iface->confname);
4541 if (wpa_s->confname == NULL) {
4548 iface->confname, wpa_s->confname);
4550 wpa_s->confname = os_strdup(iface->confname);
4552 wpa_s->conf = wpa_config_read(wpa_s->confname, NULL);
4553 if (wpa_s->conf == NULL) {
4555 "configuration '%s'.", wpa_s->confname);
4558 wpa_s->confanother = os_rel2abs_path(iface->confanother);
4559 wpa_config_read(wpa_s->confanother, wpa_s->conf);
4566 os_free(wpa_s->conf->ctrl_interface);
4567 wpa_s->conf->ctrl_interface =
4572 os_free(wpa_s->conf->driver_param);
4573 wpa_s->conf->driver_param =
4578 os_free(wpa_s->conf->ctrl_interface);
4579 wpa_s->conf->ctrl_interface = NULL;
4582 wpa_s->conf = wpa_config_alloc_empty(iface->ctrl_interface,
4585 if (wpa_s->conf == NULL) {
4594 if (os_strlen(iface->ifname) >= sizeof(wpa_s->ifname)) {
4599 os_strlcpy(wpa_s->ifname, iface->ifname, sizeof(wpa_s->ifname));
4603 sizeof(wpa_s->bridge_ifname)) {
4608 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
4609 sizeof(wpa_s->bridge_ifname));
4613 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
4614 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
4620 if (wpas_init_driver(wpa_s, iface) < 0)
4623 if (wpa_supplicant_init_wpa(wpa_s) < 0)
4626 wpa_sm_set_ifname(wpa_s->wpa, wpa_s->ifname,
4627 wpa_s->bridge_ifname[0] ? wpa_s->bridge_ifname :
4629 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
4631 if (wpa_s->conf->dot11RSNAConfigPMKLifetime &&
4632 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_LIFETIME,
4633 wpa_s->conf->dot11RSNAConfigPMKLifetime)) {
4634 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
4639 if (wpa_s->conf->dot11RSNAConfigPMKReauthThreshold &&
4640 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_REAUTH_THRESHOLD,
4641 wpa_s->conf->dot11RSNAConfigPMKReauthThreshold)) {
4642 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
4647 if (wpa_s->conf->dot11RSNAConfigSATimeout &&
4648 wpa_sm_set_param(wpa_s->wpa, RSNA_SA_TIMEOUT,
4649 wpa_s->conf->dot11RSNAConfigSATimeout)) {
4650 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
4655 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(wpa_s,
4656 &wpa_s->hw.num_modes,
4657 &wpa_s->hw.flags);
4658 if (wpa_s->hw.modes) {
4661 for (i = 0; i < wpa_s->hw.num_modes; i++) {
4662 if (wpa_s->hw.modes[i].vht_capab) {
4663 wpa_s->hw_capab = CAPAB_VHT;
4667 if (wpa_s->hw.modes[i].ht_capab &
4669 wpa_s->hw_capab = CAPAB_HT40;
4670 else if (wpa_s->hw.modes[i].ht_capab &&
4671 wpa_s->hw_capab == CAPAB_NO_HT_VHT)
4672 wpa_s->hw_capab = CAPAB_HT;
4676 capa_res = wpa_drv_get_capa(wpa_s, &capa);
4678 wpa_s->drv_capa_known = 1;
4679 wpa_s->drv_flags = capa.flags;
4680 wpa_s->drv_enc = capa.enc;
4681 wpa_s->drv_smps_modes = capa.smps_modes;
4682 wpa_s->drv_rrm_flags = capa.rrm_flags;
4683 wpa_s->probe_resp_offloads = capa.probe_resp_offloads;
4684 wpa_s->max_scan_ssids = capa.max_scan_ssids;
4685 wpa_s->max_sched_scan_ssids = capa.max_sched_scan_ssids;
4686 wpa_s->max_sched_scan_plans = capa.max_sched_scan_plans;
4687 wpa_s->max_sched_scan_plan_interval =
4689 wpa_s->max_sched_scan_plan_iterations =
4691 wpa_s->sched_scan_supported = capa.sched_scan_supported;
4692 wpa_s->max_match_sets = capa.max_match_sets;
4693 wpa_s->max_remain_on_chan = capa.max_remain_on_chan;
4694 wpa_s->max_stations = capa.max_stations;
4695 wpa_s->extended_capa = capa.extended_capa;
4696 wpa_s->extended_capa_mask = capa.extended_capa_mask;
4697 wpa_s->extended_capa_len = capa.extended_capa_len;
4698 wpa_s->num_multichan_concurrent =
4700 wpa_s->wmm_ac_supported = capa.wmm_ac_supported;
4703 wpa_s->mac_addr_rand_supported |= MAC_ADDR_RAND_SCAN;
4704 if (wpa_s->sched_scan_supported &&
4706 wpa_s->mac_addr_rand_supported |=
4709 if (wpa_s->max_remain_on_chan == 0)
4710 wpa_s->max_remain_on_chan = 1000;
4717 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE)
4718 wpa_s->p2p_mgmt = iface->p2p_mgmt;
4722 if (wpa_s->num_multichan_concurrent == 0)
4723 wpa_s->num_multichan_concurrent = 1;
4725 if (wpa_supplicant_driver_init(wpa_s) < 0)
4730 !(wpa_s->drv_flags &
4732 wpa_tdls_init(wpa_s->wpa))
4736 if (wpa_s->conf->country[0] && wpa_s->conf->country[1] &&
4737 wpa_drv_set_country(wpa_s, wpa_s->conf->country)) {
4738 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to set country");
4743 if (wpa_s->conf->fst_group_id) {
4747 fst_wpa_supplicant_fill_iface_obj(wpa_s, &iface_obj);
4748 os_strlcpy(cfg.group_id, wpa_s->conf->fst_group_id,
4750 cfg.priority = wpa_s->conf->fst_priority;
4751 cfg.llt = wpa_s->conf->fst_llt;
4753 wpa_s->fst = fst_attach(wpa_s->ifname, wpa_s->own_addr,
4755 if (!wpa_s->fst) {
4756 wpa_msg(wpa_s, MSG_ERROR,
4758 wpa_s->ifname, cfg.group_id);
4764 if (wpas_wps_init(wpa_s))
4767 if (wpa_supplicant_init_eapol(wpa_s) < 0)
4769 wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
4771 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
4772 if (wpa_s->ctrl_iface == NULL) {
4781 wpa_s->conf->ctrl_interface);
4785 wpa_s->gas = gas_query_init(wpa_s);
4786 if (wpa_s->gas == NULL) {
4791 if (iface->p2p_mgmt && wpas_p2p_init(wpa_s->global, wpa_s) < 0) {
4792 wpa_msg(wpa_s, MSG_ERROR, "Failed to init P2P");
4796 if (wpa_bss_init(wpa_s) < 0)
4804 if (capa_res == 0 && wpas_set_wowlan_triggers(wpa_s, &capa) < 0)
4810 wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, wpa_s->imsi,
4812 if (wpa_s->mnc_len > 0) {
4813 wpa_s->imsi[len] = '\0';
4815 wpa_s->imsi, wpa_s->mnc_len);
4822 if (pcsc_reader_init(wpa_s) < 0)
4825 if (wpas_init_ext_pw(wpa_s) < 0)
4828 wpas_rrm_reset(wpa_s);
4830 wpas_sched_scan_plans_set(wpa_s, wpa_s->conf->sched_scan_plans);
4833 hs20_init(wpa_s);
4836 wpas_mbo_update_non_pref_chan(wpa_s, wpa_s->conf->non_pref_chan);
4843 static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
4846 struct wpa_global *global = wpa_s->global;
4849 if (wpa_s == wpa_s->parent)
4850 wpas_p2p_group_remove(wpa_s, "*");
4854 if (iface->p2pdev == wpa_s)
4856 if (iface == wpa_s || iface->parent != wpa_s) {
4862 iface->ifname, wpa_s->ifname);
4868 wpa_s->disconnected = 1;
4869 if (wpa_s->drv_priv) {
4870 wpa_supplicant_deauthenticate(wpa_s,
4873 wpa_drv_set_countermeasures(wpa_s, 0);
4874 wpa_clear_keys(wpa_s, NULL);
4877 wpa_supplicant_cleanup(wpa_s);
4878 wpas_p2p_deinit_iface(wpa_s);
4880 wpas_ctrl_radio_work_flush(wpa_s);
4881 radio_remove_interface(wpa_s);
4884 if (wpa_s->fst) {
4885 fst_detach(wpa_s->fst);
4886 wpa_s->fst = NULL;
4888 if (wpa_s->received_mb_ies) {
4889 wpabuf_free(wpa_s->received_mb_ies);
4890 wpa_s->received_mb_ies = NULL;
4894 if (wpa_s->drv_priv)
4895 wpa_drv_deinit(wpa_s);
4898 wpas_notify_iface_removed(wpa_s);
4901 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
4903 if (wpa_s->ctrl_iface) {
4904 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
4905 wpa_s->ctrl_iface = NULL;
4909 if (wpa_s->ifmsh) {
4910 wpa_supplicant_mesh_iface_deinit(wpa_s, wpa_s->ifmsh);
4911 wpa_s->ifmsh = NULL;
4915 if (wpa_s->conf != NULL) {
4916 wpa_config_free(wpa_s->conf);
4917 wpa_s->conf = NULL;
4920 os_free(wpa_s->ssids_from_scan_req);
4922 os_free(wpa_s);
4965 struct wpa_supplicant *wpa_s;
4975 wpa_s = wpa_supplicant_get_iface(global, ifi->if_name);
4976 if (wpa_s)
4980 wpa_s = wpa_supplicant_add_iface(global, iface, NULL);
4982 if (wpa_s)
4983 wpa_s->matched = 1;
5011 struct wpa_supplicant *wpa_s;
5018 wpa_s = wpa_supplicant_alloc(parent);
5019 if (wpa_s == NULL)
5022 wpa_s->global = global;
5039 if (wpa_supplicant_init_iface(wpa_s, &t_iface)) {
5042 wpa_supplicant_deinit_iface(wpa_s, 0, 0);
5048 if (wpas_notify_iface_added(wpa_s)) {
5049 wpa_supplicant_deinit_iface(wpa_s, 1, 0);
5053 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
5054 wpas_notify_network_added(wpa_s, ssid);
5057 wpa_s->next = global->ifaces;
5058 global->ifaces = wpa_s;
5060 wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname);
5061 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
5064 if (wpa_s->global->p2p == NULL &&
5065 !wpa_s->global->p2p_disabled && !wpa_s->conf->p2p_disabled &&
5066 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_DEDICATED_P2P_DEVICE) &&
5068 wpa_s, wpa_s->global->params.conf_p2p_dev) < 0) {
5075 return wpa_s;
5082 * @wpa_s: Pointer to the network interface to be removed
5091 struct wpa_supplicant *wpa_s,
5096 unsigned int mesh_if_created = wpa_s->mesh_if_created;
5102 if (prev == wpa_s) {
5103 global->ifaces = wpa_s->next;
5105 while (prev && prev->next != wpa_s)
5109 prev->next = wpa_s->next;
5112 wpa_dbg(wpa_s, MSG_DEBUG, "Removing interface %s", wpa_s->ifname);
5116 ifname = os_strdup(wpa_s->ifname);
5118 wpa_dbg(wpa_s, MSG_ERROR,
5125 if (global->p2p_group_formation == wpa_s)
5127 if (global->p2p_invite_group == wpa_s)
5129 wpa_supplicant_deinit_iface(wpa_s, 1, terminate);
5144 * @wpa_s: Pointer to the network interface
5147 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s)
5151 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) == 0 &&
5152 wpa_s->key_mgmt != WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
5156 eapol_method = eapol_sm_get_method_name(wpa_s->eapol);
5173 struct wpa_supplicant *wpa_s;
5175 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
5176 if (os_strcmp(wpa_s->ifname, ifname) == 0)
5177 return wpa_s;
5186 struct wpa_supplicant *wpa_s = ctx;
5187 if (wpa_s == NULL)
5189 return wpa_s->ifname;
5202 struct wpa_supplicant *wpa_s;
5212 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
5213 wpa_bss_flush_by_age(wpa_s, wpa_s->conf->bss_expiration_age);
5215 ap_periodic(wpa_s);
5379 struct wpa_supplicant *wpa_s;
5392 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
5393 if (wpa_s->ctrl_iface && !wpa_s->p2p_mgmt)
5395 wpa_s->ctrl_iface);
5477 void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s)
5479 if ((wpa_s->conf->changed_parameters & CFG_CHANGED_COUNTRY) &&
5480 wpa_s->conf->country[0] && wpa_s->conf->country[1]) {
5482 country[0] = wpa_s->conf->country[0];
5483 country[1] = wpa_s->conf->country[1];
5485 if (wpa_drv_set_country(wpa_s, country) < 0) {
5491 if (wpa_s->conf->changed_parameters & CFG_CHANGED_EXT_PW_BACKEND)
5492 wpas_init_ext_pw(wpa_s);
5494 if (wpa_s->conf->changed_parameters & CFG_CHANGED_SCHED_SCAN_PLANS)
5495 wpas_sched_scan_plans_set(wpa_s, wpa_s->conf->sched_scan_plans);
5498 wpas_wps_update_config(wpa_s);
5500 wpas_p2p_update_config(wpa_s);
5501 wpa_s->conf->changed_parameters = 0;
5519 static int * get_bss_freqs_in_ess(struct wpa_supplicant *wpa_s)
5530 cbss = wpa_s->current_bss;
5532 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
5537 wpa_blacklist_get(wpa_s, bss->bssid) == NULL) {
5553 void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid)
5559 wpas_connect_work_done(wpa_s);
5564 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
5570 if (wpa_s->own_disconnect_req) {
5571 wpa_s->own_disconnect_req = 0;
5572 wpa_dbg(wpa_s, MSG_DEBUG,
5576 if (wpa_s->disconnected) {
5577 wpa_dbg(wpa_s, MSG_DEBUG, "Ignore connection failure "
5591 count = wpa_blacklist_add(wpa_s, bssid);
5592 if (count == 1 && wpa_s->current_bss) {
5599 freqs = get_bss_freqs_in_ess(wpa_s);
5601 wpa_dbg(wpa_s, MSG_DEBUG, "Another BSS in this ESS "
5603 wpa_blacklist_add(wpa_s, bssid);
5609 os_free(wpa_s->next_scan_freqs);
5610 wpa_s->next_scan_freqs = freqs;
5618 count += wpa_s->extra_blacklist_count;
5620 if (count > 3 && wpa_s->current_ssid) {
5623 wpas_auth_failed(wpa_s, "CONN_FAILED");
5644 wpa_dbg(wpa_s, MSG_DEBUG, "Blacklist count %d --> request scan in %d "
5651 wpa_supplicant_req_scan(wpa_s, timeout / 1000,
5656 int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s)
5658 return wpa_s->conf->ap_scan == 2 ||
5659 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION);
5664 int wpa_supplicant_ctrl_iface_ctrl_rsp_handle(struct wpa_supplicant *wpa_s,
5682 if (ssid == wpa_s->current_ssid)
5683 wpa_s->reassociate = 1;
5690 if (ssid == wpa_s->current_ssid)
5691 wpa_s->reassociate = 1;
5698 if (ssid == wpa_s->current_ssid)
5699 wpa_s->reassociate = 1;
5705 if (ssid == wpa_s->current_ssid)
5706 wpa_s->reassociate = 1;
5720 if (ssid == wpa_s->current_ssid)
5721 wpa_s->reassociate = 1;
5733 if (wpa_s->wpa_state == WPA_SCANNING && !wpa_s->scanning)
5734 wpa_supplicant_req_scan(wpa_s, 0, 0);
5760 int wpas_network_disabled(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
5765 if (wpa_s->p2p_mgmt)
5774 if (wpa_s->drv_capa_known)
5775 drv_enc = wpa_s->drv_enc;
5801 int wpas_get_ssid_pmf(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
5805 if (wpa_s->conf->pmf == MGMT_FRAME_PROTECTION_OPTIONAL &&
5806 !(wpa_s->drv_enc & WPA_DRIVER_CAPA_ENC_BIP)) {
5815 return wpa_s->conf->pmf;
5825 int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s)
5827 if (wpa_s->global->conc_pref == WPA_CONC_PREF_P2P)
5829 if (wpa_s->global->conc_pref == WPA_CONC_PREF_STA)
5835 void wpas_auth_failed(struct wpa_supplicant *wpa_s, char *reason)
5837 struct wpa_ssid *ssid = wpa_s->current_ssid;
5854 (wpa_s->p2p_in_provisioning || wpa_s->show_group_started)) {
5888 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TEMP_DISABLED
5895 void wpas_clear_temp_disabled(struct wpa_supplicant *wpa_s,
5902 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_REENABLED
5913 int disallowed_bssid(struct wpa_supplicant *wpa_s, const u8 *bssid)
5917 if (wpa_s->disallow_aps_bssid == NULL)
5920 for (i = 0; i < wpa_s->disallow_aps_bssid_count; i++) {
5921 if (os_memcmp(wpa_s->disallow_aps_bssid + i * ETH_ALEN,
5930 int disallowed_ssid(struct wpa_supplicant *wpa_s, const u8 *ssid,
5935 if (wpa_s->disallow_aps_ssid == NULL || ssid == NULL)
5938 for (i = 0; i < wpa_s->disallow_aps_ssid_count; i++) {
5939 struct wpa_ssid_value *s = &wpa_s->disallow_aps_ssid[i];
5951 * @wpa_s: Pointer to the network interface
5957 void wpas_request_connection(struct wpa_supplicant *wpa_s)
5959 wpa_s->normal_scans = 0;
5960 wpa_s->scan_req = NORMAL_SCAN_REQ;
5961 wpa_supplicant_reinit_autoscan(wpa_s);
5962 wpa_s->extra_blacklist_count = 0;
5963 wpa_s->disconnected = 0;
5964 wpa_s->reassociate = 1;
5966 if (wpa_supplicant_fast_associate(wpa_s) != 1)
5967 wpa_supplicant_req_scan(wpa_s, 0, 0);
5969 wpa_s->reattach = 0;
5973 void dump_freq_data(struct wpa_supplicant *wpa_s, const char *title,
5979 wpa_dbg(wpa_s, MSG_DEBUG, "Shared frequencies (len=%u): %s",
5983 wpa_dbg(wpa_s, MSG_DEBUG, "freq[%u]: %d, flags=0x%X",
5994 int get_shared_radio_freqs_data(struct wpa_supplicant *wpa_s,
6003 wpa_dbg(wpa_s, MSG_DEBUG,
6007 dl_list_for_each(ifs, &wpa_s->radio->ifaces, struct wpa_supplicant,
6039 dump_freq_data(wpa_s, "completed iteration", freqs_data, idx);
6048 int get_shared_radio_freqs(struct wpa_supplicant *wpa_s,
6060 num = get_shared_radio_freqs_data(wpa_s, freqs_data, len);
6090 * @wpa_s: Pointer to wpa_supplicant
6092 void wpas_rrm_reset(struct wpa_supplicant *wpa_s)
6094 wpa_s->rrm.rrm_used = 0;
6096 eloop_cancel_timeout(wpas_rrm_neighbor_rep_timeout_handler, &wpa_s->rrm,
6098 if (wpa_s->rrm.notify_neighbor_rep)
6099 wpas_rrm_neighbor_rep_timeout_handler(&wpa_s->rrm, NULL);
6100 wpa_s->rrm.next_neighbor_rep_token = 1;
6106 * @wpa_s: Pointer to wpa_supplicant
6110 void wpas_rrm_process_neighbor_rep(struct wpa_supplicant *wpa_s,
6119 if (report[0] != wpa_s->rrm.next_neighbor_rep_token - 1) {
6122 report[0], wpa_s->rrm.next_neighbor_rep_token - 1);
6126 eloop_cancel_timeout(wpas_rrm_neighbor_rep_timeout_handler, &wpa_s->rrm,
6129 if (!wpa_s->rrm.notify_neighbor_rep) {
6141 wpa_s->rrm.notify_neighbor_rep(wpa_s->rrm.neighbor_rep_cb_ctx,
6143 wpa_s->rrm.notify_neighbor_rep = NULL;
6144 wpa_s->rrm.neighbor_rep_cb_ctx = NULL;
6157 * @wpa_s: Pointer to wpa_supplicant
6172 int wpas_rrm_send_neighbor_rep_request(struct wpa_supplicant *wpa_s,
6181 if (wpa_s->wpa_state != WPA_COMPLETED || wpa_s->current_ssid == NULL) {
6186 if (!wpa_s->rrm.rrm_used) {
6191 rrm_ie = wpa_bss_get_ie(wpa_s->current_bss,
6193 if (!rrm_ie || !(wpa_s->current_bss->caps & IEEE80211_CAP_RRM) ||
6207 if (wpa_s->rrm.notify_neighbor_rep) {
6223 wpa_s->rrm.next_neighbor_rep_token);
6227 wpabuf_put_u8(buf, wpa_s->rrm.next_neighbor_rep_token);
6234 wpa_s->rrm.next_neighbor_rep_token++;
6236 if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
6237 wpa_s->own_addr, wpa_s->bssid,
6245 wpa_s->rrm.neighbor_rep_cb_ctx = cb_ctx;
6246 wpa_s->rrm.notify_neighbor_rep = cb;
6249 &wpa_s->rrm, NULL);
6256 void wpas_rrm_handle_link_measurement_request(struct wpa_supplicant *wpa_s,
6265 if (wpa_s->wpa_state != WPA_COMPLETED) {
6271 if (!wpa_s->rrm.rrm_used) {
6277 if (!(wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_TX_POWER_INSERTION)) {
6325 if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, src,
6326 wpa_s->own_addr, wpa_s->bssid,
6336 wpas_vendor_elem(struct wpa_supplicant *wpa_s, enum wpa_vendor_elem_frame frame)
6353 return wpa_s->p2pdev;
6356 return wpa_s;
6361 void wpas_vendor_elem_update(struct wpa_supplicant *wpa_s)
6369 if (wpa_s->vendor_elem[i]) {
6375 wpa_s->vendor_elem[i]);
6381 if (wpa_s->parent == wpa_s &&
6382 wpa_s->global->p2p &&
6383 !wpa_s->global->p2p_disabled)
6384 p2p_set_vendor_elems(wpa_s->global->p2p, wpa_s->vendor_elem);
6389 int wpas_vendor_elem_remove(struct wpa_supplicant *wpa_s, int frame,
6394 ie = wpabuf_mhead_u8(wpa_s->vendor_elem[frame]);
6395 end = ie + wpabuf_len(wpa_s->vendor_elem[frame]);
6403 if (wpabuf_len(wpa_s->vendor_elem[frame]) == len) {
6404 wpabuf_free(wpa_s->vendor_elem[frame]);
6405 wpa_s->vendor_elem[frame] = NULL;
6408 wpa_s->vendor_elem[frame]->used -= len;
6410 wpas_vendor_elem_update(wpa_s);
6433 wpa_bss_tmp_disallowed * wpas_get_disallowed_bss(struct wpa_supplicant *wpa_s,
6438 dl_list_for_each(bss, &wpa_s->bss_tmp_disallowed,
6448 void wpa_bss_tmp_disallow(struct wpa_supplicant *wpa_s, const u8 *bssid,
6457 bss = wpas_get_disallowed_bss(wpa_s, bssid);
6472 dl_list_add(&wpa_s->bss_tmp_disallowed, &bss->list);
6476 int wpa_is_bss_tmp_disallowed(struct wpa_supplicant *wpa_s, const u8 *bssid)
6483 dl_list_for_each_safe(tmp, prev, &wpa_s->bss_tmp_disallowed,