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 program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * Alternatively, this software may be distributed under the terms of BSD
14 * See README and COPYING for more details.
17 #include "utils/includes.h"
19 #ifndef CONFIG_NATIVE_WINDOWS
21 #include "utils/common.h"
22 #include "common/ieee802_11_defs.h"
23 #include "common/ieee802_11_common.h"
24 #include "drivers/driver.h"
25 #include "wps/wps_defs.h"
28 #include "ieee802_11.h"
31 #include "ap_config.h"
33 #include "p2p_hostapd.h"
34 #include "ap_drv_ops.h"
41 static u8
ieee802_11_erp_info(struct hostapd_data
*hapd
)
45 if (hapd
->iface
->current_mode
== NULL
||
46 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
49 if (hapd
->iface
->olbc
)
50 erp
|= ERP_INFO_USE_PROTECTION
;
51 if (hapd
->iface
->num_sta_non_erp
> 0) {
52 erp
|= ERP_INFO_NON_ERP_PRESENT
|
53 ERP_INFO_USE_PROTECTION
;
55 if (hapd
->iface
->num_sta_no_short_preamble
> 0 ||
56 hapd
->iconf
->preamble
== LONG_PREAMBLE
)
57 erp
|= ERP_INFO_BARKER_PREAMBLE_MODE
;
63 static u8
* hostapd_eid_ds_params(struct hostapd_data
*hapd
, u8
*eid
)
65 *eid
++ = WLAN_EID_DS_PARAMS
;
67 *eid
++ = hapd
->iconf
->channel
;
72 static u8
* hostapd_eid_erp_info(struct hostapd_data
*hapd
, u8
*eid
)
74 if (hapd
->iface
->current_mode
== NULL
||
75 hapd
->iface
->current_mode
->mode
!= HOSTAPD_MODE_IEEE80211G
)
78 /* Set NonERP_present and use_protection bits if there
79 * are any associated NonERP stations. */
80 /* TODO: use_protection bit can be set to zero even if
81 * there are NonERP stations present. This optimization
82 * might be useful if NonERP stations are "quiet".
83 * See 802.11g/D6 E-1 for recommended practice.
84 * In addition, Non ERP present might be set, if AP detects Non ERP
85 * operation on other APs. */
87 /* Add ERP Information element */
88 *eid
++ = WLAN_EID_ERP_INFO
;
90 *eid
++ = ieee802_11_erp_info(hapd
);
96 static u8
* hostapd_eid_country_add(u8
*pos
, u8
*end
, int chan_spacing
,
97 struct hostapd_channel_data
*start
,
98 struct hostapd_channel_data
*prev
)
103 /* first channel number */
104 *pos
++ = start
->chan
;
105 /* number of channels */
106 *pos
++ = (prev
->chan
- start
->chan
) / chan_spacing
+ 1;
107 /* maximum transmit power level */
108 *pos
++ = start
->max_tx_power
;
114 static u8
* hostapd_eid_country(struct hostapd_data
*hapd
, u8
*eid
,
118 u8
*end
= eid
+ max_len
;
120 struct hostapd_hw_modes
*mode
;
121 struct hostapd_channel_data
*start
, *prev
;
122 int chan_spacing
= 1;
124 if (!hapd
->iconf
->ieee80211d
|| max_len
< 6 ||
125 hapd
->iface
->current_mode
== NULL
)
128 *pos
++ = WLAN_EID_COUNTRY
;
129 pos
++; /* length will be set later */
130 os_memcpy(pos
, hapd
->iconf
->country
, 3); /* e.g., 'US ' */
133 mode
= hapd
->iface
->current_mode
;
134 if (mode
->mode
== HOSTAPD_MODE_IEEE80211A
)
138 for (i
= 0; i
< mode
->num_channels
; i
++) {
139 struct hostapd_channel_data
*chan
= &mode
->channels
[i
];
140 if (chan
->flag
& HOSTAPD_CHAN_DISABLED
)
143 prev
->chan
+ chan_spacing
== chan
->chan
&&
144 start
->max_tx_power
== chan
->max_tx_power
) {
146 continue; /* can use same entry */
150 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
155 /* Start new group */
160 pos
= hostapd_eid_country_add(pos
, end
, chan_spacing
,
164 if ((pos
- eid
) & 1) {
167 *pos
++ = 0; /* pad for 16-bit alignment */
170 eid
[1] = (pos
- eid
) - 2;
176 static u8
* hostapd_eid_wpa(struct hostapd_data
*hapd
, u8
*eid
, size_t len
)
181 ie
= wpa_auth_get_wpa_ie(hapd
->wpa_auth
, &ielen
);
182 if (ie
== NULL
|| ielen
> len
)
185 os_memcpy(eid
, ie
, ielen
);
190 static u8
* hostapd_gen_probe_resp(struct hostapd_data
*hapd
,
191 struct sta_info
*sta
,
192 const struct ieee80211_mgmt
*req
,
193 int is_p2p
, size_t *resp_len
)
195 struct ieee80211_mgmt
*resp
;
199 #define MAX_PROBERESP_LEN 768
200 buflen
= MAX_PROBERESP_LEN
;
202 if (hapd
->wps_probe_resp_ie
)
203 buflen
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
204 #endif /* CONFIG_WPS */
206 if (hapd
->p2p_probe_resp_ie
)
207 buflen
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
208 #endif /* CONFIG_P2P */
209 if (hapd
->conf
->vendor_elements
)
210 buflen
+= wpabuf_len(hapd
->conf
->vendor_elements
);
211 resp
= os_zalloc(buflen
);
215 epos
= ((u8
*) resp
) + MAX_PROBERESP_LEN
;
217 resp
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
218 WLAN_FC_STYPE_PROBE_RESP
);
220 os_memcpy(resp
->da
, req
->sa
, ETH_ALEN
);
221 os_memcpy(resp
->sa
, hapd
->own_addr
, ETH_ALEN
);
223 os_memcpy(resp
->bssid
, hapd
->own_addr
, ETH_ALEN
);
224 resp
->u
.probe_resp
.beacon_int
=
225 host_to_le16(hapd
->iconf
->beacon_int
);
227 /* hardware or low-level driver will setup seq_ctrl and timestamp */
228 resp
->u
.probe_resp
.capab_info
=
229 host_to_le16(hostapd_own_capab_info(hapd
, sta
, 1));
231 pos
= resp
->u
.probe_resp
.variable
;
232 *pos
++ = WLAN_EID_SSID
;
233 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
234 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
, hapd
->conf
->ssid
.ssid_len
);
235 pos
+= hapd
->conf
->ssid
.ssid_len
;
237 /* Supported rates */
238 pos
= hostapd_eid_supp_rates(hapd
, pos
);
241 pos
= hostapd_eid_ds_params(hapd
, pos
);
243 pos
= hostapd_eid_country(hapd
, pos
, epos
- pos
);
245 /* ERP Information element */
246 pos
= hostapd_eid_erp_info(hapd
, pos
);
248 /* Extended supported rates */
249 pos
= hostapd_eid_ext_supp_rates(hapd
, pos
);
252 pos
= hostapd_eid_wpa(hapd
, pos
, epos
- pos
);
254 #ifdef CONFIG_IEEE80211N
255 pos
= hostapd_eid_ht_capabilities(hapd
, pos
);
256 pos
= hostapd_eid_ht_operation(hapd
, pos
);
257 #endif /* CONFIG_IEEE80211N */
259 pos
= hostapd_eid_ext_capab(hapd
, pos
);
261 pos
= hostapd_eid_time_adv(hapd
, pos
);
262 pos
= hostapd_eid_time_zone(hapd
, pos
);
264 pos
= hostapd_eid_interworking(hapd
, pos
);
265 pos
= hostapd_eid_adv_proto(hapd
, pos
);
266 pos
= hostapd_eid_roaming_consortium(hapd
, pos
);
268 #ifdef CONFIG_IEEE80211AC
269 pos
= hostapd_eid_vht_capabilities(hapd
, pos
);
270 pos
= hostapd_eid_vht_operation(hapd
, pos
);
271 #endif /* CONFIG_IEEE80211AC */
273 /* Wi-Fi Alliance WMM */
274 pos
= hostapd_eid_wmm(hapd
, pos
);
277 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
) {
278 os_memcpy(pos
, wpabuf_head(hapd
->wps_probe_resp_ie
),
279 wpabuf_len(hapd
->wps_probe_resp_ie
));
280 pos
+= wpabuf_len(hapd
->wps_probe_resp_ie
);
282 #endif /* CONFIG_WPS */
285 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && is_p2p
&&
286 hapd
->p2p_probe_resp_ie
) {
287 os_memcpy(pos
, wpabuf_head(hapd
->p2p_probe_resp_ie
),
288 wpabuf_len(hapd
->p2p_probe_resp_ie
));
289 pos
+= wpabuf_len(hapd
->p2p_probe_resp_ie
);
291 #endif /* CONFIG_P2P */
292 #ifdef CONFIG_P2P_MANAGER
293 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
295 pos
= hostapd_eid_p2p_manage(hapd
, pos
);
296 #endif /* CONFIG_P2P_MANAGER */
299 pos
= hostapd_eid_hs20_indication(hapd
, pos
);
300 #endif /* CONFIG_HS20 */
302 if (hapd
->conf
->vendor_elements
) {
303 os_memcpy(pos
, wpabuf_head(hapd
->conf
->vendor_elements
),
304 wpabuf_len(hapd
->conf
->vendor_elements
));
305 pos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
308 *resp_len
= pos
- (u8
*) resp
;
313 enum ssid_match_result
{
319 static enum ssid_match_result
ssid_match(struct hostapd_data
*hapd
,
320 const u8
*ssid
, size_t ssid_len
,
322 size_t ssid_list_len
)
329 if (ssid_len
== hapd
->conf
->ssid
.ssid_len
&&
330 os_memcmp(ssid
, hapd
->conf
->ssid
.ssid
, ssid_len
) == 0)
331 return EXACT_SSID_MATCH
;
333 if (ssid_list
== NULL
)
334 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
337 end
= ssid_list
+ ssid_list_len
;
338 while (pos
+ 1 <= end
) {
339 if (pos
+ 2 + pos
[1] > end
)
343 if (pos
[1] == hapd
->conf
->ssid
.ssid_len
&&
344 os_memcmp(pos
+ 2, hapd
->conf
->ssid
.ssid
, pos
[1]) == 0)
345 return EXACT_SSID_MATCH
;
349 return wildcard
? WILDCARD_SSID_MATCH
: NO_SSID_MATCH
;
353 void handle_probe_req(struct hostapd_data
*hapd
,
354 const struct ieee80211_mgmt
*mgmt
, size_t len
,
358 struct ieee802_11_elems elems
;
361 struct sta_info
*sta
= NULL
;
364 enum ssid_match_result res
;
366 ie
= mgmt
->u
.probe_req
.variable
;
367 if (len
< IEEE80211_HDRLEN
+ sizeof(mgmt
->u
.probe_req
))
369 ie_len
= len
- (IEEE80211_HDRLEN
+ sizeof(mgmt
->u
.probe_req
));
371 for (i
= 0; hapd
->probereq_cb
&& i
< hapd
->num_probereq_cb
; i
++)
372 if (hapd
->probereq_cb
[i
].cb(hapd
->probereq_cb
[i
].ctx
,
373 mgmt
->sa
, mgmt
->da
, mgmt
->bssid
,
374 ie
, ie_len
, ssi_signal
) > 0)
377 if (!hapd
->iconf
->send_probe_response
)
380 if (ieee802_11_parse_elems(ie
, ie_len
, &elems
, 0) == ParseFailed
) {
381 wpa_printf(MSG_DEBUG
, "Could not parse ProbeReq from " MACSTR
,
386 if ((!elems
.ssid
|| !elems
.supp_rates
)) {
387 wpa_printf(MSG_DEBUG
, "STA " MACSTR
" sent probe request "
388 "without SSID or supported rates element",
394 if (hapd
->p2p
&& elems
.wps_ie
) {
396 wps
= ieee802_11_vendor_ie_concat(ie
, ie_len
, WPS_DEV_OUI_WFA
);
397 if (wps
&& !p2p_group_match_dev_type(hapd
->p2p_group
, wps
)) {
398 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
399 "due to mismatch with Requested Device "
407 if (hapd
->p2p
&& elems
.p2p
) {
409 p2p
= ieee802_11_vendor_ie_concat(ie
, ie_len
, P2P_IE_VENDOR_TYPE
);
410 if (p2p
&& !p2p_group_match_dev_id(hapd
->p2p_group
, p2p
)) {
411 wpa_printf(MSG_MSGDUMP
, "P2P: Ignore Probe Request "
412 "due to mismatch with Device ID");
418 #endif /* CONFIG_P2P */
420 if (hapd
->conf
->ignore_broadcast_ssid
&& elems
.ssid_len
== 0 &&
421 elems
.ssid_list_len
== 0) {
422 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
" for "
423 "broadcast SSID ignored", MAC2STR(mgmt
->sa
));
427 sta
= ap_get_sta(hapd
, mgmt
->sa
);
430 if ((hapd
->conf
->p2p
& P2P_GROUP_OWNER
) &&
431 elems
.ssid_len
== P2P_WILDCARD_SSID_LEN
&&
432 os_memcmp(elems
.ssid
, P2P_WILDCARD_SSID
,
433 P2P_WILDCARD_SSID_LEN
) == 0) {
434 /* Process P2P Wildcard SSID like Wildcard SSID */
437 #endif /* CONFIG_P2P */
439 res
= ssid_match(hapd
, elems
.ssid
, elems
.ssid_len
,
440 elems
.ssid_list
, elems
.ssid_list_len
);
441 if (res
!= NO_SSID_MATCH
) {
443 sta
->ssid_probe
= &hapd
->conf
->ssid
;
445 if (!(mgmt
->da
[0] & 0x01)) {
447 ieee802_11_print_ssid(ssid_txt
, elems
.ssid
,
449 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
450 " for foreign SSID '%s' (DA " MACSTR
")%s",
451 MAC2STR(mgmt
->sa
), ssid_txt
,
453 elems
.ssid_list
? " (SSID list)" : "");
458 #ifdef CONFIG_INTERWORKING
459 if (elems
.interworking
&& elems
.interworking_len
>= 1) {
460 u8 ant
= elems
.interworking
[0] & 0x0f;
461 if (ant
!= INTERWORKING_ANT_WILDCARD
&&
462 ant
!= hapd
->conf
->access_network_type
) {
463 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
464 " for mismatching ANT %u ignored",
465 MAC2STR(mgmt
->sa
), ant
);
470 if (elems
.interworking
&&
471 (elems
.interworking_len
== 7 || elems
.interworking_len
== 9)) {
473 if (elems
.interworking_len
== 7)
474 hessid
= elems
.interworking
+ 1;
476 hessid
= elems
.interworking
+ 1 + 2;
477 if (!is_broadcast_ether_addr(hessid
) &&
478 os_memcmp(hessid
, hapd
->conf
->hessid
, ETH_ALEN
) != 0) {
479 wpa_printf(MSG_MSGDUMP
, "Probe Request from " MACSTR
480 " for mismatching HESSID " MACSTR
482 MAC2STR(mgmt
->sa
), MAC2STR(hessid
));
486 #endif /* CONFIG_INTERWORKING */
488 /* TODO: verify that supp_rates contains at least one matching rate
489 * with AP configuration */
491 resp
= hostapd_gen_probe_resp(hapd
, sta
, mgmt
, elems
.p2p
!= NULL
,
497 * If this is a broadcast probe request, apply no ack policy to avoid
500 noack
= !!(res
== WILDCARD_SSID_MATCH
&&
501 is_broadcast_ether_addr(mgmt
->da
));
503 if (hostapd_drv_send_mlme(hapd
, resp
, resp_len
, noack
) < 0)
504 perror("handle_probe_req: send");
508 wpa_printf(MSG_EXCESSIVE
, "STA " MACSTR
" sent probe request for %s "
509 "SSID", MAC2STR(mgmt
->sa
),
510 elems
.ssid_len
== 0 ? "broadcast" : "our");
514 static u8
* hostapd_probe_resp_offloads(struct hostapd_data
*hapd
,
517 /* check probe response offloading caps and print warnings */
518 if (!(hapd
->iface
->drv_flags
& WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD
))
522 if (hapd
->conf
->wps_state
&& hapd
->wps_probe_resp_ie
&&
523 (!(hapd
->iface
->probe_resp_offloads
&
524 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS
|
525 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2
))))
526 wpa_printf(MSG_WARNING
, "Device is trying to offload WPS "
527 "Probe Response while not supporting this");
528 #endif /* CONFIG_WPS */
531 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_probe_resp_ie
&&
532 !(hapd
->iface
->probe_resp_offloads
&
533 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P
))
534 wpa_printf(MSG_WARNING
, "Device is trying to offload P2P "
535 "Probe Response while not supporting this");
536 #endif /* CONFIG_P2P */
538 if (hapd
->conf
->interworking
&&
539 !(hapd
->iface
->probe_resp_offloads
&
540 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING
))
541 wpa_printf(MSG_WARNING
, "Device is trying to offload "
542 "Interworking Probe Response while not supporting "
545 /* Generate a Probe Response template for the non-P2P case */
546 return hostapd_gen_probe_resp(hapd
, NULL
, NULL
, 0, resp_len
);
549 #endif /* NEED_AP_MLME */
552 void ieee802_11_set_beacon(struct hostapd_data
*hapd
)
554 struct ieee80211_mgmt
*head
= NULL
;
556 size_t head_len
= 0, tail_len
= 0;
559 struct wpa_driver_ap_params params
;
560 struct wpabuf
*beacon
, *proberesp
, *assocresp
;
564 #endif /* NEED_AP_MLME */
566 hapd
->beacon_set_done
= 1;
570 #define BEACON_HEAD_BUF_SIZE 256
571 #define BEACON_TAIL_BUF_SIZE 512
572 head
= os_zalloc(BEACON_HEAD_BUF_SIZE
);
573 tail_len
= BEACON_TAIL_BUF_SIZE
;
575 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
)
576 tail_len
+= wpabuf_len(hapd
->wps_beacon_ie
);
577 #endif /* CONFIG_WPS */
579 if (hapd
->p2p_beacon_ie
)
580 tail_len
+= wpabuf_len(hapd
->p2p_beacon_ie
);
581 #endif /* CONFIG_P2P */
582 if (hapd
->conf
->vendor_elements
)
583 tail_len
+= wpabuf_len(hapd
->conf
->vendor_elements
);
584 tailpos
= tail
= os_malloc(tail_len
);
585 if (head
== NULL
|| tail
== NULL
) {
586 wpa_printf(MSG_ERROR
, "Failed to set beacon data");
592 head
->frame_control
= IEEE80211_FC(WLAN_FC_TYPE_MGMT
,
593 WLAN_FC_STYPE_BEACON
);
594 head
->duration
= host_to_le16(0);
595 os_memset(head
->da
, 0xff, ETH_ALEN
);
597 os_memcpy(head
->sa
, hapd
->own_addr
, ETH_ALEN
);
598 os_memcpy(head
->bssid
, hapd
->own_addr
, ETH_ALEN
);
599 head
->u
.beacon
.beacon_int
=
600 host_to_le16(hapd
->iconf
->beacon_int
);
602 /* hardware or low-level driver will setup seq_ctrl and timestamp */
603 capab_info
= hostapd_own_capab_info(hapd
, NULL
, 0);
604 head
->u
.beacon
.capab_info
= host_to_le16(capab_info
);
605 pos
= &head
->u
.beacon
.variable
[0];
608 *pos
++ = WLAN_EID_SSID
;
609 if (hapd
->conf
->ignore_broadcast_ssid
== 2) {
610 /* clear the data, but keep the correct length of the SSID */
611 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
612 os_memset(pos
, 0, hapd
->conf
->ssid
.ssid_len
);
613 pos
+= hapd
->conf
->ssid
.ssid_len
;
614 } else if (hapd
->conf
->ignore_broadcast_ssid
) {
615 *pos
++ = 0; /* empty SSID */
617 *pos
++ = hapd
->conf
->ssid
.ssid_len
;
618 os_memcpy(pos
, hapd
->conf
->ssid
.ssid
,
619 hapd
->conf
->ssid
.ssid_len
);
620 pos
+= hapd
->conf
->ssid
.ssid_len
;
623 /* Supported rates */
624 pos
= hostapd_eid_supp_rates(hapd
, pos
);
627 pos
= hostapd_eid_ds_params(hapd
, pos
);
629 head_len
= pos
- (u8
*) head
;
631 tailpos
= hostapd_eid_country(hapd
, tailpos
,
632 tail
+ BEACON_TAIL_BUF_SIZE
- tailpos
);
634 /* ERP Information element */
635 tailpos
= hostapd_eid_erp_info(hapd
, tailpos
);
637 /* Extended supported rates */
638 tailpos
= hostapd_eid_ext_supp_rates(hapd
, tailpos
);
641 tailpos
= hostapd_eid_wpa(hapd
, tailpos
, tail
+ BEACON_TAIL_BUF_SIZE
-
644 #ifdef CONFIG_IEEE80211N
645 tailpos
= hostapd_eid_ht_capabilities(hapd
, tailpos
);
646 tailpos
= hostapd_eid_ht_operation(hapd
, tailpos
);
647 #endif /* CONFIG_IEEE80211N */
649 tailpos
= hostapd_eid_ext_capab(hapd
, tailpos
);
652 * TODO: Time Advertisement element should only be included in some
653 * DTIM Beacon frames.
655 tailpos
= hostapd_eid_time_adv(hapd
, tailpos
);
657 tailpos
= hostapd_eid_interworking(hapd
, tailpos
);
658 tailpos
= hostapd_eid_adv_proto(hapd
, tailpos
);
659 tailpos
= hostapd_eid_roaming_consortium(hapd
, tailpos
);
661 #ifdef CONFIG_IEEE80211AC
662 tailpos
= hostapd_eid_vht_capabilities(hapd
, tailpos
);
663 tailpos
= hostapd_eid_vht_operation(hapd
, tailpos
);
664 #endif /* CONFIG_IEEE80211AC */
666 /* Wi-Fi Alliance WMM */
667 tailpos
= hostapd_eid_wmm(hapd
, tailpos
);
670 if (hapd
->conf
->wps_state
&& hapd
->wps_beacon_ie
) {
671 os_memcpy(tailpos
, wpabuf_head(hapd
->wps_beacon_ie
),
672 wpabuf_len(hapd
->wps_beacon_ie
));
673 tailpos
+= wpabuf_len(hapd
->wps_beacon_ie
);
675 #endif /* CONFIG_WPS */
678 if ((hapd
->conf
->p2p
& P2P_ENABLED
) && hapd
->p2p_beacon_ie
) {
679 os_memcpy(tailpos
, wpabuf_head(hapd
->p2p_beacon_ie
),
680 wpabuf_len(hapd
->p2p_beacon_ie
));
681 tailpos
+= wpabuf_len(hapd
->p2p_beacon_ie
);
683 #endif /* CONFIG_P2P */
684 #ifdef CONFIG_P2P_MANAGER
685 if ((hapd
->conf
->p2p
& (P2P_MANAGE
| P2P_ENABLED
| P2P_GROUP_OWNER
)) ==
687 tailpos
= hostapd_eid_p2p_manage(hapd
, tailpos
);
688 #endif /* CONFIG_P2P_MANAGER */
691 tailpos
= hostapd_eid_hs20_indication(hapd
, tailpos
);
692 #endif /* CONFIG_HS20 */
694 if (hapd
->conf
->vendor_elements
) {
695 os_memcpy(tailpos
, wpabuf_head(hapd
->conf
->vendor_elements
),
696 wpabuf_len(hapd
->conf
->vendor_elements
));
697 tailpos
+= wpabuf_len(hapd
->conf
->vendor_elements
);
700 tail_len
= tailpos
> tail
? tailpos
- tail
: 0;
702 resp
= hostapd_probe_resp_offloads(hapd
, &resp_len
);
703 #endif /* NEED_AP_MLME */
705 os_memset(¶ms
, 0, sizeof(params
));
706 params
.head
= (u8
*) head
;
707 params
.head_len
= head_len
;
709 params
.tail_len
= tail_len
;
710 params
.proberesp
= resp
;
711 params
.proberesp_len
= resp_len
;
712 params
.dtim_period
= hapd
->conf
->dtim_period
;
713 params
.beacon_int
= hapd
->iconf
->beacon_int
;
714 params
.basic_rates
= hapd
->iface
->basic_rates
;
715 params
.ssid
= hapd
->conf
->ssid
.ssid
;
716 params
.ssid_len
= hapd
->conf
->ssid
.ssid_len
;
717 params
.pairwise_ciphers
= hapd
->conf
->rsn_pairwise
?
718 hapd
->conf
->rsn_pairwise
: hapd
->conf
->wpa_pairwise
;
719 params
.group_cipher
= hapd
->conf
->wpa_group
;
720 params
.key_mgmt_suites
= hapd
->conf
->wpa_key_mgmt
;
721 params
.auth_algs
= hapd
->conf
->auth_algs
;
722 params
.wpa_version
= hapd
->conf
->wpa
;
723 params
.privacy
= hapd
->conf
->ssid
.wep
.keys_set
|| hapd
->conf
->wpa
||
724 (hapd
->conf
->ieee802_1x
&&
725 (hapd
->conf
->default_wep_key_len
||
726 hapd
->conf
->individual_wep_key_len
));
727 switch (hapd
->conf
->ignore_broadcast_ssid
) {
729 params
.hide_ssid
= NO_SSID_HIDING
;
732 params
.hide_ssid
= HIDDEN_SSID_ZERO_LEN
;
735 params
.hide_ssid
= HIDDEN_SSID_ZERO_CONTENTS
;
738 hostapd_build_ap_extra_ies(hapd
, &beacon
, &proberesp
, &assocresp
);
739 params
.beacon_ies
= beacon
;
740 params
.proberesp_ies
= proberesp
;
741 params
.assocresp_ies
= assocresp
;
742 params
.isolate
= hapd
->conf
->isolate
;
744 params
.cts_protect
= !!(ieee802_11_erp_info(hapd
) &
745 ERP_INFO_USE_PROTECTION
);
746 params
.preamble
= hapd
->iface
->num_sta_no_short_preamble
== 0 &&
747 hapd
->iconf
->preamble
== SHORT_PREAMBLE
;
748 if (hapd
->iface
->current_mode
&&
749 hapd
->iface
->current_mode
->mode
== HOSTAPD_MODE_IEEE80211G
)
750 params
.short_slot_time
=
751 hapd
->iface
->num_sta_no_short_slot_time
> 0 ? 0 : 1;
753 params
.short_slot_time
= -1;
754 if (!hapd
->iconf
->ieee80211n
|| hapd
->conf
->disable_11n
)
755 params
.ht_opmode
= -1;
757 params
.ht_opmode
= hapd
->iface
->ht_op_mode
;
758 #endif /* NEED_AP_MLME */
759 params
.interworking
= hapd
->conf
->interworking
;
760 if (hapd
->conf
->interworking
&&
761 !is_zero_ether_addr(hapd
->conf
->hessid
))
762 params
.hessid
= hapd
->conf
->hessid
;
763 params
.access_network_type
= hapd
->conf
->access_network_type
;
764 params
.ap_max_inactivity
= hapd
->conf
->ap_max_inactivity
;
766 params
.disable_dgaf
= hapd
->conf
->disable_dgaf
;
767 #endif /* CONFIG_HS20 */
768 if (hostapd_drv_set_ap(hapd
, ¶ms
))
769 wpa_printf(MSG_ERROR
, "Failed to set beacon parameters");
770 hostapd_free_ap_extra_ies(hapd
, beacon
, proberesp
, assocresp
);
778 void ieee802_11_set_beacons(struct hostapd_iface
*iface
)
781 for (i
= 0; i
< iface
->num_bss
; i
++)
782 ieee802_11_set_beacon(iface
->bss
[i
]);
786 /* only update beacons if started */
787 void ieee802_11_update_beacons(struct hostapd_iface
*iface
)
790 for (i
= 0; i
< iface
->num_bss
; i
++)
791 if (iface
->bss
[i
]->beacon_set_done
)
792 ieee802_11_set_beacon(iface
->bss
[i
]);
795 #endif /* CONFIG_NATIVE_WINDOWS */