events.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  1. /*
  2. * WPA Supplicant - Driver event processing
  3. * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
  4. *
  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.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include "includes.h"
  15. #include "common.h"
  16. #include "eapol_supp/eapol_supp_sm.h"
  17. #include "wpa.h"
  18. #include "eloop.h"
  19. #include "drivers/driver.h"
  20. #include "config.h"
  21. #include "l2_packet/l2_packet.h"
  22. #include "wpa_supplicant_i.h"
  23. #include "pcsc_funcs.h"
  24. #include "preauth.h"
  25. #include "pmksa_cache.h"
  26. #include "wpa_ctrl.h"
  27. #include "eap_peer/eap.h"
  28. #include "ctrl_iface_dbus.h"
  29. #include "ieee802_11_defs.h"
  30. #include "blacklist.h"
  31. #include "wpas_glue.h"
  32. #include "wps_supplicant.h"
  33. #include "ibss_rsn.h"
  34. static int wpa_supplicant_select_config(struct wpa_supplicant *wpa_s)
  35. {
  36. struct wpa_ssid *ssid;
  37. if (wpa_s->conf->ap_scan == 1 && wpa_s->current_ssid)
  38. return 0;
  39. wpa_printf(MSG_DEBUG, "Select network based on association "
  40. "information");
  41. ssid = wpa_supplicant_get_ssid(wpa_s);
  42. if (ssid == NULL) {
  43. wpa_printf(MSG_INFO, "No network configuration found for the "
  44. "current AP");
  45. return -1;
  46. }
  47. if (ssid->disabled) {
  48. wpa_printf(MSG_DEBUG, "Selected network is disabled");
  49. return -1;
  50. }
  51. wpa_printf(MSG_DEBUG, "Network configuration found for the current "
  52. "AP");
  53. if (ssid->key_mgmt & (WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_IEEE8021X |
  54. WPA_KEY_MGMT_WPA_NONE |
  55. WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X |
  56. WPA_KEY_MGMT_PSK_SHA256 |
  57. WPA_KEY_MGMT_IEEE8021X_SHA256)) {
  58. u8 wpa_ie[80];
  59. size_t wpa_ie_len = sizeof(wpa_ie);
  60. wpa_supplicant_set_suites(wpa_s, NULL, ssid,
  61. wpa_ie, &wpa_ie_len);
  62. } else {
  63. wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
  64. }
  65. if (wpa_s->current_ssid && wpa_s->current_ssid != ssid)
  66. eapol_sm_invalidate_cached_session(wpa_s->eapol);
  67. wpa_s->current_ssid = ssid;
  68. wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
  69. wpa_supplicant_initiate_eapol(wpa_s);
  70. return 0;
  71. }
  72. static void wpa_supplicant_stop_countermeasures(void *eloop_ctx,
  73. void *sock_ctx)
  74. {
  75. struct wpa_supplicant *wpa_s = eloop_ctx;
  76. if (wpa_s->countermeasures) {
  77. wpa_s->countermeasures = 0;
  78. wpa_drv_set_countermeasures(wpa_s, 0);
  79. wpa_msg(wpa_s, MSG_INFO, "WPA: TKIP countermeasures stopped");
  80. wpa_supplicant_req_scan(wpa_s, 0, 0);
  81. }
  82. }
  83. void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
  84. {
  85. wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
  86. os_memset(wpa_s->bssid, 0, ETH_ALEN);
  87. os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
  88. eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
  89. eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
  90. if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt))
  91. eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
  92. wpa_s->ap_ies_from_associnfo = 0;
  93. }
  94. static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
  95. {
  96. struct wpa_ie_data ie;
  97. int pmksa_set = -1;
  98. size_t i;
  99. if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
  100. ie.pmkid == NULL)
  101. return;
  102. for (i = 0; i < ie.num_pmkid; i++) {
  103. pmksa_set = pmksa_cache_set_current(wpa_s->wpa,
  104. ie.pmkid + i * PMKID_LEN,
  105. NULL, NULL, 0);
  106. if (pmksa_set == 0) {
  107. eapol_sm_notify_pmkid_attempt(wpa_s->eapol, 1);
  108. break;
  109. }
  110. }
  111. wpa_printf(MSG_DEBUG, "RSN: PMKID from assoc IE %sfound from PMKSA "
  112. "cache", pmksa_set == 0 ? "" : "not ");
  113. }
  114. static void wpa_supplicant_event_pmkid_candidate(struct wpa_supplicant *wpa_s,
  115. union wpa_event_data *data)
  116. {
  117. if (data == NULL) {
  118. wpa_printf(MSG_DEBUG, "RSN: No data in PMKID candidate event");
  119. return;
  120. }
  121. wpa_printf(MSG_DEBUG, "RSN: PMKID candidate event - bssid=" MACSTR
  122. " index=%d preauth=%d",
  123. MAC2STR(data->pmkid_candidate.bssid),
  124. data->pmkid_candidate.index,
  125. data->pmkid_candidate.preauth);
  126. pmksa_candidate_add(wpa_s->wpa, data->pmkid_candidate.bssid,
  127. data->pmkid_candidate.index,
  128. data->pmkid_candidate.preauth);
  129. }
  130. static int wpa_supplicant_dynamic_keys(struct wpa_supplicant *wpa_s)
  131. {
  132. if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
  133. wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE)
  134. return 0;
  135. #ifdef IEEE8021X_EAPOL
  136. if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA &&
  137. wpa_s->current_ssid &&
  138. !(wpa_s->current_ssid->eapol_flags &
  139. (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
  140. EAPOL_FLAG_REQUIRE_KEY_BROADCAST))) {
  141. /* IEEE 802.1X, but not using dynamic WEP keys (i.e., either
  142. * plaintext or static WEP keys). */
  143. return 0;
  144. }
  145. #endif /* IEEE8021X_EAPOL */
  146. return 1;
  147. }
  148. /**
  149. * wpa_supplicant_scard_init - Initialize SIM/USIM access with PC/SC
  150. * @wpa_s: pointer to wpa_supplicant data
  151. * @ssid: Configuration data for the network
  152. * Returns: 0 on success, -1 on failure
  153. *
  154. * This function is called when starting authentication with a network that is
  155. * configured to use PC/SC for SIM/USIM access (EAP-SIM or EAP-AKA).
  156. */
  157. int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s,
  158. struct wpa_ssid *ssid)
  159. {
  160. #ifdef IEEE8021X_EAPOL
  161. int aka = 0, sim = 0, type;
  162. if (ssid->eap.pcsc == NULL || wpa_s->scard != NULL)
  163. return 0;
  164. if (ssid->eap.eap_methods == NULL) {
  165. sim = 1;
  166. aka = 1;
  167. } else {
  168. struct eap_method_type *eap = ssid->eap.eap_methods;
  169. while (eap->vendor != EAP_VENDOR_IETF ||
  170. eap->method != EAP_TYPE_NONE) {
  171. if (eap->vendor == EAP_VENDOR_IETF) {
  172. if (eap->method == EAP_TYPE_SIM)
  173. sim = 1;
  174. else if (eap->method == EAP_TYPE_AKA)
  175. aka = 1;
  176. }
  177. eap++;
  178. }
  179. }
  180. if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_SIM) == NULL)
  181. sim = 0;
  182. if (eap_peer_get_eap_method(EAP_VENDOR_IETF, EAP_TYPE_AKA) == NULL)
  183. aka = 0;
  184. if (!sim && !aka) {
  185. wpa_printf(MSG_DEBUG, "Selected network is configured to use "
  186. "SIM, but neither EAP-SIM nor EAP-AKA are enabled");
  187. return 0;
  188. }
  189. wpa_printf(MSG_DEBUG, "Selected network is configured to use SIM "
  190. "(sim=%d aka=%d) - initialize PCSC", sim, aka);
  191. if (sim && aka)
  192. type = SCARD_TRY_BOTH;
  193. else if (aka)
  194. type = SCARD_USIM_ONLY;
  195. else
  196. type = SCARD_GSM_SIM_ONLY;
  197. wpa_s->scard = scard_init(type);
  198. if (wpa_s->scard == NULL) {
  199. wpa_printf(MSG_WARNING, "Failed to initialize SIM "
  200. "(pcsc-lite)");
  201. return -1;
  202. }
  203. wpa_sm_set_scard_ctx(wpa_s->wpa, wpa_s->scard);
  204. eapol_sm_register_scard_ctx(wpa_s->eapol, wpa_s->scard);
  205. #endif /* IEEE8021X_EAPOL */
  206. return 0;
  207. }
  208. #ifndef CONFIG_NO_SCAN_PROCESSING
  209. static int wpa_supplicant_match_privacy(struct wpa_scan_res *bss,
  210. struct wpa_ssid *ssid)
  211. {
  212. int i, privacy = 0;
  213. if (ssid->mixed_cell)
  214. return 1;
  215. #ifdef CONFIG_WPS
  216. if (ssid->key_mgmt & WPA_KEY_MGMT_WPS)
  217. return 1;
  218. #endif /* CONFIG_WPS */
  219. for (i = 0; i < NUM_WEP_KEYS; i++) {
  220. if (ssid->wep_key_len[i]) {
  221. privacy = 1;
  222. break;
  223. }
  224. }
  225. #ifdef IEEE8021X_EAPOL
  226. if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
  227. ssid->eapol_flags & (EAPOL_FLAG_REQUIRE_KEY_UNICAST |
  228. EAPOL_FLAG_REQUIRE_KEY_BROADCAST))
  229. privacy = 1;
  230. #endif /* IEEE8021X_EAPOL */
  231. if (bss->caps & IEEE80211_CAP_PRIVACY)
  232. return privacy;
  233. return !privacy;
  234. }
  235. static int wpa_supplicant_ssid_bss_match(struct wpa_supplicant *wpa_s,
  236. struct wpa_ssid *ssid,
  237. struct wpa_scan_res *bss)
  238. {
  239. struct wpa_ie_data ie;
  240. int proto_match = 0;
  241. const u8 *rsn_ie, *wpa_ie;
  242. int ret;
  243. ret = wpas_wps_ssid_bss_match(wpa_s, ssid, bss);
  244. if (ret >= 0)
  245. return ret;
  246. rsn_ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
  247. while ((ssid->proto & WPA_PROTO_RSN) && rsn_ie) {
  248. proto_match++;
  249. if (wpa_parse_wpa_ie(rsn_ie, 2 + rsn_ie[1], &ie)) {
  250. wpa_printf(MSG_DEBUG, " skip RSN IE - parse failed");
  251. break;
  252. }
  253. if (!(ie.proto & ssid->proto)) {
  254. wpa_printf(MSG_DEBUG, " skip RSN IE - proto "
  255. "mismatch");
  256. break;
  257. }
  258. if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
  259. wpa_printf(MSG_DEBUG, " skip RSN IE - PTK cipher "
  260. "mismatch");
  261. break;
  262. }
  263. if (!(ie.group_cipher & ssid->group_cipher)) {
  264. wpa_printf(MSG_DEBUG, " skip RSN IE - GTK cipher "
  265. "mismatch");
  266. break;
  267. }
  268. if (!(ie.key_mgmt & ssid->key_mgmt)) {
  269. wpa_printf(MSG_DEBUG, " skip RSN IE - key mgmt "
  270. "mismatch");
  271. break;
  272. }
  273. #ifdef CONFIG_IEEE80211W
  274. if (!(ie.capabilities & WPA_CAPABILITY_MFPC) &&
  275. ssid->ieee80211w == IEEE80211W_REQUIRED) {
  276. wpa_printf(MSG_DEBUG, " skip RSN IE - no mgmt frame "
  277. "protection");
  278. break;
  279. }
  280. #endif /* CONFIG_IEEE80211W */
  281. wpa_printf(MSG_DEBUG, " selected based on RSN IE");
  282. return 1;
  283. }
  284. wpa_ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
  285. while ((ssid->proto & WPA_PROTO_WPA) && wpa_ie) {
  286. proto_match++;
  287. if (wpa_parse_wpa_ie(wpa_ie, 2 + wpa_ie[1], &ie)) {
  288. wpa_printf(MSG_DEBUG, " skip WPA IE - parse failed");
  289. break;
  290. }
  291. if (!(ie.proto & ssid->proto)) {
  292. wpa_printf(MSG_DEBUG, " skip WPA IE - proto "
  293. "mismatch");
  294. break;
  295. }
  296. if (!(ie.pairwise_cipher & ssid->pairwise_cipher)) {
  297. wpa_printf(MSG_DEBUG, " skip WPA IE - PTK cipher "
  298. "mismatch");
  299. break;
  300. }
  301. if (!(ie.group_cipher & ssid->group_cipher)) {
  302. wpa_printf(MSG_DEBUG, " skip WPA IE - GTK cipher "
  303. "mismatch");
  304. break;
  305. }
  306. if (!(ie.key_mgmt & ssid->key_mgmt)) {
  307. wpa_printf(MSG_DEBUG, " skip WPA IE - key mgmt "
  308. "mismatch");
  309. break;
  310. }
  311. wpa_printf(MSG_DEBUG, " selected based on WPA IE");
  312. return 1;
  313. }
  314. if (proto_match == 0)
  315. wpa_printf(MSG_DEBUG, " skip - no WPA/RSN proto match");
  316. return 0;
  317. }
  318. static struct wpa_scan_res *
  319. wpa_supplicant_select_bss_wpa(struct wpa_supplicant *wpa_s,
  320. struct wpa_ssid *group,
  321. struct wpa_ssid **selected_ssid)
  322. {
  323. struct wpa_ssid *ssid;
  324. struct wpa_scan_res *bss;
  325. size_t i;
  326. struct wpa_blacklist *e;
  327. const u8 *ie;
  328. wpa_printf(MSG_DEBUG, "Try to find WPA-enabled AP");
  329. for (i = 0; i < wpa_s->scan_res->num; i++) {
  330. const u8 *ssid_;
  331. u8 wpa_ie_len, rsn_ie_len, ssid_len;
  332. bss = wpa_s->scan_res->res[i];
  333. ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
  334. ssid_ = ie ? ie + 2 : (u8 *) "";
  335. ssid_len = ie ? ie[1] : 0;
  336. ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
  337. wpa_ie_len = ie ? ie[1] : 0;
  338. ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
  339. rsn_ie_len = ie ? ie[1] : 0;
  340. wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
  341. "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
  342. (int) i, MAC2STR(bss->bssid),
  343. wpa_ssid_txt(ssid_, ssid_len),
  344. wpa_ie_len, rsn_ie_len, bss->caps);
  345. e = wpa_blacklist_get(wpa_s, bss->bssid);
  346. if (e && e->count > 1) {
  347. wpa_printf(MSG_DEBUG, " skip - blacklisted");
  348. continue;
  349. }
  350. if (wpa_ie_len == 0 && rsn_ie_len == 0) {
  351. wpa_printf(MSG_DEBUG, " skip - no WPA/RSN IE");
  352. continue;
  353. }
  354. for (ssid = group; ssid; ssid = ssid->pnext) {
  355. int check_ssid = 1;
  356. if (ssid->disabled) {
  357. wpa_printf(MSG_DEBUG, " skip - disabled");
  358. continue;
  359. }
  360. #ifdef CONFIG_WPS
  361. if (ssid->ssid_len == 0 &&
  362. wpas_wps_ssid_wildcard_ok(wpa_s, ssid, bss))
  363. check_ssid = 0;
  364. #endif /* CONFIG_WPS */
  365. if (check_ssid &&
  366. (ssid_len != ssid->ssid_len ||
  367. os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
  368. wpa_printf(MSG_DEBUG, " skip - "
  369. "SSID mismatch");
  370. continue;
  371. }
  372. if (ssid->bssid_set &&
  373. os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
  374. {
  375. wpa_printf(MSG_DEBUG, " skip - "
  376. "BSSID mismatch");
  377. continue;
  378. }
  379. if (!wpa_supplicant_ssid_bss_match(wpa_s, ssid, bss))
  380. continue;
  381. wpa_printf(MSG_DEBUG, " selected WPA AP "
  382. MACSTR " ssid='%s'",
  383. MAC2STR(bss->bssid),
  384. wpa_ssid_txt(ssid_, ssid_len));
  385. *selected_ssid = ssid;
  386. return bss;
  387. }
  388. }
  389. return NULL;
  390. }
  391. static struct wpa_scan_res *
  392. wpa_supplicant_select_bss_non_wpa(struct wpa_supplicant *wpa_s,
  393. struct wpa_ssid *group,
  394. struct wpa_ssid **selected_ssid)
  395. {
  396. struct wpa_ssid *ssid;
  397. struct wpa_scan_res *bss;
  398. size_t i;
  399. struct wpa_blacklist *e;
  400. const u8 *ie;
  401. wpa_printf(MSG_DEBUG, "Try to find non-WPA AP");
  402. for (i = 0; i < wpa_s->scan_res->num; i++) {
  403. const u8 *ssid_;
  404. u8 wpa_ie_len, rsn_ie_len, ssid_len;
  405. bss = wpa_s->scan_res->res[i];
  406. ie = wpa_scan_get_ie(bss, WLAN_EID_SSID);
  407. ssid_ = ie ? ie + 2 : (u8 *) "";
  408. ssid_len = ie ? ie[1] : 0;
  409. ie = wpa_scan_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
  410. wpa_ie_len = ie ? ie[1] : 0;
  411. ie = wpa_scan_get_ie(bss, WLAN_EID_RSN);
  412. rsn_ie_len = ie ? ie[1] : 0;
  413. wpa_printf(MSG_DEBUG, "%d: " MACSTR " ssid='%s' "
  414. "wpa_ie_len=%u rsn_ie_len=%u caps=0x%x",
  415. (int) i, MAC2STR(bss->bssid),
  416. wpa_ssid_txt(ssid_, ssid_len),
  417. wpa_ie_len, rsn_ie_len, bss->caps);
  418. e = wpa_blacklist_get(wpa_s, bss->bssid);
  419. if (e && e->count > 1) {
  420. wpa_printf(MSG_DEBUG, " skip - blacklisted");
  421. continue;
  422. }
  423. for (ssid = group; ssid; ssid = ssid->pnext) {
  424. int check_ssid = ssid->ssid_len != 0;
  425. if (ssid->disabled) {
  426. wpa_printf(MSG_DEBUG, " skip - disabled");
  427. continue;
  428. }
  429. #ifdef CONFIG_WPS
  430. if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
  431. /* Only allow wildcard SSID match if an AP
  432. * advertises active WPS operation that matches
  433. * with our mode. */
  434. check_ssid = 1;
  435. if (ssid->ssid_len == 0 &&
  436. wpas_wps_ssid_wildcard_ok(wpa_s, ssid,
  437. bss))
  438. check_ssid = 0;
  439. }
  440. #endif /* CONFIG_WPS */
  441. if (check_ssid &&
  442. (ssid_len != ssid->ssid_len ||
  443. os_memcmp(ssid_, ssid->ssid, ssid_len) != 0)) {
  444. wpa_printf(MSG_DEBUG, " skip - "
  445. "SSID mismatch");
  446. continue;
  447. }
  448. if (ssid->bssid_set &&
  449. os_memcmp(bss->bssid, ssid->bssid, ETH_ALEN) != 0)
  450. {
  451. wpa_printf(MSG_DEBUG, " skip - "
  452. "BSSID mismatch");
  453. continue;
  454. }
  455. if (!(ssid->key_mgmt & WPA_KEY_MGMT_NONE) &&
  456. !(ssid->key_mgmt & WPA_KEY_MGMT_WPS) &&
  457. !(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA))
  458. {
  459. wpa_printf(MSG_DEBUG, " skip - "
  460. "non-WPA network not allowed");
  461. continue;
  462. }
  463. if ((ssid->key_mgmt &
  464. (WPA_KEY_MGMT_IEEE8021X | WPA_KEY_MGMT_PSK |
  465. WPA_KEY_MGMT_FT_IEEE8021X | WPA_KEY_MGMT_FT_PSK |
  466. WPA_KEY_MGMT_IEEE8021X_SHA256 |
  467. WPA_KEY_MGMT_PSK_SHA256)) &&
  468. (wpa_ie_len != 0 || rsn_ie_len != 0)) {
  469. wpa_printf(MSG_DEBUG, " skip - "
  470. "WPA network");
  471. continue;
  472. }
  473. if (!wpa_supplicant_match_privacy(bss, ssid)) {
  474. wpa_printf(MSG_DEBUG, " skip - "
  475. "privacy mismatch");
  476. continue;
  477. }
  478. if (bss->caps & IEEE80211_CAP_IBSS) {
  479. wpa_printf(MSG_DEBUG, " skip - "
  480. "IBSS (adhoc) network");
  481. continue;
  482. }
  483. wpa_printf(MSG_DEBUG, " selected non-WPA AP "
  484. MACSTR " ssid='%s'",
  485. MAC2STR(bss->bssid),
  486. wpa_ssid_txt(ssid_, ssid_len));
  487. *selected_ssid = ssid;
  488. return bss;
  489. }
  490. }
  491. return NULL;
  492. }
  493. static struct wpa_scan_res *
  494. wpa_supplicant_select_bss(struct wpa_supplicant *wpa_s, struct wpa_ssid *group,
  495. struct wpa_ssid **selected_ssid)
  496. {
  497. struct wpa_scan_res *selected;
  498. wpa_printf(MSG_DEBUG, "Selecting BSS from priority group %d",
  499. group->priority);
  500. /* First, try to find WPA-enabled AP */
  501. selected = wpa_supplicant_select_bss_wpa(wpa_s, group, selected_ssid);
  502. if (selected)
  503. return selected;
  504. /* If no WPA-enabled AP found, try to find non-WPA AP, if configuration
  505. * allows this. */
  506. return wpa_supplicant_select_bss_non_wpa(wpa_s, group, selected_ssid);
  507. }
  508. static void wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s)
  509. {
  510. int prio, timeout;
  511. struct wpa_scan_res *selected = NULL;
  512. struct wpa_ssid *ssid = NULL;
  513. if (wpa_supplicant_get_scan_results(wpa_s) < 0) {
  514. if (wpa_s->conf->ap_scan == 2)
  515. return;
  516. wpa_printf(MSG_DEBUG, "Failed to get scan results - try "
  517. "scanning again");
  518. timeout = 1;
  519. goto req_scan;
  520. }
  521. /*
  522. * Don't post the results if this was the initial cached
  523. * and there were no results.
  524. */
  525. if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1 &&
  526. wpa_s->scan_res->num == 0) {
  527. wpa_msg(wpa_s, MSG_DEBUG, "Cached scan results are "
  528. "empty - not posting");
  529. } else {
  530. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SCAN_RESULTS);
  531. wpa_supplicant_dbus_notify_scan_results(wpa_s);
  532. wpas_wps_notify_scan_results(wpa_s);
  533. }
  534. if ((wpa_s->conf->ap_scan == 2 && !wpas_wps_searching(wpa_s)) ||
  535. wpa_s->disconnected)
  536. return;
  537. while (selected == NULL) {
  538. for (prio = 0; prio < wpa_s->conf->num_prio; prio++) {
  539. selected = wpa_supplicant_select_bss(
  540. wpa_s, wpa_s->conf->pssid[prio], &ssid);
  541. if (selected)
  542. break;
  543. }
  544. if (selected == NULL && wpa_s->blacklist) {
  545. wpa_printf(MSG_DEBUG, "No APs found - clear blacklist "
  546. "and try again");
  547. wpa_blacklist_clear(wpa_s);
  548. wpa_s->blacklist_cleared++;
  549. } else if (selected == NULL) {
  550. break;
  551. }
  552. }
  553. if (selected) {
  554. if (wpas_wps_scan_pbc_overlap(wpa_s, selected, ssid)) {
  555. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OVERLAP
  556. "PBC session overlap");
  557. timeout = 10;
  558. goto req_scan;
  559. }
  560. /* Do not trigger new association unless the BSSID has changed
  561. * or if reassociation is requested. If we are in process of
  562. * associating with the selected BSSID, do not trigger new
  563. * attempt. */
  564. if (wpa_s->reassociate ||
  565. (os_memcmp(selected->bssid, wpa_s->bssid, ETH_ALEN) != 0 &&
  566. (wpa_s->wpa_state != WPA_ASSOCIATING ||
  567. os_memcmp(selected->bssid, wpa_s->pending_bssid,
  568. ETH_ALEN) != 0))) {
  569. if (wpa_supplicant_scard_init(wpa_s, ssid)) {
  570. wpa_supplicant_req_scan(wpa_s, 10, 0);
  571. return;
  572. }
  573. wpa_supplicant_associate(wpa_s, selected, ssid);
  574. } else {
  575. wpa_printf(MSG_DEBUG, "Already associated with the "
  576. "selected AP.");
  577. }
  578. rsn_preauth_scan_results(wpa_s->wpa, wpa_s->scan_res);
  579. } else {
  580. wpa_printf(MSG_DEBUG, "No suitable AP found.");
  581. timeout = 5;
  582. goto req_scan;
  583. }
  584. return;
  585. req_scan:
  586. if (wpa_s->scan_res_tried == 1 && wpa_s->conf->ap_scan == 1) {
  587. /*
  588. * Quick recovery if the initial scan results were not
  589. * complete when fetched before the first scan request.
  590. */
  591. wpa_s->scan_res_tried++;
  592. timeout = 0;
  593. }
  594. wpa_supplicant_req_scan(wpa_s, timeout, 0);
  595. }
  596. #endif /* CONFIG_NO_SCAN_PROCESSING */
  597. static void wpa_supplicant_event_associnfo(struct wpa_supplicant *wpa_s,
  598. union wpa_event_data *data)
  599. {
  600. int l, len, found = 0, wpa_found, rsn_found;
  601. u8 *p;
  602. wpa_printf(MSG_DEBUG, "Association info event");
  603. if (data->assoc_info.req_ies)
  604. wpa_hexdump(MSG_DEBUG, "req_ies", data->assoc_info.req_ies,
  605. data->assoc_info.req_ies_len);
  606. if (data->assoc_info.resp_ies)
  607. wpa_hexdump(MSG_DEBUG, "resp_ies", data->assoc_info.resp_ies,
  608. data->assoc_info.resp_ies_len);
  609. if (data->assoc_info.beacon_ies)
  610. wpa_hexdump(MSG_DEBUG, "beacon_ies",
  611. data->assoc_info.beacon_ies,
  612. data->assoc_info.beacon_ies_len);
  613. p = data->assoc_info.req_ies;
  614. l = data->assoc_info.req_ies_len;
  615. /* Go through the IEs and make a copy of the WPA/RSN IE, if present. */
  616. while (p && l >= 2) {
  617. len = p[1] + 2;
  618. if (len > l) {
  619. wpa_hexdump(MSG_DEBUG, "Truncated IE in assoc_info",
  620. p, l);
  621. break;
  622. }
  623. if ((p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
  624. (os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0)) ||
  625. (p[0] == WLAN_EID_RSN && p[1] >= 2)) {
  626. if (wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, p, len))
  627. break;
  628. found = 1;
  629. wpa_find_assoc_pmkid(wpa_s);
  630. break;
  631. }
  632. l -= len;
  633. p += len;
  634. }
  635. if (!found && data->assoc_info.req_ies)
  636. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
  637. /* WPA/RSN IE from Beacon/ProbeResp */
  638. p = data->assoc_info.beacon_ies;
  639. l = data->assoc_info.beacon_ies_len;
  640. /* Go through the IEs and make a copy of the WPA/RSN IEs, if present.
  641. */
  642. wpa_found = rsn_found = 0;
  643. while (p && l >= 2) {
  644. len = p[1] + 2;
  645. if (len > l) {
  646. wpa_hexdump(MSG_DEBUG, "Truncated IE in beacon_ies",
  647. p, l);
  648. break;
  649. }
  650. if (!wpa_found &&
  651. p[0] == WLAN_EID_VENDOR_SPECIFIC && p[1] >= 6 &&
  652. os_memcmp(&p[2], "\x00\x50\xF2\x01\x01\x00", 6) == 0) {
  653. wpa_found = 1;
  654. wpa_sm_set_ap_wpa_ie(wpa_s->wpa, p, len);
  655. }
  656. if (!rsn_found &&
  657. p[0] == WLAN_EID_RSN && p[1] >= 2) {
  658. rsn_found = 1;
  659. wpa_sm_set_ap_rsn_ie(wpa_s->wpa, p, len);
  660. }
  661. l -= len;
  662. p += len;
  663. }
  664. if (!wpa_found && data->assoc_info.beacon_ies)
  665. wpa_sm_set_ap_wpa_ie(wpa_s->wpa, NULL, 0);
  666. if (!rsn_found && data->assoc_info.beacon_ies)
  667. wpa_sm_set_ap_rsn_ie(wpa_s->wpa, NULL, 0);
  668. if (wpa_found || rsn_found)
  669. wpa_s->ap_ies_from_associnfo = 1;
  670. }
  671. static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s,
  672. union wpa_event_data *data)
  673. {
  674. u8 bssid[ETH_ALEN];
  675. int ft_completed = wpa_ft_is_completed(wpa_s->wpa);
  676. if (data)
  677. wpa_supplicant_event_associnfo(wpa_s, data);
  678. wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATED);
  679. if (wpa_s->use_client_mlme)
  680. os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
  681. if (wpa_s->use_client_mlme ||
  682. (wpa_drv_get_bssid(wpa_s, bssid) >= 0 &&
  683. os_memcmp(bssid, wpa_s->bssid, ETH_ALEN) != 0)) {
  684. wpa_msg(wpa_s, MSG_DEBUG, "Associated to a new BSS: BSSID="
  685. MACSTR, MAC2STR(bssid));
  686. os_memcpy(wpa_s->bssid, bssid, ETH_ALEN);
  687. os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
  688. if (wpa_supplicant_dynamic_keys(wpa_s) && !ft_completed) {
  689. wpa_clear_keys(wpa_s, bssid);
  690. }
  691. if (wpa_supplicant_select_config(wpa_s) < 0) {
  692. wpa_supplicant_disassociate(
  693. wpa_s, WLAN_REASON_DEAUTH_LEAVING);
  694. return;
  695. }
  696. }
  697. wpa_msg(wpa_s, MSG_INFO, "Associated with " MACSTR, MAC2STR(bssid));
  698. if (wpa_s->current_ssid) {
  699. /* When using scanning (ap_scan=1), SIM PC/SC interface can be
  700. * initialized before association, but for other modes,
  701. * initialize PC/SC here, if the current configuration needs
  702. * smartcard or SIM/USIM. */
  703. wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid);
  704. }
  705. wpa_sm_notify_assoc(wpa_s->wpa, bssid);
  706. l2_packet_notify_auth_start(wpa_s->l2);
  707. /*
  708. * Set portEnabled first to FALSE in order to get EAP state machine out
  709. * of the SUCCESS state and eapSuccess cleared. Without this, EAPOL PAE
  710. * state machine may transit to AUTHENTICATING state based on obsolete
  711. * eapSuccess and then trigger BE_AUTH to SUCCESS and PAE to
  712. * AUTHENTICATED without ever giving chance to EAP state machine to
  713. * reset the state.
  714. */
  715. if (!ft_completed) {
  716. eapol_sm_notify_portEnabled(wpa_s->eapol, FALSE);
  717. eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
  718. }
  719. if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || ft_completed)
  720. eapol_sm_notify_eap_success(wpa_s->eapol, FALSE);
  721. /* 802.1X::portControl = Auto */
  722. eapol_sm_notify_portEnabled(wpa_s->eapol, TRUE);
  723. wpa_s->eapol_received = 0;
  724. if (wpa_s->key_mgmt == WPA_KEY_MGMT_NONE ||
  725. wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
  726. wpa_supplicant_cancel_auth_timeout(wpa_s);
  727. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  728. } else if (!ft_completed) {
  729. /* Timeout for receiving the first EAPOL packet */
  730. wpa_supplicant_req_auth_timeout(wpa_s, 10, 0);
  731. }
  732. wpa_supplicant_cancel_scan(wpa_s);
  733. if (wpa_s->driver_4way_handshake &&
  734. wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
  735. /*
  736. * We are done; the driver will take care of RSN 4-way
  737. * handshake.
  738. */
  739. wpa_supplicant_cancel_auth_timeout(wpa_s);
  740. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  741. eapol_sm_notify_portValid(wpa_s->eapol, TRUE);
  742. eapol_sm_notify_eap_success(wpa_s->eapol, TRUE);
  743. }
  744. }
  745. static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
  746. {
  747. const u8 *bssid;
  748. if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPA_NONE) {
  749. /*
  750. * At least Host AP driver and a Prism3 card seemed to be
  751. * generating streams of disconnected events when configuring
  752. * IBSS for WPA-None. Ignore them for now.
  753. */
  754. wpa_printf(MSG_DEBUG, "Disconnect event - ignore in "
  755. "IBSS/WPA-None mode");
  756. return;
  757. }
  758. if (wpa_s->wpa_state == WPA_4WAY_HANDSHAKE &&
  759. wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) {
  760. wpa_msg(wpa_s, MSG_INFO, "WPA: 4-Way Handshake failed - "
  761. "pre-shared key may be incorrect");
  762. }
  763. if (wpa_s->wpa_state >= WPA_ASSOCIATED)
  764. wpa_supplicant_req_scan(wpa_s, 0, 100000);
  765. bssid = wpa_s->bssid;
  766. if (is_zero_ether_addr(bssid))
  767. bssid = wpa_s->pending_bssid;
  768. wpa_blacklist_add(wpa_s, bssid);
  769. wpa_sm_notify_disassoc(wpa_s->wpa);
  770. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "- Disconnect event - "
  771. "remove keys");
  772. if (wpa_supplicant_dynamic_keys(wpa_s)) {
  773. wpa_s->keys_cleared = 0;
  774. wpa_clear_keys(wpa_s, wpa_s->bssid);
  775. }
  776. wpa_supplicant_mark_disassoc(wpa_s);
  777. }
  778. #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
  779. static void wpa_supplicant_delayed_mic_error_report(void *eloop_ctx,
  780. void *sock_ctx)
  781. {
  782. struct wpa_supplicant *wpa_s = eloop_ctx;
  783. if (!wpa_s->pending_mic_error_report)
  784. return;
  785. wpa_printf(MSG_DEBUG, "WPA: Sending pending MIC error report");
  786. wpa_sm_key_request(wpa_s->wpa, 1, wpa_s->pending_mic_error_pairwise);
  787. wpa_s->pending_mic_error_report = 0;
  788. }
  789. #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
  790. static void
  791. wpa_supplicant_event_michael_mic_failure(struct wpa_supplicant *wpa_s,
  792. union wpa_event_data *data)
  793. {
  794. int pairwise;
  795. struct os_time t;
  796. wpa_msg(wpa_s, MSG_WARNING, "Michael MIC failure detected");
  797. pairwise = (data && data->michael_mic_failure.unicast);
  798. os_get_time(&t);
  799. if ((wpa_s->last_michael_mic_error &&
  800. t.sec - wpa_s->last_michael_mic_error <= 60) ||
  801. wpa_s->pending_mic_error_report) {
  802. if (wpa_s->pending_mic_error_report) {
  803. /*
  804. * Send the pending MIC error report immediately since
  805. * we are going to start countermeasures and AP better
  806. * do the same.
  807. */
  808. wpa_sm_key_request(wpa_s->wpa, 1,
  809. wpa_s->pending_mic_error_pairwise);
  810. }
  811. /* Send the new MIC error report immediately since we are going
  812. * to start countermeasures and AP better do the same.
  813. */
  814. wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
  815. /* initialize countermeasures */
  816. wpa_s->countermeasures = 1;
  817. wpa_msg(wpa_s, MSG_WARNING, "TKIP countermeasures started");
  818. /*
  819. * Need to wait for completion of request frame. We do not get
  820. * any callback for the message completion, so just wait a
  821. * short while and hope for the best. */
  822. os_sleep(0, 10000);
  823. wpa_drv_set_countermeasures(wpa_s, 1);
  824. wpa_supplicant_deauthenticate(wpa_s,
  825. WLAN_REASON_MICHAEL_MIC_FAILURE);
  826. eloop_cancel_timeout(wpa_supplicant_stop_countermeasures,
  827. wpa_s, NULL);
  828. eloop_register_timeout(60, 0,
  829. wpa_supplicant_stop_countermeasures,
  830. wpa_s, NULL);
  831. /* TODO: mark the AP rejected for 60 second. STA is
  832. * allowed to associate with another AP.. */
  833. } else {
  834. #ifdef CONFIG_DELAYED_MIC_ERROR_REPORT
  835. if (wpa_s->mic_errors_seen) {
  836. /*
  837. * Reduce the effectiveness of Michael MIC error
  838. * reports as a means for attacking against TKIP if
  839. * more than one MIC failure is noticed with the same
  840. * PTK. We delay the transmission of the reports by a
  841. * random time between 0 and 60 seconds in order to
  842. * force the attacker wait 60 seconds before getting
  843. * the information on whether a frame resulted in a MIC
  844. * failure.
  845. */
  846. u8 rval[4];
  847. int sec;
  848. if (os_get_random(rval, sizeof(rval)) < 0)
  849. sec = os_random() % 60;
  850. else
  851. sec = WPA_GET_BE32(rval) % 60;
  852. wpa_printf(MSG_DEBUG, "WPA: Delay MIC error report %d "
  853. "seconds", sec);
  854. wpa_s->pending_mic_error_report = 1;
  855. wpa_s->pending_mic_error_pairwise = pairwise;
  856. eloop_cancel_timeout(
  857. wpa_supplicant_delayed_mic_error_report,
  858. wpa_s, NULL);
  859. eloop_register_timeout(
  860. sec, os_random() % 1000000,
  861. wpa_supplicant_delayed_mic_error_report,
  862. wpa_s, NULL);
  863. } else {
  864. wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
  865. }
  866. #else /* CONFIG_DELAYED_MIC_ERROR_REPORT */
  867. wpa_sm_key_request(wpa_s->wpa, 1, pairwise);
  868. #endif /* CONFIG_DELAYED_MIC_ERROR_REPORT */
  869. }
  870. wpa_s->last_michael_mic_error = t.sec;
  871. wpa_s->mic_errors_seen++;
  872. }
  873. static void
  874. wpa_supplicant_event_interface_status(struct wpa_supplicant *wpa_s,
  875. union wpa_event_data *data)
  876. {
  877. if (os_strcmp(wpa_s->ifname, data->interface_status.ifname) != 0)
  878. return;
  879. switch (data->interface_status.ievent) {
  880. case EVENT_INTERFACE_ADDED:
  881. if (!wpa_s->interface_removed)
  882. break;
  883. wpa_s->interface_removed = 0;
  884. wpa_printf(MSG_DEBUG, "Configured interface was added.");
  885. if (wpa_supplicant_driver_init(wpa_s) < 0) {
  886. wpa_printf(MSG_INFO, "Failed to initialize the driver "
  887. "after interface was added.");
  888. }
  889. break;
  890. case EVENT_INTERFACE_REMOVED:
  891. wpa_printf(MSG_DEBUG, "Configured interface was removed.");
  892. wpa_s->interface_removed = 1;
  893. wpa_supplicant_mark_disassoc(wpa_s);
  894. l2_packet_deinit(wpa_s->l2);
  895. wpa_s->l2 = NULL;
  896. break;
  897. }
  898. }
  899. #ifdef CONFIG_PEERKEY
  900. static void
  901. wpa_supplicant_event_stkstart(struct wpa_supplicant *wpa_s,
  902. union wpa_event_data *data)
  903. {
  904. if (data == NULL)
  905. return;
  906. wpa_sm_stkstart(wpa_s->wpa, data->stkstart.peer);
  907. }
  908. #endif /* CONFIG_PEERKEY */
  909. #ifdef CONFIG_IEEE80211R
  910. static void
  911. wpa_supplicant_event_ft_response(struct wpa_supplicant *wpa_s,
  912. union wpa_event_data *data)
  913. {
  914. if (data == NULL)
  915. return;
  916. if (wpa_ft_process_response(wpa_s->wpa, data->ft_ies.ies,
  917. data->ft_ies.ies_len,
  918. data->ft_ies.ft_action,
  919. data->ft_ies.target_ap) < 0) {
  920. /* TODO: prevent MLME/driver from trying to associate? */
  921. }
  922. }
  923. #endif /* CONFIG_IEEE80211R */
  924. #ifdef CONFIG_IBSS_RSN
  925. static void wpa_supplicant_event_ibss_rsn_start(struct wpa_supplicant *wpa_s,
  926. union wpa_event_data *data)
  927. {
  928. if (data == NULL)
  929. return;
  930. ibss_rsn_start(wpa_s->ibss_rsn, data->ibss_rsn_start.peer);
  931. }
  932. #endif /* CONFIG_IBSS_RSN */
  933. void wpa_supplicant_event(void *ctx, wpa_event_type event,
  934. union wpa_event_data *data)
  935. {
  936. struct wpa_supplicant *wpa_s = ctx;
  937. switch (event) {
  938. case EVENT_ASSOC:
  939. wpa_supplicant_event_assoc(wpa_s, data);
  940. break;
  941. case EVENT_DISASSOC:
  942. wpa_supplicant_event_disassoc(wpa_s);
  943. break;
  944. case EVENT_MICHAEL_MIC_FAILURE:
  945. wpa_supplicant_event_michael_mic_failure(wpa_s, data);
  946. break;
  947. #ifndef CONFIG_NO_SCAN_PROCESSING
  948. case EVENT_SCAN_RESULTS:
  949. wpa_supplicant_event_scan_results(wpa_s);
  950. break;
  951. #endif /* CONFIG_NO_SCAN_PROCESSING */
  952. case EVENT_ASSOCINFO:
  953. wpa_supplicant_event_associnfo(wpa_s, data);
  954. break;
  955. case EVENT_INTERFACE_STATUS:
  956. wpa_supplicant_event_interface_status(wpa_s, data);
  957. break;
  958. case EVENT_PMKID_CANDIDATE:
  959. wpa_supplicant_event_pmkid_candidate(wpa_s, data);
  960. break;
  961. #ifdef CONFIG_PEERKEY
  962. case EVENT_STKSTART:
  963. wpa_supplicant_event_stkstart(wpa_s, data);
  964. break;
  965. #endif /* CONFIG_PEERKEY */
  966. #ifdef CONFIG_IEEE80211R
  967. case EVENT_FT_RESPONSE:
  968. wpa_supplicant_event_ft_response(wpa_s, data);
  969. break;
  970. #endif /* CONFIG_IEEE80211R */
  971. #ifdef CONFIG_IBSS_RSN
  972. case EVENT_IBSS_RSN_START:
  973. wpa_supplicant_event_ibss_rsn_start(wpa_s, data);
  974. break;
  975. #endif /* CONFIG_IBSS_RSN */
  976. default:
  977. wpa_printf(MSG_INFO, "Unknown event %d", event);
  978. break;
  979. }
  980. }