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>
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
11 #include "utils/includes.h"
13 #ifndef CONFIG_NATIVE_WINDOWS
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"
23 #include "ieee802_11.h"
26 #include "ap_config.h"
28 #include "p2p_hostapd.h"
29 #include "ap_drv_ops.h"
34 #include "ieee802_11_auth.h"
39 static u8 * hostapd_eid_rm_enabled_capab(struct hostapd_data *hapd, u8 *eid,
44 for (i = 0; i < RRM_CAPABILITIES_IE_LEN; i++) {
45 if (hapd->conf->radio_measurements[i])
49 if (i == RRM_CAPABILITIES_IE_LEN || len < 2 + RRM_CAPABILITIES_IE_LEN)
52 *eid++ = WLAN_EID_RRM_ENABLED_CAPABILITIES;
53 *eid++ = RRM_CAPABILITIES_IE_LEN;
54 os_memcpy(eid, hapd->conf->radio_measurements, RRM_CAPABILITIES_IE_LEN);
56 return eid + RRM_CAPABILITIES_IE_LEN;
60 static u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len)
65 #ifdef CONFIG_TESTING_OPTIONS
66 if (hapd->conf->bss_load_test_set) {
67 *eid++ = WLAN_EID_BSS_LOAD;
69 os_memcpy(eid, hapd->conf->bss_load_test, 5);
73 #endif /* CONFIG_TESTING_OPTIONS */
74 if (hapd->conf->bss_load_update_period) {
75 *eid++ = WLAN_EID_BSS_LOAD;
77 WPA_PUT_LE16(eid, hapd->num_sta);
79 *eid++ = hapd->iface->channel_utilization;
80 WPA_PUT_LE16(eid, 0); /* no available admission capabity */
87 static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
91 if (hapd->iface->current_mode == NULL ||
92 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
95 if (hapd->iface->olbc)
96 erp |= ERP_INFO_USE_PROTECTION;
97 if (hapd->iface->num_sta_non_erp > 0) {
98 erp |= ERP_INFO_NON_ERP_PRESENT |
99 ERP_INFO_USE_PROTECTION;
101 if (hapd->iface->num_sta_no_short_preamble > 0 ||
102 hapd->iconf->preamble == LONG_PREAMBLE)
103 erp |= ERP_INFO_BARKER_PREAMBLE_MODE;
109 static u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid)
111 *eid++ = WLAN_EID_DS_PARAMS;
113 *eid++ = hapd->iconf->channel;
118 static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid)
120 if (hapd->iface->current_mode == NULL ||
121 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
124 /* Set NonERP_present and use_protection bits if there
125 * are any associated NonERP stations. */
126 /* TODO: use_protection bit can be set to zero even if
127 * there are NonERP stations present. This optimization
128 * might be useful if NonERP stations are "quiet".
129 * See 802.11g/D6 E-1 for recommended practice.
130 * In addition, Non ERP present might be set, if AP detects Non ERP
131 * operation on other APs. */
133 /* Add ERP Information element */
134 *eid++ = WLAN_EID_ERP_INFO;
136 *eid++ = ieee802_11_erp_info(hapd);
142 static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid)
145 u8 local_pwr_constraint = 0;
148 if (hapd->iface->current_mode == NULL ||
149 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
152 /* Let host drivers add this IE if DFS support is offloaded */
153 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
157 * There is no DFS support and power constraint was not directly
158 * requested by config option.
160 if (!hapd->iconf->ieee80211h &&
161 hapd->iconf->local_pwr_constraint == -1)
164 /* Check if DFS is required by regulatory. */
165 dfs = hostapd_is_dfs_required(hapd->iface);
167 wpa_printf(MSG_WARNING, "Failed to check if DFS is required; ret=%d",
172 if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1)
176 * ieee80211h (DFS) is enabled so Power Constraint element shall
177 * be added when running on DFS channel whenever local_pwr_constraint
178 * is configured or not. In order to meet regulations when TPC is not
179 * implemented using a transmit power that is below the legal maximum
180 * (including any mitigation factor) should help. In this case,
181 * indicate 3 dB below maximum allowed transmit power.
183 if (hapd->iconf->local_pwr_constraint == -1)
184 local_pwr_constraint = 3;
187 * A STA that is not an AP shall use a transmit power less than or
188 * equal to the local maximum transmit power level for the channel.
189 * The local maximum transmit power can be calculated from the formula:
190 * local max TX pwr = max TX pwr - local pwr constraint
191 * Where max TX pwr is maximum transmit power level specified for
192 * channel in Country element and local pwr constraint is specified
193 * for channel in this Power Constraint element.
197 *pos++ = WLAN_EID_PWR_CONSTRAINT;
200 /* Local Power Constraint */
201 if (local_pwr_constraint)
202 *pos++ = local_pwr_constraint;
204 *pos++ = hapd->iconf->local_pwr_constraint;
210 static u8 * hostapd_eid_country_add(u8 *pos, u8 *end, int chan_spacing,
211 struct hostapd_channel_data *start,
212 struct hostapd_channel_data *prev)
217 /* first channel number */
218 *pos++ = start->chan;
219 /* number of channels */
220 *pos++ = (prev->chan - start->chan) / chan_spacing + 1;
221 /* maximum transmit power level */
222 *pos++ = start->max_tx_power;
228 static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid,
232 u8 *end = eid + max_len;
234 struct hostapd_hw_modes *mode;
235 struct hostapd_channel_data *start, *prev;
236 int chan_spacing = 1;
238 if (!hapd->iconf->ieee80211d || max_len < 6 ||
239 hapd->iface->current_mode == NULL)
242 *pos++ = WLAN_EID_COUNTRY;
243 pos++; /* length will be set later */
244 os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
247 mode = hapd->iface->current_mode;
248 if (mode->mode == HOSTAPD_MODE_IEEE80211A)
252 for (i = 0; i < mode->num_channels; i++) {
253 struct hostapd_channel_data *chan = &mode->channels[i];
254 if (chan->flag & HOSTAPD_CHAN_DISABLED)
257 prev->chan + chan_spacing == chan->chan &&
258 start->max_tx_power == chan->max_tx_power) {
260 continue; /* can use same entry */
264 pos = hostapd_eid_country_add(pos, end, chan_spacing,
269 /* Start new group */
274 pos = hostapd_eid_country_add(pos, end, chan_spacing,
278 if ((pos - eid) & 1) {
281 *pos++ = 0; /* pad for 16-bit alignment */
284 eid[1] = (pos - eid) - 2;
290 static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len)
295 ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen);
296 if (ie == NULL || ielen > len)
299 os_memcpy(eid, ie, ielen);
304 static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid)
306 #ifdef CONFIG_TESTING_OPTIONS
307 if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only)
309 #endif /* CONFIG_TESTING_OPTIONS */
311 if (!hapd->cs_freq_params.channel)
314 *eid++ = WLAN_EID_CHANNEL_SWITCH;
316 *eid++ = hapd->cs_block_tx;
317 *eid++ = hapd->cs_freq_params.channel;
318 *eid++ = hapd->cs_count;
324 static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
326 if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class)
329 *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN;
331 *eid++ = hapd->cs_block_tx;
332 *eid++ = hapd->iface->cs_oper_class;
333 *eid++ = hapd->cs_freq_params.channel;
334 *eid++ = hapd->cs_count;
340 static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
342 u8 op_class, channel;
344 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) ||
348 if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
349 hapd->iconf->secondary_channel,
350 hapd->iconf->vht_oper_chwidth,
351 &op_class, &channel) ==
355 *eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES;
358 /* Current Operating Class */
361 /* TODO: Advertise all the supported operating classes */
368 static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
369 const struct ieee80211_mgmt *req,
370 int is_p2p, size_t *resp_len)
372 struct ieee80211_mgmt *resp;
373 u8 *pos, *epos, *csa_pos;
376 #define MAX_PROBERESP_LEN 768
377 buflen = MAX_PROBERESP_LEN;
379 if (hapd->wps_probe_resp_ie)
380 buflen += wpabuf_len(hapd->wps_probe_resp_ie);
381 #endif /* CONFIG_WPS */
383 if (hapd->p2p_probe_resp_ie)
384 buflen += wpabuf_len(hapd->p2p_probe_resp_ie);
385 #endif /* CONFIG_P2P */
387 if (hapd->iface->fst_ies)
388 buflen += wpabuf_len(hapd->iface->fst_ies);
389 #endif /* CONFIG_FST */
390 if (hapd->conf->vendor_elements)
391 buflen += wpabuf_len(hapd->conf->vendor_elements);
392 if (hapd->conf->vendor_vht) {
393 buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) +
394 2 + sizeof(struct ieee80211_vht_operation);
397 #ifdef CONFIG_IEEE80211AX
398 if (hapd->iconf->ieee80211ax) {
399 buflen += 3 + sizeof(struct ieee80211_he_capabilities) +
400 3 + sizeof(struct ieee80211_he_operation) +
401 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set);
403 #endif /* CONFIG_IEEE80211AX */
405 buflen += hostapd_mbo_ie_len(hapd);
406 buflen += hostapd_eid_owe_trans_len(hapd);
408 resp = os_zalloc(buflen);
412 epos = ((u8 *) resp) + MAX_PROBERESP_LEN;
414 resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
415 WLAN_FC_STYPE_PROBE_RESP);
417 os_memcpy(resp->da, req->sa, ETH_ALEN);
418 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
420 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
421 resp->u.probe_resp.beacon_int =
422 host_to_le16(hapd->iconf->beacon_int);
424 /* hardware or low-level driver will setup seq_ctrl and timestamp */
425 resp->u.probe_resp.capab_info =
426 host_to_le16(hostapd_own_capab_info(hapd));
428 pos = resp->u.probe_resp.variable;
429 *pos++ = WLAN_EID_SSID;
430 *pos++ = hapd->conf->ssid.ssid_len;
431 os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len);
432 pos += hapd->conf->ssid.ssid_len;
434 /* Supported rates */
435 pos = hostapd_eid_supp_rates(hapd, pos);
438 pos = hostapd_eid_ds_params(hapd, pos);
440 pos = hostapd_eid_country(hapd, pos, epos - pos);
442 /* Power Constraint element */
443 pos = hostapd_eid_pwr_constraint(hapd, pos);
446 csa_pos = hostapd_eid_csa(hapd, pos);
448 hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1;
451 /* ERP Information element */
452 pos = hostapd_eid_erp_info(hapd, pos);
454 /* Extended supported rates */
455 pos = hostapd_eid_ext_supp_rates(hapd, pos);
458 if (hapd->conf->wpa != WPA_PROTO_WPA)
459 pos = hostapd_eid_wpa(hapd, pos, epos - pos);
461 pos = hostapd_eid_bss_load(hapd, pos, epos - pos);
463 pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos);
466 csa_pos = hostapd_eid_ecsa(hapd, pos);
468 hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1;
471 pos = hostapd_eid_supported_op_classes(hapd, pos);
473 #ifdef CONFIG_IEEE80211N
474 /* Secondary Channel Offset element */
475 /* TODO: The standard doesn't specify a position for this element. */
476 pos = hostapd_eid_secondary_channel(hapd, pos);
478 pos = hostapd_eid_ht_capabilities(hapd, pos);
479 pos = hostapd_eid_ht_operation(hapd, pos);
480 #endif /* CONFIG_IEEE80211N */
482 pos = hostapd_eid_ext_capab(hapd, pos);
484 pos = hostapd_eid_time_adv(hapd, pos);
485 pos = hostapd_eid_time_zone(hapd, pos);
487 pos = hostapd_eid_interworking(hapd, pos);
488 pos = hostapd_eid_adv_proto(hapd, pos);
489 pos = hostapd_eid_roaming_consortium(hapd, pos);
492 if (hapd->iface->fst_ies) {
493 os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies),
494 wpabuf_len(hapd->iface->fst_ies));
495 pos += wpabuf_len(hapd->iface->fst_ies);
497 #endif /* CONFIG_FST */
499 #ifdef CONFIG_IEEE80211AC
500 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
501 pos = hostapd_eid_vht_capabilities(hapd, pos, 0);
502 pos = hostapd_eid_vht_operation(hapd, pos);
503 pos = hostapd_eid_txpower_envelope(hapd, pos);
504 pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
506 #endif /* CONFIG_IEEE80211AC */
508 pos = hostapd_eid_fils_indic(hapd, pos, 0);
510 #ifdef CONFIG_IEEE80211AX
511 if (hapd->iconf->ieee80211ax) {
512 pos = hostapd_eid_he_capab(hapd, pos);
513 pos = hostapd_eid_he_operation(hapd, pos);
514 pos = hostapd_eid_he_mu_edca_parameter_set(hapd, pos);
516 #endif /* CONFIG_IEEE80211AX */
518 #ifdef CONFIG_IEEE80211AC
519 if (hapd->conf->vendor_vht)
520 pos = hostapd_eid_vendor_vht(hapd, pos);
521 #endif /* CONFIG_IEEE80211AC */
524 if (hapd->conf->wpa == WPA_PROTO_WPA)
525 pos = hostapd_eid_wpa(hapd, pos, epos - pos);
527 /* Wi-Fi Alliance WMM */
528 pos = hostapd_eid_wmm(hapd, pos);
531 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
532 os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
533 wpabuf_len(hapd->wps_probe_resp_ie));
534 pos += wpabuf_len(hapd->wps_probe_resp_ie);
536 #endif /* CONFIG_WPS */
539 if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p &&
540 hapd->p2p_probe_resp_ie) {
541 os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie),
542 wpabuf_len(hapd->p2p_probe_resp_ie));
543 pos += wpabuf_len(hapd->p2p_probe_resp_ie);
545 #endif /* CONFIG_P2P */
546 #ifdef CONFIG_P2P_MANAGER
547 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
549 pos = hostapd_eid_p2p_manage(hapd, pos);
550 #endif /* CONFIG_P2P_MANAGER */
553 pos = hostapd_eid_hs20_indication(hapd, pos);
554 pos = hostapd_eid_osen(hapd, pos);
555 #endif /* CONFIG_HS20 */
557 pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos);
558 pos = hostapd_eid_owe_trans(hapd, pos, (u8 *) resp + buflen - pos);
560 if (hapd->conf->vendor_elements) {
561 os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements),
562 wpabuf_len(hapd->conf->vendor_elements));
563 pos += wpabuf_len(hapd->conf->vendor_elements);
566 *resp_len = pos - (u8 *) resp;
571 enum ssid_match_result {
577 static enum ssid_match_result ssid_match(struct hostapd_data *hapd,
578 const u8 *ssid, size_t ssid_len,
580 size_t ssid_list_len)
587 if (ssid_len == hapd->conf->ssid.ssid_len &&
588 os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0)
589 return EXACT_SSID_MATCH;
591 if (ssid_list == NULL)
592 return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH;
595 end = ssid_list + ssid_list_len;
596 while (end - pos >= 1) {
597 if (2 + pos[1] > end - pos)
601 if (pos[1] == hapd->conf->ssid.ssid_len &&
602 os_memcmp(pos + 2, hapd->conf->ssid.ssid, pos[1]) == 0)
603 return EXACT_SSID_MATCH;
607 return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH;
611 void sta_track_expire(struct hostapd_iface *iface, int force)
613 struct os_reltime now;
614 struct hostapd_sta_info *info;
616 if (!iface->num_sta_seen)
619 os_get_reltime(&now);
620 while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info,
623 !os_reltime_expired(&now, &info->last_seen,
624 iface->conf->track_sta_max_age))
628 wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for "
629 MACSTR, iface->bss[0]->conf->iface,
630 MAC2STR(info->addr));
631 dl_list_del(&info->list);
632 iface->num_sta_seen--;
638 static struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface,
641 struct hostapd_sta_info *info;
643 dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list)
644 if (os_memcmp(addr, info->addr, ETH_ALEN) == 0)
651 void sta_track_add(struct hostapd_iface *iface, const u8 *addr, int ssi_signal)
653 struct hostapd_sta_info *info;
655 info = sta_track_get(iface, addr);
657 /* Move the most recent entry to the end of the list */
658 dl_list_del(&info->list);
659 dl_list_add_tail(&iface->sta_seen, &info->list);
660 os_get_reltime(&info->last_seen);
661 info->ssi_signal = ssi_signal;
665 /* Add a new entry */
666 info = os_zalloc(sizeof(*info));
669 os_memcpy(info->addr, addr, ETH_ALEN);
670 os_get_reltime(&info->last_seen);
671 info->ssi_signal = ssi_signal;
673 if (iface->num_sta_seen >= iface->conf->track_sta_max_num) {
674 /* Expire oldest entry to make room for a new one */
675 sta_track_expire(iface, 1);
678 wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for "
679 MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr));
680 dl_list_add_tail(&iface->sta_seen, &info->list);
681 iface->num_sta_seen++;
685 struct hostapd_data *
686 sta_track_seen_on(struct hostapd_iface *iface, const u8 *addr,
689 struct hapd_interfaces *interfaces = iface->interfaces;
692 for (i = 0; i < interfaces->count; i++) {
693 struct hostapd_data *hapd = NULL;
695 iface = interfaces->iface[i];
696 for (j = 0; j < iface->num_bss; j++) {
697 hapd = iface->bss[j];
698 if (os_strcmp(ifname, hapd->conf->iface) == 0)
703 if (hapd && sta_track_get(iface, addr))
711 #ifdef CONFIG_TAXONOMY
712 void sta_track_claim_taxonomy_info(struct hostapd_iface *iface, const u8 *addr,
713 struct wpabuf **probe_ie_taxonomy)
715 struct hostapd_sta_info *info;
717 info = sta_track_get(iface, addr);
721 wpabuf_free(*probe_ie_taxonomy);
722 *probe_ie_taxonomy = info->probe_ie_taxonomy;
723 info->probe_ie_taxonomy = NULL;
725 #endif /* CONFIG_TAXONOMY */
728 void handle_probe_req(struct hostapd_data *hapd,
729 const struct ieee80211_mgmt *mgmt, size_t len,
733 struct ieee802_11_elems elems;
738 enum ssid_match_result res;
742 u32 session_timeout, acct_interim_interval;
743 struct vlan_description vlan_id;
744 struct hostapd_sta_wpa_psk_short *psk = NULL;
745 char *identity = NULL;
746 char *radius_cui = NULL;
748 if (len < IEEE80211_HDRLEN)
750 ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN;
751 if (hapd->iconf->track_sta_max_num)
752 sta_track_add(hapd->iface, mgmt->sa, ssi_signal);
753 ie_len = len - IEEE80211_HDRLEN;
755 ret = ieee802_11_allowed_address(hapd, mgmt->sa, (const u8 *) mgmt, len,
757 &acct_interim_interval, &vlan_id,
758 &psk, &identity, &radius_cui, 1);
759 if (ret == HOSTAPD_ACL_REJECT) {
760 wpa_msg(hapd->msg_ctx, MSG_DEBUG,
761 "Ignore Probe Request frame from " MACSTR
762 " due to ACL reject ", MAC2STR(mgmt->sa));
766 for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
767 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
768 mgmt->sa, mgmt->da, mgmt->bssid,
769 ie, ie_len, ssi_signal) > 0)
772 if (!hapd->conf->send_probe_response)
775 if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) {
776 wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR,
781 if ((!elems.ssid || !elems.supp_rates)) {
782 wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request "
783 "without SSID or supported rates element",
789 * No need to reply if the Probe Request frame was sent on an adjacent
790 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
791 * AP with dot11RadioMeasurementActivated set to true, but strictly
792 * speaking does not allow such ignoring of Probe Request frames if
793 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
794 * number of unnecessary Probe Response frames for cases where the STA
795 * is less likely to see them (Probe Request frame sent on a
796 * neighboring, but partially overlapping, channel).
798 if (elems.ds_params &&
799 hapd->iface->current_mode &&
800 (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G ||
801 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) &&
802 hapd->iconf->channel != elems.ds_params[0]) {
803 wpa_printf(MSG_DEBUG,
804 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
805 hapd->iconf->channel, elems.ds_params[0]);
810 if (hapd->p2p && hapd->p2p_group && elems.wps_ie) {
812 wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA);
813 if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) {
814 wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
815 "due to mismatch with Requested Device "
823 if (hapd->p2p && hapd->p2p_group && elems.p2p) {
825 p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE);
826 if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) {
827 wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
828 "due to mismatch with Device ID");
834 #endif /* CONFIG_P2P */
836 if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 &&
837 elems.ssid_list_len == 0) {
838 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for "
839 "broadcast SSID ignored", MAC2STR(mgmt->sa));
844 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
845 elems.ssid_len == P2P_WILDCARD_SSID_LEN &&
846 os_memcmp(elems.ssid, P2P_WILDCARD_SSID,
847 P2P_WILDCARD_SSID_LEN) == 0) {
848 /* Process P2P Wildcard SSID like Wildcard SSID */
851 #endif /* CONFIG_P2P */
853 #ifdef CONFIG_TAXONOMY
855 struct sta_info *sta;
856 struct hostapd_sta_info *info;
858 if ((sta = ap_get_sta(hapd, mgmt->sa)) != NULL) {
859 taxonomy_sta_info_probe_req(hapd, sta, ie, ie_len);
860 } else if ((info = sta_track_get(hapd->iface,
861 mgmt->sa)) != NULL) {
862 taxonomy_hostapd_sta_info_probe_req(hapd, info,
866 #endif /* CONFIG_TAXONOMY */
868 res = ssid_match(hapd, elems.ssid, elems.ssid_len,
869 elems.ssid_list, elems.ssid_list_len);
870 if (res == NO_SSID_MATCH) {
871 if (!(mgmt->da[0] & 0x01)) {
872 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
873 " for foreign SSID '%s' (DA " MACSTR ")%s",
875 wpa_ssid_txt(elems.ssid, elems.ssid_len),
877 elems.ssid_list ? " (SSID list)" : "");
882 #ifdef CONFIG_INTERWORKING
883 if (hapd->conf->interworking &&
884 elems.interworking && elems.interworking_len >= 1) {
885 u8 ant = elems.interworking[0] & 0x0f;
886 if (ant != INTERWORKING_ANT_WILDCARD &&
887 ant != hapd->conf->access_network_type) {
888 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
889 " for mismatching ANT %u ignored",
890 MAC2STR(mgmt->sa), ant);
895 if (hapd->conf->interworking && elems.interworking &&
896 (elems.interworking_len == 7 || elems.interworking_len == 9)) {
898 if (elems.interworking_len == 7)
899 hessid = elems.interworking + 1;
901 hessid = elems.interworking + 1 + 2;
902 if (!is_broadcast_ether_addr(hessid) &&
903 os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) {
904 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
905 " for mismatching HESSID " MACSTR
907 MAC2STR(mgmt->sa), MAC2STR(hessid));
911 #endif /* CONFIG_INTERWORKING */
914 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
915 supp_rates_11b_only(&elems)) {
916 /* Indicates support for 11b rates only */
917 wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from "
918 MACSTR " with only 802.11b rates",
922 #endif /* CONFIG_P2P */
924 /* TODO: verify that supp_rates contains at least one matching rate
925 * with AP configuration */
927 if (hapd->conf->no_probe_resp_if_seen_on &&
928 is_multicast_ether_addr(mgmt->da) &&
929 is_multicast_ether_addr(mgmt->bssid) &&
930 sta_track_seen_on(hapd->iface, mgmt->sa,
931 hapd->conf->no_probe_resp_if_seen_on)) {
932 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
933 " since STA has been seen on %s",
934 hapd->conf->iface, MAC2STR(mgmt->sa),
935 hapd->conf->no_probe_resp_if_seen_on);
939 if (hapd->conf->no_probe_resp_if_max_sta &&
940 is_multicast_ether_addr(mgmt->da) &&
941 is_multicast_ether_addr(mgmt->bssid) &&
942 hapd->num_sta >= hapd->conf->max_num_sta &&
943 !ap_get_sta(hapd, mgmt->sa)) {
944 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
945 " since no room for additional STA",
946 hapd->conf->iface, MAC2STR(mgmt->sa));
950 #ifdef CONFIG_TESTING_OPTIONS
951 if (hapd->iconf->ignore_probe_probability > 0.0 &&
952 drand48() < hapd->iconf->ignore_probe_probability) {
954 "TESTING: ignoring probe request from " MACSTR,
958 #endif /* CONFIG_TESTING_OPTIONS */
960 wpa_msg_ctrl(hapd->msg_ctx, MSG_INFO, RX_PROBE_REQUEST "sa=" MACSTR
961 " signal=%d", MAC2STR(mgmt->sa), ssi_signal);
963 resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL,
969 * If this is a broadcast probe request, apply no ack policy to avoid
972 noack = !!(res == WILDCARD_SSID_MATCH &&
973 is_broadcast_ether_addr(mgmt->da));
976 if (hapd->csa_in_progress) {
977 if (hapd->cs_c_off_proberesp)
978 csa_offs[csa_offs_len++] =
979 hapd->cs_c_off_proberesp;
981 if (hapd->cs_c_off_ecsa_proberesp)
982 csa_offs[csa_offs_len++] =
983 hapd->cs_c_off_ecsa_proberesp;
986 ret = hostapd_drv_send_mlme_csa(hapd, resp, resp_len, noack,
987 csa_offs_len ? csa_offs : NULL,
991 wpa_printf(MSG_INFO, "handle_probe_req: send failed");
995 wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s "
996 "SSID", MAC2STR(mgmt->sa),
997 elems.ssid_len == 0 ? "broadcast" : "our");
1001 static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd,
1004 /* check probe response offloading caps and print warnings */
1005 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD))
1009 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie &&
1010 (!(hapd->iface->probe_resp_offloads &
1011 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS |
1012 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2))))
1013 wpa_printf(MSG_WARNING, "Device is trying to offload WPS "
1014 "Probe Response while not supporting this");
1015 #endif /* CONFIG_WPS */
1018 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie &&
1019 !(hapd->iface->probe_resp_offloads &
1020 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P))
1021 wpa_printf(MSG_WARNING, "Device is trying to offload P2P "
1022 "Probe Response while not supporting this");
1023 #endif /* CONFIG_P2P */
1025 if (hapd->conf->interworking &&
1026 !(hapd->iface->probe_resp_offloads &
1027 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING))
1028 wpa_printf(MSG_WARNING, "Device is trying to offload "
1029 "Interworking Probe Response while not supporting "
1032 /* Generate a Probe Response template for the non-P2P case */
1033 return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len);
1036 #endif /* NEED_AP_MLME */
1039 void sta_track_del(struct hostapd_sta_info *info)
1041 #ifdef CONFIG_TAXONOMY
1042 wpabuf_free(info->probe_ie_taxonomy);
1043 info->probe_ie_taxonomy = NULL;
1044 #endif /* CONFIG_TAXONOMY */
1049 int ieee802_11_build_ap_params(struct hostapd_data *hapd,
1050 struct wpa_driver_ap_params *params)
1052 struct ieee80211_mgmt *head = NULL;
1054 size_t head_len = 0, tail_len = 0;
1056 size_t resp_len = 0;
1059 u8 *pos, *tailpos, *csa_pos;
1061 #define BEACON_HEAD_BUF_SIZE 256
1062 #define BEACON_TAIL_BUF_SIZE 512
1063 head = os_zalloc(BEACON_HEAD_BUF_SIZE);
1064 tail_len = BEACON_TAIL_BUF_SIZE;
1066 if (hapd->conf->wps_state && hapd->wps_beacon_ie)
1067 tail_len += wpabuf_len(hapd->wps_beacon_ie);
1068 #endif /* CONFIG_WPS */
1070 if (hapd->p2p_beacon_ie)
1071 tail_len += wpabuf_len(hapd->p2p_beacon_ie);
1072 #endif /* CONFIG_P2P */
1074 if (hapd->iface->fst_ies)
1075 tail_len += wpabuf_len(hapd->iface->fst_ies);
1076 #endif /* CONFIG_FST */
1077 if (hapd->conf->vendor_elements)
1078 tail_len += wpabuf_len(hapd->conf->vendor_elements);
1080 #ifdef CONFIG_IEEE80211AC
1081 if (hapd->conf->vendor_vht) {
1082 tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) +
1083 2 + sizeof(struct ieee80211_vht_operation);
1085 #endif /* CONFIG_IEEE80211AC */
1087 #ifdef CONFIG_IEEE80211AX
1088 if (hapd->iconf->ieee80211ax) {
1089 tail_len += 3 + sizeof(struct ieee80211_he_capabilities) +
1090 3 + sizeof(struct ieee80211_he_operation) +
1091 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set);
1093 #endif /* CONFIG_IEEE80211AX */
1095 tail_len += hostapd_mbo_ie_len(hapd);
1096 tail_len += hostapd_eid_owe_trans_len(hapd);
1098 tailpos = tail = os_malloc(tail_len);
1099 if (head == NULL || tail == NULL) {
1100 wpa_printf(MSG_ERROR, "Failed to set beacon data");
1106 head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1107 WLAN_FC_STYPE_BEACON);
1108 head->duration = host_to_le16(0);
1109 os_memset(head->da, 0xff, ETH_ALEN);
1111 os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
1112 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
1113 head->u.beacon.beacon_int =
1114 host_to_le16(hapd->iconf->beacon_int);
1116 /* hardware or low-level driver will setup seq_ctrl and timestamp */
1117 capab_info = hostapd_own_capab_info(hapd);
1118 head->u.beacon.capab_info = host_to_le16(capab_info);
1119 pos = &head->u.beacon.variable[0];
1122 *pos++ = WLAN_EID_SSID;
1123 if (hapd->conf->ignore_broadcast_ssid == 2) {
1124 /* clear the data, but keep the correct length of the SSID */
1125 *pos++ = hapd->conf->ssid.ssid_len;
1126 os_memset(pos, 0, hapd->conf->ssid.ssid_len);
1127 pos += hapd->conf->ssid.ssid_len;
1128 } else if (hapd->conf->ignore_broadcast_ssid) {
1129 *pos++ = 0; /* empty SSID */
1131 *pos++ = hapd->conf->ssid.ssid_len;
1132 os_memcpy(pos, hapd->conf->ssid.ssid,
1133 hapd->conf->ssid.ssid_len);
1134 pos += hapd->conf->ssid.ssid_len;
1137 /* Supported rates */
1138 pos = hostapd_eid_supp_rates(hapd, pos);
1141 pos = hostapd_eid_ds_params(hapd, pos);
1143 head_len = pos - (u8 *) head;
1145 tailpos = hostapd_eid_country(hapd, tailpos,
1146 tail + BEACON_TAIL_BUF_SIZE - tailpos);
1148 /* Power Constraint element */
1149 tailpos = hostapd_eid_pwr_constraint(hapd, tailpos);
1152 csa_pos = hostapd_eid_csa(hapd, tailpos);
1153 if (csa_pos != tailpos)
1154 hapd->cs_c_off_beacon = csa_pos - tail - 1;
1157 /* ERP Information element */
1158 tailpos = hostapd_eid_erp_info(hapd, tailpos);
1160 /* Extended supported rates */
1161 tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);
1164 if (hapd->conf->wpa != WPA_PROTO_WPA)
1165 tailpos = hostapd_eid_wpa(hapd, tailpos,
1166 tail + BEACON_TAIL_BUF_SIZE -
1169 tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos,
1170 tail + BEACON_TAIL_BUF_SIZE -
1173 tailpos = hostapd_eid_bss_load(hapd, tailpos,
1174 tail + BEACON_TAIL_BUF_SIZE - tailpos);
1177 csa_pos = hostapd_eid_ecsa(hapd, tailpos);
1178 if (csa_pos != tailpos)
1179 hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1;
1182 tailpos = hostapd_eid_supported_op_classes(hapd, tailpos);
1184 #ifdef CONFIG_IEEE80211N
1185 /* Secondary Channel Offset element */
1186 /* TODO: The standard doesn't specify a position for this element. */
1187 tailpos = hostapd_eid_secondary_channel(hapd, tailpos);
1189 tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
1190 tailpos = hostapd_eid_ht_operation(hapd, tailpos);
1191 #endif /* CONFIG_IEEE80211N */
1193 tailpos = hostapd_eid_ext_capab(hapd, tailpos);
1196 * TODO: Time Advertisement element should only be included in some
1197 * DTIM Beacon frames.
1199 tailpos = hostapd_eid_time_adv(hapd, tailpos);
1201 tailpos = hostapd_eid_interworking(hapd, tailpos);
1202 tailpos = hostapd_eid_adv_proto(hapd, tailpos);
1203 tailpos = hostapd_eid_roaming_consortium(hapd, tailpos);
1206 if (hapd->iface->fst_ies) {
1207 os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies),
1208 wpabuf_len(hapd->iface->fst_ies));
1209 tailpos += wpabuf_len(hapd->iface->fst_ies);
1211 #endif /* CONFIG_FST */
1213 #ifdef CONFIG_IEEE80211AC
1214 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
1215 tailpos = hostapd_eid_vht_capabilities(hapd, tailpos, 0);
1216 tailpos = hostapd_eid_vht_operation(hapd, tailpos);
1217 tailpos = hostapd_eid_txpower_envelope(hapd, tailpos);
1218 tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
1220 #endif /* CONFIG_IEEE80211AC */
1222 tailpos = hostapd_eid_fils_indic(hapd, tailpos, 0);
1224 #ifdef CONFIG_IEEE80211AX
1225 if (hapd->iconf->ieee80211ax) {
1226 tailpos = hostapd_eid_he_capab(hapd, tailpos);
1227 tailpos = hostapd_eid_he_operation(hapd, tailpos);
1228 tailpos = hostapd_eid_he_mu_edca_parameter_set(hapd, tailpos);
1230 #endif /* CONFIG_IEEE80211AX */
1232 #ifdef CONFIG_IEEE80211AC
1233 if (hapd->conf->vendor_vht)
1234 tailpos = hostapd_eid_vendor_vht(hapd, tailpos);
1235 #endif /* CONFIG_IEEE80211AC */
1238 if (hapd->conf->wpa == WPA_PROTO_WPA)
1239 tailpos = hostapd_eid_wpa(hapd, tailpos,
1240 tail + BEACON_TAIL_BUF_SIZE -
1243 /* Wi-Fi Alliance WMM */
1244 tailpos = hostapd_eid_wmm(hapd, tailpos);
1247 if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
1248 os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
1249 wpabuf_len(hapd->wps_beacon_ie));
1250 tailpos += wpabuf_len(hapd->wps_beacon_ie);
1252 #endif /* CONFIG_WPS */
1255 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) {
1256 os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie),
1257 wpabuf_len(hapd->p2p_beacon_ie));
1258 tailpos += wpabuf_len(hapd->p2p_beacon_ie);
1260 #endif /* CONFIG_P2P */
1261 #ifdef CONFIG_P2P_MANAGER
1262 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
1264 tailpos = hostapd_eid_p2p_manage(hapd, tailpos);
1265 #endif /* CONFIG_P2P_MANAGER */
1268 tailpos = hostapd_eid_hs20_indication(hapd, tailpos);
1269 tailpos = hostapd_eid_osen(hapd, tailpos);
1270 #endif /* CONFIG_HS20 */
1272 tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos);
1273 tailpos = hostapd_eid_owe_trans(hapd, tailpos,
1274 tail + tail_len - tailpos);
1276 if (hapd->conf->vendor_elements) {
1277 os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements),
1278 wpabuf_len(hapd->conf->vendor_elements));
1279 tailpos += wpabuf_len(hapd->conf->vendor_elements);
1282 tail_len = tailpos > tail ? tailpos - tail : 0;
1284 resp = hostapd_probe_resp_offloads(hapd, &resp_len);
1285 #endif /* NEED_AP_MLME */
1287 os_memset(params, 0, sizeof(*params));
1288 params->head = (u8 *) head;
1289 params->head_len = head_len;
1290 params->tail = tail;
1291 params->tail_len = tail_len;
1292 params->proberesp = resp;
1293 params->proberesp_len = resp_len;
1294 params->dtim_period = hapd->conf->dtim_period;
1295 params->beacon_int = hapd->iconf->beacon_int;
1296 params->basic_rates = hapd->iface->basic_rates;
1297 params->beacon_rate = hapd->iconf->beacon_rate;
1298 params->rate_type = hapd->iconf->rate_type;
1299 params->ssid = hapd->conf->ssid.ssid;
1300 params->ssid_len = hapd->conf->ssid.ssid_len;
1301 if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
1302 (WPA_PROTO_WPA | WPA_PROTO_RSN))
1303 params->pairwise_ciphers = hapd->conf->wpa_pairwise |
1304 hapd->conf->rsn_pairwise;
1305 else if (hapd->conf->wpa & WPA_PROTO_RSN)
1306 params->pairwise_ciphers = hapd->conf->rsn_pairwise;
1307 else if (hapd->conf->wpa & WPA_PROTO_WPA)
1308 params->pairwise_ciphers = hapd->conf->wpa_pairwise;
1309 params->group_cipher = hapd->conf->wpa_group;
1310 params->key_mgmt_suites = hapd->conf->wpa_key_mgmt;
1311 params->auth_algs = hapd->conf->auth_algs;
1312 params->wpa_version = hapd->conf->wpa;
1313 params->privacy = hapd->conf->ssid.wep.keys_set || hapd->conf->wpa ||
1314 (hapd->conf->ieee802_1x &&
1315 (hapd->conf->default_wep_key_len ||
1316 hapd->conf->individual_wep_key_len));
1317 switch (hapd->conf->ignore_broadcast_ssid) {
1319 params->hide_ssid = NO_SSID_HIDING;
1322 params->hide_ssid = HIDDEN_SSID_ZERO_LEN;
1325 params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS;
1328 params->isolate = hapd->conf->isolate;
1329 params->smps_mode = hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_MASK;
1331 params->cts_protect = !!(ieee802_11_erp_info(hapd) &
1332 ERP_INFO_USE_PROTECTION);
1333 params->preamble = hapd->iface->num_sta_no_short_preamble == 0 &&
1334 hapd->iconf->preamble == SHORT_PREAMBLE;
1335 if (hapd->iface->current_mode &&
1336 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
1337 params->short_slot_time =
1338 hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1;
1340 params->short_slot_time = -1;
1341 if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
1342 params->ht_opmode = -1;
1344 params->ht_opmode = hapd->iface->ht_op_mode;
1345 #endif /* NEED_AP_MLME */
1346 params->interworking = hapd->conf->interworking;
1347 if (hapd->conf->interworking &&
1348 !is_zero_ether_addr(hapd->conf->hessid))
1349 params->hessid = hapd->conf->hessid;
1350 params->access_network_type = hapd->conf->access_network_type;
1351 params->ap_max_inactivity = hapd->conf->ap_max_inactivity;
1353 params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow;
1354 #endif /* CONFIG_P2P */
1356 params->disable_dgaf = hapd->conf->disable_dgaf;
1357 if (hapd->conf->osen) {
1358 params->privacy = 1;
1361 #endif /* CONFIG_HS20 */
1362 params->multicast_to_unicast = hapd->conf->multicast_to_unicast;
1363 params->pbss = hapd->conf->pbss;
1365 if (hapd->conf->ftm_responder) {
1366 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_FTM_RESPONDER) {
1367 params->ftm_responder = 1;
1368 params->lci = hapd->iface->conf->lci;
1369 params->civic = hapd->iface->conf->civic;
1371 wpa_printf(MSG_WARNING,
1372 "Not configuring FTM responder as the driver doesn't advertise support for it");
1380 void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params)
1382 os_free(params->tail);
1383 params->tail = NULL;
1384 os_free(params->head);
1385 params->head = NULL;
1386 os_free(params->proberesp);
1387 params->proberesp = NULL;
1391 int ieee802_11_set_beacon(struct hostapd_data *hapd)
1393 struct wpa_driver_ap_params params;
1394 struct hostapd_freq_params freq;
1395 struct hostapd_iface *iface = hapd->iface;
1396 struct hostapd_config *iconf = iface->conf;
1397 struct wpabuf *beacon, *proberesp, *assocresp;
1400 if (hapd->csa_in_progress) {
1401 wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period");
1405 hapd->beacon_set_done = 1;
1407 if (ieee802_11_build_ap_params(hapd, ¶ms) < 0)
1410 if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
1414 params.beacon_ies = beacon;
1415 params.proberesp_ies = proberesp;
1416 params.assocresp_ies = assocresp;
1417 params.reenable = hapd->reenable_beacon;
1418 hapd->reenable_beacon = 0;
1420 if (iface->current_mode &&
1421 hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq,
1422 iconf->channel, iconf->ieee80211n,
1424 iconf->secondary_channel,
1425 iconf->vht_oper_chwidth,
1426 iconf->vht_oper_centr_freq_seg0_idx,
1427 iconf->vht_oper_centr_freq_seg1_idx,
1428 iface->current_mode->vht_capab) == 0)
1429 params.freq = &freq;
1431 res = hostapd_drv_set_ap(hapd, ¶ms);
1432 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
1434 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
1438 ieee802_11_free_ap_params(¶ms);
1443 int ieee802_11_set_beacons(struct hostapd_iface *iface)
1448 for (i = 0; i < iface->num_bss; i++) {
1449 if (iface->bss[i]->started &&
1450 ieee802_11_set_beacon(iface->bss[i]) < 0)
1458 /* only update beacons if started */
1459 int ieee802_11_update_beacons(struct hostapd_iface *iface)
1464 for (i = 0; i < iface->num_bss; i++) {
1465 if (iface->bss[i]->beacon_set_done && iface->bss[i]->started &&
1466 ieee802_11_set_beacon(iface->bss[i]) < 0)
1473 #endif /* CONFIG_NATIVE_WINDOWS */