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