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 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 465 | static int |
| 466 | ieee802_11_build_ap_params_mbssid(struct hostapd_data *hapd, |
| 467 | struct wpa_driver_ap_params *params) |
| 468 | { |
| 469 | struct hostapd_iface *iface = hapd->iface; |
| 470 | struct hostapd_data *tx_bss; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 471 | size_t len, rnr_len = 0; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 472 | u8 elem_count = 0, *elem = NULL, **elem_offset = NULL, *end; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 473 | u8 rnr_elem_count = 0, *rnr_elem = NULL, **rnr_elem_offset = NULL; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 474 | |
| 475 | if (!iface->mbssid_max_interfaces || |
| 476 | iface->num_bss > iface->mbssid_max_interfaces || |
| 477 | (iface->conf->mbssid == ENHANCED_MBSSID_ENABLED && |
| 478 | !iface->ema_max_periodicity)) |
| 479 | goto fail; |
| 480 | |
| 481 | tx_bss = hostapd_mbssid_get_tx_bss(hapd); |
| 482 | len = hostapd_eid_mbssid_len(tx_bss, WLAN_FC_STYPE_BEACON, &elem_count, |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 483 | NULL, 0, &rnr_len); |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 484 | if (!len || (iface->conf->mbssid == ENHANCED_MBSSID_ENABLED && |
| 485 | elem_count > iface->ema_max_periodicity)) |
| 486 | goto fail; |
| 487 | |
| 488 | elem = os_zalloc(len); |
| 489 | if (!elem) |
| 490 | goto fail; |
| 491 | |
| 492 | elem_offset = os_zalloc(elem_count * sizeof(u8 *)); |
| 493 | if (!elem_offset) |
| 494 | goto fail; |
| 495 | |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 496 | if (rnr_len) { |
| 497 | rnr_elem = os_zalloc(rnr_len); |
| 498 | if (!rnr_elem) |
| 499 | goto fail; |
| 500 | |
| 501 | rnr_elem_offset = os_calloc(elem_count + 1, sizeof(u8 *)); |
| 502 | if (!rnr_elem_offset) |
| 503 | goto fail; |
| 504 | } |
| 505 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 506 | end = hostapd_eid_mbssid(tx_bss, elem, elem + len, WLAN_FC_STYPE_BEACON, |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 507 | elem_count, elem_offset, NULL, 0, rnr_elem, |
| 508 | &rnr_elem_count, rnr_elem_offset, rnr_len); |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 509 | |
| 510 | params->mbssid_tx_iface = tx_bss->conf->iface; |
| 511 | params->mbssid_index = hostapd_mbssid_get_bss_index(hapd); |
| 512 | params->mbssid_elem = elem; |
| 513 | params->mbssid_elem_len = end - elem; |
| 514 | params->mbssid_elem_count = elem_count; |
| 515 | params->mbssid_elem_offset = elem_offset; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 516 | params->rnr_elem = rnr_elem; |
| 517 | params->rnr_elem_len = rnr_len; |
| 518 | params->rnr_elem_count = rnr_elem_count; |
| 519 | params->rnr_elem_offset = rnr_elem_offset; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 520 | if (iface->conf->mbssid == ENHANCED_MBSSID_ENABLED) |
| 521 | params->ema = true; |
| 522 | |
| 523 | return 0; |
| 524 | |
| 525 | fail: |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 526 | os_free(rnr_elem); |
| 527 | os_free(rnr_elem_offset); |
| 528 | os_free(elem_offset); |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 529 | os_free(elem); |
| 530 | wpa_printf(MSG_ERROR, "MBSSID: Configuration failed"); |
| 531 | return -1; |
| 532 | } |
| 533 | |
| 534 | |
| 535 | static u8 * hostapd_eid_mbssid_config(struct hostapd_data *hapd, u8 *eid, |
| 536 | u8 mbssid_elem_count) |
| 537 | { |
| 538 | struct hostapd_iface *iface = hapd->iface; |
| 539 | |
| 540 | if (iface->conf->mbssid == ENHANCED_MBSSID_ENABLED) { |
| 541 | *eid++ = WLAN_EID_EXTENSION; |
| 542 | *eid++ = 3; |
| 543 | *eid++ = WLAN_EID_EXT_MULTIPLE_BSSID_CONFIGURATION; |
| 544 | *eid++ = iface->num_bss; |
| 545 | *eid++ = mbssid_elem_count; |
| 546 | } |
| 547 | |
| 548 | return eid; |
| 549 | } |
| 550 | |
| 551 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 552 | static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 553 | const struct ieee80211_mgmt *req, |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 554 | int is_p2p, size_t *resp_len, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 555 | const u8 *known_bss, u8 known_bss_len) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 556 | { |
| 557 | struct ieee80211_mgmt *resp; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 558 | u8 *pos, *epos, *csa_pos; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 559 | size_t buflen; |
| 560 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 561 | hapd = hostapd_mbssid_get_tx_bss(hapd); |
| 562 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 563 | #define MAX_PROBERESP_LEN 768 |
| 564 | buflen = MAX_PROBERESP_LEN; |
| 565 | #ifdef CONFIG_WPS |
| 566 | if (hapd->wps_probe_resp_ie) |
| 567 | buflen += wpabuf_len(hapd->wps_probe_resp_ie); |
| 568 | #endif /* CONFIG_WPS */ |
| 569 | #ifdef CONFIG_P2P |
| 570 | if (hapd->p2p_probe_resp_ie) |
| 571 | buflen += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 572 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 573 | #ifdef CONFIG_FST |
| 574 | if (hapd->iface->fst_ies) |
| 575 | buflen += wpabuf_len(hapd->iface->fst_ies); |
| 576 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 577 | if (hapd->conf->vendor_elements) |
| 578 | buflen += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 579 | if (hapd->conf->vendor_vht) { |
| 580 | buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 581 | 2 + sizeof(struct ieee80211_vht_operation); |
| 582 | } |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 583 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 584 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 585 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 586 | buflen += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 587 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 588 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 589 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 590 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 591 | buflen += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 592 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 593 | /* An additional Transmit Power Envelope element for |
| 594 | * subordinate client */ |
| 595 | if (hapd->iconf->he_6ghz_reg_pwr_type == |
| 596 | HE_6GHZ_INDOOR_AP) |
| 597 | buflen += 4; |
| 598 | } |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 599 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 600 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 601 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 602 | #ifdef CONFIG_IEEE80211BE |
| 603 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 604 | buflen += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); |
| 605 | buflen += 3 + sizeof(struct ieee80211_eht_operation); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 606 | if (hapd->iconf->punct_bitmap) |
| 607 | buflen += EHT_OPER_DISABLED_SUBCHAN_BITMAP_SIZE; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 608 | } |
| 609 | #endif /* CONFIG_IEEE80211BE */ |
| 610 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 611 | buflen += hostapd_eid_mbssid_len(hapd, WLAN_FC_STYPE_PROBE_RESP, NULL, |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 612 | known_bss, known_bss_len, NULL); |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 613 | buflen += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_PROBE_RESP); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 614 | buflen += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 615 | buflen += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 616 | buflen += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 617 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 618 | resp = os_zalloc(buflen); |
| 619 | if (resp == NULL) |
| 620 | return NULL; |
| 621 | |
| 622 | epos = ((u8 *) resp) + MAX_PROBERESP_LEN; |
| 623 | |
| 624 | resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 625 | WLAN_FC_STYPE_PROBE_RESP); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 626 | /* Unicast the response to all requests on bands other than 6 GHz. For |
| 627 | * the 6 GHz, unicast is used only if the actual SSID is not included in |
| 628 | * the Beacon frames. Otherwise, broadcast response is used per IEEE |
| 629 | * Std 802.11ax-2021, 26.17.2.3.2. Broadcast address is also used for |
| 630 | * the Probe Response frame template for the unsolicited (i.e., not as |
| 631 | * a response to a specific request) case. */ |
| 632 | if (req && (!is_6ghz_op_class(hapd->iconf->op_class) || |
| 633 | hapd->conf->ignore_broadcast_ssid)) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 634 | os_memcpy(resp->da, req->sa, ETH_ALEN); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 635 | else |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 636 | os_memset(resp->da, 0xff, ETH_ALEN); |
| 637 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 638 | os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN); |
| 639 | |
| 640 | os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); |
| 641 | resp->u.probe_resp.beacon_int = |
| 642 | host_to_le16(hapd->iconf->beacon_int); |
| 643 | |
| 644 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
| 645 | resp->u.probe_resp.capab_info = |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 646 | host_to_le16(hostapd_own_capab_info(hapd)); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 647 | |
| 648 | pos = resp->u.probe_resp.variable; |
| 649 | *pos++ = WLAN_EID_SSID; |
| 650 | *pos++ = hapd->conf->ssid.ssid_len; |
| 651 | os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len); |
| 652 | pos += hapd->conf->ssid.ssid_len; |
| 653 | |
| 654 | /* Supported rates */ |
| 655 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 656 | |
| 657 | /* DS Params */ |
| 658 | pos = hostapd_eid_ds_params(hapd, pos); |
| 659 | |
| 660 | pos = hostapd_eid_country(hapd, pos, epos - pos); |
| 661 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 662 | /* Power Constraint element */ |
| 663 | pos = hostapd_eid_pwr_constraint(hapd, pos); |
| 664 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 665 | /* CSA IE */ |
| 666 | csa_pos = hostapd_eid_csa(hapd, pos); |
| 667 | if (csa_pos != pos) |
| 668 | hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1; |
| 669 | pos = csa_pos; |
| 670 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 671 | /* ERP Information element */ |
| 672 | pos = hostapd_eid_erp_info(hapd, pos); |
| 673 | |
| 674 | /* Extended supported rates */ |
| 675 | pos = hostapd_eid_ext_supp_rates(hapd, pos); |
| 676 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 677 | pos = hostapd_get_rsne(hapd, pos, epos - pos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 678 | pos = hostapd_eid_bss_load(hapd, pos, epos - pos); |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 679 | pos = hostapd_eid_mbssid(hapd, pos, epos, WLAN_FC_STYPE_PROBE_RESP, 0, |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 680 | NULL, known_bss, known_bss_len, NULL, NULL, |
| 681 | NULL, 0); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 682 | pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 683 | pos = hostapd_get_mde(hapd, pos, epos - pos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 684 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 685 | /* eCSA IE */ |
| 686 | csa_pos = hostapd_eid_ecsa(hapd, pos); |
| 687 | if (csa_pos != pos) |
| 688 | hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1; |
| 689 | pos = csa_pos; |
| 690 | |
| 691 | pos = hostapd_eid_supported_op_classes(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 692 | pos = hostapd_eid_ht_capabilities(hapd, pos); |
| 693 | pos = hostapd_eid_ht_operation(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 694 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 695 | /* Probe Response frames always include all non-TX profiles except |
| 696 | * when a list of known BSSes is included in the Probe Request frame. */ |
| 697 | pos = hostapd_eid_ext_capab(hapd, pos, |
| 698 | hapd->iconf->mbssid >= MBSSID_ENABLED && |
| 699 | !known_bss_len); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 700 | |
| 701 | pos = hostapd_eid_time_adv(hapd, pos); |
| 702 | pos = hostapd_eid_time_zone(hapd, pos); |
| 703 | |
| 704 | pos = hostapd_eid_interworking(hapd, pos); |
| 705 | pos = hostapd_eid_adv_proto(hapd, pos); |
| 706 | pos = hostapd_eid_roaming_consortium(hapd, pos); |
| 707 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 708 | #ifdef CONFIG_FST |
| 709 | if (hapd->iface->fst_ies) { |
| 710 | os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies), |
| 711 | wpabuf_len(hapd->iface->fst_ies)); |
| 712 | pos += wpabuf_len(hapd->iface->fst_ies); |
| 713 | } |
| 714 | #endif /* CONFIG_FST */ |
| 715 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 716 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 717 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac && |
| 718 | !is_6ghz_op_class(hapd->iconf->op_class)) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 719 | pos = hostapd_eid_vht_capabilities(hapd, pos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 720 | pos = hostapd_eid_vht_operation(hapd, pos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 721 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 722 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 723 | #endif /* CONFIG_IEEE80211AC */ |
| 724 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 725 | #ifdef CONFIG_IEEE80211AX |
| 726 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax && |
| 727 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 728 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
| 729 | #endif /* CONFIG_IEEE80211AX */ |
| 730 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 731 | pos = hostapd_eid_wb_chsw_wrapper(hapd, pos); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 732 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 733 | pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_PROBE_RESP); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 734 | pos = hostapd_eid_fils_indic(hapd, pos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 735 | pos = hostapd_get_rsnxe(hapd, pos, epos - pos); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 736 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 737 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 738 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 739 | u8 *cca_pos; |
| 740 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 741 | pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 742 | pos = hostapd_eid_he_operation(hapd, pos); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 743 | |
| 744 | /* BSS Color Change Announcement element */ |
| 745 | cca_pos = hostapd_eid_cca(hapd, pos); |
| 746 | if (cca_pos != pos) |
| 747 | hapd->cca_c_off_proberesp = cca_pos - (u8 *) resp - 2; |
| 748 | pos = cca_pos; |
| 749 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 750 | pos = hostapd_eid_spatial_reuse(hapd, pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 751 | pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 752 | pos = hostapd_eid_he_6ghz_band_cap(hapd, pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 753 | } |
| 754 | #endif /* CONFIG_IEEE80211AX */ |
| 755 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 756 | #ifdef CONFIG_IEEE80211BE |
| 757 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 758 | pos = hostapd_eid_eht_capab(hapd, pos, IEEE80211_MODE_AP); |
| 759 | pos = hostapd_eid_eht_operation(hapd, pos); |
| 760 | } |
| 761 | #endif /* CONFIG_IEEE80211BE */ |
| 762 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 763 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 764 | if (hapd->conf->vendor_vht) |
| 765 | pos = hostapd_eid_vendor_vht(hapd, pos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 766 | #endif /* CONFIG_IEEE80211AC */ |
| 767 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 768 | /* WPA / OSEN */ |
| 769 | pos = hostapd_get_wpa_ie(hapd, pos, epos - pos); |
| 770 | pos = hostapd_get_osen_ie(hapd, pos, epos - pos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 771 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 772 | /* Wi-Fi Alliance WMM */ |
| 773 | pos = hostapd_eid_wmm(hapd, pos); |
| 774 | |
| 775 | #ifdef CONFIG_WPS |
| 776 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) { |
| 777 | os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie), |
| 778 | wpabuf_len(hapd->wps_probe_resp_ie)); |
| 779 | pos += wpabuf_len(hapd->wps_probe_resp_ie); |
| 780 | } |
| 781 | #endif /* CONFIG_WPS */ |
| 782 | |
| 783 | #ifdef CONFIG_P2P |
| 784 | if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p && |
| 785 | hapd->p2p_probe_resp_ie) { |
| 786 | os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie), |
| 787 | wpabuf_len(hapd->p2p_probe_resp_ie)); |
| 788 | pos += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 789 | } |
| 790 | #endif /* CONFIG_P2P */ |
| 791 | #ifdef CONFIG_P2P_MANAGER |
| 792 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 793 | P2P_MANAGE) |
| 794 | pos = hostapd_eid_p2p_manage(hapd, pos); |
| 795 | #endif /* CONFIG_P2P_MANAGER */ |
| 796 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 797 | #ifdef CONFIG_HS20 |
| 798 | pos = hostapd_eid_hs20_indication(hapd, pos); |
| 799 | #endif /* CONFIG_HS20 */ |
| 800 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 801 | pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 802 | pos = hostapd_eid_owe_trans(hapd, pos, (u8 *) resp + buflen - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 803 | pos = hostapd_eid_dpp_cc(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 804 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 805 | if (hapd->conf->vendor_elements) { |
| 806 | os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements), |
| 807 | wpabuf_len(hapd->conf->vendor_elements)); |
| 808 | pos += wpabuf_len(hapd->conf->vendor_elements); |
| 809 | } |
| 810 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 811 | *resp_len = pos - (u8 *) resp; |
| 812 | return (u8 *) resp; |
| 813 | } |
| 814 | |
| 815 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 816 | enum ssid_match_result { |
| 817 | NO_SSID_MATCH, |
| 818 | EXACT_SSID_MATCH, |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 819 | WILDCARD_SSID_MATCH, |
| 820 | CO_LOCATED_SSID_MATCH, |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 821 | }; |
| 822 | |
| 823 | static enum ssid_match_result ssid_match(struct hostapd_data *hapd, |
| 824 | const u8 *ssid, size_t ssid_len, |
| 825 | const u8 *ssid_list, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 826 | size_t ssid_list_len, |
| 827 | const u8 *short_ssid_list, |
| 828 | size_t short_ssid_list_len) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 829 | { |
| 830 | const u8 *pos, *end; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 831 | struct hostapd_iface *iface = hapd->iface; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 832 | int wildcard = 0; |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 833 | size_t i, j; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 834 | |
| 835 | if (ssid_len == 0) |
| 836 | wildcard = 1; |
| 837 | if (ssid_len == hapd->conf->ssid.ssid_len && |
| 838 | os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0) |
| 839 | return EXACT_SSID_MATCH; |
| 840 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 841 | if (ssid_list) { |
| 842 | pos = ssid_list; |
| 843 | end = ssid_list + ssid_list_len; |
| 844 | while (end - pos >= 2) { |
| 845 | if (2 + pos[1] > end - pos) |
| 846 | break; |
| 847 | if (pos[1] == 0) |
| 848 | wildcard = 1; |
| 849 | if (pos[1] == hapd->conf->ssid.ssid_len && |
| 850 | os_memcmp(pos + 2, hapd->conf->ssid.ssid, |
| 851 | pos[1]) == 0) |
| 852 | return EXACT_SSID_MATCH; |
| 853 | pos += 2 + pos[1]; |
| 854 | } |
| 855 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 856 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 857 | if (short_ssid_list) { |
| 858 | pos = short_ssid_list; |
| 859 | end = short_ssid_list + short_ssid_list_len; |
| 860 | while (end - pos >= 4) { |
| 861 | if (hapd->conf->ssid.short_ssid == WPA_GET_LE32(pos)) |
| 862 | return EXACT_SSID_MATCH; |
| 863 | pos += 4; |
| 864 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 865 | } |
| 866 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 867 | if (wildcard) |
| 868 | return WILDCARD_SSID_MATCH; |
| 869 | |
| 870 | if (!iface->interfaces || iface->interfaces->count <= 1 || |
| 871 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 872 | return NO_SSID_MATCH; |
| 873 | |
| 874 | for (i = 0; i < iface->interfaces->count; i++) { |
| 875 | struct hostapd_iface *colocated; |
| 876 | |
| 877 | colocated = iface->interfaces->iface[i]; |
| 878 | |
| 879 | if (colocated == iface || |
| 880 | !is_6ghz_op_class(colocated->conf->op_class)) |
| 881 | continue; |
| 882 | |
| 883 | for (j = 0; j < colocated->num_bss; j++) { |
| 884 | struct hostapd_bss_config *conf; |
| 885 | |
| 886 | conf = colocated->bss[j]->conf; |
| 887 | if (ssid_len == conf->ssid.ssid_len && |
| 888 | os_memcmp(ssid, conf->ssid.ssid, ssid_len) == 0) |
| 889 | return CO_LOCATED_SSID_MATCH; |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | return NO_SSID_MATCH; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 894 | } |
| 895 | |
| 896 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 897 | void sta_track_expire(struct hostapd_iface *iface, int force) |
| 898 | { |
| 899 | struct os_reltime now; |
| 900 | struct hostapd_sta_info *info; |
| 901 | |
| 902 | if (!iface->num_sta_seen) |
| 903 | return; |
| 904 | |
| 905 | os_get_reltime(&now); |
| 906 | while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, |
| 907 | list))) { |
| 908 | if (!force && |
| 909 | !os_reltime_expired(&now, &info->last_seen, |
| 910 | iface->conf->track_sta_max_age)) |
| 911 | break; |
| 912 | force = 0; |
| 913 | |
| 914 | wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for " |
| 915 | MACSTR, iface->bss[0]->conf->iface, |
| 916 | MAC2STR(info->addr)); |
| 917 | dl_list_del(&info->list); |
| 918 | iface->num_sta_seen--; |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 919 | sta_track_del(info); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 920 | } |
| 921 | } |
| 922 | |
| 923 | |
| 924 | static struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface, |
| 925 | const u8 *addr) |
| 926 | { |
| 927 | struct hostapd_sta_info *info; |
| 928 | |
| 929 | dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list) |
| 930 | if (os_memcmp(addr, info->addr, ETH_ALEN) == 0) |
| 931 | return info; |
| 932 | |
| 933 | return NULL; |
| 934 | } |
| 935 | |
| 936 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 937 | 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] | 938 | { |
| 939 | struct hostapd_sta_info *info; |
| 940 | |
| 941 | info = sta_track_get(iface, addr); |
| 942 | if (info) { |
| 943 | /* Move the most recent entry to the end of the list */ |
| 944 | dl_list_del(&info->list); |
| 945 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 946 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 947 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 948 | return; |
| 949 | } |
| 950 | |
| 951 | /* Add a new entry */ |
| 952 | info = os_zalloc(sizeof(*info)); |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 953 | if (info == NULL) |
| 954 | return; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 955 | os_memcpy(info->addr, addr, ETH_ALEN); |
| 956 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 957 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 958 | |
| 959 | if (iface->num_sta_seen >= iface->conf->track_sta_max_num) { |
| 960 | /* Expire oldest entry to make room for a new one */ |
| 961 | sta_track_expire(iface, 1); |
| 962 | } |
| 963 | |
| 964 | wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for " |
| 965 | MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr)); |
| 966 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 967 | iface->num_sta_seen++; |
| 968 | } |
| 969 | |
| 970 | |
| 971 | struct hostapd_data * |
| 972 | sta_track_seen_on(struct hostapd_iface *iface, const u8 *addr, |
| 973 | const char *ifname) |
| 974 | { |
| 975 | struct hapd_interfaces *interfaces = iface->interfaces; |
| 976 | size_t i, j; |
| 977 | |
| 978 | for (i = 0; i < interfaces->count; i++) { |
| 979 | struct hostapd_data *hapd = NULL; |
| 980 | |
| 981 | iface = interfaces->iface[i]; |
| 982 | for (j = 0; j < iface->num_bss; j++) { |
| 983 | hapd = iface->bss[j]; |
| 984 | if (os_strcmp(ifname, hapd->conf->iface) == 0) |
| 985 | break; |
| 986 | hapd = NULL; |
| 987 | } |
| 988 | |
| 989 | if (hapd && sta_track_get(iface, addr)) |
| 990 | return hapd; |
| 991 | } |
| 992 | |
| 993 | return NULL; |
| 994 | } |
| 995 | |
| 996 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 997 | #ifdef CONFIG_TAXONOMY |
| 998 | void sta_track_claim_taxonomy_info(struct hostapd_iface *iface, const u8 *addr, |
| 999 | struct wpabuf **probe_ie_taxonomy) |
| 1000 | { |
| 1001 | struct hostapd_sta_info *info; |
| 1002 | |
| 1003 | info = sta_track_get(iface, addr); |
| 1004 | if (!info) |
| 1005 | return; |
| 1006 | |
| 1007 | wpabuf_free(*probe_ie_taxonomy); |
| 1008 | *probe_ie_taxonomy = info->probe_ie_taxonomy; |
| 1009 | info->probe_ie_taxonomy = NULL; |
| 1010 | } |
| 1011 | #endif /* CONFIG_TAXONOMY */ |
| 1012 | |
| 1013 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1014 | void handle_probe_req(struct hostapd_data *hapd, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1015 | const struct ieee80211_mgmt *mgmt, size_t len, |
| 1016 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1017 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1018 | u8 *resp; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1019 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1020 | const u8 *ie; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1021 | size_t ie_len; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1022 | size_t i, resp_len; |
| 1023 | int noack; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1024 | enum ssid_match_result res; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1025 | int ret; |
| 1026 | u16 csa_offs[2]; |
| 1027 | size_t csa_offs_len; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1028 | struct radius_sta rad_info; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1029 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1030 | if (hapd->iconf->rssi_ignore_probe_request && ssi_signal && |
| 1031 | ssi_signal < hapd->iconf->rssi_ignore_probe_request) |
| 1032 | return; |
| 1033 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 1034 | if (len < IEEE80211_HDRLEN) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1035 | return; |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 1036 | ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1037 | if (hapd->iconf->track_sta_max_num) |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1038 | sta_track_add(hapd->iface, mgmt->sa, ssi_signal); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 1039 | ie_len = len - IEEE80211_HDRLEN; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1040 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1041 | ret = hostapd_allowed_address(hapd, mgmt->sa, (const u8 *) mgmt, len, |
| 1042 | &rad_info, 1); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1043 | if (ret == HOSTAPD_ACL_REJECT) { |
| 1044 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 1045 | "Ignore Probe Request frame from " MACSTR |
| 1046 | " due to ACL reject ", MAC2STR(mgmt->sa)); |
| 1047 | return; |
| 1048 | } |
| 1049 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1050 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) |
| 1051 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1052 | mgmt->sa, mgmt->da, mgmt->bssid, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1053 | ie, ie_len, ssi_signal) > 0) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1054 | return; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1055 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1056 | if (!hapd->conf->send_probe_response) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1057 | return; |
| 1058 | |
| 1059 | if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) { |
| 1060 | wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR, |
| 1061 | MAC2STR(mgmt->sa)); |
| 1062 | return; |
| 1063 | } |
| 1064 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1065 | if ((!elems.ssid || !elems.supp_rates)) { |
| 1066 | wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request " |
| 1067 | "without SSID or supported rates element", |
| 1068 | MAC2STR(mgmt->sa)); |
| 1069 | return; |
| 1070 | } |
| 1071 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1072 | /* |
| 1073 | * No need to reply if the Probe Request frame was sent on an adjacent |
| 1074 | * channel. IEEE Std 802.11-2012 describes this as a requirement for an |
| 1075 | * AP with dot11RadioMeasurementActivated set to true, but strictly |
| 1076 | * speaking does not allow such ignoring of Probe Request frames if |
| 1077 | * dot11RadioMeasurementActivated is false. Anyway, this can help reduce |
| 1078 | * number of unnecessary Probe Response frames for cases where the STA |
| 1079 | * is less likely to see them (Probe Request frame sent on a |
| 1080 | * neighboring, but partially overlapping, channel). |
| 1081 | */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1082 | if (elems.ds_params && |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1083 | hapd->iface->current_mode && |
| 1084 | (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G || |
| 1085 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) && |
| 1086 | hapd->iconf->channel != elems.ds_params[0]) { |
| 1087 | wpa_printf(MSG_DEBUG, |
| 1088 | "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u", |
| 1089 | hapd->iconf->channel, elems.ds_params[0]); |
| 1090 | return; |
| 1091 | } |
| 1092 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1093 | #ifdef CONFIG_P2P |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 1094 | if (hapd->p2p && hapd->p2p_group && elems.wps_ie) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1095 | struct wpabuf *wps; |
| 1096 | wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA); |
| 1097 | if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) { |
| 1098 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 1099 | "due to mismatch with Requested Device " |
| 1100 | "Type"); |
| 1101 | wpabuf_free(wps); |
| 1102 | return; |
| 1103 | } |
| 1104 | wpabuf_free(wps); |
| 1105 | } |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 1106 | |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 1107 | if (hapd->p2p && hapd->p2p_group && elems.p2p) { |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 1108 | struct wpabuf *p2p; |
| 1109 | p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE); |
| 1110 | if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) { |
| 1111 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 1112 | "due to mismatch with Device ID"); |
| 1113 | wpabuf_free(p2p); |
| 1114 | return; |
| 1115 | } |
| 1116 | wpabuf_free(p2p); |
| 1117 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1118 | #endif /* CONFIG_P2P */ |
| 1119 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1120 | if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 && |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1121 | elems.ssid_list_len == 0 && elems.short_ssid_list_len == 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1122 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 1123 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 1124 | return; |
| 1125 | } |
| 1126 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1127 | #ifdef CONFIG_P2P |
| 1128 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 1129 | elems.ssid_len == P2P_WILDCARD_SSID_LEN && |
| 1130 | os_memcmp(elems.ssid, P2P_WILDCARD_SSID, |
| 1131 | P2P_WILDCARD_SSID_LEN) == 0) { |
| 1132 | /* Process P2P Wildcard SSID like Wildcard SSID */ |
| 1133 | elems.ssid_len = 0; |
| 1134 | } |
| 1135 | #endif /* CONFIG_P2P */ |
| 1136 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 1137 | #ifdef CONFIG_TAXONOMY |
| 1138 | { |
| 1139 | struct sta_info *sta; |
| 1140 | struct hostapd_sta_info *info; |
| 1141 | |
| 1142 | if ((sta = ap_get_sta(hapd, mgmt->sa)) != NULL) { |
| 1143 | taxonomy_sta_info_probe_req(hapd, sta, ie, ie_len); |
| 1144 | } else if ((info = sta_track_get(hapd->iface, |
| 1145 | mgmt->sa)) != NULL) { |
| 1146 | taxonomy_hostapd_sta_info_probe_req(hapd, info, |
| 1147 | ie, ie_len); |
| 1148 | } |
| 1149 | } |
| 1150 | #endif /* CONFIG_TAXONOMY */ |
| 1151 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1152 | res = ssid_match(hapd, elems.ssid, elems.ssid_len, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1153 | elems.ssid_list, elems.ssid_list_len, |
| 1154 | elems.short_ssid_list, elems.short_ssid_list_len); |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1155 | if (res == NO_SSID_MATCH) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1156 | if (!(mgmt->da[0] & 0x01)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1157 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1158 | " for foreign SSID '%s' (DA " MACSTR ")%s", |
Dmitry Shmidt | 3c47937 | 2014-02-04 10:50:36 -0800 | [diff] [blame] | 1159 | MAC2STR(mgmt->sa), |
| 1160 | wpa_ssid_txt(elems.ssid, elems.ssid_len), |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1161 | MAC2STR(mgmt->da), |
| 1162 | elems.ssid_list ? " (SSID list)" : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1163 | } |
| 1164 | return; |
| 1165 | } |
| 1166 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1167 | if (hapd->conf->ignore_broadcast_ssid && res == WILDCARD_SSID_MATCH) { |
| 1168 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 1169 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 1170 | return; |
| 1171 | } |
| 1172 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1173 | #ifdef CONFIG_INTERWORKING |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 1174 | if (hapd->conf->interworking && |
| 1175 | elems.interworking && elems.interworking_len >= 1) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1176 | u8 ant = elems.interworking[0] & 0x0f; |
| 1177 | if (ant != INTERWORKING_ANT_WILDCARD && |
| 1178 | ant != hapd->conf->access_network_type) { |
| 1179 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 1180 | " for mismatching ANT %u ignored", |
| 1181 | MAC2STR(mgmt->sa), ant); |
| 1182 | return; |
| 1183 | } |
| 1184 | } |
| 1185 | |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 1186 | if (hapd->conf->interworking && elems.interworking && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1187 | (elems.interworking_len == 7 || elems.interworking_len == 9)) { |
| 1188 | const u8 *hessid; |
| 1189 | if (elems.interworking_len == 7) |
| 1190 | hessid = elems.interworking + 1; |
| 1191 | else |
| 1192 | hessid = elems.interworking + 1 + 2; |
| 1193 | if (!is_broadcast_ether_addr(hessid) && |
| 1194 | os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) { |
| 1195 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 1196 | " for mismatching HESSID " MACSTR |
| 1197 | " ignored", |
| 1198 | MAC2STR(mgmt->sa), MAC2STR(hessid)); |
| 1199 | return; |
| 1200 | } |
| 1201 | } |
| 1202 | #endif /* CONFIG_INTERWORKING */ |
| 1203 | |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 1204 | #ifdef CONFIG_P2P |
| 1205 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 1206 | supp_rates_11b_only(&elems)) { |
| 1207 | /* Indicates support for 11b rates only */ |
| 1208 | wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from " |
| 1209 | MACSTR " with only 802.11b rates", |
| 1210 | MAC2STR(mgmt->sa)); |
| 1211 | return; |
| 1212 | } |
| 1213 | #endif /* CONFIG_P2P */ |
| 1214 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1215 | /* TODO: verify that supp_rates contains at least one matching rate |
| 1216 | * with AP configuration */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1217 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1218 | if (hapd->conf->no_probe_resp_if_seen_on && |
| 1219 | is_multicast_ether_addr(mgmt->da) && |
| 1220 | is_multicast_ether_addr(mgmt->bssid) && |
| 1221 | sta_track_seen_on(hapd->iface, mgmt->sa, |
| 1222 | hapd->conf->no_probe_resp_if_seen_on)) { |
| 1223 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1224 | " since STA has been seen on %s", |
| 1225 | hapd->conf->iface, MAC2STR(mgmt->sa), |
| 1226 | hapd->conf->no_probe_resp_if_seen_on); |
| 1227 | return; |
| 1228 | } |
| 1229 | |
| 1230 | if (hapd->conf->no_probe_resp_if_max_sta && |
| 1231 | is_multicast_ether_addr(mgmt->da) && |
| 1232 | is_multicast_ether_addr(mgmt->bssid) && |
| 1233 | hapd->num_sta >= hapd->conf->max_num_sta && |
| 1234 | !ap_get_sta(hapd, mgmt->sa)) { |
| 1235 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1236 | " since no room for additional STA", |
| 1237 | hapd->conf->iface, MAC2STR(mgmt->sa)); |
| 1238 | return; |
| 1239 | } |
| 1240 | |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1241 | #ifdef CONFIG_TESTING_OPTIONS |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1242 | if (hapd->iconf->ignore_probe_probability > 0.0 && |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1243 | drand48() < hapd->iconf->ignore_probe_probability) { |
| 1244 | wpa_printf(MSG_INFO, |
| 1245 | "TESTING: ignoring probe request from " MACSTR, |
| 1246 | MAC2STR(mgmt->sa)); |
| 1247 | return; |
| 1248 | } |
| 1249 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 1250 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1251 | /* Do not send Probe Response frame from a non-transmitting multiple |
| 1252 | * BSSID profile unless the Probe Request frame is directed at that |
| 1253 | * particular BSS. */ |
| 1254 | if (hapd != hostapd_mbssid_get_tx_bss(hapd) && res != EXACT_SSID_MATCH) |
| 1255 | return; |
| 1256 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1257 | wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, RX_PROBE_REQUEST "sa=" MACSTR |
| 1258 | " signal=%d", MAC2STR(mgmt->sa), ssi_signal); |
| 1259 | |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1260 | resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1261 | &resp_len, elems.mbssid_known_bss, |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1262 | elems.mbssid_known_bss_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1263 | if (resp == NULL) |
| 1264 | return; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1265 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1266 | /* |
| 1267 | * If this is a broadcast probe request, apply no ack policy to avoid |
| 1268 | * excessive retries. |
| 1269 | */ |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1270 | noack = !!(res == WILDCARD_SSID_MATCH && |
| 1271 | is_broadcast_ether_addr(mgmt->da)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1272 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1273 | csa_offs_len = 0; |
| 1274 | if (hapd->csa_in_progress) { |
| 1275 | if (hapd->cs_c_off_proberesp) |
| 1276 | csa_offs[csa_offs_len++] = |
| 1277 | hapd->cs_c_off_proberesp; |
| 1278 | |
| 1279 | if (hapd->cs_c_off_ecsa_proberesp) |
| 1280 | csa_offs[csa_offs_len++] = |
| 1281 | hapd->cs_c_off_ecsa_proberesp; |
| 1282 | } |
| 1283 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1284 | ret = hostapd_drv_send_mlme(hostapd_mbssid_get_tx_bss(hapd), resp, |
| 1285 | resp_len, noack, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1286 | csa_offs_len ? csa_offs : NULL, |
| 1287 | csa_offs_len, 0); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1288 | |
| 1289 | if (ret < 0) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1290 | wpa_printf(MSG_INFO, "handle_probe_req: send failed"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1291 | |
| 1292 | os_free(resp); |
| 1293 | |
| 1294 | wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s " |
| 1295 | "SSID", MAC2STR(mgmt->sa), |
| 1296 | elems.ssid_len == 0 ? "broadcast" : "our"); |
| 1297 | } |
| 1298 | |
| 1299 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1300 | static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd, |
| 1301 | size_t *resp_len) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1302 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1303 | /* check probe response offloading caps and print warnings */ |
| 1304 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD)) |
| 1305 | return NULL; |
| 1306 | |
| 1307 | #ifdef CONFIG_WPS |
| 1308 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie && |
| 1309 | (!(hapd->iface->probe_resp_offloads & |
| 1310 | (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS | |
| 1311 | WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2)))) |
| 1312 | wpa_printf(MSG_WARNING, "Device is trying to offload WPS " |
| 1313 | "Probe Response while not supporting this"); |
| 1314 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1315 | |
| 1316 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1317 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie && |
| 1318 | !(hapd->iface->probe_resp_offloads & |
| 1319 | WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P)) |
| 1320 | wpa_printf(MSG_WARNING, "Device is trying to offload P2P " |
| 1321 | "Probe Response while not supporting this"); |
| 1322 | #endif /* CONFIG_P2P */ |
| 1323 | |
| 1324 | if (hapd->conf->interworking && |
| 1325 | !(hapd->iface->probe_resp_offloads & |
| 1326 | WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING)) |
| 1327 | wpa_printf(MSG_WARNING, "Device is trying to offload " |
| 1328 | "Interworking Probe Response while not supporting " |
| 1329 | "this"); |
| 1330 | |
| 1331 | /* Generate a Probe Response template for the non-P2P case */ |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1332 | return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len, NULL, 0); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1333 | } |
| 1334 | |
| 1335 | #endif /* NEED_AP_MLME */ |
| 1336 | |
| 1337 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1338 | #ifdef CONFIG_IEEE80211AX |
| 1339 | /* Unsolicited broadcast Probe Response transmission, 6 GHz only */ |
| 1340 | static u8 * hostapd_unsol_bcast_probe_resp(struct hostapd_data *hapd, |
| 1341 | struct wpa_driver_ap_params *params) |
| 1342 | { |
| 1343 | if (!is_6ghz_op_class(hapd->iconf->op_class)) |
| 1344 | return NULL; |
| 1345 | |
| 1346 | params->unsol_bcast_probe_resp_interval = |
| 1347 | hapd->conf->unsol_bcast_probe_resp_interval; |
| 1348 | |
| 1349 | return hostapd_gen_probe_resp(hapd, NULL, 0, |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1350 | ¶ms->unsol_bcast_probe_resp_tmpl_len, |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1351 | NULL, 0); |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1352 | } |
| 1353 | #endif /* CONFIG_IEEE80211AX */ |
| 1354 | |
| 1355 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 1356 | void sta_track_del(struct hostapd_sta_info *info) |
| 1357 | { |
| 1358 | #ifdef CONFIG_TAXONOMY |
| 1359 | wpabuf_free(info->probe_ie_taxonomy); |
| 1360 | info->probe_ie_taxonomy = NULL; |
| 1361 | #endif /* CONFIG_TAXONOMY */ |
| 1362 | os_free(info); |
| 1363 | } |
| 1364 | |
| 1365 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1366 | #ifdef CONFIG_FILS |
| 1367 | |
| 1368 | static u16 hostapd_fils_discovery_cap(struct hostapd_data *hapd) |
| 1369 | { |
| 1370 | u16 cap_info, phy_index = 0; |
| 1371 | u8 chwidth = FD_CAP_BSS_CHWIDTH_20, mcs_nss_size = 4; |
| 1372 | struct hostapd_hw_modes *mode = hapd->iface->current_mode; |
| 1373 | |
| 1374 | cap_info = FD_CAP_ESS; |
| 1375 | if (hapd->conf->wpa) |
| 1376 | cap_info |= FD_CAP_PRIVACY; |
| 1377 | |
| 1378 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
| 1379 | phy_index = FD_CAP_PHY_INDEX_HE; |
| 1380 | |
| 1381 | switch (hapd->iconf->op_class) { |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1382 | case 137: |
| 1383 | chwidth = FD_CAP_BSS_CHWIDTH_320; |
| 1384 | break; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1385 | case 135: |
| 1386 | mcs_nss_size += 4; |
| 1387 | /* fallthrough */ |
| 1388 | case 134: |
| 1389 | mcs_nss_size += 4; |
| 1390 | chwidth = FD_CAP_BSS_CHWIDTH_160_80_80; |
| 1391 | break; |
| 1392 | case 133: |
| 1393 | chwidth = FD_CAP_BSS_CHWIDTH_80; |
| 1394 | break; |
| 1395 | case 132: |
| 1396 | chwidth = FD_CAP_BSS_CHWIDTH_40; |
| 1397 | break; |
| 1398 | } |
| 1399 | } else { |
| 1400 | switch (hostapd_get_oper_chwidth(hapd->iconf)) { |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1401 | case CONF_OPER_CHWIDTH_80P80MHZ: |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1402 | mcs_nss_size += 4; |
| 1403 | /* fallthrough */ |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1404 | case CONF_OPER_CHWIDTH_160MHZ: |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1405 | mcs_nss_size += 4; |
| 1406 | chwidth = FD_CAP_BSS_CHWIDTH_160_80_80; |
| 1407 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1408 | case CONF_OPER_CHWIDTH_80MHZ: |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1409 | chwidth = FD_CAP_BSS_CHWIDTH_80; |
| 1410 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1411 | case CONF_OPER_CHWIDTH_USE_HT: |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1412 | if (hapd->iconf->secondary_channel) |
| 1413 | chwidth = FD_CAP_BSS_CHWIDTH_40; |
| 1414 | else |
| 1415 | chwidth = FD_CAP_BSS_CHWIDTH_20; |
| 1416 | break; |
Sunil | 8cd6f4d | 2022-06-28 18:40:46 +0000 | [diff] [blame] | 1417 | default: |
| 1418 | break; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1419 | } |
| 1420 | |
| 1421 | #ifdef CONFIG_IEEE80211AX |
| 1422 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) |
| 1423 | phy_index = FD_CAP_PHY_INDEX_HE; |
| 1424 | #endif /* CONFIG_IEEE80211AX */ |
| 1425 | #ifdef CONFIG_IEEE80211AC |
| 1426 | if (!phy_index && |
| 1427 | hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) |
| 1428 | phy_index = FD_CAP_PHY_INDEX_VHT; |
| 1429 | #endif /* CONFIG_IEEE80211AC */ |
| 1430 | if (!phy_index && |
| 1431 | hapd->iconf->ieee80211n && !hapd->conf->disable_11n) |
| 1432 | phy_index = FD_CAP_PHY_INDEX_HT; |
| 1433 | } |
| 1434 | |
| 1435 | cap_info |= phy_index << FD_CAP_PHY_INDEX_SHIFT; |
| 1436 | cap_info |= chwidth << FD_CAP_BSS_CHWIDTH_SHIFT; |
| 1437 | |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1438 | if (mode && phy_index == FD_CAP_PHY_INDEX_HE) { |
| 1439 | const u8 *he_mcs = mode->he_capab[IEEE80211_MODE_AP].mcs; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1440 | int i; |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1441 | u16 nss = 0, mcs[6]; |
| 1442 | |
| 1443 | os_memset(mcs, 0xffff, 6 * sizeof(u16)); |
| 1444 | |
| 1445 | if (mcs_nss_size == 4) { |
| 1446 | mcs[0] = WPA_GET_LE16(&he_mcs[0]); |
| 1447 | mcs[1] = WPA_GET_LE16(&he_mcs[2]); |
| 1448 | } |
| 1449 | |
| 1450 | if (mcs_nss_size == 8) { |
| 1451 | mcs[2] = WPA_GET_LE16(&he_mcs[4]); |
| 1452 | mcs[3] = WPA_GET_LE16(&he_mcs[6]); |
| 1453 | } |
| 1454 | |
| 1455 | if (mcs_nss_size == 12) { |
| 1456 | mcs[4] = WPA_GET_LE16(&he_mcs[8]); |
| 1457 | mcs[5] = WPA_GET_LE16(&he_mcs[10]); |
| 1458 | } |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1459 | |
| 1460 | for (i = 0; i < HE_NSS_MAX_STREAMS; i++) { |
| 1461 | u16 nss_mask = 0x3 << (i * 2); |
| 1462 | |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1463 | /* |
| 1464 | * If NSS values supported by RX and TX are different |
| 1465 | * then choose the smaller of the two as the maximum |
| 1466 | * supported NSS as that is the value supported by |
| 1467 | * both RX and TX. |
| 1468 | */ |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1469 | if (mcs_nss_size == 4 && |
| 1470 | (((mcs[0] & nss_mask) == nss_mask) || |
| 1471 | ((mcs[1] & nss_mask) == nss_mask))) |
| 1472 | continue; |
| 1473 | |
| 1474 | if (mcs_nss_size == 8 && |
| 1475 | (((mcs[2] & nss_mask) == nss_mask) || |
| 1476 | ((mcs[3] & nss_mask) == nss_mask))) |
| 1477 | continue; |
| 1478 | |
| 1479 | if (mcs_nss_size == 12 && |
| 1480 | (((mcs[4] & nss_mask) == nss_mask) || |
| 1481 | ((mcs[5] & nss_mask) == nss_mask))) |
| 1482 | continue; |
| 1483 | |
| 1484 | nss++; |
| 1485 | } |
| 1486 | |
| 1487 | if (nss > 4) |
| 1488 | cap_info |= FD_CAP_NSS_5_8 << FD_CAP_NSS_SHIFT; |
| 1489 | else if (nss) |
| 1490 | cap_info |= (nss - 1) << FD_CAP_NSS_SHIFT; |
| 1491 | } |
| 1492 | |
| 1493 | return cap_info; |
| 1494 | } |
| 1495 | |
| 1496 | |
| 1497 | static u8 * hostapd_gen_fils_discovery(struct hostapd_data *hapd, size_t *len) |
| 1498 | { |
| 1499 | struct ieee80211_mgmt *head; |
| 1500 | const u8 *mobility_domain; |
| 1501 | u8 *pos, *length_pos, buf[200]; |
| 1502 | u16 ctl = 0; |
| 1503 | u8 fd_rsn_info[5]; |
| 1504 | size_t total_len, buf_len; |
| 1505 | |
| 1506 | total_len = 24 + 2 + 12; |
| 1507 | |
| 1508 | /* FILS Discovery Frame Control */ |
| 1509 | ctl = (sizeof(hapd->conf->ssid.short_ssid) - 1) | |
| 1510 | FD_FRAME_CTL_SHORT_SSID_PRESENT | |
| 1511 | FD_FRAME_CTL_LENGTH_PRESENT | |
| 1512 | FD_FRAME_CTL_CAP_PRESENT; |
| 1513 | total_len += 4 + 1 + 2; |
| 1514 | |
| 1515 | /* Check for optional subfields and calculate length */ |
| 1516 | if (wpa_auth_write_fd_rsn_info(hapd->wpa_auth, fd_rsn_info)) { |
| 1517 | ctl |= FD_FRAME_CTL_RSN_INFO_PRESENT; |
| 1518 | total_len += sizeof(fd_rsn_info); |
| 1519 | } |
| 1520 | |
| 1521 | mobility_domain = hostapd_wpa_ie(hapd, WLAN_EID_MOBILITY_DOMAIN); |
| 1522 | if (mobility_domain) { |
| 1523 | ctl |= FD_FRAME_CTL_MD_PRESENT; |
| 1524 | total_len += 3; |
| 1525 | } |
| 1526 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1527 | total_len += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_ACTION); |
| 1528 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1529 | pos = hostapd_eid_fils_indic(hapd, buf, 0); |
| 1530 | buf_len = pos - buf; |
| 1531 | total_len += buf_len; |
| 1532 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1533 | #ifdef CONFIG_IEEE80211AX |
| 1534 | /* Transmit Power Envelope element(s) */ |
| 1535 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
| 1536 | total_len += 4; |
| 1537 | if (hapd->iconf->he_6ghz_reg_pwr_type == HE_6GHZ_INDOOR_AP) |
| 1538 | total_len += 4; |
| 1539 | } |
| 1540 | #endif /* CONFIG_IEEE80211AX */ |
| 1541 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1542 | head = os_zalloc(total_len); |
| 1543 | if (!head) |
| 1544 | return NULL; |
| 1545 | |
| 1546 | head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1547 | WLAN_FC_STYPE_ACTION); |
| 1548 | os_memset(head->da, 0xff, ETH_ALEN); |
| 1549 | os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); |
| 1550 | os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); |
| 1551 | |
| 1552 | head->u.action.category = WLAN_ACTION_PUBLIC; |
| 1553 | head->u.action.u.public_action.action = WLAN_PA_FILS_DISCOVERY; |
| 1554 | |
| 1555 | pos = &head->u.action.u.public_action.variable[0]; |
| 1556 | |
| 1557 | /* FILS Discovery Information field */ |
| 1558 | |
| 1559 | /* FILS Discovery Frame Control */ |
| 1560 | WPA_PUT_LE16(pos, ctl); |
| 1561 | pos += 2; |
| 1562 | |
| 1563 | /* Hardware or low-level driver will fill in the Timestamp value */ |
| 1564 | pos += 8; |
| 1565 | |
| 1566 | /* Beacon Interval */ |
| 1567 | WPA_PUT_LE16(pos, hapd->iconf->beacon_int); |
| 1568 | pos += 2; |
| 1569 | |
| 1570 | /* Short SSID */ |
| 1571 | WPA_PUT_LE32(pos, hapd->conf->ssid.short_ssid); |
| 1572 | pos += sizeof(hapd->conf->ssid.short_ssid); |
| 1573 | |
| 1574 | /* Store position of FILS discovery information element Length field */ |
| 1575 | length_pos = pos++; |
| 1576 | |
| 1577 | /* FD Capability */ |
| 1578 | WPA_PUT_LE16(pos, hostapd_fils_discovery_cap(hapd)); |
| 1579 | pos += 2; |
| 1580 | |
| 1581 | /* Operating Class - not present */ |
| 1582 | |
| 1583 | /* Primary Channel - not present */ |
| 1584 | |
| 1585 | /* AP Configuration Sequence Number - not present */ |
| 1586 | |
| 1587 | /* Access Network Options - not present */ |
| 1588 | |
| 1589 | /* FD RSN Information */ |
| 1590 | if (ctl & FD_FRAME_CTL_RSN_INFO_PRESENT) { |
| 1591 | os_memcpy(pos, fd_rsn_info, sizeof(fd_rsn_info)); |
| 1592 | pos += sizeof(fd_rsn_info); |
| 1593 | } |
| 1594 | |
| 1595 | /* Channel Center Frequency Segment 1 - not present */ |
| 1596 | |
| 1597 | /* Mobility Domain */ |
| 1598 | if (ctl & FD_FRAME_CTL_MD_PRESENT) { |
| 1599 | os_memcpy(pos, &mobility_domain[2], 3); |
| 1600 | pos += 3; |
| 1601 | } |
| 1602 | |
| 1603 | /* Fill in the Length field value */ |
| 1604 | *length_pos = pos - (length_pos + 1); |
| 1605 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1606 | pos = hostapd_eid_rnr(hapd, pos, WLAN_FC_STYPE_ACTION); |
| 1607 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1608 | /* FILS Indication element */ |
| 1609 | if (buf_len) { |
| 1610 | os_memcpy(pos, buf, buf_len); |
| 1611 | pos += buf_len; |
| 1612 | } |
| 1613 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1614 | if (is_6ghz_op_class(hapd->iconf->op_class)) |
| 1615 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
| 1616 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1617 | *len = pos - (u8 *) head; |
| 1618 | wpa_hexdump(MSG_DEBUG, "FILS Discovery frame template", |
| 1619 | head, pos - (u8 *) head); |
| 1620 | return (u8 *) head; |
| 1621 | } |
| 1622 | |
| 1623 | |
| 1624 | /* Configure FILS Discovery frame transmission parameters */ |
| 1625 | static u8 * hostapd_fils_discovery(struct hostapd_data *hapd, |
| 1626 | struct wpa_driver_ap_params *params) |
| 1627 | { |
| 1628 | params->fd_max_int = hapd->conf->fils_discovery_max_int; |
| 1629 | if (is_6ghz_op_class(hapd->iconf->op_class) && |
| 1630 | params->fd_max_int > FD_MAX_INTERVAL_6GHZ) |
| 1631 | params->fd_max_int = FD_MAX_INTERVAL_6GHZ; |
| 1632 | |
| 1633 | params->fd_min_int = hapd->conf->fils_discovery_min_int; |
| 1634 | if (params->fd_min_int > params->fd_max_int) |
| 1635 | params->fd_min_int = params->fd_max_int; |
| 1636 | |
| 1637 | if (params->fd_max_int) |
| 1638 | return hostapd_gen_fils_discovery(hapd, |
| 1639 | ¶ms->fd_frame_tmpl_len); |
| 1640 | |
| 1641 | return NULL; |
| 1642 | } |
| 1643 | |
| 1644 | #endif /* CONFIG_FILS */ |
| 1645 | |
| 1646 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1647 | int ieee802_11_build_ap_params(struct hostapd_data *hapd, |
| 1648 | struct wpa_driver_ap_params *params) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1649 | { |
| 1650 | struct ieee80211_mgmt *head = NULL; |
| 1651 | u8 *tail = NULL; |
| 1652 | size_t head_len = 0, tail_len = 0; |
| 1653 | u8 *resp = NULL; |
| 1654 | size_t resp_len = 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1655 | #ifdef NEED_AP_MLME |
| 1656 | u16 capab_info; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1657 | u8 *pos, *tailpos, *tailend, *csa_pos; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1658 | bool complete = false; |
| 1659 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1660 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1661 | os_memset(params, 0, sizeof(*params)); |
| 1662 | |
| 1663 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1664 | #define BEACON_HEAD_BUF_SIZE 256 |
| 1665 | #define BEACON_TAIL_BUF_SIZE 512 |
| 1666 | head = os_zalloc(BEACON_HEAD_BUF_SIZE); |
| 1667 | tail_len = BEACON_TAIL_BUF_SIZE; |
| 1668 | #ifdef CONFIG_WPS |
| 1669 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) |
| 1670 | tail_len += wpabuf_len(hapd->wps_beacon_ie); |
| 1671 | #endif /* CONFIG_WPS */ |
| 1672 | #ifdef CONFIG_P2P |
| 1673 | if (hapd->p2p_beacon_ie) |
| 1674 | tail_len += wpabuf_len(hapd->p2p_beacon_ie); |
| 1675 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1676 | #ifdef CONFIG_FST |
| 1677 | if (hapd->iface->fst_ies) |
| 1678 | tail_len += wpabuf_len(hapd->iface->fst_ies); |
| 1679 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1680 | if (hapd->conf->vendor_elements) |
| 1681 | tail_len += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1682 | |
| 1683 | #ifdef CONFIG_IEEE80211AC |
| 1684 | if (hapd->conf->vendor_vht) { |
| 1685 | tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 1686 | 2 + sizeof(struct ieee80211_vht_operation); |
| 1687 | } |
| 1688 | #endif /* CONFIG_IEEE80211AC */ |
| 1689 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1690 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1691 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1692 | tail_len += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1693 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1694 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 1695 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1696 | if (is_6ghz_op_class(hapd->iconf->op_class)) { |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 1697 | tail_len += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 1698 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1699 | /* An additional Transmit Power Envelope element for |
| 1700 | * subordinate client */ |
| 1701 | if (hapd->iconf->he_6ghz_reg_pwr_type == |
| 1702 | HE_6GHZ_INDOOR_AP) |
| 1703 | tail_len += 4; |
| 1704 | } |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1705 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1706 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1707 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1708 | #ifdef CONFIG_IEEE80211BE |
| 1709 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 1710 | tail_len += hostapd_eid_eht_capab_len(hapd, IEEE80211_MODE_AP); |
| 1711 | tail_len += 3 + sizeof(struct ieee80211_eht_operation); |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 1712 | if (hapd->iconf->punct_bitmap) |
| 1713 | tail_len += EHT_OPER_DISABLED_SUBCHAN_BITMAP_SIZE; |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1714 | } |
| 1715 | #endif /* CONFIG_IEEE80211BE */ |
| 1716 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1717 | if (hapd->iconf->mbssid == ENHANCED_MBSSID_ENABLED && |
| 1718 | hapd == hostapd_mbssid_get_tx_bss(hapd)) |
| 1719 | tail_len += 5; /* Multiple BSSID Configuration element */ |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1720 | tail_len += hostapd_eid_rnr_len(hapd, WLAN_FC_STYPE_BEACON); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1721 | tail_len += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1722 | tail_len += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1723 | tail_len += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1724 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1725 | tailpos = tail = os_malloc(tail_len); |
| 1726 | if (head == NULL || tail == NULL) { |
| 1727 | wpa_printf(MSG_ERROR, "Failed to set beacon data"); |
| 1728 | os_free(head); |
| 1729 | os_free(tail); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1730 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1731 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1732 | tailend = tail + tail_len; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1733 | |
| 1734 | head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1735 | WLAN_FC_STYPE_BEACON); |
| 1736 | head->duration = host_to_le16(0); |
| 1737 | os_memset(head->da, 0xff, ETH_ALEN); |
| 1738 | |
| 1739 | os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); |
| 1740 | os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); |
| 1741 | head->u.beacon.beacon_int = |
| 1742 | host_to_le16(hapd->iconf->beacon_int); |
| 1743 | |
| 1744 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1745 | capab_info = hostapd_own_capab_info(hapd); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1746 | head->u.beacon.capab_info = host_to_le16(capab_info); |
| 1747 | pos = &head->u.beacon.variable[0]; |
| 1748 | |
| 1749 | /* SSID */ |
| 1750 | *pos++ = WLAN_EID_SSID; |
| 1751 | if (hapd->conf->ignore_broadcast_ssid == 2) { |
| 1752 | /* clear the data, but keep the correct length of the SSID */ |
| 1753 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1754 | os_memset(pos, 0, hapd->conf->ssid.ssid_len); |
| 1755 | pos += hapd->conf->ssid.ssid_len; |
| 1756 | } else if (hapd->conf->ignore_broadcast_ssid) { |
| 1757 | *pos++ = 0; /* empty SSID */ |
| 1758 | } else { |
| 1759 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1760 | os_memcpy(pos, hapd->conf->ssid.ssid, |
| 1761 | hapd->conf->ssid.ssid_len); |
| 1762 | pos += hapd->conf->ssid.ssid_len; |
| 1763 | } |
| 1764 | |
| 1765 | /* Supported rates */ |
| 1766 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 1767 | |
| 1768 | /* DS Params */ |
| 1769 | pos = hostapd_eid_ds_params(hapd, pos); |
| 1770 | |
| 1771 | head_len = pos - (u8 *) head; |
| 1772 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1773 | tailpos = hostapd_eid_country(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1774 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1775 | /* Power Constraint element */ |
| 1776 | tailpos = hostapd_eid_pwr_constraint(hapd, tailpos); |
| 1777 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1778 | /* CSA IE */ |
| 1779 | csa_pos = hostapd_eid_csa(hapd, tailpos); |
| 1780 | if (csa_pos != tailpos) |
| 1781 | hapd->cs_c_off_beacon = csa_pos - tail - 1; |
| 1782 | tailpos = csa_pos; |
| 1783 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1784 | /* ERP Information element */ |
| 1785 | tailpos = hostapd_eid_erp_info(hapd, tailpos); |
| 1786 | |
| 1787 | /* Extended supported rates */ |
| 1788 | tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos); |
| 1789 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1790 | tailpos = hostapd_get_rsne(hapd, tailpos, tailend - tailpos); |
| 1791 | tailpos = hostapd_eid_bss_load(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1792 | tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1793 | tailend - tailpos); |
| 1794 | tailpos = hostapd_get_mde(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1795 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1796 | /* eCSA IE */ |
| 1797 | csa_pos = hostapd_eid_ecsa(hapd, tailpos); |
| 1798 | if (csa_pos != tailpos) |
| 1799 | hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1; |
| 1800 | tailpos = csa_pos; |
| 1801 | |
| 1802 | tailpos = hostapd_eid_supported_op_classes(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1803 | tailpos = hostapd_eid_ht_capabilities(hapd, tailpos); |
| 1804 | tailpos = hostapd_eid_ht_operation(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1805 | |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1806 | if (hapd->iconf->mbssid && hapd->iconf->num_bss > 1) { |
| 1807 | if (ieee802_11_build_ap_params_mbssid(hapd, params)) { |
| 1808 | os_free(head); |
| 1809 | os_free(tail); |
| 1810 | wpa_printf(MSG_ERROR, |
| 1811 | "MBSSID: Failed to set beacon data"); |
| 1812 | return -1; |
| 1813 | } |
| 1814 | complete = hapd->iconf->mbssid == MBSSID_ENABLED || |
| 1815 | (hapd->iconf->mbssid == ENHANCED_MBSSID_ENABLED && |
| 1816 | params->mbssid_elem_count == 1); |
| 1817 | } |
| 1818 | |
| 1819 | tailpos = hostapd_eid_ext_capab(hapd, tailpos, complete); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1820 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1821 | /* |
| 1822 | * TODO: Time Advertisement element should only be included in some |
| 1823 | * DTIM Beacon frames. |
| 1824 | */ |
| 1825 | tailpos = hostapd_eid_time_adv(hapd, tailpos); |
| 1826 | |
| 1827 | tailpos = hostapd_eid_interworking(hapd, tailpos); |
| 1828 | tailpos = hostapd_eid_adv_proto(hapd, tailpos); |
| 1829 | tailpos = hostapd_eid_roaming_consortium(hapd, tailpos); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1830 | |
| 1831 | #ifdef CONFIG_FST |
| 1832 | if (hapd->iface->fst_ies) { |
| 1833 | os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies), |
| 1834 | wpabuf_len(hapd->iface->fst_ies)); |
| 1835 | tailpos += wpabuf_len(hapd->iface->fst_ies); |
| 1836 | } |
| 1837 | #endif /* CONFIG_FST */ |
| 1838 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1839 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1840 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac && |
| 1841 | !is_6ghz_op_class(hapd->iconf->op_class)) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 1842 | tailpos = hostapd_eid_vht_capabilities(hapd, tailpos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1843 | tailpos = hostapd_eid_vht_operation(hapd, tailpos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 1844 | tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1845 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1846 | #endif /* CONFIG_IEEE80211AC */ |
| 1847 | |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1848 | #ifdef CONFIG_IEEE80211AX |
| 1849 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax && |
| 1850 | is_6ghz_op_class(hapd->iconf->op_class)) |
| 1851 | tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); |
| 1852 | #endif /* CONFIG_IEEE80211AX */ |
| 1853 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1854 | tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos); |
Hai Shalom | 899fcc7 | 2020-10-19 14:38:18 -0700 | [diff] [blame] | 1855 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 1856 | tailpos = hostapd_eid_rnr(hapd, tailpos, WLAN_FC_STYPE_BEACON); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1857 | tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1858 | tailpos = hostapd_get_rsnxe(hapd, tailpos, tailend - tailpos); |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 1859 | tailpos = hostapd_eid_mbssid_config(hapd, tailpos, |
| 1860 | params->mbssid_elem_count); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1861 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1862 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 1863 | if (hapd->iconf->ieee80211ax && !hapd->conf->disable_11ax) { |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1864 | u8 *cca_pos; |
| 1865 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1866 | tailpos = hostapd_eid_he_capab(hapd, tailpos, |
| 1867 | IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1868 | tailpos = hostapd_eid_he_operation(hapd, tailpos); |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1869 | |
| 1870 | /* BSS Color Change Announcement element */ |
| 1871 | cca_pos = hostapd_eid_cca(hapd, tailpos); |
| 1872 | if (cca_pos != tailpos) |
| 1873 | hapd->cca_c_off_beacon = cca_pos - tail - 2; |
| 1874 | tailpos = cca_pos; |
| 1875 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1876 | tailpos = hostapd_eid_spatial_reuse(hapd, tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1877 | tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame] | 1878 | tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1879 | } |
| 1880 | #endif /* CONFIG_IEEE80211AX */ |
| 1881 | |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 1882 | #ifdef CONFIG_IEEE80211BE |
| 1883 | if (hapd->iconf->ieee80211be && !hapd->conf->disable_11be) { |
| 1884 | tailpos = hostapd_eid_eht_capab(hapd, tailpos, |
| 1885 | IEEE80211_MODE_AP); |
| 1886 | tailpos = hostapd_eid_eht_operation(hapd, tailpos); |
| 1887 | } |
| 1888 | #endif /* CONFIG_IEEE80211BE */ |
| 1889 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1890 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1891 | if (hapd->conf->vendor_vht) |
| 1892 | tailpos = hostapd_eid_vendor_vht(hapd, tailpos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1893 | #endif /* CONFIG_IEEE80211AC */ |
| 1894 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1895 | /* WPA / OSEN */ |
| 1896 | tailpos = hostapd_get_wpa_ie(hapd, tailpos, tailend - tailpos); |
| 1897 | tailpos = hostapd_get_osen_ie(hapd, tailpos, tailend - tailpos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 1898 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1899 | /* Wi-Fi Alliance WMM */ |
| 1900 | tailpos = hostapd_eid_wmm(hapd, tailpos); |
| 1901 | |
| 1902 | #ifdef CONFIG_WPS |
| 1903 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) { |
| 1904 | os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie), |
| 1905 | wpabuf_len(hapd->wps_beacon_ie)); |
| 1906 | tailpos += wpabuf_len(hapd->wps_beacon_ie); |
| 1907 | } |
| 1908 | #endif /* CONFIG_WPS */ |
| 1909 | |
| 1910 | #ifdef CONFIG_P2P |
| 1911 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) { |
| 1912 | os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie), |
| 1913 | wpabuf_len(hapd->p2p_beacon_ie)); |
| 1914 | tailpos += wpabuf_len(hapd->p2p_beacon_ie); |
| 1915 | } |
| 1916 | #endif /* CONFIG_P2P */ |
| 1917 | #ifdef CONFIG_P2P_MANAGER |
| 1918 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 1919 | P2P_MANAGE) |
| 1920 | tailpos = hostapd_eid_p2p_manage(hapd, tailpos); |
| 1921 | #endif /* CONFIG_P2P_MANAGER */ |
| 1922 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1923 | #ifdef CONFIG_HS20 |
| 1924 | tailpos = hostapd_eid_hs20_indication(hapd, tailpos); |
| 1925 | #endif /* CONFIG_HS20 */ |
| 1926 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1927 | tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1928 | tailpos = hostapd_eid_owe_trans(hapd, tailpos, |
| 1929 | tail + tail_len - tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1930 | tailpos = hostapd_eid_dpp_cc(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1931 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1932 | if (hapd->conf->vendor_elements) { |
| 1933 | os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements), |
| 1934 | wpabuf_len(hapd->conf->vendor_elements)); |
| 1935 | tailpos += wpabuf_len(hapd->conf->vendor_elements); |
| 1936 | } |
| 1937 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1938 | tail_len = tailpos > tail ? tailpos - tail : 0; |
| 1939 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1940 | resp = hostapd_probe_resp_offloads(hapd, &resp_len); |
| 1941 | #endif /* NEED_AP_MLME */ |
| 1942 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1943 | params->head = (u8 *) head; |
| 1944 | params->head_len = head_len; |
| 1945 | params->tail = tail; |
| 1946 | params->tail_len = tail_len; |
| 1947 | params->proberesp = resp; |
| 1948 | params->proberesp_len = resp_len; |
| 1949 | params->dtim_period = hapd->conf->dtim_period; |
| 1950 | params->beacon_int = hapd->iconf->beacon_int; |
| 1951 | params->basic_rates = hapd->iface->basic_rates; |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 1952 | params->beacon_rate = hapd->iconf->beacon_rate; |
| 1953 | params->rate_type = hapd->iconf->rate_type; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1954 | params->ssid = hapd->conf->ssid.ssid; |
| 1955 | params->ssid_len = hapd->conf->ssid.ssid_len; |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 1956 | if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) == |
| 1957 | (WPA_PROTO_WPA | WPA_PROTO_RSN)) |
| 1958 | params->pairwise_ciphers = hapd->conf->wpa_pairwise | |
| 1959 | hapd->conf->rsn_pairwise; |
| 1960 | else if (hapd->conf->wpa & WPA_PROTO_RSN) |
| 1961 | params->pairwise_ciphers = hapd->conf->rsn_pairwise; |
| 1962 | else if (hapd->conf->wpa & WPA_PROTO_WPA) |
| 1963 | params->pairwise_ciphers = hapd->conf->wpa_pairwise; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1964 | params->group_cipher = hapd->conf->wpa_group; |
| 1965 | params->key_mgmt_suites = hapd->conf->wpa_key_mgmt; |
| 1966 | params->auth_algs = hapd->conf->auth_algs; |
| 1967 | params->wpa_version = hapd->conf->wpa; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1968 | params->privacy = hapd->conf->wpa; |
| 1969 | #ifdef CONFIG_WEP |
| 1970 | params->privacy |= hapd->conf->ssid.wep.keys_set || |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1971 | (hapd->conf->ieee802_1x && |
| 1972 | (hapd->conf->default_wep_key_len || |
| 1973 | hapd->conf->individual_wep_key_len)); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1974 | #endif /* CONFIG_WEP */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1975 | switch (hapd->conf->ignore_broadcast_ssid) { |
| 1976 | case 0: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1977 | params->hide_ssid = NO_SSID_HIDING; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1978 | break; |
| 1979 | case 1: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1980 | params->hide_ssid = HIDDEN_SSID_ZERO_LEN; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1981 | break; |
| 1982 | case 2: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1983 | params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1984 | break; |
| 1985 | } |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1986 | params->isolate = hapd->conf->isolate; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1987 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1988 | params->cts_protect = !!(ieee802_11_erp_info(hapd) & |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1989 | ERP_INFO_USE_PROTECTION); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1990 | params->preamble = hapd->iface->num_sta_no_short_preamble == 0 && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1991 | hapd->iconf->preamble == SHORT_PREAMBLE; |
| 1992 | if (hapd->iface->current_mode && |
| 1993 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1994 | params->short_slot_time = |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1995 | hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1; |
| 1996 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1997 | params->short_slot_time = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1998 | if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1999 | params->ht_opmode = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2000 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2001 | params->ht_opmode = hapd->iface->ht_op_mode; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2002 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2003 | params->interworking = hapd->conf->interworking; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2004 | if (hapd->conf->interworking && |
| 2005 | !is_zero_ether_addr(hapd->conf->hessid)) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2006 | params->hessid = hapd->conf->hessid; |
| 2007 | params->access_network_type = hapd->conf->access_network_type; |
| 2008 | params->ap_max_inactivity = hapd->conf->ap_max_inactivity; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2009 | #ifdef CONFIG_P2P |
| 2010 | params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow; |
| 2011 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 2012 | #ifdef CONFIG_HS20 |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2013 | params->disable_dgaf = hapd->conf->disable_dgaf; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 2014 | if (hapd->conf->osen) { |
| 2015 | params->privacy = 1; |
| 2016 | params->osen = 1; |
| 2017 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 2018 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 2019 | params->multicast_to_unicast = hapd->conf->multicast_to_unicast; |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 2020 | params->pbss = hapd->conf->pbss; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 2021 | |
| 2022 | if (hapd->conf->ftm_responder) { |
| 2023 | if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_FTM_RESPONDER) { |
| 2024 | params->ftm_responder = 1; |
| 2025 | params->lci = hapd->iface->conf->lci; |
| 2026 | params->civic = hapd->iface->conf->civic; |
| 2027 | } else { |
| 2028 | wpa_printf(MSG_WARNING, |
| 2029 | "Not configuring FTM responder as the driver doesn't advertise support for it"); |
| 2030 | } |
| 2031 | } |
| 2032 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2033 | return 0; |
| 2034 | } |
| 2035 | |
| 2036 | |
| 2037 | void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params) |
| 2038 | { |
| 2039 | os_free(params->tail); |
| 2040 | params->tail = NULL; |
| 2041 | os_free(params->head); |
| 2042 | params->head = NULL; |
| 2043 | os_free(params->proberesp); |
| 2044 | params->proberesp = NULL; |
Sunil Ravi | 77d572f | 2023-01-17 23:58:31 +0000 | [diff] [blame] | 2045 | os_free(params->mbssid_elem); |
| 2046 | params->mbssid_elem = NULL; |
| 2047 | os_free(params->mbssid_elem_offset); |
| 2048 | params->mbssid_elem_offset = NULL; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 2049 | os_free(params->rnr_elem); |
| 2050 | params->rnr_elem = NULL; |
| 2051 | os_free(params->rnr_elem_offset); |
| 2052 | params->rnr_elem_offset = NULL; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 2053 | #ifdef CONFIG_FILS |
| 2054 | os_free(params->fd_frame_tmpl); |
| 2055 | params->fd_frame_tmpl = NULL; |
| 2056 | #endif /* CONFIG_FILS */ |
| 2057 | #ifdef CONFIG_IEEE80211AX |
| 2058 | os_free(params->unsol_bcast_probe_resp_tmpl); |
| 2059 | params->unsol_bcast_probe_resp_tmpl = NULL; |
| 2060 | #endif /* CONFIG_IEEE80211AX */ |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 2061 | os_free(params->allowed_freqs); |
| 2062 | params->allowed_freqs = NULL; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2063 | } |
| 2064 | |
| 2065 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 2066 | static int __ieee802_11_set_beacon(struct hostapd_data *hapd) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2067 | { |
| 2068 | struct wpa_driver_ap_params params; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 2069 | struct hostapd_freq_params freq; |
| 2070 | struct hostapd_iface *iface = hapd->iface; |
| 2071 | struct hostapd_config *iconf = iface->conf; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2072 | struct hostapd_hw_modes *cmode = iface->current_mode; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2073 | struct wpabuf *beacon, *proberesp, *assocresp; |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 2074 | int res, ret = -1, i; |
| 2075 | struct hostapd_hw_modes *mode; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2076 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 2077 | if (!hapd->drv_priv) { |
| 2078 | wpa_printf(MSG_ERROR, "Interface is disabled"); |
| 2079 | return -1; |
| 2080 | } |
| 2081 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 2082 | if (hapd->csa_in_progress) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2083 | wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2084 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2085 | } |
| 2086 | |
| 2087 | hapd->beacon_set_done = 1; |
| 2088 | |
| 2089 | if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2090 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2091 | |
| 2092 | if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < |
| 2093 | 0) |
| 2094 | goto fail; |
| 2095 | |
| 2096 | params.beacon_ies = beacon; |
| 2097 | params.proberesp_ies = proberesp; |
| 2098 | params.assocresp_ies = assocresp; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2099 | params.reenable = hapd->reenable_beacon; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 2100 | #ifdef CONFIG_IEEE80211AX |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 2101 | params.he_spr_ctrl = hapd->iface->conf->spr.sr_control; |
| 2102 | params.he_spr_non_srg_obss_pd_max_offset = |
| 2103 | hapd->iface->conf->spr.non_srg_obss_pd_max_offset; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 2104 | params.he_spr_srg_obss_pd_min_offset = |
| 2105 | hapd->iface->conf->spr.srg_obss_pd_min_offset; |
| 2106 | params.he_spr_srg_obss_pd_max_offset = |
| 2107 | hapd->iface->conf->spr.srg_obss_pd_max_offset; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 2108 | os_memcpy(params.he_spr_bss_color_bitmap, |
| 2109 | hapd->iface->conf->spr.srg_bss_color_bitmap, 8); |
| 2110 | os_memcpy(params.he_spr_partial_bssid_bitmap, |
| 2111 | hapd->iface->conf->spr.srg_partial_bssid_bitmap, 8); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 2112 | params.he_bss_color_disabled = |
| 2113 | hapd->iface->conf->he_op.he_bss_color_disabled; |
| 2114 | params.he_bss_color_partial = |
| 2115 | hapd->iface->conf->he_op.he_bss_color_partial; |
| 2116 | params.he_bss_color = hapd->iface->conf->he_op.he_bss_color; |
| 2117 | params.twt_responder = hostapd_get_he_twt_responder(hapd, |
| 2118 | IEEE80211_MODE_AP); |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 2119 | params.unsol_bcast_probe_resp_tmpl = |
| 2120 | hostapd_unsol_bcast_probe_resp(hapd, ¶ms); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 2121 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 2122 | hapd->reenable_beacon = 0; |
Hai Shalom | 6084025 | 2021-02-19 19:02:11 -0800 | [diff] [blame] | 2123 | #ifdef CONFIG_SAE |
| 2124 | params.sae_pwe = hapd->conf->sae_pwe; |
| 2125 | #endif /* CONFIG_SAE */ |
| 2126 | |
| 2127 | #ifdef CONFIG_FILS |
| 2128 | params.fd_frame_tmpl = hostapd_fils_discovery(hapd, ¶ms); |
| 2129 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2130 | |
Sunil Ravi | 036cec5 | 2023-03-29 11:35:17 -0700 | [diff] [blame] | 2131 | #ifdef CONFIG_IEEE80211BE |
| 2132 | params.punct_bitmap = iconf->punct_bitmap; |
| 2133 | #endif /* CONFIG_IEEE80211BE */ |
| 2134 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2135 | if (cmode && |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 2136 | hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 2137 | iconf->channel, iconf->enable_edmg, |
| 2138 | iconf->edmg_channel, iconf->ieee80211n, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2139 | iconf->ieee80211ac, iconf->ieee80211ax, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2140 | iconf->ieee80211be, |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 2141 | iconf->secondary_channel, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 2142 | hostapd_get_oper_chwidth(iconf), |
| 2143 | hostapd_get_oper_centr_freq_seg0_idx(iconf), |
| 2144 | hostapd_get_oper_centr_freq_seg1_idx(iconf), |
| 2145 | cmode->vht_capab, |
Sunil Ravi | a04bd25 | 2022-05-02 22:54:18 -0700 | [diff] [blame] | 2146 | &cmode->he_capab[IEEE80211_MODE_AP], |
| 2147 | &cmode->eht_capab[IEEE80211_MODE_AP]) == 0) |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 2148 | params.freq = &freq; |
| 2149 | |
Sunil Ravi | 640215c | 2023-06-28 23:08:09 +0000 | [diff] [blame^] | 2150 | for (i = 0; i < hapd->iface->num_hw_features; i++) { |
| 2151 | mode = &hapd->iface->hw_features[i]; |
| 2152 | |
| 2153 | if (iconf->hw_mode != HOSTAPD_MODE_IEEE80211ANY && |
| 2154 | iconf->hw_mode != mode->mode) |
| 2155 | continue; |
| 2156 | |
| 2157 | hostapd_get_hw_mode_any_channels(hapd, mode, |
| 2158 | !(iconf->acs_freq_list.num || |
| 2159 | iconf->acs_ch_list.num), |
| 2160 | true, ¶ms.allowed_freqs); |
| 2161 | } |
| 2162 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2163 | res = hostapd_drv_set_ap(hapd, ¶ms); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 2164 | hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2165 | if (res) |
| 2166 | wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); |
| 2167 | else |
| 2168 | ret = 0; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 2169 | fail: |
| 2170 | ieee802_11_free_ap_params(¶ms); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2171 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2172 | } |
| 2173 | |
| 2174 | |
Hai Shalom | a20dcd7 | 2022-02-04 13:43:00 -0800 | [diff] [blame] | 2175 | int ieee802_11_set_beacon(struct hostapd_data *hapd) |
| 2176 | { |
| 2177 | struct hostapd_iface *iface = hapd->iface; |
| 2178 | int ret; |
| 2179 | size_t i, j; |
| 2180 | bool is_6g; |
| 2181 | |
| 2182 | ret = __ieee802_11_set_beacon(hapd); |
| 2183 | if (ret != 0) |
| 2184 | return ret; |
| 2185 | |
| 2186 | if (!iface->interfaces || iface->interfaces->count <= 1) |
| 2187 | return 0; |
| 2188 | |
| 2189 | /* Update Beacon frames in case of 6 GHz colocation */ |
| 2190 | is_6g = is_6ghz_op_class(iface->conf->op_class); |
| 2191 | for (j = 0; j < iface->interfaces->count; j++) { |
| 2192 | struct hostapd_iface *colocated; |
| 2193 | |
| 2194 | colocated = iface->interfaces->iface[j]; |
| 2195 | if (colocated == iface || !colocated || !colocated->conf) |
| 2196 | continue; |
| 2197 | |
| 2198 | if (is_6g == is_6ghz_op_class(colocated->conf->op_class)) |
| 2199 | continue; |
| 2200 | |
| 2201 | for (i = 0; i < colocated->num_bss; i++) { |
| 2202 | if (colocated->bss[i] && colocated->bss[i]->started) |
| 2203 | __ieee802_11_set_beacon(colocated->bss[i]); |
| 2204 | } |
| 2205 | } |
| 2206 | |
| 2207 | return 0; |
| 2208 | } |
| 2209 | |
| 2210 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2211 | int ieee802_11_set_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2212 | { |
| 2213 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2214 | int ret = 0; |
| 2215 | |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 2216 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2217 | if (iface->bss[i]->started && |
| 2218 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 2219 | ret = -1; |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 2220 | } |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2221 | |
| 2222 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2223 | } |
| 2224 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2225 | |
| 2226 | /* only update beacons if started */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2227 | int ieee802_11_update_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2228 | { |
| 2229 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 2230 | int ret = 0; |
| 2231 | |
| 2232 | for (i = 0; i < iface->num_bss; i++) { |
| 2233 | if (iface->bss[i]->beacon_set_done && iface->bss[i]->started && |
| 2234 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 2235 | ret = -1; |
| 2236 | } |
| 2237 | |
| 2238 | return ret; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 2239 | } |
| 2240 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 2241 | #endif /* CONFIG_NATIVE_WINDOWS */ |