]> git.ipfire.org Git - thirdparty/hostap.git/blob - src/ap/beacon.c
c0fa6394d773e64bce11754eb021619e4a318361
[thirdparty/hostap.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 struct sta_info *sta)
189 {
190 const u8 *ie;
191 size_t ielen;
192
193 ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen);
194 if (ie == NULL || ielen > len)
195 return eid;
196
197 os_memcpy(eid, ie, ielen);
198 return eid + ielen;
199 }
200
201
202 static u8 * hostapd_eid_interworking(struct hostapd_data *hapd, u8 *eid)
203 {
204 u8 *pos = eid;
205 #ifdef CONFIG_INTERWORKING
206 u8 *len;
207
208 if (!hapd->conf->interworking)
209 return eid;
210
211 *pos++ = WLAN_EID_INTERWORKING;
212 len = pos++;
213
214 *pos = hapd->conf->access_network_type;
215 if (hapd->conf->internet)
216 *pos |= INTERWORKING_ANO_INTERNET;
217 if (hapd->conf->asra)
218 *pos |= INTERWORKING_ANO_ASRA;
219 if (hapd->conf->esr)
220 *pos |= INTERWORKING_ANO_ESR;
221 if (hapd->conf->uesa)
222 *pos |= INTERWORKING_ANO_UESA;
223 pos++;
224
225 if (hapd->conf->venue_info_set) {
226 *pos++ = hapd->conf->venue_group;
227 *pos++ = hapd->conf->venue_type;
228 }
229
230 if (!is_zero_ether_addr(hapd->conf->hessid)) {
231 os_memcpy(pos, hapd->conf->hessid, ETH_ALEN);
232 pos += ETH_ALEN;
233 }
234
235 *len = pos - len - 1;
236 #endif /* CONFIG_INTERWORKING */
237
238 return pos;
239 }
240
241
242 void handle_probe_req(struct hostapd_data *hapd,
243 const struct ieee80211_mgmt *mgmt, size_t len)
244 {
245 struct ieee80211_mgmt *resp;
246 struct ieee802_11_elems elems;
247 char *ssid;
248 u8 *pos, *epos;
249 const u8 *ie;
250 size_t ssid_len, ie_len;
251 struct sta_info *sta = NULL;
252 size_t buflen;
253 size_t i;
254
255 ie = mgmt->u.probe_req.variable;
256 if (len < IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req))
257 return;
258 ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
259
260 for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
261 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
262 mgmt->sa, mgmt->da, mgmt->bssid,
263 ie, ie_len) > 0)
264 return;
265
266 if (!hapd->iconf->send_probe_response)
267 return;
268
269 if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) {
270 wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR,
271 MAC2STR(mgmt->sa));
272 return;
273 }
274
275 ssid = NULL;
276 ssid_len = 0;
277
278 if ((!elems.ssid || !elems.supp_rates)) {
279 wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request "
280 "without SSID or supported rates element",
281 MAC2STR(mgmt->sa));
282 return;
283 }
284
285 #ifdef CONFIG_P2P
286 if (hapd->p2p && elems.wps_ie) {
287 struct wpabuf *wps;
288 wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA);
289 if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) {
290 wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
291 "due to mismatch with Requested Device "
292 "Type");
293 wpabuf_free(wps);
294 return;
295 }
296 wpabuf_free(wps);
297 }
298 #endif /* CONFIG_P2P */
299
300 if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0) {
301 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for "
302 "broadcast SSID ignored", MAC2STR(mgmt->sa));
303 return;
304 }
305
306 sta = ap_get_sta(hapd, mgmt->sa);
307
308 #ifdef CONFIG_P2P
309 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
310 elems.ssid_len == P2P_WILDCARD_SSID_LEN &&
311 os_memcmp(elems.ssid, P2P_WILDCARD_SSID,
312 P2P_WILDCARD_SSID_LEN) == 0) {
313 /* Process P2P Wildcard SSID like Wildcard SSID */
314 elems.ssid_len = 0;
315 }
316 #endif /* CONFIG_P2P */
317
318 if (elems.ssid_len == 0 ||
319 (elems.ssid_len == hapd->conf->ssid.ssid_len &&
320 os_memcmp(elems.ssid, hapd->conf->ssid.ssid, elems.ssid_len) ==
321 0)) {
322 ssid = hapd->conf->ssid.ssid;
323 ssid_len = hapd->conf->ssid.ssid_len;
324 if (sta)
325 sta->ssid_probe = &hapd->conf->ssid;
326 }
327
328 if (!ssid) {
329 if (!(mgmt->da[0] & 0x01)) {
330 char ssid_txt[33];
331 ieee802_11_print_ssid(ssid_txt, elems.ssid,
332 elems.ssid_len);
333 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
334 " for foreign SSID '%s' (DA " MACSTR ")",
335 MAC2STR(mgmt->sa), ssid_txt,
336 MAC2STR(mgmt->da));
337 }
338 return;
339 }
340
341 /* TODO: verify that supp_rates contains at least one matching rate
342 * with AP configuration */
343 #define MAX_PROBERESP_LEN 768
344 buflen = MAX_PROBERESP_LEN;
345 #ifdef CONFIG_WPS
346 if (hapd->wps_probe_resp_ie)
347 buflen += wpabuf_len(hapd->wps_probe_resp_ie);
348 #endif /* CONFIG_WPS */
349 #ifdef CONFIG_P2P
350 if (hapd->p2p_probe_resp_ie)
351 buflen += wpabuf_len(hapd->p2p_probe_resp_ie);
352 #endif /* CONFIG_P2P */
353 resp = os_zalloc(buflen);
354 if (resp == NULL)
355 return;
356 epos = ((u8 *) resp) + MAX_PROBERESP_LEN;
357
358 resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
359 WLAN_FC_STYPE_PROBE_RESP);
360 os_memcpy(resp->da, mgmt->sa, ETH_ALEN);
361 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
362
363 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
364 resp->u.probe_resp.beacon_int =
365 host_to_le16(hapd->iconf->beacon_int);
366
367 /* hardware or low-level driver will setup seq_ctrl and timestamp */
368 resp->u.probe_resp.capab_info =
369 host_to_le16(hostapd_own_capab_info(hapd, sta, 1));
370
371 pos = resp->u.probe_resp.variable;
372 *pos++ = WLAN_EID_SSID;
373 *pos++ = ssid_len;
374 os_memcpy(pos, ssid, ssid_len);
375 pos += ssid_len;
376
377 /* Supported rates */
378 pos = hostapd_eid_supp_rates(hapd, pos);
379
380 /* DS Params */
381 pos = hostapd_eid_ds_params(hapd, pos);
382
383 pos = hostapd_eid_country(hapd, pos, epos - pos);
384
385 /* ERP Information element */
386 pos = hostapd_eid_erp_info(hapd, pos);
387
388 /* Extended supported rates */
389 pos = hostapd_eid_ext_supp_rates(hapd, pos);
390
391 /* RSN, MDIE, WPA */
392 pos = hostapd_eid_wpa(hapd, pos, epos - pos, sta);
393
394 #ifdef CONFIG_IEEE80211N
395 pos = hostapd_eid_ht_capabilities(hapd, pos);
396 pos = hostapd_eid_ht_operation(hapd, pos);
397 #endif /* CONFIG_IEEE80211N */
398
399 pos = hostapd_eid_ext_capab(hapd, pos);
400
401 pos = hostapd_eid_interworking(hapd, pos);
402
403 /* Wi-Fi Alliance WMM */
404 pos = hostapd_eid_wmm(hapd, pos);
405
406 #ifdef CONFIG_WPS
407 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
408 os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
409 wpabuf_len(hapd->wps_probe_resp_ie));
410 pos += wpabuf_len(hapd->wps_probe_resp_ie);
411 }
412 #endif /* CONFIG_WPS */
413
414 #ifdef CONFIG_P2P
415 if ((hapd->conf->p2p & P2P_ENABLED) && elems.p2p &&
416 hapd->p2p_probe_resp_ie) {
417 os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie),
418 wpabuf_len(hapd->p2p_probe_resp_ie));
419 pos += wpabuf_len(hapd->p2p_probe_resp_ie);
420 }
421 #endif /* CONFIG_P2P */
422 #ifdef CONFIG_P2P_MANAGER
423 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
424 P2P_MANAGE)
425 pos = hostapd_eid_p2p_manage(hapd, pos);
426 #endif /* CONFIG_P2P_MANAGER */
427
428 if (hostapd_drv_send_mlme(hapd, resp, pos - (u8 *) resp) < 0)
429 perror("handle_probe_req: send");
430
431 os_free(resp);
432
433 wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s "
434 "SSID", MAC2STR(mgmt->sa),
435 elems.ssid_len == 0 ? "broadcast" : "our");
436 }
437
438
439 static int hostapd_set_ap_isolate(struct hostapd_data *hapd, int value)
440 {
441 if (hapd->driver == NULL || hapd->driver->set_intra_bss == NULL)
442 return 0;
443 return hapd->driver->set_intra_bss(hapd->drv_priv, !value);
444 }
445
446
447 static int hostapd_set_bss_params(struct hostapd_data *hapd,
448 int use_protection)
449 {
450 int ret = 0;
451 int preamble;
452 #ifdef CONFIG_IEEE80211N
453 u8 buf[60], *ht_capab, *ht_oper, *pos;
454
455 pos = buf;
456 ht_capab = pos;
457 pos = hostapd_eid_ht_capabilities(hapd, pos);
458 ht_oper = pos;
459 pos = hostapd_eid_ht_operation(hapd, pos);
460 if (pos > ht_oper && ht_oper > ht_capab &&
461 hostapd_set_ht_params(hapd, ht_capab + 2, ht_capab[1],
462 ht_oper + 2, ht_oper[1])) {
463 wpa_printf(MSG_ERROR, "Could not set HT capabilities "
464 "for kernel driver");
465 ret = -1;
466 }
467
468 #endif /* CONFIG_IEEE80211N */
469
470 if (hostapd_set_cts_protect(hapd, use_protection)) {
471 wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
472 "driver");
473 ret = -1;
474 }
475
476 if (hapd->iface->current_mode &&
477 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
478 hostapd_set_short_slot_time(hapd,
479 hapd->iface->num_sta_no_short_slot_time
480 > 0 ? 0 : 1)) {
481 wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
482 "in kernel driver");
483 ret = -1;
484 }
485
486 if (hapd->iface->num_sta_no_short_preamble == 0 &&
487 hapd->iconf->preamble == SHORT_PREAMBLE)
488 preamble = SHORT_PREAMBLE;
489 else
490 preamble = LONG_PREAMBLE;
491 if (hostapd_set_preamble(hapd, preamble)) {
492 wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
493 "driver");
494 ret = -1;
495 }
496
497 if (hostapd_set_ap_isolate(hapd, hapd->conf->isolate) &&
498 hapd->conf->isolate) {
499 wpa_printf(MSG_ERROR, "Could not enable AP isolation in "
500 "kernel driver");
501 ret = -1;
502 }
503
504 return ret;
505 }
506
507 #endif /* NEED_AP_MLME */
508
509
510 void ieee802_11_set_beacon(struct hostapd_data *hapd)
511 {
512 struct ieee80211_mgmt *head = NULL;
513 u8 *tail = NULL;
514 size_t head_len = 0, tail_len = 0;
515 struct wpa_driver_ap_params params;
516 struct wpabuf *beacon, *proberesp, *assocresp;
517 #ifdef NEED_AP_MLME
518 u16 capab_info;
519 u8 *pos, *tailpos;
520 #endif /* NEED_AP_MLME */
521
522 hapd->beacon_set_done = 1;
523
524 #ifdef NEED_AP_MLME
525
526 #define BEACON_HEAD_BUF_SIZE 256
527 #define BEACON_TAIL_BUF_SIZE 512
528 head = os_zalloc(BEACON_HEAD_BUF_SIZE);
529 tail_len = BEACON_TAIL_BUF_SIZE;
530 #ifdef CONFIG_WPS
531 if (hapd->conf->wps_state && hapd->wps_beacon_ie)
532 tail_len += wpabuf_len(hapd->wps_beacon_ie);
533 #endif /* CONFIG_WPS */
534 #ifdef CONFIG_P2P
535 if (hapd->p2p_beacon_ie)
536 tail_len += wpabuf_len(hapd->p2p_beacon_ie);
537 #endif /* CONFIG_P2P */
538 tailpos = tail = os_malloc(tail_len);
539 if (head == NULL || tail == NULL) {
540 wpa_printf(MSG_ERROR, "Failed to set beacon data");
541 os_free(head);
542 os_free(tail);
543 return;
544 }
545
546 head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
547 WLAN_FC_STYPE_BEACON);
548 head->duration = host_to_le16(0);
549 os_memset(head->da, 0xff, ETH_ALEN);
550
551 os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
552 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
553 head->u.beacon.beacon_int =
554 host_to_le16(hapd->iconf->beacon_int);
555
556 /* hardware or low-level driver will setup seq_ctrl and timestamp */
557 capab_info = hostapd_own_capab_info(hapd, NULL, 0);
558 head->u.beacon.capab_info = host_to_le16(capab_info);
559 pos = &head->u.beacon.variable[0];
560
561 /* SSID */
562 *pos++ = WLAN_EID_SSID;
563 if (hapd->conf->ignore_broadcast_ssid == 2) {
564 /* clear the data, but keep the correct length of the SSID */
565 *pos++ = hapd->conf->ssid.ssid_len;
566 os_memset(pos, 0, hapd->conf->ssid.ssid_len);
567 pos += hapd->conf->ssid.ssid_len;
568 } else if (hapd->conf->ignore_broadcast_ssid) {
569 *pos++ = 0; /* empty SSID */
570 } else {
571 *pos++ = hapd->conf->ssid.ssid_len;
572 os_memcpy(pos, hapd->conf->ssid.ssid,
573 hapd->conf->ssid.ssid_len);
574 pos += hapd->conf->ssid.ssid_len;
575 }
576
577 /* Supported rates */
578 pos = hostapd_eid_supp_rates(hapd, pos);
579
580 /* DS Params */
581 pos = hostapd_eid_ds_params(hapd, pos);
582
583 head_len = pos - (u8 *) head;
584
585 tailpos = hostapd_eid_country(hapd, tailpos,
586 tail + BEACON_TAIL_BUF_SIZE - tailpos);
587
588 /* ERP Information element */
589 tailpos = hostapd_eid_erp_info(hapd, tailpos);
590
591 /* Extended supported rates */
592 tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);
593
594 /* RSN, MDIE, WPA */
595 tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
596 tailpos, NULL);
597
598 #ifdef CONFIG_IEEE80211N
599 tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
600 tailpos = hostapd_eid_ht_operation(hapd, tailpos);
601 #endif /* CONFIG_IEEE80211N */
602
603 tailpos = hostapd_eid_ext_capab(hapd, tailpos);
604
605 tailpos = hostapd_eid_interworking(hapd, tailpos);
606
607 /* Wi-Fi Alliance WMM */
608 tailpos = hostapd_eid_wmm(hapd, tailpos);
609
610 #ifdef CONFIG_WPS
611 if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
612 os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
613 wpabuf_len(hapd->wps_beacon_ie));
614 tailpos += wpabuf_len(hapd->wps_beacon_ie);
615 }
616 #endif /* CONFIG_WPS */
617
618 #ifdef CONFIG_P2P
619 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) {
620 os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie),
621 wpabuf_len(hapd->p2p_beacon_ie));
622 tailpos += wpabuf_len(hapd->p2p_beacon_ie);
623 }
624 #endif /* CONFIG_P2P */
625 #ifdef CONFIG_P2P_MANAGER
626 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
627 P2P_MANAGE)
628 tailpos = hostapd_eid_p2p_manage(hapd, tailpos);
629 #endif /* CONFIG_P2P_MANAGER */
630
631 tail_len = tailpos > tail ? tailpos - tail : 0;
632
633 #endif /* NEED_AP_MLME */
634
635 os_memset(&params, 0, sizeof(params));
636 params.head = (u8 *) head;
637 params.head_len = head_len;
638 params.tail = tail;
639 params.tail_len = tail_len;
640 params.dtim_period = hapd->conf->dtim_period;
641 params.beacon_int = hapd->iconf->beacon_int;
642 params.ssid = (u8 *) hapd->conf->ssid.ssid;
643 params.ssid_len = hapd->conf->ssid.ssid_len;
644 params.pairwise_ciphers = hapd->conf->rsn_pairwise ?
645 hapd->conf->rsn_pairwise : hapd->conf->wpa_pairwise;
646 params.group_cipher = hapd->conf->wpa_group;
647 params.key_mgmt_suites = hapd->conf->wpa_key_mgmt;
648 params.auth_algs = hapd->conf->auth_algs;
649 params.wpa_version = hapd->conf->wpa;
650 params.privacy = hapd->conf->ssid.wep.keys_set || hapd->conf->wpa ||
651 (hapd->conf->ieee802_1x &&
652 (hapd->conf->default_wep_key_len ||
653 hapd->conf->individual_wep_key_len));
654 switch (hapd->conf->ignore_broadcast_ssid) {
655 case 0:
656 params.hide_ssid = NO_SSID_HIDING;
657 break;
658 case 1:
659 params.hide_ssid = HIDDEN_SSID_ZERO_LEN;
660 break;
661 case 2:
662 params.hide_ssid = HIDDEN_SSID_ZERO_CONTENTS;
663 break;
664 }
665 hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp);
666 params.beacon_ies = beacon;
667 params.proberesp_ies = proberesp;
668 params.assocresp_ies = assocresp;
669 if (hostapd_drv_set_ap(hapd, &params))
670 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
671 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
672
673 os_free(tail);
674 os_free(head);
675
676 #ifdef NEED_AP_MLME
677 hostapd_set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) &
678 ERP_INFO_USE_PROTECTION));
679 #endif /* NEED_AP_MLME */
680 }
681
682
683 void ieee802_11_set_beacons(struct hostapd_iface *iface)
684 {
685 size_t i;
686 for (i = 0; i < iface->num_bss; i++)
687 ieee802_11_set_beacon(iface->bss[i]);
688 }
689
690 #endif /* CONFIG_NATIVE_WINDOWS */