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 #ifdef CONFIG_TESTING_OPTIONS
327 if (hapd
->conf
->no_beacon_rsnxe
) {
328 wpa_printf(MSG_INFO
, "TESTING: Do not add RSNXE into Beacon");
331 #endif /* CONFIG_TESTING_OPTIONS */
332 ie
= hostapd_wpa_ie(hapd
, WLAN_EID_RSNX
);
333 if (!ie
|| 2U + ie
[1] > len
)
336 os_memcpy(pos
, ie
, 2 + ie
[1]);
337 return pos
+ 2 + ie
[1];
341 static u8
* hostapd_get_wpa_ie(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
345 ie
= hostapd_vendor_wpa_ie(hapd
, WPA_IE_VENDOR_TYPE
);
346 if (!ie
|| 2U + ie
[1] > len
)
349 os_memcpy(pos
, ie
, 2 + ie
[1]);
350 return pos
+ 2 + ie
[1];
354 static u8
* hostapd_get_osen_ie(struct hostapd_data
*hapd
, u8
*pos
, size_t len
)
358 ie
= hostapd_vendor_wpa_ie(hapd
, OSEN_IE_VENDOR_TYPE
);
359 if (!ie
|| 2U + ie
[1] > len
)
362 os_memcpy(pos
, ie
, 2 + ie
[1]);
363 return pos
+ 2 + ie
[1];
367 static u8
* hostapd_eid_csa(struct hostapd_data
*hapd
, u8
*eid
)
369 #ifdef CONFIG_TESTING_OPTIONS
370 if (hapd
->iface
->cs_oper_class
&& hapd
->iconf
->ecsa_ie_only
)
372 #endif /* CONFIG_TESTING_OPTIONS */
374 if (!hapd
->cs_freq_params
.channel
)
377 *eid
++ = WLAN_EID_CHANNEL_SWITCH
;
379 *eid
++ = hapd
->cs_block_tx
;
380 *eid
++ = hapd
->cs_freq_params
.channel
;
381 *eid
++ = hapd
->cs_count
;
387 static u8
* hostapd_eid_ecsa(struct hostapd_data
*hapd
, u8
*eid
)
389 if (!hapd
->cs_freq_params
.channel
|| !hapd
->iface
->cs_oper_class
)
392 *eid
++ = WLAN_EID_EXT_CHANSWITCH_ANN
;
394 *eid
++ = hapd
->cs_block_tx
;
395 *eid
++ = hapd
->iface
->cs_oper_class
;
396 *eid
++ = hapd
->cs_freq_params
.channel
;
397 *eid
++ = hapd
->cs_count
;
403 static u8
* hostapd_eid_supported_op_classes(struct hostapd_data
*hapd
, u8
*eid
)
405 u8 op_class
, channel
;
407 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_AP_CSA
) ||
411 if (ieee80211_freq_to_channel_ext(hapd
->iface
->freq
,
412 hapd
->iconf
->secondary_channel
,
413 hostapd_get_oper_chwidth(hapd
->iconf
),
414 &op_class
, &channel
) ==
418 *eid
++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES
;
421 /* Current Operating Class */
424 /* TODO: Advertise all the supported operating classes */
431 static u8
* hostapd_gen_probe_resp(struct hostapd_data
*hapd
,
432 const struct ieee80211_mgmt
*req
,
433 int is_p2p
, size_t *resp_len
)
435 struct ieee80211_mgmt
*resp
;
436 u8
*pos
, *epos
, *csa_pos
;
439 #define MAX_PROBERESP_LEN 768
440 buflen
= MAX_PROBERESP_LEN
;
442 if (hapd
->wps_probe_resp_ie
)
443 buflen
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
444 #endif /* CONFIG_WPS */
446 if (hapd
->p2p_probe_resp_ie
)
447 buflen
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
448 #endif /* CONFIG_P2P */
450 if (hapd
->iface
->fst_ies
)
451 buflen
+= wpabuf_len(hapd
->iface
->fst_ies
);
452 #endif /* CONFIG_FST */
453 if (hapd
->conf
->vendor_elements
)
454 buflen
+= wpabuf_len(hapd
->conf
->vendor_elements
);
455 if (hapd
->conf
->vendor_vht
) {
456 buflen
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
457 2 + sizeof(struct ieee80211_vht_operation
);
460 #ifdef CONFIG_IEEE80211AX
461 if (hapd
->iconf
->ieee80211ax
) {
462 buflen
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
463 3 + sizeof(struct ieee80211_he_operation
) +
464 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
465 3 + sizeof(struct ieee80211_spatial_reuse
);
467 #endif /* CONFIG_IEEE80211AX */
469 buflen
+= hostapd_mbo_ie_len(hapd
);
470 buflen
+= hostapd_eid_owe_trans_len(hapd
);
472 resp
= os_zalloc(buflen
);
476 epos
= ((u8
*) resp
) + MAX_PROBERESP_LEN
;
478 resp
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
479 WLAN_FC_STYPE_PROBE_RESP
);
481 os_memcpy(resp
->da
, req
->sa
, ETH_ALEN
);
482 os_memcpy(resp
->sa
, hapd
->own_addr
, ETH_ALEN
);
484 os_memcpy(resp
->bssid
, hapd
->own_addr
, ETH_ALEN
);
485 resp
->u
.probe_resp
.beacon_int
=
486 host_to_le16(hapd
->iconf
->beacon_int
);
488 /* hardware or low-level driver will setup seq_ctrl and timestamp */
489 resp
->u
.probe_resp
.capab_info
=
490 host_to_le16(hostapd_own_capab_info(hapd
));
492 pos
= resp
->u
.probe_resp
.variable
;
493 *pos
++ = WLAN_EID_SSID
;
494 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
495 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
, hapd
->conf
->ssid
.ssid_len
);
496 pos
+= hapd
->conf
->ssid
.ssid_len
;
498 /* Supported rates */
499 pos
= hostapd_eid_supp_rates(hapd
, pos
);
502 pos
= hostapd_eid_ds_params(hapd
, pos
);
504 pos
= hostapd_eid_country(hapd
, pos
, epos
- pos
);
506 /* Power Constraint element */
507 pos
= hostapd_eid_pwr_constraint(hapd
, pos
);
510 csa_pos
= hostapd_eid_csa(hapd
, pos
);
512 hapd
->cs_c_off_proberesp
= csa_pos
- (u8
*) resp
- 1;
515 /* ERP Information element */
516 pos
= hostapd_eid_erp_info(hapd
, pos
);
518 /* Extended supported rates */
519 pos
= hostapd_eid_ext_supp_rates(hapd
, pos
);
521 pos
= hostapd_get_rsne(hapd
, pos
, epos
- pos
);
522 pos
= hostapd_eid_bss_load(hapd
, pos
, epos
- pos
);
523 pos
= hostapd_eid_rm_enabled_capab(hapd
, pos
, epos
- pos
);
524 pos
= hostapd_get_mde(hapd
, pos
, epos
- pos
);
527 csa_pos
= hostapd_eid_ecsa(hapd
, pos
);
529 hapd
->cs_c_off_ecsa_proberesp
= csa_pos
- (u8
*) resp
- 1;
532 pos
= hostapd_eid_supported_op_classes(hapd
, pos
);
533 pos
= hostapd_eid_ht_capabilities(hapd
, pos
);
534 pos
= hostapd_eid_ht_operation(hapd
, pos
);
536 pos
= hostapd_eid_ext_capab(hapd
, pos
);
538 pos
= hostapd_eid_time_adv(hapd
, pos
);
539 pos
= hostapd_eid_time_zone(hapd
, pos
);
541 pos
= hostapd_eid_interworking(hapd
, pos
);
542 pos
= hostapd_eid_adv_proto(hapd
, pos
);
543 pos
= hostapd_eid_roaming_consortium(hapd
, pos
);
546 if (hapd
->iface
->fst_ies
) {
547 os_memcpy(pos
, wpabuf_head(hapd
->iface
->fst_ies
),
548 wpabuf_len(hapd
->iface
->fst_ies
));
549 pos
+= wpabuf_len(hapd
->iface
->fst_ies
);
551 #endif /* CONFIG_FST */
553 #ifdef CONFIG_IEEE80211AC
554 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
&&
555 !is_6ghz_op_class(hapd
->iconf
->op_class
)) {
556 pos
= hostapd_eid_vht_capabilities(hapd
, pos
, 0);
557 pos
= hostapd_eid_vht_operation(hapd
, pos
);
558 pos
= hostapd_eid_txpower_envelope(hapd
, pos
);
559 pos
= hostapd_eid_wb_chsw_wrapper(hapd
, pos
);
561 #endif /* CONFIG_IEEE80211AC */
563 pos
= hostapd_eid_fils_indic(hapd
, pos
, 0);
564 pos
= hostapd_get_rsnxe(hapd
, pos
, epos
- pos
);
566 #ifdef CONFIG_IEEE80211AX
567 if (hapd
->iconf
->ieee80211ax
) {
568 pos
= hostapd_eid_he_capab(hapd
, pos
, IEEE80211_MODE_AP
);
569 pos
= hostapd_eid_he_operation(hapd
, pos
);
570 pos
= hostapd_eid_spatial_reuse(hapd
, pos
);
571 pos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, pos
);
573 #endif /* CONFIG_IEEE80211AX */
575 #ifdef CONFIG_IEEE80211AC
576 if (hapd
->conf
->vendor_vht
)
577 pos
= hostapd_eid_vendor_vht(hapd
, pos
);
578 #endif /* CONFIG_IEEE80211AC */
581 pos
= hostapd_get_wpa_ie(hapd
, pos
, epos
- pos
);
582 pos
= hostapd_get_osen_ie(hapd
, pos
, epos
- pos
);
584 /* Wi-Fi Alliance WMM */
585 pos
= hostapd_eid_wmm(hapd
, pos
);
588 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
) {
589 os_memcpy(pos
, wpabuf_head(hapd
->wps_probe_resp_ie
),
590 wpabuf_len(hapd
->wps_probe_resp_ie
));
591 pos
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
593 #endif /* CONFIG_WPS */
596 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && is_p2p
&&
597 hapd
->p2p_probe_resp_ie
) {
598 os_memcpy(pos
, wpabuf_head(hapd
->p2p_probe_resp_ie
),
599 wpabuf_len(hapd
->p2p_probe_resp_ie
));
600 pos
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
602 #endif /* CONFIG_P2P */
603 #ifdef CONFIG_P2P_MANAGER
604 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
606 pos
= hostapd_eid_p2p_manage(hapd
, pos
);
607 #endif /* CONFIG_P2P_MANAGER */
610 pos
= hostapd_eid_hs20_indication(hapd
, pos
);
611 #endif /* CONFIG_HS20 */
613 pos
= hostapd_eid_mbo(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
614 pos
= hostapd_eid_owe_trans(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
616 if (hapd
->conf
->vendor_elements
) {
617 os_memcpy(pos
, wpabuf_head(hapd
->conf
->vendor_elements
),
618 wpabuf_len(hapd
->conf
->vendor_elements
));
619 pos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
622 *resp_len
= pos
- (u8
*) resp
;
627 enum ssid_match_result
{
633 static enum ssid_match_result
ssid_match(struct hostapd_data
*hapd
,
634 const u8
*ssid
, size_t ssid_len
,
636 size_t ssid_list_len
,
637 const u8
*short_ssid_list
,
638 size_t short_ssid_list_len
)
645 if (ssid_len
== hapd
->conf
->ssid
.ssid_len
&&
646 os_memcmp(ssid
, hapd
->conf
->ssid
.ssid
, ssid_len
) == 0)
647 return EXACT_SSID_MATCH
;
651 end
= ssid_list
+ ssid_list_len
;
652 while (end
- pos
>= 2) {
653 if (2 + pos
[1] > end
- pos
)
657 if (pos
[1] == hapd
->conf
->ssid
.ssid_len
&&
658 os_memcmp(pos
+ 2, hapd
->conf
->ssid
.ssid
,
660 return EXACT_SSID_MATCH
;
665 if (short_ssid_list
) {
666 pos
= short_ssid_list
;
667 end
= short_ssid_list
+ short_ssid_list_len
;
668 while (end
- pos
>= 4) {
669 if (hapd
->conf
->ssid
.short_ssid
== WPA_GET_LE32(pos
))
670 return EXACT_SSID_MATCH
;
675 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
679 void sta_track_expire(struct hostapd_iface
*iface
, int force
)
681 struct os_reltime now
;
682 struct hostapd_sta_info
*info
;
684 if (!iface
->num_sta_seen
)
687 os_get_reltime(&now
);
688 while ((info
= dl_list_first(&iface
->sta_seen
, struct hostapd_sta_info
,
691 !os_reltime_expired(&now
, &info
->last_seen
,
692 iface
->conf
->track_sta_max_age
))
696 wpa_printf(MSG_MSGDUMP
, "%s: Expire STA tracking entry for "
697 MACSTR
, iface
->bss
[0]->conf
->iface
,
698 MAC2STR(info
->addr
));
699 dl_list_del(&info
->list
);
700 iface
->num_sta_seen
--;
706 static struct hostapd_sta_info
* sta_track_get(struct hostapd_iface
*iface
,
709 struct hostapd_sta_info
*info
;
711 dl_list_for_each(info
, &iface
->sta_seen
, struct hostapd_sta_info
, list
)
712 if (os_memcmp(addr
, info
->addr
, ETH_ALEN
) == 0)
719 void sta_track_add(struct hostapd_iface
*iface
, const u8
*addr
, int ssi_signal
)
721 struct hostapd_sta_info
*info
;
723 info
= sta_track_get(iface
, addr
);
725 /* Move the most recent entry to the end of the list */
726 dl_list_del(&info
->list
);
727 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
728 os_get_reltime(&info
->last_seen
);
729 info
->ssi_signal
= ssi_signal
;
733 /* Add a new entry */
734 info
= os_zalloc(sizeof(*info
));
737 os_memcpy(info
->addr
, addr
, ETH_ALEN
);
738 os_get_reltime(&info
->last_seen
);
739 info
->ssi_signal
= ssi_signal
;
741 if (iface
->num_sta_seen
>= iface
->conf
->track_sta_max_num
) {
742 /* Expire oldest entry to make room for a new one */
743 sta_track_expire(iface
, 1);
746 wpa_printf(MSG_MSGDUMP
, "%s: Add STA tracking entry for "
747 MACSTR
, iface
->bss
[0]->conf
->iface
, MAC2STR(addr
));
748 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
749 iface
->num_sta_seen
++;
753 struct hostapd_data
*
754 sta_track_seen_on(struct hostapd_iface
*iface
, const u8
*addr
,
757 struct hapd_interfaces
*interfaces
= iface
->interfaces
;
760 for (i
= 0; i
< interfaces
->count
; i
++) {
761 struct hostapd_data
*hapd
= NULL
;
763 iface
= interfaces
->iface
[i
];
764 for (j
= 0; j
< iface
->num_bss
; j
++) {
765 hapd
= iface
->bss
[j
];
766 if (os_strcmp(ifname
, hapd
->conf
->iface
) == 0)
771 if (hapd
&& sta_track_get(iface
, addr
))
779 #ifdef CONFIG_TAXONOMY
780 void sta_track_claim_taxonomy_info(struct hostapd_iface
*iface
, const u8
*addr
,
781 struct wpabuf
**probe_ie_taxonomy
)
783 struct hostapd_sta_info
*info
;
785 info
= sta_track_get(iface
, addr
);
789 wpabuf_free(*probe_ie_taxonomy
);
790 *probe_ie_taxonomy
= info
->probe_ie_taxonomy
;
791 info
->probe_ie_taxonomy
= NULL
;
793 #endif /* CONFIG_TAXONOMY */
796 void handle_probe_req(struct hostapd_data
*hapd
,
797 const struct ieee80211_mgmt
*mgmt
, size_t len
,
801 struct ieee802_11_elems elems
;
806 enum ssid_match_result res
;
810 struct radius_sta rad_info
;
812 if (len
< IEEE80211_HDRLEN
)
814 ie
= ((const u8
*) mgmt
) + IEEE80211_HDRLEN
;
815 if (hapd
->iconf
->track_sta_max_num
)
816 sta_track_add(hapd
->iface
, mgmt
->sa
, ssi_signal
);
817 ie_len
= len
- IEEE80211_HDRLEN
;
819 ret
= hostapd_allowed_address(hapd
, mgmt
->sa
, (const u8
*) mgmt
, len
,
821 if (ret
== HOSTAPD_ACL_REJECT
) {
822 wpa_msg(hapd
->msg_ctx
, MSG_DEBUG
,
823 "Ignore Probe Request frame from " MACSTR
824 " due to ACL reject ", MAC2STR(mgmt
->sa
));
828 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++)
829 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
830 mgmt
->sa
, mgmt
->da
, mgmt
->bssid
,
831 ie
, ie_len
, ssi_signal
) > 0)
834 if (!hapd
->conf
->send_probe_response
)
837 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 0) == ParseFailed
) {
838 wpa_printf(MSG_DEBUG
, "Could not parse ProbeReq from " MACSTR
,
843 if ((!elems
.ssid
|| !elems
.supp_rates
)) {
844 wpa_printf(MSG_DEBUG
, "STA " MACSTR
" sent probe request "
845 "without SSID or supported rates element",
851 * No need to reply if the Probe Request frame was sent on an adjacent
852 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
853 * AP with dot11RadioMeasurementActivated set to true, but strictly
854 * speaking does not allow such ignoring of Probe Request frames if
855 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
856 * number of unnecessary Probe Response frames for cases where the STA
857 * is less likely to see them (Probe Request frame sent on a
858 * neighboring, but partially overlapping, channel).
860 if (elems
.ds_params
&&
861 hapd
->iface
->current_mode
&&
862 (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
||
863 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211B
) &&
864 hapd
->iconf
->channel
!= elems
.ds_params
[0]) {
865 wpa_printf(MSG_DEBUG
,
866 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
867 hapd
->iconf
->channel
, elems
.ds_params
[0]);
872 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.wps_ie
) {
874 wps
= ieee802_11_vendor_ie_concat(ie
, ie_len
, WPS_DEV_OUI_WFA
);
875 if (wps
&& !p2p_group_match_dev_type(hapd
->p2p_group
, wps
)) {
876 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
877 "due to mismatch with Requested Device "
885 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.p2p
) {
887 p2p
= ieee802_11_vendor_ie_concat(ie
, ie_len
, P2P_IE_VENDOR_TYPE
);
888 if (p2p
&& !p2p_group_match_dev_id(hapd
->p2p_group
, p2p
)) {
889 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
890 "due to mismatch with Device ID");
896 #endif /* CONFIG_P2P */
898 if (hapd
->conf
->ignore_broadcast_ssid
&& elems
.ssid_len
== 0 &&
899 elems
.ssid_list_len
== 0 && elems
.short_ssid_list_len
== 0) {
900 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
901 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
906 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
907 elems
.ssid_len
== P2P_WILDCARD_SSID_LEN
&&
908 os_memcmp(elems
.ssid
, P2P_WILDCARD_SSID
,
909 P2P_WILDCARD_SSID_LEN
) == 0) {
910 /* Process P2P Wildcard SSID like Wildcard SSID */
913 #endif /* CONFIG_P2P */
915 #ifdef CONFIG_TAXONOMY
917 struct sta_info
*sta
;
918 struct hostapd_sta_info
*info
;
920 if ((sta
= ap_get_sta(hapd
, mgmt
->sa
)) != NULL
) {
921 taxonomy_sta_info_probe_req(hapd
, sta
, ie
, ie_len
);
922 } else if ((info
= sta_track_get(hapd
->iface
,
923 mgmt
->sa
)) != NULL
) {
924 taxonomy_hostapd_sta_info_probe_req(hapd
, info
,
928 #endif /* CONFIG_TAXONOMY */
930 res
= ssid_match(hapd
, elems
.ssid
, elems
.ssid_len
,
931 elems
.ssid_list
, elems
.ssid_list_len
,
932 elems
.short_ssid_list
, elems
.short_ssid_list_len
);
933 if (res
== NO_SSID_MATCH
) {
934 if (!(mgmt
->da
[0] & 0x01)) {
935 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
936 " for foreign SSID '%s' (DA " MACSTR
")%s",
938 wpa_ssid_txt(elems
.ssid
, elems
.ssid_len
),
940 elems
.ssid_list
? " (SSID list)" : "");
945 if (hapd
->conf
->ignore_broadcast_ssid
&& res
== WILDCARD_SSID_MATCH
) {
946 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
947 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
951 #ifdef CONFIG_INTERWORKING
952 if (hapd
->conf
->interworking
&&
953 elems
.interworking
&& elems
.interworking_len
>= 1) {
954 u8 ant
= elems
.interworking
[0] & 0x0f;
955 if (ant
!= INTERWORKING_ANT_WILDCARD
&&
956 ant
!= hapd
->conf
->access_network_type
) {
957 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
958 " for mismatching ANT %u ignored",
959 MAC2STR(mgmt
->sa
), ant
);
964 if (hapd
->conf
->interworking
&& elems
.interworking
&&
965 (elems
.interworking_len
== 7 || elems
.interworking_len
== 9)) {
967 if (elems
.interworking_len
== 7)
968 hessid
= elems
.interworking
+ 1;
970 hessid
= elems
.interworking
+ 1 + 2;
971 if (!is_broadcast_ether_addr(hessid
) &&
972 os_memcmp(hessid
, hapd
->conf
->hessid
, ETH_ALEN
) != 0) {
973 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
974 " for mismatching HESSID " MACSTR
976 MAC2STR(mgmt
->sa
), MAC2STR(hessid
));
980 #endif /* CONFIG_INTERWORKING */
983 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
984 supp_rates_11b_only(&elems
)) {
985 /* Indicates support for 11b rates only */
986 wpa_printf(MSG_EXCESSIVE
, "P2P: Ignore Probe Request from "
987 MACSTR
" with only 802.11b rates",
991 #endif /* CONFIG_P2P */
993 /* TODO: verify that supp_rates contains at least one matching rate
994 * with AP configuration */
996 if (hapd
->conf
->no_probe_resp_if_seen_on
&&
997 is_multicast_ether_addr(mgmt
->da
) &&
998 is_multicast_ether_addr(mgmt
->bssid
) &&
999 sta_track_seen_on(hapd
->iface
, mgmt
->sa
,
1000 hapd
->conf
->no_probe_resp_if_seen_on
)) {
1001 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
1002 " since STA has been seen on %s",
1003 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
),
1004 hapd
->conf
->no_probe_resp_if_seen_on
);
1008 if (hapd
->conf
->no_probe_resp_if_max_sta
&&
1009 is_multicast_ether_addr(mgmt
->da
) &&
1010 is_multicast_ether_addr(mgmt
->bssid
) &&
1011 hapd
->num_sta
>= hapd
->conf
->max_num_sta
&&
1012 !ap_get_sta(hapd
, mgmt
->sa
)) {
1013 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
1014 " since no room for additional STA",
1015 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
));
1019 #ifdef CONFIG_TESTING_OPTIONS
1020 if (hapd
->iconf
->ignore_probe_probability
> 0.0 &&
1021 drand48() < hapd
->iconf
->ignore_probe_probability
) {
1022 wpa_printf(MSG_INFO
,
1023 "TESTING: ignoring probe request from " MACSTR
,
1027 #endif /* CONFIG_TESTING_OPTIONS */
1029 wpa_msg_ctrl(hapd
->msg_ctx
, MSG_INFO
, RX_PROBE_REQUEST
"sa=" MACSTR
1030 " signal=%d", MAC2STR(mgmt
->sa
), ssi_signal
);
1032 resp
= hostapd_gen_probe_resp(hapd
, mgmt
, elems
.p2p
!= NULL
,
1038 * If this is a broadcast probe request, apply no ack policy to avoid
1039 * excessive retries.
1041 noack
= !!(res
== WILDCARD_SSID_MATCH
&&
1042 is_broadcast_ether_addr(mgmt
->da
));
1045 if (hapd
->csa_in_progress
) {
1046 if (hapd
->cs_c_off_proberesp
)
1047 csa_offs
[csa_offs_len
++] =
1048 hapd
->cs_c_off_proberesp
;
1050 if (hapd
->cs_c_off_ecsa_proberesp
)
1051 csa_offs
[csa_offs_len
++] =
1052 hapd
->cs_c_off_ecsa_proberesp
;
1055 ret
= hostapd_drv_send_mlme(hapd
, resp
, resp_len
, noack
,
1056 csa_offs_len
? csa_offs
: NULL
,
1060 wpa_printf(MSG_INFO
, "handle_probe_req: send failed");
1064 wpa_printf(MSG_EXCESSIVE
, "STA " MACSTR
" sent probe request for %s "
1065 "SSID", MAC2STR(mgmt
->sa
),
1066 elems
.ssid_len
== 0 ? "broadcast" : "our");
1070 static u8
* hostapd_probe_resp_offloads(struct hostapd_data
*hapd
,
1073 /* check probe response offloading caps and print warnings */
1074 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD
))
1078 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
&&
1079 (!(hapd
->iface
->probe_resp_offloads
&
1080 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS
|
1081 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2
))))
1082 wpa_printf(MSG_WARNING
, "Device is trying to offload WPS "
1083 "Probe Response while not supporting this");
1084 #endif /* CONFIG_WPS */
1087 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_probe_resp_ie
&&
1088 !(hapd
->iface
->probe_resp_offloads
&
1089 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P
))
1090 wpa_printf(MSG_WARNING
, "Device is trying to offload P2P "
1091 "Probe Response while not supporting this");
1092 #endif /* CONFIG_P2P */
1094 if (hapd
->conf
->interworking
&&
1095 !(hapd
->iface
->probe_resp_offloads
&
1096 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING
))
1097 wpa_printf(MSG_WARNING
, "Device is trying to offload "
1098 "Interworking Probe Response while not supporting "
1101 /* Generate a Probe Response template for the non-P2P case */
1102 return hostapd_gen_probe_resp(hapd
, NULL
, 0, resp_len
);
1105 #endif /* NEED_AP_MLME */
1108 void sta_track_del(struct hostapd_sta_info
*info
)
1110 #ifdef CONFIG_TAXONOMY
1111 wpabuf_free(info
->probe_ie_taxonomy
);
1112 info
->probe_ie_taxonomy
= NULL
;
1113 #endif /* CONFIG_TAXONOMY */
1118 int ieee802_11_build_ap_params(struct hostapd_data
*hapd
,
1119 struct wpa_driver_ap_params
*params
)
1121 struct ieee80211_mgmt
*head
= NULL
;
1123 size_t head_len
= 0, tail_len
= 0;
1125 size_t resp_len
= 0;
1128 u8
*pos
, *tailpos
, *tailend
, *csa_pos
;
1130 #define BEACON_HEAD_BUF_SIZE 256
1131 #define BEACON_TAIL_BUF_SIZE 512
1132 head
= os_zalloc(BEACON_HEAD_BUF_SIZE
);
1133 tail_len
= BEACON_TAIL_BUF_SIZE
;
1135 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
)
1136 tail_len
+= wpabuf_len(hapd
->wps_beacon_ie
);
1137 #endif /* CONFIG_WPS */
1139 if (hapd
->p2p_beacon_ie
)
1140 tail_len
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1141 #endif /* CONFIG_P2P */
1143 if (hapd
->iface
->fst_ies
)
1144 tail_len
+= wpabuf_len(hapd
->iface
->fst_ies
);
1145 #endif /* CONFIG_FST */
1146 if (hapd
->conf
->vendor_elements
)
1147 tail_len
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1149 #ifdef CONFIG_IEEE80211AC
1150 if (hapd
->conf
->vendor_vht
) {
1151 tail_len
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
1152 2 + sizeof(struct ieee80211_vht_operation
);
1154 #endif /* CONFIG_IEEE80211AC */
1156 #ifdef CONFIG_IEEE80211AX
1157 if (hapd
->iconf
->ieee80211ax
) {
1158 tail_len
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
1159 3 + sizeof(struct ieee80211_he_operation
) +
1160 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
1161 3 + sizeof(struct ieee80211_spatial_reuse
);
1163 #endif /* CONFIG_IEEE80211AX */
1165 tail_len
+= hostapd_mbo_ie_len(hapd
);
1166 tail_len
+= hostapd_eid_owe_trans_len(hapd
);
1168 tailpos
= tail
= os_malloc(tail_len
);
1169 if (head
== NULL
|| tail
== NULL
) {
1170 wpa_printf(MSG_ERROR
, "Failed to set beacon data");
1175 tailend
= tail
+ tail_len
;
1177 head
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
1178 WLAN_FC_STYPE_BEACON
);
1179 head
->duration
= host_to_le16(0);
1180 os_memset(head
->da
, 0xff, ETH_ALEN
);
1182 os_memcpy(head
->sa
, hapd
->own_addr
, ETH_ALEN
);
1183 os_memcpy(head
->bssid
, hapd
->own_addr
, ETH_ALEN
);
1184 head
->u
.beacon
.beacon_int
=
1185 host_to_le16(hapd
->iconf
->beacon_int
);
1187 /* hardware or low-level driver will setup seq_ctrl and timestamp */
1188 capab_info
= hostapd_own_capab_info(hapd
);
1189 head
->u
.beacon
.capab_info
= host_to_le16(capab_info
);
1190 pos
= &head
->u
.beacon
.variable
[0];
1193 *pos
++ = WLAN_EID_SSID
;
1194 if (hapd
->conf
->ignore_broadcast_ssid
== 2) {
1195 /* clear the data, but keep the correct length of the SSID */
1196 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1197 os_memset(pos
, 0, hapd
->conf
->ssid
.ssid_len
);
1198 pos
+= hapd
->conf
->ssid
.ssid_len
;
1199 } else if (hapd
->conf
->ignore_broadcast_ssid
) {
1200 *pos
++ = 0; /* empty SSID */
1202 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1203 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
,
1204 hapd
->conf
->ssid
.ssid_len
);
1205 pos
+= hapd
->conf
->ssid
.ssid_len
;
1208 /* Supported rates */
1209 pos
= hostapd_eid_supp_rates(hapd
, pos
);
1212 pos
= hostapd_eid_ds_params(hapd
, pos
);
1214 head_len
= pos
- (u8
*) head
;
1216 tailpos
= hostapd_eid_country(hapd
, tailpos
, tailend
- tailpos
);
1218 /* Power Constraint element */
1219 tailpos
= hostapd_eid_pwr_constraint(hapd
, tailpos
);
1222 csa_pos
= hostapd_eid_csa(hapd
, tailpos
);
1223 if (csa_pos
!= tailpos
)
1224 hapd
->cs_c_off_beacon
= csa_pos
- tail
- 1;
1227 /* ERP Information element */
1228 tailpos
= hostapd_eid_erp_info(hapd
, tailpos
);
1230 /* Extended supported rates */
1231 tailpos
= hostapd_eid_ext_supp_rates(hapd
, tailpos
);
1233 tailpos
= hostapd_get_rsne(hapd
, tailpos
, tailend
- tailpos
);
1234 tailpos
= hostapd_eid_bss_load(hapd
, tailpos
, tailend
- tailpos
);
1235 tailpos
= hostapd_eid_rm_enabled_capab(hapd
, tailpos
,
1237 tailpos
= hostapd_get_mde(hapd
, tailpos
, tailend
- tailpos
);
1240 csa_pos
= hostapd_eid_ecsa(hapd
, tailpos
);
1241 if (csa_pos
!= tailpos
)
1242 hapd
->cs_c_off_ecsa_beacon
= csa_pos
- tail
- 1;
1245 tailpos
= hostapd_eid_supported_op_classes(hapd
, tailpos
);
1246 tailpos
= hostapd_eid_ht_capabilities(hapd
, tailpos
);
1247 tailpos
= hostapd_eid_ht_operation(hapd
, tailpos
);
1249 tailpos
= hostapd_eid_ext_capab(hapd
, tailpos
);
1252 * TODO: Time Advertisement element should only be included in some
1253 * DTIM Beacon frames.
1255 tailpos
= hostapd_eid_time_adv(hapd
, tailpos
);
1257 tailpos
= hostapd_eid_interworking(hapd
, tailpos
);
1258 tailpos
= hostapd_eid_adv_proto(hapd
, tailpos
);
1259 tailpos
= hostapd_eid_roaming_consortium(hapd
, tailpos
);
1262 if (hapd
->iface
->fst_ies
) {
1263 os_memcpy(tailpos
, wpabuf_head(hapd
->iface
->fst_ies
),
1264 wpabuf_len(hapd
->iface
->fst_ies
));
1265 tailpos
+= wpabuf_len(hapd
->iface
->fst_ies
);
1267 #endif /* CONFIG_FST */
1269 #ifdef CONFIG_IEEE80211AC
1270 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
) {
1271 tailpos
= hostapd_eid_vht_capabilities(hapd
, tailpos
, 0);
1272 tailpos
= hostapd_eid_vht_operation(hapd
, tailpos
);
1273 tailpos
= hostapd_eid_txpower_envelope(hapd
, tailpos
);
1274 tailpos
= hostapd_eid_wb_chsw_wrapper(hapd
, tailpos
);
1276 #endif /* CONFIG_IEEE80211AC */
1278 tailpos
= hostapd_eid_fils_indic(hapd
, tailpos
, 0);
1279 tailpos
= hostapd_get_rsnxe(hapd
, tailpos
, tailend
- tailpos
);
1281 #ifdef CONFIG_IEEE80211AX
1282 if (hapd
->iconf
->ieee80211ax
) {
1283 tailpos
= hostapd_eid_he_capab(hapd
, tailpos
,
1285 tailpos
= hostapd_eid_he_operation(hapd
, tailpos
);
1286 tailpos
= hostapd_eid_spatial_reuse(hapd
, tailpos
);
1287 tailpos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, tailpos
);
1289 #endif /* CONFIG_IEEE80211AX */
1291 #ifdef CONFIG_IEEE80211AC
1292 if (hapd
->conf
->vendor_vht
)
1293 tailpos
= hostapd_eid_vendor_vht(hapd
, tailpos
);
1294 #endif /* CONFIG_IEEE80211AC */
1297 tailpos
= hostapd_get_wpa_ie(hapd
, tailpos
, tailend
- tailpos
);
1298 tailpos
= hostapd_get_osen_ie(hapd
, tailpos
, tailend
- tailpos
);
1300 /* Wi-Fi Alliance WMM */
1301 tailpos
= hostapd_eid_wmm(hapd
, tailpos
);
1304 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
) {
1305 os_memcpy(tailpos
, wpabuf_head(hapd
->wps_beacon_ie
),
1306 wpabuf_len(hapd
->wps_beacon_ie
));
1307 tailpos
+= wpabuf_len(hapd
->wps_beacon_ie
);
1309 #endif /* CONFIG_WPS */
1312 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_beacon_ie
) {
1313 os_memcpy(tailpos
, wpabuf_head(hapd
->p2p_beacon_ie
),
1314 wpabuf_len(hapd
->p2p_beacon_ie
));
1315 tailpos
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1317 #endif /* CONFIG_P2P */
1318 #ifdef CONFIG_P2P_MANAGER
1319 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
1321 tailpos
= hostapd_eid_p2p_manage(hapd
, tailpos
);
1322 #endif /* CONFIG_P2P_MANAGER */
1325 tailpos
= hostapd_eid_hs20_indication(hapd
, tailpos
);
1326 #endif /* CONFIG_HS20 */
1328 tailpos
= hostapd_eid_mbo(hapd
, tailpos
, tail
+ tail_len
- tailpos
);
1329 tailpos
= hostapd_eid_owe_trans(hapd
, tailpos
,
1330 tail
+ tail_len
- tailpos
);
1332 if (hapd
->conf
->vendor_elements
) {
1333 os_memcpy(tailpos
, wpabuf_head(hapd
->conf
->vendor_elements
),
1334 wpabuf_len(hapd
->conf
->vendor_elements
));
1335 tailpos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1338 tail_len
= tailpos
> tail
? tailpos
- tail
: 0;
1340 resp
= hostapd_probe_resp_offloads(hapd
, &resp_len
);
1341 #endif /* NEED_AP_MLME */
1343 os_memset(params
, 0, sizeof(*params
));
1344 params
->head
= (u8
*) head
;
1345 params
->head_len
= head_len
;
1346 params
->tail
= tail
;
1347 params
->tail_len
= tail_len
;
1348 params
->proberesp
= resp
;
1349 params
->proberesp_len
= resp_len
;
1350 params
->dtim_period
= hapd
->conf
->dtim_period
;
1351 params
->beacon_int
= hapd
->iconf
->beacon_int
;
1352 params
->basic_rates
= hapd
->iface
->basic_rates
;
1353 params
->beacon_rate
= hapd
->iconf
->beacon_rate
;
1354 params
->rate_type
= hapd
->iconf
->rate_type
;
1355 params
->ssid
= hapd
->conf
->ssid
.ssid
;
1356 params
->ssid_len
= hapd
->conf
->ssid
.ssid_len
;
1357 if ((hapd
->conf
->wpa
& (WPA_PROTO_WPA
| WPA_PROTO_RSN
)) ==
1358 (WPA_PROTO_WPA
| WPA_PROTO_RSN
))
1359 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
|
1360 hapd
->conf
->rsn_pairwise
;
1361 else if (hapd
->conf
->wpa
& WPA_PROTO_RSN
)
1362 params
->pairwise_ciphers
= hapd
->conf
->rsn_pairwise
;
1363 else if (hapd
->conf
->wpa
& WPA_PROTO_WPA
)
1364 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
;
1365 params
->group_cipher
= hapd
->conf
->wpa_group
;
1366 params
->key_mgmt_suites
= hapd
->conf
->wpa_key_mgmt
;
1367 params
->auth_algs
= hapd
->conf
->auth_algs
;
1368 params
->wpa_version
= hapd
->conf
->wpa
;
1369 params
->privacy
= hapd
->conf
->wpa
;
1371 params
->privacy
|= hapd
->conf
->ssid
.wep
.keys_set
||
1372 (hapd
->conf
->ieee802_1x
&&
1373 (hapd
->conf
->default_wep_key_len
||
1374 hapd
->conf
->individual_wep_key_len
));
1375 #endif /* CONFIG_WEP */
1376 switch (hapd
->conf
->ignore_broadcast_ssid
) {
1378 params
->hide_ssid
= NO_SSID_HIDING
;
1381 params
->hide_ssid
= HIDDEN_SSID_ZERO_LEN
;
1384 params
->hide_ssid
= HIDDEN_SSID_ZERO_CONTENTS
;
1387 params
->isolate
= hapd
->conf
->isolate
;
1389 params
->cts_protect
= !!(ieee802_11_erp_info(hapd
) &
1390 ERP_INFO_USE_PROTECTION
);
1391 params
->preamble
= hapd
->iface
->num_sta_no_short_preamble
== 0 &&
1392 hapd
->iconf
->preamble
== SHORT_PREAMBLE
;
1393 if (hapd
->iface
->current_mode
&&
1394 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
1395 params
->short_slot_time
=
1396 hapd
->iface
->num_sta_no_short_slot_time
> 0 ? 0 : 1;
1398 params
->short_slot_time
= -1;
1399 if (!hapd
->iconf
->ieee80211n
|| hapd
->conf
->disable_11n
)
1400 params
->ht_opmode
= -1;
1402 params
->ht_opmode
= hapd
->iface
->ht_op_mode
;
1403 #endif /* NEED_AP_MLME */
1404 params
->interworking
= hapd
->conf
->interworking
;
1405 if (hapd
->conf
->interworking
&&
1406 !is_zero_ether_addr(hapd
->conf
->hessid
))
1407 params
->hessid
= hapd
->conf
->hessid
;
1408 params
->access_network_type
= hapd
->conf
->access_network_type
;
1409 params
->ap_max_inactivity
= hapd
->conf
->ap_max_inactivity
;
1411 params
->p2p_go_ctwindow
= hapd
->iconf
->p2p_go_ctwindow
;
1412 #endif /* CONFIG_P2P */
1414 params
->disable_dgaf
= hapd
->conf
->disable_dgaf
;
1415 if (hapd
->conf
->osen
) {
1416 params
->privacy
= 1;
1419 #endif /* CONFIG_HS20 */
1420 params
->multicast_to_unicast
= hapd
->conf
->multicast_to_unicast
;
1421 params
->pbss
= hapd
->conf
->pbss
;
1423 if (hapd
->conf
->ftm_responder
) {
1424 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_FTM_RESPONDER
) {
1425 params
->ftm_responder
= 1;
1426 params
->lci
= hapd
->iface
->conf
->lci
;
1427 params
->civic
= hapd
->iface
->conf
->civic
;
1429 wpa_printf(MSG_WARNING
,
1430 "Not configuring FTM responder as the driver doesn't advertise support for it");
1438 void ieee802_11_free_ap_params(struct wpa_driver_ap_params
*params
)
1440 os_free(params
->tail
);
1441 params
->tail
= NULL
;
1442 os_free(params
->head
);
1443 params
->head
= NULL
;
1444 os_free(params
->proberesp
);
1445 params
->proberesp
= NULL
;
1449 int ieee802_11_set_beacon(struct hostapd_data
*hapd
)
1451 struct wpa_driver_ap_params params
;
1452 struct hostapd_freq_params freq
;
1453 struct hostapd_iface
*iface
= hapd
->iface
;
1454 struct hostapd_config
*iconf
= iface
->conf
;
1455 struct hostapd_hw_modes
*cmode
= iface
->current_mode
;
1456 struct wpabuf
*beacon
, *proberesp
, *assocresp
;
1459 if (hapd
->csa_in_progress
) {
1460 wpa_printf(MSG_ERROR
, "Cannot set beacons during CSA period");
1464 hapd
->beacon_set_done
= 1;
1466 if (ieee802_11_build_ap_params(hapd
, ¶ms
) < 0)
1469 if (hostapd_build_ap_extra_ies(hapd
, &beacon
, &proberesp
, &assocresp
) <
1473 params
.beacon_ies
= beacon
;
1474 params
.proberesp_ies
= proberesp
;
1475 params
.assocresp_ies
= assocresp
;
1476 params
.reenable
= hapd
->reenable_beacon
;
1477 #ifdef CONFIG_IEEE80211AX
1478 params
.he_spr
= !!hapd
->iface
->conf
->spr
.sr_control
;
1479 params
.he_spr_srg_obss_pd_min_offset
=
1480 hapd
->iface
->conf
->spr
.srg_obss_pd_min_offset
;
1481 params
.he_spr_srg_obss_pd_max_offset
=
1482 hapd
->iface
->conf
->spr
.srg_obss_pd_max_offset
;
1483 params
.he_bss_color_disabled
=
1484 hapd
->iface
->conf
->he_op
.he_bss_color_disabled
;
1485 params
.he_bss_color_partial
=
1486 hapd
->iface
->conf
->he_op
.he_bss_color_partial
;
1487 params
.he_bss_color
= hapd
->iface
->conf
->he_op
.he_bss_color
;
1488 params
.twt_responder
= hostapd_get_he_twt_responder(hapd
,
1490 #endif /* CONFIG_IEEE80211AX */
1491 hapd
->reenable_beacon
= 0;
1494 hostapd_set_freq_params(&freq
, iconf
->hw_mode
, iface
->freq
,
1495 iconf
->channel
, iconf
->enable_edmg
,
1496 iconf
->edmg_channel
, iconf
->ieee80211n
,
1497 iconf
->ieee80211ac
, iconf
->ieee80211ax
,
1498 iconf
->secondary_channel
,
1499 hostapd_get_oper_chwidth(iconf
),
1500 hostapd_get_oper_centr_freq_seg0_idx(iconf
),
1501 hostapd_get_oper_centr_freq_seg1_idx(iconf
),
1503 &cmode
->he_capab
[IEEE80211_MODE_AP
]) == 0)
1504 params
.freq
= &freq
;
1506 res
= hostapd_drv_set_ap(hapd
, ¶ms
);
1507 hostapd_free_ap_extra_ies(hapd
, beacon
, proberesp
, assocresp
);
1509 wpa_printf(MSG_ERROR
, "Failed to set beacon parameters");
1513 ieee802_11_free_ap_params(¶ms
);
1518 int ieee802_11_set_beacons(struct hostapd_iface
*iface
)
1523 for (i
= 0; i
< iface
->num_bss
; i
++) {
1524 if (iface
->bss
[i
]->started
&&
1525 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1533 /* only update beacons if started */
1534 int ieee802_11_update_beacons(struct hostapd_iface
*iface
)
1539 for (i
= 0; i
< iface
->num_bss
; i
++) {
1540 if (iface
->bss
[i
]->beacon_set_done
&& iface
->bss
[i
]->started
&&
1541 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1548 #endif /* CONFIG_NATIVE_WINDOWS */