blob: 202abe6de0e8e82aaa90bae7750836792249d313 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
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.
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -08005 * Copyright (c) 2008-2012, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07006 *
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08007 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07009 */
10
11#include "utils/includes.h"
12
13#ifndef CONFIG_NATIVE_WINDOWS
14
15#include "utils/common.h"
16#include "common/ieee802_11_defs.h"
17#include "common/ieee802_11_common.h"
Dmitry Shmidt7f656022015-02-25 14:36:37 -080018#include "common/hw_features_common.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070019#include "wps/wps_defs.h"
20#include "p2p/p2p.h"
21#include "hostapd.h"
22#include "ieee802_11.h"
23#include "wpa_auth.h"
24#include "wmm.h"
25#include "ap_config.h"
26#include "sta_info.h"
27#include "p2p_hostapd.h"
28#include "ap_drv_ops.h"
29#include "beacon.h"
Dmitry Shmidt61d9df32012-08-29 16:22:06 -070030#include "hs20.h"
Dmitry Shmidtf21452a2014-02-26 10:55:25 -080031#include "dfs.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070032
33
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080034#ifdef NEED_AP_MLME
35
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080036static u8 * hostapd_eid_rm_enabled_capab(struct hostapd_data *hapd, u8 *eid,
37 size_t len)
38{
Dmitry Shmidt849734c2016-05-27 09:59:01 -070039 size_t i;
40
41 for (i = 0; i < RRM_CAPABILITIES_IE_LEN; i++) {
42 if (hapd->conf->radio_measurements[i])
43 break;
44 }
45
46 if (i == RRM_CAPABILITIES_IE_LEN || len < 2 + RRM_CAPABILITIES_IE_LEN)
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080047 return eid;
48
49 *eid++ = WLAN_EID_RRM_ENABLED_CAPABILITIES;
Dmitry Shmidt849734c2016-05-27 09:59:01 -070050 *eid++ = RRM_CAPABILITIES_IE_LEN;
51 os_memcpy(eid, hapd->conf->radio_measurements, RRM_CAPABILITIES_IE_LEN);
52
53 return eid + RRM_CAPABILITIES_IE_LEN;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080054}
55
56
Dmitry Shmidt051af732013-10-22 13:52:46 -070057static u8 * hostapd_eid_bss_load(struct hostapd_data *hapd, u8 *eid, size_t len)
58{
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080059 if (len < 2 + 5)
60 return eid;
61
Dmitry Shmidt051af732013-10-22 13:52:46 -070062#ifdef CONFIG_TESTING_OPTIONS
63 if (hapd->conf->bss_load_test_set) {
Dmitry Shmidt051af732013-10-22 13:52:46 -070064 *eid++ = WLAN_EID_BSS_LOAD;
65 *eid++ = 5;
66 os_memcpy(eid, hapd->conf->bss_load_test, 5);
67 eid += 5;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080068 return eid;
Dmitry Shmidt051af732013-10-22 13:52:46 -070069 }
70#endif /* CONFIG_TESTING_OPTIONS */
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -080071 if (hapd->conf->bss_load_update_period) {
72 *eid++ = WLAN_EID_BSS_LOAD;
73 *eid++ = 5;
74 WPA_PUT_LE16(eid, hapd->num_sta);
75 eid += 2;
76 *eid++ = hapd->iface->channel_utilization;
77 WPA_PUT_LE16(eid, 0); /* no available admission capabity */
78 eid += 2;
79 }
Dmitry Shmidt051af732013-10-22 13:52:46 -070080 return eid;
81}
82
83
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070084static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
85{
86 u8 erp = 0;
87
88 if (hapd->iface->current_mode == NULL ||
89 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
90 return 0;
91
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -080092 if (hapd->iface->olbc)
93 erp |= ERP_INFO_USE_PROTECTION;
94 if (hapd->iface->num_sta_non_erp > 0) {
95 erp |= ERP_INFO_NON_ERP_PRESENT |
96 ERP_INFO_USE_PROTECTION;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070097 }
98 if (hapd->iface->num_sta_no_short_preamble > 0 ||
99 hapd->iconf->preamble == LONG_PREAMBLE)
100 erp |= ERP_INFO_BARKER_PREAMBLE_MODE;
101
102 return erp;
103}
104
105
106static u8 * hostapd_eid_ds_params(struct hostapd_data *hapd, u8 *eid)
107{
108 *eid++ = WLAN_EID_DS_PARAMS;
109 *eid++ = 1;
110 *eid++ = hapd->iconf->channel;
111 return eid;
112}
113
114
115static u8 * hostapd_eid_erp_info(struct hostapd_data *hapd, u8 *eid)
116{
117 if (hapd->iface->current_mode == NULL ||
118 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G)
119 return eid;
120
121 /* Set NonERP_present and use_protection bits if there
122 * are any associated NonERP stations. */
123 /* TODO: use_protection bit can be set to zero even if
124 * there are NonERP stations present. This optimization
125 * might be useful if NonERP stations are "quiet".
126 * See 802.11g/D6 E-1 for recommended practice.
127 * In addition, Non ERP present might be set, if AP detects Non ERP
128 * operation on other APs. */
129
130 /* Add ERP Information element */
131 *eid++ = WLAN_EID_ERP_INFO;
132 *eid++ = 1;
133 *eid++ = ieee802_11_erp_info(hapd);
134
135 return eid;
136}
137
138
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800139static u8 * hostapd_eid_pwr_constraint(struct hostapd_data *hapd, u8 *eid)
140{
141 u8 *pos = eid;
142 u8 local_pwr_constraint = 0;
143 int dfs;
144
145 if (hapd->iface->current_mode == NULL ||
146 hapd->iface->current_mode->mode != HOSTAPD_MODE_IEEE80211A)
147 return eid;
148
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700149 /* Let host drivers add this IE if DFS support is offloaded */
150 if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_DFS_OFFLOAD)
151 return eid;
152
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800153 /*
154 * There is no DFS support and power constraint was not directly
155 * requested by config option.
156 */
157 if (!hapd->iconf->ieee80211h &&
158 hapd->iconf->local_pwr_constraint == -1)
159 return eid;
160
161 /* Check if DFS is required by regulatory. */
162 dfs = hostapd_is_dfs_required(hapd->iface);
163 if (dfs < 0) {
164 wpa_printf(MSG_WARNING, "Failed to check if DFS is required; ret=%d",
165 dfs);
166 dfs = 0;
167 }
168
169 if (dfs == 0 && hapd->iconf->local_pwr_constraint == -1)
170 return eid;
171
172 /*
173 * ieee80211h (DFS) is enabled so Power Constraint element shall
174 * be added when running on DFS channel whenever local_pwr_constraint
175 * is configured or not. In order to meet regulations when TPC is not
176 * implemented using a transmit power that is below the legal maximum
177 * (including any mitigation factor) should help. In this case,
178 * indicate 3 dB below maximum allowed transmit power.
179 */
180 if (hapd->iconf->local_pwr_constraint == -1)
181 local_pwr_constraint = 3;
182
183 /*
184 * A STA that is not an AP shall use a transmit power less than or
185 * equal to the local maximum transmit power level for the channel.
186 * The local maximum transmit power can be calculated from the formula:
187 * local max TX pwr = max TX pwr - local pwr constraint
188 * Where max TX pwr is maximum transmit power level specified for
189 * channel in Country element and local pwr constraint is specified
190 * for channel in this Power Constraint element.
191 */
192
193 /* Element ID */
194 *pos++ = WLAN_EID_PWR_CONSTRAINT;
195 /* Length */
196 *pos++ = 1;
197 /* Local Power Constraint */
198 if (local_pwr_constraint)
199 *pos++ = local_pwr_constraint;
200 else
201 *pos++ = hapd->iconf->local_pwr_constraint;
202
203 return pos;
204}
205
206
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700207static u8 * hostapd_eid_country_add(u8 *pos, u8 *end, int chan_spacing,
208 struct hostapd_channel_data *start,
209 struct hostapd_channel_data *prev)
210{
211 if (end - pos < 3)
212 return pos;
213
214 /* first channel number */
215 *pos++ = start->chan;
216 /* number of channels */
217 *pos++ = (prev->chan - start->chan) / chan_spacing + 1;
218 /* maximum transmit power level */
219 *pos++ = start->max_tx_power;
220
221 return pos;
222}
223
224
225static u8 * hostapd_eid_country(struct hostapd_data *hapd, u8 *eid,
226 int max_len)
227{
228 u8 *pos = eid;
229 u8 *end = eid + max_len;
230 int i;
231 struct hostapd_hw_modes *mode;
232 struct hostapd_channel_data *start, *prev;
233 int chan_spacing = 1;
234
235 if (!hapd->iconf->ieee80211d || max_len < 6 ||
236 hapd->iface->current_mode == NULL)
237 return eid;
238
239 *pos++ = WLAN_EID_COUNTRY;
240 pos++; /* length will be set later */
241 os_memcpy(pos, hapd->iconf->country, 3); /* e.g., 'US ' */
242 pos += 3;
243
244 mode = hapd->iface->current_mode;
245 if (mode->mode == HOSTAPD_MODE_IEEE80211A)
246 chan_spacing = 4;
247
248 start = prev = NULL;
249 for (i = 0; i < mode->num_channels; i++) {
250 struct hostapd_channel_data *chan = &mode->channels[i];
251 if (chan->flag & HOSTAPD_CHAN_DISABLED)
252 continue;
253 if (start && prev &&
254 prev->chan + chan_spacing == chan->chan &&
255 start->max_tx_power == chan->max_tx_power) {
256 prev = chan;
257 continue; /* can use same entry */
258 }
259
Dmitry Shmidt09f57ba2014-06-10 16:07:13 -0700260 if (start && prev) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700261 pos = hostapd_eid_country_add(pos, end, chan_spacing,
262 start, prev);
263 start = NULL;
264 }
265
266 /* Start new group */
267 start = prev = chan;
268 }
269
270 if (start) {
271 pos = hostapd_eid_country_add(pos, end, chan_spacing,
272 start, prev);
273 }
274
275 if ((pos - eid) & 1) {
276 if (end - pos < 1)
277 return eid;
278 *pos++ = 0; /* pad for 16-bit alignment */
279 }
280
281 eid[1] = (pos - eid) - 2;
282
283 return pos;
284}
285
286
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800287static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700288{
289 const u8 *ie;
290 size_t ielen;
291
292 ie = wpa_auth_get_wpa_ie(hapd->wpa_auth, &ielen);
293 if (ie == NULL || ielen > len)
294 return eid;
295
296 os_memcpy(eid, ie, ielen);
297 return eid + ielen;
298}
299
300
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800301static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid)
302{
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800303#ifdef CONFIG_TESTING_OPTIONS
304 if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only)
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800305 return eid;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800306#endif /* CONFIG_TESTING_OPTIONS */
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800307
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800308 if (!hapd->cs_freq_params.channel)
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800309 return eid;
310
311 *eid++ = WLAN_EID_CHANNEL_SWITCH;
312 *eid++ = 3;
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700313 *eid++ = hapd->cs_block_tx;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800314 *eid++ = hapd->cs_freq_params.channel;
Dmitry Shmidtd30ac602014-06-30 09:54:22 -0700315 *eid++ = hapd->cs_count;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800316
317 return eid;
318}
319
320
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800321static u8 * hostapd_eid_ecsa(struct hostapd_data *hapd, u8 *eid)
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800322{
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800323 if (!hapd->cs_freq_params.channel || !hapd->iface->cs_oper_class)
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800324 return eid;
325
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800326 *eid++ = WLAN_EID_EXT_CHANSWITCH_ANN;
327 *eid++ = 4;
328 *eid++ = hapd->cs_block_tx;
329 *eid++ = hapd->iface->cs_oper_class;
330 *eid++ = hapd->cs_freq_params.channel;
331 *eid++ = hapd->cs_count;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800332
333 return eid;
334}
335
336
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800337static u8 * hostapd_eid_supported_op_classes(struct hostapd_data *hapd, u8 *eid)
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800338{
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800339 u8 op_class, channel;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800340
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800341 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA) ||
342 !hapd->iface->freq)
343 return eid;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800344
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800345 if (ieee80211_freq_to_channel_ext(hapd->iface->freq,
346 hapd->iconf->secondary_channel,
347 hapd->iconf->vht_oper_chwidth,
348 &op_class, &channel) ==
349 NUM_HOSTAPD_MODES)
350 return eid;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800351
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800352 *eid++ = WLAN_EID_SUPPORTED_OPERATING_CLASSES;
353 *eid++ = 2;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800354
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800355 /* Current Operating Class */
356 *eid++ = op_class;
357
358 /* TODO: Advertise all the supported operating classes */
359 *eid++ = 0;
360
361 return eid;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800362}
363
364
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800365static u8 * hostapd_gen_probe_resp(struct hostapd_data *hapd,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800366 const struct ieee80211_mgmt *req,
367 int is_p2p, size_t *resp_len)
368{
369 struct ieee80211_mgmt *resp;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800370 u8 *pos, *epos, *csa_pos;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800371 size_t buflen;
372
373#define MAX_PROBERESP_LEN 768
374 buflen = MAX_PROBERESP_LEN;
375#ifdef CONFIG_WPS
376 if (hapd->wps_probe_resp_ie)
377 buflen += wpabuf_len(hapd->wps_probe_resp_ie);
378#endif /* CONFIG_WPS */
379#ifdef CONFIG_P2P
380 if (hapd->p2p_probe_resp_ie)
381 buflen += wpabuf_len(hapd->p2p_probe_resp_ie);
382#endif /* CONFIG_P2P */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800383#ifdef CONFIG_FST
384 if (hapd->iface->fst_ies)
385 buflen += wpabuf_len(hapd->iface->fst_ies);
386#endif /* CONFIG_FST */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700387 if (hapd->conf->vendor_elements)
388 buflen += wpabuf_len(hapd->conf->vendor_elements);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800389 if (hapd->conf->vendor_vht) {
390 buflen += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) +
391 2 + sizeof(struct ieee80211_vht_operation);
392 }
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800393
394 buflen += hostapd_mbo_ie_len(hapd);
395
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800396 resp = os_zalloc(buflen);
397 if (resp == NULL)
398 return NULL;
399
400 epos = ((u8 *) resp) + MAX_PROBERESP_LEN;
401
402 resp->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
403 WLAN_FC_STYPE_PROBE_RESP);
404 if (req)
405 os_memcpy(resp->da, req->sa, ETH_ALEN);
406 os_memcpy(resp->sa, hapd->own_addr, ETH_ALEN);
407
408 os_memcpy(resp->bssid, hapd->own_addr, ETH_ALEN);
409 resp->u.probe_resp.beacon_int =
410 host_to_le16(hapd->iconf->beacon_int);
411
412 /* hardware or low-level driver will setup seq_ctrl and timestamp */
413 resp->u.probe_resp.capab_info =
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700414 host_to_le16(hostapd_own_capab_info(hapd));
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800415
416 pos = resp->u.probe_resp.variable;
417 *pos++ = WLAN_EID_SSID;
418 *pos++ = hapd->conf->ssid.ssid_len;
419 os_memcpy(pos, hapd->conf->ssid.ssid, hapd->conf->ssid.ssid_len);
420 pos += hapd->conf->ssid.ssid_len;
421
422 /* Supported rates */
423 pos = hostapd_eid_supp_rates(hapd, pos);
424
425 /* DS Params */
426 pos = hostapd_eid_ds_params(hapd, pos);
427
428 pos = hostapd_eid_country(hapd, pos, epos - pos);
429
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800430 /* Power Constraint element */
431 pos = hostapd_eid_pwr_constraint(hapd, pos);
432
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800433 /* CSA IE */
434 csa_pos = hostapd_eid_csa(hapd, pos);
435 if (csa_pos != pos)
436 hapd->cs_c_off_proberesp = csa_pos - (u8 *) resp - 1;
437 pos = csa_pos;
438
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800439 /* ERP Information element */
440 pos = hostapd_eid_erp_info(hapd, pos);
441
442 /* Extended supported rates */
443 pos = hostapd_eid_ext_supp_rates(hapd, pos);
444
445 /* RSN, MDIE, WPA */
446 pos = hostapd_eid_wpa(hapd, pos, epos - pos);
447
Dmitry Shmidt051af732013-10-22 13:52:46 -0700448 pos = hostapd_eid_bss_load(hapd, pos, epos - pos);
449
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800450 pos = hostapd_eid_rm_enabled_capab(hapd, pos, epos - pos);
451
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800452 /* eCSA IE */
453 csa_pos = hostapd_eid_ecsa(hapd, pos);
454 if (csa_pos != pos)
455 hapd->cs_c_off_ecsa_proberesp = csa_pos - (u8 *) resp - 1;
456 pos = csa_pos;
457
458 pos = hostapd_eid_supported_op_classes(hapd, pos);
459
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800460#ifdef CONFIG_IEEE80211N
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800461 /* Secondary Channel Offset element */
462 /* TODO: The standard doesn't specify a position for this element. */
463 pos = hostapd_eid_secondary_channel(hapd, pos);
464
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800465 pos = hostapd_eid_ht_capabilities(hapd, pos);
466 pos = hostapd_eid_ht_operation(hapd, pos);
467#endif /* CONFIG_IEEE80211N */
468
469 pos = hostapd_eid_ext_capab(hapd, pos);
470
471 pos = hostapd_eid_time_adv(hapd, pos);
472 pos = hostapd_eid_time_zone(hapd, pos);
473
474 pos = hostapd_eid_interworking(hapd, pos);
475 pos = hostapd_eid_adv_proto(hapd, pos);
476 pos = hostapd_eid_roaming_consortium(hapd, pos);
477
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800478#ifdef CONFIG_FST
479 if (hapd->iface->fst_ies) {
480 os_memcpy(pos, wpabuf_head(hapd->iface->fst_ies),
481 wpabuf_len(hapd->iface->fst_ies));
482 pos += wpabuf_len(hapd->iface->fst_ies);
483 }
484#endif /* CONFIG_FST */
485
Dmitry Shmidt04949592012-07-19 12:16:46 -0700486#ifdef CONFIG_IEEE80211AC
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800487 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
Dmitry Shmidt7d175302016-09-06 13:11:34 -0700488 pos = hostapd_eid_vht_capabilities(hapd, pos, 0);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800489 pos = hostapd_eid_vht_operation(hapd, pos);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -0800490 pos = hostapd_eid_txpower_envelope(hapd, pos);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800491 pos = hostapd_eid_wb_chsw_wrapper(hapd, pos);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800492 }
493 if (hapd->conf->vendor_vht)
494 pos = hostapd_eid_vendor_vht(hapd, pos);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700495#endif /* CONFIG_IEEE80211AC */
496
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800497 /* Wi-Fi Alliance WMM */
498 pos = hostapd_eid_wmm(hapd, pos);
499
500#ifdef CONFIG_WPS
501 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
502 os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
503 wpabuf_len(hapd->wps_probe_resp_ie));
504 pos += wpabuf_len(hapd->wps_probe_resp_ie);
505 }
506#endif /* CONFIG_WPS */
507
508#ifdef CONFIG_P2P
509 if ((hapd->conf->p2p & P2P_ENABLED) && is_p2p &&
510 hapd->p2p_probe_resp_ie) {
511 os_memcpy(pos, wpabuf_head(hapd->p2p_probe_resp_ie),
512 wpabuf_len(hapd->p2p_probe_resp_ie));
513 pos += wpabuf_len(hapd->p2p_probe_resp_ie);
514 }
515#endif /* CONFIG_P2P */
516#ifdef CONFIG_P2P_MANAGER
517 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
518 P2P_MANAGE)
519 pos = hostapd_eid_p2p_manage(hapd, pos);
520#endif /* CONFIG_P2P_MANAGER */
521
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700522#ifdef CONFIG_HS20
523 pos = hostapd_eid_hs20_indication(hapd, pos);
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800524 pos = hostapd_eid_osen(hapd, pos);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700525#endif /* CONFIG_HS20 */
526
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800527 pos = hostapd_eid_mbo(hapd, pos, (u8 *) resp + buflen - pos);
528
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700529 if (hapd->conf->vendor_elements) {
530 os_memcpy(pos, wpabuf_head(hapd->conf->vendor_elements),
531 wpabuf_len(hapd->conf->vendor_elements));
532 pos += wpabuf_len(hapd->conf->vendor_elements);
533 }
534
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800535 *resp_len = pos - (u8 *) resp;
536 return (u8 *) resp;
537}
538
539
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800540enum ssid_match_result {
541 NO_SSID_MATCH,
542 EXACT_SSID_MATCH,
543 WILDCARD_SSID_MATCH
544};
545
546static enum ssid_match_result ssid_match(struct hostapd_data *hapd,
547 const u8 *ssid, size_t ssid_len,
548 const u8 *ssid_list,
549 size_t ssid_list_len)
550{
551 const u8 *pos, *end;
552 int wildcard = 0;
553
554 if (ssid_len == 0)
555 wildcard = 1;
556 if (ssid_len == hapd->conf->ssid.ssid_len &&
557 os_memcmp(ssid, hapd->conf->ssid.ssid, ssid_len) == 0)
558 return EXACT_SSID_MATCH;
559
560 if (ssid_list == NULL)
561 return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH;
562
563 pos = ssid_list;
564 end = ssid_list + ssid_list_len;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800565 while (end - pos >= 1) {
566 if (2 + pos[1] > end - pos)
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800567 break;
568 if (pos[1] == 0)
569 wildcard = 1;
570 if (pos[1] == hapd->conf->ssid.ssid_len &&
571 os_memcmp(pos + 2, hapd->conf->ssid.ssid, pos[1]) == 0)
572 return EXACT_SSID_MATCH;
573 pos += 2 + pos[1];
574 }
575
576 return wildcard ? WILDCARD_SSID_MATCH : NO_SSID_MATCH;
577}
578
579
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800580void sta_track_expire(struct hostapd_iface *iface, int force)
581{
582 struct os_reltime now;
583 struct hostapd_sta_info *info;
584
585 if (!iface->num_sta_seen)
586 return;
587
588 os_get_reltime(&now);
589 while ((info = dl_list_first(&iface->sta_seen, struct hostapd_sta_info,
590 list))) {
591 if (!force &&
592 !os_reltime_expired(&now, &info->last_seen,
593 iface->conf->track_sta_max_age))
594 break;
595 force = 0;
596
597 wpa_printf(MSG_MSGDUMP, "%s: Expire STA tracking entry for "
598 MACSTR, iface->bss[0]->conf->iface,
599 MAC2STR(info->addr));
600 dl_list_del(&info->list);
601 iface->num_sta_seen--;
602 os_free(info);
603 }
604}
605
606
607static struct hostapd_sta_info * sta_track_get(struct hostapd_iface *iface,
608 const u8 *addr)
609{
610 struct hostapd_sta_info *info;
611
612 dl_list_for_each(info, &iface->sta_seen, struct hostapd_sta_info, list)
613 if (os_memcmp(addr, info->addr, ETH_ALEN) == 0)
614 return info;
615
616 return NULL;
617}
618
619
620void sta_track_add(struct hostapd_iface *iface, const u8 *addr)
621{
622 struct hostapd_sta_info *info;
623
624 info = sta_track_get(iface, addr);
625 if (info) {
626 /* Move the most recent entry to the end of the list */
627 dl_list_del(&info->list);
628 dl_list_add_tail(&iface->sta_seen, &info->list);
629 os_get_reltime(&info->last_seen);
630 return;
631 }
632
633 /* Add a new entry */
634 info = os_zalloc(sizeof(*info));
635 os_memcpy(info->addr, addr, ETH_ALEN);
636 os_get_reltime(&info->last_seen);
637
638 if (iface->num_sta_seen >= iface->conf->track_sta_max_num) {
639 /* Expire oldest entry to make room for a new one */
640 sta_track_expire(iface, 1);
641 }
642
643 wpa_printf(MSG_MSGDUMP, "%s: Add STA tracking entry for "
644 MACSTR, iface->bss[0]->conf->iface, MAC2STR(addr));
645 dl_list_add_tail(&iface->sta_seen, &info->list);
646 iface->num_sta_seen++;
647}
648
649
650struct hostapd_data *
651sta_track_seen_on(struct hostapd_iface *iface, const u8 *addr,
652 const char *ifname)
653{
654 struct hapd_interfaces *interfaces = iface->interfaces;
655 size_t i, j;
656
657 for (i = 0; i < interfaces->count; i++) {
658 struct hostapd_data *hapd = NULL;
659
660 iface = interfaces->iface[i];
661 for (j = 0; j < iface->num_bss; j++) {
662 hapd = iface->bss[j];
663 if (os_strcmp(ifname, hapd->conf->iface) == 0)
664 break;
665 hapd = NULL;
666 }
667
668 if (hapd && sta_track_get(iface, addr))
669 return hapd;
670 }
671
672 return NULL;
673}
674
675
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700676void handle_probe_req(struct hostapd_data *hapd,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700677 const struct ieee80211_mgmt *mgmt, size_t len,
678 int ssi_signal)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700679{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800680 u8 *resp;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700681 struct ieee802_11_elems elems;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700682 const u8 *ie;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800683 size_t ie_len;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800684 size_t i, resp_len;
685 int noack;
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800686 enum ssid_match_result res;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800687 int ret;
688 u16 csa_offs[2];
689 size_t csa_offs_len;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700690
Dmitry Shmidte4663042016-04-04 10:07:49 -0700691 if (len < IEEE80211_HDRLEN)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700692 return;
Dmitry Shmidte4663042016-04-04 10:07:49 -0700693 ie = ((const u8 *) mgmt) + IEEE80211_HDRLEN;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800694 if (hapd->iconf->track_sta_max_num)
695 sta_track_add(hapd->iface, mgmt->sa);
Dmitry Shmidte4663042016-04-04 10:07:49 -0700696 ie_len = len - IEEE80211_HDRLEN;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700697
698 for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
699 if (hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800700 mgmt->sa, mgmt->da, mgmt->bssid,
Dmitry Shmidt04949592012-07-19 12:16:46 -0700701 ie, ie_len, ssi_signal) > 0)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700702 return;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800703
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700704 if (!hapd->iconf->send_probe_response)
705 return;
706
707 if (ieee802_11_parse_elems(ie, ie_len, &elems, 0) == ParseFailed) {
708 wpa_printf(MSG_DEBUG, "Could not parse ProbeReq from " MACSTR,
709 MAC2STR(mgmt->sa));
710 return;
711 }
712
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700713 if ((!elems.ssid || !elems.supp_rates)) {
714 wpa_printf(MSG_DEBUG, "STA " MACSTR " sent probe request "
715 "without SSID or supported rates element",
716 MAC2STR(mgmt->sa));
717 return;
718 }
719
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800720 /*
721 * No need to reply if the Probe Request frame was sent on an adjacent
722 * channel. IEEE Std 802.11-2012 describes this as a requirement for an
723 * AP with dot11RadioMeasurementActivated set to true, but strictly
724 * speaking does not allow such ignoring of Probe Request frames if
725 * dot11RadioMeasurementActivated is false. Anyway, this can help reduce
726 * number of unnecessary Probe Response frames for cases where the STA
727 * is less likely to see them (Probe Request frame sent on a
728 * neighboring, but partially overlapping, channel).
729 */
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700730 if (elems.ds_params &&
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800731 hapd->iface->current_mode &&
732 (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G ||
733 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211B) &&
734 hapd->iconf->channel != elems.ds_params[0]) {
735 wpa_printf(MSG_DEBUG,
736 "Ignore Probe Request due to DS Params mismatch: chan=%u != ds.chan=%u",
737 hapd->iconf->channel, elems.ds_params[0]);
738 return;
739 }
740
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700741#ifdef CONFIG_P2P
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800742 if (hapd->p2p && hapd->p2p_group && elems.wps_ie) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700743 struct wpabuf *wps;
744 wps = ieee802_11_vendor_ie_concat(ie, ie_len, WPS_DEV_OUI_WFA);
745 if (wps && !p2p_group_match_dev_type(hapd->p2p_group, wps)) {
746 wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
747 "due to mismatch with Requested Device "
748 "Type");
749 wpabuf_free(wps);
750 return;
751 }
752 wpabuf_free(wps);
753 }
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800754
Dmitry Shmidtde47be72016-01-07 12:52:55 -0800755 if (hapd->p2p && hapd->p2p_group && elems.p2p) {
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -0800756 struct wpabuf *p2p;
757 p2p = ieee802_11_vendor_ie_concat(ie, ie_len, P2P_IE_VENDOR_TYPE);
758 if (p2p && !p2p_group_match_dev_id(hapd->p2p_group, p2p)) {
759 wpa_printf(MSG_MSGDUMP, "P2P: Ignore Probe Request "
760 "due to mismatch with Device ID");
761 wpabuf_free(p2p);
762 return;
763 }
764 wpabuf_free(p2p);
765 }
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700766#endif /* CONFIG_P2P */
767
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800768 if (hapd->conf->ignore_broadcast_ssid && elems.ssid_len == 0 &&
769 elems.ssid_list_len == 0) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700770 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR " for "
771 "broadcast SSID ignored", MAC2STR(mgmt->sa));
772 return;
773 }
774
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700775#ifdef CONFIG_P2P
776 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
777 elems.ssid_len == P2P_WILDCARD_SSID_LEN &&
778 os_memcmp(elems.ssid, P2P_WILDCARD_SSID,
779 P2P_WILDCARD_SSID_LEN) == 0) {
780 /* Process P2P Wildcard SSID like Wildcard SSID */
781 elems.ssid_len = 0;
782 }
783#endif /* CONFIG_P2P */
784
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800785 res = ssid_match(hapd, elems.ssid, elems.ssid_len,
786 elems.ssid_list, elems.ssid_list_len);
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700787 if (res == NO_SSID_MATCH) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700788 if (!(mgmt->da[0] & 0x01)) {
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700789 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800790 " for foreign SSID '%s' (DA " MACSTR ")%s",
Dmitry Shmidt3c479372014-02-04 10:50:36 -0800791 MAC2STR(mgmt->sa),
792 wpa_ssid_txt(elems.ssid, elems.ssid_len),
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800793 MAC2STR(mgmt->da),
794 elems.ssid_list ? " (SSID list)" : "");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700795 }
796 return;
797 }
798
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800799#ifdef CONFIG_INTERWORKING
Dmitry Shmidtf9bdef92014-04-25 10:46:36 -0700800 if (hapd->conf->interworking &&
801 elems.interworking && elems.interworking_len >= 1) {
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800802 u8 ant = elems.interworking[0] & 0x0f;
803 if (ant != INTERWORKING_ANT_WILDCARD &&
804 ant != hapd->conf->access_network_type) {
805 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
806 " for mismatching ANT %u ignored",
807 MAC2STR(mgmt->sa), ant);
808 return;
809 }
810 }
811
Dmitry Shmidtf9bdef92014-04-25 10:46:36 -0700812 if (hapd->conf->interworking && elems.interworking &&
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800813 (elems.interworking_len == 7 || elems.interworking_len == 9)) {
814 const u8 *hessid;
815 if (elems.interworking_len == 7)
816 hessid = elems.interworking + 1;
817 else
818 hessid = elems.interworking + 1 + 2;
819 if (!is_broadcast_ether_addr(hessid) &&
820 os_memcmp(hessid, hapd->conf->hessid, ETH_ALEN) != 0) {
821 wpa_printf(MSG_MSGDUMP, "Probe Request from " MACSTR
822 " for mismatching HESSID " MACSTR
823 " ignored",
824 MAC2STR(mgmt->sa), MAC2STR(hessid));
825 return;
826 }
827 }
828#endif /* CONFIG_INTERWORKING */
829
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700830#ifdef CONFIG_P2P
831 if ((hapd->conf->p2p & P2P_GROUP_OWNER) &&
832 supp_rates_11b_only(&elems)) {
833 /* Indicates support for 11b rates only */
834 wpa_printf(MSG_EXCESSIVE, "P2P: Ignore Probe Request from "
835 MACSTR " with only 802.11b rates",
836 MAC2STR(mgmt->sa));
837 return;
838 }
839#endif /* CONFIG_P2P */
840
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700841 /* TODO: verify that supp_rates contains at least one matching rate
842 * with AP configuration */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800843
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800844 if (hapd->conf->no_probe_resp_if_seen_on &&
845 is_multicast_ether_addr(mgmt->da) &&
846 is_multicast_ether_addr(mgmt->bssid) &&
847 sta_track_seen_on(hapd->iface, mgmt->sa,
848 hapd->conf->no_probe_resp_if_seen_on)) {
849 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
850 " since STA has been seen on %s",
851 hapd->conf->iface, MAC2STR(mgmt->sa),
852 hapd->conf->no_probe_resp_if_seen_on);
853 return;
854 }
855
856 if (hapd->conf->no_probe_resp_if_max_sta &&
857 is_multicast_ether_addr(mgmt->da) &&
858 is_multicast_ether_addr(mgmt->bssid) &&
859 hapd->num_sta >= hapd->conf->max_num_sta &&
860 !ap_get_sta(hapd, mgmt->sa)) {
861 wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
862 " since no room for additional STA",
863 hapd->conf->iface, MAC2STR(mgmt->sa));
864 return;
865 }
866
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700867#ifdef CONFIG_TESTING_OPTIONS
Dmitry Shmidt7832adb2014-04-29 10:53:02 -0700868 if (hapd->iconf->ignore_probe_probability > 0.0 &&
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700869 drand48() < hapd->iconf->ignore_probe_probability) {
870 wpa_printf(MSG_INFO,
871 "TESTING: ignoring probe request from " MACSTR,
872 MAC2STR(mgmt->sa));
873 return;
874 }
875#endif /* CONFIG_TESTING_OPTIONS */
876
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700877 resp = hostapd_gen_probe_resp(hapd, mgmt, elems.p2p != NULL,
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800878 &resp_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700879 if (resp == NULL)
880 return;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700881
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800882 /*
883 * If this is a broadcast probe request, apply no ack policy to avoid
884 * excessive retries.
885 */
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800886 noack = !!(res == WILDCARD_SSID_MATCH &&
887 is_broadcast_ether_addr(mgmt->da));
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700888
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800889 csa_offs_len = 0;
890 if (hapd->csa_in_progress) {
891 if (hapd->cs_c_off_proberesp)
892 csa_offs[csa_offs_len++] =
893 hapd->cs_c_off_proberesp;
894
895 if (hapd->cs_c_off_ecsa_proberesp)
896 csa_offs[csa_offs_len++] =
897 hapd->cs_c_off_ecsa_proberesp;
898 }
899
900 ret = hostapd_drv_send_mlme_csa(hapd, resp, resp_len, noack,
901 csa_offs_len ? csa_offs : NULL,
902 csa_offs_len);
903
904 if (ret < 0)
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800905 wpa_printf(MSG_INFO, "handle_probe_req: send failed");
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700906
907 os_free(resp);
908
909 wpa_printf(MSG_EXCESSIVE, "STA " MACSTR " sent probe request for %s "
910 "SSID", MAC2STR(mgmt->sa),
911 elems.ssid_len == 0 ? "broadcast" : "our");
912}
913
914
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800915static u8 * hostapd_probe_resp_offloads(struct hostapd_data *hapd,
916 size_t *resp_len)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700917{
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800918 /* check probe response offloading caps and print warnings */
919 if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_PROBE_RESP_OFFLOAD))
920 return NULL;
921
922#ifdef CONFIG_WPS
923 if (hapd->conf->wps_state && hapd->wps_probe_resp_ie &&
924 (!(hapd->iface->probe_resp_offloads &
925 (WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS |
926 WPA_DRIVER_PROBE_RESP_OFFLOAD_WPS2))))
927 wpa_printf(MSG_WARNING, "Device is trying to offload WPS "
928 "Probe Response while not supporting this");
929#endif /* CONFIG_WPS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700930
931#ifdef CONFIG_P2P
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800932 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_probe_resp_ie &&
933 !(hapd->iface->probe_resp_offloads &
934 WPA_DRIVER_PROBE_RESP_OFFLOAD_P2P))
935 wpa_printf(MSG_WARNING, "Device is trying to offload P2P "
936 "Probe Response while not supporting this");
937#endif /* CONFIG_P2P */
938
939 if (hapd->conf->interworking &&
940 !(hapd->iface->probe_resp_offloads &
941 WPA_DRIVER_PROBE_RESP_OFFLOAD_INTERWORKING))
942 wpa_printf(MSG_WARNING, "Device is trying to offload "
943 "Interworking Probe Response while not supporting "
944 "this");
945
946 /* Generate a Probe Response template for the non-P2P case */
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -0700947 return hostapd_gen_probe_resp(hapd, NULL, 0, resp_len);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800948}
949
950#endif /* NEED_AP_MLME */
951
952
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800953int ieee802_11_build_ap_params(struct hostapd_data *hapd,
954 struct wpa_driver_ap_params *params)
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800955{
956 struct ieee80211_mgmt *head = NULL;
957 u8 *tail = NULL;
958 size_t head_len = 0, tail_len = 0;
959 u8 *resp = NULL;
960 size_t resp_len = 0;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800961#ifdef NEED_AP_MLME
962 u16 capab_info;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800963 u8 *pos, *tailpos, *csa_pos;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700964
965#define BEACON_HEAD_BUF_SIZE 256
966#define BEACON_TAIL_BUF_SIZE 512
967 head = os_zalloc(BEACON_HEAD_BUF_SIZE);
968 tail_len = BEACON_TAIL_BUF_SIZE;
969#ifdef CONFIG_WPS
970 if (hapd->conf->wps_state && hapd->wps_beacon_ie)
971 tail_len += wpabuf_len(hapd->wps_beacon_ie);
972#endif /* CONFIG_WPS */
973#ifdef CONFIG_P2P
974 if (hapd->p2p_beacon_ie)
975 tail_len += wpabuf_len(hapd->p2p_beacon_ie);
976#endif /* CONFIG_P2P */
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800977#ifdef CONFIG_FST
978 if (hapd->iface->fst_ies)
979 tail_len += wpabuf_len(hapd->iface->fst_ies);
980#endif /* CONFIG_FST */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700981 if (hapd->conf->vendor_elements)
982 tail_len += wpabuf_len(hapd->conf->vendor_elements);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -0800983
984#ifdef CONFIG_IEEE80211AC
985 if (hapd->conf->vendor_vht) {
986 tail_len += 5 + 2 + sizeof(struct ieee80211_vht_capabilities) +
987 2 + sizeof(struct ieee80211_vht_operation);
988 }
989#endif /* CONFIG_IEEE80211AC */
990
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800991 tail_len += hostapd_mbo_ie_len(hapd);
992
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700993 tailpos = tail = os_malloc(tail_len);
994 if (head == NULL || tail == NULL) {
995 wpa_printf(MSG_ERROR, "Failed to set beacon data");
996 os_free(head);
997 os_free(tail);
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -0800998 return -1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700999 }
1000
1001 head->frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
1002 WLAN_FC_STYPE_BEACON);
1003 head->duration = host_to_le16(0);
1004 os_memset(head->da, 0xff, ETH_ALEN);
1005
1006 os_memcpy(head->sa, hapd->own_addr, ETH_ALEN);
1007 os_memcpy(head->bssid, hapd->own_addr, ETH_ALEN);
1008 head->u.beacon.beacon_int =
1009 host_to_le16(hapd->iconf->beacon_int);
1010
1011 /* hardware or low-level driver will setup seq_ctrl and timestamp */
Dmitry Shmidt9d9e6022015-04-23 10:34:55 -07001012 capab_info = hostapd_own_capab_info(hapd);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001013 head->u.beacon.capab_info = host_to_le16(capab_info);
1014 pos = &head->u.beacon.variable[0];
1015
1016 /* SSID */
1017 *pos++ = WLAN_EID_SSID;
1018 if (hapd->conf->ignore_broadcast_ssid == 2) {
1019 /* clear the data, but keep the correct length of the SSID */
1020 *pos++ = hapd->conf->ssid.ssid_len;
1021 os_memset(pos, 0, hapd->conf->ssid.ssid_len);
1022 pos += hapd->conf->ssid.ssid_len;
1023 } else if (hapd->conf->ignore_broadcast_ssid) {
1024 *pos++ = 0; /* empty SSID */
1025 } else {
1026 *pos++ = hapd->conf->ssid.ssid_len;
1027 os_memcpy(pos, hapd->conf->ssid.ssid,
1028 hapd->conf->ssid.ssid_len);
1029 pos += hapd->conf->ssid.ssid_len;
1030 }
1031
1032 /* Supported rates */
1033 pos = hostapd_eid_supp_rates(hapd, pos);
1034
1035 /* DS Params */
1036 pos = hostapd_eid_ds_params(hapd, pos);
1037
1038 head_len = pos - (u8 *) head;
1039
1040 tailpos = hostapd_eid_country(hapd, tailpos,
1041 tail + BEACON_TAIL_BUF_SIZE - tailpos);
1042
Dmitry Shmidtf21452a2014-02-26 10:55:25 -08001043 /* Power Constraint element */
1044 tailpos = hostapd_eid_pwr_constraint(hapd, tailpos);
1045
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001046 /* CSA IE */
1047 csa_pos = hostapd_eid_csa(hapd, tailpos);
1048 if (csa_pos != tailpos)
1049 hapd->cs_c_off_beacon = csa_pos - tail - 1;
1050 tailpos = csa_pos;
1051
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001052 /* ERP Information element */
1053 tailpos = hostapd_eid_erp_info(hapd, tailpos);
1054
1055 /* Extended supported rates */
1056 tailpos = hostapd_eid_ext_supp_rates(hapd, tailpos);
1057
1058 /* RSN, MDIE, WPA */
1059 tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001060 tailpos);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001061
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001062 tailpos = hostapd_eid_rm_enabled_capab(hapd, tailpos,
1063 tail + BEACON_TAIL_BUF_SIZE -
1064 tailpos);
1065
Dmitry Shmidt051af732013-10-22 13:52:46 -07001066 tailpos = hostapd_eid_bss_load(hapd, tailpos,
1067 tail + BEACON_TAIL_BUF_SIZE - tailpos);
1068
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001069 /* eCSA IE */
1070 csa_pos = hostapd_eid_ecsa(hapd, tailpos);
1071 if (csa_pos != tailpos)
1072 hapd->cs_c_off_ecsa_beacon = csa_pos - tail - 1;
1073 tailpos = csa_pos;
1074
1075 tailpos = hostapd_eid_supported_op_classes(hapd, tailpos);
1076
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001077#ifdef CONFIG_IEEE80211N
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001078 /* Secondary Channel Offset element */
1079 /* TODO: The standard doesn't specify a position for this element. */
1080 tailpos = hostapd_eid_secondary_channel(hapd, tailpos);
1081
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001082 tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
1083 tailpos = hostapd_eid_ht_operation(hapd, tailpos);
1084#endif /* CONFIG_IEEE80211N */
1085
1086 tailpos = hostapd_eid_ext_capab(hapd, tailpos);
1087
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001088 /*
1089 * TODO: Time Advertisement element should only be included in some
1090 * DTIM Beacon frames.
1091 */
1092 tailpos = hostapd_eid_time_adv(hapd, tailpos);
1093
1094 tailpos = hostapd_eid_interworking(hapd, tailpos);
1095 tailpos = hostapd_eid_adv_proto(hapd, tailpos);
1096 tailpos = hostapd_eid_roaming_consortium(hapd, tailpos);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001097
1098#ifdef CONFIG_FST
1099 if (hapd->iface->fst_ies) {
1100 os_memcpy(tailpos, wpabuf_head(hapd->iface->fst_ies),
1101 wpabuf_len(hapd->iface->fst_ies));
1102 tailpos += wpabuf_len(hapd->iface->fst_ies);
1103 }
1104#endif /* CONFIG_FST */
1105
Dmitry Shmidt04949592012-07-19 12:16:46 -07001106#ifdef CONFIG_IEEE80211AC
Dmitry Shmidt2f74e362015-01-21 13:19:05 -08001107 if (hapd->iconf->ieee80211ac && !hapd->conf->disable_11ac) {
Dmitry Shmidt7d175302016-09-06 13:11:34 -07001108 tailpos = hostapd_eid_vht_capabilities(hapd, tailpos, 0);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -08001109 tailpos = hostapd_eid_vht_operation(hapd, tailpos);
Dmitry Shmidtd7ff03d2015-12-04 14:49:35 -08001110 tailpos = hostapd_eid_txpower_envelope(hapd, tailpos);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001111 tailpos = hostapd_eid_wb_chsw_wrapper(hapd, tailpos);
Dmitry Shmidt2f74e362015-01-21 13:19:05 -08001112 }
1113 if (hapd->conf->vendor_vht)
1114 tailpos = hostapd_eid_vendor_vht(hapd, tailpos);
Dmitry Shmidt04949592012-07-19 12:16:46 -07001115#endif /* CONFIG_IEEE80211AC */
1116
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001117 /* Wi-Fi Alliance WMM */
1118 tailpos = hostapd_eid_wmm(hapd, tailpos);
1119
1120#ifdef CONFIG_WPS
1121 if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
1122 os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
1123 wpabuf_len(hapd->wps_beacon_ie));
1124 tailpos += wpabuf_len(hapd->wps_beacon_ie);
1125 }
1126#endif /* CONFIG_WPS */
1127
1128#ifdef CONFIG_P2P
1129 if ((hapd->conf->p2p & P2P_ENABLED) && hapd->p2p_beacon_ie) {
1130 os_memcpy(tailpos, wpabuf_head(hapd->p2p_beacon_ie),
1131 wpabuf_len(hapd->p2p_beacon_ie));
1132 tailpos += wpabuf_len(hapd->p2p_beacon_ie);
1133 }
1134#endif /* CONFIG_P2P */
1135#ifdef CONFIG_P2P_MANAGER
1136 if ((hapd->conf->p2p & (P2P_MANAGE | P2P_ENABLED | P2P_GROUP_OWNER)) ==
1137 P2P_MANAGE)
1138 tailpos = hostapd_eid_p2p_manage(hapd, tailpos);
1139#endif /* CONFIG_P2P_MANAGER */
1140
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001141#ifdef CONFIG_HS20
1142 tailpos = hostapd_eid_hs20_indication(hapd, tailpos);
Dmitry Shmidtf21452a2014-02-26 10:55:25 -08001143 tailpos = hostapd_eid_osen(hapd, tailpos);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001144#endif /* CONFIG_HS20 */
1145
Dmitry Shmidt57c2d392016-02-23 13:40:19 -08001146 tailpos = hostapd_eid_mbo(hapd, tailpos, tail + tail_len - tailpos);
1147
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001148 if (hapd->conf->vendor_elements) {
1149 os_memcpy(tailpos, wpabuf_head(hapd->conf->vendor_elements),
1150 wpabuf_len(hapd->conf->vendor_elements));
1151 tailpos += wpabuf_len(hapd->conf->vendor_elements);
1152 }
1153
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001154 tail_len = tailpos > tail ? tailpos - tail : 0;
1155
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001156 resp = hostapd_probe_resp_offloads(hapd, &resp_len);
1157#endif /* NEED_AP_MLME */
1158
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001159 os_memset(params, 0, sizeof(*params));
1160 params->head = (u8 *) head;
1161 params->head_len = head_len;
1162 params->tail = tail;
1163 params->tail_len = tail_len;
1164 params->proberesp = resp;
1165 params->proberesp_len = resp_len;
1166 params->dtim_period = hapd->conf->dtim_period;
1167 params->beacon_int = hapd->iconf->beacon_int;
1168 params->basic_rates = hapd->iface->basic_rates;
1169 params->ssid = hapd->conf->ssid.ssid;
1170 params->ssid_len = hapd->conf->ssid.ssid_len;
Dmitry Shmidt7a53dbb2015-06-11 13:13:53 -07001171 if ((hapd->conf->wpa & (WPA_PROTO_WPA | WPA_PROTO_RSN)) ==
1172 (WPA_PROTO_WPA | WPA_PROTO_RSN))
1173 params->pairwise_ciphers = hapd->conf->wpa_pairwise |
1174 hapd->conf->rsn_pairwise;
1175 else if (hapd->conf->wpa & WPA_PROTO_RSN)
1176 params->pairwise_ciphers = hapd->conf->rsn_pairwise;
1177 else if (hapd->conf->wpa & WPA_PROTO_WPA)
1178 params->pairwise_ciphers = hapd->conf->wpa_pairwise;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001179 params->group_cipher = hapd->conf->wpa_group;
1180 params->key_mgmt_suites = hapd->conf->wpa_key_mgmt;
1181 params->auth_algs = hapd->conf->auth_algs;
1182 params->wpa_version = hapd->conf->wpa;
1183 params->privacy = hapd->conf->ssid.wep.keys_set || hapd->conf->wpa ||
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001184 (hapd->conf->ieee802_1x &&
1185 (hapd->conf->default_wep_key_len ||
1186 hapd->conf->individual_wep_key_len));
1187 switch (hapd->conf->ignore_broadcast_ssid) {
1188 case 0:
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001189 params->hide_ssid = NO_SSID_HIDING;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001190 break;
1191 case 1:
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001192 params->hide_ssid = HIDDEN_SSID_ZERO_LEN;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001193 break;
1194 case 2:
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001195 params->hide_ssid = HIDDEN_SSID_ZERO_CONTENTS;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001196 break;
1197 }
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001198 params->isolate = hapd->conf->isolate;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001199 params->smps_mode = hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_MASK;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001200#ifdef NEED_AP_MLME
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001201 params->cts_protect = !!(ieee802_11_erp_info(hapd) &
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001202 ERP_INFO_USE_PROTECTION);
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001203 params->preamble = hapd->iface->num_sta_no_short_preamble == 0 &&
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001204 hapd->iconf->preamble == SHORT_PREAMBLE;
1205 if (hapd->iface->current_mode &&
1206 hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G)
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001207 params->short_slot_time =
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001208 hapd->iface->num_sta_no_short_slot_time > 0 ? 0 : 1;
1209 else
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001210 params->short_slot_time = -1;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001211 if (!hapd->iconf->ieee80211n || hapd->conf->disable_11n)
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001212 params->ht_opmode = -1;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001213 else
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001214 params->ht_opmode = hapd->iface->ht_op_mode;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001215#endif /* NEED_AP_MLME */
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001216 params->interworking = hapd->conf->interworking;
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001217 if (hapd->conf->interworking &&
1218 !is_zero_ether_addr(hapd->conf->hessid))
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001219 params->hessid = hapd->conf->hessid;
1220 params->access_network_type = hapd->conf->access_network_type;
1221 params->ap_max_inactivity = hapd->conf->ap_max_inactivity;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001222#ifdef CONFIG_P2P
1223 params->p2p_go_ctwindow = hapd->iconf->p2p_go_ctwindow;
1224#endif /* CONFIG_P2P */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001225#ifdef CONFIG_HS20
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001226 params->disable_dgaf = hapd->conf->disable_dgaf;
Dmitry Shmidtf21452a2014-02-26 10:55:25 -08001227 if (hapd->conf->osen) {
1228 params->privacy = 1;
1229 params->osen = 1;
1230 }
Dmitry Shmidt61d9df32012-08-29 16:22:06 -07001231#endif /* CONFIG_HS20 */
Dmitry Shmidt57c2d392016-02-23 13:40:19 -08001232 params->pbss = hapd->conf->pbss;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001233 return 0;
1234}
1235
1236
1237void ieee802_11_free_ap_params(struct wpa_driver_ap_params *params)
1238{
1239 os_free(params->tail);
1240 params->tail = NULL;
1241 os_free(params->head);
1242 params->head = NULL;
1243 os_free(params->proberesp);
1244 params->proberesp = NULL;
1245}
1246
1247
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001248int ieee802_11_set_beacon(struct hostapd_data *hapd)
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001249{
1250 struct wpa_driver_ap_params params;
Dmitry Shmidt7832adb2014-04-29 10:53:02 -07001251 struct hostapd_freq_params freq;
1252 struct hostapd_iface *iface = hapd->iface;
1253 struct hostapd_config *iconf = iface->conf;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001254 struct wpabuf *beacon, *proberesp, *assocresp;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001255 int res, ret = -1;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001256
Dmitry Shmidtd30ac602014-06-30 09:54:22 -07001257 if (hapd->csa_in_progress) {
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001258 wpa_printf(MSG_ERROR, "Cannot set beacons during CSA period");
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001259 return -1;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001260 }
1261
1262 hapd->beacon_set_done = 1;
1263
1264 if (ieee802_11_build_ap_params(hapd, &params) < 0)
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001265 return -1;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001266
1267 if (hostapd_build_ap_extra_ies(hapd, &beacon, &proberesp, &assocresp) <
1268 0)
1269 goto fail;
1270
1271 params.beacon_ies = beacon;
1272 params.proberesp_ies = proberesp;
1273 params.assocresp_ies = assocresp;
Dmitry Shmidt7f656022015-02-25 14:36:37 -08001274 params.reenable = hapd->reenable_beacon;
1275 hapd->reenable_beacon = 0;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001276
Dmitry Shmidt7832adb2014-04-29 10:53:02 -07001277 if (iface->current_mode &&
1278 hostapd_set_freq_params(&freq, iconf->hw_mode, iface->freq,
1279 iconf->channel, iconf->ieee80211n,
1280 iconf->ieee80211ac,
1281 iconf->secondary_channel,
1282 iconf->vht_oper_chwidth,
1283 iconf->vht_oper_centr_freq_seg0_idx,
1284 iconf->vht_oper_centr_freq_seg1_idx,
1285 iface->current_mode->vht_capab) == 0)
1286 params.freq = &freq;
1287
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001288 res = hostapd_drv_set_ap(hapd, &params);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -08001289 hostapd_free_ap_extra_ies(hapd, beacon, proberesp, assocresp);
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001290 if (res)
1291 wpa_printf(MSG_ERROR, "Failed to set beacon parameters");
1292 else
1293 ret = 0;
Dmitry Shmidte0e48dc2013-11-18 12:00:06 -08001294fail:
1295 ieee802_11_free_ap_params(&params);
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001296 return ret;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001297}
1298
1299
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001300int ieee802_11_set_beacons(struct hostapd_iface *iface)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001301{
1302 size_t i;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001303 int ret = 0;
1304
Dmitry Shmidt292b0c32013-11-22 12:54:42 -08001305 for (i = 0; i < iface->num_bss; i++) {
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001306 if (iface->bss[i]->started &&
1307 ieee802_11_set_beacon(iface->bss[i]) < 0)
1308 ret = -1;
Dmitry Shmidt292b0c32013-11-22 12:54:42 -08001309 }
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001310
1311 return ret;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001312}
1313
Dmitry Shmidt04949592012-07-19 12:16:46 -07001314
1315/* only update beacons if started */
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001316int ieee802_11_update_beacons(struct hostapd_iface *iface)
Dmitry Shmidt04949592012-07-19 12:16:46 -07001317{
1318 size_t i;
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -08001319 int ret = 0;
1320
1321 for (i = 0; i < iface->num_bss; i++) {
1322 if (iface->bss[i]->beacon_set_done && iface->bss[i]->started &&
1323 ieee802_11_set_beacon(iface->bss[i]) < 0)
1324 ret = -1;
1325 }
1326
1327 return ret;
Dmitry Shmidt04949592012-07-19 12:16:46 -07001328}
1329
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001330#endif /* CONFIG_NATIVE_WINDOWS */