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_bss_load(struct hostapd_data
*hapd
, u8
*eid
, size_t len
)
44 #ifdef CONFIG_TESTING_OPTIONS
45 if (hapd
->conf
->bss_load_test_set
) {
46 *eid
++ = WLAN_EID_BSS_LOAD
;
48 os_memcpy(eid
, hapd
->conf
->bss_load_test
, 5);
52 #endif /* CONFIG_TESTING_OPTIONS */
53 if (hapd
->conf
->bss_load_update_period
) {
54 *eid
++ = WLAN_EID_BSS_LOAD
;
56 WPA_PUT_LE16(eid
, hapd
->num_sta
);
58 *eid
++ = hapd
->iface
->channel_utilization
;
59 WPA_PUT_LE16(eid
, 0); /* no available admission capabity */
66 static u8
ieee802_11_erp_info(struct hostapd_data
*hapd
)
70 if (hapd
->iface
->current_mode
== NULL
||
71 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
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
;
80 if (hapd
->iface
->num_sta_no_short_preamble
> 0 ||
81 hapd
->iconf
->preamble
== LONG_PREAMBLE
)
82 erp
|= ERP_INFO_BARKER_PREAMBLE_MODE
;
88 static u8
* hostapd_eid_ds_params(struct hostapd_data
*hapd
, u8
*eid
)
90 *eid
++ = WLAN_EID_DS_PARAMS
;
92 *eid
++ = hapd
->iconf
->channel
;
97 static u8
* hostapd_eid_erp_info(struct hostapd_data
*hapd
, u8
*eid
)
99 if (hapd
->iface
->current_mode
== NULL
||
100 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
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. */
112 /* Add ERP Information element */
113 *eid
++ = WLAN_EID_ERP_INFO
;
115 *eid
++ = ieee802_11_erp_info(hapd
);
121 static u8
* hostapd_eid_pwr_constraint(struct hostapd_data
*hapd
, u8
*eid
)
124 u8 local_pwr_constraint
= 0;
127 if (hapd
->iface
->current_mode
== NULL
||
128 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211A
)
131 /* Let host drivers add this IE if DFS support is offloaded */
132 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_DFS_OFFLOAD
)
136 * There is no DFS support and power constraint was not directly
137 * requested by config option.
139 if (!hapd
->iconf
->ieee80211h
&&
140 hapd
->iconf
->local_pwr_constraint
== -1)
143 /* Check if DFS is required by regulatory. */
144 dfs
= hostapd_is_dfs_required(hapd
->iface
);
146 wpa_printf(MSG_WARNING
, "Failed to check if DFS is required; ret=%d",
151 if (dfs
== 0 && hapd
->iconf
->local_pwr_constraint
== -1)
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.
162 if (hapd
->iconf
->local_pwr_constraint
== -1)
163 local_pwr_constraint
= 3;
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.
176 *pos
++ = WLAN_EID_PWR_CONSTRAINT
;
179 /* Local Power Constraint */
180 if (local_pwr_constraint
)
181 *pos
++ = local_pwr_constraint
;
183 *pos
++ = hapd
->iconf
->local_pwr_constraint
;
189 static u8
* hostapd_eid_country_add(u8
*pos
, u8
*end
, int chan_spacing
,
190 struct hostapd_channel_data
*start
,
191 struct hostapd_channel_data
*prev
)
196 /* first channel number */
197 *pos
++ = start
->chan
;
198 /* number of channels */
199 *pos
++ = (prev
->chan
- start
->chan
) / chan_spacing
+ 1;
200 /* maximum transmit power level */
201 *pos
++ = start
->max_tx_power
;
207 static u8
* hostapd_eid_country(struct hostapd_data
*hapd
, u8
*eid
,
211 u8
*end
= eid
+ max_len
;
213 struct hostapd_hw_modes
*mode
;
214 struct hostapd_channel_data
*start
, *prev
;
215 int chan_spacing
= 1;
217 if (!hapd
->iconf
->ieee80211d
|| max_len
< 6 ||
218 hapd
->iface
->current_mode
== NULL
)
221 *pos
++ = WLAN_EID_COUNTRY
;
222 pos
++; /* length will be set later */
223 os_memcpy(pos
, hapd
->iconf
->country
, 3); /* e.g., 'US ' */
226 mode
= hapd
->iface
->current_mode
;
227 if (mode
->mode
== HOSTAPD_MODE_IEEE80211A
)
231 for (i
= 0; i
< mode
->num_channels
; i
++) {
232 struct hostapd_channel_data
*chan
= &mode
->channels
[i
];
233 if (chan
->flag
& HOSTAPD_CHAN_DISABLED
)
236 prev
->chan
+ chan_spacing
== chan
->chan
&&
237 start
->max_tx_power
== chan
->max_tx_power
) {
239 continue; /* can use same entry */
243 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
248 /* Start new group */
253 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
257 if ((pos
- eid
) & 1) {
260 *pos
++ = 0; /* pad for 16-bit alignment */
263 eid
[1] = (pos
- eid
) - 2;
269 static const u8
* hostapd_wpa_ie(struct hostapd_data
*hapd
, u8 eid
)
274 ies
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &ies_len
);
278 return get_ie(ies
, ies_len
, eid
);
282 static const u8
* hostapd_vendor_wpa_ie(struct hostapd_data
*hapd
,
288 ies
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &ies_len
);
292 return get_vendor_ie(ies
, ies_len
, vendor_type
);
296 static u8
* hostapd_get_rsne(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
300 ie
= hostapd_wpa_ie(hapd
, WLAN_EID_RSN
);
301 if (!ie
|| 2U + ie
[1] > len
)
304 os_memcpy(pos
, ie
, 2 + ie
[1]);
305 return pos
+ 2 + ie
[1];
309 static u8
* hostapd_get_mde(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
313 ie
= hostapd_wpa_ie(hapd
, WLAN_EID_MOBILITY_DOMAIN
);
314 if (!ie
|| 2U + ie
[1] > len
)
317 os_memcpy(pos
, ie
, 2 + ie
[1]);
318 return pos
+ 2 + ie
[1];
322 static u8
* hostapd_get_rsnxe(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
326 ie
= hostapd_wpa_ie(hapd
, WLAN_EID_RSNX
);
327 if (!ie
|| 2U + ie
[1] > len
)
330 os_memcpy(pos
, ie
, 2 + ie
[1]);
331 return pos
+ 2 + ie
[1];
335 static u8
* hostapd_get_wpa_ie(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
339 ie
= hostapd_vendor_wpa_ie(hapd
, WPA_IE_VENDOR_TYPE
);
340 if (!ie
|| 2U + ie
[1] > len
)
343 os_memcpy(pos
, ie
, 2 + ie
[1]);
344 return pos
+ 2 + ie
[1];
348 static u8
* hostapd_get_osen_ie(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
352 ie
= hostapd_vendor_wpa_ie(hapd
, OSEN_IE_VENDOR_TYPE
);
353 if (!ie
|| 2U + ie
[1] > len
)
356 os_memcpy(pos
, ie
, 2 + ie
[1]);
357 return pos
+ 2 + ie
[1];
361 static u8
* hostapd_eid_csa(struct hostapd_data
*hapd
, u8
*eid
)
363 #ifdef CONFIG_TESTING_OPTIONS
364 if (hapd
->iface
->cs_oper_class
&& hapd
->iconf
->ecsa_ie_only
)
366 #endif /* CONFIG_TESTING_OPTIONS */
368 if (!hapd
->cs_freq_params
.channel
)
371 *eid
++ = WLAN_EID_CHANNEL_SWITCH
;
373 *eid
++ = hapd
->cs_block_tx
;
374 *eid
++ = hapd
->cs_freq_params
.channel
;
375 *eid
++ = hapd
->cs_count
;
381 static u8
* hostapd_eid_ecsa(struct hostapd_data
*hapd
, u8
*eid
)
383 if (!hapd
->cs_freq_params
.channel
|| !hapd
->iface
->cs_oper_class
)
386 *eid
++ = WLAN_EID_EXT_CHANSWITCH_ANN
;
388 *eid
++ = hapd
->cs_block_tx
;
389 *eid
++ = hapd
->iface
->cs_oper_class
;
390 *eid
++ = hapd
->cs_freq_params
.channel
;
391 *eid
++ = hapd
->cs_count
;
397 static u8
* hostapd_eid_supported_op_classes(struct hostapd_data
*hapd
, u8
*eid
)
399 u8 op_class
, channel
;
401 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_AP_CSA
) ||
405 if (ieee80211_freq_to_channel_ext(hapd
->iface
->freq
,
406 hapd
->iconf
->secondary_channel
,
407 hostapd_get_oper_chwidth(hapd
->iconf
),
408 &op_class
, &channel
) ==
412 *eid
++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES
;
415 /* Current Operating Class */
418 /* TODO: Advertise all the supported operating classes */
425 static u8
* hostapd_gen_probe_resp(struct hostapd_data
*hapd
,
426 const struct ieee80211_mgmt
*req
,
427 int is_p2p
, size_t *resp_len
)
429 struct ieee80211_mgmt
*resp
;
430 u8
*pos
, *epos
, *csa_pos
;
433 #define MAX_PROBERESP_LEN 768
434 buflen
= MAX_PROBERESP_LEN
;
436 if (hapd
->wps_probe_resp_ie
)
437 buflen
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
438 #endif /* CONFIG_WPS */
440 if (hapd
->p2p_probe_resp_ie
)
441 buflen
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
442 #endif /* CONFIG_P2P */
444 if (hapd
->iface
->fst_ies
)
445 buflen
+= wpabuf_len(hapd
->iface
->fst_ies
);
446 #endif /* CONFIG_FST */
447 if (hapd
->conf
->vendor_elements
)
448 buflen
+= wpabuf_len(hapd
->conf
->vendor_elements
);
449 if (hapd
->conf
->vendor_vht
) {
450 buflen
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
451 2 + sizeof(struct ieee80211_vht_operation
);
454 #ifdef CONFIG_IEEE80211AX
455 if (hapd
->iconf
->ieee80211ax
) {
456 buflen
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
457 3 + sizeof(struct ieee80211_he_operation
) +
458 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
459 3 + sizeof(struct ieee80211_spatial_reuse
);
461 #endif /* CONFIG_IEEE80211AX */
463 buflen
+= hostapd_mbo_ie_len(hapd
);
464 buflen
+= hostapd_eid_owe_trans_len(hapd
);
466 resp
= os_zalloc(buflen
);
470 epos
= ((u8
*) resp
) + MAX_PROBERESP_LEN
;
472 resp
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
473 WLAN_FC_STYPE_PROBE_RESP
);
475 os_memcpy(resp
->da
, req
->sa
, ETH_ALEN
);
476 os_memcpy(resp
->sa
, hapd
->own_addr
, ETH_ALEN
);
478 os_memcpy(resp
->bssid
, hapd
->own_addr
, ETH_ALEN
);
479 resp
->u
.probe_resp
.beacon_int
=
480 host_to_le16(hapd
->iconf
->beacon_int
);
482 /* hardware or low-level driver will setup seq_ctrl and timestamp */
483 resp
->u
.probe_resp
.capab_info
=
484 host_to_le16(hostapd_own_capab_info(hapd
));
486 pos
= resp
->u
.probe_resp
.variable
;
487 *pos
++ = WLAN_EID_SSID
;
488 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
489 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
, hapd
->conf
->ssid
.ssid_len
);
490 pos
+= hapd
->conf
->ssid
.ssid_len
;
492 /* Supported rates */
493 pos
= hostapd_eid_supp_rates(hapd
, pos
);
496 pos
= hostapd_eid_ds_params(hapd
, pos
);
498 pos
= hostapd_eid_country(hapd
, pos
, epos
- pos
);
500 /* Power Constraint element */
501 pos
= hostapd_eid_pwr_constraint(hapd
, pos
);
504 csa_pos
= hostapd_eid_csa(hapd
, pos
);
506 hapd
->cs_c_off_proberesp
= csa_pos
- (u8
*) resp
- 1;
509 /* ERP Information element */
510 pos
= hostapd_eid_erp_info(hapd
, pos
);
512 /* Extended supported rates */
513 pos
= hostapd_eid_ext_supp_rates(hapd
, pos
);
515 pos
= hostapd_get_rsne(hapd
, pos
, epos
- pos
);
516 pos
= hostapd_eid_bss_load(hapd
, pos
, epos
- pos
);
517 pos
= hostapd_eid_rm_enabled_capab(hapd
, pos
, epos
- pos
);
518 pos
= hostapd_get_mde(hapd
, pos
, epos
- pos
);
521 csa_pos
= hostapd_eid_ecsa(hapd
, pos
);
523 hapd
->cs_c_off_ecsa_proberesp
= csa_pos
- (u8
*) resp
- 1;
526 pos
= hostapd_eid_supported_op_classes(hapd
, pos
);
527 pos
= hostapd_eid_ht_capabilities(hapd
, pos
);
528 pos
= hostapd_eid_ht_operation(hapd
, pos
);
530 pos
= hostapd_eid_ext_capab(hapd
, pos
);
532 pos
= hostapd_eid_time_adv(hapd
, pos
);
533 pos
= hostapd_eid_time_zone(hapd
, pos
);
535 pos
= hostapd_eid_interworking(hapd
, pos
);
536 pos
= hostapd_eid_adv_proto(hapd
, pos
);
537 pos
= hostapd_eid_roaming_consortium(hapd
, pos
);
540 if (hapd
->iface
->fst_ies
) {
541 os_memcpy(pos
, wpabuf_head(hapd
->iface
->fst_ies
),
542 wpabuf_len(hapd
->iface
->fst_ies
));
543 pos
+= wpabuf_len(hapd
->iface
->fst_ies
);
545 #endif /* CONFIG_FST */
547 #ifdef CONFIG_IEEE80211AC
548 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
&&
549 !is_6ghz_op_class(hapd
->iconf
->op_class
)) {
550 pos
= hostapd_eid_vht_capabilities(hapd
, pos
, 0);
551 pos
= hostapd_eid_vht_operation(hapd
, pos
);
552 pos
= hostapd_eid_txpower_envelope(hapd
, pos
);
553 pos
= hostapd_eid_wb_chsw_wrapper(hapd
, pos
);
555 #endif /* CONFIG_IEEE80211AC */
557 pos
= hostapd_eid_fils_indic(hapd
, pos
, 0);
558 pos
= hostapd_get_rsnxe(hapd
, pos
, epos
- pos
);
560 #ifdef CONFIG_IEEE80211AX
561 if (hapd
->iconf
->ieee80211ax
) {
562 pos
= hostapd_eid_he_capab(hapd
, pos
, IEEE80211_MODE_AP
);
563 pos
= hostapd_eid_he_operation(hapd
, pos
);
564 pos
= hostapd_eid_spatial_reuse(hapd
, pos
);
565 pos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, pos
);
567 #endif /* CONFIG_IEEE80211AX */
569 #ifdef CONFIG_IEEE80211AC
570 if (hapd
->conf
->vendor_vht
)
571 pos
= hostapd_eid_vendor_vht(hapd
, pos
);
572 #endif /* CONFIG_IEEE80211AC */
575 pos
= hostapd_get_wpa_ie(hapd
, pos
, epos
- pos
);
576 pos
= hostapd_get_osen_ie(hapd
, pos
, epos
- pos
);
578 /* Wi-Fi Alliance WMM */
579 pos
= hostapd_eid_wmm(hapd
, pos
);
582 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
) {
583 os_memcpy(pos
, wpabuf_head(hapd
->wps_probe_resp_ie
),
584 wpabuf_len(hapd
->wps_probe_resp_ie
));
585 pos
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
587 #endif /* CONFIG_WPS */
590 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && is_p2p
&&
591 hapd
->p2p_probe_resp_ie
) {
592 os_memcpy(pos
, wpabuf_head(hapd
->p2p_probe_resp_ie
),
593 wpabuf_len(hapd
->p2p_probe_resp_ie
));
594 pos
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
596 #endif /* CONFIG_P2P */
597 #ifdef CONFIG_P2P_MANAGER
598 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
600 pos
= hostapd_eid_p2p_manage(hapd
, pos
);
601 #endif /* CONFIG_P2P_MANAGER */
604 pos
= hostapd_eid_hs20_indication(hapd
, pos
);
605 #endif /* CONFIG_HS20 */
607 pos
= hostapd_eid_mbo(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
608 pos
= hostapd_eid_owe_trans(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
610 if (hapd
->conf
->vendor_elements
) {
611 os_memcpy(pos
, wpabuf_head(hapd
->conf
->vendor_elements
),
612 wpabuf_len(hapd
->conf
->vendor_elements
));
613 pos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
616 *resp_len
= pos
- (u8
*) resp
;
621 enum ssid_match_result
{
627 static enum ssid_match_result
ssid_match(struct hostapd_data
*hapd
,
628 const u8
*ssid
, size_t ssid_len
,
630 size_t ssid_list_len
,
631 const u8
*short_ssid_list
,
632 size_t short_ssid_list_len
)
639 if (ssid_len
== hapd
->conf
->ssid
.ssid_len
&&
640 os_memcmp(ssid
, hapd
->conf
->ssid
.ssid
, ssid_len
) == 0)
641 return EXACT_SSID_MATCH
;
645 end
= ssid_list
+ ssid_list_len
;
646 while (end
- pos
>= 2) {
647 if (2 + pos
[1] > end
- pos
)
651 if (pos
[1] == hapd
->conf
->ssid
.ssid_len
&&
652 os_memcmp(pos
+ 2, hapd
->conf
->ssid
.ssid
,
654 return EXACT_SSID_MATCH
;
659 if (short_ssid_list
) {
660 pos
= short_ssid_list
;
661 end
= short_ssid_list
+ short_ssid_list_len
;
662 while (end
- pos
>= 4) {
663 if (hapd
->conf
->ssid
.short_ssid
== WPA_GET_LE32(pos
))
664 return EXACT_SSID_MATCH
;
669 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
673 void sta_track_expire(struct hostapd_iface
*iface
, int force
)
675 struct os_reltime now
;
676 struct hostapd_sta_info
*info
;
678 if (!iface
->num_sta_seen
)
681 os_get_reltime(&now
);
682 while ((info
= dl_list_first(&iface
->sta_seen
, struct hostapd_sta_info
,
685 !os_reltime_expired(&now
, &info
->last_seen
,
686 iface
->conf
->track_sta_max_age
))
690 wpa_printf(MSG_MSGDUMP
, "%s: Expire STA tracking entry for "
691 MACSTR
, iface
->bss
[0]->conf
->iface
,
692 MAC2STR(info
->addr
));
693 dl_list_del(&info
->list
);
694 iface
->num_sta_seen
--;
700 static struct hostapd_sta_info
* sta_track_get(struct hostapd_iface
*iface
,
703 struct hostapd_sta_info
*info
;
705 dl_list_for_each(info
, &iface
->sta_seen
, struct hostapd_sta_info
, list
)
706 if (os_memcmp(addr
, info
->addr
, ETH_ALEN
) == 0)
713 void sta_track_add(struct hostapd_iface
*iface
, const u8
*addr
, int ssi_signal
)
715 struct hostapd_sta_info
*info
;
717 info
= sta_track_get(iface
, addr
);
719 /* Move the most recent entry to the end of the list */
720 dl_list_del(&info
->list
);
721 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
722 os_get_reltime(&info
->last_seen
);
723 info
->ssi_signal
= ssi_signal
;
727 /* Add a new entry */
728 info
= os_zalloc(sizeof(*info
));
731 os_memcpy(info
->addr
, addr
, ETH_ALEN
);
732 os_get_reltime(&info
->last_seen
);
733 info
->ssi_signal
= ssi_signal
;
735 if (iface
->num_sta_seen
>= iface
->conf
->track_sta_max_num
) {
736 /* Expire oldest entry to make room for a new one */
737 sta_track_expire(iface
, 1);
740 wpa_printf(MSG_MSGDUMP
, "%s: Add STA tracking entry for "
741 MACSTR
, iface
->bss
[0]->conf
->iface
, MAC2STR(addr
));
742 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
743 iface
->num_sta_seen
++;
747 struct hostapd_data
*
748 sta_track_seen_on(struct hostapd_iface
*iface
, const u8
*addr
,
751 struct hapd_interfaces
*interfaces
= iface
->interfaces
;
754 for (i
= 0; i
< interfaces
->count
; i
++) {
755 struct hostapd_data
*hapd
= NULL
;
757 iface
= interfaces
->iface
[i
];
758 for (j
= 0; j
< iface
->num_bss
; j
++) {
759 hapd
= iface
->bss
[j
];
760 if (os_strcmp(ifname
, hapd
->conf
->iface
) == 0)
765 if (hapd
&& sta_track_get(iface
, addr
))
773 #ifdef CONFIG_TAXONOMY
774 void sta_track_claim_taxonomy_info(struct hostapd_iface
*iface
, const u8
*addr
,
775 struct wpabuf
**probe_ie_taxonomy
)
777 struct hostapd_sta_info
*info
;
779 info
= sta_track_get(iface
, addr
);
783 wpabuf_free(*probe_ie_taxonomy
);
784 *probe_ie_taxonomy
= info
->probe_ie_taxonomy
;
785 info
->probe_ie_taxonomy
= NULL
;
787 #endif /* CONFIG_TAXONOMY */
790 void handle_probe_req(struct hostapd_data
*hapd
,
791 const struct ieee80211_mgmt
*mgmt
, size_t len
,
795 struct ieee802_11_elems elems
;
800 enum ssid_match_result res
;
804 struct radius_sta rad_info
;
806 if (len
< IEEE80211_HDRLEN
)
808 ie
= ((const u8
*) mgmt
) + IEEE80211_HDRLEN
;
809 if (hapd
->iconf
->track_sta_max_num
)
810 sta_track_add(hapd
->iface
, mgmt
->sa
, ssi_signal
);
811 ie_len
= len
- IEEE80211_HDRLEN
;
813 ret
= hostapd_allowed_address(hapd
, mgmt
->sa
, (const u8
*) mgmt
, len
,
815 if (ret
== HOSTAPD_ACL_REJECT
) {
816 wpa_msg(hapd
->msg_ctx
, MSG_DEBUG
,
817 "Ignore Probe Request frame from " MACSTR
818 " due to ACL reject ", MAC2STR(mgmt
->sa
));
822 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++)
823 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
824 mgmt
->sa
, mgmt
->da
, mgmt
->bssid
,
825 ie
, ie_len
, ssi_signal
) > 0)
828 if (!hapd
->conf
->send_probe_response
)
831 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 0) == ParseFailed
) {
832 wpa_printf(MSG_DEBUG
, "Could not parse ProbeReq from " MACSTR
,
837 if ((!elems
.ssid
|| !elems
.supp_rates
)) {
838 wpa_printf(MSG_DEBUG
, "STA " MACSTR
" sent probe request "
839 "without SSID or supported rates element",
845 * No need to reply if the Probe Request frame was sent on an adjacent
846 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
847 * AP with dot11RadioMeasurementActivated set to true, but strictly
848 * speaking does not allow such ignoring of Probe Request frames if
849 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
850 * number of unnecessary Probe Response frames for cases where the STA
851 * is less likely to see them (Probe Request frame sent on a
852 * neighboring, but partially overlapping, channel).
854 if (elems
.ds_params
&&
855 hapd
->iface
->current_mode
&&
856 (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
||
857 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211B
) &&
858 hapd
->iconf
->channel
!= elems
.ds_params
[0]) {
859 wpa_printf(MSG_DEBUG
,
860 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
861 hapd
->iconf
->channel
, elems
.ds_params
[0]);
866 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.wps_ie
) {
868 wps
= ieee802_11_vendor_ie_concat(ie
, ie_len
, WPS_DEV_OUI_WFA
);
869 if (wps
&& !p2p_group_match_dev_type(hapd
->p2p_group
, wps
)) {
870 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
871 "due to mismatch with Requested Device "
879 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.p2p
) {
881 p2p
= ieee802_11_vendor_ie_concat(ie
, ie_len
, P2P_IE_VENDOR_TYPE
);
882 if (p2p
&& !p2p_group_match_dev_id(hapd
->p2p_group
, p2p
)) {
883 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
884 "due to mismatch with Device ID");
890 #endif /* CONFIG_P2P */
892 if (hapd
->conf
->ignore_broadcast_ssid
&& elems
.ssid_len
== 0 &&
893 elems
.ssid_list_len
== 0 && elems
.short_ssid_list_len
== 0) {
894 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
895 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
900 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
901 elems
.ssid_len
== P2P_WILDCARD_SSID_LEN
&&
902 os_memcmp(elems
.ssid
, P2P_WILDCARD_SSID
,
903 P2P_WILDCARD_SSID_LEN
) == 0) {
904 /* Process P2P Wildcard SSID like Wildcard SSID */
907 #endif /* CONFIG_P2P */
909 #ifdef CONFIG_TAXONOMY
911 struct sta_info
*sta
;
912 struct hostapd_sta_info
*info
;
914 if ((sta
= ap_get_sta(hapd
, mgmt
->sa
)) != NULL
) {
915 taxonomy_sta_info_probe_req(hapd
, sta
, ie
, ie_len
);
916 } else if ((info
= sta_track_get(hapd
->iface
,
917 mgmt
->sa
)) != NULL
) {
918 taxonomy_hostapd_sta_info_probe_req(hapd
, info
,
922 #endif /* CONFIG_TAXONOMY */
924 res
= ssid_match(hapd
, elems
.ssid
, elems
.ssid_len
,
925 elems
.ssid_list
, elems
.ssid_list_len
,
926 elems
.short_ssid_list
, elems
.short_ssid_list_len
);
927 if (res
== NO_SSID_MATCH
) {
928 if (!(mgmt
->da
[0] & 0x01)) {
929 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
930 " for foreign SSID '%s' (DA " MACSTR
")%s",
932 wpa_ssid_txt(elems
.ssid
, elems
.ssid_len
),
934 elems
.ssid_list
? " (SSID list)" : "");
939 if (hapd
->conf
->ignore_broadcast_ssid
&& res
== WILDCARD_SSID_MATCH
) {
940 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
941 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
945 #ifdef CONFIG_INTERWORKING
946 if (hapd
->conf
->interworking
&&
947 elems
.interworking
&& elems
.interworking_len
>= 1) {
948 u8 ant
= elems
.interworking
[0] & 0x0f;
949 if (ant
!= INTERWORKING_ANT_WILDCARD
&&
950 ant
!= hapd
->conf
->access_network_type
) {
951 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
952 " for mismatching ANT %u ignored",
953 MAC2STR(mgmt
->sa
), ant
);
958 if (hapd
->conf
->interworking
&& elems
.interworking
&&
959 (elems
.interworking_len
== 7 || elems
.interworking_len
== 9)) {
961 if (elems
.interworking_len
== 7)
962 hessid
= elems
.interworking
+ 1;
964 hessid
= elems
.interworking
+ 1 + 2;
965 if (!is_broadcast_ether_addr(hessid
) &&
966 os_memcmp(hessid
, hapd
->conf
->hessid
, ETH_ALEN
) != 0) {
967 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
968 " for mismatching HESSID " MACSTR
970 MAC2STR(mgmt
->sa
), MAC2STR(hessid
));
974 #endif /* CONFIG_INTERWORKING */
977 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
978 supp_rates_11b_only(&elems
)) {
979 /* Indicates support for 11b rates only */
980 wpa_printf(MSG_EXCESSIVE
, "P2P: Ignore Probe Request from "
981 MACSTR
" with only 802.11b rates",
985 #endif /* CONFIG_P2P */
987 /* TODO: verify that supp_rates contains at least one matching rate
988 * with AP configuration */
990 if (hapd
->conf
->no_probe_resp_if_seen_on
&&
991 is_multicast_ether_addr(mgmt
->da
) &&
992 is_multicast_ether_addr(mgmt
->bssid
) &&
993 sta_track_seen_on(hapd
->iface
, mgmt
->sa
,
994 hapd
->conf
->no_probe_resp_if_seen_on
)) {
995 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
996 " since STA has been seen on %s",
997 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
),
998 hapd
->conf
->no_probe_resp_if_seen_on
);
1002 if (hapd
->conf
->no_probe_resp_if_max_sta
&&
1003 is_multicast_ether_addr(mgmt
->da
) &&
1004 is_multicast_ether_addr(mgmt
->bssid
) &&
1005 hapd
->num_sta
>= hapd
->conf
->max_num_sta
&&
1006 !ap_get_sta(hapd
, mgmt
->sa
)) {
1007 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
1008 " since no room for additional STA",
1009 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
));
1013 #ifdef CONFIG_TESTING_OPTIONS
1014 if (hapd
->iconf
->ignore_probe_probability
> 0.0 &&
1015 drand48() < hapd
->iconf
->ignore_probe_probability
) {
1016 wpa_printf(MSG_INFO
,
1017 "TESTING: ignoring probe request from " MACSTR
,
1021 #endif /* CONFIG_TESTING_OPTIONS */
1023 wpa_msg_ctrl(hapd
->msg_ctx
, MSG_INFO
, RX_PROBE_REQUEST
"sa=" MACSTR
1024 " signal=%d", MAC2STR(mgmt
->sa
), ssi_signal
);
1026 resp
= hostapd_gen_probe_resp(hapd
, mgmt
, elems
.p2p
!= NULL
,
1032 * If this is a broadcast probe request, apply no ack policy to avoid
1033 * excessive retries.
1035 noack
= !!(res
== WILDCARD_SSID_MATCH
&&
1036 is_broadcast_ether_addr(mgmt
->da
));
1039 if (hapd
->csa_in_progress
) {
1040 if (hapd
->cs_c_off_proberesp
)
1041 csa_offs
[csa_offs_len
++] =
1042 hapd
->cs_c_off_proberesp
;
1044 if (hapd
->cs_c_off_ecsa_proberesp
)
1045 csa_offs
[csa_offs_len
++] =
1046 hapd
->cs_c_off_ecsa_proberesp
;
1049 ret
= hostapd_drv_send_mlme(hapd
, resp
, resp_len
, noack
,
1050 csa_offs_len
? csa_offs
: NULL
,
1054 wpa_printf(MSG_INFO
, "handle_probe_req: send failed");
1058 wpa_printf(MSG_EXCESSIVE
, "STA " MACSTR
" sent probe request for %s "
1059 "SSID", MAC2STR(mgmt
->sa
),
1060 elems
.ssid_len
== 0 ? "broadcast" : "our");
1064 static u8
* hostapd_probe_resp_offloads(struct hostapd_data
*hapd
,
1067 /* check probe response offloading caps and print warnings */
1068 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD
))
1072 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
&&
1073 (!(hapd
->iface
->probe_resp_offloads
&
1074 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS
|
1075 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2
))))
1076 wpa_printf(MSG_WARNING
, "Device is trying to offload WPS "
1077 "Probe Response while not supporting this");
1078 #endif /* CONFIG_WPS */
1081 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_probe_resp_ie
&&
1082 !(hapd
->iface
->probe_resp_offloads
&
1083 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P
))
1084 wpa_printf(MSG_WARNING
, "Device is trying to offload P2P "
1085 "Probe Response while not supporting this");
1086 #endif /* CONFIG_P2P */
1088 if (hapd
->conf
->interworking
&&
1089 !(hapd
->iface
->probe_resp_offloads
&
1090 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING
))
1091 wpa_printf(MSG_WARNING
, "Device is trying to offload "
1092 "Interworking Probe Response while not supporting "
1095 /* Generate a Probe Response template for the non-P2P case */
1096 return hostapd_gen_probe_resp(hapd
, NULL
, 0, resp_len
);
1099 #endif /* NEED_AP_MLME */
1102 void sta_track_del(struct hostapd_sta_info
*info
)
1104 #ifdef CONFIG_TAXONOMY
1105 wpabuf_free(info
->probe_ie_taxonomy
);
1106 info
->probe_ie_taxonomy
= NULL
;
1107 #endif /* CONFIG_TAXONOMY */
1112 int ieee802_11_build_ap_params(struct hostapd_data
*hapd
,
1113 struct wpa_driver_ap_params
*params
)
1115 struct ieee80211_mgmt
*head
= NULL
;
1117 size_t head_len
= 0, tail_len
= 0;
1119 size_t resp_len
= 0;
1122 u8
*pos
, *tailpos
, *tailend
, *csa_pos
;
1124 #define BEACON_HEAD_BUF_SIZE 256
1125 #define BEACON_TAIL_BUF_SIZE 512
1126 head
= os_zalloc(BEACON_HEAD_BUF_SIZE
);
1127 tail_len
= BEACON_TAIL_BUF_SIZE
;
1129 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
)
1130 tail_len
+= wpabuf_len(hapd
->wps_beacon_ie
);
1131 #endif /* CONFIG_WPS */
1133 if (hapd
->p2p_beacon_ie
)
1134 tail_len
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1135 #endif /* CONFIG_P2P */
1137 if (hapd
->iface
->fst_ies
)
1138 tail_len
+= wpabuf_len(hapd
->iface
->fst_ies
);
1139 #endif /* CONFIG_FST */
1140 if (hapd
->conf
->vendor_elements
)
1141 tail_len
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1143 #ifdef CONFIG_IEEE80211AC
1144 if (hapd
->conf
->vendor_vht
) {
1145 tail_len
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
1146 2 + sizeof(struct ieee80211_vht_operation
);
1148 #endif /* CONFIG_IEEE80211AC */
1150 #ifdef CONFIG_IEEE80211AX
1151 if (hapd
->iconf
->ieee80211ax
) {
1152 tail_len
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
1153 3 + sizeof(struct ieee80211_he_operation
) +
1154 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
1155 3 + sizeof(struct ieee80211_spatial_reuse
);
1157 #endif /* CONFIG_IEEE80211AX */
1159 tail_len
+= hostapd_mbo_ie_len(hapd
);
1160 tail_len
+= hostapd_eid_owe_trans_len(hapd
);
1162 tailpos
= tail
= os_malloc(tail_len
);
1163 if (head
== NULL
|| tail
== NULL
) {
1164 wpa_printf(MSG_ERROR
, "Failed to set beacon data");
1169 tailend
= tail
+ tail_len
;
1171 head
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
1172 WLAN_FC_STYPE_BEACON
);
1173 head
->duration
= host_to_le16(0);
1174 os_memset(head
->da
, 0xff, ETH_ALEN
);
1176 os_memcpy(head
->sa
, hapd
->own_addr
, ETH_ALEN
);
1177 os_memcpy(head
->bssid
, hapd
->own_addr
, ETH_ALEN
);
1178 head
->u
.beacon
.beacon_int
=
1179 host_to_le16(hapd
->iconf
->beacon_int
);
1181 /* hardware or low-level driver will setup seq_ctrl and timestamp */
1182 capab_info
= hostapd_own_capab_info(hapd
);
1183 head
->u
.beacon
.capab_info
= host_to_le16(capab_info
);
1184 pos
= &head
->u
.beacon
.variable
[0];
1187 *pos
++ = WLAN_EID_SSID
;
1188 if (hapd
->conf
->ignore_broadcast_ssid
== 2) {
1189 /* clear the data, but keep the correct length of the SSID */
1190 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1191 os_memset(pos
, 0, hapd
->conf
->ssid
.ssid_len
);
1192 pos
+= hapd
->conf
->ssid
.ssid_len
;
1193 } else if (hapd
->conf
->ignore_broadcast_ssid
) {
1194 *pos
++ = 0; /* empty SSID */
1196 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1197 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
,
1198 hapd
->conf
->ssid
.ssid_len
);
1199 pos
+= hapd
->conf
->ssid
.ssid_len
;
1202 /* Supported rates */
1203 pos
= hostapd_eid_supp_rates(hapd
, pos
);
1206 pos
= hostapd_eid_ds_params(hapd
, pos
);
1208 head_len
= pos
- (u8
*) head
;
1210 tailpos
= hostapd_eid_country(hapd
, tailpos
, tailend
- tailpos
);
1212 /* Power Constraint element */
1213 tailpos
= hostapd_eid_pwr_constraint(hapd
, tailpos
);
1216 csa_pos
= hostapd_eid_csa(hapd
, tailpos
);
1217 if (csa_pos
!= tailpos
)
1218 hapd
->cs_c_off_beacon
= csa_pos
- tail
- 1;
1221 /* ERP Information element */
1222 tailpos
= hostapd_eid_erp_info(hapd
, tailpos
);
1224 /* Extended supported rates */
1225 tailpos
= hostapd_eid_ext_supp_rates(hapd
, tailpos
);
1227 tailpos
= hostapd_get_rsne(hapd
, tailpos
, tailend
- tailpos
);
1228 tailpos
= hostapd_eid_bss_load(hapd
, tailpos
, tailend
- tailpos
);
1229 tailpos
= hostapd_eid_rm_enabled_capab(hapd
, tailpos
,
1231 tailpos
= hostapd_get_mde(hapd
, tailpos
, tailend
- tailpos
);
1234 csa_pos
= hostapd_eid_ecsa(hapd
, tailpos
);
1235 if (csa_pos
!= tailpos
)
1236 hapd
->cs_c_off_ecsa_beacon
= csa_pos
- tail
- 1;
1239 tailpos
= hostapd_eid_supported_op_classes(hapd
, tailpos
);
1240 tailpos
= hostapd_eid_ht_capabilities(hapd
, tailpos
);
1241 tailpos
= hostapd_eid_ht_operation(hapd
, tailpos
);
1243 tailpos
= hostapd_eid_ext_capab(hapd
, tailpos
);
1246 * TODO: Time Advertisement element should only be included in some
1247 * DTIM Beacon frames.
1249 tailpos
= hostapd_eid_time_adv(hapd
, tailpos
);
1251 tailpos
= hostapd_eid_interworking(hapd
, tailpos
);
1252 tailpos
= hostapd_eid_adv_proto(hapd
, tailpos
);
1253 tailpos
= hostapd_eid_roaming_consortium(hapd
, tailpos
);
1256 if (hapd
->iface
->fst_ies
) {
1257 os_memcpy(tailpos
, wpabuf_head(hapd
->iface
->fst_ies
),
1258 wpabuf_len(hapd
->iface
->fst_ies
));
1259 tailpos
+= wpabuf_len(hapd
->iface
->fst_ies
);
1261 #endif /* CONFIG_FST */
1263 #ifdef CONFIG_IEEE80211AC
1264 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
) {
1265 tailpos
= hostapd_eid_vht_capabilities(hapd
, tailpos
, 0);
1266 tailpos
= hostapd_eid_vht_operation(hapd
, tailpos
);
1267 tailpos
= hostapd_eid_txpower_envelope(hapd
, tailpos
);
1268 tailpos
= hostapd_eid_wb_chsw_wrapper(hapd
, tailpos
);
1270 #endif /* CONFIG_IEEE80211AC */
1272 tailpos
= hostapd_eid_fils_indic(hapd
, tailpos
, 0);
1273 tailpos
= hostapd_get_rsnxe(hapd
, tailpos
, tailend
- tailpos
);
1275 #ifdef CONFIG_IEEE80211AX
1276 if (hapd
->iconf
->ieee80211ax
) {
1277 tailpos
= hostapd_eid_he_capab(hapd
, tailpos
,
1279 tailpos
= hostapd_eid_he_operation(hapd
, tailpos
);
1280 tailpos
= hostapd_eid_spatial_reuse(hapd
, tailpos
);
1281 tailpos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, tailpos
);
1283 #endif /* CONFIG_IEEE80211AX */
1285 #ifdef CONFIG_IEEE80211AC
1286 if (hapd
->conf
->vendor_vht
)
1287 tailpos
= hostapd_eid_vendor_vht(hapd
, tailpos
);
1288 #endif /* CONFIG_IEEE80211AC */
1291 tailpos
= hostapd_get_wpa_ie(hapd
, tailpos
, tailend
- tailpos
);
1292 tailpos
= hostapd_get_osen_ie(hapd
, tailpos
, tailend
- tailpos
);
1294 /* Wi-Fi Alliance WMM */
1295 tailpos
= hostapd_eid_wmm(hapd
, tailpos
);
1298 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
) {
1299 os_memcpy(tailpos
, wpabuf_head(hapd
->wps_beacon_ie
),
1300 wpabuf_len(hapd
->wps_beacon_ie
));
1301 tailpos
+= wpabuf_len(hapd
->wps_beacon_ie
);
1303 #endif /* CONFIG_WPS */
1306 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_beacon_ie
) {
1307 os_memcpy(tailpos
, wpabuf_head(hapd
->p2p_beacon_ie
),
1308 wpabuf_len(hapd
->p2p_beacon_ie
));
1309 tailpos
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1311 #endif /* CONFIG_P2P */
1312 #ifdef CONFIG_P2P_MANAGER
1313 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
1315 tailpos
= hostapd_eid_p2p_manage(hapd
, tailpos
);
1316 #endif /* CONFIG_P2P_MANAGER */
1319 tailpos
= hostapd_eid_hs20_indication(hapd
, tailpos
);
1320 #endif /* CONFIG_HS20 */
1322 tailpos
= hostapd_eid_mbo(hapd
, tailpos
, tail
+ tail_len
- tailpos
);
1323 tailpos
= hostapd_eid_owe_trans(hapd
, tailpos
,
1324 tail
+ tail_len
- tailpos
);
1326 if (hapd
->conf
->vendor_elements
) {
1327 os_memcpy(tailpos
, wpabuf_head(hapd
->conf
->vendor_elements
),
1328 wpabuf_len(hapd
->conf
->vendor_elements
));
1329 tailpos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1332 tail_len
= tailpos
> tail
? tailpos
- tail
: 0;
1334 resp
= hostapd_probe_resp_offloads(hapd
, &resp_len
);
1335 #endif /* NEED_AP_MLME */
1337 os_memset(params
, 0, sizeof(*params
));
1338 params
->head
= (u8
*) head
;
1339 params
->head_len
= head_len
;
1340 params
->tail
= tail
;
1341 params
->tail_len
= tail_len
;
1342 params
->proberesp
= resp
;
1343 params
->proberesp_len
= resp_len
;
1344 params
->dtim_period
= hapd
->conf
->dtim_period
;
1345 params
->beacon_int
= hapd
->iconf
->beacon_int
;
1346 params
->basic_rates
= hapd
->iface
->basic_rates
;
1347 params
->beacon_rate
= hapd
->iconf
->beacon_rate
;
1348 params
->rate_type
= hapd
->iconf
->rate_type
;
1349 params
->ssid
= hapd
->conf
->ssid
.ssid
;
1350 params
->ssid_len
= hapd
->conf
->ssid
.ssid_len
;
1351 if ((hapd
->conf
->wpa
& (WPA_PROTO_WPA
| WPA_PROTO_RSN
)) ==
1352 (WPA_PROTO_WPA
| WPA_PROTO_RSN
))
1353 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
|
1354 hapd
->conf
->rsn_pairwise
;
1355 else if (hapd
->conf
->wpa
& WPA_PROTO_RSN
)
1356 params
->pairwise_ciphers
= hapd
->conf
->rsn_pairwise
;
1357 else if (hapd
->conf
->wpa
& WPA_PROTO_WPA
)
1358 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
;
1359 params
->group_cipher
= hapd
->conf
->wpa_group
;
1360 params
->key_mgmt_suites
= hapd
->conf
->wpa_key_mgmt
;
1361 params
->auth_algs
= hapd
->conf
->auth_algs
;
1362 params
->wpa_version
= hapd
->conf
->wpa
;
1363 params
->privacy
= hapd
->conf
->wpa
;
1365 params
->privacy
|= hapd
->conf
->ssid
.wep
.keys_set
||
1366 (hapd
->conf
->ieee802_1x
&&
1367 (hapd
->conf
->default_wep_key_len
||
1368 hapd
->conf
->individual_wep_key_len
));
1369 #endif /* CONFIG_WEP */
1370 switch (hapd
->conf
->ignore_broadcast_ssid
) {
1372 params
->hide_ssid
= NO_SSID_HIDING
;
1375 params
->hide_ssid
= HIDDEN_SSID_ZERO_LEN
;
1378 params
->hide_ssid
= HIDDEN_SSID_ZERO_CONTENTS
;
1381 params
->isolate
= hapd
->conf
->isolate
;
1383 params
->cts_protect
= !!(ieee802_11_erp_info(hapd
) &
1384 ERP_INFO_USE_PROTECTION
);
1385 params
->preamble
= hapd
->iface
->num_sta_no_short_preamble
== 0 &&
1386 hapd
->iconf
->preamble
== SHORT_PREAMBLE
;
1387 if (hapd
->iface
->current_mode
&&
1388 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
1389 params
->short_slot_time
=
1390 hapd
->iface
->num_sta_no_short_slot_time
> 0 ? 0 : 1;
1392 params
->short_slot_time
= -1;
1393 if (!hapd
->iconf
->ieee80211n
|| hapd
->conf
->disable_11n
)
1394 params
->ht_opmode
= -1;
1396 params
->ht_opmode
= hapd
->iface
->ht_op_mode
;
1397 #endif /* NEED_AP_MLME */
1398 params
->interworking
= hapd
->conf
->interworking
;
1399 if (hapd
->conf
->interworking
&&
1400 !is_zero_ether_addr(hapd
->conf
->hessid
))
1401 params
->hessid
= hapd
->conf
->hessid
;
1402 params
->access_network_type
= hapd
->conf
->access_network_type
;
1403 params
->ap_max_inactivity
= hapd
->conf
->ap_max_inactivity
;
1405 params
->p2p_go_ctwindow
= hapd
->iconf
->p2p_go_ctwindow
;
1406 #endif /* CONFIG_P2P */
1408 params
->disable_dgaf
= hapd
->conf
->disable_dgaf
;
1409 if (hapd
->conf
->osen
) {
1410 params
->privacy
= 1;
1413 #endif /* CONFIG_HS20 */
1414 params
->multicast_to_unicast
= hapd
->conf
->multicast_to_unicast
;
1415 params
->pbss
= hapd
->conf
->pbss
;
1417 if (hapd
->conf
->ftm_responder
) {
1418 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_FTM_RESPONDER
) {
1419 params
->ftm_responder
= 1;
1420 params
->lci
= hapd
->iface
->conf
->lci
;
1421 params
->civic
= hapd
->iface
->conf
->civic
;
1423 wpa_printf(MSG_WARNING
,
1424 "Not configuring FTM responder as the driver doesn't advertise support for it");
1432 void ieee802_11_free_ap_params(struct wpa_driver_ap_params
*params
)
1434 os_free(params
->tail
);
1435 params
->tail
= NULL
;
1436 os_free(params
->head
);
1437 params
->head
= NULL
;
1438 os_free(params
->proberesp
);
1439 params
->proberesp
= NULL
;
1443 int ieee802_11_set_beacon(struct hostapd_data
*hapd
)
1445 struct wpa_driver_ap_params params
;
1446 struct hostapd_freq_params freq
;
1447 struct hostapd_iface
*iface
= hapd
->iface
;
1448 struct hostapd_config
*iconf
= iface
->conf
;
1449 struct hostapd_hw_modes
*cmode
= iface
->current_mode
;
1450 struct wpabuf
*beacon
, *proberesp
, *assocresp
;
1453 if (hapd
->csa_in_progress
) {
1454 wpa_printf(MSG_ERROR
, "Cannot set beacons during CSA period");
1458 hapd
->beacon_set_done
= 1;
1460 if (ieee802_11_build_ap_params(hapd
, ¶ms
) < 0)
1463 if (hostapd_build_ap_extra_ies(hapd
, &beacon
, &proberesp
, &assocresp
) <
1467 params
.beacon_ies
= beacon
;
1468 params
.proberesp_ies
= proberesp
;
1469 params
.assocresp_ies
= assocresp
;
1470 params
.reenable
= hapd
->reenable_beacon
;
1471 #ifdef CONFIG_IEEE80211AX
1472 params
.he_spr
= !!hapd
->iface
->conf
->spr
.sr_control
;
1473 params
.he_spr_srg_obss_pd_min_offset
=
1474 hapd
->iface
->conf
->spr
.srg_obss_pd_min_offset
;
1475 params
.he_spr_srg_obss_pd_max_offset
=
1476 hapd
->iface
->conf
->spr
.srg_obss_pd_max_offset
;
1477 params
.he_bss_color_disabled
=
1478 hapd
->iface
->conf
->he_op
.he_bss_color_disabled
;
1479 params
.he_bss_color_partial
=
1480 hapd
->iface
->conf
->he_op
.he_bss_color_partial
;
1481 params
.he_bss_color
= hapd
->iface
->conf
->he_op
.he_bss_color
;
1482 params
.twt_responder
= hostapd_get_he_twt_responder(hapd
,
1484 #endif /* CONFIG_IEEE80211AX */
1485 hapd
->reenable_beacon
= 0;
1488 hostapd_set_freq_params(&freq
, iconf
->hw_mode
, iface
->freq
,
1489 iconf
->channel
, iconf
->enable_edmg
,
1490 iconf
->edmg_channel
, iconf
->ieee80211n
,
1491 iconf
->ieee80211ac
, iconf
->ieee80211ax
,
1492 iconf
->secondary_channel
,
1493 hostapd_get_oper_chwidth(iconf
),
1494 hostapd_get_oper_centr_freq_seg0_idx(iconf
),
1495 hostapd_get_oper_centr_freq_seg1_idx(iconf
),
1497 &cmode
->he_capab
[IEEE80211_MODE_AP
]) == 0)
1498 params
.freq
= &freq
;
1500 res
= hostapd_drv_set_ap(hapd
, ¶ms
);
1501 hostapd_free_ap_extra_ies(hapd
, beacon
, proberesp
, assocresp
);
1503 wpa_printf(MSG_ERROR
, "Failed to set beacon parameters");
1507 ieee802_11_free_ap_params(¶ms
);
1512 int ieee802_11_set_beacons(struct hostapd_iface
*iface
)
1517 for (i
= 0; i
< iface
->num_bss
; i
++) {
1518 if (iface
->bss
[i
]->started
&&
1519 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1527 /* only update beacons if started */
1528 int ieee802_11_update_beacons(struct hostapd_iface
*iface
)
1533 for (i
= 0; i
< iface
->num_bss
; i
++) {
1534 if (iface
->bss
[i
]->beacon_set_done
&& iface
->bss
[i
]->started
&&
1535 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1542 #endif /* CONFIG_NATIVE_WINDOWS */