1 /*
2 * hostapd / WPA authenticator glue code
3 * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #include "utils/includes.h"
10
11 #include "utils/common.h"
12 #include "utils/eloop.h"
13 #include "utils/list.h"
14 #include "common/ieee802_11_defs.h"
15 #include "common/sae.h"
16 #include "common/wpa_ctrl.h"
17 #include "common/ptksa_cache.h"
18 #include "crypto/sha1.h"
19 #include "eapol_auth/eapol_auth_sm.h"
20 #include "eapol_auth/eapol_auth_sm_i.h"
21 #include "eap_server/eap.h"
22 #include "l2_packet/l2_packet.h"
23 #include "eth_p_oui.h"
24 #include "hostapd.h"
25 #include "ieee802_1x.h"
26 #include "preauth_auth.h"
27 #include "sta_info.h"
28 #include "tkip_countermeasures.h"
29 #include "ap_drv_ops.h"
30 #include "ap_config.h"
31 #include "ieee802_11.h"
32 #include "pmksa_cache_auth.h"
33 #include "wpa_auth.h"
34 #include "wpa_auth_glue.h"
35 #ifdef CONFIG_LIBWPA_VENDOR
36 #include "hostapd_client.h"
37 #endif
38
hostapd_wpa_auth_conf(struct hostapd_bss_config *conf, struct hostapd_config *iconf, struct wpa_auth_config *wconf)39 static void hostapd_wpa_auth_conf(struct hostapd_bss_config *conf,
40 struct hostapd_config *iconf,
41 struct wpa_auth_config *wconf)
42 {
43 int sae_pw_id;
44
45 os_memset(wconf, 0, sizeof(*wconf));
46 wconf->wpa = conf->wpa;
47 wconf->extended_key_id = conf->extended_key_id;
48 wconf->wpa_key_mgmt = conf->wpa_key_mgmt;
49 wconf->wpa_pairwise = conf->wpa_pairwise;
50 wconf->wpa_group = conf->wpa_group;
51 wconf->wpa_group_rekey = conf->wpa_group_rekey;
52 wconf->wpa_strict_rekey = conf->wpa_strict_rekey;
53 wconf->wpa_gmk_rekey = conf->wpa_gmk_rekey;
54 wconf->wpa_ptk_rekey = conf->wpa_ptk_rekey;
55 wconf->wpa_group_update_count = conf->wpa_group_update_count;
56 wconf->wpa_disable_eapol_key_retries =
57 conf->wpa_disable_eapol_key_retries;
58 wconf->wpa_pairwise_update_count = conf->wpa_pairwise_update_count;
59 wconf->rsn_pairwise = conf->rsn_pairwise;
60 wconf->rsn_preauth = conf->rsn_preauth;
61 wconf->eapol_version = conf->eapol_version;
62 #ifdef CONFIG_MACSEC
63 if (wconf->eapol_version > 2)
64 wconf->eapol_version = 2;
65 #endif /* CONFIG_MACSEC */
66 wconf->wmm_enabled = conf->wmm_enabled;
67 wconf->wmm_uapsd = conf->wmm_uapsd;
68 wconf->disable_pmksa_caching = conf->disable_pmksa_caching;
69 #ifdef CONFIG_OCV
70 wconf->ocv = conf->ocv;
71 #endif /* CONFIG_OCV */
72 wconf->okc = conf->okc;
73 wconf->ieee80211w = conf->ieee80211w;
74 wconf->beacon_prot = conf->beacon_prot;
75 wconf->group_mgmt_cipher = conf->group_mgmt_cipher;
76 wconf->sae_require_mfp = conf->sae_require_mfp;
77 #ifdef CONFIG_IEEE80211R_AP
78 wconf->ssid_len = conf->ssid.ssid_len;
79 if (wconf->ssid_len > SSID_MAX_LEN)
80 wconf->ssid_len = SSID_MAX_LEN;
81 os_memcpy(wconf->ssid, conf->ssid.ssid, wconf->ssid_len);
82 os_memcpy(wconf->mobility_domain, conf->mobility_domain,
83 MOBILITY_DOMAIN_ID_LEN);
84 if (conf->nas_identifier &&
85 os_strlen(conf->nas_identifier) <= FT_R0KH_ID_MAX_LEN) {
86 wconf->r0_key_holder_len = os_strlen(conf->nas_identifier);
87 os_memcpy(wconf->r0_key_holder, conf->nas_identifier,
88 wconf->r0_key_holder_len);
89 }
90 os_memcpy(wconf->r1_key_holder, conf->r1_key_holder, FT_R1KH_ID_LEN);
91 wconf->r0_key_lifetime = conf->r0_key_lifetime;
92 wconf->r1_max_key_lifetime = conf->r1_max_key_lifetime;
93 wconf->reassociation_deadline = conf->reassociation_deadline;
94 wconf->rkh_pos_timeout = conf->rkh_pos_timeout;
95 wconf->rkh_neg_timeout = conf->rkh_neg_timeout;
96 wconf->rkh_pull_timeout = conf->rkh_pull_timeout;
97 wconf->rkh_pull_retries = conf->rkh_pull_retries;
98 wconf->r0kh_list = &conf->r0kh_list;
99 wconf->r1kh_list = &conf->r1kh_list;
100 wconf->pmk_r1_push = conf->pmk_r1_push;
101 wconf->ft_over_ds = conf->ft_over_ds;
102 wconf->ft_psk_generate_local = conf->ft_psk_generate_local;
103 #endif /* CONFIG_IEEE80211R_AP */
104 #ifdef CONFIG_HS20
105 wconf->disable_gtk = conf->disable_dgaf;
106 if (conf->osen) {
107 wconf->disable_gtk = 1;
108 wconf->wpa = WPA_PROTO_OSEN;
109 wconf->wpa_key_mgmt = WPA_KEY_MGMT_OSEN;
110 wconf->wpa_pairwise = 0;
111 wconf->wpa_group = WPA_CIPHER_CCMP;
112 wconf->rsn_pairwise = WPA_CIPHER_CCMP;
113 wconf->rsn_preauth = 0;
114 wconf->disable_pmksa_caching = 1;
115 wconf->ieee80211w = 1;
116 }
117 #endif /* CONFIG_HS20 */
118 #ifdef CONFIG_TESTING_OPTIONS
119 wconf->corrupt_gtk_rekey_mic_probability =
120 iconf->corrupt_gtk_rekey_mic_probability;
121 if (conf->own_ie_override &&
122 wpabuf_len(conf->own_ie_override) <= MAX_OWN_IE_OVERRIDE) {
123 wconf->own_ie_override_len = wpabuf_len(conf->own_ie_override);
124 os_memcpy(wconf->own_ie_override,
125 wpabuf_head(conf->own_ie_override),
126 wconf->own_ie_override_len);
127 }
128 if (conf->rsne_override_eapol &&
129 wpabuf_len(conf->rsne_override_eapol) <= MAX_OWN_IE_OVERRIDE) {
130 wconf->rsne_override_eapol_set = 1;
131 wconf->rsne_override_eapol_len =
132 wpabuf_len(conf->rsne_override_eapol);
133 os_memcpy(wconf->rsne_override_eapol,
134 wpabuf_head(conf->rsne_override_eapol),
135 wconf->rsne_override_eapol_len);
136 }
137 if (conf->rsnxe_override_eapol &&
138 wpabuf_len(conf->rsnxe_override_eapol) <= MAX_OWN_IE_OVERRIDE) {
139 wconf->rsnxe_override_eapol_set = 1;
140 wconf->rsnxe_override_eapol_len =
141 wpabuf_len(conf->rsnxe_override_eapol);
142 os_memcpy(wconf->rsnxe_override_eapol,
143 wpabuf_head(conf->rsnxe_override_eapol),
144 wconf->rsnxe_override_eapol_len);
145 }
146 if (conf->rsne_override_ft &&
147 wpabuf_len(conf->rsne_override_ft) <= MAX_OWN_IE_OVERRIDE) {
148 wconf->rsne_override_ft_set = 1;
149 wconf->rsne_override_ft_len =
150 wpabuf_len(conf->rsne_override_ft);
151 os_memcpy(wconf->rsne_override_ft,
152 wpabuf_head(conf->rsne_override_ft),
153 wconf->rsne_override_ft_len);
154 }
155 if (conf->rsnxe_override_ft &&
156 wpabuf_len(conf->rsnxe_override_ft) <= MAX_OWN_IE_OVERRIDE) {
157 wconf->rsnxe_override_ft_set = 1;
158 wconf->rsnxe_override_ft_len =
159 wpabuf_len(conf->rsnxe_override_ft);
160 os_memcpy(wconf->rsnxe_override_ft,
161 wpabuf_head(conf->rsnxe_override_ft),
162 wconf->rsnxe_override_ft_len);
163 }
164 if (conf->gtk_rsc_override &&
165 wpabuf_len(conf->gtk_rsc_override) > 0 &&
166 wpabuf_len(conf->gtk_rsc_override) <= WPA_KEY_RSC_LEN) {
167 os_memcpy(wconf->gtk_rsc_override,
168 wpabuf_head(conf->gtk_rsc_override),
169 wpabuf_len(conf->gtk_rsc_override));
170 wconf->gtk_rsc_override_set = 1;
171 }
172 if (conf->igtk_rsc_override &&
173 wpabuf_len(conf->igtk_rsc_override) > 0 &&
174 wpabuf_len(conf->igtk_rsc_override) <= WPA_KEY_RSC_LEN) {
175 os_memcpy(wconf->igtk_rsc_override,
176 wpabuf_head(conf->igtk_rsc_override),
177 wpabuf_len(conf->igtk_rsc_override));
178 wconf->igtk_rsc_override_set = 1;
179 }
180 wconf->ft_rsnxe_used = conf->ft_rsnxe_used;
181 wconf->oci_freq_override_eapol_m3 = conf->oci_freq_override_eapol_m3;
182 wconf->oci_freq_override_eapol_g1 = conf->oci_freq_override_eapol_g1;
183 wconf->oci_freq_override_ft_assoc = conf->oci_freq_override_ft_assoc;
184 wconf->oci_freq_override_fils_assoc =
185 conf->oci_freq_override_fils_assoc;
186 #endif /* CONFIG_TESTING_OPTIONS */
187 #ifdef CONFIG_P2P
188 os_memcpy(wconf->ip_addr_go, conf->ip_addr_go, 4);
189 os_memcpy(wconf->ip_addr_mask, conf->ip_addr_mask, 4);
190 os_memcpy(wconf->ip_addr_start, conf->ip_addr_start, 4);
191 os_memcpy(wconf->ip_addr_end, conf->ip_addr_end, 4);
192 #endif /* CONFIG_P2P */
193 #ifdef CONFIG_FILS
194 wconf->fils_cache_id_set = conf->fils_cache_id_set;
195 os_memcpy(wconf->fils_cache_id, conf->fils_cache_id,
196 FILS_CACHE_ID_LEN);
197 #endif /* CONFIG_FILS */
198 wconf->sae_pwe = conf->sae_pwe;
199 sae_pw_id = hostapd_sae_pw_id_in_use(conf);
200 if (sae_pw_id == 2 && wconf->sae_pwe != 3)
201 wconf->sae_pwe = 1;
202 else if (sae_pw_id == 1 && wconf->sae_pwe == 0)
203 wconf->sae_pwe = 2;
204 #ifdef CONFIG_SAE_PK
205 wconf->sae_pk = hostapd_sae_pk_in_use(conf);
206 #endif /* CONFIG_SAE_PK */
207 #ifdef CONFIG_OWE
208 wconf->owe_ptk_workaround = conf->owe_ptk_workaround;
209 #endif /* CONFIG_OWE */
210 wconf->transition_disable = conf->transition_disable;
211 #ifdef CONFIG_DPP2
212 wconf->dpp_pfs = conf->dpp_pfs;
213 #endif /* CONFIG_DPP2 */
214 #ifdef CONFIG_PASN
215 #ifdef CONFIG_TESTING_OPTIONS
216 wconf->force_kdk_derivation = conf->force_kdk_derivation;
217 #endif /* CONFIG_TESTING_OPTIONS */
218 #endif /* CONFIG_PASN */
219 }
220
221
hostapd_wpa_auth_logger(void *ctx, const u8 *addr, logger_level level, const char *txt)222 static void hostapd_wpa_auth_logger(void *ctx, const u8 *addr,
223 logger_level level, const char *txt)
224 {
225 #ifndef CONFIG_NO_HOSTAPD_LOGGER
226 struct hostapd_data *hapd = ctx;
227 int hlevel;
228
229 switch (level) {
230 case LOGGER_WARNING:
231 hlevel = HOSTAPD_LEVEL_WARNING;
232 break;
233 case LOGGER_INFO:
234 hlevel = HOSTAPD_LEVEL_INFO;
235 break;
236 case LOGGER_DEBUG:
237 default:
238 hlevel = HOSTAPD_LEVEL_DEBUG;
239 break;
240 }
241
242 hostapd_logger(hapd, addr, HOSTAPD_MODULE_WPA, hlevel, "%s", txt);
243 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
244 }
245
246
hostapd_wpa_auth_disconnect(void *ctx, const u8 *addr, u16 reason)247 static void hostapd_wpa_auth_disconnect(void *ctx, const u8 *addr,
248 u16 reason)
249 {
250 struct hostapd_data *hapd = ctx;
251 wpa_printf(MSG_DEBUG, "%s: WPA authenticator requests disconnect: "
252 "STA " MACSTR_SEC " reason %d",
253 __func__, MAC2STR_SEC(addr), reason);
254 ap_sta_disconnect(hapd, NULL, addr, reason);
255 }
256
257
hostapd_wpa_auth_mic_failure_report(void *ctx, const u8 *addr)258 static int hostapd_wpa_auth_mic_failure_report(void *ctx, const u8 *addr)
259 {
260 struct hostapd_data *hapd = ctx;
261 return michael_mic_failure(hapd, addr, 0);
262 }
263
264
hostapd_wpa_auth_psk_failure_report(void *ctx, const u8 *addr)265 static void hostapd_wpa_auth_psk_failure_report(void *ctx, const u8 *addr)
266 {
267 struct hostapd_data *hapd = ctx;
268 wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR,
269 MAC2STR(addr));
270 #ifdef CONFIG_LIBWPA_VENDOR
271 struct HostapdApCbParm hostapdApCbParm = {};
272 int result = os_snprintf((char *)hostapdApCbParm.content, WIFI_HOSTAPD_CB_CONTENT_LENGTH,
273 AP_STA_POSSIBLE_PSK_MISMATCH MACSTR, MAC2STR(addr));
274 if (os_snprintf_error(WIFI_HOSTAPD_CB_CONTENT_LENGTH, result)) {
275 wpa_printf(MSG_ERROR, "AP_STA_POSSIBLE_PSK_MISMATCH os_snprintf_error");
276 } else {
277 hostapdApCbParm.id = 0;
278 wpa_printf(MSG_INFO, "%s HOSTAPD_EVENT_AP_STATE %s%d", __func__,
279 get_anonymized_result_setnetwork_for_bssid((char *)hostapdApCbParm.content), hostapdApCbParm.id);
280 HostapdEventReport(hapd->conf->iface, HOSTAPD_EVENT_AP_STATE, (void *) &hostapdApCbParm);
281 }
282 #endif
283 }
284
285
hostapd_wpa_auth_set_eapol(void *ctx, const u8 *addr, wpa_eapol_variable var, int value)286 static void hostapd_wpa_auth_set_eapol(void *ctx, const u8 *addr,
287 wpa_eapol_variable var, int value)
288 {
289 struct hostapd_data *hapd = ctx;
290 struct sta_info *sta = ap_get_sta(hapd, addr);
291 if (sta == NULL)
292 return;
293 switch (var) {
294 case WPA_EAPOL_portEnabled:
295 ieee802_1x_notify_port_enabled(sta->eapol_sm, value);
296 break;
297 case WPA_EAPOL_portValid:
298 ieee802_1x_notify_port_valid(sta->eapol_sm, value);
299 break;
300 case WPA_EAPOL_authorized:
301 ieee802_1x_set_sta_authorized(hapd, sta, value);
302 break;
303 case WPA_EAPOL_portControl_Auto:
304 if (sta->eapol_sm)
305 sta->eapol_sm->portControl = Auto;
306 break;
307 case WPA_EAPOL_keyRun:
308 if (sta->eapol_sm)
309 sta->eapol_sm->keyRun = value;
310 break;
311 case WPA_EAPOL_keyAvailable:
312 if (sta->eapol_sm)
313 sta->eapol_sm->eap_if->eapKeyAvailable = value;
314 break;
315 case WPA_EAPOL_keyDone:
316 if (sta->eapol_sm)
317 sta->eapol_sm->keyDone = value;
318 break;
319 case WPA_EAPOL_inc_EapolFramesTx:
320 if (sta->eapol_sm)
321 sta->eapol_sm->dot1xAuthEapolFramesTx++;
322 break;
323 }
324 }
325
326
hostapd_wpa_auth_get_eapol(void *ctx, const u8 *addr, wpa_eapol_variable var)327 static int hostapd_wpa_auth_get_eapol(void *ctx, const u8 *addr,
328 wpa_eapol_variable var)
329 {
330 struct hostapd_data *hapd = ctx;
331 struct sta_info *sta = ap_get_sta(hapd, addr);
332 if (sta == NULL || sta->eapol_sm == NULL)
333 return -1;
334 switch (var) {
335 case WPA_EAPOL_keyRun:
336 return sta->eapol_sm->keyRun;
337 case WPA_EAPOL_keyAvailable:
338 return sta->eapol_sm->eap_if->eapKeyAvailable;
339 default:
340 return -1;
341 }
342 }
343
344
hostapd_wpa_auth_get_psk(void *ctx, const u8 *addr, const u8 *p2p_dev_addr, const u8 *prev_psk, size_t *psk_len, int *vlan_id)345 static const u8 * hostapd_wpa_auth_get_psk(void *ctx, const u8 *addr,
346 const u8 *p2p_dev_addr,
347 const u8 *prev_psk, size_t *psk_len,
348 int *vlan_id)
349 {
350 struct hostapd_data *hapd = ctx;
351 struct sta_info *sta = ap_get_sta(hapd, addr);
352 const u8 *psk;
353
354 if (vlan_id)
355 *vlan_id = 0;
356 if (psk_len)
357 *psk_len = PMK_LEN;
358
359 #ifdef CONFIG_SAE
360 if (sta && sta->auth_alg == WLAN_AUTH_SAE) {
361 if (!sta->sae || prev_psk)
362 return NULL;
363 if (psk_len)
364 *psk_len = sta->sae->pmk_len;
365 return sta->sae->pmk;
366 }
367 if (sta && wpa_auth_uses_sae(sta->wpa_sm)) {
368 wpa_printf(MSG_DEBUG,
369 "No PSK for STA trying to use SAE with PMKSA caching");
370 return NULL;
371 }
372 #endif /* CONFIG_SAE */
373
374 #ifdef CONFIG_OWE
375 if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) &&
376 sta && sta->owe_pmk) {
377 if (psk_len)
378 *psk_len = sta->owe_pmk_len;
379 return sta->owe_pmk;
380 }
381 if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) && sta) {
382 struct rsn_pmksa_cache_entry *sa;
383
384 sa = wpa_auth_sta_get_pmksa(sta->wpa_sm);
385 if (sa && sa->akmp == WPA_KEY_MGMT_OWE) {
386 if (psk_len)
387 *psk_len = sa->pmk_len;
388 return sa->pmk;
389 }
390 }
391 #endif /* CONFIG_OWE */
392
393 psk = hostapd_get_psk(hapd->conf, addr, p2p_dev_addr, prev_psk,
394 vlan_id);
395 /*
396 * This is about to iterate over all psks, prev_psk gives the last
397 * returned psk which should not be returned again.
398 * logic list (all hostapd_get_psk; all sta->psk)
399 */
400 if (sta && sta->psk && !psk) {
401 struct hostapd_sta_wpa_psk_short *pos;
402
403 if (vlan_id)
404 *vlan_id = 0;
405 psk = sta->psk->psk;
406 for (pos = sta->psk; pos; pos = pos->next) {
407 if (pos->is_passphrase) {
408 pbkdf2_sha1(pos->passphrase,
409 hapd->conf->ssid.ssid,
410 hapd->conf->ssid.ssid_len, 4096,
411 pos->psk, PMK_LEN);
412 pos->is_passphrase = 0;
413 }
414 if (pos->psk == prev_psk) {
415 psk = pos->next ? pos->next->psk : NULL;
416 break;
417 }
418 }
419 }
420 return psk;
421 }
422
423
hostapd_wpa_auth_get_msk(void *ctx, const u8 *addr, u8 *msk, size_t *len)424 static int hostapd_wpa_auth_get_msk(void *ctx, const u8 *addr, u8 *msk,
425 size_t *len)
426 {
427 struct hostapd_data *hapd = ctx;
428 const u8 *key;
429 size_t keylen;
430 struct sta_info *sta;
431
432 sta = ap_get_sta(hapd, addr);
433 if (sta == NULL) {
434 wpa_printf(MSG_DEBUG, "AUTH_GET_MSK: Cannot find STA");
435 return -1;
436 }
437
438 key = ieee802_1x_get_key(sta->eapol_sm, &keylen);
439 if (key == NULL) {
440 wpa_printf(MSG_DEBUG, "AUTH_GET_MSK: Key is null, eapol_sm: %p",
441 sta->eapol_sm);
442 return -1;
443 }
444
445 if (keylen > *len)
446 keylen = *len;
447 os_memcpy(msk, key, keylen);
448 *len = keylen;
449
450 return 0;
451 }
452
453
hostapd_wpa_auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg, const u8 *addr, int idx, u8 *key, size_t key_len, enum key_flag key_flag)454 static int hostapd_wpa_auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
455 const u8 *addr, int idx, u8 *key,
456 size_t key_len, enum key_flag key_flag)
457 {
458 struct hostapd_data *hapd = ctx;
459 const char *ifname = hapd->conf->iface;
460
461 if (vlan_id > 0) {
462 ifname = hostapd_get_vlan_id_ifname(hapd->conf->vlan, vlan_id);
463 if (!ifname) {
464 if (!(hapd->iface->drv_flags &
465 WPA_DRIVER_FLAGS_VLAN_OFFLOAD))
466 return -1;
467 ifname = hapd->conf->iface;
468 }
469 }
470
471 #ifdef CONFIG_TESTING_OPTIONS
472 if (key_flag & KEY_FLAG_MODIFY) {
473 /* We are updating an already installed key. Don't overwrite
474 * the already stored key information with zeros.
475 */
476 } else if (addr && !is_broadcast_ether_addr(addr)) {
477 struct sta_info *sta;
478
479 sta = ap_get_sta(hapd, addr);
480 if (sta) {
481 sta->last_tk_alg = alg;
482 sta->last_tk_key_idx = idx;
483 if (key)
484 os_memcpy(sta->last_tk, key, key_len);
485 sta->last_tk_len = key_len;
486 }
487 } else if (alg == WPA_ALG_BIP_CMAC_128 ||
488 alg == WPA_ALG_BIP_GMAC_128 ||
489 alg == WPA_ALG_BIP_GMAC_256 ||
490 alg == WPA_ALG_BIP_CMAC_256) {
491 if (idx == 4 || idx == 5) {
492 hapd->last_igtk_alg = alg;
493 hapd->last_igtk_key_idx = idx;
494 if (key)
495 os_memcpy(hapd->last_igtk, key, key_len);
496 hapd->last_igtk_len = key_len;
497 } else if (idx == 6 || idx == 7) {
498 hapd->last_bigtk_alg = alg;
499 hapd->last_bigtk_key_idx = idx;
500 if (key)
501 os_memcpy(hapd->last_bigtk, key, key_len);
502 hapd->last_bigtk_len = key_len;
503 }
504 } else {
505 hapd->last_gtk_alg = alg;
506 hapd->last_gtk_key_idx = idx;
507 if (key)
508 os_memcpy(hapd->last_gtk, key, key_len);
509 hapd->last_gtk_len = key_len;
510 }
511 #endif /* CONFIG_TESTING_OPTIONS */
512 return hostapd_drv_set_key(ifname, hapd, alg, addr, idx, vlan_id, 1,
513 NULL, 0, key, key_len, key_flag);
514 }
515
516
hostapd_wpa_auth_get_seqnum(void *ctx, const u8 *addr, int idx, u8 *seq)517 static int hostapd_wpa_auth_get_seqnum(void *ctx, const u8 *addr, int idx,
518 u8 *seq)
519 {
520 struct hostapd_data *hapd = ctx;
521 return hostapd_get_seqnum(hapd->conf->iface, hapd, addr, idx, seq);
522 }
523
524
hostapd_wpa_auth_send_eapol(void *ctx, const u8 *addr, const u8 *data, size_t data_len, int encrypt)525 int hostapd_wpa_auth_send_eapol(void *ctx, const u8 *addr,
526 const u8 *data, size_t data_len,
527 int encrypt)
528 {
529 struct hostapd_data *hapd = ctx;
530 struct sta_info *sta;
531 u32 flags = 0;
532
533 #ifdef CONFIG_TESTING_OPTIONS
534 if (hapd->ext_eapol_frame_io) {
535 size_t hex_len = 2 * data_len + 1;
536 char *hex = os_malloc(hex_len);
537
538 if (hex == NULL)
539 return -1;
540 wpa_snprintf_hex(hex, hex_len, data, data_len);
541 wpa_msg(hapd->msg_ctx, MSG_INFO, "EAPOL-TX " MACSTR " %s",
542 MAC2STR(addr), hex);
543 os_free(hex);
544 return 0;
545 }
546 #endif /* CONFIG_TESTING_OPTIONS */
547
548 sta = ap_get_sta(hapd, addr);
549 if (sta)
550 flags = hostapd_sta_flags_to_drv(sta->flags);
551
552 return hostapd_drv_hapd_send_eapol(hapd, addr, data, data_len,
553 encrypt, flags);
554 }
555
556
hostapd_wpa_auth_for_each_sta( void *ctx, int (*cb)(struct wpa_state_machine *sm, void *ctx), void *cb_ctx)557 static int hostapd_wpa_auth_for_each_sta(
558 void *ctx, int (*cb)(struct wpa_state_machine *sm, void *ctx),
559 void *cb_ctx)
560 {
561 struct hostapd_data *hapd = ctx;
562 struct sta_info *sta;
563
564 for (sta = hapd->sta_list; sta; sta = sta->next) {
565 if (sta->wpa_sm && cb(sta->wpa_sm, cb_ctx))
566 return 1;
567 }
568 return 0;
569 }
570
571
572 struct wpa_auth_iface_iter_data {
573 int (*cb)(struct wpa_authenticator *sm, void *ctx);
574 void *cb_ctx;
575 };
576
wpa_auth_iface_iter(struct hostapd_iface *iface, void *ctx)577 static int wpa_auth_iface_iter(struct hostapd_iface *iface, void *ctx)
578 {
579 struct wpa_auth_iface_iter_data *data = ctx;
580 size_t i;
581 for (i = 0; i < iface->num_bss; i++) {
582 if (iface->bss[i]->wpa_auth &&
583 data->cb(iface->bss[i]->wpa_auth, data->cb_ctx))
584 return 1;
585 }
586 return 0;
587 }
588
589
hostapd_wpa_auth_for_each_auth( void *ctx, int (*cb)(struct wpa_authenticator *sm, void *ctx), void *cb_ctx)590 static int hostapd_wpa_auth_for_each_auth(
591 void *ctx, int (*cb)(struct wpa_authenticator *sm, void *ctx),
592 void *cb_ctx)
593 {
594 struct hostapd_data *hapd = ctx;
595 struct wpa_auth_iface_iter_data data;
596 if (hapd->iface->interfaces == NULL ||
597 hapd->iface->interfaces->for_each_interface == NULL)
598 return -1;
599 data.cb = cb;
600 data.cb_ctx = cb_ctx;
601 return hapd->iface->interfaces->for_each_interface(
602 hapd->iface->interfaces, wpa_auth_iface_iter, &data);
603 }
604
605
606 #ifdef CONFIG_IEEE80211R_AP
607
608 struct wpa_ft_rrb_rx_later_data {
609 struct dl_list list;
610 u8 addr[ETH_ALEN];
611 size_t data_len;
612 /* followed by data_len octets of data */
613 };
614
hostapd_wpa_ft_rrb_rx_later(void *eloop_ctx, void *timeout_ctx)615 static void hostapd_wpa_ft_rrb_rx_later(void *eloop_ctx, void *timeout_ctx)
616 {
617 struct hostapd_data *hapd = eloop_ctx;
618 struct wpa_ft_rrb_rx_later_data *data, *n;
619
620 dl_list_for_each_safe(data, n, &hapd->l2_queue,
621 struct wpa_ft_rrb_rx_later_data, list) {
622 if (hapd->wpa_auth) {
623 wpa_ft_rrb_rx(hapd->wpa_auth, data->addr,
624 (const u8 *) (data + 1),
625 data->data_len);
626 }
627 dl_list_del(&data->list);
628 os_free(data);
629 }
630 }
631
632
633 struct wpa_auth_ft_iface_iter_data {
634 struct hostapd_data *src_hapd;
635 const u8 *dst;
636 const u8 *data;
637 size_t data_len;
638 };
639
640
hostapd_wpa_auth_ft_iter(struct hostapd_iface *iface, void *ctx)641 static int hostapd_wpa_auth_ft_iter(struct hostapd_iface *iface, void *ctx)
642 {
643 struct wpa_auth_ft_iface_iter_data *idata = ctx;
644 struct wpa_ft_rrb_rx_later_data *data;
645 struct hostapd_data *hapd;
646 size_t j;
647
648 for (j = 0; j < iface->num_bss; j++) {
649 hapd = iface->bss[j];
650 if (hapd == idata->src_hapd ||
651 !hapd->wpa_auth ||
652 os_memcmp(hapd->own_addr, idata->dst, ETH_ALEN) != 0)
653 continue;
654
655 wpa_printf(MSG_DEBUG,
656 "FT: Send RRB data directly to locally managed BSS "
657 MACSTR_SEC "@%s -> " MACSTR_SEC "@%s",
658 MAC2STR_SEC(idata->src_hapd->own_addr),
659 idata->src_hapd->conf->iface,
660 MAC2STR_SEC(hapd->own_addr), hapd->conf->iface);
661
662 /* Defer wpa_ft_rrb_rx() until next eloop step as this is
663 * when it would be triggered when reading from a socket.
664 * This avoids
665 * hapd0:send -> hapd1:recv -> hapd1:send -> hapd0:recv,
666 * that is calling hapd0:recv handler from within
667 * hapd0:send directly.
668 */
669 data = os_zalloc(sizeof(*data) + idata->data_len);
670 if (!data)
671 return 1;
672
673 os_memcpy(data->addr, idata->src_hapd->own_addr, ETH_ALEN);
674 os_memcpy(data + 1, idata->data, idata->data_len);
675 data->data_len = idata->data_len;
676
677 dl_list_add(&hapd->l2_queue, &data->list);
678
679 if (!eloop_is_timeout_registered(hostapd_wpa_ft_rrb_rx_later,
680 hapd, NULL))
681 eloop_register_timeout(0, 0,
682 hostapd_wpa_ft_rrb_rx_later,
683 hapd, NULL);
684
685 return 1;
686 }
687
688 return 0;
689 }
690
691 #endif /* CONFIG_IEEE80211R_AP */
692
693
hostapd_wpa_auth_send_ether(void *ctx, const u8 *dst, u16 proto, const u8 *data, size_t data_len)694 static int hostapd_wpa_auth_send_ether(void *ctx, const u8 *dst, u16 proto,
695 const u8 *data, size_t data_len)
696 {
697 struct hostapd_data *hapd = ctx;
698 struct l2_ethhdr *buf;
699 int ret;
700
701 #ifdef CONFIG_TESTING_OPTIONS
702 if (hapd->ext_eapol_frame_io && proto == ETH_P_EAPOL) {
703 size_t hex_len = 2 * data_len + 1;
704 char *hex = os_malloc(hex_len);
705
706 if (hex == NULL)
707 return -1;
708 wpa_snprintf_hex(hex, hex_len, data, data_len);
709 wpa_msg(hapd->msg_ctx, MSG_INFO, "EAPOL-TX " MACSTR " %s",
710 MAC2STR(dst), hex);
711 os_free(hex);
712 return 0;
713 }
714 #endif /* CONFIG_TESTING_OPTIONS */
715
716 #ifdef CONFIG_IEEE80211R_AP
717 if (proto == ETH_P_RRB && hapd->iface->interfaces &&
718 hapd->iface->interfaces->for_each_interface) {
719 int res;
720 struct wpa_auth_ft_iface_iter_data idata;
721 idata.src_hapd = hapd;
722 idata.dst = dst;
723 idata.data = data;
724 idata.data_len = data_len;
725 res = hapd->iface->interfaces->for_each_interface(
726 hapd->iface->interfaces, hostapd_wpa_auth_ft_iter,
727 &idata);
728 if (res == 1)
729 return data_len;
730 }
731 #endif /* CONFIG_IEEE80211R_AP */
732
733 if (hapd->l2 == NULL)
734 return -1;
735
736 buf = os_malloc(sizeof(*buf) + data_len);
737 if (buf == NULL)
738 return -1;
739 os_memcpy(buf->h_dest, dst, ETH_ALEN);
740 os_memcpy(buf->h_source, hapd->own_addr, ETH_ALEN);
741 buf->h_proto = host_to_be16(proto);
742 os_memcpy(buf + 1, data, data_len);
743 ret = l2_packet_send(hapd->l2, dst, proto, (u8 *) buf,
744 sizeof(*buf) + data_len);
745 os_free(buf);
746 return ret;
747 }
748
749
750 #ifdef CONFIG_ETH_P_OUI
hostapd_wpa_get_oui(struct hostapd_data *hapd, u8 oui_suffix)751 static struct eth_p_oui_ctx * hostapd_wpa_get_oui(struct hostapd_data *hapd,
752 u8 oui_suffix)
753 {
754 switch (oui_suffix) {
755 #ifdef CONFIG_IEEE80211R_AP
756 case FT_PACKET_R0KH_R1KH_PULL:
757 return hapd->oui_pull;
758 case FT_PACKET_R0KH_R1KH_RESP:
759 return hapd->oui_resp;
760 case FT_PACKET_R0KH_R1KH_PUSH:
761 return hapd->oui_push;
762 case FT_PACKET_R0KH_R1KH_SEQ_REQ:
763 return hapd->oui_sreq;
764 case FT_PACKET_R0KH_R1KH_SEQ_RESP:
765 return hapd->oui_sresp;
766 #endif /* CONFIG_IEEE80211R_AP */
767 default:
768 return NULL;
769 }
770 }
771 #endif /* CONFIG_ETH_P_OUI */
772
773
774 #ifdef CONFIG_IEEE80211R_AP
775
776 struct oui_deliver_later_data {
777 struct dl_list list;
778 u8 src_addr[ETH_ALEN];
779 u8 dst_addr[ETH_ALEN];
780 size_t data_len;
781 u8 oui_suffix;
782 /* followed by data_len octets of data */
783 };
784
hostapd_oui_deliver_later(void *eloop_ctx, void *timeout_ctx)785 static void hostapd_oui_deliver_later(void *eloop_ctx, void *timeout_ctx)
786 {
787 struct hostapd_data *hapd = eloop_ctx;
788 struct oui_deliver_later_data *data, *n;
789 struct eth_p_oui_ctx *oui_ctx;
790
791 dl_list_for_each_safe(data, n, &hapd->l2_oui_queue,
792 struct oui_deliver_later_data, list) {
793 oui_ctx = hostapd_wpa_get_oui(hapd, data->oui_suffix);
794 wpa_printf(MSG_DEBUG, "RRB(%s): %s src=" MACSTR_SEC " dst=" MACSTR_SEC
795 " oui_suffix=%u data_len=%u data=%p",
796 hapd->conf->iface, __func__,
797 MAC2STR_SEC(data->src_addr), MAC2STR_SEC(data->dst_addr),
798 data->oui_suffix, (unsigned int) data->data_len,
799 data);
800 if (hapd->wpa_auth && oui_ctx) {
801 eth_p_oui_deliver(oui_ctx, data->src_addr,
802 data->dst_addr,
803 (const u8 *) (data + 1),
804 data->data_len);
805 }
806 dl_list_del(&data->list);
807 os_free(data);
808 }
809 }
810
811
812 struct wpa_auth_oui_iface_iter_data {
813 struct hostapd_data *src_hapd;
814 const u8 *dst_addr;
815 const u8 *data;
816 size_t data_len;
817 u8 oui_suffix;
818 };
819
hostapd_wpa_auth_oui_iter(struct hostapd_iface *iface, void *ctx)820 static int hostapd_wpa_auth_oui_iter(struct hostapd_iface *iface, void *ctx)
821 {
822 struct wpa_auth_oui_iface_iter_data *idata = ctx;
823 struct oui_deliver_later_data *data;
824 struct hostapd_data *hapd, *src_hapd = idata->src_hapd;
825 size_t j;
826
827 for (j = 0; j < iface->num_bss; j++) {
828 hapd = iface->bss[j];
829 if (hapd == src_hapd)
830 continue; /* don't deliver back to same interface */
831 if (!wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt) ||
832 hapd->conf->ssid.ssid_len !=
833 src_hapd->conf->ssid.ssid_len ||
834 os_memcmp(hapd->conf->ssid.ssid,
835 src_hapd->conf->ssid.ssid,
836 hapd->conf->ssid.ssid_len) != 0 ||
837 os_memcmp(hapd->conf->mobility_domain,
838 src_hapd->conf->mobility_domain,
839 MOBILITY_DOMAIN_ID_LEN) != 0)
840 continue; /* no matching FT SSID/mobility domain */
841 if (!is_multicast_ether_addr(idata->dst_addr) &&
842 os_memcmp(hapd->own_addr, idata->dst_addr, ETH_ALEN) != 0)
843 continue; /* destination address does not match */
844
845 /* defer eth_p_oui_deliver until next eloop step as this is
846 * when it would be triggerd from reading from sock
847 * This avoids
848 * hapd0:send -> hapd1:recv -> hapd1:send -> hapd0:recv,
849 * that is calling hapd0:recv handler from within
850 * hapd0:send directly.
851 */
852 data = os_zalloc(sizeof(*data) + idata->data_len);
853 if (!data)
854 return 1;
855 wpa_printf(MSG_DEBUG,
856 "RRB(%s): local delivery to %s dst=" MACSTR_SEC
857 " oui_suffix=%u data_len=%u data=%p",
858 src_hapd->conf->iface, hapd->conf->iface,
859 MAC2STR_SEC(idata->dst_addr), idata->oui_suffix,
860 (unsigned int) idata->data_len, data);
861
862 os_memcpy(data->src_addr, src_hapd->own_addr, ETH_ALEN);
863 os_memcpy(data->dst_addr, idata->dst_addr, ETH_ALEN);
864 os_memcpy(data + 1, idata->data, idata->data_len);
865 data->data_len = idata->data_len;
866 data->oui_suffix = idata->oui_suffix;
867
868 dl_list_add_tail(&hapd->l2_oui_queue, &data->list);
869
870 if (!eloop_is_timeout_registered(hostapd_oui_deliver_later,
871 hapd, NULL))
872 eloop_register_timeout(0, 0,
873 hostapd_oui_deliver_later,
874 hapd, NULL);
875
876 /* If dst_addr is a multicast address, do not return any
877 * non-zero value here. Otherwise, the iteration of
878 * for_each_interface() will be stopped. */
879 if (!is_multicast_ether_addr(idata->dst_addr))
880 return 1;
881 }
882
883 return 0;
884 }
885
886 #endif /* CONFIG_IEEE80211R_AP */
887
888
hostapd_wpa_auth_send_oui(void *ctx, const u8 *dst, u8 oui_suffix, const u8 *data, size_t data_len)889 static int hostapd_wpa_auth_send_oui(void *ctx, const u8 *dst, u8 oui_suffix,
890 const u8 *data, size_t data_len)
891 {
892 #ifdef CONFIG_ETH_P_OUI
893 struct hostapd_data *hapd = ctx;
894 struct eth_p_oui_ctx *oui_ctx;
895
896 wpa_printf(MSG_DEBUG, "RRB(%s): send to dst=" MACSTR_SEC
897 " oui_suffix=%u data_len=%u",
898 hapd->conf->iface, MAC2STR_SEC(dst), oui_suffix,
899 (unsigned int) data_len);
900 #ifdef CONFIG_IEEE80211R_AP
901 if (hapd->iface->interfaces &&
902 hapd->iface->interfaces->for_each_interface) {
903 struct wpa_auth_oui_iface_iter_data idata;
904 int res;
905
906 idata.src_hapd = hapd;
907 idata.dst_addr = dst;
908 idata.data = data;
909 idata.data_len = data_len;
910 idata.oui_suffix = oui_suffix;
911 res = hapd->iface->interfaces->for_each_interface(
912 hapd->iface->interfaces, hostapd_wpa_auth_oui_iter,
913 &idata);
914 if (res == 1)
915 return data_len;
916 }
917 #endif /* CONFIG_IEEE80211R_AP */
918
919 oui_ctx = hostapd_wpa_get_oui(hapd, oui_suffix);
920 if (!oui_ctx)
921 return -1;
922
923 return eth_p_oui_send(oui_ctx, hapd->own_addr, dst, data, data_len);
924 #else /* CONFIG_ETH_P_OUI */
925 return -1;
926 #endif /* CONFIG_ETH_P_OUI */
927 }
928
929
hostapd_channel_info(void *ctx, struct wpa_channel_info *ci)930 static int hostapd_channel_info(void *ctx, struct wpa_channel_info *ci)
931 {
932 struct hostapd_data *hapd = ctx;
933
934 return hostapd_drv_channel_info(hapd, ci);
935 }
936
937
938 #ifdef CONFIG_PASN
939
hostapd_store_ptksa(void *ctx, const u8 *addr,int cipher, u32 life_time, const struct wpa_ptk *ptk)940 static void hostapd_store_ptksa(void *ctx, const u8 *addr,int cipher,
941 u32 life_time, const struct wpa_ptk *ptk)
942 {
943 struct hostapd_data *hapd = ctx;
944
945 ptksa_cache_add(hapd->ptksa, addr, cipher, life_time, ptk);
946 }
947
948
hostapd_clear_ptksa(void *ctx, const u8 *addr, int cipher)949 static void hostapd_clear_ptksa(void *ctx, const u8 *addr, int cipher)
950 {
951 struct hostapd_data *hapd = ctx;
952
953 ptksa_cache_flush(hapd->ptksa, addr, cipher);
954 }
955
956 #endif /* CONFIG_PASN */
957
958
hostapd_wpa_auth_update_vlan(void *ctx, const u8 *addr, int vlan_id)959 static int hostapd_wpa_auth_update_vlan(void *ctx, const u8 *addr, int vlan_id)
960 {
961 #ifndef CONFIG_NO_VLAN
962 struct hostapd_data *hapd = ctx;
963 struct sta_info *sta;
964
965 sta = ap_get_sta(hapd, addr);
966 if (!sta)
967 return -1;
968
969 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_VLAN_OFFLOAD)) {
970 struct vlan_description vlan_desc;
971
972 os_memset(&vlan_desc, 0, sizeof(vlan_desc));
973 vlan_desc.notempty = 1;
974 vlan_desc.untagged = vlan_id;
975 if (!hostapd_vlan_valid(hapd->conf->vlan, &vlan_desc)) {
976 wpa_printf(MSG_INFO,
977 "Invalid VLAN ID %d in wpa_psk_file",
978 vlan_id);
979 return -1;
980 }
981
982 if (ap_sta_set_vlan(hapd, sta, &vlan_desc) < 0) {
983 wpa_printf(MSG_INFO,
984 "Failed to assign VLAN ID %d from wpa_psk_file to "
985 MACSTR_SEC, vlan_id, MAC2STR_SEC(sta->addr));
986 return -1;
987 }
988 } else {
989 sta->vlan_id = vlan_id;
990 }
991
992 wpa_printf(MSG_INFO,
993 "Assigned VLAN ID %d from wpa_psk_file to " MACSTR_SEC,
994 vlan_id, MAC2STR_SEC(sta->addr));
995 if ((sta->flags & WLAN_STA_ASSOC) &&
996 ap_sta_bind_vlan(hapd, sta) < 0)
997 return -1;
998 #endif /* CONFIG_NO_VLAN */
999
1000 return 0;
1001 }
1002
1003
1004 #ifdef CONFIG_OCV
hostapd_get_sta_tx_params(void *ctx, const u8 *addr, int ap_max_chanwidth, int ap_seg1_idx, int *bandwidth, int *seg1_idx)1005 static int hostapd_get_sta_tx_params(void *ctx, const u8 *addr,
1006 int ap_max_chanwidth, int ap_seg1_idx,
1007 int *bandwidth, int *seg1_idx)
1008 {
1009 struct hostapd_data *hapd = ctx;
1010 struct sta_info *sta;
1011
1012 sta = ap_get_sta(hapd, addr);
1013 if (!sta) {
1014 hostapd_wpa_auth_logger(hapd, addr, LOGGER_INFO,
1015 "Failed to get STA info to validate received OCI");
1016 return -1;
1017 }
1018
1019 return get_tx_parameters(sta, ap_max_chanwidth, ap_seg1_idx, bandwidth,
1020 seg1_idx);
1021 }
1022 #endif /* CONFIG_OCV */
1023
1024
1025 #ifdef CONFIG_IEEE80211R_AP
1026
hostapd_wpa_auth_send_ft_action(void *ctx, const u8 *dst, const u8 *data, size_t data_len)1027 static int hostapd_wpa_auth_send_ft_action(void *ctx, const u8 *dst,
1028 const u8 *data, size_t data_len)
1029 {
1030 struct hostapd_data *hapd = ctx;
1031 int res;
1032 struct ieee80211_mgmt *m;
1033 size_t mlen;
1034 struct sta_info *sta;
1035
1036 sta = ap_get_sta(hapd, dst);
1037 if (sta == NULL || sta->wpa_sm == NULL)
1038 return -1;
1039
1040 m = os_zalloc(sizeof(*m) + data_len);
1041 if (m == NULL)
1042 return -1;
1043 mlen = ((u8 *) &m->u - (u8 *) m) + data_len;
1044 m->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1045 WLAN_FC_STYPE_ACTION);
1046 os_memcpy(m->da, dst, ETH_ALEN);
1047 os_memcpy(m->sa, hapd->own_addr, ETH_ALEN);
1048 os_memcpy(m->bssid, hapd->own_addr, ETH_ALEN);
1049 os_memcpy(&m->u, data, data_len);
1050
1051 res = hostapd_drv_send_mlme(hapd, (u8 *) m, mlen, 0, NULL, 0, 0);
1052 os_free(m);
1053 return res;
1054 }
1055
1056
1057 static struct wpa_state_machine *
hostapd_wpa_auth_add_sta(void *ctx, const u8 *sta_addr)1058 hostapd_wpa_auth_add_sta(void *ctx, const u8 *sta_addr)
1059 {
1060 struct hostapd_data *hapd = ctx;
1061 struct sta_info *sta;
1062 int ret;
1063
1064 wpa_printf(MSG_DEBUG, "Add station entry for " MACSTR_SEC
1065 " based on WPA authenticator callback",
1066 MAC2STR_SEC(sta_addr));
1067 ret = hostapd_add_sta_node(hapd, sta_addr, WLAN_AUTH_FT);
1068
1069 /*
1070 * The expected return values from hostapd_add_sta_node() are
1071 * 0: successfully added STA entry
1072 * -EOPNOTSUPP: driver or driver wrapper does not support/need this
1073 * operations
1074 * any other negative value: error in adding the STA entry */
1075 if (ret < 0 && ret != -EOPNOTSUPP)
1076 return NULL;
1077
1078 sta = ap_sta_add(hapd, sta_addr);
1079 if (sta == NULL)
1080 return NULL;
1081 if (ret == 0)
1082 sta->added_unassoc = 1;
1083
1084 sta->ft_over_ds = 1;
1085 if (sta->wpa_sm) {
1086 sta->auth_alg = WLAN_AUTH_FT;
1087 return sta->wpa_sm;
1088 }
1089
1090 sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, sta->addr, NULL);
1091 if (sta->wpa_sm == NULL) {
1092 ap_free_sta(hapd, sta);
1093 return NULL;
1094 }
1095 sta->auth_alg = WLAN_AUTH_FT;
1096
1097 return sta->wpa_sm;
1098 }
1099
1100
hostapd_wpa_auth_add_sta_ft(void *ctx, const u8 *sta_addr)1101 static int hostapd_wpa_auth_add_sta_ft(void *ctx, const u8 *sta_addr)
1102 {
1103 struct hostapd_data *hapd = ctx;
1104 struct sta_info *sta;
1105
1106 sta = ap_get_sta(hapd, sta_addr);
1107 if (!sta)
1108 return -1;
1109
1110 if (FULL_AP_CLIENT_STATE_SUPP(hapd->iface->drv_flags) &&
1111 (sta->flags & WLAN_STA_MFP) && ap_sta_is_authorized(sta) &&
1112 !(hapd->conf->mesh & MESH_ENABLED) && !(sta->added_unassoc)) {
1113 /* We could not do this in handle_auth() since there was a
1114 * PMF-enabled association for the STA and the new
1115 * authentication attempt was not yet fully processed. Now that
1116 * we are ready to configure the TK to the driver,
1117 * authentication has succeeded and we can clean up the driver
1118 * STA entry to avoid issues with any maintained state from the
1119 * previous association. */
1120 wpa_printf(MSG_DEBUG,
1121 "FT: Remove and re-add driver STA entry after successful FT authentication");
1122 return ap_sta_re_add(hapd, sta);
1123 }
1124
1125 return 0;
1126 }
1127
1128
hostapd_wpa_auth_set_vlan(void *ctx, const u8 *sta_addr, struct vlan_description *vlan)1129 static int hostapd_wpa_auth_set_vlan(void *ctx, const u8 *sta_addr,
1130 struct vlan_description *vlan)
1131 {
1132 struct hostapd_data *hapd = ctx;
1133 struct sta_info *sta;
1134
1135 sta = ap_get_sta(hapd, sta_addr);
1136 if (!sta || !sta->wpa_sm)
1137 return -1;
1138
1139 if (vlan->notempty &&
1140 !hostapd_vlan_valid(hapd->conf->vlan, vlan)) {
1141 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1142 HOSTAPD_LEVEL_INFO,
1143 "Invalid VLAN %d%s received from FT",
1144 vlan->untagged, vlan->tagged[0] ? "+" : "");
1145 return -1;
1146 }
1147
1148 if (ap_sta_set_vlan(hapd, sta, vlan) < 0)
1149 return -1;
1150 /* Configure wpa_group for GTK but ignore error due to driver not
1151 * knowing this STA. */
1152 ap_sta_bind_vlan(hapd, sta);
1153
1154 if (sta->vlan_id)
1155 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
1156 HOSTAPD_LEVEL_INFO, "VLAN ID %d", sta->vlan_id);
1157
1158 return 0;
1159 }
1160
1161
hostapd_wpa_auth_get_vlan(void *ctx, const u8 *sta_addr, struct vlan_description *vlan)1162 static int hostapd_wpa_auth_get_vlan(void *ctx, const u8 *sta_addr,
1163 struct vlan_description *vlan)
1164 {
1165 struct hostapd_data *hapd = ctx;
1166 struct sta_info *sta;
1167
1168 sta = ap_get_sta(hapd, sta_addr);
1169 if (!sta)
1170 return -1;
1171
1172 if (sta->vlan_desc)
1173 *vlan = *sta->vlan_desc;
1174 else
1175 os_memset(vlan, 0, sizeof(*vlan));
1176
1177 return 0;
1178 }
1179
1180
1181 static int
hostapd_wpa_auth_set_identity(void *ctx, const u8 *sta_addr, const u8 *identity, size_t identity_len)1182 hostapd_wpa_auth_set_identity(void *ctx, const u8 *sta_addr,
1183 const u8 *identity, size_t identity_len)
1184 {
1185 struct hostapd_data *hapd = ctx;
1186 struct sta_info *sta;
1187
1188 sta = ap_get_sta(hapd, sta_addr);
1189 if (!sta)
1190 return -1;
1191
1192 os_free(sta->identity);
1193 sta->identity = NULL;
1194
1195 if (sta->eapol_sm) {
1196 os_free(sta->eapol_sm->identity);
1197 sta->eapol_sm->identity = NULL;
1198 sta->eapol_sm->identity_len = 0;
1199 }
1200
1201 if (!identity_len)
1202 return 0;
1203
1204 /* sta->identity is NULL terminated */
1205 sta->identity = os_zalloc(identity_len + 1);
1206 if (!sta->identity)
1207 return -1;
1208 os_memcpy(sta->identity, identity, identity_len);
1209
1210 if (sta->eapol_sm) {
1211 sta->eapol_sm->identity = os_zalloc(identity_len);
1212 if (!sta->eapol_sm->identity)
1213 return -1;
1214 os_memcpy(sta->eapol_sm->identity, identity, identity_len);
1215 sta->eapol_sm->identity_len = identity_len;
1216 }
1217
1218 return 0;
1219 }
1220
1221
1222 static size_t
hostapd_wpa_auth_get_identity(void *ctx, const u8 *sta_addr, const u8 **buf)1223 hostapd_wpa_auth_get_identity(void *ctx, const u8 *sta_addr, const u8 **buf)
1224 {
1225 struct hostapd_data *hapd = ctx;
1226 struct sta_info *sta;
1227 size_t len;
1228 char *identity;
1229
1230 sta = ap_get_sta(hapd, sta_addr);
1231 if (!sta)
1232 return 0;
1233
1234 *buf = ieee802_1x_get_identity(sta->eapol_sm, &len);
1235 if (*buf && len)
1236 return len;
1237
1238 if (!sta->identity) {
1239 *buf = NULL;
1240 return 0;
1241 }
1242
1243 identity = sta->identity;
1244 len = os_strlen(identity);
1245 *buf = (u8 *) identity;
1246
1247 return len;
1248 }
1249
1250
1251 static int
hostapd_wpa_auth_set_radius_cui(void *ctx, const u8 *sta_addr, const u8 *radius_cui, size_t radius_cui_len)1252 hostapd_wpa_auth_set_radius_cui(void *ctx, const u8 *sta_addr,
1253 const u8 *radius_cui, size_t radius_cui_len)
1254 {
1255 struct hostapd_data *hapd = ctx;
1256 struct sta_info *sta;
1257
1258 sta = ap_get_sta(hapd, sta_addr);
1259 if (!sta)
1260 return -1;
1261
1262 os_free(sta->radius_cui);
1263 sta->radius_cui = NULL;
1264
1265 if (sta->eapol_sm) {
1266 wpabuf_free(sta->eapol_sm->radius_cui);
1267 sta->eapol_sm->radius_cui = NULL;
1268 }
1269
1270 if (!radius_cui)
1271 return 0;
1272
1273 /* sta->radius_cui is NULL terminated */
1274 sta->radius_cui = os_zalloc(radius_cui_len + 1);
1275 if (!sta->radius_cui)
1276 return -1;
1277 os_memcpy(sta->radius_cui, radius_cui, radius_cui_len);
1278
1279 if (sta->eapol_sm) {
1280 sta->eapol_sm->radius_cui = wpabuf_alloc_copy(radius_cui,
1281 radius_cui_len);
1282 if (!sta->eapol_sm->radius_cui)
1283 return -1;
1284 }
1285
1286 return 0;
1287 }
1288
1289
1290 static size_t
hostapd_wpa_auth_get_radius_cui(void *ctx, const u8 *sta_addr, const u8 **buf)1291 hostapd_wpa_auth_get_radius_cui(void *ctx, const u8 *sta_addr, const u8 **buf)
1292 {
1293 struct hostapd_data *hapd = ctx;
1294 struct sta_info *sta;
1295 struct wpabuf *b;
1296 size_t len;
1297 char *radius_cui;
1298
1299 sta = ap_get_sta(hapd, sta_addr);
1300 if (!sta)
1301 return 0;
1302
1303 b = ieee802_1x_get_radius_cui(sta->eapol_sm);
1304 if (b) {
1305 len = wpabuf_len(b);
1306 *buf = wpabuf_head(b);
1307 return len;
1308 }
1309
1310 if (!sta->radius_cui) {
1311 *buf = NULL;
1312 return 0;
1313 }
1314
1315 radius_cui = sta->radius_cui;
1316 len = os_strlen(radius_cui);
1317 *buf = (u8 *) radius_cui;
1318
1319 return len;
1320 }
1321
1322
hostapd_wpa_auth_set_session_timeout(void *ctx, const u8 *sta_addr, int session_timeout)1323 static void hostapd_wpa_auth_set_session_timeout(void *ctx, const u8 *sta_addr,
1324 int session_timeout)
1325 {
1326 struct hostapd_data *hapd = ctx;
1327 struct sta_info *sta;
1328
1329 sta = ap_get_sta(hapd, sta_addr);
1330 if (!sta)
1331 return;
1332
1333 if (session_timeout) {
1334 os_get_reltime(&sta->session_timeout);
1335 sta->session_timeout.sec += session_timeout;
1336 sta->session_timeout_set = 1;
1337 ap_sta_session_timeout(hapd, sta, session_timeout);
1338 } else {
1339 sta->session_timeout_set = 0;
1340 ap_sta_no_session_timeout(hapd, sta);
1341 }
1342 }
1343
1344
hostapd_wpa_auth_get_session_timeout(void *ctx, const u8 *sta_addr)1345 static int hostapd_wpa_auth_get_session_timeout(void *ctx, const u8 *sta_addr)
1346 {
1347 struct hostapd_data *hapd = ctx;
1348 struct sta_info *sta;
1349 struct os_reltime now, remaining;
1350
1351 sta = ap_get_sta(hapd, sta_addr);
1352 if (!sta || !sta->session_timeout_set)
1353 return 0;
1354
1355 os_get_reltime(&now);
1356 if (os_reltime_before(&sta->session_timeout, &now)) {
1357 /* already expired, return >0 as timeout was set */
1358 return 1;
1359 }
1360
1361 os_reltime_sub(&sta->session_timeout, &now, &remaining);
1362
1363 return (remaining.sec > 0) ? remaining.sec : 1;
1364 }
1365
1366
hostapd_rrb_receive(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)1367 static void hostapd_rrb_receive(void *ctx, const u8 *src_addr, const u8 *buf,
1368 size_t len)
1369 {
1370 struct hostapd_data *hapd = ctx;
1371 struct l2_ethhdr *ethhdr;
1372 if (len < sizeof(*ethhdr))
1373 return;
1374 ethhdr = (struct l2_ethhdr *) buf;
1375 wpa_printf(MSG_DEBUG, "FT: RRB received packet " MACSTR_SEC " -> "
1376 MACSTR_SEC, MAC2STR_SEC(ethhdr->h_source), MAC2STR_SEC(ethhdr->h_dest));
1377 if (!is_multicast_ether_addr(ethhdr->h_dest) &&
1378 os_memcmp(hapd->own_addr, ethhdr->h_dest, ETH_ALEN) != 0)
1379 return;
1380 wpa_ft_rrb_rx(hapd->wpa_auth, ethhdr->h_source, buf + sizeof(*ethhdr),
1381 len - sizeof(*ethhdr));
1382 }
1383
1384
hostapd_rrb_oui_receive(void *ctx, const u8 *src_addr, const u8 *dst_addr, u8 oui_suffix, const u8 *buf, size_t len)1385 static void hostapd_rrb_oui_receive(void *ctx, const u8 *src_addr,
1386 const u8 *dst_addr, u8 oui_suffix,
1387 const u8 *buf, size_t len)
1388 {
1389 struct hostapd_data *hapd = ctx;
1390
1391 wpa_printf(MSG_DEBUG, "FT: RRB received packet " MACSTR_SEC " -> "
1392 MACSTR_SEC, MAC2STR_SEC(src_addr), MAC2STR_SEC(dst_addr));
1393 if (!is_multicast_ether_addr(dst_addr) &&
1394 os_memcmp(hapd->own_addr, dst_addr, ETH_ALEN) != 0)
1395 return;
1396 wpa_ft_rrb_oui_rx(hapd->wpa_auth, src_addr, dst_addr, oui_suffix, buf,
1397 len);
1398 }
1399
1400
hostapd_wpa_auth_add_tspec(void *ctx, const u8 *sta_addr, u8 *tspec_ie, size_t tspec_ielen)1401 static int hostapd_wpa_auth_add_tspec(void *ctx, const u8 *sta_addr,
1402 u8 *tspec_ie, size_t tspec_ielen)
1403 {
1404 struct hostapd_data *hapd = ctx;
1405 return hostapd_add_tspec(hapd, sta_addr, tspec_ie, tspec_ielen);
1406 }
1407
1408
1409
hostapd_wpa_register_ft_oui(struct hostapd_data *hapd, const char *ft_iface)1410 static int hostapd_wpa_register_ft_oui(struct hostapd_data *hapd,
1411 const char *ft_iface)
1412 {
1413 hapd->oui_pull = eth_p_oui_register(hapd, ft_iface,
1414 FT_PACKET_R0KH_R1KH_PULL,
1415 hostapd_rrb_oui_receive, hapd);
1416 if (!hapd->oui_pull)
1417 return -1;
1418
1419 hapd->oui_resp = eth_p_oui_register(hapd, ft_iface,
1420 FT_PACKET_R0KH_R1KH_RESP,
1421 hostapd_rrb_oui_receive, hapd);
1422 if (!hapd->oui_resp)
1423 return -1;
1424
1425 hapd->oui_push = eth_p_oui_register(hapd, ft_iface,
1426 FT_PACKET_R0KH_R1KH_PUSH,
1427 hostapd_rrb_oui_receive, hapd);
1428 if (!hapd->oui_push)
1429 return -1;
1430
1431 hapd->oui_sreq = eth_p_oui_register(hapd, ft_iface,
1432 FT_PACKET_R0KH_R1KH_SEQ_REQ,
1433 hostapd_rrb_oui_receive, hapd);
1434 if (!hapd->oui_sreq)
1435 return -1;
1436
1437 hapd->oui_sresp = eth_p_oui_register(hapd, ft_iface,
1438 FT_PACKET_R0KH_R1KH_SEQ_RESP,
1439 hostapd_rrb_oui_receive, hapd);
1440 if (!hapd->oui_sresp)
1441 return -1;
1442
1443 return 0;
1444 }
1445
1446
hostapd_wpa_unregister_ft_oui(struct hostapd_data *hapd)1447 static void hostapd_wpa_unregister_ft_oui(struct hostapd_data *hapd)
1448 {
1449 eth_p_oui_unregister(hapd->oui_pull);
1450 hapd->oui_pull = NULL;
1451 eth_p_oui_unregister(hapd->oui_resp);
1452 hapd->oui_resp = NULL;
1453 eth_p_oui_unregister(hapd->oui_push);
1454 hapd->oui_push = NULL;
1455 eth_p_oui_unregister(hapd->oui_sreq);
1456 hapd->oui_sreq = NULL;
1457 eth_p_oui_unregister(hapd->oui_sresp);
1458 hapd->oui_sresp = NULL;
1459 }
1460 #endif /* CONFIG_IEEE80211R_AP */
1461
1462
hostapd_setup_wpa(struct hostapd_data *hapd)1463 int hostapd_setup_wpa(struct hostapd_data *hapd)
1464 {
1465 struct wpa_auth_config _conf;
1466 static const struct wpa_auth_callbacks cb = {
1467 .logger = hostapd_wpa_auth_logger,
1468 .disconnect = hostapd_wpa_auth_disconnect,
1469 .mic_failure_report = hostapd_wpa_auth_mic_failure_report,
1470 .psk_failure_report = hostapd_wpa_auth_psk_failure_report,
1471 .set_eapol = hostapd_wpa_auth_set_eapol,
1472 .get_eapol = hostapd_wpa_auth_get_eapol,
1473 .get_psk = hostapd_wpa_auth_get_psk,
1474 .get_msk = hostapd_wpa_auth_get_msk,
1475 .set_key = hostapd_wpa_auth_set_key,
1476 .get_seqnum = hostapd_wpa_auth_get_seqnum,
1477 .send_eapol = hostapd_wpa_auth_send_eapol,
1478 .for_each_sta = hostapd_wpa_auth_for_each_sta,
1479 .for_each_auth = hostapd_wpa_auth_for_each_auth,
1480 .send_ether = hostapd_wpa_auth_send_ether,
1481 .send_oui = hostapd_wpa_auth_send_oui,
1482 .channel_info = hostapd_channel_info,
1483 .update_vlan = hostapd_wpa_auth_update_vlan,
1484 #ifdef CONFIG_PASN
1485 .store_ptksa = hostapd_store_ptksa,
1486 .clear_ptksa = hostapd_clear_ptksa,
1487 #endif /* CONFIG_PASN */
1488
1489 #ifdef CONFIG_OCV
1490 .get_sta_tx_params = hostapd_get_sta_tx_params,
1491 #endif /* CONFIG_OCV */
1492 #ifdef CONFIG_IEEE80211R_AP
1493 .send_ft_action = hostapd_wpa_auth_send_ft_action,
1494 .add_sta = hostapd_wpa_auth_add_sta,
1495 .add_sta_ft = hostapd_wpa_auth_add_sta_ft,
1496 .add_tspec = hostapd_wpa_auth_add_tspec,
1497 .set_vlan = hostapd_wpa_auth_set_vlan,
1498 .get_vlan = hostapd_wpa_auth_get_vlan,
1499 .set_identity = hostapd_wpa_auth_set_identity,
1500 .get_identity = hostapd_wpa_auth_get_identity,
1501 .set_radius_cui = hostapd_wpa_auth_set_radius_cui,
1502 .get_radius_cui = hostapd_wpa_auth_get_radius_cui,
1503 .set_session_timeout = hostapd_wpa_auth_set_session_timeout,
1504 .get_session_timeout = hostapd_wpa_auth_get_session_timeout,
1505 #endif /* CONFIG_IEEE80211R_AP */
1506 };
1507 const u8 *wpa_ie;
1508 size_t wpa_ie_len;
1509
1510 hostapd_wpa_auth_conf(hapd->conf, hapd->iconf, &_conf);
1511 _conf.msg_ctx = hapd->msg_ctx;
1512 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_EAPOL_TX_STATUS)
1513 _conf.tx_status = 1;
1514 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_MLME)
1515 _conf.ap_mlme = 1;
1516
1517 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_WIRED) &&
1518 (hapd->conf->wpa_deny_ptk0_rekey == PTK0_REKEY_ALLOW_NEVER ||
1519 (hapd->conf->wpa_deny_ptk0_rekey == PTK0_REKEY_ALLOW_LOCAL_OK &&
1520 !(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_SAFE_PTK0_REKEYS)))) {
1521 wpa_msg(hapd->msg_ctx, MSG_INFO,
1522 "Disable PTK0 rekey support - replaced with disconnect");
1523 _conf.wpa_deny_ptk0_rekey = 1;
1524 }
1525
1526 if (_conf.extended_key_id &&
1527 (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_EXTENDED_KEY_ID))
1528 wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Extended Key ID supported");
1529 else
1530 _conf.extended_key_id = 0;
1531
1532 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_BEACON_PROTECTION))
1533 _conf.beacon_prot = 0;
1534
1535 #ifdef CONFIG_OCV
1536 if (!(hapd->iface->drv_flags2 &
1537 (WPA_DRIVER_FLAGS2_AP_SME | WPA_DRIVER_FLAGS2_OCV)))
1538 _conf.ocv = 0;
1539 #endif /* CONFIG_OCV */
1540
1541 _conf.secure_ltf =
1542 !!(hapd->iface->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_LTF);
1543 _conf.secure_rtt =
1544 !!(hapd->iface->drv_flags2 & WPA_DRIVER_FLAGS2_SEC_RTT);
1545 _conf.prot_range_neg =
1546 !!(hapd->iface->drv_flags2 & WPA_DRIVER_FLAGS2_PROT_RANGE_NEG);
1547
1548 hapd->wpa_auth = wpa_init(hapd->own_addr, &_conf, &cb, hapd);
1549 if (hapd->wpa_auth == NULL) {
1550 wpa_printf(MSG_ERROR, "WPA initialization failed.");
1551 return -1;
1552 }
1553
1554 if (hostapd_set_privacy(hapd, 1)) {
1555 wpa_printf(MSG_ERROR, "Could not set PrivacyInvoked "
1556 "for interface %s", hapd->conf->iface);
1557 return -1;
1558 }
1559
1560 wpa_ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &wpa_ie_len);
1561 if (hostapd_set_generic_elem(hapd, wpa_ie, wpa_ie_len)) {
1562 wpa_printf(MSG_ERROR, "Failed to configure WPA IE for "
1563 "the kernel driver.");
1564 return -1;
1565 }
1566
1567 if (rsn_preauth_iface_init(hapd)) {
1568 wpa_printf(MSG_ERROR, "Initialization of RSN "
1569 "pre-authentication failed.");
1570 return -1;
1571 }
1572
1573 if (!hapd->ptksa)
1574 hapd->ptksa = ptksa_cache_init();
1575 if (!hapd->ptksa) {
1576 wpa_printf(MSG_ERROR, "Failed to allocate PTKSA cache");
1577 return -1;
1578 }
1579
1580 #ifdef CONFIG_IEEE80211R_AP
1581 if (!hostapd_drv_none(hapd) &&
1582 wpa_key_mgmt_ft(hapd->conf->wpa_key_mgmt)) {
1583 const char *ft_iface;
1584
1585 ft_iface = hapd->conf->bridge[0] ? hapd->conf->bridge :
1586 hapd->conf->iface;
1587 hapd->l2 = l2_packet_init(ft_iface, NULL, ETH_P_RRB,
1588 hostapd_rrb_receive, hapd, 1);
1589 if (!hapd->l2) {
1590 wpa_printf(MSG_ERROR, "Failed to open l2_packet "
1591 "interface");
1592 return -1;
1593 }
1594
1595 if (hostapd_wpa_register_ft_oui(hapd, ft_iface)) {
1596 wpa_printf(MSG_ERROR,
1597 "Failed to open ETH_P_OUI interface");
1598 return -1;
1599 }
1600 }
1601 #endif /* CONFIG_IEEE80211R_AP */
1602
1603 return 0;
1604
1605 }
1606
1607
hostapd_reconfig_wpa(struct hostapd_data *hapd)1608 void hostapd_reconfig_wpa(struct hostapd_data *hapd)
1609 {
1610 struct wpa_auth_config wpa_auth_conf;
1611 hostapd_wpa_auth_conf(hapd->conf, hapd->iconf, &wpa_auth_conf);
1612 wpa_reconfig(hapd->wpa_auth, &wpa_auth_conf);
1613 }
1614
1615
hostapd_deinit_wpa(struct hostapd_data *hapd)1616 void hostapd_deinit_wpa(struct hostapd_data *hapd)
1617 {
1618 ieee80211_tkip_countermeasures_deinit(hapd);
1619 ptksa_cache_deinit(hapd->ptksa);
1620 hapd->ptksa = NULL;
1621
1622 rsn_preauth_iface_deinit(hapd);
1623 if (hapd->wpa_auth) {
1624 wpa_deinit(hapd->wpa_auth);
1625 hapd->wpa_auth = NULL;
1626
1627 if (hapd->drv_priv && hostapd_set_privacy(hapd, 0)) {
1628 wpa_printf(MSG_DEBUG, "Could not disable "
1629 "PrivacyInvoked for interface %s",
1630 hapd->conf->iface);
1631 }
1632
1633 if (hapd->drv_priv &&
1634 hostapd_set_generic_elem(hapd, (u8 *) "", 0)) {
1635 wpa_printf(MSG_DEBUG, "Could not remove generic "
1636 "information element from interface %s",
1637 hapd->conf->iface);
1638 }
1639 }
1640 ieee802_1x_deinit(hapd);
1641
1642 #ifdef CONFIG_IEEE80211R_AP
1643 eloop_cancel_timeout(hostapd_wpa_ft_rrb_rx_later, hapd, ELOOP_ALL_CTX);
1644 hostapd_wpa_ft_rrb_rx_later(hapd, NULL); /* flush without delivering */
1645 eloop_cancel_timeout(hostapd_oui_deliver_later, hapd, ELOOP_ALL_CTX);
1646 hostapd_oui_deliver_later(hapd, NULL); /* flush without delivering */
1647 l2_packet_deinit(hapd->l2);
1648 hapd->l2 = NULL;
1649 hostapd_wpa_unregister_ft_oui(hapd);
1650 #endif /* CONFIG_IEEE80211R_AP */
1651 }
1652