Lines Matching refs:wpa_s
116 static int wpa_set_wep_keys(struct wpa_supplicant *wpa_s,
126 wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
136 static int wpa_supplicant_set_wpa_none_key(struct wpa_supplicant *wpa_s,
158 switch (wpa_s->group_cipher) {
173 "WPA-None", wpa_s->group_cipher);
180 return wpa_drv_set_key(wpa_s, alg, (u8 *) "\xff\xff\xff\xff\xff\xff",
187 struct wpa_supplicant *wpa_s = eloop_ctx;
188 const u8 *bssid = wpa_s->bssid;
190 bssid = wpa_s->pending_bssid;
191 wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
193 wpa_blacklist_add(wpa_s, bssid);
194 wpa_sm_notify_disassoc(wpa_s->wpa);
195 wpa_supplicant_disassociate(wpa_s, WLAN_REASON_DEAUTH_LEAVING);
196 wpa_s->reassociate = 1;
197 wpa_supplicant_req_scan(wpa_s, 0, 0);
203 * @wpa_s: Pointer to wpa_supplicant data
210 void wpa_supplicant_req_auth_timeout(struct wpa_supplicant *wpa_s,
213 if (wpa_s->conf && wpa_s->conf->ap_scan == 0 &&
214 wpa_s->driver && IS_WIRED(wpa_s->driver))
217 wpa_msg(wpa_s, MSG_DEBUG, "Setting authentication timeout: %d sec "
219 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
220 eloop_register_timeout(sec, usec, wpa_supplicant_timeout, wpa_s, NULL);
226 * @wpa_s: Pointer to wpa_supplicant data
232 void wpa_supplicant_cancel_auth_timeout(struct wpa_supplicant *wpa_s)
234 wpa_msg(wpa_s, MSG_DEBUG, "Cancelling authentication timeout");
235 eloop_cancel_timeout(wpa_supplicant_timeout, wpa_s, NULL);
236 wpa_blacklist_del(wpa_s, wpa_s->bssid);
242 * @wpa_s: Pointer to wpa_supplicant data
247 void wpa_supplicant_initiate_eapol(struct wpa_supplicant *wpa_s)
251 struct wpa_ssid *ssid = wpa_s->current_ssid;
253 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
254 eapol_sm_notify_eap_fail(wpa_s->eapol, FALSE);
256 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
257 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
258 eapol_sm_notify_portControl(wpa_s->eapol, ForceAuthorized);
260 eapol_sm_notify_portControl(wpa_s->eapol, Auto);
263 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
274 if (wpa_s->conf && wpa_s->driver && IS_WIRED(wpa_s->driver)) {
278 if (wpa_s->conf)
279 eapol_conf.fast_reauth = wpa_s->conf->fast_reauth;
282 !wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) &&
283 wpa_s->key_mgmt != WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
284 wpa_s->key_mgmt != WPA_KEY_MGMT_WPS;
285 eapol_sm_notify_config(wpa_s->eapol, &ssid->eap, &eapol_conf);
292 * @wpa_s: Pointer to wpa_supplicant data
299 void wpa_supplicant_set_non_wpa_policy(struct wpa_supplicant *wpa_s,
305 wpa_s->key_mgmt = WPA_KEY_MGMT_WPS;
307 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
309 wpa_s->key_mgmt = WPA_KEY_MGMT_NONE;
310 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
311 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
312 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
313 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
314 wpa_s->group_cipher = WPA_CIPHER_NONE;
315 wpa_s->mgmt_group_cipher = 0;
319 wpa_s->pairwise_cipher = WPA_CIPHER_WEP104;
320 wpa_s->group_cipher = WPA_CIPHER_WEP104;
323 wpa_s->pairwise_cipher = WPA_CIPHER_WEP40;
324 wpa_s->group_cipher = WPA_CIPHER_WEP40;
329 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED, 0);
330 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
331 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
332 wpa_s->pairwise_cipher);
333 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
335 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
336 wpa_s->mgmt_group_cipher);
339 pmksa_cache_clear_current(wpa_s->wpa);
343 static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s)
345 scard_deinit(wpa_s->scard);
346 wpa_s->scard = NULL;
347 wpa_sm_set_scard_ctx(wpa_s->wpa, NULL);
348 eapol_sm_register_scard_ctx(wpa_s->eapol, NULL);
349 l2_packet_deinit(wpa_s->l2);
350 wpa_s->l2 = NULL;
351 if (wpa_s->l2_br) {
352 l2_packet_deinit(wpa_s->l2_br);
353 wpa_s->l2_br = NULL;
356 if (wpa_s->ctrl_iface) {
357 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
358 wpa_s->ctrl_iface = NULL;
360 if (wpa_s->conf != NULL) {
361 wpa_config_free(wpa_s->conf);
362 wpa_s->conf = NULL;
365 os_free(wpa_s->confname);
366 wpa_s->confname = NULL;
368 wpa_sm_set_eapol(wpa_s->wpa, NULL);
369 eapol_sm_deinit(wpa_s->eapol);
370 wpa_s->eapol = NULL;
372 rsn_preauth_deinit(wpa_s->wpa);
374 pmksa_candidate_free(wpa_s->wpa);
375 wpa_sm_deinit(wpa_s->wpa);
376 wpa_s->wpa = NULL;
377 wpa_blacklist_clear(wpa_s);
379 wpa_scan_results_free(wpa_s->scan_res);
380 wpa_s->scan_res = NULL;
382 wpa_supplicant_cancel_scan(wpa_s);
383 wpa_supplicant_cancel_auth_timeout(wpa_s);
385 ieee80211_sta_deinit(wpa_s);
387 wpas_wps_deinit(wpa_s);
389 wpabuf_free(wpa_s->pending_eapol_rx);
390 wpa_s->pending_eapol_rx = NULL;
396 * @wpa_s: Pointer to wpa_supplicant data
402 void wpa_clear_keys(struct wpa_supplicant *wpa_s, const u8 *addr)
406 if (wpa_s->keys_cleared) {
420 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 0, 0, NULL, 0, NULL, 0);
421 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 1, 0, NULL, 0, NULL, 0);
422 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 2, 0, NULL, 0, NULL, 0);
423 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 3, 0, NULL, 0, NULL, 0);
425 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 4, 0, NULL, 0, NULL, 0);
426 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, bcast, 5, 0, NULL, 0, NULL, 0);
429 wpa_drv_set_key(wpa_s, WPA_ALG_NONE, addr, 0, 0, NULL, 0, NULL,
433 wpa_s, addr,
437 wpa_s->keys_cleared = 1;
473 * @wpa_s: Pointer to wpa_supplicant data
479 void wpa_supplicant_set_state(struct wpa_supplicant *wpa_s, wpa_states state)
484 if (wpa_s && wpa_s->current_ssid)
485 network_id = wpa_s->current_ssid->id;
488 wpa_supplicant_state_txt(wpa_s->wpa_state),
492 wpa_supplicant_notify_scanning(wpa_s, 0);
494 wpa_supplicant_dbus_notify_state_change(wpa_s, state,
495 wpa_s->wpa_state);
497 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE "id=%d state=%d BSSID=" MACSTR,
498 network_id, state, MAC2STR(wpa_s->pending_bssid));
501 if (state == WPA_COMPLETED && wpa_s->new_connection) {
503 struct wpa_ssid *ssid = wpa_s->current_ssid;
504 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_CONNECTED "- Connection to "
506 MAC2STR(wpa_s->bssid), wpa_s->reassociated_connection ?
511 wpa_s->new_connection = 0;
512 wpa_s->reassociated_connection = 1;
513 wpa_drv_set_operstate(wpa_s, 1);
516 wpa_s->new_connection = 1;
517 wpa_drv_set_operstate(wpa_s, 0);
519 wpa_s->wpa_state = state;
527 struct wpa_supplicant *wpa_s;
528 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
529 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_TERMINATING "- signal %d "
536 static void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s)
538 wpa_s->pairwise_cipher = 0;
539 wpa_s->group_cipher = 0;
540 wpa_s->mgmt_group_cipher = 0;
541 wpa_s->key_mgmt = 0;
542 wpa_s->wpa_state = WPA_DISCONNECTED;
548 * @wpa_s: Pointer to wpa_supplicant data
557 int wpa_supplicant_reload_configuration(struct wpa_supplicant *wpa_s)
561 if (wpa_s->confname == NULL)
563 conf = wpa_config_read(wpa_s->confname);
565 wpa_msg(wpa_s, MSG_ERROR, "Failed to parse the configuration "
566 "file '%s' - exiting", wpa_s->confname);
570 reconf_ctrl = !!conf->ctrl_interface != !!wpa_s->conf->ctrl_interface
571 || (conf->ctrl_interface && wpa_s->conf->ctrl_interface &&
573 wpa_s->conf->ctrl_interface) != 0);
575 if (reconf_ctrl && wpa_s->ctrl_iface) {
576 wpa_supplicant_ctrl_iface_deinit(wpa_s->ctrl_iface);
577 wpa_s->ctrl_iface = NULL;
580 eapol_sm_invalidate_cached_session(wpa_s->eapol);
581 wpa_s->current_ssid = NULL;
586 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
591 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
593 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
594 wpa_sm_set_config(wpa_s->wpa, NULL);
595 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
596 rsn_preauth_deinit(wpa_s->wpa);
597 wpa_config_free(wpa_s->conf);
598 wpa_s->conf = conf;
600 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
602 wpa_supplicant_clear_status(wpa_s);
603 wpa_s->reassociate = 1;
605 wpa_supplicant_req_scan(wpa_s, 2, 0);
607 wpa_supplicant_req_scan(wpa_s, 0, 0);
609 wpa_msg(wpa_s, MSG_DEBUG, "Reconfiguration completed");
618 struct wpa_supplicant *wpa_s;
620 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
621 if (wpa_supplicant_reload_configuration(wpa_s) < 0) {
674 static int wpa_supplicant_suites_from_ai(struct wpa_supplicant *wpa_s,
678 int ret = wpa_sm_parse_own_wpa_ie(wpa_s->wpa, ie);
681 wpa_msg(wpa_s, MSG_INFO, "WPA: Failed to parse WPA IE "
690 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled group "
696 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled pairwise "
702 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver used disabled key "
711 wpa_msg(wpa_s, MSG_INFO, "WPA: Driver associated with an AP "
724 * @wpa_s: Pointer to wpa_supplicant data
736 int wpa_supplicant_set_suites(struct wpa_supplicant *wpa_s,
756 wpa_msg(wpa_s, MSG_DEBUG, "RSN: using IEEE 802.11i/D9.0");
763 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using IEEE 802.11i/D3.0");
766 wpa_msg(wpa_s, MSG_WARNING, "WPA: Failed to select WPA/RSN");
773 if (wpa_supplicant_suites_from_ai(wpa_s, ssid, &ie) < 0) {
799 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PROTO, proto);
800 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_RSN_ENABLED,
803 if (bss || !wpa_s->ap_ies_from_associnfo) {
804 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, bss_wpa,
806 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, bss_rsn,
813 wpa_s->group_cipher = WPA_CIPHER_CCMP;
814 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK CCMP");
816 wpa_s->group_cipher = WPA_CIPHER_TKIP;
817 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK TKIP");
819 wpa_s->group_cipher = WPA_CIPHER_WEP104;
820 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP104");
822 wpa_s->group_cipher = WPA_CIPHER_WEP40;
823 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using GTK WEP40");
831 wpa_s->pairwise_cipher = WPA_CIPHER_CCMP;
832 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK CCMP");
834 wpa_s->pairwise_cipher = WPA_CIPHER_TKIP;
835 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK TKIP");
837 wpa_s->pairwise_cipher = WPA_CIPHER_NONE;
838 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using PTK NONE");
849 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_IEEE8021X;
850 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/802.1X");
852 wpa_s->key_mgmt = WPA_KEY_MGMT_FT_PSK;
853 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT FT/PSK");
857 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X_SHA256;
858 wpa_msg(wpa_s, MSG_DEBUG,
861 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK_SHA256;
862 wpa_msg(wpa_s, MSG_DEBUG,
866 wpa_s->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
867 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT 802.1X");
869 wpa_s->key_mgmt = WPA_KEY_MGMT_PSK;
870 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-PSK");
872 wpa_s->key_mgmt = WPA_KEY_MGMT_WPA_NONE;
873 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using KEY_MGMT WPA-NONE");
880 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_KEY_MGMT, wpa_s->key_mgmt);
881 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_PAIRWISE,
882 wpa_s->pairwise_cipher);
883 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_GROUP, wpa_s->group_cipher);
891 wpa_s->mgmt_group_cipher = WPA_CIPHER_AES_128_CMAC;
892 wpa_msg(wpa_s, MSG_DEBUG, "WPA: using MGMT group cipher "
895 wpa_s->mgmt_group_cipher = 0;
896 wpa_msg(wpa_s, MSG_DEBUG, "WPA: not using MGMT group cipher");
898 wpa_sm_set_param(wpa_s->wpa, WPA_PARAM_MGMT_GROUP,
899 wpa_s->mgmt_group_cipher);
902 if (wpa_sm_set_assoc_wpa_ie_default(wpa_s->wpa, wpa_ie, wpa_ie_len)) {
909 wpa_sm_set_pmk(wpa_s->wpa, ssid->psk, PMK_LEN);
911 wpa_sm_set_pmk_from_pmksa(wpa_s->wpa);
919 * @wpa_s: Pointer to wpa_supplicant data
925 void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
938 wpa_s->reassociate = 0;
944 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
947 os_memset(wpa_s->bssid, 0, ETH_ALEN);
948 os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
949 wpa_s->link_speed = wpa_scan_get_max_rate(bss) * 500000;
950 wpa_s->rssi = bss->level;
955 wpa_sm_set_ft_params(wpa_s->wpa, md, NULL, 0, NULL);
958 wpa_ft_prepare_auth_request(wpa_s->wpa);
963 wpa_s->conf->ap_scan == 2 &&
967 wpa_s->scan_req = 2;
968 wpa_s->reassociate = 1;
969 wpa_supplicant_req_scan(wpa_s, 0, 0);
973 wpa_msg(wpa_s, MSG_INFO, "Trying to associate with SSID '%s'",
975 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
977 wpa_supplicant_cancel_scan(wpa_s);
981 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
983 if (wpa_drv_set_mode(wpa_s, ssid->mode)) {
1010 wpa_drv_set_auth_alg(wpa_s, algs);
1022 if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
1023 wpa_s->current_ssid,
1025 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
1027 if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
1039 if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
1056 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
1059 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
1063 wpa_clear_keys(wpa_s, bss ? bss->bssid : NULL);
1065 cipher_pairwise = cipher_suite2driver(wpa_s->pairwise_cipher);
1066 cipher_group = cipher_suite2driver(wpa_s->group_cipher);
1067 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1068 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
1069 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE)
1071 if (wpa_set_wep_keys(wpa_s, ssid)) {
1076 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS)
1080 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
1095 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1097 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
1100 wpa_drv_set_drop_unencrypted(wpa_s, use_crypt);
1101 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
1119 params.key_mgmt_suite = key_mgmt2driver(wpa_s->key_mgmt);
1129 if (wpa_s->driver_4way_handshake &&
1163 if (wpa_s->use_client_mlme)
1164 ret = ieee80211_sta_associate(wpa_s, ¶ms);
1166 ret = wpa_drv_associate(wpa_s, ¶ms);
1168 wpa_msg(wpa_s, MSG_INFO, "Association request to the driver "
1175 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1178 wpa_supplicant_set_wpa_none_key(wpa_s, ssid);
1181 wpa_supplicant_cancel_auth_timeout(wpa_s);
1182 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1190 } else if (wpa_s->conf->ap_scan == 1) {
1194 wpa_supplicant_req_auth_timeout(wpa_s, timeout, 0);
1197 if (wep_keys_set && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1200 wpa_set_wep_keys(wpa_s, ssid);
1203 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid) {
1208 eapol_sm_invalidate_cached_session(wpa_s->eapol);
1210 wpa_s->current_ssid = ssid;
1211 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
1212 wpa_supplicant_initiate_eapol(wpa_s);
1218 * @wpa_s: Pointer to wpa_supplicant data
1224 void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
1228 if (!is_zero_ether_addr(wpa_s->bssid)) {
1229 if (wpa_s->use_client_mlme)
1230 ieee80211_sta_disassociate(wpa_s, reason_code);
1232 wpa_drv_disassociate(wpa_s, wpa_s->bssid, reason_code);
1233 addr = wpa_s->bssid;
1235 wpa_clear_keys(wpa_s, addr);
1236 wpa_supplicant_mark_disassoc(wpa_s);
1237 wpa_s->current_ssid = NULL;
1238 wpa_sm_set_config(wpa_s->wpa, NULL);
1239 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
1245 * @wpa_s: Pointer to wpa_supplicant data
1251 void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
1255 if (!is_zero_ether_addr(wpa_s->bssid)) {
1256 if (wpa_s->use_client_mlme)
1257 ieee80211_sta_deauthenticate(wpa_s, reason_code);
1259 wpa_drv_deauthenticate(wpa_s, wpa_s->bssid,
1261 addr = wpa_s->bssid;
1263 wpa_clear_keys(wpa_s, addr);
1264 wpa_supplicant_mark_disassoc(wpa_s);
1265 wpa_s->current_ssid = NULL;
1266 wpa_sm_set_config(wpa_s->wpa, NULL);
1267 eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
1271 static int wpa_supplicant_get_scan_results_old(struct wpa_supplicant *wpa_s)
1285 num = wpa_drv_get_scan_results(wpa_s, results, SCAN_AP_LIMIT);
1298 wpa_scan_results_free(wpa_s->scan_res);
1299 wpa_s->scan_res = NULL;
1373 wpa_s->scan_res = res;
1381 * @wpa_s: Pointer to wpa_supplicant data
1385 * a local copy of the results in wpa_s->scan_res.
1387 int wpa_supplicant_get_scan_results(struct wpa_supplicant *wpa_s)
1391 if (wpa_s->use_client_mlme) {
1392 wpa_scan_results_free(wpa_s->scan_res);
1393 wpa_s->scan_res = ieee80211_sta_get_scan_results(wpa_s);
1394 if (wpa_s->scan_res == NULL) {
1399 } else if (wpa_s->driver->get_scan_results2 == NULL)
1400 ret = wpa_supplicant_get_scan_results_old(wpa_s);
1402 wpa_scan_results_free(wpa_s->scan_res);
1403 wpa_s->scan_res = wpa_drv_get_scan_results2(wpa_s);
1404 if (wpa_s->scan_res == NULL) {
1411 if (wpa_s->scan_res)
1412 wpa_scan_sort_results(wpa_s->scan_res);
1420 * @wpa_s: Pointer to wpa_supplicant data
1423 struct wpa_ssid * wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s)
1432 if (wpa_s->use_client_mlme) {
1433 if (ieee80211_sta_get_ssid(wpa_s, ssid, &ssid_len)) {
1439 res = wpa_drv_get_ssid(wpa_s, ssid);
1448 if (wpa_s->use_client_mlme)
1449 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
1450 else if (wpa_drv_get_bssid(wpa_s, bssid) < 0) {
1455 wired = wpa_s->conf->ap_scan == 0 && wpa_s->driver &&
1456 IS_WIRED(wpa_s->driver);
1458 entry = wpa_s->conf->ssid;
1480 int wpa_drv_scan(struct wpa_supplicant *wpa_s, struct wpa_ssid **ssid_ptr)
1486 if (wpa_s->driver->combo_scan) {
1487 ret = wpa_s->driver->combo_scan(wpa_s->drv_priv, ssid_ptr,
1488 wpa_s->conf->ssid);
1489 wpa_s->prev_scan_ssid = (*ssid_ptr && !ret) ?
1492 else if (wpa_s->driver->scan) {
1498 ret = wpa_s->driver->scan(wpa_s->drv_priv, ssid_nm, ssid_len);
1503 static int wpa_supplicant_set_driver(struct wpa_supplicant *wpa_s,
1508 if (wpa_s == NULL)
1519 wpa_s->driver = wpa_supplicant_drivers[0];
1520 wpa_s->global_drv_priv = wpa_s->global->drv_priv[0];
1526 wpa_s->driver = wpa_supplicant_drivers[i];
1527 wpa_s->global_drv_priv = wpa_s->global->drv_priv[i];
1540 struct wpa_supplicant *wpa_s = ctx;
1545 if (wpa_s->wpa_state < WPA_ASSOCIATED) {
1556 wpabuf_free(wpa_s->pending_eapol_rx);
1557 wpa_s->pending_eapol_rx = wpabuf_alloc_copy(buf, len);
1558 if (wpa_s->pending_eapol_rx) {
1559 os_get_time(&wpa_s->pending_eapol_rx_time);
1560 os_memcpy(wpa_s->pending_eapol_rx_src, src_addr,
1566 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
1572 if (wpa_s->eapol_received == 0 &&
1573 (!wpa_s->driver_4way_handshake ||
1574 !wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
1575 wpa_s->wpa_state != WPA_COMPLETED)) {
1578 wpa_s,
1579 (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) ||
1580 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA ||
1581 wpa_s->key_mgmt == WPA_KEY_MGMT_WPS) ?
1584 wpa_s->eapol_received++;
1586 if (wpa_s->countermeasures) {
1598 os_memcpy(wpa_s->last_eapol_src, src_addr, ETH_ALEN);
1599 if (!wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) &&
1600 eapol_sm_rx_eapol(wpa_s->eapol, src_addr, buf, len) > 0)
1602 wpa_drv_poll(wpa_s);
1603 if (!wpa_s->driver_4way_handshake)
1604 wpa_sm_rx_eapol(wpa_s->wpa, src_addr, buf, len);
1605 else if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
1612 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1627 struct wpa_supplicant *wpa_s = ctx;
1628 ieee80211_sta_rx(wpa_s, buf, len, rx_status);
1634 * @wpa_s: Pointer to wpa_supplicant data
1641 int wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s)
1645 if (wpa_s->driver->send_eapol) {
1646 const u8 *addr = wpa_drv_get_mac_addr(wpa_s);
1648 os_memcpy(wpa_s->own_addr, addr, ETH_ALEN);
1650 wpa_s->l2 = l2_packet_init(wpa_s->ifname,
1651 wpa_drv_get_mac_addr(wpa_s),
1653 wpa_supplicant_rx_eapol, wpa_s, 0);
1654 if (wpa_s->l2 == NULL)
1658 if (wpa_s->l2 && l2_packet_get_own_addr(wpa_s->l2, wpa_s->own_addr)) {
1664 MAC2STR(wpa_s->own_addr));
1666 if (wpa_s->bridge_ifname[0]) {
1668 " '%s'", wpa_s->bridge_ifname);
1669 wpa_s->l2_br = l2_packet_init(wpa_s->bridge_ifname,
1670 wpa_s->own_addr,
1672 wpa_supplicant_rx_eapol, wpa_s,
1674 if (wpa_s->l2_br == NULL) {
1677 wpa_s->bridge_ifname);
1685 if (wpa_drv_set_wpa(wpa_s, 1) < 0) {
1687 if (wpa_drv_get_capa(wpa_s, &capa) < 0 ||
1699 wpa_clear_keys(wpa_s, NULL);
1703 wpa_drv_set_countermeasures(wpa_s, 0);
1705 wpa_drv_set_drop_unencrypted(wpa_s, 1);
1708 wpa_drv_flush_pmkid(wpa_s);
1710 wpa_s->prev_scan_ssid = BROADCAST_SSID_SCAN;
1711 wpa_supplicant_req_scan(wpa_s, interface_count, 100000);
1727 struct wpa_supplicant *wpa_s;
1729 wpa_s = os_zalloc(sizeof(*wpa_s));
1730 if (wpa_s == NULL)
1732 wpa_s->scan_req = 1;
1734 wpa_s->scan_interval = 5;
1736 return wpa_s;
1740 static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s,
1750 if (wpa_supplicant_set_driver(wpa_s, iface->driver) < 0) {
1756 wpa_s->confname = os_rel2abs_path(iface->confname);
1757 if (wpa_s->confname == NULL) {
1764 iface->confname, wpa_s->confname);
1766 wpa_s->confname = os_strdup(iface->confname);
1768 wpa_s->conf = wpa_config_read(wpa_s->confname);
1769 if (wpa_s->conf == NULL) {
1771 "configuration '%s'.", wpa_s->confname);
1780 os_free(wpa_s->conf->ctrl_interface);
1781 wpa_s->conf->ctrl_interface =
1786 os_free(wpa_s->conf->driver_param);
1787 wpa_s->conf->driver_param =
1791 wpa_s->conf = wpa_config_alloc_empty(iface->ctrl_interface,
1794 if (wpa_s->conf == NULL) {
1803 if (os_strlen(iface->ifname) >= sizeof(wpa_s->ifname)) {
1808 os_strlcpy(wpa_s->ifname, iface->ifname, sizeof(wpa_s->ifname));
1812 sizeof(wpa_s->bridge_ifname)) {
1817 os_strlcpy(wpa_s->bridge_ifname, iface->bridge_ifname,
1818 sizeof(wpa_s->bridge_ifname));
1825 static int wpa_supplicant_init_iface2(struct wpa_supplicant *wpa_s)
1831 wpa_s->ifname);
1834 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1835 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1841 wpa_s->drv_priv = wpa_drv_init(wpa_s, wpa_s->ifname);
1842 if (wpa_s->drv_priv == NULL) {
1846 if (wpa_drv_set_param(wpa_s, wpa_s->conf->driver_param) < 0) {
1848 "driver_param '%s'", wpa_s->conf->driver_param);
1852 ifname = wpa_drv_get_ifname(wpa_s);
1853 if (ifname && os_strcmp(ifname, wpa_s->ifname) != 0) {
1856 os_strlcpy(wpa_s->ifname, ifname, sizeof(wpa_s->ifname));
1859 if (wpa_supplicant_init_wpa(wpa_s) < 0)
1862 wpa_sm_set_ifname(wpa_s->wpa, wpa_s->ifname,
1863 wpa_s->bridge_ifname[0] ? wpa_s->bridge_ifname :
1865 wpa_sm_set_fast_reauth(wpa_s->wpa, wpa_s->conf->fast_reauth);
1867 if (wpa_s->conf->dot11RSNAConfigPMKLifetime &&
1868 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_LIFETIME,
1869 wpa_s->conf->dot11RSNAConfigPMKLifetime)) {
1875 if (wpa_s->conf->dot11RSNAConfigPMKReauthThreshold &&
1876 wpa_sm_set_param(wpa_s->wpa, RSNA_PMK_REAUTH_THRESHOLD,
1877 wpa_s->conf->dot11RSNAConfigPMKReauthThreshold)) {
1883 if (wpa_s->conf->dot11RSNAConfigSATimeout &&
1884 wpa_sm_set_param(wpa_s->wpa, RSNA_SA_TIMEOUT,
1885 wpa_s->conf->dot11RSNAConfigSATimeout)) {
1891 if (wpa_supplicant_driver_init(wpa_s) < 0)
1894 if (wpa_s->conf->country[0] && wpa_s->conf->country[1] &&
1895 wpa_drv_set_country(wpa_s, wpa_s->conf->country)) {
1900 wpa_sm_set_own_addr(wpa_s->wpa, wpa_s->own_addr);
1902 if (wpas_wps_init(wpa_s))
1905 if (wpa_supplicant_init_eapol(wpa_s) < 0)
1907 wpa_sm_set_eapol(wpa_s->wpa, wpa_s->eapol);
1909 wpa_s->ctrl_iface = wpa_supplicant_ctrl_iface_init(wpa_s);
1910 if (wpa_s->ctrl_iface == NULL) {
1919 wpa_s->conf->ctrl_interface);
1923 if (wpa_drv_get_capa(wpa_s, &capa) == 0) {
1925 wpa_s->use_client_mlme = 1;
1926 if (ieee80211_sta_init(wpa_s))
1930 wpa_s->driver_4way_handshake = 1;
1937 static void wpa_supplicant_deinit_iface(struct wpa_supplicant *wpa_s)
1939 if (wpa_s->drv_priv) {
1940 wpa_supplicant_deauthenticate(wpa_s,
1946 if (wpa_drv_set_wpa(wpa_s, 0) < 0) {
1951 wpa_drv_set_drop_unencrypted(wpa_s, 0);
1952 wpa_drv_set_countermeasures(wpa_s, 0);
1953 wpa_clear_keys(wpa_s, NULL);
1956 wpas_dbus_unregister_iface(wpa_s);
1958 wpa_supplicant_cleanup(wpa_s);
1960 if (wpa_s->drv_priv)
1961 wpa_drv_deinit(wpa_s);
1980 struct wpa_supplicant *wpa_s;
1985 wpa_s = wpa_supplicant_alloc();
1986 if (wpa_s == NULL)
1989 wpa_s->global = global;
1991 if (wpa_supplicant_init_iface(wpa_s, iface) ||
1992 wpa_supplicant_init_iface2(wpa_s)) {
1995 wpa_supplicant_deinit_iface(wpa_s);
1996 os_free(wpa_s);
2001 if (wpas_dbus_register_iface(wpa_s)) {
2002 wpa_supplicant_deinit_iface(wpa_s);
2003 os_free(wpa_s);
2007 wpa_s->next = global->ifaces;
2008 global->ifaces = wpa_s;
2010 wpa_printf(MSG_DEBUG, "Added interface %s", wpa_s->ifname);
2012 return wpa_s;
2019 * @wpa_s: Pointer to the network interface to be removed
2028 struct wpa_supplicant *wpa_s)
2034 if (prev == wpa_s) {
2035 global->ifaces = wpa_s->next;
2037 while (prev && prev->next != wpa_s)
2041 prev->next = wpa_s->next;
2044 wpa_printf(MSG_DEBUG, "Removing interface %s", wpa_s->ifname);
2046 wpa_supplicant_deinit_iface(wpa_s);
2047 os_free(wpa_s);
2062 struct wpa_supplicant *wpa_s;
2064 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
2065 if (os_strcmp(wpa_s->ifname, ifname) == 0)
2066 return wpa_s;
2178 struct wpa_supplicant *wpa_s;
2185 for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
2186 if (wpa_s->ctrl_iface)
2188 wpa_s->ctrl_iface);