beacon.c 16 KB

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