2 * hostapd / Callback functions for driver wrappers
3 * Copyright (c) 2002-2013, 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 "radius/radius.h"
14 #include "drivers/driver.h"
15 #include "common/ieee802_11_defs.h"
16 #include "common/ieee802_11_common.h"
17 #include "common/wpa_ctrl.h"
18 #include "common/dpp.h"
19 #include "common/sae.h"
20 #include "common/hw_features_common.h"
21 #include "crypto/random.h"
27 #include "ieee802_11.h"
28 #include "ieee802_11_auth.h"
30 #include "accounting.h"
31 #include "tkip_countermeasures.h"
32 #include "ieee802_1x.h"
34 #include "wps_hostapd.h"
35 #include "ap_drv_ops.h"
36 #include "ap_config.h"
38 #include "hw_features.h"
42 #include "dpp_hostapd.h"
44 #include "neighbor_db.h"
48 void hostapd_notify_assoc_fils_finish(struct hostapd_data
*hapd
,
51 u16 reply_res
= WLAN_STATUS_SUCCESS
;
52 struct ieee802_11_elems elems
;
53 u8 buf
[IEEE80211_MAX_MMPDU_SIZE
], *p
= buf
;
56 wpa_printf(MSG_DEBUG
, "%s FILS: Finish association with " MACSTR
,
57 __func__
, MAC2STR(sta
->addr
));
58 eloop_cancel_timeout(fils_hlp_timeout
, hapd
, sta
);
59 if (!sta
->fils_pending_assoc_req
)
62 ieee802_11_parse_elems(sta
->fils_pending_assoc_req
,
63 sta
->fils_pending_assoc_req_len
, &elems
, 0);
64 if (!elems
.fils_session
) {
65 wpa_printf(MSG_DEBUG
, "%s failed to find FILS Session element",
70 p
= hostapd_eid_assoc_fils_session(sta
->wpa_sm
, p
,
74 reply_res
= hostapd_sta_assoc(hapd
, sta
->addr
,
75 sta
->fils_pending_assoc_is_reassoc
,
78 ap_sta_set_authorized(hapd
, sta
, 1);
79 new_assoc
= (sta
->flags
& WLAN_STA_ASSOC
) == 0;
80 sta
->flags
|= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
81 sta
->flags
&= ~WLAN_STA_WNM_SLEEP_MODE
;
82 hostapd_set_sta_flags(hapd
, sta
);
83 wpa_auth_sm_event(sta
->wpa_sm
, WPA_ASSOC_FILS
);
84 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, 1);
85 hostapd_new_assoc_sta(hapd
, sta
, !new_assoc
);
86 os_free(sta
->fils_pending_assoc_req
);
87 sta
->fils_pending_assoc_req
= NULL
;
88 sta
->fils_pending_assoc_req_len
= 0;
89 wpabuf_free(sta
->fils_hlp_resp
);
90 sta
->fils_hlp_resp
= NULL
;
91 wpabuf_free(sta
->hlp_dhcp_discover
);
92 sta
->hlp_dhcp_discover
= NULL
;
93 fils_hlp_deinit(hapd
);
96 * Remove the station in case transmission of a success response fails
97 * (the STA was added associated to the driver) or if the station was
98 * previously added unassociated.
100 if (reply_res
!= WLAN_STATUS_SUCCESS
|| sta
->added_unassoc
) {
101 hostapd_drv_sta_remove(hapd
, sta
->addr
);
102 sta
->added_unassoc
= 0;
105 #endif /* CONFIG_FILS */
108 int hostapd_notif_assoc(struct hostapd_data
*hapd
, const u8
*addr
,
109 const u8
*req_ies
, size_t req_ies_len
, int reassoc
)
111 struct sta_info
*sta
;
113 enum wpa_validate_result res
;
114 struct ieee802_11_elems elems
;
117 u8 buf
[sizeof(struct ieee80211_mgmt
) + 1024];
119 u16 reason
= WLAN_REASON_UNSPECIFIED
;
120 u16 status
= WLAN_STATUS_SUCCESS
;
121 const u8
*p2p_dev_addr
= NULL
;
125 * This could potentially happen with unexpected event from the
126 * driver wrapper. This was seen at least in one case where the
127 * driver ended up being set to station mode while hostapd was
128 * running, so better make sure we stop processing such an
131 wpa_printf(MSG_DEBUG
,
132 "hostapd_notif_assoc: Skip event with no address");
136 if (is_multicast_ether_addr(addr
) ||
137 is_zero_ether_addr(addr
) ||
138 os_memcmp(addr
, hapd
->own_addr
, ETH_ALEN
) == 0) {
139 /* Do not process any frames with unexpected/invalid SA so that
140 * we do not add any state for unexpected STA addresses or end
141 * up sending out frames to unexpected destination. */
142 wpa_printf(MSG_DEBUG
, "%s: Invalid SA=" MACSTR
143 " in received indication - ignore this indication silently",
144 __func__
, MAC2STR(addr
));
148 random_add_randomness(addr
, ETH_ALEN
);
150 hostapd_logger(hapd
, addr
, HOSTAPD_MODULE_IEEE80211
,
151 HOSTAPD_LEVEL_INFO
, "associated");
153 ieee802_11_parse_elems(req_ies
, req_ies_len
, &elems
, 0);
155 ie
= elems
.wps_ie
- 2;
156 ielen
= elems
.wps_ie_len
+ 2;
157 wpa_printf(MSG_DEBUG
, "STA included WPS IE in (Re)AssocReq");
158 } else if (elems
.rsn_ie
) {
159 ie
= elems
.rsn_ie
- 2;
160 ielen
= elems
.rsn_ie_len
+ 2;
161 wpa_printf(MSG_DEBUG
, "STA included RSN IE in (Re)AssocReq");
162 } else if (elems
.wpa_ie
) {
163 ie
= elems
.wpa_ie
- 2;
164 ielen
= elems
.wpa_ie_len
+ 2;
165 wpa_printf(MSG_DEBUG
, "STA included WPA IE in (Re)AssocReq");
167 } else if (elems
.osen
) {
169 ielen
= elems
.osen_len
+ 2;
170 wpa_printf(MSG_DEBUG
, "STA included OSEN IE in (Re)AssocReq");
171 #endif /* CONFIG_HS20 */
175 wpa_printf(MSG_DEBUG
,
176 "STA did not include WPS/RSN/WPA IE in (Re)AssocReq");
179 sta
= ap_get_sta(hapd
, addr
);
181 ap_sta_no_session_timeout(hapd
, sta
);
182 accounting_sta_stop(hapd
, sta
);
185 * Make sure that the previously registered inactivity timer
186 * will not remove the STA immediately.
188 sta
->timeout_next
= STA_NULLFUNC
;
190 sta
= ap_sta_add(hapd
, addr
);
192 hostapd_drv_sta_disassoc(hapd
, addr
,
193 WLAN_REASON_DISASSOC_AP_BUSY
);
197 sta
->flags
&= ~(WLAN_STA_WPS
| WLAN_STA_MAYBE_WPS
| WLAN_STA_WPS2
);
200 * ACL configurations to the drivers (implementing AP SME and ACL
201 * offload) without hostapd's knowledge, can result in a disconnection
202 * though the driver accepts the connection. Skip the hostapd check for
203 * ACL if the driver supports ACL offload to avoid potentially
204 * conflicting ACL rules.
206 if (hapd
->iface
->drv_max_acl_mac_addrs
== 0 &&
207 hostapd_check_acl(hapd
, addr
, NULL
) != HOSTAPD_ACL_ACCEPT
) {
208 wpa_printf(MSG_INFO
, "STA " MACSTR
" not allowed to connect",
210 reason
= WLAN_REASON_UNSPECIFIED
;
216 wpabuf_free(sta
->p2p_ie
);
217 sta
->p2p_ie
= ieee802_11_vendor_ie_concat(req_ies
, req_ies_len
,
220 p2p_dev_addr
= p2p_get_go_dev_addr(sta
->p2p_ie
);
222 #endif /* CONFIG_P2P */
225 if (elems
.ht_capabilities
&&
226 (hapd
->iface
->conf
->ht_capab
&
227 HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
)) {
228 struct ieee80211_ht_capabilities
*ht_cap
=
229 (struct ieee80211_ht_capabilities
*)
230 elems
.ht_capabilities
;
232 if (le_to_host16(ht_cap
->ht_capabilities_info
) &
233 HT_CAP_INFO_40MHZ_INTOLERANT
)
234 ht40_intolerant_add(hapd
->iface
, sta
);
236 #endif /* NEED_AP_MLME */
238 #ifdef CONFIG_INTERWORKING
239 if (elems
.ext_capab
&& elems
.ext_capab_len
> 4) {
240 if (elems
.ext_capab
[4] & 0x01)
241 sta
->qos_map_enabled
= 1;
243 #endif /* CONFIG_INTERWORKING */
246 wpabuf_free(sta
->hs20_ie
);
247 if (elems
.hs20
&& elems
.hs20_len
> 4) {
248 sta
->hs20_ie
= wpabuf_alloc_copy(elems
.hs20
+ 4,
253 wpabuf_free(sta
->roaming_consortium
);
254 if (elems
.roaming_cons_sel
)
255 sta
->roaming_consortium
= wpabuf_alloc_copy(
256 elems
.roaming_cons_sel
+ 4,
257 elems
.roaming_cons_sel_len
- 4);
259 sta
->roaming_consortium
= NULL
;
260 #endif /* CONFIG_HS20 */
263 wpabuf_free(sta
->mb_ies
);
264 if (hapd
->iface
->fst
)
265 sta
->mb_ies
= mb_ies_by_info(&elems
.mb_ies
);
268 #endif /* CONFIG_FST */
270 mbo_ap_check_sta_assoc(hapd
, sta
, &elems
);
272 ap_copy_sta_supp_op_classes(sta
, elems
.supp_op_classes
,
273 elems
.supp_op_classes_len
);
275 if (hapd
->conf
->wpa
) {
276 if (ie
== NULL
|| ielen
== 0) {
278 if (hapd
->conf
->wps_state
) {
279 wpa_printf(MSG_DEBUG
,
280 "STA did not include WPA/RSN IE in (Re)Association Request - possible WPS use");
281 sta
->flags
|= WLAN_STA_MAYBE_WPS
;
284 #endif /* CONFIG_WPS */
286 wpa_printf(MSG_DEBUG
, "No WPA/RSN IE from STA");
287 reason
= WLAN_REASON_INVALID_IE
;
288 status
= WLAN_STATUS_INVALID_IE
;
292 if (hapd
->conf
->wps_state
&& ie
[0] == 0xdd && ie
[1] >= 4 &&
293 os_memcmp(ie
+ 2, "\x00\x50\xf2\x04", 4) == 0) {
296 sta
->flags
|= WLAN_STA_WPS
;
297 wps
= ieee802_11_vendor_ie_concat(ie
, ielen
,
300 if (wps_is_20(wps
)) {
301 wpa_printf(MSG_DEBUG
,
302 "WPS: STA supports WPS 2.0");
303 sta
->flags
|= WLAN_STA_WPS2
;
309 #endif /* CONFIG_WPS */
311 if (sta
->wpa_sm
== NULL
)
312 sta
->wpa_sm
= wpa_auth_sta_init(hapd
->wpa_auth
,
315 if (sta
->wpa_sm
== NULL
) {
316 wpa_printf(MSG_ERROR
,
317 "Failed to initialize WPA state machine");
320 res
= wpa_validate_wpa_ie(hapd
->wpa_auth
, sta
->wpa_sm
,
323 elems
.rsnxe
? elems
.rsnxe
- 2 : NULL
,
324 elems
.rsnxe
? elems
.rsnxe_len
+ 2 : 0,
325 elems
.mdie
, elems
.mdie_len
,
326 elems
.owe_dh
, elems
.owe_dh_len
);
327 reason
= WLAN_REASON_INVALID_IE
;
328 status
= WLAN_STATUS_INVALID_IE
;
331 reason
= WLAN_REASON_UNSPECIFIED
;
332 status
= WLAN_STATUS_SUCCESS
;
335 reason
= WLAN_REASON_INVALID_IE
;
336 status
= WLAN_STATUS_INVALID_IE
;
338 case WPA_INVALID_GROUP
:
339 reason
= WLAN_REASON_GROUP_CIPHER_NOT_VALID
;
340 status
= WLAN_STATUS_GROUP_CIPHER_NOT_VALID
;
342 case WPA_INVALID_PAIRWISE
:
343 reason
= WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID
;
344 status
= WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID
;
346 case WPA_INVALID_AKMP
:
347 reason
= WLAN_REASON_AKMP_NOT_VALID
;
348 status
= WLAN_STATUS_AKMP_NOT_VALID
;
350 case WPA_NOT_ENABLED
:
351 reason
= WLAN_REASON_INVALID_IE
;
352 status
= WLAN_STATUS_INVALID_IE
;
355 reason
= WLAN_REASON_UNSPECIFIED
;
356 status
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
358 case WPA_MGMT_FRAME_PROTECTION_VIOLATION
:
359 reason
= WLAN_REASON_INVALID_IE
;
360 status
= WLAN_STATUS_INVALID_IE
;
362 case WPA_INVALID_MGMT_GROUP_CIPHER
:
363 reason
= WLAN_REASON_CIPHER_SUITE_REJECTED
;
364 status
= WLAN_STATUS_CIPHER_REJECTED_PER_POLICY
;
366 case WPA_INVALID_MDIE
:
367 reason
= WLAN_REASON_INVALID_MDE
;
368 status
= WLAN_STATUS_INVALID_MDIE
;
370 case WPA_INVALID_PROTO
:
371 reason
= WLAN_REASON_INVALID_IE
;
372 status
= WLAN_STATUS_INVALID_IE
;
374 case WPA_INVALID_PMKID
:
375 reason
= WLAN_REASON_INVALID_PMKID
;
376 status
= WLAN_STATUS_INVALID_PMKID
;
378 case WPA_DENIED_OTHER_REASON
:
379 reason
= WLAN_REASON_UNSPECIFIED
;
380 status
= WLAN_STATUS_ASSOC_DENIED_UNSPEC
;
383 if (status
!= WLAN_STATUS_SUCCESS
) {
384 wpa_printf(MSG_DEBUG
,
385 "WPA/RSN information element rejected? (res %u)",
387 wpa_hexdump(MSG_DEBUG
, "IE", ie
, ielen
);
391 if ((sta
->flags
& (WLAN_STA_ASSOC
| WLAN_STA_MFP
)) ==
392 (WLAN_STA_ASSOC
| WLAN_STA_MFP
) &&
393 !sta
->sa_query_timed_out
&&
394 sta
->sa_query_count
> 0)
395 ap_check_sa_query_timeout(hapd
, sta
);
396 if ((sta
->flags
& (WLAN_STA_ASSOC
| WLAN_STA_MFP
)) ==
397 (WLAN_STA_ASSOC
| WLAN_STA_MFP
) &&
398 !sta
->sa_query_timed_out
&&
399 (sta
->auth_alg
!= WLAN_AUTH_FT
)) {
401 * STA has already been associated with MFP and SA
402 * Query timeout has not been reached. Reject the
403 * association attempt temporarily and start SA Query,
404 * if one is not pending.
407 if (sta
->sa_query_count
== 0)
408 ap_sta_start_sa_query(hapd
, sta
);
410 status
= WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY
;
412 p
= hostapd_eid_assoc_comeback_time(hapd
, sta
, p
);
414 hostapd_sta_assoc(hapd
, addr
, reassoc
, status
, buf
,
419 if (wpa_auth_uses_mfp(sta
->wpa_sm
))
420 sta
->flags
|= WLAN_STA_MFP
;
422 sta
->flags
&= ~WLAN_STA_MFP
;
424 #ifdef CONFIG_IEEE80211R_AP
425 if (sta
->auth_alg
== WLAN_AUTH_FT
) {
426 status
= wpa_ft_validate_reassoc(sta
->wpa_sm
, req_ies
,
428 if (status
!= WLAN_STATUS_SUCCESS
) {
429 if (status
== WLAN_STATUS_INVALID_PMKID
)
430 reason
= WLAN_REASON_INVALID_IE
;
431 if (status
== WLAN_STATUS_INVALID_MDIE
)
432 reason
= WLAN_REASON_INVALID_IE
;
433 if (status
== WLAN_STATUS_INVALID_FTIE
)
434 reason
= WLAN_REASON_INVALID_IE
;
438 #endif /* CONFIG_IEEE80211R_AP */
440 if (hapd
->conf
->sae_pwe
== 2 &&
441 sta
->auth_alg
== WLAN_AUTH_SAE
&&
442 sta
->sae
&& sta
->sae
->tmp
&& !sta
->sae
->tmp
->h2e
&&
443 elems
.rsnxe
&& elems
.rsnxe_len
>= 1 &&
444 (elems
.rsnxe
[0] & BIT(WLAN_RSNX_CAPAB_SAE_H2E
))) {
445 wpa_printf(MSG_INFO
, "SAE: " MACSTR
446 " indicates support for SAE H2E, but did not use it",
448 status
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
449 reason
= WLAN_REASON_UNSPECIFIED
;
452 #endif /* CONFIG_SAE */
453 } else if (hapd
->conf
->wps_state
) {
458 wps
= ieee802_11_vendor_ie_concat(req_ies
, req_ies_len
,
462 #ifdef CONFIG_WPS_STRICT
463 if (wps
&& wps_validate_assoc_req(wps
) < 0) {
464 reason
= WLAN_REASON_INVALID_IE
;
465 status
= WLAN_STATUS_INVALID_IE
;
469 #endif /* CONFIG_WPS_STRICT */
471 sta
->flags
|= WLAN_STA_WPS
;
472 if (wps_is_20(wps
)) {
473 wpa_printf(MSG_DEBUG
,
474 "WPS: STA supports WPS 2.0");
475 sta
->flags
|= WLAN_STA_WPS2
;
478 sta
->flags
|= WLAN_STA_MAYBE_WPS
;
480 #endif /* CONFIG_WPS */
482 } else if (hapd
->conf
->osen
) {
483 if (elems
.osen
== NULL
) {
485 hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
487 "No HS 2.0 OSEN element in association request");
488 return WLAN_STATUS_INVALID_IE
;
491 wpa_printf(MSG_DEBUG
, "HS 2.0: OSEN association");
492 if (sta
->wpa_sm
== NULL
)
493 sta
->wpa_sm
= wpa_auth_sta_init(hapd
->wpa_auth
,
495 if (sta
->wpa_sm
== NULL
) {
496 wpa_printf(MSG_WARNING
,
497 "Failed to initialize WPA state machine");
498 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
500 if (wpa_validate_osen(hapd
->wpa_auth
, sta
->wpa_sm
,
501 elems
.osen
- 2, elems
.osen_len
+ 2) < 0)
502 return WLAN_STATUS_INVALID_IE
;
503 #endif /* CONFIG_HS20 */
507 #endif /* CONFIG_WPS */
510 if (hapd
->conf
->mbo_enabled
&& (hapd
->conf
->wpa
& 2) &&
511 elems
.mbo
&& sta
->cell_capa
&& !(sta
->flags
& WLAN_STA_MFP
) &&
512 hapd
->conf
->ieee80211w
!= NO_MGMT_FRAME_PROTECTION
) {
514 "MBO: Reject WPA2 association without PMF");
515 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
517 #endif /* CONFIG_MBO */
519 #ifdef CONFIG_IEEE80211R_AP
520 p
= wpa_sm_write_assoc_resp_ies(sta
->wpa_sm
, buf
, sizeof(buf
),
521 sta
->auth_alg
, req_ies
, req_ies_len
,
524 wpa_printf(MSG_DEBUG
, "FT: Failed to write AssocResp IEs");
525 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
527 #endif /* CONFIG_IEEE80211R_AP */
530 if (sta
->auth_alg
== WLAN_AUTH_FILS_SK
||
531 sta
->auth_alg
== WLAN_AUTH_FILS_SK_PFS
||
532 sta
->auth_alg
== WLAN_AUTH_FILS_PK
) {
536 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
538 if (!wpa_fils_validate_fils_session(sta
->wpa_sm
, req_ies
,
540 sta
->fils_session
)) {
541 wpa_printf(MSG_DEBUG
,
542 "FILS: Session validation failed");
543 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
546 res
= wpa_fils_validate_key_confirm(sta
->wpa_sm
, req_ies
,
549 wpa_printf(MSG_DEBUG
,
550 "FILS: Key Confirm validation failed");
551 return WLAN_STATUS_UNSPECIFIED_FAILURE
;
554 if (fils_process_hlp(hapd
, sta
, req_ies
, req_ies_len
) > 0) {
555 wpa_printf(MSG_DEBUG
,
556 "FILS: Delaying Assoc Response (HLP)");
559 wpa_printf(MSG_DEBUG
,
560 "FILS: Going ahead with Assoc Response (no HLP)");
564 wpa_printf(MSG_DEBUG
, "FILS: HLP callback cleanup");
565 eloop_cancel_timeout(fils_hlp_timeout
, hapd
, sta
);
566 os_free(sta
->fils_pending_assoc_req
);
567 sta
->fils_pending_assoc_req
= NULL
;
568 sta
->fils_pending_assoc_req_len
= 0;
569 wpabuf_free(sta
->fils_hlp_resp
);
570 sta
->fils_hlp_resp
= NULL
;
571 sta
->fils_drv_assoc_finish
= 0;
574 if (sta
&& delay_assoc
&& status
== WLAN_STATUS_SUCCESS
) {
577 req_tmp
= os_malloc(req_ies_len
);
579 wpa_printf(MSG_DEBUG
,
580 "FILS: buffer allocation failed for assoc req");
583 os_memcpy(req_tmp
, req_ies
, req_ies_len
);
584 sta
->fils_pending_assoc_req
= req_tmp
;
585 sta
->fils_pending_assoc_req_len
= req_ies_len
;
586 sta
->fils_pending_assoc_is_reassoc
= reassoc
;
587 sta
->fils_drv_assoc_finish
= 1;
588 wpa_printf(MSG_DEBUG
,
589 "FILS: Waiting for HLP processing before sending (Re)Association Response frame to "
590 MACSTR
, MAC2STR(sta
->addr
));
591 eloop_register_timeout(
592 0, hapd
->conf
->fils_hlp_wait_time
* 1024,
593 fils_hlp_timeout
, hapd
, sta
);
596 p
= hostapd_eid_assoc_fils_session(sta
->wpa_sm
, p
,
599 wpa_hexdump(MSG_DEBUG
, "FILS Assoc Resp BUF (IEs)",
602 #endif /* CONFIG_FILS */
605 if ((hapd
->conf
->wpa_key_mgmt
& WPA_KEY_MGMT_OWE
) &&
606 wpa_auth_sta_key_mgmt(sta
->wpa_sm
) == WPA_KEY_MGMT_OWE
&&
610 npos
= owe_assoc_req_process(hapd
, sta
,
611 elems
.owe_dh
, elems
.owe_dh_len
,
612 p
, sizeof(buf
) - (p
- buf
),
618 status
== WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED
) {
619 hostapd_sta_assoc(hapd
, addr
, reassoc
, status
, buf
,
624 if (!npos
|| status
!= WLAN_STATUS_SUCCESS
)
627 #endif /* CONFIG_OWE */
630 dpp_pfs_free(sta
->dpp_pfs
);
633 if ((hapd
->conf
->wpa_key_mgmt
& WPA_KEY_MGMT_DPP
) &&
634 hapd
->conf
->dpp_netaccesskey
&& sta
->wpa_sm
&&
635 wpa_auth_sta_key_mgmt(sta
->wpa_sm
) == WPA_KEY_MGMT_DPP
&&
637 sta
->dpp_pfs
= dpp_pfs_init(
638 wpabuf_head(hapd
->conf
->dpp_netaccesskey
),
639 wpabuf_len(hapd
->conf
->dpp_netaccesskey
));
641 wpa_printf(MSG_DEBUG
,
642 "DPP: Could not initialize PFS");
643 /* Try to continue without PFS */
647 if (dpp_pfs_process(sta
->dpp_pfs
, elems
.owe_dh
,
648 elems
.owe_dh_len
) < 0) {
649 dpp_pfs_free(sta
->dpp_pfs
);
651 reason
= WLAN_REASON_UNSPECIFIED
;
656 wpa_auth_set_dpp_z(sta
->wpa_sm
, sta
->dpp_pfs
?
657 sta
->dpp_pfs
->secret
: NULL
);
659 #endif /* CONFIG_DPP2 */
661 if (elems
.rrm_enabled
&&
662 elems
.rrm_enabled_len
>= sizeof(sta
->rrm_enabled_capa
))
663 os_memcpy(sta
->rrm_enabled_capa
, elems
.rrm_enabled
,
664 sizeof(sta
->rrm_enabled_capa
));
666 #if defined(CONFIG_IEEE80211R_AP) || defined(CONFIG_FILS) || defined(CONFIG_OWE)
667 hostapd_sta_assoc(hapd
, addr
, reassoc
, status
, buf
, p
- buf
);
669 if (sta
->auth_alg
== WLAN_AUTH_FT
||
670 sta
->auth_alg
== WLAN_AUTH_FILS_SK
||
671 sta
->auth_alg
== WLAN_AUTH_FILS_SK_PFS
||
672 sta
->auth_alg
== WLAN_AUTH_FILS_PK
)
673 ap_sta_set_authorized(hapd
, sta
, 1);
674 #else /* CONFIG_IEEE80211R_AP || CONFIG_FILS */
675 /* Keep compiler silent about unused variables */
678 #endif /* CONFIG_IEEE80211R_AP || CONFIG_FILS */
680 new_assoc
= (sta
->flags
& WLAN_STA_ASSOC
) == 0;
681 sta
->flags
|= WLAN_STA_AUTH
| WLAN_STA_ASSOC
;
682 sta
->flags
&= ~WLAN_STA_WNM_SLEEP_MODE
;
684 hostapd_set_sta_flags(hapd
, sta
);
686 if (reassoc
&& (sta
->auth_alg
== WLAN_AUTH_FT
))
687 wpa_auth_sm_event(sta
->wpa_sm
, WPA_ASSOC_FT
);
689 else if (sta
->auth_alg
== WLAN_AUTH_FILS_SK
||
690 sta
->auth_alg
== WLAN_AUTH_FILS_SK_PFS
||
691 sta
->auth_alg
== WLAN_AUTH_FILS_PK
)
692 wpa_auth_sm_event(sta
->wpa_sm
, WPA_ASSOC_FILS
);
693 #endif /* CONFIG_FILS */
695 wpa_auth_sm_event(sta
->wpa_sm
, WPA_ASSOC
);
697 hostapd_new_assoc_sta(hapd
, sta
, !new_assoc
);
699 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, 1);
703 p2p_group_notif_assoc(hapd
->p2p_group
, sta
->addr
,
704 req_ies
, req_ies_len
);
706 #endif /* CONFIG_P2P */
711 #ifdef CONFIG_IEEE80211R_AP
712 hostapd_sta_assoc(hapd
, addr
, reassoc
, status
, buf
, p
- buf
);
713 #endif /* CONFIG_IEEE80211R_AP */
714 hostapd_drv_sta_disassoc(hapd
, sta
->addr
, reason
);
715 ap_free_sta(hapd
, sta
);
720 void hostapd_notif_disassoc(struct hostapd_data
*hapd
, const u8
*addr
)
722 struct sta_info
*sta
;
726 * This could potentially happen with unexpected event from the
727 * driver wrapper. This was seen at least in one case where the
728 * driver ended up reporting a station mode event while hostapd
729 * was running, so better make sure we stop processing such an
732 wpa_printf(MSG_DEBUG
,
733 "hostapd_notif_disassoc: Skip event with no address");
737 hostapd_logger(hapd
, addr
, HOSTAPD_MODULE_IEEE80211
,
738 HOSTAPD_LEVEL_INFO
, "disassociated");
740 sta
= ap_get_sta(hapd
, addr
);
742 wpa_printf(MSG_DEBUG
,
743 "Disassociation notification for unknown STA "
744 MACSTR
, MAC2STR(addr
));
748 ap_sta_set_authorized(hapd
, sta
, 0);
749 sta
->flags
&= ~(WLAN_STA_AUTH
| WLAN_STA_ASSOC
);
750 hostapd_set_sta_flags(hapd
, sta
);
751 wpa_auth_sm_event(sta
->wpa_sm
, WPA_DISASSOC
);
752 sta
->acct_terminate_cause
= RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST
;
753 ieee802_1x_notify_port_enabled(sta
->eapol_sm
, 0);
754 ap_free_sta(hapd
, sta
);
758 void hostapd_event_sta_low_ack(struct hostapd_data
*hapd
, const u8
*addr
)
760 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
762 if (!sta
|| !hapd
->conf
->disassoc_low_ack
|| sta
->agreed_to_steer
)
765 hostapd_logger(hapd
, addr
, HOSTAPD_MODULE_IEEE80211
,
767 "disconnected due to excessive missing ACKs");
768 hostapd_drv_sta_disassoc(hapd
, addr
, WLAN_REASON_DISASSOC_LOW_ACK
);
769 ap_sta_disassociate(hapd
, sta
, WLAN_REASON_DISASSOC_LOW_ACK
);
773 void hostapd_event_sta_opmode_changed(struct hostapd_data
*hapd
, const u8
*addr
,
774 enum smps_mode smps_mode
,
775 enum chan_width chan_width
, u8 rx_nss
)
777 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
801 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, STA_OPMODE_SMPS_MODE_CHANGED
802 MACSTR
" %s", MAC2STR(addr
), txt
);
805 switch (chan_width
) {
806 case CHAN_WIDTH_20_NOHT
:
818 case CHAN_WIDTH_80P80
:
829 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, STA_OPMODE_MAX_BW_CHANGED
830 MACSTR
" %s", MAC2STR(addr
), txt
);
833 if (rx_nss
!= 0xff) {
834 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, STA_OPMODE_N_SS_CHANGED
835 MACSTR
" %d", MAC2STR(addr
), rx_nss
);
840 void hostapd_event_ch_switch(struct hostapd_data
*hapd
, int freq
, int ht
,
841 int offset
, int width
, int cf1
, int cf2
,
844 /* TODO: If OCV is enabled deauth STAs that don't perform a SA Query */
847 int channel
, chwidth
, is_dfs
;
848 u8 seg0_idx
= 0, seg1_idx
= 0;
851 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE80211
,
853 "driver %s channel switch: freq=%d, ht=%d, vht_ch=0x%x, offset=%d, width=%d (%s), cf1=%d, cf2=%d",
854 finished
? "had" : "starting",
855 freq
, ht
, hapd
->iconf
->ch_switch_vht_config
, offset
,
856 width
, channel_width_to_string(width
), cf1
, cf2
);
858 if (!hapd
->iface
->current_mode
) {
859 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE80211
,
860 HOSTAPD_LEVEL_WARNING
,
861 "ignore channel switch since the interface is not yet ready");
865 hapd
->iface
->freq
= freq
;
867 channel
= hostapd_hw_get_channel(hapd
, freq
);
869 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE80211
,
870 HOSTAPD_LEVEL_WARNING
,
871 "driver switched to bad channel!");
877 chwidth
= CHANWIDTH_80MHZ
;
879 case CHAN_WIDTH_80P80
:
880 chwidth
= CHANWIDTH_80P80MHZ
;
883 chwidth
= CHANWIDTH_160MHZ
;
885 case CHAN_WIDTH_20_NOHT
:
889 chwidth
= CHANWIDTH_USE_HT
;
893 switch (hapd
->iface
->current_mode
->mode
) {
894 case HOSTAPD_MODE_IEEE80211A
:
896 seg0_idx
= (cf1
- 5000) / 5;
898 seg1_idx
= (cf2
- 5000) / 5;
901 ieee80211_freq_to_chan(cf1
, &seg0_idx
);
902 ieee80211_freq_to_chan(cf2
, &seg1_idx
);
906 hapd
->iconf
->channel
= channel
;
907 hapd
->iconf
->ieee80211n
= ht
;
909 hapd
->iconf
->ieee80211ac
= 0;
910 } else if (hapd
->iconf
->ch_switch_vht_config
) {
911 /* CHAN_SWITCH VHT config */
912 if (hapd
->iconf
->ch_switch_vht_config
&
913 CH_SWITCH_VHT_ENABLED
)
914 hapd
->iconf
->ieee80211ac
= 1;
915 else if (hapd
->iconf
->ch_switch_vht_config
&
916 CH_SWITCH_VHT_DISABLED
)
917 hapd
->iconf
->ieee80211ac
= 0;
919 hapd
->iconf
->ch_switch_vht_config
= 0;
921 hapd
->iconf
->secondary_channel
= offset
;
922 hostapd_set_oper_chwidth(hapd
->iconf
, chwidth
);
923 hostapd_set_oper_centr_freq_seg0_idx(hapd
->iconf
, seg0_idx
);
924 hostapd_set_oper_centr_freq_seg1_idx(hapd
->iconf
, seg1_idx
);
926 is_dfs
= ieee80211_is_dfs(freq
, hapd
->iface
->hw_features
,
927 hapd
->iface
->num_hw_features
);
929 wpa_msg(hapd
->msg_ctx
, MSG_INFO
,
930 "%sfreq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d dfs=%d",
931 finished
? WPA_EVENT_CHANNEL_SWITCH
:
932 WPA_EVENT_CHANNEL_SWITCH_STARTED
,
933 freq
, ht
, offset
, channel_width_to_string(width
),
938 if (hapd
->csa_in_progress
&&
939 freq
== hapd
->cs_freq_params
.freq
) {
940 hostapd_cleanup_cs_params(hapd
);
941 ieee802_11_set_beacon(hapd
);
943 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, AP_CSA_FINISHED
944 "freq=%d dfs=%d", freq
, is_dfs
);
945 } else if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_DFS_OFFLOAD
) {
946 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, AP_CSA_FINISHED
947 "freq=%d dfs=%d", freq
, is_dfs
);
949 hostapd_is_dfs_required(hapd
->iface
) &&
950 !hostapd_is_dfs_chan_available(hapd
->iface
) &&
951 !hapd
->iface
->cac_started
) {
952 hostapd_disable_iface(hapd
->iface
);
953 hostapd_enable_iface(hapd
->iface
);
956 for (i
= 0; i
< hapd
->iface
->num_bss
; i
++)
957 hostapd_neighbor_set_own_report(hapd
->iface
->bss
[i
]);
958 #endif /* NEED_AP_MLME */
962 void hostapd_event_connect_failed_reason(struct hostapd_data
*hapd
,
963 const u8
*addr
, int reason_code
)
965 switch (reason_code
) {
966 case MAX_CLIENT_REACHED
:
967 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, AP_REJECTED_MAX_STA MACSTR
,
971 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, AP_REJECTED_BLOCKED_STA MACSTR
,
979 void hostapd_acs_channel_selected(struct hostapd_data
*hapd
,
980 struct acs_selected_channels
*acs_res
)
984 struct hostapd_channel_data
*pri_chan
;
986 if (hapd
->iconf
->channel
) {
987 wpa_printf(MSG_INFO
, "ACS: Channel was already set to %d",
988 hapd
->iconf
->channel
);
992 hapd
->iface
->freq
= acs_res
->pri_freq
;
994 if (!hapd
->iface
->current_mode
) {
995 for (i
= 0; i
< hapd
->iface
->num_hw_features
; i
++) {
996 struct hostapd_hw_modes
*mode
=
997 &hapd
->iface
->hw_features
[i
];
999 if (mode
->mode
== acs_res
->hw_mode
) {
1000 if (hapd
->iface
->freq
> 0 &&
1001 !hw_get_chan(mode
->mode
,
1003 hapd
->iface
->hw_features
,
1004 hapd
->iface
->num_hw_features
))
1006 hapd
->iface
->current_mode
= mode
;
1010 if (!hapd
->iface
->current_mode
) {
1011 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE80211
,
1012 HOSTAPD_LEVEL_WARNING
,
1013 "driver selected to bad hw_mode");
1019 if (!acs_res
->pri_freq
) {
1020 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE80211
,
1021 HOSTAPD_LEVEL_WARNING
,
1022 "driver switched to bad channel");
1026 pri_chan
= hw_get_channel_freq(hapd
->iface
->current_mode
->mode
,
1027 acs_res
->pri_freq
, NULL
,
1028 hapd
->iface
->hw_features
,
1029 hapd
->iface
->num_hw_features
);
1031 wpa_printf(MSG_ERROR
,
1032 "ACS: Could not determine primary channel number from pri_freq %u",
1038 hapd
->iconf
->channel
= pri_chan
->chan
;
1039 hapd
->iconf
->acs
= 1;
1041 if (acs_res
->sec_freq
== 0)
1042 hapd
->iconf
->secondary_channel
= 0;
1043 else if (acs_res
->sec_freq
< acs_res
->pri_freq
)
1044 hapd
->iconf
->secondary_channel
= -1;
1045 else if (acs_res
->sec_freq
> acs_res
->pri_freq
)
1046 hapd
->iconf
->secondary_channel
= 1;
1048 wpa_printf(MSG_ERROR
, "Invalid secondary channel!");
1053 hapd
->iconf
->edmg_channel
= acs_res
->edmg_channel
;
1055 if (hapd
->iface
->conf
->ieee80211ac
|| hapd
->iface
->conf
->ieee80211ax
) {
1056 /* set defaults for backwards compatibility */
1057 hostapd_set_oper_centr_freq_seg1_idx(hapd
->iconf
, 0);
1058 hostapd_set_oper_centr_freq_seg0_idx(hapd
->iconf
, 0);
1059 hostapd_set_oper_chwidth(hapd
->iconf
, CHANWIDTH_USE_HT
);
1060 if (acs_res
->ch_width
== 40) {
1061 if (is_6ghz_freq(acs_res
->pri_freq
))
1062 hostapd_set_oper_centr_freq_seg0_idx(
1064 acs_res
->vht_seg0_center_ch
);
1065 } else if (acs_res
->ch_width
== 80) {
1066 hostapd_set_oper_centr_freq_seg0_idx(
1067 hapd
->iconf
, acs_res
->vht_seg0_center_ch
);
1068 if (acs_res
->vht_seg1_center_ch
== 0) {
1069 hostapd_set_oper_chwidth(hapd
->iconf
,
1072 hostapd_set_oper_chwidth(hapd
->iconf
,
1073 CHANWIDTH_80P80MHZ
);
1074 hostapd_set_oper_centr_freq_seg1_idx(
1076 acs_res
->vht_seg1_center_ch
);
1078 } else if (acs_res
->ch_width
== 160) {
1079 hostapd_set_oper_chwidth(hapd
->iconf
, CHANWIDTH_160MHZ
);
1080 hostapd_set_oper_centr_freq_seg0_idx(
1081 hapd
->iconf
, acs_res
->vht_seg1_center_ch
);
1086 ret
= hostapd_acs_completed(hapd
->iface
, err
);
1088 wpa_printf(MSG_ERROR
,
1089 "ACS: Possibly channel configuration is invalid");
1092 #endif /* CONFIG_ACS */
1095 int hostapd_probe_req_rx(struct hostapd_data
*hapd
, const u8
*sa
, const u8
*da
,
1096 const u8
*bssid
, const u8
*ie
, size_t ie_len
,
1102 if (sa
== NULL
|| ie
== NULL
)
1105 random_add_randomness(sa
, ETH_ALEN
);
1106 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++) {
1107 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
1108 sa
, da
, bssid
, ie
, ie_len
,
1120 #ifdef CONFIG_IEEE80211R_AP
1121 static void hostapd_notify_auth_ft_finish(void *ctx
, const u8
*dst
,
1123 u16 auth_transaction
, u16 status
,
1124 const u8
*ies
, size_t ies_len
)
1126 struct hostapd_data
*hapd
= ctx
;
1127 struct sta_info
*sta
;
1129 sta
= ap_get_sta(hapd
, dst
);
1133 hostapd_logger(hapd
, dst
, HOSTAPD_MODULE_IEEE80211
,
1134 HOSTAPD_LEVEL_DEBUG
, "authentication OK (FT)");
1135 sta
->flags
|= WLAN_STA_AUTH
;
1137 hostapd_sta_auth(hapd
, dst
, auth_transaction
, status
, ies
, ies_len
);
1139 #endif /* CONFIG_IEEE80211R_AP */
1143 static void hostapd_notify_auth_fils_finish(struct hostapd_data
*hapd
,
1144 struct sta_info
*sta
, u16 resp
,
1145 struct wpabuf
*data
, int pub
)
1147 if (resp
== WLAN_STATUS_SUCCESS
) {
1148 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
1149 HOSTAPD_LEVEL_DEBUG
, "authentication OK (FILS)");
1150 sta
->flags
|= WLAN_STA_AUTH
;
1151 wpa_auth_sm_event(sta
->wpa_sm
, WPA_AUTH
);
1152 sta
->auth_alg
= WLAN_AUTH_FILS_SK
;
1153 mlme_authenticate_indication(hapd
, sta
);
1155 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE80211
,
1156 HOSTAPD_LEVEL_DEBUG
,
1157 "authentication failed (FILS)");
1160 hostapd_sta_auth(hapd
, sta
->addr
, 2, resp
,
1161 data
? wpabuf_head(data
) : NULL
,
1162 data
? wpabuf_len(data
) : 0);
1165 #endif /* CONFIG_FILS */
1168 static void hostapd_notif_auth(struct hostapd_data
*hapd
,
1169 struct auth_info
*rx_auth
)
1171 struct sta_info
*sta
;
1172 u16 status
= WLAN_STATUS_SUCCESS
;
1173 u8 resp_ies
[2 + WLAN_AUTH_CHALLENGE_LEN
];
1174 size_t resp_ies_len
= 0;
1176 sta
= ap_get_sta(hapd
, rx_auth
->peer
);
1178 sta
= ap_sta_add(hapd
, rx_auth
->peer
);
1180 status
= WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA
;
1184 sta
->flags
&= ~WLAN_STA_PREAUTH
;
1185 ieee802_1x_notify_pre_auth(sta
->eapol_sm
, 0);
1186 #ifdef CONFIG_IEEE80211R_AP
1187 if (rx_auth
->auth_type
== WLAN_AUTH_FT
&& hapd
->wpa_auth
) {
1188 sta
->auth_alg
= WLAN_AUTH_FT
;
1189 if (sta
->wpa_sm
== NULL
)
1190 sta
->wpa_sm
= wpa_auth_sta_init(hapd
->wpa_auth
,
1192 if (sta
->wpa_sm
== NULL
) {
1193 wpa_printf(MSG_DEBUG
,
1194 "FT: Failed to initialize WPA state machine");
1195 status
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1198 wpa_ft_process_auth(sta
->wpa_sm
, rx_auth
->bssid
,
1199 rx_auth
->auth_transaction
, rx_auth
->ies
,
1201 hostapd_notify_auth_ft_finish
, hapd
);
1204 #endif /* CONFIG_IEEE80211R_AP */
1207 if (rx_auth
->auth_type
== WLAN_AUTH_FILS_SK
) {
1208 sta
->auth_alg
= WLAN_AUTH_FILS_SK
;
1209 handle_auth_fils(hapd
, sta
, rx_auth
->ies
, rx_auth
->ies_len
,
1210 rx_auth
->auth_type
, rx_auth
->auth_transaction
,
1211 rx_auth
->status_code
,
1212 hostapd_notify_auth_fils_finish
);
1215 #endif /* CONFIG_FILS */
1218 hostapd_sta_auth(hapd
, rx_auth
->peer
, rx_auth
->auth_transaction
+ 1,
1219 status
, resp_ies
, resp_ies_len
);
1223 #ifndef NEED_AP_MLME
1224 static void hostapd_action_rx(struct hostapd_data
*hapd
,
1225 struct rx_mgmt
*drv_mgmt
)
1227 struct ieee80211_mgmt
*mgmt
;
1228 struct sta_info
*sta
;
1229 size_t plen __maybe_unused
;
1231 u8
*action __maybe_unused
;
1233 if (drv_mgmt
->frame_len
< IEEE80211_HDRLEN
+ 2 + 1)
1236 plen
= drv_mgmt
->frame_len
- IEEE80211_HDRLEN
;
1238 mgmt
= (struct ieee80211_mgmt
*) drv_mgmt
->frame
;
1239 fc
= le_to_host16(mgmt
->frame_control
);
1240 if (WLAN_FC_GET_STYPE(fc
) != WLAN_FC_STYPE_ACTION
)
1241 return; /* handled by the driver */
1243 action
= (u8
*) &mgmt
->u
.action
.u
;
1244 wpa_printf(MSG_DEBUG
, "RX_ACTION category %u action %u sa " MACSTR
1245 " da " MACSTR
" plen %d",
1246 mgmt
->u
.action
.category
, *action
,
1247 MAC2STR(mgmt
->sa
), MAC2STR(mgmt
->da
), (int) plen
);
1249 sta
= ap_get_sta(hapd
, mgmt
->sa
);
1251 wpa_printf(MSG_DEBUG
, "%s: station not found", __func__
);
1254 #ifdef CONFIG_IEEE80211R_AP
1255 if (mgmt
->u
.action
.category
== WLAN_ACTION_FT
) {
1256 wpa_ft_action_rx(sta
->wpa_sm
, (u8
*) &mgmt
->u
.action
, plen
);
1259 #endif /* CONFIG_IEEE80211R_AP */
1260 if (mgmt
->u
.action
.category
== WLAN_ACTION_SA_QUERY
) {
1261 ieee802_11_sa_query_action(hapd
, mgmt
, drv_mgmt
->frame_len
);
1264 #ifdef CONFIG_WNM_AP
1265 if (mgmt
->u
.action
.category
== WLAN_ACTION_WNM
) {
1266 ieee802_11_rx_wnm_action_ap(hapd
, mgmt
, drv_mgmt
->frame_len
);
1269 #endif /* CONFIG_WNM_AP */
1271 if (mgmt
->u
.action
.category
== WLAN_ACTION_FST
&& hapd
->iface
->fst
) {
1272 fst_rx_action(hapd
->iface
->fst
, mgmt
, drv_mgmt
->frame_len
);
1275 #endif /* CONFIG_FST */
1277 if (plen
>= 2 + 4 &&
1278 mgmt
->u
.action
.u
.vs_public_action
.action
==
1279 WLAN_PA_VENDOR_SPECIFIC
&&
1280 WPA_GET_BE24(mgmt
->u
.action
.u
.vs_public_action
.oui
) ==
1282 mgmt
->u
.action
.u
.vs_public_action
.variable
[0] ==
1284 const u8
*pos
, *end
;
1286 pos
= mgmt
->u
.action
.u
.vs_public_action
.oui
;
1287 end
= drv_mgmt
->frame
+ drv_mgmt
->frame_len
;
1288 hostapd_dpp_rx_action(hapd
, mgmt
->sa
, pos
, end
- pos
,
1292 #endif /* CONFIG_DPP */
1294 #endif /* NEED_AP_MLME */
1299 #define HAPD_BROADCAST ((struct hostapd_data *) -1)
1301 static struct hostapd_data
* get_hapd_bssid(struct hostapd_iface
*iface
,
1308 if (bssid
[0] == 0xff && bssid
[1] == 0xff && bssid
[2] == 0xff &&
1309 bssid
[3] == 0xff && bssid
[4] == 0xff && bssid
[5] == 0xff)
1310 return HAPD_BROADCAST
;
1312 for (i
= 0; i
< iface
->num_bss
; i
++) {
1313 if (os_memcmp(bssid
, iface
->bss
[i
]->own_addr
, ETH_ALEN
) == 0)
1314 return iface
->bss
[i
];
1321 static void hostapd_rx_from_unknown_sta(struct hostapd_data
*hapd
,
1322 const u8
*bssid
, const u8
*addr
,
1325 hapd
= get_hapd_bssid(hapd
->iface
, bssid
);
1326 if (hapd
== NULL
|| hapd
== HAPD_BROADCAST
)
1329 ieee802_11_rx_from_unknown(hapd
, addr
, wds
);
1333 static int hostapd_mgmt_rx(struct hostapd_data
*hapd
, struct rx_mgmt
*rx_mgmt
)
1335 struct hostapd_iface
*iface
= hapd
->iface
;
1336 const struct ieee80211_hdr
*hdr
;
1338 struct hostapd_frame_info fi
;
1341 #ifdef CONFIG_TESTING_OPTIONS
1342 if (hapd
->ext_mgmt_frame_handling
) {
1343 size_t hex_len
= 2 * rx_mgmt
->frame_len
+ 1;
1344 char *hex
= os_malloc(hex_len
);
1347 wpa_snprintf_hex(hex
, hex_len
, rx_mgmt
->frame
,
1348 rx_mgmt
->frame_len
);
1349 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, "MGMT-RX %s", hex
);
1354 #endif /* CONFIG_TESTING_OPTIONS */
1356 hdr
= (const struct ieee80211_hdr
*) rx_mgmt
->frame
;
1357 bssid
= get_hdr_bssid(hdr
, rx_mgmt
->frame_len
);
1361 hapd
= get_hapd_bssid(iface
, bssid
);
1363 u16 fc
= le_to_host16(hdr
->frame_control
);
1366 * Drop frames to unknown BSSIDs except for Beacon frames which
1367 * could be used to update neighbor information.
1369 if (WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
1370 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_BEACON
)
1371 hapd
= iface
->bss
[0];
1376 os_memset(&fi
, 0, sizeof(fi
));
1377 fi
.freq
= rx_mgmt
->freq
;
1378 fi
.datarate
= rx_mgmt
->datarate
;
1379 fi
.ssi_signal
= rx_mgmt
->ssi_signal
;
1381 if (hapd
== HAPD_BROADCAST
) {
1385 for (i
= 0; i
< iface
->num_bss
; i
++) {
1386 /* if bss is set, driver will call this function for
1387 * each bss individually. */
1388 if (rx_mgmt
->drv_priv
&&
1389 (iface
->bss
[i
]->drv_priv
!= rx_mgmt
->drv_priv
))
1392 if (ieee802_11_mgmt(iface
->bss
[i
], rx_mgmt
->frame
,
1393 rx_mgmt
->frame_len
, &fi
) > 0)
1397 ret
= ieee802_11_mgmt(hapd
, rx_mgmt
->frame
, rx_mgmt
->frame_len
,
1400 random_add_randomness(&fi
, sizeof(fi
));
1406 static void hostapd_mgmt_tx_cb(struct hostapd_data
*hapd
, const u8
*buf
,
1407 size_t len
, u16 stype
, int ok
)
1409 struct ieee80211_hdr
*hdr
;
1410 struct hostapd_data
*orig_hapd
= hapd
;
1412 hdr
= (struct ieee80211_hdr
*) buf
;
1413 hapd
= get_hapd_bssid(hapd
->iface
, get_hdr_bssid(hdr
, len
));
1416 if (hapd
== HAPD_BROADCAST
) {
1417 if (stype
!= WLAN_FC_STYPE_ACTION
|| len
<= 25 ||
1418 buf
[24] != WLAN_ACTION_PUBLIC
)
1420 hapd
= get_hapd_bssid(orig_hapd
->iface
, hdr
->addr2
);
1421 if (!hapd
|| hapd
== HAPD_BROADCAST
)
1424 * Allow processing of TX status for a Public Action frame that
1425 * used wildcard BBSID.
1428 ieee802_11_mgmt_cb(hapd
, buf
, len
, stype
, ok
);
1431 #endif /* NEED_AP_MLME */
1434 static int hostapd_event_new_sta(struct hostapd_data
*hapd
, const u8
*addr
)
1436 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
1441 wpa_printf(MSG_DEBUG
, "Data frame from unknown STA " MACSTR
1442 " - adding a new STA", MAC2STR(addr
));
1443 sta
= ap_sta_add(hapd
, addr
);
1445 hostapd_new_assoc_sta(hapd
, sta
, 0);
1447 wpa_printf(MSG_DEBUG
, "Failed to add STA entry for " MACSTR
,
1456 static void hostapd_event_eapol_rx(struct hostapd_data
*hapd
, const u8
*src
,
1457 const u8
*data
, size_t data_len
)
1459 struct hostapd_iface
*iface
= hapd
->iface
;
1460 struct sta_info
*sta
;
1463 for (j
= 0; j
< iface
->num_bss
; j
++) {
1464 sta
= ap_get_sta(iface
->bss
[j
], src
);
1465 if (sta
&& sta
->flags
& WLAN_STA_ASSOC
) {
1466 hapd
= iface
->bss
[j
];
1471 ieee802_1x_receive(hapd
, src
, data
, data_len
);
1474 #endif /* HOSTAPD */
1477 static struct hostapd_channel_data
*
1478 hostapd_get_mode_chan(struct hostapd_hw_modes
*mode
, unsigned int freq
)
1481 struct hostapd_channel_data
*chan
;
1483 for (i
= 0; i
< mode
->num_channels
; i
++) {
1484 chan
= &mode
->channels
[i
];
1485 if ((unsigned int) chan
->freq
== freq
)
1493 static struct hostapd_channel_data
* hostapd_get_mode_channel(
1494 struct hostapd_iface
*iface
, unsigned int freq
)
1497 struct hostapd_channel_data
*chan
;
1499 for (i
= 0; i
< iface
->num_hw_features
; i
++) {
1500 if (hostapd_hw_skip_mode(iface
, &iface
->hw_features
[i
]))
1502 chan
= hostapd_get_mode_chan(&iface
->hw_features
[i
], freq
);
1511 static void hostapd_update_nf(struct hostapd_iface
*iface
,
1512 struct hostapd_channel_data
*chan
,
1513 struct freq_survey
*survey
)
1515 if (!iface
->chans_surveyed
) {
1516 chan
->min_nf
= survey
->nf
;
1517 iface
->lowest_nf
= survey
->nf
;
1519 if (dl_list_empty(&chan
->survey_list
))
1520 chan
->min_nf
= survey
->nf
;
1521 else if (survey
->nf
< chan
->min_nf
)
1522 chan
->min_nf
= survey
->nf
;
1523 if (survey
->nf
< iface
->lowest_nf
)
1524 iface
->lowest_nf
= survey
->nf
;
1529 static void hostapd_single_channel_get_survey(struct hostapd_iface
*iface
,
1530 struct survey_results
*survey_res
)
1532 struct hostapd_channel_data
*chan
;
1533 struct freq_survey
*survey
;
1534 u64 divisor
, dividend
;
1536 survey
= dl_list_first(&survey_res
->survey_list
, struct freq_survey
,
1538 if (!survey
|| !survey
->freq
)
1541 chan
= hostapd_get_mode_channel(iface
, survey
->freq
);
1542 if (!chan
|| chan
->flag
& HOSTAPD_CHAN_DISABLED
)
1545 wpa_printf(MSG_DEBUG
,
1546 "Single Channel Survey: (freq=%d channel_time=%ld channel_time_busy=%ld)",
1548 (unsigned long int) survey
->channel_time
,
1549 (unsigned long int) survey
->channel_time_busy
);
1551 if (survey
->channel_time
> iface
->last_channel_time
&&
1552 survey
->channel_time
> survey
->channel_time_busy
) {
1553 dividend
= survey
->channel_time_busy
-
1554 iface
->last_channel_time_busy
;
1555 divisor
= survey
->channel_time
- iface
->last_channel_time
;
1557 iface
->channel_utilization
= dividend
* 255 / divisor
;
1558 wpa_printf(MSG_DEBUG
, "Channel Utilization: %d",
1559 iface
->channel_utilization
);
1561 iface
->last_channel_time
= survey
->channel_time
;
1562 iface
->last_channel_time_busy
= survey
->channel_time_busy
;
1566 void hostapd_event_get_survey(struct hostapd_iface
*iface
,
1567 struct survey_results
*survey_results
)
1569 struct freq_survey
*survey
, *tmp
;
1570 struct hostapd_channel_data
*chan
;
1572 if (dl_list_empty(&survey_results
->survey_list
)) {
1573 wpa_printf(MSG_DEBUG
, "No survey data received");
1577 if (survey_results
->freq_filter
) {
1578 hostapd_single_channel_get_survey(iface
, survey_results
);
1582 dl_list_for_each_safe(survey
, tmp
, &survey_results
->survey_list
,
1583 struct freq_survey
, list
) {
1584 chan
= hostapd_get_mode_channel(iface
, survey
->freq
);
1587 if (chan
->flag
& HOSTAPD_CHAN_DISABLED
)
1590 dl_list_del(&survey
->list
);
1591 dl_list_add_tail(&chan
->survey_list
, &survey
->list
);
1593 hostapd_update_nf(iface
, chan
, survey
);
1595 iface
->chans_surveyed
++;
1603 static void hostapd_event_iface_unavailable(struct hostapd_data
*hapd
)
1605 wpa_printf(MSG_DEBUG
, "Interface %s is unavailable -- stopped",
1608 if (hapd
->csa_in_progress
) {
1609 wpa_printf(MSG_INFO
, "CSA failed (%s was stopped)",
1611 hostapd_switch_channel_fallback(hapd
->iface
,
1612 &hapd
->cs_freq_params
);
1617 static void hostapd_event_dfs_radar_detected(struct hostapd_data
*hapd
,
1618 struct dfs_event
*radar
)
1620 wpa_printf(MSG_DEBUG
, "DFS radar detected on %d MHz", radar
->freq
);
1621 hostapd_dfs_radar_detected(hapd
->iface
, radar
->freq
, radar
->ht_enabled
,
1622 radar
->chan_offset
, radar
->chan_width
,
1623 radar
->cf1
, radar
->cf2
);
1627 static void hostapd_event_dfs_pre_cac_expired(struct hostapd_data
*hapd
,
1628 struct dfs_event
*radar
)
1630 wpa_printf(MSG_DEBUG
, "DFS Pre-CAC expired on %d MHz", radar
->freq
);
1631 hostapd_dfs_pre_cac_expired(hapd
->iface
, radar
->freq
, radar
->ht_enabled
,
1632 radar
->chan_offset
, radar
->chan_width
,
1633 radar
->cf1
, radar
->cf2
);
1637 static void hostapd_event_dfs_cac_finished(struct hostapd_data
*hapd
,
1638 struct dfs_event
*radar
)
1640 wpa_printf(MSG_DEBUG
, "DFS CAC finished on %d MHz", radar
->freq
);
1641 hostapd_dfs_complete_cac(hapd
->iface
, 1, radar
->freq
, radar
->ht_enabled
,
1642 radar
->chan_offset
, radar
->chan_width
,
1643 radar
->cf1
, radar
->cf2
);
1647 static void hostapd_event_dfs_cac_aborted(struct hostapd_data
*hapd
,
1648 struct dfs_event
*radar
)
1650 wpa_printf(MSG_DEBUG
, "DFS CAC aborted on %d MHz", radar
->freq
);
1651 hostapd_dfs_complete_cac(hapd
->iface
, 0, radar
->freq
, radar
->ht_enabled
,
1652 radar
->chan_offset
, radar
->chan_width
,
1653 radar
->cf1
, radar
->cf2
);
1657 static void hostapd_event_dfs_nop_finished(struct hostapd_data
*hapd
,
1658 struct dfs_event
*radar
)
1660 wpa_printf(MSG_DEBUG
, "DFS NOP finished on %d MHz", radar
->freq
);
1661 hostapd_dfs_nop_finished(hapd
->iface
, radar
->freq
, radar
->ht_enabled
,
1662 radar
->chan_offset
, radar
->chan_width
,
1663 radar
->cf1
, radar
->cf2
);
1667 static void hostapd_event_dfs_cac_started(struct hostapd_data
*hapd
,
1668 struct dfs_event
*radar
)
1670 wpa_printf(MSG_DEBUG
, "DFS offload CAC started on %d MHz", radar
->freq
);
1671 hostapd_dfs_start_cac(hapd
->iface
, radar
->freq
, radar
->ht_enabled
,
1672 radar
->chan_offset
, radar
->chan_width
,
1673 radar
->cf1
, radar
->cf2
);
1676 #endif /* NEED_AP_MLME */
1679 static void hostapd_event_wds_sta_interface_status(struct hostapd_data
*hapd
,
1684 struct sta_info
*sta
= ap_get_sta(hapd
, addr
);
1687 os_free(sta
->ifname_wds
);
1688 if (istatus
== INTERFACE_ADDED
)
1689 sta
->ifname_wds
= os_strdup(ifname
);
1691 sta
->ifname_wds
= NULL
;
1694 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, "%sifname=%s sta_addr=" MACSTR
,
1695 istatus
== INTERFACE_ADDED
?
1696 WDS_STA_INTERFACE_ADDED
: WDS_STA_INTERFACE_REMOVED
,
1697 ifname
, MAC2STR(addr
));
1702 static int hostapd_notif_update_dh_ie(struct hostapd_data
*hapd
,
1703 const u8
*peer
, const u8
*ie
,
1707 struct sta_info
*sta
;
1708 struct ieee802_11_elems elems
;
1710 if (!hapd
|| !hapd
->wpa_auth
) {
1711 wpa_printf(MSG_DEBUG
, "OWE: Invalid hapd context");
1715 wpa_printf(MSG_DEBUG
, "OWE: Peer unknown");
1718 if (!(hapd
->conf
->wpa_key_mgmt
& WPA_KEY_MGMT_OWE
)) {
1719 wpa_printf(MSG_DEBUG
, "OWE: No OWE AKM configured");
1720 status
= WLAN_STATUS_AKMP_NOT_VALID
;
1723 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 1) == ParseFailed
) {
1724 wpa_printf(MSG_DEBUG
, "OWE: Failed to parse OWE IE for "
1725 MACSTR
, MAC2STR(peer
));
1726 status
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1729 status
= owe_validate_request(hapd
, peer
, elems
.rsn_ie
,
1731 elems
.owe_dh
, elems
.owe_dh_len
);
1732 if (status
!= WLAN_STATUS_SUCCESS
)
1735 sta
= ap_get_sta(hapd
, peer
);
1737 ap_sta_no_session_timeout(hapd
, sta
);
1738 accounting_sta_stop(hapd
, sta
);
1741 * Make sure that the previously registered inactivity timer
1742 * will not remove the STA immediately.
1744 sta
->timeout_next
= STA_NULLFUNC
;
1746 sta
= ap_sta_add(hapd
, peer
);
1748 status
= WLAN_STATUS_UNSPECIFIED_FAILURE
;
1752 sta
->flags
&= ~(WLAN_STA_WPS
| WLAN_STA_MAYBE_WPS
| WLAN_STA_WPS2
);
1754 status
= owe_process_rsn_ie(hapd
, sta
, elems
.rsn_ie
,
1755 elems
.rsn_ie_len
, elems
.owe_dh
,
1757 if (status
!= WLAN_STATUS_SUCCESS
)
1758 ap_free_sta(hapd
, sta
);
1762 hostapd_drv_update_dh_ie(hapd
, peer
, status
, NULL
, 0);
1765 #endif /* CONFIG_OWE */
1768 void wpa_supplicant_event(void *ctx
, enum wpa_event_type event
,
1769 union wpa_event_data
*data
)
1771 struct hostapd_data
*hapd
= ctx
;
1772 #ifndef CONFIG_NO_STDOUT_DEBUG
1773 int level
= MSG_DEBUG
;
1775 if (event
== EVENT_RX_MGMT
&& data
->rx_mgmt
.frame
&&
1776 data
->rx_mgmt
.frame_len
>= 24) {
1777 const struct ieee80211_hdr
*hdr
;
1780 hdr
= (const struct ieee80211_hdr
*) data
->rx_mgmt
.frame
;
1781 fc
= le_to_host16(hdr
->frame_control
);
1782 if (WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
1783 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_BEACON
)
1784 level
= MSG_EXCESSIVE
;
1785 if (WLAN_FC_GET_TYPE(fc
) == WLAN_FC_TYPE_MGMT
&&
1786 WLAN_FC_GET_STYPE(fc
) == WLAN_FC_STYPE_PROBE_REQ
)
1787 level
= MSG_EXCESSIVE
;
1790 wpa_dbg(hapd
->msg_ctx
, level
, "Event %s (%d) received",
1791 event_to_string(event
), event
);
1792 #endif /* CONFIG_NO_STDOUT_DEBUG */
1795 case EVENT_MICHAEL_MIC_FAILURE
:
1796 michael_mic_failure(hapd
, data
->michael_mic_failure
.src
, 1);
1798 case EVENT_SCAN_RESULTS
:
1799 if (hapd
->iface
->scan_cb
)
1800 hapd
->iface
->scan_cb(hapd
->iface
);
1802 case EVENT_WPS_BUTTON_PUSHED
:
1803 hostapd_wps_button_pushed(hapd
, NULL
);
1806 case EVENT_TX_STATUS
:
1807 switch (data
->tx_status
.type
) {
1808 case WLAN_FC_TYPE_MGMT
:
1809 hostapd_mgmt_tx_cb(hapd
, data
->tx_status
.data
,
1810 data
->tx_status
.data_len
,
1811 data
->tx_status
.stype
,
1812 data
->tx_status
.ack
);
1814 case WLAN_FC_TYPE_DATA
:
1815 hostapd_tx_status(hapd
, data
->tx_status
.dst
,
1816 data
->tx_status
.data
,
1817 data
->tx_status
.data_len
,
1818 data
->tx_status
.ack
);
1822 case EVENT_EAPOL_TX_STATUS
:
1823 hostapd_eapol_tx_status(hapd
, data
->eapol_tx_status
.dst
,
1824 data
->eapol_tx_status
.data
,
1825 data
->eapol_tx_status
.data_len
,
1826 data
->eapol_tx_status
.ack
);
1828 case EVENT_DRIVER_CLIENT_POLL_OK
:
1829 hostapd_client_poll_ok(hapd
, data
->client_poll
.addr
);
1831 case EVENT_RX_FROM_UNKNOWN
:
1832 hostapd_rx_from_unknown_sta(hapd
, data
->rx_from_unknown
.bssid
,
1833 data
->rx_from_unknown
.addr
,
1834 data
->rx_from_unknown
.wds
);
1836 #endif /* NEED_AP_MLME */
1838 if (!data
->rx_mgmt
.frame
)
1841 hostapd_mgmt_rx(hapd
, &data
->rx_mgmt
);
1842 #else /* NEED_AP_MLME */
1843 hostapd_action_rx(hapd
, &data
->rx_mgmt
);
1844 #endif /* NEED_AP_MLME */
1846 case EVENT_RX_PROBE_REQ
:
1847 if (data
->rx_probe_req
.sa
== NULL
||
1848 data
->rx_probe_req
.ie
== NULL
)
1850 hostapd_probe_req_rx(hapd
, data
->rx_probe_req
.sa
,
1851 data
->rx_probe_req
.da
,
1852 data
->rx_probe_req
.bssid
,
1853 data
->rx_probe_req
.ie
,
1854 data
->rx_probe_req
.ie_len
,
1855 data
->rx_probe_req
.ssi_signal
);
1858 hostapd_event_new_sta(hapd
, data
->new_sta
.addr
);
1860 case EVENT_EAPOL_RX
:
1861 hostapd_event_eapol_rx(hapd
, data
->eapol_rx
.src
,
1862 data
->eapol_rx
.data
,
1863 data
->eapol_rx
.data_len
);
1868 hostapd_notif_assoc(hapd
, data
->assoc_info
.addr
,
1869 data
->assoc_info
.req_ies
,
1870 data
->assoc_info
.req_ies_len
,
1871 data
->assoc_info
.reassoc
);
1874 case EVENT_UPDATE_DH
:
1877 hostapd_notif_update_dh_ie(hapd
, data
->update_dh
.peer
,
1879 data
->update_dh
.ie_len
);
1881 #endif /* CONFIG_OWE */
1882 case EVENT_DISASSOC
:
1884 hostapd_notif_disassoc(hapd
, data
->disassoc_info
.addr
);
1888 hostapd_notif_disassoc(hapd
, data
->deauth_info
.addr
);
1890 case EVENT_STATION_LOW_ACK
:
1893 hostapd_event_sta_low_ack(hapd
, data
->low_ack
.addr
);
1896 hostapd_notif_auth(hapd
, &data
->auth
);
1898 case EVENT_CH_SWITCH_STARTED
:
1899 case EVENT_CH_SWITCH
:
1902 hostapd_event_ch_switch(hapd
, data
->ch_switch
.freq
,
1903 data
->ch_switch
.ht_enabled
,
1904 data
->ch_switch
.ch_offset
,
1905 data
->ch_switch
.ch_width
,
1906 data
->ch_switch
.cf1
,
1907 data
->ch_switch
.cf2
,
1908 event
== EVENT_CH_SWITCH
);
1910 case EVENT_CONNECT_FAILED_REASON
:
1913 hostapd_event_connect_failed_reason(
1914 hapd
, data
->connect_failed_reason
.addr
,
1915 data
->connect_failed_reason
.code
);
1918 hostapd_event_get_survey(hapd
->iface
, &data
->survey_results
);
1921 case EVENT_INTERFACE_UNAVAILABLE
:
1922 hostapd_event_iface_unavailable(hapd
);
1924 case EVENT_DFS_RADAR_DETECTED
:
1927 hostapd_event_dfs_radar_detected(hapd
, &data
->dfs_event
);
1929 case EVENT_DFS_PRE_CAC_EXPIRED
:
1932 hostapd_event_dfs_pre_cac_expired(hapd
, &data
->dfs_event
);
1934 case EVENT_DFS_CAC_FINISHED
:
1937 hostapd_event_dfs_cac_finished(hapd
, &data
->dfs_event
);
1939 case EVENT_DFS_CAC_ABORTED
:
1942 hostapd_event_dfs_cac_aborted(hapd
, &data
->dfs_event
);
1944 case EVENT_DFS_NOP_FINISHED
:
1947 hostapd_event_dfs_nop_finished(hapd
, &data
->dfs_event
);
1949 case EVENT_CHANNEL_LIST_CHANGED
:
1950 /* channel list changed (regulatory?), update channel list */
1951 /* TODO: check this. hostapd_get_hw_features() initializes
1952 * too much stuff. */
1953 /* hostapd_get_hw_features(hapd->iface); */
1954 hostapd_channel_list_updated(
1955 hapd
->iface
, data
->channel_list_changed
.initiator
);
1957 case EVENT_DFS_CAC_STARTED
:
1960 hostapd_event_dfs_cac_started(hapd
, &data
->dfs_event
);
1962 #endif /* NEED_AP_MLME */
1963 case EVENT_INTERFACE_ENABLED
:
1964 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, INTERFACE_ENABLED
);
1965 if (hapd
->disabled
&& hapd
->started
) {
1968 * Try to re-enable interface if the driver stopped it
1969 * when the interface got disabled.
1972 wpa_auth_reconfig_group_keys(hapd
->wpa_auth
);
1974 hostapd_reconfig_encryption(hapd
);
1975 hapd
->reenable_beacon
= 1;
1976 ieee802_11_set_beacon(hapd
);
1978 } else if (hapd
->disabled
&& hapd
->iface
->cac_started
) {
1979 wpa_printf(MSG_DEBUG
, "DFS: restarting pending CAC");
1980 hostapd_handle_dfs(hapd
->iface
);
1981 #endif /* NEED_AP_MLME */
1984 case EVENT_INTERFACE_DISABLED
:
1985 hostapd_free_stas(hapd
);
1986 wpa_msg(hapd
->msg_ctx
, MSG_INFO
, INTERFACE_DISABLED
);
1990 case EVENT_ACS_CHANNEL_SELECTED
:
1991 hostapd_acs_channel_selected(hapd
,
1992 &data
->acs_selected_channels
);
1994 #endif /* CONFIG_ACS */
1995 case EVENT_STATION_OPMODE_CHANGED
:
1996 hostapd_event_sta_opmode_changed(hapd
, data
->sta_opmode
.addr
,
1997 data
->sta_opmode
.smps_mode
,
1998 data
->sta_opmode
.chan_width
,
1999 data
->sta_opmode
.rx_nss
);
2001 case EVENT_WDS_STA_INTERFACE_STATUS
:
2002 hostapd_event_wds_sta_interface_status(
2003 hapd
, data
->wds_sta_interface
.istatus
,
2004 data
->wds_sta_interface
.ifname
,
2005 data
->wds_sta_interface
.sta_addr
);
2008 wpa_printf(MSG_DEBUG
, "Unknown event %d", event
);
2014 void wpa_supplicant_event_global(void *ctx
, enum wpa_event_type event
,
2015 union wpa_event_data
*data
)
2017 struct hapd_interfaces
*interfaces
= ctx
;
2018 struct hostapd_data
*hapd
;
2020 if (event
!= EVENT_INTERFACE_STATUS
)
2023 hapd
= hostapd_get_iface(interfaces
, data
->interface_status
.ifname
);
2024 if (hapd
&& hapd
->driver
&& hapd
->driver
->get_ifindex
&&
2026 unsigned int ifindex
;
2028 ifindex
= hapd
->driver
->get_ifindex(hapd
->drv_priv
);
2029 if (ifindex
!= data
->interface_status
.ifindex
) {
2030 wpa_dbg(hapd
->msg_ctx
, MSG_DEBUG
,
2031 "interface status ifindex %d mismatch (%d)",
2032 ifindex
, data
->interface_status
.ifindex
);
2037 wpa_supplicant_event(hapd
, event
, data
);
2040 #endif /* HOSTAPD */