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