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