wpas_glue.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  1. /*
  2. * WPA Supplicant - Glue code to setup EAPOL and RSN modules
  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 "config.h"
  20. #include "l2_packet/l2_packet.h"
  21. #include "wpa_common.h"
  22. #include "wpa_supplicant_i.h"
  23. #include "pmksa_cache.h"
  24. #include "mlme.h"
  25. #include "ieee802_11_defs.h"
  26. #include "wpa_ctrl.h"
  27. #include "wpas_glue.h"
  28. #ifndef CONFIG_NO_CONFIG_BLOBS
  29. #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
  30. static void wpa_supplicant_set_config_blob(void *ctx,
  31. struct wpa_config_blob *blob)
  32. {
  33. struct wpa_supplicant *wpa_s = ctx;
  34. wpa_config_set_blob(wpa_s->conf, blob);
  35. }
  36. static const struct wpa_config_blob *
  37. wpa_supplicant_get_config_blob(void *ctx, const char *name)
  38. {
  39. struct wpa_supplicant *wpa_s = ctx;
  40. return wpa_config_get_blob(wpa_s->conf, name);
  41. }
  42. #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
  43. #endif /* CONFIG_NO_CONFIG_BLOBS */
  44. #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
  45. static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
  46. const void *data, u16 data_len,
  47. size_t *msg_len, void **data_pos)
  48. {
  49. struct ieee802_1x_hdr *hdr;
  50. *msg_len = sizeof(*hdr) + data_len;
  51. hdr = os_malloc(*msg_len);
  52. if (hdr == NULL)
  53. return NULL;
  54. hdr->version = wpa_s->conf->eapol_version;
  55. hdr->type = type;
  56. hdr->length = host_to_be16(data_len);
  57. if (data)
  58. os_memcpy(hdr + 1, data, data_len);
  59. else
  60. os_memset(hdr + 1, 0, data_len);
  61. if (data_pos)
  62. *data_pos = hdr + 1;
  63. return (u8 *) hdr;
  64. }
  65. /**
  66. * wpa_ether_send - Send Ethernet frame
  67. * @wpa_s: Pointer to wpa_supplicant data
  68. * @dest: Destination MAC address
  69. * @proto: Ethertype in host byte order
  70. * @buf: Frame payload starting from IEEE 802.1X header
  71. * @len: Frame payload length
  72. * Returns: >=0 on success, <0 on failure
  73. */
  74. static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
  75. u16 proto, const u8 *buf, size_t len)
  76. {
  77. if (wpa_s->l2) {
  78. return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
  79. }
  80. return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
  81. }
  82. #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
  83. #ifdef IEEE8021X_EAPOL
  84. /**
  85. * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
  86. * @ctx: Pointer to wpa_supplicant data (wpa_s)
  87. * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
  88. * @buf: EAPOL payload (after IEEE 802.1X header)
  89. * @len: EAPOL payload length
  90. * Returns: >=0 on success, <0 on failure
  91. *
  92. * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
  93. * to the current Authenticator.
  94. */
  95. static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
  96. size_t len)
  97. {
  98. struct wpa_supplicant *wpa_s = ctx;
  99. u8 *msg, *dst, bssid[ETH_ALEN];
  100. size_t msglen;
  101. int res;
  102. /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
  103. * extra copy here */
  104. if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
  105. wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
  106. /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
  107. * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
  108. * machines. */
  109. wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
  110. "mode (type=%d len=%lu)", type,
  111. (unsigned long) len);
  112. return -1;
  113. }
  114. if (pmksa_cache_get_current(wpa_s->wpa) &&
  115. type == IEEE802_1X_TYPE_EAPOL_START) {
  116. /* Trying to use PMKSA caching - do not send EAPOL-Start frames
  117. * since they will trigger full EAPOL authentication. */
  118. wpa_printf(MSG_DEBUG, "RSN: PMKSA caching - do not send "
  119. "EAPOL-Start");
  120. return -1;
  121. }
  122. if (is_zero_ether_addr(wpa_s->bssid)) {
  123. wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
  124. "EAPOL frame");
  125. if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
  126. !is_zero_ether_addr(bssid)) {
  127. dst = bssid;
  128. wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
  129. " from the driver as the EAPOL destination",
  130. MAC2STR(dst));
  131. } else {
  132. dst = wpa_s->last_eapol_src;
  133. wpa_printf(MSG_DEBUG, "Using the source address of the"
  134. " last received EAPOL frame " MACSTR " as "
  135. "the EAPOL destination",
  136. MAC2STR(dst));
  137. }
  138. } else {
  139. /* BSSID was already set (from (Re)Assoc event, so use it as
  140. * the EAPOL destination. */
  141. dst = wpa_s->bssid;
  142. }
  143. msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
  144. if (msg == NULL)
  145. return -1;
  146. wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
  147. wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
  148. res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
  149. os_free(msg);
  150. return res;
  151. }
  152. /**
  153. * wpa_eapol_set_wep_key - set WEP key for the driver
  154. * @ctx: Pointer to wpa_supplicant data (wpa_s)
  155. * @unicast: 1 = individual unicast key, 0 = broadcast key
  156. * @keyidx: WEP key index (0..3)
  157. * @key: Pointer to key data
  158. * @keylen: Key length in bytes
  159. * Returns: 0 on success or < 0 on error.
  160. */
  161. static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
  162. const u8 *key, size_t keylen)
  163. {
  164. struct wpa_supplicant *wpa_s = ctx;
  165. if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
  166. int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
  167. WPA_CIPHER_WEP104;
  168. if (unicast)
  169. wpa_s->pairwise_cipher = cipher;
  170. else
  171. wpa_s->group_cipher = cipher;
  172. }
  173. return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
  174. unicast ? wpa_s->bssid :
  175. (u8 *) "\xff\xff\xff\xff\xff\xff",
  176. keyidx, unicast, (u8 *) "", 0, key, keylen);
  177. }
  178. static void wpa_supplicant_aborted_cached(void *ctx)
  179. {
  180. struct wpa_supplicant *wpa_s = ctx;
  181. wpa_sm_aborted_cached(wpa_s->wpa);
  182. }
  183. static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, int success,
  184. void *ctx)
  185. {
  186. struct wpa_supplicant *wpa_s = ctx;
  187. int res, pmk_len;
  188. u8 pmk[PMK_LEN];
  189. wpa_printf(MSG_DEBUG, "EAPOL authentication completed %ssuccessfully",
  190. success ? "" : "un");
  191. if (!success || !wpa_s->driver_4way_handshake)
  192. return;
  193. if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
  194. return;
  195. wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
  196. "handshake");
  197. pmk_len = PMK_LEN;
  198. res = eapol_sm_get_key(eapol, pmk, PMK_LEN);
  199. if (res) {
  200. /*
  201. * EAP-LEAP is an exception from other EAP methods: it
  202. * uses only 16-byte PMK.
  203. */
  204. res = eapol_sm_get_key(eapol, pmk, 16);
  205. pmk_len = 16;
  206. }
  207. if (res) {
  208. wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
  209. "machines");
  210. return;
  211. }
  212. if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
  213. pmk_len)) {
  214. wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
  215. }
  216. wpa_supplicant_cancel_scan(wpa_s);
  217. wpa_supplicant_cancel_auth_timeout(wpa_s);
  218. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  219. }
  220. static void wpa_supplicant_notify_eapol_done(void *ctx)
  221. {
  222. struct wpa_supplicant *wpa_s = ctx;
  223. wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
  224. if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
  225. wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
  226. } else {
  227. wpa_supplicant_cancel_auth_timeout(wpa_s);
  228. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  229. }
  230. }
  231. #endif /* IEEE8021X_EAPOL */
  232. #ifndef CONFIG_NO_WPA
  233. static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
  234. {
  235. size_t i;
  236. int ret = 0;
  237. struct wpa_scan_res *curr = NULL;
  238. struct wpa_ssid *ssid = wpa_s->current_ssid;
  239. const u8 *ie;
  240. if (wpa_s->scan_res == NULL)
  241. return -1;
  242. for (i = 0; i < wpa_s->scan_res->num; i++) {
  243. struct wpa_scan_res *r = wpa_s->scan_res->res[i];
  244. if (os_memcmp(r->bssid, wpa_s->bssid, ETH_ALEN) != 0)
  245. continue;
  246. ie = wpa_scan_get_ie(r, WLAN_EID_SSID);
  247. if (ssid == NULL ||
  248. ((ie && ie[1] == ssid->ssid_len &&
  249. os_memcmp(ie + 2, ssid->ssid, ssid->ssid_len) == 0) ||
  250. ssid->ssid_len == 0)) {
  251. curr = r;
  252. break;
  253. }
  254. }
  255. if (curr) {
  256. ie = wpa_scan_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
  257. if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
  258. ret = -1;
  259. ie = wpa_scan_get_ie(curr, WLAN_EID_RSN);
  260. if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
  261. ret = -1;
  262. } else {
  263. ret = -1;
  264. }
  265. return ret;
  266. }
  267. static int wpa_supplicant_get_beacon_ie(void *ctx)
  268. {
  269. struct wpa_supplicant *wpa_s = ctx;
  270. if (wpa_get_beacon_ie(wpa_s) == 0) {
  271. return 0;
  272. }
  273. /* No WPA/RSN IE found in the cached scan results. Try to get updated
  274. * scan results from the driver. */
  275. if (wpa_supplicant_get_scan_results(wpa_s) < 0) {
  276. return -1;
  277. }
  278. return wpa_get_beacon_ie(wpa_s);
  279. }
  280. static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
  281. const void *data, u16 data_len,
  282. size_t *msg_len, void **data_pos)
  283. {
  284. return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
  285. }
  286. static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
  287. const u8 *buf, size_t len)
  288. {
  289. return wpa_ether_send(wpa_s, dest, proto, buf, len);
  290. }
  291. static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
  292. {
  293. wpa_supplicant_cancel_auth_timeout(wpa_s);
  294. }
  295. static void _wpa_supplicant_set_state(void *wpa_s, wpa_states state)
  296. {
  297. wpa_supplicant_set_state(wpa_s, state);
  298. }
  299. /**
  300. * wpa_supplicant_get_state - Get the connection state
  301. * @wpa_s: Pointer to wpa_supplicant data
  302. * Returns: The current connection state (WPA_*)
  303. */
  304. static wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
  305. {
  306. return wpa_s->wpa_state;
  307. }
  308. static wpa_states _wpa_supplicant_get_state(void *wpa_s)
  309. {
  310. return wpa_supplicant_get_state(wpa_s);
  311. }
  312. static void _wpa_supplicant_disassociate(void *wpa_s, int reason_code)
  313. {
  314. wpa_supplicant_disassociate(wpa_s, reason_code);
  315. /* Schedule a scan to make sure we continue looking for networks */
  316. wpa_supplicant_req_scan(wpa_s, 0, 0);
  317. }
  318. static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
  319. {
  320. wpa_supplicant_deauthenticate(wpa_s, reason_code);
  321. /* Schedule a scan to make sure we continue looking for networks */
  322. wpa_supplicant_req_scan(wpa_s, 0, 0);
  323. }
  324. static void * wpa_supplicant_get_network_ctx(void *wpa_s)
  325. {
  326. return wpa_supplicant_get_ssid(wpa_s);
  327. }
  328. static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
  329. {
  330. struct wpa_supplicant *wpa_s = ctx;
  331. if (wpa_s->use_client_mlme) {
  332. os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
  333. return 0;
  334. }
  335. return wpa_drv_get_bssid(wpa_s, bssid);
  336. }
  337. static int wpa_supplicant_set_key(void *wpa_s, wpa_alg alg,
  338. const u8 *addr, int key_idx, int set_tx,
  339. const u8 *seq, size_t seq_len,
  340. const u8 *key, size_t key_len)
  341. {
  342. return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
  343. key, key_len);
  344. }
  345. static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
  346. int protection_type,
  347. int key_type)
  348. {
  349. return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
  350. key_type);
  351. }
  352. static int wpa_supplicant_add_pmkid(void *wpa_s,
  353. const u8 *bssid, const u8 *pmkid)
  354. {
  355. return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
  356. }
  357. static int wpa_supplicant_remove_pmkid(void *wpa_s,
  358. const u8 *bssid, const u8 *pmkid)
  359. {
  360. return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
  361. }
  362. #ifdef CONFIG_IEEE80211R
  363. static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
  364. const u8 *ies, size_t ies_len)
  365. {
  366. struct wpa_supplicant *wpa_s = ctx;
  367. if (wpa_s->use_client_mlme)
  368. return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
  369. return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
  370. }
  371. static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
  372. const u8 *target_ap,
  373. const u8 *ies, size_t ies_len)
  374. {
  375. struct wpa_supplicant *wpa_s = ctx;
  376. if (wpa_s->use_client_mlme)
  377. return ieee80211_sta_send_ft_action(wpa_s, action, target_ap,
  378. ies, ies_len);
  379. return wpa_drv_send_ft_action(wpa_s, action, target_ap, ies, ies_len);
  380. }
  381. #endif /* CONFIG_IEEE80211R */
  382. #endif /* CONFIG_NO_WPA */
  383. #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
  384. static void wpa_supplicant_eap_param_needed(void *ctx, const char *field,
  385. const char *txt)
  386. {
  387. struct wpa_supplicant *wpa_s = ctx;
  388. struct wpa_ssid *ssid = wpa_s->current_ssid;
  389. char *buf;
  390. size_t buflen;
  391. int len;
  392. if (ssid == NULL)
  393. return;
  394. buflen = 100 + os_strlen(txt) + ssid->ssid_len;
  395. buf = os_malloc(buflen);
  396. if (buf == NULL)
  397. return;
  398. len = os_snprintf(buf, buflen,
  399. WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
  400. field, ssid->id, txt);
  401. if (len < 0 || (size_t) len >= buflen) {
  402. os_free(buf);
  403. return;
  404. }
  405. if (ssid->ssid && buflen > len + ssid->ssid_len) {
  406. os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
  407. len += ssid->ssid_len;
  408. buf[len] = '\0';
  409. }
  410. buf[buflen - 1] = '\0';
  411. wpa_msg(wpa_s, MSG_INFO, "%s", buf);
  412. os_free(buf);
  413. }
  414. #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
  415. #define wpa_supplicant_eap_param_needed NULL
  416. #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
  417. int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
  418. {
  419. #ifdef IEEE8021X_EAPOL
  420. struct eapol_ctx *ctx;
  421. ctx = os_zalloc(sizeof(*ctx));
  422. if (ctx == NULL) {
  423. wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
  424. return -1;
  425. }
  426. ctx->ctx = wpa_s;
  427. ctx->msg_ctx = wpa_s;
  428. ctx->eapol_send_ctx = wpa_s;
  429. ctx->preauth = 0;
  430. ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
  431. ctx->eapol_send = wpa_supplicant_eapol_send;
  432. ctx->set_wep_key = wpa_eapol_set_wep_key;
  433. ctx->set_config_blob = wpa_supplicant_set_config_blob;
  434. ctx->get_config_blob = wpa_supplicant_get_config_blob;
  435. ctx->aborted_cached = wpa_supplicant_aborted_cached;
  436. #ifdef EAP_TLS_OPENSSL
  437. ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
  438. ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
  439. ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
  440. #endif /* EAP_TLS_OPENSSL */
  441. ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
  442. ctx->cb = wpa_supplicant_eapol_cb;
  443. ctx->cb_ctx = wpa_s;
  444. wpa_s->eapol = eapol_sm_init(ctx);
  445. if (wpa_s->eapol == NULL) {
  446. os_free(ctx);
  447. wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
  448. "machines.");
  449. return -1;
  450. }
  451. #endif /* IEEE8021X_EAPOL */
  452. return 0;
  453. }
  454. int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
  455. {
  456. #ifndef CONFIG_NO_WPA
  457. struct wpa_sm_ctx *ctx;
  458. ctx = os_zalloc(sizeof(*ctx));
  459. if (ctx == NULL) {
  460. wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
  461. return -1;
  462. }
  463. ctx->ctx = wpa_s;
  464. ctx->set_state = _wpa_supplicant_set_state;
  465. ctx->get_state = _wpa_supplicant_get_state;
  466. ctx->deauthenticate = _wpa_supplicant_deauthenticate;
  467. ctx->disassociate = _wpa_supplicant_disassociate;
  468. ctx->set_key = wpa_supplicant_set_key;
  469. ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
  470. ctx->get_bssid = wpa_supplicant_get_bssid;
  471. ctx->ether_send = _wpa_ether_send;
  472. ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
  473. ctx->alloc_eapol = _wpa_alloc_eapol;
  474. ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
  475. ctx->add_pmkid = wpa_supplicant_add_pmkid;
  476. ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
  477. #ifndef CONFIG_NO_CONFIG_BLOBS
  478. ctx->set_config_blob = wpa_supplicant_set_config_blob;
  479. ctx->get_config_blob = wpa_supplicant_get_config_blob;
  480. #endif /* CONFIG_NO_CONFIG_BLOBS */
  481. ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
  482. #ifdef CONFIG_IEEE80211R
  483. ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
  484. ctx->send_ft_action = wpa_supplicant_send_ft_action;
  485. #endif /* CONFIG_IEEE80211R */
  486. wpa_s->wpa = wpa_sm_init(ctx);
  487. if (wpa_s->wpa == NULL) {
  488. wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
  489. "machine");
  490. return -1;
  491. }
  492. #endif /* CONFIG_NO_WPA */
  493. return 0;
  494. }
  495. void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
  496. struct wpa_ssid *ssid)
  497. {
  498. struct rsn_supp_config conf;
  499. if (ssid) {
  500. os_memset(&conf, 0, sizeof(conf));
  501. conf.network_ctx = ssid;
  502. conf.peerkey_enabled = ssid->peerkey;
  503. conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
  504. #ifdef IEEE8021X_EAPOL
  505. conf.eap_workaround = ssid->eap_workaround;
  506. conf.eap_conf_ctx = &ssid->eap;
  507. #endif /* IEEE8021X_EAPOL */
  508. conf.ssid = ssid->ssid;
  509. conf.ssid_len = ssid->ssid_len;
  510. }
  511. wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);
  512. }