2 * hostapd / WPA authenticator glue code
3 * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
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 "crypto/sha1.h"
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"
22 #include "eth_p_oui.h"
24 #include "ieee802_1x.h"
25 #include "preauth_auth.h"
27 #include "tkip_countermeasures.h"
28 #include "ap_drv_ops.h"
29 #include "ap_config.h"
30 #include "ieee802_11.h"
31 #include "pmksa_cache_auth.h"
33 #include "wpa_auth_glue.h"
36 static void hostapd_wpa_auth_conf(struct hostapd_bss_config
*conf
,
37 struct hostapd_config
*iconf
,
38 struct wpa_auth_config
*wconf
)
42 os_memset(wconf
, 0, sizeof(*wconf
));
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
;
51 wconf
->wpa_group_update_count
= conf
->wpa_group_update_count
;
52 wconf
->wpa_disable_eapol_key_retries
=
53 conf
->wpa_disable_eapol_key_retries
;
54 wconf
->wpa_pairwise_update_count
= conf
->wpa_pairwise_update_count
;
55 wconf
->rsn_pairwise
= conf
->rsn_pairwise
;
56 wconf
->rsn_preauth
= conf
->rsn_preauth
;
57 wconf
->eapol_version
= conf
->eapol_version
;
59 if (wconf
->eapol_version
> 2)
60 wconf
->eapol_version
= 2;
61 #endif /* CONFIG_MACSEC */
62 wconf
->wmm_enabled
= conf
->wmm_enabled
;
63 wconf
->wmm_uapsd
= conf
->wmm_uapsd
;
64 wconf
->disable_pmksa_caching
= conf
->disable_pmksa_caching
;
66 wconf
->ocv
= conf
->ocv
;
67 #endif /* CONFIG_OCV */
68 wconf
->okc
= conf
->okc
;
69 wconf
->ieee80211w
= conf
->ieee80211w
;
70 wconf
->beacon_prot
= conf
->beacon_prot
;
71 wconf
->group_mgmt_cipher
= conf
->group_mgmt_cipher
;
72 wconf
->sae_require_mfp
= conf
->sae_require_mfp
;
73 #ifdef CONFIG_IEEE80211R_AP
74 wconf
->ssid_len
= conf
->ssid
.ssid_len
;
75 if (wconf
->ssid_len
> SSID_MAX_LEN
)
76 wconf
->ssid_len
= SSID_MAX_LEN
;
77 os_memcpy(wconf
->ssid
, conf
->ssid
.ssid
, wconf
->ssid_len
);
78 os_memcpy(wconf
->mobility_domain
, conf
->mobility_domain
,
79 MOBILITY_DOMAIN_ID_LEN
);
80 if (conf
->nas_identifier
&&
81 os_strlen(conf
->nas_identifier
) <= FT_R0KH_ID_MAX_LEN
) {
82 wconf
->r0_key_holder_len
= os_strlen(conf
->nas_identifier
);
83 os_memcpy(wconf
->r0_key_holder
, conf
->nas_identifier
,
84 wconf
->r0_key_holder_len
);
86 os_memcpy(wconf
->r1_key_holder
, conf
->r1_key_holder
, FT_R1KH_ID_LEN
);
87 wconf
->r0_key_lifetime
= conf
->r0_key_lifetime
;
88 wconf
->r1_max_key_lifetime
= conf
->r1_max_key_lifetime
;
89 wconf
->reassociation_deadline
= conf
->reassociation_deadline
;
90 wconf
->rkh_pos_timeout
= conf
->rkh_pos_timeout
;
91 wconf
->rkh_neg_timeout
= conf
->rkh_neg_timeout
;
92 wconf
->rkh_pull_timeout
= conf
->rkh_pull_timeout
;
93 wconf
->rkh_pull_retries
= conf
->rkh_pull_retries
;
94 wconf
->r0kh_list
= &conf
->r0kh_list
;
95 wconf
->r1kh_list
= &conf
->r1kh_list
;
96 wconf
->pmk_r1_push
= conf
->pmk_r1_push
;
97 wconf
->ft_over_ds
= conf
->ft_over_ds
;
98 wconf
->ft_psk_generate_local
= conf
->ft_psk_generate_local
;
99 #endif /* CONFIG_IEEE80211R_AP */
101 wconf
->disable_gtk
= conf
->disable_dgaf
;
103 wconf
->disable_gtk
= 1;
104 wconf
->wpa
= WPA_PROTO_OSEN
;
105 wconf
->wpa_key_mgmt
= WPA_KEY_MGMT_OSEN
;
106 wconf
->wpa_pairwise
= 0;
107 wconf
->wpa_group
= WPA_CIPHER_CCMP
;
108 wconf
->rsn_pairwise
= WPA_CIPHER_CCMP
;
109 wconf
->rsn_preauth
= 0;
110 wconf
->disable_pmksa_caching
= 1;
111 wconf
->ieee80211w
= 1;
113 #endif /* CONFIG_HS20 */
114 #ifdef CONFIG_TESTING_OPTIONS
115 wconf
->corrupt_gtk_rekey_mic_probability
=
116 iconf
->corrupt_gtk_rekey_mic_probability
;
117 if (conf
->own_ie_override
&&
118 wpabuf_len(conf
->own_ie_override
) <= MAX_OWN_IE_OVERRIDE
) {
119 wconf
->own_ie_override_len
= wpabuf_len(conf
->own_ie_override
);
120 os_memcpy(wconf
->own_ie_override
,
121 wpabuf_head(conf
->own_ie_override
),
122 wconf
->own_ie_override_len
);
124 if (conf
->rsne_override_eapol
&&
125 wpabuf_len(conf
->rsne_override_eapol
) <= MAX_OWN_IE_OVERRIDE
) {
126 wconf
->rsne_override_eapol_set
= 1;
127 wconf
->rsne_override_eapol_len
=
128 wpabuf_len(conf
->rsne_override_eapol
);
129 os_memcpy(wconf
->rsne_override_eapol
,
130 wpabuf_head(conf
->rsne_override_eapol
),
131 wconf
->rsne_override_eapol_len
);
133 if (conf
->rsnxe_override_eapol
&&
134 wpabuf_len(conf
->rsnxe_override_eapol
) <= MAX_OWN_IE_OVERRIDE
) {
135 wconf
->rsnxe_override_eapol_set
= 1;
136 wconf
->rsnxe_override_eapol_len
=
137 wpabuf_len(conf
->rsnxe_override_eapol
);
138 os_memcpy(wconf
->rsnxe_override_eapol
,
139 wpabuf_head(conf
->rsnxe_override_eapol
),
140 wconf
->rsnxe_override_eapol_len
);
142 if (conf
->gtk_rsc_override
&&
143 wpabuf_len(conf
->gtk_rsc_override
) > 0 &&
144 wpabuf_len(conf
->gtk_rsc_override
) <= WPA_KEY_RSC_LEN
) {
145 os_memcpy(wconf
->gtk_rsc_override
,
146 wpabuf_head(conf
->gtk_rsc_override
),
147 wpabuf_len(conf
->gtk_rsc_override
));
148 wconf
->gtk_rsc_override_set
= 1;
150 if (conf
->igtk_rsc_override
&&
151 wpabuf_len(conf
->igtk_rsc_override
) > 0 &&
152 wpabuf_len(conf
->igtk_rsc_override
) <= WPA_KEY_RSC_LEN
) {
153 os_memcpy(wconf
->igtk_rsc_override
,
154 wpabuf_head(conf
->igtk_rsc_override
),
155 wpabuf_len(conf
->igtk_rsc_override
));
156 wconf
->igtk_rsc_override_set
= 1;
158 #endif /* CONFIG_TESTING_OPTIONS */
160 os_memcpy(wconf
->ip_addr_go
, conf
->ip_addr_go
, 4);
161 os_memcpy(wconf
->ip_addr_mask
, conf
->ip_addr_mask
, 4);
162 os_memcpy(wconf
->ip_addr_start
, conf
->ip_addr_start
, 4);
163 os_memcpy(wconf
->ip_addr_end
, conf
->ip_addr_end
, 4);
164 #endif /* CONFIG_P2P */
166 wconf
->fils_cache_id_set
= conf
->fils_cache_id_set
;
167 os_memcpy(wconf
->fils_cache_id
, conf
->fils_cache_id
,
169 #endif /* CONFIG_FILS */
170 wconf
->sae_pwe
= conf
->sae_pwe
;
171 sae_pw_id
= hostapd_sae_pw_id_in_use(conf
);
172 if (sae_pw_id
== 2 && wconf
->sae_pwe
!= 3)
174 else if (sae_pw_id
== 1 && wconf
->sae_pwe
== 0)
177 wconf
->owe_ptk_workaround
= conf
->owe_ptk_workaround
;
178 #endif /* CONFIG_OWE */
182 static void hostapd_wpa_auth_logger(void *ctx
, const u8
*addr
,
183 logger_level level
, const char *txt
)
185 #ifndef CONFIG_NO_HOSTAPD_LOGGER
186 struct hostapd_data
*hapd
= ctx
;
191 hlevel
= HOSTAPD_LEVEL_WARNING
;
194 hlevel
= HOSTAPD_LEVEL_INFO
;
198 hlevel
= HOSTAPD_LEVEL_DEBUG
;
202 hostapd_logger(hapd
, addr
, HOSTAPD_MODULE_WPA
, hlevel
, "%s", txt
);
203 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
207 static void hostapd_wpa_auth_disconnect(void *ctx
, const u8
*addr
,
210 struct hostapd_data
*hapd
= ctx
;
211 wpa_printf(MSG_DEBUG
, "%s: WPA authenticator requests disconnect: "
212 "STA " MACSTR
" reason %d",
213 __func__
, MAC2STR(addr
), reason
);
214 ap_sta_disconnect(hapd
, NULL
, addr
, reason
);
218 static int hostapd_wpa_auth_mic_failure_report(void *ctx
, const u8
*addr
)
220 struct hostapd_data
*hapd
= ctx
;
221 return michael_mic_failure(hapd
, addr
, 0);
225 static void hostapd_wpa_auth_psk_failure_report(void *ctx
, const u8
*addr
)
227 struct hostapd_data
*hapd
= ctx
;
228 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, AP_STA_POSSIBLE_PSK_MISMATCH MACSTR
,
233 static void hostapd_wpa_auth_set_eapol(void *ctx
, const u8
*addr
,
234 wpa_eapol_variable var
, int value
)
236 struct hostapd_data
*hapd
= ctx
;
237 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
241 case WPA_EAPOL_portEnabled
:
242 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, value
);
244 case WPA_EAPOL_portValid
:
245 ieee802_1x_notify_port_valid(sta
->eapol_sm
, value
);
247 case WPA_EAPOL_authorized
:
248 ieee802_1x_set_sta_authorized(hapd
, sta
, value
);
250 case WPA_EAPOL_portControl_Auto
:
252 sta
->eapol_sm
->portControl
= Auto
;
254 case WPA_EAPOL_keyRun
:
256 sta
->eapol_sm
->keyRun
= value
? TRUE
: FALSE
;
258 case WPA_EAPOL_keyAvailable
:
260 sta
->eapol_sm
->eap_if
->eapKeyAvailable
=
261 value
? TRUE
: FALSE
;
263 case WPA_EAPOL_keyDone
:
265 sta
->eapol_sm
->keyDone
= value
? TRUE
: FALSE
;
267 case WPA_EAPOL_inc_EapolFramesTx
:
269 sta
->eapol_sm
->dot1xAuthEapolFramesTx
++;
275 static int hostapd_wpa_auth_get_eapol(void *ctx
, const u8
*addr
,
276 wpa_eapol_variable var
)
278 struct hostapd_data
*hapd
= ctx
;
279 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
280 if (sta
== NULL
|| sta
->eapol_sm
== NULL
)
283 case WPA_EAPOL_keyRun
:
284 return sta
->eapol_sm
->keyRun
;
285 case WPA_EAPOL_keyAvailable
:
286 return sta
->eapol_sm
->eap_if
->eapKeyAvailable
;
293 static const u8
* hostapd_wpa_auth_get_psk(void *ctx
, const u8
*addr
,
294 const u8
*p2p_dev_addr
,
295 const u8
*prev_psk
, size_t *psk_len
,
298 struct hostapd_data
*hapd
= ctx
;
299 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
308 if (sta
&& sta
->auth_alg
== WLAN_AUTH_SAE
) {
309 if (!sta
->sae
|| prev_psk
)
311 return sta
->sae
->pmk
;
313 if (sta
&& wpa_auth_uses_sae(sta
->wpa_sm
)) {
314 wpa_printf(MSG_DEBUG
,
315 "No PSK for STA trying to use SAE with PMKSA caching");
318 #endif /* CONFIG_SAE */
321 if ((hapd
->conf
->wpa_key_mgmt
& WPA_KEY_MGMT_OWE
) &&
322 sta
&& sta
->owe_pmk
) {
324 *psk_len
= sta
->owe_pmk_len
;
327 if ((hapd
->conf
->wpa_key_mgmt
& WPA_KEY_MGMT_OWE
) && sta
) {
328 struct rsn_pmksa_cache_entry
*sa
;
330 sa
= wpa_auth_sta_get_pmksa(sta
->wpa_sm
);
331 if (sa
&& sa
->akmp
== WPA_KEY_MGMT_OWE
) {
333 *psk_len
= sa
->pmk_len
;
337 #endif /* CONFIG_OWE */
339 psk
= hostapd_get_psk(hapd
->conf
, addr
, p2p_dev_addr
, prev_psk
,
342 * This is about to iterate over all psks, prev_psk gives the last
343 * returned psk which should not be returned again.
344 * logic list (all hostapd_get_psk; all sta->psk)
346 if (sta
&& sta
->psk
&& !psk
) {
347 struct hostapd_sta_wpa_psk_short
*pos
;
352 for (pos
= sta
->psk
; pos
; pos
= pos
->next
) {
353 if (pos
->is_passphrase
) {
354 pbkdf2_sha1(pos
->passphrase
,
355 hapd
->conf
->ssid
.ssid
,
356 hapd
->conf
->ssid
.ssid_len
, 4096,
358 pos
->is_passphrase
= 0;
360 if (pos
->psk
== prev_psk
) {
361 psk
= pos
->next
? pos
->next
->psk
: NULL
;
370 static int hostapd_wpa_auth_get_msk(void *ctx
, const u8
*addr
, u8
*msk
,
373 struct hostapd_data
*hapd
= ctx
;
376 struct sta_info
*sta
;
378 sta
= ap_get_sta(hapd
, addr
);
380 wpa_printf(MSG_DEBUG
, "AUTH_GET_MSK: Cannot find STA");
384 key
= ieee802_1x_get_key(sta
->eapol_sm
, &keylen
);
386 wpa_printf(MSG_DEBUG
, "AUTH_GET_MSK: Key is null, eapol_sm: %p",
393 os_memcpy(msk
, key
, keylen
);
400 static int hostapd_wpa_auth_set_key(void *ctx
, int vlan_id
, enum wpa_alg alg
,
401 const u8
*addr
, int idx
, u8
*key
,
402 size_t key_len
, enum key_flag key_flag
)
404 struct hostapd_data
*hapd
= ctx
;
405 const char *ifname
= hapd
->conf
->iface
;
408 ifname
= hostapd_get_vlan_id_ifname(hapd
->conf
->vlan
, vlan_id
);
410 if (!(hapd
->iface
->drv_flags
&
411 WPA_DRIVER_FLAGS_VLAN_OFFLOAD
))
413 ifname
= hapd
->conf
->iface
;
417 #ifdef CONFIG_TESTING_OPTIONS
418 if (addr
&& !is_broadcast_ether_addr(addr
)) {
419 struct sta_info
*sta
;
421 sta
= ap_get_sta(hapd
, addr
);
423 sta
->last_tk_alg
= alg
;
424 sta
->last_tk_key_idx
= idx
;
426 os_memcpy(sta
->last_tk
, key
, key_len
);
427 sta
->last_tk_len
= key_len
;
429 } else if (alg
== WPA_ALG_IGTK
||
430 alg
== WPA_ALG_BIP_GMAC_128
||
431 alg
== WPA_ALG_BIP_GMAC_256
||
432 alg
== WPA_ALG_BIP_CMAC_256
) {
433 hapd
->last_igtk_alg
= alg
;
434 hapd
->last_igtk_key_idx
= idx
;
436 os_memcpy(hapd
->last_igtk
, key
, key_len
);
437 hapd
->last_igtk_len
= key_len
;
439 hapd
->last_gtk_alg
= alg
;
440 hapd
->last_gtk_key_idx
= idx
;
442 os_memcpy(hapd
->last_gtk
, key
, key_len
);
443 hapd
->last_gtk_len
= key_len
;
445 #endif /* CONFIG_TESTING_OPTIONS */
446 return hostapd_drv_set_key(ifname
, hapd
, alg
, addr
, idx
, vlan_id
, 1,
447 NULL
, 0, key
, key_len
, key_flag
);
451 static int hostapd_wpa_auth_get_seqnum(void *ctx
, const u8
*addr
, int idx
,
454 struct hostapd_data
*hapd
= ctx
;
455 return hostapd_get_seqnum(hapd
->conf
->iface
, hapd
, addr
, idx
, seq
);
459 static int hostapd_wpa_auth_send_eapol(void *ctx
, const u8
*addr
,
460 const u8
*data
, size_t data_len
,
463 struct hostapd_data
*hapd
= ctx
;
464 struct sta_info
*sta
;
467 #ifdef CONFIG_TESTING_OPTIONS
468 if (hapd
->ext_eapol_frame_io
) {
469 size_t hex_len
= 2 * data_len
+ 1;
470 char *hex
= os_malloc(hex_len
);
474 wpa_snprintf_hex(hex
, hex_len
, data
, data_len
);
475 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, "EAPOL-TX " MACSTR
" %s",
480 #endif /* CONFIG_TESTING_OPTIONS */
482 sta
= ap_get_sta(hapd
, addr
);
484 flags
= hostapd_sta_flags_to_drv(sta
->flags
);
486 return hostapd_drv_hapd_send_eapol(hapd
, addr
, data
, data_len
,
491 static int hostapd_wpa_auth_for_each_sta(
492 void *ctx
, int (*cb
)(struct wpa_state_machine
*sm
, void *ctx
),
495 struct hostapd_data
*hapd
= ctx
;
496 struct sta_info
*sta
;
498 for (sta
= hapd
->sta_list
; sta
; sta
= sta
->next
) {
499 if (sta
->wpa_sm
&& cb(sta
->wpa_sm
, cb_ctx
))
506 struct wpa_auth_iface_iter_data
{
507 int (*cb
)(struct wpa_authenticator
*sm
, void *ctx
);
511 static int wpa_auth_iface_iter(struct hostapd_iface
*iface
, void *ctx
)
513 struct wpa_auth_iface_iter_data
*data
= ctx
;
515 for (i
= 0; i
< iface
->num_bss
; i
++) {
516 if (iface
->bss
[i
]->wpa_auth
&&
517 data
->cb(iface
->bss
[i
]->wpa_auth
, data
->cb_ctx
))
524 static int hostapd_wpa_auth_for_each_auth(
525 void *ctx
, int (*cb
)(struct wpa_authenticator
*sm
, void *ctx
),
528 struct hostapd_data
*hapd
= ctx
;
529 struct wpa_auth_iface_iter_data data
;
530 if (hapd
->iface
->interfaces
== NULL
||
531 hapd
->iface
->interfaces
->for_each_interface
== NULL
)
534 data
.cb_ctx
= cb_ctx
;
535 return hapd
->iface
->interfaces
->for_each_interface(
536 hapd
->iface
->interfaces
, wpa_auth_iface_iter
, &data
);
540 #ifdef CONFIG_IEEE80211R_AP
542 struct wpa_ft_rrb_rx_later_data
{
546 /* followed by data_len octets of data */
549 static void hostapd_wpa_ft_rrb_rx_later(void *eloop_ctx
, void *timeout_ctx
)
551 struct hostapd_data
*hapd
= eloop_ctx
;
552 struct wpa_ft_rrb_rx_later_data
*data
, *n
;
554 dl_list_for_each_safe(data
, n
, &hapd
->l2_queue
,
555 struct wpa_ft_rrb_rx_later_data
, list
) {
556 if (hapd
->wpa_auth
) {
557 wpa_ft_rrb_rx(hapd
->wpa_auth
, data
->addr
,
558 (const u8
*) (data
+ 1),
561 dl_list_del(&data
->list
);
567 struct wpa_auth_ft_iface_iter_data
{
568 struct hostapd_data
*src_hapd
;
575 static int hostapd_wpa_auth_ft_iter(struct hostapd_iface
*iface
, void *ctx
)
577 struct wpa_auth_ft_iface_iter_data
*idata
= ctx
;
578 struct wpa_ft_rrb_rx_later_data
*data
;
579 struct hostapd_data
*hapd
;
582 for (j
= 0; j
< iface
->num_bss
; j
++) {
583 hapd
= iface
->bss
[j
];
584 if (hapd
== idata
->src_hapd
||
586 os_memcmp(hapd
->own_addr
, idata
->dst
, ETH_ALEN
) != 0)
589 wpa_printf(MSG_DEBUG
,
590 "FT: Send RRB data directly to locally managed BSS "
591 MACSTR
"@%s -> " MACSTR
"@%s",
592 MAC2STR(idata
->src_hapd
->own_addr
),
593 idata
->src_hapd
->conf
->iface
,
594 MAC2STR(hapd
->own_addr
), hapd
->conf
->iface
);
596 /* Defer wpa_ft_rrb_rx() until next eloop step as this is
597 * when it would be triggered when reading from a socket.
599 * hapd0:send -> hapd1:recv -> hapd1:send -> hapd0:recv,
600 * that is calling hapd0:recv handler from within
601 * hapd0:send directly.
603 data
= os_zalloc(sizeof(*data
) + idata
->data_len
);
607 os_memcpy(data
->addr
, idata
->src_hapd
->own_addr
, ETH_ALEN
);
608 os_memcpy(data
+ 1, idata
->data
, idata
->data_len
);
609 data
->data_len
= idata
->data_len
;
611 dl_list_add(&hapd
->l2_queue
, &data
->list
);
613 if (!eloop_is_timeout_registered(hostapd_wpa_ft_rrb_rx_later
,
615 eloop_register_timeout(0, 0,
616 hostapd_wpa_ft_rrb_rx_later
,
625 #endif /* CONFIG_IEEE80211R_AP */
628 static int hostapd_wpa_auth_send_ether(void *ctx
, const u8
*dst
, u16 proto
,
629 const u8
*data
, size_t data_len
)
631 struct hostapd_data
*hapd
= ctx
;
632 struct l2_ethhdr
*buf
;
635 #ifdef CONFIG_TESTING_OPTIONS
636 if (hapd
->ext_eapol_frame_io
&& proto
== ETH_P_EAPOL
) {
637 size_t hex_len
= 2 * data_len
+ 1;
638 char *hex
= os_malloc(hex_len
);
642 wpa_snprintf_hex(hex
, hex_len
, data
, data_len
);
643 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, "EAPOL-TX " MACSTR
" %s",
648 #endif /* CONFIG_TESTING_OPTIONS */
650 #ifdef CONFIG_IEEE80211R_AP
651 if (proto
== ETH_P_RRB
&& hapd
->iface
->interfaces
&&
652 hapd
->iface
->interfaces
->for_each_interface
) {
654 struct wpa_auth_ft_iface_iter_data idata
;
655 idata
.src_hapd
= hapd
;
658 idata
.data_len
= data_len
;
659 res
= hapd
->iface
->interfaces
->for_each_interface(
660 hapd
->iface
->interfaces
, hostapd_wpa_auth_ft_iter
,
665 #endif /* CONFIG_IEEE80211R_AP */
667 if (hapd
->l2
== NULL
)
670 buf
= os_malloc(sizeof(*buf
) + data_len
);
673 os_memcpy(buf
->h_dest
, dst
, ETH_ALEN
);
674 os_memcpy(buf
->h_source
, hapd
->own_addr
, ETH_ALEN
);
675 buf
->h_proto
= host_to_be16(proto
);
676 os_memcpy(buf
+ 1, data
, data_len
);
677 ret
= l2_packet_send(hapd
->l2
, dst
, proto
, (u8
*) buf
,
678 sizeof(*buf
) + data_len
);
684 #ifdef CONFIG_ETH_P_OUI
685 static struct eth_p_oui_ctx
* hostapd_wpa_get_oui(struct hostapd_data
*hapd
,
688 switch (oui_suffix
) {
689 #ifdef CONFIG_IEEE80211R_AP
690 case FT_PACKET_R0KH_R1KH_PULL
:
691 return hapd
->oui_pull
;
692 case FT_PACKET_R0KH_R1KH_RESP
:
693 return hapd
->oui_resp
;
694 case FT_PACKET_R0KH_R1KH_PUSH
:
695 return hapd
->oui_push
;
696 case FT_PACKET_R0KH_R1KH_SEQ_REQ
:
697 return hapd
->oui_sreq
;
698 case FT_PACKET_R0KH_R1KH_SEQ_RESP
:
699 return hapd
->oui_sresp
;
700 #endif /* CONFIG_IEEE80211R_AP */
705 #endif /* CONFIG_ETH_P_OUI */
708 #ifdef CONFIG_IEEE80211R_AP
710 struct oui_deliver_later_data
{
712 u8 src_addr
[ETH_ALEN
];
713 u8 dst_addr
[ETH_ALEN
];
716 /* followed by data_len octets of data */
719 static void hostapd_oui_deliver_later(void *eloop_ctx
, void *timeout_ctx
)
721 struct hostapd_data
*hapd
= eloop_ctx
;
722 struct oui_deliver_later_data
*data
, *n
;
723 struct eth_p_oui_ctx
*oui_ctx
;
725 dl_list_for_each_safe(data
, n
, &hapd
->l2_oui_queue
,
726 struct oui_deliver_later_data
, list
) {
727 oui_ctx
= hostapd_wpa_get_oui(hapd
, data
->oui_suffix
);
728 wpa_printf(MSG_DEBUG
, "RRB(%s): %s src=" MACSTR
" dst=" MACSTR
729 " oui_suffix=%u data_len=%u data=%p",
730 hapd
->conf
->iface
, __func__
,
731 MAC2STR(data
->src_addr
), MAC2STR(data
->dst_addr
),
732 data
->oui_suffix
, (unsigned int) data
->data_len
,
734 if (hapd
->wpa_auth
&& oui_ctx
) {
735 eth_p_oui_deliver(oui_ctx
, data
->src_addr
,
737 (const u8
*) (data
+ 1),
740 dl_list_del(&data
->list
);
746 struct wpa_auth_oui_iface_iter_data
{
747 struct hostapd_data
*src_hapd
;
754 static int hostapd_wpa_auth_oui_iter(struct hostapd_iface
*iface
, void *ctx
)
756 struct wpa_auth_oui_iface_iter_data
*idata
= ctx
;
757 struct oui_deliver_later_data
*data
;
758 struct hostapd_data
*hapd
, *src_hapd
= idata
->src_hapd
;
761 for (j
= 0; j
< iface
->num_bss
; j
++) {
762 hapd
= iface
->bss
[j
];
763 if (hapd
== src_hapd
)
764 continue; /* don't deliver back to same interface */
765 if (!wpa_key_mgmt_ft(hapd
->conf
->wpa_key_mgmt
) ||
766 hapd
->conf
->ssid
.ssid_len
!=
767 src_hapd
->conf
->ssid
.ssid_len
||
768 os_memcmp(hapd
->conf
->ssid
.ssid
,
769 src_hapd
->conf
->ssid
.ssid
,
770 hapd
->conf
->ssid
.ssid_len
) != 0 ||
771 os_memcmp(hapd
->conf
->mobility_domain
,
772 src_hapd
->conf
->mobility_domain
,
773 MOBILITY_DOMAIN_ID_LEN
) != 0)
774 continue; /* no matching FT SSID/mobility domain */
775 if (!is_multicast_ether_addr(idata
->dst_addr
) &&
776 os_memcmp(hapd
->own_addr
, idata
->dst_addr
, ETH_ALEN
) != 0)
777 continue; /* destination address does not match */
779 /* defer eth_p_oui_deliver until next eloop step as this is
780 * when it would be triggerd from reading from sock
782 * hapd0:send -> hapd1:recv -> hapd1:send -> hapd0:recv,
783 * that is calling hapd0:recv handler from within
784 * hapd0:send directly.
786 data
= os_zalloc(sizeof(*data
) + idata
->data_len
);
789 wpa_printf(MSG_DEBUG
,
790 "RRB(%s): local delivery to %s dst=" MACSTR
791 " oui_suffix=%u data_len=%u data=%p",
792 src_hapd
->conf
->iface
, hapd
->conf
->iface
,
793 MAC2STR(idata
->dst_addr
), idata
->oui_suffix
,
794 (unsigned int) idata
->data_len
, data
);
796 os_memcpy(data
->src_addr
, src_hapd
->own_addr
, ETH_ALEN
);
797 os_memcpy(data
->dst_addr
, idata
->dst_addr
, ETH_ALEN
);
798 os_memcpy(data
+ 1, idata
->data
, idata
->data_len
);
799 data
->data_len
= idata
->data_len
;
800 data
->oui_suffix
= idata
->oui_suffix
;
802 dl_list_add_tail(&hapd
->l2_oui_queue
, &data
->list
);
804 if (!eloop_is_timeout_registered(hostapd_oui_deliver_later
,
806 eloop_register_timeout(0, 0,
807 hostapd_oui_deliver_later
,
810 /* If dst_addr is a multicast address, do not return any
811 * non-zero value here. Otherwise, the iteration of
812 * for_each_interface() will be stopped. */
813 if (!is_multicast_ether_addr(idata
->dst_addr
))
820 #endif /* CONFIG_IEEE80211R_AP */
823 static int hostapd_wpa_auth_send_oui(void *ctx
, const u8
*dst
, u8 oui_suffix
,
824 const u8
*data
, size_t data_len
)
826 #ifdef CONFIG_ETH_P_OUI
827 struct hostapd_data
*hapd
= ctx
;
828 struct eth_p_oui_ctx
*oui_ctx
;
830 wpa_printf(MSG_DEBUG
, "RRB(%s): send to dst=" MACSTR
831 " oui_suffix=%u data_len=%u",
832 hapd
->conf
->iface
, MAC2STR(dst
), oui_suffix
,
833 (unsigned int) data_len
);
834 #ifdef CONFIG_IEEE80211R_AP
835 if (hapd
->iface
->interfaces
&&
836 hapd
->iface
->interfaces
->for_each_interface
) {
837 struct wpa_auth_oui_iface_iter_data idata
;
840 idata
.src_hapd
= hapd
;
841 idata
.dst_addr
= dst
;
843 idata
.data_len
= data_len
;
844 idata
.oui_suffix
= oui_suffix
;
845 res
= hapd
->iface
->interfaces
->for_each_interface(
846 hapd
->iface
->interfaces
, hostapd_wpa_auth_oui_iter
,
851 #endif /* CONFIG_IEEE80211R_AP */
853 oui_ctx
= hostapd_wpa_get_oui(hapd
, oui_suffix
);
857 return eth_p_oui_send(oui_ctx
, hapd
->own_addr
, dst
, data
, data_len
);
858 #else /* CONFIG_ETH_P_OUI */
860 #endif /* CONFIG_ETH_P_OUI */
864 static int hostapd_channel_info(void *ctx
, struct wpa_channel_info
*ci
)
866 struct hostapd_data
*hapd
= ctx
;
868 return hostapd_drv_channel_info(hapd
, ci
);
872 static int hostapd_wpa_auth_update_vlan(void *ctx
, const u8
*addr
, int vlan_id
)
874 #ifndef CONFIG_NO_VLAN
875 struct hostapd_data
*hapd
= ctx
;
876 struct sta_info
*sta
;
878 sta
= ap_get_sta(hapd
, addr
);
882 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_VLAN_OFFLOAD
)) {
883 struct vlan_description vlan_desc
;
885 os_memset(&vlan_desc
, 0, sizeof(vlan_desc
));
886 vlan_desc
.notempty
= 1;
887 vlan_desc
.untagged
= vlan_id
;
888 if (!hostapd_vlan_valid(hapd
->conf
->vlan
, &vlan_desc
)) {
890 "Invalid VLAN ID %d in wpa_psk_file",
895 if (ap_sta_set_vlan(hapd
, sta
, &vlan_desc
) < 0) {
897 "Failed to assign VLAN ID %d from wpa_psk_file to "
898 MACSTR
, vlan_id
, MAC2STR(sta
->addr
));
902 sta
->vlan_id
= vlan_id
;
906 "Assigned VLAN ID %d from wpa_psk_file to " MACSTR
,
907 vlan_id
, MAC2STR(sta
->addr
));
908 if ((sta
->flags
& WLAN_STA_ASSOC
) &&
909 ap_sta_bind_vlan(hapd
, sta
) < 0)
911 #endif /* CONFIG_NO_VLAN */
918 static int hostapd_get_sta_tx_params(void *ctx
, const u8
*addr
,
919 int ap_max_chanwidth
, int ap_seg1_idx
,
920 int *bandwidth
, int *seg1_idx
)
922 struct hostapd_data
*hapd
= ctx
;
923 struct sta_info
*sta
;
925 sta
= ap_get_sta(hapd
, addr
);
927 hostapd_wpa_auth_logger(hapd
, addr
, LOGGER_INFO
,
928 "Failed to get STA info to validate received OCI");
932 return get_tx_parameters(sta
, ap_max_chanwidth
, ap_seg1_idx
, bandwidth
,
935 #endif /* CONFIG_OCV */
938 #ifdef CONFIG_IEEE80211R_AP
940 static int hostapd_wpa_auth_send_ft_action(void *ctx
, const u8
*dst
,
941 const u8
*data
, size_t data_len
)
943 struct hostapd_data
*hapd
= ctx
;
945 struct ieee80211_mgmt
*m
;
947 struct sta_info
*sta
;
949 sta
= ap_get_sta(hapd
, dst
);
950 if (sta
== NULL
|| sta
->wpa_sm
== NULL
)
953 m
= os_zalloc(sizeof(*m
) + data_len
);
956 mlen
= ((u8
*) &m
->u
- (u8
*) m
) + data_len
;
957 m
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
958 WLAN_FC_STYPE_ACTION
);
959 os_memcpy(m
->da
, dst
, ETH_ALEN
);
960 os_memcpy(m
->sa
, hapd
->own_addr
, ETH_ALEN
);
961 os_memcpy(m
->bssid
, hapd
->own_addr
, ETH_ALEN
);
962 os_memcpy(&m
->u
, data
, data_len
);
964 res
= hostapd_drv_send_mlme(hapd
, (u8
*) m
, mlen
, 0, NULL
, 0, 0);
970 static struct wpa_state_machine
*
971 hostapd_wpa_auth_add_sta(void *ctx
, const u8
*sta_addr
)
973 struct hostapd_data
*hapd
= ctx
;
974 struct sta_info
*sta
;
977 wpa_printf(MSG_DEBUG
, "Add station entry for " MACSTR
978 " based on WPA authenticator callback",
980 ret
= hostapd_add_sta_node(hapd
, sta_addr
, WLAN_AUTH_FT
);
983 * The expected return values from hostapd_add_sta_node() are
984 * 0: successfully added STA entry
985 * -EOPNOTSUPP: driver or driver wrapper does not support/need this
987 * any other negative value: error in adding the STA entry */
988 if (ret
< 0 && ret
!= -EOPNOTSUPP
)
991 sta
= ap_sta_add(hapd
, sta_addr
);
995 sta
->added_unassoc
= 1;
999 sta
->auth_alg
= WLAN_AUTH_FT
;
1003 sta
->wpa_sm
= wpa_auth_sta_init(hapd
->wpa_auth
, sta
->addr
, NULL
);
1004 if (sta
->wpa_sm
== NULL
) {
1005 ap_free_sta(hapd
, sta
);
1008 sta
->auth_alg
= WLAN_AUTH_FT
;
1014 static int hostapd_wpa_auth_set_vlan(void *ctx
, const u8
*sta_addr
,
1015 struct vlan_description
*vlan
)
1017 struct hostapd_data
*hapd
= ctx
;
1018 struct sta_info
*sta
;
1020 sta
= ap_get_sta(hapd
, sta_addr
);
1021 if (!sta
|| !sta
->wpa_sm
)
1024 if (vlan
->notempty
&&
1025 !hostapd_vlan_valid(hapd
->conf
->vlan
, vlan
)) {
1026 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
1028 "Invalid VLAN %d%s received from FT",
1029 vlan
->untagged
, vlan
->tagged
[0] ? "+" : "");
1033 if (ap_sta_set_vlan(hapd
, sta
, vlan
) < 0)
1035 /* Configure wpa_group for GTK but ignore error due to driver not
1036 * knowing this STA. */
1037 ap_sta_bind_vlan(hapd
, sta
);
1040 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
1041 HOSTAPD_LEVEL_INFO
, "VLAN ID %d", sta
->vlan_id
);
1047 static int hostapd_wpa_auth_get_vlan(void *ctx
, const u8
*sta_addr
,
1048 struct vlan_description
*vlan
)
1050 struct hostapd_data
*hapd
= ctx
;
1051 struct sta_info
*sta
;
1053 sta
= ap_get_sta(hapd
, sta_addr
);
1058 *vlan
= *sta
->vlan_desc
;
1060 os_memset(vlan
, 0, sizeof(*vlan
));
1067 hostapd_wpa_auth_set_identity(void *ctx
, const u8
*sta_addr
,
1068 const u8
*identity
, size_t identity_len
)
1070 struct hostapd_data
*hapd
= ctx
;
1071 struct sta_info
*sta
;
1073 sta
= ap_get_sta(hapd
, sta_addr
);
1077 os_free(sta
->identity
);
1078 sta
->identity
= NULL
;
1080 if (sta
->eapol_sm
) {
1081 os_free(sta
->eapol_sm
->identity
);
1082 sta
->eapol_sm
->identity
= NULL
;
1083 sta
->eapol_sm
->identity_len
= 0;
1089 /* sta->identity is NULL terminated */
1090 sta
->identity
= os_zalloc(identity_len
+ 1);
1093 os_memcpy(sta
->identity
, identity
, identity_len
);
1095 if (sta
->eapol_sm
) {
1096 sta
->eapol_sm
->identity
= os_zalloc(identity_len
);
1097 if (!sta
->eapol_sm
->identity
)
1099 os_memcpy(sta
->eapol_sm
->identity
, identity
, identity_len
);
1100 sta
->eapol_sm
->identity_len
= identity_len
;
1108 hostapd_wpa_auth_get_identity(void *ctx
, const u8
*sta_addr
, const u8
**buf
)
1110 struct hostapd_data
*hapd
= ctx
;
1111 struct sta_info
*sta
;
1115 sta
= ap_get_sta(hapd
, sta_addr
);
1119 *buf
= ieee802_1x_get_identity(sta
->eapol_sm
, &len
);
1123 if (!sta
->identity
) {
1128 identity
= sta
->identity
;
1129 len
= os_strlen(identity
);
1130 *buf
= (u8
*) identity
;
1137 hostapd_wpa_auth_set_radius_cui(void *ctx
, const u8
*sta_addr
,
1138 const u8
*radius_cui
, size_t radius_cui_len
)
1140 struct hostapd_data
*hapd
= ctx
;
1141 struct sta_info
*sta
;
1143 sta
= ap_get_sta(hapd
, sta_addr
);
1147 os_free(sta
->radius_cui
);
1148 sta
->radius_cui
= NULL
;
1150 if (sta
->eapol_sm
) {
1151 wpabuf_free(sta
->eapol_sm
->radius_cui
);
1152 sta
->eapol_sm
->radius_cui
= NULL
;
1158 /* sta->radius_cui is NULL terminated */
1159 sta
->radius_cui
= os_zalloc(radius_cui_len
+ 1);
1160 if (!sta
->radius_cui
)
1162 os_memcpy(sta
->radius_cui
, radius_cui
, radius_cui_len
);
1164 if (sta
->eapol_sm
) {
1165 sta
->eapol_sm
->radius_cui
= wpabuf_alloc_copy(radius_cui
,
1167 if (!sta
->eapol_sm
->radius_cui
)
1176 hostapd_wpa_auth_get_radius_cui(void *ctx
, const u8
*sta_addr
, const u8
**buf
)
1178 struct hostapd_data
*hapd
= ctx
;
1179 struct sta_info
*sta
;
1184 sta
= ap_get_sta(hapd
, sta_addr
);
1188 b
= ieee802_1x_get_radius_cui(sta
->eapol_sm
);
1190 len
= wpabuf_len(b
);
1191 *buf
= wpabuf_head(b
);
1195 if (!sta
->radius_cui
) {
1200 radius_cui
= sta
->radius_cui
;
1201 len
= os_strlen(radius_cui
);
1202 *buf
= (u8
*) radius_cui
;
1208 static void hostapd_wpa_auth_set_session_timeout(void *ctx
, const u8
*sta_addr
,
1209 int session_timeout
)
1211 struct hostapd_data
*hapd
= ctx
;
1212 struct sta_info
*sta
;
1214 sta
= ap_get_sta(hapd
, sta_addr
);
1218 if (session_timeout
) {
1219 os_get_reltime(&sta
->session_timeout
);
1220 sta
->session_timeout
.sec
+= session_timeout
;
1221 sta
->session_timeout_set
= 1;
1222 ap_sta_session_timeout(hapd
, sta
, session_timeout
);
1224 sta
->session_timeout_set
= 0;
1225 ap_sta_no_session_timeout(hapd
, sta
);
1230 static int hostapd_wpa_auth_get_session_timeout(void *ctx
, const u8
*sta_addr
)
1232 struct hostapd_data
*hapd
= ctx
;
1233 struct sta_info
*sta
;
1234 struct os_reltime now
, remaining
;
1236 sta
= ap_get_sta(hapd
, sta_addr
);
1237 if (!sta
|| !sta
->session_timeout_set
)
1240 os_get_reltime(&now
);
1241 if (os_reltime_before(&sta
->session_timeout
, &now
)) {
1242 /* already expired, return >0 as timeout was set */
1246 os_reltime_sub(&sta
->session_timeout
, &now
, &remaining
);
1248 return (remaining
.sec
> 0) ? remaining
.sec
: 1;
1252 static void hostapd_rrb_receive(void *ctx
, const u8
*src_addr
, const u8
*buf
,
1255 struct hostapd_data
*hapd
= ctx
;
1256 struct l2_ethhdr
*ethhdr
;
1257 if (len
< sizeof(*ethhdr
))
1259 ethhdr
= (struct l2_ethhdr
*) buf
;
1260 wpa_printf(MSG_DEBUG
, "FT: RRB received packet " MACSTR
" -> "
1261 MACSTR
, MAC2STR(ethhdr
->h_source
), MAC2STR(ethhdr
->h_dest
));
1262 if (!is_multicast_ether_addr(ethhdr
->h_dest
) &&
1263 os_memcmp(hapd
->own_addr
, ethhdr
->h_dest
, ETH_ALEN
) != 0)
1265 wpa_ft_rrb_rx(hapd
->wpa_auth
, ethhdr
->h_source
, buf
+ sizeof(*ethhdr
),
1266 len
- sizeof(*ethhdr
));
1270 static void hostapd_rrb_oui_receive(void *ctx
, const u8
*src_addr
,
1271 const u8
*dst_addr
, u8 oui_suffix
,
1272 const u8
*buf
, size_t len
)
1274 struct hostapd_data
*hapd
= ctx
;
1276 wpa_printf(MSG_DEBUG
, "FT: RRB received packet " MACSTR
" -> "
1277 MACSTR
, MAC2STR(src_addr
), MAC2STR(dst_addr
));
1278 if (!is_multicast_ether_addr(dst_addr
) &&
1279 os_memcmp(hapd
->own_addr
, dst_addr
, ETH_ALEN
) != 0)
1281 wpa_ft_rrb_oui_rx(hapd
->wpa_auth
, src_addr
, dst_addr
, oui_suffix
, buf
,
1286 static int hostapd_wpa_auth_add_tspec(void *ctx
, const u8
*sta_addr
,
1287 u8
*tspec_ie
, size_t tspec_ielen
)
1289 struct hostapd_data
*hapd
= ctx
;
1290 return hostapd_add_tspec(hapd
, sta_addr
, tspec_ie
, tspec_ielen
);
1295 static int hostapd_wpa_register_ft_oui(struct hostapd_data
*hapd
,
1296 const char *ft_iface
)
1298 hapd
->oui_pull
= eth_p_oui_register(hapd
, ft_iface
,
1299 FT_PACKET_R0KH_R1KH_PULL
,
1300 hostapd_rrb_oui_receive
, hapd
);
1301 if (!hapd
->oui_pull
)
1304 hapd
->oui_resp
= eth_p_oui_register(hapd
, ft_iface
,
1305 FT_PACKET_R0KH_R1KH_RESP
,
1306 hostapd_rrb_oui_receive
, hapd
);
1307 if (!hapd
->oui_resp
)
1310 hapd
->oui_push
= eth_p_oui_register(hapd
, ft_iface
,
1311 FT_PACKET_R0KH_R1KH_PUSH
,
1312 hostapd_rrb_oui_receive
, hapd
);
1313 if (!hapd
->oui_push
)
1316 hapd
->oui_sreq
= eth_p_oui_register(hapd
, ft_iface
,
1317 FT_PACKET_R0KH_R1KH_SEQ_REQ
,
1318 hostapd_rrb_oui_receive
, hapd
);
1319 if (!hapd
->oui_sreq
)
1322 hapd
->oui_sresp
= eth_p_oui_register(hapd
, ft_iface
,
1323 FT_PACKET_R0KH_R1KH_SEQ_RESP
,
1324 hostapd_rrb_oui_receive
, hapd
);
1325 if (!hapd
->oui_sresp
)
1332 static void hostapd_wpa_unregister_ft_oui(struct hostapd_data
*hapd
)
1334 eth_p_oui_unregister(hapd
->oui_pull
);
1335 hapd
->oui_pull
= NULL
;
1336 eth_p_oui_unregister(hapd
->oui_resp
);
1337 hapd
->oui_resp
= NULL
;
1338 eth_p_oui_unregister(hapd
->oui_push
);
1339 hapd
->oui_push
= NULL
;
1340 eth_p_oui_unregister(hapd
->oui_sreq
);
1341 hapd
->oui_sreq
= NULL
;
1342 eth_p_oui_unregister(hapd
->oui_sresp
);
1343 hapd
->oui_sresp
= NULL
;
1345 #endif /* CONFIG_IEEE80211R_AP */
1348 int hostapd_setup_wpa(struct hostapd_data
*hapd
)
1350 struct wpa_auth_config _conf
;
1351 static const struct wpa_auth_callbacks cb
= {
1352 .logger
= hostapd_wpa_auth_logger
,
1353 .disconnect
= hostapd_wpa_auth_disconnect
,
1354 .mic_failure_report
= hostapd_wpa_auth_mic_failure_report
,
1355 .psk_failure_report
= hostapd_wpa_auth_psk_failure_report
,
1356 .set_eapol
= hostapd_wpa_auth_set_eapol
,
1357 .get_eapol
= hostapd_wpa_auth_get_eapol
,
1358 .get_psk
= hostapd_wpa_auth_get_psk
,
1359 .get_msk
= hostapd_wpa_auth_get_msk
,
1360 .set_key
= hostapd_wpa_auth_set_key
,
1361 .get_seqnum
= hostapd_wpa_auth_get_seqnum
,
1362 .send_eapol
= hostapd_wpa_auth_send_eapol
,
1363 .for_each_sta
= hostapd_wpa_auth_for_each_sta
,
1364 .for_each_auth
= hostapd_wpa_auth_for_each_auth
,
1365 .send_ether
= hostapd_wpa_auth_send_ether
,
1366 .send_oui
= hostapd_wpa_auth_send_oui
,
1367 .channel_info
= hostapd_channel_info
,
1368 .update_vlan
= hostapd_wpa_auth_update_vlan
,
1370 .get_sta_tx_params
= hostapd_get_sta_tx_params
,
1371 #endif /* CONFIG_OCV */
1372 #ifdef CONFIG_IEEE80211R_AP
1373 .send_ft_action
= hostapd_wpa_auth_send_ft_action
,
1374 .add_sta
= hostapd_wpa_auth_add_sta
,
1375 .add_tspec
= hostapd_wpa_auth_add_tspec
,
1376 .set_vlan
= hostapd_wpa_auth_set_vlan
,
1377 .get_vlan
= hostapd_wpa_auth_get_vlan
,
1378 .set_identity
= hostapd_wpa_auth_set_identity
,
1379 .get_identity
= hostapd_wpa_auth_get_identity
,
1380 .set_radius_cui
= hostapd_wpa_auth_set_radius_cui
,
1381 .get_radius_cui
= hostapd_wpa_auth_get_radius_cui
,
1382 .set_session_timeout
= hostapd_wpa_auth_set_session_timeout
,
1383 .get_session_timeout
= hostapd_wpa_auth_get_session_timeout
,
1384 #endif /* CONFIG_IEEE80211R_AP */
1389 hostapd_wpa_auth_conf(hapd
->conf
, hapd
->iconf
, &_conf
);
1390 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_EAPOL_TX_STATUS
)
1391 _conf
.tx_status
= 1;
1392 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_AP_MLME
)
1395 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_WIRED
) &&
1396 (hapd
->conf
->wpa_deny_ptk0_rekey
== PTK0_REKEY_ALLOW_NEVER
||
1397 (hapd
->conf
->wpa_deny_ptk0_rekey
== PTK0_REKEY_ALLOW_LOCAL_OK
&&
1398 !(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_SAFE_PTK0_REKEYS
)))) {
1399 wpa_msg(hapd
->msg_ctx
, MSG_INFO
,
1400 "Disable PTK0 rekey support - replaced with disconnect");
1401 _conf
.wpa_deny_ptk0_rekey
= 1;
1404 hapd
->wpa_auth
= wpa_init(hapd
->own_addr
, &_conf
, &cb
, hapd
);
1405 if (hapd
->wpa_auth
== NULL
) {
1406 wpa_printf(MSG_ERROR
, "WPA initialization failed.");
1410 if (hostapd_set_privacy(hapd
, 1)) {
1411 wpa_printf(MSG_ERROR
, "Could not set PrivacyInvoked "
1412 "for interface %s", hapd
->conf
->iface
);
1416 wpa_ie
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &wpa_ie_len
);
1417 if (hostapd_set_generic_elem(hapd
, wpa_ie
, wpa_ie_len
)) {
1418 wpa_printf(MSG_ERROR
, "Failed to configure WPA IE for "
1419 "the kernel driver.");
1423 if (rsn_preauth_iface_init(hapd
)) {
1424 wpa_printf(MSG_ERROR
, "Initialization of RSN "
1425 "pre-authentication failed.");
1429 #ifdef CONFIG_IEEE80211R_AP
1430 if (!hostapd_drv_none(hapd
) &&
1431 wpa_key_mgmt_ft(hapd
->conf
->wpa_key_mgmt
)) {
1432 const char *ft_iface
;
1434 ft_iface
= hapd
->conf
->bridge
[0] ? hapd
->conf
->bridge
:
1436 hapd
->l2
= l2_packet_init(ft_iface
, NULL
, ETH_P_RRB
,
1437 hostapd_rrb_receive
, hapd
, 1);
1439 wpa_printf(MSG_ERROR
, "Failed to open l2_packet "
1444 if (hostapd_wpa_register_ft_oui(hapd
, ft_iface
)) {
1445 wpa_printf(MSG_ERROR
,
1446 "Failed to open ETH_P_OUI interface");
1450 #endif /* CONFIG_IEEE80211R_AP */
1457 void hostapd_reconfig_wpa(struct hostapd_data
*hapd
)
1459 struct wpa_auth_config wpa_auth_conf
;
1460 hostapd_wpa_auth_conf(hapd
->conf
, hapd
->iconf
, &wpa_auth_conf
);
1461 wpa_reconfig(hapd
->wpa_auth
, &wpa_auth_conf
);
1465 void hostapd_deinit_wpa(struct hostapd_data
*hapd
)
1467 ieee80211_tkip_countermeasures_deinit(hapd
);
1468 rsn_preauth_iface_deinit(hapd
);
1469 if (hapd
->wpa_auth
) {
1470 wpa_deinit(hapd
->wpa_auth
);
1471 hapd
->wpa_auth
= NULL
;
1473 if (hapd
->drv_priv
&& hostapd_set_privacy(hapd
, 0)) {
1474 wpa_printf(MSG_DEBUG
, "Could not disable "
1475 "PrivacyInvoked for interface %s",
1479 if (hapd
->drv_priv
&&
1480 hostapd_set_generic_elem(hapd
, (u8
*) "", 0)) {
1481 wpa_printf(MSG_DEBUG
, "Could not remove generic "
1482 "information element from interface %s",
1486 ieee802_1x_deinit(hapd
);
1488 #ifdef CONFIG_IEEE80211R_AP
1489 eloop_cancel_timeout(hostapd_wpa_ft_rrb_rx_later
, hapd
, ELOOP_ALL_CTX
);
1490 hostapd_wpa_ft_rrb_rx_later(hapd
, NULL
); /* flush without delivering */
1491 eloop_cancel_timeout(hostapd_oui_deliver_later
, hapd
, ELOOP_ALL_CTX
);
1492 hostapd_oui_deliver_later(hapd
, NULL
); /* flush without delivering */
1493 l2_packet_deinit(hapd
->l2
);
1495 hostapd_wpa_unregister_ft_oui(hapd
);
1496 #endif /* CONFIG_IEEE80211R_AP */