Lines Matching refs:wpa_s
107 int wpa_set_wep_keys(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
116 wpa_drv_set_key(wpa_s, WPA_ALG_WEP, NULL,
125 static int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
137 wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid mode %d (not "
143 wpa_msg(wpa_s, MSG_INFO, "WPA: No PSK configured for "
148 switch (wpa_s->group_cipher) {
162 wpa_msg(wpa_s, MSG_INFO, "WPA: Invalid group cipher %d for "
163 "WPA-None", wpa_s->group_cipher);
170 return wpa_drv_set_key(wpa_s, alg, NULL, 0, 1, seq, 6, key, keylen);
176 struct wpa_supplicant *wpa_s = eloop_ctx;
177 const u8 *bssid = wpa_s->bssid;
179 bssid = wpa_s->pending_bssid;
180 wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
182 wpa_blacklist_add(wpa_s, bssid);
183 wpa_sm_notify_disassoc(wpa_s->wpa);
184 wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
185 wpa_s->reassociate = 1;
191 wpa_supplicant_req_scan(wpa_s, 1, 0);
197 * @wpa_s: Pointer to wpa_supplicant data
204 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
207 if (wpa_s->conf && wpa_s->conf->ap_scan == 0 &&
208 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED))
211 wpa_dbg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec "
213 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
214 eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL);
220 * @wpa_s: Pointer to wpa_supplicant data
226 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s)
228 wpa_dbg(wpa_s, MSG_DEBUG, "Cancelling authentication timeout");
229 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
230 wpa_blacklist_del(wpa_s, wpa_s->bssid);
236 * @wpa_s: Pointer to wpa_supplicant data
241 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s)
245 struct wpa_ssid *ssid = wpa_s->current_ssid;
249 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
250 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE) {
255 eapol_sm_notify_portControl(wpa_s->eapol, ForceAuthorized);
256 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
257 eapol_sm_notify_eap_fail(wpa_s->eapol, FALSE);
262 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
263 eapol_sm_notify_eap_fail(wpa_s->eapol, FALSE);
265 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
266 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
267 eapol_sm_notify_portControl(wpa_s->eapol, ForceAuthorized);
269 eapol_sm_notify_portControl(wpa_s->eapol, Auto);
272 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
283 if (wpa_s->conf && (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED))
286 if (wpa_s->conf)
287 eapol_conf.fast_reauth = wpa_s->conf->fast_reauth;
290 !wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) &&
291 wpa_s->key_mgmt != WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
292 wpa_s->key_mgmt != WPA_KEY_MGMT_WPS;
293 eapol_sm_notify_config(wpa_s->eapol, &ssid->eap, &eapol_conf);
300 * @wpa_s: Pointer to wpa_supplicant data
307 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
313 wpa_s->key_mgmt = WPA_KEY_MGMT_WPS;
315 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
317 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
318 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
319 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
320 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
321 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
322 wpa_s->group_cipher = WPA_CIPHER_NONE;
323 wpa_s->mgmt_group_cipher = 0;
327 wpa_s->pairwise_cipher = WPA_CIPHER_WEP104;
328 wpa_s->group_cipher = WPA_CIPHER_WEP104;
331 wpa_s->pairwise_cipher = WPA_CIPHER_WEP40;
332 wpa_s->group_cipher = WPA_CIPHER_WEP40;
337 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED, 0);
338 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
339 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
340 wpa_s->pairwise_cipher);
341 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
343 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
344 wpa_s->mgmt_group_cipher);
347 pmksa_cache_clear_current(wpa_s->wpa);
351 static void free_hw_features(struct wpa_supplicant *wpa_s)
354 if (wpa_s->hw.modes == NULL)
357 for (i = 0; i < wpa_s->hw.num_modes; i++) {
358 os_free(wpa_s->hw.modes[i].channels);
359 os_free(wpa_s->hw.modes[i].rates);
362 os_free(wpa_s->hw.modes);
363 wpa_s->hw.modes = NULL;
367 static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
369 bgscan_deinit(wpa_s);
370 scard_deinit(wpa_s->scard);
371 wpa_s->scard = NULL;
372 wpa_sm_set_scard_ctx(wpa_s->wpa, NULL);
373 eapol_sm_register_scard_ctx(wpa_s->eapol, NULL);
374 l2_packet_deinit(wpa_s->l2);
375 wpa_s->l2 = NULL;
376 if (wpa_s->l2_br) {
377 l2_packet_deinit(wpa_s->l2_br);
378 wpa_s->l2_br = NULL;
381 if (wpa_s->conf != NULL) {
383 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
384 wpas_notify_network_removed(wpa_s, ssid);
387 os_free(wpa_s->confname);
388 wpa_s->confname = NULL;
390 wpa_sm_set_eapol(wpa_s->wpa, NULL);
391 eapol_sm_deinit(wpa_s->eapol);
392 wpa_s->eapol = NULL;
394 rsn_preauth_deinit(wpa_s->wpa);
397 wpa_tdls_deinit(wpa_s->wpa);
400 pmksa_candidate_free(wpa_s->wpa);
401 wpa_sm_deinit(wpa_s->wpa);
402 wpa_s->wpa = NULL;
403 wpa_blacklist_clear(wpa_s);
405 wpa_bss_deinit(wpa_s);
407 wpa_supplicant_cancel_scan(wpa_s);
408 wpa_supplicant_cancel_auth_timeout(wpa_s);
409 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures, wpa_s, NULL);
412 wpa_s, NULL);
415 wpas_wps_deinit(wpa_s);
417 wpabuf_free(wpa_s->pending_eapol_rx);
418 wpa_s->pending_eapol_rx = NULL;
421 ibss_rsn_deinit(wpa_s->ibss_rsn);
422 wpa_s->ibss_rsn = NULL;
425 sme_deinit(wpa_s);
428 wpa_supplicant_ap_deinit(wpa_s);
432 wpas_p2p_deinit(wpa_s);
436 offchannel_deinit(wpa_s);
439 wpa_supplicant_cancel_sched_scan(wpa_s);
441 os_free(wpa_s->next_scan_freqs);
442 wpa_s->next_scan_freqs = NULL;
444 gas_query_deinit(wpa_s->gas);
445 wpa_s->gas = NULL;
447 free_hw_features(wpa_s);
453 * @wpa_s: Pointer to wpa_supplicant data
459 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr)
461 if (wpa_s->keys_cleared) {
469 wpa_dbg(wpa_s, MSG_DEBUG, "No keys have been configured - "
475 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 0, 0, NULL, 0, NULL, 0);
476 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 1, 0, NULL, 0, NULL, 0);
477 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 2, 0, NULL, 0, NULL, 0);
478 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 3, 0, NULL, 0, NULL, 0);
480 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 4, 0, NULL, 0, NULL, 0);
481 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, NULL, 5, 0, NULL, 0, NULL, 0);
484 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, addr, 0, 0, NULL, 0, NULL,
488 wpa_s, addr,
492 wpa_s->keys_cleared = 1;
532 static void wpa_supplicant_start_bgscan(struct wpa_supplicant *wpa_s)
534 if (wpas_driver_bss_selection(wpa_s))
536 if (wpa_s->current_ssid == wpa_s->bgscan_ssid)
539 bgscan_deinit(wpa_s);
540 if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) {
541 if (bgscan_init(wpa_s, wpa_s->current_ssid)) {
542 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
550 wpa_s->bgscan_ssid = wpa_s->current_ssid;
552 wpa_s->bgscan_ssid = NULL;
556 static void wpa_supplicant_stop_bgscan(struct wpa_supplicant *wpa_s)
558 if (wpa_s->bgscan_ssid != NULL) {
559 bgscan_deinit(wpa_s);
560 wpa_s->bgscan_ssid = NULL;
569 * @wpa_s: Pointer to wpa_supplicant data
575 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s,
578 enum wpa_states old_state = wpa_s->wpa_state;
580 wpa_dbg(wpa_s, MSG_DEBUG, "State: %s -> %s",
581 wpa_supplicant_state_txt(wpa_s->wpa_state),
585 if(state == WPA_ASSOCIATED && wpa_s->current_ssid) {
586 wpa_s->current_ssid->assoc_retry = 0;
591 wpa_supplicant_notify_scanning(wpa_s, 0);
593 if (state == WPA_COMPLETED && wpa_s->new_connection) {
595 struct wpa_ssid *ssid = wpa_s->current_ssid;
596 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_CONNECTED "- Connection to "
598 MAC2STR(wpa_s->bssid), wpa_s->reassociated_connection ?
603 wpa_s->new_connection = 0;
604 wpa_s->reassociated_connection = 1;
605 wpa_drv_set_operstate(wpa_s, 1);
607 wpa_drv_set_supp_port(wpa_s, 1);
609 wpa_s->after_wps = 0;
611 wpas_p2p_completed(wpa_s);
615 wpa_s->new_connection = 1;
616 wpa_drv_set_operstate(wpa_s, 0);
618 wpa_drv_set_supp_port(wpa_s, 0);
621 wpa_s->wpa_state = state;
625 wpa_supplicant_start_bgscan(wpa_s);
627 wpa_supplicant_stop_bgscan(wpa_s);
630 if (wpa_s->wpa_state != old_state) {
631 wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
633 if (wpa_s->wpa_state == WPA_COMPLETED ||
635 wpas_notify_auth_changed(wpa_s);
644 struct wpa_supplicant *wpa_s = global->ifaces;
645 while (wpa_s) {
646 if (wpas_wps_terminate_pending(wpa_s) == 1)
648 wpa_s = wpa_s->next;
664 void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
666 enum wpa_states old_state = wpa_s->wpa_state;
668 wpa_s->pairwise_cipher = 0;
669 wpa_s->group_cipher = 0;
670 wpa_s->mgmt_group_cipher = 0;
671 wpa_s->key_mgmt = 0;
672 if (wpa_s->wpa_state != WPA_INTERFACE_DISABLED)
673 wpa_s->wpa_state = WPA_DISCONNECTED;
675 if (wpa_s->wpa_state != old_state)
676 wpas_notify_state_changed(wpa_s, wpa_s->wpa_state, old_state);
682 * @wpa_s: Pointer to wpa_supplicant data
691 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
697 if (wpa_s->confname == NULL)
699 conf = wpa_config_read(wpa_s->confname);
701 wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
702 "file '%s' - exiting", wpa_s->confname);
707 reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
708 || (conf->ctrl_interface && wpa_s->conf->ctrl_interface &&
710 wpa_s->conf->ctrl_interface) != 0);
712 if (reconf_ctrl && wpa_s->ctrl_iface) {
713 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
714 wpa_s->ctrl_iface = NULL;
717 eapol_sm_invalidate_cached_session(wpa_s->eapol);
718 if (wpa_s->current_ssid) {
719 wpa_supplicant_deauthenticate(wpa_s,
727 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
732 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
734 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
735 wpa_sm_set_config(wpa_s->wpa, NULL);
736 wpa_sm_pmksa_cache_flush(wpa_s->wpa, NULL);
737 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
738 rsn_preauth_deinit(wpa_s->wpa);
740 old_ap_scan = wpa_s->conf->ap_scan;
741 wpa_config_free(wpa_s->conf);
742 wpa_s->conf = conf;
743 if (old_ap_scan != wpa_s->conf->ap_scan)
744 wpas_notify_ap_scan_changed(wpa_s);
747 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
749 wpa_supplicant_update_config(wpa_s);
751 wpa_supplicant_clear_status(wpa_s);
752 if (wpa_supplicant_enabled_networks(wpa_s->conf)) {
753 wpa_s->reassociate = 1;
754 wpa_supplicant_req_scan(wpa_s, 0, 0);
756 wpa_dbg(wpa_s, MSG_DEBUG, "Reconfiguration completed");
764 struct wpa_supplicant *wpa_s;
765 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
766 wpa_dbg(wpa_s, MSG_DEBUG, "Signal %d received - reconfiguring",
768 if (wpa_supplicant_reload_configuration(wpa_s) < 0) {
821 static int wpa_supplicant_suites_from_ai(struct wpa_supplicant *wpa_s,
825 int ret = wpa_sm_parse_own_wpa_ie(wpa_s->wpa, ie);
828 wpa_msg(wpa_s, MSG_INFO, "WPA: Failed to parse WPA IE "
834 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Using WPA IE from AssocReq to set "
837 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled group "
843 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled pairwise "
849 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled key "
858 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver associated with an AP "
871 * @wpa_s: Pointer to wpa_supplicant data
883 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
902 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: using IEEE 802.11i/D9.0");
909 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using IEEE 802.11i/D3.0");
912 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select WPA/RSN");
919 if (wpa_supplicant_suites_from_ai(wpa_s, ssid, &ie) < 0) {
929 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Set cipher suites "
935 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected cipher suites: group %d "
940 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected mgmt group cipher %d",
945 wpa_s->wpa_proto = proto;
946 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, proto);
947 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED,
950 if (bss || !wpa_s->ap_ies_from_associnfo) {
951 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
953 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
960 wpa_s->group_cipher = WPA_CIPHER_CCMP;
961 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK CCMP");
963 wpa_s->group_cipher = WPA_CIPHER_TKIP;
964 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK TKIP");
966 wpa_s->group_cipher = WPA_CIPHER_WEP104;
967 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP104");
969 wpa_s->group_cipher = WPA_CIPHER_WEP40;
970 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP40");
972 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select group "
979 wpa_s->pairwise_cipher = WPA_CIPHER_CCMP;
980 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK CCMP");
982 wpa_s->pairwise_cipher = WPA_CIPHER_TKIP;
983 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK TKIP");
985 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
986 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using PTK NONE");
988 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select pairwise "
997 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_IEEE8021X;
998 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/802.1X");
1000 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_PSK;
1001 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/PSK");
1005 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SHA256;
1006 wpa_dbg(wpa_s, MSG_DEBUG,
1009 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK_SHA256;
1010 wpa_dbg(wpa_s, MSG_DEBUG,
1014 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
1015 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X");
1017 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
1018 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-PSK");
1020 wpa_s->key_mgmt = WPA_KEY_MGMT_WPA_NONE;
1021 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-NONE");
1023 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select "
1028 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
1029 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
1030 wpa_s->pairwise_cipher);
1031 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
1039 wpa_s->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC;
1040 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
1043 wpa_s->mgmt_group_cipher = 0;
1044 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher");
1046 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
1047 wpa_s->mgmt_group_cipher);
1048 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MFP, ssid->ieee80211w);
1051 if (wpa_sm_set_assoc_wpa_ie_default(wpa_s->wpa, wpa_ie, wpa_ie_len)) {
1052 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to generate WPA IE");
1057 wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN);
1066 wpa_sm_set_pmk(wpa_s->wpa, psk, PMK_LEN);
1070 wpa_sm_set_pmk_from_pmksa(wpa_s->wpa);
1078 * @wpa_s: Pointer to wpa_supplicant data
1084 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
1103 ibss_rsn_deinit(wpa_s->ibss_rsn);
1104 wpa_s->ibss_rsn = NULL;
1113 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_AP)) {
1114 wpa_msg(wpa_s, MSG_INFO, "Driver does not support AP "
1118 wpa_supplicant_create_ap(wpa_s, ssid);
1119 wpa_s->current_bss = bss;
1121 wpa_msg(wpa_s, MSG_ERROR, "AP mode support not included in "
1129 wpa_tdls_ap_ies(wpa_s->wpa, (const u8 *) (bss + 1),
1133 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) &&
1135 sme_authenticate(wpa_s, bss, ssid);
1140 wpa_s->reassociate = 0;
1141 if (bss && !wpas_driver_bss_selection(wpa_s)) {
1145 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
1148 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
1149 os_memset(wpa_s->bssid, 0, ETH_ALEN);
1150 os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
1152 wpas_notify_bssid_changed(wpa_s);
1157 wpa_sm_set_ft_params(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0);
1160 wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
1165 wpa_s->conf->ap_scan == 2 &&
1169 wpa_s->scan_req = 2;
1170 wpa_s->reassociate = 1;
1171 wpa_supplicant_req_scan(wpa_s, 0, 0);
1175 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with SSID '%s'",
1177 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1179 wpa_supplicant_cancel_sched_scan(wpa_s);
1180 wpa_supplicant_cancel_scan(wpa_s);
1184 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
1196 wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x", algs);
1199 wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: "
1209 if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
1210 wpa_s->current_ssid,
1212 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
1214 if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
1216 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA "
1222 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
1224 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to set WPA "
1239 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
1244 wpa_s->wpa_proto = 0;
1247 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
1249 wpa_s->wpa_proto = 0;
1253 if (wpa_s->global->p2p) {
1258 p2p_group = wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_CAPABLE;
1261 res = wpas_p2p_assoc_req_ie(wpa_s, bss, pos, len, p2p_group);
1266 wpa_s->cross_connect_disallowed = 0;
1271 wpa_s->cross_connect_disallowed =
1274 wpa_dbg(wpa_s, MSG_DEBUG, "P2P: WLAN AP %s cross "
1276 wpa_s->cross_connect_disallowed ?
1283 if (wpa_s->conf->interworking) {
1298 wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
1300 cipher_pairwise = cipher_suite2driver(wpa_s->pairwise_cipher);
1301 cipher_group = cipher_suite2driver(wpa_s->group_cipher);
1302 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1303 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
1304 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE)
1306 if (wpa_set_wep_keys(wpa_s, ssid)) {
1311 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)
1315 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
1330 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1332 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
1335 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
1339 if (!wpas_driver_bss_selection(wpa_s)) {
1349 wpa_s->conf->ap_scan == 2) {
1361 params.key_mgmt_suite = key_mgmt2driver(wpa_s->key_mgmt);
1362 params.wpa_proto = wpa_s->wpa_proto;
1372 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1390 wpa_dbg(wpa_s, MSG_DEBUG, "WPA: Selected AP supports "
1400 if (wpa_s->parent->set_sta_uapsd)
1401 params.uapsd = wpa_s->parent->sta_uapsd;
1410 wpa_supplicant_apply_ht_overrides(wpa_s, ssid, ¶ms);
1417 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_MULTI_CHANNEL_CONCURRENT) &&
1418 ((freq = wpa_drv_shared_freq(wpa_s)) > 0) && (freq != params.freq)) {
1421 if (wpas_p2p_handle_frequency_conflicts(wpa_s, params.freq) < 0) {
1425 wpa_supplicant_disable_network(wpa_s, ssid);
1426 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_FREQ_CONFLICT
1428 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1433 ret = wpa_drv_associate(wpa_s, ¶ms);
1435 wpa_msg(wpa_s, MSG_INFO, "Association request to the driver "
1437 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SANE_ERROR_CODES) {
1443 wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
1444 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1452 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1455 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
1458 wpa_supplicant_cancel_auth_timeout(wpa_s);
1459 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1462 wpa_s->key_mgmt != WPA_KEY_MGMT_NONE &&
1463 wpa_s->key_mgmt != WPA_KEY_MGMT_WPA_NONE) {
1468 wpa_supplicant_cancel_auth_timeout(wpa_s);
1477 } else if (wpa_s->conf->ap_scan == 1) {
1481 wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
1484 if (wep_keys_set && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1487 wpa_set_wep_keys(wpa_s, ssid);
1490 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid) {
1495 eapol_sm_invalidate_cached_session(wpa_s->eapol);
1497 old_ssid = wpa_s->current_ssid;
1498 wpa_s->current_ssid = ssid;
1499 wpa_s->current_bss = bss;
1500 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
1501 wpa_supplicant_initiate_eapol(wpa_s);
1502 if (old_ssid != wpa_s->current_ssid)
1503 wpas_notify_network_changed(wpa_s);
1507 static void wpa_supplicant_clear_connection(struct wpa_supplicant *wpa_s,
1512 wpa_clear_keys(wpa_s, addr);
1513 wpa_supplicant_mark_disassoc(wpa_s);
1514 old_ssid = wpa_s->current_ssid;
1515 wpa_s->current_ssid = NULL;
1516 wpa_s->current_bss = NULL;
1517 wpa_sm_set_config(wpa_s->wpa, NULL);
1518 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
1519 if (old_ssid != wpa_s->current_ssid)
1520 wpas_notify_network_changed(wpa_s);
1521 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
1527 * @wpa_s: Pointer to wpa_supplicant data
1533 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
1538 if (!is_zero_ether_addr(wpa_s->bssid)) {
1539 wpa_drv_disassociate(wpa_s, wpa_s->bssid, reason_code);
1540 addr = wpa_s->bssid;
1543 wpa_supplicant_clear_connection(wpa_s, addr);
1549 * @wpa_s: Pointer to wpa_supplicant data
1555 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
1560 if (!is_zero_ether_addr(wpa_s->bssid)) {
1561 wpa_drv_deauthenticate(wpa_s, wpa_s->bssid, reason_code);
1562 addr = wpa_s->bssid;
1565 wpa_supplicant_clear_connection(wpa_s, addr);
1571 * @wpa_s: wpa_supplicant structure for a network interface
1576 void wpa_supplicant_enable_network(struct wpa_supplicant *wpa_s,
1583 for (other_ssid = wpa_s->conf->ssid; other_ssid;
1588 if (other_ssid == wpa_s->current_ssid &&
1590 wpa_s->reassociate = 1;
1598 wpa_s, other_ssid);
1600 if (wpa_s->reassociate)
1601 wpa_supplicant_req_scan(wpa_s, 0, 0);
1603 if (wpa_s->current_ssid == NULL) {
1608 wpa_s->reassociate = 1;
1609 wpa_supplicant_req_scan(wpa_s, 0, 0);
1617 wpas_notify_network_enabled_changed(wpa_s, ssid);
1624 * @wpa_s: wpa_supplicant structure for a network interface
1629 void wpa_supplicant_disable_network(struct wpa_supplicant *wpa_s,
1636 for (other_ssid = wpa_s->conf->ssid; other_ssid;
1647 wpa_s, other_ssid);
1649 if (wpa_s->current_ssid)
1651 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1653 if (ssid == wpa_s->current_ssid)
1655 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1662 wpas_notify_network_enabled_changed(wpa_s, ssid);
1669 * @wpa_s: wpa_supplicant structure for a network interface
1672 void wpa_supplicant_select_network(struct wpa_supplicant *wpa_s,
1679 if (ssid && ssid != wpa_s->current_ssid && wpa_s->current_ssid) {
1681 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1689 for (other_ssid = wpa_s->conf->ssid; other_ssid;
1698 wpas_notify_network_enabled_changed(wpa_s, other_ssid);
1701 if (ssid && ssid == wpa_s->current_ssid && wpa_s->current_ssid) {
1709 wpa_s->current_ssid = ssid;
1710 wpa_s->connect_without_scan = NULL;
1711 wpa_s->disconnected = 0;
1712 wpa_s->reassociate = 1;
1713 wpa_supplicant_req_scan(wpa_s, 0, disconnected ? 100000 : 0);
1716 wpas_notify_network_selected(wpa_s, ssid);
1722 * @wpa_s: wpa_supplicant structure for a network interface
1727 int wpa_supplicant_set_ap_scan(struct wpa_supplicant *wpa_s, int ap_scan)
1736 if (ap_scan == 2 && ap_scan != wpa_s->conf->ap_scan &&
1737 wpa_s->wpa_state >= WPA_ASSOCIATING &&
1738 wpa_s->wpa_state < WPA_COMPLETED) {
1740 "associating", wpa_s->conf->ap_scan, ap_scan);
1745 old_ap_scan = wpa_s->conf->ap_scan;
1746 wpa_s->conf->ap_scan = ap_scan;
1748 if (old_ap_scan != wpa_s->conf->ap_scan)
1749 wpas_notify_ap_scan_changed(wpa_s);
1757 * @wpa_s: wpa_supplicant structure for a network interface
1762 int wpa_supplicant_set_bss_expiration_age(struct wpa_supplicant *wpa_s,
1766 wpa_msg(wpa_s, MSG_ERROR, "Invalid bss expiration age %u",
1770 wpa_msg(wpa_s, MSG_DEBUG, "Setting bss expiration age: %d sec",
1772 wpa_s->conf->bss_expiration_age = bss_expire_age;
1780 * @wpa_s: wpa_supplicant structure for a network interface
1785 int wpa_supplicant_set_bss_expiration_count(struct wpa_supplicant *wpa_s,
1789 wpa_msg(wpa_s, MSG_ERROR, "Invalid bss expiration count %u",
1793 wpa_msg(wpa_s, MSG_DEBUG, "Setting bss expiration scan count: %u",
1795 wpa_s->conf->bss_expiration_scan_count = bss_expire_count;
1845 * @wpa_s: Pointer to wpa_supplicant data
1848 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
1857 res = wpa_drv_get_ssid(wpa_s, ssid);
1859 wpa_msg(wpa_s, MSG_WARNING, "Could not read SSID from "
1865 if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
1866 wpa_msg(wpa_s, MSG_WARNING, "Could not read BSSID from "
1871 wired = wpa_s->conf->ap_scan == 0 &&
1872 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_WIRED);
1874 entry = wpa_s->conf->ssid;
1903 static int select_driver(struct wpa_supplicant *wpa_s, int i)
1905 struct wpa_global *global = wpa_s->global;
1916 wpa_s->driver = wpa_drivers[i];
1917 wpa_s->global_drv_priv = global->drv_priv[i];
1923 static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
1930 if (wpa_s == NULL)
1934 wpa_msg(wpa_s, MSG_ERROR, "No driver interfaces build into "
1941 return select_driver(wpa_s, 0);
1956 if (select_driver(wpa_s, i) == 0)
1964 wpa_msg(wpa_s, MSG_ERROR, "Unsupported driver '%s'", name);
1971 * @ctx: Context pointer (wpa_s); this is the ctx variable registered
1986 struct wpa_supplicant *wpa_s = ctx;
1988 wpa_dbg(wpa_s, MSG_DEBUG, "RX EAPOL from " MACSTR, MAC2STR(src_addr));
1991 if (wpa_s->wpa_state < WPA_ASSOCIATED) {
2000 wpa_dbg(wpa_s, MSG_DEBUG, "Not associated - Delay processing "
2002 wpabuf_free(wpa_s->pending_eapol_rx);
2003 wpa_s->pending_eapol_rx = wpabuf_alloc_copy(buf, len);
2004 if (wpa_s->pending_eapol_rx) {
2005 os_get_time(&wpa_s->pending_eapol_rx_time);
2006 os_memcpy(wpa_s->pending_eapol_rx_src, src_addr,
2013 if (wpa_s->ap_iface) {
2014 wpa_supplicant_ap_rx_eapol(wpa_s, src_addr, buf, len);
2019 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
2020 wpa_dbg(wpa_s, MSG_DEBUG, "Ignored received EAPOL frame since "
2025 if (wpa_s->eapol_received == 0 &&
2026 (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) ||
2027 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
2028 wpa_s->wpa_state != WPA_COMPLETED) &&
2029 (wpa_s->current_ssid == NULL ||
2030 wpa_s->current_ssid->mode != IEEE80211_MODE_IBSS)) {
2033 wpa_s,
2034 (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
2035 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA ||
2036 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) ?
2039 wpa_s->eapol_received++;
2041 if (wpa_s->countermeasures) {
2042 wpa_msg(wpa_s, MSG_INFO, "WPA: Countermeasures - dropped "
2048 if (wpa_s->current_ssid &&
2049 wpa_s->current_ssid->mode == WPAS_MODE_IBSS) {
2050 ibss_rsn_rx_eapol(wpa_s->ibss_rsn, src_addr, buf, len);
2061 os_memcpy(wpa_s->last_eapol_src, src_addr, ETH_ALEN);
2062 if (!wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) &&
2063 eapol_sm_rx_eapol(wpa_s->eapol, src_addr, buf, len) > 0)
2065 wpa_drv_poll(wpa_s);
2066 if (!(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
2067 wpa_sm_rx_eapol(wpa_s->wpa, src_addr, buf, len);
2068 else if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
2075 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
2080 int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s)
2082 if (wpa_s->driver->send_eapol) {
2083 const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
2085 os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
2086 } else if (!(wpa_s->drv_flags &
2088 l2_packet_deinit(wpa_s->l2);
2089 wpa_s->l2 = l2_packet_init(wpa_s->ifname,
2090 wpa_drv_get_mac_addr(wpa_s),
2092 wpa_supplicant_rx_eapol, wpa_s, 0);
2093 if (wpa_s->l2 == NULL)
2096 const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
2098 os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
2101 if (wpa_s->l2 && l2_packet_get_own_addr(wpa_s->l2, wpa_s->own_addr)) {
2102 wpa_msg(wpa_s, MSG_ERROR, "Failed to get own L2 address");
2106 wpa_dbg(wpa_s, MSG_DEBUG, "Own MAC address: " MACSTR,
2107 MAC2STR(wpa_s->own_addr));
2108 wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
2116 * @wpa_s: Pointer to wpa_supplicant data
2123 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
2127 if (wpa_supplicant_update_mac_addr(wpa_s) < 0)
2130 if (wpa_s->bridge_ifname[0]) {
2131 wpa_dbg(wpa_s, MSG_DEBUG, "Receiving packets from bridge "
2132 "interface '%s'", wpa_s->bridge_ifname);
2133 wpa_s->l2_br = l2_packet_init(wpa_s->bridge_ifname,
2134 wpa_s->own_addr,
2136 wpa_supplicant_rx_eapol, wpa_s,
2138 if (wpa_s->l2_br == NULL) {
2139 wpa_msg(wpa_s, MSG_ERROR, "Failed to open l2_packet "
2141 wpa_s->bridge_ifname);
2146 wpa_clear_keys(wpa_s, NULL);
2150 wpa_drv_set_countermeasures(wpa_s, 0);
2152 wpa_dbg(wpa_s, MSG_DEBUG, "RSN: flushing PMKID list in the driver");
2153 wpa_drv_flush_pmkid(wpa_s);
2155 wpa_s->prev_scan_ssid = WILDCARD_SSID_SCAN;
2156 wpa_s->prev_scan_wildcard = 0;
2158 if (wpa_supplicant_enabled_networks(wpa_s->conf)) {
2159 if (wpa_supplicant_delayed_sched_scan(wpa_s, interface_count,
2161 wpa_supplicant_req_scan(wpa_s, interface_count,
2165 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
2180 struct wpa_supplicant *wpa_s;
2182 wpa_s = os_zalloc(sizeof(*wpa_s));
2183 if (wpa_s == NULL)
2185 wpa_s->scan_req = 1;
2186 wpa_s->scan_interval = 5;
2187 wpa_s->new_connection = 1;
2188 wpa_s->parent = wpa_s;
2189 wpa_s->sched_scanning = 0;
2191 return wpa_s;
2197 static int wpa_set_htcap_mcs(struct wpa_supplicant *wpa_s,
2214 wpa_msg(wpa_s
2220 wpa_msg(wpa_s, MSG_DEBUG,
2229 wpa_msg(wpa_s, MSG_ERROR,
2251 static int wpa_disable_max_amsdu(struct wpa_supplicant *wpa_s,
2258 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_max_amsdu: %d", disabled);
2274 static int wpa_set_ampdu_factor(struct wpa_supplicant *wpa_s,
2279 wpa_msg(wpa_s, MSG_DEBUG, "set_ampdu_factor: %d", factor);
2285 wpa_msg(wpa_s, MSG_ERROR, "ampdu_factor: %d out of range. "
2298 static int wpa_set_ampdu_density(struct wpa_supplicant *wpa_s,
2303 wpa_msg(wpa_s, MSG_DEBUG, "set_ampdu_density: %d", density);
2309 wpa_msg(wpa_s, MSG_ERROR,
2323 static int wpa_set_disable_ht40(struct wpa_supplicant *wpa_s,
2332 wpa_msg(wpa_s, MSG_DEBUG, "set_disable_ht40: %d", disabled);
2346 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
2361 wpa_set_htcap_mcs(wpa_s, htcaps, htcaps_mask, ssid->ht_mcs);
2362 wpa_disable_max_amsdu(wpa_s, htcaps, htcaps_mask,
2364 wpa_set_ampdu_factor(wpa_s, htcaps, htcaps_mask, ssid->ampdu_factor);
2365 wpa_set_ampdu_density(wpa_s, htcaps, htcaps_mask, ssid->ampdu_density);
2366 wpa_set_disable_ht40(wpa_s, htcaps, htcaps_mask, ssid->disable_ht40);
2372 static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
2387 wpa_s->confname = os_rel2abs_path(iface->confname);
2388 if (wpa_s->confname == NULL) {
2395 iface->confname, wpa_s->confname);
2397 wpa_s->confname = os_strdup(iface->confname);
2399 wpa_s->conf = wpa_config_read(wpa_s->confname);
2400 if (wpa_s->conf == NULL) {
2402 "configuration '%s'.", wpa_s->confname);
2411 os_free(wpa_s->conf->ctrl_interface);
2412 wpa_s->conf->ctrl_interface =
2417 os_free(wpa_s->conf->driver_param);
2418 wpa_s->conf->driver_param =
2422 wpa_s->conf = wpa_config_alloc_empty(iface->ctrl_interface,
2425 if (wpa_s->conf == NULL) {
2434 if (os_strlen(iface->ifname) >= sizeof(wpa_s->ifname)) {
2439 os_strlcpy(wpa_s->ifname, iface->ifname, sizeof(wpa_s->ifname));
2443 sizeof(wpa_s->bridge_ifname)) {
2448 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
2449 sizeof(wpa_s->bridge_ifname));
2453 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
2454 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
2462 if (wpa_supplicant_set_driver(wpa_s, driver) < 0)
2465 wpa_s->drv_priv = wpa_drv_init(wpa_s, wpa_s->ifname);
2466 if (wpa_s->drv_priv == NULL) {
2470 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to initialize "
2475 wpa_msg(wpa_s, MSG_ERROR, "Failed to initialize driver "
2479 if (wpa_drv_set_param(wpa_s, wpa_s->conf->driver_param) < 0) {
2480 wpa_msg(wpa_s, MSG_ERROR, "Driver interface rejected "
2481 "driver_param '%s'", wpa_s->conf->driver_param);
2485 ifname = wpa_drv_get_ifname(wpa_s);
2486 if (ifname && os_strcmp(ifname, wpa_s->ifname) != 0) {
2487 wpa_dbg(wpa_s, MSG_DEBUG, "Driver interface replaced "
2489 os_strlcpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
2492 if (wpa_supplicant_init_wpa(wpa_s) < 0)
2495 wpa_sm_set_ifname(wpa_s->wpa, wpa_s->ifname,
2496 wpa_s->bridge_ifname[0] ? wpa_s->bridge_ifname :
2498 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
2500 if (wpa_s->conf->dot11RSNAConfigPMKLifetime &&
2501 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_LIFETIME,
2502 wpa_s->conf->dot11RSNAConfigPMKLifetime)) {
2503 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
2508 if (wpa_s->conf->dot11RSNAConfigPMKReauthThreshold &&
2509 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_REAUTH_THRESHOLD,
2510 wpa_s->conf->dot11RSNAConfigPMKReauthThreshold)) {
2511 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
2516 if (wpa_s->conf->dot11RSNAConfigSATimeout &&
2517 wpa_sm_set_param(wpa_s->wpa, RSNA_SA_TIMEOUT,
2518 wpa_s->conf->dot11RSNAConfigSATimeout)) {
2519 wpa_msg(wpa_s, MSG_ERROR, "Invalid WPA parameter value for "
2524 wpa_s->hw.modes = wpa_drv_get_hw_feature_data(wpa_s,
2525 &wpa_s->hw.num_modes,
2526 &wpa_s->hw.flags);
2528 if (wpa_drv_get_capa(wpa_s, &capa) == 0) {
2529 wpa_s->drv_capa_known = 1;
2530 wpa_s->drv_flags = capa.flags;
2531 wpa_s->probe_resp_offloads = capa.probe_resp_offloads;
2532 wpa_s->max_scan_ssids = capa.max_scan_ssids;
2533 wpa_s->max_sched_scan_ssids = capa.max_sched_scan_ssids;
2534 wpa_s->sched_scan_supported = capa.sched_scan_supported;
2535 wpa_s->max_match_sets = capa.max_match_sets;
2536 wpa_s->max_remain_on_chan = capa.max_remain_on_chan;
2537 wpa_s->max_stations = capa.max_stations;
2539 if (wpa_s->max_remain_on_chan == 0)
2540 wpa_s->max_remain_on_chan = 1000;
2542 if (wpa_supplicant_driver_init(wpa_s) < 0)
2546 if (wpa_tdls_init(wpa_s->wpa))
2550 if (wpa_s->conf->country[0] && wpa_s->conf->country[1] &&
2551 wpa_drv_set_country(wpa_s, wpa_s->conf->country)) {
2552 wpa_dbg(wpa_s, MSG_DEBUG, "Failed to set country");
2556 if (wpas_wps_init(wpa_s))
2559 if (wpa_supplicant_init_eapol(wpa_s) < 0)
2561 wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
2563 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
2564 if (wpa_s->ctrl_iface == NULL) {
2573 wpa_s->conf->ctrl_interface);
2577 wpa_s->gas = gas_query_init(wpa_s);
2578 if (wpa_s->gas == NULL) {
2584 if (wpas_p2p_init(wpa_s->global, wpa_s) < 0) {
2585 wpa_msg(wpa_s, MSG_ERROR, "Failed to init P2P");
2590 if (wpa_bss_init(wpa_s) < 0)
2597 static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s,
2600 if (wpa_s->drv_priv) {
2601 wpa_supplicant_deauthenticate(wpa_s,
2604 wpa_drv_set_countermeasures(wpa_s, 0);
2605 wpa_clear_keys(wpa_s, NULL);
2608 wpa_supplicant_cleanup(wpa_s);
2610 if (wpa_s->drv_priv)
2611 wpa_drv_deinit(wpa_s);
2614 wpas_notify_iface_removed(wpa_s);
2617 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING);
2619 if (wpa_s->ctrl_iface) {
2620 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
2621 wpa_s->ctrl_iface = NULL;
2624 if (wpa_s->conf != NULL) {
2625 wpa_config_free(wpa_s->conf);
2626 wpa_s->conf = NULL;
2646 struct wpa_supplicant *wpa_s;
2653 wpa_s = wpa_supplicant_alloc();
2654 if (wpa_s == NULL)
2657 wpa_s->global = global;
2674 if (wpa_supplicant_init_iface(wpa_s, &t_iface)) {
2677 wpa_supplicant_deinit_iface(wpa_s, 0, 0);
2678 os_free(wpa_s);
2683 if (wpas_notify_iface_added(wpa_s)) {
2684 wpa_supplicant_deinit_iface(wpa_s, 1, 0);
2685 os_free(wpa_s);
2689 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next)
2690 wpas_notify_network_added(wpa_s, ssid);
2692 wpa_s->next = global->ifaces;
2693 global->ifaces = wpa_s;
2695 wpa_dbg(wpa_s, MSG_DEBUG, "Added interface %s", wpa_s->ifname);
2697 return wpa_s;
2704 * @wpa_s: Pointer to the network interface to be removed
2713 struct wpa_supplicant *wpa_s,
2720 if (prev == wpa_s) {
2721 global->ifaces = wpa_s->next;
2723 while (prev && prev->next != wpa_s)
2727 prev->next = wpa_s->next;
2730 wpa_dbg(wpa_s, MSG_DEBUG, "Removing interface %s", wpa_s->ifname);
2732 if (global->p2p_group_formation == wpa_s)
2734 wpa_supplicant_deinit_iface(wpa_s, 1, terminate);
2735 os_free(wpa_s);
2743 * @wpa_s: Pointer to the network interface
2746 const char * wpa_supplicant_get_eap_mode(struct wpa_supplicant *wpa_s)
2750 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) == 0 &&
2751 wpa_s->key_mgmt != WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
2755 eapol_method = eapol_sm_get_method_name(wpa_s->eapol);
2772 struct wpa_supplicant *wpa_s;
2774 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
2775 if (os_strcmp(wpa_s->ifname, ifname) == 0)
2776 return wpa_s;
2785 struct wpa_supplicant *wpa_s = ctx;
2786 if (wpa_s == NULL)
2788 return wpa_s->ifname;
2909 struct wpa_supplicant *wpa_s;
2916 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
2917 if (wpa_s->ctrl_iface)
2919 wpa_s->ctrl_iface);
2987 void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s)
2989 if ((wpa_s->conf->changed_parameters & CFG_CHANGED_COUNTRY) &&
2990 wpa_s->conf->country[0] && wpa_s->conf->country[1]) {
2992 country[0] = wpa_s->conf->country[0];
2993 country[1] = wpa_s->conf->country[1];
2995 if (wpa_drv_set_country(wpa_s, country) < 0) {
3002 wpas_wps_update_config(wpa_s);
3006 wpas_p2p_update_config(wpa_s);
3009 wpa_s->conf->changed_parameters = 0;
3027 static int * get_bss_freqs_in_ess(struct wpa_supplicant *wpa_s)
3038 cbss = wpa_s->current_bss;
3040 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
3045 wpa_blacklist_get(wpa_s, bss->bssid) == NULL) {
3061 void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid)
3070 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
3080 count = wpa_blacklist_add(wpa_s, bssid);
3081 if (count == 1 && wpa_s->current_bss) {
3088 freqs = get_bss_freqs_in_ess(wpa_s);
3090 wpa_dbg(wpa_s, MSG_DEBUG, "Another BSS in this ESS "
3092 wpa_blacklist_add(wpa_s, bssid);
3098 os_free(wpa_s->next_scan_freqs);
3099 wpa_s->next_scan_freqs = freqs;
3121 wpa_supplicant_req_scan(wpa_s, timeout / 1000,
3126 int wpas_driver_bss_selection(struct wpa_supplicant *wpa_s)
3128 return wpa_s->conf->ap_scan == 2 ||
3129 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_BSS_SELECTION);
3133 int wpas_is_p2p_prioritized(struct wpa_supplicant *wpa_s)
3135 if (wpa_s->global->conc_pref == WPA_CONC_PREF_P2P)
3137 if (wpa_s->global->conc_pref == WPA_CONC_PREF_STA)