wpas_glue.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. /*
  2. * WPA Supplicant - Glue code to setup EAPOL and RSN modules
  3. * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "includes.h"
  9. #include "common.h"
  10. #include "eapol_supp/eapol_supp_sm.h"
  11. #include "rsn_supp/wpa.h"
  12. #include "eloop.h"
  13. #include "config.h"
  14. #include "l2_packet/l2_packet.h"
  15. #include "common/wpa_common.h"
  16. #include "wpa_supplicant_i.h"
  17. #include "driver_i.h"
  18. #include "rsn_supp/pmksa_cache.h"
  19. #include "sme.h"
  20. #include "common/ieee802_11_defs.h"
  21. #include "common/wpa_ctrl.h"
  22. #include "wpas_glue.h"
  23. #include "wps_supplicant.h"
  24. #include "bss.h"
  25. #include "scan.h"
  26. #include "notify.h"
  27. #include "wpas_kay.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. if (wpa_s->conf->update_config) {
  36. int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
  37. if (ret) {
  38. wpa_printf(MSG_DEBUG, "Failed to update config after "
  39. "blob set");
  40. }
  41. }
  42. }
  43. static const struct wpa_config_blob *
  44. wpa_supplicant_get_config_blob(void *ctx, const char *name)
  45. {
  46. struct wpa_supplicant *wpa_s = ctx;
  47. return wpa_config_get_blob(wpa_s->conf, name);
  48. }
  49. #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
  50. #endif /* CONFIG_NO_CONFIG_BLOBS */
  51. #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
  52. static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
  53. const void *data, u16 data_len,
  54. size_t *msg_len, void **data_pos)
  55. {
  56. struct ieee802_1x_hdr *hdr;
  57. *msg_len = sizeof(*hdr) + data_len;
  58. hdr = os_malloc(*msg_len);
  59. if (hdr == NULL)
  60. return NULL;
  61. hdr->version = wpa_s->conf->eapol_version;
  62. hdr->type = type;
  63. hdr->length = host_to_be16(data_len);
  64. if (data)
  65. os_memcpy(hdr + 1, data, data_len);
  66. else
  67. os_memset(hdr + 1, 0, data_len);
  68. if (data_pos)
  69. *data_pos = hdr + 1;
  70. return (u8 *) hdr;
  71. }
  72. /**
  73. * wpa_ether_send - Send Ethernet frame
  74. * @wpa_s: Pointer to wpa_supplicant data
  75. * @dest: Destination MAC address
  76. * @proto: Ethertype in host byte order
  77. * @buf: Frame payload starting from IEEE 802.1X header
  78. * @len: Frame payload length
  79. * Returns: >=0 on success, <0 on failure
  80. */
  81. static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
  82. u16 proto, const u8 *buf, size_t len)
  83. {
  84. #ifdef CONFIG_TESTING_OPTIONS
  85. if (wpa_s->ext_eapol_frame_io && proto == ETH_P_EAPOL) {
  86. size_t hex_len = 2 * len + 1;
  87. char *hex = os_malloc(hex_len);
  88. if (hex == NULL)
  89. return -1;
  90. wpa_snprintf_hex(hex, hex_len, buf, len);
  91. wpa_msg(wpa_s, MSG_INFO, "EAPOL-TX " MACSTR " %s",
  92. MAC2STR(dest), hex);
  93. os_free(hex);
  94. return 0;
  95. }
  96. #endif /* CONFIG_TESTING_OPTIONS */
  97. if (wpa_s->l2) {
  98. return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
  99. }
  100. return -1;
  101. }
  102. #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
  103. #ifdef IEEE8021X_EAPOL
  104. /**
  105. * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
  106. * @ctx: Pointer to wpa_supplicant data (wpa_s)
  107. * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
  108. * @buf: EAPOL payload (after IEEE 802.1X header)
  109. * @len: EAPOL payload length
  110. * Returns: >=0 on success, <0 on failure
  111. *
  112. * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
  113. * to the current Authenticator.
  114. */
  115. static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
  116. size_t len)
  117. {
  118. struct wpa_supplicant *wpa_s = ctx;
  119. u8 *msg, *dst, bssid[ETH_ALEN];
  120. size_t msglen;
  121. int res;
  122. /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
  123. * extra copy here */
  124. if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
  125. wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
  126. /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
  127. * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
  128. * machines. */
  129. wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
  130. "mode (type=%d len=%lu)", type,
  131. (unsigned long) len);
  132. return -1;
  133. }
  134. if (pmksa_cache_get_current(wpa_s->wpa) &&
  135. type == IEEE802_1X_TYPE_EAPOL_START) {
  136. /*
  137. * We were trying to use PMKSA caching and sending EAPOL-Start
  138. * would abort that and trigger full EAPOL authentication.
  139. * However, we've already waited for the AP/Authenticator to
  140. * start 4-way handshake or EAP authentication, and apparently
  141. * it has not done so since the startWhen timer has reached zero
  142. * to get the state machine sending EAPOL-Start. This is not
  143. * really supposed to happen, but an interoperability issue with
  144. * a deployed AP has been identified where the connection fails
  145. * due to that AP failing to operate correctly if PMKID is
  146. * included in the Association Request frame. To work around
  147. * this, assume PMKSA caching failed and try to initiate full
  148. * EAP authentication.
  149. */
  150. if (!wpa_s->current_ssid ||
  151. wpa_s->current_ssid->eap_workaround) {
  152. wpa_printf(MSG_DEBUG,
  153. "RSN: Timeout on waiting for the AP to initiate 4-way handshake for PMKSA caching or EAP authentication - try to force it to start EAP authentication");
  154. } else {
  155. wpa_printf(MSG_DEBUG,
  156. "RSN: PMKSA caching - do not send EAPOL-Start");
  157. return -1;
  158. }
  159. }
  160. if (is_zero_ether_addr(wpa_s->bssid)) {
  161. wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
  162. "EAPOL frame");
  163. if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
  164. !is_zero_ether_addr(bssid)) {
  165. dst = bssid;
  166. wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
  167. " from the driver as the EAPOL destination",
  168. MAC2STR(dst));
  169. } else {
  170. dst = wpa_s->last_eapol_src;
  171. wpa_printf(MSG_DEBUG, "Using the source address of the"
  172. " last received EAPOL frame " MACSTR " as "
  173. "the EAPOL destination",
  174. MAC2STR(dst));
  175. }
  176. } else {
  177. /* BSSID was already set (from (Re)Assoc event, so use it as
  178. * the EAPOL destination. */
  179. dst = wpa_s->bssid;
  180. }
  181. msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
  182. if (msg == NULL)
  183. return -1;
  184. wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
  185. wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
  186. res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
  187. os_free(msg);
  188. return res;
  189. }
  190. /**
  191. * wpa_eapol_set_wep_key - set WEP key for the driver
  192. * @ctx: Pointer to wpa_supplicant data (wpa_s)
  193. * @unicast: 1 = individual unicast key, 0 = broadcast key
  194. * @keyidx: WEP key index (0..3)
  195. * @key: Pointer to key data
  196. * @keylen: Key length in bytes
  197. * Returns: 0 on success or < 0 on error.
  198. */
  199. static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
  200. const u8 *key, size_t keylen)
  201. {
  202. struct wpa_supplicant *wpa_s = ctx;
  203. if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
  204. int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
  205. WPA_CIPHER_WEP104;
  206. if (unicast)
  207. wpa_s->pairwise_cipher = cipher;
  208. else
  209. wpa_s->group_cipher = cipher;
  210. }
  211. return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
  212. unicast ? wpa_s->bssid : NULL,
  213. keyidx, unicast, NULL, 0, key, keylen);
  214. }
  215. static void wpa_supplicant_aborted_cached(void *ctx)
  216. {
  217. struct wpa_supplicant *wpa_s = ctx;
  218. wpa_sm_aborted_cached(wpa_s->wpa);
  219. }
  220. static const char * result_str(enum eapol_supp_result result)
  221. {
  222. switch (result) {
  223. case EAPOL_SUPP_RESULT_FAILURE:
  224. return "FAILURE";
  225. case EAPOL_SUPP_RESULT_SUCCESS:
  226. return "SUCCESS";
  227. case EAPOL_SUPP_RESULT_EXPECTED_FAILURE:
  228. return "EXPECTED_FAILURE";
  229. }
  230. return "?";
  231. }
  232. static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol,
  233. enum eapol_supp_result result,
  234. void *ctx)
  235. {
  236. struct wpa_supplicant *wpa_s = ctx;
  237. int res, pmk_len;
  238. u8 pmk[PMK_LEN];
  239. wpa_printf(MSG_DEBUG, "EAPOL authentication completed - result=%s",
  240. result_str(result));
  241. if (wpas_wps_eapol_cb(wpa_s) > 0)
  242. return;
  243. wpa_s->eap_expected_failure = result ==
  244. EAPOL_SUPP_RESULT_EXPECTED_FAILURE;
  245. if (result != EAPOL_SUPP_RESULT_SUCCESS) {
  246. /*
  247. * Make sure we do not get stuck here waiting for long EAPOL
  248. * timeout if the AP does not disconnect in case of
  249. * authentication failure.
  250. */
  251. wpa_supplicant_req_auth_timeout(wpa_s, 2, 0);
  252. } else {
  253. ieee802_1x_notify_create_actor(wpa_s, wpa_s->last_eapol_src);
  254. }
  255. if (result != EAPOL_SUPP_RESULT_SUCCESS ||
  256. !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
  257. return;
  258. if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
  259. return;
  260. wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
  261. "handshake");
  262. pmk_len = PMK_LEN;
  263. if (wpa_key_mgmt_ft(wpa_s->key_mgmt)) {
  264. #ifdef CONFIG_IEEE80211R
  265. u8 buf[2 * PMK_LEN];
  266. wpa_printf(MSG_DEBUG, "RSN: Use FT XXKey as PMK for "
  267. "driver-based 4-way hs and FT");
  268. res = eapol_sm_get_key(eapol, buf, 2 * PMK_LEN);
  269. if (res == 0) {
  270. os_memcpy(pmk, buf + PMK_LEN, PMK_LEN);
  271. os_memset(buf, 0, sizeof(buf));
  272. }
  273. #else /* CONFIG_IEEE80211R */
  274. res = -1;
  275. #endif /* CONFIG_IEEE80211R */
  276. } else {
  277. res = eapol_sm_get_key(eapol, pmk, PMK_LEN);
  278. if (res) {
  279. /*
  280. * EAP-LEAP is an exception from other EAP methods: it
  281. * uses only 16-byte PMK.
  282. */
  283. res = eapol_sm_get_key(eapol, pmk, 16);
  284. pmk_len = 16;
  285. }
  286. }
  287. if (res) {
  288. wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
  289. "machines");
  290. return;
  291. }
  292. wpa_hexdump_key(MSG_DEBUG, "RSN: Configure PMK for driver-based 4-way "
  293. "handshake", pmk, pmk_len);
  294. if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
  295. pmk_len)) {
  296. wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
  297. }
  298. wpa_supplicant_cancel_scan(wpa_s);
  299. wpa_supplicant_cancel_auth_timeout(wpa_s);
  300. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  301. }
  302. static void wpa_supplicant_notify_eapol_done(void *ctx)
  303. {
  304. struct wpa_supplicant *wpa_s = ctx;
  305. wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
  306. if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
  307. wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
  308. } else {
  309. wpa_supplicant_cancel_auth_timeout(wpa_s);
  310. wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
  311. }
  312. }
  313. #endif /* IEEE8021X_EAPOL */
  314. #ifndef CONFIG_NO_WPA
  315. static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
  316. {
  317. int ret = 0;
  318. struct wpa_bss *curr = NULL, *bss;
  319. struct wpa_ssid *ssid = wpa_s->current_ssid;
  320. const u8 *ie;
  321. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  322. if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) != 0)
  323. continue;
  324. if (ssid == NULL ||
  325. ((bss->ssid_len == ssid->ssid_len &&
  326. os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) ||
  327. ssid->ssid_len == 0)) {
  328. curr = bss;
  329. break;
  330. }
  331. }
  332. if (curr) {
  333. ie = wpa_bss_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
  334. if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
  335. ret = -1;
  336. ie = wpa_bss_get_ie(curr, WLAN_EID_RSN);
  337. if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
  338. ret = -1;
  339. } else {
  340. ret = -1;
  341. }
  342. return ret;
  343. }
  344. static int wpa_supplicant_get_beacon_ie(void *ctx)
  345. {
  346. struct wpa_supplicant *wpa_s = ctx;
  347. if (wpa_get_beacon_ie(wpa_s) == 0) {
  348. return 0;
  349. }
  350. /* No WPA/RSN IE found in the cached scan results. Try to get updated
  351. * scan results from the driver. */
  352. if (wpa_supplicant_update_scan_results(wpa_s) < 0)
  353. return -1;
  354. return wpa_get_beacon_ie(wpa_s);
  355. }
  356. static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
  357. const void *data, u16 data_len,
  358. size_t *msg_len, void **data_pos)
  359. {
  360. return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
  361. }
  362. static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
  363. const u8 *buf, size_t len)
  364. {
  365. return wpa_ether_send(wpa_s, dest, proto, buf, len);
  366. }
  367. static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
  368. {
  369. wpa_supplicant_cancel_auth_timeout(wpa_s);
  370. }
  371. static void _wpa_supplicant_set_state(void *wpa_s, enum wpa_states state)
  372. {
  373. wpa_supplicant_set_state(wpa_s, state);
  374. }
  375. /**
  376. * wpa_supplicant_get_state - Get the connection state
  377. * @wpa_s: Pointer to wpa_supplicant data
  378. * Returns: The current connection state (WPA_*)
  379. */
  380. static enum wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
  381. {
  382. return wpa_s->wpa_state;
  383. }
  384. static enum wpa_states _wpa_supplicant_get_state(void *wpa_s)
  385. {
  386. return wpa_supplicant_get_state(wpa_s);
  387. }
  388. static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
  389. {
  390. wpa_supplicant_deauthenticate(wpa_s, reason_code);
  391. /* Schedule a scan to make sure we continue looking for networks */
  392. wpa_supplicant_req_scan(wpa_s, 5, 0);
  393. }
  394. static void * wpa_supplicant_get_network_ctx(void *wpa_s)
  395. {
  396. return wpa_supplicant_get_ssid(wpa_s);
  397. }
  398. static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
  399. {
  400. struct wpa_supplicant *wpa_s = ctx;
  401. return wpa_drv_get_bssid(wpa_s, bssid);
  402. }
  403. static int wpa_supplicant_set_key(void *_wpa_s, enum wpa_alg alg,
  404. const u8 *addr, int key_idx, int set_tx,
  405. const u8 *seq, size_t seq_len,
  406. const u8 *key, size_t key_len)
  407. {
  408. struct wpa_supplicant *wpa_s = _wpa_s;
  409. if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
  410. /* Clear the MIC error counter when setting a new PTK. */
  411. wpa_s->mic_errors_seen = 0;
  412. }
  413. #ifdef CONFIG_TESTING_GET_GTK
  414. if (key_idx > 0 && addr && is_broadcast_ether_addr(addr) &&
  415. alg != WPA_ALG_NONE && key_len <= sizeof(wpa_s->last_gtk)) {
  416. os_memcpy(wpa_s->last_gtk, key, key_len);
  417. wpa_s->last_gtk_len = key_len;
  418. }
  419. #endif /* CONFIG_TESTING_GET_GTK */
  420. return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
  421. key, key_len);
  422. }
  423. static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
  424. int protection_type,
  425. int key_type)
  426. {
  427. return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
  428. key_type);
  429. }
  430. static struct wpa_ssid * wpas_get_network_ctx(struct wpa_supplicant *wpa_s,
  431. void *network_ctx)
  432. {
  433. struct wpa_ssid *ssid;
  434. for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
  435. if (network_ctx == ssid)
  436. return ssid;
  437. }
  438. return NULL;
  439. }
  440. static int wpa_supplicant_add_pmkid(void *_wpa_s, void *network_ctx,
  441. const u8 *bssid, const u8 *pmkid)
  442. {
  443. struct wpa_supplicant *wpa_s = _wpa_s;
  444. struct wpa_ssid *ssid;
  445. ssid = wpas_get_network_ctx(wpa_s, network_ctx);
  446. if (ssid)
  447. wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_ADDED MACSTR " %d",
  448. MAC2STR(bssid), ssid->id);
  449. return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
  450. }
  451. static int wpa_supplicant_remove_pmkid(void *_wpa_s, void *network_ctx,
  452. const u8 *bssid, const u8 *pmkid)
  453. {
  454. struct wpa_supplicant *wpa_s = _wpa_s;
  455. struct wpa_ssid *ssid;
  456. ssid = wpas_get_network_ctx(wpa_s, network_ctx);
  457. if (ssid)
  458. wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_REMOVED MACSTR " %d",
  459. MAC2STR(bssid), ssid->id);
  460. return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
  461. }
  462. #ifdef CONFIG_IEEE80211R
  463. static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
  464. const u8 *ies, size_t ies_len)
  465. {
  466. struct wpa_supplicant *wpa_s = ctx;
  467. if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
  468. return sme_update_ft_ies(wpa_s, md, ies, ies_len);
  469. return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
  470. }
  471. static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
  472. const u8 *target_ap,
  473. const u8 *ies, size_t ies_len)
  474. {
  475. struct wpa_supplicant *wpa_s = ctx;
  476. int ret;
  477. u8 *data, *pos;
  478. size_t data_len;
  479. if (action != 1) {
  480. wpa_printf(MSG_ERROR, "Unsupported send_ft_action action %d",
  481. action);
  482. return -1;
  483. }
  484. /*
  485. * Action frame payload:
  486. * Category[1] = 6 (Fast BSS Transition)
  487. * Action[1] = 1 (Fast BSS Transition Request)
  488. * STA Address
  489. * Target AP Address
  490. * FT IEs
  491. */
  492. data_len = 2 + 2 * ETH_ALEN + ies_len;
  493. data = os_malloc(data_len);
  494. if (data == NULL)
  495. return -1;
  496. pos = data;
  497. *pos++ = 0x06; /* FT Action category */
  498. *pos++ = action;
  499. os_memcpy(pos, wpa_s->own_addr, ETH_ALEN);
  500. pos += ETH_ALEN;
  501. os_memcpy(pos, target_ap, ETH_ALEN);
  502. pos += ETH_ALEN;
  503. os_memcpy(pos, ies, ies_len);
  504. ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0,
  505. wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid,
  506. data, data_len, 0);
  507. os_free(data);
  508. return ret;
  509. }
  510. static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap)
  511. {
  512. struct wpa_supplicant *wpa_s = ctx;
  513. struct wpa_driver_auth_params params;
  514. struct wpa_bss *bss;
  515. bss = wpa_bss_get_bssid(wpa_s, target_ap);
  516. if (bss == NULL)
  517. return -1;
  518. os_memset(&params, 0, sizeof(params));
  519. params.bssid = target_ap;
  520. params.freq = bss->freq;
  521. params.ssid = bss->ssid;
  522. params.ssid_len = bss->ssid_len;
  523. params.auth_alg = WPA_AUTH_ALG_FT;
  524. params.local_state_change = 1;
  525. return wpa_drv_authenticate(wpa_s, &params);
  526. }
  527. #endif /* CONFIG_IEEE80211R */
  528. #ifdef CONFIG_TDLS
  529. static int wpa_supplicant_tdls_get_capa(void *ctx, int *tdls_supported,
  530. int *tdls_ext_setup,
  531. int *tdls_chan_switch)
  532. {
  533. struct wpa_supplicant *wpa_s = ctx;
  534. *tdls_supported = 0;
  535. *tdls_ext_setup = 0;
  536. *tdls_chan_switch = 0;
  537. if (!wpa_s->drv_capa_known)
  538. return -1;
  539. if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_SUPPORT)
  540. *tdls_supported = 1;
  541. if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP)
  542. *tdls_ext_setup = 1;
  543. if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH)
  544. *tdls_chan_switch = 1;
  545. return 0;
  546. }
  547. static int wpa_supplicant_send_tdls_mgmt(void *ctx, const u8 *dst,
  548. u8 action_code, u8 dialog_token,
  549. u16 status_code, u32 peer_capab,
  550. int initiator, const u8 *buf,
  551. size_t len)
  552. {
  553. struct wpa_supplicant *wpa_s = ctx;
  554. return wpa_drv_send_tdls_mgmt(wpa_s, dst, action_code, dialog_token,
  555. status_code, peer_capab, initiator, buf,
  556. len);
  557. }
  558. static int wpa_supplicant_tdls_oper(void *ctx, int oper, const u8 *peer)
  559. {
  560. struct wpa_supplicant *wpa_s = ctx;
  561. return wpa_drv_tdls_oper(wpa_s, oper, peer);
  562. }
  563. static int wpa_supplicant_tdls_peer_addset(
  564. void *ctx, const u8 *peer, int add, u16 aid, u16 capability,
  565. const u8 *supp_rates, size_t supp_rates_len,
  566. const struct ieee80211_ht_capabilities *ht_capab,
  567. const struct ieee80211_vht_capabilities *vht_capab,
  568. u8 qosinfo, int wmm, const u8 *ext_capab, size_t ext_capab_len,
  569. const u8 *supp_channels, size_t supp_channels_len,
  570. const u8 *supp_oper_classes, size_t supp_oper_classes_len)
  571. {
  572. struct wpa_supplicant *wpa_s = ctx;
  573. struct hostapd_sta_add_params params;
  574. os_memset(&params, 0, sizeof(params));
  575. params.addr = peer;
  576. params.aid = aid;
  577. params.capability = capability;
  578. params.flags = WPA_STA_TDLS_PEER | WPA_STA_AUTHORIZED;
  579. /*
  580. * Don't rely only on qosinfo for WMM capability. It may be 0 even when
  581. * present. Allow the WMM IE to also indicate QoS support.
  582. */
  583. if (wmm || qosinfo)
  584. params.flags |= WPA_STA_WMM;
  585. params.ht_capabilities = ht_capab;
  586. params.vht_capabilities = vht_capab;
  587. params.qosinfo = qosinfo;
  588. params.listen_interval = 0;
  589. params.supp_rates = supp_rates;
  590. params.supp_rates_len = supp_rates_len;
  591. params.set = !add;
  592. params.ext_capab = ext_capab;
  593. params.ext_capab_len = ext_capab_len;
  594. params.supp_channels = supp_channels;
  595. params.supp_channels_len = supp_channels_len;
  596. params.supp_oper_classes = supp_oper_classes;
  597. params.supp_oper_classes_len = supp_oper_classes_len;
  598. return wpa_drv_sta_add(wpa_s, &params);
  599. }
  600. static int wpa_supplicant_tdls_enable_channel_switch(
  601. void *ctx, const u8 *addr, u8 oper_class,
  602. const struct hostapd_freq_params *params)
  603. {
  604. struct wpa_supplicant *wpa_s = ctx;
  605. return wpa_drv_tdls_enable_channel_switch(wpa_s, addr, oper_class,
  606. params);
  607. }
  608. static int wpa_supplicant_tdls_disable_channel_switch(void *ctx, const u8 *addr)
  609. {
  610. struct wpa_supplicant *wpa_s = ctx;
  611. return wpa_drv_tdls_disable_channel_switch(wpa_s, addr);
  612. }
  613. #endif /* CONFIG_TDLS */
  614. #endif /* CONFIG_NO_WPA */
  615. enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field)
  616. {
  617. if (os_strcmp(field, "IDENTITY") == 0)
  618. return WPA_CTRL_REQ_EAP_IDENTITY;
  619. else if (os_strcmp(field, "PASSWORD") == 0)
  620. return WPA_CTRL_REQ_EAP_PASSWORD;
  621. else if (os_strcmp(field, "NEW_PASSWORD") == 0)
  622. return WPA_CTRL_REQ_EAP_NEW_PASSWORD;
  623. else if (os_strcmp(field, "PIN") == 0)
  624. return WPA_CTRL_REQ_EAP_PIN;
  625. else if (os_strcmp(field, "OTP") == 0)
  626. return WPA_CTRL_REQ_EAP_OTP;
  627. else if (os_strcmp(field, "PASSPHRASE") == 0)
  628. return WPA_CTRL_REQ_EAP_PASSPHRASE;
  629. else if (os_strcmp(field, "SIM") == 0)
  630. return WPA_CTRL_REQ_SIM;
  631. else if (os_strcmp(field, "PSK_PASSPHRASE") == 0)
  632. return WPA_CTRL_REQ_PSK_PASSPHRASE;
  633. else if (os_strcmp(field, "EXT_CERT_CHECK") == 0)
  634. return WPA_CTRL_REQ_EXT_CERT_CHECK;
  635. return WPA_CTRL_REQ_UNKNOWN;
  636. }
  637. const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
  638. const char *default_txt,
  639. const char **txt)
  640. {
  641. const char *ret = NULL;
  642. *txt = default_txt;
  643. switch (field) {
  644. case WPA_CTRL_REQ_EAP_IDENTITY:
  645. *txt = "Identity";
  646. ret = "IDENTITY";
  647. break;
  648. case WPA_CTRL_REQ_EAP_PASSWORD:
  649. *txt = "Password";
  650. ret = "PASSWORD";
  651. break;
  652. case WPA_CTRL_REQ_EAP_NEW_PASSWORD:
  653. *txt = "New Password";
  654. ret = "NEW_PASSWORD";
  655. break;
  656. case WPA_CTRL_REQ_EAP_PIN:
  657. *txt = "PIN";
  658. ret = "PIN";
  659. break;
  660. case WPA_CTRL_REQ_EAP_OTP:
  661. ret = "OTP";
  662. break;
  663. case WPA_CTRL_REQ_EAP_PASSPHRASE:
  664. *txt = "Private key passphrase";
  665. ret = "PASSPHRASE";
  666. break;
  667. case WPA_CTRL_REQ_SIM:
  668. ret = "SIM";
  669. break;
  670. case WPA_CTRL_REQ_PSK_PASSPHRASE:
  671. *txt = "PSK or passphrase";
  672. ret = "PSK_PASSPHRASE";
  673. break;
  674. case WPA_CTRL_REQ_EXT_CERT_CHECK:
  675. *txt = "External server certificate validation";
  676. ret = "EXT_CERT_CHECK";
  677. break;
  678. default:
  679. break;
  680. }
  681. /* txt needs to be something */
  682. if (*txt == NULL) {
  683. wpa_printf(MSG_WARNING, "No message for request %d", field);
  684. ret = NULL;
  685. }
  686. return ret;
  687. }
  688. void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
  689. const char *field_name, const char *txt)
  690. {
  691. char *buf;
  692. size_t buflen;
  693. int len;
  694. buflen = 100 + os_strlen(txt) + ssid->ssid_len;
  695. buf = os_malloc(buflen);
  696. if (buf == NULL)
  697. return;
  698. len = os_snprintf(buf, buflen, "%s-%d:%s needed for SSID ",
  699. field_name, ssid->id, txt);
  700. if (os_snprintf_error(buflen, len)) {
  701. os_free(buf);
  702. return;
  703. }
  704. if (ssid->ssid && buflen > len + ssid->ssid_len) {
  705. os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
  706. len += ssid->ssid_len;
  707. buf[len] = '\0';
  708. }
  709. buf[buflen - 1] = '\0';
  710. wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s", buf);
  711. os_free(buf);
  712. }
  713. #ifdef IEEE8021X_EAPOL
  714. #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
  715. static void wpa_supplicant_eap_param_needed(void *ctx,
  716. enum wpa_ctrl_req_type field,
  717. const char *default_txt)
  718. {
  719. struct wpa_supplicant *wpa_s = ctx;
  720. struct wpa_ssid *ssid = wpa_s->current_ssid;
  721. const char *field_name, *txt = NULL;
  722. if (ssid == NULL)
  723. return;
  724. if (field == WPA_CTRL_REQ_EXT_CERT_CHECK)
  725. ssid->eap.pending_ext_cert_check = PENDING_CHECK;
  726. wpas_notify_network_request(wpa_s, ssid, field, default_txt);
  727. field_name = wpa_supplicant_ctrl_req_to_string(field, default_txt,
  728. &txt);
  729. if (field_name == NULL) {
  730. wpa_printf(MSG_WARNING, "Unhandled EAP param %d needed",
  731. field);
  732. return;
  733. }
  734. wpas_notify_eap_status(wpa_s, "eap parameter needed", field_name);
  735. wpas_send_ctrl_req(wpa_s, ssid, field_name, txt);
  736. }
  737. #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
  738. #define wpa_supplicant_eap_param_needed NULL
  739. #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
  740. #ifdef CONFIG_EAP_PROXY
  741. static void wpa_supplicant_eap_proxy_cb(void *ctx)
  742. {
  743. struct wpa_supplicant *wpa_s = ctx;
  744. size_t len;
  745. wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol,
  746. wpa_s->imsi, &len);
  747. if (wpa_s->mnc_len > 0) {
  748. wpa_s->imsi[len] = '\0';
  749. wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)",
  750. wpa_s->imsi, wpa_s->mnc_len);
  751. } else {
  752. wpa_printf(MSG_DEBUG, "eap_proxy: IMSI not available");
  753. }
  754. }
  755. #endif /* CONFIG_EAP_PROXY */
  756. static void wpa_supplicant_port_cb(void *ctx, int authorized)
  757. {
  758. struct wpa_supplicant *wpa_s = ctx;
  759. #ifdef CONFIG_AP
  760. if (wpa_s->ap_iface) {
  761. wpa_printf(MSG_DEBUG, "AP mode active - skip EAPOL Supplicant "
  762. "port status: %s",
  763. authorized ? "Authorized" : "Unauthorized");
  764. return;
  765. }
  766. #endif /* CONFIG_AP */
  767. wpa_printf(MSG_DEBUG, "EAPOL: Supplicant port status: %s",
  768. authorized ? "Authorized" : "Unauthorized");
  769. wpa_drv_set_supp_port(wpa_s, authorized);
  770. }
  771. static void wpa_supplicant_cert_cb(void *ctx, int depth, const char *subject,
  772. const char *altsubject[], int num_altsubject,
  773. const char *cert_hash,
  774. const struct wpabuf *cert)
  775. {
  776. struct wpa_supplicant *wpa_s = ctx;
  777. wpas_notify_certification(wpa_s, depth, subject, altsubject,
  778. num_altsubject, cert_hash, cert);
  779. }
  780. static void wpa_supplicant_status_cb(void *ctx, const char *status,
  781. const char *parameter)
  782. {
  783. struct wpa_supplicant *wpa_s = ctx;
  784. wpas_notify_eap_status(wpa_s, status, parameter);
  785. }
  786. static void wpa_supplicant_set_anon_id(void *ctx, const u8 *id, size_t len)
  787. {
  788. struct wpa_supplicant *wpa_s = ctx;
  789. char *str;
  790. int res;
  791. wpa_hexdump_ascii(MSG_DEBUG, "EAP method updated anonymous_identity",
  792. id, len);
  793. if (wpa_s->current_ssid == NULL)
  794. return;
  795. if (id == NULL) {
  796. if (wpa_config_set(wpa_s->current_ssid, "anonymous_identity",
  797. "NULL", 0) < 0)
  798. return;
  799. } else {
  800. str = os_malloc(len * 2 + 1);
  801. if (str == NULL)
  802. return;
  803. wpa_snprintf_hex(str, len * 2 + 1, id, len);
  804. res = wpa_config_set(wpa_s->current_ssid, "anonymous_identity",
  805. str, 0);
  806. os_free(str);
  807. if (res < 0)
  808. return;
  809. }
  810. if (wpa_s->conf->update_config) {
  811. res = wpa_config_write(wpa_s->confname, wpa_s->conf);
  812. if (res) {
  813. wpa_printf(MSG_DEBUG, "Failed to update config after "
  814. "anonymous_id update");
  815. }
  816. }
  817. }
  818. #endif /* IEEE8021X_EAPOL */
  819. int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
  820. {
  821. #ifdef IEEE8021X_EAPOL
  822. struct eapol_ctx *ctx;
  823. ctx = os_zalloc(sizeof(*ctx));
  824. if (ctx == NULL) {
  825. wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
  826. return -1;
  827. }
  828. ctx->ctx = wpa_s;
  829. ctx->msg_ctx = wpa_s;
  830. ctx->eapol_send_ctx = wpa_s;
  831. ctx->preauth = 0;
  832. ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
  833. ctx->eapol_send = wpa_supplicant_eapol_send;
  834. ctx->set_wep_key = wpa_eapol_set_wep_key;
  835. #ifndef CONFIG_NO_CONFIG_BLOBS
  836. ctx->set_config_blob = wpa_supplicant_set_config_blob;
  837. ctx->get_config_blob = wpa_supplicant_get_config_blob;
  838. #endif /* CONFIG_NO_CONFIG_BLOBS */
  839. ctx->aborted_cached = wpa_supplicant_aborted_cached;
  840. ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
  841. ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
  842. ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
  843. ctx->openssl_ciphers = wpa_s->conf->openssl_ciphers;
  844. ctx->wps = wpa_s->wps;
  845. ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
  846. #ifdef CONFIG_EAP_PROXY
  847. ctx->eap_proxy_cb = wpa_supplicant_eap_proxy_cb;
  848. #endif /* CONFIG_EAP_PROXY */
  849. ctx->port_cb = wpa_supplicant_port_cb;
  850. ctx->cb = wpa_supplicant_eapol_cb;
  851. ctx->cert_cb = wpa_supplicant_cert_cb;
  852. ctx->cert_in_cb = wpa_s->conf->cert_in_cb;
  853. ctx->status_cb = wpa_supplicant_status_cb;
  854. ctx->set_anon_id = wpa_supplicant_set_anon_id;
  855. ctx->cb_ctx = wpa_s;
  856. wpa_s->eapol = eapol_sm_init(ctx);
  857. if (wpa_s->eapol == NULL) {
  858. os_free(ctx);
  859. wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
  860. "machines.");
  861. return -1;
  862. }
  863. #endif /* IEEE8021X_EAPOL */
  864. return 0;
  865. }
  866. #ifndef CONFIG_NO_WPA
  867. static void wpa_supplicant_set_rekey_offload(void *ctx,
  868. const u8 *kek, size_t kek_len,
  869. const u8 *kck, size_t kck_len,
  870. const u8 *replay_ctr)
  871. {
  872. struct wpa_supplicant *wpa_s = ctx;
  873. wpa_drv_set_rekey_info(wpa_s, kek, kek_len, kck, kck_len, replay_ctr);
  874. }
  875. static int wpa_supplicant_key_mgmt_set_pmk(void *ctx, const u8 *pmk,
  876. size_t pmk_len)
  877. {
  878. struct wpa_supplicant *wpa_s = ctx;
  879. if (wpa_s->conf->key_mgmt_offload &&
  880. (wpa_s->drv_flags & WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD))
  881. return wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0,
  882. NULL, 0, pmk, pmk_len);
  883. else
  884. return 0;
  885. }
  886. #endif /* CONFIG_NO_WPA */
  887. int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
  888. {
  889. #ifndef CONFIG_NO_WPA
  890. struct wpa_sm_ctx *ctx;
  891. ctx = os_zalloc(sizeof(*ctx));
  892. if (ctx == NULL) {
  893. wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
  894. return -1;
  895. }
  896. ctx->ctx = wpa_s;
  897. ctx->msg_ctx = wpa_s;
  898. ctx->set_state = _wpa_supplicant_set_state;
  899. ctx->get_state = _wpa_supplicant_get_state;
  900. ctx->deauthenticate = _wpa_supplicant_deauthenticate;
  901. ctx->set_key = wpa_supplicant_set_key;
  902. ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
  903. ctx->get_bssid = wpa_supplicant_get_bssid;
  904. ctx->ether_send = _wpa_ether_send;
  905. ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
  906. ctx->alloc_eapol = _wpa_alloc_eapol;
  907. ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
  908. ctx->add_pmkid = wpa_supplicant_add_pmkid;
  909. ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
  910. #ifndef CONFIG_NO_CONFIG_BLOBS
  911. ctx->set_config_blob = wpa_supplicant_set_config_blob;
  912. ctx->get_config_blob = wpa_supplicant_get_config_blob;
  913. #endif /* CONFIG_NO_CONFIG_BLOBS */
  914. ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
  915. #ifdef CONFIG_IEEE80211R
  916. ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
  917. ctx->send_ft_action = wpa_supplicant_send_ft_action;
  918. ctx->mark_authenticated = wpa_supplicant_mark_authenticated;
  919. #endif /* CONFIG_IEEE80211R */
  920. #ifdef CONFIG_TDLS
  921. ctx->tdls_get_capa = wpa_supplicant_tdls_get_capa;
  922. ctx->send_tdls_mgmt = wpa_supplicant_send_tdls_mgmt;
  923. ctx->tdls_oper = wpa_supplicant_tdls_oper;
  924. ctx->tdls_peer_addset = wpa_supplicant_tdls_peer_addset;
  925. ctx->tdls_enable_channel_switch =
  926. wpa_supplicant_tdls_enable_channel_switch;
  927. ctx->tdls_disable_channel_switch =
  928. wpa_supplicant_tdls_disable_channel_switch;
  929. #endif /* CONFIG_TDLS */
  930. ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload;
  931. ctx->key_mgmt_set_pmk = wpa_supplicant_key_mgmt_set_pmk;
  932. wpa_s->wpa = wpa_sm_init(ctx);
  933. if (wpa_s->wpa == NULL) {
  934. wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
  935. "machine");
  936. os_free(ctx);
  937. return -1;
  938. }
  939. #endif /* CONFIG_NO_WPA */
  940. return 0;
  941. }
  942. void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
  943. struct wpa_ssid *ssid)
  944. {
  945. struct rsn_supp_config conf;
  946. if (ssid) {
  947. os_memset(&conf, 0, sizeof(conf));
  948. conf.network_ctx = ssid;
  949. conf.peerkey_enabled = ssid->peerkey;
  950. conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
  951. #ifdef IEEE8021X_EAPOL
  952. conf.proactive_key_caching = ssid->proactive_key_caching < 0 ?
  953. wpa_s->conf->okc : ssid->proactive_key_caching;
  954. conf.eap_workaround = ssid->eap_workaround;
  955. conf.eap_conf_ctx = &ssid->eap;
  956. #endif /* IEEE8021X_EAPOL */
  957. conf.ssid = ssid->ssid;
  958. conf.ssid_len = ssid->ssid_len;
  959. conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
  960. #ifdef CONFIG_P2P
  961. if (ssid->p2p_group && wpa_s->current_bss &&
  962. !wpa_s->p2p_disable_ip_addr_req) {
  963. struct wpabuf *p2p;
  964. p2p = wpa_bss_get_vendor_ie_multi(wpa_s->current_bss,
  965. P2P_IE_VENDOR_TYPE);
  966. if (p2p) {
  967. u8 group_capab;
  968. group_capab = p2p_get_group_capab(p2p);
  969. if (group_capab &
  970. P2P_GROUP_CAPAB_IP_ADDR_ALLOCATION)
  971. conf.p2p = 1;
  972. wpabuf_free(p2p);
  973. }
  974. }
  975. #endif /* CONFIG_P2P */
  976. conf.wpa_rsc_relaxation = wpa_s->conf->wpa_rsc_relaxation;
  977. }
  978. wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);
  979. }