2 * WPA Supplicant - Driver event processing
3 * Copyright (c) 2003-2010, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "eapol_supp/eapol_supp_sm.h"
19 #include "rsn_supp/wpa.h"
22 #include "l2_packet/l2_packet.h"
23 #include "wpa_supplicant_i.h"
25 #include "pcsc_funcs.h"
26 #include "rsn_supp/preauth.h"
27 #include "rsn_supp/pmksa_cache.h"
28 #include "common/wpa_ctrl.h"
29 #include "eap_peer/eap.h"
31 #include "common/ieee802_11_defs.h"
32 #include "blacklist.h"
33 #include "wpas_glue.h"
34 #include "wps_supplicant.h"
42 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
44 struct wpa_ssid *ssid, *old_ssid;
46 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
49 wpa_printf(MSG_DEBUG, "Select network based on association "
51 ssid = wpa_supplicant_get_ssid(wpa_s);
53 wpa_printf(MSG_INFO, "No network configuration found for the "
59 wpa_printf(MSG_DEBUG, "Selected network is disabled");
63 wpa_printf(MSG_DEBUG, "Network configuration found for the current "
65 if (ssid->key_mgmt & (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X |
66 WPA_KEY_MGMT_WPA_NONE |
67 WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X |
68 WPA_KEY_MGMT_PSK_SHA256 |
69 WPA_KEY_MGMT_IEEE8021X_SHA256)) {
71 size_t wpa_ie_len = sizeof(wpa_ie);
72 wpa_supplicant_set_suites(wpa_s, NULL, ssid,
75 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
78 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
79 eapol_sm_invalidate_cached_session(wpa_s->eapol);
80 old_ssid = wpa_s->current_ssid;
81 wpa_s->current_ssid = ssid;
82 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
83 wpa_supplicant_initiate_eapol(wpa_s);
84 if (old_ssid != wpa_s->current_ssid)
85 wpas_notify_network_changed(wpa_s);
91 static void wpa_supplicant_stop_countermeasures(void *eloop_ctx,
94 struct wpa_supplicant *wpa_s = eloop_ctx;
96 if (wpa_s->countermeasures) {
97 wpa_s->countermeasures = 0;
98 wpa_drv_set_countermeasures(wpa_s, 0);
99 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
100 wpa_supplicant_req_scan(wpa_s, 0, 0);
105 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
109 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
110 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
111 os_memset(wpa_s->bssid, 0, ETH_ALEN);
112 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
114 wpas_notify_bssid_changed(wpa_s);
116 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
117 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
118 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
119 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
120 wpa_s->ap_ies_from_associnfo = 0;
124 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
126 struct wpa_ie_data ie;
130 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
134 for (i = 0; i < ie.num_pmkid; i++) {
135 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
136 ie.pmkid + i * PMKID_LEN,
138 if (pmksa_set == 0) {
139 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
144 wpa_printf(MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from PMKSA "
145 "cache", pmksa_set == 0 ? "" : "not ");
149 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
150 union wpa_event_data *data)
153 wpa_printf(MSG_DEBUG, "RSN: No data in PMKID candidate event");
156 wpa_printf(MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
157 " index=%d preauth=%d",
158 MAC2STR(data->pmkid_candidate.bssid),
159 data->pmkid_candidate.index,
160 data->pmkid_candidate.preauth);
162 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
163 data->pmkid_candidate.index,
164 data->pmkid_candidate.preauth);
168 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
170 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
171 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
174 #ifdef IEEE8021X_EAPOL
175 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
176 wpa_s->current_ssid &&
177 !(wpa_s->current_ssid->eapol_flags &
178 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
179 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
180 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
181 * plaintext or static WEP keys). */
184 #endif /* IEEE8021X_EAPOL */
191 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
192 * @wpa_s: pointer to wpa_supplicant data
193 * @ssid: Configuration data for the network
194 * Returns: 0 on success, -1 on failure
196 * This function is called when starting authentication with a network that is
197 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
199 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
200 struct wpa_ssid *ssid)
202 #ifdef IEEE8021X_EAPOL
203 int aka = 0, sim = 0, type;
205 if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
208 if (ssid->eap.eap_methods == NULL) {
212 struct eap_method_type *eap = ssid->eap.eap_methods;
213 while (eap->vendor != EAP_VENDOR_IETF ||
214 eap->method != EAP_TYPE_NONE) {
215 if (eap->vendor == EAP_VENDOR_IETF) {
216 if (eap->method == EAP_TYPE_SIM)
218 else if (eap->method == EAP_TYPE_AKA)
225 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
227 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL)
231 wpa_printf(MSG_DEBUG, "Selected network is configured to use "
232 "SIM, but neither EAP-SIM nor EAP-AKA are enabled");
236 wpa_printf(MSG_DEBUG, "Selected network is configured to use SIM "
237 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
239 type = SCARD_TRY_BOTH;
241 type = SCARD_USIM_ONLY;
243 type = SCARD_GSM_SIM_ONLY;
245 wpa_s->scard = scard_init(type);
246 if (wpa_s->scard == NULL) {
247 wpa_printf(MSG_WARNING, "Failed to initialize SIM "
251 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
252 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
253 #endif /* IEEE8021X_EAPOL */
259 #ifndef CONFIG_NO_SCAN_PROCESSING
260 static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
261 struct wpa_ssid *ssid)
265 if (ssid->mixed_cell)
269 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
271 #endif /* CONFIG_WPS */
273 for (i = 0; i < NUM_WEP_KEYS; i++) {
274 if (ssid->wep_key_len[i]) {
279 #ifdef IEEE8021X_EAPOL
280 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
281 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
282 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
284 #endif /* IEEE8021X_EAPOL */
286 if (bss->caps & IEEE80211_CAP_PRIVACY)
292 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
293 struct wpa_ssid *ssid,
294 struct wpa_scan_res *bss)
296 struct wpa_ie_data ie;
298 const u8 *rsn_ie, *wpa_ie;
301 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
305 rsn_ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
306 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
309 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
310 wpa_printf(MSG_DEBUG, " skip RSN IE - parse failed");
313 if (!(ie.proto & ssid->proto)) {
314 wpa_printf(MSG_DEBUG, " skip RSN IE - proto "
319 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
320 wpa_printf(MSG_DEBUG, " skip RSN IE - PTK cipher "
325 if (!(ie.group_cipher & ssid->group_cipher)) {
326 wpa_printf(MSG_DEBUG, " skip RSN IE - GTK cipher "
331 if (!(ie.key_mgmt & ssid->key_mgmt)) {
332 wpa_printf(MSG_DEBUG, " skip RSN IE - key mgmt "
337 #ifdef CONFIG_IEEE80211W
338 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
339 ssid->ieee80211w == IEEE80211W_REQUIRED) {
340 wpa_printf(MSG_DEBUG, " skip RSN IE - no mgmt frame "
344 #endif /* CONFIG_IEEE80211W */
346 wpa_printf(MSG_DEBUG, " selected based on RSN IE");
350 wpa_ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
351 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
354 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
355 wpa_printf(MSG_DEBUG, " skip WPA IE - parse failed");
358 if (!(ie.proto & ssid->proto)) {
359 wpa_printf(MSG_DEBUG, " skip WPA IE - proto "
364 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
365 wpa_printf(MSG_DEBUG, " skip WPA IE - PTK cipher "
370 if (!(ie.group_cipher & ssid->group_cipher)) {
371 wpa_printf(MSG_DEBUG, " skip WPA IE - GTK cipher "
376 if (!(ie.key_mgmt & ssid->key_mgmt)) {
377 wpa_printf(MSG_DEBUG, " skip WPA IE - key mgmt "
382 wpa_printf(MSG_DEBUG, " selected based on WPA IE");
386 if (proto_match == 0)
387 wpa_printf(MSG_DEBUG, " skip - no WPA/RSN proto match");
393 static struct wpa_bss *
394 wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
395 struct wpa_scan_results *scan_res,
396 struct wpa_ssid *group,
397 struct wpa_ssid **selected_ssid)
399 struct wpa_ssid *ssid;
400 struct wpa_scan_res *bss;
402 struct wpa_blacklist *e;
405 wpa_printf(MSG_DEBUG, "Try to find WPA-enabled AP");
406 for (i = 0; i < scan_res->num; i++) {
408 u8 wpa_ie_len, rsn_ie_len, ssid_len;
409 bss = scan_res->res[i];
411 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
412 ssid_ = ie ? ie + 2 : (u8 *) "";
413 ssid_len = ie ? ie[1] : 0;
415 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
416 wpa_ie_len = ie ? ie[1] : 0;
418 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
419 rsn_ie_len = ie ? ie[1] : 0;
421 wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
422 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
423 (int) i, MAC2STR(bss->bssid),
424 wpa_ssid_txt(ssid_, ssid_len),
425 wpa_ie_len, rsn_ie_len, bss->caps);
427 e = wpa_blacklist_get(wpa_s, bss->bssid);
428 if (e && e->count > 1) {
429 wpa_printf(MSG_DEBUG, " skip - blacklisted");
434 wpa_printf(MSG_DEBUG, " skip - SSID not known");
438 if (wpa_ie_len == 0 && rsn_ie_len == 0) {
439 wpa_printf(MSG_DEBUG, " skip - no WPA/RSN IE");
443 for (ssid = group; ssid; ssid = ssid->pnext) {
446 if (ssid->disabled) {
447 wpa_printf(MSG_DEBUG, " skip - disabled");
452 if (ssid->ssid_len == 0 &&
453 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
455 #endif /* CONFIG_WPS */
458 (ssid_len != ssid->ssid_len ||
459 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
460 wpa_printf(MSG_DEBUG, " skip - "
465 if (ssid->bssid_set &&
466 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
468 wpa_printf(MSG_DEBUG, " skip - "
473 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
476 wpa_printf(MSG_DEBUG, " selected WPA AP "
479 wpa_ssid_txt(ssid_, ssid_len));
480 *selected_ssid = ssid;
481 return wpa_bss_get(wpa_s, bss->bssid, ssid_, ssid_len);
489 static struct wpa_bss *
490 wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
491 struct wpa_scan_results *scan_res,
492 struct wpa_ssid *group,
493 struct wpa_ssid **selected_ssid)
495 struct wpa_ssid *ssid;
496 struct wpa_scan_res *bss;
498 struct wpa_blacklist *e;
501 wpa_printf(MSG_DEBUG, "Try to find non-WPA AP");
502 for (i = 0; i < scan_res->num; i++) {
504 u8 wpa_ie_len, rsn_ie_len, ssid_len;
505 bss = scan_res->res[i];
507 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
508 ssid_ = ie ? ie + 2 : (u8 *) "";
509 ssid_len = ie ? ie[1] : 0;
511 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
512 wpa_ie_len = ie ? ie[1] : 0;
514 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
515 rsn_ie_len = ie ? ie[1] : 0;
517 wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
518 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
519 (int) i, MAC2STR(bss->bssid),
520 wpa_ssid_txt(ssid_, ssid_len),
521 wpa_ie_len, rsn_ie_len, bss->caps);
523 e = wpa_blacklist_get(wpa_s, bss->bssid);
524 if (e && e->count > 1) {
525 wpa_printf(MSG_DEBUG, " skip - blacklisted");
530 wpa_printf(MSG_DEBUG, " skip - SSID not known");
534 for (ssid = group; ssid; ssid = ssid->pnext) {
535 int check_ssid = ssid->ssid_len != 0;
537 if (ssid->disabled) {
538 wpa_printf(MSG_DEBUG, " skip - disabled");
543 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
544 /* Only allow wildcard SSID match if an AP
545 * advertises active WPS operation that matches
548 if (ssid->ssid_len == 0 &&
549 wpas_wps_ssid_wildcard_ok(wpa_s, ssid,
553 #endif /* CONFIG_WPS */
556 (ssid_len != ssid->ssid_len ||
557 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
558 wpa_printf(MSG_DEBUG, " skip - "
563 if (ssid->bssid_set &&
564 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
566 wpa_printf(MSG_DEBUG, " skip - "
571 if (!(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
572 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
573 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA))
575 wpa_printf(MSG_DEBUG, " skip - "
576 "non-WPA network not allowed");
580 if ((ssid->key_mgmt &
581 (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
582 WPA_KEY_MGMT_FT_IEEE8021X | WPA_KEY_MGMT_FT_PSK |
583 WPA_KEY_MGMT_IEEE8021X_SHA256 |
584 WPA_KEY_MGMT_PSK_SHA256)) &&
585 (wpa_ie_len != 0 || rsn_ie_len != 0)) {
586 wpa_printf(MSG_DEBUG, " skip - "
591 if (!wpa_supplicant_match_privacy(bss, ssid)) {
592 wpa_printf(MSG_DEBUG, " skip - "
597 if (bss->caps & IEEE80211_CAP_IBSS) {
598 wpa_printf(MSG_DEBUG, " skip - "
599 "IBSS (adhoc) network");
603 wpa_printf(MSG_DEBUG, " selected non-WPA AP "
606 wpa_ssid_txt(ssid_, ssid_len));
607 *selected_ssid = ssid;
608 return wpa_bss_get(wpa_s, bss->bssid, ssid_, ssid_len);
616 static struct wpa_bss *
617 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s,
618 struct wpa_scan_results *scan_res,
619 struct wpa_ssid *group,
620 struct wpa_ssid **selected_ssid)
622 struct wpa_bss *selected;
624 wpa_printf(MSG_DEBUG, "Selecting BSS from priority group %d",
627 /* First, try to find WPA-enabled AP */
628 selected = wpa_supplicant_select_bss_wpa(wpa_s, scan_res, group,
633 /* If no WPA-enabled AP found, try to find non-WPA AP, if configuration
635 return wpa_supplicant_select_bss_non_wpa(wpa_s, scan_res, group,
640 static struct wpa_bss *
641 wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
642 struct wpa_scan_results *scan_res,
643 struct wpa_ssid **selected_ssid)
645 struct wpa_bss *selected = NULL;
648 while (selected == NULL) {
649 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
650 selected = wpa_supplicant_select_bss(
651 wpa_s, scan_res, wpa_s->conf->pssid[prio],
657 if (selected == NULL && wpa_s->blacklist) {
658 wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
660 wpa_blacklist_clear(wpa_s);
661 wpa_s->blacklist_cleared++;
662 } else if (selected == NULL)
670 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
673 if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1) {
675 * Quick recovery if the initial scan results were not
676 * complete when fetched before the first scan request.
678 wpa_s->scan_res_tried++;
680 } else if (!wpa_supplicant_enabled_networks(wpa_s->conf)) {
682 * No networks are enabled; short-circuit request so
683 * we don't wait timeout seconds before transitioning
686 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
689 wpa_supplicant_req_scan(wpa_s, timeout, 0);
693 static void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
694 struct wpa_bss *selected,
695 struct wpa_ssid *ssid)
697 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
698 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
699 "PBC session overlap");
700 wpa_supplicant_req_new_scan(wpa_s, 10);
705 * Do not trigger new association unless the BSSID has changed or if
706 * reassociation is requested. If we are in process of associating with
707 * the selected BSSID, do not trigger new attempt.
709 if (wpa_s->reassociate ||
710 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
711 (wpa_s->wpa_state != WPA_ASSOCIATING ||
712 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
714 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
715 wpa_supplicant_req_new_scan(wpa_s, 10);
718 wpa_supplicant_associate(wpa_s, selected, ssid);
720 wpa_printf(MSG_DEBUG, "Already associated with the selected "
726 static struct wpa_ssid *
727 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
730 struct wpa_ssid *ssid;
732 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
733 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
737 if (ssid->mode == IEEE80211_MODE_IBSS ||
738 ssid->mode == IEEE80211_MODE_AP)
746 /* TODO: move the rsn_preauth_scan_result*() to be called from notify.c based
747 * on BSS added and BSS changed events */
748 static void wpa_supplicant_rsn_preauth_scan_results(
749 struct wpa_supplicant *wpa_s, struct wpa_scan_results *scan_res)
753 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
756 for (i = scan_res->num - 1; i >= 0; i--) {
757 const u8 *ssid, *rsn;
758 struct wpa_scan_res *r;
760 r = scan_res->res[i];
762 ssid = wpa_scan_get_ie(r, WLAN_EID_SSID);
766 rsn = wpa_scan_get_ie(r, WLAN_EID_RSN);
770 rsn_preauth_scan_result(wpa_s->wpa, r->bssid, ssid, rsn);
776 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s,
777 union wpa_event_data *data)
779 struct wpa_bss *selected;
780 struct wpa_ssid *ssid = NULL;
781 struct wpa_scan_results *scan_res;
783 wpa_supplicant_notify_scanning(wpa_s, 0);
785 scan_res = wpa_supplicant_get_scan_results(wpa_s,
786 data ? &data->scan_info :
788 if (scan_res == NULL) {
789 if (wpa_s->conf->ap_scan == 2)
791 wpa_printf(MSG_DEBUG, "Failed to get scan results - try "
793 wpa_supplicant_req_new_scan(wpa_s, 1);
798 * Don't post the results if this was the initial cached
799 * and there were no results.
801 if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1 &&
802 scan_res->num == 0) {
803 wpa_msg(wpa_s, MSG_DEBUG, "Cached scan results are "
804 "empty - not posting");
806 wpa_printf(MSG_DEBUG, "New scan results available");
807 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
808 wpas_notify_scan_results(wpa_s);
811 wpas_notify_scan_done(wpa_s, 1);
813 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s))) {
814 wpa_scan_results_free(scan_res);
818 if (wpa_s->disconnected) {
819 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
820 wpa_scan_results_free(scan_res);
824 if (bgscan_notify_scan(wpa_s) == 1) {
825 wpa_scan_results_free(scan_res);
829 wpa_supplicant_rsn_preauth_scan_results(wpa_s, scan_res);
831 selected = wpa_supplicant_pick_network(wpa_s, scan_res, &ssid);
832 wpa_scan_results_free(scan_res);
835 wpa_supplicant_connect(wpa_s, selected, ssid);
837 wpa_printf(MSG_DEBUG, "No suitable network found");
838 ssid = wpa_supplicant_pick_new_network(wpa_s);
840 wpa_printf(MSG_DEBUG, "Setup a new network");
841 wpa_supplicant_associate(wpa_s, NULL, ssid);
843 wpa_supplicant_req_new_scan(wpa_s, 5);
846 #endif /* CONFIG_NO_SCAN_PROCESSING */
849 #ifdef CONFIG_IEEE80211R
850 static void wpa_assoc_set_ft_params(struct wpa_supplicant *wpa_s,
851 const u8 *ftie, const u8 *mdie)
853 const u8 *mobility_domain = NULL;
854 const u8 *r0kh_id = NULL;
855 size_t r0kh_id_len = 0;
856 const u8 *r1kh_id = NULL;
857 struct rsn_ftie *hdr;
860 if (mdie == NULL || ftie == NULL)
863 if (mdie[1] >= MOBILITY_DOMAIN_ID_LEN) {
864 mobility_domain = mdie + 2;
866 wpa_s->sme.ft_used = 1;
867 os_memcpy(wpa_s->sme.mobility_domain, mobility_domain, 2);
868 #endif /* CONFIG_SME */
870 if (ftie[1] >= sizeof(struct rsn_ftie)) {
871 end = ftie + 2 + ftie[1];
872 hdr = (struct rsn_ftie *) (ftie + 2);
873 pos = (const u8 *) (hdr + 1);
874 while (pos + 1 < end) {
875 if (pos + 2 + pos[1] > end)
877 if (pos[0] == FTIE_SUBELEM_R1KH_ID &&
878 pos[1] == FT_R1KH_ID_LEN)
880 else if (pos[0] == FTIE_SUBELEM_R0KH_ID &&
881 pos[1] >= 1 && pos[1] <= FT_R0KH_ID_MAX_LEN) {
883 r0kh_id_len = pos[1];
888 wpa_sm_set_ft_params(wpa_s->wpa, mobility_domain, r0kh_id,
889 r0kh_id_len, r1kh_id);
891 #endif /* CONFIG_IEEE80211R */
893 static void wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
894 union wpa_event_data *data)
896 int l, len, found = 0, wpa_found, rsn_found;
898 #ifdef CONFIG_IEEE80211R
899 const u8 *mdie = NULL, *ftie = NULL;
900 #endif /* CONFIG_IEEE80211R */
902 wpa_printf(MSG_DEBUG, "Association info event");
903 if (data->assoc_info.req_ies)
904 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
905 data->assoc_info.req_ies_len);
906 if (data->assoc_info.resp_ies)
907 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
908 data->assoc_info.resp_ies_len);
909 if (data->assoc_info.beacon_ies)
910 wpa_hexdump(MSG_DEBUG, "beacon_ies",
911 data->assoc_info.beacon_ies,
912 data->assoc_info.beacon_ies_len);
913 if (data->assoc_info.freq)
914 wpa_printf(MSG_DEBUG, "freq=%u MHz", data->assoc_info.freq);
916 p = data->assoc_info.req_ies;
917 l = data->assoc_info.req_ies_len;
919 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
920 while (p && l >= 2) {
923 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
927 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
928 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
929 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
930 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
933 wpa_find_assoc_pmkid(wpa_s);
939 if (!found && data->assoc_info.req_ies)
940 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
942 #ifdef CONFIG_IEEE80211R
943 p = data->assoc_info.resp_ies;
944 l = data->assoc_info.resp_ies_len;
946 /* Go through the IEs and make a copy of the FT/MD IE, if present. */
947 while (p && l >= 2) {
950 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
954 if (p[0] == WLAN_EID_FAST_BSS_TRANSITION)
956 else if (p[0] == WLAN_EID_MOBILITY_DOMAIN)
962 wpa_assoc_set_ft_params(wpa_s, ftie, mdie);
963 #endif /* CONFIG_IEEE80211R */
965 /* WPA/RSN IE from Beacon/ProbeResp */
966 p = data->assoc_info.beacon_ies;
967 l = data->assoc_info.beacon_ies_len;
969 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
971 wpa_found = rsn_found = 0;
972 while (p && l >= 2) {
975 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
980 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
981 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
983 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
987 p[0] == WLAN_EID_RSN && p[1] >= 2) {
989 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
996 if (!wpa_found && data->assoc_info.beacon_ies)
997 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
998 if (!rsn_found && data->assoc_info.beacon_ies)
999 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
1000 if (wpa_found || rsn_found)
1001 wpa_s->ap_ies_from_associnfo = 1;
1003 wpa_s->assoc_freq = data->assoc_info.freq;
1007 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
1008 union wpa_event_data *data)
1011 int ft_completed = wpa_ft_is_completed(wpa_s->wpa);
1013 struct wpa_driver_capa capa;
1016 wpa_supplicant_event_associnfo(wpa_s, data);
1018 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
1019 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
1020 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
1021 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) ||
1022 (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
1023 os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) {
1024 wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
1025 MACSTR, MAC2STR(bssid));
1026 bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
1027 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1028 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1030 wpas_notify_bssid_changed(wpa_s);
1032 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1033 wpa_clear_keys(wpa_s, bssid);
1035 if (wpa_supplicant_select_config(wpa_s) < 0) {
1036 wpa_supplicant_disassociate(
1037 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1043 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1044 wpa_s->sme.prev_bssid_set = 1;
1045 #endif /* CONFIG_SME */
1047 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1048 if (wpa_s->current_ssid) {
1049 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1050 * initialized before association, but for other modes,
1051 * initialize PC/SC here, if the current configuration needs
1052 * smartcard or SIM/USIM. */
1053 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1055 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1056 l2_packet_notify_auth_start(wpa_s->l2);
1059 * Set portEnabled first to FALSE in order to get EAP state machine out
1060 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1061 * state machine may transit to AUTHENTICATING state based on obsolete
1062 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1063 * AUTHENTICATED without ever giving chance to EAP state machine to
1066 if (!ft_completed) {
1067 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1068 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1070 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1071 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1072 /* 802.1X::portControl = Auto */
1073 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1074 wpa_s->eapol_received = 0;
1075 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1076 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1077 (wpa_s->current_ssid &&
1078 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1079 wpa_supplicant_cancel_auth_timeout(wpa_s);
1080 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1081 } else if (!ft_completed) {
1082 /* Timeout for receiving the first EAPOL packet */
1083 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1085 wpa_supplicant_cancel_scan(wpa_s);
1087 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1088 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1090 * We are done; the driver will take care of RSN 4-way
1093 wpa_supplicant_cancel_auth_timeout(wpa_s);
1094 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1095 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1096 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1099 if (wpa_s->pending_eapol_rx) {
1100 struct os_time now, age;
1102 os_time_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1103 if (age.sec == 0 && age.usec < 100000 &&
1104 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1106 wpa_printf(MSG_DEBUG, "Process pending EAPOL frame "
1107 "that was received just before association "
1109 wpa_supplicant_rx_eapol(
1110 wpa_s, wpa_s->pending_eapol_rx_src,
1111 wpabuf_head(wpa_s->pending_eapol_rx),
1112 wpabuf_len(wpa_s->pending_eapol_rx));
1114 wpabuf_free(wpa_s->pending_eapol_rx);
1115 wpa_s->pending_eapol_rx = NULL;
1118 #ifdef CONFIG_BGSCAN
1119 if (wpa_s->current_ssid != wpa_s->bgscan_ssid) {
1120 bgscan_deinit(wpa_s);
1121 if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) {
1122 if (bgscan_init(wpa_s, wpa_s->current_ssid)) {
1123 wpa_printf(MSG_DEBUG, "Failed to initialize "
1126 * Live without bgscan; it is only used as a
1127 * roaming optimization, so the initial
1128 * connection is not affected.
1131 wpa_s->bgscan_ssid = wpa_s->current_ssid;
1133 wpa_s->bgscan_ssid = NULL;
1135 #endif /* CONFIG_BGSCAN */
1137 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1138 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
1139 wpa_s->current_ssid && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1140 capa.flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) {
1141 /* Set static WEP keys again */
1142 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
1147 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
1152 u8 prev_pending_bssid[ETH_ALEN];
1154 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
1155 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
1156 #endif /* CONFIG_SME */
1158 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1160 * At least Host AP driver and a Prism3 card seemed to be
1161 * generating streams of disconnected events when configuring
1162 * IBSS for WPA-None. Ignore them for now.
1164 wpa_printf(MSG_DEBUG, "Disconnect event - ignore in "
1165 "IBSS/WPA-None mode");
1169 if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
1170 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1171 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
1172 "pre-shared key may be incorrect");
1174 if (wpa_s->wpa_state >= WPA_ASSOCIATED)
1175 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1176 bssid = wpa_s->bssid;
1177 if (is_zero_ether_addr(bssid))
1178 bssid = wpa_s->pending_bssid;
1179 wpa_blacklist_add(wpa_s, bssid);
1180 wpa_sm_notify_disassoc(wpa_s->wpa);
1181 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "- Disconnect event - "
1183 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1184 wpa_s->keys_cleared = 0;
1185 wpa_clear_keys(wpa_s, wpa_s->bssid);
1187 wpa_supplicant_mark_disassoc(wpa_s);
1188 bgscan_deinit(wpa_s);
1190 if (authenticating &&
1191 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) {
1193 * mac80211-workaround to force deauth on failed auth cmd,
1194 * requires us to remain in authenticating state to allow the
1195 * second authentication attempt to be continued properly.
1197 wpa_printf(MSG_DEBUG, "SME: Allow pending authentication to "
1198 "proceed after disconnection event");
1199 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
1200 os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN);
1202 #endif /* CONFIG_SME */
1206 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1207 static void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx,
1210 struct wpa_supplicant *wpa_s = eloop_ctx;
1212 if (!wpa_s->pending_mic_error_report)
1215 wpa_printf(MSG_DEBUG, "WPA: Sending pending MIC error report");
1216 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1217 wpa_s->pending_mic_error_report = 0;
1219 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1223 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1224 union wpa_event_data *data)
1229 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1230 pairwise = (data && data->michael_mic_failure.unicast);
1232 if ((wpa_s->last_michael_mic_error &&
1233 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1234 wpa_s->pending_mic_error_report) {
1235 if (wpa_s->pending_mic_error_report) {
1237 * Send the pending MIC error report immediately since
1238 * we are going to start countermeasures and AP better
1241 wpa_sm_key_request(wpa_s->wpa, 1,
1242 wpa_s->pending_mic_error_pairwise);
1245 /* Send the new MIC error report immediately since we are going
1246 * to start countermeasures and AP better do the same.
1248 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1250 /* initialize countermeasures */
1251 wpa_s->countermeasures = 1;
1252 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1255 * Need to wait for completion of request frame. We do not get
1256 * any callback for the message completion, so just wait a
1257 * short while and hope for the best. */
1260 wpa_drv_set_countermeasures(wpa_s, 1);
1261 wpa_supplicant_deauthenticate(wpa_s,
1262 WLAN_REASON_MICHAEL_MIC_FAILURE);
1263 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1265 eloop_register_timeout(60, 0,
1266 wpa_supplicant_stop_countermeasures,
1268 /* TODO: mark the AP rejected for 60 second. STA is
1269 * allowed to associate with another AP.. */
1271 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1272 if (wpa_s->mic_errors_seen) {
1274 * Reduce the effectiveness of Michael MIC error
1275 * reports as a means for attacking against TKIP if
1276 * more than one MIC failure is noticed with the same
1277 * PTK. We delay the transmission of the reports by a
1278 * random time between 0 and 60 seconds in order to
1279 * force the attacker wait 60 seconds before getting
1280 * the information on whether a frame resulted in a MIC
1286 if (os_get_random(rval, sizeof(rval)) < 0)
1287 sec = os_random() % 60;
1289 sec = WPA_GET_BE32(rval) % 60;
1290 wpa_printf(MSG_DEBUG, "WPA: Delay MIC error report %d "
1292 wpa_s->pending_mic_error_report = 1;
1293 wpa_s->pending_mic_error_pairwise = pairwise;
1294 eloop_cancel_timeout(
1295 wpa_supplicant_delayed_mic_error_report,
1297 eloop_register_timeout(
1298 sec, os_random() % 1000000,
1299 wpa_supplicant_delayed_mic_error_report,
1302 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1304 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1305 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1306 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1308 wpa_s->last_michael_mic_error = t.sec;
1309 wpa_s->mic_errors_seen++;
1313 #ifdef CONFIG_TERMINATE_ONLASTIF
1314 static int any_interfaces(struct wpa_supplicant *head)
1316 struct wpa_supplicant *wpa_s;
1318 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1319 if (!wpa_s->interface_removed)
1323 #endif /* CONFIG_TERMINATE_ONLASTIF */
1327 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1328 union wpa_event_data *data)
1330 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1333 switch (data->interface_status.ievent) {
1334 case EVENT_INTERFACE_ADDED:
1335 if (!wpa_s->interface_removed)
1337 wpa_s->interface_removed = 0;
1338 wpa_printf(MSG_DEBUG, "Configured interface was added.");
1339 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1340 wpa_printf(MSG_INFO, "Failed to initialize the driver "
1341 "after interface was added.");
1344 case EVENT_INTERFACE_REMOVED:
1345 wpa_printf(MSG_DEBUG, "Configured interface was removed.");
1346 wpa_s->interface_removed = 1;
1347 wpa_supplicant_mark_disassoc(wpa_s);
1348 l2_packet_deinit(wpa_s->l2);
1350 #ifdef CONFIG_TERMINATE_ONLASTIF
1351 /* check if last interface */
1352 if (!any_interfaces(wpa_s->global->ifaces))
1354 #endif /* CONFIG_TERMINATE_ONLASTIF */
1360 #ifdef CONFIG_PEERKEY
1362 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1363 union wpa_event_data *data)
1367 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1369 #endif /* CONFIG_PEERKEY */
1372 #ifdef CONFIG_IEEE80211R
1374 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1375 union wpa_event_data *data)
1380 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
1381 data->ft_ies.ies_len,
1382 data->ft_ies.ft_action,
1383 data->ft_ies.target_ap,
1384 data->ft_ies.ric_ies,
1385 data->ft_ies.ric_ies_len) < 0) {
1386 /* TODO: prevent MLME/driver from trying to associate? */
1389 #endif /* CONFIG_IEEE80211R */
1392 #ifdef CONFIG_IBSS_RSN
1393 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
1394 union wpa_event_data *data)
1398 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
1400 #endif /* CONFIG_IBSS_RSN */
1403 void wpa_supplicant_event(void *ctx, wpa_event_type event,
1404 union wpa_event_data *data)
1406 struct wpa_supplicant *wpa_s = ctx;
1410 sme_event_auth(wpa_s, data);
1413 wpa_supplicant_event_assoc(wpa_s, data);
1415 case EVENT_DISASSOC:
1416 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
1417 sme_event_disassoc(wpa_s, data);
1420 wpa_supplicant_event_disassoc(wpa_s);
1422 case EVENT_MICHAEL_MIC_FAILURE:
1423 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
1425 #ifndef CONFIG_NO_SCAN_PROCESSING
1426 case EVENT_SCAN_RESULTS:
1427 wpa_supplicant_event_scan_results(wpa_s, data);
1429 #endif /* CONFIG_NO_SCAN_PROCESSING */
1430 case EVENT_ASSOCINFO:
1431 wpa_supplicant_event_associnfo(wpa_s, data);
1433 case EVENT_INTERFACE_STATUS:
1434 wpa_supplicant_event_interface_status(wpa_s, data);
1436 case EVENT_PMKID_CANDIDATE:
1437 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
1439 #ifdef CONFIG_PEERKEY
1440 case EVENT_STKSTART:
1441 wpa_supplicant_event_stkstart(wpa_s, data);
1443 #endif /* CONFIG_PEERKEY */
1444 #ifdef CONFIG_IEEE80211R
1445 case EVENT_FT_RESPONSE:
1446 wpa_supplicant_event_ft_response(wpa_s, data);
1448 #endif /* CONFIG_IEEE80211R */
1449 #ifdef CONFIG_IBSS_RSN
1450 case EVENT_IBSS_RSN_START:
1451 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
1453 #endif /* CONFIG_IBSS_RSN */
1454 case EVENT_ASSOC_REJECT:
1455 sme_event_assoc_reject(wpa_s, data);
1457 case EVENT_AUTH_TIMED_OUT:
1458 sme_event_auth_timed_out(wpa_s, data);
1460 case EVENT_ASSOC_TIMED_OUT:
1461 sme_event_assoc_timed_out(wpa_s, data);
1464 case EVENT_TX_STATUS:
1465 if (wpa_s->ap_iface == NULL)
1467 switch (data->tx_status.type) {
1468 case WLAN_FC_TYPE_MGMT:
1469 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
1470 data->tx_status.data_len,
1471 data->tx_status.stype,
1472 data->tx_status.ack);
1474 case WLAN_FC_TYPE_DATA:
1475 ap_tx_status(wpa_s, data->tx_status.dst,
1476 data->tx_status.data,
1477 data->tx_status.data_len,
1478 data->tx_status.ack);
1482 case EVENT_RX_FROM_UNKNOWN:
1483 if (wpa_s->ap_iface == NULL)
1485 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.hdr,
1486 data->rx_from_unknown.len);
1489 if (wpa_s->ap_iface == NULL)
1491 ap_mgmt_rx(wpa_s, data->rx_mgmt.frame,
1492 data->rx_mgmt.frame_len, data->rx_mgmt.fi);
1494 #endif /* CONFIG_AP */
1496 wpa_printf(MSG_INFO, "Unknown event %d", event);