Initial import of binutils 2.22 on the new vendor branch
[dragonfly.git] / contrib / wpa_supplicant / wpa_supplicant / wpas_glue.c
1 /*
2  * WPA Supplicant - Glue code to setup EAPOL and RSN modules
3  * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation.
8  *
9  * Alternatively, this software may be distributed under the terms of BSD
10  * license.
11  *
12  * See README and COPYING for more details.
13  */
14
15 #include "includes.h"
16
17 #include "common.h"
18 #include "eapol_supp/eapol_supp_sm.h"
19 #include "wpa.h"
20 #include "eloop.h"
21 #include "config.h"
22 #include "l2_packet/l2_packet.h"
23 #include "wpa_common.h"
24 #include "wpa_supplicant_i.h"
25 #include "pmksa_cache.h"
26 #include "mlme.h"
27 #include "ieee802_11_defs.h"
28 #include "wpa_ctrl.h"
29 #include "wpas_glue.h"
30 #include "wps_supplicant.h"
31
32
33 #ifndef CONFIG_NO_CONFIG_BLOBS
34 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
35 static void wpa_supplicant_set_config_blob(void *ctx,
36                                            struct wpa_config_blob *blob)
37 {
38         struct wpa_supplicant *wpa_s = ctx;
39         wpa_config_set_blob(wpa_s->conf, blob);
40         if (wpa_s->conf->update_config) {
41                 int ret = wpa_config_write(wpa_s->confname, wpa_s->conf);
42                 if (ret) {
43                         wpa_printf(MSG_DEBUG, "Failed to update config after "
44                                    "blob set");
45                 }
46         }
47 }
48
49
50 static const struct wpa_config_blob *
51 wpa_supplicant_get_config_blob(void *ctx, const char *name)
52 {
53         struct wpa_supplicant *wpa_s = ctx;
54         return wpa_config_get_blob(wpa_s->conf, name);
55 }
56 #endif /* defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA) */
57 #endif /* CONFIG_NO_CONFIG_BLOBS */
58
59
60 #if defined(IEEE8021X_EAPOL) || !defined(CONFIG_NO_WPA)
61 static u8 * wpa_alloc_eapol(const struct wpa_supplicant *wpa_s, u8 type,
62                             const void *data, u16 data_len,
63                             size_t *msg_len, void **data_pos)
64 {
65         struct ieee802_1x_hdr *hdr;
66
67         *msg_len = sizeof(*hdr) + data_len;
68         hdr = os_malloc(*msg_len);
69         if (hdr == NULL)
70                 return NULL;
71
72         hdr->version = wpa_s->conf->eapol_version;
73         hdr->type = type;
74         hdr->length = host_to_be16(data_len);
75
76         if (data)
77                 os_memcpy(hdr + 1, data, data_len);
78         else
79                 os_memset(hdr + 1, 0, data_len);
80
81         if (data_pos)
82                 *data_pos = hdr + 1;
83
84         return (u8 *) hdr;
85 }
86
87
88 /**
89  * wpa_ether_send - Send Ethernet frame
90  * @wpa_s: Pointer to wpa_supplicant data
91  * @dest: Destination MAC address
92  * @proto: Ethertype in host byte order
93  * @buf: Frame payload starting from IEEE 802.1X header
94  * @len: Frame payload length
95  * Returns: >=0 on success, <0 on failure
96  */
97 static int wpa_ether_send(struct wpa_supplicant *wpa_s, const u8 *dest,
98                           u16 proto, const u8 *buf, size_t len)
99 {
100         if (wpa_s->l2) {
101                 return l2_packet_send(wpa_s->l2, dest, proto, buf, len);
102         }
103
104         return wpa_drv_send_eapol(wpa_s, dest, proto, buf, len);
105 }
106 #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */
107
108
109 #ifdef IEEE8021X_EAPOL
110
111 /**
112  * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator
113  * @ctx: Pointer to wpa_supplicant data (wpa_s)
114  * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*)
115  * @buf: EAPOL payload (after IEEE 802.1X header)
116  * @len: EAPOL payload length
117  * Returns: >=0 on success, <0 on failure
118  *
119  * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame
120  * to the current Authenticator.
121  */
122 static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
123                                      size_t len)
124 {
125         struct wpa_supplicant *wpa_s = ctx;
126         u8 *msg, *dst, bssid[ETH_ALEN];
127         size_t msglen;
128         int res;
129
130         /* TODO: could add l2_packet_sendmsg that allows fragments to avoid
131          * extra copy here */
132
133         if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) ||
134             wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) {
135                 /* Current SSID is not using IEEE 802.1X/EAP, so drop possible
136                  * EAPOL frames (mainly, EAPOL-Start) from EAPOL state
137                  * machines. */
138                 wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X "
139                            "mode (type=%d len=%lu)", type,
140                            (unsigned long) len);
141                 return -1;
142         }
143
144         if (pmksa_cache_get_current(wpa_s->wpa) &&
145             type == IEEE802_1X_TYPE_EAPOL_START) {
146                 /* Trying to use PMKSA caching - do not send EAPOL-Start frames
147                  * since they will trigger full EAPOL authentication. */
148                 wpa_printf(MSG_DEBUG, "RSN: PMKSA caching - do not send "
149                            "EAPOL-Start");
150                 return -1;
151         }
152
153         if (is_zero_ether_addr(wpa_s->bssid)) {
154                 wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
155                            "EAPOL frame");
156                 if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
157                     !is_zero_ether_addr(bssid)) {
158                         dst = bssid;
159                         wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
160                                    " from the driver as the EAPOL destination",
161                                    MAC2STR(dst));
162                 } else {
163                         dst = wpa_s->last_eapol_src;
164                         wpa_printf(MSG_DEBUG, "Using the source address of the"
165                                    " last received EAPOL frame " MACSTR " as "
166                                    "the EAPOL destination",
167                                    MAC2STR(dst));
168                 }
169         } else {
170                 /* BSSID was already set (from (Re)Assoc event, so use it as
171                  * the EAPOL destination. */
172                 dst = wpa_s->bssid;
173         }
174
175         msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL);
176         if (msg == NULL)
177                 return -1;
178
179         wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst));
180         wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen);
181         res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen);
182         os_free(msg);
183         return res;
184 }
185
186
187 /**
188  * wpa_eapol_set_wep_key - set WEP key for the driver
189  * @ctx: Pointer to wpa_supplicant data (wpa_s)
190  * @unicast: 1 = individual unicast key, 0 = broadcast key
191  * @keyidx: WEP key index (0..3)
192  * @key: Pointer to key data
193  * @keylen: Key length in bytes
194  * Returns: 0 on success or < 0 on error.
195  */
196 static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx,
197                                  const u8 *key, size_t keylen)
198 {
199         struct wpa_supplicant *wpa_s = ctx;
200         if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
201                 int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 :
202                         WPA_CIPHER_WEP104;
203                 if (unicast)
204                         wpa_s->pairwise_cipher = cipher;
205                 else
206                         wpa_s->group_cipher = cipher;
207         }
208         return wpa_drv_set_key(wpa_s, WPA_ALG_WEP,
209                                unicast ? wpa_s->bssid :
210                                (u8 *) "\xff\xff\xff\xff\xff\xff",
211                                keyidx, unicast, (u8 *) "", 0, key, keylen);
212 }
213
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
221
222 static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, int success,
223                                     void *ctx)
224 {
225         struct wpa_supplicant *wpa_s = ctx;
226         int res, pmk_len;
227         u8 pmk[PMK_LEN];
228
229         wpa_printf(MSG_DEBUG, "EAPOL authentication completed %ssuccessfully",
230                    success ? "" : "un");
231
232         if (wpas_wps_eapol_cb(wpa_s) > 0)
233                 return;
234
235         if (!success) {
236                 /*
237                  * Make sure we do not get stuck here waiting for long EAPOL
238                  * timeout if the AP does not disconnect in case of
239                  * authentication failure.
240                  */
241                 wpa_supplicant_req_auth_timeout(wpa_s, 2, 0);
242         }
243
244         if (!success || !wpa_s->driver_4way_handshake)
245                 return;
246
247         if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt))
248                 return;
249
250         wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way "
251                    "handshake");
252
253         pmk_len = PMK_LEN;
254         res = eapol_sm_get_key(eapol, pmk, PMK_LEN);
255         if (res) {
256                 /*
257                  * EAP-LEAP is an exception from other EAP methods: it
258                  * uses only 16-byte PMK.
259                  */
260                 res = eapol_sm_get_key(eapol, pmk, 16);
261                 pmk_len = 16;
262         }
263
264         if (res) {
265                 wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state "
266                            "machines");
267                 return;
268         }
269
270         if (wpa_drv_set_key(wpa_s, WPA_ALG_PMK, NULL, 0, 0, NULL, 0, pmk,
271                             pmk_len)) {
272                 wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver");
273         }
274
275         wpa_supplicant_cancel_scan(wpa_s);
276         wpa_supplicant_cancel_auth_timeout(wpa_s);
277         wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
278
279 }
280
281
282 static void wpa_supplicant_notify_eapol_done(void *ctx)
283 {
284         struct wpa_supplicant *wpa_s = ctx;
285         wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete");
286         if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) {
287                 wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE);
288         } else {
289                 wpa_supplicant_cancel_auth_timeout(wpa_s);
290                 wpa_supplicant_set_state(wpa_s, WPA_COMPLETED);
291         }
292 }
293
294 #endif /* IEEE8021X_EAPOL */
295
296
297 #ifndef CONFIG_NO_WPA
298
299 static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s)
300 {
301         size_t i;
302         int ret = 0;
303         struct wpa_scan_res *curr = NULL;
304         struct wpa_ssid *ssid = wpa_s->current_ssid;
305         const u8 *ie;
306
307         if (wpa_s->scan_res == NULL)
308                 return -1;
309
310         for (i = 0; i < wpa_s->scan_res->num; i++) {
311                 struct wpa_scan_res *r = wpa_s->scan_res->res[i];
312                 if (os_memcmp(r->bssid, wpa_s->bssid, ETH_ALEN) != 0)
313                         continue;
314                 ie = wpa_scan_get_ie(r, WLAN_EID_SSID);
315                 if (ssid == NULL ||
316                     ((ie && ie[1] == ssid->ssid_len &&
317                       os_memcmp(ie + 2, ssid->ssid, ssid->ssid_len) == 0) ||
318                      ssid->ssid_len == 0)) {
319                         curr = r;
320                         break;
321                 }
322         }
323
324         if (curr) {
325                 ie = wpa_scan_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;
328
329                 ie = wpa_scan_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;
334         }
335
336         return ret;
337 }
338
339
340 static int wpa_supplicant_get_beacon_ie(void *ctx)
341 {
342         struct wpa_supplicant *wpa_s = ctx;
343         if (wpa_get_beacon_ie(wpa_s) == 0) {
344                 return 0;
345         }
346
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_get_scan_results(wpa_s) < 0) {
350                 return -1;
351         }
352
353         return wpa_get_beacon_ie(wpa_s);
354 }
355
356
357 static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type,
358                              const void *data, u16 data_len,
359                              size_t *msg_len, void **data_pos)
360 {
361         return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos);
362 }
363
364
365 static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto,
366                            const u8 *buf, size_t len)
367 {
368         return wpa_ether_send(wpa_s, dest, proto, buf, len);
369 }
370
371
372 static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s)
373 {
374         wpa_supplicant_cancel_auth_timeout(wpa_s);
375 }
376
377
378 static void _wpa_supplicant_set_state(void *wpa_s, wpa_states state)
379 {
380         wpa_supplicant_set_state(wpa_s, state);
381 }
382
383
384 /**
385  * wpa_supplicant_get_state - Get the connection state
386  * @wpa_s: Pointer to wpa_supplicant data
387  * Returns: The current connection state (WPA_*)
388  */
389 static wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s)
390 {
391         return wpa_s->wpa_state;
392 }
393
394
395 static wpa_states _wpa_supplicant_get_state(void *wpa_s)
396 {
397         return wpa_supplicant_get_state(wpa_s);
398 }
399
400
401 static void _wpa_supplicant_disassociate(void *wpa_s, int reason_code)
402 {
403         wpa_supplicant_disassociate(wpa_s, reason_code);
404         /* Schedule a scan to make sure we continue looking for networks */
405         wpa_supplicant_req_scan(wpa_s, 5, 0);
406 }
407
408
409 static void _wpa_supplicant_deauthenticate(void *wpa_s, int reason_code)
410 {
411         wpa_supplicant_deauthenticate(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);
414 }
415
416
417 static void * wpa_supplicant_get_network_ctx(void *wpa_s)
418 {
419         return wpa_supplicant_get_ssid(wpa_s);
420 }
421
422
423 static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid)
424 {
425         struct wpa_supplicant *wpa_s = ctx;
426         if (wpa_s->use_client_mlme) {
427                 os_memcpy(bssid, wpa_s->bssid, ETH_ALEN);
428                 return 0;
429         }
430         return wpa_drv_get_bssid(wpa_s, bssid);
431 }
432
433
434 static int wpa_supplicant_set_key(void *_wpa_s, wpa_alg alg,
435                                   const u8 *addr, int key_idx, int set_tx,
436                                   const u8 *seq, size_t seq_len,
437                                   const u8 *key, size_t key_len)
438 {
439         struct wpa_supplicant *wpa_s = _wpa_s;
440         if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) {
441                 /* Clear the MIC error counter when setting a new PTK. */
442                 wpa_s->mic_errors_seen = 0;
443         }
444         return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len,
445                                key, key_len);
446 }
447
448
449 static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
450                                              int protection_type,
451                                              int key_type)
452 {
453         return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type,
454                                           key_type);
455 }
456
457
458 static int wpa_supplicant_add_pmkid(void *wpa_s,
459                                     const u8 *bssid, const u8 *pmkid)
460 {
461         return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
462 }
463
464
465 static int wpa_supplicant_remove_pmkid(void *wpa_s,
466                                        const u8 *bssid, const u8 *pmkid)
467 {
468         return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
469 }
470
471
472 #ifdef CONFIG_IEEE80211R
473 static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md,
474                                         const u8 *ies, size_t ies_len)
475 {
476         struct wpa_supplicant *wpa_s = ctx;
477         if (wpa_s->use_client_mlme)
478                 return ieee80211_sta_update_ft_ies(wpa_s, md, ies, ies_len);
479         return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len);
480 }
481
482
483 static int wpa_supplicant_send_ft_action(void *ctx, u8 action,
484                                          const u8 *target_ap,
485                                          const u8 *ies, size_t ies_len)
486 {
487         struct wpa_supplicant *wpa_s = ctx;
488         if (wpa_s->use_client_mlme)
489                 return ieee80211_sta_send_ft_action(wpa_s, action, target_ap,
490                                                     ies, ies_len);
491         return wpa_drv_send_ft_action(wpa_s, action, target_ap, ies, ies_len);
492 }
493 #endif /* CONFIG_IEEE80211R */
494
495 #endif /* CONFIG_NO_WPA */
496
497
498 #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG)
499 static void wpa_supplicant_eap_param_needed(void *ctx, const char *field,
500                                             const char *txt)
501 {
502         struct wpa_supplicant *wpa_s = ctx;
503         struct wpa_ssid *ssid = wpa_s->current_ssid;
504         char *buf;
505         size_t buflen;
506         int len;
507
508         if (ssid == NULL)
509                 return;
510
511         buflen = 100 + os_strlen(txt) + ssid->ssid_len;
512         buf = os_malloc(buflen);
513         if (buf == NULL)
514                 return;
515         len = os_snprintf(buf, buflen,
516                           WPA_CTRL_REQ "%s-%d:%s needed for SSID ",
517                           field, ssid->id, txt);
518         if (len < 0 || (size_t) len >= buflen) {
519                 os_free(buf);
520                 return;
521         }
522         if (ssid->ssid && buflen > len + ssid->ssid_len) {
523                 os_memcpy(buf + len, ssid->ssid, ssid->ssid_len);
524                 len += ssid->ssid_len;
525                 buf[len] = '\0';
526         }
527         buf[buflen - 1] = '\0';
528         wpa_msg(wpa_s, MSG_INFO, "%s", buf);
529         os_free(buf);
530 }
531 #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
532 #define wpa_supplicant_eap_param_needed NULL
533 #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */
534
535
536 int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s)
537 {
538 #ifdef IEEE8021X_EAPOL
539         struct eapol_ctx *ctx;
540         ctx = os_zalloc(sizeof(*ctx));
541         if (ctx == NULL) {
542                 wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context.");
543                 return -1;
544         }
545
546         ctx->ctx = wpa_s;
547         ctx->msg_ctx = wpa_s;
548         ctx->eapol_send_ctx = wpa_s;
549         ctx->preauth = 0;
550         ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done;
551         ctx->eapol_send = wpa_supplicant_eapol_send;
552         ctx->set_wep_key = wpa_eapol_set_wep_key;
553         ctx->set_config_blob = wpa_supplicant_set_config_blob;
554         ctx->get_config_blob = wpa_supplicant_get_config_blob;
555         ctx->aborted_cached = wpa_supplicant_aborted_cached;
556 #ifdef EAP_TLS_OPENSSL
557         ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path;
558         ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path;
559         ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path;
560 #endif /* EAP_TLS_OPENSSL */
561         ctx->wps = wpa_s->wps;
562         ctx->eap_param_needed = wpa_supplicant_eap_param_needed;
563         ctx->cb = wpa_supplicant_eapol_cb;
564         ctx->cb_ctx = wpa_s;
565         wpa_s->eapol = eapol_sm_init(ctx);
566         if (wpa_s->eapol == NULL) {
567                 os_free(ctx);
568                 wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state "
569                            "machines.");
570                 return -1;
571         }
572 #endif /* IEEE8021X_EAPOL */
573
574         return 0;
575 }
576
577
578 int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s)
579 {
580 #ifndef CONFIG_NO_WPA
581         struct wpa_sm_ctx *ctx;
582         ctx = os_zalloc(sizeof(*ctx));
583         if (ctx == NULL) {
584                 wpa_printf(MSG_ERROR, "Failed to allocate WPA context.");
585                 return -1;
586         }
587
588         ctx->ctx = wpa_s;
589         ctx->set_state = _wpa_supplicant_set_state;
590         ctx->get_state = _wpa_supplicant_get_state;
591         ctx->deauthenticate = _wpa_supplicant_deauthenticate;
592         ctx->disassociate = _wpa_supplicant_disassociate;
593         ctx->set_key = wpa_supplicant_set_key;
594         ctx->get_network_ctx = wpa_supplicant_get_network_ctx;
595         ctx->get_bssid = wpa_supplicant_get_bssid;
596         ctx->ether_send = _wpa_ether_send;
597         ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie;
598         ctx->alloc_eapol = _wpa_alloc_eapol;
599         ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout;
600         ctx->add_pmkid = wpa_supplicant_add_pmkid;
601         ctx->remove_pmkid = wpa_supplicant_remove_pmkid;
602 #ifndef CONFIG_NO_CONFIG_BLOBS
603         ctx->set_config_blob = wpa_supplicant_set_config_blob;
604         ctx->get_config_blob = wpa_supplicant_get_config_blob;
605 #endif /* CONFIG_NO_CONFIG_BLOBS */
606         ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection;
607 #ifdef CONFIG_IEEE80211R
608         ctx->update_ft_ies = wpa_supplicant_update_ft_ies;
609         ctx->send_ft_action = wpa_supplicant_send_ft_action;
610 #endif /* CONFIG_IEEE80211R */
611
612         wpa_s->wpa = wpa_sm_init(ctx);
613         if (wpa_s->wpa == NULL) {
614                 wpa_printf(MSG_ERROR, "Failed to initialize WPA state "
615                            "machine");
616                 return -1;
617         }
618 #endif /* CONFIG_NO_WPA */
619
620         return 0;
621 }
622
623
624 void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
625                                         struct wpa_ssid *ssid)
626 {
627         struct rsn_supp_config conf;
628         if (ssid) {
629                 os_memset(&conf, 0, sizeof(conf));
630                 conf.network_ctx = ssid;
631                 conf.peerkey_enabled = ssid->peerkey;
632                 conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
633 #ifdef IEEE8021X_EAPOL
634                 conf.eap_workaround = ssid->eap_workaround;
635                 conf.eap_conf_ctx = &ssid->eap;
636 #endif /* IEEE8021X_EAPOL */
637                 conf.ssid = ssid->ssid;
638                 conf.ssid_len = ssid->ssid_len;
639                 conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey;
640         }
641         wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL);
642 }