Interworking: Filter Probe Request frames based on HESSID and ANT
[mech_eap.git] / src / ap / beacon.c
1 /*
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-2009, Jouni Malinen <j@w1.fi>
6  *
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.
10  *
11  * Alternatively, this software may be distributed under the terms of BSD
12  * license.
13  *
14  * See README and COPYING for more details.
15  */
16
17 #include "utils/includes.h"
18
19 #ifndef CONFIG_NATIVE_WINDOWS
20
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"
26 #include "p2p/p2p.h"
27 #include "hostapd.h"
28 #include "ieee802_11.h"
29 #include "wpa_auth.h"
30 #include "wmm.h"
31 #include "ap_config.h"
32 #include "sta_info.h"
33 #include "p2p_hostapd.h"
34 #include "ap_drv_ops.h"
35 #include "beacon.h"
36
37
38 #ifdef NEED_AP_MLME
39
40 static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
41 {
42         u8 erp = 0;
43
44         if (hapd->iface->current_mode == NULL ||
45             hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
46                 return 0;
47
48         switch (hapd->iconf->cts_protection_type) {
49         case CTS_PROTECTION_FORCE_ENABLED:
50                 erp |= ERP_INFO_NON_ERP_PRESENT | ERP_INFO_USE_PROTECTION;
51                 break;
52         case CTS_PROTECTION_FORCE_DISABLED:
53                 erp = 0;
54                 break;
55         case CTS_PROTECTION_AUTOMATIC:
56                 if (hapd->iface->olbc)
57                         erp |= ERP_INFO_USE_PROTECTION;
58                 /* continue */
59         case CTS_PROTECTION_AUTOMATIC_NO_OLBC:
60                 if (hapd->iface->num_sta_non_erp > 0) {
61                         erp |= ERP_INFO_NON_ERP_PRESENT |
62                                 ERP_INFO_USE_PROTECTION;
63                 }
64                 break;
65         }
66         if (hapd->iface->num_sta_no_short_preamble > 0 ||
67             hapd->iconf->preamble == LONG_PREAMBLE)
68                 erp |= ERP_INFO_BARKER_PREAMBLE_MODE;
69
70         return erp;
71 }
72
73
74 static u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid)
75 {
76         *eid++ = WLAN_EID_DS_PARAMS;
77         *eid++ = 1;
78         *eid++ = hapd->iconf->channel;
79         return eid;
80 }
81
82
83 static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid)
84 {
85         if (hapd->iface->current_mode == NULL ||
86             hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
87                 return eid;
88
89         /* Set NonERP_present and use_protection bits if there
90          * are any associated NonERP stations. */
91         /* TODO: use_protection bit can be set to zero even if
92          * there are NonERP stations present. This optimization
93          * might be useful if NonERP stations are "quiet".
94          * See 802.11g/D6 E-1 for recommended practice.
95          * In addition, Non ERP present might be set, if AP detects Non ERP
96          * operation on other APs. */
97
98         /* Add ERP Information element */
99         *eid++ = WLAN_EID_ERP_INFO;
100         *eid++ = 1;
101         *eid++ = ieee802_11_erp_info(hapd);
102
103         return eid;
104 }
105
106
107 static u8 * hostapd_eid_country_add(u8 *pos, u8 *end, int chan_spacing,
108                                     struct hostapd_channel_data *start,
109                                     struct hostapd_channel_data *prev)
110 {
111         if (end - pos < 3)
112                 return pos;
113
114         /* first channel number */
115         *pos++ = start->chan;
116         /* number of channels */
117         *pos++ = (prev->chan - start->chan) / chan_spacing + 1;
118         /* maximum transmit power level */
119         *pos++ = start->max_tx_power;
120
121         return pos;
122 }
123
124
125 static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid,
126                                 int max_len)
127 {
128         u8 *pos = eid;
129         u8 *end = eid + max_len;
130         int i;
131         struct hostapd_hw_modes *mode;
132         struct hostapd_channel_data *start, *prev;
133         int chan_spacing = 1;
134
135         if (!hapd->iconf->ieee80211d || max_len < 6 ||
136             hapd->iface->current_mode == NULL)
137                 return eid;
138
139         *pos++ = WLAN_EID_COUNTRY;
140         pos++; /* length will be set later */
141         os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
142         pos += 3;
143
144         mode = hapd->iface->current_mode;
145         if (mode->mode == HOSTAPD_MODE_IEEE80211A)
146                 chan_spacing = 4;
147
148         start = prev = NULL;
149         for (i = 0; i < mode->num_channels; i++) {
150                 struct hostapd_channel_data *chan = &mode->channels[i];
151                 if (chan->flag & HOSTAPD_CHAN_DISABLED)
152                         continue;
153                 if (start && prev &&
154                     prev->chan + chan_spacing == chan->chan &&
155                     start->max_tx_power == chan->max_tx_power) {
156                         prev = chan;
157                         continue; /* can use same entry */
158                 }
159
160                 if (start) {
161                         pos = hostapd_eid_country_add(pos, end, chan_spacing,
162                                                       start, prev);
163                         start = NULL;
164                 }
165
166                 /* Start new group */
167                 start = prev = chan;
168         }
169
170         if (start) {
171                 pos = hostapd_eid_country_add(pos, end, chan_spacing,
172                                               start, prev);
173         }
174
175         if ((pos - eid) & 1) {
176                 if (end - pos < 1)
177                         return eid;
178                 *pos++ = 0; /* pad for 16-bit alignment */
179         }
180
181         eid[1] = (pos - eid) - 2;
182
183         return pos;
184 }
185
186
187 static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len)
188 {
189         const u8 *ie;
190         size_t ielen;
191
192         ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen);
193         if (ie == NULL || ielen > len)
194                 return eid;
195
196         os_memcpy(eid, ie, ielen);
197         return eid + ielen;
198 }
199
200
201 void handle_probe_req(struct hostapd_data *hapd,
202                       const struct ieee80211_mgmt *mgmt, size_t len)
203 {
204         struct ieee80211_mgmt *resp;
205         struct ieee802_11_elems elems;
206         char *ssid;
207         u8 *pos, *epos;
208         const u8 *ie;
209         size_t ssid_len, ie_len;
210         struct sta_info *sta = NULL;
211         size_t buflen;
212         size_t i;
213
214         ie = mgmt->u.probe_req.variable;
215         if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
216                 return;
217         ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
218
219         for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
220                 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
221                                             mgmt->sa, mgmt->da, mgmt->bssid,
222                                             ie, ie_len) > 0)
223                         return;
224
225         if (!hapd->iconf->send_probe_response)
226                 return;
227
228         if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) {
229                 wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR,
230                            MAC2STR(mgmt->sa));
231                 return;
232         }
233
234         ssid = NULL;
235         ssid_len = 0;
236
237         if ((!elems.ssid || !elems.supp_rates)) {
238                 wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request "
239                            "without SSID or supported rates element",
240                            MAC2STR(mgmt->sa));
241                 return;
242         }
243
244 #ifdef CONFIG_P2P
245         if (hapd->p2p && elems.wps_ie) {
246                 struct wpabuf *wps;
247                 wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA);
248                 if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) {
249                         wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
250                                    "due to mismatch with Requested Device "
251                                    "Type");
252                         wpabuf_free(wps);
253                         return;
254                 }
255                 wpabuf_free(wps);
256         }
257 #endif /* CONFIG_P2P */
258
259         if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0) {
260                 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for "
261                            "broadcast SSID ignored", MAC2STR(mgmt->sa));
262                 return;
263         }
264
265         sta = ap_get_sta(hapd, mgmt->sa);
266
267 #ifdef CONFIG_P2P
268         if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
269             elems.ssid_len == P2P_WILDCARD_SSID_LEN &&
270             os_memcmp(elems.ssid, P2P_WILDCARD_SSID,
271                       P2P_WILDCARD_SSID_LEN) == 0) {
272                 /* Process P2P Wildcard SSID like Wildcard SSID */
273                 elems.ssid_len = 0;
274         }
275 #endif /* CONFIG_P2P */
276
277         if (elems.ssid_len == 0 ||
278             (elems.ssid_len == hapd->conf->ssid.ssid_len &&
279              os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) ==
280              0)) {
281                 ssid = hapd->conf->ssid.ssid;
282                 ssid_len = hapd->conf->ssid.ssid_len;
283                 if (sta)
284                         sta->ssid_probe = &hapd->conf->ssid;
285         }
286
287         if (!ssid) {
288                 if (!(mgmt->da[0] & 0x01)) {
289                         char ssid_txt[33];
290                         ieee802_11_print_ssid(ssid_txt, elems.ssid,
291                                               elems.ssid_len);
292                         wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
293                                    " for foreign SSID '%s' (DA " MACSTR ")",
294                                    MAC2STR(mgmt->sa), ssid_txt,
295                                    MAC2STR(mgmt->da));
296                 }
297                 return;
298         }
299
300 #ifdef CONFIG_INTERWORKING
301         if (elems.interworking && elems.interworking_len >= 1) {
302                 u8 ant = elems.interworking[0] & 0x0f;
303                 if (ant != INTERWORKING_ANT_WILDCARD &&
304                     ant != hapd->conf->access_network_type) {
305                         wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
306                                    " for mismatching ANT %u ignored",
307                                    MAC2STR(mgmt->sa), ant);
308                         return;
309                 }
310         }
311
312         if (elems.interworking &&
313             (elems.interworking_len == 7 || elems.interworking_len == 9)) {
314                 const u8 *hessid;
315                 if (elems.interworking_len == 7)
316                         hessid = elems.interworking + 1;
317                 else
318                         hessid = elems.interworking + 1 + 2;
319                 if (!is_broadcast_ether_addr(hessid) &&
320                     os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) {
321                         wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
322                                    " for mismatching HESSID " MACSTR
323                                    " ignored",
324                                    MAC2STR(mgmt->sa), MAC2STR(hessid));
325                         return;
326                 }
327         }
328 #endif /* CONFIG_INTERWORKING */
329
330         /* TODO: verify that supp_rates contains at least one matching rate
331          * with AP configuration */
332 #define MAX_PROBERESP_LEN 768
333         buflen = MAX_PROBERESP_LEN;
334 #ifdef CONFIG_WPS
335         if (hapd->wps_probe_resp_ie)
336                 buflen += wpabuf_len(hapd->wps_probe_resp_ie);
337 #endif /* CONFIG_WPS */
338 #ifdef CONFIG_P2P
339         if (hapd->p2p_probe_resp_ie)
340                 buflen += wpabuf_len(hapd->p2p_probe_resp_ie);
341 #endif /* CONFIG_P2P */
342         resp = os_zalloc(buflen);
343         if (resp == NULL)
344                 return;
345         epos = ((u8 *) resp) + MAX_PROBERESP_LEN;
346
347         resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
348                                            WLAN_FC_STYPE_PROBE_RESP);
349         os_memcpy(resp->da, mgmt->sa, ETH_ALEN);
350         os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
351
352         os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
353         resp->u.probe_resp.beacon_int =
354                 host_to_le16(hapd->iconf->beacon_int);
355
356         /* hardware or low-level driver will setup seq_ctrl and timestamp */
357         resp->u.probe_resp.capab_info =
358                 host_to_le16(hostapd_own_capab_info(hapd, sta, 1));
359
360         pos = resp->u.probe_resp.variable;
361         *pos++ = WLAN_EID_SSID;
362         *pos++ = ssid_len;
363         os_memcpy(pos, ssid, ssid_len);
364         pos += ssid_len;
365
366         /* Supported rates */
367         pos = hostapd_eid_supp_rates(hapd, pos);
368
369         /* DS Params */
370         pos = hostapd_eid_ds_params(hapd, pos);
371
372         pos = hostapd_eid_country(hapd, pos, epos - pos);
373
374         /* ERP Information element */
375         pos = hostapd_eid_erp_info(hapd, pos);
376
377         /* Extended supported rates */
378         pos = hostapd_eid_ext_supp_rates(hapd, pos);
379
380         /* RSN, MDIE, WPA */
381         pos = hostapd_eid_wpa(hapd, pos, epos - pos);
382
383 #ifdef CONFIG_IEEE80211N
384         pos = hostapd_eid_ht_capabilities(hapd, pos);
385         pos = hostapd_eid_ht_operation(hapd, pos);
386 #endif /* CONFIG_IEEE80211N */
387
388         pos = hostapd_eid_ext_capab(hapd, pos);
389
390         pos = hostapd_eid_time_adv(hapd, pos);
391         pos = hostapd_eid_time_zone(hapd, pos);
392
393         pos = hostapd_eid_interworking(hapd, pos);
394         pos = hostapd_eid_adv_proto(hapd, pos);
395         pos = hostapd_eid_roaming_consortium(hapd, pos);
396
397         /* Wi-Fi Alliance WMM */
398         pos = hostapd_eid_wmm(hapd, pos);
399
400 #ifdef CONFIG_WPS
401         if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
402                 os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
403                           wpabuf_len(hapd->wps_probe_resp_ie));
404                 pos += wpabuf_len(hapd->wps_probe_resp_ie);
405         }
406 #endif /* CONFIG_WPS */
407
408 #ifdef CONFIG_P2P
409         if ((hapd->conf->p2p & P2P_ENABLED) && elems.p2p &&
410             hapd->p2p_probe_resp_ie) {
411                 os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie),
412                           wpabuf_len(hapd->p2p_probe_resp_ie));
413                 pos += wpabuf_len(hapd->p2p_probe_resp_ie);
414         }
415 #endif /* CONFIG_P2P */
416 #ifdef CONFIG_P2P_MANAGER
417         if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
418             P2P_MANAGE)
419                 pos = hostapd_eid_p2p_manage(hapd, pos);
420 #endif /* CONFIG_P2P_MANAGER */
421
422         if (hostapd_drv_send_mlme(hapd, resp, pos - (u8 *) resp) < 0)
423                 perror("handle_probe_req: send");
424
425         os_free(resp);
426
427         wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s "
428                    "SSID", MAC2STR(mgmt->sa),
429                    elems.ssid_len == 0 ? "broadcast" : "our");
430 }
431
432 #endif /* NEED_AP_MLME */
433
434
435 void ieee802_11_set_beacon(struct hostapd_data *hapd)
436 {
437         struct ieee80211_mgmt *head = NULL;
438         u8 *tail = NULL;
439         size_t head_len = 0, tail_len = 0;
440         struct wpa_driver_ap_params params;
441         struct wpabuf *beacon, *proberesp, *assocresp;
442 #ifdef NEED_AP_MLME
443         u16 capab_info;
444         u8 *pos, *tailpos;
445 #endif /* NEED_AP_MLME */
446
447         hapd->beacon_set_done = 1;
448
449 #ifdef NEED_AP_MLME
450
451 #define BEACON_HEAD_BUF_SIZE 256
452 #define BEACON_TAIL_BUF_SIZE 512
453         head = os_zalloc(BEACON_HEAD_BUF_SIZE);
454         tail_len = BEACON_TAIL_BUF_SIZE;
455 #ifdef CONFIG_WPS
456         if (hapd->conf->wps_state && hapd->wps_beacon_ie)
457                 tail_len += wpabuf_len(hapd->wps_beacon_ie);
458 #endif /* CONFIG_WPS */
459 #ifdef CONFIG_P2P
460         if (hapd->p2p_beacon_ie)
461                 tail_len += wpabuf_len(hapd->p2p_beacon_ie);
462 #endif /* CONFIG_P2P */
463         tailpos = tail = os_malloc(tail_len);
464         if (head == NULL || tail == NULL) {
465                 wpa_printf(MSG_ERROR, "Failed to set beacon data");
466                 os_free(head);
467                 os_free(tail);
468                 return;
469         }
470
471         head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
472                                            WLAN_FC_STYPE_BEACON);
473         head->duration = host_to_le16(0);
474         os_memset(head->da, 0xff, ETH_ALEN);
475
476         os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
477         os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
478         head->u.beacon.beacon_int =
479                 host_to_le16(hapd->iconf->beacon_int);
480
481         /* hardware or low-level driver will setup seq_ctrl and timestamp */
482         capab_info = hostapd_own_capab_info(hapd, NULL, 0);
483         head->u.beacon.capab_info = host_to_le16(capab_info);
484         pos = &head->u.beacon.variable[0];
485
486         /* SSID */
487         *pos++ = WLAN_EID_SSID;
488         if (hapd->conf->ignore_broadcast_ssid == 2) {
489                 /* clear the data, but keep the correct length of the SSID */
490                 *pos++ = hapd->conf->ssid.ssid_len;
491                 os_memset(pos, 0, hapd->conf->ssid.ssid_len);
492                 pos += hapd->conf->ssid.ssid_len;
493         } else if (hapd->conf->ignore_broadcast_ssid) {
494                 *pos++ = 0; /* empty SSID */
495         } else {
496                 *pos++ = hapd->conf->ssid.ssid_len;
497                 os_memcpy(pos, hapd->conf->ssid.ssid,
498                           hapd->conf->ssid.ssid_len);
499                 pos += hapd->conf->ssid.ssid_len;
500         }
501
502         /* Supported rates */
503         pos = hostapd_eid_supp_rates(hapd, pos);
504
505         /* DS Params */
506         pos = hostapd_eid_ds_params(hapd, pos);
507
508         head_len = pos - (u8 *) head;
509
510         tailpos = hostapd_eid_country(hapd, tailpos,
511                                       tail + BEACON_TAIL_BUF_SIZE - tailpos);
512
513         /* ERP Information element */
514         tailpos = hostapd_eid_erp_info(hapd, tailpos);
515
516         /* Extended supported rates */
517         tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);
518
519         /* RSN, MDIE, WPA */
520         tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
521                                   tailpos);
522
523 #ifdef CONFIG_IEEE80211N
524         tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
525         tailpos = hostapd_eid_ht_operation(hapd, tailpos);
526 #endif /* CONFIG_IEEE80211N */
527
528         tailpos = hostapd_eid_ext_capab(hapd, tailpos);
529
530         /*
531          * TODO: Time Advertisement element should only be included in some
532          * DTIM Beacon frames.
533          */
534         tailpos = hostapd_eid_time_adv(hapd, tailpos);
535
536         tailpos = hostapd_eid_interworking(hapd, tailpos);
537         tailpos = hostapd_eid_adv_proto(hapd, tailpos);
538         tailpos = hostapd_eid_roaming_consortium(hapd, tailpos);
539
540         /* Wi-Fi Alliance WMM */
541         tailpos = hostapd_eid_wmm(hapd, tailpos);
542
543 #ifdef CONFIG_WPS
544         if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
545                 os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
546                           wpabuf_len(hapd->wps_beacon_ie));
547                 tailpos += wpabuf_len(hapd->wps_beacon_ie);
548         }
549 #endif /* CONFIG_WPS */
550
551 #ifdef CONFIG_P2P
552         if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) {
553                 os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie),
554                           wpabuf_len(hapd->p2p_beacon_ie));
555                 tailpos += wpabuf_len(hapd->p2p_beacon_ie);
556         }
557 #endif /* CONFIG_P2P */
558 #ifdef CONFIG_P2P_MANAGER
559         if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
560             P2P_MANAGE)
561                 tailpos = hostapd_eid_p2p_manage(hapd, tailpos);
562 #endif /* CONFIG_P2P_MANAGER */
563
564         tail_len = tailpos > tail ? tailpos - tail : 0;
565
566 #endif /* NEED_AP_MLME */
567
568         os_memset(&params, 0, sizeof(params));
569         params.head = (u8 *) head;
570         params.head_len = head_len;
571         params.tail = tail;
572         params.tail_len = tail_len;
573         params.dtim_period = hapd->conf->dtim_period;
574         params.beacon_int = hapd->iconf->beacon_int;
575         params.ssid = (u8 *) hapd->conf->ssid.ssid;
576         params.ssid_len = hapd->conf->ssid.ssid_len;
577         params.pairwise_ciphers = hapd->conf->rsn_pairwise ?
578                 hapd->conf->rsn_pairwise : hapd->conf->wpa_pairwise;
579         params.group_cipher = hapd->conf->wpa_group;
580         params.key_mgmt_suites = hapd->conf->wpa_key_mgmt;
581         params.auth_algs = hapd->conf->auth_algs;
582         params.wpa_version = hapd->conf->wpa;
583         params.privacy = hapd->conf->ssid.wep.keys_set || hapd->conf->wpa ||
584                 (hapd->conf->ieee802_1x &&
585                  (hapd->conf->default_wep_key_len ||
586                   hapd->conf->individual_wep_key_len));
587         switch (hapd->conf->ignore_broadcast_ssid) {
588         case 0:
589                 params.hide_ssid = NO_SSID_HIDING;
590                 break;
591         case 1:
592                 params.hide_ssid = HIDDEN_SSID_ZERO_LEN;
593                 break;
594         case 2:
595                 params.hide_ssid = HIDDEN_SSID_ZERO_CONTENTS;
596                 break;
597         }
598         hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp);
599         params.beacon_ies = beacon;
600         params.proberesp_ies = proberesp;
601         params.assocresp_ies = assocresp;
602         params.isolate = hapd->conf->isolate;
603 #ifdef NEED_AP_MLME
604         params.cts_protect = !!(ieee802_11_erp_info(hapd) &
605                                 ERP_INFO_USE_PROTECTION);
606         params.preamble = hapd->iface->num_sta_no_short_preamble == 0 &&
607                 hapd->iconf->preamble == SHORT_PREAMBLE;
608         if (hapd->iface->current_mode &&
609             hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
610                 params.short_slot_time =
611                         hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1;
612         else
613                 params.short_slot_time = -1;
614         if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
615                 params.ht_opmode = -1;
616         else
617                 params.ht_opmode = hapd->iface->ht_op_mode;
618 #endif /* NEED_AP_MLME */
619         params.interworking = hapd->conf->interworking;
620         if (hapd->conf->interworking &&
621             !is_zero_ether_addr(hapd->conf->hessid))
622                 params.hessid = hapd->conf->hessid;
623         params.access_network_type = hapd->conf->access_network_type;
624         if (hostapd_drv_set_ap(hapd, &params))
625                 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
626         hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
627
628         os_free(tail);
629         os_free(head);
630 }
631
632
633 void ieee802_11_set_beacons(struct hostapd_iface *iface)
634 {
635         size_t i;
636         for (i = 0; i < iface->num_bss; i++)
637                 ieee802_11_set_beacon(iface->bss[i]);
638 }
639
640 #endif /* CONFIG_NATIVE_WINDOWS */