Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Callback functions for driver wrappers |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 3 | * Copyright (c) 2002-2013, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 12 | #include "utils/eloop.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 13 | #include "radius/radius.h" |
| 14 | #include "drivers/driver.h" |
| 15 | #include "common/ieee802_11_defs.h" |
| 16 | #include "common/ieee802_11_common.h" |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 17 | #include "common/wpa_ctrl.h" |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 18 | #include "common/dpp.h" |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 19 | #include "common/sae.h" |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 20 | #include "common/hw_features_common.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 21 | #include "crypto/random.h" |
| 22 | #include "p2p/p2p.h" |
| 23 | #include "wps/wps.h" |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 24 | #include "fst/fst.h" |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 25 | #include "wnm_ap.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 26 | #include "hostapd.h" |
| 27 | #include "ieee802_11.h" |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 28 | #include "ieee802_11_auth.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 29 | #include "sta_info.h" |
| 30 | #include "accounting.h" |
| 31 | #include "tkip_countermeasures.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 32 | #include "ieee802_1x.h" |
| 33 | #include "wpa_auth.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 34 | #include "wps_hostapd.h" |
| 35 | #include "ap_drv_ops.h" |
| 36 | #include "ap_config.h" |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 37 | #include "ap_mlme.h" |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 38 | #include "hw_features.h" |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 39 | #include "dfs.h" |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 40 | #include "beacon.h" |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 41 | #include "mbo_ap.h" |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 42 | #include "dpp_hostapd.h" |
| 43 | #include "fils_hlp.h" |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 44 | #include "neighbor_db.h" |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 45 | #include "nan_usd_ap.h" |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 46 | |
| 47 | |
| 48 | #ifdef CONFIG_FILS |
| 49 | void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd, |
| 50 | struct sta_info *sta) |
| 51 | { |
| 52 | u16 reply_res = WLAN_STATUS_SUCCESS; |
| 53 | struct ieee802_11_elems elems; |
| 54 | u8 buf[IEEE80211_MAX_MMPDU_SIZE], *p = buf; |
| 55 | int new_assoc; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 56 | bool updated; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 57 | |
| 58 | wpa_printf(MSG_DEBUG, "%s FILS: Finish association with " MACSTR, |
| 59 | __func__, MAC2STR(sta->addr)); |
| 60 | eloop_cancel_timeout(fils_hlp_timeout, hapd, sta); |
| 61 | if (!sta->fils_pending_assoc_req) |
| 62 | return; |
| 63 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 64 | if (ieee802_11_parse_elems(sta->fils_pending_assoc_req, |
| 65 | sta->fils_pending_assoc_req_len, &elems, |
| 66 | 0) == ParseFailed || |
| 67 | !elems.fils_session) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 68 | wpa_printf(MSG_DEBUG, "%s failed to find FILS Session element", |
| 69 | __func__); |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | p = hostapd_eid_assoc_fils_session(sta->wpa_sm, p, |
| 74 | elems.fils_session, |
| 75 | sta->fils_hlp_resp); |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 76 | if (!p) |
| 77 | return; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 78 | |
| 79 | reply_res = hostapd_sta_assoc(hapd, sta->addr, |
| 80 | sta->fils_pending_assoc_is_reassoc, |
| 81 | WLAN_STATUS_SUCCESS, |
| 82 | buf, p - buf); |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 83 | updated = ap_sta_set_authorized_flag(hapd, sta, 1); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 84 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; |
| 85 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 86 | sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; |
| 87 | hostapd_set_sta_flags(hapd, sta); |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 88 | if (updated) |
| 89 | ap_sta_set_authorized_event(hapd, sta, 1); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 90 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FILS); |
| 91 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); |
| 92 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); |
| 93 | os_free(sta->fils_pending_assoc_req); |
| 94 | sta->fils_pending_assoc_req = NULL; |
| 95 | sta->fils_pending_assoc_req_len = 0; |
| 96 | wpabuf_free(sta->fils_hlp_resp); |
| 97 | sta->fils_hlp_resp = NULL; |
| 98 | wpabuf_free(sta->hlp_dhcp_discover); |
| 99 | sta->hlp_dhcp_discover = NULL; |
| 100 | fils_hlp_deinit(hapd); |
| 101 | |
| 102 | /* |
| 103 | * Remove the station in case transmission of a success response fails |
| 104 | * (the STA was added associated to the driver) or if the station was |
| 105 | * previously added unassociated. |
| 106 | */ |
| 107 | if (reply_res != WLAN_STATUS_SUCCESS || sta->added_unassoc) { |
| 108 | hostapd_drv_sta_remove(hapd, sta->addr); |
| 109 | sta->added_unassoc = 0; |
| 110 | } |
| 111 | } |
| 112 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 113 | |
| 114 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 115 | static bool check_sa_query_need(struct hostapd_data *hapd, struct sta_info *sta) |
| 116 | { |
| 117 | if ((sta->flags & |
| 118 | (WLAN_STA_ASSOC | WLAN_STA_MFP | WLAN_STA_AUTHORIZED)) != |
| 119 | (WLAN_STA_ASSOC | WLAN_STA_MFP | WLAN_STA_AUTHORIZED)) |
| 120 | return false; |
| 121 | |
| 122 | if (!sta->sa_query_timed_out && sta->sa_query_count > 0) |
| 123 | ap_check_sa_query_timeout(hapd, sta); |
| 124 | |
| 125 | if (!sta->sa_query_timed_out && (sta->auth_alg != WLAN_AUTH_FT)) { |
| 126 | /* |
| 127 | * STA has already been associated with MFP and SA Query timeout |
| 128 | * has not been reached. Reject the association attempt |
| 129 | * temporarily and start SA Query, if one is not pending. |
| 130 | */ |
| 131 | if (sta->sa_query_count == 0) |
| 132 | ap_sta_start_sa_query(hapd, sta); |
| 133 | |
| 134 | return true; |
| 135 | } |
| 136 | |
| 137 | return false; |
| 138 | } |
| 139 | |
| 140 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 141 | #ifdef CONFIG_IEEE80211BE |
| 142 | static int hostapd_update_sta_links_status(struct hostapd_data *hapd, |
| 143 | struct sta_info *sta, |
| 144 | const u8 *resp_ies, |
| 145 | size_t resp_ies_len) |
| 146 | { |
| 147 | struct mld_info *info = &sta->mld_info; |
| 148 | struct wpabuf *mlebuf; |
| 149 | const u8 *mle, *pos; |
| 150 | struct ieee802_11_elems elems; |
| 151 | size_t mle_len, rem_len; |
| 152 | int ret = 0; |
| 153 | |
| 154 | if (!resp_ies) { |
| 155 | wpa_printf(MSG_DEBUG, |
| 156 | "MLO: (Re)Association Response frame elements not available"); |
| 157 | return -1; |
| 158 | } |
| 159 | |
| 160 | if (ieee802_11_parse_elems(resp_ies, resp_ies_len, &elems, 0) == |
| 161 | ParseFailed) { |
| 162 | wpa_printf(MSG_DEBUG, |
| 163 | "MLO: Failed to parse (Re)Association Response frame elements"); |
| 164 | return -1; |
| 165 | } |
| 166 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 167 | mlebuf = ieee802_11_defrag(elems.basic_mle, elems.basic_mle_len, true); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 168 | if (!mlebuf) { |
| 169 | wpa_printf(MSG_ERROR, |
| 170 | "MLO: Basic Multi-Link element not found in (Re)Association Response frame"); |
| 171 | return -1; |
| 172 | } |
| 173 | |
| 174 | mle = wpabuf_head(mlebuf); |
| 175 | mle_len = wpabuf_len(mlebuf); |
| 176 | if (mle_len < MULTI_LINK_CONTROL_LEN + 1 || |
| 177 | mle_len - MULTI_LINK_CONTROL_LEN < mle[MULTI_LINK_CONTROL_LEN]) { |
| 178 | wpa_printf(MSG_ERROR, |
| 179 | "MLO: Invalid Multi-Link element in (Re)Association Response frame"); |
| 180 | ret = -1; |
| 181 | goto out; |
| 182 | } |
| 183 | |
| 184 | /* Skip Common Info */ |
| 185 | pos = mle + MULTI_LINK_CONTROL_LEN + mle[MULTI_LINK_CONTROL_LEN]; |
| 186 | rem_len = mle_len - |
| 187 | (MULTI_LINK_CONTROL_LEN + mle[MULTI_LINK_CONTROL_LEN]); |
| 188 | |
| 189 | /* Parse Subelements */ |
| 190 | while (rem_len > 2) { |
| 191 | size_t ie_len = 2 + pos[1]; |
| 192 | |
| 193 | if (rem_len < ie_len) |
| 194 | break; |
| 195 | |
| 196 | if (pos[0] == MULTI_LINK_SUB_ELEM_ID_PER_STA_PROFILE) { |
| 197 | u8 link_id; |
| 198 | const u8 *sta_profile; |
| 199 | size_t sta_profile_len; |
| 200 | u16 sta_ctrl; |
| 201 | |
| 202 | if (pos[1] < BASIC_MLE_STA_CTRL_LEN + 1) { |
| 203 | wpa_printf(MSG_DEBUG, |
| 204 | "MLO: Invalid per-STA profile IE"); |
| 205 | goto next_subelem; |
| 206 | } |
| 207 | |
| 208 | sta_profile_len = pos[1]; |
| 209 | sta_profile = &pos[2]; |
| 210 | sta_ctrl = WPA_GET_LE16(sta_profile); |
| 211 | link_id = sta_ctrl & BASIC_MLE_STA_CTRL_LINK_ID_MASK; |
| 212 | if (link_id >= MAX_NUM_MLD_LINKS) { |
| 213 | wpa_printf(MSG_DEBUG, |
| 214 | "MLO: Invalid link ID in per-STA profile IE"); |
| 215 | goto next_subelem; |
| 216 | } |
| 217 | |
| 218 | /* Skip STA Control and STA Info */ |
| 219 | if (sta_profile_len - BASIC_MLE_STA_CTRL_LEN < |
| 220 | sta_profile[BASIC_MLE_STA_CTRL_LEN]) { |
| 221 | wpa_printf(MSG_DEBUG, |
| 222 | "MLO: Invalid STA info in per-STA profile IE"); |
| 223 | goto next_subelem; |
| 224 | } |
| 225 | |
| 226 | sta_profile_len = sta_profile_len - |
| 227 | (BASIC_MLE_STA_CTRL_LEN + |
| 228 | sta_profile[BASIC_MLE_STA_CTRL_LEN]); |
| 229 | sta_profile = sta_profile + BASIC_MLE_STA_CTRL_LEN + |
| 230 | sta_profile[BASIC_MLE_STA_CTRL_LEN]; |
| 231 | |
| 232 | /* Skip Capabilities Information field */ |
| 233 | if (sta_profile_len < 2) |
| 234 | goto next_subelem; |
| 235 | sta_profile_len -= 2; |
| 236 | sta_profile += 2; |
| 237 | |
| 238 | /* Get status of the link */ |
| 239 | info->links[link_id].status = WPA_GET_LE16(sta_profile); |
| 240 | } |
| 241 | next_subelem: |
| 242 | pos += ie_len; |
| 243 | rem_len -= ie_len; |
| 244 | } |
| 245 | |
| 246 | out: |
| 247 | wpabuf_free(mlebuf); |
| 248 | return ret; |
| 249 | } |
| 250 | #endif /* CONFIG_IEEE80211BE */ |
| 251 | |
| 252 | |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 253 | #if defined(HOSTAPD) || defined(CONFIG_IEEE80211BE) |
| 254 | static struct hostapd_data * hostapd_find_by_sta(struct hostapd_iface *iface, |
| 255 | const u8 *src, bool rsn, |
| 256 | struct sta_info **sta_ret) |
| 257 | { |
| 258 | struct hostapd_data *hapd; |
| 259 | struct sta_info *sta; |
| 260 | unsigned int j; |
| 261 | |
| 262 | if (sta_ret) |
| 263 | *sta_ret = NULL; |
| 264 | |
| 265 | for (j = 0; j < iface->num_bss; j++) { |
| 266 | hapd = iface->bss[j]; |
| 267 | sta = ap_get_sta(hapd, src); |
| 268 | if (sta && (sta->flags & WLAN_STA_ASSOC) && |
| 269 | (!rsn || sta->wpa_sm)) { |
| 270 | if (sta_ret) |
| 271 | *sta_ret = sta; |
| 272 | return hapd; |
| 273 | } |
| 274 | #ifdef CONFIG_IEEE80211BE |
| 275 | if (hapd->conf->mld_ap) { |
| 276 | struct hostapd_data *p_hapd; |
| 277 | |
| 278 | for_each_mld_link(p_hapd, hapd) { |
| 279 | if (p_hapd == hapd) |
| 280 | continue; |
| 281 | |
| 282 | sta = ap_get_sta(p_hapd, src); |
| 283 | if (sta && (sta->flags & WLAN_STA_ASSOC) && |
| 284 | (!rsn || sta->wpa_sm)) { |
| 285 | if (sta_ret) |
| 286 | *sta_ret = sta; |
| 287 | return p_hapd; |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | #endif /* CONFIG_IEEE80211BE */ |
| 292 | } |
| 293 | |
| 294 | return NULL; |
| 295 | } |
| 296 | #endif /* HOSTAPD || CONFIG_IEEE80211BE */ |
| 297 | |
| 298 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 299 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 300 | const u8 *req_ies, size_t req_ies_len, |
| 301 | const u8 *resp_ies, size_t resp_ies_len, |
| 302 | const u8 *link_addr, int reassoc) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 303 | { |
| 304 | struct sta_info *sta; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 305 | int new_assoc; |
| 306 | enum wpa_validate_result res; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 307 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 308 | const u8 *ie; |
| 309 | size_t ielen; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 310 | u8 buf[sizeof(struct ieee80211_mgmt) + 1024]; |
| 311 | u8 *p = buf; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 312 | u16 reason = WLAN_REASON_UNSPECIFIED; |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 313 | int status = WLAN_STATUS_SUCCESS; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 314 | const u8 *p2p_dev_addr = NULL; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 315 | #ifdef CONFIG_OWE |
| 316 | struct hostapd_iface *iface = hapd->iface; |
| 317 | #endif /* CONFIG_OWE */ |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 318 | bool updated = false; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 319 | |
| 320 | if (addr == NULL) { |
| 321 | /* |
| 322 | * This could potentially happen with unexpected event from the |
| 323 | * driver wrapper. This was seen at least in one case where the |
| 324 | * driver ended up being set to station mode while hostapd was |
| 325 | * running, so better make sure we stop processing such an |
| 326 | * event here. |
| 327 | */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 328 | wpa_printf(MSG_DEBUG, |
| 329 | "hostapd_notif_assoc: Skip event with no address"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 330 | return -1; |
| 331 | } |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 332 | |
| 333 | if (is_multicast_ether_addr(addr) || |
| 334 | is_zero_ether_addr(addr) || |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 335 | ether_addr_equal(addr, hapd->own_addr)) { |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 336 | /* Do not process any frames with unexpected/invalid SA so that |
| 337 | * we do not add any state for unexpected STA addresses or end |
| 338 | * up sending out frames to unexpected destination. */ |
| 339 | wpa_printf(MSG_DEBUG, "%s: Invalid SA=" MACSTR |
| 340 | " in received indication - ignore this indication silently", |
| 341 | __func__, MAC2STR(addr)); |
| 342 | return 0; |
| 343 | } |
| 344 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 345 | random_add_randomness(addr, ETH_ALEN); |
| 346 | |
| 347 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 348 | HOSTAPD_LEVEL_INFO, "associated"); |
| 349 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 350 | if (ieee802_11_parse_elems(req_ies, req_ies_len, &elems, 0) == |
| 351 | ParseFailed) { |
| 352 | wpa_printf(MSG_DEBUG, "%s: Could not parse elements", __func__); |
| 353 | return -1; |
| 354 | } |
| 355 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 356 | if (elems.wps_ie) { |
| 357 | ie = elems.wps_ie - 2; |
| 358 | ielen = elems.wps_ie_len + 2; |
| 359 | wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)AssocReq"); |
| 360 | } else if (elems.rsn_ie) { |
| 361 | ie = elems.rsn_ie - 2; |
| 362 | ielen = elems.rsn_ie_len + 2; |
| 363 | wpa_printf(MSG_DEBUG, "STA included RSN IE in (Re)AssocReq"); |
| 364 | } else if (elems.wpa_ie) { |
| 365 | ie = elems.wpa_ie - 2; |
| 366 | ielen = elems.wpa_ie_len + 2; |
| 367 | wpa_printf(MSG_DEBUG, "STA included WPA IE in (Re)AssocReq"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 368 | #ifdef CONFIG_HS20 |
| 369 | } else if (elems.osen) { |
| 370 | ie = elems.osen - 2; |
| 371 | ielen = elems.osen_len + 2; |
| 372 | wpa_printf(MSG_DEBUG, "STA included OSEN IE in (Re)AssocReq"); |
| 373 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 374 | } else { |
| 375 | ie = NULL; |
| 376 | ielen = 0; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 377 | wpa_printf(MSG_DEBUG, |
| 378 | "STA did not include WPS/RSN/WPA IE in (Re)AssocReq"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | sta = ap_get_sta(hapd, addr); |
| 382 | if (sta) { |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 383 | ap_sta_no_session_timeout(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 384 | accounting_sta_stop(hapd, sta); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 385 | |
| 386 | /* |
| 387 | * Make sure that the previously registered inactivity timer |
| 388 | * will not remove the STA immediately. |
| 389 | */ |
| 390 | sta->timeout_next = STA_NULLFUNC; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 391 | } else { |
| 392 | sta = ap_sta_add(hapd, addr); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 393 | if (sta == NULL) { |
| 394 | hostapd_drv_sta_disassoc(hapd, addr, |
| 395 | WLAN_REASON_DISASSOC_AP_BUSY); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 396 | return -1; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 397 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 398 | } |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 399 | |
| 400 | if (hapd->conf->wpa && check_sa_query_need(hapd, sta)) { |
| 401 | status = WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY; |
| 402 | p = hostapd_eid_assoc_comeback_time(hapd, sta, p); |
| 403 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
| 404 | |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | #ifdef CONFIG_IEEE80211BE |
| 409 | if (link_addr) { |
| 410 | struct mld_info *info = &sta->mld_info; |
| 411 | int i, num_valid_links = 0; |
| 412 | u8 link_id = hapd->mld_link_id; |
| 413 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 414 | ap_sta_set_mld(sta, true); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 415 | sta->mld_assoc_link_id = link_id; |
| 416 | os_memcpy(info->common_info.mld_addr, addr, ETH_ALEN); |
| 417 | info->links[link_id].valid = true; |
| 418 | os_memcpy(info->links[link_id].peer_addr, link_addr, ETH_ALEN); |
| 419 | os_memcpy(info->links[link_id].local_addr, hapd->own_addr, |
| 420 | ETH_ALEN); |
| 421 | |
| 422 | if (!elems.basic_mle || |
| 423 | hostapd_process_ml_assoc_req(hapd, &elems, sta) != |
| 424 | WLAN_STATUS_SUCCESS) { |
| 425 | reason = WLAN_REASON_UNSPECIFIED; |
| 426 | wpa_printf(MSG_DEBUG, |
| 427 | "Failed to get STA non-assoc links info"); |
| 428 | goto fail; |
| 429 | } |
| 430 | |
| 431 | for (i = 0 ; i < MAX_NUM_MLD_LINKS; i++) { |
| 432 | if (info->links[i].valid) |
| 433 | num_valid_links++; |
| 434 | } |
| 435 | if (num_valid_links > 1 && |
| 436 | hostapd_update_sta_links_status(hapd, sta, resp_ies, |
| 437 | resp_ies_len)) { |
| 438 | wpa_printf(MSG_DEBUG, |
| 439 | "Failed to get STA non-assoc links status info"); |
| 440 | reason = WLAN_REASON_UNSPECIFIED; |
| 441 | goto fail; |
| 442 | } |
| 443 | } |
| 444 | #endif /* CONFIG_IEEE80211BE */ |
| 445 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 446 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 447 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 448 | /* |
| 449 | * ACL configurations to the drivers (implementing AP SME and ACL |
| 450 | * offload) without hostapd's knowledge, can result in a disconnection |
| 451 | * though the driver accepts the connection. Skip the hostapd check for |
| 452 | * ACL if the driver supports ACL offload to avoid potentially |
| 453 | * conflicting ACL rules. |
| 454 | */ |
| 455 | if (hapd->iface->drv_max_acl_mac_addrs == 0 && |
| 456 | hostapd_check_acl(hapd, addr, NULL) != HOSTAPD_ACL_ACCEPT) { |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 457 | wpa_printf(MSG_INFO, "STA " MACSTR " not allowed to connect", |
| 458 | MAC2STR(addr)); |
| 459 | reason = WLAN_REASON_UNSPECIFIED; |
| 460 | goto fail; |
| 461 | } |
| 462 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 463 | #ifdef CONFIG_P2P |
| 464 | if (elems.p2p) { |
| 465 | wpabuf_free(sta->p2p_ie); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 466 | sta->p2p_ie = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 467 | P2P_IE_VENDOR_TYPE); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 468 | if (sta->p2p_ie) |
| 469 | p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 470 | } |
| 471 | #endif /* CONFIG_P2P */ |
| 472 | |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 473 | #ifdef NEED_AP_MLME |
| 474 | if (elems.ht_capabilities && |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 475 | (hapd->iface->conf->ht_capab & |
| 476 | HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) { |
| 477 | struct ieee80211_ht_capabilities *ht_cap = |
| 478 | (struct ieee80211_ht_capabilities *) |
| 479 | elems.ht_capabilities; |
| 480 | |
| 481 | if (le_to_host16(ht_cap->ht_capabilities_info) & |
| 482 | HT_CAP_INFO_40MHZ_INTOLERANT) |
| 483 | ht40_intolerant_add(hapd->iface, sta); |
| 484 | } |
| 485 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 486 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 487 | check_ext_capab(hapd, sta, elems.ext_capab, elems.ext_capab_len); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 488 | |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 489 | #ifdef CONFIG_HS20 |
| 490 | wpabuf_free(sta->hs20_ie); |
| 491 | if (elems.hs20 && elems.hs20_len > 4) { |
| 492 | sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4, |
| 493 | elems.hs20_len - 4); |
| 494 | } else |
| 495 | sta->hs20_ie = NULL; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 496 | |
| 497 | wpabuf_free(sta->roaming_consortium); |
| 498 | if (elems.roaming_cons_sel) |
| 499 | sta->roaming_consortium = wpabuf_alloc_copy( |
| 500 | elems.roaming_cons_sel + 4, |
| 501 | elems.roaming_cons_sel_len - 4); |
| 502 | else |
| 503 | sta->roaming_consortium = NULL; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 504 | #endif /* CONFIG_HS20 */ |
| 505 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 506 | #ifdef CONFIG_FST |
| 507 | wpabuf_free(sta->mb_ies); |
| 508 | if (hapd->iface->fst) |
| 509 | sta->mb_ies = mb_ies_by_info(&elems.mb_ies); |
| 510 | else |
| 511 | sta->mb_ies = NULL; |
| 512 | #endif /* CONFIG_FST */ |
| 513 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 514 | mbo_ap_check_sta_assoc(hapd, sta, &elems); |
| 515 | |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 516 | ap_copy_sta_supp_op_classes(sta, elems.supp_op_classes, |
| 517 | elems.supp_op_classes_len); |
| 518 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 519 | if (hapd->conf->wpa) { |
| 520 | if (ie == NULL || ielen == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 521 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 522 | if (hapd->conf->wps_state) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 523 | wpa_printf(MSG_DEBUG, |
| 524 | "STA did not include WPA/RSN IE in (Re)Association Request - possible WPS use"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 525 | sta->flags |= WLAN_STA_MAYBE_WPS; |
| 526 | goto skip_wpa_check; |
| 527 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 528 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 529 | |
| 530 | wpa_printf(MSG_DEBUG, "No WPA/RSN IE from STA"); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 531 | reason = WLAN_REASON_INVALID_IE; |
| 532 | status = WLAN_STATUS_INVALID_IE; |
| 533 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 534 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 535 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 536 | if (hapd->conf->wps_state && ie[0] == 0xdd && ie[1] >= 4 && |
| 537 | os_memcmp(ie + 2, "\x00\x50\xf2\x04", 4) == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 538 | struct wpabuf *wps; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 539 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 540 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 541 | wps = ieee802_11_vendor_ie_concat(ie, ielen, |
| 542 | WPS_IE_VENDOR_TYPE); |
| 543 | if (wps) { |
| 544 | if (wps_is_20(wps)) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 545 | wpa_printf(MSG_DEBUG, |
| 546 | "WPS: STA supports WPS 2.0"); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 547 | sta->flags |= WLAN_STA_WPS2; |
| 548 | } |
| 549 | wpabuf_free(wps); |
| 550 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 551 | goto skip_wpa_check; |
| 552 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 553 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 554 | |
| 555 | if (sta->wpa_sm == NULL) |
| 556 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 557 | sta->addr, |
| 558 | p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 559 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 560 | wpa_printf(MSG_ERROR, |
| 561 | "Failed to initialize WPA state machine"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 562 | return -1; |
| 563 | } |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 564 | wpa_auth_set_rsn_selection(sta->wpa_sm, elems.rsn_selection, |
| 565 | elems.rsn_selection_len); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 566 | #ifdef CONFIG_IEEE80211BE |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 567 | if (ap_sta_is_mld(hapd, sta)) { |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 568 | wpa_printf(MSG_DEBUG, |
| 569 | "MLD: Set ML info in RSN Authenticator"); |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 570 | wpa_auth_set_ml_info(sta->wpa_sm, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 571 | sta->mld_assoc_link_id, |
| 572 | &sta->mld_info); |
| 573 | } |
| 574 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 575 | res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 576 | hapd->iface->freq, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 577 | ie, ielen, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 578 | elems.rsnxe ? elems.rsnxe - 2 : NULL, |
| 579 | elems.rsnxe ? elems.rsnxe_len + 2 : 0, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 580 | elems.mdie, elems.mdie_len, |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 581 | elems.owe_dh, elems.owe_dh_len, NULL); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 582 | reason = WLAN_REASON_INVALID_IE; |
| 583 | status = WLAN_STATUS_INVALID_IE; |
| 584 | switch (res) { |
| 585 | case WPA_IE_OK: |
| 586 | reason = WLAN_REASON_UNSPECIFIED; |
| 587 | status = WLAN_STATUS_SUCCESS; |
| 588 | break; |
| 589 | case WPA_INVALID_IE: |
| 590 | reason = WLAN_REASON_INVALID_IE; |
| 591 | status = WLAN_STATUS_INVALID_IE; |
| 592 | break; |
| 593 | case WPA_INVALID_GROUP: |
| 594 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
| 595 | status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; |
| 596 | break; |
| 597 | case WPA_INVALID_PAIRWISE: |
| 598 | reason = WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID; |
| 599 | status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; |
| 600 | break; |
| 601 | case WPA_INVALID_AKMP: |
| 602 | reason = WLAN_REASON_AKMP_NOT_VALID; |
| 603 | status = WLAN_STATUS_AKMP_NOT_VALID; |
| 604 | break; |
| 605 | case WPA_NOT_ENABLED: |
| 606 | reason = WLAN_REASON_INVALID_IE; |
| 607 | status = WLAN_STATUS_INVALID_IE; |
| 608 | break; |
| 609 | case WPA_ALLOC_FAIL: |
| 610 | reason = WLAN_REASON_UNSPECIFIED; |
| 611 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 612 | break; |
| 613 | case WPA_MGMT_FRAME_PROTECTION_VIOLATION: |
| 614 | reason = WLAN_REASON_INVALID_IE; |
| 615 | status = WLAN_STATUS_INVALID_IE; |
| 616 | break; |
| 617 | case WPA_INVALID_MGMT_GROUP_CIPHER: |
| 618 | reason = WLAN_REASON_CIPHER_SUITE_REJECTED; |
| 619 | status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; |
| 620 | break; |
| 621 | case WPA_INVALID_MDIE: |
| 622 | reason = WLAN_REASON_INVALID_MDE; |
| 623 | status = WLAN_STATUS_INVALID_MDIE; |
| 624 | break; |
| 625 | case WPA_INVALID_PROTO: |
| 626 | reason = WLAN_REASON_INVALID_IE; |
| 627 | status = WLAN_STATUS_INVALID_IE; |
| 628 | break; |
| 629 | case WPA_INVALID_PMKID: |
| 630 | reason = WLAN_REASON_INVALID_PMKID; |
| 631 | status = WLAN_STATUS_INVALID_PMKID; |
| 632 | break; |
| 633 | case WPA_DENIED_OTHER_REASON: |
| 634 | reason = WLAN_REASON_UNSPECIFIED; |
| 635 | status = WLAN_STATUS_ASSOC_DENIED_UNSPEC; |
| 636 | break; |
| 637 | } |
| 638 | if (status != WLAN_STATUS_SUCCESS) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 639 | wpa_printf(MSG_DEBUG, |
| 640 | "WPA/RSN information element rejected? (res %u)", |
| 641 | res); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 642 | wpa_hexdump(MSG_DEBUG, "IE", ie, ielen); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 643 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 644 | } |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 645 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 646 | if (wpa_auth_uses_mfp(sta->wpa_sm)) |
| 647 | sta->flags |= WLAN_STA_MFP; |
| 648 | else |
| 649 | sta->flags &= ~WLAN_STA_MFP; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 650 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 651 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 652 | if (sta->auth_alg == WLAN_AUTH_FT) { |
| 653 | status = wpa_ft_validate_reassoc(sta->wpa_sm, req_ies, |
| 654 | req_ies_len); |
| 655 | if (status != WLAN_STATUS_SUCCESS) { |
| 656 | if (status == WLAN_STATUS_INVALID_PMKID) |
| 657 | reason = WLAN_REASON_INVALID_IE; |
| 658 | if (status == WLAN_STATUS_INVALID_MDIE) |
| 659 | reason = WLAN_REASON_INVALID_IE; |
| 660 | if (status == WLAN_STATUS_INVALID_FTIE) |
| 661 | reason = WLAN_REASON_INVALID_IE; |
| 662 | goto fail; |
| 663 | } |
| 664 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 665 | #endif /* CONFIG_IEEE80211R_AP */ |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 666 | #ifdef CONFIG_SAE |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 667 | if (hapd->conf->sae_pwe == SAE_PWE_BOTH && |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 668 | sta->auth_alg == WLAN_AUTH_SAE && |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 669 | sta->sae && !sta->sae->h2e && |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 670 | ieee802_11_rsnx_capab_len(elems.rsnxe, elems.rsnxe_len, |
| 671 | WLAN_RSNX_CAPAB_SAE_H2E)) { |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 672 | wpa_printf(MSG_INFO, "SAE: " MACSTR |
| 673 | " indicates support for SAE H2E, but did not use it", |
| 674 | MAC2STR(sta->addr)); |
| 675 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 676 | reason = WLAN_REASON_UNSPECIFIED; |
| 677 | goto fail; |
| 678 | } |
| 679 | #endif /* CONFIG_SAE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 680 | } else if (hapd->conf->wps_state) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 681 | #ifdef CONFIG_WPS |
| 682 | struct wpabuf *wps; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 683 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 684 | if (req_ies) |
| 685 | wps = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 686 | WPS_IE_VENDOR_TYPE); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 687 | else |
| 688 | wps = NULL; |
| 689 | #ifdef CONFIG_WPS_STRICT |
| 690 | if (wps && wps_validate_assoc_req(wps) < 0) { |
| 691 | reason = WLAN_REASON_INVALID_IE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 692 | status = WLAN_STATUS_INVALID_IE; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 693 | wpabuf_free(wps); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 694 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 695 | } |
| 696 | #endif /* CONFIG_WPS_STRICT */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 697 | if (wps) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 698 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 699 | if (wps_is_20(wps)) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 700 | wpa_printf(MSG_DEBUG, |
| 701 | "WPS: STA supports WPS 2.0"); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 702 | sta->flags |= WLAN_STA_WPS2; |
| 703 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 704 | } else |
| 705 | sta->flags |= WLAN_STA_MAYBE_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 706 | wpabuf_free(wps); |
| 707 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 708 | #ifdef CONFIG_HS20 |
| 709 | } else if (hapd->conf->osen) { |
| 710 | if (elems.osen == NULL) { |
| 711 | hostapd_logger( |
| 712 | hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 713 | HOSTAPD_LEVEL_INFO, |
| 714 | "No HS 2.0 OSEN element in association request"); |
| 715 | return WLAN_STATUS_INVALID_IE; |
| 716 | } |
| 717 | |
| 718 | wpa_printf(MSG_DEBUG, "HS 2.0: OSEN association"); |
| 719 | if (sta->wpa_sm == NULL) |
| 720 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
| 721 | sta->addr, NULL); |
| 722 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 723 | wpa_printf(MSG_WARNING, |
| 724 | "Failed to initialize WPA state machine"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 725 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 726 | } |
| 727 | if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm, |
| 728 | elems.osen - 2, elems.osen_len + 2) < 0) |
| 729 | return WLAN_STATUS_INVALID_IE; |
| 730 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 731 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 732 | #ifdef CONFIG_WPS |
| 733 | skip_wpa_check: |
| 734 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 735 | |
| 736 | #ifdef CONFIG_MBO |
| 737 | if (hapd->conf->mbo_enabled && (hapd->conf->wpa & 2) && |
| 738 | elems.mbo && sta->cell_capa && !(sta->flags & WLAN_STA_MFP) && |
| 739 | hapd->conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) { |
| 740 | wpa_printf(MSG_INFO, |
| 741 | "MBO: Reject WPA2 association without PMF"); |
| 742 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 743 | } |
| 744 | #endif /* CONFIG_MBO */ |
| 745 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 746 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 747 | p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, buf, sizeof(buf), |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 748 | sta->auth_alg, req_ies, req_ies_len, |
| 749 | !elems.rsnxe); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 750 | if (!p) { |
| 751 | wpa_printf(MSG_DEBUG, "FT: Failed to write AssocResp IEs"); |
| 752 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 753 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 754 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 755 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 756 | #ifdef CONFIG_FILS |
| 757 | if (sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 758 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 759 | sta->auth_alg == WLAN_AUTH_FILS_PK) { |
| 760 | int delay_assoc = 0; |
| 761 | |
| 762 | if (!req_ies) |
| 763 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 764 | |
| 765 | if (!wpa_fils_validate_fils_session(sta->wpa_sm, req_ies, |
| 766 | req_ies_len, |
| 767 | sta->fils_session)) { |
| 768 | wpa_printf(MSG_DEBUG, |
| 769 | "FILS: Session validation failed"); |
| 770 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 771 | } |
| 772 | |
| 773 | res = wpa_fils_validate_key_confirm(sta->wpa_sm, req_ies, |
| 774 | req_ies_len); |
| 775 | if (res < 0) { |
| 776 | wpa_printf(MSG_DEBUG, |
| 777 | "FILS: Key Confirm validation failed"); |
| 778 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 779 | } |
| 780 | |
| 781 | if (fils_process_hlp(hapd, sta, req_ies, req_ies_len) > 0) { |
| 782 | wpa_printf(MSG_DEBUG, |
| 783 | "FILS: Delaying Assoc Response (HLP)"); |
| 784 | delay_assoc = 1; |
| 785 | } else { |
| 786 | wpa_printf(MSG_DEBUG, |
| 787 | "FILS: Going ahead with Assoc Response (no HLP)"); |
| 788 | } |
| 789 | |
| 790 | if (sta) { |
| 791 | wpa_printf(MSG_DEBUG, "FILS: HLP callback cleanup"); |
| 792 | eloop_cancel_timeout(fils_hlp_timeout, hapd, sta); |
| 793 | os_free(sta->fils_pending_assoc_req); |
| 794 | sta->fils_pending_assoc_req = NULL; |
| 795 | sta->fils_pending_assoc_req_len = 0; |
| 796 | wpabuf_free(sta->fils_hlp_resp); |
| 797 | sta->fils_hlp_resp = NULL; |
| 798 | sta->fils_drv_assoc_finish = 0; |
| 799 | } |
| 800 | |
| 801 | if (sta && delay_assoc && status == WLAN_STATUS_SUCCESS) { |
| 802 | u8 *req_tmp; |
| 803 | |
| 804 | req_tmp = os_malloc(req_ies_len); |
| 805 | if (!req_tmp) { |
| 806 | wpa_printf(MSG_DEBUG, |
| 807 | "FILS: buffer allocation failed for assoc req"); |
| 808 | goto fail; |
| 809 | } |
| 810 | os_memcpy(req_tmp, req_ies, req_ies_len); |
| 811 | sta->fils_pending_assoc_req = req_tmp; |
| 812 | sta->fils_pending_assoc_req_len = req_ies_len; |
| 813 | sta->fils_pending_assoc_is_reassoc = reassoc; |
| 814 | sta->fils_drv_assoc_finish = 1; |
| 815 | wpa_printf(MSG_DEBUG, |
| 816 | "FILS: Waiting for HLP processing before sending (Re)Association Response frame to " |
| 817 | MACSTR, MAC2STR(sta->addr)); |
| 818 | eloop_register_timeout( |
| 819 | 0, hapd->conf->fils_hlp_wait_time * 1024, |
| 820 | fils_hlp_timeout, hapd, sta); |
| 821 | return 0; |
| 822 | } |
| 823 | p = hostapd_eid_assoc_fils_session(sta->wpa_sm, p, |
| 824 | elems.fils_session, |
| 825 | sta->fils_hlp_resp); |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 826 | if (!p) |
| 827 | goto fail; |
| 828 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 829 | wpa_hexdump(MSG_DEBUG, "FILS Assoc Resp BUF (IEs)", |
| 830 | buf, p - buf); |
| 831 | } |
| 832 | #endif /* CONFIG_FILS */ |
| 833 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 834 | #ifdef CONFIG_OWE |
| 835 | if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) && |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 836 | !(iface->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_AP) && |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 837 | wpa_auth_sta_key_mgmt(sta->wpa_sm) == WPA_KEY_MGMT_OWE && |
| 838 | elems.owe_dh) { |
| 839 | u8 *npos; |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 840 | u16 ret_status; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 841 | |
| 842 | npos = owe_assoc_req_process(hapd, sta, |
| 843 | elems.owe_dh, elems.owe_dh_len, |
| 844 | p, sizeof(buf) - (p - buf), |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 845 | &ret_status); |
| 846 | status = ret_status; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 847 | if (npos) |
| 848 | p = npos; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 849 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 850 | if (!npos && |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 851 | status == WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED) { |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 852 | hostapd_sta_assoc(hapd, addr, reassoc, ret_status, buf, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 853 | p - buf); |
| 854 | return 0; |
| 855 | } |
| 856 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 857 | if (!npos || status != WLAN_STATUS_SUCCESS) |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 858 | goto fail; |
| 859 | } |
| 860 | #endif /* CONFIG_OWE */ |
| 861 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 862 | #ifdef CONFIG_DPP2 |
| 863 | dpp_pfs_free(sta->dpp_pfs); |
| 864 | sta->dpp_pfs = NULL; |
| 865 | |
| 866 | if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_DPP) && |
| 867 | hapd->conf->dpp_netaccesskey && sta->wpa_sm && |
| 868 | wpa_auth_sta_key_mgmt(sta->wpa_sm) == WPA_KEY_MGMT_DPP && |
| 869 | elems.owe_dh) { |
| 870 | sta->dpp_pfs = dpp_pfs_init( |
| 871 | wpabuf_head(hapd->conf->dpp_netaccesskey), |
| 872 | wpabuf_len(hapd->conf->dpp_netaccesskey)); |
| 873 | if (!sta->dpp_pfs) { |
| 874 | wpa_printf(MSG_DEBUG, |
| 875 | "DPP: Could not initialize PFS"); |
| 876 | /* Try to continue without PFS */ |
| 877 | goto pfs_fail; |
| 878 | } |
| 879 | |
| 880 | if (dpp_pfs_process(sta->dpp_pfs, elems.owe_dh, |
| 881 | elems.owe_dh_len) < 0) { |
| 882 | dpp_pfs_free(sta->dpp_pfs); |
| 883 | sta->dpp_pfs = NULL; |
| 884 | reason = WLAN_REASON_UNSPECIFIED; |
| 885 | goto fail; |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | wpa_auth_set_dpp_z(sta->wpa_sm, sta->dpp_pfs ? |
| 890 | sta->dpp_pfs->secret : NULL); |
| 891 | pfs_fail: |
| 892 | #endif /* CONFIG_DPP2 */ |
| 893 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 894 | if (elems.rrm_enabled && |
| 895 | elems.rrm_enabled_len >= sizeof(sta->rrm_enabled_capa)) |
| 896 | os_memcpy(sta->rrm_enabled_capa, elems.rrm_enabled, |
| 897 | sizeof(sta->rrm_enabled_capa)); |
| 898 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 899 | #if defined(CONFIG_IEEE80211R_AP) || defined(CONFIG_FILS) || defined(CONFIG_OWE) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 900 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 901 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 902 | if (sta->auth_alg == WLAN_AUTH_FT || |
| 903 | sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 904 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 905 | sta->auth_alg == WLAN_AUTH_FILS_PK) |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 906 | updated = ap_sta_set_authorized_flag(hapd, sta, 1); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 907 | #else /* CONFIG_IEEE80211R_AP || CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 908 | /* Keep compiler silent about unused variables */ |
| 909 | if (status) { |
| 910 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 911 | #endif /* CONFIG_IEEE80211R_AP || CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 912 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 913 | #ifdef CONFIG_IEEE80211BE |
| 914 | if (hostapd_process_assoc_ml_info(hapd, sta, req_ies, req_ies_len, |
| 915 | !!reassoc, WLAN_STATUS_SUCCESS, |
| 916 | true)) { |
| 917 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 918 | reason = WLAN_REASON_UNSPECIFIED; |
| 919 | goto fail; |
| 920 | } |
| 921 | #endif /* CONFIG_IEEE80211BE */ |
| 922 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 923 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; |
| 924 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 925 | sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 926 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 927 | hostapd_set_sta_flags(hapd, sta); |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 928 | if (updated) |
| 929 | ap_sta_set_authorized_event(hapd, sta, 1); |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 930 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 931 | if (reassoc && (sta->auth_alg == WLAN_AUTH_FT)) |
| 932 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 933 | #ifdef CONFIG_FILS |
| 934 | else if (sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 935 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 936 | sta->auth_alg == WLAN_AUTH_FILS_PK) |
| 937 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FILS); |
| 938 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 939 | else |
| 940 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 941 | |
| 942 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); |
| 943 | |
| 944 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); |
| 945 | |
| 946 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 947 | if (req_ies) { |
| 948 | p2p_group_notif_assoc(hapd->p2p_group, sta->addr, |
| 949 | req_ies, req_ies_len); |
| 950 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 951 | #endif /* CONFIG_P2P */ |
| 952 | |
| 953 | return 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 954 | |
| 955 | fail: |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 956 | #ifdef CONFIG_IEEE80211R_AP |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 957 | if (status >= 0) |
| 958 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 959 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 960 | hostapd_drv_sta_disassoc(hapd, sta->addr, reason); |
| 961 | ap_free_sta(hapd, sta); |
| 962 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 966 | static void hostapd_remove_sta(struct hostapd_data *hapd, struct sta_info *sta) |
| 967 | { |
| 968 | ap_sta_set_authorized(hapd, sta, 0); |
| 969 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
| 970 | hostapd_set_sta_flags(hapd, sta); |
| 971 | wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC); |
| 972 | sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST; |
| 973 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
| 974 | ap_free_sta(hapd, sta); |
| 975 | } |
| 976 | |
| 977 | |
| 978 | #ifdef CONFIG_IEEE80211BE |
| 979 | static void hostapd_notif_disassoc_mld(struct hostapd_data *assoc_hapd, |
| 980 | struct sta_info *sta, |
| 981 | const u8 *addr) |
| 982 | { |
| 983 | unsigned int link_id, i; |
| 984 | struct hostapd_data *tmp_hapd; |
| 985 | struct hapd_interfaces *interfaces = assoc_hapd->iface->interfaces; |
| 986 | |
| 987 | /* Remove STA entry in non-assoc links */ |
| 988 | for (link_id = 0; link_id < MAX_NUM_MLD_LINKS; link_id++) { |
| 989 | if (!sta->mld_info.links[link_id].valid) |
| 990 | continue; |
| 991 | |
| 992 | for (i = 0; i < interfaces->count; i++) { |
| 993 | struct sta_info *tmp_sta; |
| 994 | |
| 995 | tmp_hapd = interfaces->iface[i]->bss[0]; |
| 996 | |
| 997 | if (!tmp_hapd->conf->mld_ap || |
| 998 | assoc_hapd == tmp_hapd || |
| 999 | assoc_hapd->conf->mld_id != tmp_hapd->conf->mld_id) |
| 1000 | continue; |
| 1001 | |
| 1002 | tmp_sta = ap_get_sta(tmp_hapd, addr); |
| 1003 | if (tmp_sta) |
| 1004 | ap_free_sta(tmp_hapd, tmp_sta); |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | /* Remove STA in assoc link */ |
| 1009 | hostapd_remove_sta(assoc_hapd, sta); |
| 1010 | } |
| 1011 | #endif /* CONFIG_IEEE80211BE */ |
| 1012 | |
| 1013 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1014 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr) |
| 1015 | { |
| 1016 | struct sta_info *sta; |
| 1017 | |
| 1018 | if (addr == NULL) { |
| 1019 | /* |
| 1020 | * This could potentially happen with unexpected event from the |
| 1021 | * driver wrapper. This was seen at least in one case where the |
| 1022 | * driver ended up reporting a station mode event while hostapd |
| 1023 | * was running, so better make sure we stop processing such an |
| 1024 | * event here. |
| 1025 | */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1026 | wpa_printf(MSG_DEBUG, |
| 1027 | "hostapd_notif_disassoc: Skip event with no address"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 1032 | HOSTAPD_LEVEL_INFO, "disassociated"); |
| 1033 | |
| 1034 | sta = ap_get_sta(hapd, addr); |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1035 | #ifdef CONFIG_IEEE80211BE |
| 1036 | if (hostapd_is_mld_ap(hapd)) { |
| 1037 | struct hostapd_data *assoc_hapd; |
| 1038 | unsigned int i; |
| 1039 | |
| 1040 | if (!sta) { |
| 1041 | /* Find non-MLO cases from any of the affiliated AP |
| 1042 | * links. */ |
| 1043 | for (i = 0; i < hapd->iface->interfaces->count; ++i) { |
| 1044 | struct hostapd_iface *h = |
| 1045 | hapd->iface->interfaces->iface[i]; |
| 1046 | struct hostapd_data *h_hapd = h->bss[0]; |
| 1047 | struct hostapd_bss_config *hconf = h_hapd->conf; |
| 1048 | |
| 1049 | if (!hconf->mld_ap || |
| 1050 | hconf->mld_id != hapd->conf->mld_id) |
| 1051 | continue; |
| 1052 | |
| 1053 | sta = ap_get_sta(h_hapd, addr); |
| 1054 | if (sta) { |
| 1055 | if (!sta->mld_info.mld_sta) { |
| 1056 | hapd = h_hapd; |
| 1057 | goto legacy; |
| 1058 | } |
| 1059 | break; |
| 1060 | } |
| 1061 | } |
| 1062 | } else if (!sta->mld_info.mld_sta) { |
| 1063 | goto legacy; |
| 1064 | } |
| 1065 | if (!sta) { |
| 1066 | wpa_printf(MSG_DEBUG, |
| 1067 | "Disassociation notification for unknown STA " |
| 1068 | MACSTR, MAC2STR(addr)); |
| 1069 | return; |
| 1070 | } |
| 1071 | sta = hostapd_ml_get_assoc_sta(hapd, sta, &assoc_hapd); |
| 1072 | if (sta) |
| 1073 | hostapd_notif_disassoc_mld(assoc_hapd, sta, addr); |
| 1074 | return; |
| 1075 | } |
| 1076 | |
| 1077 | legacy: |
| 1078 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1079 | if (sta == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1080 | wpa_printf(MSG_DEBUG, |
| 1081 | "Disassociation notification for unknown STA " |
| 1082 | MACSTR, MAC2STR(addr)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1083 | return; |
| 1084 | } |
| 1085 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1086 | hostapd_remove_sta(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1087 | } |
| 1088 | |
| 1089 | |
| 1090 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr) |
| 1091 | { |
| 1092 | struct sta_info *sta = ap_get_sta(hapd, addr); |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 1093 | #ifdef CONFIG_IEEE80211BE |
| 1094 | struct hostapd_data *orig_hapd = hapd; |
| 1095 | |
| 1096 | if (!sta && hapd->conf->mld_ap) { |
| 1097 | hapd = hostapd_find_by_sta(hapd->iface, addr, true, &sta); |
| 1098 | if (!hapd) { |
| 1099 | wpa_printf(MSG_DEBUG, |
| 1100 | "No partner link BSS found for STA " MACSTR |
| 1101 | " - fallback to received context", |
| 1102 | MAC2STR(addr)); |
| 1103 | hapd = orig_hapd; |
| 1104 | } |
| 1105 | } |
| 1106 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1107 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1108 | if (!sta || !hapd->conf->disassoc_low_ack || sta->agreed_to_steer) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1109 | return; |
| 1110 | |
| 1111 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1112 | HOSTAPD_LEVEL_INFO, |
| 1113 | "disconnected due to excessive missing ACKs"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1114 | hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_LOW_ACK); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1115 | ap_sta_disassociate(hapd, sta, WLAN_REASON_DISASSOC_LOW_ACK); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1119 | void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr, |
| 1120 | enum smps_mode smps_mode, |
| 1121 | enum chan_width chan_width, u8 rx_nss) |
| 1122 | { |
| 1123 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 1124 | const char *txt; |
| 1125 | |
| 1126 | if (!sta) |
| 1127 | return; |
| 1128 | |
| 1129 | switch (smps_mode) { |
| 1130 | case SMPS_AUTOMATIC: |
| 1131 | txt = "automatic"; |
| 1132 | break; |
| 1133 | case SMPS_OFF: |
| 1134 | txt = "off"; |
| 1135 | break; |
| 1136 | case SMPS_DYNAMIC: |
| 1137 | txt = "dynamic"; |
| 1138 | break; |
| 1139 | case SMPS_STATIC: |
| 1140 | txt = "static"; |
| 1141 | break; |
| 1142 | default: |
| 1143 | txt = NULL; |
| 1144 | break; |
| 1145 | } |
| 1146 | if (txt) { |
| 1147 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_SMPS_MODE_CHANGED |
| 1148 | MACSTR " %s", MAC2STR(addr), txt); |
| 1149 | } |
| 1150 | |
| 1151 | switch (chan_width) { |
| 1152 | case CHAN_WIDTH_20_NOHT: |
| 1153 | txt = "20(no-HT)"; |
| 1154 | break; |
| 1155 | case CHAN_WIDTH_20: |
| 1156 | txt = "20"; |
| 1157 | break; |
| 1158 | case CHAN_WIDTH_40: |
| 1159 | txt = "40"; |
| 1160 | break; |
| 1161 | case CHAN_WIDTH_80: |
| 1162 | txt = "80"; |
| 1163 | break; |
| 1164 | case CHAN_WIDTH_80P80: |
| 1165 | txt = "80+80"; |
| 1166 | break; |
| 1167 | case CHAN_WIDTH_160: |
| 1168 | txt = "160"; |
| 1169 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1170 | case CHAN_WIDTH_320: |
| 1171 | txt = "320"; |
| 1172 | break; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1173 | default: |
| 1174 | txt = NULL; |
| 1175 | break; |
| 1176 | } |
| 1177 | if (txt) { |
| 1178 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_MAX_BW_CHANGED |
| 1179 | MACSTR " %s", MAC2STR(addr), txt); |
| 1180 | } |
| 1181 | |
| 1182 | if (rx_nss != 0xff) { |
| 1183 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_N_SS_CHANGED |
| 1184 | MACSTR " %d", MAC2STR(addr), rx_nss); |
| 1185 | } |
| 1186 | } |
| 1187 | |
| 1188 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1189 | void hostapd_event_ch_switch(struct hostapd_data *hapd, int freq, int ht, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1190 | int offset, int width, int cf1, int cf2, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1191 | u16 punct_bitmap, int finished) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1192 | { |
| 1193 | #ifdef NEED_AP_MLME |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1194 | int channel, chwidth, is_dfs0, is_dfs; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1195 | u8 seg0_idx = 0, seg1_idx = 0, op_class, chan_no; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1196 | size_t i; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1197 | |
| 1198 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1199 | HOSTAPD_LEVEL_INFO, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1200 | "driver %s channel switch: iface->freq=%d, freq=%d, ht=%d, vht_ch=0x%x, he_ch=0x%x, eht_ch=0x%x, offset=%d, width=%d (%s), cf1=%d, cf2=%d, puncturing_bitmap=0x%x", |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1201 | finished ? "had" : "starting", |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1202 | hapd->iface->freq, |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1203 | freq, ht, hapd->iconf->ch_switch_vht_config, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1204 | hapd->iconf->ch_switch_he_config, |
| 1205 | hapd->iconf->ch_switch_eht_config, offset, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1206 | width, channel_width_to_string(width), cf1, cf2, |
| 1207 | punct_bitmap); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1208 | |
Hai Shalom | 1dc4d20 | 2019-04-29 16:22:27 -0700 | [diff] [blame] | 1209 | if (!hapd->iface->current_mode) { |
| 1210 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 1211 | HOSTAPD_LEVEL_WARNING, |
| 1212 | "ignore channel switch since the interface is not yet ready"); |
| 1213 | return; |
| 1214 | } |
| 1215 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1216 | /* Check if any of configured channels require DFS */ |
| 1217 | is_dfs0 = hostapd_is_dfs_required(hapd->iface); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1218 | hapd->iface->freq = freq; |
| 1219 | |
| 1220 | channel = hostapd_hw_get_channel(hapd, freq); |
| 1221 | if (!channel) { |
| 1222 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1223 | HOSTAPD_LEVEL_WARNING, |
| 1224 | "driver switched to bad channel!"); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1225 | return; |
| 1226 | } |
| 1227 | |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1228 | switch (width) { |
| 1229 | case CHAN_WIDTH_80: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1230 | chwidth = CONF_OPER_CHWIDTH_80MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1231 | break; |
| 1232 | case CHAN_WIDTH_80P80: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1233 | chwidth = CONF_OPER_CHWIDTH_80P80MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1234 | break; |
| 1235 | case CHAN_WIDTH_160: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1236 | chwidth = CONF_OPER_CHWIDTH_160MHZ; |
| 1237 | break; |
| 1238 | case CHAN_WIDTH_320: |
| 1239 | chwidth = CONF_OPER_CHWIDTH_320MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1240 | break; |
| 1241 | case CHAN_WIDTH_20_NOHT: |
| 1242 | case CHAN_WIDTH_20: |
| 1243 | case CHAN_WIDTH_40: |
| 1244 | default: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1245 | chwidth = CONF_OPER_CHWIDTH_USE_HT; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1246 | break; |
| 1247 | } |
| 1248 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1249 | /* The operating channel changed when CSA finished, so need to update |
| 1250 | * hw_mode for all following operations to cover the cases where the |
| 1251 | * driver changed the operating band. */ |
| 1252 | if (finished && hostapd_csa_update_hwmode(hapd->iface)) |
| 1253 | return; |
| 1254 | |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1255 | switch (hapd->iface->current_mode->mode) { |
| 1256 | case HOSTAPD_MODE_IEEE80211A: |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1257 | if (cf1 == 5935) |
| 1258 | seg0_idx = (cf1 - 5925) / 5; |
| 1259 | else if (cf1 > 5950) |
| 1260 | seg0_idx = (cf1 - 5950) / 5; |
| 1261 | else if (cf1 > 5000) |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1262 | seg0_idx = (cf1 - 5000) / 5; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1263 | |
| 1264 | if (cf2 == 5935) |
| 1265 | seg1_idx = (cf2 - 5925) / 5; |
| 1266 | else if (cf2 > 5950) |
| 1267 | seg1_idx = (cf2 - 5950) / 5; |
| 1268 | else if (cf2 > 5000) |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1269 | seg1_idx = (cf2 - 5000) / 5; |
| 1270 | break; |
| 1271 | default: |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1272 | ieee80211_freq_to_chan(cf1, &seg0_idx); |
| 1273 | ieee80211_freq_to_chan(cf2, &seg1_idx); |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 1274 | break; |
| 1275 | } |
| 1276 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1277 | hapd->iconf->channel = channel; |
| 1278 | hapd->iconf->ieee80211n = ht; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1279 | if (!ht) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1280 | hapd->iconf->ieee80211ac = 0; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1281 | if (hapd->iconf->ch_switch_vht_config) { |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1282 | /* CHAN_SWITCH VHT config */ |
| 1283 | if (hapd->iconf->ch_switch_vht_config & |
| 1284 | CH_SWITCH_VHT_ENABLED) |
| 1285 | hapd->iconf->ieee80211ac = 1; |
| 1286 | else if (hapd->iconf->ch_switch_vht_config & |
| 1287 | CH_SWITCH_VHT_DISABLED) |
| 1288 | hapd->iconf->ieee80211ac = 0; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1289 | } |
| 1290 | if (hapd->iconf->ch_switch_he_config) { |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1291 | /* CHAN_SWITCH HE config */ |
| 1292 | if (hapd->iconf->ch_switch_he_config & |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1293 | CH_SWITCH_HE_ENABLED) { |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1294 | hapd->iconf->ieee80211ax = 1; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1295 | if (hapd->iface->freq > 4000 && |
| 1296 | hapd->iface->freq < 5895) |
| 1297 | hapd->iconf->ieee80211ac = 1; |
| 1298 | } |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1299 | else if (hapd->iconf->ch_switch_he_config & |
| 1300 | CH_SWITCH_HE_DISABLED) |
| 1301 | hapd->iconf->ieee80211ax = 0; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1302 | } |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1303 | #ifdef CONFIG_IEEE80211BE |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1304 | if (hapd->iconf->ch_switch_eht_config) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1305 | /* CHAN_SWITCH EHT config */ |
| 1306 | if (hapd->iconf->ch_switch_eht_config & |
| 1307 | CH_SWITCH_EHT_ENABLED) { |
| 1308 | hapd->iconf->ieee80211be = 1; |
| 1309 | hapd->iconf->ieee80211ax = 1; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1310 | if (!is_6ghz_freq(hapd->iface->freq) && |
| 1311 | hapd->iface->freq > 4000) |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1312 | hapd->iconf->ieee80211ac = 1; |
| 1313 | } else if (hapd->iconf->ch_switch_eht_config & |
| 1314 | CH_SWITCH_EHT_DISABLED) |
| 1315 | hapd->iconf->ieee80211be = 0; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1316 | } |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1317 | #endif /* CONFIG_IEEE80211BE */ |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1318 | hapd->iconf->ch_switch_vht_config = 0; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1319 | hapd->iconf->ch_switch_he_config = 0; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1320 | hapd->iconf->ch_switch_eht_config = 0; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1321 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1322 | if (width == CHAN_WIDTH_40 || width == CHAN_WIDTH_80 || |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame] | 1323 | width == CHAN_WIDTH_80P80 || width == CHAN_WIDTH_160 || |
| 1324 | width == CHAN_WIDTH_320) |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1325 | hapd->iconf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 1326 | else if (width == CHAN_WIDTH_20 || width == CHAN_WIDTH_20_NOHT) |
| 1327 | hapd->iconf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 1328 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1329 | hapd->iconf->secondary_channel = offset; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1330 | if (ieee80211_freq_to_channel_ext(freq, offset, chwidth, |
| 1331 | &op_class, &chan_no) != |
| 1332 | NUM_HOSTAPD_MODES) |
| 1333 | hapd->iconf->op_class = op_class; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1334 | hostapd_set_oper_chwidth(hapd->iconf, chwidth); |
| 1335 | hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, seg0_idx); |
| 1336 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, seg1_idx); |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1337 | /* Auto-detect new bw320_offset */ |
| 1338 | hostapd_set_and_check_bw320_offset(hapd->iconf, 0); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1339 | #ifdef CONFIG_IEEE80211BE |
| 1340 | hapd->iconf->punct_bitmap = punct_bitmap; |
| 1341 | #endif /* CONFIG_IEEE80211BE */ |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1342 | if (hapd->iconf->ieee80211ac) { |
| 1343 | hapd->iconf->vht_capab &= ~VHT_CAP_SUPP_CHAN_WIDTH_MASK; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1344 | if (chwidth == CONF_OPER_CHWIDTH_160MHZ) |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1345 | hapd->iconf->vht_capab |= |
| 1346 | VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1347 | else if (chwidth == CONF_OPER_CHWIDTH_80P80MHZ) |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1348 | hapd->iconf->vht_capab |= |
| 1349 | VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
| 1350 | } |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1351 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1352 | is_dfs = ieee80211_is_dfs(freq, hapd->iface->hw_features, |
| 1353 | hapd->iface->num_hw_features); |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1354 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1355 | wpa_msg(hapd->msg_ctx, MSG_INFO, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1356 | "%sfreq=%d ht_enabled=%d ch_offset=%d ch_width=%s cf1=%d cf2=%d is_dfs0=%d dfs=%d puncturing_bitmap=0x%04x", |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1357 | finished ? WPA_EVENT_CHANNEL_SWITCH : |
| 1358 | WPA_EVENT_CHANNEL_SWITCH_STARTED, |
| 1359 | freq, ht, offset, channel_width_to_string(width), |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1360 | cf1, cf2, is_dfs0, is_dfs, punct_bitmap); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1361 | if (!finished) |
| 1362 | return; |
| 1363 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1364 | if (hapd->csa_in_progress && |
| 1365 | freq == hapd->cs_freq_params.freq) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1366 | hostapd_cleanup_cs_params(hapd); |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1367 | ieee802_11_set_beacon(hapd); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1368 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1369 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED |
| 1370 | "freq=%d dfs=%d", freq, is_dfs); |
| 1371 | } else if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) { |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1372 | /* Complete AP configuration for the first bring up. */ |
| 1373 | if (is_dfs0 > 0 && |
| 1374 | hostapd_is_dfs_required(hapd->iface) <= 0 && |
| 1375 | hapd->iface->state != HAPD_IFACE_ENABLED) { |
| 1376 | /* Fake a CAC start bit to skip setting channel */ |
| 1377 | hapd->iface->cac_started = 1; |
| 1378 | hostapd_setup_interface_complete(hapd->iface, 0); |
| 1379 | } |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1380 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED |
| 1381 | "freq=%d dfs=%d", freq, is_dfs); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1382 | } else if (is_dfs && |
| 1383 | hostapd_is_dfs_required(hapd->iface) && |
| 1384 | !hostapd_is_dfs_chan_available(hapd->iface) && |
| 1385 | !hapd->iface->cac_started) { |
| 1386 | hostapd_disable_iface(hapd->iface); |
| 1387 | hostapd_enable_iface(hapd->iface); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1388 | } |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1389 | |
| 1390 | for (i = 0; i < hapd->iface->num_bss; i++) |
| 1391 | hostapd_neighbor_set_own_report(hapd->iface->bss[i]); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1392 | |
| 1393 | #ifdef CONFIG_OCV |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1394 | if (hapd->conf->ocv && |
| 1395 | !(hapd->iface->drv_flags2 & |
| 1396 | WPA_DRIVER_FLAGS2_SA_QUERY_OFFLOAD_AP)) { |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1397 | struct sta_info *sta; |
| 1398 | bool check_sa_query = false; |
| 1399 | |
| 1400 | for (sta = hapd->sta_list; sta; sta = sta->next) { |
| 1401 | if (wpa_auth_uses_ocv(sta->wpa_sm) && |
| 1402 | !(sta->flags & WLAN_STA_WNM_SLEEP_MODE)) { |
| 1403 | sta->post_csa_sa_query = 1; |
| 1404 | check_sa_query = true; |
| 1405 | } |
| 1406 | } |
| 1407 | |
| 1408 | if (check_sa_query) { |
| 1409 | wpa_printf(MSG_DEBUG, |
| 1410 | "OCV: Check post-CSA SA Query initiation in 15 seconds"); |
| 1411 | eloop_register_timeout(15, 0, |
| 1412 | hostapd_ocv_check_csa_sa_query, |
| 1413 | hapd, NULL); |
| 1414 | } |
| 1415 | } |
| 1416 | #endif /* CONFIG_OCV */ |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1417 | #endif /* NEED_AP_MLME */ |
| 1418 | } |
| 1419 | |
| 1420 | |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 1421 | void hostapd_event_connect_failed_reason(struct hostapd_data *hapd, |
| 1422 | const u8 *addr, int reason_code) |
| 1423 | { |
| 1424 | switch (reason_code) { |
| 1425 | case MAX_CLIENT_REACHED: |
| 1426 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_MAX_STA MACSTR, |
| 1427 | MAC2STR(addr)); |
| 1428 | break; |
| 1429 | case BLOCKED_CLIENT: |
| 1430 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_BLOCKED_STA MACSTR, |
| 1431 | MAC2STR(addr)); |
| 1432 | break; |
| 1433 | } |
| 1434 | } |
| 1435 | |
| 1436 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1437 | #ifdef CONFIG_ACS |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 1438 | void hostapd_acs_channel_selected(struct hostapd_data *hapd, |
| 1439 | struct acs_selected_channels *acs_res) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1440 | { |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1441 | int ret, i; |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1442 | int err = 0; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1443 | struct hostapd_channel_data *pri_chan; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1444 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1445 | #ifdef CONFIG_IEEE80211BE |
| 1446 | if (acs_res->link_id != -1) { |
| 1447 | hapd = hostapd_mld_get_link_bss(hapd, acs_res->link_id); |
| 1448 | if (!hapd) { |
| 1449 | wpa_printf(MSG_ERROR, |
| 1450 | "MLD: Failed to get link BSS for EVENT_ACS_CHANNEL_SELECTED link_id=%d", |
| 1451 | acs_res->link_id); |
| 1452 | return; |
| 1453 | } |
| 1454 | } |
| 1455 | #endif /* CONFIG_IEEE80211BE */ |
| 1456 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1457 | if (hapd->iconf->channel) { |
| 1458 | wpa_printf(MSG_INFO, "ACS: Channel was already set to %d", |
| 1459 | hapd->iconf->channel); |
| 1460 | return; |
| 1461 | } |
| 1462 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1463 | hapd->iface->freq = acs_res->pri_freq; |
| 1464 | |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1465 | if (!hapd->iface->current_mode) { |
| 1466 | for (i = 0; i < hapd->iface->num_hw_features; i++) { |
| 1467 | struct hostapd_hw_modes *mode = |
| 1468 | &hapd->iface->hw_features[i]; |
| 1469 | |
| 1470 | if (mode->mode == acs_res->hw_mode) { |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1471 | if (hapd->iface->freq > 0 && |
| 1472 | !hw_get_chan(mode->mode, |
| 1473 | hapd->iface->freq, |
| 1474 | hapd->iface->hw_features, |
| 1475 | hapd->iface->num_hw_features)) |
| 1476 | continue; |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1477 | hapd->iface->current_mode = mode; |
| 1478 | break; |
| 1479 | } |
| 1480 | } |
| 1481 | if (!hapd->iface->current_mode) { |
| 1482 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 1483 | HOSTAPD_LEVEL_WARNING, |
| 1484 | "driver selected to bad hw_mode"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1485 | err = 1; |
| 1486 | goto out; |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1487 | } |
| 1488 | } |
| 1489 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1490 | if (!acs_res->pri_freq) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1491 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 1492 | HOSTAPD_LEVEL_WARNING, |
| 1493 | "driver switched to bad channel"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1494 | err = 1; |
| 1495 | goto out; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1496 | } |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1497 | pri_chan = hw_get_channel_freq(hapd->iface->current_mode->mode, |
| 1498 | acs_res->pri_freq, NULL, |
| 1499 | hapd->iface->hw_features, |
| 1500 | hapd->iface->num_hw_features); |
| 1501 | if (!pri_chan) { |
| 1502 | wpa_printf(MSG_ERROR, |
| 1503 | "ACS: Could not determine primary channel number from pri_freq %u", |
| 1504 | acs_res->pri_freq); |
| 1505 | err = 1; |
| 1506 | goto out; |
| 1507 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1508 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1509 | hapd->iconf->channel = pri_chan->chan; |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1510 | hapd->iconf->acs = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1511 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1512 | if (acs_res->sec_freq == 0) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1513 | hapd->iconf->secondary_channel = 0; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1514 | else if (acs_res->sec_freq < acs_res->pri_freq) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1515 | hapd->iconf->secondary_channel = -1; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1516 | else if (acs_res->sec_freq > acs_res->pri_freq) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1517 | hapd->iconf->secondary_channel = 1; |
| 1518 | else { |
| 1519 | wpa_printf(MSG_ERROR, "Invalid secondary channel!"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1520 | err = 1; |
| 1521 | goto out; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1522 | } |
| 1523 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1524 | hapd->iconf->edmg_channel = acs_res->edmg_channel; |
| 1525 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1526 | if (hapd->iface->conf->ieee80211ac || hapd->iface->conf->ieee80211ax) { |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1527 | /* set defaults for backwards compatibility */ |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1528 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); |
| 1529 | hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, 0); |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1530 | hostapd_set_oper_chwidth(hapd->iconf, CONF_OPER_CHWIDTH_USE_HT); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1531 | if (acs_res->ch_width == 40) { |
| 1532 | if (is_6ghz_freq(acs_res->pri_freq)) |
| 1533 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1534 | hapd->iconf, |
| 1535 | acs_res->vht_seg0_center_ch); |
| 1536 | } else if (acs_res->ch_width == 80) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1537 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1538 | hapd->iconf, acs_res->vht_seg0_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1539 | if (acs_res->vht_seg1_center_ch == 0) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1540 | hostapd_set_oper_chwidth( |
| 1541 | hapd->iconf, CONF_OPER_CHWIDTH_80MHZ); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1542 | } else { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1543 | hostapd_set_oper_chwidth( |
| 1544 | hapd->iconf, |
| 1545 | CONF_OPER_CHWIDTH_80P80MHZ); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1546 | hostapd_set_oper_centr_freq_seg1_idx( |
| 1547 | hapd->iconf, |
| 1548 | acs_res->vht_seg1_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1549 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1550 | } else if (acs_res->ch_width == 160) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1551 | hostapd_set_oper_chwidth(hapd->iconf, |
| 1552 | CONF_OPER_CHWIDTH_160MHZ); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1553 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1554 | hapd->iconf, acs_res->vht_seg1_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1555 | } |
| 1556 | } |
| 1557 | |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1558 | #ifdef CONFIG_IEEE80211BE |
| 1559 | if (hapd->iface->conf->ieee80211be && acs_res->ch_width == 320) { |
| 1560 | hostapd_set_oper_chwidth(hapd->iconf, CONF_OPER_CHWIDTH_320MHZ); |
| 1561 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1562 | hapd->iconf, acs_res->vht_seg1_center_ch); |
| 1563 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); |
| 1564 | } |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1565 | |
| 1566 | if (hapd->iface->conf->ieee80211be && acs_res->puncture_bitmap) |
| 1567 | hapd->iconf->punct_bitmap = acs_res->puncture_bitmap; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1568 | #endif /* CONFIG_IEEE80211BE */ |
| 1569 | |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1570 | out: |
| 1571 | ret = hostapd_acs_completed(hapd->iface, err); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1572 | if (ret) { |
| 1573 | wpa_printf(MSG_ERROR, |
| 1574 | "ACS: Possibly channel configuration is invalid"); |
| 1575 | } |
| 1576 | } |
| 1577 | #endif /* CONFIG_ACS */ |
| 1578 | |
| 1579 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1580 | int hostapd_probe_req_rx(struct hostapd_data *hapd, const u8 *sa, const u8 *da, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1581 | const u8 *bssid, const u8 *ie, size_t ie_len, |
| 1582 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1583 | { |
| 1584 | size_t i; |
| 1585 | int ret = 0; |
| 1586 | |
| 1587 | if (sa == NULL || ie == NULL) |
| 1588 | return -1; |
| 1589 | |
| 1590 | random_add_randomness(sa, ETH_ALEN); |
| 1591 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) { |
| 1592 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1593 | sa, da, bssid, ie, ie_len, |
| 1594 | ssi_signal) > 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1595 | ret = 1; |
| 1596 | break; |
| 1597 | } |
| 1598 | } |
| 1599 | return ret; |
| 1600 | } |
| 1601 | |
| 1602 | |
| 1603 | #ifdef HOSTAPD |
| 1604 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1605 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1606 | static void hostapd_notify_auth_ft_finish(void *ctx, const u8 *dst, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1607 | u16 auth_transaction, u16 status, |
| 1608 | const u8 *ies, size_t ies_len) |
| 1609 | { |
| 1610 | struct hostapd_data *hapd = ctx; |
| 1611 | struct sta_info *sta; |
| 1612 | |
| 1613 | sta = ap_get_sta(hapd, dst); |
| 1614 | if (sta == NULL) |
| 1615 | return; |
| 1616 | |
| 1617 | hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211, |
| 1618 | HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)"); |
| 1619 | sta->flags |= WLAN_STA_AUTH; |
| 1620 | |
| 1621 | hostapd_sta_auth(hapd, dst, auth_transaction, status, ies, ies_len); |
| 1622 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1623 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1624 | |
| 1625 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1626 | #ifdef CONFIG_FILS |
| 1627 | static void hostapd_notify_auth_fils_finish(struct hostapd_data *hapd, |
| 1628 | struct sta_info *sta, u16 resp, |
| 1629 | struct wpabuf *data, int pub) |
| 1630 | { |
| 1631 | if (resp == WLAN_STATUS_SUCCESS) { |
| 1632 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 1633 | HOSTAPD_LEVEL_DEBUG, "authentication OK (FILS)"); |
| 1634 | sta->flags |= WLAN_STA_AUTH; |
| 1635 | wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH); |
| 1636 | sta->auth_alg = WLAN_AUTH_FILS_SK; |
| 1637 | mlme_authenticate_indication(hapd, sta); |
| 1638 | } else { |
| 1639 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 1640 | HOSTAPD_LEVEL_DEBUG, |
| 1641 | "authentication failed (FILS)"); |
| 1642 | } |
| 1643 | |
| 1644 | hostapd_sta_auth(hapd, sta->addr, 2, resp, |
| 1645 | data ? wpabuf_head(data) : NULL, |
| 1646 | data ? wpabuf_len(data) : 0); |
| 1647 | wpabuf_free(data); |
| 1648 | } |
| 1649 | #endif /* CONFIG_FILS */ |
| 1650 | |
| 1651 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1652 | static void hostapd_notif_auth(struct hostapd_data *hapd, |
| 1653 | struct auth_info *rx_auth) |
| 1654 | { |
| 1655 | struct sta_info *sta; |
| 1656 | u16 status = WLAN_STATUS_SUCCESS; |
| 1657 | u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN]; |
| 1658 | size_t resp_ies_len = 0; |
| 1659 | |
| 1660 | sta = ap_get_sta(hapd, rx_auth->peer); |
| 1661 | if (!sta) { |
| 1662 | sta = ap_sta_add(hapd, rx_auth->peer); |
| 1663 | if (sta == NULL) { |
Dmitry Shmidt | 4b06059 | 2013-04-29 16:42:49 -0700 | [diff] [blame] | 1664 | status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1665 | goto fail; |
| 1666 | } |
| 1667 | } |
| 1668 | sta->flags &= ~WLAN_STA_PREAUTH; |
| 1669 | ieee802_1x_notify_pre_auth(sta->eapol_sm, 0); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1670 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1671 | if (rx_auth->auth_type == WLAN_AUTH_FT && hapd->wpa_auth) { |
| 1672 | sta->auth_alg = WLAN_AUTH_FT; |
| 1673 | if (sta->wpa_sm == NULL) |
| 1674 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 1675 | sta->addr, NULL); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1676 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1677 | wpa_printf(MSG_DEBUG, |
| 1678 | "FT: Failed to initialize WPA state machine"); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1679 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 1680 | goto fail; |
| 1681 | } |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1682 | wpa_ft_process_auth(sta->wpa_sm, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1683 | rx_auth->auth_transaction, rx_auth->ies, |
| 1684 | rx_auth->ies_len, |
| 1685 | hostapd_notify_auth_ft_finish, hapd); |
| 1686 | return; |
| 1687 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1688 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1689 | |
| 1690 | #ifdef CONFIG_FILS |
| 1691 | if (rx_auth->auth_type == WLAN_AUTH_FILS_SK) { |
| 1692 | sta->auth_alg = WLAN_AUTH_FILS_SK; |
| 1693 | handle_auth_fils(hapd, sta, rx_auth->ies, rx_auth->ies_len, |
| 1694 | rx_auth->auth_type, rx_auth->auth_transaction, |
| 1695 | rx_auth->status_code, |
| 1696 | hostapd_notify_auth_fils_finish); |
| 1697 | return; |
| 1698 | } |
| 1699 | #endif /* CONFIG_FILS */ |
| 1700 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1701 | fail: |
| 1702 | hostapd_sta_auth(hapd, rx_auth->peer, rx_auth->auth_transaction + 1, |
| 1703 | status, resp_ies, resp_ies_len); |
| 1704 | } |
| 1705 | |
| 1706 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1707 | #ifndef NEED_AP_MLME |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1708 | static void hostapd_action_rx(struct hostapd_data *hapd, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1709 | struct rx_mgmt *drv_mgmt) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1710 | { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1711 | struct ieee80211_mgmt *mgmt; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1712 | struct sta_info *sta; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1713 | size_t plen __maybe_unused; |
| 1714 | u16 fc; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1715 | u8 *action __maybe_unused; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1716 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1717 | if (drv_mgmt->frame_len < IEEE80211_HDRLEN + 2 + 1) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1718 | return; |
| 1719 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1720 | plen = drv_mgmt->frame_len - IEEE80211_HDRLEN; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1721 | |
| 1722 | mgmt = (struct ieee80211_mgmt *) drv_mgmt->frame; |
| 1723 | fc = le_to_host16(mgmt->frame_control); |
| 1724 | if (WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ACTION) |
| 1725 | return; /* handled by the driver */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1726 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1727 | action = (u8 *) &mgmt->u.action.u; |
| 1728 | wpa_printf(MSG_DEBUG, "RX_ACTION category %u action %u sa " MACSTR |
| 1729 | " da " MACSTR " plen %d", |
| 1730 | mgmt->u.action.category, *action, |
| 1731 | MAC2STR(mgmt->sa), MAC2STR(mgmt->da), (int) plen); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1732 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1733 | sta = ap_get_sta(hapd, mgmt->sa); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1734 | if (sta == NULL) { |
| 1735 | wpa_printf(MSG_DEBUG, "%s: station not found", __func__); |
| 1736 | return; |
| 1737 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1738 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1739 | if (mgmt->u.action.category == WLAN_ACTION_FT) { |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1740 | wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action, plen); |
| 1741 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1742 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1743 | #endif /* CONFIG_IEEE80211R_AP */ |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1744 | if (mgmt->u.action.category == WLAN_ACTION_SA_QUERY) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1745 | ieee802_11_sa_query_action(hapd, mgmt, drv_mgmt->frame_len); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1746 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1747 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1748 | #ifdef CONFIG_WNM_AP |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1749 | if (mgmt->u.action.category == WLAN_ACTION_WNM) { |
| 1750 | ieee802_11_rx_wnm_action_ap(hapd, mgmt, drv_mgmt->frame_len); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1751 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1752 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1753 | #endif /* CONFIG_WNM_AP */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1754 | #ifdef CONFIG_FST |
| 1755 | if (mgmt->u.action.category == WLAN_ACTION_FST && hapd->iface->fst) { |
| 1756 | fst_rx_action(hapd->iface->fst, mgmt, drv_mgmt->frame_len); |
| 1757 | return; |
| 1758 | } |
| 1759 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1760 | #ifdef CONFIG_DPP |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1761 | if (plen >= 2 + 4 && |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1762 | mgmt->u.action.category == WLAN_ACTION_PUBLIC && |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1763 | mgmt->u.action.u.vs_public_action.action == |
| 1764 | WLAN_PA_VENDOR_SPECIFIC && |
| 1765 | WPA_GET_BE24(mgmt->u.action.u.vs_public_action.oui) == |
| 1766 | OUI_WFA && |
| 1767 | mgmt->u.action.u.vs_public_action.variable[0] == |
| 1768 | DPP_OUI_TYPE) { |
| 1769 | const u8 *pos, *end; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1770 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1771 | pos = mgmt->u.action.u.vs_public_action.oui; |
| 1772 | end = drv_mgmt->frame + drv_mgmt->frame_len; |
| 1773 | hostapd_dpp_rx_action(hapd, mgmt->sa, pos, end - pos, |
| 1774 | drv_mgmt->freq); |
| 1775 | return; |
| 1776 | } |
| 1777 | #endif /* CONFIG_DPP */ |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1778 | #ifdef CONFIG_NAN_USD |
| 1779 | if (mgmt->u.action.category == WLAN_ACTION_PUBLIC && plen >= 5 && |
| 1780 | mgmt->u.action.u.vs_public_action.action == |
| 1781 | WLAN_PA_VENDOR_SPECIFIC && |
| 1782 | WPA_GET_BE24(mgmt->u.action.u.vs_public_action.oui) == |
| 1783 | OUI_WFA && |
| 1784 | mgmt->u.action.u.vs_public_action.variable[0] == NAN_OUI_TYPE) { |
| 1785 | const u8 *pos, *end; |
| 1786 | |
| 1787 | pos = mgmt->u.action.u.vs_public_action.variable; |
| 1788 | end = drv_mgmt->frame + drv_mgmt->frame_len; |
| 1789 | pos++; |
| 1790 | hostapd_nan_usd_rx_sdf(hapd, mgmt->sa, drv_mgmt->freq, |
| 1791 | pos, end - pos); |
| 1792 | return; |
| 1793 | } |
| 1794 | #endif /* CONFIG_NAN_USD */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1795 | } |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1796 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1797 | |
| 1798 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1799 | #ifdef NEED_AP_MLME |
| 1800 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1801 | static struct hostapd_data * |
| 1802 | switch_link_hapd(struct hostapd_data *hapd, int link_id) |
| 1803 | { |
| 1804 | #ifdef CONFIG_IEEE80211BE |
| 1805 | if (hapd->conf->mld_ap && link_id >= 0) { |
| 1806 | struct hostapd_data *link_bss; |
| 1807 | |
| 1808 | link_bss = hostapd_mld_get_link_bss(hapd, link_id); |
| 1809 | if (link_bss) |
| 1810 | return link_bss; |
| 1811 | } |
| 1812 | #endif /* CONFIG_IEEE80211BE */ |
| 1813 | |
| 1814 | return hapd; |
| 1815 | } |
| 1816 | |
| 1817 | |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 1818 | static struct hostapd_data * |
| 1819 | switch_link_scan(struct hostapd_data *hapd, u64 scan_cookie) |
| 1820 | { |
| 1821 | #ifdef CONFIG_IEEE80211BE |
| 1822 | if (hapd->conf->mld_ap && scan_cookie != 0) { |
| 1823 | unsigned int i; |
| 1824 | |
| 1825 | for (i = 0; i < hapd->iface->interfaces->count; i++) { |
| 1826 | struct hostapd_iface *h; |
| 1827 | struct hostapd_data *h_hapd; |
| 1828 | |
| 1829 | h = hapd->iface->interfaces->iface[i]; |
| 1830 | h_hapd = h->bss[0]; |
| 1831 | if (!hostapd_is_ml_partner(hapd, h_hapd)) |
| 1832 | continue; |
| 1833 | |
| 1834 | if (h_hapd->scan_cookie == scan_cookie) { |
| 1835 | h_hapd->scan_cookie = 0; |
| 1836 | return h_hapd; |
| 1837 | } |
| 1838 | } |
| 1839 | } |
| 1840 | #endif /* CONFIG_IEEE80211BE */ |
| 1841 | |
| 1842 | return hapd; |
| 1843 | } |
| 1844 | |
| 1845 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1846 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) |
| 1847 | |
| 1848 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1849 | const u8 *bssid, int link_id) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1850 | { |
| 1851 | size_t i; |
| 1852 | |
| 1853 | if (bssid == NULL) |
| 1854 | return NULL; |
| 1855 | if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff && |
| 1856 | bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff) |
| 1857 | return HAPD_BROADCAST; |
| 1858 | |
| 1859 | for (i = 0; i < iface->num_bss; i++) { |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1860 | struct hostapd_data *hapd; |
| 1861 | #ifdef CONFIG_IEEE80211BE |
| 1862 | struct hostapd_data *p_hapd; |
| 1863 | #endif /* CONFIG_IEEE80211BE */ |
| 1864 | |
| 1865 | hapd = iface->bss[i]; |
| 1866 | if (ether_addr_equal(bssid, hapd->own_addr)) |
| 1867 | return hapd; |
| 1868 | |
| 1869 | #ifdef CONFIG_IEEE80211BE |
| 1870 | if (ether_addr_equal(bssid, hapd->own_addr) || |
| 1871 | (hapd->conf->mld_ap && |
| 1872 | ether_addr_equal(bssid, hapd->mld->mld_addr) && |
| 1873 | link_id == hapd->mld_link_id)) |
| 1874 | return hapd; |
| 1875 | |
| 1876 | if (!hapd->conf->mld_ap) |
| 1877 | continue; |
| 1878 | |
| 1879 | for_each_mld_link(p_hapd, hapd) { |
| 1880 | if (p_hapd == hapd) |
| 1881 | continue; |
| 1882 | |
| 1883 | if (ether_addr_equal(bssid, p_hapd->own_addr) || |
| 1884 | (ether_addr_equal(bssid, p_hapd->mld->mld_addr) && |
| 1885 | link_id == p_hapd->mld_link_id)) |
| 1886 | return p_hapd; |
| 1887 | } |
| 1888 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1889 | } |
| 1890 | |
| 1891 | return NULL; |
| 1892 | } |
| 1893 | |
| 1894 | |
| 1895 | static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1896 | const u8 *bssid, const u8 *addr, |
| 1897 | int wds) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1898 | { |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1899 | hapd = get_hapd_bssid(hapd->iface, bssid, -1); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1900 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
| 1901 | return; |
| 1902 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1903 | ieee802_11_rx_from_unknown(hapd, addr, wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1904 | } |
| 1905 | |
| 1906 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1907 | static int hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1908 | { |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1909 | struct hostapd_iface *iface; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1910 | const struct ieee80211_hdr *hdr; |
| 1911 | const u8 *bssid; |
| 1912 | struct hostapd_frame_info fi; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1913 | int ret; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1914 | |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1915 | if (rx_mgmt->ctx) |
| 1916 | hapd = rx_mgmt->ctx; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1917 | hapd = switch_link_hapd(hapd, rx_mgmt->link_id); |
| 1918 | iface = hapd->iface; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1919 | |
Dmitry Shmidt | 7d5c8f2 | 2014-03-03 13:53:28 -0800 | [diff] [blame] | 1920 | #ifdef CONFIG_TESTING_OPTIONS |
| 1921 | if (hapd->ext_mgmt_frame_handling) { |
| 1922 | size_t hex_len = 2 * rx_mgmt->frame_len + 1; |
| 1923 | char *hex = os_malloc(hex_len); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1924 | |
Dmitry Shmidt | 7d5c8f2 | 2014-03-03 13:53:28 -0800 | [diff] [blame] | 1925 | if (hex) { |
| 1926 | wpa_snprintf_hex(hex, hex_len, rx_mgmt->frame, |
| 1927 | rx_mgmt->frame_len); |
| 1928 | wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-RX %s", hex); |
| 1929 | os_free(hex); |
| 1930 | } |
| 1931 | return 1; |
| 1932 | } |
| 1933 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 1934 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1935 | hdr = (const struct ieee80211_hdr *) rx_mgmt->frame; |
| 1936 | bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len); |
| 1937 | if (bssid == NULL) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1938 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1939 | |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1940 | hapd = get_hapd_bssid(iface, bssid, rx_mgmt->link_id); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1941 | |
| 1942 | if (!hapd) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1943 | u16 fc = le_to_host16(hdr->frame_control); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1944 | |
| 1945 | /* |
| 1946 | * Drop frames to unknown BSSIDs except for Beacon frames which |
| 1947 | * could be used to update neighbor information. |
| 1948 | */ |
| 1949 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 1950 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 1951 | hapd = iface->bss[0]; |
| 1952 | else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1953 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1954 | } |
| 1955 | |
| 1956 | os_memset(&fi, 0, sizeof(fi)); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1957 | fi.freq = rx_mgmt->freq; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1958 | fi.datarate = rx_mgmt->datarate; |
| 1959 | fi.ssi_signal = rx_mgmt->ssi_signal; |
| 1960 | |
| 1961 | if (hapd == HAPD_BROADCAST) { |
| 1962 | size_t i; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1963 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1964 | ret = 0; |
| 1965 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | 9866086 | 2014-03-11 17:26:21 -0700 | [diff] [blame] | 1966 | /* if bss is set, driver will call this function for |
| 1967 | * each bss individually. */ |
| 1968 | if (rx_mgmt->drv_priv && |
| 1969 | (iface->bss[i]->drv_priv != rx_mgmt->drv_priv)) |
| 1970 | continue; |
| 1971 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1972 | if (ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame, |
| 1973 | rx_mgmt->frame_len, &fi) > 0) |
| 1974 | ret = 1; |
| 1975 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1976 | } else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1977 | ret = ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, |
| 1978 | &fi); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1979 | |
| 1980 | random_add_randomness(&fi, sizeof(fi)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1981 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1982 | return ret; |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 1983 | } |
| 1984 | |
| 1985 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1986 | static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1987 | size_t len, u16 stype, int ok, int link_id) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1988 | { |
| 1989 | struct ieee80211_hdr *hdr; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1990 | struct hostapd_data *orig_hapd, *tmp_hapd; |
| 1991 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1992 | orig_hapd = hapd; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1993 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1994 | hdr = (struct ieee80211_hdr *) buf; |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 1995 | hapd = switch_link_hapd(hapd, link_id); |
| 1996 | tmp_hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len), link_id); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 1997 | if (tmp_hapd) { |
| 1998 | hapd = tmp_hapd; |
| 1999 | #ifdef CONFIG_IEEE80211BE |
| 2000 | } else if (hapd->conf->mld_ap && |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2001 | ether_addr_equal(hapd->mld->mld_addr, |
| 2002 | get_hdr_bssid(hdr, len))) { |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2003 | /* AP MLD address match - use hapd pointer as-is */ |
| 2004 | #endif /* CONFIG_IEEE80211BE */ |
| 2005 | } else { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2006 | return; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2007 | } |
| 2008 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 2009 | if (hapd == HAPD_BROADCAST) { |
| 2010 | if (stype != WLAN_FC_STYPE_ACTION || len <= 25 || |
| 2011 | buf[24] != WLAN_ACTION_PUBLIC) |
| 2012 | return; |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2013 | hapd = get_hapd_bssid(orig_hapd->iface, hdr->addr2, link_id); |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 2014 | if (!hapd || hapd == HAPD_BROADCAST) |
| 2015 | return; |
| 2016 | /* |
| 2017 | * Allow processing of TX status for a Public Action frame that |
| 2018 | * used wildcard BBSID. |
| 2019 | */ |
| 2020 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2021 | ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); |
| 2022 | } |
| 2023 | |
| 2024 | #endif /* NEED_AP_MLME */ |
| 2025 | |
| 2026 | |
| 2027 | static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) |
| 2028 | { |
| 2029 | struct sta_info *sta = ap_get_sta(hapd, addr); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 2030 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2031 | if (sta) |
| 2032 | return 0; |
| 2033 | |
| 2034 | wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR |
| 2035 | " - adding a new STA", MAC2STR(addr)); |
| 2036 | sta = ap_sta_add(hapd, addr); |
| 2037 | if (sta) { |
| 2038 | hostapd_new_assoc_sta(hapd, sta, 0); |
| 2039 | } else { |
| 2040 | wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR, |
| 2041 | MAC2STR(addr)); |
| 2042 | return -1; |
| 2043 | } |
| 2044 | |
| 2045 | return 0; |
| 2046 | } |
| 2047 | |
| 2048 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2049 | static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, |
| 2050 | const u8 *data, size_t data_len, |
| 2051 | enum frame_encryption encrypted, |
| 2052 | int link_id) |
| 2053 | { |
| 2054 | struct hostapd_data *orig_hapd = hapd; |
| 2055 | |
| 2056 | #ifdef CONFIG_IEEE80211BE |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2057 | hapd = switch_link_hapd(hapd, link_id); |
| 2058 | hapd = hostapd_find_by_sta(hapd->iface, src, true, NULL); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2059 | #else /* CONFIG_IEEE80211BE */ |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2060 | hapd = hostapd_find_by_sta(hapd->iface, src, false, NULL); |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2061 | #endif /* CONFIG_IEEE80211BE */ |
| 2062 | |
| 2063 | if (!hapd) { |
| 2064 | /* WLAN cases need to have an existing association, but non-WLAN |
| 2065 | * cases (mainly, wired IEEE 802.1X) need to be able to process |
| 2066 | * EAPOL frames from new devices that do not yet have a STA |
| 2067 | * entry and as such, do not get a match in |
| 2068 | * hostapd_find_by_sta(). */ |
| 2069 | wpa_printf(MSG_DEBUG, |
| 2070 | "No STA-specific hostapd instance for EAPOL RX found - fall back to initial context"); |
| 2071 | hapd = orig_hapd; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2072 | } |
| 2073 | |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 2074 | ieee802_1x_receive(hapd, src, data, data_len, encrypted); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2075 | } |
| 2076 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 2077 | #endif /* HOSTAPD */ |
| 2078 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2079 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 2080 | static struct hostapd_channel_data * |
| 2081 | hostapd_get_mode_chan(struct hostapd_hw_modes *mode, unsigned int freq) |
| 2082 | { |
| 2083 | int i; |
| 2084 | struct hostapd_channel_data *chan; |
| 2085 | |
| 2086 | for (i = 0; i < mode->num_channels; i++) { |
| 2087 | chan = &mode->channels[i]; |
| 2088 | if ((unsigned int) chan->freq == freq) |
| 2089 | return chan; |
| 2090 | } |
| 2091 | |
| 2092 | return NULL; |
| 2093 | } |
| 2094 | |
| 2095 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2096 | static struct hostapd_channel_data * hostapd_get_mode_channel( |
| 2097 | struct hostapd_iface *iface, unsigned int freq) |
| 2098 | { |
| 2099 | int i; |
| 2100 | struct hostapd_channel_data *chan; |
| 2101 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 2102 | for (i = 0; i < iface->num_hw_features; i++) { |
| 2103 | if (hostapd_hw_skip_mode(iface, &iface->hw_features[i])) |
| 2104 | continue; |
| 2105 | chan = hostapd_get_mode_chan(&iface->hw_features[i], freq); |
| 2106 | if (chan) |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2107 | return chan; |
| 2108 | } |
| 2109 | |
| 2110 | return NULL; |
| 2111 | } |
| 2112 | |
| 2113 | |
| 2114 | static void hostapd_update_nf(struct hostapd_iface *iface, |
| 2115 | struct hostapd_channel_data *chan, |
| 2116 | struct freq_survey *survey) |
| 2117 | { |
| 2118 | if (!iface->chans_surveyed) { |
| 2119 | chan->min_nf = survey->nf; |
| 2120 | iface->lowest_nf = survey->nf; |
| 2121 | } else { |
| 2122 | if (dl_list_empty(&chan->survey_list)) |
| 2123 | chan->min_nf = survey->nf; |
| 2124 | else if (survey->nf < chan->min_nf) |
| 2125 | chan->min_nf = survey->nf; |
| 2126 | if (survey->nf < iface->lowest_nf) |
| 2127 | iface->lowest_nf = survey->nf; |
| 2128 | } |
| 2129 | } |
| 2130 | |
| 2131 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2132 | static void hostapd_single_channel_get_survey(struct hostapd_iface *iface, |
| 2133 | struct survey_results *survey_res) |
| 2134 | { |
| 2135 | struct hostapd_channel_data *chan; |
| 2136 | struct freq_survey *survey; |
| 2137 | u64 divisor, dividend; |
| 2138 | |
| 2139 | survey = dl_list_first(&survey_res->survey_list, struct freq_survey, |
| 2140 | list); |
| 2141 | if (!survey || !survey->freq) |
| 2142 | return; |
| 2143 | |
| 2144 | chan = hostapd_get_mode_channel(iface, survey->freq); |
| 2145 | if (!chan || chan->flag & HOSTAPD_CHAN_DISABLED) |
| 2146 | return; |
| 2147 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 2148 | wpa_printf(MSG_DEBUG, |
| 2149 | "Single Channel Survey: (freq=%d channel_time=%ld channel_time_busy=%ld)", |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2150 | survey->freq, |
| 2151 | (unsigned long int) survey->channel_time, |
| 2152 | (unsigned long int) survey->channel_time_busy); |
| 2153 | |
| 2154 | if (survey->channel_time > iface->last_channel_time && |
| 2155 | survey->channel_time > survey->channel_time_busy) { |
| 2156 | dividend = survey->channel_time_busy - |
| 2157 | iface->last_channel_time_busy; |
| 2158 | divisor = survey->channel_time - iface->last_channel_time; |
| 2159 | |
| 2160 | iface->channel_utilization = dividend * 255 / divisor; |
| 2161 | wpa_printf(MSG_DEBUG, "Channel Utilization: %d", |
| 2162 | iface->channel_utilization); |
| 2163 | } |
| 2164 | iface->last_channel_time = survey->channel_time; |
| 2165 | iface->last_channel_time_busy = survey->channel_time_busy; |
| 2166 | } |
| 2167 | |
| 2168 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 2169 | void hostapd_event_get_survey(struct hostapd_iface *iface, |
| 2170 | struct survey_results *survey_results) |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2171 | { |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2172 | struct freq_survey *survey, *tmp; |
| 2173 | struct hostapd_channel_data *chan; |
| 2174 | |
| 2175 | if (dl_list_empty(&survey_results->survey_list)) { |
| 2176 | wpa_printf(MSG_DEBUG, "No survey data received"); |
| 2177 | return; |
| 2178 | } |
| 2179 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2180 | if (survey_results->freq_filter) { |
| 2181 | hostapd_single_channel_get_survey(iface, survey_results); |
| 2182 | return; |
| 2183 | } |
| 2184 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2185 | dl_list_for_each_safe(survey, tmp, &survey_results->survey_list, |
| 2186 | struct freq_survey, list) { |
| 2187 | chan = hostapd_get_mode_channel(iface, survey->freq); |
| 2188 | if (!chan) |
| 2189 | continue; |
| 2190 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 2191 | continue; |
| 2192 | |
| 2193 | dl_list_del(&survey->list); |
| 2194 | dl_list_add_tail(&chan->survey_list, &survey->list); |
| 2195 | |
| 2196 | hostapd_update_nf(iface, chan, survey); |
| 2197 | |
| 2198 | iface->chans_surveyed++; |
| 2199 | } |
| 2200 | } |
| 2201 | |
| 2202 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 2203 | #ifdef HOSTAPD |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2204 | #ifdef NEED_AP_MLME |
| 2205 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 2206 | static void hostapd_event_iface_unavailable(struct hostapd_data *hapd) |
| 2207 | { |
| 2208 | wpa_printf(MSG_DEBUG, "Interface %s is unavailable -- stopped", |
| 2209 | hapd->conf->iface); |
| 2210 | |
| 2211 | if (hapd->csa_in_progress) { |
| 2212 | wpa_printf(MSG_INFO, "CSA failed (%s was stopped)", |
| 2213 | hapd->conf->iface); |
| 2214 | hostapd_switch_channel_fallback(hapd->iface, |
| 2215 | &hapd->cs_freq_params); |
| 2216 | } |
Yu Ouyang | 378d3c4 | 2021-08-20 17:31:08 +0800 | [diff] [blame] | 2217 | |
| 2218 | // inform framework that interface is unavailable |
| 2219 | hostapd_disable_iface(hapd->iface); |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 2220 | } |
| 2221 | |
| 2222 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2223 | static void hostapd_event_dfs_radar_detected(struct hostapd_data *hapd, |
| 2224 | struct dfs_event *radar) |
| 2225 | { |
| 2226 | wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 2227 | hostapd_dfs_radar_detected(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2228 | radar->chan_offset, radar->chan_width, |
| 2229 | radar->cf1, radar->cf2); |
| 2230 | } |
| 2231 | |
| 2232 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 2233 | static void hostapd_event_dfs_pre_cac_expired(struct hostapd_data *hapd, |
| 2234 | struct dfs_event *radar) |
| 2235 | { |
| 2236 | wpa_printf(MSG_DEBUG, "DFS Pre-CAC expired on %d MHz", radar->freq); |
| 2237 | hostapd_dfs_pre_cac_expired(hapd->iface, radar->freq, radar->ht_enabled, |
| 2238 | radar->chan_offset, radar->chan_width, |
| 2239 | radar->cf1, radar->cf2); |
| 2240 | } |
| 2241 | |
| 2242 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2243 | static void hostapd_event_dfs_cac_finished(struct hostapd_data *hapd, |
| 2244 | struct dfs_event *radar) |
| 2245 | { |
| 2246 | wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 2247 | hostapd_dfs_complete_cac(hapd->iface, 1, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2248 | radar->chan_offset, radar->chan_width, |
| 2249 | radar->cf1, radar->cf2); |
| 2250 | } |
| 2251 | |
| 2252 | |
| 2253 | static void hostapd_event_dfs_cac_aborted(struct hostapd_data *hapd, |
| 2254 | struct dfs_event *radar) |
| 2255 | { |
| 2256 | wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 2257 | hostapd_dfs_complete_cac(hapd->iface, 0, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2258 | radar->chan_offset, radar->chan_width, |
| 2259 | radar->cf1, radar->cf2); |
| 2260 | } |
| 2261 | |
| 2262 | |
| 2263 | static void hostapd_event_dfs_nop_finished(struct hostapd_data *hapd, |
| 2264 | struct dfs_event *radar) |
| 2265 | { |
| 2266 | wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 2267 | hostapd_dfs_nop_finished(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2268 | radar->chan_offset, radar->chan_width, |
| 2269 | radar->cf1, radar->cf2); |
| 2270 | } |
| 2271 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 2272 | |
| 2273 | static void hostapd_event_dfs_cac_started(struct hostapd_data *hapd, |
| 2274 | struct dfs_event *radar) |
| 2275 | { |
| 2276 | wpa_printf(MSG_DEBUG, "DFS offload CAC started on %d MHz", radar->freq); |
| 2277 | hostapd_dfs_start_cac(hapd->iface, radar->freq, radar->ht_enabled, |
| 2278 | radar->chan_offset, radar->chan_width, |
| 2279 | radar->cf1, radar->cf2); |
| 2280 | } |
| 2281 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2282 | #endif /* NEED_AP_MLME */ |
| 2283 | |
| 2284 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 2285 | static void hostapd_event_wds_sta_interface_status(struct hostapd_data *hapd, |
| 2286 | int istatus, |
| 2287 | const char *ifname, |
| 2288 | const u8 *addr) |
| 2289 | { |
| 2290 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 2291 | |
| 2292 | if (sta) { |
| 2293 | os_free(sta->ifname_wds); |
| 2294 | if (istatus == INTERFACE_ADDED) |
| 2295 | sta->ifname_wds = os_strdup(ifname); |
| 2296 | else |
| 2297 | sta->ifname_wds = NULL; |
| 2298 | } |
| 2299 | |
| 2300 | wpa_msg(hapd->msg_ctx, MSG_INFO, "%sifname=%s sta_addr=" MACSTR, |
| 2301 | istatus == INTERFACE_ADDED ? |
| 2302 | WDS_STA_INTERFACE_ADDED : WDS_STA_INTERFACE_REMOVED, |
| 2303 | ifname, MAC2STR(addr)); |
| 2304 | } |
| 2305 | |
| 2306 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2307 | #ifdef CONFIG_OWE |
| 2308 | static int hostapd_notif_update_dh_ie(struct hostapd_data *hapd, |
| 2309 | const u8 *peer, const u8 *ie, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2310 | size_t ie_len, const u8 *link_addr) |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2311 | { |
| 2312 | u16 status; |
| 2313 | struct sta_info *sta; |
| 2314 | struct ieee802_11_elems elems; |
| 2315 | |
| 2316 | if (!hapd || !hapd->wpa_auth) { |
| 2317 | wpa_printf(MSG_DEBUG, "OWE: Invalid hapd context"); |
| 2318 | return -1; |
| 2319 | } |
| 2320 | if (!peer) { |
| 2321 | wpa_printf(MSG_DEBUG, "OWE: Peer unknown"); |
| 2322 | return -1; |
| 2323 | } |
| 2324 | if (!(hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE)) { |
| 2325 | wpa_printf(MSG_DEBUG, "OWE: No OWE AKM configured"); |
| 2326 | status = WLAN_STATUS_AKMP_NOT_VALID; |
| 2327 | goto err; |
| 2328 | } |
| 2329 | if (ieee802_11_parse_elems(ie, ie_len, &elems, 1) == ParseFailed) { |
| 2330 | wpa_printf(MSG_DEBUG, "OWE: Failed to parse OWE IE for " |
| 2331 | MACSTR, MAC2STR(peer)); |
| 2332 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 2333 | goto err; |
| 2334 | } |
| 2335 | status = owe_validate_request(hapd, peer, elems.rsn_ie, |
| 2336 | elems.rsn_ie_len, |
| 2337 | elems.owe_dh, elems.owe_dh_len); |
| 2338 | if (status != WLAN_STATUS_SUCCESS) |
| 2339 | goto err; |
| 2340 | |
| 2341 | sta = ap_get_sta(hapd, peer); |
| 2342 | if (sta) { |
| 2343 | ap_sta_no_session_timeout(hapd, sta); |
| 2344 | accounting_sta_stop(hapd, sta); |
| 2345 | |
| 2346 | /* |
| 2347 | * Make sure that the previously registered inactivity timer |
| 2348 | * will not remove the STA immediately. |
| 2349 | */ |
| 2350 | sta->timeout_next = STA_NULLFUNC; |
| 2351 | } else { |
| 2352 | sta = ap_sta_add(hapd, peer); |
| 2353 | if (!sta) { |
| 2354 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 2355 | goto err; |
| 2356 | } |
| 2357 | } |
| 2358 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
| 2359 | |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2360 | #ifdef CONFIG_IEEE80211BE |
| 2361 | if (link_addr) { |
| 2362 | struct mld_info *info = &sta->mld_info; |
| 2363 | u8 link_id = hapd->mld_link_id; |
| 2364 | |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2365 | ap_sta_set_mld(sta, true); |
| 2366 | sta->mld_assoc_link_id = link_id; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2367 | os_memcpy(info->common_info.mld_addr, peer, ETH_ALEN); |
| 2368 | info->links[link_id].valid = true; |
| 2369 | os_memcpy(info->links[link_id].local_addr, hapd->own_addr, |
| 2370 | ETH_ALEN); |
| 2371 | os_memcpy(info->links[link_id].peer_addr, link_addr, ETH_ALEN); |
| 2372 | } |
| 2373 | #endif /* CONFIG_IEEE80211BE */ |
| 2374 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2375 | status = owe_process_rsn_ie(hapd, sta, elems.rsn_ie, |
| 2376 | elems.rsn_ie_len, elems.owe_dh, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2377 | elems.owe_dh_len, link_addr); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2378 | if (status != WLAN_STATUS_SUCCESS) |
| 2379 | ap_free_sta(hapd, sta); |
| 2380 | |
| 2381 | return 0; |
| 2382 | err: |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2383 | hostapd_drv_update_dh_ie(hapd, link_addr ? link_addr : peer, status, |
| 2384 | NULL, 0); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2385 | return 0; |
| 2386 | } |
| 2387 | #endif /* CONFIG_OWE */ |
| 2388 | |
| 2389 | |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2390 | #ifdef NEED_AP_MLME |
| 2391 | static void hostapd_eapol_tx_status(struct hostapd_data *hapd, const u8 *dst, |
| 2392 | const u8 *data, size_t len, int ack, |
| 2393 | int link_id) |
| 2394 | { |
| 2395 | struct sta_info *sta; |
| 2396 | |
| 2397 | hapd = switch_link_hapd(hapd, link_id); |
| 2398 | hapd = hostapd_find_by_sta(hapd->iface, dst, false, &sta); |
| 2399 | |
| 2400 | if (!sta) { |
| 2401 | wpa_printf(MSG_DEBUG, "Ignore TX status for Data frame to STA " |
| 2402 | MACSTR " that is not currently associated", |
| 2403 | MAC2STR(dst)); |
| 2404 | return; |
| 2405 | } |
| 2406 | |
| 2407 | ieee802_1x_eapol_tx_status(hapd, sta, data, len, ack); |
| 2408 | } |
| 2409 | #endif /* NEED_AP_MLME */ |
| 2410 | |
| 2411 | |
| 2412 | #ifdef CONFIG_IEEE80211AX |
| 2413 | static void hostapd_event_color_change(struct hostapd_data *hapd, bool success) |
| 2414 | { |
| 2415 | struct hostapd_data *bss; |
| 2416 | size_t i; |
| 2417 | |
| 2418 | for (i = 0; i < hapd->iface->num_bss; i++) { |
| 2419 | bss = hapd->iface->bss[i]; |
| 2420 | if (bss->cca_color == 0) |
| 2421 | continue; |
| 2422 | |
| 2423 | if (success) |
| 2424 | hapd->iface->conf->he_op.he_bss_color = bss->cca_color; |
| 2425 | |
| 2426 | bss->cca_in_progress = 0; |
| 2427 | if (ieee802_11_set_beacon(bss)) { |
| 2428 | wpa_printf(MSG_ERROR, "Failed to remove BCCA element"); |
| 2429 | bss->cca_in_progress = 1; |
| 2430 | } else { |
| 2431 | hostapd_cleanup_cca_params(bss); |
| 2432 | } |
| 2433 | } |
| 2434 | } |
| 2435 | #endif /* CONFIG_IEEE80211AX */ |
| 2436 | |
| 2437 | |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 2438 | static void hostapd_iface_enable(struct hostapd_data *hapd) |
| 2439 | { |
| 2440 | wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_ENABLED); |
| 2441 | if (hapd->disabled && hapd->started) { |
| 2442 | hapd->disabled = 0; |
| 2443 | /* |
| 2444 | * Try to re-enable interface if the driver stopped it |
| 2445 | * when the interface got disabled. |
| 2446 | */ |
| 2447 | if (hapd->wpa_auth) |
| 2448 | wpa_auth_reconfig_group_keys(hapd->wpa_auth); |
| 2449 | else |
| 2450 | hostapd_reconfig_encryption(hapd); |
| 2451 | hapd->reenable_beacon = 1; |
| 2452 | ieee802_11_set_beacon(hapd); |
| 2453 | #ifdef NEED_AP_MLME |
| 2454 | } else if (hapd->disabled && hapd->iface->cac_started) { |
| 2455 | wpa_printf(MSG_DEBUG, "DFS: restarting pending CAC"); |
| 2456 | hostapd_handle_dfs(hapd->iface); |
| 2457 | #endif /* NEED_AP_MLME */ |
| 2458 | } |
| 2459 | } |
| 2460 | |
| 2461 | |
| 2462 | static void hostapd_iface_disable(struct hostapd_data *hapd) |
| 2463 | { |
| 2464 | hostapd_free_stas(hapd); |
| 2465 | wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_DISABLED); |
| 2466 | hapd->disabled = 1; |
| 2467 | } |
| 2468 | |
| 2469 | |
| 2470 | #ifdef CONFIG_IEEE80211BE |
| 2471 | |
| 2472 | static void hostapd_mld_iface_enable(struct hostapd_data *hapd) |
| 2473 | { |
| 2474 | struct hostapd_data *first_link, *link_bss; |
| 2475 | |
| 2476 | first_link = hostapd_mld_is_first_bss(hapd) ? hapd : |
| 2477 | hostapd_mld_get_first_bss(hapd); |
| 2478 | |
| 2479 | /* Links have been removed. Re-add all links and enable them, but |
| 2480 | * enable the first link BSS before doing that. */ |
| 2481 | if (hostapd_drv_link_add(first_link, first_link->mld_link_id, |
| 2482 | first_link->own_addr)) { |
| 2483 | wpa_printf(MSG_ERROR, "MLD: Failed to re-add link %d in MLD %s", |
| 2484 | first_link->mld_link_id, first_link->conf->iface); |
| 2485 | return; |
| 2486 | } |
| 2487 | |
| 2488 | hostapd_iface_enable(first_link); |
| 2489 | |
| 2490 | /* Add other affiliated links */ |
| 2491 | for_each_mld_link(link_bss, first_link) { |
| 2492 | if (link_bss == first_link) |
| 2493 | continue; |
| 2494 | |
| 2495 | if (hostapd_drv_link_add(link_bss, link_bss->mld_link_id, |
| 2496 | link_bss->own_addr)) { |
| 2497 | wpa_printf(MSG_ERROR, |
| 2498 | "MLD: Failed to re-add link %d in MLD %s", |
| 2499 | link_bss->mld_link_id, |
| 2500 | link_bss->conf->iface); |
| 2501 | continue; |
| 2502 | } |
| 2503 | |
| 2504 | hostapd_iface_enable(link_bss); |
| 2505 | } |
| 2506 | } |
| 2507 | |
| 2508 | |
| 2509 | static void hostapd_mld_iface_disable(struct hostapd_data *hapd) |
| 2510 | { |
| 2511 | struct hostapd_data *link_bss; |
| 2512 | |
| 2513 | for_each_mld_link(link_bss, hapd) |
| 2514 | hostapd_iface_disable(link_bss); |
| 2515 | } |
| 2516 | |
| 2517 | #endif /* CONFIG_IEEE80211BE */ |
| 2518 | |
| 2519 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2520 | void wpa_supplicant_event(void *ctx, enum wpa_event_type event, |
| 2521 | union wpa_event_data *data) |
| 2522 | { |
| 2523 | struct hostapd_data *hapd = ctx; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2524 | struct sta_info *sta; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2525 | #ifndef CONFIG_NO_STDOUT_DEBUG |
| 2526 | int level = MSG_DEBUG; |
| 2527 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 2528 | if (event == EVENT_RX_MGMT && data->rx_mgmt.frame && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2529 | data->rx_mgmt.frame_len >= 24) { |
| 2530 | const struct ieee80211_hdr *hdr; |
| 2531 | u16 fc; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 2532 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2533 | hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame; |
| 2534 | fc = le_to_host16(hdr->frame_control); |
| 2535 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 2536 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 2537 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 2538 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 2539 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_PROBE_REQ) |
| 2540 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2541 | } |
| 2542 | |
| 2543 | wpa_dbg(hapd->msg_ctx, level, "Event %s (%d) received", |
| 2544 | event_to_string(event), event); |
| 2545 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2546 | |
| 2547 | switch (event) { |
| 2548 | case EVENT_MICHAEL_MIC_FAILURE: |
| 2549 | michael_mic_failure(hapd, data->michael_mic_failure.src, 1); |
| 2550 | break; |
| 2551 | case EVENT_SCAN_RESULTS: |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2552 | #ifdef NEED_AP_MLME |
| 2553 | if (data) |
| 2554 | hapd = switch_link_scan(hapd, |
| 2555 | data->scan_info.scan_cookie); |
| 2556 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2557 | if (hapd->iface->scan_cb) |
| 2558 | hapd->iface->scan_cb(hapd->iface); |
Sunil Ravi | 99c035e | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2559 | #ifdef CONFIG_IEEE80211BE |
| 2560 | if (!hapd->iface->scan_cb && hapd->conf->mld_ap) { |
| 2561 | /* Other links may be waiting for HT scan result */ |
| 2562 | unsigned int i; |
| 2563 | |
| 2564 | for (i = 0; i < hapd->iface->interfaces->count; i++) { |
| 2565 | struct hostapd_iface *h = |
| 2566 | hapd->iface->interfaces->iface[i]; |
| 2567 | struct hostapd_data *h_hapd = h->bss[0]; |
| 2568 | |
| 2569 | if (hostapd_is_ml_partner(hapd, h_hapd) && |
| 2570 | h_hapd->iface->scan_cb) |
| 2571 | h_hapd->iface->scan_cb(h_hapd->iface); |
| 2572 | } |
| 2573 | } |
| 2574 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2575 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2576 | case EVENT_WPS_BUTTON_PUSHED: |
| 2577 | hostapd_wps_button_pushed(hapd, NULL); |
| 2578 | break; |
| 2579 | #ifdef NEED_AP_MLME |
| 2580 | case EVENT_TX_STATUS: |
| 2581 | switch (data->tx_status.type) { |
| 2582 | case WLAN_FC_TYPE_MGMT: |
| 2583 | hostapd_mgmt_tx_cb(hapd, data->tx_status.data, |
| 2584 | data->tx_status.data_len, |
| 2585 | data->tx_status.stype, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2586 | data->tx_status.ack, |
| 2587 | data->tx_status.link_id); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2588 | break; |
| 2589 | case WLAN_FC_TYPE_DATA: |
| 2590 | hostapd_tx_status(hapd, data->tx_status.dst, |
| 2591 | data->tx_status.data, |
| 2592 | data->tx_status.data_len, |
| 2593 | data->tx_status.ack); |
| 2594 | break; |
| 2595 | } |
| 2596 | break; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2597 | case EVENT_EAPOL_TX_STATUS: |
| 2598 | hostapd_eapol_tx_status(hapd, data->eapol_tx_status.dst, |
| 2599 | data->eapol_tx_status.data, |
| 2600 | data->eapol_tx_status.data_len, |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2601 | data->eapol_tx_status.ack, |
| 2602 | data->eapol_tx_status.link_id); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2603 | break; |
| 2604 | case EVENT_DRIVER_CLIENT_POLL_OK: |
| 2605 | hostapd_client_poll_ok(hapd, data->client_poll.addr); |
| 2606 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2607 | case EVENT_RX_FROM_UNKNOWN: |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2608 | hostapd_rx_from_unknown_sta(hapd, data->rx_from_unknown.bssid, |
| 2609 | data->rx_from_unknown.addr, |
| 2610 | data->rx_from_unknown.wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2611 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2612 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2613 | case EVENT_RX_MGMT: |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 2614 | if (!data->rx_mgmt.frame) |
| 2615 | break; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2616 | #ifdef NEED_AP_MLME |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 2617 | hostapd_mgmt_rx(hapd, &data->rx_mgmt); |
| 2618 | #else /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2619 | hostapd_action_rx(hapd, &data->rx_mgmt); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 2620 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2621 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2622 | case EVENT_RX_PROBE_REQ: |
| 2623 | if (data->rx_probe_req.sa == NULL || |
| 2624 | data->rx_probe_req.ie == NULL) |
| 2625 | break; |
| 2626 | hostapd_probe_req_rx(hapd, data->rx_probe_req.sa, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2627 | data->rx_probe_req.da, |
| 2628 | data->rx_probe_req.bssid, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2629 | data->rx_probe_req.ie, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2630 | data->rx_probe_req.ie_len, |
| 2631 | data->rx_probe_req.ssi_signal); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2632 | break; |
| 2633 | case EVENT_NEW_STA: |
| 2634 | hostapd_event_new_sta(hapd, data->new_sta.addr); |
| 2635 | break; |
| 2636 | case EVENT_EAPOL_RX: |
| 2637 | hostapd_event_eapol_rx(hapd, data->eapol_rx.src, |
| 2638 | data->eapol_rx.data, |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 2639 | data->eapol_rx.data_len, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2640 | data->eapol_rx.encrypted, |
| 2641 | data->eapol_rx.link_id); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2642 | break; |
| 2643 | case EVENT_ASSOC: |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 2644 | if (!data) |
| 2645 | return; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2646 | #ifdef CONFIG_IEEE80211BE |
| 2647 | if (data->assoc_info.assoc_link_id != -1) { |
| 2648 | hapd = hostapd_mld_get_link_bss( |
| 2649 | hapd, data->assoc_info.assoc_link_id); |
| 2650 | if (!hapd) { |
| 2651 | wpa_printf(MSG_ERROR, |
| 2652 | "MLD: Failed to get link BSS for EVENT_ASSOC"); |
| 2653 | return; |
| 2654 | } |
| 2655 | } |
| 2656 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2657 | hostapd_notif_assoc(hapd, data->assoc_info.addr, |
| 2658 | data->assoc_info.req_ies, |
| 2659 | data->assoc_info.req_ies_len, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2660 | data->assoc_info.resp_ies, |
| 2661 | data->assoc_info.resp_ies_len, |
| 2662 | data->assoc_info.link_addr, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2663 | data->assoc_info.reassoc); |
| 2664 | break; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2665 | case EVENT_PORT_AUTHORIZED: |
| 2666 | /* Port authorized event for an associated STA */ |
| 2667 | sta = ap_get_sta(hapd, data->port_authorized.sta_addr); |
| 2668 | if (sta) |
| 2669 | ap_sta_set_authorized(hapd, sta, 1); |
| 2670 | else |
| 2671 | wpa_printf(MSG_DEBUG, |
| 2672 | "No STA info matching port authorized event found"); |
| 2673 | break; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2674 | #ifdef CONFIG_OWE |
| 2675 | case EVENT_UPDATE_DH: |
| 2676 | if (!data) |
| 2677 | return; |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2678 | #ifdef CONFIG_IEEE80211BE |
| 2679 | if (data->update_dh.assoc_link_id != -1) { |
| 2680 | hapd = hostapd_mld_get_link_bss( |
| 2681 | hapd, data->update_dh.assoc_link_id); |
| 2682 | if (!hapd) { |
| 2683 | wpa_printf(MSG_ERROR, |
| 2684 | "MLD: Failed to get link BSS for EVENT_UPDATE_DH assoc_link_id=%d", |
| 2685 | data->update_dh.assoc_link_id); |
| 2686 | return; |
| 2687 | } |
| 2688 | } |
| 2689 | #endif /* CONFIG_IEEE80211BE */ |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2690 | hostapd_notif_update_dh_ie(hapd, data->update_dh.peer, |
| 2691 | data->update_dh.ie, |
Sunil Ravi | 2a14cf1 | 2023-11-21 00:54:38 +0000 | [diff] [blame] | 2692 | data->update_dh.ie_len, |
| 2693 | data->update_dh.link_addr); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2694 | break; |
| 2695 | #endif /* CONFIG_OWE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2696 | case EVENT_DISASSOC: |
| 2697 | if (data) |
| 2698 | hostapd_notif_disassoc(hapd, data->disassoc_info.addr); |
| 2699 | break; |
| 2700 | case EVENT_DEAUTH: |
| 2701 | if (data) |
| 2702 | hostapd_notif_disassoc(hapd, data->deauth_info.addr); |
| 2703 | break; |
| 2704 | case EVENT_STATION_LOW_ACK: |
| 2705 | if (!data) |
| 2706 | break; |
| 2707 | hostapd_event_sta_low_ack(hapd, data->low_ack.addr); |
| 2708 | break; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 2709 | case EVENT_AUTH: |
| 2710 | hostapd_notif_auth(hapd, &data->auth); |
| 2711 | break; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2712 | case EVENT_CH_SWITCH_STARTED: |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2713 | case EVENT_CH_SWITCH: |
| 2714 | if (!data) |
| 2715 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2716 | #ifdef CONFIG_IEEE80211BE |
| 2717 | if (data->ch_switch.link_id != -1) { |
| 2718 | hapd = hostapd_mld_get_link_bss( |
| 2719 | hapd, data->ch_switch.link_id); |
| 2720 | if (!hapd) { |
| 2721 | wpa_printf(MSG_ERROR, |
| 2722 | "MLD: Failed to get link (ID %d) BSS for EVENT_CH_SWITCH/EVENT_CH_SWITCH_STARTED", |
| 2723 | data->ch_switch.link_id); |
| 2724 | break; |
| 2725 | } |
| 2726 | } |
| 2727 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2728 | hostapd_event_ch_switch(hapd, data->ch_switch.freq, |
| 2729 | data->ch_switch.ht_enabled, |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 2730 | data->ch_switch.ch_offset, |
| 2731 | data->ch_switch.ch_width, |
| 2732 | data->ch_switch.cf1, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2733 | data->ch_switch.cf2, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 2734 | data->ch_switch.punct_bitmap, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2735 | event == EVENT_CH_SWITCH); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2736 | break; |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 2737 | case EVENT_CONNECT_FAILED_REASON: |
| 2738 | if (!data) |
| 2739 | break; |
| 2740 | hostapd_event_connect_failed_reason( |
| 2741 | hapd, data->connect_failed_reason.addr, |
| 2742 | data->connect_failed_reason.code); |
| 2743 | break; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2744 | case EVENT_SURVEY: |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 2745 | hostapd_event_get_survey(hapd->iface, &data->survey_results); |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2746 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2747 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 2748 | case EVENT_INTERFACE_UNAVAILABLE: |
| 2749 | hostapd_event_iface_unavailable(hapd); |
| 2750 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2751 | case EVENT_DFS_RADAR_DETECTED: |
| 2752 | if (!data) |
| 2753 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2754 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2755 | hostapd_event_dfs_radar_detected(hapd, &data->dfs_event); |
| 2756 | break; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 2757 | case EVENT_DFS_PRE_CAC_EXPIRED: |
| 2758 | if (!data) |
| 2759 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2760 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 2761 | hostapd_event_dfs_pre_cac_expired(hapd, &data->dfs_event); |
| 2762 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2763 | case EVENT_DFS_CAC_FINISHED: |
| 2764 | if (!data) |
| 2765 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2766 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2767 | hostapd_event_dfs_cac_finished(hapd, &data->dfs_event); |
| 2768 | break; |
| 2769 | case EVENT_DFS_CAC_ABORTED: |
| 2770 | if (!data) |
| 2771 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2772 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2773 | hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event); |
| 2774 | break; |
| 2775 | case EVENT_DFS_NOP_FINISHED: |
| 2776 | if (!data) |
| 2777 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2778 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2779 | hostapd_event_dfs_nop_finished(hapd, &data->dfs_event); |
| 2780 | break; |
| 2781 | case EVENT_CHANNEL_LIST_CHANGED: |
| 2782 | /* channel list changed (regulatory?), update channel list */ |
| 2783 | /* TODO: check this. hostapd_get_hw_features() initializes |
| 2784 | * too much stuff. */ |
| 2785 | /* hostapd_get_hw_features(hapd->iface); */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2786 | hostapd_channel_list_updated( |
| 2787 | hapd->iface, data->channel_list_changed.initiator); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2788 | break; |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 2789 | case EVENT_DFS_CAC_STARTED: |
| 2790 | if (!data) |
| 2791 | break; |
Sunil Ravi | b0ac25f | 2024-07-12 01:42:03 +0000 | [diff] [blame] | 2792 | hapd = switch_link_hapd(hapd, data->dfs_event.link_id); |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 2793 | hostapd_event_dfs_cac_started(hapd, &data->dfs_event); |
| 2794 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2795 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2796 | case EVENT_INTERFACE_ENABLED: |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 2797 | #ifdef CONFIG_IEEE80211BE |
| 2798 | if (hapd->conf->mld_ap) { |
| 2799 | hostapd_mld_iface_enable(hapd); |
| 2800 | break; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2801 | } |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 2802 | #endif /* CONFIG_IEEE80211BE */ |
| 2803 | hostapd_iface_enable(hapd); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2804 | break; |
| 2805 | case EVENT_INTERFACE_DISABLED: |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 2806 | #ifdef CONFIG_IEEE80211BE |
| 2807 | if (hapd->conf->mld_ap) { |
| 2808 | hostapd_mld_iface_disable(hapd); |
| 2809 | break; |
| 2810 | } |
| 2811 | #endif /* CONFIG_IEEE80211BE */ |
| 2812 | hostapd_iface_disable(hapd); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2813 | break; |
| 2814 | #ifdef CONFIG_ACS |
| 2815 | case EVENT_ACS_CHANNEL_SELECTED: |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 2816 | hostapd_acs_channel_selected(hapd, |
| 2817 | &data->acs_selected_channels); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2818 | break; |
| 2819 | #endif /* CONFIG_ACS */ |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 2820 | case EVENT_STATION_OPMODE_CHANGED: |
| 2821 | hostapd_event_sta_opmode_changed(hapd, data->sta_opmode.addr, |
| 2822 | data->sta_opmode.smps_mode, |
| 2823 | data->sta_opmode.chan_width, |
| 2824 | data->sta_opmode.rx_nss); |
| 2825 | break; |
| 2826 | case EVENT_WDS_STA_INTERFACE_STATUS: |
| 2827 | hostapd_event_wds_sta_interface_status( |
| 2828 | hapd, data->wds_sta_interface.istatus, |
| 2829 | data->wds_sta_interface.ifname, |
| 2830 | data->wds_sta_interface.sta_addr); |
| 2831 | break; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2832 | #ifdef CONFIG_IEEE80211AX |
| 2833 | case EVENT_BSS_COLOR_COLLISION: |
| 2834 | /* The BSS color is shared amongst all BBSs on a specific phy. |
| 2835 | * Therefore we always start the color change on the primary |
| 2836 | * BSS. */ |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2837 | hapd = switch_link_hapd(hapd, |
| 2838 | data->bss_color_collision.link_id); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2839 | wpa_printf(MSG_DEBUG, "BSS color collision on %s", |
| 2840 | hapd->conf->iface); |
| 2841 | hostapd_switch_color(hapd->iface->bss[0], |
| 2842 | data->bss_color_collision.bitmap); |
| 2843 | break; |
| 2844 | case EVENT_CCA_STARTED_NOTIFY: |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2845 | hapd = switch_link_hapd(hapd, |
| 2846 | data->bss_color_collision.link_id); |
| 2847 | wpa_printf(MSG_DEBUG, "CCA started on %s", |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2848 | hapd->conf->iface); |
| 2849 | break; |
| 2850 | case EVENT_CCA_ABORTED_NOTIFY: |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2851 | hapd = switch_link_hapd(hapd, |
| 2852 | data->bss_color_collision.link_id); |
| 2853 | wpa_printf(MSG_DEBUG, "CCA aborted on %s", |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2854 | hapd->conf->iface); |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2855 | hostapd_event_color_change(hapd, false); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2856 | break; |
| 2857 | case EVENT_CCA_NOTIFY: |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2858 | hapd = switch_link_hapd(hapd, |
| 2859 | data->bss_color_collision.link_id); |
| 2860 | wpa_printf(MSG_DEBUG, "CCA finished on %s", |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2861 | hapd->conf->iface); |
Sunil Ravi | 7f76929 | 2024-07-23 22:21:32 +0000 | [diff] [blame] | 2862 | hostapd_event_color_change(hapd, true); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2863 | break; |
| 2864 | #endif /* CONFIG_IEEE80211AX */ |
Sunil Ravi | c0f5d41 | 2024-09-11 22:12:49 +0000 | [diff] [blame] | 2865 | #ifdef CONFIG_IEEE80211BE |
| 2866 | case EVENT_MLD_INTERFACE_FREED: |
| 2867 | wpa_printf(MSG_DEBUG, "MLD: Interface %s freed", |
| 2868 | hapd->conf->iface); |
| 2869 | hostapd_mld_interface_freed(hapd); |
| 2870 | break; |
| 2871 | #endif /* CONFIG_IEEE80211BE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2872 | default: |
| 2873 | wpa_printf(MSG_DEBUG, "Unknown event %d", event); |
| 2874 | break; |
| 2875 | } |
| 2876 | } |
| 2877 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 2878 | |
| 2879 | void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, |
| 2880 | union wpa_event_data *data) |
| 2881 | { |
| 2882 | struct hapd_interfaces *interfaces = ctx; |
| 2883 | struct hostapd_data *hapd; |
| 2884 | |
| 2885 | if (event != EVENT_INTERFACE_STATUS) |
| 2886 | return; |
| 2887 | |
| 2888 | hapd = hostapd_get_iface(interfaces, data->interface_status.ifname); |
| 2889 | if (hapd && hapd->driver && hapd->driver->get_ifindex && |
| 2890 | hapd->drv_priv) { |
| 2891 | unsigned int ifindex; |
| 2892 | |
| 2893 | ifindex = hapd->driver->get_ifindex(hapd->drv_priv); |
| 2894 | if (ifindex != data->interface_status.ifindex) { |
| 2895 | wpa_dbg(hapd->msg_ctx, MSG_DEBUG, |
| 2896 | "interface status ifindex %d mismatch (%d)", |
| 2897 | ifindex, data->interface_status.ifindex); |
| 2898 | return; |
| 2899 | } |
| 2900 | } |
| 2901 | if (hapd) |
| 2902 | wpa_supplicant_event(hapd, event, data); |
| 2903 | } |
| 2904 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2905 | #endif /* HOSTAPD */ |