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
12 * See README and COPYING for more details.
18 #include "eapol_supp/eapol_supp_sm.h"
22 #include "l2_packet/l2_packet.h"
23 #include "wpa_common.h"
24 #include "wpa_supplicant_i.h"
25 #include "pmksa_cache.h"
27 #include "ieee802_11_defs.h"
29 #include "wps/wps_defs.h"
31 #include "wpas_glue.h"
34 #ifndef CONFIG_NO_CONFIG_BLOBS
35 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
36 static void wpa_supplicant_set_config_blob(void *ctx,
37 struct wpa_config_blob *blob)
39 struct wpa_supplicant *wpa_s = ctx;
40 wpa_config_set_blob(wpa_s->conf, blob);
41 if (wpa_s->conf->update_config) {
42 int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
44 wpa_printf(MSG_DEBUG, "Failed to update config after "
51 static const struct wpa_config_blob *
52 wpa_supplicant_get_config_blob(void *ctx, const char *name)
54 struct wpa_supplicant *wpa_s = ctx;
55 return wpa_config_get_blob(wpa_s->conf, name);
57 #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
58 #endif /* CONFIG_NO_CONFIG_BLOBS */
61 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
62 static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
63 const void *data, u16 data_len,
64 size_t *msg_len, void **data_pos)
66 struct ieee802_1x_hdr *hdr;
68 *msg_len = sizeof(*hdr) + data_len;
69 hdr = os_malloc(*msg_len);
73 hdr->version = wpa_s->conf->eapol_version;
75 hdr->length = host_to_be16(data_len);
78 os_memcpy(hdr + 1, data, data_len);
80 os_memset(hdr + 1, 0, data_len);
90 * wpa_ether_send - Send Ethernet frame
91 * @wpa_s: Pointer to wpa_supplicant data
92 * @dest: Destination MAC address
93 * @proto: Ethertype in host byte order
94 * @buf: Frame payload starting from IEEE 802.1X header
95 * @len: Frame payload length
96 * Returns: >=0 on success, <0 on failure
98 static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
99 u16 proto, const u8 *buf, size_t len)
102 return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
105 return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
107 #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
110 #ifdef IEEE8021X_EAPOL
113 * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
114 * @ctx: Pointer to wpa_supplicant data (wpa_s)
115 * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
116 * @buf: EAPOL payload (after IEEE 802.1X header)
117 * @len: EAPOL payload length
118 * Returns: >=0 on success, <0 on failure
120 * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
121 * to the current Authenticator.
123 static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
126 struct wpa_supplicant *wpa_s = ctx;
127 u8 *msg, *dst, bssid[ETH_ALEN];
131 /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
134 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
135 wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
136 /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
137 * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
139 wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
140 "mode (type=%d len=%lu)", type,
141 (unsigned long) len);
145 if (pmksa_cache_get_current(wpa_s->wpa) &&
146 type == IEEE802_1X_TYPE_EAPOL_START) {
147 /* Trying to use PMKSA caching - do not send EAPOL-Start frames
148 * since they will trigger full EAPOL authentication. */
149 wpa_printf(MSG_DEBUG, "RSN: PMKSA caching - do not send "
154 if (is_zero_ether_addr(wpa_s->bssid)) {
155 wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
157 if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
158 !is_zero_ether_addr(bssid)) {
160 wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
161 " from the driver as the EAPOL destination",
164 dst = wpa_s->last_eapol_src;
165 wpa_printf(MSG_DEBUG, "Using the source address of the"
166 " last received EAPOL frame " MACSTR " as "
167 "the EAPOL destination",
171 /* BSSID was already set (from (Re)Assoc event, so use it as
172 * the EAPOL destination. */
176 msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
180 wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
181 wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
182 res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
189 * wpa_eapol_set_wep_key - set WEP key for the driver
190 * @ctx: Pointer to wpa_supplicant data (wpa_s)
191 * @unicast: 1 = individual unicast key, 0 = broadcast key
192 * @keyidx: WEP key index (0..3)
193 * @key: Pointer to key data
194 * @keylen: Key length in bytes
195 * Returns: 0 on success or < 0 on error.
197 static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
198 const u8 *key, size_t keylen)
200 struct wpa_supplicant *wpa_s = ctx;
201 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
202 int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
205 wpa_s->pairwise_cipher = cipher;
207 wpa_s->group_cipher = cipher;
209 return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
210 unicast ? wpa_s->bssid :
211 (u8 *) "\xff\xff\xff\xff\xff\xff",
212 keyidx, unicast, (u8 *) "", 0, key, keylen);
216 static void wpa_supplicant_aborted_cached(void *ctx)
218 struct wpa_supplicant *wpa_s = ctx;
219 wpa_sm_aborted_cached(wpa_s->wpa);
223 static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, int success,
226 struct wpa_supplicant *wpa_s = ctx;
230 wpa_printf(MSG_DEBUG, "EAPOL authentication completed %ssuccessfully",
231 success ? "" : "un");
234 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid &&
235 !(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
236 wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
237 "try to associate with the received credential");
238 wpa_supplicant_deauthenticate(wpa_s,
239 WLAN_REASON_DEAUTH_LEAVING);
240 wpa_s->reassociate = 1;
241 wpa_supplicant_req_scan(wpa_s, 0, 0);
244 #endif /* CONFIG_WPS */
248 * Make sure we do not get stuck here waiting for long EAPOL
249 * timeout if the AP does not disconnect in case of
250 * authentication failure.
252 wpa_supplicant_req_auth_timeout(wpa_s, 2, 0);
255 if (!success || !wpa_s->driver_4way_handshake)
258 if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
261 wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
265 res = eapol_sm_get_key(eapol, pmk, PMK_LEN);
268 * EAP-LEAP is an exception from other EAP methods: it
269 * uses only 16-byte PMK.
271 res = eapol_sm_get_key(eapol, pmk, 16);
276 wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
281 if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
283 wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
286 wpa_supplicant_cancel_scan(wpa_s);
287 wpa_supplicant_cancel_auth_timeout(wpa_s);
288 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
293 static void wpa_supplicant_notify_eapol_done(void *ctx)
295 struct wpa_supplicant *wpa_s = ctx;
296 wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
297 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
298 wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
300 wpa_supplicant_cancel_auth_timeout(wpa_s);
301 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
305 #endif /* IEEE8021X_EAPOL */
308 #ifndef CONFIG_NO_WPA
310 static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
314 struct wpa_scan_res *curr = NULL;
315 struct wpa_ssid *ssid = wpa_s->current_ssid;
318 if (wpa_s->scan_res == NULL)
321 for (i = 0; i < wpa_s->scan_res->num; i++) {
322 struct wpa_scan_res *r = wpa_s->scan_res->res[i];
323 if (os_memcmp(r->bssid, wpa_s->bssid, ETH_ALEN) != 0)
325 ie = wpa_scan_get_ie(r, WLAN_EID_SSID);
327 ((ie && ie[1] == ssid->ssid_len &&
328 os_memcmp(ie + 2, ssid->ssid, ssid->ssid_len) == 0) ||
329 ssid->ssid_len == 0)) {
336 ie = wpa_scan_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
337 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
340 ie = wpa_scan_get_ie(curr, WLAN_EID_RSN);
341 if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
351 static int wpa_supplicant_get_beacon_ie(void *ctx)
353 struct wpa_supplicant *wpa_s = ctx;
354 if (wpa_get_beacon_ie(wpa_s) == 0) {
358 /* No WPA/RSN IE found in the cached scan results. Try to get updated
359 * scan results from the driver. */
360 if (wpa_supplicant_get_scan_results(wpa_s) < 0) {
364 return wpa_get_beacon_ie(wpa_s);
368 static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
369 const void *data, u16 data_len,
370 size_t *msg_len, void **data_pos)
372 return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
376 static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
377 const u8 *buf, size_t len)
379 return wpa_ether_send(wpa_s, dest, proto, buf, len);
383 static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
385 wpa_supplicant_cancel_auth_timeout(wpa_s);
389 static void _wpa_supplicant_set_state(void *wpa_s, wpa_states state)
391 wpa_supplicant_set_state(wpa_s, state);
396 * wpa_supplicant_get_state - Get the connection state
397 * @wpa_s: Pointer to wpa_supplicant data
398 * Returns: The current connection state (WPA_*)
400 static wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
402 return wpa_s->wpa_state;
406 static wpa_states _wpa_supplicant_get_state(void *wpa_s)
408 return wpa_supplicant_get_state(wpa_s);
412 static void _wpa_supplicant_disassociate(void *wpa_s, int reason_code)
414 wpa_supplicant_disassociate(wpa_s, reason_code);
415 /* Schedule a scan to make sure we continue looking for networks */
416 wpa_supplicant_req_scan(wpa_s, 0, 0);
420 static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
422 wpa_supplicant_deauthenticate(wpa_s, reason_code);
423 /* Schedule a scan to make sure we continue looking for networks */
424 wpa_supplicant_req_scan(wpa_s, 0, 0);
428 static void * wpa_supplicant_get_network_ctx(void *wpa_s)
430 return wpa_supplicant_get_ssid(wpa_s);
434 static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
436 struct wpa_supplicant *wpa_s = ctx;
437 if (wpa_s->use_client_mlme) {
438 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
441 return wpa_drv_get_bssid(wpa_s, bssid);
445 static int wpa_supplicant_set_key(void *_wpa_s, wpa_alg alg,
446 const u8 *addr, int key_idx, int set_tx,
447 const u8 *seq, size_t seq_len,
448 const u8 *key, size_t key_len)
450 struct wpa_supplicant *wpa_s = _wpa_s;
451 if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
452 /* Clear the MIC error counter when setting a new PTK. */
453 wpa_s->mic_errors_seen = 0;
455 return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
460 static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
464 return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
469 static int wpa_supplicant_add_pmkid(void *wpa_s,
470 const u8 *bssid, const u8 *pmkid)
472 return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
476 static int wpa_supplicant_remove_pmkid(void *wpa_s,
477 const u8 *bssid, const u8 *pmkid)
479 return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
483 #ifdef CONFIG_IEEE80211R
484 static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
485 const u8 *ies, size_t ies_len)
487 struct wpa_supplicant *wpa_s = ctx;
488 if (wpa_s->use_client_mlme)
489 return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
490 return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
494 static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
496 const u8 *ies, size_t ies_len)
498 struct wpa_supplicant *wpa_s = ctx;
499 if (wpa_s->use_client_mlme)
500 return ieee80211_sta_send_ft_action(wpa_s, action, target_ap,
502 return wpa_drv_send_ft_action(wpa_s, action, target_ap, ies, ies_len);
504 #endif /* CONFIG_IEEE80211R */
506 #endif /* CONFIG_NO_WPA */
510 static int wpa_supplicant_wps_cred(void *ctx, struct wps_credential *cred)
512 struct wpa_supplicant *wpa_s = ctx;
513 struct wpa_ssid *ssid = wpa_s->current_ssid;
515 wpa_msg(wpa_s, MSG_INFO, "WPS: New credential received");
517 if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
518 wpa_printf(MSG_DEBUG, "WPS: Replace WPS network block based "
519 "on the received credential");
520 os_free(ssid->eap.identity);
521 ssid->eap.identity = NULL;
522 ssid->eap.identity_len = 0;
523 os_free(ssid->eap.phase1);
524 ssid->eap.phase1 = NULL;
525 os_free(ssid->eap.eap_methods);
526 ssid->eap.eap_methods = NULL;
528 wpa_printf(MSG_DEBUG, "WPS: Create a new network based on the "
529 "received credential");
530 ssid = wpa_config_add_network(wpa_s->conf);
535 wpa_config_set_network_defaults(ssid);
538 ssid->ssid = os_malloc(cred->ssid_len);
540 os_memcpy(ssid->ssid, cred->ssid, cred->ssid_len);
541 ssid->ssid_len = cred->ssid_len;
544 switch (cred->encr_type) {
546 ssid->pairwise_cipher = ssid->group_cipher = WPA_CIPHER_NONE;
549 ssid->pairwise_cipher = ssid->group_cipher =
550 WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104;
551 if (cred->key_len > 0 && cred->key_len <= MAX_WEP_KEY_LEN &&
552 cred->key_idx < NUM_WEP_KEYS) {
553 os_memcpy(ssid->wep_key[cred->key_idx], cred->key,
555 ssid->wep_key_len[cred->key_idx] = cred->key_len;
556 ssid->wep_tx_keyidx = cred->key_idx;
560 ssid->pairwise_cipher = WPA_CIPHER_TKIP;
561 ssid->group_cipher = WPA_CIPHER_TKIP;
564 ssid->pairwise_cipher = WPA_CIPHER_CCMP;
565 ssid->group_cipher = WPA_CIPHER_CCMP | WPA_CIPHER_TKIP;
569 switch (cred->auth_type) {
571 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
572 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
575 case WPS_AUTH_SHARED:
576 ssid->auth_alg = WPA_AUTH_ALG_SHARED;
577 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
580 case WPS_AUTH_WPAPSK:
581 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
582 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
583 ssid->proto = WPA_PROTO_WPA;
586 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
587 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
588 ssid->proto = WPA_PROTO_WPA;
591 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
592 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
593 ssid->proto = WPA_PROTO_RSN;
595 case WPS_AUTH_WPA2PSK:
596 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
597 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
598 ssid->proto = WPA_PROTO_RSN;
602 if (ssid->key_mgmt == WPA_KEY_MGMT_PSK) {
603 if (cred->key_len == 2 * PMK_LEN) {
604 if (hexstr2bin((const char *) cred->key, ssid->psk,
606 wpa_printf(MSG_ERROR, "WPS: Invalid Network "
611 } else if (cred->key_len >= 8 && cred->key_len < 2 * PMK_LEN) {
612 os_free(ssid->passphrase);
613 ssid->passphrase = os_malloc(cred->key_len + 1);
614 if (ssid->passphrase == NULL)
616 os_memcpy(ssid->passphrase, cred->key, cred->key_len);
617 ssid->passphrase[cred->key_len] = '\0';
618 wpa_config_update_psk(ssid);
620 wpa_printf(MSG_ERROR, "WPS: Invalid Network Key "
622 (unsigned long) cred->key_len);
627 #ifndef CONFIG_NO_CONFIG_WRITE
628 if (wpa_s->conf->update_config &&
629 wpa_config_write(wpa_s->confname, wpa_s->conf)) {
630 wpa_printf(MSG_DEBUG, "WPS: Failed to update configuration");
633 #endif /* CONFIG_NO_CONFIG_WRITE */
637 #else /* CONFIG_WPS */
638 #define wpa_supplicant_wps_cred NULL
639 #endif /* CONFIG_WPS */
642 #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
643 static void wpa_supplicant_eap_param_needed(void *ctx, const char *field,
646 struct wpa_supplicant *wpa_s = ctx;
647 struct wpa_ssid *ssid = wpa_s->current_ssid;
655 buflen = 100 + os_strlen(txt) + ssid->ssid_len;
656 buf = os_malloc(buflen);
659 len = os_snprintf(buf, buflen,
660 WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
661 field, ssid->id, txt);
662 if (len < 0 || (size_t) len >= buflen) {
666 if (ssid->ssid && buflen > len + ssid->ssid_len) {
667 os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
668 len += ssid->ssid_len;
671 buf[buflen - 1] = '\0';
672 wpa_msg(wpa_s, MSG_INFO, "%s", buf);
675 #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
676 #define wpa_supplicant_eap_param_needed NULL
677 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
680 int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
682 #ifdef IEEE8021X_EAPOL
683 struct eapol_ctx *ctx;
684 ctx = os_zalloc(sizeof(*ctx));
686 wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
691 ctx->msg_ctx = wpa_s;
692 ctx->eapol_send_ctx = wpa_s;
694 ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
695 ctx->eapol_send = wpa_supplicant_eapol_send;
696 ctx->set_wep_key = wpa_eapol_set_wep_key;
697 ctx->set_config_blob = wpa_supplicant_set_config_blob;
698 ctx->get_config_blob = wpa_supplicant_get_config_blob;
699 ctx->aborted_cached = wpa_supplicant_aborted_cached;
700 #ifdef EAP_TLS_OPENSSL
701 ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
702 ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
703 ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
704 #endif /* EAP_TLS_OPENSSL */
705 ctx->mac_addr = wpa_s->own_addr;
706 ctx->uuid = wpa_s->conf->uuid;
707 ctx->wps_cred = wpa_supplicant_wps_cred;
708 ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
709 ctx->cb = wpa_supplicant_eapol_cb;
711 wpa_s->eapol = eapol_sm_init(ctx);
712 if (wpa_s->eapol == NULL) {
714 wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
718 #endif /* IEEE8021X_EAPOL */
724 int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
726 #ifndef CONFIG_NO_WPA
727 struct wpa_sm_ctx *ctx;
728 ctx = os_zalloc(sizeof(*ctx));
730 wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
735 ctx->set_state = _wpa_supplicant_set_state;
736 ctx->get_state = _wpa_supplicant_get_state;
737 ctx->deauthenticate = _wpa_supplicant_deauthenticate;
738 ctx->disassociate = _wpa_supplicant_disassociate;
739 ctx->set_key = wpa_supplicant_set_key;
740 ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
741 ctx->get_bssid = wpa_supplicant_get_bssid;
742 ctx->ether_send = _wpa_ether_send;
743 ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
744 ctx->alloc_eapol = _wpa_alloc_eapol;
745 ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
746 ctx->add_pmkid = wpa_supplicant_add_pmkid;
747 ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
748 #ifndef CONFIG_NO_CONFIG_BLOBS
749 ctx->set_config_blob = wpa_supplicant_set_config_blob;
750 ctx->get_config_blob = wpa_supplicant_get_config_blob;
751 #endif /* CONFIG_NO_CONFIG_BLOBS */
752 ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
753 #ifdef CONFIG_IEEE80211R
754 ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
755 ctx->send_ft_action = wpa_supplicant_send_ft_action;
756 #endif /* CONFIG_IEEE80211R */
758 wpa_s->wpa = wpa_sm_init(ctx);
759 if (wpa_s->wpa == NULL) {
760 wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
764 #endif /* CONFIG_NO_WPA */
770 void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
771 struct wpa_ssid *ssid)
773 struct rsn_supp_config conf;
775 os_memset(&conf, 0, sizeof(conf));
776 conf.network_ctx = ssid;
777 conf.peerkey_enabled = ssid->peerkey;
778 conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
779 #ifdef IEEE8021X_EAPOL
780 conf.eap_workaround = ssid->eap_workaround;
781 conf.eap_conf_ctx = &ssid->eap;
782 #endif /* IEEE8021X_EAPOL */
783 conf.ssid = ssid->ssid;
784 conf.ssid_len = ssid->ssid_len;
785 conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
787 wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);