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 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 189 | static u8 * hostapd_eid_country_add(u8 *pos, u8 *end, int chan_spacing, |
| 190 | struct hostapd_channel_data *start, |
| 191 | struct hostapd_channel_data *prev) |
| 192 | { |
| 193 | if (end - pos < 3) |
| 194 | return pos; |
| 195 | |
| 196 | /* first channel number */ |
| 197 | *pos++ = start->chan; |
| 198 | /* number of channels */ |
| 199 | *pos++ = (prev->chan - start->chan) / chan_spacing + 1; |
| 200 | /* maximum transmit power level */ |
| 201 | *pos++ = start->max_tx_power; |
| 202 | |
| 203 | return pos; |
| 204 | } |
| 205 | |
| 206 | |
| 207 | static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid, |
| 208 | int max_len) |
| 209 | { |
| 210 | u8 *pos = eid; |
| 211 | u8 *end = eid + max_len; |
| 212 | int i; |
| 213 | struct hostapd_hw_modes *mode; |
| 214 | struct hostapd_channel_data *start, *prev; |
| 215 | int chan_spacing = 1; |
| 216 | |
| 217 | if (!hapd->iconf->ieee80211d || max_len < 6 || |
| 218 | hapd->iface->current_mode == NULL) |
| 219 | return eid; |
| 220 | |
| 221 | *pos++ = WLAN_EID_COUNTRY; |
| 222 | pos++; /* length will be set later */ |
| 223 | os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */ |
| 224 | pos += 3; |
| 225 | |
| 226 | mode = hapd->iface->current_mode; |
| 227 | if (mode->mode == HOSTAPD_MODE_IEEE80211A) |
| 228 | chan_spacing = 4; |
| 229 | |
| 230 | start = prev = NULL; |
| 231 | for (i = 0; i < mode->num_channels; i++) { |
| 232 | struct hostapd_channel_data *chan = &mode->channels[i]; |
| 233 | if (chan->flag & HOSTAPD_CHAN_DISABLED) |
| 234 | continue; |
| 235 | if (start && prev && |
| 236 | prev->chan + chan_spacing == chan->chan && |
| 237 | start->max_tx_power == chan->max_tx_power) { |
| 238 | prev = chan; |
| 239 | continue; /* can use same entry */ |
| 240 | } |
| 241 | |
Dmitry Shmidt | 09f57ba | 2014-06-10 16:07:13 -0700 | [diff] [blame] | 242 | if (start && prev) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 243 | pos = hostapd_eid_country_add(pos, end, chan_spacing, |
| 244 | start, prev); |
| 245 | start = NULL; |
| 246 | } |
| 247 | |
| 248 | /* Start new group */ |
| 249 | start = prev = chan; |
| 250 | } |
| 251 | |
| 252 | if (start) { |
| 253 | pos = hostapd_eid_country_add(pos, end, chan_spacing, |
| 254 | start, prev); |
| 255 | } |
| 256 | |
| 257 | if ((pos - eid) & 1) { |
| 258 | if (end - pos < 1) |
| 259 | return eid; |
| 260 | *pos++ = 0; /* pad for 16-bit alignment */ |
| 261 | } |
| 262 | |
| 263 | eid[1] = (pos - eid) - 2; |
| 264 | |
| 265 | return pos; |
| 266 | } |
| 267 | |
| 268 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 269 | static const u8 * hostapd_wpa_ie(struct hostapd_data *hapd, u8 eid) |
| 270 | { |
| 271 | const u8 *ies; |
| 272 | size_t ies_len; |
| 273 | |
| 274 | ies = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ies_len); |
| 275 | if (!ies) |
| 276 | return NULL; |
| 277 | |
| 278 | return get_ie(ies, ies_len, eid); |
| 279 | } |
| 280 | |
| 281 | |
| 282 | static const u8 * hostapd_vendor_wpa_ie(struct hostapd_data *hapd, |
| 283 | u32 vendor_type) |
| 284 | { |
| 285 | const u8 *ies; |
| 286 | size_t ies_len; |
| 287 | |
| 288 | ies = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ies_len); |
| 289 | if (!ies) |
| 290 | return NULL; |
| 291 | |
| 292 | return get_vendor_ie(ies, ies_len, vendor_type); |
| 293 | } |
| 294 | |
| 295 | |
| 296 | 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] | 297 | { |
| 298 | const u8 *ie; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 299 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 300 | ie = hostapd_wpa_ie(hapd, WLAN_EID_RSN); |
| 301 | if (!ie || 2U + ie[1] > len) |
| 302 | return pos; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 303 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 304 | os_memcpy(pos, ie, 2 + ie[1]); |
| 305 | return pos + 2 + ie[1]; |
| 306 | } |
| 307 | |
| 308 | |
| 309 | static u8 * hostapd_get_mde(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 310 | { |
| 311 | const u8 *ie; |
| 312 | |
| 313 | ie = hostapd_wpa_ie(hapd, WLAN_EID_MOBILITY_DOMAIN); |
| 314 | if (!ie || 2U + ie[1] > len) |
| 315 | return pos; |
| 316 | |
| 317 | os_memcpy(pos, ie, 2 + ie[1]); |
| 318 | return pos + 2 + ie[1]; |
| 319 | } |
| 320 | |
| 321 | |
| 322 | static u8 * hostapd_get_rsnxe(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 323 | { |
| 324 | const u8 *ie; |
| 325 | |
| 326 | #ifdef CONFIG_TESTING_OPTIONS |
| 327 | if (hapd->conf->no_beacon_rsnxe) { |
| 328 | wpa_printf(MSG_INFO, "TESTING: Do not add RSNXE into Beacon"); |
| 329 | return pos; |
| 330 | } |
| 331 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 332 | ie = hostapd_wpa_ie(hapd, WLAN_EID_RSNX); |
| 333 | if (!ie || 2U + ie[1] > len) |
| 334 | return pos; |
| 335 | |
| 336 | os_memcpy(pos, ie, 2 + ie[1]); |
| 337 | return pos + 2 + ie[1]; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | static u8 * hostapd_get_wpa_ie(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 342 | { |
| 343 | const u8 *ie; |
| 344 | |
| 345 | ie = hostapd_vendor_wpa_ie(hapd, WPA_IE_VENDOR_TYPE); |
| 346 | if (!ie || 2U + ie[1] > len) |
| 347 | return pos; |
| 348 | |
| 349 | os_memcpy(pos, ie, 2 + ie[1]); |
| 350 | return pos + 2 + ie[1]; |
| 351 | } |
| 352 | |
| 353 | |
| 354 | static u8 * hostapd_get_osen_ie(struct hostapd_data *hapd, u8 *pos, size_t len) |
| 355 | { |
| 356 | const u8 *ie; |
| 357 | |
| 358 | ie = hostapd_vendor_wpa_ie(hapd, OSEN_IE_VENDOR_TYPE); |
| 359 | if (!ie || 2U + ie[1] > len) |
| 360 | return pos; |
| 361 | |
| 362 | os_memcpy(pos, ie, 2 + ie[1]); |
| 363 | return pos + 2 + ie[1]; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 367 | static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid) |
| 368 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 369 | #ifdef CONFIG_TESTING_OPTIONS |
| 370 | if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 371 | return eid; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 372 | #endif /* CONFIG_TESTING_OPTIONS */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 373 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 374 | if (!hapd->cs_freq_params.channel) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 375 | return eid; |
| 376 | |
| 377 | *eid++ = WLAN_EID_CHANNEL_SWITCH; |
| 378 | *eid++ = 3; |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 379 | *eid++ = hapd->cs_block_tx; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 380 | *eid++ = hapd->cs_freq_params.channel; |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 381 | *eid++ = hapd->cs_count; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 382 | |
| 383 | return eid; |
| 384 | } |
| 385 | |
| 386 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 387 | static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 388 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 389 | if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 390 | return eid; |
| 391 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 392 | *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN; |
| 393 | *eid++ = 4; |
| 394 | *eid++ = hapd->cs_block_tx; |
| 395 | *eid++ = hapd->iface->cs_oper_class; |
| 396 | *eid++ = hapd->cs_freq_params.channel; |
| 397 | *eid++ = hapd->cs_count; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 398 | |
| 399 | return eid; |
| 400 | } |
| 401 | |
| 402 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 403 | 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] | 404 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 405 | u8 op_class, channel; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 406 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 407 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) || |
| 408 | !hapd->iface->freq) |
| 409 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 410 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 411 | if (ieee80211_freq_to_channel_ext(hapd->iface->freq, |
| 412 | hapd->iconf->secondary_channel, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 413 | hostapd_get_oper_chwidth(hapd->iconf), |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 414 | &op_class, &channel) == |
| 415 | NUM_HOSTAPD_MODES) |
| 416 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 417 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 418 | *eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES; |
| 419 | *eid++ = 2; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 420 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 421 | /* Current Operating Class */ |
| 422 | *eid++ = op_class; |
| 423 | |
| 424 | /* TODO: Advertise all the supported operating classes */ |
| 425 | *eid++ = 0; |
| 426 | |
| 427 | return eid; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 431 | static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 432 | const struct ieee80211_mgmt *req, |
| 433 | int is_p2p, size_t *resp_len) |
| 434 | { |
| 435 | struct ieee80211_mgmt *resp; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 436 | u8 *pos, *epos, *csa_pos; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 437 | size_t buflen; |
| 438 | |
| 439 | #define MAX_PROBERESP_LEN 768 |
| 440 | buflen = MAX_PROBERESP_LEN; |
| 441 | #ifdef CONFIG_WPS |
| 442 | if (hapd->wps_probe_resp_ie) |
| 443 | buflen += wpabuf_len(hapd->wps_probe_resp_ie); |
| 444 | #endif /* CONFIG_WPS */ |
| 445 | #ifdef CONFIG_P2P |
| 446 | if (hapd->p2p_probe_resp_ie) |
| 447 | buflen += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 448 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 449 | #ifdef CONFIG_FST |
| 450 | if (hapd->iface->fst_ies) |
| 451 | buflen += wpabuf_len(hapd->iface->fst_ies); |
| 452 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 453 | if (hapd->conf->vendor_elements) |
| 454 | buflen += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 455 | if (hapd->conf->vendor_vht) { |
| 456 | buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 457 | 2 + sizeof(struct ieee80211_vht_operation); |
| 458 | } |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 459 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 460 | #ifdef CONFIG_IEEE80211AX |
| 461 | if (hapd->iconf->ieee80211ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 462 | buflen += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 463 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 464 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 465 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame^] | 466 | if (is_6ghz_op_class(hapd->iconf->op_class)) |
| 467 | buflen += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 468 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 469 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 470 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 471 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 472 | buflen += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 473 | buflen += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 474 | buflen += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 475 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 476 | resp = os_zalloc(buflen); |
| 477 | if (resp == NULL) |
| 478 | return NULL; |
| 479 | |
| 480 | epos = ((u8 *) resp) + MAX_PROBERESP_LEN; |
| 481 | |
| 482 | resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 483 | WLAN_FC_STYPE_PROBE_RESP); |
| 484 | if (req) |
| 485 | os_memcpy(resp->da, req->sa, ETH_ALEN); |
| 486 | os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN); |
| 487 | |
| 488 | os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN); |
| 489 | resp->u.probe_resp.beacon_int = |
| 490 | host_to_le16(hapd->iconf->beacon_int); |
| 491 | |
| 492 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
| 493 | resp->u.probe_resp.capab_info = |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 494 | host_to_le16(hostapd_own_capab_info(hapd)); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 495 | |
| 496 | pos = resp->u.probe_resp.variable; |
| 497 | *pos++ = WLAN_EID_SSID; |
| 498 | *pos++ = hapd->conf->ssid.ssid_len; |
| 499 | os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len); |
| 500 | pos += hapd->conf->ssid.ssid_len; |
| 501 | |
| 502 | /* Supported rates */ |
| 503 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 504 | |
| 505 | /* DS Params */ |
| 506 | pos = hostapd_eid_ds_params(hapd, pos); |
| 507 | |
| 508 | pos = hostapd_eid_country(hapd, pos, epos - pos); |
| 509 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 510 | /* Power Constraint element */ |
| 511 | pos = hostapd_eid_pwr_constraint(hapd, pos); |
| 512 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 513 | /* CSA IE */ |
| 514 | csa_pos = hostapd_eid_csa(hapd, pos); |
| 515 | if (csa_pos != pos) |
| 516 | hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1; |
| 517 | pos = csa_pos; |
| 518 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 519 | /* ERP Information element */ |
| 520 | pos = hostapd_eid_erp_info(hapd, pos); |
| 521 | |
| 522 | /* Extended supported rates */ |
| 523 | pos = hostapd_eid_ext_supp_rates(hapd, pos); |
| 524 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 525 | pos = hostapd_get_rsne(hapd, pos, epos - pos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 526 | pos = hostapd_eid_bss_load(hapd, pos, epos - pos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 527 | pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 528 | pos = hostapd_get_mde(hapd, pos, epos - pos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 529 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 530 | /* eCSA IE */ |
| 531 | csa_pos = hostapd_eid_ecsa(hapd, pos); |
| 532 | if (csa_pos != pos) |
| 533 | hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1; |
| 534 | pos = csa_pos; |
| 535 | |
| 536 | pos = hostapd_eid_supported_op_classes(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 537 | pos = hostapd_eid_ht_capabilities(hapd, pos); |
| 538 | pos = hostapd_eid_ht_operation(hapd, pos); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 539 | |
| 540 | pos = hostapd_eid_ext_capab(hapd, pos); |
| 541 | |
| 542 | pos = hostapd_eid_time_adv(hapd, pos); |
| 543 | pos = hostapd_eid_time_zone(hapd, pos); |
| 544 | |
| 545 | pos = hostapd_eid_interworking(hapd, pos); |
| 546 | pos = hostapd_eid_adv_proto(hapd, pos); |
| 547 | pos = hostapd_eid_roaming_consortium(hapd, pos); |
| 548 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 549 | #ifdef CONFIG_FST |
| 550 | if (hapd->iface->fst_ies) { |
| 551 | os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies), |
| 552 | wpabuf_len(hapd->iface->fst_ies)); |
| 553 | pos += wpabuf_len(hapd->iface->fst_ies); |
| 554 | } |
| 555 | #endif /* CONFIG_FST */ |
| 556 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 557 | #ifdef CONFIG_IEEE80211AC |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 558 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac && |
| 559 | !is_6ghz_op_class(hapd->iconf->op_class)) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 560 | pos = hostapd_eid_vht_capabilities(hapd, pos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 561 | pos = hostapd_eid_vht_operation(hapd, pos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 562 | pos = hostapd_eid_txpower_envelope(hapd, pos); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 563 | pos = hostapd_eid_wb_chsw_wrapper(hapd, pos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 564 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 565 | #endif /* CONFIG_IEEE80211AC */ |
| 566 | |
| 567 | pos = hostapd_eid_fils_indic(hapd, pos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 568 | pos = hostapd_get_rsnxe(hapd, pos, epos - pos); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 569 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 570 | #ifdef CONFIG_IEEE80211AX |
| 571 | if (hapd->iconf->ieee80211ax) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 572 | pos = hostapd_eid_he_capab(hapd, pos, IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 573 | pos = hostapd_eid_he_operation(hapd, pos); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 574 | pos = hostapd_eid_spatial_reuse(hapd, pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 575 | pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame^] | 576 | pos = hostapd_eid_he_6ghz_band_cap(hapd, pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 577 | } |
| 578 | #endif /* CONFIG_IEEE80211AX */ |
| 579 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 580 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 581 | if (hapd->conf->vendor_vht) |
| 582 | pos = hostapd_eid_vendor_vht(hapd, pos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 583 | #endif /* CONFIG_IEEE80211AC */ |
| 584 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 585 | /* WPA / OSEN */ |
| 586 | pos = hostapd_get_wpa_ie(hapd, pos, epos - pos); |
| 587 | pos = hostapd_get_osen_ie(hapd, pos, epos - pos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 588 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 589 | /* Wi-Fi Alliance WMM */ |
| 590 | pos = hostapd_eid_wmm(hapd, pos); |
| 591 | |
| 592 | #ifdef CONFIG_WPS |
| 593 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) { |
| 594 | os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie), |
| 595 | wpabuf_len(hapd->wps_probe_resp_ie)); |
| 596 | pos += wpabuf_len(hapd->wps_probe_resp_ie); |
| 597 | } |
| 598 | #endif /* CONFIG_WPS */ |
| 599 | |
| 600 | #ifdef CONFIG_P2P |
| 601 | if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p && |
| 602 | hapd->p2p_probe_resp_ie) { |
| 603 | os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie), |
| 604 | wpabuf_len(hapd->p2p_probe_resp_ie)); |
| 605 | pos += wpabuf_len(hapd->p2p_probe_resp_ie); |
| 606 | } |
| 607 | #endif /* CONFIG_P2P */ |
| 608 | #ifdef CONFIG_P2P_MANAGER |
| 609 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 610 | P2P_MANAGE) |
| 611 | pos = hostapd_eid_p2p_manage(hapd, pos); |
| 612 | #endif /* CONFIG_P2P_MANAGER */ |
| 613 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 614 | #ifdef CONFIG_HS20 |
| 615 | pos = hostapd_eid_hs20_indication(hapd, pos); |
| 616 | #endif /* CONFIG_HS20 */ |
| 617 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 618 | pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 619 | pos = hostapd_eid_owe_trans(hapd, pos, (u8 *) resp + buflen - pos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 620 | pos = hostapd_eid_dpp_cc(hapd, pos, (u8 *) resp + buflen - pos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 621 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 622 | if (hapd->conf->vendor_elements) { |
| 623 | os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements), |
| 624 | wpabuf_len(hapd->conf->vendor_elements)); |
| 625 | pos += wpabuf_len(hapd->conf->vendor_elements); |
| 626 | } |
| 627 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 628 | *resp_len = pos - (u8 *) resp; |
| 629 | return (u8 *) resp; |
| 630 | } |
| 631 | |
| 632 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 633 | enum ssid_match_result { |
| 634 | NO_SSID_MATCH, |
| 635 | EXACT_SSID_MATCH, |
| 636 | WILDCARD_SSID_MATCH |
| 637 | }; |
| 638 | |
| 639 | static enum ssid_match_result ssid_match(struct hostapd_data *hapd, |
| 640 | const u8 *ssid, size_t ssid_len, |
| 641 | const u8 *ssid_list, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 642 | size_t ssid_list_len, |
| 643 | const u8 *short_ssid_list, |
| 644 | size_t short_ssid_list_len) |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 645 | { |
| 646 | const u8 *pos, *end; |
| 647 | int wildcard = 0; |
| 648 | |
| 649 | if (ssid_len == 0) |
| 650 | wildcard = 1; |
| 651 | if (ssid_len == hapd->conf->ssid.ssid_len && |
| 652 | os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0) |
| 653 | return EXACT_SSID_MATCH; |
| 654 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 655 | if (ssid_list) { |
| 656 | pos = ssid_list; |
| 657 | end = ssid_list + ssid_list_len; |
| 658 | while (end - pos >= 2) { |
| 659 | if (2 + pos[1] > end - pos) |
| 660 | break; |
| 661 | if (pos[1] == 0) |
| 662 | wildcard = 1; |
| 663 | if (pos[1] == hapd->conf->ssid.ssid_len && |
| 664 | os_memcmp(pos + 2, hapd->conf->ssid.ssid, |
| 665 | pos[1]) == 0) |
| 666 | return EXACT_SSID_MATCH; |
| 667 | pos += 2 + pos[1]; |
| 668 | } |
| 669 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 670 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 671 | if (short_ssid_list) { |
| 672 | pos = short_ssid_list; |
| 673 | end = short_ssid_list + short_ssid_list_len; |
| 674 | while (end - pos >= 4) { |
| 675 | if (hapd->conf->ssid.short_ssid == WPA_GET_LE32(pos)) |
| 676 | return EXACT_SSID_MATCH; |
| 677 | pos += 4; |
| 678 | } |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH; |
| 682 | } |
| 683 | |
| 684 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 685 | void sta_track_expire(struct hostapd_iface *iface, int force) |
| 686 | { |
| 687 | struct os_reltime now; |
| 688 | struct hostapd_sta_info *info; |
| 689 | |
| 690 | if (!iface->num_sta_seen) |
| 691 | return; |
| 692 | |
| 693 | os_get_reltime(&now); |
| 694 | while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info, |
| 695 | list))) { |
| 696 | if (!force && |
| 697 | !os_reltime_expired(&now, &info->last_seen, |
| 698 | iface->conf->track_sta_max_age)) |
| 699 | break; |
| 700 | force = 0; |
| 701 | |
| 702 | wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for " |
| 703 | MACSTR, iface->bss[0]->conf->iface, |
| 704 | MAC2STR(info->addr)); |
| 705 | dl_list_del(&info->list); |
| 706 | iface->num_sta_seen--; |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 707 | sta_track_del(info); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 708 | } |
| 709 | } |
| 710 | |
| 711 | |
| 712 | static struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface, |
| 713 | const u8 *addr) |
| 714 | { |
| 715 | struct hostapd_sta_info *info; |
| 716 | |
| 717 | dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list) |
| 718 | if (os_memcmp(addr, info->addr, ETH_ALEN) == 0) |
| 719 | return info; |
| 720 | |
| 721 | return NULL; |
| 722 | } |
| 723 | |
| 724 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 725 | 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] | 726 | { |
| 727 | struct hostapd_sta_info *info; |
| 728 | |
| 729 | info = sta_track_get(iface, addr); |
| 730 | if (info) { |
| 731 | /* Move the most recent entry to the end of the list */ |
| 732 | dl_list_del(&info->list); |
| 733 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 734 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 735 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 736 | return; |
| 737 | } |
| 738 | |
| 739 | /* Add a new entry */ |
| 740 | info = os_zalloc(sizeof(*info)); |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 741 | if (info == NULL) |
| 742 | return; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 743 | os_memcpy(info->addr, addr, ETH_ALEN); |
| 744 | os_get_reltime(&info->last_seen); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 745 | info->ssi_signal = ssi_signal; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 746 | |
| 747 | if (iface->num_sta_seen >= iface->conf->track_sta_max_num) { |
| 748 | /* Expire oldest entry to make room for a new one */ |
| 749 | sta_track_expire(iface, 1); |
| 750 | } |
| 751 | |
| 752 | wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for " |
| 753 | MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr)); |
| 754 | dl_list_add_tail(&iface->sta_seen, &info->list); |
| 755 | iface->num_sta_seen++; |
| 756 | } |
| 757 | |
| 758 | |
| 759 | struct hostapd_data * |
| 760 | sta_track_seen_on(struct hostapd_iface *iface, const u8 *addr, |
| 761 | const char *ifname) |
| 762 | { |
| 763 | struct hapd_interfaces *interfaces = iface->interfaces; |
| 764 | size_t i, j; |
| 765 | |
| 766 | for (i = 0; i < interfaces->count; i++) { |
| 767 | struct hostapd_data *hapd = NULL; |
| 768 | |
| 769 | iface = interfaces->iface[i]; |
| 770 | for (j = 0; j < iface->num_bss; j++) { |
| 771 | hapd = iface->bss[j]; |
| 772 | if (os_strcmp(ifname, hapd->conf->iface) == 0) |
| 773 | break; |
| 774 | hapd = NULL; |
| 775 | } |
| 776 | |
| 777 | if (hapd && sta_track_get(iface, addr)) |
| 778 | return hapd; |
| 779 | } |
| 780 | |
| 781 | return NULL; |
| 782 | } |
| 783 | |
| 784 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 785 | #ifdef CONFIG_TAXONOMY |
| 786 | void sta_track_claim_taxonomy_info(struct hostapd_iface *iface, const u8 *addr, |
| 787 | struct wpabuf **probe_ie_taxonomy) |
| 788 | { |
| 789 | struct hostapd_sta_info *info; |
| 790 | |
| 791 | info = sta_track_get(iface, addr); |
| 792 | if (!info) |
| 793 | return; |
| 794 | |
| 795 | wpabuf_free(*probe_ie_taxonomy); |
| 796 | *probe_ie_taxonomy = info->probe_ie_taxonomy; |
| 797 | info->probe_ie_taxonomy = NULL; |
| 798 | } |
| 799 | #endif /* CONFIG_TAXONOMY */ |
| 800 | |
| 801 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 802 | void handle_probe_req(struct hostapd_data *hapd, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 803 | const struct ieee80211_mgmt *mgmt, size_t len, |
| 804 | int ssi_signal) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 805 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 806 | u8 *resp; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 807 | struct ieee802_11_elems elems; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 808 | const u8 *ie; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 809 | size_t ie_len; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 810 | size_t i, resp_len; |
| 811 | int noack; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 812 | enum ssid_match_result res; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 813 | int ret; |
| 814 | u16 csa_offs[2]; |
| 815 | size_t csa_offs_len; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 816 | struct radius_sta rad_info; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 817 | |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 818 | if (len < IEEE80211_HDRLEN) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 819 | return; |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 820 | ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 821 | if (hapd->iconf->track_sta_max_num) |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 822 | sta_track_add(hapd->iface, mgmt->sa, ssi_signal); |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 823 | ie_len = len - IEEE80211_HDRLEN; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 824 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 825 | ret = hostapd_allowed_address(hapd, mgmt->sa, (const u8 *) mgmt, len, |
| 826 | &rad_info, 1); |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 827 | if (ret == HOSTAPD_ACL_REJECT) { |
| 828 | wpa_msg(hapd->msg_ctx, MSG_DEBUG, |
| 829 | "Ignore Probe Request frame from " MACSTR |
| 830 | " due to ACL reject ", MAC2STR(mgmt->sa)); |
| 831 | return; |
| 832 | } |
| 833 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 834 | for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++) |
| 835 | if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 836 | mgmt->sa, mgmt->da, mgmt->bssid, |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 837 | ie, ie_len, ssi_signal) > 0) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 838 | return; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 839 | |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 840 | if (!hapd->conf->send_probe_response) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 841 | return; |
| 842 | |
| 843 | if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) { |
| 844 | wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR, |
| 845 | MAC2STR(mgmt->sa)); |
| 846 | return; |
| 847 | } |
| 848 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 849 | if ((!elems.ssid || !elems.supp_rates)) { |
| 850 | wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request " |
| 851 | "without SSID or supported rates element", |
| 852 | MAC2STR(mgmt->sa)); |
| 853 | return; |
| 854 | } |
| 855 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 856 | /* |
| 857 | * No need to reply if the Probe Request frame was sent on an adjacent |
| 858 | * channel. IEEE Std 802.11-2012 describes this as a requirement for an |
| 859 | * AP with dot11RadioMeasurementActivated set to true, but strictly |
| 860 | * speaking does not allow such ignoring of Probe Request frames if |
| 861 | * dot11RadioMeasurementActivated is false. Anyway, this can help reduce |
| 862 | * number of unnecessary Probe Response frames for cases where the STA |
| 863 | * is less likely to see them (Probe Request frame sent on a |
| 864 | * neighboring, but partially overlapping, channel). |
| 865 | */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 866 | if (elems.ds_params && |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 867 | hapd->iface->current_mode && |
| 868 | (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G || |
| 869 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) && |
| 870 | hapd->iconf->channel != elems.ds_params[0]) { |
| 871 | wpa_printf(MSG_DEBUG, |
| 872 | "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u", |
| 873 | hapd->iconf->channel, elems.ds_params[0]); |
| 874 | return; |
| 875 | } |
| 876 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 877 | #ifdef CONFIG_P2P |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 878 | if (hapd->p2p && hapd->p2p_group && elems.wps_ie) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 879 | struct wpabuf *wps; |
| 880 | wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA); |
| 881 | if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) { |
| 882 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 883 | "due to mismatch with Requested Device " |
| 884 | "Type"); |
| 885 | wpabuf_free(wps); |
| 886 | return; |
| 887 | } |
| 888 | wpabuf_free(wps); |
| 889 | } |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 890 | |
Dmitry Shmidt | de47be7 | 2016-01-07 12:52:55 -0800 | [diff] [blame] | 891 | if (hapd->p2p && hapd->p2p_group && elems.p2p) { |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 892 | struct wpabuf *p2p; |
| 893 | p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE); |
| 894 | if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) { |
| 895 | wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request " |
| 896 | "due to mismatch with Device ID"); |
| 897 | wpabuf_free(p2p); |
| 898 | return; |
| 899 | } |
| 900 | wpabuf_free(p2p); |
| 901 | } |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 902 | #endif /* CONFIG_P2P */ |
| 903 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 904 | if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 && |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 905 | elems.ssid_list_len == 0 && elems.short_ssid_list_len == 0) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 906 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 907 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 908 | return; |
| 909 | } |
| 910 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 911 | #ifdef CONFIG_P2P |
| 912 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 913 | elems.ssid_len == P2P_WILDCARD_SSID_LEN && |
| 914 | os_memcmp(elems.ssid, P2P_WILDCARD_SSID, |
| 915 | P2P_WILDCARD_SSID_LEN) == 0) { |
| 916 | /* Process P2P Wildcard SSID like Wildcard SSID */ |
| 917 | elems.ssid_len = 0; |
| 918 | } |
| 919 | #endif /* CONFIG_P2P */ |
| 920 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 921 | #ifdef CONFIG_TAXONOMY |
| 922 | { |
| 923 | struct sta_info *sta; |
| 924 | struct hostapd_sta_info *info; |
| 925 | |
| 926 | if ((sta = ap_get_sta(hapd, mgmt->sa)) != NULL) { |
| 927 | taxonomy_sta_info_probe_req(hapd, sta, ie, ie_len); |
| 928 | } else if ((info = sta_track_get(hapd->iface, |
| 929 | mgmt->sa)) != NULL) { |
| 930 | taxonomy_hostapd_sta_info_probe_req(hapd, info, |
| 931 | ie, ie_len); |
| 932 | } |
| 933 | } |
| 934 | #endif /* CONFIG_TAXONOMY */ |
| 935 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 936 | res = ssid_match(hapd, elems.ssid, elems.ssid_len, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 937 | elems.ssid_list, elems.ssid_list_len, |
| 938 | elems.short_ssid_list, elems.short_ssid_list_len); |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 939 | if (res == NO_SSID_MATCH) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 940 | if (!(mgmt->da[0] & 0x01)) { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 941 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 942 | " for foreign SSID '%s' (DA " MACSTR ")%s", |
Dmitry Shmidt | 3c47937 | 2014-02-04 10:50:36 -0800 | [diff] [blame] | 943 | MAC2STR(mgmt->sa), |
| 944 | wpa_ssid_txt(elems.ssid, elems.ssid_len), |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 945 | MAC2STR(mgmt->da), |
| 946 | elems.ssid_list ? " (SSID list)" : ""); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 947 | } |
| 948 | return; |
| 949 | } |
| 950 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 951 | if (hapd->conf->ignore_broadcast_ssid && res == WILDCARD_SSID_MATCH) { |
| 952 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for " |
| 953 | "broadcast SSID ignored", MAC2STR(mgmt->sa)); |
| 954 | return; |
| 955 | } |
| 956 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 957 | #ifdef CONFIG_INTERWORKING |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 958 | if (hapd->conf->interworking && |
| 959 | elems.interworking && elems.interworking_len >= 1) { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 960 | u8 ant = elems.interworking[0] & 0x0f; |
| 961 | if (ant != INTERWORKING_ANT_WILDCARD && |
| 962 | ant != hapd->conf->access_network_type) { |
| 963 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 964 | " for mismatching ANT %u ignored", |
| 965 | MAC2STR(mgmt->sa), ant); |
| 966 | return; |
| 967 | } |
| 968 | } |
| 969 | |
Dmitry Shmidt | f9bdef9 | 2014-04-25 10:46:36 -0700 | [diff] [blame] | 970 | if (hapd->conf->interworking && elems.interworking && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 971 | (elems.interworking_len == 7 || elems.interworking_len == 9)) { |
| 972 | const u8 *hessid; |
| 973 | if (elems.interworking_len == 7) |
| 974 | hessid = elems.interworking + 1; |
| 975 | else |
| 976 | hessid = elems.interworking + 1 + 2; |
| 977 | if (!is_broadcast_ether_addr(hessid) && |
| 978 | os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) { |
| 979 | wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR |
| 980 | " for mismatching HESSID " MACSTR |
| 981 | " ignored", |
| 982 | MAC2STR(mgmt->sa), MAC2STR(hessid)); |
| 983 | return; |
| 984 | } |
| 985 | } |
| 986 | #endif /* CONFIG_INTERWORKING */ |
| 987 | |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 988 | #ifdef CONFIG_P2P |
| 989 | if ((hapd->conf->p2p & P2P_GROUP_OWNER) && |
| 990 | supp_rates_11b_only(&elems)) { |
| 991 | /* Indicates support for 11b rates only */ |
| 992 | wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from " |
| 993 | MACSTR " with only 802.11b rates", |
| 994 | MAC2STR(mgmt->sa)); |
| 995 | return; |
| 996 | } |
| 997 | #endif /* CONFIG_P2P */ |
| 998 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 999 | /* TODO: verify that supp_rates contains at least one matching rate |
| 1000 | * with AP configuration */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1001 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1002 | if (hapd->conf->no_probe_resp_if_seen_on && |
| 1003 | is_multicast_ether_addr(mgmt->da) && |
| 1004 | is_multicast_ether_addr(mgmt->bssid) && |
| 1005 | sta_track_seen_on(hapd->iface, mgmt->sa, |
| 1006 | hapd->conf->no_probe_resp_if_seen_on)) { |
| 1007 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1008 | " since STA has been seen on %s", |
| 1009 | hapd->conf->iface, MAC2STR(mgmt->sa), |
| 1010 | hapd->conf->no_probe_resp_if_seen_on); |
| 1011 | return; |
| 1012 | } |
| 1013 | |
| 1014 | if (hapd->conf->no_probe_resp_if_max_sta && |
| 1015 | is_multicast_ether_addr(mgmt->da) && |
| 1016 | is_multicast_ether_addr(mgmt->bssid) && |
| 1017 | hapd->num_sta >= hapd->conf->max_num_sta && |
| 1018 | !ap_get_sta(hapd, mgmt->sa)) { |
| 1019 | wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR |
| 1020 | " since no room for additional STA", |
| 1021 | hapd->conf->iface, MAC2STR(mgmt->sa)); |
| 1022 | return; |
| 1023 | } |
| 1024 | |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1025 | #ifdef CONFIG_TESTING_OPTIONS |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1026 | if (hapd->iconf->ignore_probe_probability > 0.0 && |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 1027 | drand48() < hapd->iconf->ignore_probe_probability) { |
| 1028 | wpa_printf(MSG_INFO, |
| 1029 | "TESTING: ignoring probe request from " MACSTR, |
| 1030 | MAC2STR(mgmt->sa)); |
| 1031 | return; |
| 1032 | } |
| 1033 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 1034 | |
Roshan Pius | 3a1667e | 2018-07-03 15:17:14 -0700 | [diff] [blame] | 1035 | wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, RX_PROBE_REQUEST "sa=" MACSTR |
| 1036 | " signal=%d", MAC2STR(mgmt->sa), ssi_signal); |
| 1037 | |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1038 | resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL, |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1039 | &resp_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1040 | if (resp == NULL) |
| 1041 | return; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1042 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1043 | /* |
| 1044 | * If this is a broadcast probe request, apply no ack policy to avoid |
| 1045 | * excessive retries. |
| 1046 | */ |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 1047 | noack = !!(res == WILDCARD_SSID_MATCH && |
| 1048 | is_broadcast_ether_addr(mgmt->da)); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1049 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1050 | csa_offs_len = 0; |
| 1051 | if (hapd->csa_in_progress) { |
| 1052 | if (hapd->cs_c_off_proberesp) |
| 1053 | csa_offs[csa_offs_len++] = |
| 1054 | hapd->cs_c_off_proberesp; |
| 1055 | |
| 1056 | if (hapd->cs_c_off_ecsa_proberesp) |
| 1057 | csa_offs[csa_offs_len++] = |
| 1058 | hapd->cs_c_off_ecsa_proberesp; |
| 1059 | } |
| 1060 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1061 | ret = hostapd_drv_send_mlme(hapd, resp, resp_len, noack, |
| 1062 | csa_offs_len ? csa_offs : NULL, |
| 1063 | csa_offs_len, 0); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1064 | |
| 1065 | if (ret < 0) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1066 | wpa_printf(MSG_INFO, "handle_probe_req: send failed"); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1067 | |
| 1068 | os_free(resp); |
| 1069 | |
| 1070 | wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s " |
| 1071 | "SSID", MAC2STR(mgmt->sa), |
| 1072 | elems.ssid_len == 0 ? "broadcast" : "our"); |
| 1073 | } |
| 1074 | |
| 1075 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1076 | static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd, |
| 1077 | size_t *resp_len) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1078 | { |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1079 | /* check probe response offloading caps and print warnings */ |
| 1080 | if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD)) |
| 1081 | return NULL; |
| 1082 | |
| 1083 | #ifdef CONFIG_WPS |
| 1084 | if (hapd->conf->wps_state && hapd->wps_probe_resp_ie && |
| 1085 | (!(hapd->iface->probe_resp_offloads & |
| 1086 | (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS | |
| 1087 | WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2)))) |
| 1088 | wpa_printf(MSG_WARNING, "Device is trying to offload WPS " |
| 1089 | "Probe Response while not supporting this"); |
| 1090 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1091 | |
| 1092 | #ifdef CONFIG_P2P |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1093 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie && |
| 1094 | !(hapd->iface->probe_resp_offloads & |
| 1095 | WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P)) |
| 1096 | wpa_printf(MSG_WARNING, "Device is trying to offload P2P " |
| 1097 | "Probe Response while not supporting this"); |
| 1098 | #endif /* CONFIG_P2P */ |
| 1099 | |
| 1100 | if (hapd->conf->interworking && |
| 1101 | !(hapd->iface->probe_resp_offloads & |
| 1102 | WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING)) |
| 1103 | wpa_printf(MSG_WARNING, "Device is trying to offload " |
| 1104 | "Interworking Probe Response while not supporting " |
| 1105 | "this"); |
| 1106 | |
| 1107 | /* Generate a Probe Response template for the non-P2P case */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1108 | return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | #endif /* NEED_AP_MLME */ |
| 1112 | |
| 1113 | |
Dmitry Shmidt | aca489e | 2016-09-28 15:44:14 -0700 | [diff] [blame] | 1114 | void sta_track_del(struct hostapd_sta_info *info) |
| 1115 | { |
| 1116 | #ifdef CONFIG_TAXONOMY |
| 1117 | wpabuf_free(info->probe_ie_taxonomy); |
| 1118 | info->probe_ie_taxonomy = NULL; |
| 1119 | #endif /* CONFIG_TAXONOMY */ |
| 1120 | os_free(info); |
| 1121 | } |
| 1122 | |
| 1123 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1124 | int ieee802_11_build_ap_params(struct hostapd_data *hapd, |
| 1125 | struct wpa_driver_ap_params *params) |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1126 | { |
| 1127 | struct ieee80211_mgmt *head = NULL; |
| 1128 | u8 *tail = NULL; |
| 1129 | size_t head_len = 0, tail_len = 0; |
| 1130 | u8 *resp = NULL; |
| 1131 | size_t resp_len = 0; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1132 | #ifdef NEED_AP_MLME |
| 1133 | u16 capab_info; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1134 | u8 *pos, *tailpos, *tailend, *csa_pos; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1135 | |
| 1136 | #define BEACON_HEAD_BUF_SIZE 256 |
| 1137 | #define BEACON_TAIL_BUF_SIZE 512 |
| 1138 | head = os_zalloc(BEACON_HEAD_BUF_SIZE); |
| 1139 | tail_len = BEACON_TAIL_BUF_SIZE; |
| 1140 | #ifdef CONFIG_WPS |
| 1141 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) |
| 1142 | tail_len += wpabuf_len(hapd->wps_beacon_ie); |
| 1143 | #endif /* CONFIG_WPS */ |
| 1144 | #ifdef CONFIG_P2P |
| 1145 | if (hapd->p2p_beacon_ie) |
| 1146 | tail_len += wpabuf_len(hapd->p2p_beacon_ie); |
| 1147 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1148 | #ifdef CONFIG_FST |
| 1149 | if (hapd->iface->fst_ies) |
| 1150 | tail_len += wpabuf_len(hapd->iface->fst_ies); |
| 1151 | #endif /* CONFIG_FST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1152 | if (hapd->conf->vendor_elements) |
| 1153 | tail_len += wpabuf_len(hapd->conf->vendor_elements); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1154 | |
| 1155 | #ifdef CONFIG_IEEE80211AC |
| 1156 | if (hapd->conf->vendor_vht) { |
| 1157 | tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) + |
| 1158 | 2 + sizeof(struct ieee80211_vht_operation); |
| 1159 | } |
| 1160 | #endif /* CONFIG_IEEE80211AC */ |
| 1161 | |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1162 | #ifdef CONFIG_IEEE80211AX |
| 1163 | if (hapd->iconf->ieee80211ax) { |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1164 | tail_len += 3 + sizeof(struct ieee80211_he_capabilities) + |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1165 | 3 + sizeof(struct ieee80211_he_operation) + |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1166 | 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set) + |
| 1167 | 3 + sizeof(struct ieee80211_spatial_reuse); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame^] | 1168 | if (is_6ghz_op_class(hapd->iconf->op_class)) |
| 1169 | tail_len += sizeof(struct ieee80211_he_6ghz_oper_info) + |
| 1170 | 3 + sizeof(struct ieee80211_he_6ghz_band_cap); |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1171 | } |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1172 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 1173 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1174 | tail_len += hostapd_mbo_ie_len(hapd); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1175 | tail_len += hostapd_eid_owe_trans_len(hapd); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1176 | tail_len += hostapd_eid_dpp_cc_len(hapd); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1177 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1178 | tailpos = tail = os_malloc(tail_len); |
| 1179 | if (head == NULL || tail == NULL) { |
| 1180 | wpa_printf(MSG_ERROR, "Failed to set beacon data"); |
| 1181 | os_free(head); |
| 1182 | os_free(tail); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1183 | return -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1184 | } |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1185 | tailend = tail + tail_len; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1186 | |
| 1187 | head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT, |
| 1188 | WLAN_FC_STYPE_BEACON); |
| 1189 | head->duration = host_to_le16(0); |
| 1190 | os_memset(head->da, 0xff, ETH_ALEN); |
| 1191 | |
| 1192 | os_memcpy(head->sa, hapd->own_addr, ETH_ALEN); |
| 1193 | os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN); |
| 1194 | head->u.beacon.beacon_int = |
| 1195 | host_to_le16(hapd->iconf->beacon_int); |
| 1196 | |
| 1197 | /* hardware or low-level driver will setup seq_ctrl and timestamp */ |
Dmitry Shmidt | 9d9e602 | 2015-04-23 10:34:55 -0700 | [diff] [blame] | 1198 | capab_info = hostapd_own_capab_info(hapd); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1199 | head->u.beacon.capab_info = host_to_le16(capab_info); |
| 1200 | pos = &head->u.beacon.variable[0]; |
| 1201 | |
| 1202 | /* SSID */ |
| 1203 | *pos++ = WLAN_EID_SSID; |
| 1204 | if (hapd->conf->ignore_broadcast_ssid == 2) { |
| 1205 | /* clear the data, but keep the correct length of the SSID */ |
| 1206 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1207 | os_memset(pos, 0, hapd->conf->ssid.ssid_len); |
| 1208 | pos += hapd->conf->ssid.ssid_len; |
| 1209 | } else if (hapd->conf->ignore_broadcast_ssid) { |
| 1210 | *pos++ = 0; /* empty SSID */ |
| 1211 | } else { |
| 1212 | *pos++ = hapd->conf->ssid.ssid_len; |
| 1213 | os_memcpy(pos, hapd->conf->ssid.ssid, |
| 1214 | hapd->conf->ssid.ssid_len); |
| 1215 | pos += hapd->conf->ssid.ssid_len; |
| 1216 | } |
| 1217 | |
| 1218 | /* Supported rates */ |
| 1219 | pos = hostapd_eid_supp_rates(hapd, pos); |
| 1220 | |
| 1221 | /* DS Params */ |
| 1222 | pos = hostapd_eid_ds_params(hapd, pos); |
| 1223 | |
| 1224 | head_len = pos - (u8 *) head; |
| 1225 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1226 | tailpos = hostapd_eid_country(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1227 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1228 | /* Power Constraint element */ |
| 1229 | tailpos = hostapd_eid_pwr_constraint(hapd, tailpos); |
| 1230 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1231 | /* CSA IE */ |
| 1232 | csa_pos = hostapd_eid_csa(hapd, tailpos); |
| 1233 | if (csa_pos != tailpos) |
| 1234 | hapd->cs_c_off_beacon = csa_pos - tail - 1; |
| 1235 | tailpos = csa_pos; |
| 1236 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1237 | /* ERP Information element */ |
| 1238 | tailpos = hostapd_eid_erp_info(hapd, tailpos); |
| 1239 | |
| 1240 | /* Extended supported rates */ |
| 1241 | tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos); |
| 1242 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1243 | tailpos = hostapd_get_rsne(hapd, tailpos, tailend - tailpos); |
| 1244 | tailpos = hostapd_eid_bss_load(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1245 | tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos, |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1246 | tailend - tailpos); |
| 1247 | tailpos = hostapd_get_mde(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 051af73 | 2013-10-22 13:52:46 -0700 | [diff] [blame] | 1248 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1249 | /* eCSA IE */ |
| 1250 | csa_pos = hostapd_eid_ecsa(hapd, tailpos); |
| 1251 | if (csa_pos != tailpos) |
| 1252 | hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1; |
| 1253 | tailpos = csa_pos; |
| 1254 | |
| 1255 | tailpos = hostapd_eid_supported_op_classes(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1256 | tailpos = hostapd_eid_ht_capabilities(hapd, tailpos); |
| 1257 | tailpos = hostapd_eid_ht_operation(hapd, tailpos); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1258 | |
| 1259 | tailpos = hostapd_eid_ext_capab(hapd, tailpos); |
| 1260 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1261 | /* |
| 1262 | * TODO: Time Advertisement element should only be included in some |
| 1263 | * DTIM Beacon frames. |
| 1264 | */ |
| 1265 | tailpos = hostapd_eid_time_adv(hapd, tailpos); |
| 1266 | |
| 1267 | tailpos = hostapd_eid_interworking(hapd, tailpos); |
| 1268 | tailpos = hostapd_eid_adv_proto(hapd, tailpos); |
| 1269 | tailpos = hostapd_eid_roaming_consortium(hapd, tailpos); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1270 | |
| 1271 | #ifdef CONFIG_FST |
| 1272 | if (hapd->iface->fst_ies) { |
| 1273 | os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies), |
| 1274 | wpabuf_len(hapd->iface->fst_ies)); |
| 1275 | tailpos += wpabuf_len(hapd->iface->fst_ies); |
| 1276 | } |
| 1277 | #endif /* CONFIG_FST */ |
| 1278 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1279 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1280 | if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) { |
Dmitry Shmidt | 7d17530 | 2016-09-06 13:11:34 -0700 | [diff] [blame] | 1281 | tailpos = hostapd_eid_vht_capabilities(hapd, tailpos, 0); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1282 | tailpos = hostapd_eid_vht_operation(hapd, tailpos); |
Dmitry Shmidt | d7ff03d | 2015-12-04 14:49:35 -0800 | [diff] [blame] | 1283 | tailpos = hostapd_eid_txpower_envelope(hapd, tailpos); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1284 | tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos); |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1285 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1286 | #endif /* CONFIG_IEEE80211AC */ |
| 1287 | |
| 1288 | tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1289 | tailpos = hostapd_get_rsnxe(hapd, tailpos, tailend - tailpos); |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1290 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1291 | #ifdef CONFIG_IEEE80211AX |
| 1292 | if (hapd->iconf->ieee80211ax) { |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1293 | tailpos = hostapd_eid_he_capab(hapd, tailpos, |
| 1294 | IEEE80211_MODE_AP); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1295 | tailpos = hostapd_eid_he_operation(hapd, tailpos); |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1296 | tailpos = hostapd_eid_spatial_reuse(hapd, tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1297 | tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos); |
Hai Shalom | 4fbc08f | 2020-05-18 12:37:00 -0700 | [diff] [blame^] | 1298 | tailpos = hostapd_eid_he_6ghz_band_cap(hapd, tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1299 | } |
| 1300 | #endif /* CONFIG_IEEE80211AX */ |
| 1301 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 1302 | #ifdef CONFIG_IEEE80211AC |
Dmitry Shmidt | 2f74e36 | 2015-01-21 13:19:05 -0800 | [diff] [blame] | 1303 | if (hapd->conf->vendor_vht) |
| 1304 | tailpos = hostapd_eid_vendor_vht(hapd, tailpos); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1305 | #endif /* CONFIG_IEEE80211AC */ |
| 1306 | |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1307 | /* WPA / OSEN */ |
| 1308 | tailpos = hostapd_get_wpa_ie(hapd, tailpos, tailend - tailpos); |
| 1309 | tailpos = hostapd_get_osen_ie(hapd, tailpos, tailend - tailpos); |
Hai Shalom | 39ba6fc | 2019-01-22 12:40:38 -0800 | [diff] [blame] | 1310 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1311 | /* Wi-Fi Alliance WMM */ |
| 1312 | tailpos = hostapd_eid_wmm(hapd, tailpos); |
| 1313 | |
| 1314 | #ifdef CONFIG_WPS |
| 1315 | if (hapd->conf->wps_state && hapd->wps_beacon_ie) { |
| 1316 | os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie), |
| 1317 | wpabuf_len(hapd->wps_beacon_ie)); |
| 1318 | tailpos += wpabuf_len(hapd->wps_beacon_ie); |
| 1319 | } |
| 1320 | #endif /* CONFIG_WPS */ |
| 1321 | |
| 1322 | #ifdef CONFIG_P2P |
| 1323 | if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) { |
| 1324 | os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie), |
| 1325 | wpabuf_len(hapd->p2p_beacon_ie)); |
| 1326 | tailpos += wpabuf_len(hapd->p2p_beacon_ie); |
| 1327 | } |
| 1328 | #endif /* CONFIG_P2P */ |
| 1329 | #ifdef CONFIG_P2P_MANAGER |
| 1330 | if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) == |
| 1331 | P2P_MANAGE) |
| 1332 | tailpos = hostapd_eid_p2p_manage(hapd, tailpos); |
| 1333 | #endif /* CONFIG_P2P_MANAGER */ |
| 1334 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1335 | #ifdef CONFIG_HS20 |
| 1336 | tailpos = hostapd_eid_hs20_indication(hapd, tailpos); |
| 1337 | #endif /* CONFIG_HS20 */ |
| 1338 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1339 | tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame] | 1340 | tailpos = hostapd_eid_owe_trans(hapd, tailpos, |
| 1341 | tail + tail_len - tailpos); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1342 | tailpos = hostapd_eid_dpp_cc(hapd, tailpos, tail + tail_len - tailpos); |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1343 | |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1344 | if (hapd->conf->vendor_elements) { |
| 1345 | os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements), |
| 1346 | wpabuf_len(hapd->conf->vendor_elements)); |
| 1347 | tailpos += wpabuf_len(hapd->conf->vendor_elements); |
| 1348 | } |
| 1349 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1350 | tail_len = tailpos > tail ? tailpos - tail : 0; |
| 1351 | |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1352 | resp = hostapd_probe_resp_offloads(hapd, &resp_len); |
| 1353 | #endif /* NEED_AP_MLME */ |
| 1354 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1355 | os_memset(params, 0, sizeof(*params)); |
| 1356 | params->head = (u8 *) head; |
| 1357 | params->head_len = head_len; |
| 1358 | params->tail = tail; |
| 1359 | params->tail_len = tail_len; |
| 1360 | params->proberesp = resp; |
| 1361 | params->proberesp_len = resp_len; |
| 1362 | params->dtim_period = hapd->conf->dtim_period; |
| 1363 | params->beacon_int = hapd->iconf->beacon_int; |
| 1364 | params->basic_rates = hapd->iface->basic_rates; |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 1365 | params->beacon_rate = hapd->iconf->beacon_rate; |
| 1366 | params->rate_type = hapd->iconf->rate_type; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1367 | params->ssid = hapd->conf->ssid.ssid; |
| 1368 | params->ssid_len = hapd->conf->ssid.ssid_len; |
Dmitry Shmidt | 7a53dbb | 2015-06-11 13:13:53 -0700 | [diff] [blame] | 1369 | if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) == |
| 1370 | (WPA_PROTO_WPA | WPA_PROTO_RSN)) |
| 1371 | params->pairwise_ciphers = hapd->conf->wpa_pairwise | |
| 1372 | hapd->conf->rsn_pairwise; |
| 1373 | else if (hapd->conf->wpa & WPA_PROTO_RSN) |
| 1374 | params->pairwise_ciphers = hapd->conf->rsn_pairwise; |
| 1375 | else if (hapd->conf->wpa & WPA_PROTO_WPA) |
| 1376 | params->pairwise_ciphers = hapd->conf->wpa_pairwise; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1377 | params->group_cipher = hapd->conf->wpa_group; |
| 1378 | params->key_mgmt_suites = hapd->conf->wpa_key_mgmt; |
| 1379 | params->auth_algs = hapd->conf->auth_algs; |
| 1380 | params->wpa_version = hapd->conf->wpa; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1381 | params->privacy = hapd->conf->wpa; |
| 1382 | #ifdef CONFIG_WEP |
| 1383 | params->privacy |= hapd->conf->ssid.wep.keys_set || |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1384 | (hapd->conf->ieee802_1x && |
| 1385 | (hapd->conf->default_wep_key_len || |
| 1386 | hapd->conf->individual_wep_key_len)); |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1387 | #endif /* CONFIG_WEP */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1388 | switch (hapd->conf->ignore_broadcast_ssid) { |
| 1389 | case 0: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1390 | params->hide_ssid = NO_SSID_HIDING; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1391 | break; |
| 1392 | case 1: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1393 | params->hide_ssid = HIDDEN_SSID_ZERO_LEN; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1394 | break; |
| 1395 | case 2: |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1396 | params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1397 | break; |
| 1398 | } |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1399 | params->isolate = hapd->conf->isolate; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1400 | #ifdef NEED_AP_MLME |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1401 | params->cts_protect = !!(ieee802_11_erp_info(hapd) & |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1402 | ERP_INFO_USE_PROTECTION); |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1403 | params->preamble = hapd->iface->num_sta_no_short_preamble == 0 && |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1404 | hapd->iconf->preamble == SHORT_PREAMBLE; |
| 1405 | if (hapd->iface->current_mode && |
| 1406 | hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1407 | params->short_slot_time = |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1408 | hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1; |
| 1409 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1410 | params->short_slot_time = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1411 | if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1412 | params->ht_opmode = -1; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1413 | else |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1414 | params->ht_opmode = hapd->iface->ht_op_mode; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1415 | #endif /* NEED_AP_MLME */ |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1416 | params->interworking = hapd->conf->interworking; |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1417 | if (hapd->conf->interworking && |
| 1418 | !is_zero_ether_addr(hapd->conf->hessid)) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1419 | params->hessid = hapd->conf->hessid; |
| 1420 | params->access_network_type = hapd->conf->access_network_type; |
| 1421 | params->ap_max_inactivity = hapd->conf->ap_max_inactivity; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1422 | #ifdef CONFIG_P2P |
| 1423 | params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow; |
| 1424 | #endif /* CONFIG_P2P */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1425 | #ifdef CONFIG_HS20 |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1426 | params->disable_dgaf = hapd->conf->disable_dgaf; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1427 | if (hapd->conf->osen) { |
| 1428 | params->privacy = 1; |
| 1429 | params->osen = 1; |
| 1430 | } |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 1431 | #endif /* CONFIG_HS20 */ |
Dmitry Shmidt | abb90a3 | 2016-12-05 15:34:39 -0800 | [diff] [blame] | 1432 | params->multicast_to_unicast = hapd->conf->multicast_to_unicast; |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 1433 | params->pbss = hapd->conf->pbss; |
Hai Shalom | 74f70d4 | 2019-02-11 14:42:39 -0800 | [diff] [blame] | 1434 | |
| 1435 | if (hapd->conf->ftm_responder) { |
| 1436 | if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_FTM_RESPONDER) { |
| 1437 | params->ftm_responder = 1; |
| 1438 | params->lci = hapd->iface->conf->lci; |
| 1439 | params->civic = hapd->iface->conf->civic; |
| 1440 | } else { |
| 1441 | wpa_printf(MSG_WARNING, |
| 1442 | "Not configuring FTM responder as the driver doesn't advertise support for it"); |
| 1443 | } |
| 1444 | } |
| 1445 | |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1446 | return 0; |
| 1447 | } |
| 1448 | |
| 1449 | |
| 1450 | void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params) |
| 1451 | { |
| 1452 | os_free(params->tail); |
| 1453 | params->tail = NULL; |
| 1454 | os_free(params->head); |
| 1455 | params->head = NULL; |
| 1456 | os_free(params->proberesp); |
| 1457 | params->proberesp = NULL; |
| 1458 | } |
| 1459 | |
| 1460 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1461 | int ieee802_11_set_beacon(struct hostapd_data *hapd) |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1462 | { |
| 1463 | struct wpa_driver_ap_params params; |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1464 | struct hostapd_freq_params freq; |
| 1465 | struct hostapd_iface *iface = hapd->iface; |
| 1466 | struct hostapd_config *iconf = iface->conf; |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1467 | struct hostapd_hw_modes *cmode = iface->current_mode; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1468 | struct wpabuf *beacon, *proberesp, *assocresp; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1469 | int res, ret = -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1470 | |
Dmitry Shmidt | d30ac60 | 2014-06-30 09:54:22 -0700 | [diff] [blame] | 1471 | if (hapd->csa_in_progress) { |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1472 | wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period"); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1473 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1474 | } |
| 1475 | |
| 1476 | hapd->beacon_set_done = 1; |
| 1477 | |
| 1478 | if (ieee802_11_build_ap_params(hapd, ¶ms) < 0) |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1479 | return -1; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1480 | |
| 1481 | if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) < |
| 1482 | 0) |
| 1483 | goto fail; |
| 1484 | |
| 1485 | params.beacon_ies = beacon; |
| 1486 | params.proberesp_ies = proberesp; |
| 1487 | params.assocresp_ies = assocresp; |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1488 | params.reenable = hapd->reenable_beacon; |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1489 | #ifdef CONFIG_IEEE80211AX |
| 1490 | params.he_spr = !!hapd->iface->conf->spr.sr_control; |
| 1491 | params.he_spr_srg_obss_pd_min_offset = |
| 1492 | hapd->iface->conf->spr.srg_obss_pd_min_offset; |
| 1493 | params.he_spr_srg_obss_pd_max_offset = |
| 1494 | hapd->iface->conf->spr.srg_obss_pd_max_offset; |
Hai Shalom | fdcde76 | 2020-04-02 11:19:20 -0700 | [diff] [blame] | 1495 | params.he_bss_color_disabled = |
| 1496 | hapd->iface->conf->he_op.he_bss_color_disabled; |
| 1497 | params.he_bss_color_partial = |
| 1498 | hapd->iface->conf->he_op.he_bss_color_partial; |
| 1499 | params.he_bss_color = hapd->iface->conf->he_op.he_bss_color; |
| 1500 | params.twt_responder = hostapd_get_he_twt_responder(hapd, |
| 1501 | IEEE80211_MODE_AP); |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1502 | #endif /* CONFIG_IEEE80211AX */ |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 1503 | hapd->reenable_beacon = 0; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1504 | |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1505 | if (cmode && |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1506 | hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq, |
Hai Shalom | c356592 | 2019-10-28 11:58:20 -0700 | [diff] [blame] | 1507 | iconf->channel, iconf->enable_edmg, |
| 1508 | iconf->edmg_channel, iconf->ieee80211n, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1509 | iconf->ieee80211ac, iconf->ieee80211ax, |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1510 | iconf->secondary_channel, |
Hai Shalom | 81f62d8 | 2019-07-22 12:10:00 -0700 | [diff] [blame] | 1511 | hostapd_get_oper_chwidth(iconf), |
| 1512 | hostapd_get_oper_centr_freq_seg0_idx(iconf), |
| 1513 | hostapd_get_oper_centr_freq_seg1_idx(iconf), |
| 1514 | cmode->vht_capab, |
| 1515 | &cmode->he_capab[IEEE80211_MODE_AP]) == 0) |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 1516 | params.freq = &freq; |
| 1517 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1518 | res = hostapd_drv_set_ap(hapd, ¶ms); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 1519 | hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1520 | if (res) |
| 1521 | wpa_printf(MSG_ERROR, "Failed to set beacon parameters"); |
| 1522 | else |
| 1523 | ret = 0; |
Dmitry Shmidt | e0e48dc | 2013-11-18 12:00:06 -0800 | [diff] [blame] | 1524 | fail: |
| 1525 | ieee802_11_free_ap_params(¶ms); |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1526 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1530 | int ieee802_11_set_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1531 | { |
| 1532 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1533 | int ret = 0; |
| 1534 | |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 1535 | for (i = 0; i < iface->num_bss; i++) { |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1536 | if (iface->bss[i]->started && |
| 1537 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 1538 | ret = -1; |
Dmitry Shmidt | 292b0c3 | 2013-11-22 12:54:42 -0800 | [diff] [blame] | 1539 | } |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1540 | |
| 1541 | return ret; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1542 | } |
| 1543 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1544 | |
| 1545 | /* only update beacons if started */ |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1546 | int ieee802_11_update_beacons(struct hostapd_iface *iface) |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1547 | { |
| 1548 | size_t i; |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 1549 | int ret = 0; |
| 1550 | |
| 1551 | for (i = 0; i < iface->num_bss; i++) { |
| 1552 | if (iface->bss[i]->beacon_set_done && iface->bss[i]->started && |
| 1553 | ieee802_11_set_beacon(iface->bss[i]) < 0) |
| 1554 | ret = -1; |
| 1555 | } |
| 1556 | |
| 1557 | return ret; |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 1558 | } |
| 1559 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1560 | #endif /* CONFIG_NATIVE_WINDOWS */ |