2 * WPA Supplicant - Glue code to setup EAPOL and RSN modules
3 * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
12 #include "eapol_supp/eapol_supp_sm.h"
13 #include "rsn_supp/wpa.h"
16 #include "l2_packet/l2_packet.h"
17 #include "common/wpa_common.h"
18 #include "wpa_supplicant_i.h"
20 #include "rsn_supp/pmksa_cache.h"
22 #include "common/ieee802_11_defs.h"
23 #include "common/wpa_ctrl.h"
24 #include "wpas_glue.h"
25 #include "wps_supplicant.h"
31 #ifndef CONFIG_NO_CONFIG_BLOBS
32 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
33 static void wpa_supplicant_set_config_blob(void *ctx,
34 struct wpa_config_blob *blob)
36 struct wpa_supplicant *wpa_s = ctx;
37 wpa_config_set_blob(wpa_s->conf, blob);
38 if (wpa_s->conf->update_config) {
39 int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
41 wpa_printf(MSG_DEBUG, "Failed to update config after "
48 static const struct wpa_config_blob *
49 wpa_supplicant_get_config_blob(void *ctx, const char *name)
51 struct wpa_supplicant *wpa_s = ctx;
52 return wpa_config_get_blob(wpa_s->conf, name);
54 #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
55 #endif /* CONFIG_NO_CONFIG_BLOBS */
58 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
59 static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
60 const void *data, u16 data_len,
61 size_t *msg_len, void **data_pos)
63 struct ieee802_1x_hdr *hdr;
65 *msg_len = sizeof(*hdr) + data_len;
66 hdr = os_malloc(*msg_len);
70 hdr->version = wpa_s->conf->eapol_version;
72 hdr->length = host_to_be16(data_len);
75 os_memcpy(hdr + 1, data, data_len);
77 os_memset(hdr + 1, 0, data_len);
87 * wpa_ether_send - Send Ethernet frame
88 * @wpa_s: Pointer to wpa_supplicant data
89 * @dest: Destination MAC address
90 * @proto: Ethertype in host byte order
91 * @buf: Frame payload starting from IEEE 802.1X header
92 * @len: Frame payload length
93 * Returns: >=0 on success, <0 on failure
95 static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
96 u16 proto, const u8 *buf, size_t len)
99 return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
102 return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
104 #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
107 #ifdef IEEE8021X_EAPOL
110 * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
111 * @ctx: Pointer to wpa_supplicant data (wpa_s)
112 * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
113 * @buf: EAPOL payload (after IEEE 802.1X header)
114 * @len: EAPOL payload length
115 * Returns: >=0 on success, <0 on failure
117 * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
118 * to the current Authenticator.
120 static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
123 struct wpa_supplicant *wpa_s = ctx;
124 u8 *msg, *dst, bssid[ETH_ALEN];
128 /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
131 if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
132 wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
133 /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
134 * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
136 wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
137 "mode (type=%d len=%lu)", type,
138 (unsigned long) len);
142 if (pmksa_cache_get_current(wpa_s->wpa) &&
143 type == IEEE802_1X_TYPE_EAPOL_START) {
144 /* Trying to use PMKSA caching - do not send EAPOL-Start frames
145 * since they will trigger full EAPOL authentication. */
146 wpa_printf(MSG_DEBUG, "RSN: PMKSA caching - do not send "
151 if (is_zero_ether_addr(wpa_s->bssid)) {
152 wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
154 if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
155 !is_zero_ether_addr(bssid)) {
157 wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
158 " from the driver as the EAPOL destination",
161 dst = wpa_s->last_eapol_src;
162 wpa_printf(MSG_DEBUG, "Using the source address of the"
163 " last received EAPOL frame " MACSTR " as "
164 "the EAPOL destination",
168 /* BSSID was already set (from (Re)Assoc event, so use it as
169 * the EAPOL destination. */
173 msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
177 wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
178 wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
179 res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
186 * wpa_eapol_set_wep_key - set WEP key for the driver
187 * @ctx: Pointer to wpa_supplicant data (wpa_s)
188 * @unicast: 1 = individual unicast key, 0 = broadcast key
189 * @keyidx: WEP key index (0..3)
190 * @key: Pointer to key data
191 * @keylen: Key length in bytes
192 * Returns: 0 on success or < 0 on error.
194 static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
195 const u8 *key, size_t keylen)
197 struct wpa_supplicant *wpa_s = ctx;
198 if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
199 int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
202 wpa_s->pairwise_cipher = cipher;
204 wpa_s->group_cipher = cipher;
206 return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
207 unicast ? wpa_s->bssid : NULL,
208 keyidx, unicast, NULL, 0, key, keylen);
212 static void wpa_supplicant_aborted_cached(void *ctx)
214 struct wpa_supplicant *wpa_s = ctx;
215 wpa_sm_aborted_cached(wpa_s->wpa);
219 static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, int success,
222 struct wpa_supplicant *wpa_s = ctx;
226 wpa_printf(MSG_DEBUG, "EAPOL authentication completed %ssuccessfully",
227 success ? "" : "un");
229 if (wpas_wps_eapol_cb(wpa_s) > 0)
234 * Make sure we do not get stuck here waiting for long EAPOL
235 * timeout if the AP does not disconnect in case of
236 * authentication failure.
238 wpa_supplicant_req_auth_timeout(wpa_s, 2, 0);
241 if (!success || !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE))
244 if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
247 wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
251 if (wpa_key_mgmt_ft(wpa_s->key_mgmt)) {
252 #ifdef CONFIG_IEEE80211R
254 wpa_printf(MSG_DEBUG, "RSN: Use FT XXKey as PMK for "
255 "driver-based 4-way hs and FT");
256 res = eapol_sm_get_key(eapol, buf, 2 * PMK_LEN);
258 os_memcpy(pmk, buf + PMK_LEN, PMK_LEN);
259 os_memset(buf, 0, sizeof(buf));
261 #else /* CONFIG_IEEE80211R */
263 #endif /* CONFIG_IEEE80211R */
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);
277 wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
282 wpa_hexdump_key(MSG_DEBUG, "RSN: Configure PMK for driver-based 4-way "
283 "handshake", pmk, pmk_len);
285 if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
287 wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
290 wpa_supplicant_cancel_scan(wpa_s);
291 wpa_supplicant_cancel_auth_timeout(wpa_s);
292 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
297 static void wpa_supplicant_notify_eapol_done(void *ctx)
299 struct wpa_supplicant *wpa_s = ctx;
300 wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
301 if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
302 wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
304 wpa_supplicant_cancel_auth_timeout(wpa_s);
305 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
309 #endif /* IEEE8021X_EAPOL */
312 #ifndef CONFIG_NO_WPA
314 static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
317 struct wpa_bss *curr = NULL, *bss;
318 struct wpa_ssid *ssid = wpa_s->current_ssid;
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)
325 ((bss->ssid_len == ssid->ssid_len &&
326 os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) ||
327 ssid->ssid_len == 0)) {
334 ie = wpa_bss_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE);
335 if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
338 ie = wpa_bss_get_ie(curr, WLAN_EID_RSN);
339 if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0))
349 static int wpa_supplicant_get_beacon_ie(void *ctx)
351 struct wpa_supplicant *wpa_s = ctx;
352 if (wpa_get_beacon_ie(wpa_s) == 0) {
356 /* No WPA/RSN IE found in the cached scan results. Try to get updated
357 * scan results from the driver. */
358 if (wpa_supplicant_update_scan_results(wpa_s) < 0)
361 return wpa_get_beacon_ie(wpa_s);
365 static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
366 const void *data, u16 data_len,
367 size_t *msg_len, void **data_pos)
369 return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
373 static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
374 const u8 *buf, size_t len)
376 return wpa_ether_send(wpa_s, dest, proto, buf, len);
380 static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
382 wpa_supplicant_cancel_auth_timeout(wpa_s);
386 static void _wpa_supplicant_set_state(void *wpa_s, enum wpa_states state)
388 wpa_supplicant_set_state(wpa_s, state);
393 * wpa_supplicant_get_state - Get the connection state
394 * @wpa_s: Pointer to wpa_supplicant data
395 * Returns: The current connection state (WPA_*)
397 static enum wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
399 return wpa_s->wpa_state;
403 static enum wpa_states _wpa_supplicant_get_state(void *wpa_s)
405 return wpa_supplicant_get_state(wpa_s);
409 static void _wpa_supplicant_disassociate(void *wpa_s, int reason_code)
411 wpa_supplicant_disassociate(wpa_s, reason_code);
412 /* Schedule a scan to make sure we continue looking for networks */
413 wpa_supplicant_req_scan(wpa_s, 5, 0);
417 static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
419 wpa_supplicant_deauthenticate(wpa_s, reason_code);
420 /* Schedule a scan to make sure we continue looking for networks */
421 wpa_supplicant_req_scan(wpa_s, 5, 0);
425 static void * wpa_supplicant_get_network_ctx(void *wpa_s)
427 return wpa_supplicant_get_ssid(wpa_s);
431 static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
433 struct wpa_supplicant *wpa_s = ctx;
434 return wpa_drv_get_bssid(wpa_s, bssid);
438 static int wpa_supplicant_set_key(void *_wpa_s, enum wpa_alg alg,
439 const u8 *addr, int key_idx, int set_tx,
440 const u8 *seq, size_t seq_len,
441 const u8 *key, size_t key_len)
443 struct wpa_supplicant *wpa_s = _wpa_s;
444 if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
445 /* Clear the MIC error counter when setting a new PTK. */
446 wpa_s->mic_errors_seen = 0;
448 return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
453 static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
457 return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
462 static int wpa_supplicant_add_pmkid(void *wpa_s,
463 const u8 *bssid, const u8 *pmkid)
465 return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
469 static int wpa_supplicant_remove_pmkid(void *wpa_s,
470 const u8 *bssid, const u8 *pmkid)
472 return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
476 #ifdef CONFIG_IEEE80211R
477 static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
478 const u8 *ies, size_t ies_len)
480 struct wpa_supplicant *wpa_s = ctx;
481 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME)
482 return sme_update_ft_ies(wpa_s, md, ies, ies_len);
483 return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
487 static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
489 const u8 *ies, size_t ies_len)
491 struct wpa_supplicant *wpa_s = ctx;
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;
502 bss = wpa_bss_get_bssid(wpa_s, target_ap);
506 os_memset(¶ms, 0, sizeof(params));
507 params.bssid = target_ap;
508 params.freq = bss->freq;
509 params.ssid = bss->ssid;
510 params.ssid_len = bss->ssid_len;
511 params.auth_alg = WPA_AUTH_ALG_FT;
512 params.local_state_change = 1;
513 return wpa_drv_authenticate(wpa_s, ¶ms);
515 #endif /* CONFIG_IEEE80211R */
517 #endif /* CONFIG_NO_WPA */
522 static int wpa_supplicant_tdls_get_capa(void *ctx, int *tdls_supported,
525 struct wpa_supplicant *wpa_s = ctx;
530 if (!wpa_s->drv_capa_known)
533 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_SUPPORT)
536 if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP)
543 static int wpa_supplicant_send_tdls_mgmt(void *ctx, const u8 *dst,
544 u8 action_code, u8 dialog_token,
545 u16 status_code, const u8 *buf,
548 struct wpa_supplicant *wpa_s = ctx;
549 return wpa_drv_send_tdls_mgmt(wpa_s, dst, action_code, dialog_token,
550 status_code, buf, len);
554 static int wpa_supplicant_tdls_oper(void *ctx, int oper, const u8 *peer)
556 struct wpa_supplicant *wpa_s = ctx;
557 return wpa_drv_tdls_oper(wpa_s, oper, peer);
561 static int wpa_supplicant_tdls_peer_addset(
562 void *ctx, const u8 *peer, int add, u16 capability,
563 const u8 *supp_rates, size_t supp_rates_len)
565 struct wpa_supplicant *wpa_s = ctx;
566 struct hostapd_sta_add_params params;
570 params.capability = capability;
571 params.flags = WPA_STA_TDLS_PEER | WPA_STA_AUTHORIZED;
572 params.ht_capabilities = NULL;
573 params.listen_interval = 0;
574 params.supp_rates = supp_rates;
575 params.supp_rates_len = supp_rates_len;
578 return wpa_drv_sta_add(wpa_s, ¶ms);
581 #endif /* CONFIG_TDLS */
584 enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field)
586 if (os_strcmp(field, "IDENTITY") == 0)
587 return WPA_CTRL_REQ_EAP_IDENTITY;
588 else if (os_strcmp(field, "PASSWORD") == 0)
589 return WPA_CTRL_REQ_EAP_PASSWORD;
590 else if (os_strcmp(field, "NEW_PASSWORD") == 0)
591 return WPA_CTRL_REQ_EAP_NEW_PASSWORD;
592 else if (os_strcmp(field, "PIN") == 0)
593 return WPA_CTRL_REQ_EAP_PIN;
594 else if (os_strcmp(field, "OTP") == 0)
595 return WPA_CTRL_REQ_EAP_OTP;
596 else if (os_strcmp(field, "PASSPHRASE") == 0)
597 return WPA_CTRL_REQ_EAP_PASSPHRASE;
598 return WPA_CTRL_REQ_UNKNOWN;
602 const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field,
603 const char *default_txt,
606 const char *ret = NULL;
611 case WPA_CTRL_REQ_EAP_IDENTITY:
615 case WPA_CTRL_REQ_EAP_PASSWORD:
619 case WPA_CTRL_REQ_EAP_NEW_PASSWORD:
620 *txt = "New Password";
621 ret = "NEW_PASSWORD";
623 case WPA_CTRL_REQ_EAP_PIN:
627 case WPA_CTRL_REQ_EAP_OTP:
630 case WPA_CTRL_REQ_EAP_PASSPHRASE:
631 *txt = "Private key passphrase";
638 /* txt needs to be something */
640 wpa_printf(MSG_WARNING, "No message for request %d", field);
647 #ifdef IEEE8021X_EAPOL
648 #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
649 static void wpa_supplicant_eap_param_needed(void *ctx,
650 enum wpa_ctrl_req_type field,
651 const char *default_txt)
653 struct wpa_supplicant *wpa_s = ctx;
654 struct wpa_ssid *ssid = wpa_s->current_ssid;
655 const char *field_name, *txt = NULL;
663 wpas_notify_network_request(wpa_s, ssid, field, default_txt);
665 field_name = wpa_supplicant_ctrl_req_to_string(field, default_txt,
667 if (field_name == NULL) {
668 wpa_printf(MSG_WARNING, "Unhandled EAP param %d needed",
673 buflen = 100 + os_strlen(txt) + ssid->ssid_len;
674 buf = os_malloc(buflen);
677 len = os_snprintf(buf, buflen,
678 WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
679 field_name, ssid->id, txt);
680 if (len < 0 || (size_t) len >= buflen) {
684 if (ssid->ssid && buflen > len + ssid->ssid_len) {
685 os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
686 len += ssid->ssid_len;
689 buf[buflen - 1] = '\0';
690 wpa_msg(wpa_s, MSG_INFO, "%s", buf);
693 #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
694 #define wpa_supplicant_eap_param_needed NULL
695 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
698 static void wpa_supplicant_port_cb(void *ctx, int authorized)
700 struct wpa_supplicant *wpa_s = ctx;
702 if (wpa_s->ap_iface) {
703 wpa_printf(MSG_DEBUG, "AP mode active - skip EAPOL Supplicant "
705 authorized ? "Authorized" : "Unauthorized");
708 #endif /* CONFIG_AP */
709 wpa_printf(MSG_DEBUG, "EAPOL: Supplicant port status: %s",
710 authorized ? "Authorized" : "Unauthorized");
711 wpa_drv_set_supp_port(wpa_s, authorized);
715 static void wpa_supplicant_cert_cb(void *ctx, int depth, const char *subject,
716 const char *cert_hash,
717 const struct wpabuf *cert)
719 struct wpa_supplicant *wpa_s = ctx;
721 wpas_notify_certification(wpa_s, depth, subject, cert_hash, cert);
725 static void wpa_supplicant_status_cb(void *ctx, const char *status,
726 const char *parameter)
728 struct wpa_supplicant *wpa_s = ctx;
730 wpas_notify_eap_status(wpa_s, status, parameter);
732 #endif /* IEEE8021X_EAPOL */
735 int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
737 #ifdef IEEE8021X_EAPOL
738 struct eapol_ctx *ctx;
739 ctx = os_zalloc(sizeof(*ctx));
741 wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
746 ctx->msg_ctx = wpa_s;
747 ctx->eapol_send_ctx = wpa_s;
749 ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
750 ctx->eapol_send = wpa_supplicant_eapol_send;
751 ctx->set_wep_key = wpa_eapol_set_wep_key;
752 ctx->set_config_blob = wpa_supplicant_set_config_blob;
753 ctx->get_config_blob = wpa_supplicant_get_config_blob;
754 ctx->aborted_cached = wpa_supplicant_aborted_cached;
755 ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
756 ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
757 ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
758 ctx->wps = wpa_s->wps;
759 ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
760 ctx->port_cb = wpa_supplicant_port_cb;
761 ctx->cb = wpa_supplicant_eapol_cb;
762 ctx->cert_cb = wpa_supplicant_cert_cb;
763 ctx->status_cb = wpa_supplicant_status_cb;
765 wpa_s->eapol = eapol_sm_init(ctx);
766 if (wpa_s->eapol == NULL) {
768 wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
772 #endif /* IEEE8021X_EAPOL */
778 static void wpa_supplicant_set_rekey_offload(void *ctx, const u8 *kek,
780 const u8 *replay_ctr)
782 struct wpa_supplicant *wpa_s = ctx;
784 wpa_drv_set_rekey_info(wpa_s, kek, kck, replay_ctr);
788 int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
790 #ifndef CONFIG_NO_WPA
791 struct wpa_sm_ctx *ctx;
792 ctx = os_zalloc(sizeof(*ctx));
794 wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
799 ctx->msg_ctx = wpa_s;
800 ctx->set_state = _wpa_supplicant_set_state;
801 ctx->get_state = _wpa_supplicant_get_state;
802 ctx->deauthenticate = _wpa_supplicant_deauthenticate;
803 ctx->disassociate = _wpa_supplicant_disassociate;
804 ctx->set_key = wpa_supplicant_set_key;
805 ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
806 ctx->get_bssid = wpa_supplicant_get_bssid;
807 ctx->ether_send = _wpa_ether_send;
808 ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
809 ctx->alloc_eapol = _wpa_alloc_eapol;
810 ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
811 ctx->add_pmkid = wpa_supplicant_add_pmkid;
812 ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
813 #ifndef CONFIG_NO_CONFIG_BLOBS
814 ctx->set_config_blob = wpa_supplicant_set_config_blob;
815 ctx->get_config_blob = wpa_supplicant_get_config_blob;
816 #endif /* CONFIG_NO_CONFIG_BLOBS */
817 ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
818 #ifdef CONFIG_IEEE80211R
819 ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
820 ctx->send_ft_action = wpa_supplicant_send_ft_action;
821 ctx->mark_authenticated = wpa_supplicant_mark_authenticated;
822 #endif /* CONFIG_IEEE80211R */
824 ctx->tdls_get_capa = wpa_supplicant_tdls_get_capa;
825 ctx->send_tdls_mgmt = wpa_supplicant_send_tdls_mgmt;
826 ctx->tdls_oper = wpa_supplicant_tdls_oper;
827 ctx->tdls_peer_addset = wpa_supplicant_tdls_peer_addset;
828 #endif /* CONFIG_TDLS */
829 ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload;
831 wpa_s->wpa = wpa_sm_init(ctx);
832 if (wpa_s->wpa == NULL) {
833 wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
837 #endif /* CONFIG_NO_WPA */
843 void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
844 struct wpa_ssid *ssid)
846 struct rsn_supp_config conf;
848 os_memset(&conf, 0, sizeof(conf));
849 conf.network_ctx = ssid;
850 conf.peerkey_enabled = ssid->peerkey;
851 conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
852 #ifdef IEEE8021X_EAPOL
853 conf.proactive_key_caching = ssid->proactive_key_caching;
854 conf.eap_workaround = ssid->eap_workaround;
855 conf.eap_conf_ctx = &ssid->eap;
856 #endif /* IEEE8021X_EAPOL */
857 conf.ssid = ssid->ssid;
858 conf.ssid_len = ssid->ssid_len;
859 conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
861 wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);