sta_info.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  1. /*
  2. * hostapd / Station table
  3. * Copyright (c) 2002-2013, 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 "utils/eloop.h"
  11. #include "common/ieee802_11_defs.h"
  12. #include "common/wpa_ctrl.h"
  13. #include "common/sae.h"
  14. #include "radius/radius.h"
  15. #include "radius/radius_client.h"
  16. #include "p2p/p2p.h"
  17. #include "hostapd.h"
  18. #include "accounting.h"
  19. #include "ieee802_1x.h"
  20. #include "ieee802_11.h"
  21. #include "ieee802_11_auth.h"
  22. #include "wpa_auth.h"
  23. #include "preauth_auth.h"
  24. #include "ap_config.h"
  25. #include "beacon.h"
  26. #include "ap_mlme.h"
  27. #include "vlan_init.h"
  28. #include "p2p_hostapd.h"
  29. #include "ap_drv_ops.h"
  30. #include "gas_serv.h"
  31. #include "wnm_ap.h"
  32. #include "sta_info.h"
  33. static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
  34. struct sta_info *sta);
  35. static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx);
  36. static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx);
  37. static void ap_sta_deauth_cb_timeout(void *eloop_ctx, void *timeout_ctx);
  38. static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx);
  39. #ifdef CONFIG_IEEE80211W
  40. static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx);
  41. #endif /* CONFIG_IEEE80211W */
  42. static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta);
  43. int ap_for_each_sta(struct hostapd_data *hapd,
  44. int (*cb)(struct hostapd_data *hapd, struct sta_info *sta,
  45. void *ctx),
  46. void *ctx)
  47. {
  48. struct sta_info *sta;
  49. for (sta = hapd->sta_list; sta; sta = sta->next) {
  50. if (cb(hapd, sta, ctx))
  51. return 1;
  52. }
  53. return 0;
  54. }
  55. struct sta_info * ap_get_sta(struct hostapd_data *hapd, const u8 *sta)
  56. {
  57. struct sta_info *s;
  58. s = hapd->sta_hash[STA_HASH(sta)];
  59. while (s != NULL && os_memcmp(s->addr, sta, 6) != 0)
  60. s = s->hnext;
  61. return s;
  62. }
  63. #ifdef CONFIG_P2P
  64. struct sta_info * ap_get_sta_p2p(struct hostapd_data *hapd, const u8 *addr)
  65. {
  66. struct sta_info *sta;
  67. for (sta = hapd->sta_list; sta; sta = sta->next) {
  68. const u8 *p2p_dev_addr;
  69. if (sta->p2p_ie == NULL)
  70. continue;
  71. p2p_dev_addr = p2p_get_go_dev_addr(sta->p2p_ie);
  72. if (p2p_dev_addr == NULL)
  73. continue;
  74. if (os_memcmp(p2p_dev_addr, addr, ETH_ALEN) == 0)
  75. return sta;
  76. }
  77. return NULL;
  78. }
  79. #endif /* CONFIG_P2P */
  80. static void ap_sta_list_del(struct hostapd_data *hapd, struct sta_info *sta)
  81. {
  82. struct sta_info *tmp;
  83. if (hapd->sta_list == sta) {
  84. hapd->sta_list = sta->next;
  85. return;
  86. }
  87. tmp = hapd->sta_list;
  88. while (tmp != NULL && tmp->next != sta)
  89. tmp = tmp->next;
  90. if (tmp == NULL) {
  91. wpa_printf(MSG_DEBUG, "Could not remove STA " MACSTR " from "
  92. "list.", MAC2STR(sta->addr));
  93. } else
  94. tmp->next = sta->next;
  95. }
  96. void ap_sta_hash_add(struct hostapd_data *hapd, struct sta_info *sta)
  97. {
  98. sta->hnext = hapd->sta_hash[STA_HASH(sta->addr)];
  99. hapd->sta_hash[STA_HASH(sta->addr)] = sta;
  100. }
  101. static void ap_sta_hash_del(struct hostapd_data *hapd, struct sta_info *sta)
  102. {
  103. struct sta_info *s;
  104. s = hapd->sta_hash[STA_HASH(sta->addr)];
  105. if (s == NULL) return;
  106. if (os_memcmp(s->addr, sta->addr, 6) == 0) {
  107. hapd->sta_hash[STA_HASH(sta->addr)] = s->hnext;
  108. return;
  109. }
  110. while (s->hnext != NULL &&
  111. os_memcmp(s->hnext->addr, sta->addr, ETH_ALEN) != 0)
  112. s = s->hnext;
  113. if (s->hnext != NULL)
  114. s->hnext = s->hnext->hnext;
  115. else
  116. wpa_printf(MSG_DEBUG, "AP: could not remove STA " MACSTR
  117. " from hash table", MAC2STR(sta->addr));
  118. }
  119. void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
  120. {
  121. int set_beacon = 0;
  122. accounting_sta_stop(hapd, sta);
  123. /* just in case */
  124. ap_sta_set_authorized(hapd, sta, 0);
  125. if (sta->flags & WLAN_STA_WDS)
  126. hostapd_set_wds_sta(hapd, NULL, sta->addr, sta->aid, 0);
  127. if (!hapd->iface->driver_ap_teardown &&
  128. !(sta->flags & WLAN_STA_PREAUTH))
  129. hostapd_drv_sta_remove(hapd, sta->addr);
  130. ap_sta_hash_del(hapd, sta);
  131. ap_sta_list_del(hapd, sta);
  132. if (sta->aid > 0)
  133. hapd->sta_aid[(sta->aid - 1) / 32] &=
  134. ~BIT((sta->aid - 1) % 32);
  135. hapd->num_sta--;
  136. if (sta->nonerp_set) {
  137. sta->nonerp_set = 0;
  138. hapd->iface->num_sta_non_erp--;
  139. if (hapd->iface->num_sta_non_erp == 0)
  140. set_beacon++;
  141. }
  142. if (sta->no_short_slot_time_set) {
  143. sta->no_short_slot_time_set = 0;
  144. hapd->iface->num_sta_no_short_slot_time--;
  145. if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
  146. && hapd->iface->num_sta_no_short_slot_time == 0)
  147. set_beacon++;
  148. }
  149. if (sta->no_short_preamble_set) {
  150. sta->no_short_preamble_set = 0;
  151. hapd->iface->num_sta_no_short_preamble--;
  152. if (hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G
  153. && hapd->iface->num_sta_no_short_preamble == 0)
  154. set_beacon++;
  155. }
  156. if (sta->no_ht_gf_set) {
  157. sta->no_ht_gf_set = 0;
  158. hapd->iface->num_sta_ht_no_gf--;
  159. }
  160. if (sta->no_ht_set) {
  161. sta->no_ht_set = 0;
  162. hapd->iface->num_sta_no_ht--;
  163. }
  164. if (sta->ht_20mhz_set) {
  165. sta->ht_20mhz_set = 0;
  166. hapd->iface->num_sta_ht_20mhz--;
  167. }
  168. #ifdef CONFIG_IEEE80211N
  169. ht40_intolerant_remove(hapd->iface, sta);
  170. #endif /* CONFIG_IEEE80211N */
  171. #ifdef CONFIG_P2P
  172. if (sta->no_p2p_set) {
  173. sta->no_p2p_set = 0;
  174. hapd->num_sta_no_p2p--;
  175. if (hapd->num_sta_no_p2p == 0)
  176. hostapd_p2p_non_p2p_sta_disconnected(hapd);
  177. }
  178. #endif /* CONFIG_P2P */
  179. #if defined(NEED_AP_MLME) && defined(CONFIG_IEEE80211N)
  180. if (hostapd_ht_operation_update(hapd->iface) > 0)
  181. set_beacon++;
  182. #endif /* NEED_AP_MLME && CONFIG_IEEE80211N */
  183. if (set_beacon)
  184. ieee802_11_set_beacons(hapd->iface);
  185. wpa_printf(MSG_DEBUG, "%s: cancel ap_handle_timer for " MACSTR,
  186. __func__, MAC2STR(sta->addr));
  187. eloop_cancel_timeout(ap_handle_timer, hapd, sta);
  188. eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
  189. eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
  190. eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
  191. eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
  192. ieee802_1x_free_station(sta);
  193. wpa_auth_sta_deinit(sta->wpa_sm);
  194. rsn_preauth_free_station(hapd, sta);
  195. #ifndef CONFIG_NO_RADIUS
  196. if (hapd->radius)
  197. radius_client_flush_auth(hapd->radius, sta->addr);
  198. #endif /* CONFIG_NO_RADIUS */
  199. os_free(sta->challenge);
  200. #ifdef CONFIG_IEEE80211W
  201. os_free(sta->sa_query_trans_id);
  202. eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
  203. #endif /* CONFIG_IEEE80211W */
  204. #ifdef CONFIG_P2P
  205. p2p_group_notif_disassoc(hapd->p2p_group, sta->addr);
  206. #endif /* CONFIG_P2P */
  207. #ifdef CONFIG_INTERWORKING
  208. if (sta->gas_dialog) {
  209. int i;
  210. for (i = 0; i < GAS_DIALOG_MAX; i++)
  211. gas_serv_dialog_clear(&sta->gas_dialog[i]);
  212. os_free(sta->gas_dialog);
  213. }
  214. #endif /* CONFIG_INTERWORKING */
  215. wpabuf_free(sta->wps_ie);
  216. wpabuf_free(sta->p2p_ie);
  217. wpabuf_free(sta->hs20_ie);
  218. os_free(sta->ht_capabilities);
  219. os_free(sta->vht_capabilities);
  220. hostapd_free_psk_list(sta->psk);
  221. os_free(sta->identity);
  222. os_free(sta->radius_cui);
  223. os_free(sta->remediation_url);
  224. wpabuf_free(sta->hs20_deauth_req);
  225. os_free(sta->hs20_session_info_url);
  226. #ifdef CONFIG_SAE
  227. sae_clear_data(sta->sae);
  228. os_free(sta->sae);
  229. #endif /* CONFIG_SAE */
  230. os_free(sta);
  231. }
  232. void hostapd_free_stas(struct hostapd_data *hapd)
  233. {
  234. struct sta_info *sta, *prev;
  235. sta = hapd->sta_list;
  236. while (sta) {
  237. prev = sta;
  238. if (sta->flags & WLAN_STA_AUTH) {
  239. mlme_deauthenticate_indication(
  240. hapd, sta, WLAN_REASON_UNSPECIFIED);
  241. }
  242. sta = sta->next;
  243. wpa_printf(MSG_DEBUG, "Removing station " MACSTR,
  244. MAC2STR(prev->addr));
  245. ap_free_sta(hapd, prev);
  246. }
  247. }
  248. /**
  249. * ap_handle_timer - Per STA timer handler
  250. * @eloop_ctx: struct hostapd_data *
  251. * @timeout_ctx: struct sta_info *
  252. *
  253. * This function is called to check station activity and to remove inactive
  254. * stations.
  255. */
  256. void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
  257. {
  258. struct hostapd_data *hapd = eloop_ctx;
  259. struct sta_info *sta = timeout_ctx;
  260. unsigned long next_time = 0;
  261. int reason;
  262. wpa_printf(MSG_DEBUG, "%s: " MACSTR " flags=0x%x timeout_next=%d",
  263. __func__, MAC2STR(sta->addr), sta->flags,
  264. sta->timeout_next);
  265. if (sta->timeout_next == STA_REMOVE) {
  266. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  267. HOSTAPD_LEVEL_INFO, "deauthenticated due to "
  268. "local deauth request");
  269. ap_free_sta(hapd, sta);
  270. return;
  271. }
  272. if ((sta->flags & WLAN_STA_ASSOC) &&
  273. (sta->timeout_next == STA_NULLFUNC ||
  274. sta->timeout_next == STA_DISASSOC)) {
  275. int inactive_sec;
  276. /*
  277. * Add random value to timeout so that we don't end up bouncing
  278. * all stations at the same time if we have lots of associated
  279. * stations that are idle (but keep re-associating).
  280. */
  281. int fuzz = os_random() % 20;
  282. inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
  283. if (inactive_sec == -1) {
  284. wpa_msg(hapd->msg_ctx, MSG_DEBUG,
  285. "Check inactivity: Could not "
  286. "get station info from kernel driver for "
  287. MACSTR, MAC2STR(sta->addr));
  288. /*
  289. * The driver may not support this functionality.
  290. * Anyway, try again after the next inactivity timeout,
  291. * but do not disconnect the station now.
  292. */
  293. next_time = hapd->conf->ap_max_inactivity + fuzz;
  294. } else if (inactive_sec < hapd->conf->ap_max_inactivity &&
  295. sta->flags & WLAN_STA_ASSOC) {
  296. /* station activity detected; reset timeout state */
  297. wpa_msg(hapd->msg_ctx, MSG_DEBUG,
  298. "Station " MACSTR " has been active %is ago",
  299. MAC2STR(sta->addr), inactive_sec);
  300. sta->timeout_next = STA_NULLFUNC;
  301. next_time = hapd->conf->ap_max_inactivity + fuzz -
  302. inactive_sec;
  303. } else {
  304. wpa_msg(hapd->msg_ctx, MSG_DEBUG,
  305. "Station " MACSTR " has been "
  306. "inactive too long: %d sec, max allowed: %d",
  307. MAC2STR(sta->addr), inactive_sec,
  308. hapd->conf->ap_max_inactivity);
  309. if (hapd->conf->skip_inactivity_poll)
  310. sta->timeout_next = STA_DISASSOC;
  311. }
  312. }
  313. if ((sta->flags & WLAN_STA_ASSOC) &&
  314. sta->timeout_next == STA_DISASSOC &&
  315. !(sta->flags & WLAN_STA_PENDING_POLL) &&
  316. !hapd->conf->skip_inactivity_poll) {
  317. wpa_msg(hapd->msg_ctx, MSG_DEBUG, "Station " MACSTR
  318. " has ACKed data poll", MAC2STR(sta->addr));
  319. /* data nullfunc frame poll did not produce TX errors; assume
  320. * station ACKed it */
  321. sta->timeout_next = STA_NULLFUNC;
  322. next_time = hapd->conf->ap_max_inactivity;
  323. }
  324. if (next_time) {
  325. wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout "
  326. "for " MACSTR " (%lu seconds)",
  327. __func__, MAC2STR(sta->addr), next_time);
  328. eloop_register_timeout(next_time, 0, ap_handle_timer, hapd,
  329. sta);
  330. return;
  331. }
  332. if (sta->timeout_next == STA_NULLFUNC &&
  333. (sta->flags & WLAN_STA_ASSOC)) {
  334. wpa_printf(MSG_DEBUG, " Polling STA");
  335. sta->flags |= WLAN_STA_PENDING_POLL;
  336. hostapd_drv_poll_client(hapd, hapd->own_addr, sta->addr,
  337. sta->flags & WLAN_STA_WMM);
  338. } else if (sta->timeout_next != STA_REMOVE) {
  339. int deauth = sta->timeout_next == STA_DEAUTH;
  340. wpa_dbg(hapd->msg_ctx, MSG_DEBUG,
  341. "Timeout, sending %s info to STA " MACSTR,
  342. deauth ? "deauthentication" : "disassociation",
  343. MAC2STR(sta->addr));
  344. if (deauth) {
  345. hostapd_drv_sta_deauth(
  346. hapd, sta->addr,
  347. WLAN_REASON_PREV_AUTH_NOT_VALID);
  348. } else {
  349. reason = (sta->timeout_next == STA_DISASSOC) ?
  350. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY :
  351. WLAN_REASON_PREV_AUTH_NOT_VALID;
  352. hostapd_drv_sta_disassoc(hapd, sta->addr, reason);
  353. }
  354. }
  355. switch (sta->timeout_next) {
  356. case STA_NULLFUNC:
  357. sta->timeout_next = STA_DISASSOC;
  358. wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout "
  359. "for " MACSTR " (%d seconds - AP_DISASSOC_DELAY)",
  360. __func__, MAC2STR(sta->addr), AP_DISASSOC_DELAY);
  361. eloop_register_timeout(AP_DISASSOC_DELAY, 0, ap_handle_timer,
  362. hapd, sta);
  363. break;
  364. case STA_DISASSOC:
  365. case STA_DISASSOC_FROM_CLI:
  366. ap_sta_set_authorized(hapd, sta, 0);
  367. sta->flags &= ~WLAN_STA_ASSOC;
  368. ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
  369. if (!sta->acct_terminate_cause)
  370. sta->acct_terminate_cause =
  371. RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
  372. accounting_sta_stop(hapd, sta);
  373. ieee802_1x_free_station(sta);
  374. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  375. HOSTAPD_LEVEL_INFO, "disassociated due to "
  376. "inactivity");
  377. reason = (sta->timeout_next == STA_DISASSOC) ?
  378. WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY :
  379. WLAN_REASON_PREV_AUTH_NOT_VALID;
  380. sta->timeout_next = STA_DEAUTH;
  381. wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout "
  382. "for " MACSTR " (%d seconds - AP_DEAUTH_DELAY)",
  383. __func__, MAC2STR(sta->addr), AP_DEAUTH_DELAY);
  384. eloop_register_timeout(AP_DEAUTH_DELAY, 0, ap_handle_timer,
  385. hapd, sta);
  386. mlme_disassociate_indication(hapd, sta, reason);
  387. break;
  388. case STA_DEAUTH:
  389. case STA_REMOVE:
  390. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  391. HOSTAPD_LEVEL_INFO, "deauthenticated due to "
  392. "inactivity (timer DEAUTH/REMOVE)");
  393. if (!sta->acct_terminate_cause)
  394. sta->acct_terminate_cause =
  395. RADIUS_ACCT_TERMINATE_CAUSE_IDLE_TIMEOUT;
  396. mlme_deauthenticate_indication(
  397. hapd, sta,
  398. WLAN_REASON_PREV_AUTH_NOT_VALID);
  399. ap_free_sta(hapd, sta);
  400. break;
  401. }
  402. }
  403. static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
  404. {
  405. struct hostapd_data *hapd = eloop_ctx;
  406. struct sta_info *sta = timeout_ctx;
  407. if (!(sta->flags & WLAN_STA_AUTH)) {
  408. if (sta->flags & WLAN_STA_GAS) {
  409. wpa_printf(MSG_DEBUG, "GAS: Remove temporary STA "
  410. "entry " MACSTR, MAC2STR(sta->addr));
  411. ap_free_sta(hapd, sta);
  412. }
  413. return;
  414. }
  415. hostapd_drv_sta_deauth(hapd, sta->addr,
  416. WLAN_REASON_PREV_AUTH_NOT_VALID);
  417. mlme_deauthenticate_indication(hapd, sta,
  418. WLAN_REASON_PREV_AUTH_NOT_VALID);
  419. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  420. HOSTAPD_LEVEL_INFO, "deauthenticated due to "
  421. "session timeout");
  422. sta->acct_terminate_cause =
  423. RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
  424. ap_free_sta(hapd, sta);
  425. }
  426. void ap_sta_replenish_timeout(struct hostapd_data *hapd, struct sta_info *sta,
  427. u32 session_timeout)
  428. {
  429. if (eloop_replenish_timeout(session_timeout, 0,
  430. ap_handle_session_timer, hapd, sta) == 1) {
  431. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  432. HOSTAPD_LEVEL_DEBUG, "setting session timeout "
  433. "to %d seconds", session_timeout);
  434. }
  435. }
  436. void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
  437. u32 session_timeout)
  438. {
  439. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  440. HOSTAPD_LEVEL_DEBUG, "setting session timeout to %d "
  441. "seconds", session_timeout);
  442. eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
  443. eloop_register_timeout(session_timeout, 0, ap_handle_session_timer,
  444. hapd, sta);
  445. }
  446. void ap_sta_no_session_timeout(struct hostapd_data *hapd, struct sta_info *sta)
  447. {
  448. eloop_cancel_timeout(ap_handle_session_timer, hapd, sta);
  449. }
  450. static void ap_handle_session_warning_timer(void *eloop_ctx, void *timeout_ctx)
  451. {
  452. #ifdef CONFIG_WNM
  453. struct hostapd_data *hapd = eloop_ctx;
  454. struct sta_info *sta = timeout_ctx;
  455. wpa_printf(MSG_DEBUG, "WNM: Session warning time reached for " MACSTR,
  456. MAC2STR(sta->addr));
  457. if (sta->hs20_session_info_url == NULL)
  458. return;
  459. wnm_send_ess_disassoc_imminent(hapd, sta, sta->hs20_session_info_url,
  460. sta->hs20_disassoc_timer);
  461. #endif /* CONFIG_WNM */
  462. }
  463. void ap_sta_session_warning_timeout(struct hostapd_data *hapd,
  464. struct sta_info *sta, int warning_time)
  465. {
  466. eloop_cancel_timeout(ap_handle_session_warning_timer, hapd, sta);
  467. eloop_register_timeout(warning_time, 0, ap_handle_session_warning_timer,
  468. hapd, sta);
  469. }
  470. struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
  471. {
  472. struct sta_info *sta;
  473. sta = ap_get_sta(hapd, addr);
  474. if (sta)
  475. return sta;
  476. wpa_printf(MSG_DEBUG, " New STA");
  477. if (hapd->num_sta >= hapd->conf->max_num_sta) {
  478. /* FIX: might try to remove some old STAs first? */
  479. wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)",
  480. hapd->num_sta, hapd->conf->max_num_sta);
  481. return NULL;
  482. }
  483. sta = os_zalloc(sizeof(struct sta_info));
  484. if (sta == NULL) {
  485. wpa_printf(MSG_ERROR, "malloc failed");
  486. return NULL;
  487. }
  488. sta->acct_interim_interval = hapd->conf->acct_interim_interval;
  489. accounting_sta_get_id(hapd, sta);
  490. if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_INACTIVITY_TIMER)) {
  491. wpa_printf(MSG_DEBUG, "%s: register ap_handle_timer timeout "
  492. "for " MACSTR " (%d seconds - ap_max_inactivity)",
  493. __func__, MAC2STR(addr),
  494. hapd->conf->ap_max_inactivity);
  495. eloop_register_timeout(hapd->conf->ap_max_inactivity, 0,
  496. ap_handle_timer, hapd, sta);
  497. }
  498. /* initialize STA info data */
  499. os_memcpy(sta->addr, addr, ETH_ALEN);
  500. sta->next = hapd->sta_list;
  501. hapd->sta_list = sta;
  502. hapd->num_sta++;
  503. ap_sta_hash_add(hapd, sta);
  504. sta->ssid = &hapd->conf->ssid;
  505. ap_sta_remove_in_other_bss(hapd, sta);
  506. return sta;
  507. }
  508. static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
  509. {
  510. ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
  511. wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
  512. MAC2STR(sta->addr));
  513. if (hostapd_drv_sta_remove(hapd, sta->addr) &&
  514. sta->flags & WLAN_STA_ASSOC) {
  515. wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
  516. " from kernel driver.", MAC2STR(sta->addr));
  517. return -1;
  518. }
  519. return 0;
  520. }
  521. static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
  522. struct sta_info *sta)
  523. {
  524. struct hostapd_iface *iface = hapd->iface;
  525. size_t i;
  526. for (i = 0; i < iface->num_bss; i++) {
  527. struct hostapd_data *bss = iface->bss[i];
  528. struct sta_info *sta2;
  529. /* bss should always be set during operation, but it may be
  530. * NULL during reconfiguration. Assume the STA is not
  531. * associated to another BSS in that case to avoid NULL pointer
  532. * dereferences. */
  533. if (bss == hapd || bss == NULL)
  534. continue;
  535. sta2 = ap_get_sta(bss, sta->addr);
  536. if (!sta2)
  537. continue;
  538. ap_sta_disconnect(bss, sta2, sta2->addr,
  539. WLAN_REASON_PREV_AUTH_NOT_VALID);
  540. }
  541. }
  542. static void ap_sta_disassoc_cb_timeout(void *eloop_ctx, void *timeout_ctx)
  543. {
  544. struct hostapd_data *hapd = eloop_ctx;
  545. struct sta_info *sta = timeout_ctx;
  546. ap_sta_remove(hapd, sta);
  547. mlme_disassociate_indication(hapd, sta, sta->disassoc_reason);
  548. }
  549. void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
  550. u16 reason)
  551. {
  552. wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
  553. hapd->conf->iface, MAC2STR(sta->addr));
  554. sta->flags &= ~(WLAN_STA_ASSOC | WLAN_STA_ASSOC_REQ_OK);
  555. ap_sta_set_authorized(hapd, sta, 0);
  556. sta->timeout_next = STA_DEAUTH;
  557. wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
  558. "for " MACSTR " (%d seconds - "
  559. "AP_MAX_INACTIVITY_AFTER_DISASSOC)",
  560. __func__, MAC2STR(sta->addr),
  561. AP_MAX_INACTIVITY_AFTER_DISASSOC);
  562. eloop_cancel_timeout(ap_handle_timer, hapd, sta);
  563. eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0,
  564. ap_handle_timer, hapd, sta);
  565. accounting_sta_stop(hapd, sta);
  566. ieee802_1x_free_station(sta);
  567. sta->disassoc_reason = reason;
  568. sta->flags |= WLAN_STA_PENDING_DISASSOC_CB;
  569. eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
  570. eloop_register_timeout(hapd->iface->drv_flags &
  571. WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0,
  572. ap_sta_disassoc_cb_timeout, hapd, sta);
  573. }
  574. static void ap_sta_deauth_cb_timeout(void *eloop_ctx, void *timeout_ctx)
  575. {
  576. struct hostapd_data *hapd = eloop_ctx;
  577. struct sta_info *sta = timeout_ctx;
  578. ap_sta_remove(hapd, sta);
  579. mlme_deauthenticate_indication(hapd, sta, sta->deauth_reason);
  580. }
  581. void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
  582. u16 reason)
  583. {
  584. wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
  585. hapd->conf->iface, MAC2STR(sta->addr));
  586. sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
  587. ap_sta_set_authorized(hapd, sta, 0);
  588. sta->timeout_next = STA_REMOVE;
  589. wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
  590. "for " MACSTR " (%d seconds - "
  591. "AP_MAX_INACTIVITY_AFTER_DEAUTH)",
  592. __func__, MAC2STR(sta->addr),
  593. AP_MAX_INACTIVITY_AFTER_DEAUTH);
  594. eloop_cancel_timeout(ap_handle_timer, hapd, sta);
  595. eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,
  596. ap_handle_timer, hapd, sta);
  597. accounting_sta_stop(hapd, sta);
  598. ieee802_1x_free_station(sta);
  599. sta->deauth_reason = reason;
  600. sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
  601. eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
  602. eloop_register_timeout(hapd->iface->drv_flags &
  603. WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0,
  604. ap_sta_deauth_cb_timeout, hapd, sta);
  605. }
  606. #ifdef CONFIG_WPS
  607. int ap_sta_wps_cancel(struct hostapd_data *hapd,
  608. struct sta_info *sta, void *ctx)
  609. {
  610. if (sta && (sta->flags & WLAN_STA_WPS)) {
  611. ap_sta_deauthenticate(hapd, sta,
  612. WLAN_REASON_PREV_AUTH_NOT_VALID);
  613. wpa_printf(MSG_DEBUG, "WPS: %s: Deauth sta=" MACSTR,
  614. __func__, MAC2STR(sta->addr));
  615. return 1;
  616. }
  617. return 0;
  618. }
  619. #endif /* CONFIG_WPS */
  620. int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
  621. int old_vlanid)
  622. {
  623. #ifndef CONFIG_NO_VLAN
  624. const char *iface;
  625. struct hostapd_vlan *vlan = NULL;
  626. int ret;
  627. /*
  628. * Do not proceed furthur if the vlan id remains same. We do not want
  629. * duplicate dynamic vlan entries.
  630. */
  631. if (sta->vlan_id == old_vlanid)
  632. return 0;
  633. /*
  634. * During 1x reauth, if the vlan id changes, then remove the old id and
  635. * proceed furthur to add the new one.
  636. */
  637. if (old_vlanid > 0)
  638. vlan_remove_dynamic(hapd, old_vlanid);
  639. iface = hapd->conf->iface;
  640. if (sta->ssid->vlan[0])
  641. iface = sta->ssid->vlan;
  642. if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
  643. sta->vlan_id = 0;
  644. else if (sta->vlan_id > 0) {
  645. struct hostapd_vlan *wildcard_vlan = NULL;
  646. vlan = hapd->conf->vlan;
  647. while (vlan) {
  648. if (vlan->vlan_id == sta->vlan_id)
  649. break;
  650. if (vlan->vlan_id == VLAN_ID_WILDCARD)
  651. wildcard_vlan = vlan;
  652. vlan = vlan->next;
  653. }
  654. if (!vlan)
  655. vlan = wildcard_vlan;
  656. if (vlan)
  657. iface = vlan->ifname;
  658. }
  659. if (sta->vlan_id > 0 && vlan == NULL) {
  660. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  661. HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
  662. "binding station to (vlan_id=%d)",
  663. sta->vlan_id);
  664. return -1;
  665. } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
  666. vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
  667. if (vlan == NULL) {
  668. hostapd_logger(hapd, sta->addr,
  669. HOSTAPD_MODULE_IEEE80211,
  670. HOSTAPD_LEVEL_DEBUG, "could not add "
  671. "dynamic VLAN interface for vlan_id=%d",
  672. sta->vlan_id);
  673. return -1;
  674. }
  675. iface = vlan->ifname;
  676. if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
  677. hostapd_logger(hapd, sta->addr,
  678. HOSTAPD_MODULE_IEEE80211,
  679. HOSTAPD_LEVEL_DEBUG, "could not "
  680. "configure encryption for dynamic VLAN "
  681. "interface for vlan_id=%d",
  682. sta->vlan_id);
  683. }
  684. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  685. HOSTAPD_LEVEL_DEBUG, "added new dynamic VLAN "
  686. "interface '%s'", iface);
  687. } else if (vlan && vlan->vlan_id == sta->vlan_id) {
  688. if (sta->vlan_id > 0) {
  689. vlan->dynamic_vlan++;
  690. hostapd_logger(hapd, sta->addr,
  691. HOSTAPD_MODULE_IEEE80211,
  692. HOSTAPD_LEVEL_DEBUG, "updated existing "
  693. "dynamic VLAN interface '%s'", iface);
  694. }
  695. /*
  696. * Update encryption configuration for statically generated
  697. * VLAN interface. This is only used for static WEP
  698. * configuration for the case where hostapd did not yet know
  699. * which keys are to be used when the interface was added.
  700. */
  701. if (vlan_setup_encryption_dyn(hapd, sta->ssid, iface) != 0) {
  702. hostapd_logger(hapd, sta->addr,
  703. HOSTAPD_MODULE_IEEE80211,
  704. HOSTAPD_LEVEL_DEBUG, "could not "
  705. "configure encryption for VLAN "
  706. "interface for vlan_id=%d",
  707. sta->vlan_id);
  708. }
  709. }
  710. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  711. HOSTAPD_LEVEL_DEBUG, "binding station to interface "
  712. "'%s'", iface);
  713. if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
  714. wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
  715. ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
  716. if (ret < 0) {
  717. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  718. HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
  719. "entry to vlan_id=%d", sta->vlan_id);
  720. }
  721. return ret;
  722. #else /* CONFIG_NO_VLAN */
  723. return 0;
  724. #endif /* CONFIG_NO_VLAN */
  725. }
  726. #ifdef CONFIG_IEEE80211W
  727. int ap_check_sa_query_timeout(struct hostapd_data *hapd, struct sta_info *sta)
  728. {
  729. u32 tu;
  730. struct os_reltime now, passed;
  731. os_get_reltime(&now);
  732. os_reltime_sub(&now, &sta->sa_query_start, &passed);
  733. tu = (passed.sec * 1000000 + passed.usec) / 1024;
  734. if (hapd->conf->assoc_sa_query_max_timeout < tu) {
  735. hostapd_logger(hapd, sta->addr,
  736. HOSTAPD_MODULE_IEEE80211,
  737. HOSTAPD_LEVEL_DEBUG,
  738. "association SA Query timed out");
  739. sta->sa_query_timed_out = 1;
  740. os_free(sta->sa_query_trans_id);
  741. sta->sa_query_trans_id = NULL;
  742. sta->sa_query_count = 0;
  743. eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
  744. return 1;
  745. }
  746. return 0;
  747. }
  748. static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
  749. {
  750. struct hostapd_data *hapd = eloop_ctx;
  751. struct sta_info *sta = timeout_ctx;
  752. unsigned int timeout, sec, usec;
  753. u8 *trans_id, *nbuf;
  754. if (sta->sa_query_count > 0 &&
  755. ap_check_sa_query_timeout(hapd, sta))
  756. return;
  757. nbuf = os_realloc_array(sta->sa_query_trans_id,
  758. sta->sa_query_count + 1,
  759. WLAN_SA_QUERY_TR_ID_LEN);
  760. if (nbuf == NULL)
  761. return;
  762. if (sta->sa_query_count == 0) {
  763. /* Starting a new SA Query procedure */
  764. os_get_reltime(&sta->sa_query_start);
  765. }
  766. trans_id = nbuf + sta->sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
  767. sta->sa_query_trans_id = nbuf;
  768. sta->sa_query_count++;
  769. os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  770. timeout = hapd->conf->assoc_sa_query_retry_timeout;
  771. sec = ((timeout / 1000) * 1024) / 1000;
  772. usec = (timeout % 1000) * 1024;
  773. eloop_register_timeout(sec, usec, ap_sa_query_timer, hapd, sta);
  774. hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
  775. HOSTAPD_LEVEL_DEBUG,
  776. "association SA Query attempt %d", sta->sa_query_count);
  777. ieee802_11_send_sa_query_req(hapd, sta->addr, trans_id);
  778. }
  779. void ap_sta_start_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
  780. {
  781. ap_sa_query_timer(hapd, sta);
  782. }
  783. void ap_sta_stop_sa_query(struct hostapd_data *hapd, struct sta_info *sta)
  784. {
  785. eloop_cancel_timeout(ap_sa_query_timer, hapd, sta);
  786. os_free(sta->sa_query_trans_id);
  787. sta->sa_query_trans_id = NULL;
  788. sta->sa_query_count = 0;
  789. }
  790. #endif /* CONFIG_IEEE80211W */
  791. void ap_sta_set_authorized(struct hostapd_data *hapd, struct sta_info *sta,
  792. int authorized)
  793. {
  794. const u8 *dev_addr = NULL;
  795. char buf[100];
  796. #ifdef CONFIG_P2P
  797. u8 addr[ETH_ALEN];
  798. u8 ip_addr_buf[4];
  799. #endif /* CONFIG_P2P */
  800. if (!!authorized == !!(sta->flags & WLAN_STA_AUTHORIZED))
  801. return;
  802. #ifdef CONFIG_P2P
  803. if (hapd->p2p_group == NULL) {
  804. if (sta->p2p_ie != NULL &&
  805. p2p_parse_dev_addr_in_p2p_ie(sta->p2p_ie, addr) == 0)
  806. dev_addr = addr;
  807. } else
  808. dev_addr = p2p_group_get_dev_addr(hapd->p2p_group, sta->addr);
  809. #endif /* CONFIG_P2P */
  810. if (dev_addr)
  811. os_snprintf(buf, sizeof(buf), MACSTR " p2p_dev_addr=" MACSTR,
  812. MAC2STR(sta->addr), MAC2STR(dev_addr));
  813. else
  814. os_snprintf(buf, sizeof(buf), MACSTR, MAC2STR(sta->addr));
  815. if (authorized) {
  816. char ip_addr[100];
  817. ip_addr[0] = '\0';
  818. #ifdef CONFIG_P2P
  819. if (wpa_auth_get_ip_addr(sta->wpa_sm, ip_addr_buf) == 0) {
  820. os_snprintf(ip_addr, sizeof(ip_addr),
  821. " ip_addr=%u.%u.%u.%u",
  822. ip_addr_buf[0], ip_addr_buf[1],
  823. ip_addr_buf[2], ip_addr_buf[3]);
  824. }
  825. #endif /* CONFIG_P2P */
  826. wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_CONNECTED "%s%s",
  827. buf, ip_addr);
  828. if (hapd->msg_ctx_parent &&
  829. hapd->msg_ctx_parent != hapd->msg_ctx)
  830. wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
  831. AP_STA_CONNECTED "%s%s",
  832. buf, ip_addr);
  833. sta->flags |= WLAN_STA_AUTHORIZED;
  834. } else {
  835. wpa_msg(hapd->msg_ctx, MSG_INFO, AP_STA_DISCONNECTED "%s", buf);
  836. if (hapd->msg_ctx_parent &&
  837. hapd->msg_ctx_parent != hapd->msg_ctx)
  838. wpa_msg_no_global(hapd->msg_ctx_parent, MSG_INFO,
  839. AP_STA_DISCONNECTED "%s", buf);
  840. sta->flags &= ~WLAN_STA_AUTHORIZED;
  841. }
  842. if (hapd->sta_authorized_cb)
  843. hapd->sta_authorized_cb(hapd->sta_authorized_cb_ctx,
  844. sta->addr, authorized, dev_addr);
  845. }
  846. void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
  847. const u8 *addr, u16 reason)
  848. {
  849. if (sta == NULL && addr)
  850. sta = ap_get_sta(hapd, addr);
  851. if (addr)
  852. hostapd_drv_sta_deauth(hapd, addr, reason);
  853. if (sta == NULL)
  854. return;
  855. ap_sta_set_authorized(hapd, sta, 0);
  856. wpa_auth_sm_event(sta->wpa_sm, WPA_DEAUTH);
  857. ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
  858. sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
  859. wpa_printf(MSG_DEBUG, "%s: reschedule ap_handle_timer timeout "
  860. "for " MACSTR " (%d seconds - "
  861. "AP_MAX_INACTIVITY_AFTER_DEAUTH)",
  862. __func__, MAC2STR(sta->addr),
  863. AP_MAX_INACTIVITY_AFTER_DEAUTH);
  864. eloop_cancel_timeout(ap_handle_timer, hapd, sta);
  865. eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,
  866. ap_handle_timer, hapd, sta);
  867. sta->timeout_next = STA_REMOVE;
  868. sta->deauth_reason = reason;
  869. sta->flags |= WLAN_STA_PENDING_DEAUTH_CB;
  870. eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
  871. eloop_register_timeout(hapd->iface->drv_flags &
  872. WPA_DRIVER_FLAGS_DEAUTH_TX_STATUS ? 2 : 0, 0,
  873. ap_sta_deauth_cb_timeout, hapd, sta);
  874. }
  875. void ap_sta_deauth_cb(struct hostapd_data *hapd, struct sta_info *sta)
  876. {
  877. if (!(sta->flags & WLAN_STA_PENDING_DEAUTH_CB)) {
  878. wpa_printf(MSG_DEBUG, "Ignore deauth cb for test frame");
  879. return;
  880. }
  881. sta->flags &= ~WLAN_STA_PENDING_DEAUTH_CB;
  882. eloop_cancel_timeout(ap_sta_deauth_cb_timeout, hapd, sta);
  883. ap_sta_deauth_cb_timeout(hapd, sta);
  884. }
  885. void ap_sta_disassoc_cb(struct hostapd_data *hapd, struct sta_info *sta)
  886. {
  887. if (!(sta->flags & WLAN_STA_PENDING_DISASSOC_CB)) {
  888. wpa_printf(MSG_DEBUG, "Ignore disassoc cb for test frame");
  889. return;
  890. }
  891. sta->flags &= ~WLAN_STA_PENDING_DISASSOC_CB;
  892. eloop_cancel_timeout(ap_sta_disassoc_cb_timeout, hapd, sta);
  893. ap_sta_disassoc_cb_timeout(hapd, sta);
  894. }
  895. int ap_sta_flags_txt(u32 flags, char *buf, size_t buflen)
  896. {
  897. int res;
  898. buf[0] = '\0';
  899. res = os_snprintf(buf, buflen, "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
  900. (flags & WLAN_STA_AUTH ? "[AUTH]" : ""),
  901. (flags & WLAN_STA_ASSOC ? "[ASSOC]" : ""),
  902. (flags & WLAN_STA_AUTHORIZED ? "[AUTHORIZED]" : ""),
  903. (flags & WLAN_STA_PENDING_POLL ? "[PENDING_POLL" :
  904. ""),
  905. (flags & WLAN_STA_SHORT_PREAMBLE ?
  906. "[SHORT_PREAMBLE]" : ""),
  907. (flags & WLAN_STA_PREAUTH ? "[PREAUTH]" : ""),
  908. (flags & WLAN_STA_WMM ? "[WMM]" : ""),
  909. (flags & WLAN_STA_MFP ? "[MFP]" : ""),
  910. (flags & WLAN_STA_WPS ? "[WPS]" : ""),
  911. (flags & WLAN_STA_MAYBE_WPS ? "[MAYBE_WPS]" : ""),
  912. (flags & WLAN_STA_WDS ? "[WDS]" : ""),
  913. (flags & WLAN_STA_NONERP ? "[NonERP]" : ""),
  914. (flags & WLAN_STA_WPS2 ? "[WPS2]" : ""),
  915. (flags & WLAN_STA_GAS ? "[GAS]" : ""),
  916. (flags & WLAN_STA_VHT ? "[VHT]" : ""),
  917. (flags & WLAN_STA_WNM_SLEEP_MODE ?
  918. "[WNM_SLEEP_MODE]" : ""));
  919. return res;
  920. }