]>
Commit | Line | Data |
---|---|---|
6fc6879b JM |
1 | /* |
2 | * WPA Supplicant - Glue code to setup EAPOL and RSN modules | |
98cd3d1c | 3 | * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi> |
6fc6879b | 4 | * |
0f3d578e JM |
5 | * This software may be distributed under the terms of the BSD license. |
6 | * See README for more details. | |
6fc6879b JM |
7 | */ |
8 | ||
9 | #include "includes.h" | |
10 | ||
11 | #include "common.h" | |
12 | #include "eapol_supp/eapol_supp_sm.h" | |
c167662d | 13 | #include "eap_peer/eap.h" |
3acb5005 | 14 | #include "rsn_supp/wpa.h" |
6fc6879b JM |
15 | #include "eloop.h" |
16 | #include "config.h" | |
17 | #include "l2_packet/l2_packet.h" | |
90973fb2 | 18 | #include "common/wpa_common.h" |
6fc6879b | 19 | #include "wpa_supplicant_i.h" |
2d5b792d | 20 | #include "driver_i.h" |
3acb5005 | 21 | #include "rsn_supp/pmksa_cache.h" |
c2a04078 | 22 | #include "sme.h" |
90973fb2 JM |
23 | #include "common/ieee802_11_defs.h" |
24 | #include "common/wpa_ctrl.h" | |
6fc6879b | 25 | #include "wpas_glue.h" |
fa201b69 | 26 | #include "wps_supplicant.h" |
e48f0fb6 | 27 | #include "bss.h" |
9ba9fa07 | 28 | #include "scan.h" |
ade74830 | 29 | #include "notify.h" |
dd10abcc | 30 | #include "wpas_kay.h" |
6fc6879b JM |
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); | |
c08b9180 JM |
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 | } | |
6fc6879b JM |
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 | { | |
9d4ff04a JM |
100 | #ifdef CONFIG_TESTING_OPTIONS |
101 | if (wpa_s->ext_eapol_frame_io && proto == ETH_P_EAPOL) { | |
102 | size_t hex_len = 2 * len + 1; | |
103 | char *hex = os_malloc(hex_len); | |
104 | ||
105 | if (hex == NULL) | |
106 | return -1; | |
107 | wpa_snprintf_hex(hex, hex_len, buf, len); | |
108 | wpa_msg(wpa_s, MSG_INFO, "EAPOL-TX " MACSTR " %s", | |
109 | MAC2STR(dest), hex); | |
110 | os_free(hex); | |
111 | return 0; | |
112 | } | |
113 | #endif /* CONFIG_TESTING_OPTIONS */ | |
114 | ||
a79ed068 MT |
115 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_CONTROL_PORT) { |
116 | int encrypt = wpa_s->wpa && | |
117 | wpa_sm_has_ptk_installed(wpa_s->wpa); | |
118 | ||
119 | return wpa_drv_tx_control_port(wpa_s, dest, proto, buf, len, | |
120 | !encrypt); | |
121 | } | |
144314ea | 122 | |
6fc6879b JM |
123 | if (wpa_s->l2) { |
124 | return l2_packet_send(wpa_s->l2, dest, proto, buf, len); | |
125 | } | |
126 | ||
2961bfa8 | 127 | return -1; |
6fc6879b JM |
128 | } |
129 | #endif /* IEEE8021X_EAPOL || !CONFIG_NO_WPA */ | |
130 | ||
131 | ||
132 | #ifdef IEEE8021X_EAPOL | |
133 | ||
134 | /** | |
135 | * wpa_supplicant_eapol_send - Send IEEE 802.1X EAPOL packet to Authenticator | |
136 | * @ctx: Pointer to wpa_supplicant data (wpa_s) | |
137 | * @type: IEEE 802.1X packet type (IEEE802_1X_TYPE_*) | |
138 | * @buf: EAPOL payload (after IEEE 802.1X header) | |
139 | * @len: EAPOL payload length | |
140 | * Returns: >=0 on success, <0 on failure | |
141 | * | |
142 | * This function adds Ethernet and IEEE 802.1X header and sends the EAPOL frame | |
143 | * to the current Authenticator. | |
144 | */ | |
145 | static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf, | |
146 | size_t len) | |
147 | { | |
148 | struct wpa_supplicant *wpa_s = ctx; | |
149 | u8 *msg, *dst, bssid[ETH_ALEN]; | |
150 | size_t msglen; | |
151 | int res; | |
152 | ||
153 | /* TODO: could add l2_packet_sendmsg that allows fragments to avoid | |
154 | * extra copy here */ | |
155 | ||
56586197 | 156 | if (wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt) || |
a1ea1b45 | 157 | wpa_s->key_mgmt == WPA_KEY_MGMT_OWE || |
567da5bb | 158 | wpa_s->key_mgmt == WPA_KEY_MGMT_DPP || |
6fc6879b JM |
159 | wpa_s->key_mgmt == WPA_KEY_MGMT_NONE) { |
160 | /* Current SSID is not using IEEE 802.1X/EAP, so drop possible | |
161 | * EAPOL frames (mainly, EAPOL-Start) from EAPOL state | |
162 | * machines. */ | |
163 | wpa_printf(MSG_DEBUG, "WPA: drop TX EAPOL in non-IEEE 802.1X " | |
164 | "mode (type=%d len=%lu)", type, | |
165 | (unsigned long) len); | |
166 | return -1; | |
167 | } | |
168 | ||
169 | if (pmksa_cache_get_current(wpa_s->wpa) && | |
170 | type == IEEE802_1X_TYPE_EAPOL_START) { | |
76db5b6b JM |
171 | /* |
172 | * We were trying to use PMKSA caching and sending EAPOL-Start | |
173 | * would abort that and trigger full EAPOL authentication. | |
174 | * However, we've already waited for the AP/Authenticator to | |
175 | * start 4-way handshake or EAP authentication, and apparently | |
176 | * it has not done so since the startWhen timer has reached zero | |
177 | * to get the state machine sending EAPOL-Start. This is not | |
178 | * really supposed to happen, but an interoperability issue with | |
179 | * a deployed AP has been identified where the connection fails | |
180 | * due to that AP failing to operate correctly if PMKID is | |
181 | * included in the Association Request frame. To work around | |
182 | * this, assume PMKSA caching failed and try to initiate full | |
183 | * EAP authentication. | |
184 | */ | |
185 | if (!wpa_s->current_ssid || | |
186 | wpa_s->current_ssid->eap_workaround) { | |
187 | wpa_printf(MSG_DEBUG, | |
188 | "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"); | |
189 | } else { | |
190 | wpa_printf(MSG_DEBUG, | |
191 | "RSN: PMKSA caching - do not send EAPOL-Start"); | |
192 | return -1; | |
193 | } | |
6fc6879b JM |
194 | } |
195 | ||
a8e16edc | 196 | if (is_zero_ether_addr(wpa_s->bssid)) { |
6fc6879b JM |
197 | wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an " |
198 | "EAPOL frame"); | |
199 | if (wpa_drv_get_bssid(wpa_s, bssid) == 0 && | |
a8e16edc | 200 | !is_zero_ether_addr(bssid)) { |
6fc6879b JM |
201 | dst = bssid; |
202 | wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR | |
203 | " from the driver as the EAPOL destination", | |
204 | MAC2STR(dst)); | |
205 | } else { | |
206 | dst = wpa_s->last_eapol_src; | |
207 | wpa_printf(MSG_DEBUG, "Using the source address of the" | |
208 | " last received EAPOL frame " MACSTR " as " | |
209 | "the EAPOL destination", | |
210 | MAC2STR(dst)); | |
211 | } | |
212 | } else { | |
213 | /* BSSID was already set (from (Re)Assoc event, so use it as | |
214 | * the EAPOL destination. */ | |
215 | dst = wpa_s->bssid; | |
216 | } | |
217 | ||
218 | msg = wpa_alloc_eapol(wpa_s, type, buf, len, &msglen, NULL); | |
219 | if (msg == NULL) | |
220 | return -1; | |
221 | ||
222 | wpa_printf(MSG_DEBUG, "TX EAPOL: dst=" MACSTR, MAC2STR(dst)); | |
223 | wpa_hexdump(MSG_MSGDUMP, "TX EAPOL", msg, msglen); | |
224 | res = wpa_ether_send(wpa_s, dst, ETH_P_EAPOL, msg, msglen); | |
225 | os_free(msg); | |
226 | return res; | |
227 | } | |
228 | ||
229 | ||
200c7693 | 230 | #ifdef CONFIG_WEP |
6fc6879b JM |
231 | /** |
232 | * wpa_eapol_set_wep_key - set WEP key for the driver | |
233 | * @ctx: Pointer to wpa_supplicant data (wpa_s) | |
234 | * @unicast: 1 = individual unicast key, 0 = broadcast key | |
235 | * @keyidx: WEP key index (0..3) | |
236 | * @key: Pointer to key data | |
237 | * @keylen: Key length in bytes | |
238 | * Returns: 0 on success or < 0 on error. | |
239 | */ | |
240 | static int wpa_eapol_set_wep_key(void *ctx, int unicast, int keyidx, | |
241 | const u8 *key, size_t keylen) | |
242 | { | |
243 | struct wpa_supplicant *wpa_s = ctx; | |
244 | if (wpa_s->key_mgmt == WPA_KEY_MGMT_IEEE8021X_NO_WPA) { | |
245 | int cipher = (keylen == 5) ? WPA_CIPHER_WEP40 : | |
246 | WPA_CIPHER_WEP104; | |
247 | if (unicast) | |
248 | wpa_s->pairwise_cipher = cipher; | |
249 | else | |
250 | wpa_s->group_cipher = cipher; | |
251 | } | |
252 | return wpa_drv_set_key(wpa_s, WPA_ALG_WEP, | |
0382097e | 253 | unicast ? wpa_s->bssid : NULL, |
a919a260 AW |
254 | keyidx, unicast, NULL, 0, key, keylen, |
255 | unicast ? KEY_FLAG_PAIRWISE_RX_TX : | |
256 | KEY_FLAG_GROUP_RX_TX_DEFAULT); | |
6fc6879b | 257 | } |
200c7693 | 258 | #endif /* CONFIG_WEP */ |
6fc6879b JM |
259 | |
260 | ||
261 | static void wpa_supplicant_aborted_cached(void *ctx) | |
262 | { | |
263 | struct wpa_supplicant *wpa_s = ctx; | |
264 | wpa_sm_aborted_cached(wpa_s->wpa); | |
265 | } | |
266 | ||
267 | ||
c60ba9f7 JM |
268 | static const char * result_str(enum eapol_supp_result result) |
269 | { | |
270 | switch (result) { | |
271 | case EAPOL_SUPP_RESULT_FAILURE: | |
272 | return "FAILURE"; | |
273 | case EAPOL_SUPP_RESULT_SUCCESS: | |
274 | return "SUCCESS"; | |
275 | case EAPOL_SUPP_RESULT_EXPECTED_FAILURE: | |
276 | return "EXPECTED_FAILURE"; | |
277 | } | |
278 | return "?"; | |
279 | } | |
280 | ||
281 | ||
282 | static void wpa_supplicant_eapol_cb(struct eapol_sm *eapol, | |
283 | enum eapol_supp_result result, | |
6fc6879b JM |
284 | void *ctx) |
285 | { | |
286 | struct wpa_supplicant *wpa_s = ctx; | |
287 | int res, pmk_len; | |
288 | u8 pmk[PMK_LEN]; | |
289 | ||
c60ba9f7 JM |
290 | wpa_printf(MSG_DEBUG, "EAPOL authentication completed - result=%s", |
291 | result_str(result)); | |
6fc6879b | 292 | |
fa201b69 | 293 | if (wpas_wps_eapol_cb(wpa_s) > 0) |
ad08c363 | 294 | return; |
ad08c363 | 295 | |
c60ba9f7 JM |
296 | wpa_s->eap_expected_failure = result == |
297 | EAPOL_SUPP_RESULT_EXPECTED_FAILURE; | |
298 | ||
299 | if (result != EAPOL_SUPP_RESULT_SUCCESS) { | |
0930209d JM |
300 | /* |
301 | * Make sure we do not get stuck here waiting for long EAPOL | |
302 | * timeout if the AP does not disconnect in case of | |
303 | * authentication failure. | |
304 | */ | |
305 | wpa_supplicant_req_auth_timeout(wpa_s, 2, 0); | |
dd10abcc HW |
306 | } else { |
307 | ieee802_1x_notify_create_actor(wpa_s, wpa_s->last_eapol_src); | |
0930209d JM |
308 | } |
309 | ||
c60ba9f7 | 310 | if (result != EAPOL_SUPP_RESULT_SUCCESS || |
436ee2fd | 311 | !(wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X)) |
6fc6879b JM |
312 | return; |
313 | ||
56586197 | 314 | if (!wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) |
6fc6879b JM |
315 | return; |
316 | ||
317 | wpa_printf(MSG_DEBUG, "Configure PMK for driver-based RSN 4-way " | |
318 | "handshake"); | |
319 | ||
320 | pmk_len = PMK_LEN; | |
09c395b4 JM |
321 | if (wpa_key_mgmt_ft(wpa_s->key_mgmt)) { |
322 | #ifdef CONFIG_IEEE80211R | |
323 | u8 buf[2 * PMK_LEN]; | |
324 | wpa_printf(MSG_DEBUG, "RSN: Use FT XXKey as PMK for " | |
325 | "driver-based 4-way hs and FT"); | |
326 | res = eapol_sm_get_key(eapol, buf, 2 * PMK_LEN); | |
327 | if (res == 0) { | |
328 | os_memcpy(pmk, buf + PMK_LEN, PMK_LEN); | |
329 | os_memset(buf, 0, sizeof(buf)); | |
330 | } | |
331 | #else /* CONFIG_IEEE80211R */ | |
332 | res = -1; | |
333 | #endif /* CONFIG_IEEE80211R */ | |
334 | } else { | |
335 | res = eapol_sm_get_key(eapol, pmk, PMK_LEN); | |
336 | if (res) { | |
337 | /* | |
338 | * EAP-LEAP is an exception from other EAP methods: it | |
339 | * uses only 16-byte PMK. | |
340 | */ | |
341 | res = eapol_sm_get_key(eapol, pmk, 16); | |
342 | pmk_len = 16; | |
343 | } | |
6fc6879b JM |
344 | } |
345 | ||
346 | if (res) { | |
347 | wpa_printf(MSG_DEBUG, "Failed to get PMK from EAPOL state " | |
348 | "machines"); | |
349 | return; | |
350 | } | |
351 | ||
09c395b4 JM |
352 | wpa_hexdump_key(MSG_DEBUG, "RSN: Configure PMK for driver-based 4-way " |
353 | "handshake", pmk, pmk_len); | |
354 | ||
be15f33d | 355 | if (wpa_drv_set_key(wpa_s, 0, NULL, 0, 0, NULL, 0, pmk, |
a919a260 | 356 | pmk_len, KEY_FLAG_PMK)) { |
6fc6879b JM |
357 | wpa_printf(MSG_DEBUG, "Failed to set PMK to the driver"); |
358 | } | |
359 | ||
360 | wpa_supplicant_cancel_scan(wpa_s); | |
361 | wpa_supplicant_cancel_auth_timeout(wpa_s); | |
362 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); | |
363 | ||
364 | } | |
365 | ||
366 | ||
367 | static void wpa_supplicant_notify_eapol_done(void *ctx) | |
368 | { | |
369 | struct wpa_supplicant *wpa_s = ctx; | |
370 | wpa_msg(wpa_s, MSG_DEBUG, "WPA: EAPOL processing complete"); | |
56586197 | 371 | if (wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) { |
6fc6879b JM |
372 | wpa_supplicant_set_state(wpa_s, WPA_4WAY_HANDSHAKE); |
373 | } else { | |
6fc6879b JM |
374 | wpa_supplicant_cancel_auth_timeout(wpa_s); |
375 | wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); | |
376 | } | |
377 | } | |
378 | ||
379 | #endif /* IEEE8021X_EAPOL */ | |
380 | ||
381 | ||
382 | #ifndef CONFIG_NO_WPA | |
383 | ||
384 | static int wpa_get_beacon_ie(struct wpa_supplicant *wpa_s) | |
385 | { | |
6fc6879b | 386 | int ret = 0; |
e48f0fb6 | 387 | struct wpa_bss *curr = NULL, *bss; |
6fc6879b JM |
388 | struct wpa_ssid *ssid = wpa_s->current_ssid; |
389 | const u8 *ie; | |
390 | ||
e48f0fb6 JM |
391 | dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) { |
392 | if (os_memcmp(bss->bssid, wpa_s->bssid, ETH_ALEN) != 0) | |
6fc6879b | 393 | continue; |
6fc6879b | 394 | if (ssid == NULL || |
e48f0fb6 JM |
395 | ((bss->ssid_len == ssid->ssid_len && |
396 | os_memcmp(bss->ssid, ssid->ssid, ssid->ssid_len) == 0) || | |
6fc6879b | 397 | ssid->ssid_len == 0)) { |
e48f0fb6 | 398 | curr = bss; |
6fc6879b JM |
399 | break; |
400 | } | |
f4bf6a5d JM |
401 | #ifdef CONFIG_OWE |
402 | if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_OWE) && | |
403 | (bss->flags & WPA_BSS_OWE_TRANSITION)) { | |
404 | curr = bss; | |
405 | break; | |
406 | } | |
407 | #endif /* CONFIG_OWE */ | |
6fc6879b JM |
408 | } |
409 | ||
410 | if (curr) { | |
e48f0fb6 | 411 | ie = wpa_bss_get_vendor_ie(curr, WPA_IE_VENDOR_TYPE); |
6fc6879b JM |
412 | if (wpa_sm_set_ap_wpa_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0)) |
413 | ret = -1; | |
414 | ||
e48f0fb6 | 415 | ie = wpa_bss_get_ie(curr, WLAN_EID_RSN); |
6fc6879b JM |
416 | if (wpa_sm_set_ap_rsn_ie(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0)) |
417 | ret = -1; | |
146889e3 JM |
418 | |
419 | ie = wpa_bss_get_ie(curr, WLAN_EID_RSNX); | |
420 | if (wpa_sm_set_ap_rsnxe(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0)) | |
421 | ret = -1; | |
6fc6879b JM |
422 | } else { |
423 | ret = -1; | |
424 | } | |
425 | ||
426 | return ret; | |
427 | } | |
428 | ||
429 | ||
430 | static int wpa_supplicant_get_beacon_ie(void *ctx) | |
431 | { | |
432 | struct wpa_supplicant *wpa_s = ctx; | |
433 | if (wpa_get_beacon_ie(wpa_s) == 0) { | |
434 | return 0; | |
435 | } | |
436 | ||
437 | /* No WPA/RSN IE found in the cached scan results. Try to get updated | |
438 | * scan results from the driver. */ | |
a1fd2ce5 | 439 | if (wpa_supplicant_update_scan_results(wpa_s) < 0) |
6fc6879b | 440 | return -1; |
6fc6879b JM |
441 | |
442 | return wpa_get_beacon_ie(wpa_s); | |
443 | } | |
444 | ||
445 | ||
446 | static u8 * _wpa_alloc_eapol(void *wpa_s, u8 type, | |
447 | const void *data, u16 data_len, | |
448 | size_t *msg_len, void **data_pos) | |
449 | { | |
450 | return wpa_alloc_eapol(wpa_s, type, data, data_len, msg_len, data_pos); | |
451 | } | |
452 | ||
453 | ||
454 | static int _wpa_ether_send(void *wpa_s, const u8 *dest, u16 proto, | |
455 | const u8 *buf, size_t len) | |
456 | { | |
457 | return wpa_ether_send(wpa_s, dest, proto, buf, len); | |
458 | } | |
459 | ||
460 | ||
6fc6879b JM |
461 | static void _wpa_supplicant_cancel_auth_timeout(void *wpa_s) |
462 | { | |
463 | wpa_supplicant_cancel_auth_timeout(wpa_s); | |
464 | } | |
465 | ||
466 | ||
71934751 | 467 | static void _wpa_supplicant_set_state(void *wpa_s, enum wpa_states state) |
6fc6879b JM |
468 | { |
469 | wpa_supplicant_set_state(wpa_s, state); | |
470 | } | |
471 | ||
472 | ||
473 | /** | |
474 | * wpa_supplicant_get_state - Get the connection state | |
475 | * @wpa_s: Pointer to wpa_supplicant data | |
476 | * Returns: The current connection state (WPA_*) | |
477 | */ | |
71934751 | 478 | static enum wpa_states wpa_supplicant_get_state(struct wpa_supplicant *wpa_s) |
6fc6879b JM |
479 | { |
480 | return wpa_s->wpa_state; | |
481 | } | |
482 | ||
483 | ||
71934751 | 484 | static enum wpa_states _wpa_supplicant_get_state(void *wpa_s) |
6fc6879b JM |
485 | { |
486 | return wpa_supplicant_get_state(wpa_s); | |
487 | } | |
488 | ||
489 | ||
4be17ffb | 490 | static void _wpa_supplicant_deauthenticate(void *wpa_s, u16 reason_code) |
6fc6879b JM |
491 | { |
492 | wpa_supplicant_deauthenticate(wpa_s, reason_code); | |
3e2ad1b9 | 493 | /* Schedule a scan to make sure we continue looking for networks */ |
83935317 | 494 | wpa_supplicant_req_scan(wpa_s, 5, 0); |
6fc6879b JM |
495 | } |
496 | ||
497 | ||
1f90a49d AW |
498 | static void _wpa_supplicant_reconnect(void *wpa_s) |
499 | { | |
500 | wpa_supplicant_reconnect(wpa_s); | |
501 | } | |
502 | ||
503 | ||
6fc6879b JM |
504 | static void * wpa_supplicant_get_network_ctx(void *wpa_s) |
505 | { | |
506 | return wpa_supplicant_get_ssid(wpa_s); | |
507 | } | |
508 | ||
509 | ||
510 | static int wpa_supplicant_get_bssid(void *ctx, u8 *bssid) | |
511 | { | |
512 | struct wpa_supplicant *wpa_s = ctx; | |
6fc6879b JM |
513 | return wpa_drv_get_bssid(wpa_s, bssid); |
514 | } | |
515 | ||
516 | ||
71934751 | 517 | static int wpa_supplicant_set_key(void *_wpa_s, enum wpa_alg alg, |
6fc6879b JM |
518 | const u8 *addr, int key_idx, int set_tx, |
519 | const u8 *seq, size_t seq_len, | |
a919a260 AW |
520 | const u8 *key, size_t key_len, |
521 | enum key_flag key_flag) | |
6fc6879b | 522 | { |
46690a3b JM |
523 | struct wpa_supplicant *wpa_s = _wpa_s; |
524 | if (alg == WPA_ALG_TKIP && key_idx == 0 && key_len == 32) { | |
525 | /* Clear the MIC error counter when setting a new PTK. */ | |
526 | wpa_s->mic_errors_seen = 0; | |
527 | } | |
fa7ae950 JM |
528 | #ifdef CONFIG_TESTING_GET_GTK |
529 | if (key_idx > 0 && addr && is_broadcast_ether_addr(addr) && | |
530 | alg != WPA_ALG_NONE && key_len <= sizeof(wpa_s->last_gtk)) { | |
531 | os_memcpy(wpa_s->last_gtk, key, key_len); | |
532 | wpa_s->last_gtk_len = key_len; | |
533 | } | |
534 | #endif /* CONFIG_TESTING_GET_GTK */ | |
16579769 | 535 | #ifdef CONFIG_TESTING_OPTIONS |
b17b7a8e AW |
536 | if (addr && !is_broadcast_ether_addr(addr) && |
537 | !(key_flag & KEY_FLAG_MODIFY)) { | |
16579769 JM |
538 | wpa_s->last_tk_alg = alg; |
539 | os_memcpy(wpa_s->last_tk_addr, addr, ETH_ALEN); | |
540 | wpa_s->last_tk_key_idx = key_idx; | |
541 | if (key) | |
542 | os_memcpy(wpa_s->last_tk, key, key_len); | |
543 | wpa_s->last_tk_len = key_len; | |
544 | } | |
545 | #endif /* CONFIG_TESTING_OPTIONS */ | |
6fc6879b | 546 | return wpa_drv_set_key(wpa_s, alg, addr, key_idx, set_tx, seq, seq_len, |
a919a260 | 547 | key, key_len, key_flag); |
6fc6879b JM |
548 | } |
549 | ||
550 | ||
551 | static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr, | |
552 | int protection_type, | |
553 | int key_type) | |
554 | { | |
555 | return wpa_drv_mlme_setprotection(wpa_s, addr, protection_type, | |
556 | key_type); | |
557 | } | |
558 | ||
559 | ||
c5793127 JM |
560 | static struct wpa_ssid * wpas_get_network_ctx(struct wpa_supplicant *wpa_s, |
561 | void *network_ctx) | |
562 | { | |
563 | struct wpa_ssid *ssid; | |
564 | ||
565 | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { | |
566 | if (network_ctx == ssid) | |
567 | return ssid; | |
568 | } | |
569 | ||
570 | return NULL; | |
571 | } | |
572 | ||
573 | ||
574 | static int wpa_supplicant_add_pmkid(void *_wpa_s, void *network_ctx, | |
42e69bda VK |
575 | const u8 *bssid, const u8 *pmkid, |
576 | const u8 *fils_cache_id, | |
bbf94a09 VJ |
577 | const u8 *pmk, size_t pmk_len, |
578 | u32 pmk_lifetime, u8 pmk_reauth_threshold) | |
6fc6879b | 579 | { |
c5793127 JM |
580 | struct wpa_supplicant *wpa_s = _wpa_s; |
581 | struct wpa_ssid *ssid; | |
6fbb5414 | 582 | struct wpa_pmkid_params params; |
c5793127 | 583 | |
6fbb5414 | 584 | os_memset(¶ms, 0, sizeof(params)); |
c5793127 JM |
585 | ssid = wpas_get_network_ctx(wpa_s, network_ctx); |
586 | if (ssid) | |
587 | wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_ADDED MACSTR " %d", | |
588 | MAC2STR(bssid), ssid->id); | |
42e69bda VK |
589 | if (ssid && fils_cache_id) { |
590 | params.ssid = ssid->ssid; | |
591 | params.ssid_len = ssid->ssid_len; | |
592 | params.fils_cache_id = fils_cache_id; | |
593 | } else { | |
594 | params.bssid = bssid; | |
595 | } | |
596 | ||
6fbb5414 | 597 | params.pmkid = pmkid; |
42e69bda VK |
598 | params.pmk = pmk; |
599 | params.pmk_len = pmk_len; | |
bbf94a09 VJ |
600 | params.pmk_lifetime = pmk_lifetime; |
601 | params.pmk_reauth_threshold = pmk_reauth_threshold; | |
6fbb5414 VK |
602 | |
603 | return wpa_drv_add_pmkid(wpa_s, ¶ms); | |
6fc6879b JM |
604 | } |
605 | ||
606 | ||
c5793127 | 607 | static int wpa_supplicant_remove_pmkid(void *_wpa_s, void *network_ctx, |
42e69bda VK |
608 | const u8 *bssid, const u8 *pmkid, |
609 | const u8 *fils_cache_id) | |
6fc6879b | 610 | { |
c5793127 JM |
611 | struct wpa_supplicant *wpa_s = _wpa_s; |
612 | struct wpa_ssid *ssid; | |
6fbb5414 | 613 | struct wpa_pmkid_params params; |
c5793127 | 614 | |
6fbb5414 | 615 | os_memset(¶ms, 0, sizeof(params)); |
c5793127 JM |
616 | ssid = wpas_get_network_ctx(wpa_s, network_ctx); |
617 | if (ssid) | |
618 | wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_REMOVED MACSTR " %d", | |
619 | MAC2STR(bssid), ssid->id); | |
42e69bda VK |
620 | if (ssid && fils_cache_id) { |
621 | params.ssid = ssid->ssid; | |
622 | params.ssid_len = ssid->ssid_len; | |
623 | params.fils_cache_id = fils_cache_id; | |
624 | } else { | |
625 | params.bssid = bssid; | |
626 | } | |
6fbb5414 | 627 | |
6fbb5414 VK |
628 | params.pmkid = pmkid; |
629 | ||
630 | return wpa_drv_remove_pmkid(wpa_s, ¶ms); | |
6fc6879b JM |
631 | } |
632 | ||
633 | ||
634 | #ifdef CONFIG_IEEE80211R | |
635 | static int wpa_supplicant_update_ft_ies(void *ctx, const u8 *md, | |
636 | const u8 *ies, size_t ies_len) | |
637 | { | |
638 | struct wpa_supplicant *wpa_s = ctx; | |
c2a04078 JM |
639 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) |
640 | return sme_update_ft_ies(wpa_s, md, ies, ies_len); | |
6fc6879b JM |
641 | return wpa_drv_update_ft_ies(wpa_s, md, ies, ies_len); |
642 | } | |
643 | ||
644 | ||
645 | static int wpa_supplicant_send_ft_action(void *ctx, u8 action, | |
646 | const u8 *target_ap, | |
647 | const u8 *ies, size_t ies_len) | |
648 | { | |
649 | struct wpa_supplicant *wpa_s = ctx; | |
8105821b JM |
650 | int ret; |
651 | u8 *data, *pos; | |
652 | size_t data_len; | |
653 | ||
654 | if (action != 1) { | |
655 | wpa_printf(MSG_ERROR, "Unsupported send_ft_action action %d", | |
656 | action); | |
657 | return -1; | |
658 | } | |
659 | ||
660 | /* | |
661 | * Action frame payload: | |
662 | * Category[1] = 6 (Fast BSS Transition) | |
663 | * Action[1] = 1 (Fast BSS Transition Request) | |
664 | * STA Address | |
665 | * Target AP Address | |
666 | * FT IEs | |
667 | */ | |
668 | ||
669 | data_len = 2 + 2 * ETH_ALEN + ies_len; | |
670 | data = os_malloc(data_len); | |
671 | if (data == NULL) | |
672 | return -1; | |
673 | pos = data; | |
674 | *pos++ = 0x06; /* FT Action category */ | |
675 | *pos++ = action; | |
676 | os_memcpy(pos, wpa_s->own_addr, ETH_ALEN); | |
677 | pos += ETH_ALEN; | |
678 | os_memcpy(pos, target_ap, ETH_ALEN); | |
679 | pos += ETH_ALEN; | |
680 | os_memcpy(pos, ies, ies_len); | |
681 | ||
682 | ret = wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, | |
683 | wpa_s->bssid, wpa_s->own_addr, wpa_s->bssid, | |
684 | data, data_len, 0); | |
685 | os_free(data); | |
686 | ||
687 | return ret; | |
6fc6879b | 688 | } |
2a7e7f4e JM |
689 | |
690 | ||
691 | static int wpa_supplicant_mark_authenticated(void *ctx, const u8 *target_ap) | |
692 | { | |
693 | struct wpa_supplicant *wpa_s = ctx; | |
694 | struct wpa_driver_auth_params params; | |
695 | struct wpa_bss *bss; | |
696 | ||
2a7e7f4e JM |
697 | bss = wpa_bss_get_bssid(wpa_s, target_ap); |
698 | if (bss == NULL) | |
699 | return -1; | |
700 | ||
701 | os_memset(¶ms, 0, sizeof(params)); | |
702 | params.bssid = target_ap; | |
703 | params.freq = bss->freq; | |
704 | params.ssid = bss->ssid; | |
705 | params.ssid_len = bss->ssid_len; | |
706 | params.auth_alg = WPA_AUTH_ALG_FT; | |
707 | params.local_state_change = 1; | |
708 | return wpa_drv_authenticate(wpa_s, ¶ms); | |
709 | } | |
6fc6879b JM |
710 | #endif /* CONFIG_IEEE80211R */ |
711 | ||
6fc6879b | 712 | |
281ff0aa GP |
713 | #ifdef CONFIG_TDLS |
714 | ||
c58ab8f2 | 715 | static int wpa_supplicant_tdls_get_capa(void *ctx, int *tdls_supported, |
4daa5729 AN |
716 | int *tdls_ext_setup, |
717 | int *tdls_chan_switch) | |
c58ab8f2 AN |
718 | { |
719 | struct wpa_supplicant *wpa_s = ctx; | |
720 | ||
721 | *tdls_supported = 0; | |
722 | *tdls_ext_setup = 0; | |
4daa5729 | 723 | *tdls_chan_switch = 0; |
c58ab8f2 AN |
724 | |
725 | if (!wpa_s->drv_capa_known) | |
726 | return -1; | |
727 | ||
728 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_SUPPORT) | |
729 | *tdls_supported = 1; | |
730 | ||
731 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_EXTERNAL_SETUP) | |
732 | *tdls_ext_setup = 1; | |
733 | ||
4daa5729 AN |
734 | if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_TDLS_CHANNEL_SWITCH) |
735 | *tdls_chan_switch = 1; | |
736 | ||
c58ab8f2 AN |
737 | return 0; |
738 | } | |
739 | ||
740 | ||
281ff0aa GP |
741 | static int wpa_supplicant_send_tdls_mgmt(void *ctx, const u8 *dst, |
742 | u8 action_code, u8 dialog_token, | |
96ecea5e | 743 | u16 status_code, u32 peer_capab, |
984dadc2 AN |
744 | int initiator, const u8 *buf, |
745 | size_t len) | |
281ff0aa GP |
746 | { |
747 | struct wpa_supplicant *wpa_s = ctx; | |
748 | return wpa_drv_send_tdls_mgmt(wpa_s, dst, action_code, dialog_token, | |
984dadc2 AN |
749 | status_code, peer_capab, initiator, buf, |
750 | len); | |
281ff0aa GP |
751 | } |
752 | ||
753 | ||
754 | static int wpa_supplicant_tdls_oper(void *ctx, int oper, const u8 *peer) | |
755 | { | |
756 | struct wpa_supplicant *wpa_s = ctx; | |
757 | return wpa_drv_tdls_oper(wpa_s, oper, peer); | |
758 | } | |
759 | ||
45b722f1 AN |
760 | |
761 | static int wpa_supplicant_tdls_peer_addset( | |
78533699 | 762 | void *ctx, const u8 *peer, int add, u16 aid, u16 capability, |
ff4178d5 SD |
763 | const u8 *supp_rates, size_t supp_rates_len, |
764 | const struct ieee80211_ht_capabilities *ht_capab, | |
f8361e3d | 765 | const struct ieee80211_vht_capabilities *vht_capab, |
08d7665c | 766 | u8 qosinfo, int wmm, const u8 *ext_capab, size_t ext_capab_len, |
3ed97271 SD |
767 | const u8 *supp_channels, size_t supp_channels_len, |
768 | const u8 *supp_oper_classes, size_t supp_oper_classes_len) | |
45b722f1 AN |
769 | { |
770 | struct wpa_supplicant *wpa_s = ctx; | |
771 | struct hostapd_sta_add_params params; | |
772 | ||
b8df43de JM |
773 | os_memset(¶ms, 0, sizeof(params)); |
774 | ||
45b722f1 | 775 | params.addr = peer; |
f11b72c3 | 776 | params.aid = aid; |
45b722f1 AN |
777 | params.capability = capability; |
778 | params.flags = WPA_STA_TDLS_PEER | WPA_STA_AUTHORIZED; | |
ff4178d5 SD |
779 | |
780 | /* | |
08d7665c AN |
781 | * Don't rely only on qosinfo for WMM capability. It may be 0 even when |
782 | * present. Allow the WMM IE to also indicate QoS support. | |
ff4178d5 | 783 | */ |
08d7665c | 784 | if (wmm || qosinfo) |
ff4178d5 SD |
785 | params.flags |= WPA_STA_WMM; |
786 | ||
787 | params.ht_capabilities = ht_capab; | |
f8361e3d | 788 | params.vht_capabilities = vht_capab; |
ff4178d5 | 789 | params.qosinfo = qosinfo; |
45b722f1 AN |
790 | params.listen_interval = 0; |
791 | params.supp_rates = supp_rates; | |
792 | params.supp_rates_len = supp_rates_len; | |
793 | params.set = !add; | |
d16531c4 SD |
794 | params.ext_capab = ext_capab; |
795 | params.ext_capab_len = ext_capab_len; | |
3ed97271 SD |
796 | params.supp_channels = supp_channels; |
797 | params.supp_channels_len = supp_channels_len; | |
798 | params.supp_oper_classes = supp_oper_classes; | |
799 | params.supp_oper_classes_len = supp_oper_classes_len; | |
45b722f1 AN |
800 | |
801 | return wpa_drv_sta_add(wpa_s, ¶ms); | |
802 | } | |
803 | ||
6b90deae AN |
804 | |
805 | static int wpa_supplicant_tdls_enable_channel_switch( | |
806 | void *ctx, const u8 *addr, u8 oper_class, | |
807 | const struct hostapd_freq_params *params) | |
808 | { | |
809 | struct wpa_supplicant *wpa_s = ctx; | |
810 | ||
811 | return wpa_drv_tdls_enable_channel_switch(wpa_s, addr, oper_class, | |
812 | params); | |
813 | } | |
814 | ||
815 | ||
816 | static int wpa_supplicant_tdls_disable_channel_switch(void *ctx, const u8 *addr) | |
817 | { | |
818 | struct wpa_supplicant *wpa_s = ctx; | |
819 | ||
820 | return wpa_drv_tdls_disable_channel_switch(wpa_s, addr); | |
821 | } | |
822 | ||
281ff0aa GP |
823 | #endif /* CONFIG_TDLS */ |
824 | ||
9aaa6955 JM |
825 | #endif /* CONFIG_NO_WPA */ |
826 | ||
281ff0aa | 827 | |
81c57e22 DW |
828 | enum wpa_ctrl_req_type wpa_supplicant_ctrl_req_from_string(const char *field) |
829 | { | |
830 | if (os_strcmp(field, "IDENTITY") == 0) | |
831 | return WPA_CTRL_REQ_EAP_IDENTITY; | |
832 | else if (os_strcmp(field, "PASSWORD") == 0) | |
833 | return WPA_CTRL_REQ_EAP_PASSWORD; | |
834 | else if (os_strcmp(field, "NEW_PASSWORD") == 0) | |
835 | return WPA_CTRL_REQ_EAP_NEW_PASSWORD; | |
836 | else if (os_strcmp(field, "PIN") == 0) | |
837 | return WPA_CTRL_REQ_EAP_PIN; | |
838 | else if (os_strcmp(field, "OTP") == 0) | |
839 | return WPA_CTRL_REQ_EAP_OTP; | |
840 | else if (os_strcmp(field, "PASSPHRASE") == 0) | |
841 | return WPA_CTRL_REQ_EAP_PASSPHRASE; | |
a5d44ac0 JM |
842 | else if (os_strcmp(field, "SIM") == 0) |
843 | return WPA_CTRL_REQ_SIM; | |
a52410c2 JM |
844 | else if (os_strcmp(field, "PSK_PASSPHRASE") == 0) |
845 | return WPA_CTRL_REQ_PSK_PASSPHRASE; | |
3c108b75 JM |
846 | else if (os_strcmp(field, "EXT_CERT_CHECK") == 0) |
847 | return WPA_CTRL_REQ_EXT_CERT_CHECK; | |
81c57e22 DW |
848 | return WPA_CTRL_REQ_UNKNOWN; |
849 | } | |
850 | ||
851 | ||
9ef1aaae DW |
852 | const char * wpa_supplicant_ctrl_req_to_string(enum wpa_ctrl_req_type field, |
853 | const char *default_txt, | |
854 | const char **txt) | |
855 | { | |
856 | const char *ret = NULL; | |
857 | ||
858 | *txt = default_txt; | |
859 | ||
860 | switch (field) { | |
861 | case WPA_CTRL_REQ_EAP_IDENTITY: | |
862 | *txt = "Identity"; | |
863 | ret = "IDENTITY"; | |
864 | break; | |
865 | case WPA_CTRL_REQ_EAP_PASSWORD: | |
866 | *txt = "Password"; | |
867 | ret = "PASSWORD"; | |
868 | break; | |
869 | case WPA_CTRL_REQ_EAP_NEW_PASSWORD: | |
870 | *txt = "New Password"; | |
871 | ret = "NEW_PASSWORD"; | |
872 | break; | |
873 | case WPA_CTRL_REQ_EAP_PIN: | |
874 | *txt = "PIN"; | |
875 | ret = "PIN"; | |
876 | break; | |
877 | case WPA_CTRL_REQ_EAP_OTP: | |
878 | ret = "OTP"; | |
879 | break; | |
880 | case WPA_CTRL_REQ_EAP_PASSPHRASE: | |
881 | *txt = "Private key passphrase"; | |
882 | ret = "PASSPHRASE"; | |
883 | break; | |
a5d44ac0 JM |
884 | case WPA_CTRL_REQ_SIM: |
885 | ret = "SIM"; | |
886 | break; | |
a52410c2 JM |
887 | case WPA_CTRL_REQ_PSK_PASSPHRASE: |
888 | *txt = "PSK or passphrase"; | |
889 | ret = "PSK_PASSPHRASE"; | |
890 | break; | |
3c108b75 JM |
891 | case WPA_CTRL_REQ_EXT_CERT_CHECK: |
892 | *txt = "External server certificate validation"; | |
893 | ret = "EXT_CERT_CHECK"; | |
894 | break; | |
9ef1aaae DW |
895 | default: |
896 | break; | |
897 | } | |
898 | ||
899 | /* txt needs to be something */ | |
900 | if (*txt == NULL) { | |
901 | wpa_printf(MSG_WARNING, "No message for request %d", field); | |
902 | ret = NULL; | |
903 | } | |
904 | ||
905 | return ret; | |
906 | } | |
907 | ||
a52410c2 JM |
908 | |
909 | void wpas_send_ctrl_req(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, | |
910 | const char *field_name, const char *txt) | |
911 | { | |
912 | char *buf; | |
913 | size_t buflen; | |
914 | int len; | |
915 | ||
916 | buflen = 100 + os_strlen(txt) + ssid->ssid_len; | |
917 | buf = os_malloc(buflen); | |
918 | if (buf == NULL) | |
919 | return; | |
920 | len = os_snprintf(buf, buflen, "%s-%d:%s needed for SSID ", | |
921 | field_name, ssid->id, txt); | |
922 | if (os_snprintf_error(buflen, len)) { | |
923 | os_free(buf); | |
924 | return; | |
925 | } | |
926 | if (ssid->ssid && buflen > len + ssid->ssid_len) { | |
927 | os_memcpy(buf + len, ssid->ssid, ssid->ssid_len); | |
928 | len += ssid->ssid_len; | |
929 | buf[len] = '\0'; | |
930 | } | |
931 | buf[buflen - 1] = '\0'; | |
932 | wpa_msg(wpa_s, MSG_INFO, WPA_CTRL_REQ "%s", buf); | |
933 | os_free(buf); | |
934 | } | |
935 | ||
936 | ||
b1491202 | 937 | #ifdef IEEE8021X_EAPOL |
6fc6879b | 938 | #if defined(CONFIG_CTRL_IFACE) || !defined(CONFIG_NO_STDOUT_DEBUG) |
9ef1aaae DW |
939 | static void wpa_supplicant_eap_param_needed(void *ctx, |
940 | enum wpa_ctrl_req_type field, | |
941 | const char *default_txt) | |
6fc6879b JM |
942 | { |
943 | struct wpa_supplicant *wpa_s = ctx; | |
944 | struct wpa_ssid *ssid = wpa_s->current_ssid; | |
9ef1aaae | 945 | const char *field_name, *txt = NULL; |
6fc6879b JM |
946 | |
947 | if (ssid == NULL) | |
948 | return; | |
949 | ||
3c108b75 JM |
950 | if (field == WPA_CTRL_REQ_EXT_CERT_CHECK) |
951 | ssid->eap.pending_ext_cert_check = PENDING_CHECK; | |
a9022616 DW |
952 | wpas_notify_network_request(wpa_s, ssid, field, default_txt); |
953 | ||
9ef1aaae DW |
954 | field_name = wpa_supplicant_ctrl_req_to_string(field, default_txt, |
955 | &txt); | |
956 | if (field_name == NULL) { | |
957 | wpa_printf(MSG_WARNING, "Unhandled EAP param %d needed", | |
958 | field); | |
959 | return; | |
960 | } | |
961 | ||
93c7e332 PS |
962 | wpas_notify_eap_status(wpa_s, "eap parameter needed", field_name); |
963 | ||
a52410c2 | 964 | wpas_send_ctrl_req(wpa_s, ssid, field_name, txt); |
6fc6879b JM |
965 | } |
966 | #else /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */ | |
967 | #define wpa_supplicant_eap_param_needed NULL | |
968 | #endif /* CONFIG_CTRL_IFACE || !CONFIG_NO_STDOUT_DEBUG */ | |
969 | ||
970 | ||
dd5c155e | 971 | #ifdef CONFIG_EAP_PROXY |
a6f3761f | 972 | |
dd5c155e SD |
973 | static void wpa_supplicant_eap_proxy_cb(void *ctx) |
974 | { | |
975 | struct wpa_supplicant *wpa_s = ctx; | |
976 | size_t len; | |
977 | ||
b5db6e5d | 978 | wpa_s->mnc_len = eapol_sm_get_eap_proxy_imsi(wpa_s->eapol, -1, |
dd5c155e SD |
979 | wpa_s->imsi, &len); |
980 | if (wpa_s->mnc_len > 0) { | |
981 | wpa_s->imsi[len] = '\0'; | |
982 | wpa_printf(MSG_DEBUG, "eap_proxy: IMSI %s (MNC length %d)", | |
983 | wpa_s->imsi, wpa_s->mnc_len); | |
984 | } else { | |
985 | wpa_printf(MSG_DEBUG, "eap_proxy: IMSI not available"); | |
986 | } | |
987 | } | |
a6f3761f PK |
988 | |
989 | ||
c167662d PK |
990 | static void wpa_sm_sim_state_error_handler(struct wpa_supplicant *wpa_s) |
991 | { | |
992 | int i; | |
993 | struct wpa_ssid *ssid; | |
994 | const struct eap_method_type *eap_methods; | |
995 | ||
996 | if (!wpa_s->conf) | |
997 | return; | |
998 | ||
999 | for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) { | |
1000 | eap_methods = ssid->eap.eap_methods; | |
1001 | if (!eap_methods) | |
1002 | continue; | |
1003 | ||
1004 | for (i = 0; eap_methods[i].method != EAP_TYPE_NONE; i++) { | |
1005 | if (eap_methods[i].vendor == EAP_VENDOR_IETF && | |
1006 | (eap_methods[i].method == EAP_TYPE_SIM || | |
1007 | eap_methods[i].method == EAP_TYPE_AKA || | |
1008 | eap_methods[i].method == EAP_TYPE_AKA_PRIME)) { | |
1009 | wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid); | |
1010 | break; | |
1011 | } | |
1012 | } | |
1013 | } | |
1014 | } | |
1015 | ||
1016 | ||
a6f3761f PK |
1017 | static void |
1018 | wpa_supplicant_eap_proxy_notify_sim_status(void *ctx, | |
1019 | enum eap_proxy_sim_state sim_state) | |
1020 | { | |
1021 | struct wpa_supplicant *wpa_s = ctx; | |
1022 | ||
1023 | wpa_printf(MSG_DEBUG, "eap_proxy: SIM card status %u", sim_state); | |
1024 | switch (sim_state) { | |
1025 | case SIM_STATE_ERROR: | |
c167662d | 1026 | wpa_sm_sim_state_error_handler(wpa_s); |
a6f3761f PK |
1027 | break; |
1028 | default: | |
1029 | wpa_printf(MSG_DEBUG, "eap_proxy: SIM card status unknown"); | |
1030 | break; | |
1031 | } | |
1032 | } | |
1033 | ||
dd5c155e SD |
1034 | #endif /* CONFIG_EAP_PROXY */ |
1035 | ||
1036 | ||
4bc181ec JM |
1037 | static void wpa_supplicant_port_cb(void *ctx, int authorized) |
1038 | { | |
1039 | struct wpa_supplicant *wpa_s = ctx; | |
69a6b47a JM |
1040 | #ifdef CONFIG_AP |
1041 | if (wpa_s->ap_iface) { | |
1042 | wpa_printf(MSG_DEBUG, "AP mode active - skip EAPOL Supplicant " | |
1043 | "port status: %s", | |
1044 | authorized ? "Authorized" : "Unauthorized"); | |
1045 | return; | |
1046 | } | |
1047 | #endif /* CONFIG_AP */ | |
4bc181ec JM |
1048 | wpa_printf(MSG_DEBUG, "EAPOL: Supplicant port status: %s", |
1049 | authorized ? "Authorized" : "Unauthorized"); | |
1050 | wpa_drv_set_supp_port(wpa_s, authorized); | |
1051 | } | |
ade74830 MC |
1052 | |
1053 | ||
bc0634da JM |
1054 | static void wpa_supplicant_cert_cb(void *ctx, struct tls_cert_data *cert, |
1055 | const char *cert_hash) | |
ade74830 MC |
1056 | { |
1057 | struct wpa_supplicant *wpa_s = ctx; | |
1058 | ||
bc0634da | 1059 | wpas_notify_certification(wpa_s, cert, cert_hash); |
ade74830 | 1060 | } |
dd7fec1f PS |
1061 | |
1062 | ||
1063 | static void wpa_supplicant_status_cb(void *ctx, const char *status, | |
1064 | const char *parameter) | |
1065 | { | |
1066 | struct wpa_supplicant *wpa_s = ctx; | |
1067 | ||
1068 | wpas_notify_eap_status(wpa_s, status, parameter); | |
1069 | } | |
e026159a JM |
1070 | |
1071 | ||
45f7574d AE |
1072 | static void wpa_supplicant_eap_error_cb(void *ctx, int error_code) |
1073 | { | |
1074 | struct wpa_supplicant *wpa_s = ctx; | |
1075 | ||
1076 | wpas_notify_eap_error(wpa_s, error_code); | |
1077 | } | |
1078 | ||
1079 | ||
1f90a49d AW |
1080 | static int wpa_supplicant_eap_auth_start_cb(void *ctx) |
1081 | { | |
1082 | struct wpa_supplicant *wpa_s = ctx; | |
1083 | ||
b17b7a8e AW |
1084 | if (!wpa_s->new_connection && wpa_s->deny_ptk0_rekey && |
1085 | !wpa_sm_ext_key_id_active(wpa_s->wpa)) { | |
1f90a49d AW |
1086 | wpa_msg(wpa_s, MSG_INFO, |
1087 | "WPA: PTK0 rekey not allowed, reconnecting"); | |
1088 | wpa_supplicant_reconnect(wpa_s); | |
1089 | return -1; | |
1090 | } | |
1091 | return 0; | |
1092 | } | |
1093 | ||
1094 | ||
e026159a JM |
1095 | static void wpa_supplicant_set_anon_id(void *ctx, const u8 *id, size_t len) |
1096 | { | |
1097 | struct wpa_supplicant *wpa_s = ctx; | |
1098 | char *str; | |
1099 | int res; | |
1100 | ||
1101 | wpa_hexdump_ascii(MSG_DEBUG, "EAP method updated anonymous_identity", | |
1102 | id, len); | |
1103 | ||
1104 | if (wpa_s->current_ssid == NULL) | |
1105 | return; | |
1106 | ||
1107 | if (id == NULL) { | |
1108 | if (wpa_config_set(wpa_s->current_ssid, "anonymous_identity", | |
1109 | "NULL", 0) < 0) | |
1110 | return; | |
1111 | } else { | |
1112 | str = os_malloc(len * 2 + 1); | |
1113 | if (str == NULL) | |
1114 | return; | |
1115 | wpa_snprintf_hex(str, len * 2 + 1, id, len); | |
1116 | res = wpa_config_set(wpa_s->current_ssid, "anonymous_identity", | |
1117 | str, 0); | |
1118 | os_free(str); | |
1119 | if (res < 0) | |
1120 | return; | |
1121 | } | |
1122 | ||
1123 | if (wpa_s->conf->update_config) { | |
1124 | res = wpa_config_write(wpa_s->confname, wpa_s->conf); | |
1125 | if (res) { | |
1126 | wpa_printf(MSG_DEBUG, "Failed to update config after " | |
1127 | "anonymous_id update"); | |
1128 | } | |
1129 | } | |
1130 | } | |
b1491202 | 1131 | #endif /* IEEE8021X_EAPOL */ |
4bc181ec JM |
1132 | |
1133 | ||
6fc6879b JM |
1134 | int wpa_supplicant_init_eapol(struct wpa_supplicant *wpa_s) |
1135 | { | |
1136 | #ifdef IEEE8021X_EAPOL | |
1137 | struct eapol_ctx *ctx; | |
1138 | ctx = os_zalloc(sizeof(*ctx)); | |
1139 | if (ctx == NULL) { | |
1140 | wpa_printf(MSG_ERROR, "Failed to allocate EAPOL context."); | |
1141 | return -1; | |
1142 | } | |
1143 | ||
1144 | ctx->ctx = wpa_s; | |
1145 | ctx->msg_ctx = wpa_s; | |
1146 | ctx->eapol_send_ctx = wpa_s; | |
1147 | ctx->preauth = 0; | |
1148 | ctx->eapol_done_cb = wpa_supplicant_notify_eapol_done; | |
1149 | ctx->eapol_send = wpa_supplicant_eapol_send; | |
200c7693 | 1150 | #ifdef CONFIG_WEP |
6fc6879b | 1151 | ctx->set_wep_key = wpa_eapol_set_wep_key; |
200c7693 | 1152 | #endif /* CONFIG_WEP */ |
21f01a8e | 1153 | #ifndef CONFIG_NO_CONFIG_BLOBS |
6fc6879b JM |
1154 | ctx->set_config_blob = wpa_supplicant_set_config_blob; |
1155 | ctx->get_config_blob = wpa_supplicant_get_config_blob; | |
21f01a8e | 1156 | #endif /* CONFIG_NO_CONFIG_BLOBS */ |
6fc6879b | 1157 | ctx->aborted_cached = wpa_supplicant_aborted_cached; |
6fc6879b JM |
1158 | ctx->opensc_engine_path = wpa_s->conf->opensc_engine_path; |
1159 | ctx->pkcs11_engine_path = wpa_s->conf->pkcs11_engine_path; | |
1160 | ctx->pkcs11_module_path = wpa_s->conf->pkcs11_module_path; | |
07e2de31 | 1161 | ctx->openssl_ciphers = wpa_s->conf->openssl_ciphers; |
116654ce | 1162 | ctx->wps = wpa_s->wps; |
6fc6879b | 1163 | ctx->eap_param_needed = wpa_supplicant_eap_param_needed; |
dd5c155e SD |
1164 | #ifdef CONFIG_EAP_PROXY |
1165 | ctx->eap_proxy_cb = wpa_supplicant_eap_proxy_cb; | |
a6f3761f PK |
1166 | ctx->eap_proxy_notify_sim_status = |
1167 | wpa_supplicant_eap_proxy_notify_sim_status; | |
dd5c155e | 1168 | #endif /* CONFIG_EAP_PROXY */ |
4bc181ec | 1169 | ctx->port_cb = wpa_supplicant_port_cb; |
6fc6879b | 1170 | ctx->cb = wpa_supplicant_eapol_cb; |
ade74830 | 1171 | ctx->cert_cb = wpa_supplicant_cert_cb; |
483dd6a5 | 1172 | ctx->cert_in_cb = wpa_s->conf->cert_in_cb; |
dd7fec1f | 1173 | ctx->status_cb = wpa_supplicant_status_cb; |
45f7574d | 1174 | ctx->eap_error_cb = wpa_supplicant_eap_error_cb; |
1f90a49d | 1175 | ctx->confirm_auth_cb = wpa_supplicant_eap_auth_start_cb; |
e026159a | 1176 | ctx->set_anon_id = wpa_supplicant_set_anon_id; |
6fc6879b JM |
1177 | ctx->cb_ctx = wpa_s; |
1178 | wpa_s->eapol = eapol_sm_init(ctx); | |
1179 | if (wpa_s->eapol == NULL) { | |
1180 | os_free(ctx); | |
1181 | wpa_printf(MSG_ERROR, "Failed to initialize EAPOL state " | |
1182 | "machines."); | |
1183 | return -1; | |
1184 | } | |
1185 | #endif /* IEEE8021X_EAPOL */ | |
1186 | ||
1187 | return 0; | |
1188 | } | |
1189 | ||
1190 | ||
77d7b090 | 1191 | #ifndef CONFIG_NO_WPA |
124ddfa1 | 1192 | |
98cd3d1c JM |
1193 | static void wpa_supplicant_set_rekey_offload(void *ctx, |
1194 | const u8 *kek, size_t kek_len, | |
1195 | const u8 *kck, size_t kck_len, | |
b14a210c JB |
1196 | const u8 *replay_ctr) |
1197 | { | |
1198 | struct wpa_supplicant *wpa_s = ctx; | |
1199 | ||
98cd3d1c | 1200 | wpa_drv_set_rekey_info(wpa_s, kek, kek_len, kck, kck_len, replay_ctr); |
b14a210c JB |
1201 | } |
1202 | ||
1203 | ||
b41f2684 CL |
1204 | static int wpa_supplicant_key_mgmt_set_pmk(void *ctx, const u8 *pmk, |
1205 | size_t pmk_len) | |
1206 | { | |
1207 | struct wpa_supplicant *wpa_s = ctx; | |
1208 | ||
a250722f JM |
1209 | if (wpa_s->conf->key_mgmt_offload && |
1210 | (wpa_s->drv_flags & WPA_DRIVER_FLAGS_KEY_MGMT_OFFLOAD)) | |
be15f33d | 1211 | return wpa_drv_set_key(wpa_s, 0, NULL, 0, 0, |
a919a260 | 1212 | NULL, 0, pmk, pmk_len, KEY_FLAG_PMK); |
b41f2684 CL |
1213 | else |
1214 | return 0; | |
1215 | } | |
124ddfa1 JM |
1216 | |
1217 | ||
1218 | static void wpa_supplicant_fils_hlp_rx(void *ctx, const u8 *dst, const u8 *src, | |
1219 | const u8 *pkt, size_t pkt_len) | |
1220 | { | |
1221 | struct wpa_supplicant *wpa_s = ctx; | |
1222 | char *hex; | |
1223 | size_t hexlen; | |
1224 | ||
1225 | hexlen = pkt_len * 2 + 1; | |
1226 | hex = os_malloc(hexlen); | |
1227 | if (!hex) | |
1228 | return; | |
1229 | wpa_snprintf_hex(hex, hexlen, pkt, pkt_len); | |
1230 | wpa_msg(wpa_s, MSG_INFO, FILS_HLP_RX "dst=" MACSTR " src=" MACSTR | |
1231 | " frame=%s", MAC2STR(dst), MAC2STR(src), hex); | |
1232 | os_free(hex); | |
1233 | } | |
1234 | ||
4b62b52e MV |
1235 | |
1236 | static int wpa_supplicant_channel_info(void *_wpa_s, | |
1237 | struct wpa_channel_info *ci) | |
1238 | { | |
1239 | struct wpa_supplicant *wpa_s = _wpa_s; | |
1240 | ||
1241 | return wpa_drv_channel_info(wpa_s, ci); | |
1242 | } | |
1243 | ||
9d1857cf JM |
1244 | |
1245 | static void disable_wpa_wpa2(struct wpa_ssid *ssid) | |
1246 | { | |
1247 | ssid->proto &= ~WPA_PROTO_WPA; | |
1248 | ssid->proto |= WPA_PROTO_RSN; | |
1249 | ssid->key_mgmt &= ~(WPA_KEY_MGMT_PSK | WPA_KEY_MGMT_FT_PSK | | |
1250 | WPA_KEY_MGMT_PSK_SHA256); | |
1251 | ssid->group_cipher &= ~WPA_CIPHER_TKIP; | |
1252 | if (!(ssid->group_cipher & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | | |
1253 | WPA_CIPHER_GCMP_256 | WPA_CIPHER_CCMP_256))) | |
1254 | ssid->group_cipher |= WPA_CIPHER_CCMP; | |
1255 | ssid->ieee80211w = MGMT_FRAME_PROTECTION_REQUIRED; | |
1256 | } | |
1257 | ||
1258 | ||
1259 | static void wpa_supplicant_transition_disable(void *_wpa_s, u8 bitmap) | |
1260 | { | |
1261 | struct wpa_supplicant *wpa_s = _wpa_s; | |
1262 | struct wpa_ssid *ssid; | |
1263 | int changed = 0; | |
1264 | ||
1265 | wpa_msg(wpa_s, MSG_INFO, TRANSITION_DISABLE "%02x", bitmap); | |
1266 | ||
1267 | ssid = wpa_s->current_ssid; | |
1268 | if (!ssid) | |
1269 | return; | |
1270 | ||
1271 | if ((bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) && | |
1272 | wpa_key_mgmt_sae(wpa_s->key_mgmt) && | |
1273 | (ssid->key_mgmt & (WPA_KEY_MGMT_SAE | WPA_KEY_MGMT_FT_SAE)) && | |
1274 | (ssid->ieee80211w != MGMT_FRAME_PROTECTION_REQUIRED || | |
1275 | (ssid->group_cipher & WPA_CIPHER_TKIP))) { | |
1276 | wpa_printf(MSG_DEBUG, | |
1277 | "WPA3-Personal transition mode disabled based on AP notification"); | |
1278 | disable_wpa_wpa2(ssid); | |
1279 | changed = 1; | |
1280 | } | |
1281 | ||
1282 | if ((bitmap & TRANSITION_DISABLE_WPA3_ENTERPRISE) && | |
1283 | wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt) && | |
1284 | (ssid->key_mgmt & (WPA_KEY_MGMT_IEEE8021X | | |
1285 | WPA_KEY_MGMT_FT_IEEE8021X | | |
1286 | WPA_KEY_MGMT_IEEE8021X_SHA256)) && | |
1287 | (ssid->ieee80211w != MGMT_FRAME_PROTECTION_REQUIRED || | |
1288 | (ssid->group_cipher & WPA_CIPHER_TKIP))) { | |
1289 | disable_wpa_wpa2(ssid); | |
1290 | changed = 1; | |
1291 | } | |
1292 | ||
1293 | if ((bitmap & TRANSITION_DISABLE_ENHANCED_OPEN) && | |
1294 | wpa_s->key_mgmt == WPA_KEY_MGMT_OWE && | |
1295 | (ssid->key_mgmt & WPA_KEY_MGMT_OWE) && | |
1296 | !ssid->owe_only) { | |
1297 | ssid->owe_only = 1; | |
1298 | changed = 1; | |
1299 | } | |
1300 | ||
1301 | if (!changed) | |
1302 | return; | |
1303 | ||
1304 | #ifndef CONFIG_NO_CONFIG_WRITE | |
1305 | if (wpa_s->conf->update_config && | |
1306 | wpa_config_write(wpa_s->confname, wpa_s->conf)) | |
1307 | wpa_printf(MSG_DEBUG, "Failed to update configuration"); | |
1308 | #endif /* CONFIG_NO_CONFIG_WRITE */ | |
1309 | } | |
1310 | ||
9e68742e | 1311 | #endif /* CONFIG_NO_WPA */ |
b41f2684 CL |
1312 | |
1313 | ||
6fc6879b JM |
1314 | int wpa_supplicant_init_wpa(struct wpa_supplicant *wpa_s) |
1315 | { | |
1316 | #ifndef CONFIG_NO_WPA | |
1317 | struct wpa_sm_ctx *ctx; | |
1318 | ctx = os_zalloc(sizeof(*ctx)); | |
1319 | if (ctx == NULL) { | |
1320 | wpa_printf(MSG_ERROR, "Failed to allocate WPA context."); | |
1321 | return -1; | |
1322 | } | |
1323 | ||
1324 | ctx->ctx = wpa_s; | |
0f057fb2 | 1325 | ctx->msg_ctx = wpa_s; |
6fc6879b JM |
1326 | ctx->set_state = _wpa_supplicant_set_state; |
1327 | ctx->get_state = _wpa_supplicant_get_state; | |
6fc6879b | 1328 | ctx->deauthenticate = _wpa_supplicant_deauthenticate; |
1f90a49d | 1329 | ctx->reconnect = _wpa_supplicant_reconnect; |
6fc6879b JM |
1330 | ctx->set_key = wpa_supplicant_set_key; |
1331 | ctx->get_network_ctx = wpa_supplicant_get_network_ctx; | |
1332 | ctx->get_bssid = wpa_supplicant_get_bssid; | |
1333 | ctx->ether_send = _wpa_ether_send; | |
1334 | ctx->get_beacon_ie = wpa_supplicant_get_beacon_ie; | |
1335 | ctx->alloc_eapol = _wpa_alloc_eapol; | |
1336 | ctx->cancel_auth_timeout = _wpa_supplicant_cancel_auth_timeout; | |
1337 | ctx->add_pmkid = wpa_supplicant_add_pmkid; | |
1338 | ctx->remove_pmkid = wpa_supplicant_remove_pmkid; | |
1339 | #ifndef CONFIG_NO_CONFIG_BLOBS | |
1340 | ctx->set_config_blob = wpa_supplicant_set_config_blob; | |
1341 | ctx->get_config_blob = wpa_supplicant_get_config_blob; | |
1342 | #endif /* CONFIG_NO_CONFIG_BLOBS */ | |
1343 | ctx->mlme_setprotection = wpa_supplicant_mlme_setprotection; | |
1344 | #ifdef CONFIG_IEEE80211R | |
1345 | ctx->update_ft_ies = wpa_supplicant_update_ft_ies; | |
1346 | ctx->send_ft_action = wpa_supplicant_send_ft_action; | |
2a7e7f4e | 1347 | ctx->mark_authenticated = wpa_supplicant_mark_authenticated; |
6fc6879b | 1348 | #endif /* CONFIG_IEEE80211R */ |
281ff0aa | 1349 | #ifdef CONFIG_TDLS |
c58ab8f2 | 1350 | ctx->tdls_get_capa = wpa_supplicant_tdls_get_capa; |
281ff0aa GP |
1351 | ctx->send_tdls_mgmt = wpa_supplicant_send_tdls_mgmt; |
1352 | ctx->tdls_oper = wpa_supplicant_tdls_oper; | |
45b722f1 | 1353 | ctx->tdls_peer_addset = wpa_supplicant_tdls_peer_addset; |
6b90deae AN |
1354 | ctx->tdls_enable_channel_switch = |
1355 | wpa_supplicant_tdls_enable_channel_switch; | |
1356 | ctx->tdls_disable_channel_switch = | |
1357 | wpa_supplicant_tdls_disable_channel_switch; | |
281ff0aa | 1358 | #endif /* CONFIG_TDLS */ |
b14a210c | 1359 | ctx->set_rekey_offload = wpa_supplicant_set_rekey_offload; |
b41f2684 | 1360 | ctx->key_mgmt_set_pmk = wpa_supplicant_key_mgmt_set_pmk; |
124ddfa1 | 1361 | ctx->fils_hlp_rx = wpa_supplicant_fils_hlp_rx; |
4b62b52e | 1362 | ctx->channel_info = wpa_supplicant_channel_info; |
9d1857cf | 1363 | ctx->transition_disable = wpa_supplicant_transition_disable; |
6fc6879b JM |
1364 | |
1365 | wpa_s->wpa = wpa_sm_init(ctx); | |
1366 | if (wpa_s->wpa == NULL) { | |
1367 | wpa_printf(MSG_ERROR, "Failed to initialize WPA state " | |
1368 | "machine"); | |
ef035578 | 1369 | os_free(ctx); |
6fc6879b JM |
1370 | return -1; |
1371 | } | |
1372 | #endif /* CONFIG_NO_WPA */ | |
1373 | ||
1374 | return 0; | |
1375 | } | |
1376 | ||
1377 | ||
1378 | void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s, | |
1379 | struct wpa_ssid *ssid) | |
1380 | { | |
1381 | struct rsn_supp_config conf; | |
1382 | if (ssid) { | |
1383 | os_memset(&conf, 0, sizeof(conf)); | |
886a807f | 1384 | conf.network_ctx = ssid; |
6fc6879b | 1385 | conf.allowed_pairwise_cipher = ssid->pairwise_cipher; |
a6a89fea | 1386 | #ifdef IEEE8021X_EAPOL |
6e202021 JM |
1387 | conf.proactive_key_caching = ssid->proactive_key_caching < 0 ? |
1388 | wpa_s->conf->okc : ssid->proactive_key_caching; | |
6fc6879b JM |
1389 | conf.eap_workaround = ssid->eap_workaround; |
1390 | conf.eap_conf_ctx = &ssid->eap; | |
a6a89fea | 1391 | #endif /* IEEE8021X_EAPOL */ |
6fc6879b JM |
1392 | conf.ssid = ssid->ssid; |
1393 | conf.ssid_len = ssid->ssid_len; | |
581a8cde | 1394 | conf.wpa_ptk_rekey = ssid->wpa_ptk_rekey; |
1f90a49d | 1395 | conf.wpa_deny_ptk0_rekey = ssid->wpa_deny_ptk0_rekey; |
8b138d28 | 1396 | conf.owe_ptk_workaround = ssid->owe_ptk_workaround; |
25ef8529 | 1397 | #ifdef CONFIG_P2P |
201b0f5f JM |
1398 | if (ssid->p2p_group && wpa_s->current_bss && |
1399 | !wpa_s->p2p_disable_ip_addr_req) { | |
25ef8529 JM |
1400 | struct wpabuf *p2p; |
1401 | p2p = wpa_bss_get_vendor_ie_multi(wpa_s->current_bss, | |
1402 | P2P_IE_VENDOR_TYPE); | |
1403 | if (p2p) { | |
1404 | u8 group_capab; | |
1405 | group_capab = p2p_get_group_capab(p2p); | |
1406 | if (group_capab & | |
1407 | P2P_GROUP_CAPAB_IP_ADDR_ALLOCATION) | |
1408 | conf.p2p = 1; | |
1409 | wpabuf_free(p2p); | |
1410 | } | |
1411 | } | |
1412 | #endif /* CONFIG_P2P */ | |
73ed03f3 | 1413 | conf.wpa_rsc_relaxation = wpa_s->conf->wpa_rsc_relaxation; |
869af307 JM |
1414 | #ifdef CONFIG_FILS |
1415 | if (wpa_key_mgmt_fils(wpa_s->key_mgmt)) | |
1416 | conf.fils_cache_id = | |
1417 | wpa_bss_get_fils_cache_id(wpa_s->current_bss); | |
1418 | #endif /* CONFIG_FILS */ | |
ecbf59e6 | 1419 | conf.beacon_prot = ssid->beacon_prot; |
6fc6879b JM |
1420 | } |
1421 | wpa_sm_set_config(wpa_s->wpa, ssid ? &conf : NULL); | |
1422 | } |