revert between 56095 -> 55830 in arch
[AROS.git] / workbench / network / WirelessManager / wpa_supplicant / wpas_glue.c
blob347d0304e2bfb54a21ad318803cb4f26026a1147
1 /*
2 * WPA Supplicant - Glue code to setup EAPOL and RSN modules
3 * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
12 * See README and COPYING for more details.
15 #include "includes.h"
17 #include "common.h"
18 #include "eapol_supp/eapol_supp_sm.h"
19 #include "rsn_supp/wpa.h"
20 #include "eloop.h"
21 #include "config.h"
22 #include "l2_packet/l2_packet.h"
23 #include "common/wpa_common.h"
24 #include "wpa_supplicant_i.h"
25 #include "driver_i.h"
26 #include "rsn_supp/pmksa_cache.h"
27 #include "mlme.h"
28 #include "sme.h"
29 #include "common/ieee802_11_defs.h"
30 #include "common/wpa_ctrl.h"
31 #include "wpas_glue.h"
32 #include "wps_supplicant.h"
33 #include "bss.h"
34 #include "scan.h"
37 #ifndef CONFIG_NO_CONFIG_BLOBS
38 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
39 static void wpa_supplicant_set_config_blob(void *ctx,
40 struct wpa_config_blob *blob)
42 struct wpa_supplicant *wpa_s = ctx;
43 wpa_config_set_blob(wpa_s->conf, blob);
44 if (wpa_s->conf->update_config) {
45 int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
46 if (ret) {
47 wpa_printf(MSG_DEBUG, "Failed to update config after "
48 "blob set");
54 static const struct wpa_config_blob *
55 wpa_supplicant_get_config_blob(void *ctx, const char *name)
57 struct wpa_supplicant *wpa_s = ctx;
58 return wpa_config_get_blob(wpa_s->conf, name);
60 #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
61 #endif /* CONFIG_NO_CONFIG_BLOBS */
64 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
65 static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
66 const void *data, u16 data_len,
67 size_t *msg_len, void **data_pos)
69 struct ieee802_1x_hdr *hdr;
71 *msg_len = sizeof(*hdr) + data_len;
72 hdr = os_malloc(*msg_len);
73 if (hdr == NULL)
74 return NULL;
76 hdr->version = wpa_s->conf->eapol_version;
77 hdr->type = type;
78 hdr->length = host_to_be16(data_len);
80 if (data)
81 os_memcpy(hdr + 1, data, data_len);
82 else
83 os_memset(hdr + 1, 0, data_len);
85 if (data_pos)
86 *data_pos = hdr + 1;
88 return (u8 *) hdr;
92 /**
93 * wpa_ether_send - Send Ethernet frame
94 * @wpa_s: Pointer to wpa_supplicant data
95 * @dest: Destination MAC address
96 * @proto: Ethertype in host byte order
97 * @buf: Frame payload starting from IEEE 802.1X header
98 * @len: Frame payload length
99 * Returns: >=0 on success, <0 on failure
101 static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
102 u16 proto, const u8 *buf, size_t len)
104 if (wpa_s->l2) {
105 return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
108 return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
110 #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
113 #ifdef IEEE8021X_EAPOL
116 * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
117 * @ctx: Pointer to wpa_supplicant data (wpa_s)
118 * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
119 * @buf: EAPOL payload (after IEEE 802.1X header)
120 * @len: EAPOL payload length
121 * Returns: >=0 on success, <0 on failure
123 * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
124 * to the current Authenticator.
126 static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
127 size_t len)
129 struct wpa_supplicant *wpa_s = ctx;
130 u8 *msg, *dst, bssid[ETH_ALEN];
131 size_t msglen;
132 int res;
134 /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
135 * extra copy here */
137 #if 0
138 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
139 wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
140 /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
141 * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
142 * machines. */
143 wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
144 "mode (type=%d len=%lu)", type,
145 (unsigned long) len);
146 return -1;
148 #endif
150 if (pmksa_cache_get_current(wpa_s->wpa) &&
151 type == IEEE802_1X_TYPE_EAPOL_START) {
152 /* Trying to use PMKSA caching - do not send EAPOL-Start frames
153 * since they will trigger full EAPOL authentication. */
154 wpa_printf(MSG_DEBUG, "RSN: PMKSA caching - do not send "
155 "EAPOL-Start");
156 return -1;
159 if (is_zero_ether_addr(wpa_s->bssid)) {
160 wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
161 "EAPOL frame");
162 if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
163 !is_zero_ether_addr(bssid)) {
164 dst = bssid;
165 wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
166 " from the driver as the EAPOL destination",
167 MAC2STR(dst));
168 } else {
169 dst = wpa_s->last_eapol_src;
170 wpa_printf(MSG_DEBUG, "Using the source address of the"
171 " last received EAPOL frame " MACSTR " as "
172 "the EAPOL destination",
173 MAC2STR(dst));
175 } else {
176 /* BSSID was already set (from (Re)Assoc event, so use it as
177 * the EAPOL destination. */
178 dst = wpa_s->bssid;
181 msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
182 if (msg == NULL)
183 return -1;
185 wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
186 wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
187 res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
188 os_free(msg);
189 return res;
194 * wpa_eapol_set_wep_key - set WEP key for the driver
195 * @ctx: Pointer to wpa_supplicant data (wpa_s)
196 * @unicast: 1 = individual unicast key, 0 = broadcast key
197 * @keyidx: WEP key index (0..3)
198 * @key: Pointer to key data
199 * @keylen: Key length in bytes
200 * Returns: 0 on success or < 0 on error.
202 static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
203 const u8 *key, size_t keylen)
205 struct wpa_supplicant *wpa_s = ctx;
206 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
207 int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
208 WPA_CIPHER_WEP104;
209 if (unicast)
210 wpa_s->pairwise_cipher = cipher;
211 else
212 wpa_s->group_cipher = cipher;
214 return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
215 unicast ? wpa_s->bssid :
216 (u8 *) "\xff\xff\xff\xff\xff\xff",
217 keyidx, unicast, (u8 *) "", 0, key, keylen);
221 static void wpa_supplicant_aborted_cached(void *ctx)
223 struct wpa_supplicant *wpa_s = ctx;
224 wpa_sm_aborted_cached(wpa_s->wpa);
228 static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, int success,
229 void *ctx)
231 struct wpa_supplicant *wpa_s = ctx;
232 int res, pmk_len;
233 u8 pmk[PMK_LEN];
235 wpa_printf(MSG_DEBUG, "EAPOL authentication completed %ssuccessfully",
236 success ? "" : "un");
238 if (wpas_wps_eapol_cb(wpa_s) > 0)
239 return;
241 if (!success) {
243 * Make sure we do not get stuck here waiting for long EAPOL
244 * timeout if the AP does not disconnect in case of
245 * authentication failure.
247 wpa_supplicant_req_auth_timeout(wpa_s, 2, 0);
250 if (!success || !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
251 return;
253 if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
254 return;
256 wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
257 "handshake");
259 pmk_len = PMK_LEN;
260 res = eapol_sm_get_key(eapol, pmk, PMK_LEN);
261 if (res) {
263 * EAP-LEAP is an exception from other EAP methods: it
264 * uses only 16-byte PMK.
266 res = eapol_sm_get_key(eapol, pmk, 16);
267 pmk_len = 16;
270 if (res) {
271 wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
272 "machines");
273 return;
276 if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
277 pmk_len)) {
278 wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
281 wpa_supplicant_cancel_scan(wpa_s);
282 wpa_supplicant_cancel_auth_timeout(wpa_s);
283 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
288 static void wpa_supplicant_notify_eapol_done(void *ctx)
290 struct wpa_supplicant *wpa_s = ctx;
291 wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
292 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
293 wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
294 } else {
295 wpa_supplicant_cancel_auth_timeout(wpa_s);
296 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
300 #endif /* IEEE8021X_EAPOL */
303 #ifndef CONFIG_NO_WPA
305 static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
307 int ret = 0;
308 struct wpa_bss *curr = NULL, *bss;
309 struct wpa_ssid *ssid = wpa_s->current_ssid;
310 const u8 *ie;
312 dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
313 if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) != 0)
314 continue;
315 if (ssid == NULL ||
316 ((bss->ssid_len == ssid->ssid_len &&
317 os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) ||
318 ssid->ssid_len == 0)) {
319 curr = bss;
320 break;
324 if (curr) {
325 ie = wpa_bss_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
326 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
327 ret = -1;
329 ie = wpa_bss_get_ie(curr, WLAN_EID_RSN);
330 if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
331 ret = -1;
332 } else {
333 ret = -1;
336 return ret;
340 static int wpa_supplicant_get_beacon_ie(void *ctx)
342 struct wpa_supplicant *wpa_s = ctx;
343 if (wpa_get_beacon_ie(wpa_s) == 0) {
344 return 0;
347 /* No WPA/RSN IE found in the cached scan results. Try to get updated
348 * scan results from the driver. */
349 if (wpa_supplicant_update_scan_results(wpa_s) < 0)
350 return -1;
352 return wpa_get_beacon_ie(wpa_s);
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)
360 return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
364 static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
365 const u8 *buf, size_t len)
367 return wpa_ether_send(wpa_s, dest, proto, buf, len);
371 static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
373 wpa_supplicant_cancel_auth_timeout(wpa_s);
377 static void _wpa_supplicant_set_state(void *wpa_s, enum wpa_states state)
379 wpa_supplicant_set_state(wpa_s, state);
384 * wpa_supplicant_get_state - Get the connection state
385 * @wpa_s: Pointer to wpa_supplicant data
386 * Returns: The current connection state (WPA_*)
388 static enum wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
390 return wpa_s->wpa_state;
394 static enum wpa_states _wpa_supplicant_get_state(void *wpa_s)
396 return wpa_supplicant_get_state(wpa_s);
400 static void _wpa_supplicant_disassociate(void *wpa_s, int reason_code)
402 wpa_supplicant_disassociate(wpa_s, reason_code);
403 /* Schedule a scan to make sure we continue looking for networks */
404 wpa_supplicant_req_scan(wpa_s, 5, 0);
408 static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
410 wpa_supplicant_deauthenticate(wpa_s, reason_code);
411 /* Schedule a scan to make sure we continue looking for networks */
412 wpa_supplicant_req_scan(wpa_s, 5, 0);
416 static void * wpa_supplicant_get_network_ctx(void *wpa_s)
418 return wpa_supplicant_get_ssid(wpa_s);
422 static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
424 struct wpa_supplicant *wpa_s = ctx;
425 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME) {
426 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
427 return 0;
429 return wpa_drv_get_bssid(wpa_s, bssid);
433 static int wpa_supplicant_set_key(void *_wpa_s, enum wpa_alg alg,
434 const u8 *addr, int key_idx, int set_tx,
435 const u8 *seq, size_t seq_len,
436 const u8 *key, size_t key_len)
438 struct wpa_supplicant *wpa_s = _wpa_s;
439 if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
440 /* Clear the MIC error counter when setting a new PTK. */
441 wpa_s->mic_errors_seen = 0;
443 return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
444 key, key_len);
448 static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
449 int protection_type,
450 int key_type)
452 return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
453 key_type);
457 static int wpa_supplicant_add_pmkid(void *wpa_s,
458 const u8 *bssid, const u8 *pmkid)
460 return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
464 static int wpa_supplicant_remove_pmkid(void *wpa_s,
465 const u8 *bssid, const u8 *pmkid)
467 return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
471 #ifdef CONFIG_IEEE80211R
472 static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
473 const u8 *ies, size_t ies_len)
475 struct wpa_supplicant *wpa_s = ctx;
476 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
477 return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
478 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
479 return sme_update_ft_ies(wpa_s, md, ies, ies_len);
480 return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
484 static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
485 const u8 *target_ap,
486 const u8 *ies, size_t ies_len)
488 struct wpa_supplicant *wpa_s = ctx;
489 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
490 return ieee80211_sta_send_ft_action(wpa_s, action, target_ap,
491 ies, ies_len);
492 return wpa_drv_send_ft_action(wpa_s, action, target_ap, ies, ies_len);
496 static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap)
498 struct wpa_supplicant *wpa_s = ctx;
499 struct wpa_driver_auth_params params;
500 struct wpa_bss *bss;
502 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_USER_SPACE_MLME)
503 return -1;
505 bss = wpa_bss_get_bssid(wpa_s, target_ap);
506 if (bss == NULL)
507 return -1;
509 os_memset(&params, 0, sizeof(params));
510 params.bssid = target_ap;
511 params.freq = bss->freq;
512 params.ssid = bss->ssid;
513 params.ssid_len = bss->ssid_len;
514 params.auth_alg = WPA_AUTH_ALG_FT;
515 params.local_state_change = 1;
516 return wpa_drv_authenticate(wpa_s, &params);
518 #endif /* CONFIG_IEEE80211R */
520 #endif /* CONFIG_NO_WPA */
523 #ifdef IEEE8021X_EAPOL
524 #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
525 static void wpa_supplicant_eap_param_needed(void *ctx, const char *field,
526 const char *txt)
528 struct wpa_supplicant *wpa_s = ctx;
529 struct wpa_ssid *ssid = wpa_s->current_ssid;
530 char *buf;
531 size_t buflen;
532 int len;
534 if (ssid == NULL)
535 return;
537 buflen = 100 + os_strlen(txt) + ssid->ssid_len;
538 buf = os_malloc(buflen);
539 if (buf == NULL)
540 return;
541 len = os_snprintf(buf, buflen,
542 WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
543 field, ssid->id, txt);
544 if (len < 0 || (size_t) len >= buflen) {
545 os_free(buf);
546 return;
548 if (ssid->ssid && buflen > len + ssid->ssid_len) {
549 os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
550 len += ssid->ssid_len;
551 buf[len] = '\0';
553 buf[buflen - 1] = '\0';
554 wpa_msg(wpa_s, MSG_INFO, "%s", buf);
555 os_free(buf);
557 #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
558 #define wpa_supplicant_eap_param_needed NULL
559 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
562 static void wpa_supplicant_port_cb(void *ctx, int authorized)
564 struct wpa_supplicant *wpa_s = ctx;
565 #ifdef CONFIG_AP
566 if (wpa_s->ap_iface) {
567 wpa_printf(MSG_DEBUG, "AP mode active - skip EAPOL Supplicant "
568 "port status: %s",
569 authorized ? "Authorized" : "Unauthorized");
570 return;
572 #endif /* CONFIG_AP */
573 wpa_printf(MSG_DEBUG, "EAPOL: Supplicant port status: %s",
574 authorized ? "Authorized" : "Unauthorized");
575 wpa_drv_set_supp_port(wpa_s, authorized);
577 #endif /* IEEE8021X_EAPOL */
580 int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
582 #ifdef IEEE8021X_EAPOL
583 struct eapol_ctx *ctx;
584 ctx = os_zalloc(sizeof(*ctx));
585 if (ctx == NULL) {
586 wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
587 return -1;
590 ctx->ctx = wpa_s;
591 ctx->msg_ctx = wpa_s;
592 ctx->eapol_send_ctx = wpa_s;
593 ctx->preauth = 0;
594 ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
595 ctx->eapol_send = wpa_supplicant_eapol_send;
596 ctx->set_wep_key = wpa_eapol_set_wep_key;
597 #ifndef CONFIG_NO_CONFIG_BLOBS
598 ctx->set_config_blob = wpa_supplicant_set_config_blob;
599 ctx->get_config_blob = wpa_supplicant_get_config_blob;
600 #endif /* CONFIG_NO_CONFIG_BLOBS */
601 ctx->aborted_cached = wpa_supplicant_aborted_cached;
602 ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
603 ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
604 ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
605 ctx->wps = wpa_s->wps;
606 ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
607 ctx->port_cb = wpa_supplicant_port_cb;
608 ctx->cb = wpa_supplicant_eapol_cb;
609 ctx->cb_ctx = wpa_s;
610 wpa_s->eapol = eapol_sm_init(ctx);
611 if (wpa_s->eapol == NULL) {
612 os_free(ctx);
613 wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
614 "machines.");
615 return -1;
617 #endif /* IEEE8021X_EAPOL */
619 return 0;
623 int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
625 #ifndef CONFIG_NO_WPA
626 struct wpa_sm_ctx *ctx;
627 ctx = os_zalloc(sizeof(*ctx));
628 if (ctx == NULL) {
629 wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
630 return -1;
633 ctx->ctx = wpa_s;
634 ctx->msg_ctx = wpa_s;
635 ctx->set_state = _wpa_supplicant_set_state;
636 ctx->get_state = _wpa_supplicant_get_state;
637 ctx->deauthenticate = _wpa_supplicant_deauthenticate;
638 ctx->disassociate = _wpa_supplicant_disassociate;
639 ctx->set_key = wpa_supplicant_set_key;
640 ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
641 ctx->get_bssid = wpa_supplicant_get_bssid;
642 ctx->ether_send = _wpa_ether_send;
643 ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
644 ctx->alloc_eapol = _wpa_alloc_eapol;
645 ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
646 ctx->add_pmkid = wpa_supplicant_add_pmkid;
647 ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
648 #ifndef CONFIG_NO_CONFIG_BLOBS
649 ctx->set_config_blob = wpa_supplicant_set_config_blob;
650 ctx->get_config_blob = wpa_supplicant_get_config_blob;
651 #endif /* CONFIG_NO_CONFIG_BLOBS */
652 ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
653 #ifdef CONFIG_IEEE80211R
654 ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
655 ctx->send_ft_action = wpa_supplicant_send_ft_action;
656 ctx->mark_authenticated = wpa_supplicant_mark_authenticated;
657 #endif /* CONFIG_IEEE80211R */
659 wpa_s->wpa = wpa_sm_init(ctx);
660 if (wpa_s->wpa == NULL) {
661 wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
662 "machine");
663 return -1;
665 #endif /* CONFIG_NO_WPA */
667 return 0;
671 void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
672 struct wpa_ssid *ssid)
674 struct rsn_supp_config conf;
675 if (ssid) {
676 os_memset(&conf, 0, sizeof(conf));
677 conf.network_ctx = ssid;
678 conf.peerkey_enabled = ssid->peerkey;
679 conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
680 #ifdef IEEE8021X_EAPOL
681 conf.eap_workaround = ssid->eap_workaround;
682 conf.eap_conf_ctx = &ssid->eap;
683 #endif /* IEEE8021X_EAPOL */
684 conf.ssid = ssid->ssid;
685 conf.ssid_len = ssid->ssid_len;
686 conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
688 wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);