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" |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 45 | |
| 46 | |
| 47 | #ifdef CONFIG_FILS |
| 48 | void hostapd_notify_assoc_fils_finish(struct hostapd_data *hapd, |
| 49 | struct sta_info *sta) |
| 50 | { |
| 51 | u16 reply_res = WLAN_STATUS_SUCCESS; |
| 52 | struct ieee802_11_elems elems; |
| 53 | u8 buf[IEEE80211_MAX_MMPDU_SIZE], *p = buf; |
| 54 | int new_assoc; |
| 55 | |
| 56 | wpa_printf(MSG_DEBUG, "%s FILS: Finish association with " MACSTR, |
| 57 | __func__, MAC2STR(sta->addr)); |
| 58 | eloop_cancel_timeout(fils_hlp_timeout, hapd, sta); |
| 59 | if (!sta->fils_pending_assoc_req) |
| 60 | return; |
| 61 | |
| 62 | ieee802_11_parse_elems(sta->fils_pending_assoc_req, |
| 63 | sta->fils_pending_assoc_req_len, &elems, 0); |
| 64 | if (!elems.fils_session) { |
| 65 | wpa_printf(MSG_DEBUG, "%s failed to find FILS Session element", |
| 66 | __func__); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | p = hostapd_eid_assoc_fils_session(sta->wpa_sm, p, |
| 71 | elems.fils_session, |
| 72 | sta->fils_hlp_resp); |
| 73 | |
| 74 | reply_res = hostapd_sta_assoc(hapd, sta->addr, |
| 75 | sta->fils_pending_assoc_is_reassoc, |
| 76 | WLAN_STATUS_SUCCESS, |
| 77 | buf, p - buf); |
| 78 | ap_sta_set_authorized(hapd, sta, 1); |
| 79 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; |
| 80 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; |
| 81 | sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; |
| 82 | hostapd_set_sta_flags(hapd, sta); |
| 83 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FILS); |
| 84 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); |
| 85 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); |
| 86 | os_free(sta->fils_pending_assoc_req); |
| 87 | sta->fils_pending_assoc_req = NULL; |
| 88 | sta->fils_pending_assoc_req_len = 0; |
| 89 | wpabuf_free(sta->fils_hlp_resp); |
| 90 | sta->fils_hlp_resp = NULL; |
| 91 | wpabuf_free(sta->hlp_dhcp_discover); |
| 92 | sta->hlp_dhcp_discover = NULL; |
| 93 | fils_hlp_deinit(hapd); |
| 94 | |
| 95 | /* |
| 96 | * Remove the station in case transmission of a success response fails |
| 97 | * (the STA was added associated to the driver) or if the station was |
| 98 | * previously added unassociated. |
| 99 | */ |
| 100 | if (reply_res != WLAN_STATUS_SUCCESS || sta->added_unassoc) { |
| 101 | hostapd_drv_sta_remove(hapd, sta->addr); |
| 102 | sta->added_unassoc = 0; |
| 103 | } |
| 104 | } |
| 105 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 106 | |
| 107 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 108 | static bool check_sa_query_need(struct hostapd_data *hapd, struct sta_info *sta) |
| 109 | { |
| 110 | if ((sta->flags & |
| 111 | (WLAN_STA_ASSOC | WLAN_STA_MFP | WLAN_STA_AUTHORIZED)) != |
| 112 | (WLAN_STA_ASSOC | WLAN_STA_MFP | WLAN_STA_AUTHORIZED)) |
| 113 | return false; |
| 114 | |
| 115 | if (!sta->sa_query_timed_out && sta->sa_query_count > 0) |
| 116 | ap_check_sa_query_timeout(hapd, sta); |
| 117 | |
| 118 | if (!sta->sa_query_timed_out && (sta->auth_alg != WLAN_AUTH_FT)) { |
| 119 | /* |
| 120 | * STA has already been associated with MFP and SA Query timeout |
| 121 | * has not been reached. Reject the association attempt |
| 122 | * temporarily and start SA Query, if one is not pending. |
| 123 | */ |
| 124 | if (sta->sa_query_count == 0) |
| 125 | ap_sta_start_sa_query(hapd, sta); |
| 126 | |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 134 | int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 135 | const u8 *req_ies, size_t req_ies_len, int reassoc) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 136 | { |
| 137 | struct sta_info *sta; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 138 | int new_assoc; |
| 139 | enum wpa_validate_result res; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 140 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 141 | const u8 *ie; |
| 142 | size_t ielen; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 143 | u8 buf[sizeof(struct ieee80211_mgmt) + 1024]; |
| 144 | u8 *p = buf; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 145 | u16 reason = WLAN_REASON_UNSPECIFIED; |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 146 | int status = WLAN_STATUS_SUCCESS; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 147 | const u8 *p2p_dev_addr = NULL; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 148 | |
| 149 | if (addr == NULL) { |
| 150 | /* |
| 151 | * This could potentially happen with unexpected event from the |
| 152 | * driver wrapper. This was seen at least in one case where the |
| 153 | * driver ended up being set to station mode while hostapd was |
| 154 | * running, so better make sure we stop processing such an |
| 155 | * event here. |
| 156 | */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 157 | wpa_printf(MSG_DEBUG, |
| 158 | "hostapd_notif_assoc: Skip event with no address"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 159 | return -1; |
| 160 | } |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 161 | |
| 162 | if (is_multicast_ether_addr(addr) || |
| 163 | is_zero_ether_addr(addr) || |
| 164 | os_memcmp(addr, hapd->own_addr, ETH_ALEN) == 0) { |
| 165 | /* Do not process any frames with unexpected/invalid SA so that |
| 166 | * we do not add any state for unexpected STA addresses or end |
| 167 | * up sending out frames to unexpected destination. */ |
| 168 | wpa_printf(MSG_DEBUG, "%s: Invalid SA=" MACSTR |
| 169 | " in received indication - ignore this indication silently", |
| 170 | __func__, MAC2STR(addr)); |
| 171 | return 0; |
| 172 | } |
| 173 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 174 | random_add_randomness(addr, ETH_ALEN); |
| 175 | |
| 176 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 177 | HOSTAPD_LEVEL_INFO, "associated"); |
| 178 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 179 | ieee802_11_parse_elems(req_ies, req_ies_len, &elems, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 180 | if (elems.wps_ie) { |
| 181 | ie = elems.wps_ie - 2; |
| 182 | ielen = elems.wps_ie_len + 2; |
| 183 | wpa_printf(MSG_DEBUG, "STA included WPS IE in (Re)AssocReq"); |
| 184 | } else if (elems.rsn_ie) { |
| 185 | ie = elems.rsn_ie - 2; |
| 186 | ielen = elems.rsn_ie_len + 2; |
| 187 | wpa_printf(MSG_DEBUG, "STA included RSN IE in (Re)AssocReq"); |
| 188 | } else if (elems.wpa_ie) { |
| 189 | ie = elems.wpa_ie - 2; |
| 190 | ielen = elems.wpa_ie_len + 2; |
| 191 | wpa_printf(MSG_DEBUG, "STA included WPA IE in (Re)AssocReq"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 192 | #ifdef CONFIG_HS20 |
| 193 | } else if (elems.osen) { |
| 194 | ie = elems.osen - 2; |
| 195 | ielen = elems.osen_len + 2; |
| 196 | wpa_printf(MSG_DEBUG, "STA included OSEN IE in (Re)AssocReq"); |
| 197 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 198 | } else { |
| 199 | ie = NULL; |
| 200 | ielen = 0; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 201 | wpa_printf(MSG_DEBUG, |
| 202 | "STA did not include WPS/RSN/WPA IE in (Re)AssocReq"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | sta = ap_get_sta(hapd, addr); |
| 206 | if (sta) { |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 207 | ap_sta_no_session_timeout(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 208 | accounting_sta_stop(hapd, sta); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 209 | |
| 210 | /* |
| 211 | * Make sure that the previously registered inactivity timer |
| 212 | * will not remove the STA immediately. |
| 213 | */ |
| 214 | sta->timeout_next = STA_NULLFUNC; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 215 | } else { |
| 216 | sta = ap_sta_add(hapd, addr); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 217 | if (sta == NULL) { |
| 218 | hostapd_drv_sta_disassoc(hapd, addr, |
| 219 | WLAN_REASON_DISASSOC_AP_BUSY); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 220 | return -1; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 221 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 222 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 223 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 224 | |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 225 | /* |
| 226 | * ACL configurations to the drivers (implementing AP SME and ACL |
| 227 | * offload) without hostapd's knowledge, can result in a disconnection |
| 228 | * though the driver accepts the connection. Skip the hostapd check for |
| 229 | * ACL if the driver supports ACL offload to avoid potentially |
| 230 | * conflicting ACL rules. |
| 231 | */ |
| 232 | if (hapd->iface->drv_max_acl_mac_addrs == 0 && |
| 233 | hostapd_check_acl(hapd, addr, NULL) != HOSTAPD_ACL_ACCEPT) { |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 234 | wpa_printf(MSG_INFO, "STA " MACSTR " not allowed to connect", |
| 235 | MAC2STR(addr)); |
| 236 | reason = WLAN_REASON_UNSPECIFIED; |
| 237 | goto fail; |
| 238 | } |
| 239 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 240 | #ifdef CONFIG_P2P |
| 241 | if (elems.p2p) { |
| 242 | wpabuf_free(sta->p2p_ie); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 243 | 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] | 244 | P2P_IE_VENDOR_TYPE); |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 245 | if (sta->p2p_ie) |
| 246 | p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 247 | } |
| 248 | #endif /* CONFIG_P2P */ |
| 249 | |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 250 | #ifdef NEED_AP_MLME |
| 251 | if (elems.ht_capabilities && |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 252 | (hapd->iface->conf->ht_capab & |
| 253 | HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET)) { |
| 254 | struct ieee80211_ht_capabilities *ht_cap = |
| 255 | (struct ieee80211_ht_capabilities *) |
| 256 | elems.ht_capabilities; |
| 257 | |
| 258 | if (le_to_host16(ht_cap->ht_capabilities_info) & |
| 259 | HT_CAP_INFO_40MHZ_INTOLERANT) |
| 260 | ht40_intolerant_add(hapd->iface, sta); |
| 261 | } |
| 262 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 263 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 264 | check_ext_capab(hapd, sta, elems.ext_capab, elems.ext_capab_len); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 265 | |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 266 | #ifdef CONFIG_HS20 |
| 267 | wpabuf_free(sta->hs20_ie); |
| 268 | if (elems.hs20 && elems.hs20_len > 4) { |
| 269 | sta->hs20_ie = wpabuf_alloc_copy(elems.hs20 + 4, |
| 270 | elems.hs20_len - 4); |
| 271 | } else |
| 272 | sta->hs20_ie = NULL; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 273 | |
| 274 | wpabuf_free(sta->roaming_consortium); |
| 275 | if (elems.roaming_cons_sel) |
| 276 | sta->roaming_consortium = wpabuf_alloc_copy( |
| 277 | elems.roaming_cons_sel + 4, |
| 278 | elems.roaming_cons_sel_len - 4); |
| 279 | else |
| 280 | sta->roaming_consortium = NULL; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 281 | #endif /* CONFIG_HS20 */ |
| 282 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 283 | #ifdef CONFIG_FST |
| 284 | wpabuf_free(sta->mb_ies); |
| 285 | if (hapd->iface->fst) |
| 286 | sta->mb_ies = mb_ies_by_info(&elems.mb_ies); |
| 287 | else |
| 288 | sta->mb_ies = NULL; |
| 289 | #endif /* CONFIG_FST */ |
| 290 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 291 | mbo_ap_check_sta_assoc(hapd, sta, &elems); |
| 292 | |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 293 | ap_copy_sta_supp_op_classes(sta, elems.supp_op_classes, |
| 294 | elems.supp_op_classes_len); |
| 295 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 296 | if (hapd->conf->wpa) { |
| 297 | if (ie == NULL || ielen == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 298 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 299 | if (hapd->conf->wps_state) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 300 | wpa_printf(MSG_DEBUG, |
| 301 | "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] | 302 | sta->flags |= WLAN_STA_MAYBE_WPS; |
| 303 | goto skip_wpa_check; |
| 304 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 305 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 306 | |
| 307 | wpa_printf(MSG_DEBUG, "No WPA/RSN IE from STA"); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 308 | reason = WLAN_REASON_INVALID_IE; |
| 309 | status = WLAN_STATUS_INVALID_IE; |
| 310 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 311 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 312 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 313 | if (hapd->conf->wps_state && ie[0] == 0xdd && ie[1] >= 4 && |
| 314 | os_memcmp(ie + 2, "\x00\x50\xf2\x04", 4) == 0) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 315 | struct wpabuf *wps; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 316 | |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 317 | if (check_sa_query_need(hapd, sta)) { |
| 318 | status = WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY; |
| 319 | |
| 320 | p = hostapd_eid_assoc_comeback_time(hapd, sta, |
| 321 | p); |
| 322 | |
| 323 | hostapd_sta_assoc(hapd, addr, reassoc, status, |
| 324 | buf, p - buf); |
| 325 | return 0; |
| 326 | } |
| 327 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 328 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 329 | wps = ieee802_11_vendor_ie_concat(ie, ielen, |
| 330 | WPS_IE_VENDOR_TYPE); |
| 331 | if (wps) { |
| 332 | if (wps_is_20(wps)) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 333 | wpa_printf(MSG_DEBUG, |
| 334 | "WPS: STA supports WPS 2.0"); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 335 | sta->flags |= WLAN_STA_WPS2; |
| 336 | } |
| 337 | wpabuf_free(wps); |
| 338 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 339 | goto skip_wpa_check; |
| 340 | } |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 341 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 342 | |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 343 | if (check_sa_query_need(hapd, sta)) { |
| 344 | status = WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY; |
| 345 | |
| 346 | p = hostapd_eid_assoc_comeback_time(hapd, sta, p); |
| 347 | |
| 348 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, |
| 349 | p - buf); |
| 350 | return 0; |
| 351 | } |
| 352 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 353 | if (sta->wpa_sm == NULL) |
| 354 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 355 | sta->addr, |
| 356 | p2p_dev_addr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 357 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 358 | wpa_printf(MSG_ERROR, |
| 359 | "Failed to initialize WPA state machine"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 360 | return -1; |
| 361 | } |
| 362 | res = wpa_validate_wpa_ie(hapd->wpa_auth, sta->wpa_sm, |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 363 | hapd->iface->freq, |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 364 | ie, ielen, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 365 | elems.rsnxe ? elems.rsnxe - 2 : NULL, |
| 366 | elems.rsnxe ? elems.rsnxe_len + 2 : 0, |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 367 | elems.mdie, elems.mdie_len, |
| 368 | elems.owe_dh, elems.owe_dh_len); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 369 | reason = WLAN_REASON_INVALID_IE; |
| 370 | status = WLAN_STATUS_INVALID_IE; |
| 371 | switch (res) { |
| 372 | case WPA_IE_OK: |
| 373 | reason = WLAN_REASON_UNSPECIFIED; |
| 374 | status = WLAN_STATUS_SUCCESS; |
| 375 | break; |
| 376 | case WPA_INVALID_IE: |
| 377 | reason = WLAN_REASON_INVALID_IE; |
| 378 | status = WLAN_STATUS_INVALID_IE; |
| 379 | break; |
| 380 | case WPA_INVALID_GROUP: |
| 381 | reason = WLAN_REASON_GROUP_CIPHER_NOT_VALID; |
| 382 | status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; |
| 383 | break; |
| 384 | case WPA_INVALID_PAIRWISE: |
| 385 | reason = WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID; |
| 386 | status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; |
| 387 | break; |
| 388 | case WPA_INVALID_AKMP: |
| 389 | reason = WLAN_REASON_AKMP_NOT_VALID; |
| 390 | status = WLAN_STATUS_AKMP_NOT_VALID; |
| 391 | break; |
| 392 | case WPA_NOT_ENABLED: |
| 393 | reason = WLAN_REASON_INVALID_IE; |
| 394 | status = WLAN_STATUS_INVALID_IE; |
| 395 | break; |
| 396 | case WPA_ALLOC_FAIL: |
| 397 | reason = WLAN_REASON_UNSPECIFIED; |
| 398 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 399 | break; |
| 400 | case WPA_MGMT_FRAME_PROTECTION_VIOLATION: |
| 401 | reason = WLAN_REASON_INVALID_IE; |
| 402 | status = WLAN_STATUS_INVALID_IE; |
| 403 | break; |
| 404 | case WPA_INVALID_MGMT_GROUP_CIPHER: |
| 405 | reason = WLAN_REASON_CIPHER_SUITE_REJECTED; |
| 406 | status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; |
| 407 | break; |
| 408 | case WPA_INVALID_MDIE: |
| 409 | reason = WLAN_REASON_INVALID_MDE; |
| 410 | status = WLAN_STATUS_INVALID_MDIE; |
| 411 | break; |
| 412 | case WPA_INVALID_PROTO: |
| 413 | reason = WLAN_REASON_INVALID_IE; |
| 414 | status = WLAN_STATUS_INVALID_IE; |
| 415 | break; |
| 416 | case WPA_INVALID_PMKID: |
| 417 | reason = WLAN_REASON_INVALID_PMKID; |
| 418 | status = WLAN_STATUS_INVALID_PMKID; |
| 419 | break; |
| 420 | case WPA_DENIED_OTHER_REASON: |
| 421 | reason = WLAN_REASON_UNSPECIFIED; |
| 422 | status = WLAN_STATUS_ASSOC_DENIED_UNSPEC; |
| 423 | break; |
| 424 | } |
| 425 | if (status != WLAN_STATUS_SUCCESS) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 426 | wpa_printf(MSG_DEBUG, |
| 427 | "WPA/RSN information element rejected? (res %u)", |
| 428 | res); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 429 | wpa_hexdump(MSG_DEBUG, "IE", ie, ielen); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 430 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 431 | } |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 432 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 433 | if (wpa_auth_uses_mfp(sta->wpa_sm)) |
| 434 | sta->flags |= WLAN_STA_MFP; |
| 435 | else |
| 436 | sta->flags &= ~WLAN_STA_MFP; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 437 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 438 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 439 | if (sta->auth_alg == WLAN_AUTH_FT) { |
| 440 | status = wpa_ft_validate_reassoc(sta->wpa_sm, req_ies, |
| 441 | req_ies_len); |
| 442 | if (status != WLAN_STATUS_SUCCESS) { |
| 443 | if (status == WLAN_STATUS_INVALID_PMKID) |
| 444 | reason = WLAN_REASON_INVALID_IE; |
| 445 | if (status == WLAN_STATUS_INVALID_MDIE) |
| 446 | reason = WLAN_REASON_INVALID_IE; |
| 447 | if (status == WLAN_STATUS_INVALID_FTIE) |
| 448 | reason = WLAN_REASON_INVALID_IE; |
| 449 | goto fail; |
| 450 | } |
| 451 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 452 | #endif /* CONFIG_IEEE80211R_AP */ |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 453 | #ifdef CONFIG_SAE |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 454 | if (hapd->conf->sae_pwe == SAE_PWE_BOTH && |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 455 | sta->auth_alg == WLAN_AUTH_SAE && |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 456 | sta->sae && !sta->sae->h2e && |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 457 | ieee802_11_rsnx_capab_len(elems.rsnxe, elems.rsnxe_len, |
| 458 | WLAN_RSNX_CAPAB_SAE_H2E)) { |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 459 | wpa_printf(MSG_INFO, "SAE: " MACSTR |
| 460 | " indicates support for SAE H2E, but did not use it", |
| 461 | MAC2STR(sta->addr)); |
| 462 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 463 | reason = WLAN_REASON_UNSPECIFIED; |
| 464 | goto fail; |
| 465 | } |
| 466 | #endif /* CONFIG_SAE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 467 | } else if (hapd->conf->wps_state) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 468 | #ifdef CONFIG_WPS |
| 469 | struct wpabuf *wps; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 470 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 471 | if (req_ies) |
| 472 | wps = ieee802_11_vendor_ie_concat(req_ies, req_ies_len, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 473 | WPS_IE_VENDOR_TYPE); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 474 | else |
| 475 | wps = NULL; |
| 476 | #ifdef CONFIG_WPS_STRICT |
| 477 | if (wps && wps_validate_assoc_req(wps) < 0) { |
| 478 | reason = WLAN_REASON_INVALID_IE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 479 | status = WLAN_STATUS_INVALID_IE; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 480 | wpabuf_free(wps); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 481 | goto fail; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 482 | } |
| 483 | #endif /* CONFIG_WPS_STRICT */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 484 | if (wps) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 485 | sta->flags |= WLAN_STA_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 486 | if (wps_is_20(wps)) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 487 | wpa_printf(MSG_DEBUG, |
| 488 | "WPS: STA supports WPS 2.0"); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 489 | sta->flags |= WLAN_STA_WPS2; |
| 490 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 491 | } else |
| 492 | sta->flags |= WLAN_STA_MAYBE_WPS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 493 | wpabuf_free(wps); |
| 494 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 495 | #ifdef CONFIG_HS20 |
| 496 | } else if (hapd->conf->osen) { |
| 497 | if (elems.osen == NULL) { |
| 498 | hostapd_logger( |
| 499 | hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 500 | HOSTAPD_LEVEL_INFO, |
| 501 | "No HS 2.0 OSEN element in association request"); |
| 502 | return WLAN_STATUS_INVALID_IE; |
| 503 | } |
| 504 | |
| 505 | wpa_printf(MSG_DEBUG, "HS 2.0: OSEN association"); |
| 506 | if (sta->wpa_sm == NULL) |
| 507 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
| 508 | sta->addr, NULL); |
| 509 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 510 | wpa_printf(MSG_WARNING, |
| 511 | "Failed to initialize WPA state machine"); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 512 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 513 | } |
| 514 | if (wpa_validate_osen(hapd->wpa_auth, sta->wpa_sm, |
| 515 | elems.osen - 2, elems.osen_len + 2) < 0) |
| 516 | return WLAN_STATUS_INVALID_IE; |
| 517 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 518 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 519 | #ifdef CONFIG_WPS |
| 520 | skip_wpa_check: |
| 521 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 522 | |
| 523 | #ifdef CONFIG_MBO |
| 524 | if (hapd->conf->mbo_enabled && (hapd->conf->wpa & 2) && |
| 525 | elems.mbo && sta->cell_capa && !(sta->flags & WLAN_STA_MFP) && |
| 526 | hapd->conf->ieee80211w != NO_MGMT_FRAME_PROTECTION) { |
| 527 | wpa_printf(MSG_INFO, |
| 528 | "MBO: Reject WPA2 association without PMF"); |
| 529 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 530 | } |
| 531 | #endif /* CONFIG_MBO */ |
| 532 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 533 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 534 | 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] | 535 | sta->auth_alg, req_ies, req_ies_len, |
| 536 | !elems.rsnxe); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 537 | if (!p) { |
| 538 | wpa_printf(MSG_DEBUG, "FT: Failed to write AssocResp IEs"); |
| 539 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 540 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 541 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 542 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 543 | #ifdef CONFIG_FILS |
| 544 | if (sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 545 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 546 | sta->auth_alg == WLAN_AUTH_FILS_PK) { |
| 547 | int delay_assoc = 0; |
| 548 | |
| 549 | if (!req_ies) |
| 550 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 551 | |
| 552 | if (!wpa_fils_validate_fils_session(sta->wpa_sm, req_ies, |
| 553 | req_ies_len, |
| 554 | sta->fils_session)) { |
| 555 | wpa_printf(MSG_DEBUG, |
| 556 | "FILS: Session validation failed"); |
| 557 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 558 | } |
| 559 | |
| 560 | res = wpa_fils_validate_key_confirm(sta->wpa_sm, req_ies, |
| 561 | req_ies_len); |
| 562 | if (res < 0) { |
| 563 | wpa_printf(MSG_DEBUG, |
| 564 | "FILS: Key Confirm validation failed"); |
| 565 | return WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 566 | } |
| 567 | |
| 568 | if (fils_process_hlp(hapd, sta, req_ies, req_ies_len) > 0) { |
| 569 | wpa_printf(MSG_DEBUG, |
| 570 | "FILS: Delaying Assoc Response (HLP)"); |
| 571 | delay_assoc = 1; |
| 572 | } else { |
| 573 | wpa_printf(MSG_DEBUG, |
| 574 | "FILS: Going ahead with Assoc Response (no HLP)"); |
| 575 | } |
| 576 | |
| 577 | if (sta) { |
| 578 | wpa_printf(MSG_DEBUG, "FILS: HLP callback cleanup"); |
| 579 | eloop_cancel_timeout(fils_hlp_timeout, hapd, sta); |
| 580 | os_free(sta->fils_pending_assoc_req); |
| 581 | sta->fils_pending_assoc_req = NULL; |
| 582 | sta->fils_pending_assoc_req_len = 0; |
| 583 | wpabuf_free(sta->fils_hlp_resp); |
| 584 | sta->fils_hlp_resp = NULL; |
| 585 | sta->fils_drv_assoc_finish = 0; |
| 586 | } |
| 587 | |
| 588 | if (sta && delay_assoc && status == WLAN_STATUS_SUCCESS) { |
| 589 | u8 *req_tmp; |
| 590 | |
| 591 | req_tmp = os_malloc(req_ies_len); |
| 592 | if (!req_tmp) { |
| 593 | wpa_printf(MSG_DEBUG, |
| 594 | "FILS: buffer allocation failed for assoc req"); |
| 595 | goto fail; |
| 596 | } |
| 597 | os_memcpy(req_tmp, req_ies, req_ies_len); |
| 598 | sta->fils_pending_assoc_req = req_tmp; |
| 599 | sta->fils_pending_assoc_req_len = req_ies_len; |
| 600 | sta->fils_pending_assoc_is_reassoc = reassoc; |
| 601 | sta->fils_drv_assoc_finish = 1; |
| 602 | wpa_printf(MSG_DEBUG, |
| 603 | "FILS: Waiting for HLP processing before sending (Re)Association Response frame to " |
| 604 | MACSTR, MAC2STR(sta->addr)); |
| 605 | eloop_register_timeout( |
| 606 | 0, hapd->conf->fils_hlp_wait_time * 1024, |
| 607 | fils_hlp_timeout, hapd, sta); |
| 608 | return 0; |
| 609 | } |
| 610 | p = hostapd_eid_assoc_fils_session(sta->wpa_sm, p, |
| 611 | elems.fils_session, |
| 612 | sta->fils_hlp_resp); |
| 613 | wpa_hexdump(MSG_DEBUG, "FILS Assoc Resp BUF (IEs)", |
| 614 | buf, p - buf); |
| 615 | } |
| 616 | #endif /* CONFIG_FILS */ |
| 617 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 618 | #ifdef CONFIG_OWE |
| 619 | if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE) && |
| 620 | wpa_auth_sta_key_mgmt(sta->wpa_sm) == WPA_KEY_MGMT_OWE && |
| 621 | elems.owe_dh) { |
| 622 | u8 *npos; |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 623 | u16 ret_status; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 624 | |
| 625 | npos = owe_assoc_req_process(hapd, sta, |
| 626 | elems.owe_dh, elems.owe_dh_len, |
| 627 | p, sizeof(buf) - (p - buf), |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 628 | &ret_status); |
| 629 | status = ret_status; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 630 | if (npos) |
| 631 | p = npos; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 632 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 633 | if (!npos && |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 634 | status == WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED) { |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 635 | hostapd_sta_assoc(hapd, addr, reassoc, ret_status, buf, |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 636 | p - buf); |
| 637 | return 0; |
| 638 | } |
| 639 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 640 | if (!npos || status != WLAN_STATUS_SUCCESS) |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 641 | goto fail; |
| 642 | } |
| 643 | #endif /* CONFIG_OWE */ |
| 644 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 645 | #ifdef CONFIG_DPP2 |
| 646 | dpp_pfs_free(sta->dpp_pfs); |
| 647 | sta->dpp_pfs = NULL; |
| 648 | |
| 649 | if ((hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_DPP) && |
| 650 | hapd->conf->dpp_netaccesskey && sta->wpa_sm && |
| 651 | wpa_auth_sta_key_mgmt(sta->wpa_sm) == WPA_KEY_MGMT_DPP && |
| 652 | elems.owe_dh) { |
| 653 | sta->dpp_pfs = dpp_pfs_init( |
| 654 | wpabuf_head(hapd->conf->dpp_netaccesskey), |
| 655 | wpabuf_len(hapd->conf->dpp_netaccesskey)); |
| 656 | if (!sta->dpp_pfs) { |
| 657 | wpa_printf(MSG_DEBUG, |
| 658 | "DPP: Could not initialize PFS"); |
| 659 | /* Try to continue without PFS */ |
| 660 | goto pfs_fail; |
| 661 | } |
| 662 | |
| 663 | if (dpp_pfs_process(sta->dpp_pfs, elems.owe_dh, |
| 664 | elems.owe_dh_len) < 0) { |
| 665 | dpp_pfs_free(sta->dpp_pfs); |
| 666 | sta->dpp_pfs = NULL; |
| 667 | reason = WLAN_REASON_UNSPECIFIED; |
| 668 | goto fail; |
| 669 | } |
| 670 | } |
| 671 | |
| 672 | wpa_auth_set_dpp_z(sta->wpa_sm, sta->dpp_pfs ? |
| 673 | sta->dpp_pfs->secret : NULL); |
| 674 | pfs_fail: |
| 675 | #endif /* CONFIG_DPP2 */ |
| 676 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 677 | if (elems.rrm_enabled && |
| 678 | elems.rrm_enabled_len >= sizeof(sta->rrm_enabled_capa)) |
| 679 | os_memcpy(sta->rrm_enabled_capa, elems.rrm_enabled, |
| 680 | sizeof(sta->rrm_enabled_capa)); |
| 681 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 682 | #if defined(CONFIG_IEEE80211R_AP) || defined(CONFIG_FILS) || defined(CONFIG_OWE) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 683 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 684 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 685 | if (sta->auth_alg == WLAN_AUTH_FT || |
| 686 | sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 687 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 688 | sta->auth_alg == WLAN_AUTH_FILS_PK) |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 689 | ap_sta_set_authorized(hapd, sta, 1); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 690 | #else /* CONFIG_IEEE80211R_AP || CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 691 | /* Keep compiler silent about unused variables */ |
| 692 | if (status) { |
| 693 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 694 | #endif /* CONFIG_IEEE80211R_AP || CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 695 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 696 | new_assoc = (sta->flags & WLAN_STA_ASSOC) == 0; |
| 697 | sta->flags |= WLAN_STA_AUTH | WLAN_STA_ASSOC; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 698 | sta->flags &= ~WLAN_STA_WNM_SLEEP_MODE; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 699 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 700 | hostapd_set_sta_flags(hapd, sta); |
| 701 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 702 | if (reassoc && (sta->auth_alg == WLAN_AUTH_FT)) |
| 703 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 704 | #ifdef CONFIG_FILS |
| 705 | else if (sta->auth_alg == WLAN_AUTH_FILS_SK || |
| 706 | sta->auth_alg == WLAN_AUTH_FILS_SK_PFS || |
| 707 | sta->auth_alg == WLAN_AUTH_FILS_PK) |
| 708 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FILS); |
| 709 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 710 | else |
| 711 | wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 712 | |
| 713 | hostapd_new_assoc_sta(hapd, sta, !new_assoc); |
| 714 | |
| 715 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 1); |
| 716 | |
| 717 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 718 | if (req_ies) { |
| 719 | p2p_group_notif_assoc(hapd->p2p_group, sta->addr, |
| 720 | req_ies, req_ies_len); |
| 721 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 722 | #endif /* CONFIG_P2P */ |
| 723 | |
| 724 | return 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 725 | |
| 726 | fail: |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 727 | #ifdef CONFIG_IEEE80211R_AP |
Hai Shalom | b755a2a | 2020-04-23 21:49:02 -0700 | [diff] [blame] | 728 | if (status >= 0) |
| 729 | hostapd_sta_assoc(hapd, addr, reassoc, status, buf, p - buf); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 730 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 731 | hostapd_drv_sta_disassoc(hapd, sta->addr, reason); |
| 732 | ap_free_sta(hapd, sta); |
| 733 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | |
| 737 | void hostapd_notif_disassoc(struct hostapd_data *hapd, const u8 *addr) |
| 738 | { |
| 739 | struct sta_info *sta; |
| 740 | |
| 741 | if (addr == NULL) { |
| 742 | /* |
| 743 | * This could potentially happen with unexpected event from the |
| 744 | * driver wrapper. This was seen at least in one case where the |
| 745 | * driver ended up reporting a station mode event while hostapd |
| 746 | * was running, so better make sure we stop processing such an |
| 747 | * event here. |
| 748 | */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 749 | wpa_printf(MSG_DEBUG, |
| 750 | "hostapd_notif_disassoc: Skip event with no address"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 751 | return; |
| 752 | } |
| 753 | |
| 754 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
| 755 | HOSTAPD_LEVEL_INFO, "disassociated"); |
| 756 | |
| 757 | sta = ap_get_sta(hapd, addr); |
| 758 | if (sta == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 759 | wpa_printf(MSG_DEBUG, |
| 760 | "Disassociation notification for unknown STA " |
| 761 | MACSTR, MAC2STR(addr)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 762 | return; |
| 763 | } |
| 764 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 765 | ap_sta_set_authorized(hapd, sta, 0); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 766 | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 767 | hostapd_set_sta_flags(hapd, sta); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 768 | wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC); |
| 769 | sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST; |
| 770 | ieee802_1x_notify_port_enabled(sta->eapol_sm, 0); |
| 771 | ap_free_sta(hapd, sta); |
| 772 | } |
| 773 | |
| 774 | |
| 775 | void hostapd_event_sta_low_ack(struct hostapd_data *hapd, const u8 *addr) |
| 776 | { |
| 777 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 778 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 779 | if (!sta || !hapd->conf->disassoc_low_ack || sta->agreed_to_steer) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 780 | return; |
| 781 | |
| 782 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 783 | HOSTAPD_LEVEL_INFO, |
| 784 | "disconnected due to excessive missing ACKs"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 785 | hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_DISASSOC_LOW_ACK); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 786 | ap_sta_disassociate(hapd, sta, WLAN_REASON_DISASSOC_LOW_ACK); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 790 | void hostapd_event_sta_opmode_changed(struct hostapd_data *hapd, const u8 *addr, |
| 791 | enum smps_mode smps_mode, |
| 792 | enum chan_width chan_width, u8 rx_nss) |
| 793 | { |
| 794 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 795 | const char *txt; |
| 796 | |
| 797 | if (!sta) |
| 798 | return; |
| 799 | |
| 800 | switch (smps_mode) { |
| 801 | case SMPS_AUTOMATIC: |
| 802 | txt = "automatic"; |
| 803 | break; |
| 804 | case SMPS_OFF: |
| 805 | txt = "off"; |
| 806 | break; |
| 807 | case SMPS_DYNAMIC: |
| 808 | txt = "dynamic"; |
| 809 | break; |
| 810 | case SMPS_STATIC: |
| 811 | txt = "static"; |
| 812 | break; |
| 813 | default: |
| 814 | txt = NULL; |
| 815 | break; |
| 816 | } |
| 817 | if (txt) { |
| 818 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_SMPS_MODE_CHANGED |
| 819 | MACSTR " %s", MAC2STR(addr), txt); |
| 820 | } |
| 821 | |
| 822 | switch (chan_width) { |
| 823 | case CHAN_WIDTH_20_NOHT: |
| 824 | txt = "20(no-HT)"; |
| 825 | break; |
| 826 | case CHAN_WIDTH_20: |
| 827 | txt = "20"; |
| 828 | break; |
| 829 | case CHAN_WIDTH_40: |
| 830 | txt = "40"; |
| 831 | break; |
| 832 | case CHAN_WIDTH_80: |
| 833 | txt = "80"; |
| 834 | break; |
| 835 | case CHAN_WIDTH_80P80: |
| 836 | txt = "80+80"; |
| 837 | break; |
| 838 | case CHAN_WIDTH_160: |
| 839 | txt = "160"; |
| 840 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 841 | case CHAN_WIDTH_320: |
| 842 | txt = "320"; |
| 843 | break; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 844 | default: |
| 845 | txt = NULL; |
| 846 | break; |
| 847 | } |
| 848 | if (txt) { |
| 849 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_MAX_BW_CHANGED |
| 850 | MACSTR " %s", MAC2STR(addr), txt); |
| 851 | } |
| 852 | |
| 853 | if (rx_nss != 0xff) { |
| 854 | wpa_msg(hapd->msg_ctx, MSG_INFO, STA_OPMODE_N_SS_CHANGED |
| 855 | MACSTR " %d", MAC2STR(addr), rx_nss); |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 860 | 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] | 861 | int offset, int width, int cf1, int cf2, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 862 | u16 punct_bitmap, int finished) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 863 | { |
| 864 | #ifdef NEED_AP_MLME |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 865 | int channel, chwidth, is_dfs0, is_dfs; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 866 | u8 seg0_idx = 0, seg1_idx = 0; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 867 | size_t i; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 868 | |
| 869 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 870 | HOSTAPD_LEVEL_INFO, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 871 | "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] | 872 | finished ? "had" : "starting", |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 873 | hapd->iface->freq, |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 874 | freq, ht, hapd->iconf->ch_switch_vht_config, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 875 | hapd->iconf->ch_switch_he_config, |
| 876 | hapd->iconf->ch_switch_eht_config, offset, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 877 | width, channel_width_to_string(width), cf1, cf2, |
| 878 | punct_bitmap); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 879 | |
Hai Shalom | 1dc4d20 | 2019-04-29 16:22:27 -0700 | [diff] [blame] | 880 | if (!hapd->iface->current_mode) { |
| 881 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 882 | HOSTAPD_LEVEL_WARNING, |
| 883 | "ignore channel switch since the interface is not yet ready"); |
| 884 | return; |
| 885 | } |
| 886 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 887 | /* Check if any of configured channels require DFS */ |
| 888 | is_dfs0 = hostapd_is_dfs_required(hapd->iface); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 889 | hapd->iface->freq = freq; |
| 890 | |
| 891 | channel = hostapd_hw_get_channel(hapd, freq); |
| 892 | if (!channel) { |
| 893 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 894 | HOSTAPD_LEVEL_WARNING, |
| 895 | "driver switched to bad channel!"); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 896 | return; |
| 897 | } |
| 898 | |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 899 | switch (width) { |
| 900 | case CHAN_WIDTH_80: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 901 | chwidth = CONF_OPER_CHWIDTH_80MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 902 | break; |
| 903 | case CHAN_WIDTH_80P80: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 904 | chwidth = CONF_OPER_CHWIDTH_80P80MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 905 | break; |
| 906 | case CHAN_WIDTH_160: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 907 | chwidth = CONF_OPER_CHWIDTH_160MHZ; |
| 908 | break; |
| 909 | case CHAN_WIDTH_320: |
| 910 | chwidth = CONF_OPER_CHWIDTH_320MHZ; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 911 | break; |
| 912 | case CHAN_WIDTH_20_NOHT: |
| 913 | case CHAN_WIDTH_20: |
| 914 | case CHAN_WIDTH_40: |
| 915 | default: |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 916 | chwidth = CONF_OPER_CHWIDTH_USE_HT; |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 917 | break; |
| 918 | } |
| 919 | |
| 920 | switch (hapd->iface->current_mode->mode) { |
| 921 | case HOSTAPD_MODE_IEEE80211A: |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 922 | if (cf1 == 5935) |
| 923 | seg0_idx = (cf1 - 5925) / 5; |
| 924 | else if (cf1 > 5950) |
| 925 | seg0_idx = (cf1 - 5950) / 5; |
| 926 | else if (cf1 > 5000) |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 927 | seg0_idx = (cf1 - 5000) / 5; |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 928 | |
| 929 | if (cf2 == 5935) |
| 930 | seg1_idx = (cf2 - 5925) / 5; |
| 931 | else if (cf2 > 5950) |
| 932 | seg1_idx = (cf2 - 5950) / 5; |
| 933 | else if (cf2 > 5000) |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 934 | seg1_idx = (cf2 - 5000) / 5; |
| 935 | break; |
| 936 | default: |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 937 | ieee80211_freq_to_chan(cf1, &seg0_idx); |
| 938 | ieee80211_freq_to_chan(cf2, &seg1_idx); |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 939 | break; |
| 940 | } |
| 941 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 942 | hapd->iconf->channel = channel; |
| 943 | hapd->iconf->ieee80211n = ht; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 944 | if (!ht) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 945 | hapd->iconf->ieee80211ac = 0; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 946 | } else if (hapd->iconf->ch_switch_vht_config) { |
| 947 | /* CHAN_SWITCH VHT config */ |
| 948 | if (hapd->iconf->ch_switch_vht_config & |
| 949 | CH_SWITCH_VHT_ENABLED) |
| 950 | hapd->iconf->ieee80211ac = 1; |
| 951 | else if (hapd->iconf->ch_switch_vht_config & |
| 952 | CH_SWITCH_VHT_DISABLED) |
| 953 | hapd->iconf->ieee80211ac = 0; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 954 | } else if (hapd->iconf->ch_switch_he_config) { |
| 955 | /* CHAN_SWITCH HE config */ |
| 956 | if (hapd->iconf->ch_switch_he_config & |
| 957 | CH_SWITCH_HE_ENABLED) |
| 958 | hapd->iconf->ieee80211ax = 1; |
| 959 | else if (hapd->iconf->ch_switch_he_config & |
| 960 | CH_SWITCH_HE_DISABLED) |
| 961 | hapd->iconf->ieee80211ax = 0; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 962 | #ifdef CONFIG_IEEE80211BE |
| 963 | } else if (hapd->iconf->ch_switch_eht_config) { |
| 964 | /* CHAN_SWITCH EHT config */ |
| 965 | if (hapd->iconf->ch_switch_eht_config & |
| 966 | CH_SWITCH_EHT_ENABLED) { |
| 967 | hapd->iconf->ieee80211be = 1; |
| 968 | hapd->iconf->ieee80211ax = 1; |
| 969 | if (!is_6ghz_freq(hapd->iface->freq)) |
| 970 | hapd->iconf->ieee80211ac = 1; |
| 971 | } else if (hapd->iconf->ch_switch_eht_config & |
| 972 | CH_SWITCH_EHT_DISABLED) |
| 973 | hapd->iconf->ieee80211be = 0; |
| 974 | #endif /* CONFIG_IEEE80211BE */ |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 975 | } |
| 976 | hapd->iconf->ch_switch_vht_config = 0; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 977 | hapd->iconf->ch_switch_he_config = 0; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 978 | hapd->iconf->ch_switch_eht_config = 0; |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 979 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 980 | if (width == CHAN_WIDTH_40 || width == CHAN_WIDTH_80 || |
| 981 | width == CHAN_WIDTH_80P80 || width == CHAN_WIDTH_160) |
| 982 | hapd->iconf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 983 | else if (width == CHAN_WIDTH_20 || width == CHAN_WIDTH_20_NOHT) |
| 984 | hapd->iconf->ht_capab &= ~HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET; |
| 985 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 986 | hapd->iconf->secondary_channel = offset; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 987 | hostapd_set_oper_chwidth(hapd->iconf, chwidth); |
| 988 | hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, seg0_idx); |
| 989 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, seg1_idx); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 990 | #ifdef CONFIG_IEEE80211BE |
| 991 | hapd->iconf->punct_bitmap = punct_bitmap; |
| 992 | #endif /* CONFIG_IEEE80211BE */ |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 993 | if (hapd->iconf->ieee80211ac) { |
| 994 | hapd->iconf->vht_capab &= ~VHT_CAP_SUPP_CHAN_WIDTH_MASK; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 995 | if (chwidth == CONF_OPER_CHWIDTH_160MHZ) |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 996 | hapd->iconf->vht_capab |= |
| 997 | VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 998 | else if (chwidth == CONF_OPER_CHWIDTH_80P80MHZ) |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 999 | hapd->iconf->vht_capab |= |
| 1000 | VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
| 1001 | } |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1002 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1003 | is_dfs = ieee80211_is_dfs(freq, hapd->iface->hw_features, |
| 1004 | hapd->iface->num_hw_features); |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1005 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1006 | wpa_msg(hapd->msg_ctx, MSG_INFO, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 1007 | "%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] | 1008 | finished ? WPA_EVENT_CHANNEL_SWITCH : |
| 1009 | WPA_EVENT_CHANNEL_SWITCH_STARTED, |
| 1010 | freq, ht, offset, channel_width_to_string(width), |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 1011 | cf1, cf2, is_dfs0, is_dfs, punct_bitmap); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1012 | if (!finished) |
| 1013 | return; |
| 1014 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1015 | if (hapd->csa_in_progress && |
| 1016 | freq == hapd->cs_freq_params.freq) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1017 | hostapd_cleanup_cs_params(hapd); |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1018 | ieee802_11_set_beacon(hapd); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1019 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1020 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED |
| 1021 | "freq=%d dfs=%d", freq, is_dfs); |
| 1022 | } else if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) { |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1023 | /* Complete AP configuration for the first bring up. */ |
| 1024 | if (is_dfs0 > 0 && |
| 1025 | hostapd_is_dfs_required(hapd->iface) <= 0 && |
| 1026 | hapd->iface->state != HAPD_IFACE_ENABLED) { |
| 1027 | /* Fake a CAC start bit to skip setting channel */ |
| 1028 | hapd->iface->cac_started = 1; |
| 1029 | hostapd_setup_interface_complete(hapd->iface, 0); |
| 1030 | } |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1031 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_CSA_FINISHED |
| 1032 | "freq=%d dfs=%d", freq, is_dfs); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1033 | } else if (is_dfs && |
| 1034 | hostapd_is_dfs_required(hapd->iface) && |
| 1035 | !hostapd_is_dfs_chan_available(hapd->iface) && |
| 1036 | !hapd->iface->cac_started) { |
| 1037 | hostapd_disable_iface(hapd->iface); |
| 1038 | hostapd_enable_iface(hapd->iface); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1039 | } |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1040 | |
| 1041 | for (i = 0; i < hapd->iface->num_bss; i++) |
| 1042 | hostapd_neighbor_set_own_report(hapd->iface->bss[i]); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1043 | |
| 1044 | #ifdef CONFIG_OCV |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1045 | if (hapd->conf->ocv && |
| 1046 | !(hapd->iface->drv_flags2 & |
| 1047 | WPA_DRIVER_FLAGS2_SA_QUERY_OFFLOAD_AP)) { |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1048 | struct sta_info *sta; |
| 1049 | bool check_sa_query = false; |
| 1050 | |
| 1051 | for (sta = hapd->sta_list; sta; sta = sta->next) { |
| 1052 | if (wpa_auth_uses_ocv(sta->wpa_sm) && |
| 1053 | !(sta->flags & WLAN_STA_WNM_SLEEP_MODE)) { |
| 1054 | sta->post_csa_sa_query = 1; |
| 1055 | check_sa_query = true; |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | if (check_sa_query) { |
| 1060 | wpa_printf(MSG_DEBUG, |
| 1061 | "OCV: Check post-CSA SA Query initiation in 15 seconds"); |
| 1062 | eloop_register_timeout(15, 0, |
| 1063 | hostapd_ocv_check_csa_sa_query, |
| 1064 | hapd, NULL); |
| 1065 | } |
| 1066 | } |
| 1067 | #endif /* CONFIG_OCV */ |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1068 | #endif /* NEED_AP_MLME */ |
| 1069 | } |
| 1070 | |
| 1071 | |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 1072 | void hostapd_event_connect_failed_reason(struct hostapd_data *hapd, |
| 1073 | const u8 *addr, int reason_code) |
| 1074 | { |
| 1075 | switch (reason_code) { |
| 1076 | case MAX_CLIENT_REACHED: |
| 1077 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_MAX_STA MACSTR, |
| 1078 | MAC2STR(addr)); |
| 1079 | break; |
| 1080 | case BLOCKED_CLIENT: |
| 1081 | wpa_msg(hapd->msg_ctx, MSG_INFO, AP_REJECTED_BLOCKED_STA MACSTR, |
| 1082 | MAC2STR(addr)); |
| 1083 | break; |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1088 | #ifdef CONFIG_ACS |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 1089 | void hostapd_acs_channel_selected(struct hostapd_data *hapd, |
| 1090 | struct acs_selected_channels *acs_res) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1091 | { |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1092 | int ret, i; |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1093 | int err = 0; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1094 | struct hostapd_channel_data *pri_chan; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1095 | |
| 1096 | if (hapd->iconf->channel) { |
| 1097 | wpa_printf(MSG_INFO, "ACS: Channel was already set to %d", |
| 1098 | hapd->iconf->channel); |
| 1099 | return; |
| 1100 | } |
| 1101 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1102 | hapd->iface->freq = acs_res->pri_freq; |
| 1103 | |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1104 | if (!hapd->iface->current_mode) { |
| 1105 | for (i = 0; i < hapd->iface->num_hw_features; i++) { |
| 1106 | struct hostapd_hw_modes *mode = |
| 1107 | &hapd->iface->hw_features[i]; |
| 1108 | |
| 1109 | if (mode->mode == acs_res->hw_mode) { |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1110 | if (hapd->iface->freq > 0 && |
| 1111 | !hw_get_chan(mode->mode, |
| 1112 | hapd->iface->freq, |
| 1113 | hapd->iface->hw_features, |
| 1114 | hapd->iface->num_hw_features)) |
| 1115 | continue; |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1116 | hapd->iface->current_mode = mode; |
| 1117 | break; |
| 1118 | } |
| 1119 | } |
| 1120 | if (!hapd->iface->current_mode) { |
| 1121 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 1122 | HOSTAPD_LEVEL_WARNING, |
| 1123 | "driver selected to bad hw_mode"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1124 | err = 1; |
| 1125 | goto out; |
Dmitry Shmidt | b1e5210 | 2015-05-29 12:36:29 -0700 | [diff] [blame] | 1126 | } |
| 1127 | } |
| 1128 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1129 | if (!acs_res->pri_freq) { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1130 | hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211, |
| 1131 | HOSTAPD_LEVEL_WARNING, |
| 1132 | "driver switched to bad channel"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1133 | err = 1; |
| 1134 | goto out; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1135 | } |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1136 | pri_chan = hw_get_channel_freq(hapd->iface->current_mode->mode, |
| 1137 | acs_res->pri_freq, NULL, |
| 1138 | hapd->iface->hw_features, |
| 1139 | hapd->iface->num_hw_features); |
| 1140 | if (!pri_chan) { |
| 1141 | wpa_printf(MSG_ERROR, |
| 1142 | "ACS: Could not determine primary channel number from pri_freq %u", |
| 1143 | acs_res->pri_freq); |
| 1144 | err = 1; |
| 1145 | goto out; |
| 1146 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1147 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1148 | hapd->iconf->channel = pri_chan->chan; |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1149 | hapd->iconf->acs = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1150 | |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1151 | if (acs_res->sec_freq == 0) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1152 | hapd->iconf->secondary_channel = 0; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1153 | else if (acs_res->sec_freq < acs_res->pri_freq) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1154 | hapd->iconf->secondary_channel = -1; |
Ahmed ElArabawy | 0ff61c5 | 2019-12-26 12:38:39 -0800 | [diff] [blame] | 1155 | else if (acs_res->sec_freq > acs_res->pri_freq) |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1156 | hapd->iconf->secondary_channel = 1; |
| 1157 | else { |
| 1158 | wpa_printf(MSG_ERROR, "Invalid secondary channel!"); |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1159 | err = 1; |
| 1160 | goto out; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1161 | } |
| 1162 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1163 | hapd->iconf->edmg_channel = acs_res->edmg_channel; |
| 1164 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1165 | if (hapd->iface->conf->ieee80211ac || hapd->iface->conf->ieee80211ax) { |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1166 | /* set defaults for backwards compatibility */ |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1167 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); |
| 1168 | hostapd_set_oper_centr_freq_seg0_idx(hapd->iconf, 0); |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1169 | hostapd_set_oper_chwidth(hapd->iconf, CONF_OPER_CHWIDTH_USE_HT); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1170 | if (acs_res->ch_width == 40) { |
| 1171 | if (is_6ghz_freq(acs_res->pri_freq)) |
| 1172 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1173 | hapd->iconf, |
| 1174 | acs_res->vht_seg0_center_ch); |
| 1175 | } else if (acs_res->ch_width == 80) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1176 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1177 | hapd->iconf, acs_res->vht_seg0_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1178 | if (acs_res->vht_seg1_center_ch == 0) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1179 | hostapd_set_oper_chwidth( |
| 1180 | hapd->iconf, CONF_OPER_CHWIDTH_80MHZ); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1181 | } else { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1182 | hostapd_set_oper_chwidth( |
| 1183 | hapd->iconf, |
| 1184 | CONF_OPER_CHWIDTH_80P80MHZ); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1185 | hostapd_set_oper_centr_freq_seg1_idx( |
| 1186 | hapd->iconf, |
| 1187 | acs_res->vht_seg1_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1188 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1189 | } else if (acs_res->ch_width == 160) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1190 | hostapd_set_oper_chwidth(hapd->iconf, |
| 1191 | CONF_OPER_CHWIDTH_160MHZ); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1192 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1193 | hapd->iconf, acs_res->vht_seg1_center_ch); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 1194 | } |
| 1195 | } |
| 1196 | |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1197 | #ifdef CONFIG_IEEE80211BE |
| 1198 | if (hapd->iface->conf->ieee80211be && acs_res->ch_width == 320) { |
| 1199 | hostapd_set_oper_chwidth(hapd->iconf, CONF_OPER_CHWIDTH_320MHZ); |
| 1200 | hostapd_set_oper_centr_freq_seg0_idx( |
| 1201 | hapd->iconf, acs_res->vht_seg1_center_ch); |
| 1202 | hostapd_set_oper_centr_freq_seg1_idx(hapd->iconf, 0); |
| 1203 | } |
| 1204 | #endif /* CONFIG_IEEE80211BE */ |
| 1205 | |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 1206 | out: |
| 1207 | ret = hostapd_acs_completed(hapd->iface, err); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1208 | if (ret) { |
| 1209 | wpa_printf(MSG_ERROR, |
| 1210 | "ACS: Possibly channel configuration is invalid"); |
| 1211 | } |
| 1212 | } |
| 1213 | #endif /* CONFIG_ACS */ |
| 1214 | |
| 1215 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1216 | 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] | 1217 | const u8 *bssid, const u8 *ie, size_t ie_len, |
| 1218 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1219 | { |
| 1220 | size_t i; |
| 1221 | int ret = 0; |
| 1222 | |
| 1223 | if (sa == NULL || ie == NULL) |
| 1224 | return -1; |
| 1225 | |
| 1226 | random_add_randomness(sa, ETH_ALEN); |
| 1227 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) { |
| 1228 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1229 | sa, da, bssid, ie, ie_len, |
| 1230 | ssi_signal) > 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1231 | ret = 1; |
| 1232 | break; |
| 1233 | } |
| 1234 | } |
| 1235 | return ret; |
| 1236 | } |
| 1237 | |
| 1238 | |
| 1239 | #ifdef HOSTAPD |
| 1240 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1241 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1242 | static void hostapd_notify_auth_ft_finish(void *ctx, const u8 *dst, |
| 1243 | const u8 *bssid, |
| 1244 | u16 auth_transaction, u16 status, |
| 1245 | const u8 *ies, size_t ies_len) |
| 1246 | { |
| 1247 | struct hostapd_data *hapd = ctx; |
| 1248 | struct sta_info *sta; |
| 1249 | |
| 1250 | sta = ap_get_sta(hapd, dst); |
| 1251 | if (sta == NULL) |
| 1252 | return; |
| 1253 | |
| 1254 | hostapd_logger(hapd, dst, HOSTAPD_MODULE_IEEE80211, |
| 1255 | HOSTAPD_LEVEL_DEBUG, "authentication OK (FT)"); |
| 1256 | sta->flags |= WLAN_STA_AUTH; |
| 1257 | |
| 1258 | hostapd_sta_auth(hapd, dst, auth_transaction, status, ies, ies_len); |
| 1259 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1260 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1261 | |
| 1262 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1263 | #ifdef CONFIG_FILS |
| 1264 | static void hostapd_notify_auth_fils_finish(struct hostapd_data *hapd, |
| 1265 | struct sta_info *sta, u16 resp, |
| 1266 | struct wpabuf *data, int pub) |
| 1267 | { |
| 1268 | if (resp == WLAN_STATUS_SUCCESS) { |
| 1269 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 1270 | HOSTAPD_LEVEL_DEBUG, "authentication OK (FILS)"); |
| 1271 | sta->flags |= WLAN_STA_AUTH; |
| 1272 | wpa_auth_sm_event(sta->wpa_sm, WPA_AUTH); |
| 1273 | sta->auth_alg = WLAN_AUTH_FILS_SK; |
| 1274 | mlme_authenticate_indication(hapd, sta); |
| 1275 | } else { |
| 1276 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, |
| 1277 | HOSTAPD_LEVEL_DEBUG, |
| 1278 | "authentication failed (FILS)"); |
| 1279 | } |
| 1280 | |
| 1281 | hostapd_sta_auth(hapd, sta->addr, 2, resp, |
| 1282 | data ? wpabuf_head(data) : NULL, |
| 1283 | data ? wpabuf_len(data) : 0); |
| 1284 | wpabuf_free(data); |
| 1285 | } |
| 1286 | #endif /* CONFIG_FILS */ |
| 1287 | |
| 1288 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1289 | static void hostapd_notif_auth(struct hostapd_data *hapd, |
| 1290 | struct auth_info *rx_auth) |
| 1291 | { |
| 1292 | struct sta_info *sta; |
| 1293 | u16 status = WLAN_STATUS_SUCCESS; |
| 1294 | u8 resp_ies[2 + WLAN_AUTH_CHALLENGE_LEN]; |
| 1295 | size_t resp_ies_len = 0; |
| 1296 | |
| 1297 | sta = ap_get_sta(hapd, rx_auth->peer); |
| 1298 | if (!sta) { |
| 1299 | sta = ap_sta_add(hapd, rx_auth->peer); |
| 1300 | if (sta == NULL) { |
Dmitry Shmidt | 4b06059 | 2013-04-29 16:42:49 -0700 | [diff] [blame] | 1301 | status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1302 | goto fail; |
| 1303 | } |
| 1304 | } |
| 1305 | sta->flags &= ~WLAN_STA_PREAUTH; |
| 1306 | ieee802_1x_notify_pre_auth(sta->eapol_sm, 0); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1307 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1308 | if (rx_auth->auth_type == WLAN_AUTH_FT && hapd->wpa_auth) { |
| 1309 | sta->auth_alg = WLAN_AUTH_FT; |
| 1310 | if (sta->wpa_sm == NULL) |
| 1311 | sta->wpa_sm = wpa_auth_sta_init(hapd->wpa_auth, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 1312 | sta->addr, NULL); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1313 | if (sta->wpa_sm == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1314 | wpa_printf(MSG_DEBUG, |
| 1315 | "FT: Failed to initialize WPA state machine"); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1316 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 1317 | goto fail; |
| 1318 | } |
| 1319 | wpa_ft_process_auth(sta->wpa_sm, rx_auth->bssid, |
| 1320 | rx_auth->auth_transaction, rx_auth->ies, |
| 1321 | rx_auth->ies_len, |
| 1322 | hostapd_notify_auth_ft_finish, hapd); |
| 1323 | return; |
| 1324 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1325 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1326 | |
| 1327 | #ifdef CONFIG_FILS |
| 1328 | if (rx_auth->auth_type == WLAN_AUTH_FILS_SK) { |
| 1329 | sta->auth_alg = WLAN_AUTH_FILS_SK; |
| 1330 | handle_auth_fils(hapd, sta, rx_auth->ies, rx_auth->ies_len, |
| 1331 | rx_auth->auth_type, rx_auth->auth_transaction, |
| 1332 | rx_auth->status_code, |
| 1333 | hostapd_notify_auth_fils_finish); |
| 1334 | return; |
| 1335 | } |
| 1336 | #endif /* CONFIG_FILS */ |
| 1337 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1338 | fail: |
| 1339 | hostapd_sta_auth(hapd, rx_auth->peer, rx_auth->auth_transaction + 1, |
| 1340 | status, resp_ies, resp_ies_len); |
| 1341 | } |
| 1342 | |
| 1343 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1344 | #ifndef NEED_AP_MLME |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1345 | static void hostapd_action_rx(struct hostapd_data *hapd, |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1346 | struct rx_mgmt *drv_mgmt) |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1347 | { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1348 | struct ieee80211_mgmt *mgmt; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1349 | struct sta_info *sta; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1350 | size_t plen __maybe_unused; |
| 1351 | u16 fc; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1352 | u8 *action __maybe_unused; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1353 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1354 | if (drv_mgmt->frame_len < IEEE80211_HDRLEN + 2 + 1) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1355 | return; |
| 1356 | |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1357 | plen = drv_mgmt->frame_len - IEEE80211_HDRLEN; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1358 | |
| 1359 | mgmt = (struct ieee80211_mgmt *) drv_mgmt->frame; |
| 1360 | fc = le_to_host16(mgmt->frame_control); |
| 1361 | if (WLAN_FC_GET_STYPE(fc) != WLAN_FC_STYPE_ACTION) |
| 1362 | return; /* handled by the driver */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1363 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1364 | action = (u8 *) &mgmt->u.action.u; |
| 1365 | wpa_printf(MSG_DEBUG, "RX_ACTION category %u action %u sa " MACSTR |
| 1366 | " da " MACSTR " plen %d", |
| 1367 | mgmt->u.action.category, *action, |
| 1368 | MAC2STR(mgmt->sa), MAC2STR(mgmt->da), (int) plen); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1369 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1370 | sta = ap_get_sta(hapd, mgmt->sa); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1371 | if (sta == NULL) { |
| 1372 | wpa_printf(MSG_DEBUG, "%s: station not found", __func__); |
| 1373 | return; |
| 1374 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1375 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1376 | if (mgmt->u.action.category == WLAN_ACTION_FT) { |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1377 | wpa_ft_action_rx(sta->wpa_sm, (u8 *) &mgmt->u.action, plen); |
| 1378 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1379 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1380 | #endif /* CONFIG_IEEE80211R_AP */ |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1381 | if (mgmt->u.action.category == WLAN_ACTION_SA_QUERY) { |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1382 | ieee802_11_sa_query_action(hapd, mgmt, drv_mgmt->frame_len); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1383 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1384 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1385 | #ifdef CONFIG_WNM_AP |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1386 | if (mgmt->u.action.category == WLAN_ACTION_WNM) { |
| 1387 | ieee802_11_rx_wnm_action_ap(hapd, mgmt, drv_mgmt->frame_len); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1388 | return; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1389 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1390 | #endif /* CONFIG_WNM_AP */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1391 | #ifdef CONFIG_FST |
| 1392 | if (mgmt->u.action.category == WLAN_ACTION_FST && hapd->iface->fst) { |
| 1393 | fst_rx_action(hapd->iface->fst, mgmt, drv_mgmt->frame_len); |
| 1394 | return; |
| 1395 | } |
| 1396 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1397 | #ifdef CONFIG_DPP |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1398 | if (plen >= 2 + 4 && |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1399 | mgmt->u.action.u.vs_public_action.action == |
| 1400 | WLAN_PA_VENDOR_SPECIFIC && |
| 1401 | WPA_GET_BE24(mgmt->u.action.u.vs_public_action.oui) == |
| 1402 | OUI_WFA && |
| 1403 | mgmt->u.action.u.vs_public_action.variable[0] == |
| 1404 | DPP_OUI_TYPE) { |
| 1405 | const u8 *pos, *end; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1406 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1407 | pos = mgmt->u.action.u.vs_public_action.oui; |
| 1408 | end = drv_mgmt->frame + drv_mgmt->frame_len; |
| 1409 | hostapd_dpp_rx_action(hapd, mgmt->sa, pos, end - pos, |
| 1410 | drv_mgmt->freq); |
| 1411 | return; |
| 1412 | } |
| 1413 | #endif /* CONFIG_DPP */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1414 | } |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1415 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1416 | |
| 1417 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1418 | #ifdef NEED_AP_MLME |
| 1419 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1420 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) |
| 1421 | |
| 1422 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 1423 | const u8 *bssid) |
| 1424 | { |
| 1425 | size_t i; |
| 1426 | |
| 1427 | if (bssid == NULL) |
| 1428 | return NULL; |
| 1429 | if (bssid[0] == 0xff && bssid[1] == 0xff && bssid[2] == 0xff && |
| 1430 | bssid[3] == 0xff && bssid[4] == 0xff && bssid[5] == 0xff) |
| 1431 | return HAPD_BROADCAST; |
| 1432 | |
| 1433 | for (i = 0; i < iface->num_bss; i++) { |
| 1434 | if (os_memcmp(bssid, iface->bss[i]->own_addr, ETH_ALEN) == 0) |
| 1435 | return iface->bss[i]; |
| 1436 | } |
| 1437 | |
| 1438 | return NULL; |
| 1439 | } |
| 1440 | |
| 1441 | |
| 1442 | static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1443 | const u8 *bssid, const u8 *addr, |
| 1444 | int wds) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1445 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1446 | hapd = get_hapd_bssid(hapd->iface, bssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1447 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
| 1448 | return; |
| 1449 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1450 | ieee802_11_rx_from_unknown(hapd, addr, wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1451 | } |
| 1452 | |
| 1453 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1454 | 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] | 1455 | { |
| 1456 | struct hostapd_iface *iface = hapd->iface; |
| 1457 | const struct ieee80211_hdr *hdr; |
| 1458 | const u8 *bssid; |
| 1459 | struct hostapd_frame_info fi; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1460 | int ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1461 | |
Dmitry Shmidt | 7d5c8f2 | 2014-03-03 13:53:28 -0800 | [diff] [blame] | 1462 | #ifdef CONFIG_TESTING_OPTIONS |
| 1463 | if (hapd->ext_mgmt_frame_handling) { |
| 1464 | size_t hex_len = 2 * rx_mgmt->frame_len + 1; |
| 1465 | char *hex = os_malloc(hex_len); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1466 | |
Dmitry Shmidt | 7d5c8f2 | 2014-03-03 13:53:28 -0800 | [diff] [blame] | 1467 | if (hex) { |
| 1468 | wpa_snprintf_hex(hex, hex_len, rx_mgmt->frame, |
| 1469 | rx_mgmt->frame_len); |
| 1470 | wpa_msg(hapd->msg_ctx, MSG_INFO, "MGMT-RX %s", hex); |
| 1471 | os_free(hex); |
| 1472 | } |
| 1473 | return 1; |
| 1474 | } |
| 1475 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 1476 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1477 | hdr = (const struct ieee80211_hdr *) rx_mgmt->frame; |
| 1478 | bssid = get_hdr_bssid(hdr, rx_mgmt->frame_len); |
| 1479 | if (bssid == NULL) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1480 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1481 | |
| 1482 | hapd = get_hapd_bssid(iface, bssid); |
| 1483 | if (hapd == NULL) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1484 | u16 fc = le_to_host16(hdr->frame_control); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1485 | |
| 1486 | /* |
| 1487 | * Drop frames to unknown BSSIDs except for Beacon frames which |
| 1488 | * could be used to update neighbor information. |
| 1489 | */ |
| 1490 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 1491 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 1492 | hapd = iface->bss[0]; |
| 1493 | else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1494 | return 0; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | os_memset(&fi, 0, sizeof(fi)); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1498 | fi.freq = rx_mgmt->freq; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1499 | fi.datarate = rx_mgmt->datarate; |
| 1500 | fi.ssi_signal = rx_mgmt->ssi_signal; |
| 1501 | |
| 1502 | if (hapd == HAPD_BROADCAST) { |
| 1503 | size_t i; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1504 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1505 | ret = 0; |
| 1506 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | 9866086 | 2014-03-11 17:26:21 -0700 | [diff] [blame] | 1507 | /* if bss is set, driver will call this function for |
| 1508 | * each bss individually. */ |
| 1509 | if (rx_mgmt->drv_priv && |
| 1510 | (iface->bss[i]->drv_priv != rx_mgmt->drv_priv)) |
| 1511 | continue; |
| 1512 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1513 | if (ieee802_11_mgmt(iface->bss[i], rx_mgmt->frame, |
| 1514 | rx_mgmt->frame_len, &fi) > 0) |
| 1515 | ret = 1; |
| 1516 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1517 | } else |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1518 | ret = ieee802_11_mgmt(hapd, rx_mgmt->frame, rx_mgmt->frame_len, |
| 1519 | &fi); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1520 | |
| 1521 | random_add_randomness(&fi, sizeof(fi)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1522 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1523 | return ret; |
Jouni Malinen | 75ecf52 | 2011-06-27 15:19:46 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
| 1526 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1527 | static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
| 1528 | size_t len, u16 stype, int ok) |
| 1529 | { |
| 1530 | struct ieee80211_hdr *hdr; |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 1531 | struct hostapd_data *orig_hapd = hapd; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1532 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1533 | hdr = (struct ieee80211_hdr *) buf; |
| 1534 | hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 1535 | if (!hapd) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1536 | return; |
Dmitry Shmidt | d5ab1b5 | 2016-06-21 12:38:41 -0700 | [diff] [blame] | 1537 | if (hapd == HAPD_BROADCAST) { |
| 1538 | if (stype != WLAN_FC_STYPE_ACTION || len <= 25 || |
| 1539 | buf[24] != WLAN_ACTION_PUBLIC) |
| 1540 | return; |
| 1541 | hapd = get_hapd_bssid(orig_hapd->iface, hdr->addr2); |
| 1542 | if (!hapd || hapd == HAPD_BROADCAST) |
| 1543 | return; |
| 1544 | /* |
| 1545 | * Allow processing of TX status for a Public Action frame that |
| 1546 | * used wildcard BBSID. |
| 1547 | */ |
| 1548 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1549 | ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); |
| 1550 | } |
| 1551 | |
| 1552 | #endif /* NEED_AP_MLME */ |
| 1553 | |
| 1554 | |
| 1555 | static int hostapd_event_new_sta(struct hostapd_data *hapd, const u8 *addr) |
| 1556 | { |
| 1557 | struct sta_info *sta = ap_get_sta(hapd, addr); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1558 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1559 | if (sta) |
| 1560 | return 0; |
| 1561 | |
| 1562 | wpa_printf(MSG_DEBUG, "Data frame from unknown STA " MACSTR |
| 1563 | " - adding a new STA", MAC2STR(addr)); |
| 1564 | sta = ap_sta_add(hapd, addr); |
| 1565 | if (sta) { |
| 1566 | hostapd_new_assoc_sta(hapd, sta, 0); |
| 1567 | } else { |
| 1568 | wpa_printf(MSG_DEBUG, "Failed to add STA entry for " MACSTR, |
| 1569 | MAC2STR(addr)); |
| 1570 | return -1; |
| 1571 | } |
| 1572 | |
| 1573 | return 0; |
| 1574 | } |
| 1575 | |
| 1576 | |
| 1577 | static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1578 | const u8 *data, size_t data_len, |
| 1579 | enum frame_encryption encrypted) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1580 | { |
| 1581 | struct hostapd_iface *iface = hapd->iface; |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 1582 | struct sta_info *sta; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1583 | size_t j; |
| 1584 | |
| 1585 | for (j = 0; j < iface->num_bss; j++) { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1586 | sta = ap_get_sta(iface->bss[j], src); |
| 1587 | if (sta && sta->flags & WLAN_STA_ASSOC) { |
| 1588 | hapd = iface->bss[j]; |
| 1589 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1590 | } |
| 1591 | } |
| 1592 | |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1593 | ieee802_1x_receive(hapd, src, data, data_len, encrypted); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 1596 | #endif /* HOSTAPD */ |
| 1597 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1598 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1599 | static struct hostapd_channel_data * |
| 1600 | hostapd_get_mode_chan(struct hostapd_hw_modes *mode, unsigned int freq) |
| 1601 | { |
| 1602 | int i; |
| 1603 | struct hostapd_channel_data *chan; |
| 1604 | |
| 1605 | for (i = 0; i < mode->num_channels; i++) { |
| 1606 | chan = &mode->channels[i]; |
| 1607 | if ((unsigned int) chan->freq == freq) |
| 1608 | return chan; |
| 1609 | } |
| 1610 | |
| 1611 | return NULL; |
| 1612 | } |
| 1613 | |
| 1614 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1615 | static struct hostapd_channel_data * hostapd_get_mode_channel( |
| 1616 | struct hostapd_iface *iface, unsigned int freq) |
| 1617 | { |
| 1618 | int i; |
| 1619 | struct hostapd_channel_data *chan; |
| 1620 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1621 | for (i = 0; i < iface->num_hw_features; i++) { |
| 1622 | if (hostapd_hw_skip_mode(iface, &iface->hw_features[i])) |
| 1623 | continue; |
| 1624 | chan = hostapd_get_mode_chan(&iface->hw_features[i], freq); |
| 1625 | if (chan) |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1626 | return chan; |
| 1627 | } |
| 1628 | |
| 1629 | return NULL; |
| 1630 | } |
| 1631 | |
| 1632 | |
| 1633 | static void hostapd_update_nf(struct hostapd_iface *iface, |
| 1634 | struct hostapd_channel_data *chan, |
| 1635 | struct freq_survey *survey) |
| 1636 | { |
| 1637 | if (!iface->chans_surveyed) { |
| 1638 | chan->min_nf = survey->nf; |
| 1639 | iface->lowest_nf = survey->nf; |
| 1640 | } else { |
| 1641 | if (dl_list_empty(&chan->survey_list)) |
| 1642 | chan->min_nf = survey->nf; |
| 1643 | else if (survey->nf < chan->min_nf) |
| 1644 | chan->min_nf = survey->nf; |
| 1645 | if (survey->nf < iface->lowest_nf) |
| 1646 | iface->lowest_nf = survey->nf; |
| 1647 | } |
| 1648 | } |
| 1649 | |
| 1650 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1651 | static void hostapd_single_channel_get_survey(struct hostapd_iface *iface, |
| 1652 | struct survey_results *survey_res) |
| 1653 | { |
| 1654 | struct hostapd_channel_data *chan; |
| 1655 | struct freq_survey *survey; |
| 1656 | u64 divisor, dividend; |
| 1657 | |
| 1658 | survey = dl_list_first(&survey_res->survey_list, struct freq_survey, |
| 1659 | list); |
| 1660 | if (!survey || !survey->freq) |
| 1661 | return; |
| 1662 | |
| 1663 | chan = hostapd_get_mode_channel(iface, survey->freq); |
| 1664 | if (!chan || chan->flag & HOSTAPD_CHAN_DISABLED) |
| 1665 | return; |
| 1666 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1667 | wpa_printf(MSG_DEBUG, |
| 1668 | "Single Channel Survey: (freq=%d channel_time=%ld channel_time_busy=%ld)", |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1669 | survey->freq, |
| 1670 | (unsigned long int) survey->channel_time, |
| 1671 | (unsigned long int) survey->channel_time_busy); |
| 1672 | |
| 1673 | if (survey->channel_time > iface->last_channel_time && |
| 1674 | survey->channel_time > survey->channel_time_busy) { |
| 1675 | dividend = survey->channel_time_busy - |
| 1676 | iface->last_channel_time_busy; |
| 1677 | divisor = survey->channel_time - iface->last_channel_time; |
| 1678 | |
| 1679 | iface->channel_utilization = dividend * 255 / divisor; |
| 1680 | wpa_printf(MSG_DEBUG, "Channel Utilization: %d", |
| 1681 | iface->channel_utilization); |
| 1682 | } |
| 1683 | iface->last_channel_time = survey->channel_time; |
| 1684 | iface->last_channel_time_busy = survey->channel_time_busy; |
| 1685 | } |
| 1686 | |
| 1687 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 1688 | void hostapd_event_get_survey(struct hostapd_iface *iface, |
| 1689 | struct survey_results *survey_results) |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1690 | { |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1691 | struct freq_survey *survey, *tmp; |
| 1692 | struct hostapd_channel_data *chan; |
| 1693 | |
| 1694 | if (dl_list_empty(&survey_results->survey_list)) { |
| 1695 | wpa_printf(MSG_DEBUG, "No survey data received"); |
| 1696 | return; |
| 1697 | } |
| 1698 | |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1699 | if (survey_results->freq_filter) { |
| 1700 | hostapd_single_channel_get_survey(iface, survey_results); |
| 1701 | return; |
| 1702 | } |
| 1703 | |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 1704 | dl_list_for_each_safe(survey, tmp, &survey_results->survey_list, |
| 1705 | struct freq_survey, list) { |
| 1706 | chan = hostapd_get_mode_channel(iface, survey->freq); |
| 1707 | if (!chan) |
| 1708 | continue; |
| 1709 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 1710 | continue; |
| 1711 | |
| 1712 | dl_list_del(&survey->list); |
| 1713 | dl_list_add_tail(&chan->survey_list, &survey->list); |
| 1714 | |
| 1715 | hostapd_update_nf(iface, chan, survey); |
| 1716 | |
| 1717 | iface->chans_surveyed++; |
| 1718 | } |
| 1719 | } |
| 1720 | |
| 1721 | |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 1722 | #ifdef HOSTAPD |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1723 | #ifdef NEED_AP_MLME |
| 1724 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1725 | static void hostapd_event_iface_unavailable(struct hostapd_data *hapd) |
| 1726 | { |
| 1727 | wpa_printf(MSG_DEBUG, "Interface %s is unavailable -- stopped", |
| 1728 | hapd->conf->iface); |
| 1729 | |
| 1730 | if (hapd->csa_in_progress) { |
| 1731 | wpa_printf(MSG_INFO, "CSA failed (%s was stopped)", |
| 1732 | hapd->conf->iface); |
| 1733 | hostapd_switch_channel_fallback(hapd->iface, |
| 1734 | &hapd->cs_freq_params); |
| 1735 | } |
Yu Ouyang | 378d3c4 | 2021-08-20 17:31:08 +0800 | [diff] [blame] | 1736 | |
| 1737 | // inform framework that interface is unavailable |
| 1738 | hostapd_disable_iface(hapd->iface); |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1739 | } |
| 1740 | |
| 1741 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1742 | static void hostapd_event_dfs_radar_detected(struct hostapd_data *hapd, |
| 1743 | struct dfs_event *radar) |
| 1744 | { |
| 1745 | wpa_printf(MSG_DEBUG, "DFS radar detected on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1746 | hostapd_dfs_radar_detected(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1747 | radar->chan_offset, radar->chan_width, |
| 1748 | radar->cf1, radar->cf2); |
| 1749 | } |
| 1750 | |
| 1751 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1752 | static void hostapd_event_dfs_pre_cac_expired(struct hostapd_data *hapd, |
| 1753 | struct dfs_event *radar) |
| 1754 | { |
| 1755 | wpa_printf(MSG_DEBUG, "DFS Pre-CAC expired on %d MHz", radar->freq); |
| 1756 | hostapd_dfs_pre_cac_expired(hapd->iface, radar->freq, radar->ht_enabled, |
| 1757 | radar->chan_offset, radar->chan_width, |
| 1758 | radar->cf1, radar->cf2); |
| 1759 | } |
| 1760 | |
| 1761 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1762 | static void hostapd_event_dfs_cac_finished(struct hostapd_data *hapd, |
| 1763 | struct dfs_event *radar) |
| 1764 | { |
| 1765 | wpa_printf(MSG_DEBUG, "DFS CAC finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1766 | hostapd_dfs_complete_cac(hapd->iface, 1, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1767 | radar->chan_offset, radar->chan_width, |
| 1768 | radar->cf1, radar->cf2); |
| 1769 | } |
| 1770 | |
| 1771 | |
| 1772 | static void hostapd_event_dfs_cac_aborted(struct hostapd_data *hapd, |
| 1773 | struct dfs_event *radar) |
| 1774 | { |
| 1775 | wpa_printf(MSG_DEBUG, "DFS CAC aborted on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1776 | hostapd_dfs_complete_cac(hapd->iface, 0, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1777 | radar->chan_offset, radar->chan_width, |
| 1778 | radar->cf1, radar->cf2); |
| 1779 | } |
| 1780 | |
| 1781 | |
| 1782 | static void hostapd_event_dfs_nop_finished(struct hostapd_data *hapd, |
| 1783 | struct dfs_event *radar) |
| 1784 | { |
| 1785 | wpa_printf(MSG_DEBUG, "DFS NOP finished on %d MHz", radar->freq); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1786 | hostapd_dfs_nop_finished(hapd->iface, radar->freq, radar->ht_enabled, |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1787 | radar->chan_offset, radar->chan_width, |
| 1788 | radar->cf1, radar->cf2); |
| 1789 | } |
| 1790 | |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 1791 | |
| 1792 | static void hostapd_event_dfs_cac_started(struct hostapd_data *hapd, |
| 1793 | struct dfs_event *radar) |
| 1794 | { |
| 1795 | wpa_printf(MSG_DEBUG, "DFS offload CAC started on %d MHz", radar->freq); |
| 1796 | hostapd_dfs_start_cac(hapd->iface, radar->freq, radar->ht_enabled, |
| 1797 | radar->chan_offset, radar->chan_width, |
| 1798 | radar->cf1, radar->cf2); |
| 1799 | } |
| 1800 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1801 | #endif /* NEED_AP_MLME */ |
| 1802 | |
| 1803 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1804 | static void hostapd_event_wds_sta_interface_status(struct hostapd_data *hapd, |
| 1805 | int istatus, |
| 1806 | const char *ifname, |
| 1807 | const u8 *addr) |
| 1808 | { |
| 1809 | struct sta_info *sta = ap_get_sta(hapd, addr); |
| 1810 | |
| 1811 | if (sta) { |
| 1812 | os_free(sta->ifname_wds); |
| 1813 | if (istatus == INTERFACE_ADDED) |
| 1814 | sta->ifname_wds = os_strdup(ifname); |
| 1815 | else |
| 1816 | sta->ifname_wds = NULL; |
| 1817 | } |
| 1818 | |
| 1819 | wpa_msg(hapd->msg_ctx, MSG_INFO, "%sifname=%s sta_addr=" MACSTR, |
| 1820 | istatus == INTERFACE_ADDED ? |
| 1821 | WDS_STA_INTERFACE_ADDED : WDS_STA_INTERFACE_REMOVED, |
| 1822 | ifname, MAC2STR(addr)); |
| 1823 | } |
| 1824 | |
| 1825 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1826 | #ifdef CONFIG_OWE |
| 1827 | static int hostapd_notif_update_dh_ie(struct hostapd_data *hapd, |
| 1828 | const u8 *peer, const u8 *ie, |
| 1829 | size_t ie_len) |
| 1830 | { |
| 1831 | u16 status; |
| 1832 | struct sta_info *sta; |
| 1833 | struct ieee802_11_elems elems; |
| 1834 | |
| 1835 | if (!hapd || !hapd->wpa_auth) { |
| 1836 | wpa_printf(MSG_DEBUG, "OWE: Invalid hapd context"); |
| 1837 | return -1; |
| 1838 | } |
| 1839 | if (!peer) { |
| 1840 | wpa_printf(MSG_DEBUG, "OWE: Peer unknown"); |
| 1841 | return -1; |
| 1842 | } |
| 1843 | if (!(hapd->conf->wpa_key_mgmt & WPA_KEY_MGMT_OWE)) { |
| 1844 | wpa_printf(MSG_DEBUG, "OWE: No OWE AKM configured"); |
| 1845 | status = WLAN_STATUS_AKMP_NOT_VALID; |
| 1846 | goto err; |
| 1847 | } |
| 1848 | if (ieee802_11_parse_elems(ie, ie_len, &elems, 1) == ParseFailed) { |
| 1849 | wpa_printf(MSG_DEBUG, "OWE: Failed to parse OWE IE for " |
| 1850 | MACSTR, MAC2STR(peer)); |
| 1851 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 1852 | goto err; |
| 1853 | } |
| 1854 | status = owe_validate_request(hapd, peer, elems.rsn_ie, |
| 1855 | elems.rsn_ie_len, |
| 1856 | elems.owe_dh, elems.owe_dh_len); |
| 1857 | if (status != WLAN_STATUS_SUCCESS) |
| 1858 | goto err; |
| 1859 | |
| 1860 | sta = ap_get_sta(hapd, peer); |
| 1861 | if (sta) { |
| 1862 | ap_sta_no_session_timeout(hapd, sta); |
| 1863 | accounting_sta_stop(hapd, sta); |
| 1864 | |
| 1865 | /* |
| 1866 | * Make sure that the previously registered inactivity timer |
| 1867 | * will not remove the STA immediately. |
| 1868 | */ |
| 1869 | sta->timeout_next = STA_NULLFUNC; |
| 1870 | } else { |
| 1871 | sta = ap_sta_add(hapd, peer); |
| 1872 | if (!sta) { |
| 1873 | status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 1874 | goto err; |
| 1875 | } |
| 1876 | } |
| 1877 | sta->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS | WLAN_STA_WPS2); |
| 1878 | |
| 1879 | status = owe_process_rsn_ie(hapd, sta, elems.rsn_ie, |
| 1880 | elems.rsn_ie_len, elems.owe_dh, |
| 1881 | elems.owe_dh_len); |
| 1882 | if (status != WLAN_STATUS_SUCCESS) |
| 1883 | ap_free_sta(hapd, sta); |
| 1884 | |
| 1885 | return 0; |
| 1886 | err: |
| 1887 | hostapd_drv_update_dh_ie(hapd, peer, status, NULL, 0); |
| 1888 | return 0; |
| 1889 | } |
| 1890 | #endif /* CONFIG_OWE */ |
| 1891 | |
| 1892 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1893 | void wpa_supplicant_event(void *ctx, enum wpa_event_type event, |
| 1894 | union wpa_event_data *data) |
| 1895 | { |
| 1896 | struct hostapd_data *hapd = ctx; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1897 | #ifndef CONFIG_NO_STDOUT_DEBUG |
| 1898 | int level = MSG_DEBUG; |
| 1899 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1900 | if (event == EVENT_RX_MGMT && data->rx_mgmt.frame && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1901 | data->rx_mgmt.frame_len >= 24) { |
| 1902 | const struct ieee80211_hdr *hdr; |
| 1903 | u16 fc; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1904 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1905 | hdr = (const struct ieee80211_hdr *) data->rx_mgmt.frame; |
| 1906 | fc = le_to_host16(hdr->frame_control); |
| 1907 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 1908 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_BEACON) |
| 1909 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1910 | if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_MGMT && |
| 1911 | WLAN_FC_GET_STYPE(fc) == WLAN_FC_STYPE_PROBE_REQ) |
| 1912 | level = MSG_EXCESSIVE; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1913 | } |
| 1914 | |
| 1915 | wpa_dbg(hapd->msg_ctx, level, "Event %s (%d) received", |
| 1916 | event_to_string(event), event); |
| 1917 | #endif /* CONFIG_NO_STDOUT_DEBUG */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1918 | |
| 1919 | switch (event) { |
| 1920 | case EVENT_MICHAEL_MIC_FAILURE: |
| 1921 | michael_mic_failure(hapd, data->michael_mic_failure.src, 1); |
| 1922 | break; |
| 1923 | case EVENT_SCAN_RESULTS: |
| 1924 | if (hapd->iface->scan_cb) |
| 1925 | hapd->iface->scan_cb(hapd->iface); |
| 1926 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1927 | case EVENT_WPS_BUTTON_PUSHED: |
| 1928 | hostapd_wps_button_pushed(hapd, NULL); |
| 1929 | break; |
| 1930 | #ifdef NEED_AP_MLME |
| 1931 | case EVENT_TX_STATUS: |
| 1932 | switch (data->tx_status.type) { |
| 1933 | case WLAN_FC_TYPE_MGMT: |
| 1934 | hostapd_mgmt_tx_cb(hapd, data->tx_status.data, |
| 1935 | data->tx_status.data_len, |
| 1936 | data->tx_status.stype, |
| 1937 | data->tx_status.ack); |
| 1938 | break; |
| 1939 | case WLAN_FC_TYPE_DATA: |
| 1940 | hostapd_tx_status(hapd, data->tx_status.dst, |
| 1941 | data->tx_status.data, |
| 1942 | data->tx_status.data_len, |
| 1943 | data->tx_status.ack); |
| 1944 | break; |
| 1945 | } |
| 1946 | break; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1947 | case EVENT_EAPOL_TX_STATUS: |
| 1948 | hostapd_eapol_tx_status(hapd, data->eapol_tx_status.dst, |
| 1949 | data->eapol_tx_status.data, |
| 1950 | data->eapol_tx_status.data_len, |
| 1951 | data->eapol_tx_status.ack); |
| 1952 | break; |
| 1953 | case EVENT_DRIVER_CLIENT_POLL_OK: |
| 1954 | hostapd_client_poll_ok(hapd, data->client_poll.addr); |
| 1955 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1956 | case EVENT_RX_FROM_UNKNOWN: |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1957 | hostapd_rx_from_unknown_sta(hapd, data->rx_from_unknown.bssid, |
| 1958 | data->rx_from_unknown.addr, |
| 1959 | data->rx_from_unknown.wds); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1960 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1961 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1962 | case EVENT_RX_MGMT: |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1963 | if (!data->rx_mgmt.frame) |
| 1964 | break; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1965 | #ifdef NEED_AP_MLME |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1966 | hostapd_mgmt_rx(hapd, &data->rx_mgmt); |
| 1967 | #else /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1968 | hostapd_action_rx(hapd, &data->rx_mgmt); |
Hai Shalom | 021b0b5 | 2019-04-10 11:17:58 -0700 | [diff] [blame] | 1969 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1970 | break; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1971 | case EVENT_RX_PROBE_REQ: |
| 1972 | if (data->rx_probe_req.sa == NULL || |
| 1973 | data->rx_probe_req.ie == NULL) |
| 1974 | break; |
| 1975 | hostapd_probe_req_rx(hapd, data->rx_probe_req.sa, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1976 | data->rx_probe_req.da, |
| 1977 | data->rx_probe_req.bssid, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1978 | data->rx_probe_req.ie, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1979 | data->rx_probe_req.ie_len, |
| 1980 | data->rx_probe_req.ssi_signal); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1981 | break; |
| 1982 | case EVENT_NEW_STA: |
| 1983 | hostapd_event_new_sta(hapd, data->new_sta.addr); |
| 1984 | break; |
| 1985 | case EVENT_EAPOL_RX: |
| 1986 | hostapd_event_eapol_rx(hapd, data->eapol_rx.src, |
| 1987 | data->eapol_rx.data, |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1988 | data->eapol_rx.data_len, |
| 1989 | data->eapol_rx.encrypted); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1990 | break; |
| 1991 | case EVENT_ASSOC: |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 1992 | if (!data) |
| 1993 | return; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1994 | hostapd_notif_assoc(hapd, data->assoc_info.addr, |
| 1995 | data->assoc_info.req_ies, |
| 1996 | data->assoc_info.req_ies_len, |
| 1997 | data->assoc_info.reassoc); |
| 1998 | break; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1999 | #ifdef CONFIG_OWE |
| 2000 | case EVENT_UPDATE_DH: |
| 2001 | if (!data) |
| 2002 | return; |
| 2003 | hostapd_notif_update_dh_ie(hapd, data->update_dh.peer, |
| 2004 | data->update_dh.ie, |
| 2005 | data->update_dh.ie_len); |
| 2006 | break; |
| 2007 | #endif /* CONFIG_OWE */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2008 | case EVENT_DISASSOC: |
| 2009 | if (data) |
| 2010 | hostapd_notif_disassoc(hapd, data->disassoc_info.addr); |
| 2011 | break; |
| 2012 | case EVENT_DEAUTH: |
| 2013 | if (data) |
| 2014 | hostapd_notif_disassoc(hapd, data->deauth_info.addr); |
| 2015 | break; |
| 2016 | case EVENT_STATION_LOW_ACK: |
| 2017 | if (!data) |
| 2018 | break; |
| 2019 | hostapd_event_sta_low_ack(hapd, data->low_ack.addr); |
| 2020 | break; |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 2021 | case EVENT_AUTH: |
| 2022 | hostapd_notif_auth(hapd, &data->auth); |
| 2023 | break; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2024 | case EVENT_CH_SWITCH_STARTED: |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2025 | case EVENT_CH_SWITCH: |
| 2026 | if (!data) |
| 2027 | break; |
| 2028 | hostapd_event_ch_switch(hapd, data->ch_switch.freq, |
| 2029 | data->ch_switch.ht_enabled, |
Dmitry Shmidt | 04f534e | 2013-12-09 15:50:16 -0800 | [diff] [blame] | 2030 | data->ch_switch.ch_offset, |
| 2031 | data->ch_switch.ch_width, |
| 2032 | data->ch_switch.cf1, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2033 | data->ch_switch.cf2, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame^] | 2034 | data->ch_switch.punct_bitmap, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2035 | event == EVENT_CH_SWITCH); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2036 | break; |
Dmitry Shmidt | f862328 | 2013-02-20 14:34:59 -0800 | [diff] [blame] | 2037 | case EVENT_CONNECT_FAILED_REASON: |
| 2038 | if (!data) |
| 2039 | break; |
| 2040 | hostapd_event_connect_failed_reason( |
| 2041 | hapd, data->connect_failed_reason.addr, |
| 2042 | data->connect_failed_reason.code); |
| 2043 | break; |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2044 | case EVENT_SURVEY: |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 2045 | hostapd_event_get_survey(hapd->iface, &data->survey_results); |
Dmitry Shmidt | b7b4d0e | 2013-08-26 12:09:05 -0700 | [diff] [blame] | 2046 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2047 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 2048 | case EVENT_INTERFACE_UNAVAILABLE: |
| 2049 | hostapd_event_iface_unavailable(hapd); |
| 2050 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2051 | case EVENT_DFS_RADAR_DETECTED: |
| 2052 | if (!data) |
| 2053 | break; |
| 2054 | hostapd_event_dfs_radar_detected(hapd, &data->dfs_event); |
| 2055 | break; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 2056 | case EVENT_DFS_PRE_CAC_EXPIRED: |
| 2057 | if (!data) |
| 2058 | break; |
| 2059 | hostapd_event_dfs_pre_cac_expired(hapd, &data->dfs_event); |
| 2060 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2061 | case EVENT_DFS_CAC_FINISHED: |
| 2062 | if (!data) |
| 2063 | break; |
| 2064 | hostapd_event_dfs_cac_finished(hapd, &data->dfs_event); |
| 2065 | break; |
| 2066 | case EVENT_DFS_CAC_ABORTED: |
| 2067 | if (!data) |
| 2068 | break; |
| 2069 | hostapd_event_dfs_cac_aborted(hapd, &data->dfs_event); |
| 2070 | break; |
| 2071 | case EVENT_DFS_NOP_FINISHED: |
| 2072 | if (!data) |
| 2073 | break; |
| 2074 | hostapd_event_dfs_nop_finished(hapd, &data->dfs_event); |
| 2075 | break; |
| 2076 | case EVENT_CHANNEL_LIST_CHANGED: |
| 2077 | /* channel list changed (regulatory?), update channel list */ |
| 2078 | /* TODO: check this. hostapd_get_hw_features() initializes |
| 2079 | * too much stuff. */ |
| 2080 | /* hostapd_get_hw_features(hapd->iface); */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2081 | hostapd_channel_list_updated( |
| 2082 | hapd->iface, data->channel_list_changed.initiator); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2083 | break; |
Dmitry Shmidt | 203eadb | 2015-03-05 14:16:04 -0800 | [diff] [blame] | 2084 | case EVENT_DFS_CAC_STARTED: |
| 2085 | if (!data) |
| 2086 | break; |
| 2087 | hostapd_event_dfs_cac_started(hapd, &data->dfs_event); |
| 2088 | break; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 2089 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2090 | case EVENT_INTERFACE_ENABLED: |
| 2091 | wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_ENABLED); |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2092 | if (hapd->disabled && hapd->started) { |
| 2093 | hapd->disabled = 0; |
| 2094 | /* |
| 2095 | * Try to re-enable interface if the driver stopped it |
| 2096 | * when the interface got disabled. |
| 2097 | */ |
Hai Shalom | ce48b4a | 2018-09-05 11:41:35 -0700 | [diff] [blame] | 2098 | if (hapd->wpa_auth) |
| 2099 | wpa_auth_reconfig_group_keys(hapd->wpa_auth); |
| 2100 | else |
| 2101 | hostapd_reconfig_encryption(hapd); |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2102 | hapd->reenable_beacon = 1; |
| 2103 | ieee802_11_set_beacon(hapd); |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 2104 | #ifdef NEED_AP_MLME |
| 2105 | } else if (hapd->disabled && hapd->iface->cac_started) { |
| 2106 | wpa_printf(MSG_DEBUG, "DFS: restarting pending CAC"); |
| 2107 | hostapd_handle_dfs(hapd->iface); |
| 2108 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2109 | } |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2110 | break; |
| 2111 | case EVENT_INTERFACE_DISABLED: |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2112 | hostapd_free_stas(hapd); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2113 | wpa_msg(hapd->msg_ctx, MSG_INFO, INTERFACE_DISABLED); |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2114 | hapd->disabled = 1; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2115 | break; |
| 2116 | #ifdef CONFIG_ACS |
| 2117 | case EVENT_ACS_CHANNEL_SELECTED: |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 2118 | hostapd_acs_channel_selected(hapd, |
| 2119 | &data->acs_selected_channels); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 2120 | break; |
| 2121 | #endif /* CONFIG_ACS */ |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 2122 | case EVENT_STATION_OPMODE_CHANGED: |
| 2123 | hostapd_event_sta_opmode_changed(hapd, data->sta_opmode.addr, |
| 2124 | data->sta_opmode.smps_mode, |
| 2125 | data->sta_opmode.chan_width, |
| 2126 | data->sta_opmode.rx_nss); |
| 2127 | break; |
| 2128 | case EVENT_WDS_STA_INTERFACE_STATUS: |
| 2129 | hostapd_event_wds_sta_interface_status( |
| 2130 | hapd, data->wds_sta_interface.istatus, |
| 2131 | data->wds_sta_interface.ifname, |
| 2132 | data->wds_sta_interface.sta_addr); |
| 2133 | break; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2134 | #ifdef CONFIG_IEEE80211AX |
| 2135 | case EVENT_BSS_COLOR_COLLISION: |
| 2136 | /* The BSS color is shared amongst all BBSs on a specific phy. |
| 2137 | * Therefore we always start the color change on the primary |
| 2138 | * BSS. */ |
| 2139 | wpa_printf(MSG_DEBUG, "BSS color collision on %s", |
| 2140 | hapd->conf->iface); |
| 2141 | hostapd_switch_color(hapd->iface->bss[0], |
| 2142 | data->bss_color_collision.bitmap); |
| 2143 | break; |
| 2144 | case EVENT_CCA_STARTED_NOTIFY: |
| 2145 | wpa_printf(MSG_DEBUG, "CCA started on on %s", |
| 2146 | hapd->conf->iface); |
| 2147 | break; |
| 2148 | case EVENT_CCA_ABORTED_NOTIFY: |
| 2149 | wpa_printf(MSG_DEBUG, "CCA aborted on on %s", |
| 2150 | hapd->conf->iface); |
| 2151 | hostapd_cleanup_cca_params(hapd); |
| 2152 | break; |
| 2153 | case EVENT_CCA_NOTIFY: |
| 2154 | wpa_printf(MSG_DEBUG, "CCA finished on on %s", |
| 2155 | hapd->conf->iface); |
| 2156 | hapd->iface->conf->he_op.he_bss_color = hapd->cca_color; |
| 2157 | hostapd_cleanup_cca_params(hapd); |
| 2158 | break; |
| 2159 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2160 | default: |
| 2161 | wpa_printf(MSG_DEBUG, "Unknown event %d", event); |
| 2162 | break; |
| 2163 | } |
| 2164 | } |
| 2165 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 2166 | |
| 2167 | void wpa_supplicant_event_global(void *ctx, enum wpa_event_type event, |
| 2168 | union wpa_event_data *data) |
| 2169 | { |
| 2170 | struct hapd_interfaces *interfaces = ctx; |
| 2171 | struct hostapd_data *hapd; |
| 2172 | |
| 2173 | if (event != EVENT_INTERFACE_STATUS) |
| 2174 | return; |
| 2175 | |
| 2176 | hapd = hostapd_get_iface(interfaces, data->interface_status.ifname); |
| 2177 | if (hapd && hapd->driver && hapd->driver->get_ifindex && |
| 2178 | hapd->drv_priv) { |
| 2179 | unsigned int ifindex; |
| 2180 | |
| 2181 | ifindex = hapd->driver->get_ifindex(hapd->drv_priv); |
| 2182 | if (ifindex != data->interface_status.ifindex) { |
| 2183 | wpa_dbg(hapd->msg_ctx, MSG_DEBUG, |
| 2184 | "interface status ifindex %d mismatch (%d)", |
| 2185 | ifindex, data->interface_status.ifindex); |
| 2186 | return; |
| 2187 | } |
| 2188 | } |
| 2189 | if (hapd) |
| 2190 | wpa_supplicant_event(hapd, event, data); |
| 2191 | } |
| 2192 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2193 | #endif /* HOSTAPD */ |