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 u8
* hostapd_eid_wpa(struct hostapd_data
*hapd
, u8
*eid
, size_t len
)
274 ie
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &ielen
);
275 if (ie
== NULL
|| ielen
> len
)
278 os_memcpy(eid
, ie
, ielen
);
283 static u8
* hostapd_eid_csa(struct hostapd_data
*hapd
, u8
*eid
)
285 #ifdef CONFIG_TESTING_OPTIONS
286 if (hapd
->iface
->cs_oper_class
&& hapd
->iconf
->ecsa_ie_only
)
288 #endif /* CONFIG_TESTING_OPTIONS */
290 if (!hapd
->cs_freq_params
.channel
)
293 *eid
++ = WLAN_EID_CHANNEL_SWITCH
;
295 *eid
++ = hapd
->cs_block_tx
;
296 *eid
++ = hapd
->cs_freq_params
.channel
;
297 *eid
++ = hapd
->cs_count
;
303 static u8
* hostapd_eid_ecsa(struct hostapd_data
*hapd
, u8
*eid
)
305 if (!hapd
->cs_freq_params
.channel
|| !hapd
->iface
->cs_oper_class
)
308 *eid
++ = WLAN_EID_EXT_CHANSWITCH_ANN
;
310 *eid
++ = hapd
->cs_block_tx
;
311 *eid
++ = hapd
->iface
->cs_oper_class
;
312 *eid
++ = hapd
->cs_freq_params
.channel
;
313 *eid
++ = hapd
->cs_count
;
319 static u8
* hostapd_eid_supported_op_classes(struct hostapd_data
*hapd
, u8
*eid
)
321 u8 op_class
, channel
;
323 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_AP_CSA
) ||
327 if (ieee80211_freq_to_channel_ext(hapd
->iface
->freq
,
328 hapd
->iconf
->secondary_channel
,
329 hostapd_get_oper_chwidth(hapd
->iconf
),
330 &op_class
, &channel
) ==
334 *eid
++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES
;
337 /* Current Operating Class */
340 /* TODO: Advertise all the supported operating classes */
347 static u8
* hostapd_gen_probe_resp(struct hostapd_data
*hapd
,
348 const struct ieee80211_mgmt
*req
,
349 int is_p2p
, size_t *resp_len
)
351 struct ieee80211_mgmt
*resp
;
352 u8
*pos
, *epos
, *csa_pos
;
355 #define MAX_PROBERESP_LEN 768
356 buflen
= MAX_PROBERESP_LEN
;
358 if (hapd
->wps_probe_resp_ie
)
359 buflen
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
360 #endif /* CONFIG_WPS */
362 if (hapd
->p2p_probe_resp_ie
)
363 buflen
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
364 #endif /* CONFIG_P2P */
366 if (hapd
->iface
->fst_ies
)
367 buflen
+= wpabuf_len(hapd
->iface
->fst_ies
);
368 #endif /* CONFIG_FST */
369 if (hapd
->conf
->vendor_elements
)
370 buflen
+= wpabuf_len(hapd
->conf
->vendor_elements
);
371 if (hapd
->conf
->vendor_vht
) {
372 buflen
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
373 2 + sizeof(struct ieee80211_vht_operation
);
376 #ifdef CONFIG_IEEE80211AX
377 if (hapd
->iconf
->ieee80211ax
) {
378 buflen
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
379 3 + sizeof(struct ieee80211_he_operation
) +
380 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
381 3 + sizeof(struct ieee80211_spatial_reuse
);
383 #endif /* CONFIG_IEEE80211AX */
385 buflen
+= hostapd_mbo_ie_len(hapd
);
386 buflen
+= hostapd_eid_owe_trans_len(hapd
);
388 resp
= os_zalloc(buflen
);
392 epos
= ((u8
*) resp
) + MAX_PROBERESP_LEN
;
394 resp
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
395 WLAN_FC_STYPE_PROBE_RESP
);
397 os_memcpy(resp
->da
, req
->sa
, ETH_ALEN
);
398 os_memcpy(resp
->sa
, hapd
->own_addr
, ETH_ALEN
);
400 os_memcpy(resp
->bssid
, hapd
->own_addr
, ETH_ALEN
);
401 resp
->u
.probe_resp
.beacon_int
=
402 host_to_le16(hapd
->iconf
->beacon_int
);
404 /* hardware or low-level driver will setup seq_ctrl and timestamp */
405 resp
->u
.probe_resp
.capab_info
=
406 host_to_le16(hostapd_own_capab_info(hapd
));
408 pos
= resp
->u
.probe_resp
.variable
;
409 *pos
++ = WLAN_EID_SSID
;
410 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
411 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
, hapd
->conf
->ssid
.ssid_len
);
412 pos
+= hapd
->conf
->ssid
.ssid_len
;
414 /* Supported rates */
415 pos
= hostapd_eid_supp_rates(hapd
, pos
);
418 pos
= hostapd_eid_ds_params(hapd
, pos
);
420 pos
= hostapd_eid_country(hapd
, pos
, epos
- pos
);
422 /* Power Constraint element */
423 pos
= hostapd_eid_pwr_constraint(hapd
, pos
);
426 csa_pos
= hostapd_eid_csa(hapd
, pos
);
428 hapd
->cs_c_off_proberesp
= csa_pos
- (u8
*) resp
- 1;
431 /* ERP Information element */
432 pos
= hostapd_eid_erp_info(hapd
, pos
);
434 /* Extended supported rates */
435 pos
= hostapd_eid_ext_supp_rates(hapd
, pos
);
438 if (!(hapd
->conf
->wpa
== WPA_PROTO_WPA
||
439 (hapd
->conf
->osen
&& !hapd
->conf
->wpa
)))
440 pos
= hostapd_eid_wpa(hapd
, pos
, epos
- pos
);
442 pos
= hostapd_eid_bss_load(hapd
, pos
, epos
- pos
);
444 pos
= hostapd_eid_rm_enabled_capab(hapd
, pos
, epos
- pos
);
447 csa_pos
= hostapd_eid_ecsa(hapd
, pos
);
449 hapd
->cs_c_off_ecsa_proberesp
= csa_pos
- (u8
*) resp
- 1;
452 pos
= hostapd_eid_supported_op_classes(hapd
, pos
);
454 #ifdef CONFIG_IEEE80211N
455 /* Secondary Channel Offset element */
456 /* TODO: The standard doesn't specify a position for this element. */
457 pos
= hostapd_eid_secondary_channel(hapd
, pos
);
459 pos
= hostapd_eid_ht_capabilities(hapd
, pos
);
460 pos
= hostapd_eid_ht_operation(hapd
, pos
);
461 #endif /* CONFIG_IEEE80211N */
463 pos
= hostapd_eid_ext_capab(hapd
, pos
);
465 pos
= hostapd_eid_time_adv(hapd
, pos
);
466 pos
= hostapd_eid_time_zone(hapd
, pos
);
468 pos
= hostapd_eid_interworking(hapd
, pos
);
469 pos
= hostapd_eid_adv_proto(hapd
, pos
);
470 pos
= hostapd_eid_roaming_consortium(hapd
, pos
);
473 if (hapd
->iface
->fst_ies
) {
474 os_memcpy(pos
, wpabuf_head(hapd
->iface
->fst_ies
),
475 wpabuf_len(hapd
->iface
->fst_ies
));
476 pos
+= wpabuf_len(hapd
->iface
->fst_ies
);
478 #endif /* CONFIG_FST */
480 #ifdef CONFIG_IEEE80211AC
481 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
&&
482 !is_6ghz_op_class(hapd
->iconf
->op_class
)) {
483 pos
= hostapd_eid_vht_capabilities(hapd
, pos
, 0);
484 pos
= hostapd_eid_vht_operation(hapd
, pos
);
485 pos
= hostapd_eid_txpower_envelope(hapd
, pos
);
486 pos
= hostapd_eid_wb_chsw_wrapper(hapd
, pos
);
488 #endif /* CONFIG_IEEE80211AC */
490 pos
= hostapd_eid_fils_indic(hapd
, pos
, 0);
492 #ifdef CONFIG_IEEE80211AX
493 if (hapd
->iconf
->ieee80211ax
) {
494 pos
= hostapd_eid_he_capab(hapd
, pos
, IEEE80211_MODE_AP
);
495 pos
= hostapd_eid_he_operation(hapd
, pos
);
496 pos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, pos
);
497 pos
= hostapd_eid_spatial_reuse(hapd
, pos
);
499 #endif /* CONFIG_IEEE80211AX */
501 #ifdef CONFIG_IEEE80211AC
502 if (hapd
->conf
->vendor_vht
)
503 pos
= hostapd_eid_vendor_vht(hapd
, pos
);
504 #endif /* CONFIG_IEEE80211AC */
507 if (hapd
->conf
->wpa
== WPA_PROTO_WPA
||
508 (hapd
->conf
->osen
&& !hapd
->conf
->wpa
))
509 pos
= hostapd_eid_wpa(hapd
, pos
, epos
- pos
);
511 /* Wi-Fi Alliance WMM */
512 pos
= hostapd_eid_wmm(hapd
, pos
);
515 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
) {
516 os_memcpy(pos
, wpabuf_head(hapd
->wps_probe_resp_ie
),
517 wpabuf_len(hapd
->wps_probe_resp_ie
));
518 pos
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
520 #endif /* CONFIG_WPS */
523 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && is_p2p
&&
524 hapd
->p2p_probe_resp_ie
) {
525 os_memcpy(pos
, wpabuf_head(hapd
->p2p_probe_resp_ie
),
526 wpabuf_len(hapd
->p2p_probe_resp_ie
));
527 pos
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
529 #endif /* CONFIG_P2P */
530 #ifdef CONFIG_P2P_MANAGER
531 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
533 pos
= hostapd_eid_p2p_manage(hapd
, pos
);
534 #endif /* CONFIG_P2P_MANAGER */
537 pos
= hostapd_eid_hs20_indication(hapd
, pos
);
538 #endif /* CONFIG_HS20 */
540 pos
= hostapd_eid_mbo(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
541 pos
= hostapd_eid_owe_trans(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
543 if (hapd
->conf
->vendor_elements
) {
544 os_memcpy(pos
, wpabuf_head(hapd
->conf
->vendor_elements
),
545 wpabuf_len(hapd
->conf
->vendor_elements
));
546 pos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
549 *resp_len
= pos
- (u8
*) resp
;
554 enum ssid_match_result
{
560 static enum ssid_match_result
ssid_match(struct hostapd_data
*hapd
,
561 const u8
*ssid
, size_t ssid_len
,
563 size_t ssid_list_len
,
564 const u8
*short_ssid_list
,
565 size_t short_ssid_list_len
)
572 if (ssid_len
== hapd
->conf
->ssid
.ssid_len
&&
573 os_memcmp(ssid
, hapd
->conf
->ssid
.ssid
, ssid_len
) == 0)
574 return EXACT_SSID_MATCH
;
578 end
= ssid_list
+ ssid_list_len
;
579 while (end
- pos
>= 2) {
580 if (2 + pos
[1] > end
- pos
)
584 if (pos
[1] == hapd
->conf
->ssid
.ssid_len
&&
585 os_memcmp(pos
+ 2, hapd
->conf
->ssid
.ssid
,
587 return EXACT_SSID_MATCH
;
592 if (short_ssid_list
) {
593 pos
= short_ssid_list
;
594 end
= short_ssid_list
+ short_ssid_list_len
;
595 while (end
- pos
>= 4) {
596 if (hapd
->conf
->ssid
.short_ssid
== WPA_GET_LE32(pos
))
597 return EXACT_SSID_MATCH
;
602 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
606 void sta_track_expire(struct hostapd_iface
*iface
, int force
)
608 struct os_reltime now
;
609 struct hostapd_sta_info
*info
;
611 if (!iface
->num_sta_seen
)
614 os_get_reltime(&now
);
615 while ((info
= dl_list_first(&iface
->sta_seen
, struct hostapd_sta_info
,
618 !os_reltime_expired(&now
, &info
->last_seen
,
619 iface
->conf
->track_sta_max_age
))
623 wpa_printf(MSG_MSGDUMP
, "%s: Expire STA tracking entry for "
624 MACSTR
, iface
->bss
[0]->conf
->iface
,
625 MAC2STR(info
->addr
));
626 dl_list_del(&info
->list
);
627 iface
->num_sta_seen
--;
633 static struct hostapd_sta_info
* sta_track_get(struct hostapd_iface
*iface
,
636 struct hostapd_sta_info
*info
;
638 dl_list_for_each(info
, &iface
->sta_seen
, struct hostapd_sta_info
, list
)
639 if (os_memcmp(addr
, info
->addr
, ETH_ALEN
) == 0)
646 void sta_track_add(struct hostapd_iface
*iface
, const u8
*addr
, int ssi_signal
)
648 struct hostapd_sta_info
*info
;
650 info
= sta_track_get(iface
, addr
);
652 /* Move the most recent entry to the end of the list */
653 dl_list_del(&info
->list
);
654 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
655 os_get_reltime(&info
->last_seen
);
656 info
->ssi_signal
= ssi_signal
;
660 /* Add a new entry */
661 info
= os_zalloc(sizeof(*info
));
664 os_memcpy(info
->addr
, addr
, ETH_ALEN
);
665 os_get_reltime(&info
->last_seen
);
666 info
->ssi_signal
= ssi_signal
;
668 if (iface
->num_sta_seen
>= iface
->conf
->track_sta_max_num
) {
669 /* Expire oldest entry to make room for a new one */
670 sta_track_expire(iface
, 1);
673 wpa_printf(MSG_MSGDUMP
, "%s: Add STA tracking entry for "
674 MACSTR
, iface
->bss
[0]->conf
->iface
, MAC2STR(addr
));
675 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
676 iface
->num_sta_seen
++;
680 struct hostapd_data
*
681 sta_track_seen_on(struct hostapd_iface
*iface
, const u8
*addr
,
684 struct hapd_interfaces
*interfaces
= iface
->interfaces
;
687 for (i
= 0; i
< interfaces
->count
; i
++) {
688 struct hostapd_data
*hapd
= NULL
;
690 iface
= interfaces
->iface
[i
];
691 for (j
= 0; j
< iface
->num_bss
; j
++) {
692 hapd
= iface
->bss
[j
];
693 if (os_strcmp(ifname
, hapd
->conf
->iface
) == 0)
698 if (hapd
&& sta_track_get(iface
, addr
))
706 #ifdef CONFIG_TAXONOMY
707 void sta_track_claim_taxonomy_info(struct hostapd_iface
*iface
, const u8
*addr
,
708 struct wpabuf
**probe_ie_taxonomy
)
710 struct hostapd_sta_info
*info
;
712 info
= sta_track_get(iface
, addr
);
716 wpabuf_free(*probe_ie_taxonomy
);
717 *probe_ie_taxonomy
= info
->probe_ie_taxonomy
;
718 info
->probe_ie_taxonomy
= NULL
;
720 #endif /* CONFIG_TAXONOMY */
723 void handle_probe_req(struct hostapd_data
*hapd
,
724 const struct ieee80211_mgmt
*mgmt
, size_t len
,
728 struct ieee802_11_elems elems
;
733 enum ssid_match_result res
;
737 struct radius_sta rad_info
;
739 if (len
< IEEE80211_HDRLEN
)
741 ie
= ((const u8
*) mgmt
) + IEEE80211_HDRLEN
;
742 if (hapd
->iconf
->track_sta_max_num
)
743 sta_track_add(hapd
->iface
, mgmt
->sa
, ssi_signal
);
744 ie_len
= len
- IEEE80211_HDRLEN
;
746 ret
= hostapd_allowed_address(hapd
, mgmt
->sa
, (const u8
*) mgmt
, len
,
748 if (ret
== HOSTAPD_ACL_REJECT
) {
749 wpa_msg(hapd
->msg_ctx
, MSG_DEBUG
,
750 "Ignore Probe Request frame from " MACSTR
751 " due to ACL reject ", MAC2STR(mgmt
->sa
));
755 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++)
756 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
757 mgmt
->sa
, mgmt
->da
, mgmt
->bssid
,
758 ie
, ie_len
, ssi_signal
) > 0)
761 if (!hapd
->conf
->send_probe_response
)
764 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 0) == ParseFailed
) {
765 wpa_printf(MSG_DEBUG
, "Could not parse ProbeReq from " MACSTR
,
770 if ((!elems
.ssid
|| !elems
.supp_rates
)) {
771 wpa_printf(MSG_DEBUG
, "STA " MACSTR
" sent probe request "
772 "without SSID or supported rates element",
778 * No need to reply if the Probe Request frame was sent on an adjacent
779 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
780 * AP with dot11RadioMeasurementActivated set to true, but strictly
781 * speaking does not allow such ignoring of Probe Request frames if
782 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
783 * number of unnecessary Probe Response frames for cases where the STA
784 * is less likely to see them (Probe Request frame sent on a
785 * neighboring, but partially overlapping, channel).
787 if (elems
.ds_params
&&
788 hapd
->iface
->current_mode
&&
789 (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
||
790 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211B
) &&
791 hapd
->iconf
->channel
!= elems
.ds_params
[0]) {
792 wpa_printf(MSG_DEBUG
,
793 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
794 hapd
->iconf
->channel
, elems
.ds_params
[0]);
799 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.wps_ie
) {
801 wps
= ieee802_11_vendor_ie_concat(ie
, ie_len
, WPS_DEV_OUI_WFA
);
802 if (wps
&& !p2p_group_match_dev_type(hapd
->p2p_group
, wps
)) {
803 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
804 "due to mismatch with Requested Device "
812 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.p2p
) {
814 p2p
= ieee802_11_vendor_ie_concat(ie
, ie_len
, P2P_IE_VENDOR_TYPE
);
815 if (p2p
&& !p2p_group_match_dev_id(hapd
->p2p_group
, p2p
)) {
816 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
817 "due to mismatch with Device ID");
823 #endif /* CONFIG_P2P */
825 if (hapd
->conf
->ignore_broadcast_ssid
&& elems
.ssid_len
== 0 &&
826 elems
.ssid_list_len
== 0 && elems
.short_ssid_list_len
== 0) {
827 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
828 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
833 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
834 elems
.ssid_len
== P2P_WILDCARD_SSID_LEN
&&
835 os_memcmp(elems
.ssid
, P2P_WILDCARD_SSID
,
836 P2P_WILDCARD_SSID_LEN
) == 0) {
837 /* Process P2P Wildcard SSID like Wildcard SSID */
840 #endif /* CONFIG_P2P */
842 #ifdef CONFIG_TAXONOMY
844 struct sta_info
*sta
;
845 struct hostapd_sta_info
*info
;
847 if ((sta
= ap_get_sta(hapd
, mgmt
->sa
)) != NULL
) {
848 taxonomy_sta_info_probe_req(hapd
, sta
, ie
, ie_len
);
849 } else if ((info
= sta_track_get(hapd
->iface
,
850 mgmt
->sa
)) != NULL
) {
851 taxonomy_hostapd_sta_info_probe_req(hapd
, info
,
855 #endif /* CONFIG_TAXONOMY */
857 res
= ssid_match(hapd
, elems
.ssid
, elems
.ssid_len
,
858 elems
.ssid_list
, elems
.ssid_list_len
,
859 elems
.short_ssid_list
, elems
.short_ssid_list_len
);
860 if (res
== NO_SSID_MATCH
) {
861 if (!(mgmt
->da
[0] & 0x01)) {
862 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
863 " for foreign SSID '%s' (DA " MACSTR
")%s",
865 wpa_ssid_txt(elems
.ssid
, elems
.ssid_len
),
867 elems
.ssid_list
? " (SSID list)" : "");
872 if (hapd
->conf
->ignore_broadcast_ssid
&& res
== WILDCARD_SSID_MATCH
) {
873 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
874 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
878 #ifdef CONFIG_INTERWORKING
879 if (hapd
->conf
->interworking
&&
880 elems
.interworking
&& elems
.interworking_len
>= 1) {
881 u8 ant
= elems
.interworking
[0] & 0x0f;
882 if (ant
!= INTERWORKING_ANT_WILDCARD
&&
883 ant
!= hapd
->conf
->access_network_type
) {
884 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
885 " for mismatching ANT %u ignored",
886 MAC2STR(mgmt
->sa
), ant
);
891 if (hapd
->conf
->interworking
&& elems
.interworking
&&
892 (elems
.interworking_len
== 7 || elems
.interworking_len
== 9)) {
894 if (elems
.interworking_len
== 7)
895 hessid
= elems
.interworking
+ 1;
897 hessid
= elems
.interworking
+ 1 + 2;
898 if (!is_broadcast_ether_addr(hessid
) &&
899 os_memcmp(hessid
, hapd
->conf
->hessid
, ETH_ALEN
) != 0) {
900 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
901 " for mismatching HESSID " MACSTR
903 MAC2STR(mgmt
->sa
), MAC2STR(hessid
));
907 #endif /* CONFIG_INTERWORKING */
910 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
911 supp_rates_11b_only(&elems
)) {
912 /* Indicates support for 11b rates only */
913 wpa_printf(MSG_EXCESSIVE
, "P2P: Ignore Probe Request from "
914 MACSTR
" with only 802.11b rates",
918 #endif /* CONFIG_P2P */
920 /* TODO: verify that supp_rates contains at least one matching rate
921 * with AP configuration */
923 if (hapd
->conf
->no_probe_resp_if_seen_on
&&
924 is_multicast_ether_addr(mgmt
->da
) &&
925 is_multicast_ether_addr(mgmt
->bssid
) &&
926 sta_track_seen_on(hapd
->iface
, mgmt
->sa
,
927 hapd
->conf
->no_probe_resp_if_seen_on
)) {
928 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
929 " since STA has been seen on %s",
930 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
),
931 hapd
->conf
->no_probe_resp_if_seen_on
);
935 if (hapd
->conf
->no_probe_resp_if_max_sta
&&
936 is_multicast_ether_addr(mgmt
->da
) &&
937 is_multicast_ether_addr(mgmt
->bssid
) &&
938 hapd
->num_sta
>= hapd
->conf
->max_num_sta
&&
939 !ap_get_sta(hapd
, mgmt
->sa
)) {
940 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
941 " since no room for additional STA",
942 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
));
946 #ifdef CONFIG_TESTING_OPTIONS
947 if (hapd
->iconf
->ignore_probe_probability
> 0.0 &&
948 drand48() < hapd
->iconf
->ignore_probe_probability
) {
950 "TESTING: ignoring probe request from " MACSTR
,
954 #endif /* CONFIG_TESTING_OPTIONS */
956 wpa_msg_ctrl(hapd
->msg_ctx
, MSG_INFO
, RX_PROBE_REQUEST
"sa=" MACSTR
957 " signal=%d", MAC2STR(mgmt
->sa
), ssi_signal
);
959 resp
= hostapd_gen_probe_resp(hapd
, mgmt
, elems
.p2p
!= NULL
,
965 * If this is a broadcast probe request, apply no ack policy to avoid
968 noack
= !!(res
== WILDCARD_SSID_MATCH
&&
969 is_broadcast_ether_addr(mgmt
->da
));
972 if (hapd
->csa_in_progress
) {
973 if (hapd
->cs_c_off_proberesp
)
974 csa_offs
[csa_offs_len
++] =
975 hapd
->cs_c_off_proberesp
;
977 if (hapd
->cs_c_off_ecsa_proberesp
)
978 csa_offs
[csa_offs_len
++] =
979 hapd
->cs_c_off_ecsa_proberesp
;
982 ret
= hostapd_drv_send_mlme(hapd
, resp
, resp_len
, noack
,
983 csa_offs_len
? csa_offs
: NULL
,
987 wpa_printf(MSG_INFO
, "handle_probe_req: send failed");
991 wpa_printf(MSG_EXCESSIVE
, "STA " MACSTR
" sent probe request for %s "
992 "SSID", MAC2STR(mgmt
->sa
),
993 elems
.ssid_len
== 0 ? "broadcast" : "our");
997 static u8
* hostapd_probe_resp_offloads(struct hostapd_data
*hapd
,
1000 /* check probe response offloading caps and print warnings */
1001 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD
))
1005 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
&&
1006 (!(hapd
->iface
->probe_resp_offloads
&
1007 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS
|
1008 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2
))))
1009 wpa_printf(MSG_WARNING
, "Device is trying to offload WPS "
1010 "Probe Response while not supporting this");
1011 #endif /* CONFIG_WPS */
1014 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_probe_resp_ie
&&
1015 !(hapd
->iface
->probe_resp_offloads
&
1016 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P
))
1017 wpa_printf(MSG_WARNING
, "Device is trying to offload P2P "
1018 "Probe Response while not supporting this");
1019 #endif /* CONFIG_P2P */
1021 if (hapd
->conf
->interworking
&&
1022 !(hapd
->iface
->probe_resp_offloads
&
1023 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING
))
1024 wpa_printf(MSG_WARNING
, "Device is trying to offload "
1025 "Interworking Probe Response while not supporting "
1028 /* Generate a Probe Response template for the non-P2P case */
1029 return hostapd_gen_probe_resp(hapd
, NULL
, 0, resp_len
);
1032 #endif /* NEED_AP_MLME */
1035 void sta_track_del(struct hostapd_sta_info
*info
)
1037 #ifdef CONFIG_TAXONOMY
1038 wpabuf_free(info
->probe_ie_taxonomy
);
1039 info
->probe_ie_taxonomy
= NULL
;
1040 #endif /* CONFIG_TAXONOMY */
1045 int ieee802_11_build_ap_params(struct hostapd_data
*hapd
,
1046 struct wpa_driver_ap_params
*params
)
1048 struct ieee80211_mgmt
*head
= NULL
;
1050 size_t head_len
= 0, tail_len
= 0;
1052 size_t resp_len
= 0;
1055 u8
*pos
, *tailpos
, *csa_pos
;
1057 #define BEACON_HEAD_BUF_SIZE 256
1058 #define BEACON_TAIL_BUF_SIZE 512
1059 head
= os_zalloc(BEACON_HEAD_BUF_SIZE
);
1060 tail_len
= BEACON_TAIL_BUF_SIZE
;
1062 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
)
1063 tail_len
+= wpabuf_len(hapd
->wps_beacon_ie
);
1064 #endif /* CONFIG_WPS */
1066 if (hapd
->p2p_beacon_ie
)
1067 tail_len
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1068 #endif /* CONFIG_P2P */
1070 if (hapd
->iface
->fst_ies
)
1071 tail_len
+= wpabuf_len(hapd
->iface
->fst_ies
);
1072 #endif /* CONFIG_FST */
1073 if (hapd
->conf
->vendor_elements
)
1074 tail_len
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1076 #ifdef CONFIG_IEEE80211AC
1077 if (hapd
->conf
->vendor_vht
) {
1078 tail_len
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
1079 2 + sizeof(struct ieee80211_vht_operation
);
1081 #endif /* CONFIG_IEEE80211AC */
1083 #ifdef CONFIG_IEEE80211AX
1084 if (hapd
->iconf
->ieee80211ax
) {
1085 tail_len
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
1086 3 + sizeof(struct ieee80211_he_operation
) +
1087 3 + sizeof(struct ieee80211_he_mu_edca_parameter_set
) +
1088 3 + sizeof(struct ieee80211_spatial_reuse
);
1090 #endif /* CONFIG_IEEE80211AX */
1092 tail_len
+= hostapd_mbo_ie_len(hapd
);
1093 tail_len
+= hostapd_eid_owe_trans_len(hapd
);
1095 tailpos
= tail
= os_malloc(tail_len
);
1096 if (head
== NULL
|| tail
== NULL
) {
1097 wpa_printf(MSG_ERROR
, "Failed to set beacon data");
1103 head
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
1104 WLAN_FC_STYPE_BEACON
);
1105 head
->duration
= host_to_le16(0);
1106 os_memset(head
->da
, 0xff, ETH_ALEN
);
1108 os_memcpy(head
->sa
, hapd
->own_addr
, ETH_ALEN
);
1109 os_memcpy(head
->bssid
, hapd
->own_addr
, ETH_ALEN
);
1110 head
->u
.beacon
.beacon_int
=
1111 host_to_le16(hapd
->iconf
->beacon_int
);
1113 /* hardware or low-level driver will setup seq_ctrl and timestamp */
1114 capab_info
= hostapd_own_capab_info(hapd
);
1115 head
->u
.beacon
.capab_info
= host_to_le16(capab_info
);
1116 pos
= &head
->u
.beacon
.variable
[0];
1119 *pos
++ = WLAN_EID_SSID
;
1120 if (hapd
->conf
->ignore_broadcast_ssid
== 2) {
1121 /* clear the data, but keep the correct length of the SSID */
1122 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1123 os_memset(pos
, 0, hapd
->conf
->ssid
.ssid_len
);
1124 pos
+= hapd
->conf
->ssid
.ssid_len
;
1125 } else if (hapd
->conf
->ignore_broadcast_ssid
) {
1126 *pos
++ = 0; /* empty SSID */
1128 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1129 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
,
1130 hapd
->conf
->ssid
.ssid_len
);
1131 pos
+= hapd
->conf
->ssid
.ssid_len
;
1134 /* Supported rates */
1135 pos
= hostapd_eid_supp_rates(hapd
, pos
);
1138 pos
= hostapd_eid_ds_params(hapd
, pos
);
1140 head_len
= pos
- (u8
*) head
;
1142 tailpos
= hostapd_eid_country(hapd
, tailpos
,
1143 tail
+ BEACON_TAIL_BUF_SIZE
- tailpos
);
1145 /* Power Constraint element */
1146 tailpos
= hostapd_eid_pwr_constraint(hapd
, tailpos
);
1149 csa_pos
= hostapd_eid_csa(hapd
, tailpos
);
1150 if (csa_pos
!= tailpos
)
1151 hapd
->cs_c_off_beacon
= csa_pos
- tail
- 1;
1154 /* ERP Information element */
1155 tailpos
= hostapd_eid_erp_info(hapd
, tailpos
);
1157 /* Extended supported rates */
1158 tailpos
= hostapd_eid_ext_supp_rates(hapd
, tailpos
);
1161 if (!(hapd
->conf
->wpa
== WPA_PROTO_WPA
||
1162 (hapd
->conf
->osen
&& !hapd
->conf
->wpa
)))
1163 tailpos
= hostapd_eid_wpa(hapd
, tailpos
,
1164 tail
+ BEACON_TAIL_BUF_SIZE
-
1167 tailpos
= hostapd_eid_rm_enabled_capab(hapd
, tailpos
,
1168 tail
+ BEACON_TAIL_BUF_SIZE
-
1171 tailpos
= hostapd_eid_bss_load(hapd
, tailpos
,
1172 tail
+ BEACON_TAIL_BUF_SIZE
- tailpos
);
1175 csa_pos
= hostapd_eid_ecsa(hapd
, tailpos
);
1176 if (csa_pos
!= tailpos
)
1177 hapd
->cs_c_off_ecsa_beacon
= csa_pos
- tail
- 1;
1180 tailpos
= hostapd_eid_supported_op_classes(hapd
, tailpos
);
1182 #ifdef CONFIG_IEEE80211N
1183 /* Secondary Channel Offset element */
1184 /* TODO: The standard doesn't specify a position for this element. */
1185 tailpos
= hostapd_eid_secondary_channel(hapd
, tailpos
);
1187 tailpos
= hostapd_eid_ht_capabilities(hapd
, tailpos
);
1188 tailpos
= hostapd_eid_ht_operation(hapd
, tailpos
);
1189 #endif /* CONFIG_IEEE80211N */
1191 tailpos
= hostapd_eid_ext_capab(hapd
, tailpos
);
1194 * TODO: Time Advertisement element should only be included in some
1195 * DTIM Beacon frames.
1197 tailpos
= hostapd_eid_time_adv(hapd
, tailpos
);
1199 tailpos
= hostapd_eid_interworking(hapd
, tailpos
);
1200 tailpos
= hostapd_eid_adv_proto(hapd
, tailpos
);
1201 tailpos
= hostapd_eid_roaming_consortium(hapd
, tailpos
);
1204 if (hapd
->iface
->fst_ies
) {
1205 os_memcpy(tailpos
, wpabuf_head(hapd
->iface
->fst_ies
),
1206 wpabuf_len(hapd
->iface
->fst_ies
));
1207 tailpos
+= wpabuf_len(hapd
->iface
->fst_ies
);
1209 #endif /* CONFIG_FST */
1211 #ifdef CONFIG_IEEE80211AC
1212 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
) {
1213 tailpos
= hostapd_eid_vht_capabilities(hapd
, tailpos
, 0);
1214 tailpos
= hostapd_eid_vht_operation(hapd
, tailpos
);
1215 tailpos
= hostapd_eid_txpower_envelope(hapd
, tailpos
);
1216 tailpos
= hostapd_eid_wb_chsw_wrapper(hapd
, tailpos
);
1218 #endif /* CONFIG_IEEE80211AC */
1220 tailpos
= hostapd_eid_fils_indic(hapd
, tailpos
, 0);
1222 #ifdef CONFIG_IEEE80211AX
1223 if (hapd
->iconf
->ieee80211ax
) {
1224 tailpos
= hostapd_eid_he_capab(hapd
, tailpos
,
1226 tailpos
= hostapd_eid_he_operation(hapd
, tailpos
);
1227 tailpos
= hostapd_eid_he_mu_edca_parameter_set(hapd
, tailpos
);
1228 tailpos
= hostapd_eid_spatial_reuse(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 (hapd
->conf
->osen
&& !hapd
->conf
->wpa
))
1240 tailpos
= hostapd_eid_wpa(hapd
, tailpos
,
1241 tail
+ BEACON_TAIL_BUF_SIZE
-
1244 /* Wi-Fi Alliance WMM */
1245 tailpos
= hostapd_eid_wmm(hapd
, tailpos
);
1248 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
) {
1249 os_memcpy(tailpos
, wpabuf_head(hapd
->wps_beacon_ie
),
1250 wpabuf_len(hapd
->wps_beacon_ie
));
1251 tailpos
+= wpabuf_len(hapd
->wps_beacon_ie
);
1253 #endif /* CONFIG_WPS */
1256 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_beacon_ie
) {
1257 os_memcpy(tailpos
, wpabuf_head(hapd
->p2p_beacon_ie
),
1258 wpabuf_len(hapd
->p2p_beacon_ie
));
1259 tailpos
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1261 #endif /* CONFIG_P2P */
1262 #ifdef CONFIG_P2P_MANAGER
1263 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
1265 tailpos
= hostapd_eid_p2p_manage(hapd
, tailpos
);
1266 #endif /* CONFIG_P2P_MANAGER */
1269 tailpos
= hostapd_eid_hs20_indication(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 hostapd_hw_modes
*cmode
= iface
->current_mode
;
1398 struct wpabuf
*beacon
, *proberesp
, *assocresp
;
1401 if (hapd
->csa_in_progress
) {
1402 wpa_printf(MSG_ERROR
, "Cannot set beacons during CSA period");
1406 hapd
->beacon_set_done
= 1;
1408 if (ieee802_11_build_ap_params(hapd
, ¶ms
) < 0)
1411 if (hostapd_build_ap_extra_ies(hapd
, &beacon
, &proberesp
, &assocresp
) <
1415 params
.beacon_ies
= beacon
;
1416 params
.proberesp_ies
= proberesp
;
1417 params
.assocresp_ies
= assocresp
;
1418 params
.reenable
= hapd
->reenable_beacon
;
1419 #ifdef CONFIG_IEEE80211AX
1420 params
.he_spr
= !!hapd
->iface
->conf
->spr
.sr_control
;
1421 params
.he_spr_srg_obss_pd_min_offset
=
1422 hapd
->iface
->conf
->spr
.srg_obss_pd_min_offset
;
1423 params
.he_spr_srg_obss_pd_max_offset
=
1424 hapd
->iface
->conf
->spr
.srg_obss_pd_max_offset
;
1425 #endif /* CONFIG_IEEE80211AX */
1426 hapd
->reenable_beacon
= 0;
1429 hostapd_set_freq_params(&freq
, iconf
->hw_mode
, iface
->freq
,
1430 iconf
->channel
, iconf
->enable_edmg
,
1431 iconf
->edmg_channel
, iconf
->ieee80211n
,
1432 iconf
->ieee80211ac
, iconf
->ieee80211ax
,
1433 iconf
->secondary_channel
,
1434 hostapd_get_oper_chwidth(iconf
),
1435 hostapd_get_oper_centr_freq_seg0_idx(iconf
),
1436 hostapd_get_oper_centr_freq_seg1_idx(iconf
),
1438 &cmode
->he_capab
[IEEE80211_MODE_AP
]) == 0)
1439 params
.freq
= &freq
;
1441 res
= hostapd_drv_set_ap(hapd
, ¶ms
);
1442 hostapd_free_ap_extra_ies(hapd
, beacon
, proberesp
, assocresp
);
1444 wpa_printf(MSG_ERROR
, "Failed to set beacon parameters");
1448 ieee802_11_free_ap_params(¶ms
);
1453 int ieee802_11_set_beacons(struct hostapd_iface
*iface
)
1458 for (i
= 0; i
< iface
->num_bss
; i
++) {
1459 if (iface
->bss
[i
]->started
&&
1460 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1468 /* only update beacons if started */
1469 int ieee802_11_update_beacons(struct hostapd_iface
*iface
)
1474 for (i
= 0; i
< iface
->num_bss
; i
++) {
1475 if (iface
->bss
[i
]->beacon_set_done
&& iface
->bss
[i
]->started
&&
1476 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1483 #endif /* CONFIG_NATIVE_WINDOWS */