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