ieee802_11_shared.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * hostapd / IEEE 802.11 Management
  3. * Copyright (c) 2002-2012, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "utils/includes.h"
  9. #include "utils/common.h"
  10. #include "common/ieee802_11_defs.h"
  11. #include "hostapd.h"
  12. #include "sta_info.h"
  13. #include "ap_config.h"
  14. #include "ap_drv_ops.h"
  15. #include "ieee802_11.h"
  16. #ifdef CONFIG_IEEE80211W
  17. u8 * hostapd_eid_assoc_comeback_time(struct hostapd_data *hapd,
  18. struct sta_info *sta, u8 *eid)
  19. {
  20. u8 *pos = eid;
  21. u32 timeout, tu;
  22. struct os_reltime now, passed;
  23. *pos++ = WLAN_EID_TIMEOUT_INTERVAL;
  24. *pos++ = 5;
  25. *pos++ = WLAN_TIMEOUT_ASSOC_COMEBACK;
  26. os_get_reltime(&now);
  27. os_reltime_sub(&now, &sta->sa_query_start, &passed);
  28. tu = (passed.sec * 1000000 + passed.usec) / 1024;
  29. if (hapd->conf->assoc_sa_query_max_timeout > tu)
  30. timeout = hapd->conf->assoc_sa_query_max_timeout - tu;
  31. else
  32. timeout = 0;
  33. if (timeout < hapd->conf->assoc_sa_query_max_timeout)
  34. timeout++; /* add some extra time for local timers */
  35. WPA_PUT_LE32(pos, timeout);
  36. pos += 4;
  37. return pos;
  38. }
  39. /* MLME-SAQuery.request */
  40. void ieee802_11_send_sa_query_req(struct hostapd_data *hapd,
  41. const u8 *addr, const u8 *trans_id)
  42. {
  43. struct ieee80211_mgmt mgmt;
  44. u8 *end;
  45. wpa_printf(MSG_DEBUG, "IEEE 802.11: Sending SA Query Request to "
  46. MACSTR, MAC2STR(addr));
  47. wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
  48. trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  49. os_memset(&mgmt, 0, sizeof(mgmt));
  50. mgmt.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
  51. WLAN_FC_STYPE_ACTION);
  52. os_memcpy(mgmt.da, addr, ETH_ALEN);
  53. os_memcpy(mgmt.sa, hapd->own_addr, ETH_ALEN);
  54. os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
  55. mgmt.u.action.category = WLAN_ACTION_SA_QUERY;
  56. mgmt.u.action.u.sa_query_req.action = WLAN_SA_QUERY_REQUEST;
  57. os_memcpy(mgmt.u.action.u.sa_query_req.trans_id, trans_id,
  58. WLAN_SA_QUERY_TR_ID_LEN);
  59. end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
  60. if (hostapd_drv_send_mlme(hapd, &mgmt, end - (u8 *) &mgmt, 0) < 0)
  61. wpa_printf(MSG_INFO, "ieee802_11_send_sa_query_req: send failed");
  62. }
  63. static void ieee802_11_send_sa_query_resp(struct hostapd_data *hapd,
  64. const u8 *sa, const u8 *trans_id)
  65. {
  66. struct sta_info *sta;
  67. struct ieee80211_mgmt resp;
  68. u8 *end;
  69. wpa_printf(MSG_DEBUG, "IEEE 802.11: Received SA Query Request from "
  70. MACSTR, MAC2STR(sa));
  71. wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
  72. trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  73. sta = ap_get_sta(hapd, sa);
  74. if (sta == NULL || !(sta->flags & WLAN_STA_ASSOC)) {
  75. wpa_printf(MSG_DEBUG, "IEEE 802.11: Ignore SA Query Request "
  76. "from unassociated STA " MACSTR, MAC2STR(sa));
  77. return;
  78. }
  79. wpa_printf(MSG_DEBUG, "IEEE 802.11: Sending SA Query Response to "
  80. MACSTR, MAC2STR(sa));
  81. os_memset(&resp, 0, sizeof(resp));
  82. resp.frame_control = IEEE80211_FC(WLAN_FC_TYPE_MGMT,
  83. WLAN_FC_STYPE_ACTION);
  84. os_memcpy(resp.da, sa, ETH_ALEN);
  85. os_memcpy(resp.sa, hapd->own_addr, ETH_ALEN);
  86. os_memcpy(resp.bssid, hapd->own_addr, ETH_ALEN);
  87. resp.u.action.category = WLAN_ACTION_SA_QUERY;
  88. resp.u.action.u.sa_query_req.action = WLAN_SA_QUERY_RESPONSE;
  89. os_memcpy(resp.u.action.u.sa_query_req.trans_id, trans_id,
  90. WLAN_SA_QUERY_TR_ID_LEN);
  91. end = resp.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
  92. if (hostapd_drv_send_mlme(hapd, &resp, end - (u8 *) &resp, 0) < 0)
  93. wpa_printf(MSG_INFO, "ieee80211_mgmt_sa_query_request: send failed");
  94. }
  95. void ieee802_11_sa_query_action(struct hostapd_data *hapd, const u8 *sa,
  96. const u8 action_type, const u8 *trans_id)
  97. {
  98. struct sta_info *sta;
  99. int i;
  100. if (action_type == WLAN_SA_QUERY_REQUEST) {
  101. ieee802_11_send_sa_query_resp(hapd, sa, trans_id);
  102. return;
  103. }
  104. if (action_type != WLAN_SA_QUERY_RESPONSE) {
  105. wpa_printf(MSG_DEBUG, "IEEE 802.11: Unexpected SA Query "
  106. "Action %d", action_type);
  107. return;
  108. }
  109. wpa_printf(MSG_DEBUG, "IEEE 802.11: Received SA Query Response from "
  110. MACSTR, MAC2STR(sa));
  111. wpa_hexdump(MSG_DEBUG, "IEEE 802.11: SA Query Transaction ID",
  112. trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  113. /* MLME-SAQuery.confirm */
  114. sta = ap_get_sta(hapd, sa);
  115. if (sta == NULL || sta->sa_query_trans_id == NULL) {
  116. wpa_printf(MSG_DEBUG, "IEEE 802.11: No matching STA with "
  117. "pending SA Query request found");
  118. return;
  119. }
  120. for (i = 0; i < sta->sa_query_count; i++) {
  121. if (os_memcmp(sta->sa_query_trans_id +
  122. i * WLAN_SA_QUERY_TR_ID_LEN,
  123. trans_id, WLAN_SA_QUERY_TR_ID_LEN) == 0)
  124. break;
  125. }
  126. if (i >= sta->sa_query_count) {
  127. wpa_printf(MSG_DEBUG, "IEEE 802.11: No matching SA Query "
  128. "transaction identifier found");
  129. return;
  130. }
  131. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  132. HOSTAPD_LEVEL_DEBUG,
  133. "Reply to pending SA Query received");
  134. ap_sta_stop_sa_query(hapd, sta);
  135. }
  136. #endif /* CONFIG_IEEE80211W */
  137. static void hostapd_ext_capab_byte(struct hostapd_data *hapd, u8 *pos, int idx)
  138. {
  139. *pos = 0x00;
  140. switch (idx) {
  141. case 0: /* Bits 0-7 */
  142. if (hapd->iconf->obss_interval)
  143. *pos |= 0x01; /* Bit 0 - Coexistence management */
  144. if (hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)
  145. *pos |= 0x04; /* Bit 2 - Extended Channel Switching */
  146. break;
  147. case 1: /* Bits 8-15 */
  148. if (hapd->conf->proxy_arp)
  149. *pos |= 0x10; /* Bit 12 - Proxy ARP */
  150. break;
  151. case 2: /* Bits 16-23 */
  152. if (hapd->conf->wnm_sleep_mode)
  153. *pos |= 0x02; /* Bit 17 - WNM-Sleep Mode */
  154. if (hapd->conf->bss_transition)
  155. *pos |= 0x08; /* Bit 19 - BSS Transition */
  156. break;
  157. case 3: /* Bits 24-31 */
  158. #ifdef CONFIG_WNM
  159. *pos |= 0x02; /* Bit 25 - SSID List */
  160. #endif /* CONFIG_WNM */
  161. if (hapd->conf->time_advertisement == 2)
  162. *pos |= 0x08; /* Bit 27 - UTC TSF Offset */
  163. if (hapd->conf->interworking)
  164. *pos |= 0x80; /* Bit 31 - Interworking */
  165. break;
  166. case 4: /* Bits 32-39 */
  167. if (hapd->conf->qos_map_set_len)
  168. *pos |= 0x01; /* Bit 32 - QoS Map */
  169. if (hapd->conf->tdls & TDLS_PROHIBIT)
  170. *pos |= 0x40; /* Bit 38 - TDLS Prohibited */
  171. if (hapd->conf->tdls & TDLS_PROHIBIT_CHAN_SWITCH) {
  172. /* Bit 39 - TDLS Channel Switching Prohibited */
  173. *pos |= 0x80;
  174. }
  175. break;
  176. case 5: /* Bits 40-47 */
  177. #ifdef CONFIG_HS20
  178. if (hapd->conf->hs20)
  179. *pos |= 0x40; /* Bit 46 - WNM-Notification */
  180. #endif /* CONFIG_HS20 */
  181. #ifdef CONFIG_MBO
  182. if (hapd->conf->mbo_enabled)
  183. *pos |= 0x40; /* Bit 46 - WNM-Notification */
  184. #endif /* CONFIG_MBO */
  185. break;
  186. case 6: /* Bits 48-55 */
  187. if (hapd->conf->ssid.utf8_ssid)
  188. *pos |= 0x01; /* Bit 48 - UTF-8 SSID */
  189. break;
  190. case 7: /* Bits 56-63 */
  191. break;
  192. case 8: /* Bits 64-71 */
  193. if (hapd->conf->ftm_responder)
  194. *pos |= 0x40; /* Bit 70 - FTM responder */
  195. if (hapd->conf->ftm_initiator)
  196. *pos |= 0x80; /* Bit 71 - FTM initiator */
  197. case 9: /* Bits 72-79 */
  198. #ifdef CONFIG_FILS
  199. if ((hapd->conf->wpa & WPA_PROTO_RSN) &&
  200. wpa_key_mgmt_fils(hapd->conf->wpa_key_mgmt))
  201. *pos |= 0x01;
  202. #endif /* CONFIG_FILS */
  203. break;
  204. }
  205. }
  206. u8 * hostapd_eid_ext_capab(struct hostapd_data *hapd, u8 *eid)
  207. {
  208. u8 *pos = eid;
  209. u8 len = 0, i;
  210. if (hapd->conf->tdls & (TDLS_PROHIBIT | TDLS_PROHIBIT_CHAN_SWITCH))
  211. len = 5;
  212. if (len < 4 && hapd->conf->interworking)
  213. len = 4;
  214. if (len < 3 && hapd->conf->wnm_sleep_mode)
  215. len = 3;
  216. if (len < 1 && hapd->iconf->obss_interval)
  217. len = 1;
  218. if (len < 7 && hapd->conf->ssid.utf8_ssid)
  219. len = 7;
  220. if (len < 9 &&
  221. (hapd->conf->ftm_initiator || hapd->conf->ftm_responder))
  222. len = 9;
  223. #ifdef CONFIG_WNM
  224. if (len < 4)
  225. len = 4;
  226. #endif /* CONFIG_WNM */
  227. #ifdef CONFIG_HS20
  228. if (hapd->conf->hs20 && len < 6)
  229. len = 6;
  230. #endif /* CONFIG_HS20 */
  231. #ifdef CONFIG_MBO
  232. if (hapd->conf->mbo_enabled && len < 6)
  233. len = 6;
  234. #endif /* CONFIG_MBO */
  235. #ifdef CONFIG_FILS
  236. if ((!(hapd->conf->wpa & WPA_PROTO_RSN) ||
  237. !wpa_key_mgmt_fils(hapd->conf->wpa_key_mgmt)) && len < 10)
  238. len = 10;
  239. #endif /* CONFIG_FILS */
  240. if (len < hapd->iface->extended_capa_len)
  241. len = hapd->iface->extended_capa_len;
  242. if (len == 0)
  243. return eid;
  244. *pos++ = WLAN_EID_EXT_CAPAB;
  245. *pos++ = len;
  246. for (i = 0; i < len; i++, pos++) {
  247. hostapd_ext_capab_byte(hapd, pos, i);
  248. if (i < hapd->iface->extended_capa_len) {
  249. *pos &= ~hapd->iface->extended_capa_mask[i];
  250. *pos |= hapd->iface->extended_capa[i];
  251. }
  252. }
  253. while (len > 0 && eid[1 + len] == 0) {
  254. len--;
  255. eid[1] = len;
  256. }
  257. if (len == 0)
  258. return eid;
  259. return eid + 2 + len;
  260. }
  261. u8 * hostapd_eid_qos_map_set(struct hostapd_data *hapd, u8 *eid)
  262. {
  263. u8 *pos = eid;
  264. u8 len = hapd->conf->qos_map_set_len;
  265. if (!len)
  266. return eid;
  267. *pos++ = WLAN_EID_QOS_MAP_SET;
  268. *pos++ = len;
  269. os_memcpy(pos, hapd->conf->qos_map_set, len);
  270. pos += len;
  271. return pos;
  272. }
  273. u8 * hostapd_eid_interworking(struct hostapd_data *hapd, u8 *eid)
  274. {
  275. u8 *pos = eid;
  276. #ifdef CONFIG_INTERWORKING
  277. u8 *len;
  278. if (!hapd->conf->interworking)
  279. return eid;
  280. *pos++ = WLAN_EID_INTERWORKING;
  281. len = pos++;
  282. *pos = hapd->conf->access_network_type;
  283. if (hapd->conf->internet)
  284. *pos |= INTERWORKING_ANO_INTERNET;
  285. if (hapd->conf->asra)
  286. *pos |= INTERWORKING_ANO_ASRA;
  287. if (hapd->conf->esr)
  288. *pos |= INTERWORKING_ANO_ESR;
  289. if (hapd->conf->uesa)
  290. *pos |= INTERWORKING_ANO_UESA;
  291. pos++;
  292. if (hapd->conf->venue_info_set) {
  293. *pos++ = hapd->conf->venue_group;
  294. *pos++ = hapd->conf->venue_type;
  295. }
  296. if (!is_zero_ether_addr(hapd->conf->hessid)) {
  297. os_memcpy(pos, hapd->conf->hessid, ETH_ALEN);
  298. pos += ETH_ALEN;
  299. }
  300. *len = pos - len - 1;
  301. #endif /* CONFIG_INTERWORKING */
  302. return pos;
  303. }
  304. u8 * hostapd_eid_adv_proto(struct hostapd_data *hapd, u8 *eid)
  305. {
  306. u8 *pos = eid;
  307. #ifdef CONFIG_INTERWORKING
  308. /* TODO: Separate configuration for ANQP? */
  309. if (!hapd->conf->interworking)
  310. return eid;
  311. *pos++ = WLAN_EID_ADV_PROTO;
  312. *pos++ = 2;
  313. *pos++ = 0x7F; /* Query Response Length Limit | PAME-BI */
  314. *pos++ = ACCESS_NETWORK_QUERY_PROTOCOL;
  315. #endif /* CONFIG_INTERWORKING */
  316. return pos;
  317. }
  318. u8 * hostapd_eid_roaming_consortium(struct hostapd_data *hapd, u8 *eid)
  319. {
  320. u8 *pos = eid;
  321. #ifdef CONFIG_INTERWORKING
  322. u8 *len;
  323. unsigned int i, count;
  324. if (!hapd->conf->interworking ||
  325. hapd->conf->roaming_consortium == NULL ||
  326. hapd->conf->roaming_consortium_count == 0)
  327. return eid;
  328. *pos++ = WLAN_EID_ROAMING_CONSORTIUM;
  329. len = pos++;
  330. /* Number of ANQP OIs (in addition to the max 3 listed here) */
  331. if (hapd->conf->roaming_consortium_count > 3 + 255)
  332. *pos++ = 255;
  333. else if (hapd->conf->roaming_consortium_count > 3)
  334. *pos++ = hapd->conf->roaming_consortium_count - 3;
  335. else
  336. *pos++ = 0;
  337. /* OU #1 and #2 Lengths */
  338. *pos = hapd->conf->roaming_consortium[0].len;
  339. if (hapd->conf->roaming_consortium_count > 1)
  340. *pos |= hapd->conf->roaming_consortium[1].len << 4;
  341. pos++;
  342. if (hapd->conf->roaming_consortium_count > 3)
  343. count = 3;
  344. else
  345. count = hapd->conf->roaming_consortium_count;
  346. for (i = 0; i < count; i++) {
  347. os_memcpy(pos, hapd->conf->roaming_consortium[i].oi,
  348. hapd->conf->roaming_consortium[i].len);
  349. pos += hapd->conf->roaming_consortium[i].len;
  350. }
  351. *len = pos - len - 1;
  352. #endif /* CONFIG_INTERWORKING */
  353. return pos;
  354. }
  355. u8 * hostapd_eid_time_adv(struct hostapd_data *hapd, u8 *eid)
  356. {
  357. if (hapd->conf->time_advertisement != 2)
  358. return eid;
  359. if (hapd->time_adv == NULL &&
  360. hostapd_update_time_adv(hapd) < 0)
  361. return eid;
  362. if (hapd->time_adv == NULL)
  363. return eid;
  364. os_memcpy(eid, wpabuf_head(hapd->time_adv),
  365. wpabuf_len(hapd->time_adv));
  366. eid += wpabuf_len(hapd->time_adv);
  367. return eid;
  368. }
  369. u8 * hostapd_eid_time_zone(struct hostapd_data *hapd, u8 *eid)
  370. {
  371. size_t len;
  372. if (hapd->conf->time_advertisement != 2)
  373. return eid;
  374. len = os_strlen(hapd->conf->time_zone);
  375. *eid++ = WLAN_EID_TIME_ZONE;
  376. *eid++ = len;
  377. os_memcpy(eid, hapd->conf->time_zone, len);
  378. eid += len;
  379. return eid;
  380. }
  381. int hostapd_update_time_adv(struct hostapd_data *hapd)
  382. {
  383. const int elen = 2 + 1 + 10 + 5 + 1;
  384. struct os_time t;
  385. struct os_tm tm;
  386. u8 *pos;
  387. if (hapd->conf->time_advertisement != 2)
  388. return 0;
  389. if (os_get_time(&t) < 0 || os_gmtime(t.sec, &tm) < 0)
  390. return -1;
  391. if (!hapd->time_adv) {
  392. hapd->time_adv = wpabuf_alloc(elen);
  393. if (hapd->time_adv == NULL)
  394. return -1;
  395. pos = wpabuf_put(hapd->time_adv, elen);
  396. } else
  397. pos = wpabuf_mhead_u8(hapd->time_adv);
  398. *pos++ = WLAN_EID_TIME_ADVERTISEMENT;
  399. *pos++ = 1 + 10 + 5 + 1;
  400. *pos++ = 2; /* UTC time at which the TSF timer is 0 */
  401. /* Time Value at TSF 0 */
  402. /* FIX: need to calculate this based on the current TSF value */
  403. WPA_PUT_LE16(pos, tm.year); /* Year */
  404. pos += 2;
  405. *pos++ = tm.month; /* Month */
  406. *pos++ = tm.day; /* Day of month */
  407. *pos++ = tm.hour; /* Hours */
  408. *pos++ = tm.min; /* Minutes */
  409. *pos++ = tm.sec; /* Seconds */
  410. WPA_PUT_LE16(pos, 0); /* Milliseconds (not used) */
  411. pos += 2;
  412. *pos++ = 0; /* Reserved */
  413. /* Time Error */
  414. /* TODO: fill in an estimate on the error */
  415. *pos++ = 0;
  416. *pos++ = 0;
  417. *pos++ = 0;
  418. *pos++ = 0;
  419. *pos++ = 0;
  420. *pos++ = hapd->time_update_counter++;
  421. return 0;
  422. }
  423. u8 * hostapd_eid_bss_max_idle_period(struct hostapd_data *hapd, u8 *eid)
  424. {
  425. u8 *pos = eid;
  426. #ifdef CONFIG_WNM
  427. if (hapd->conf->ap_max_inactivity > 0) {
  428. unsigned int val;
  429. *pos++ = WLAN_EID_BSS_MAX_IDLE_PERIOD;
  430. *pos++ = 3;
  431. val = hapd->conf->ap_max_inactivity;
  432. if (val > 68000)
  433. val = 68000;
  434. val *= 1000;
  435. val /= 1024;
  436. if (val == 0)
  437. val = 1;
  438. if (val > 65535)
  439. val = 65535;
  440. WPA_PUT_LE16(pos, val);
  441. pos += 2;
  442. *pos++ = 0x00; /* TODO: Protected Keep-Alive Required */
  443. }
  444. #endif /* CONFIG_WNM */
  445. return pos;
  446. }
  447. #ifdef CONFIG_MBO
  448. u8 * hostapd_eid_mbo(struct hostapd_data *hapd, u8 *eid, size_t len)
  449. {
  450. u8 mbo[6], *mbo_pos = mbo;
  451. u8 *pos = eid;
  452. if (!hapd->conf->mbo_enabled)
  453. return eid;
  454. *mbo_pos++ = MBO_ATTR_ID_AP_CAPA_IND;
  455. *mbo_pos++ = 1;
  456. /* Not Cellular aware */
  457. *mbo_pos++ = 0;
  458. if (hapd->mbo_assoc_disallow) {
  459. *mbo_pos++ = MBO_ATTR_ID_ASSOC_DISALLOW;
  460. *mbo_pos++ = 1;
  461. *mbo_pos++ = hapd->mbo_assoc_disallow;
  462. }
  463. pos += mbo_add_ie(pos, len, mbo, mbo_pos - mbo);
  464. return pos;
  465. }
  466. u8 hostapd_mbo_ie_len(struct hostapd_data *hapd)
  467. {
  468. if (!hapd->conf->mbo_enabled)
  469. return 0;
  470. /*
  471. * MBO IE header (6) + Capability Indication attribute (3) +
  472. * Association Disallowed attribute (3) = 12
  473. */
  474. return 6 + 3 + (hapd->mbo_assoc_disallow ? 3 : 0);
  475. }
  476. #endif /* CONFIG_MBO */
  477. void ap_copy_sta_supp_op_classes(struct sta_info *sta,
  478. const u8 *supp_op_classes,
  479. size_t supp_op_classes_len)
  480. {
  481. if (!supp_op_classes)
  482. return;
  483. os_free(sta->supp_op_classes);
  484. sta->supp_op_classes = os_malloc(1 + supp_op_classes_len);
  485. if (!sta->supp_op_classes)
  486. return;
  487. sta->supp_op_classes[0] = supp_op_classes_len;
  488. os_memcpy(sta->supp_op_classes + 1, supp_op_classes,
  489. supp_op_classes_len);
  490. }
  491. u8 * hostapd_eid_fils_indic(struct hostapd_data *hapd, u8 *eid, int hessid)
  492. {
  493. u8 *pos = eid;
  494. #ifdef CONFIG_FILS
  495. u8 *len;
  496. u16 fils_info = 0;
  497. if (!(hapd->conf->wpa & WPA_PROTO_RSN) ||
  498. !wpa_key_mgmt_fils(hapd->conf->wpa_key_mgmt))
  499. return pos;
  500. *pos++ = WLAN_EID_FILS_INDICATION;
  501. len = pos++;
  502. /* TODO: B0..B2: Number of Public Key Identifiers */
  503. if (hapd->conf->erp_domain) {
  504. /* TODO: Support for setting multiple domain identifiers */
  505. /* B3..B5: Number of Realm Identifiers */
  506. fils_info |= BIT(3);
  507. }
  508. /* TODO: B6: FILS IP Address Configuration */
  509. if (hapd->conf->fils_cache_id_set)
  510. fils_info |= BIT(7);
  511. if (hessid && !is_zero_ether_addr(hapd->conf->hessid))
  512. fils_info |= BIT(8); /* HESSID Included */
  513. /* FILS Shared Key Authentication without PFS Supported */
  514. fils_info |= BIT(9);
  515. /* TODO: B10: FILS Shared Key Authentication with PFS Supported */
  516. /* TODO: B11: FILS Public Key Authentication Supported */
  517. /* B12..B15: Reserved */
  518. WPA_PUT_LE16(pos, fils_info);
  519. pos += 2;
  520. if (hapd->conf->fils_cache_id_set) {
  521. os_memcpy(pos, hapd->conf->fils_cache_id, FILS_CACHE_ID_LEN);
  522. pos += FILS_CACHE_ID_LEN;
  523. }
  524. if (hessid && !is_zero_ether_addr(hapd->conf->hessid)) {
  525. os_memcpy(pos, hapd->conf->hessid, ETH_ALEN);
  526. pos += ETH_ALEN;
  527. }
  528. if (hapd->conf->erp_domain) {
  529. fils_domain_name_hash(hapd->conf->erp_domain, pos);
  530. pos += 2;
  531. }
  532. *len = pos - len - 1;
  533. #endif /* CONFIG_FILS */
  534. return pos;
  535. }