2 * WPA Supplicant - Driver event processing
3 * Copyright (c) 2003-2009, 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"
41 static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
43 struct wpa_ssid *ssid, *old_ssid;
45 if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
48 wpa_printf(MSG_DEBUG, "Select network based on association "
50 ssid = wpa_supplicant_get_ssid(wpa_s);
52 wpa_printf(MSG_INFO, "No network configuration found for the "
58 wpa_printf(MSG_DEBUG, "Selected network is disabled");
62 wpa_printf(MSG_DEBUG, "Network configuration found for the current "
64 if (ssid->key_mgmt & (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X |
65 WPA_KEY_MGMT_WPA_NONE |
66 WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X |
67 WPA_KEY_MGMT_PSK_SHA256 |
68 WPA_KEY_MGMT_IEEE8021X_SHA256)) {
70 size_t wpa_ie_len = sizeof(wpa_ie);
71 wpa_supplicant_set_suites(wpa_s, NULL, ssid,
74 wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
77 if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
78 eapol_sm_invalidate_cached_session(wpa_s->eapol);
79 old_ssid = wpa_s->current_ssid;
80 wpa_s->current_ssid = ssid;
81 wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
82 wpa_supplicant_initiate_eapol(wpa_s);
83 if (old_ssid != wpa_s->current_ssid)
84 wpas_notify_network_changed(wpa_s);
90 static void wpa_supplicant_stop_countermeasures(void *eloop_ctx,
93 struct wpa_supplicant *wpa_s = eloop_ctx;
95 if (wpa_s->countermeasures) {
96 wpa_s->countermeasures = 0;
97 wpa_drv_set_countermeasures(wpa_s, 0);
98 wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
99 wpa_supplicant_req_scan(wpa_s, 0, 0);
104 void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
108 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
109 bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
110 os_memset(wpa_s->bssid, 0, ETH_ALEN);
111 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
113 wpas_notify_bssid_changed(wpa_s);
115 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
116 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
117 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
118 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
119 wpa_s->ap_ies_from_associnfo = 0;
123 static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
125 struct wpa_ie_data ie;
129 if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
133 for (i = 0; i < ie.num_pmkid; i++) {
134 pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
135 ie.pmkid + i * PMKID_LEN,
137 if (pmksa_set == 0) {
138 eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
143 wpa_printf(MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from PMKSA "
144 "cache", pmksa_set == 0 ? "" : "not ");
148 static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
149 union wpa_event_data *data)
152 wpa_printf(MSG_DEBUG, "RSN: No data in PMKID candidate event");
155 wpa_printf(MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
156 " index=%d preauth=%d",
157 MAC2STR(data->pmkid_candidate.bssid),
158 data->pmkid_candidate.index,
159 data->pmkid_candidate.preauth);
161 pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
162 data->pmkid_candidate.index,
163 data->pmkid_candidate.preauth);
167 static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
169 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
170 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
173 #ifdef IEEE8021X_EAPOL
174 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
175 wpa_s->current_ssid &&
176 !(wpa_s->current_ssid->eapol_flags &
177 (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
178 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
179 /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
180 * plaintext or static WEP keys). */
183 #endif /* IEEE8021X_EAPOL */
190 * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
191 * @wpa_s: pointer to wpa_supplicant data
192 * @ssid: Configuration data for the network
193 * Returns: 0 on success, -1 on failure
195 * This function is called when starting authentication with a network that is
196 * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
198 int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
199 struct wpa_ssid *ssid)
201 #ifdef IEEE8021X_EAPOL
202 int aka = 0, sim = 0, type;
204 if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
207 if (ssid->eap.eap_methods == NULL) {
211 struct eap_method_type *eap = ssid->eap.eap_methods;
212 while (eap->vendor != EAP_VENDOR_IETF ||
213 eap->method != EAP_TYPE_NONE) {
214 if (eap->vendor == EAP_VENDOR_IETF) {
215 if (eap->method == EAP_TYPE_SIM)
217 else if (eap->method == EAP_TYPE_AKA)
224 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
226 if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL)
230 wpa_printf(MSG_DEBUG, "Selected network is configured to use "
231 "SIM, but neither EAP-SIM nor EAP-AKA are enabled");
235 wpa_printf(MSG_DEBUG, "Selected network is configured to use SIM "
236 "(sim=%d aka=%d) - initialize PCSC", sim, aka);
238 type = SCARD_TRY_BOTH;
240 type = SCARD_USIM_ONLY;
242 type = SCARD_GSM_SIM_ONLY;
244 wpa_s->scard = scard_init(type);
245 if (wpa_s->scard == NULL) {
246 wpa_printf(MSG_WARNING, "Failed to initialize SIM "
250 wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
251 eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
252 #endif /* IEEE8021X_EAPOL */
258 #ifndef CONFIG_NO_SCAN_PROCESSING
259 static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
260 struct wpa_ssid *ssid)
264 if (ssid->mixed_cell)
268 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
270 #endif /* CONFIG_WPS */
272 for (i = 0; i < NUM_WEP_KEYS; i++) {
273 if (ssid->wep_key_len[i]) {
278 #ifdef IEEE8021X_EAPOL
279 if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
280 ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
281 EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
283 #endif /* IEEE8021X_EAPOL */
285 if (bss->caps & IEEE80211_CAP_PRIVACY)
291 static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
292 struct wpa_ssid *ssid,
293 struct wpa_scan_res *bss)
295 struct wpa_ie_data ie;
297 const u8 *rsn_ie, *wpa_ie;
300 ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
304 rsn_ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
305 while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
308 if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
309 wpa_printf(MSG_DEBUG, " skip RSN IE - parse failed");
312 if (!(ie.proto & ssid->proto)) {
313 wpa_printf(MSG_DEBUG, " skip RSN IE - proto "
318 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
319 wpa_printf(MSG_DEBUG, " skip RSN IE - PTK cipher "
324 if (!(ie.group_cipher & ssid->group_cipher)) {
325 wpa_printf(MSG_DEBUG, " skip RSN IE - GTK cipher "
330 if (!(ie.key_mgmt & ssid->key_mgmt)) {
331 wpa_printf(MSG_DEBUG, " skip RSN IE - key mgmt "
336 #ifdef CONFIG_IEEE80211W
337 if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
338 ssid->ieee80211w == IEEE80211W_REQUIRED) {
339 wpa_printf(MSG_DEBUG, " skip RSN IE - no mgmt frame "
343 #endif /* CONFIG_IEEE80211W */
345 wpa_printf(MSG_DEBUG, " selected based on RSN IE");
349 wpa_ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
350 while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
353 if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
354 wpa_printf(MSG_DEBUG, " skip WPA IE - parse failed");
357 if (!(ie.proto & ssid->proto)) {
358 wpa_printf(MSG_DEBUG, " skip WPA IE - proto "
363 if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
364 wpa_printf(MSG_DEBUG, " skip WPA IE - PTK cipher "
369 if (!(ie.group_cipher & ssid->group_cipher)) {
370 wpa_printf(MSG_DEBUG, " skip WPA IE - GTK cipher "
375 if (!(ie.key_mgmt & ssid->key_mgmt)) {
376 wpa_printf(MSG_DEBUG, " skip WPA IE - key mgmt "
381 wpa_printf(MSG_DEBUG, " selected based on WPA IE");
385 if (proto_match == 0)
386 wpa_printf(MSG_DEBUG, " skip - no WPA/RSN proto match");
392 static struct wpa_scan_res *
393 wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
394 struct wpa_ssid *group,
395 struct wpa_ssid **selected_ssid)
397 struct wpa_ssid *ssid;
398 struct wpa_scan_res *bss;
400 struct wpa_blacklist *e;
403 wpa_printf(MSG_DEBUG, "Try to find WPA-enabled AP");
404 for (i = 0; i < wpa_s->scan_res->num; i++) {
406 u8 wpa_ie_len, rsn_ie_len, ssid_len;
407 bss = wpa_s->scan_res->res[i];
409 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
410 ssid_ = ie ? ie + 2 : (u8 *) "";
411 ssid_len = ie ? ie[1] : 0;
413 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
414 wpa_ie_len = ie ? ie[1] : 0;
416 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
417 rsn_ie_len = ie ? ie[1] : 0;
419 wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
420 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
421 (int) i, MAC2STR(bss->bssid),
422 wpa_ssid_txt(ssid_, ssid_len),
423 wpa_ie_len, rsn_ie_len, bss->caps);
425 e = wpa_blacklist_get(wpa_s, bss->bssid);
426 if (e && e->count > 1) {
427 wpa_printf(MSG_DEBUG, " skip - blacklisted");
432 wpa_printf(MSG_DEBUG, " skip - SSID not known");
436 if (wpa_ie_len == 0 && rsn_ie_len == 0) {
437 wpa_printf(MSG_DEBUG, " skip - no WPA/RSN IE");
441 for (ssid = group; ssid; ssid = ssid->pnext) {
444 if (ssid->disabled) {
445 wpa_printf(MSG_DEBUG, " skip - disabled");
450 if (ssid->ssid_len == 0 &&
451 wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
453 #endif /* CONFIG_WPS */
456 (ssid_len != ssid->ssid_len ||
457 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
458 wpa_printf(MSG_DEBUG, " skip - "
463 if (ssid->bssid_set &&
464 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
466 wpa_printf(MSG_DEBUG, " skip - "
471 if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
474 wpa_printf(MSG_DEBUG, " selected WPA AP "
477 wpa_ssid_txt(ssid_, ssid_len));
478 *selected_ssid = ssid;
487 static struct wpa_scan_res *
488 wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
489 struct wpa_ssid *group,
490 struct wpa_ssid **selected_ssid)
492 struct wpa_ssid *ssid;
493 struct wpa_scan_res *bss;
495 struct wpa_blacklist *e;
498 wpa_printf(MSG_DEBUG, "Try to find non-WPA AP");
499 for (i = 0; i < wpa_s->scan_res->num; i++) {
501 u8 wpa_ie_len, rsn_ie_len, ssid_len;
502 bss = wpa_s->scan_res->res[i];
504 ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
505 ssid_ = ie ? ie + 2 : (u8 *) "";
506 ssid_len = ie ? ie[1] : 0;
508 ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
509 wpa_ie_len = ie ? ie[1] : 0;
511 ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
512 rsn_ie_len = ie ? ie[1] : 0;
514 wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
515 "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
516 (int) i, MAC2STR(bss->bssid),
517 wpa_ssid_txt(ssid_, ssid_len),
518 wpa_ie_len, rsn_ie_len, bss->caps);
520 e = wpa_blacklist_get(wpa_s, bss->bssid);
521 if (e && e->count > 1) {
522 wpa_printf(MSG_DEBUG, " skip - blacklisted");
527 wpa_printf(MSG_DEBUG, " skip - SSID not known");
531 for (ssid = group; ssid; ssid = ssid->pnext) {
532 int check_ssid = ssid->ssid_len != 0;
534 if (ssid->disabled) {
535 wpa_printf(MSG_DEBUG, " skip - disabled");
540 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
541 /* Only allow wildcard SSID match if an AP
542 * advertises active WPS operation that matches
545 if (ssid->ssid_len == 0 &&
546 wpas_wps_ssid_wildcard_ok(wpa_s, ssid,
550 #endif /* CONFIG_WPS */
553 (ssid_len != ssid->ssid_len ||
554 os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
555 wpa_printf(MSG_DEBUG, " skip - "
560 if (ssid->bssid_set &&
561 os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
563 wpa_printf(MSG_DEBUG, " skip - "
568 if (!(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
569 !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
570 !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA))
572 wpa_printf(MSG_DEBUG, " skip - "
573 "non-WPA network not allowed");
577 if ((ssid->key_mgmt &
578 (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
579 WPA_KEY_MGMT_FT_IEEE8021X | WPA_KEY_MGMT_FT_PSK |
580 WPA_KEY_MGMT_IEEE8021X_SHA256 |
581 WPA_KEY_MGMT_PSK_SHA256)) &&
582 (wpa_ie_len != 0 || rsn_ie_len != 0)) {
583 wpa_printf(MSG_DEBUG, " skip - "
588 if (!wpa_supplicant_match_privacy(bss, ssid)) {
589 wpa_printf(MSG_DEBUG, " skip - "
594 if (bss->caps & IEEE80211_CAP_IBSS) {
595 wpa_printf(MSG_DEBUG, " skip - "
596 "IBSS (adhoc) network");
600 wpa_printf(MSG_DEBUG, " selected non-WPA AP "
603 wpa_ssid_txt(ssid_, ssid_len));
604 *selected_ssid = ssid;
613 static struct wpa_scan_res *
614 wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, struct wpa_ssid *group,
615 struct wpa_ssid **selected_ssid)
617 struct wpa_scan_res *selected;
619 wpa_printf(MSG_DEBUG, "Selecting BSS from priority group %d",
622 /* First, try to find WPA-enabled AP */
623 selected = wpa_supplicant_select_bss_wpa(wpa_s, group, selected_ssid);
627 /* If no WPA-enabled AP found, try to find non-WPA AP, if configuration
629 return wpa_supplicant_select_bss_non_wpa(wpa_s, group, selected_ssid);
633 static struct wpa_scan_res *
634 wpa_supplicant_pick_network(struct wpa_supplicant *wpa_s,
635 struct wpa_ssid **selected_ssid)
637 struct wpa_scan_res *selected = NULL;
640 while (selected == NULL) {
641 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
642 selected = wpa_supplicant_select_bss(
643 wpa_s, wpa_s->conf->pssid[prio],
649 if (selected == NULL && wpa_s->blacklist) {
650 wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
652 wpa_blacklist_clear(wpa_s);
653 wpa_s->blacklist_cleared++;
654 } else if (selected == NULL)
662 static void wpa_supplicant_req_new_scan(struct wpa_supplicant *wpa_s,
665 if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1) {
667 * Quick recovery if the initial scan results were not
668 * complete when fetched before the first scan request.
670 wpa_s->scan_res_tried++;
672 } else if (!wpa_supplicant_enabled_networks(wpa_s->conf)) {
674 * No networks are enabled; short-circuit request so
675 * we don't wait timeout seconds before transitioning
678 wpa_supplicant_set_state(wpa_s, WPA_INACTIVE);
681 wpa_supplicant_req_scan(wpa_s, timeout, 0);
685 static void wpa_supplicant_connect(struct wpa_supplicant *wpa_s,
686 struct wpa_scan_res *selected,
687 struct wpa_ssid *ssid)
689 if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
690 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
691 "PBC session overlap");
692 wpa_supplicant_req_new_scan(wpa_s, 10);
697 * Do not trigger new association unless the BSSID has changed or if
698 * reassociation is requested. If we are in process of associating with
699 * the selected BSSID, do not trigger new attempt.
701 if (wpa_s->reassociate ||
702 (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
703 (wpa_s->wpa_state != WPA_ASSOCIATING ||
704 os_memcmp(selected->bssid, wpa_s->pending_bssid, ETH_ALEN) !=
706 if (wpa_supplicant_scard_init(wpa_s, ssid)) {
707 wpa_supplicant_req_new_scan(wpa_s, 10);
710 wpa_supplicant_associate(wpa_s, selected, ssid);
712 wpa_printf(MSG_DEBUG, "Already associated with the selected "
718 static struct wpa_ssid *
719 wpa_supplicant_pick_new_network(struct wpa_supplicant *wpa_s)
722 struct wpa_ssid *ssid;
724 for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
725 for (ssid = wpa_s->conf->pssid[prio]; ssid; ssid = ssid->pnext)
729 if (ssid->mode == IEEE80211_MODE_IBSS ||
730 ssid->mode == IEEE80211_MODE_AP)
738 static void wpa_supplicant_rsn_preauth_scan_results(
739 struct wpa_supplicant *wpa_s)
743 if (rsn_preauth_scan_results(wpa_s->wpa) < 0)
746 for (i = wpa_s->scan_res->num - 1; i >= 0; i--) {
747 const u8 *ssid, *rsn;
748 struct wpa_scan_res *r;
750 r = wpa_s->scan_res->res[i];
752 ssid = wpa_scan_get_ie(r, WLAN_EID_SSID);
756 rsn = wpa_scan_get_ie(r, WLAN_EID_RSN);
760 rsn_preauth_scan_result(wpa_s->wpa, r->bssid, ssid, rsn);
766 static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s)
768 struct wpa_scan_res *selected;
769 struct wpa_ssid *ssid = NULL;
771 wpa_supplicant_notify_scanning(wpa_s, 0);
773 if (wpa_supplicant_get_scan_results(wpa_s) < 0) {
774 if (wpa_s->conf->ap_scan == 2)
776 wpa_printf(MSG_DEBUG, "Failed to get scan results - try "
778 wpa_supplicant_req_new_scan(wpa_s, 1);
783 * Don't post the results if this was the initial cached
784 * and there were no results.
786 if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1 &&
787 wpa_s->scan_res->num == 0) {
788 wpa_msg(wpa_s, MSG_DEBUG, "Cached scan results are "
789 "empty - not posting");
791 wpa_printf(MSG_DEBUG, "New scan results available");
792 wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
793 wpas_notify_scan_results(wpa_s);
796 wpas_notify_scan_done(wpa_s, 1);
798 if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)))
801 if (wpa_s->disconnected) {
802 wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
806 if (bgscan_notify_scan(wpa_s) == 1)
809 wpa_supplicant_rsn_preauth_scan_results(wpa_s);
811 selected = wpa_supplicant_pick_network(wpa_s, &ssid);
813 wpa_supplicant_connect(wpa_s, selected, ssid);
815 wpa_printf(MSG_DEBUG, "No suitable network found");
816 ssid = wpa_supplicant_pick_new_network(wpa_s);
818 wpa_printf(MSG_DEBUG, "Setup a new network");
819 wpa_supplicant_associate(wpa_s, NULL, ssid);
821 wpa_supplicant_req_new_scan(wpa_s, 5);
824 #endif /* CONFIG_NO_SCAN_PROCESSING */
827 #ifdef CONFIG_IEEE80211R
828 static void wpa_assoc_set_ft_params(struct wpa_supplicant *wpa_s,
829 const u8 *ftie, const u8 *mdie)
831 const u8 *mobility_domain = NULL;
832 const u8 *r0kh_id = NULL;
833 size_t r0kh_id_len = 0;
834 const u8 *r1kh_id = NULL;
835 struct rsn_ftie *hdr;
838 if (mdie == NULL || ftie == NULL)
841 if (mdie[1] >= MOBILITY_DOMAIN_ID_LEN) {
842 mobility_domain = mdie + 2;
844 wpa_s->sme.ft_used = 1;
845 os_memcpy(wpa_s->sme.mobility_domain, mobility_domain, 2);
846 #endif /* CONFIG_SME */
848 if (ftie[1] >= sizeof(struct rsn_ftie)) {
849 end = ftie + 2 + ftie[1];
850 hdr = (struct rsn_ftie *) (ftie + 2);
851 pos = (const u8 *) (hdr + 1);
852 while (pos + 1 < end) {
853 if (pos + 2 + pos[1] > end)
855 if (pos[0] == FTIE_SUBELEM_R1KH_ID &&
856 pos[1] == FT_R1KH_ID_LEN)
858 else if (pos[0] == FTIE_SUBELEM_R0KH_ID &&
859 pos[1] >= 1 && pos[1] <= FT_R0KH_ID_MAX_LEN) {
861 r0kh_id_len = pos[1];
866 wpa_sm_set_ft_params(wpa_s->wpa, mobility_domain, r0kh_id,
867 r0kh_id_len, r1kh_id);
869 #endif /* CONFIG_IEEE80211R */
871 static void wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
872 union wpa_event_data *data)
874 int l, len, found = 0, wpa_found, rsn_found;
876 #ifdef CONFIG_IEEE80211R
877 const u8 *mdie = NULL, *ftie = NULL;
878 #endif /* CONFIG_IEEE80211R */
880 wpa_printf(MSG_DEBUG, "Association info event");
881 if (data->assoc_info.req_ies)
882 wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
883 data->assoc_info.req_ies_len);
884 if (data->assoc_info.resp_ies)
885 wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
886 data->assoc_info.resp_ies_len);
887 if (data->assoc_info.beacon_ies)
888 wpa_hexdump(MSG_DEBUG, "beacon_ies",
889 data->assoc_info.beacon_ies,
890 data->assoc_info.beacon_ies_len);
892 p = data->assoc_info.req_ies;
893 l = data->assoc_info.req_ies_len;
895 /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
896 while (p && l >= 2) {
899 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
903 if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
904 (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
905 (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
906 if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
909 wpa_find_assoc_pmkid(wpa_s);
915 if (!found && data->assoc_info.req_ies)
916 wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
918 #ifdef CONFIG_IEEE80211R
919 p = data->assoc_info.resp_ies;
920 l = data->assoc_info.resp_ies_len;
922 /* Go through the IEs and make a copy of the FT/MD IE, if present. */
923 while (p && l >= 2) {
926 wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
930 if (p[0] == WLAN_EID_FAST_BSS_TRANSITION)
932 else if (p[0] == WLAN_EID_MOBILITY_DOMAIN)
938 wpa_assoc_set_ft_params(wpa_s, ftie, mdie);
939 #endif /* CONFIG_IEEE80211R */
941 /* WPA/RSN IE from Beacon/ProbeResp */
942 p = data->assoc_info.beacon_ies;
943 l = data->assoc_info.beacon_ies_len;
945 /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
947 wpa_found = rsn_found = 0;
948 while (p && l >= 2) {
951 wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
956 p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
957 os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
959 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
963 p[0] == WLAN_EID_RSN && p[1] >= 2) {
965 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
972 if (!wpa_found && data->assoc_info.beacon_ies)
973 wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
974 if (!rsn_found && data->assoc_info.beacon_ies)
975 wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
976 if (wpa_found || rsn_found)
977 wpa_s->ap_ies_from_associnfo = 1;
981 static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
982 union wpa_event_data *data)
985 int ft_completed = wpa_ft_is_completed(wpa_s->wpa);
987 struct wpa_driver_capa capa;
990 wpa_supplicant_event_associnfo(wpa_s, data);
992 wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
993 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
994 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
995 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) ||
996 (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
997 os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) {
998 wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
999 MACSTR, MAC2STR(bssid));
1000 bssid_changed = os_memcmp(wpa_s->bssid, bssid, ETH_ALEN);
1001 os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
1002 os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
1004 wpas_notify_bssid_changed(wpa_s);
1006 if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
1007 wpa_clear_keys(wpa_s, bssid);
1009 if (wpa_supplicant_select_config(wpa_s) < 0) {
1010 wpa_supplicant_disassociate(
1011 wpa_s, WLAN_REASON_DEAUTH_LEAVING);
1017 os_memcpy(wpa_s->sme.prev_bssid, bssid, ETH_ALEN);
1018 wpa_s->sme.prev_bssid_set = 1;
1019 #endif /* CONFIG_SME */
1021 wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
1022 if (wpa_s->current_ssid) {
1023 /* When using scanning (ap_scan=1), SIM PC/SC interface can be
1024 * initialized before association, but for other modes,
1025 * initialize PC/SC here, if the current configuration needs
1026 * smartcard or SIM/USIM. */
1027 wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
1029 wpa_sm_notify_assoc(wpa_s->wpa, bssid);
1030 l2_packet_notify_auth_start(wpa_s->l2);
1033 * Set portEnabled first to FALSE in order to get EAP state machine out
1034 * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
1035 * state machine may transit to AUTHENTICATING state based on obsolete
1036 * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
1037 * AUTHENTICATED without ever giving chance to EAP state machine to
1040 if (!ft_completed) {
1041 eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
1042 eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
1044 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
1045 eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
1046 /* 802.1X::portControl = Auto */
1047 eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
1048 wpa_s->eapol_received = 0;
1049 if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1050 wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE ||
1051 (wpa_s->current_ssid &&
1052 wpa_s->current_ssid->mode == IEEE80211_MODE_IBSS)) {
1053 wpa_supplicant_cancel_auth_timeout(wpa_s);
1054 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1055 } else if (!ft_completed) {
1056 /* Timeout for receiving the first EAPOL packet */
1057 wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
1059 wpa_supplicant_cancel_scan(wpa_s);
1061 if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE) &&
1062 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1064 * We are done; the driver will take care of RSN 4-way
1067 wpa_supplicant_cancel_auth_timeout(wpa_s);
1068 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
1069 eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
1070 eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
1073 if (wpa_s->pending_eapol_rx) {
1074 struct os_time now, age;
1076 os_time_sub(&now, &wpa_s->pending_eapol_rx_time, &age);
1077 if (age.sec == 0 && age.usec < 100000 &&
1078 os_memcmp(wpa_s->pending_eapol_rx_src, bssid, ETH_ALEN) ==
1080 wpa_printf(MSG_DEBUG, "Process pending EAPOL frame "
1081 "that was received just before association "
1083 wpa_supplicant_rx_eapol(
1084 wpa_s, wpa_s->pending_eapol_rx_src,
1085 wpabuf_head(wpa_s->pending_eapol_rx),
1086 wpabuf_len(wpa_s->pending_eapol_rx));
1088 wpabuf_free(wpa_s->pending_eapol_rx);
1089 wpa_s->pending_eapol_rx = NULL;
1092 #ifdef CONFIG_BGSCAN
1093 if (wpa_s->current_ssid != wpa_s->bgscan_ssid) {
1094 bgscan_deinit(wpa_s);
1095 if (wpa_s->current_ssid && wpa_s->current_ssid->bgscan) {
1096 if (bgscan_init(wpa_s, wpa_s->current_ssid)) {
1097 wpa_printf(MSG_DEBUG, "Failed to initialize "
1100 * Live without bgscan; it is only used as a
1101 * roaming optimization, so the initial
1102 * connection is not affected.
1105 wpa_s->bgscan_ssid = wpa_s->current_ssid;
1107 wpa_s->bgscan_ssid = NULL;
1109 #endif /* CONFIG_BGSCAN */
1111 if ((wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
1112 wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
1113 wpa_s->current_ssid && wpa_drv_get_capa(wpa_s, &capa) == 0 &&
1114 capa.flags & WPA_DRIVER_FLAGS_SET_KEYS_AFTER_ASSOC_DONE) {
1115 /* Set static WEP keys again */
1116 wpa_set_wep_keys(wpa_s, wpa_s->current_ssid);
1121 static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
1126 u8 prev_pending_bssid[ETH_ALEN];
1128 authenticating = wpa_s->wpa_state == WPA_AUTHENTICATING;
1129 os_memcpy(prev_pending_bssid, wpa_s->pending_bssid, ETH_ALEN);
1130 #endif /* CONFIG_SME */
1132 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
1134 * At least Host AP driver and a Prism3 card seemed to be
1135 * generating streams of disconnected events when configuring
1136 * IBSS for WPA-None. Ignore them for now.
1138 wpa_printf(MSG_DEBUG, "Disconnect event - ignore in "
1139 "IBSS/WPA-None mode");
1143 if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
1144 wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
1145 wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
1146 "pre-shared key may be incorrect");
1148 if (wpa_s->wpa_state >= WPA_ASSOCIATED)
1149 wpa_supplicant_req_scan(wpa_s, 0, 100000);
1150 bssid = wpa_s->bssid;
1151 if (is_zero_ether_addr(bssid))
1152 bssid = wpa_s->pending_bssid;
1153 wpa_blacklist_add(wpa_s, bssid);
1154 wpa_sm_notify_disassoc(wpa_s->wpa);
1155 wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "- Disconnect event - "
1157 if (wpa_supplicant_dynamic_keys(wpa_s)) {
1158 wpa_s->keys_cleared = 0;
1159 wpa_clear_keys(wpa_s, wpa_s->bssid);
1161 wpa_supplicant_mark_disassoc(wpa_s);
1162 bgscan_deinit(wpa_s);
1164 if (authenticating &&
1165 (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)) {
1167 * mac80211-workaround to force deauth on failed auth cmd,
1168 * requires us to remain in authenticating state to allow the
1169 * second authentication attempt to be continued properly.
1171 wpa_printf(MSG_DEBUG, "SME: Allow pending authentication to "
1172 "proceed after disconnection event");
1173 wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
1174 os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN);
1176 #endif /* CONFIG_SME */
1180 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1181 static void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx,
1184 struct wpa_supplicant *wpa_s = eloop_ctx;
1186 if (!wpa_s->pending_mic_error_report)
1189 wpa_printf(MSG_DEBUG, "WPA: Sending pending MIC error report");
1190 wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
1191 wpa_s->pending_mic_error_report = 0;
1193 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1197 wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
1198 union wpa_event_data *data)
1203 wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
1204 pairwise = (data && data->michael_mic_failure.unicast);
1206 if ((wpa_s->last_michael_mic_error &&
1207 t.sec - wpa_s->last_michael_mic_error <= 60) ||
1208 wpa_s->pending_mic_error_report) {
1209 if (wpa_s->pending_mic_error_report) {
1211 * Send the pending MIC error report immediately since
1212 * we are going to start countermeasures and AP better
1215 wpa_sm_key_request(wpa_s->wpa, 1,
1216 wpa_s->pending_mic_error_pairwise);
1219 /* Send the new MIC error report immediately since we are going
1220 * to start countermeasures and AP better do the same.
1222 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1224 /* initialize countermeasures */
1225 wpa_s->countermeasures = 1;
1226 wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
1229 * Need to wait for completion of request frame. We do not get
1230 * any callback for the message completion, so just wait a
1231 * short while and hope for the best. */
1234 wpa_drv_set_countermeasures(wpa_s, 1);
1235 wpa_supplicant_deauthenticate(wpa_s,
1236 WLAN_REASON_MICHAEL_MIC_FAILURE);
1237 eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
1239 eloop_register_timeout(60, 0,
1240 wpa_supplicant_stop_countermeasures,
1242 /* TODO: mark the AP rejected for 60 second. STA is
1243 * allowed to associate with another AP.. */
1245 #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
1246 if (wpa_s->mic_errors_seen) {
1248 * Reduce the effectiveness of Michael MIC error
1249 * reports as a means for attacking against TKIP if
1250 * more than one MIC failure is noticed with the same
1251 * PTK. We delay the transmission of the reports by a
1252 * random time between 0 and 60 seconds in order to
1253 * force the attacker wait 60 seconds before getting
1254 * the information on whether a frame resulted in a MIC
1260 if (os_get_random(rval, sizeof(rval)) < 0)
1261 sec = os_random() % 60;
1263 sec = WPA_GET_BE32(rval) % 60;
1264 wpa_printf(MSG_DEBUG, "WPA: Delay MIC error report %d "
1266 wpa_s->pending_mic_error_report = 1;
1267 wpa_s->pending_mic_error_pairwise = pairwise;
1268 eloop_cancel_timeout(
1269 wpa_supplicant_delayed_mic_error_report,
1271 eloop_register_timeout(
1272 sec, os_random() % 1000000,
1273 wpa_supplicant_delayed_mic_error_report,
1276 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1278 #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1279 wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
1280 #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
1282 wpa_s->last_michael_mic_error = t.sec;
1283 wpa_s->mic_errors_seen++;
1287 #ifdef CONFIG_TERMINATE_ONLASTIF
1288 static int any_interfaces(struct wpa_supplicant *head)
1290 struct wpa_supplicant *wpa_s;
1292 for (wpa_s = head; wpa_s != NULL; wpa_s = wpa_s->next)
1293 if (!wpa_s->interface_removed)
1297 #endif /* CONFIG_TERMINATE_ONLASTIF */
1301 wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
1302 union wpa_event_data *data)
1304 if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
1307 switch (data->interface_status.ievent) {
1308 case EVENT_INTERFACE_ADDED:
1309 if (!wpa_s->interface_removed)
1311 wpa_s->interface_removed = 0;
1312 wpa_printf(MSG_DEBUG, "Configured interface was added.");
1313 if (wpa_supplicant_driver_init(wpa_s) < 0) {
1314 wpa_printf(MSG_INFO, "Failed to initialize the driver "
1315 "after interface was added.");
1318 case EVENT_INTERFACE_REMOVED:
1319 wpa_printf(MSG_DEBUG, "Configured interface was removed.");
1320 wpa_s->interface_removed = 1;
1321 wpa_supplicant_mark_disassoc(wpa_s);
1322 l2_packet_deinit(wpa_s->l2);
1324 #ifdef CONFIG_TERMINATE_ONLASTIF
1325 /* check if last interface */
1326 if (!any_interfaces(wpa_s->global->ifaces))
1328 #endif /* CONFIG_TERMINATE_ONLASTIF */
1334 #ifdef CONFIG_PEERKEY
1336 wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
1337 union wpa_event_data *data)
1341 wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
1343 #endif /* CONFIG_PEERKEY */
1346 #ifdef CONFIG_IEEE80211R
1348 wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
1349 union wpa_event_data *data)
1354 if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
1355 data->ft_ies.ies_len,
1356 data->ft_ies.ft_action,
1357 data->ft_ies.target_ap,
1358 data->ft_ies.ric_ies,
1359 data->ft_ies.ric_ies_len) < 0) {
1360 /* TODO: prevent MLME/driver from trying to associate? */
1363 #endif /* CONFIG_IEEE80211R */
1366 #ifdef CONFIG_IBSS_RSN
1367 static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
1368 union wpa_event_data *data)
1372 ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
1374 #endif /* CONFIG_IBSS_RSN */
1377 void wpa_supplicant_event(void *ctx, wpa_event_type event,
1378 union wpa_event_data *data)
1380 struct wpa_supplicant *wpa_s = ctx;
1384 sme_event_auth(wpa_s, data);
1387 wpa_supplicant_event_assoc(wpa_s, data);
1389 case EVENT_DISASSOC:
1390 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
1391 sme_event_disassoc(wpa_s, data);
1394 wpa_supplicant_event_disassoc(wpa_s);
1396 case EVENT_MICHAEL_MIC_FAILURE:
1397 wpa_supplicant_event_michael_mic_failure(wpa_s, data);
1399 #ifndef CONFIG_NO_SCAN_PROCESSING
1400 case EVENT_SCAN_RESULTS:
1401 wpa_supplicant_event_scan_results(wpa_s);
1403 #endif /* CONFIG_NO_SCAN_PROCESSING */
1404 case EVENT_ASSOCINFO:
1405 wpa_supplicant_event_associnfo(wpa_s, data);
1407 case EVENT_INTERFACE_STATUS:
1408 wpa_supplicant_event_interface_status(wpa_s, data);
1410 case EVENT_PMKID_CANDIDATE:
1411 wpa_supplicant_event_pmkid_candidate(wpa_s, data);
1413 #ifdef CONFIG_PEERKEY
1414 case EVENT_STKSTART:
1415 wpa_supplicant_event_stkstart(wpa_s, data);
1417 #endif /* CONFIG_PEERKEY */
1418 #ifdef CONFIG_IEEE80211R
1419 case EVENT_FT_RESPONSE:
1420 wpa_supplicant_event_ft_response(wpa_s, data);
1422 #endif /* CONFIG_IEEE80211R */
1423 #ifdef CONFIG_IBSS_RSN
1424 case EVENT_IBSS_RSN_START:
1425 wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
1427 #endif /* CONFIG_IBSS_RSN */
1428 case EVENT_ASSOC_REJECT:
1429 sme_event_assoc_reject(wpa_s, data);
1431 case EVENT_AUTH_TIMED_OUT:
1432 sme_event_auth_timed_out(wpa_s, data);
1434 case EVENT_ASSOC_TIMED_OUT:
1435 sme_event_assoc_timed_out(wpa_s, data);
1438 case EVENT_TX_STATUS:
1439 if (wpa_s->ap_iface == NULL)
1441 switch (data->tx_status.type) {
1442 case WLAN_FC_TYPE_MGMT:
1443 ap_mgmt_tx_cb(wpa_s, data->tx_status.data,
1444 data->tx_status.data_len,
1445 data->tx_status.stype,
1446 data->tx_status.ack);
1448 case WLAN_FC_TYPE_DATA:
1449 ap_tx_status(wpa_s, data->tx_status.dst,
1450 data->tx_status.data,
1451 data->tx_status.data_len,
1452 data->tx_status.ack);
1456 case EVENT_RX_FROM_UNKNOWN:
1457 if (wpa_s->ap_iface == NULL)
1459 ap_rx_from_unknown_sta(wpa_s, data->rx_from_unknown.hdr,
1460 data->rx_from_unknown.len);
1463 if (wpa_s->ap_iface == NULL)
1465 ap_mgmt_rx(wpa_s, data->rx_mgmt.frame,
1466 data->rx_mgmt.frame_len, data->rx_mgmt.fi);
1468 #endif /* CONFIG_AP */
1470 wpa_printf(MSG_INFO, "Unknown event %d", event);