Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / IEEE 802.11 Management: Beacon and Probe Request/Response |
| 3 | * Copyright (c) 2002-2004, Instant802 Networks, Inc. |
| 4 | * Copyright (c) 2005-2006, Devicescape Software, Inc. |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 5 | * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 6 | * |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 7 | * This software may be distributed under the terms of the BSD license. |
| 8 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include "utils/includes.h" |
| 12 | |
| 13 | #ifndef CONFIG_NATIVE_WINDOWS |
| 14 | |
| 15 | #include "utils/common.h" |
| 16 | #include "common/ieee802_11_defs.h" |
| 17 | #include "common/ieee802_11_common.h" |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 18 | #include "common/hw_features_common.h" |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 19 | #include "common/wpa_ctrl.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 20 | #include "wps/wps_defs.h" |
| 21 | #include "p2p/p2p.h" |
| 22 | #include "hostapd.h" |
| 23 | #include "ieee802_11.h" |
| 24 | #include "wpa_auth.h" |
| 25 | #include "wmm.h" |
| 26 | #include "ap_config.h" |
| 27 | #include "sta_info.h" |
| 28 | #include "p2p_hostapd.h" |
| 29 | #include "ap_drv_ops.h" |
| 30 | #include "beacon.h" |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 31 | #include "hs20.h" |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 32 | #include "dfs.h" |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 33 | #include "taxonomy.h" |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 34 | #include "ieee802_11_auth.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 35 | |
| 36 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 37 | #ifdef NEED_AP_MLME |
| 38 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 39 | static u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len) |
| 40 | { |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 41 | if (len < 2 + 5) |
| 42 | return eid; |
| 43 | |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 44 | #ifdef CONFIG_TESTING_OPTIONS |
| 45 | if (hapd->conf->bss_load_test_set) { |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 46 | *eid++ = WLAN_EID_BSS_LOAD; |
| 47 | *eid++ = 5; |
| 48 | os_memcpy(eid, hapd->conf->bss_load_test, 5); |
| 49 | eid += 5; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 50 | return eid; |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 51 | } |
| 52 | #endif /* CONFIG_TESTING_OPTIONS */ |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 53 | if (hapd->conf->bss_load_update_period) { |
| 54 | *eid++ = WLAN_EID_BSS_LOAD; |
| 55 | *eid++ = 5; |
| 56 | WPA_PUT_LE16(eid, hapd->num_sta); |
| 57 | eid += 2; |
| 58 | *eid++ = hapd->iface->channel_utilization; |
| 59 | WPA_PUT_LE16(eid, 0); /* no available admission capabity */ |
| 60 | eid += 2; |
| 61 | } |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 62 | return eid; |
| 63 | } |
| 64 | |
| 65 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 66 | static u8 ieee802_11_erp_info(struct hostapd_data *hapd) |
| 67 | { |
| 68 | u8 erp = 0; |
| 69 | |
| 70 | if (hapd->iface->current_mode == NULL || |
| 71 | hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) |
| 72 | return 0; |
| 73 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 74 | if (hapd->iface->olbc) |
| 75 | erp |= ERP_INFO_USE_PROTECTION; |
| 76 | if (hapd->iface->num_sta_non_erp > 0) { |
| 77 | erp |= ERP_INFO_NON_ERP_PRESENT | |
| 78 | ERP_INFO_USE_PROTECTION; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 79 | } |
| 80 | if (hapd->iface->num_sta_no_short_preamble > 0 || |
| 81 | hapd->iconf->preamble == LONG_PREAMBLE) |
| 82 | erp |= ERP_INFO_BARKER_PREAMBLE_MODE; |
| 83 | |
| 84 | return erp; |
| 85 | } |
| 86 | |
| 87 | |
| 88 | static u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid) |
| 89 | { |
| 90 | *eid++ = WLAN_EID_DS_PARAMS; |
| 91 | *eid++ = 1; |
| 92 | *eid++ = hapd->iconf->channel; |
| 93 | return eid; |
| 94 | } |
| 95 | |
| 96 | |
| 97 | static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid) |
| 98 | { |
| 99 | if (hapd->iface->current_mode == NULL || |
| 100 | hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G) |
| 101 | return eid; |
| 102 | |
| 103 | /* Set NonERP_present and use_protection bits if there |
| 104 | * are any associated NonERP stations. */ |
| 105 | /* TODO: use_protection bit can be set to zero even if |
| 106 | * there are NonERP stations present. This optimization |
| 107 | * might be useful if NonERP stations are "quiet". |
| 108 | * See 802.11g/D6 E-1 for recommended practice. |
| 109 | * In addition, Non ERP present might be set, if AP detects Non ERP |
| 110 | * operation on other APs. */ |
| 111 | |
| 112 | /* Add ERP Information element */ |
| 113 | *eid++ = WLAN_EID_ERP_INFO; |
| 114 | *eid++ = 1; |
| 115 | *eid++ = ieee802_11_erp_info(hapd); |
| 116 | |
| 117 | return eid; |
| 118 | } |
| 119 | |
| 120 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 121 | static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid) |
| 122 | { |
| 123 | u8 *pos = eid; |
| 124 | u8 local_pwr_constraint = 0; |
| 125 | int dfs; |
| 126 | |
| 127 | if (hapd->iface->current_mode == NULL || |
| 128 | hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A) |
| 129 | return eid; |
| 130 | |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 131 | /* Let host drivers add this IE if DFS support is offloaded */ |
| 132 | if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD) |
| 133 | return eid; |
| 134 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 135 | /* |
| 136 | * There is no DFS support and power constraint was not directly |
| 137 | * requested by config option. |
| 138 | */ |
| 139 | if (!hapd->iconf->ieee80211h && |
| 140 | hapd->iconf->local_pwr_constraint == -1) |
| 141 | return eid; |
| 142 | |
| 143 | /* Check if DFS is required by regulatory. */ |
| 144 | dfs = hostapd_is_dfs_required(hapd->iface); |
| 145 | if (dfs < 0) { |
| 146 | wpa_printf(MSG_WARNING, "Failed to check if DFS is required; ret=%d", |
| 147 | dfs); |
| 148 | dfs = 0; |
| 149 | } |
| 150 | |
| 151 | if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1) |
| 152 | return eid; |
| 153 | |
| 154 | /* |
| 155 | * ieee80211h (DFS) is enabled so Power Constraint element shall |
| 156 | * be added when running on DFS channel whenever local_pwr_constraint |
| 157 | * is configured or not. In order to meet regulations when TPC is not |
| 158 | * implemented using a transmit power that is below the legal maximum |
| 159 | * (including any mitigation factor) should help. In this case, |
| 160 | * indicate 3 dB below maximum allowed transmit power. |
| 161 | */ |
| 162 | if (hapd->iconf->local_pwr_constraint == -1) |
| 163 | local_pwr_constraint = 3; |
| 164 | |
| 165 | /* |
| 166 | * A STA that is not an AP shall use a transmit power less than or |
| 167 | * equal to the local maximum transmit power level for the channel. |
| 168 | * The local maximum transmit power can be calculated from the formula: |
| 169 | * local max TX pwr = max TX pwr - local pwr constraint |
| 170 | * Where max TX pwr is maximum transmit power level specified for |
| 171 | * channel in Country element and local pwr constraint is specified |
| 172 | * for channel in this Power Constraint element. |
| 173 | */ |
| 174 | |
| 175 | /* Element ID */ |
| 176 | *pos++ = WLAN_EID_PWR_CONSTRAINT; |
| 177 | /* Length */ |
| 178 | *pos++ = 1; |
| 179 | /* Local Power Constraint */ |
| 180 | if (local_pwr_constraint) |
| 181 | *pos++ = local_pwr_constraint; |
| 182 | else |
| 183 | *pos++ = hapd->iconf->local_pwr_constraint; |
| 184 | |
| 185 | return pos; |
| 186 | } |
| 187 | |
| 188 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 189 | static u8 * hostapd_eid_country_add(struct hostapd_data *hapd, u8 *pos, |
| 190 | u8 *end, int chan_spacing, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 191 | struct hostapd_channel_data *start, |
| 192 | struct hostapd_channel_data *prev) |
| 193 | { |
| 194 | if (end - pos < 3) |
| 195 | return pos; |
| 196 | |
| 197 | /* first channel number */ |
| 198 | *pos++ = start->chan; |
| 199 | /* number of channels */ |
| 200 | *pos++ = (prev->chan - start->chan) / chan_spacing + 1; |
| 201 | /* maximum transmit power level */ |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 202 | if (!is_6ghz_op_class(hapd->iconf->op_class)) |
| 203 | *pos++ = start->max_tx_power; |
| 204 | else |
| 205 | *pos++ = 0; /* Reserved when operating on the 6 GHz band */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 206 | |
| 207 | return pos; |
| 208 | } |
| 209 | |
| 210 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 211 | static u8 * hostapd_fill_subband_triplets(struct hostapd_data *hapd, u8 *pos, |
| 212 | u8 *end) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 213 | { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 214 | int i; |
| 215 | struct hostapd_hw_modes *mode; |
| 216 | struct hostapd_channel_data *start, *prev; |
| 217 | int chan_spacing = 1; |
| 218 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 219 | mode = hapd->iface->current_mode; |
| 220 | if (mode->mode == HOSTAPD_MODE_IEEE80211A) |
| 221 | chan_spacing = 4; |
| 222 | |
| 223 | start = prev = NULL; |
| 224 | for (i = 0; i < mode->num_channels; i++) { |
| 225 | struct hostapd_channel_data *chan = &mode->channels[i]; |
| 226 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 227 | continue; |
| 228 | if (start && prev && |
| 229 | prev->chan + chan_spacing == chan->chan && |
| 230 | start->max_tx_power == chan->max_tx_power) { |
| 231 | prev = chan; |
| 232 | continue; /* can use same entry */ |
| 233 | } |
| 234 | |
Dmitry Shmidt | 09f57ba | 2014-06-10 16:07:13 -0700 | [diff] [blame] | 235 | if (start && prev) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 236 | pos = hostapd_eid_country_add(hapd, pos, end, |
| 237 | chan_spacing, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 238 | start, prev); |
| 239 | start = NULL; |
| 240 | } |
| 241 | |
| 242 | /* Start new group */ |
| 243 | start = prev = chan; |
| 244 | } |
| 245 | |
| 246 | if (start) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 247 | pos = hostapd_eid_country_add(hapd, pos, end, chan_spacing, |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 248 | start, prev); |
| 249 | } |
| 250 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 251 | return pos; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid, |
| 256 | int max_len) |
| 257 | { |
| 258 | u8 *pos = eid; |
| 259 | u8 *end = eid + max_len; |
| 260 | |
| 261 | if (!hapd->iconf->ieee80211d || max_len < 6 || |
| 262 | hapd->iface->current_mode == NULL) |
| 263 | return eid; |
| 264 | |
| 265 | *pos++ = WLAN_EID_COUNTRY; |
| 266 | pos++; /* length will be set later */ |
| 267 | os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */ |
| 268 | pos += 3; |
| 269 | |
| 270 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
| 271 | /* Force the third octet of the country string to indicate |
| 272 | * Global Operating Class (Table E-4) */ |
| 273 | eid[4] = 0x04; |
| 274 | |
| 275 | /* Operating Triplet field */ |
| 276 | /* Operating Extension Identifier (>= 201 to indicate this is |
| 277 | * not a Subband Triplet field) */ |
| 278 | *pos++ = 201; |
| 279 | /* Operating Class */ |
| 280 | *pos++ = hapd->iconf->op_class; |
| 281 | /* Coverage Class */ |
| 282 | *pos++ = 0; |
| 283 | /* Subband Triplets are required only for the 20 MHz case */ |
| 284 | if (hapd->iconf->op_class == 131 || |
| 285 | hapd->iconf->op_class == 136) |
| 286 | pos = hostapd_fill_subband_triplets(hapd, pos, end); |
| 287 | } else { |
| 288 | pos = hostapd_fill_subband_triplets(hapd, pos, end); |
| 289 | } |
| 290 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 291 | if ((pos - eid) & 1) { |
| 292 | if (end - pos < 1) |
| 293 | return eid; |
| 294 | *pos++ = 0; /* pad for 16-bit alignment */ |
| 295 | } |
| 296 | |
| 297 | eid[1] = (pos - eid) - 2; |
| 298 | |
| 299 | return pos; |
| 300 | } |
| 301 | |
| 302 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 303 | const u8 * hostapd_wpa_ie(struct hostapd_data *hapd, u8 eid) |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 304 | { |
| 305 | const u8 *ies; |
| 306 | size_t ies_len; |
| 307 | |
| 308 | ies = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ies_len); |
| 309 | if (!ies) |
| 310 | return NULL; |
| 311 | |
| 312 | return get_ie(ies, ies_len, eid); |
| 313 | } |
| 314 | |
| 315 | |
| 316 | static const u8 * hostapd_vendor_wpa_ie(struct hostapd_data *hapd, |
| 317 | u32 vendor_type) |
| 318 | { |
| 319 | const u8 *ies; |
| 320 | size_t ies_len; |
| 321 | |
| 322 | ies = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ies_len); |
| 323 | if (!ies) |
| 324 | return NULL; |
| 325 | |
| 326 | return get_vendor_ie(ies, ies_len, vendor_type); |
| 327 | } |
| 328 | |
| 329 | |
| 330 | static u8 * hostapd_get_rsne(struct hostapd_data *hapd, u8 *pos, size_t len) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 331 | { |
| 332 | const u8 *ie; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 333 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 334 | ie = hostapd_wpa_ie(hapd, WLAN_EID_RSN); |
| 335 | if (!ie || 2U + ie[1] > len) |
| 336 | return pos; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 337 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 338 | os_memcpy(pos, ie, 2 + ie[1]); |
| 339 | return pos + 2 + ie[1]; |
| 340 | } |
| 341 | |
| 342 | |
| 343 | static u8 * hostapd_get_mde(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 344 | { |
| 345 | const u8 *ie; |
| 346 | |
| 347 | ie = hostapd_wpa_ie(hapd, WLAN_EID_MOBILITY_DOMAIN); |
| 348 | if (!ie || 2U + ie[1] > len) |
| 349 | return pos; |
| 350 | |
| 351 | os_memcpy(pos, ie, 2 + ie[1]); |
| 352 | return pos + 2 + ie[1]; |
| 353 | } |
| 354 | |
| 355 | |
| 356 | static u8 * hostapd_get_rsnxe(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 357 | { |
| 358 | const u8 *ie; |
| 359 | |
| 360 | #ifdef CONFIG_TESTING_OPTIONS |
| 361 | if (hapd->conf->no_beacon_rsnxe) { |
| 362 | wpa_printf(MSG_INFO, "TESTING: Do not add RSNXE into Beacon"); |
| 363 | return pos; |
| 364 | } |
| 365 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 366 | ie = hostapd_wpa_ie(hapd, WLAN_EID_RSNX); |
| 367 | if (!ie || 2U + ie[1] > len) |
| 368 | return pos; |
| 369 | |
| 370 | os_memcpy(pos, ie, 2 + ie[1]); |
| 371 | return pos + 2 + ie[1]; |
| 372 | } |
| 373 | |
| 374 | |
| 375 | static u8 * hostapd_get_wpa_ie(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 376 | { |
| 377 | const u8 *ie; |
| 378 | |
| 379 | ie = hostapd_vendor_wpa_ie(hapd, WPA_IE_VENDOR_TYPE); |
| 380 | if (!ie || 2U + ie[1] > len) |
| 381 | return pos; |
| 382 | |
| 383 | os_memcpy(pos, ie, 2 + ie[1]); |
| 384 | return pos + 2 + ie[1]; |
| 385 | } |
| 386 | |
| 387 | |
| 388 | static u8 * hostapd_get_osen_ie(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 389 | { |
| 390 | const u8 *ie; |
| 391 | |
| 392 | ie = hostapd_vendor_wpa_ie(hapd, OSEN_IE_VENDOR_TYPE); |
| 393 | if (!ie || 2U + ie[1] > len) |
| 394 | return pos; |
| 395 | |
| 396 | os_memcpy(pos, ie, 2 + ie[1]); |
| 397 | return pos + 2 + ie[1]; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 401 | static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid) |
| 402 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 403 | #ifdef CONFIG_TESTING_OPTIONS |
| 404 | if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 405 | return eid; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 406 | #endif /* CONFIG_TESTING_OPTIONS */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 407 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 408 | if (!hapd->cs_freq_params.channel) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 409 | return eid; |
| 410 | |
| 411 | *eid++ = WLAN_EID_CHANNEL_SWITCH; |
| 412 | *eid++ = 3; |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 413 | *eid++ = hapd->cs_block_tx; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 414 | *eid++ = hapd->cs_freq_params.channel; |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 415 | *eid++ = hapd->cs_count; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 416 | |
| 417 | return eid; |
| 418 | } |
| 419 | |
| 420 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 421 | static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 422 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 423 | if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 424 | return eid; |
| 425 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 426 | *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN; |
| 427 | *eid++ = 4; |
| 428 | *eid++ = hapd->cs_block_tx; |
| 429 | *eid++ = hapd->iface->cs_oper_class; |
| 430 | *eid++ = hapd->cs_freq_params.channel; |
| 431 | *eid++ = hapd->cs_count; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 432 | |
| 433 | return eid; |
| 434 | } |
| 435 | |
| 436 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 437 | static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 438 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 439 | u8 op_class, channel; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 440 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 441 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) || |
| 442 | !hapd->iface->freq) |
| 443 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 444 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 445 | if (ieee80211_freq_to_channel_ext(hapd->iface->freq, |
| 446 | hapd->iconf->secondary_channel, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 447 | hostapd_get_oper_chwidth(hapd->iconf), |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 448 | &op_class, &channel) == |
| 449 | NUM_HOSTAPD_MODES) |
| 450 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 451 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 452 | *eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES; |
| 453 | *eid++ = 2; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 454 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 455 | /* Current Operating Class */ |
| 456 | *eid++ = op_class; |
| 457 | |
| 458 | /* TODO: Advertise all the supported operating classes */ |
| 459 | *eid++ = 0; |
| 460 | |
| 461 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 465 | static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 466 | const struct ieee80211_mgmt *req, |
| 467 | int is_p2p, size_t *resp_len) |
| 468 | { |
| 469 | struct ieee80211_mgmt *resp; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 470 | u8 *pos, *epos, *csa_pos; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 471 | size_t buflen; |
| 472 | |
| 473 | #define MAX_PROBERESP_LEN 768 |
| 474 | buflen = MAX_PROBERESP_LEN; |
| 475 | #ifdef CONFIG_WPS |
| 476 | if (hapd->wps_probe_resp_ie) |
| 477 | buflen += wpabuf_len(hapd->wps_probe_resp_ie); |
| 478 | #endif /* CONFIG_WPS */ |
| 479 | #ifdef CONFIG_P2P |
| 480 | if (hapd->p2p_probe_resp_ie) |
| 481 | buflen += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 482 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 483 | #ifdef CONFIG_FST |
| 484 | if (hapd->iface->fst_ies) |
| 485 | buflen += wpabuf_len(hapd->iface->fst_ies); |
| 486 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 487 | if (hapd->conf->vendor_elements) |
| 488 | buflen += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 489 | if (hapd->conf->vendor_vht) { |
| 490 | buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 491 | 2 + sizeof(struct ieee80211_vht_operation); |
| 492 | } |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 493 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 494 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 495 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 496 | buflen += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 497 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 498 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 499 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 500 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 501 | buflen += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 502 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 503 | /* An additional Transmit Power Envelope element for |
| 504 | * subordinate client */ |
| 505 | if (hapd->iconf->he_6ghz_reg_pwr_type == |
| 506 | HE_6GHZ_INDOOR_AP) |
| 507 | buflen += 4; |
| 508 | } |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 509 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 510 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 511 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 512 | #ifdef CONFIG_IEEE80211BE |
| 513 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 514 | buflen += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); |
| 515 | buflen += 3 + sizeof(struct ieee80211_eht_operation); |
| 516 | } |
| 517 | #endif /* CONFIG_IEEE80211BE */ |
| 518 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 519 | buflen += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_PROBE_RESP); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 520 | buflen += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 521 | buflen += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 522 | buflen += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 523 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 524 | resp = os_zalloc(buflen); |
| 525 | if (resp == NULL) |
| 526 | return NULL; |
| 527 | |
| 528 | epos = ((u8 *) resp) + MAX_PROBERESP_LEN; |
| 529 | |
| 530 | resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 531 | WLAN_FC_STYPE_PROBE_RESP); |
| 532 | if (req) |
| 533 | os_memcpy(resp->da, req->sa, ETH_ALEN); |
| 534 | os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN); |
| 535 | |
| 536 | os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); |
| 537 | resp->u.probe_resp.beacon_int = |
| 538 | host_to_le16(hapd->iconf->beacon_int); |
| 539 | |
| 540 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
| 541 | resp->u.probe_resp.capab_info = |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 542 | host_to_le16(hostapd_own_capab_info(hapd)); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 543 | |
| 544 | pos = resp->u.probe_resp.variable; |
| 545 | *pos++ = WLAN_EID_SSID; |
| 546 | *pos++ = hapd->conf->ssid.ssid_len; |
| 547 | os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len); |
| 548 | pos += hapd->conf->ssid.ssid_len; |
| 549 | |
| 550 | /* Supported rates */ |
| 551 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 552 | |
| 553 | /* DS Params */ |
| 554 | pos = hostapd_eid_ds_params(hapd, pos); |
| 555 | |
| 556 | pos = hostapd_eid_country(hapd, pos, epos - pos); |
| 557 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 558 | /* Power Constraint element */ |
| 559 | pos = hostapd_eid_pwr_constraint(hapd, pos); |
| 560 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 561 | /* CSA IE */ |
| 562 | csa_pos = hostapd_eid_csa(hapd, pos); |
| 563 | if (csa_pos != pos) |
| 564 | hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1; |
| 565 | pos = csa_pos; |
| 566 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 567 | /* ERP Information element */ |
| 568 | pos = hostapd_eid_erp_info(hapd, pos); |
| 569 | |
| 570 | /* Extended supported rates */ |
| 571 | pos = hostapd_eid_ext_supp_rates(hapd, pos); |
| 572 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 573 | pos = hostapd_get_rsne(hapd, pos, epos - pos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 574 | pos = hostapd_eid_bss_load(hapd, pos, epos - pos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 575 | pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 576 | pos = hostapd_get_mde(hapd, pos, epos - pos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 577 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 578 | /* eCSA IE */ |
| 579 | csa_pos = hostapd_eid_ecsa(hapd, pos); |
| 580 | if (csa_pos != pos) |
| 581 | hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1; |
| 582 | pos = csa_pos; |
| 583 | |
| 584 | pos = hostapd_eid_supported_op_classes(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 585 | pos = hostapd_eid_ht_capabilities(hapd, pos); |
| 586 | pos = hostapd_eid_ht_operation(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 587 | |
| 588 | pos = hostapd_eid_ext_capab(hapd, pos); |
| 589 | |
| 590 | pos = hostapd_eid_time_adv(hapd, pos); |
| 591 | pos = hostapd_eid_time_zone(hapd, pos); |
| 592 | |
| 593 | pos = hostapd_eid_interworking(hapd, pos); |
| 594 | pos = hostapd_eid_adv_proto(hapd, pos); |
| 595 | pos = hostapd_eid_roaming_consortium(hapd, pos); |
| 596 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 597 | #ifdef CONFIG_FST |
| 598 | if (hapd->iface->fst_ies) { |
| 599 | os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies), |
| 600 | wpabuf_len(hapd->iface->fst_ies)); |
| 601 | pos += wpabuf_len(hapd->iface->fst_ies); |
| 602 | } |
| 603 | #endif /* CONFIG_FST */ |
| 604 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 605 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 606 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac && |
| 607 | !is_6ghz_op_class(hapd->iconf->op_class)) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 608 | pos = hostapd_eid_vht_capabilities(hapd, pos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 609 | pos = hostapd_eid_vht_operation(hapd, pos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 610 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 611 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 612 | #endif /* CONFIG_IEEE80211AC */ |
| 613 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 614 | #ifdef CONFIG_IEEE80211AX |
| 615 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax && |
| 616 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 617 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
| 618 | #endif /* CONFIG_IEEE80211AX */ |
| 619 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 620 | pos = hostapd_eid_wb_chsw_wrapper(hapd, pos); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 621 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 622 | pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_PROBE_RESP); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 623 | pos = hostapd_eid_fils_indic(hapd, pos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 624 | pos = hostapd_get_rsnxe(hapd, pos, epos - pos); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 625 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 626 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 627 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 628 | u8 *cca_pos; |
| 629 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 630 | pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 631 | pos = hostapd_eid_he_operation(hapd, pos); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 632 | |
| 633 | /* BSS Color Change Announcement element */ |
| 634 | cca_pos = hostapd_eid_cca(hapd, pos); |
| 635 | if (cca_pos != pos) |
| 636 | hapd->cca_c_off_proberesp = cca_pos - (u8 *) resp - 2; |
| 637 | pos = cca_pos; |
| 638 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 639 | pos = hostapd_eid_spatial_reuse(hapd, pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 640 | pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 641 | pos = hostapd_eid_he_6ghz_band_cap(hapd, pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 642 | } |
| 643 | #endif /* CONFIG_IEEE80211AX */ |
| 644 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 645 | #ifdef CONFIG_IEEE80211BE |
| 646 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 647 | pos = hostapd_eid_eht_capab(hapd, pos, IEEE80211_MODE_AP); |
| 648 | pos = hostapd_eid_eht_operation(hapd, pos); |
| 649 | } |
| 650 | #endif /* CONFIG_IEEE80211BE */ |
| 651 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 652 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 653 | if (hapd->conf->vendor_vht) |
| 654 | pos = hostapd_eid_vendor_vht(hapd, pos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 655 | #endif /* CONFIG_IEEE80211AC */ |
| 656 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 657 | /* WPA / OSEN */ |
| 658 | pos = hostapd_get_wpa_ie(hapd, pos, epos - pos); |
| 659 | pos = hostapd_get_osen_ie(hapd, pos, epos - pos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 660 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 661 | /* Wi-Fi Alliance WMM */ |
| 662 | pos = hostapd_eid_wmm(hapd, pos); |
| 663 | |
| 664 | #ifdef CONFIG_WPS |
| 665 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) { |
| 666 | os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie), |
| 667 | wpabuf_len(hapd->wps_probe_resp_ie)); |
| 668 | pos += wpabuf_len(hapd->wps_probe_resp_ie); |
| 669 | } |
| 670 | #endif /* CONFIG_WPS */ |
| 671 | |
| 672 | #ifdef CONFIG_P2P |
| 673 | if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p && |
| 674 | hapd->p2p_probe_resp_ie) { |
| 675 | os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie), |
| 676 | wpabuf_len(hapd->p2p_probe_resp_ie)); |
| 677 | pos += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 678 | } |
| 679 | #endif /* CONFIG_P2P */ |
| 680 | #ifdef CONFIG_P2P_MANAGER |
| 681 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 682 | P2P_MANAGE) |
| 683 | pos = hostapd_eid_p2p_manage(hapd, pos); |
| 684 | #endif /* CONFIG_P2P_MANAGER */ |
| 685 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 686 | #ifdef CONFIG_HS20 |
| 687 | pos = hostapd_eid_hs20_indication(hapd, pos); |
| 688 | #endif /* CONFIG_HS20 */ |
| 689 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 690 | pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 691 | pos = hostapd_eid_owe_trans(hapd, pos, (u8 *) resp + buflen - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 692 | pos = hostapd_eid_dpp_cc(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 693 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 694 | if (hapd->conf->vendor_elements) { |
| 695 | os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements), |
| 696 | wpabuf_len(hapd->conf->vendor_elements)); |
| 697 | pos += wpabuf_len(hapd->conf->vendor_elements); |
| 698 | } |
| 699 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 700 | *resp_len = pos - (u8 *) resp; |
| 701 | return (u8 *) resp; |
| 702 | } |
| 703 | |
| 704 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 705 | enum ssid_match_result { |
| 706 | NO_SSID_MATCH, |
| 707 | EXACT_SSID_MATCH, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 708 | WILDCARD_SSID_MATCH, |
| 709 | CO_LOCATED_SSID_MATCH, |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 710 | }; |
| 711 | |
| 712 | static enum ssid_match_result ssid_match(struct hostapd_data *hapd, |
| 713 | const u8 *ssid, size_t ssid_len, |
| 714 | const u8 *ssid_list, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 715 | size_t ssid_list_len, |
| 716 | const u8 *short_ssid_list, |
| 717 | size_t short_ssid_list_len) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 718 | { |
| 719 | const u8 *pos, *end; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 720 | struct hostapd_iface *iface = hapd->iface; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 721 | int wildcard = 0; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 722 | size_t i, j; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 723 | |
| 724 | if (ssid_len == 0) |
| 725 | wildcard = 1; |
| 726 | if (ssid_len == hapd->conf->ssid.ssid_len && |
| 727 | os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0) |
| 728 | return EXACT_SSID_MATCH; |
| 729 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 730 | if (ssid_list) { |
| 731 | pos = ssid_list; |
| 732 | end = ssid_list + ssid_list_len; |
| 733 | while (end - pos >= 2) { |
| 734 | if (2 + pos[1] > end - pos) |
| 735 | break; |
| 736 | if (pos[1] == 0) |
| 737 | wildcard = 1; |
| 738 | if (pos[1] == hapd->conf->ssid.ssid_len && |
| 739 | os_memcmp(pos + 2, hapd->conf->ssid.ssid, |
| 740 | pos[1]) == 0) |
| 741 | return EXACT_SSID_MATCH; |
| 742 | pos += 2 + pos[1]; |
| 743 | } |
| 744 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 745 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 746 | if (short_ssid_list) { |
| 747 | pos = short_ssid_list; |
| 748 | end = short_ssid_list + short_ssid_list_len; |
| 749 | while (end - pos >= 4) { |
| 750 | if (hapd->conf->ssid.short_ssid == WPA_GET_LE32(pos)) |
| 751 | return EXACT_SSID_MATCH; |
| 752 | pos += 4; |
| 753 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 754 | } |
| 755 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 756 | if (wildcard) |
| 757 | return WILDCARD_SSID_MATCH; |
| 758 | |
| 759 | if (!iface->interfaces || iface->interfaces->count <= 1 || |
| 760 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 761 | return NO_SSID_MATCH; |
| 762 | |
| 763 | for (i = 0; i < iface->interfaces->count; i++) { |
| 764 | struct hostapd_iface *colocated; |
| 765 | |
| 766 | colocated = iface->interfaces->iface[i]; |
| 767 | |
| 768 | if (colocated == iface || |
| 769 | !is_6ghz_op_class(colocated->conf->op_class)) |
| 770 | continue; |
| 771 | |
| 772 | for (j = 0; j < colocated->num_bss; j++) { |
| 773 | struct hostapd_bss_config *conf; |
| 774 | |
| 775 | conf = colocated->bss[j]->conf; |
| 776 | if (ssid_len == conf->ssid.ssid_len && |
| 777 | os_memcmp(ssid, conf->ssid.ssid, ssid_len) == 0) |
| 778 | return CO_LOCATED_SSID_MATCH; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | return NO_SSID_MATCH; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 783 | } |
| 784 | |
| 785 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 786 | void sta_track_expire(struct hostapd_iface *iface, int force) |
| 787 | { |
| 788 | struct os_reltime now; |
| 789 | struct hostapd_sta_info *info; |
| 790 | |
| 791 | if (!iface->num_sta_seen) |
| 792 | return; |
| 793 | |
| 794 | os_get_reltime(&now); |
| 795 | while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, |
| 796 | list))) { |
| 797 | if (!force && |
| 798 | !os_reltime_expired(&now, &info->last_seen, |
| 799 | iface->conf->track_sta_max_age)) |
| 800 | break; |
| 801 | force = 0; |
| 802 | |
| 803 | wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for " |
| 804 | MACSTR, iface->bss[0]->conf->iface, |
| 805 | MAC2STR(info->addr)); |
| 806 | dl_list_del(&info->list); |
| 807 | iface->num_sta_seen--; |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 808 | sta_track_del(info); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 809 | } |
| 810 | } |
| 811 | |
| 812 | |
| 813 | static struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface, |
| 814 | const u8 *addr) |
| 815 | { |
| 816 | struct hostapd_sta_info *info; |
| 817 | |
| 818 | dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list) |
| 819 | if (os_memcmp(addr, info->addr, ETH_ALEN) == 0) |
| 820 | return info; |
| 821 | |
| 822 | return NULL; |
| 823 | } |
| 824 | |
| 825 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 826 | void sta_track_add(struct hostapd_iface *iface, const u8 *addr, int ssi_signal) |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 827 | { |
| 828 | struct hostapd_sta_info *info; |
| 829 | |
| 830 | info = sta_track_get(iface, addr); |
| 831 | if (info) { |
| 832 | /* Move the most recent entry to the end of the list */ |
| 833 | dl_list_del(&info->list); |
| 834 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 835 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 836 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 837 | return; |
| 838 | } |
| 839 | |
| 840 | /* Add a new entry */ |
| 841 | info = os_zalloc(sizeof(*info)); |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 842 | if (info == NULL) |
| 843 | return; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 844 | os_memcpy(info->addr, addr, ETH_ALEN); |
| 845 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 846 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 847 | |
| 848 | if (iface->num_sta_seen >= iface->conf->track_sta_max_num) { |
| 849 | /* Expire oldest entry to make room for a new one */ |
| 850 | sta_track_expire(iface, 1); |
| 851 | } |
| 852 | |
| 853 | wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for " |
| 854 | MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr)); |
| 855 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 856 | iface->num_sta_seen++; |
| 857 | } |
| 858 | |
| 859 | |
| 860 | struct hostapd_data * |
| 861 | sta_track_seen_on(struct hostapd_iface *iface, const u8 *addr, |
| 862 | const char *ifname) |
| 863 | { |
| 864 | struct hapd_interfaces *interfaces = iface->interfaces; |
| 865 | size_t i, j; |
| 866 | |
| 867 | for (i = 0; i < interfaces->count; i++) { |
| 868 | struct hostapd_data *hapd = NULL; |
| 869 | |
| 870 | iface = interfaces->iface[i]; |
| 871 | for (j = 0; j < iface->num_bss; j++) { |
| 872 | hapd = iface->bss[j]; |
| 873 | if (os_strcmp(ifname, hapd->conf->iface) == 0) |
| 874 | break; |
| 875 | hapd = NULL; |
| 876 | } |
| 877 | |
| 878 | if (hapd && sta_track_get(iface, addr)) |
| 879 | return hapd; |
| 880 | } |
| 881 | |
| 882 | return NULL; |
| 883 | } |
| 884 | |
| 885 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 886 | #ifdef CONFIG_TAXONOMY |
| 887 | void sta_track_claim_taxonomy_info(struct hostapd_iface *iface, const u8 *addr, |
| 888 | struct wpabuf **probe_ie_taxonomy) |
| 889 | { |
| 890 | struct hostapd_sta_info *info; |
| 891 | |
| 892 | info = sta_track_get(iface, addr); |
| 893 | if (!info) |
| 894 | return; |
| 895 | |
| 896 | wpabuf_free(*probe_ie_taxonomy); |
| 897 | *probe_ie_taxonomy = info->probe_ie_taxonomy; |
| 898 | info->probe_ie_taxonomy = NULL; |
| 899 | } |
| 900 | #endif /* CONFIG_TAXONOMY */ |
| 901 | |
| 902 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 903 | void handle_probe_req(struct hostapd_data *hapd, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 904 | const struct ieee80211_mgmt *mgmt, size_t len, |
| 905 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 906 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 907 | u8 *resp; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 908 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 909 | const u8 *ie; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 910 | size_t ie_len; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 911 | size_t i, resp_len; |
| 912 | int noack; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 913 | enum ssid_match_result res; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 914 | int ret; |
| 915 | u16 csa_offs[2]; |
| 916 | size_t csa_offs_len; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 917 | struct radius_sta rad_info; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 918 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 919 | if (hapd->iconf->rssi_ignore_probe_request && ssi_signal && |
| 920 | ssi_signal < hapd->iconf->rssi_ignore_probe_request) |
| 921 | return; |
| 922 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 923 | if (len < IEEE80211_HDRLEN) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 924 | return; |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 925 | ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 926 | if (hapd->iconf->track_sta_max_num) |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 927 | sta_track_add(hapd->iface, mgmt->sa, ssi_signal); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 928 | ie_len = len - IEEE80211_HDRLEN; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 929 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 930 | ret = hostapd_allowed_address(hapd, mgmt->sa, (const u8 *) mgmt, len, |
| 931 | &rad_info, 1); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 932 | if (ret == HOSTAPD_ACL_REJECT) { |
| 933 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 934 | "Ignore Probe Request frame from " MACSTR |
| 935 | " due to ACL reject ", MAC2STR(mgmt->sa)); |
| 936 | return; |
| 937 | } |
| 938 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 939 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) |
| 940 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 941 | mgmt->sa, mgmt->da, mgmt->bssid, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 942 | ie, ie_len, ssi_signal) > 0) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 943 | return; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 944 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 945 | if (!hapd->conf->send_probe_response) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 946 | return; |
| 947 | |
| 948 | if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) { |
| 949 | wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR, |
| 950 | MAC2STR(mgmt->sa)); |
| 951 | return; |
| 952 | } |
| 953 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 954 | if ((!elems.ssid || !elems.supp_rates)) { |
| 955 | wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request " |
| 956 | "without SSID or supported rates element", |
| 957 | MAC2STR(mgmt->sa)); |
| 958 | return; |
| 959 | } |
| 960 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 961 | /* |
| 962 | * No need to reply if the Probe Request frame was sent on an adjacent |
| 963 | * channel. IEEE Std 802.11-2012 describes this as a requirement for an |
| 964 | * AP with dot11RadioMeasurementActivated set to true, but strictly |
| 965 | * speaking does not allow such ignoring of Probe Request frames if |
| 966 | * dot11RadioMeasurementActivated is false. Anyway, this can help reduce |
| 967 | * number of unnecessary Probe Response frames for cases where the STA |
| 968 | * is less likely to see them (Probe Request frame sent on a |
| 969 | * neighboring, but partially overlapping, channel). |
| 970 | */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 971 | if (elems.ds_params && |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 972 | hapd->iface->current_mode && |
| 973 | (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G || |
| 974 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) && |
| 975 | hapd->iconf->channel != elems.ds_params[0]) { |
| 976 | wpa_printf(MSG_DEBUG, |
| 977 | "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u", |
| 978 | hapd->iconf->channel, elems.ds_params[0]); |
| 979 | return; |
| 980 | } |
| 981 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 982 | #ifdef CONFIG_P2P |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 983 | if (hapd->p2p && hapd->p2p_group && elems.wps_ie) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 984 | struct wpabuf *wps; |
| 985 | wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA); |
| 986 | if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) { |
| 987 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 988 | "due to mismatch with Requested Device " |
| 989 | "Type"); |
| 990 | wpabuf_free(wps); |
| 991 | return; |
| 992 | } |
| 993 | wpabuf_free(wps); |
| 994 | } |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 995 | |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 996 | if (hapd->p2p && hapd->p2p_group && elems.p2p) { |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 997 | struct wpabuf *p2p; |
| 998 | p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE); |
| 999 | if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) { |
| 1000 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 1001 | "due to mismatch with Device ID"); |
| 1002 | wpabuf_free(p2p); |
| 1003 | return; |
| 1004 | } |
| 1005 | wpabuf_free(p2p); |
| 1006 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1007 | #endif /* CONFIG_P2P */ |
| 1008 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1009 | if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 && |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1010 | elems.ssid_list_len == 0 && elems.short_ssid_list_len == 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1011 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 1012 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 1013 | return; |
| 1014 | } |
| 1015 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1016 | #ifdef CONFIG_P2P |
| 1017 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 1018 | elems.ssid_len == P2P_WILDCARD_SSID_LEN && |
| 1019 | os_memcmp(elems.ssid, P2P_WILDCARD_SSID, |
| 1020 | P2P_WILDCARD_SSID_LEN) == 0) { |
| 1021 | /* Process P2P Wildcard SSID like Wildcard SSID */ |
| 1022 | elems.ssid_len = 0; |
| 1023 | } |
| 1024 | #endif /* CONFIG_P2P */ |
| 1025 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 1026 | #ifdef CONFIG_TAXONOMY |
| 1027 | { |
| 1028 | struct sta_info *sta; |
| 1029 | struct hostapd_sta_info *info; |
| 1030 | |
| 1031 | if ((sta = ap_get_sta(hapd, mgmt->sa)) != NULL) { |
| 1032 | taxonomy_sta_info_probe_req(hapd, sta, ie, ie_len); |
| 1033 | } else if ((info = sta_track_get(hapd->iface, |
| 1034 | mgmt->sa)) != NULL) { |
| 1035 | taxonomy_hostapd_sta_info_probe_req(hapd, info, |
| 1036 | ie, ie_len); |
| 1037 | } |
| 1038 | } |
| 1039 | #endif /* CONFIG_TAXONOMY */ |
| 1040 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1041 | res = ssid_match(hapd, elems.ssid, elems.ssid_len, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1042 | elems.ssid_list, elems.ssid_list_len, |
| 1043 | elems.short_ssid_list, elems.short_ssid_list_len); |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1044 | if (res == NO_SSID_MATCH) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1045 | if (!(mgmt->da[0] & 0x01)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1046 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1047 | " for foreign SSID '%s' (DA " MACSTR ")%s", |
Dmitry Shmidt | 3c47937 | 2014-02-04 10:50:36 -0800 | [diff] [blame] | 1048 | MAC2STR(mgmt->sa), |
| 1049 | wpa_ssid_txt(elems.ssid, elems.ssid_len), |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1050 | MAC2STR(mgmt->da), |
| 1051 | elems.ssid_list ? " (SSID list)" : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1052 | } |
| 1053 | return; |
| 1054 | } |
| 1055 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1056 | if (hapd->conf->ignore_broadcast_ssid && res == WILDCARD_SSID_MATCH) { |
| 1057 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 1058 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 1059 | return; |
| 1060 | } |
| 1061 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1062 | #ifdef CONFIG_INTERWORKING |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 1063 | if (hapd->conf->interworking && |
| 1064 | elems.interworking && elems.interworking_len >= 1) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1065 | u8 ant = elems.interworking[0] & 0x0f; |
| 1066 | if (ant != INTERWORKING_ANT_WILDCARD && |
| 1067 | ant != hapd->conf->access_network_type) { |
| 1068 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 1069 | " for mismatching ANT %u ignored", |
| 1070 | MAC2STR(mgmt->sa), ant); |
| 1071 | return; |
| 1072 | } |
| 1073 | } |
| 1074 | |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 1075 | if (hapd->conf->interworking && elems.interworking && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1076 | (elems.interworking_len == 7 || elems.interworking_len == 9)) { |
| 1077 | const u8 *hessid; |
| 1078 | if (elems.interworking_len == 7) |
| 1079 | hessid = elems.interworking + 1; |
| 1080 | else |
| 1081 | hessid = elems.interworking + 1 + 2; |
| 1082 | if (!is_broadcast_ether_addr(hessid) && |
| 1083 | os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) { |
| 1084 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 1085 | " for mismatching HESSID " MACSTR |
| 1086 | " ignored", |
| 1087 | MAC2STR(mgmt->sa), MAC2STR(hessid)); |
| 1088 | return; |
| 1089 | } |
| 1090 | } |
| 1091 | #endif /* CONFIG_INTERWORKING */ |
| 1092 | |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 1093 | #ifdef CONFIG_P2P |
| 1094 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 1095 | supp_rates_11b_only(&elems)) { |
| 1096 | /* Indicates support for 11b rates only */ |
| 1097 | wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from " |
| 1098 | MACSTR " with only 802.11b rates", |
| 1099 | MAC2STR(mgmt->sa)); |
| 1100 | return; |
| 1101 | } |
| 1102 | #endif /* CONFIG_P2P */ |
| 1103 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1104 | /* TODO: verify that supp_rates contains at least one matching rate |
| 1105 | * with AP configuration */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1106 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1107 | if (hapd->conf->no_probe_resp_if_seen_on && |
| 1108 | is_multicast_ether_addr(mgmt->da) && |
| 1109 | is_multicast_ether_addr(mgmt->bssid) && |
| 1110 | sta_track_seen_on(hapd->iface, mgmt->sa, |
| 1111 | hapd->conf->no_probe_resp_if_seen_on)) { |
| 1112 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1113 | " since STA has been seen on %s", |
| 1114 | hapd->conf->iface, MAC2STR(mgmt->sa), |
| 1115 | hapd->conf->no_probe_resp_if_seen_on); |
| 1116 | return; |
| 1117 | } |
| 1118 | |
| 1119 | if (hapd->conf->no_probe_resp_if_max_sta && |
| 1120 | is_multicast_ether_addr(mgmt->da) && |
| 1121 | is_multicast_ether_addr(mgmt->bssid) && |
| 1122 | hapd->num_sta >= hapd->conf->max_num_sta && |
| 1123 | !ap_get_sta(hapd, mgmt->sa)) { |
| 1124 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1125 | " since no room for additional STA", |
| 1126 | hapd->conf->iface, MAC2STR(mgmt->sa)); |
| 1127 | return; |
| 1128 | } |
| 1129 | |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1130 | #ifdef CONFIG_TESTING_OPTIONS |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1131 | if (hapd->iconf->ignore_probe_probability > 0.0 && |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1132 | drand48() < hapd->iconf->ignore_probe_probability) { |
| 1133 | wpa_printf(MSG_INFO, |
| 1134 | "TESTING: ignoring probe request from " MACSTR, |
| 1135 | MAC2STR(mgmt->sa)); |
| 1136 | return; |
| 1137 | } |
| 1138 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 1139 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1140 | wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, RX_PROBE_REQUEST "sa=" MACSTR |
| 1141 | " signal=%d", MAC2STR(mgmt->sa), ssi_signal); |
| 1142 | |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1143 | resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1144 | &resp_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1145 | if (resp == NULL) |
| 1146 | return; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1147 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1148 | /* |
| 1149 | * If this is a broadcast probe request, apply no ack policy to avoid |
| 1150 | * excessive retries. |
| 1151 | */ |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1152 | noack = !!(res == WILDCARD_SSID_MATCH && |
| 1153 | is_broadcast_ether_addr(mgmt->da)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1154 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1155 | csa_offs_len = 0; |
| 1156 | if (hapd->csa_in_progress) { |
| 1157 | if (hapd->cs_c_off_proberesp) |
| 1158 | csa_offs[csa_offs_len++] = |
| 1159 | hapd->cs_c_off_proberesp; |
| 1160 | |
| 1161 | if (hapd->cs_c_off_ecsa_proberesp) |
| 1162 | csa_offs[csa_offs_len++] = |
| 1163 | hapd->cs_c_off_ecsa_proberesp; |
| 1164 | } |
| 1165 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1166 | ret = hostapd_drv_send_mlme(hapd, resp, resp_len, noack, |
| 1167 | csa_offs_len ? csa_offs : NULL, |
| 1168 | csa_offs_len, 0); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1169 | |
| 1170 | if (ret < 0) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1171 | wpa_printf(MSG_INFO, "handle_probe_req: send failed"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1172 | |
| 1173 | os_free(resp); |
| 1174 | |
| 1175 | wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s " |
| 1176 | "SSID", MAC2STR(mgmt->sa), |
| 1177 | elems.ssid_len == 0 ? "broadcast" : "our"); |
| 1178 | } |
| 1179 | |
| 1180 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1181 | static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd, |
| 1182 | size_t *resp_len) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1183 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1184 | /* check probe response offloading caps and print warnings */ |
| 1185 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD)) |
| 1186 | return NULL; |
| 1187 | |
| 1188 | #ifdef CONFIG_WPS |
| 1189 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie && |
| 1190 | (!(hapd->iface->probe_resp_offloads & |
| 1191 | (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS | |
| 1192 | WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2)))) |
| 1193 | wpa_printf(MSG_WARNING, "Device is trying to offload WPS " |
| 1194 | "Probe Response while not supporting this"); |
| 1195 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1196 | |
| 1197 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1198 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie && |
| 1199 | !(hapd->iface->probe_resp_offloads & |
| 1200 | WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P)) |
| 1201 | wpa_printf(MSG_WARNING, "Device is trying to offload P2P " |
| 1202 | "Probe Response while not supporting this"); |
| 1203 | #endif /* CONFIG_P2P */ |
| 1204 | |
| 1205 | if (hapd->conf->interworking && |
| 1206 | !(hapd->iface->probe_resp_offloads & |
| 1207 | WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING)) |
| 1208 | wpa_printf(MSG_WARNING, "Device is trying to offload " |
| 1209 | "Interworking Probe Response while not supporting " |
| 1210 | "this"); |
| 1211 | |
| 1212 | /* Generate a Probe Response template for the non-P2P case */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1213 | return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1214 | } |
| 1215 | |
| 1216 | #endif /* NEED_AP_MLME */ |
| 1217 | |
| 1218 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1219 | #ifdef CONFIG_IEEE80211AX |
| 1220 | /* Unsolicited broadcast Probe Response transmission, 6 GHz only */ |
| 1221 | static u8 * hostapd_unsol_bcast_probe_resp(struct hostapd_data *hapd, |
| 1222 | struct wpa_driver_ap_params *params) |
| 1223 | { |
| 1224 | if (!is_6ghz_op_class(hapd->iconf->op_class)) |
| 1225 | return NULL; |
| 1226 | |
| 1227 | params->unsol_bcast_probe_resp_interval = |
| 1228 | hapd->conf->unsol_bcast_probe_resp_interval; |
| 1229 | |
| 1230 | return hostapd_gen_probe_resp(hapd, NULL, 0, |
| 1231 | ¶ms->unsol_bcast_probe_resp_tmpl_len); |
| 1232 | } |
| 1233 | #endif /* CONFIG_IEEE80211AX */ |
| 1234 | |
| 1235 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 1236 | void sta_track_del(struct hostapd_sta_info *info) |
| 1237 | { |
| 1238 | #ifdef CONFIG_TAXONOMY |
| 1239 | wpabuf_free(info->probe_ie_taxonomy); |
| 1240 | info->probe_ie_taxonomy = NULL; |
| 1241 | #endif /* CONFIG_TAXONOMY */ |
| 1242 | os_free(info); |
| 1243 | } |
| 1244 | |
| 1245 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1246 | #ifdef CONFIG_FILS |
| 1247 | |
| 1248 | static u16 hostapd_fils_discovery_cap(struct hostapd_data *hapd) |
| 1249 | { |
| 1250 | u16 cap_info, phy_index = 0; |
| 1251 | u8 chwidth = FD_CAP_BSS_CHWIDTH_20, mcs_nss_size = 4; |
| 1252 | struct hostapd_hw_modes *mode = hapd->iface->current_mode; |
| 1253 | |
| 1254 | cap_info = FD_CAP_ESS; |
| 1255 | if (hapd->conf->wpa) |
| 1256 | cap_info |= FD_CAP_PRIVACY; |
| 1257 | |
| 1258 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
| 1259 | phy_index = FD_CAP_PHY_INDEX_HE; |
| 1260 | |
| 1261 | switch (hapd->iconf->op_class) { |
| 1262 | case 135: |
| 1263 | mcs_nss_size += 4; |
| 1264 | /* fallthrough */ |
| 1265 | case 134: |
| 1266 | mcs_nss_size += 4; |
| 1267 | chwidth = FD_CAP_BSS_CHWIDTH_160_80_80; |
| 1268 | break; |
| 1269 | case 133: |
| 1270 | chwidth = FD_CAP_BSS_CHWIDTH_80; |
| 1271 | break; |
| 1272 | case 132: |
| 1273 | chwidth = FD_CAP_BSS_CHWIDTH_40; |
| 1274 | break; |
| 1275 | } |
| 1276 | } else { |
| 1277 | switch (hostapd_get_oper_chwidth(hapd->iconf)) { |
| 1278 | case CHANWIDTH_80P80MHZ: |
| 1279 | mcs_nss_size += 4; |
| 1280 | /* fallthrough */ |
| 1281 | case CHANWIDTH_160MHZ: |
| 1282 | mcs_nss_size += 4; |
| 1283 | chwidth = FD_CAP_BSS_CHWIDTH_160_80_80; |
| 1284 | break; |
| 1285 | case CHANWIDTH_80MHZ: |
| 1286 | chwidth = FD_CAP_BSS_CHWIDTH_80; |
| 1287 | break; |
| 1288 | case CHANWIDTH_USE_HT: |
| 1289 | if (hapd->iconf->secondary_channel) |
| 1290 | chwidth = FD_CAP_BSS_CHWIDTH_40; |
| 1291 | else |
| 1292 | chwidth = FD_CAP_BSS_CHWIDTH_20; |
| 1293 | break; |
| 1294 | } |
| 1295 | |
| 1296 | #ifdef CONFIG_IEEE80211AX |
| 1297 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) |
| 1298 | phy_index = FD_CAP_PHY_INDEX_HE; |
| 1299 | #endif /* CONFIG_IEEE80211AX */ |
| 1300 | #ifdef CONFIG_IEEE80211AC |
| 1301 | if (!phy_index && |
| 1302 | hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) |
| 1303 | phy_index = FD_CAP_PHY_INDEX_VHT; |
| 1304 | #endif /* CONFIG_IEEE80211AC */ |
| 1305 | if (!phy_index && |
| 1306 | hapd->iconf->ieee80211n && !hapd->conf->disable_11n) |
| 1307 | phy_index = FD_CAP_PHY_INDEX_HT; |
| 1308 | } |
| 1309 | |
| 1310 | cap_info |= phy_index << FD_CAP_PHY_INDEX_SHIFT; |
| 1311 | cap_info |= chwidth << FD_CAP_BSS_CHWIDTH_SHIFT; |
| 1312 | |
| 1313 | if (mode) { |
| 1314 | u16 *mcs = (u16 *) mode->he_capab[IEEE80211_MODE_AP].mcs; |
| 1315 | int i; |
| 1316 | u16 nss = 0; |
| 1317 | |
| 1318 | for (i = 0; i < HE_NSS_MAX_STREAMS; i++) { |
| 1319 | u16 nss_mask = 0x3 << (i * 2); |
| 1320 | |
| 1321 | if (mcs_nss_size == 4 && |
| 1322 | (((mcs[0] & nss_mask) == nss_mask) || |
| 1323 | ((mcs[1] & nss_mask) == nss_mask))) |
| 1324 | continue; |
| 1325 | |
| 1326 | if (mcs_nss_size == 8 && |
| 1327 | (((mcs[2] & nss_mask) == nss_mask) || |
| 1328 | ((mcs[3] & nss_mask) == nss_mask))) |
| 1329 | continue; |
| 1330 | |
| 1331 | if (mcs_nss_size == 12 && |
| 1332 | (((mcs[4] & nss_mask) == nss_mask) || |
| 1333 | ((mcs[5] & nss_mask) == nss_mask))) |
| 1334 | continue; |
| 1335 | |
| 1336 | nss++; |
| 1337 | } |
| 1338 | |
| 1339 | if (nss > 4) |
| 1340 | cap_info |= FD_CAP_NSS_5_8 << FD_CAP_NSS_SHIFT; |
| 1341 | else if (nss) |
| 1342 | cap_info |= (nss - 1) << FD_CAP_NSS_SHIFT; |
| 1343 | } |
| 1344 | |
| 1345 | return cap_info; |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | static u8 * hostapd_gen_fils_discovery(struct hostapd_data *hapd, size_t *len) |
| 1350 | { |
| 1351 | struct ieee80211_mgmt *head; |
| 1352 | const u8 *mobility_domain; |
| 1353 | u8 *pos, *length_pos, buf[200]; |
| 1354 | u16 ctl = 0; |
| 1355 | u8 fd_rsn_info[5]; |
| 1356 | size_t total_len, buf_len; |
| 1357 | |
| 1358 | total_len = 24 + 2 + 12; |
| 1359 | |
| 1360 | /* FILS Discovery Frame Control */ |
| 1361 | ctl = (sizeof(hapd->conf->ssid.short_ssid) - 1) | |
| 1362 | FD_FRAME_CTL_SHORT_SSID_PRESENT | |
| 1363 | FD_FRAME_CTL_LENGTH_PRESENT | |
| 1364 | FD_FRAME_CTL_CAP_PRESENT; |
| 1365 | total_len += 4 + 1 + 2; |
| 1366 | |
| 1367 | /* Check for optional subfields and calculate length */ |
| 1368 | if (wpa_auth_write_fd_rsn_info(hapd->wpa_auth, fd_rsn_info)) { |
| 1369 | ctl |= FD_FRAME_CTL_RSN_INFO_PRESENT; |
| 1370 | total_len += sizeof(fd_rsn_info); |
| 1371 | } |
| 1372 | |
| 1373 | mobility_domain = hostapd_wpa_ie(hapd, WLAN_EID_MOBILITY_DOMAIN); |
| 1374 | if (mobility_domain) { |
| 1375 | ctl |= FD_FRAME_CTL_MD_PRESENT; |
| 1376 | total_len += 3; |
| 1377 | } |
| 1378 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1379 | total_len += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_ACTION); |
| 1380 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1381 | pos = hostapd_eid_fils_indic(hapd, buf, 0); |
| 1382 | buf_len = pos - buf; |
| 1383 | total_len += buf_len; |
| 1384 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1385 | #ifdef CONFIG_IEEE80211AX |
| 1386 | /* Transmit Power Envelope element(s) */ |
| 1387 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
| 1388 | total_len += 4; |
| 1389 | if (hapd->iconf->he_6ghz_reg_pwr_type == HE_6GHZ_INDOOR_AP) |
| 1390 | total_len += 4; |
| 1391 | } |
| 1392 | #endif /* CONFIG_IEEE80211AX */ |
| 1393 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1394 | head = os_zalloc(total_len); |
| 1395 | if (!head) |
| 1396 | return NULL; |
| 1397 | |
| 1398 | head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1399 | WLAN_FC_STYPE_ACTION); |
| 1400 | os_memset(head->da, 0xff, ETH_ALEN); |
| 1401 | os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); |
| 1402 | os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); |
| 1403 | |
| 1404 | head->u.action.category = WLAN_ACTION_PUBLIC; |
| 1405 | head->u.action.u.public_action.action = WLAN_PA_FILS_DISCOVERY; |
| 1406 | |
| 1407 | pos = &head->u.action.u.public_action.variable[0]; |
| 1408 | |
| 1409 | /* FILS Discovery Information field */ |
| 1410 | |
| 1411 | /* FILS Discovery Frame Control */ |
| 1412 | WPA_PUT_LE16(pos, ctl); |
| 1413 | pos += 2; |
| 1414 | |
| 1415 | /* Hardware or low-level driver will fill in the Timestamp value */ |
| 1416 | pos += 8; |
| 1417 | |
| 1418 | /* Beacon Interval */ |
| 1419 | WPA_PUT_LE16(pos, hapd->iconf->beacon_int); |
| 1420 | pos += 2; |
| 1421 | |
| 1422 | /* Short SSID */ |
| 1423 | WPA_PUT_LE32(pos, hapd->conf->ssid.short_ssid); |
| 1424 | pos += sizeof(hapd->conf->ssid.short_ssid); |
| 1425 | |
| 1426 | /* Store position of FILS discovery information element Length field */ |
| 1427 | length_pos = pos++; |
| 1428 | |
| 1429 | /* FD Capability */ |
| 1430 | WPA_PUT_LE16(pos, hostapd_fils_discovery_cap(hapd)); |
| 1431 | pos += 2; |
| 1432 | |
| 1433 | /* Operating Class - not present */ |
| 1434 | |
| 1435 | /* Primary Channel - not present */ |
| 1436 | |
| 1437 | /* AP Configuration Sequence Number - not present */ |
| 1438 | |
| 1439 | /* Access Network Options - not present */ |
| 1440 | |
| 1441 | /* FD RSN Information */ |
| 1442 | if (ctl & FD_FRAME_CTL_RSN_INFO_PRESENT) { |
| 1443 | os_memcpy(pos, fd_rsn_info, sizeof(fd_rsn_info)); |
| 1444 | pos += sizeof(fd_rsn_info); |
| 1445 | } |
| 1446 | |
| 1447 | /* Channel Center Frequency Segment 1 - not present */ |
| 1448 | |
| 1449 | /* Mobility Domain */ |
| 1450 | if (ctl & FD_FRAME_CTL_MD_PRESENT) { |
| 1451 | os_memcpy(pos, &mobility_domain[2], 3); |
| 1452 | pos += 3; |
| 1453 | } |
| 1454 | |
| 1455 | /* Fill in the Length field value */ |
| 1456 | *length_pos = pos - (length_pos + 1); |
| 1457 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1458 | pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_ACTION); |
| 1459 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1460 | /* FILS Indication element */ |
| 1461 | if (buf_len) { |
| 1462 | os_memcpy(pos, buf, buf_len); |
| 1463 | pos += buf_len; |
| 1464 | } |
| 1465 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1466 | if (is_6ghz_op_class(hapd->iconf->op_class)) |
| 1467 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
| 1468 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1469 | *len = pos - (u8 *) head; |
| 1470 | wpa_hexdump(MSG_DEBUG, "FILS Discovery frame template", |
| 1471 | head, pos - (u8 *) head); |
| 1472 | return (u8 *) head; |
| 1473 | } |
| 1474 | |
| 1475 | |
| 1476 | /* Configure FILS Discovery frame transmission parameters */ |
| 1477 | static u8 * hostapd_fils_discovery(struct hostapd_data *hapd, |
| 1478 | struct wpa_driver_ap_params *params) |
| 1479 | { |
| 1480 | params->fd_max_int = hapd->conf->fils_discovery_max_int; |
| 1481 | if (is_6ghz_op_class(hapd->iconf->op_class) && |
| 1482 | params->fd_max_int > FD_MAX_INTERVAL_6GHZ) |
| 1483 | params->fd_max_int = FD_MAX_INTERVAL_6GHZ; |
| 1484 | |
| 1485 | params->fd_min_int = hapd->conf->fils_discovery_min_int; |
| 1486 | if (params->fd_min_int > params->fd_max_int) |
| 1487 | params->fd_min_int = params->fd_max_int; |
| 1488 | |
| 1489 | if (params->fd_max_int) |
| 1490 | return hostapd_gen_fils_discovery(hapd, |
| 1491 | ¶ms->fd_frame_tmpl_len); |
| 1492 | |
| 1493 | return NULL; |
| 1494 | } |
| 1495 | |
| 1496 | #endif /* CONFIG_FILS */ |
| 1497 | |
| 1498 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1499 | int ieee802_11_build_ap_params(struct hostapd_data *hapd, |
| 1500 | struct wpa_driver_ap_params *params) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1501 | { |
| 1502 | struct ieee80211_mgmt *head = NULL; |
| 1503 | u8 *tail = NULL; |
| 1504 | size_t head_len = 0, tail_len = 0; |
| 1505 | u8 *resp = NULL; |
| 1506 | size_t resp_len = 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1507 | #ifdef NEED_AP_MLME |
| 1508 | u16 capab_info; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1509 | u8 *pos, *tailpos, *tailend, *csa_pos; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1510 | |
| 1511 | #define BEACON_HEAD_BUF_SIZE 256 |
| 1512 | #define BEACON_TAIL_BUF_SIZE 512 |
| 1513 | head = os_zalloc(BEACON_HEAD_BUF_SIZE); |
| 1514 | tail_len = BEACON_TAIL_BUF_SIZE; |
| 1515 | #ifdef CONFIG_WPS |
| 1516 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) |
| 1517 | tail_len += wpabuf_len(hapd->wps_beacon_ie); |
| 1518 | #endif /* CONFIG_WPS */ |
| 1519 | #ifdef CONFIG_P2P |
| 1520 | if (hapd->p2p_beacon_ie) |
| 1521 | tail_len += wpabuf_len(hapd->p2p_beacon_ie); |
| 1522 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1523 | #ifdef CONFIG_FST |
| 1524 | if (hapd->iface->fst_ies) |
| 1525 | tail_len += wpabuf_len(hapd->iface->fst_ies); |
| 1526 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1527 | if (hapd->conf->vendor_elements) |
| 1528 | tail_len += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1529 | |
| 1530 | #ifdef CONFIG_IEEE80211AC |
| 1531 | if (hapd->conf->vendor_vht) { |
| 1532 | tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 1533 | 2 + sizeof(struct ieee80211_vht_operation); |
| 1534 | } |
| 1535 | #endif /* CONFIG_IEEE80211AC */ |
| 1536 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1537 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1538 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1539 | tail_len += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1540 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1541 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 1542 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1543 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 1544 | tail_len += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 1545 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1546 | /* An additional Transmit Power Envelope element for |
| 1547 | * subordinate client */ |
| 1548 | if (hapd->iconf->he_6ghz_reg_pwr_type == |
| 1549 | HE_6GHZ_INDOOR_AP) |
| 1550 | tail_len += 4; |
| 1551 | } |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1552 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1553 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1554 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1555 | #ifdef CONFIG_IEEE80211BE |
| 1556 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 1557 | tail_len += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); |
| 1558 | tail_len += 3 + sizeof(struct ieee80211_eht_operation); |
| 1559 | } |
| 1560 | #endif /* CONFIG_IEEE80211BE */ |
| 1561 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1562 | tail_len += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_BEACON); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1563 | tail_len += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1564 | tail_len += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1565 | tail_len += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1566 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1567 | tailpos = tail = os_malloc(tail_len); |
| 1568 | if (head == NULL || tail == NULL) { |
| 1569 | wpa_printf(MSG_ERROR, "Failed to set beacon data"); |
| 1570 | os_free(head); |
| 1571 | os_free(tail); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1572 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1573 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1574 | tailend = tail + tail_len; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1575 | |
| 1576 | head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1577 | WLAN_FC_STYPE_BEACON); |
| 1578 | head->duration = host_to_le16(0); |
| 1579 | os_memset(head->da, 0xff, ETH_ALEN); |
| 1580 | |
| 1581 | os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); |
| 1582 | os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); |
| 1583 | head->u.beacon.beacon_int = |
| 1584 | host_to_le16(hapd->iconf->beacon_int); |
| 1585 | |
| 1586 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1587 | capab_info = hostapd_own_capab_info(hapd); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1588 | head->u.beacon.capab_info = host_to_le16(capab_info); |
| 1589 | pos = &head->u.beacon.variable[0]; |
| 1590 | |
| 1591 | /* SSID */ |
| 1592 | *pos++ = WLAN_EID_SSID; |
| 1593 | if (hapd->conf->ignore_broadcast_ssid == 2) { |
| 1594 | /* clear the data, but keep the correct length of the SSID */ |
| 1595 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1596 | os_memset(pos, 0, hapd->conf->ssid.ssid_len); |
| 1597 | pos += hapd->conf->ssid.ssid_len; |
| 1598 | } else if (hapd->conf->ignore_broadcast_ssid) { |
| 1599 | *pos++ = 0; /* empty SSID */ |
| 1600 | } else { |
| 1601 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1602 | os_memcpy(pos, hapd->conf->ssid.ssid, |
| 1603 | hapd->conf->ssid.ssid_len); |
| 1604 | pos += hapd->conf->ssid.ssid_len; |
| 1605 | } |
| 1606 | |
| 1607 | /* Supported rates */ |
| 1608 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 1609 | |
| 1610 | /* DS Params */ |
| 1611 | pos = hostapd_eid_ds_params(hapd, pos); |
| 1612 | |
| 1613 | head_len = pos - (u8 *) head; |
| 1614 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1615 | tailpos = hostapd_eid_country(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1616 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1617 | /* Power Constraint element */ |
| 1618 | tailpos = hostapd_eid_pwr_constraint(hapd, tailpos); |
| 1619 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1620 | /* CSA IE */ |
| 1621 | csa_pos = hostapd_eid_csa(hapd, tailpos); |
| 1622 | if (csa_pos != tailpos) |
| 1623 | hapd->cs_c_off_beacon = csa_pos - tail - 1; |
| 1624 | tailpos = csa_pos; |
| 1625 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1626 | /* ERP Information element */ |
| 1627 | tailpos = hostapd_eid_erp_info(hapd, tailpos); |
| 1628 | |
| 1629 | /* Extended supported rates */ |
| 1630 | tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos); |
| 1631 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1632 | tailpos = hostapd_get_rsne(hapd, tailpos, tailend - tailpos); |
| 1633 | tailpos = hostapd_eid_bss_load(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1634 | tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1635 | tailend - tailpos); |
| 1636 | tailpos = hostapd_get_mde(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1637 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1638 | /* eCSA IE */ |
| 1639 | csa_pos = hostapd_eid_ecsa(hapd, tailpos); |
| 1640 | if (csa_pos != tailpos) |
| 1641 | hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1; |
| 1642 | tailpos = csa_pos; |
| 1643 | |
| 1644 | tailpos = hostapd_eid_supported_op_classes(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1645 | tailpos = hostapd_eid_ht_capabilities(hapd, tailpos); |
| 1646 | tailpos = hostapd_eid_ht_operation(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1647 | |
| 1648 | tailpos = hostapd_eid_ext_capab(hapd, tailpos); |
| 1649 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1650 | /* |
| 1651 | * TODO: Time Advertisement element should only be included in some |
| 1652 | * DTIM Beacon frames. |
| 1653 | */ |
| 1654 | tailpos = hostapd_eid_time_adv(hapd, tailpos); |
| 1655 | |
| 1656 | tailpos = hostapd_eid_interworking(hapd, tailpos); |
| 1657 | tailpos = hostapd_eid_adv_proto(hapd, tailpos); |
| 1658 | tailpos = hostapd_eid_roaming_consortium(hapd, tailpos); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1659 | |
| 1660 | #ifdef CONFIG_FST |
| 1661 | if (hapd->iface->fst_ies) { |
| 1662 | os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies), |
| 1663 | wpabuf_len(hapd->iface->fst_ies)); |
| 1664 | tailpos += wpabuf_len(hapd->iface->fst_ies); |
| 1665 | } |
| 1666 | #endif /* CONFIG_FST */ |
| 1667 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1668 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1669 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac && |
| 1670 | !is_6ghz_op_class(hapd->iconf->op_class)) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 1671 | tailpos = hostapd_eid_vht_capabilities(hapd, tailpos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1672 | tailpos = hostapd_eid_vht_operation(hapd, tailpos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 1673 | tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1674 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1675 | #endif /* CONFIG_IEEE80211AC */ |
| 1676 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1677 | #ifdef CONFIG_IEEE80211AX |
| 1678 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax && |
| 1679 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 1680 | tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); |
| 1681 | #endif /* CONFIG_IEEE80211AX */ |
| 1682 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1683 | tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1684 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1685 | tailpos = hostapd_eid_rnr(hapd, tailpos, WLAN_FC_STYPE_BEACON); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1686 | tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1687 | tailpos = hostapd_get_rsnxe(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1688 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1689 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1690 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1691 | u8 *cca_pos; |
| 1692 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1693 | tailpos = hostapd_eid_he_capab(hapd, tailpos, |
| 1694 | IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1695 | tailpos = hostapd_eid_he_operation(hapd, tailpos); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1696 | |
| 1697 | /* BSS Color Change Announcement element */ |
| 1698 | cca_pos = hostapd_eid_cca(hapd, tailpos); |
| 1699 | if (cca_pos != tailpos) |
| 1700 | hapd->cca_c_off_beacon = cca_pos - tail - 2; |
| 1701 | tailpos = cca_pos; |
| 1702 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1703 | tailpos = hostapd_eid_spatial_reuse(hapd, tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1704 | tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 1705 | tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1706 | } |
| 1707 | #endif /* CONFIG_IEEE80211AX */ |
| 1708 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1709 | #ifdef CONFIG_IEEE80211BE |
| 1710 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 1711 | tailpos = hostapd_eid_eht_capab(hapd, tailpos, |
| 1712 | IEEE80211_MODE_AP); |
| 1713 | tailpos = hostapd_eid_eht_operation(hapd, tailpos); |
| 1714 | } |
| 1715 | #endif /* CONFIG_IEEE80211BE */ |
| 1716 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1717 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1718 | if (hapd->conf->vendor_vht) |
| 1719 | tailpos = hostapd_eid_vendor_vht(hapd, tailpos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1720 | #endif /* CONFIG_IEEE80211AC */ |
| 1721 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1722 | /* WPA / OSEN */ |
| 1723 | tailpos = hostapd_get_wpa_ie(hapd, tailpos, tailend - tailpos); |
| 1724 | tailpos = hostapd_get_osen_ie(hapd, tailpos, tailend - tailpos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 1725 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1726 | /* Wi-Fi Alliance WMM */ |
| 1727 | tailpos = hostapd_eid_wmm(hapd, tailpos); |
| 1728 | |
| 1729 | #ifdef CONFIG_WPS |
| 1730 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) { |
| 1731 | os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie), |
| 1732 | wpabuf_len(hapd->wps_beacon_ie)); |
| 1733 | tailpos += wpabuf_len(hapd->wps_beacon_ie); |
| 1734 | } |
| 1735 | #endif /* CONFIG_WPS */ |
| 1736 | |
| 1737 | #ifdef CONFIG_P2P |
| 1738 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) { |
| 1739 | os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie), |
| 1740 | wpabuf_len(hapd->p2p_beacon_ie)); |
| 1741 | tailpos += wpabuf_len(hapd->p2p_beacon_ie); |
| 1742 | } |
| 1743 | #endif /* CONFIG_P2P */ |
| 1744 | #ifdef CONFIG_P2P_MANAGER |
| 1745 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 1746 | P2P_MANAGE) |
| 1747 | tailpos = hostapd_eid_p2p_manage(hapd, tailpos); |
| 1748 | #endif /* CONFIG_P2P_MANAGER */ |
| 1749 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1750 | #ifdef CONFIG_HS20 |
| 1751 | tailpos = hostapd_eid_hs20_indication(hapd, tailpos); |
| 1752 | #endif /* CONFIG_HS20 */ |
| 1753 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1754 | tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1755 | tailpos = hostapd_eid_owe_trans(hapd, tailpos, |
| 1756 | tail + tail_len - tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1757 | tailpos = hostapd_eid_dpp_cc(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1758 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1759 | if (hapd->conf->vendor_elements) { |
| 1760 | os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements), |
| 1761 | wpabuf_len(hapd->conf->vendor_elements)); |
| 1762 | tailpos += wpabuf_len(hapd->conf->vendor_elements); |
| 1763 | } |
| 1764 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1765 | tail_len = tailpos > tail ? tailpos - tail : 0; |
| 1766 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1767 | resp = hostapd_probe_resp_offloads(hapd, &resp_len); |
| 1768 | #endif /* NEED_AP_MLME */ |
| 1769 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1770 | os_memset(params, 0, sizeof(*params)); |
| 1771 | params->head = (u8 *) head; |
| 1772 | params->head_len = head_len; |
| 1773 | params->tail = tail; |
| 1774 | params->tail_len = tail_len; |
| 1775 | params->proberesp = resp; |
| 1776 | params->proberesp_len = resp_len; |
| 1777 | params->dtim_period = hapd->conf->dtim_period; |
| 1778 | params->beacon_int = hapd->iconf->beacon_int; |
| 1779 | params->basic_rates = hapd->iface->basic_rates; |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 1780 | params->beacon_rate = hapd->iconf->beacon_rate; |
| 1781 | params->rate_type = hapd->iconf->rate_type; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1782 | params->ssid = hapd->conf->ssid.ssid; |
| 1783 | params->ssid_len = hapd->conf->ssid.ssid_len; |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 1784 | if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) == |
| 1785 | (WPA_PROTO_WPA | WPA_PROTO_RSN)) |
| 1786 | params->pairwise_ciphers = hapd->conf->wpa_pairwise | |
| 1787 | hapd->conf->rsn_pairwise; |
| 1788 | else if (hapd->conf->wpa & WPA_PROTO_RSN) |
| 1789 | params->pairwise_ciphers = hapd->conf->rsn_pairwise; |
| 1790 | else if (hapd->conf->wpa & WPA_PROTO_WPA) |
| 1791 | params->pairwise_ciphers = hapd->conf->wpa_pairwise; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1792 | params->group_cipher = hapd->conf->wpa_group; |
| 1793 | params->key_mgmt_suites = hapd->conf->wpa_key_mgmt; |
| 1794 | params->auth_algs = hapd->conf->auth_algs; |
| 1795 | params->wpa_version = hapd->conf->wpa; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1796 | params->privacy = hapd->conf->wpa; |
| 1797 | #ifdef CONFIG_WEP |
| 1798 | params->privacy |= hapd->conf->ssid.wep.keys_set || |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1799 | (hapd->conf->ieee802_1x && |
| 1800 | (hapd->conf->default_wep_key_len || |
| 1801 | hapd->conf->individual_wep_key_len)); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1802 | #endif /* CONFIG_WEP */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1803 | switch (hapd->conf->ignore_broadcast_ssid) { |
| 1804 | case 0: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1805 | params->hide_ssid = NO_SSID_HIDING; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1806 | break; |
| 1807 | case 1: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1808 | params->hide_ssid = HIDDEN_SSID_ZERO_LEN; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1809 | break; |
| 1810 | case 2: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1811 | params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1812 | break; |
| 1813 | } |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1814 | params->isolate = hapd->conf->isolate; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1815 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1816 | params->cts_protect = !!(ieee802_11_erp_info(hapd) & |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1817 | ERP_INFO_USE_PROTECTION); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1818 | params->preamble = hapd->iface->num_sta_no_short_preamble == 0 && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1819 | hapd->iconf->preamble == SHORT_PREAMBLE; |
| 1820 | if (hapd->iface->current_mode && |
| 1821 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1822 | params->short_slot_time = |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1823 | hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1; |
| 1824 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1825 | params->short_slot_time = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1826 | if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1827 | params->ht_opmode = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1828 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1829 | params->ht_opmode = hapd->iface->ht_op_mode; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1830 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1831 | params->interworking = hapd->conf->interworking; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1832 | if (hapd->conf->interworking && |
| 1833 | !is_zero_ether_addr(hapd->conf->hessid)) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1834 | params->hessid = hapd->conf->hessid; |
| 1835 | params->access_network_type = hapd->conf->access_network_type; |
| 1836 | params->ap_max_inactivity = hapd->conf->ap_max_inactivity; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1837 | #ifdef CONFIG_P2P |
| 1838 | params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow; |
| 1839 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1840 | #ifdef CONFIG_HS20 |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1841 | params->disable_dgaf = hapd->conf->disable_dgaf; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1842 | if (hapd->conf->osen) { |
| 1843 | params->privacy = 1; |
| 1844 | params->osen = 1; |
| 1845 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1846 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 1847 | params->multicast_to_unicast = hapd->conf->multicast_to_unicast; |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1848 | params->pbss = hapd->conf->pbss; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1849 | |
| 1850 | if (hapd->conf->ftm_responder) { |
| 1851 | if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_FTM_RESPONDER) { |
| 1852 | params->ftm_responder = 1; |
| 1853 | params->lci = hapd->iface->conf->lci; |
| 1854 | params->civic = hapd->iface->conf->civic; |
| 1855 | } else { |
| 1856 | wpa_printf(MSG_WARNING, |
| 1857 | "Not configuring FTM responder as the driver doesn't advertise support for it"); |
| 1858 | } |
| 1859 | } |
| 1860 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1861 | return 0; |
| 1862 | } |
| 1863 | |
| 1864 | |
| 1865 | void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params) |
| 1866 | { |
| 1867 | os_free(params->tail); |
| 1868 | params->tail = NULL; |
| 1869 | os_free(params->head); |
| 1870 | params->head = NULL; |
| 1871 | os_free(params->proberesp); |
| 1872 | params->proberesp = NULL; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1873 | #ifdef CONFIG_FILS |
| 1874 | os_free(params->fd_frame_tmpl); |
| 1875 | params->fd_frame_tmpl = NULL; |
| 1876 | #endif /* CONFIG_FILS */ |
| 1877 | #ifdef CONFIG_IEEE80211AX |
| 1878 | os_free(params->unsol_bcast_probe_resp_tmpl); |
| 1879 | params->unsol_bcast_probe_resp_tmpl = NULL; |
| 1880 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1884 | static int __ieee802_11_set_beacon(struct hostapd_data *hapd) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1885 | { |
| 1886 | struct wpa_driver_ap_params params; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1887 | struct hostapd_freq_params freq; |
| 1888 | struct hostapd_iface *iface = hapd->iface; |
| 1889 | struct hostapd_config *iconf = iface->conf; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1890 | struct hostapd_hw_modes *cmode = iface->current_mode; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1891 | struct wpabuf *beacon, *proberesp, *assocresp; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1892 | int res, ret = -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1893 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1894 | if (!hapd->drv_priv) { |
| 1895 | wpa_printf(MSG_ERROR, "Interface is disabled"); |
| 1896 | return -1; |
| 1897 | } |
| 1898 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1899 | if (hapd->csa_in_progress) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1900 | wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1901 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1902 | } |
| 1903 | |
| 1904 | hapd->beacon_set_done = 1; |
| 1905 | |
| 1906 | if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1907 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1908 | |
| 1909 | if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < |
| 1910 | 0) |
| 1911 | goto fail; |
| 1912 | |
| 1913 | params.beacon_ies = beacon; |
| 1914 | params.proberesp_ies = proberesp; |
| 1915 | params.assocresp_ies = assocresp; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1916 | params.reenable = hapd->reenable_beacon; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1917 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1918 | params.he_spr_ctrl = hapd->iface->conf->spr.sr_control; |
| 1919 | params.he_spr_non_srg_obss_pd_max_offset = |
| 1920 | hapd->iface->conf->spr.non_srg_obss_pd_max_offset; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1921 | params.he_spr_srg_obss_pd_min_offset = |
| 1922 | hapd->iface->conf->spr.srg_obss_pd_min_offset; |
| 1923 | params.he_spr_srg_obss_pd_max_offset = |
| 1924 | hapd->iface->conf->spr.srg_obss_pd_max_offset; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1925 | os_memcpy(params.he_spr_bss_color_bitmap, |
| 1926 | hapd->iface->conf->spr.srg_bss_color_bitmap, 8); |
| 1927 | os_memcpy(params.he_spr_partial_bssid_bitmap, |
| 1928 | hapd->iface->conf->spr.srg_partial_bssid_bitmap, 8); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1929 | params.he_bss_color_disabled = |
| 1930 | hapd->iface->conf->he_op.he_bss_color_disabled; |
| 1931 | params.he_bss_color_partial = |
| 1932 | hapd->iface->conf->he_op.he_bss_color_partial; |
| 1933 | params.he_bss_color = hapd->iface->conf->he_op.he_bss_color; |
| 1934 | params.twt_responder = hostapd_get_he_twt_responder(hapd, |
| 1935 | IEEE80211_MODE_AP); |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1936 | params.unsol_bcast_probe_resp_tmpl = |
| 1937 | hostapd_unsol_bcast_probe_resp(hapd, ¶ms); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1938 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1939 | hapd->reenable_beacon = 0; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1940 | #ifdef CONFIG_SAE |
| 1941 | params.sae_pwe = hapd->conf->sae_pwe; |
| 1942 | #endif /* CONFIG_SAE */ |
| 1943 | |
| 1944 | #ifdef CONFIG_FILS |
| 1945 | params.fd_frame_tmpl = hostapd_fils_discovery(hapd, ¶ms); |
| 1946 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1947 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1948 | if (cmode && |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1949 | hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1950 | iconf->channel, iconf->enable_edmg, |
| 1951 | iconf->edmg_channel, iconf->ieee80211n, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1952 | iconf->ieee80211ac, iconf->ieee80211ax, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1953 | iconf->ieee80211be, |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1954 | iconf->secondary_channel, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1955 | hostapd_get_oper_chwidth(iconf), |
| 1956 | hostapd_get_oper_centr_freq_seg0_idx(iconf), |
| 1957 | hostapd_get_oper_centr_freq_seg1_idx(iconf), |
| 1958 | cmode->vht_capab, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame^] | 1959 | &cmode->he_capab[IEEE80211_MODE_AP], |
| 1960 | &cmode->eht_capab[IEEE80211_MODE_AP]) == 0) |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1961 | params.freq = &freq; |
| 1962 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1963 | res = hostapd_drv_set_ap(hapd, ¶ms); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1964 | hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1965 | if (res) |
| 1966 | wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); |
| 1967 | else |
| 1968 | ret = 0; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1969 | fail: |
| 1970 | ieee802_11_free_ap_params(¶ms); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1971 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1975 | int ieee802_11_set_beacon(struct hostapd_data *hapd) |
| 1976 | { |
| 1977 | struct hostapd_iface *iface = hapd->iface; |
| 1978 | int ret; |
| 1979 | size_t i, j; |
| 1980 | bool is_6g; |
| 1981 | |
| 1982 | ret = __ieee802_11_set_beacon(hapd); |
| 1983 | if (ret != 0) |
| 1984 | return ret; |
| 1985 | |
| 1986 | if (!iface->interfaces || iface->interfaces->count <= 1) |
| 1987 | return 0; |
| 1988 | |
| 1989 | /* Update Beacon frames in case of 6 GHz colocation */ |
| 1990 | is_6g = is_6ghz_op_class(iface->conf->op_class); |
| 1991 | for (j = 0; j < iface->interfaces->count; j++) { |
| 1992 | struct hostapd_iface *colocated; |
| 1993 | |
| 1994 | colocated = iface->interfaces->iface[j]; |
| 1995 | if (colocated == iface || !colocated || !colocated->conf) |
| 1996 | continue; |
| 1997 | |
| 1998 | if (is_6g == is_6ghz_op_class(colocated->conf->op_class)) |
| 1999 | continue; |
| 2000 | |
| 2001 | for (i = 0; i < colocated->num_bss; i++) { |
| 2002 | if (colocated->bss[i] && colocated->bss[i]->started) |
| 2003 | __ieee802_11_set_beacon(colocated->bss[i]); |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | return 0; |
| 2008 | } |
| 2009 | |
| 2010 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2011 | int ieee802_11_set_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2012 | { |
| 2013 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2014 | int ret = 0; |
| 2015 | |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 2016 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2017 | if (iface->bss[i]->started && |
| 2018 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 2019 | ret = -1; |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 2020 | } |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2021 | |
| 2022 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2023 | } |
| 2024 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2025 | |
| 2026 | /* only update beacons if started */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2027 | int ieee802_11_update_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2028 | { |
| 2029 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2030 | int ret = 0; |
| 2031 | |
| 2032 | for (i = 0; i < iface->num_bss; i++) { |
| 2033 | if (iface->bss[i]->beacon_set_done && iface->bss[i]->started && |
| 2034 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 2035 | ret = -1; |
| 2036 | } |
| 2037 | |
| 2038 | return ret; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2039 | } |
| 2040 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2041 | #endif /* CONFIG_NATIVE_WINDOWS */ |