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"
38 static u8
* hostapd_eid_rm_enabled_capab(struct hostapd_data
*hapd
, u8
*eid
,
43 for (i
= 0; i
< RRM_CAPABILITIES_IE_LEN
; i
++) {
44 if (hapd
->conf
->radio_measurements
[i
])
48 if (i
== RRM_CAPABILITIES_IE_LEN
|| len
< 2 + RRM_CAPABILITIES_IE_LEN
)
51 *eid
++ = WLAN_EID_RRM_ENABLED_CAPABILITIES
;
52 *eid
++ = RRM_CAPABILITIES_IE_LEN
;
53 os_memcpy(eid
, hapd
->conf
->radio_measurements
, RRM_CAPABILITIES_IE_LEN
);
55 return eid
+ RRM_CAPABILITIES_IE_LEN
;
59 static u8
* hostapd_eid_bss_load(struct hostapd_data
*hapd
, u8
*eid
, size_t len
)
64 #ifdef CONFIG_TESTING_OPTIONS
65 if (hapd
->conf
->bss_load_test_set
) {
66 *eid
++ = WLAN_EID_BSS_LOAD
;
68 os_memcpy(eid
, hapd
->conf
->bss_load_test
, 5);
72 #endif /* CONFIG_TESTING_OPTIONS */
73 if (hapd
->conf
->bss_load_update_period
) {
74 *eid
++ = WLAN_EID_BSS_LOAD
;
76 WPA_PUT_LE16(eid
, hapd
->num_sta
);
78 *eid
++ = hapd
->iface
->channel_utilization
;
79 WPA_PUT_LE16(eid
, 0); /* no available admission capabity */
86 static u8
ieee802_11_erp_info(struct hostapd_data
*hapd
)
90 if (hapd
->iface
->current_mode
== NULL
||
91 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
94 if (hapd
->iface
->olbc
)
95 erp
|= ERP_INFO_USE_PROTECTION
;
96 if (hapd
->iface
->num_sta_non_erp
> 0) {
97 erp
|= ERP_INFO_NON_ERP_PRESENT
|
98 ERP_INFO_USE_PROTECTION
;
100 if (hapd
->iface
->num_sta_no_short_preamble
> 0 ||
101 hapd
->iconf
->preamble
== LONG_PREAMBLE
)
102 erp
|= ERP_INFO_BARKER_PREAMBLE_MODE
;
108 static u8
* hostapd_eid_ds_params(struct hostapd_data
*hapd
, u8
*eid
)
110 *eid
++ = WLAN_EID_DS_PARAMS
;
112 *eid
++ = hapd
->iconf
->channel
;
117 static u8
* hostapd_eid_erp_info(struct hostapd_data
*hapd
, u8
*eid
)
119 if (hapd
->iface
->current_mode
== NULL
||
120 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
123 /* Set NonERP_present and use_protection bits if there
124 * are any associated NonERP stations. */
125 /* TODO: use_protection bit can be set to zero even if
126 * there are NonERP stations present. This optimization
127 * might be useful if NonERP stations are "quiet".
128 * See 802.11g/D6 E-1 for recommended practice.
129 * In addition, Non ERP present might be set, if AP detects Non ERP
130 * operation on other APs. */
132 /* Add ERP Information element */
133 *eid
++ = WLAN_EID_ERP_INFO
;
135 *eid
++ = ieee802_11_erp_info(hapd
);
141 static u8
* hostapd_eid_pwr_constraint(struct hostapd_data
*hapd
, u8
*eid
)
144 u8 local_pwr_constraint
= 0;
147 if (hapd
->iface
->current_mode
== NULL
||
148 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211A
)
151 /* Let host drivers add this IE if DFS support is offloaded */
152 if (hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_DFS_OFFLOAD
)
156 * There is no DFS support and power constraint was not directly
157 * requested by config option.
159 if (!hapd
->iconf
->ieee80211h
&&
160 hapd
->iconf
->local_pwr_constraint
== -1)
163 /* Check if DFS is required by regulatory. */
164 dfs
= hostapd_is_dfs_required(hapd
->iface
);
166 wpa_printf(MSG_WARNING
, "Failed to check if DFS is required; ret=%d",
171 if (dfs
== 0 && hapd
->iconf
->local_pwr_constraint
== -1)
175 * ieee80211h (DFS) is enabled so Power Constraint element shall
176 * be added when running on DFS channel whenever local_pwr_constraint
177 * is configured or not. In order to meet regulations when TPC is not
178 * implemented using a transmit power that is below the legal maximum
179 * (including any mitigation factor) should help. In this case,
180 * indicate 3 dB below maximum allowed transmit power.
182 if (hapd
->iconf
->local_pwr_constraint
== -1)
183 local_pwr_constraint
= 3;
186 * A STA that is not an AP shall use a transmit power less than or
187 * equal to the local maximum transmit power level for the channel.
188 * The local maximum transmit power can be calculated from the formula:
189 * local max TX pwr = max TX pwr - local pwr constraint
190 * Where max TX pwr is maximum transmit power level specified for
191 * channel in Country element and local pwr constraint is specified
192 * for channel in this Power Constraint element.
196 *pos
++ = WLAN_EID_PWR_CONSTRAINT
;
199 /* Local Power Constraint */
200 if (local_pwr_constraint
)
201 *pos
++ = local_pwr_constraint
;
203 *pos
++ = hapd
->iconf
->local_pwr_constraint
;
209 static u8
* hostapd_eid_country_add(u8
*pos
, u8
*end
, int chan_spacing
,
210 struct hostapd_channel_data
*start
,
211 struct hostapd_channel_data
*prev
)
216 /* first channel number */
217 *pos
++ = start
->chan
;
218 /* number of channels */
219 *pos
++ = (prev
->chan
- start
->chan
) / chan_spacing
+ 1;
220 /* maximum transmit power level */
221 *pos
++ = start
->max_tx_power
;
227 static u8
* hostapd_eid_country(struct hostapd_data
*hapd
, u8
*eid
,
231 u8
*end
= eid
+ max_len
;
233 struct hostapd_hw_modes
*mode
;
234 struct hostapd_channel_data
*start
, *prev
;
235 int chan_spacing
= 1;
237 if (!hapd
->iconf
->ieee80211d
|| max_len
< 6 ||
238 hapd
->iface
->current_mode
== NULL
)
241 *pos
++ = WLAN_EID_COUNTRY
;
242 pos
++; /* length will be set later */
243 os_memcpy(pos
, hapd
->iconf
->country
, 3); /* e.g., 'US ' */
246 mode
= hapd
->iface
->current_mode
;
247 if (mode
->mode
== HOSTAPD_MODE_IEEE80211A
)
251 for (i
= 0; i
< mode
->num_channels
; i
++) {
252 struct hostapd_channel_data
*chan
= &mode
->channels
[i
];
253 if (chan
->flag
& HOSTAPD_CHAN_DISABLED
)
256 prev
->chan
+ chan_spacing
== chan
->chan
&&
257 start
->max_tx_power
== chan
->max_tx_power
) {
259 continue; /* can use same entry */
263 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
268 /* Start new group */
273 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
277 if ((pos
- eid
) & 1) {
280 *pos
++ = 0; /* pad for 16-bit alignment */
283 eid
[1] = (pos
- eid
) - 2;
289 static u8
* hostapd_eid_wpa(struct hostapd_data
*hapd
, u8
*eid
, size_t len
)
294 ie
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &ielen
);
295 if (ie
== NULL
|| ielen
> len
)
298 os_memcpy(eid
, ie
, ielen
);
303 static u8
* hostapd_eid_csa(struct hostapd_data
*hapd
, u8
*eid
)
305 #ifdef CONFIG_TESTING_OPTIONS
306 if (hapd
->iface
->cs_oper_class
&& hapd
->iconf
->ecsa_ie_only
)
308 #endif /* CONFIG_TESTING_OPTIONS */
310 if (!hapd
->cs_freq_params
.channel
)
313 *eid
++ = WLAN_EID_CHANNEL_SWITCH
;
315 *eid
++ = hapd
->cs_block_tx
;
316 *eid
++ = hapd
->cs_freq_params
.channel
;
317 *eid
++ = hapd
->cs_count
;
323 static u8
* hostapd_eid_ecsa(struct hostapd_data
*hapd
, u8
*eid
)
325 if (!hapd
->cs_freq_params
.channel
|| !hapd
->iface
->cs_oper_class
)
328 *eid
++ = WLAN_EID_EXT_CHANSWITCH_ANN
;
330 *eid
++ = hapd
->cs_block_tx
;
331 *eid
++ = hapd
->iface
->cs_oper_class
;
332 *eid
++ = hapd
->cs_freq_params
.channel
;
333 *eid
++ = hapd
->cs_count
;
339 static u8
* hostapd_eid_supported_op_classes(struct hostapd_data
*hapd
, u8
*eid
)
341 u8 op_class
, channel
;
343 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_AP_CSA
) ||
347 if (ieee80211_freq_to_channel_ext(hapd
->iface
->freq
,
348 hapd
->iconf
->secondary_channel
,
349 hapd
->iconf
->vht_oper_chwidth
,
350 &op_class
, &channel
) ==
354 *eid
++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES
;
357 /* Current Operating Class */
360 /* TODO: Advertise all the supported operating classes */
368 static int hostapd_eid_owe_trans_enabled(struct hostapd_data
*hapd
)
370 return hapd
->conf
->owe_transition_ssid_len
> 0 &&
371 !is_zero_ether_addr(hapd
->conf
->owe_transition_bssid
);
373 #endif /* CONFIG_OWE */
376 static size_t hostapd_eid_owe_trans_len(struct hostapd_data
*hapd
)
379 if (!hostapd_eid_owe_trans_enabled(hapd
))
381 return 6 + ETH_ALEN
+ 1 + hapd
->conf
->owe_transition_ssid_len
;
382 #else /* CONFIG_OWE */
384 #endif /* CONFIG_OWE */
388 static u8
* hostapd_eid_owe_trans(struct hostapd_data
*hapd
, u8
*eid
,
395 if (hapd
->conf
->owe_transition_ifname
[0] &&
396 !hostapd_eid_owe_trans_enabled(hapd
))
397 hostapd_owe_trans_get_info(hapd
);
399 if (!hostapd_eid_owe_trans_enabled(hapd
))
402 elen
= hostapd_eid_owe_trans_len(hapd
);
404 wpa_printf(MSG_DEBUG
,
405 "OWE: Not enough room in the buffer for OWE IE");
409 *pos
++ = WLAN_EID_VENDOR_SPECIFIC
;
411 WPA_PUT_BE24(pos
, OUI_WFA
);
413 *pos
++ = OWE_OUI_TYPE
;
414 os_memcpy(pos
, hapd
->conf
->owe_transition_bssid
, ETH_ALEN
);
416 *pos
++ = hapd
->conf
->owe_transition_ssid_len
;
417 os_memcpy(pos
, hapd
->conf
->owe_transition_ssid
,
418 hapd
->conf
->owe_transition_ssid_len
);
419 pos
+= hapd
->conf
->owe_transition_ssid_len
;
422 #else /* CONFIG_OWE */
424 #endif /* CONFIG_OWE */
428 static u8
* hostapd_gen_probe_resp(struct hostapd_data
*hapd
,
429 const struct ieee80211_mgmt
*req
,
430 int is_p2p
, size_t *resp_len
)
432 struct ieee80211_mgmt
*resp
;
433 u8
*pos
, *epos
, *csa_pos
;
436 #define MAX_PROBERESP_LEN 768
437 buflen
= MAX_PROBERESP_LEN
;
439 if (hapd
->wps_probe_resp_ie
)
440 buflen
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
441 #endif /* CONFIG_WPS */
443 if (hapd
->p2p_probe_resp_ie
)
444 buflen
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
445 #endif /* CONFIG_P2P */
447 if (hapd
->iface
->fst_ies
)
448 buflen
+= wpabuf_len(hapd
->iface
->fst_ies
);
449 #endif /* CONFIG_FST */
450 if (hapd
->conf
->vendor_elements
)
451 buflen
+= wpabuf_len(hapd
->conf
->vendor_elements
);
452 if (hapd
->conf
->vendor_vht
) {
453 buflen
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
454 2 + sizeof(struct ieee80211_vht_operation
);
457 #ifdef CONFIG_IEEE80211AX
458 if (hapd
->iconf
->ieee80211ax
) {
459 buflen
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
460 3 + sizeof(struct ieee80211_he_operation
);
462 #endif /* CONFIG_IEEE80211AX */
464 buflen
+= hostapd_mbo_ie_len(hapd
);
465 buflen
+= hostapd_eid_owe_trans_len(hapd
);
467 resp
= os_zalloc(buflen
);
471 epos
= ((u8
*) resp
) + MAX_PROBERESP_LEN
;
473 resp
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
474 WLAN_FC_STYPE_PROBE_RESP
);
476 os_memcpy(resp
->da
, req
->sa
, ETH_ALEN
);
477 os_memcpy(resp
->sa
, hapd
->own_addr
, ETH_ALEN
);
479 os_memcpy(resp
->bssid
, hapd
->own_addr
, ETH_ALEN
);
480 resp
->u
.probe_resp
.beacon_int
=
481 host_to_le16(hapd
->iconf
->beacon_int
);
483 /* hardware or low-level driver will setup seq_ctrl and timestamp */
484 resp
->u
.probe_resp
.capab_info
=
485 host_to_le16(hostapd_own_capab_info(hapd
));
487 pos
= resp
->u
.probe_resp
.variable
;
488 *pos
++ = WLAN_EID_SSID
;
489 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
490 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
, hapd
->conf
->ssid
.ssid_len
);
491 pos
+= hapd
->conf
->ssid
.ssid_len
;
493 /* Supported rates */
494 pos
= hostapd_eid_supp_rates(hapd
, pos
);
497 pos
= hostapd_eid_ds_params(hapd
, pos
);
499 pos
= hostapd_eid_country(hapd
, pos
, epos
- pos
);
501 /* Power Constraint element */
502 pos
= hostapd_eid_pwr_constraint(hapd
, pos
);
505 csa_pos
= hostapd_eid_csa(hapd
, pos
);
507 hapd
->cs_c_off_proberesp
= csa_pos
- (u8
*) resp
- 1;
510 /* ERP Information element */
511 pos
= hostapd_eid_erp_info(hapd
, pos
);
513 /* Extended supported rates */
514 pos
= hostapd_eid_ext_supp_rates(hapd
, pos
);
517 pos
= hostapd_eid_wpa(hapd
, pos
, epos
- pos
);
519 pos
= hostapd_eid_bss_load(hapd
, pos
, epos
- pos
);
521 pos
= hostapd_eid_rm_enabled_capab(hapd
, pos
, epos
- pos
);
524 csa_pos
= hostapd_eid_ecsa(hapd
, pos
);
526 hapd
->cs_c_off_ecsa_proberesp
= csa_pos
- (u8
*) resp
- 1;
529 pos
= hostapd_eid_supported_op_classes(hapd
, pos
);
531 #ifdef CONFIG_IEEE80211N
532 /* Secondary Channel Offset element */
533 /* TODO: The standard doesn't specify a position for this element. */
534 pos
= hostapd_eid_secondary_channel(hapd
, pos
);
536 pos
= hostapd_eid_ht_capabilities(hapd
, pos
);
537 pos
= hostapd_eid_ht_operation(hapd
, pos
);
538 #endif /* CONFIG_IEEE80211N */
540 pos
= hostapd_eid_ext_capab(hapd
, pos
);
542 pos
= hostapd_eid_time_adv(hapd
, pos
);
543 pos
= hostapd_eid_time_zone(hapd
, pos
);
545 pos
= hostapd_eid_interworking(hapd
, pos
);
546 pos
= hostapd_eid_adv_proto(hapd
, pos
);
547 pos
= hostapd_eid_roaming_consortium(hapd
, pos
);
550 if (hapd
->iface
->fst_ies
) {
551 os_memcpy(pos
, wpabuf_head(hapd
->iface
->fst_ies
),
552 wpabuf_len(hapd
->iface
->fst_ies
));
553 pos
+= wpabuf_len(hapd
->iface
->fst_ies
);
555 #endif /* CONFIG_FST */
557 #ifdef CONFIG_IEEE80211AC
558 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
) {
559 pos
= hostapd_eid_vht_capabilities(hapd
, pos
, 0);
560 pos
= hostapd_eid_vht_operation(hapd
, pos
);
561 pos
= hostapd_eid_txpower_envelope(hapd
, pos
);
562 pos
= hostapd_eid_wb_chsw_wrapper(hapd
, pos
);
564 #endif /* CONFIG_IEEE80211AC */
566 pos
= hostapd_eid_fils_indic(hapd
, pos
, 0);
568 #ifdef CONFIG_IEEE80211AX
569 if (hapd
->iconf
->ieee80211ax
) {
570 pos
= hostapd_eid_he_capab(hapd
, pos
);
571 pos
= hostapd_eid_he_operation(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 */
580 /* Wi-Fi Alliance WMM */
581 pos
= hostapd_eid_wmm(hapd
, pos
);
584 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
) {
585 os_memcpy(pos
, wpabuf_head(hapd
->wps_probe_resp_ie
),
586 wpabuf_len(hapd
->wps_probe_resp_ie
));
587 pos
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
589 #endif /* CONFIG_WPS */
592 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && is_p2p
&&
593 hapd
->p2p_probe_resp_ie
) {
594 os_memcpy(pos
, wpabuf_head(hapd
->p2p_probe_resp_ie
),
595 wpabuf_len(hapd
->p2p_probe_resp_ie
));
596 pos
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
598 #endif /* CONFIG_P2P */
599 #ifdef CONFIG_P2P_MANAGER
600 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
602 pos
= hostapd_eid_p2p_manage(hapd
, pos
);
603 #endif /* CONFIG_P2P_MANAGER */
606 pos
= hostapd_eid_hs20_indication(hapd
, pos
);
607 pos
= hostapd_eid_osen(hapd
, pos
);
608 #endif /* CONFIG_HS20 */
610 pos
= hostapd_eid_mbo(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
611 pos
= hostapd_eid_owe_trans(hapd
, pos
, (u8
*) resp
+ buflen
- pos
);
613 if (hapd
->conf
->vendor_elements
) {
614 os_memcpy(pos
, wpabuf_head(hapd
->conf
->vendor_elements
),
615 wpabuf_len(hapd
->conf
->vendor_elements
));
616 pos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
619 *resp_len
= pos
- (u8
*) resp
;
624 enum ssid_match_result
{
630 static enum ssid_match_result
ssid_match(struct hostapd_data
*hapd
,
631 const u8
*ssid
, size_t ssid_len
,
633 size_t ssid_list_len
)
640 if (ssid_len
== hapd
->conf
->ssid
.ssid_len
&&
641 os_memcmp(ssid
, hapd
->conf
->ssid
.ssid
, ssid_len
) == 0)
642 return EXACT_SSID_MATCH
;
644 if (ssid_list
== NULL
)
645 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
648 end
= ssid_list
+ ssid_list_len
;
649 while (end
- pos
>= 1) {
650 if (2 + pos
[1] > end
- pos
)
654 if (pos
[1] == hapd
->conf
->ssid
.ssid_len
&&
655 os_memcmp(pos
+ 2, hapd
->conf
->ssid
.ssid
, pos
[1]) == 0)
656 return EXACT_SSID_MATCH
;
660 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
664 void sta_track_expire(struct hostapd_iface
*iface
, int force
)
666 struct os_reltime now
;
667 struct hostapd_sta_info
*info
;
669 if (!iface
->num_sta_seen
)
672 os_get_reltime(&now
);
673 while ((info
= dl_list_first(&iface
->sta_seen
, struct hostapd_sta_info
,
676 !os_reltime_expired(&now
, &info
->last_seen
,
677 iface
->conf
->track_sta_max_age
))
681 wpa_printf(MSG_MSGDUMP
, "%s: Expire STA tracking entry for "
682 MACSTR
, iface
->bss
[0]->conf
->iface
,
683 MAC2STR(info
->addr
));
684 dl_list_del(&info
->list
);
685 iface
->num_sta_seen
--;
691 static struct hostapd_sta_info
* sta_track_get(struct hostapd_iface
*iface
,
694 struct hostapd_sta_info
*info
;
696 dl_list_for_each(info
, &iface
->sta_seen
, struct hostapd_sta_info
, list
)
697 if (os_memcmp(addr
, info
->addr
, ETH_ALEN
) == 0)
704 void sta_track_add(struct hostapd_iface
*iface
, const u8
*addr
, int ssi_signal
)
706 struct hostapd_sta_info
*info
;
708 info
= sta_track_get(iface
, addr
);
710 /* Move the most recent entry to the end of the list */
711 dl_list_del(&info
->list
);
712 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
713 os_get_reltime(&info
->last_seen
);
714 info
->ssi_signal
= ssi_signal
;
718 /* Add a new entry */
719 info
= os_zalloc(sizeof(*info
));
722 os_memcpy(info
->addr
, addr
, ETH_ALEN
);
723 os_get_reltime(&info
->last_seen
);
724 info
->ssi_signal
= ssi_signal
;
726 if (iface
->num_sta_seen
>= iface
->conf
->track_sta_max_num
) {
727 /* Expire oldest entry to make room for a new one */
728 sta_track_expire(iface
, 1);
731 wpa_printf(MSG_MSGDUMP
, "%s: Add STA tracking entry for "
732 MACSTR
, iface
->bss
[0]->conf
->iface
, MAC2STR(addr
));
733 dl_list_add_tail(&iface
->sta_seen
, &info
->list
);
734 iface
->num_sta_seen
++;
738 struct hostapd_data
*
739 sta_track_seen_on(struct hostapd_iface
*iface
, const u8
*addr
,
742 struct hapd_interfaces
*interfaces
= iface
->interfaces
;
745 for (i
= 0; i
< interfaces
->count
; i
++) {
746 struct hostapd_data
*hapd
= NULL
;
748 iface
= interfaces
->iface
[i
];
749 for (j
= 0; j
< iface
->num_bss
; j
++) {
750 hapd
= iface
->bss
[j
];
751 if (os_strcmp(ifname
, hapd
->conf
->iface
) == 0)
756 if (hapd
&& sta_track_get(iface
, addr
))
764 #ifdef CONFIG_TAXONOMY
765 void sta_track_claim_taxonomy_info(struct hostapd_iface
*iface
, const u8
*addr
,
766 struct wpabuf
**probe_ie_taxonomy
)
768 struct hostapd_sta_info
*info
;
770 info
= sta_track_get(iface
, addr
);
774 wpabuf_free(*probe_ie_taxonomy
);
775 *probe_ie_taxonomy
= info
->probe_ie_taxonomy
;
776 info
->probe_ie_taxonomy
= NULL
;
778 #endif /* CONFIG_TAXONOMY */
781 void handle_probe_req(struct hostapd_data
*hapd
,
782 const struct ieee80211_mgmt
*mgmt
, size_t len
,
786 struct ieee802_11_elems elems
;
791 enum ssid_match_result res
;
796 if (len
< IEEE80211_HDRLEN
)
798 ie
= ((const u8
*) mgmt
) + IEEE80211_HDRLEN
;
799 if (hapd
->iconf
->track_sta_max_num
)
800 sta_track_add(hapd
->iface
, mgmt
->sa
, ssi_signal
);
801 ie_len
= len
- IEEE80211_HDRLEN
;
803 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++)
804 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
805 mgmt
->sa
, mgmt
->da
, mgmt
->bssid
,
806 ie
, ie_len
, ssi_signal
) > 0)
809 if (!hapd
->iconf
->send_probe_response
)
812 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 0) == ParseFailed
) {
813 wpa_printf(MSG_DEBUG
, "Could not parse ProbeReq from " MACSTR
,
818 if ((!elems
.ssid
|| !elems
.supp_rates
)) {
819 wpa_printf(MSG_DEBUG
, "STA " MACSTR
" sent probe request "
820 "without SSID or supported rates element",
826 * No need to reply if the Probe Request frame was sent on an adjacent
827 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
828 * AP with dot11RadioMeasurementActivated set to true, but strictly
829 * speaking does not allow such ignoring of Probe Request frames if
830 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
831 * number of unnecessary Probe Response frames for cases where the STA
832 * is less likely to see them (Probe Request frame sent on a
833 * neighboring, but partially overlapping, channel).
835 if (elems
.ds_params
&&
836 hapd
->iface
->current_mode
&&
837 (hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
||
838 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211B
) &&
839 hapd
->iconf
->channel
!= elems
.ds_params
[0]) {
840 wpa_printf(MSG_DEBUG
,
841 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
842 hapd
->iconf
->channel
, elems
.ds_params
[0]);
847 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.wps_ie
) {
849 wps
= ieee802_11_vendor_ie_concat(ie
, ie_len
, WPS_DEV_OUI_WFA
);
850 if (wps
&& !p2p_group_match_dev_type(hapd
->p2p_group
, wps
)) {
851 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
852 "due to mismatch with Requested Device "
860 if (hapd
->p2p
&& hapd
->p2p_group
&& elems
.p2p
) {
862 p2p
= ieee802_11_vendor_ie_concat(ie
, ie_len
, P2P_IE_VENDOR_TYPE
);
863 if (p2p
&& !p2p_group_match_dev_id(hapd
->p2p_group
, p2p
)) {
864 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
865 "due to mismatch with Device ID");
871 #endif /* CONFIG_P2P */
873 if (hapd
->conf
->ignore_broadcast_ssid
&& elems
.ssid_len
== 0 &&
874 elems
.ssid_list_len
== 0) {
875 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
876 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
881 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
882 elems
.ssid_len
== P2P_WILDCARD_SSID_LEN
&&
883 os_memcmp(elems
.ssid
, P2P_WILDCARD_SSID
,
884 P2P_WILDCARD_SSID_LEN
) == 0) {
885 /* Process P2P Wildcard SSID like Wildcard SSID */
888 #endif /* CONFIG_P2P */
890 #ifdef CONFIG_TAXONOMY
892 struct sta_info
*sta
;
893 struct hostapd_sta_info
*info
;
895 if ((sta
= ap_get_sta(hapd
, mgmt
->sa
)) != NULL
) {
896 taxonomy_sta_info_probe_req(hapd
, sta
, ie
, ie_len
);
897 } else if ((info
= sta_track_get(hapd
->iface
,
898 mgmt
->sa
)) != NULL
) {
899 taxonomy_hostapd_sta_info_probe_req(hapd
, info
,
903 #endif /* CONFIG_TAXONOMY */
905 res
= ssid_match(hapd
, elems
.ssid
, elems
.ssid_len
,
906 elems
.ssid_list
, elems
.ssid_list_len
);
907 if (res
== NO_SSID_MATCH
) {
908 if (!(mgmt
->da
[0] & 0x01)) {
909 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
910 " for foreign SSID '%s' (DA " MACSTR
")%s",
912 wpa_ssid_txt(elems
.ssid
, elems
.ssid_len
),
914 elems
.ssid_list
? " (SSID list)" : "");
919 #ifdef CONFIG_INTERWORKING
920 if (hapd
->conf
->interworking
&&
921 elems
.interworking
&& elems
.interworking_len
>= 1) {
922 u8 ant
= elems
.interworking
[0] & 0x0f;
923 if (ant
!= INTERWORKING_ANT_WILDCARD
&&
924 ant
!= hapd
->conf
->access_network_type
) {
925 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
926 " for mismatching ANT %u ignored",
927 MAC2STR(mgmt
->sa
), ant
);
932 if (hapd
->conf
->interworking
&& elems
.interworking
&&
933 (elems
.interworking_len
== 7 || elems
.interworking_len
== 9)) {
935 if (elems
.interworking_len
== 7)
936 hessid
= elems
.interworking
+ 1;
938 hessid
= elems
.interworking
+ 1 + 2;
939 if (!is_broadcast_ether_addr(hessid
) &&
940 os_memcmp(hessid
, hapd
->conf
->hessid
, ETH_ALEN
) != 0) {
941 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
942 " for mismatching HESSID " MACSTR
944 MAC2STR(mgmt
->sa
), MAC2STR(hessid
));
948 #endif /* CONFIG_INTERWORKING */
951 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
952 supp_rates_11b_only(&elems
)) {
953 /* Indicates support for 11b rates only */
954 wpa_printf(MSG_EXCESSIVE
, "P2P: Ignore Probe Request from "
955 MACSTR
" with only 802.11b rates",
959 #endif /* CONFIG_P2P */
961 /* TODO: verify that supp_rates contains at least one matching rate
962 * with AP configuration */
964 if (hapd
->conf
->no_probe_resp_if_seen_on
&&
965 is_multicast_ether_addr(mgmt
->da
) &&
966 is_multicast_ether_addr(mgmt
->bssid
) &&
967 sta_track_seen_on(hapd
->iface
, mgmt
->sa
,
968 hapd
->conf
->no_probe_resp_if_seen_on
)) {
969 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
970 " since STA has been seen on %s",
971 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
),
972 hapd
->conf
->no_probe_resp_if_seen_on
);
976 if (hapd
->conf
->no_probe_resp_if_max_sta
&&
977 is_multicast_ether_addr(mgmt
->da
) &&
978 is_multicast_ether_addr(mgmt
->bssid
) &&
979 hapd
->num_sta
>= hapd
->conf
->max_num_sta
&&
980 !ap_get_sta(hapd
, mgmt
->sa
)) {
981 wpa_printf(MSG_MSGDUMP
, "%s: Ignore Probe Request from " MACSTR
982 " since no room for additional STA",
983 hapd
->conf
->iface
, MAC2STR(mgmt
->sa
));
987 #ifdef CONFIG_TESTING_OPTIONS
988 if (hapd
->iconf
->ignore_probe_probability
> 0.0 &&
989 drand48() < hapd
->iconf
->ignore_probe_probability
) {
991 "TESTING: ignoring probe request from " MACSTR
,
995 #endif /* CONFIG_TESTING_OPTIONS */
997 wpa_msg_ctrl(hapd
->msg_ctx
, MSG_INFO
, RX_PROBE_REQUEST
"sa=" MACSTR
998 " signal=%d", MAC2STR(mgmt
->sa
), ssi_signal
);
1000 resp
= hostapd_gen_probe_resp(hapd
, mgmt
, elems
.p2p
!= NULL
,
1006 * If this is a broadcast probe request, apply no ack policy to avoid
1007 * excessive retries.
1009 noack
= !!(res
== WILDCARD_SSID_MATCH
&&
1010 is_broadcast_ether_addr(mgmt
->da
));
1013 if (hapd
->csa_in_progress
) {
1014 if (hapd
->cs_c_off_proberesp
)
1015 csa_offs
[csa_offs_len
++] =
1016 hapd
->cs_c_off_proberesp
;
1018 if (hapd
->cs_c_off_ecsa_proberesp
)
1019 csa_offs
[csa_offs_len
++] =
1020 hapd
->cs_c_off_ecsa_proberesp
;
1023 ret
= hostapd_drv_send_mlme_csa(hapd
, resp
, resp_len
, noack
,
1024 csa_offs_len
? csa_offs
: NULL
,
1028 wpa_printf(MSG_INFO
, "handle_probe_req: send failed");
1032 wpa_printf(MSG_EXCESSIVE
, "STA " MACSTR
" sent probe request for %s "
1033 "SSID", MAC2STR(mgmt
->sa
),
1034 elems
.ssid_len
== 0 ? "broadcast" : "our");
1038 static u8
* hostapd_probe_resp_offloads(struct hostapd_data
*hapd
,
1041 /* check probe response offloading caps and print warnings */
1042 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD
))
1046 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
&&
1047 (!(hapd
->iface
->probe_resp_offloads
&
1048 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS
|
1049 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2
))))
1050 wpa_printf(MSG_WARNING
, "Device is trying to offload WPS "
1051 "Probe Response while not supporting this");
1052 #endif /* CONFIG_WPS */
1055 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_probe_resp_ie
&&
1056 !(hapd
->iface
->probe_resp_offloads
&
1057 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P
))
1058 wpa_printf(MSG_WARNING
, "Device is trying to offload P2P "
1059 "Probe Response while not supporting this");
1060 #endif /* CONFIG_P2P */
1062 if (hapd
->conf
->interworking
&&
1063 !(hapd
->iface
->probe_resp_offloads
&
1064 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING
))
1065 wpa_printf(MSG_WARNING
, "Device is trying to offload "
1066 "Interworking Probe Response while not supporting "
1069 /* Generate a Probe Response template for the non-P2P case */
1070 return hostapd_gen_probe_resp(hapd
, NULL
, 0, resp_len
);
1073 #endif /* NEED_AP_MLME */
1076 void sta_track_del(struct hostapd_sta_info
*info
)
1078 #ifdef CONFIG_TAXONOMY
1079 wpabuf_free(info
->probe_ie_taxonomy
);
1080 info
->probe_ie_taxonomy
= NULL
;
1081 #endif /* CONFIG_TAXONOMY */
1086 int ieee802_11_build_ap_params(struct hostapd_data
*hapd
,
1087 struct wpa_driver_ap_params
*params
)
1089 struct ieee80211_mgmt
*head
= NULL
;
1091 size_t head_len
= 0, tail_len
= 0;
1093 size_t resp_len
= 0;
1096 u8
*pos
, *tailpos
, *csa_pos
;
1098 #define BEACON_HEAD_BUF_SIZE 256
1099 #define BEACON_TAIL_BUF_SIZE 512
1100 head
= os_zalloc(BEACON_HEAD_BUF_SIZE
);
1101 tail_len
= BEACON_TAIL_BUF_SIZE
;
1103 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
)
1104 tail_len
+= wpabuf_len(hapd
->wps_beacon_ie
);
1105 #endif /* CONFIG_WPS */
1107 if (hapd
->p2p_beacon_ie
)
1108 tail_len
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1109 #endif /* CONFIG_P2P */
1111 if (hapd
->iface
->fst_ies
)
1112 tail_len
+= wpabuf_len(hapd
->iface
->fst_ies
);
1113 #endif /* CONFIG_FST */
1114 if (hapd
->conf
->vendor_elements
)
1115 tail_len
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1117 #ifdef CONFIG_IEEE80211AC
1118 if (hapd
->conf
->vendor_vht
) {
1119 tail_len
+= 5 + 2 + sizeof(struct ieee80211_vht_capabilities
) +
1120 2 + sizeof(struct ieee80211_vht_operation
);
1122 #endif /* CONFIG_IEEE80211AC */
1124 #ifdef CONFIG_IEEE80211AX
1125 if (hapd
->iconf
->ieee80211ax
) {
1126 tail_len
+= 3 + sizeof(struct ieee80211_he_capabilities
) +
1127 3 + sizeof(struct ieee80211_he_operation
);
1129 #endif /* CONFIG_IEEE80211AX */
1131 tail_len
+= hostapd_mbo_ie_len(hapd
);
1132 tail_len
+= hostapd_eid_owe_trans_len(hapd
);
1134 tailpos
= tail
= os_malloc(tail_len
);
1135 if (head
== NULL
|| tail
== NULL
) {
1136 wpa_printf(MSG_ERROR
, "Failed to set beacon data");
1142 head
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
1143 WLAN_FC_STYPE_BEACON
);
1144 head
->duration
= host_to_le16(0);
1145 os_memset(head
->da
, 0xff, ETH_ALEN
);
1147 os_memcpy(head
->sa
, hapd
->own_addr
, ETH_ALEN
);
1148 os_memcpy(head
->bssid
, hapd
->own_addr
, ETH_ALEN
);
1149 head
->u
.beacon
.beacon_int
=
1150 host_to_le16(hapd
->iconf
->beacon_int
);
1152 /* hardware or low-level driver will setup seq_ctrl and timestamp */
1153 capab_info
= hostapd_own_capab_info(hapd
);
1154 head
->u
.beacon
.capab_info
= host_to_le16(capab_info
);
1155 pos
= &head
->u
.beacon
.variable
[0];
1158 *pos
++ = WLAN_EID_SSID
;
1159 if (hapd
->conf
->ignore_broadcast_ssid
== 2) {
1160 /* clear the data, but keep the correct length of the SSID */
1161 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1162 os_memset(pos
, 0, hapd
->conf
->ssid
.ssid_len
);
1163 pos
+= hapd
->conf
->ssid
.ssid_len
;
1164 } else if (hapd
->conf
->ignore_broadcast_ssid
) {
1165 *pos
++ = 0; /* empty SSID */
1167 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
1168 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
,
1169 hapd
->conf
->ssid
.ssid_len
);
1170 pos
+= hapd
->conf
->ssid
.ssid_len
;
1173 /* Supported rates */
1174 pos
= hostapd_eid_supp_rates(hapd
, pos
);
1177 pos
= hostapd_eid_ds_params(hapd
, pos
);
1179 head_len
= pos
- (u8
*) head
;
1181 tailpos
= hostapd_eid_country(hapd
, tailpos
,
1182 tail
+ BEACON_TAIL_BUF_SIZE
- tailpos
);
1184 /* Power Constraint element */
1185 tailpos
= hostapd_eid_pwr_constraint(hapd
, tailpos
);
1188 csa_pos
= hostapd_eid_csa(hapd
, tailpos
);
1189 if (csa_pos
!= tailpos
)
1190 hapd
->cs_c_off_beacon
= csa_pos
- tail
- 1;
1193 /* ERP Information element */
1194 tailpos
= hostapd_eid_erp_info(hapd
, tailpos
);
1196 /* Extended supported rates */
1197 tailpos
= hostapd_eid_ext_supp_rates(hapd
, tailpos
);
1199 /* RSN, MDIE, WPA */
1200 tailpos
= hostapd_eid_wpa(hapd
, tailpos
, tail
+ BEACON_TAIL_BUF_SIZE
-
1203 tailpos
= hostapd_eid_rm_enabled_capab(hapd
, tailpos
,
1204 tail
+ BEACON_TAIL_BUF_SIZE
-
1207 tailpos
= hostapd_eid_bss_load(hapd
, tailpos
,
1208 tail
+ BEACON_TAIL_BUF_SIZE
- tailpos
);
1211 csa_pos
= hostapd_eid_ecsa(hapd
, tailpos
);
1212 if (csa_pos
!= tailpos
)
1213 hapd
->cs_c_off_ecsa_beacon
= csa_pos
- tail
- 1;
1216 tailpos
= hostapd_eid_supported_op_classes(hapd
, tailpos
);
1218 #ifdef CONFIG_IEEE80211N
1219 /* Secondary Channel Offset element */
1220 /* TODO: The standard doesn't specify a position for this element. */
1221 tailpos
= hostapd_eid_secondary_channel(hapd
, tailpos
);
1223 tailpos
= hostapd_eid_ht_capabilities(hapd
, tailpos
);
1224 tailpos
= hostapd_eid_ht_operation(hapd
, tailpos
);
1225 #endif /* CONFIG_IEEE80211N */
1227 tailpos
= hostapd_eid_ext_capab(hapd
, tailpos
);
1230 * TODO: Time Advertisement element should only be included in some
1231 * DTIM Beacon frames.
1233 tailpos
= hostapd_eid_time_adv(hapd
, tailpos
);
1235 tailpos
= hostapd_eid_interworking(hapd
, tailpos
);
1236 tailpos
= hostapd_eid_adv_proto(hapd
, tailpos
);
1237 tailpos
= hostapd_eid_roaming_consortium(hapd
, tailpos
);
1240 if (hapd
->iface
->fst_ies
) {
1241 os_memcpy(tailpos
, wpabuf_head(hapd
->iface
->fst_ies
),
1242 wpabuf_len(hapd
->iface
->fst_ies
));
1243 tailpos
+= wpabuf_len(hapd
->iface
->fst_ies
);
1245 #endif /* CONFIG_FST */
1247 #ifdef CONFIG_IEEE80211AC
1248 if (hapd
->iconf
->ieee80211ac
&& !hapd
->conf
->disable_11ac
) {
1249 tailpos
= hostapd_eid_vht_capabilities(hapd
, tailpos
, 0);
1250 tailpos
= hostapd_eid_vht_operation(hapd
, tailpos
);
1251 tailpos
= hostapd_eid_txpower_envelope(hapd
, tailpos
);
1252 tailpos
= hostapd_eid_wb_chsw_wrapper(hapd
, tailpos
);
1254 #endif /* CONFIG_IEEE80211AC */
1256 tailpos
= hostapd_eid_fils_indic(hapd
, tailpos
, 0);
1258 #ifdef CONFIG_IEEE80211AX
1259 if (hapd
->iconf
->ieee80211ax
) {
1260 tailpos
= hostapd_eid_he_capab(hapd
, tailpos
);
1261 tailpos
= hostapd_eid_he_operation(hapd
, tailpos
);
1263 #endif /* CONFIG_IEEE80211AX */
1265 #ifdef CONFIG_IEEE80211AC
1266 if (hapd
->conf
->vendor_vht
)
1267 tailpos
= hostapd_eid_vendor_vht(hapd
, tailpos
);
1268 #endif /* CONFIG_IEEE80211AC */
1270 /* Wi-Fi Alliance WMM */
1271 tailpos
= hostapd_eid_wmm(hapd
, tailpos
);
1274 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
) {
1275 os_memcpy(tailpos
, wpabuf_head(hapd
->wps_beacon_ie
),
1276 wpabuf_len(hapd
->wps_beacon_ie
));
1277 tailpos
+= wpabuf_len(hapd
->wps_beacon_ie
);
1279 #endif /* CONFIG_WPS */
1282 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_beacon_ie
) {
1283 os_memcpy(tailpos
, wpabuf_head(hapd
->p2p_beacon_ie
),
1284 wpabuf_len(hapd
->p2p_beacon_ie
));
1285 tailpos
+= wpabuf_len(hapd
->p2p_beacon_ie
);
1287 #endif /* CONFIG_P2P */
1288 #ifdef CONFIG_P2P_MANAGER
1289 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
1291 tailpos
= hostapd_eid_p2p_manage(hapd
, tailpos
);
1292 #endif /* CONFIG_P2P_MANAGER */
1295 tailpos
= hostapd_eid_hs20_indication(hapd
, tailpos
);
1296 tailpos
= hostapd_eid_osen(hapd
, tailpos
);
1297 #endif /* CONFIG_HS20 */
1299 tailpos
= hostapd_eid_mbo(hapd
, tailpos
, tail
+ tail_len
- tailpos
);
1300 tailpos
= hostapd_eid_owe_trans(hapd
, tailpos
,
1301 tail
+ tail_len
- tailpos
);
1303 if (hapd
->conf
->vendor_elements
) {
1304 os_memcpy(tailpos
, wpabuf_head(hapd
->conf
->vendor_elements
),
1305 wpabuf_len(hapd
->conf
->vendor_elements
));
1306 tailpos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
1309 tail_len
= tailpos
> tail
? tailpos
- tail
: 0;
1311 resp
= hostapd_probe_resp_offloads(hapd
, &resp_len
);
1312 #endif /* NEED_AP_MLME */
1314 os_memset(params
, 0, sizeof(*params
));
1315 params
->head
= (u8
*) head
;
1316 params
->head_len
= head_len
;
1317 params
->tail
= tail
;
1318 params
->tail_len
= tail_len
;
1319 params
->proberesp
= resp
;
1320 params
->proberesp_len
= resp_len
;
1321 params
->dtim_period
= hapd
->conf
->dtim_period
;
1322 params
->beacon_int
= hapd
->iconf
->beacon_int
;
1323 params
->basic_rates
= hapd
->iface
->basic_rates
;
1324 params
->beacon_rate
= hapd
->iconf
->beacon_rate
;
1325 params
->rate_type
= hapd
->iconf
->rate_type
;
1326 params
->ssid
= hapd
->conf
->ssid
.ssid
;
1327 params
->ssid_len
= hapd
->conf
->ssid
.ssid_len
;
1328 if ((hapd
->conf
->wpa
& (WPA_PROTO_WPA
| WPA_PROTO_RSN
)) ==
1329 (WPA_PROTO_WPA
| WPA_PROTO_RSN
))
1330 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
|
1331 hapd
->conf
->rsn_pairwise
;
1332 else if (hapd
->conf
->wpa
& WPA_PROTO_RSN
)
1333 params
->pairwise_ciphers
= hapd
->conf
->rsn_pairwise
;
1334 else if (hapd
->conf
->wpa
& WPA_PROTO_WPA
)
1335 params
->pairwise_ciphers
= hapd
->conf
->wpa_pairwise
;
1336 params
->group_cipher
= hapd
->conf
->wpa_group
;
1337 params
->key_mgmt_suites
= hapd
->conf
->wpa_key_mgmt
;
1338 params
->auth_algs
= hapd
->conf
->auth_algs
;
1339 params
->wpa_version
= hapd
->conf
->wpa
;
1340 params
->privacy
= hapd
->conf
->ssid
.wep
.keys_set
|| hapd
->conf
->wpa
||
1341 (hapd
->conf
->ieee802_1x
&&
1342 (hapd
->conf
->default_wep_key_len
||
1343 hapd
->conf
->individual_wep_key_len
));
1344 switch (hapd
->conf
->ignore_broadcast_ssid
) {
1346 params
->hide_ssid
= NO_SSID_HIDING
;
1349 params
->hide_ssid
= HIDDEN_SSID_ZERO_LEN
;
1352 params
->hide_ssid
= HIDDEN_SSID_ZERO_CONTENTS
;
1355 params
->isolate
= hapd
->conf
->isolate
;
1356 params
->smps_mode
= hapd
->iconf
->ht_capab
& HT_CAP_INFO_SMPS_MASK
;
1358 params
->cts_protect
= !!(ieee802_11_erp_info(hapd
) &
1359 ERP_INFO_USE_PROTECTION
);
1360 params
->preamble
= hapd
->iface
->num_sta_no_short_preamble
== 0 &&
1361 hapd
->iconf
->preamble
== SHORT_PREAMBLE
;
1362 if (hapd
->iface
->current_mode
&&
1363 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
1364 params
->short_slot_time
=
1365 hapd
->iface
->num_sta_no_short_slot_time
> 0 ? 0 : 1;
1367 params
->short_slot_time
= -1;
1368 if (!hapd
->iconf
->ieee80211n
|| hapd
->conf
->disable_11n
)
1369 params
->ht_opmode
= -1;
1371 params
->ht_opmode
= hapd
->iface
->ht_op_mode
;
1372 #endif /* NEED_AP_MLME */
1373 params
->interworking
= hapd
->conf
->interworking
;
1374 if (hapd
->conf
->interworking
&&
1375 !is_zero_ether_addr(hapd
->conf
->hessid
))
1376 params
->hessid
= hapd
->conf
->hessid
;
1377 params
->access_network_type
= hapd
->conf
->access_network_type
;
1378 params
->ap_max_inactivity
= hapd
->conf
->ap_max_inactivity
;
1380 params
->p2p_go_ctwindow
= hapd
->iconf
->p2p_go_ctwindow
;
1381 #endif /* CONFIG_P2P */
1383 params
->disable_dgaf
= hapd
->conf
->disable_dgaf
;
1384 if (hapd
->conf
->osen
) {
1385 params
->privacy
= 1;
1388 #endif /* CONFIG_HS20 */
1389 params
->multicast_to_unicast
= hapd
->conf
->multicast_to_unicast
;
1390 params
->pbss
= hapd
->conf
->pbss
;
1395 void ieee802_11_free_ap_params(struct wpa_driver_ap_params
*params
)
1397 os_free(params
->tail
);
1398 params
->tail
= NULL
;
1399 os_free(params
->head
);
1400 params
->head
= NULL
;
1401 os_free(params
->proberesp
);
1402 params
->proberesp
= NULL
;
1406 int ieee802_11_set_beacon(struct hostapd_data
*hapd
)
1408 struct wpa_driver_ap_params params
;
1409 struct hostapd_freq_params freq
;
1410 struct hostapd_iface
*iface
= hapd
->iface
;
1411 struct hostapd_config
*iconf
= iface
->conf
;
1412 struct wpabuf
*beacon
, *proberesp
, *assocresp
;
1415 if (hapd
->csa_in_progress
) {
1416 wpa_printf(MSG_ERROR
, "Cannot set beacons during CSA period");
1420 hapd
->beacon_set_done
= 1;
1422 if (ieee802_11_build_ap_params(hapd
, ¶ms
) < 0)
1425 if (hostapd_build_ap_extra_ies(hapd
, &beacon
, &proberesp
, &assocresp
) <
1429 params
.beacon_ies
= beacon
;
1430 params
.proberesp_ies
= proberesp
;
1431 params
.assocresp_ies
= assocresp
;
1432 params
.reenable
= hapd
->reenable_beacon
;
1433 hapd
->reenable_beacon
= 0;
1435 if (iface
->current_mode
&&
1436 hostapd_set_freq_params(&freq
, iconf
->hw_mode
, iface
->freq
,
1437 iconf
->channel
, iconf
->ieee80211n
,
1439 iconf
->secondary_channel
,
1440 iconf
->vht_oper_chwidth
,
1441 iconf
->vht_oper_centr_freq_seg0_idx
,
1442 iconf
->vht_oper_centr_freq_seg1_idx
,
1443 iface
->current_mode
->vht_capab
) == 0)
1444 params
.freq
= &freq
;
1446 res
= hostapd_drv_set_ap(hapd
, ¶ms
);
1447 hostapd_free_ap_extra_ies(hapd
, beacon
, proberesp
, assocresp
);
1449 wpa_printf(MSG_ERROR
, "Failed to set beacon parameters");
1453 ieee802_11_free_ap_params(¶ms
);
1458 int ieee802_11_set_beacons(struct hostapd_iface
*iface
)
1463 for (i
= 0; i
< iface
->num_bss
; i
++) {
1464 if (iface
->bss
[i
]->started
&&
1465 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1473 /* only update beacons if started */
1474 int ieee802_11_update_beacons(struct hostapd_iface
*iface
)
1479 for (i
= 0; i
< iface
->num_bss
; i
++) {
1480 if (iface
->bss
[i
]->beacon_set_done
&& iface
->bss
[i
]->started
&&
1481 ieee802_11_set_beacon(iface
->bss
[i
]) < 0)
1488 #endif /* CONFIG_NATIVE_WINDOWS */