sme.c 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990
  1. /*
  2. * wpa_supplicant - SME
  3. * Copyright (c) 2009-2014, 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 "includes.h"
  9. #include "common.h"
  10. #include "utils/eloop.h"
  11. #include "common/ieee802_11_defs.h"
  12. #include "common/ieee802_11_common.h"
  13. #include "eapol_supp/eapol_supp_sm.h"
  14. #include "common/wpa_common.h"
  15. #include "common/sae.h"
  16. #include "rsn_supp/wpa.h"
  17. #include "rsn_supp/pmksa_cache.h"
  18. #include "config.h"
  19. #include "wpa_supplicant_i.h"
  20. #include "driver_i.h"
  21. #include "wpas_glue.h"
  22. #include "wps_supplicant.h"
  23. #include "p2p_supplicant.h"
  24. #include "notify.h"
  25. #include "bss.h"
  26. #include "scan.h"
  27. #include "sme.h"
  28. #include "hs20_supplicant.h"
  29. #define SME_AUTH_TIMEOUT 5
  30. #define SME_ASSOC_TIMEOUT 5
  31. static void sme_auth_timer(void *eloop_ctx, void *timeout_ctx);
  32. static void sme_assoc_timer(void *eloop_ctx, void *timeout_ctx);
  33. static void sme_obss_scan_timeout(void *eloop_ctx, void *timeout_ctx);
  34. #ifdef CONFIG_IEEE80211W
  35. static void sme_stop_sa_query(struct wpa_supplicant *wpa_s);
  36. #endif /* CONFIG_IEEE80211W */
  37. #ifdef CONFIG_SAE
  38. static int index_within_array(const int *array, int idx)
  39. {
  40. int i;
  41. for (i = 0; i < idx; i++) {
  42. if (array[i] <= 0)
  43. return 0;
  44. }
  45. return 1;
  46. }
  47. static int sme_set_sae_group(struct wpa_supplicant *wpa_s)
  48. {
  49. int *groups = wpa_s->conf->sae_groups;
  50. int default_groups[] = { 19, 20, 21, 25, 26, 0 };
  51. if (!groups || groups[0] <= 0)
  52. groups = default_groups;
  53. /* Configuration may have changed, so validate current index */
  54. if (!index_within_array(groups, wpa_s->sme.sae_group_index))
  55. return -1;
  56. for (;;) {
  57. int group = groups[wpa_s->sme.sae_group_index];
  58. if (group <= 0)
  59. break;
  60. if (sae_set_group(&wpa_s->sme.sae, group) == 0) {
  61. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected SAE group %d",
  62. wpa_s->sme.sae.group);
  63. return 0;
  64. }
  65. wpa_s->sme.sae_group_index++;
  66. }
  67. return -1;
  68. }
  69. static struct wpabuf * sme_auth_build_sae_commit(struct wpa_supplicant *wpa_s,
  70. struct wpa_ssid *ssid,
  71. const u8 *bssid)
  72. {
  73. struct wpabuf *buf;
  74. size_t len;
  75. const char *password;
  76. #ifdef CONFIG_TESTING_OPTIONS
  77. if (wpa_s->sae_commit_override) {
  78. wpa_printf(MSG_DEBUG, "SAE: TESTING - commit override");
  79. buf = wpabuf_alloc(4 + wpabuf_len(wpa_s->sae_commit_override));
  80. if (!buf)
  81. return NULL;
  82. wpabuf_put_le16(buf, 1); /* Transaction seq# */
  83. wpabuf_put_le16(buf, WLAN_STATUS_SUCCESS);
  84. wpabuf_put_buf(buf, wpa_s->sae_commit_override);
  85. return buf;
  86. }
  87. #endif /* CONFIG_TESTING_OPTIONS */
  88. password = ssid->sae_password;
  89. if (!password)
  90. password = ssid->passphrase;
  91. if (!password) {
  92. wpa_printf(MSG_DEBUG, "SAE: No password available");
  93. return NULL;
  94. }
  95. if (sme_set_sae_group(wpa_s) < 0) {
  96. wpa_printf(MSG_DEBUG, "SAE: Failed to select group");
  97. return NULL;
  98. }
  99. if (sae_prepare_commit(wpa_s->own_addr, bssid,
  100. (u8 *) password, os_strlen(password),
  101. &wpa_s->sme.sae) < 0) {
  102. wpa_printf(MSG_DEBUG, "SAE: Could not pick PWE");
  103. return NULL;
  104. }
  105. len = wpa_s->sme.sae_token ? wpabuf_len(wpa_s->sme.sae_token) : 0;
  106. buf = wpabuf_alloc(4 + SAE_COMMIT_MAX_LEN + len);
  107. if (buf == NULL)
  108. return NULL;
  109. wpabuf_put_le16(buf, 1); /* Transaction seq# */
  110. wpabuf_put_le16(buf, WLAN_STATUS_SUCCESS);
  111. sae_write_commit(&wpa_s->sme.sae, buf, wpa_s->sme.sae_token);
  112. return buf;
  113. }
  114. static struct wpabuf * sme_auth_build_sae_confirm(struct wpa_supplicant *wpa_s)
  115. {
  116. struct wpabuf *buf;
  117. buf = wpabuf_alloc(4 + SAE_CONFIRM_MAX_LEN);
  118. if (buf == NULL)
  119. return NULL;
  120. wpabuf_put_le16(buf, 2); /* Transaction seq# */
  121. wpabuf_put_le16(buf, WLAN_STATUS_SUCCESS);
  122. sae_write_confirm(&wpa_s->sme.sae, buf);
  123. return buf;
  124. }
  125. #endif /* CONFIG_SAE */
  126. /**
  127. * sme_auth_handle_rrm - Handle RRM aspects of current authentication attempt
  128. * @wpa_s: Pointer to wpa_supplicant data
  129. * @bss: Pointer to the bss which is the target of authentication attempt
  130. */
  131. static void sme_auth_handle_rrm(struct wpa_supplicant *wpa_s,
  132. struct wpa_bss *bss)
  133. {
  134. const u8 rrm_ie_len = 5;
  135. u8 *pos;
  136. const u8 *rrm_ie;
  137. wpa_s->rrm.rrm_used = 0;
  138. wpa_printf(MSG_DEBUG,
  139. "RRM: Determining whether RRM can be used - device support: 0x%x",
  140. wpa_s->drv_rrm_flags);
  141. rrm_ie = wpa_bss_get_ie(bss, WLAN_EID_RRM_ENABLED_CAPABILITIES);
  142. if (!rrm_ie || !(bss->caps & IEEE80211_CAP_RRM)) {
  143. wpa_printf(MSG_DEBUG, "RRM: No RRM in network");
  144. return;
  145. }
  146. if (!((wpa_s->drv_rrm_flags &
  147. WPA_DRIVER_FLAGS_DS_PARAM_SET_IE_IN_PROBES) &&
  148. (wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_QUIET)) &&
  149. !(wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_SUPPORT_RRM)) {
  150. wpa_printf(MSG_DEBUG,
  151. "RRM: Insufficient RRM support in driver - do not use RRM");
  152. return;
  153. }
  154. if (sizeof(wpa_s->sme.assoc_req_ie) <
  155. wpa_s->sme.assoc_req_ie_len + rrm_ie_len + 2) {
  156. wpa_printf(MSG_INFO,
  157. "RRM: Unable to use RRM, no room for RRM IE");
  158. return;
  159. }
  160. wpa_printf(MSG_DEBUG, "RRM: Adding RRM IE to Association Request");
  161. pos = wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len;
  162. os_memset(pos, 0, 2 + rrm_ie_len);
  163. *pos++ = WLAN_EID_RRM_ENABLED_CAPABILITIES;
  164. *pos++ = rrm_ie_len;
  165. /* Set supported capabilites flags */
  166. if (wpa_s->drv_rrm_flags & WPA_DRIVER_FLAGS_TX_POWER_INSERTION)
  167. *pos |= WLAN_RRM_CAPS_LINK_MEASUREMENT;
  168. *pos |= WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE |
  169. WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE |
  170. WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
  171. if (wpa_s->lci)
  172. pos[1] |= WLAN_RRM_CAPS_LCI_MEASUREMENT;
  173. wpa_s->sme.assoc_req_ie_len += rrm_ie_len + 2;
  174. wpa_s->rrm.rrm_used = 1;
  175. }
  176. static void sme_send_authentication(struct wpa_supplicant *wpa_s,
  177. struct wpa_bss *bss, struct wpa_ssid *ssid,
  178. int start)
  179. {
  180. struct wpa_driver_auth_params params;
  181. struct wpa_ssid *old_ssid;
  182. #ifdef CONFIG_IEEE80211R
  183. const u8 *ie;
  184. #endif /* CONFIG_IEEE80211R */
  185. #if defined(CONFIG_IEEE80211R) || defined(CONFIG_FILS)
  186. const u8 *md = NULL;
  187. #endif /* CONFIG_IEEE80211R || CONFIG_FILS */
  188. int i, bssid_changed;
  189. struct wpabuf *resp = NULL;
  190. u8 ext_capab[18];
  191. int ext_capab_len;
  192. int skip_auth;
  193. if (bss == NULL) {
  194. wpa_msg(wpa_s, MSG_ERROR, "SME: No scan result available for "
  195. "the network");
  196. wpas_connect_work_done(wpa_s);
  197. return;
  198. }
  199. skip_auth = wpa_s->conf->reassoc_same_bss_optim &&
  200. wpa_s->reassoc_same_bss;
  201. wpa_s->current_bss = bss;
  202. os_memset(&params, 0, sizeof(params));
  203. wpa_s->reassociate = 0;
  204. params.freq = bss->freq;
  205. params.bssid = bss->bssid;
  206. params.ssid = bss->ssid;
  207. params.ssid_len = bss->ssid_len;
  208. params.p2p = ssid->p2p_group;
  209. if (wpa_s->sme.ssid_len != params.ssid_len ||
  210. os_memcmp(wpa_s->sme.ssid, params.ssid, params.ssid_len) != 0)
  211. wpa_s->sme.prev_bssid_set = 0;
  212. wpa_s->sme.freq = params.freq;
  213. os_memcpy(wpa_s->sme.ssid, params.ssid, params.ssid_len);
  214. wpa_s->sme.ssid_len = params.ssid_len;
  215. params.auth_alg = WPA_AUTH_ALG_OPEN;
  216. #ifdef IEEE8021X_EAPOL
  217. if (ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) {
  218. if (ssid->leap) {
  219. if (ssid->non_leap == 0)
  220. params.auth_alg = WPA_AUTH_ALG_LEAP;
  221. else
  222. params.auth_alg |= WPA_AUTH_ALG_LEAP;
  223. }
  224. }
  225. #endif /* IEEE8021X_EAPOL */
  226. wpa_dbg(wpa_s, MSG_DEBUG, "Automatic auth_alg selection: 0x%x",
  227. params.auth_alg);
  228. if (ssid->auth_alg) {
  229. params.auth_alg = ssid->auth_alg;
  230. wpa_dbg(wpa_s, MSG_DEBUG, "Overriding auth_alg selection: "
  231. "0x%x", params.auth_alg);
  232. }
  233. #ifdef CONFIG_SAE
  234. wpa_s->sme.sae_pmksa_caching = 0;
  235. if (wpa_key_mgmt_sae(ssid->key_mgmt)) {
  236. const u8 *rsn;
  237. struct wpa_ie_data ied;
  238. rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
  239. if (!rsn) {
  240. wpa_dbg(wpa_s, MSG_DEBUG,
  241. "SAE enabled, but target BSS does not advertise RSN");
  242. } else if (wpa_parse_wpa_ie(rsn, 2 + rsn[1], &ied) == 0 &&
  243. wpa_key_mgmt_sae(ied.key_mgmt)) {
  244. wpa_dbg(wpa_s, MSG_DEBUG, "Using SAE auth_alg");
  245. params.auth_alg = WPA_AUTH_ALG_SAE;
  246. } else {
  247. wpa_dbg(wpa_s, MSG_DEBUG,
  248. "SAE enabled, but target BSS does not advertise SAE AKM for RSN");
  249. }
  250. }
  251. #endif /* CONFIG_SAE */
  252. for (i = 0; i < NUM_WEP_KEYS; i++) {
  253. if (ssid->wep_key_len[i])
  254. params.wep_key[i] = ssid->wep_key[i];
  255. params.wep_key_len[i] = ssid->wep_key_len[i];
  256. }
  257. params.wep_tx_keyidx = ssid->wep_tx_keyidx;
  258. bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
  259. os_memset(wpa_s->bssid, 0, ETH_ALEN);
  260. os_memcpy(wpa_s->pending_bssid, bss->bssid, ETH_ALEN);
  261. if (bssid_changed)
  262. wpas_notify_bssid_changed(wpa_s);
  263. if ((wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE) ||
  264. wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
  265. wpa_key_mgmt_wpa(ssid->key_mgmt)) {
  266. int try_opportunistic;
  267. const u8 *cache_id = NULL;
  268. try_opportunistic = (ssid->proactive_key_caching < 0 ?
  269. wpa_s->conf->okc :
  270. ssid->proactive_key_caching) &&
  271. (ssid->proto & WPA_PROTO_RSN);
  272. #ifdef CONFIG_FILS
  273. if (wpa_key_mgmt_fils(ssid->key_mgmt))
  274. cache_id = wpa_bss_get_fils_cache_id(bss);
  275. #endif /* CONFIG_FILS */
  276. if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
  277. wpa_s->current_ssid,
  278. try_opportunistic, cache_id) == 0)
  279. eapol_sm_notify_pmkid_attempt(wpa_s->eapol);
  280. wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
  281. if (wpa_supplicant_set_suites(wpa_s, bss, ssid,
  282. wpa_s->sme.assoc_req_ie,
  283. &wpa_s->sme.assoc_req_ie_len)) {
  284. wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
  285. "key management and encryption suites");
  286. wpas_connect_work_done(wpa_s);
  287. return;
  288. }
  289. } else if ((ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X_NO_WPA) &&
  290. wpa_key_mgmt_wpa_ieee8021x(ssid->key_mgmt)) {
  291. /*
  292. * Both WPA and non-WPA IEEE 802.1X enabled in configuration -
  293. * use non-WPA since the scan results did not indicate that the
  294. * AP is using WPA or WPA2.
  295. */
  296. wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
  297. wpa_s->sme.assoc_req_ie_len = 0;
  298. } else if (wpa_key_mgmt_wpa_any(ssid->key_mgmt)) {
  299. wpa_s->sme.assoc_req_ie_len = sizeof(wpa_s->sme.assoc_req_ie);
  300. if (wpa_supplicant_set_suites(wpa_s, NULL, ssid,
  301. wpa_s->sme.assoc_req_ie,
  302. &wpa_s->sme.assoc_req_ie_len)) {
  303. wpa_msg(wpa_s, MSG_WARNING, "SME: Failed to set WPA "
  304. "key management and encryption suites (no "
  305. "scan results)");
  306. wpas_connect_work_done(wpa_s);
  307. return;
  308. }
  309. #ifdef CONFIG_WPS
  310. } else if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
  311. struct wpabuf *wps_ie;
  312. wps_ie = wps_build_assoc_req_ie(wpas_wps_get_req_type(ssid));
  313. if (wps_ie && wpabuf_len(wps_ie) <=
  314. sizeof(wpa_s->sme.assoc_req_ie)) {
  315. wpa_s->sme.assoc_req_ie_len = wpabuf_len(wps_ie);
  316. os_memcpy(wpa_s->sme.assoc_req_ie, wpabuf_head(wps_ie),
  317. wpa_s->sme.assoc_req_ie_len);
  318. } else
  319. wpa_s->sme.assoc_req_ie_len = 0;
  320. wpabuf_free(wps_ie);
  321. wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
  322. #endif /* CONFIG_WPS */
  323. } else {
  324. wpa_supplicant_set_non_wpa_policy(wpa_s, ssid);
  325. wpa_s->sme.assoc_req_ie_len = 0;
  326. }
  327. #ifdef CONFIG_IEEE80211R
  328. ie = wpa_bss_get_ie(bss, WLAN_EID_MOBILITY_DOMAIN);
  329. if (ie && ie[1] >= MOBILITY_DOMAIN_ID_LEN)
  330. md = ie + 2;
  331. wpa_sm_set_ft_params(wpa_s->wpa, ie, ie ? 2 + ie[1] : 0);
  332. if (md) {
  333. /* Prepare for the next transition */
  334. wpa_ft_prepare_auth_request(wpa_s->wpa, ie);
  335. }
  336. if (md && !wpa_key_mgmt_ft(ssid->key_mgmt))
  337. md = NULL;
  338. if (md) {
  339. wpa_dbg(wpa_s, MSG_DEBUG, "SME: FT mobility domain %02x%02x",
  340. md[0], md[1]);
  341. if (wpa_s->sme.assoc_req_ie_len + 5 <
  342. sizeof(wpa_s->sme.assoc_req_ie)) {
  343. struct rsn_mdie *mdie;
  344. u8 *pos = wpa_s->sme.assoc_req_ie +
  345. wpa_s->sme.assoc_req_ie_len;
  346. *pos++ = WLAN_EID_MOBILITY_DOMAIN;
  347. *pos++ = sizeof(*mdie);
  348. mdie = (struct rsn_mdie *) pos;
  349. os_memcpy(mdie->mobility_domain, md,
  350. MOBILITY_DOMAIN_ID_LEN);
  351. mdie->ft_capab = md[MOBILITY_DOMAIN_ID_LEN];
  352. wpa_s->sme.assoc_req_ie_len += 5;
  353. }
  354. if (wpa_s->sme.ft_used &&
  355. os_memcmp(md, wpa_s->sme.mobility_domain, 2) == 0 &&
  356. wpa_sm_has_ptk(wpa_s->wpa)) {
  357. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying to use FT "
  358. "over-the-air");
  359. params.auth_alg = WPA_AUTH_ALG_FT;
  360. params.ie = wpa_s->sme.ft_ies;
  361. params.ie_len = wpa_s->sme.ft_ies_len;
  362. }
  363. }
  364. #endif /* CONFIG_IEEE80211R */
  365. #ifdef CONFIG_IEEE80211W
  366. wpa_s->sme.mfp = wpas_get_ssid_pmf(wpa_s, ssid);
  367. if (wpa_s->sme.mfp != NO_MGMT_FRAME_PROTECTION) {
  368. const u8 *rsn = wpa_bss_get_ie(bss, WLAN_EID_RSN);
  369. struct wpa_ie_data _ie;
  370. if (rsn && wpa_parse_wpa_ie(rsn, 2 + rsn[1], &_ie) == 0 &&
  371. _ie.capabilities &
  372. (WPA_CAPABILITY_MFPC | WPA_CAPABILITY_MFPR)) {
  373. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Selected AP supports "
  374. "MFP: require MFP");
  375. wpa_s->sme.mfp = MGMT_FRAME_PROTECTION_REQUIRED;
  376. }
  377. }
  378. #endif /* CONFIG_IEEE80211W */
  379. #ifdef CONFIG_P2P
  380. if (wpa_s->global->p2p) {
  381. u8 *pos;
  382. size_t len;
  383. int res;
  384. pos = wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len;
  385. len = sizeof(wpa_s->sme.assoc_req_ie) -
  386. wpa_s->sme.assoc_req_ie_len;
  387. res = wpas_p2p_assoc_req_ie(wpa_s, bss, pos, len,
  388. ssid->p2p_group);
  389. if (res >= 0)
  390. wpa_s->sme.assoc_req_ie_len += res;
  391. }
  392. #endif /* CONFIG_P2P */
  393. #ifdef CONFIG_FST
  394. if (wpa_s->fst_ies) {
  395. int fst_ies_len = wpabuf_len(wpa_s->fst_ies);
  396. if (wpa_s->sme.assoc_req_ie_len + fst_ies_len <=
  397. sizeof(wpa_s->sme.assoc_req_ie)) {
  398. os_memcpy(wpa_s->sme.assoc_req_ie +
  399. wpa_s->sme.assoc_req_ie_len,
  400. wpabuf_head(wpa_s->fst_ies),
  401. fst_ies_len);
  402. wpa_s->sme.assoc_req_ie_len += fst_ies_len;
  403. }
  404. }
  405. #endif /* CONFIG_FST */
  406. sme_auth_handle_rrm(wpa_s, bss);
  407. wpa_s->sme.assoc_req_ie_len += wpas_supp_op_class_ie(
  408. wpa_s, bss->freq,
  409. wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
  410. sizeof(wpa_s->sme.assoc_req_ie) - wpa_s->sme.assoc_req_ie_len);
  411. if (params.p2p)
  412. wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_CLIENT);
  413. else
  414. wpa_drv_get_ext_capa(wpa_s, WPA_IF_STATION);
  415. ext_capab_len = wpas_build_ext_capab(wpa_s, ext_capab,
  416. sizeof(ext_capab));
  417. if (ext_capab_len > 0) {
  418. u8 *pos = wpa_s->sme.assoc_req_ie;
  419. if (wpa_s->sme.assoc_req_ie_len > 0 && pos[0] == WLAN_EID_RSN)
  420. pos += 2 + pos[1];
  421. os_memmove(pos + ext_capab_len, pos,
  422. wpa_s->sme.assoc_req_ie_len -
  423. (pos - wpa_s->sme.assoc_req_ie));
  424. wpa_s->sme.assoc_req_ie_len += ext_capab_len;
  425. os_memcpy(pos, ext_capab, ext_capab_len);
  426. }
  427. #ifdef CONFIG_HS20
  428. if (is_hs20_network(wpa_s, ssid, bss)) {
  429. struct wpabuf *hs20;
  430. hs20 = wpabuf_alloc(20);
  431. if (hs20) {
  432. int pps_mo_id = hs20_get_pps_mo_id(wpa_s, ssid);
  433. size_t len;
  434. wpas_hs20_add_indication(hs20, pps_mo_id);
  435. len = sizeof(wpa_s->sme.assoc_req_ie) -
  436. wpa_s->sme.assoc_req_ie_len;
  437. if (wpabuf_len(hs20) <= len) {
  438. os_memcpy(wpa_s->sme.assoc_req_ie +
  439. wpa_s->sme.assoc_req_ie_len,
  440. wpabuf_head(hs20), wpabuf_len(hs20));
  441. wpa_s->sme.assoc_req_ie_len += wpabuf_len(hs20);
  442. }
  443. wpabuf_free(hs20);
  444. }
  445. }
  446. #endif /* CONFIG_HS20 */
  447. if (wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ]) {
  448. struct wpabuf *buf = wpa_s->vendor_elem[VENDOR_ELEM_ASSOC_REQ];
  449. size_t len;
  450. len = sizeof(wpa_s->sme.assoc_req_ie) -
  451. wpa_s->sme.assoc_req_ie_len;
  452. if (wpabuf_len(buf) <= len) {
  453. os_memcpy(wpa_s->sme.assoc_req_ie +
  454. wpa_s->sme.assoc_req_ie_len,
  455. wpabuf_head(buf), wpabuf_len(buf));
  456. wpa_s->sme.assoc_req_ie_len += wpabuf_len(buf);
  457. }
  458. }
  459. #ifdef CONFIG_MBO
  460. if (wpa_bss_get_vendor_ie(bss, MBO_IE_VENDOR_TYPE)) {
  461. int len;
  462. len = wpas_mbo_ie(wpa_s, wpa_s->sme.assoc_req_ie +
  463. wpa_s->sme.assoc_req_ie_len,
  464. sizeof(wpa_s->sme.assoc_req_ie) -
  465. wpa_s->sme.assoc_req_ie_len);
  466. if (len >= 0)
  467. wpa_s->sme.assoc_req_ie_len += len;
  468. }
  469. #endif /* CONFIG_MBO */
  470. #ifdef CONFIG_SAE
  471. if (!skip_auth && params.auth_alg == WPA_AUTH_ALG_SAE &&
  472. pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid, ssid, 0,
  473. NULL) == 0) {
  474. wpa_dbg(wpa_s, MSG_DEBUG,
  475. "PMKSA cache entry found - try to use PMKSA caching instead of new SAE authentication");
  476. params.auth_alg = WPA_AUTH_ALG_OPEN;
  477. wpa_s->sme.sae_pmksa_caching = 1;
  478. }
  479. if (!skip_auth && params.auth_alg == WPA_AUTH_ALG_SAE) {
  480. if (start)
  481. resp = sme_auth_build_sae_commit(wpa_s, ssid,
  482. bss->bssid);
  483. else
  484. resp = sme_auth_build_sae_confirm(wpa_s);
  485. if (resp == NULL) {
  486. wpas_connection_failed(wpa_s, bss->bssid);
  487. return;
  488. }
  489. params.auth_data = wpabuf_head(resp);
  490. params.auth_data_len = wpabuf_len(resp);
  491. wpa_s->sme.sae.state = start ? SAE_COMMITTED : SAE_CONFIRMED;
  492. }
  493. #endif /* CONFIG_SAE */
  494. old_ssid = wpa_s->current_ssid;
  495. wpa_s->current_ssid = ssid;
  496. wpa_supplicant_rsn_supp_set_config(wpa_s, wpa_s->current_ssid);
  497. wpa_supplicant_initiate_eapol(wpa_s);
  498. #ifdef CONFIG_FILS
  499. /* TODO: FILS operations can in some cases be done between different
  500. * network_ctx (i.e., same credentials can be used with multiple
  501. * networks). */
  502. if (params.auth_alg == WPA_AUTH_ALG_OPEN &&
  503. wpa_key_mgmt_fils(ssid->key_mgmt)) {
  504. const u8 *indic;
  505. u16 fils_info;
  506. /*
  507. * Check FILS Indication element (FILS Information field) bits
  508. * indicating supported authentication algorithms against local
  509. * configuration (ssid->fils_dh_group). Try to use FILS
  510. * authentication only if the AP supports the combination in the
  511. * network profile. */
  512. indic = wpa_bss_get_ie(bss, WLAN_EID_FILS_INDICATION);
  513. if (!indic || indic[1] < 2) {
  514. wpa_printf(MSG_DEBUG, "SME: " MACSTR
  515. " does not include FILS Indication element - cannot use FILS authentication with it",
  516. MAC2STR(bss->bssid));
  517. goto no_fils;
  518. }
  519. fils_info = WPA_GET_LE16(indic + 2);
  520. if (ssid->fils_dh_group == 0 && !(fils_info & BIT(9))) {
  521. wpa_printf(MSG_DEBUG, "SME: " MACSTR
  522. " does not support FILS SK without PFS - cannot use FILS authentication with it",
  523. MAC2STR(bss->bssid));
  524. goto no_fils;
  525. }
  526. if (ssid->fils_dh_group != 0 && !(fils_info & BIT(10))) {
  527. wpa_printf(MSG_DEBUG, "SME: " MACSTR
  528. " does not support FILS SK with PFS - cannot use FILS authentication with it",
  529. MAC2STR(bss->bssid));
  530. goto no_fils;
  531. }
  532. if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
  533. ssid, 0,
  534. wpa_bss_get_fils_cache_id(bss)) ==
  535. 0)
  536. wpa_printf(MSG_DEBUG,
  537. "SME: Try to use FILS with PMKSA caching");
  538. resp = fils_build_auth(wpa_s->wpa, ssid->fils_dh_group, md);
  539. if (resp) {
  540. int auth_alg;
  541. if (ssid->fils_dh_group)
  542. wpa_printf(MSG_DEBUG,
  543. "SME: Try to use FILS SK authentication with PFS (DH Group %u)",
  544. ssid->fils_dh_group);
  545. else
  546. wpa_printf(MSG_DEBUG,
  547. "SME: Try to use FILS SK authentication without PFS");
  548. auth_alg = ssid->fils_dh_group ?
  549. WPA_AUTH_ALG_FILS_SK_PFS : WPA_AUTH_ALG_FILS;
  550. params.auth_alg = auth_alg;
  551. params.auth_data = wpabuf_head(resp);
  552. params.auth_data_len = wpabuf_len(resp);
  553. wpa_s->sme.auth_alg = auth_alg;
  554. }
  555. }
  556. no_fils:
  557. #endif /* CONFIG_FILS */
  558. wpa_supplicant_cancel_sched_scan(wpa_s);
  559. wpa_supplicant_cancel_scan(wpa_s);
  560. wpa_msg(wpa_s, MSG_INFO, "SME: Trying to authenticate with " MACSTR
  561. " (SSID='%s' freq=%d MHz)", MAC2STR(params.bssid),
  562. wpa_ssid_txt(params.ssid, params.ssid_len), params.freq);
  563. eapol_sm_notify_portValid(wpa_s->eapol, FALSE);
  564. wpa_clear_keys(wpa_s, bss->bssid);
  565. wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
  566. if (old_ssid != wpa_s->current_ssid)
  567. wpas_notify_network_changed(wpa_s);
  568. #ifdef CONFIG_HS20
  569. hs20_configure_frame_filters(wpa_s);
  570. #endif /* CONFIG_HS20 */
  571. #ifdef CONFIG_P2P
  572. /*
  573. * If multi-channel concurrency is not supported, check for any
  574. * frequency conflict. In case of any frequency conflict, remove the
  575. * least prioritized connection.
  576. */
  577. if (wpa_s->num_multichan_concurrent < 2) {
  578. int freq, num;
  579. num = get_shared_radio_freqs(wpa_s, &freq, 1);
  580. if (num > 0 && freq > 0 && freq != params.freq) {
  581. wpa_printf(MSG_DEBUG,
  582. "Conflicting frequency found (%d != %d)",
  583. freq, params.freq);
  584. if (wpas_p2p_handle_frequency_conflicts(wpa_s,
  585. params.freq,
  586. ssid) < 0) {
  587. wpas_connection_failed(wpa_s, bss->bssid);
  588. wpa_supplicant_mark_disassoc(wpa_s);
  589. wpabuf_free(resp);
  590. wpas_connect_work_done(wpa_s);
  591. return;
  592. }
  593. }
  594. }
  595. #endif /* CONFIG_P2P */
  596. if (skip_auth) {
  597. wpa_msg(wpa_s, MSG_DEBUG,
  598. "SME: Skip authentication step on reassoc-to-same-BSS");
  599. wpabuf_free(resp);
  600. sme_associate(wpa_s, ssid->mode, bss->bssid, WLAN_AUTH_OPEN);
  601. return;
  602. }
  603. wpa_s->sme.auth_alg = params.auth_alg;
  604. if (wpa_drv_authenticate(wpa_s, &params) < 0) {
  605. wpa_msg(wpa_s, MSG_INFO, "SME: Authentication request to the "
  606. "driver failed");
  607. wpas_connection_failed(wpa_s, bss->bssid);
  608. wpa_supplicant_mark_disassoc(wpa_s);
  609. wpabuf_free(resp);
  610. wpas_connect_work_done(wpa_s);
  611. return;
  612. }
  613. eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
  614. NULL);
  615. /*
  616. * Association will be started based on the authentication event from
  617. * the driver.
  618. */
  619. wpabuf_free(resp);
  620. }
  621. static void sme_auth_start_cb(struct wpa_radio_work *work, int deinit)
  622. {
  623. struct wpa_connect_work *cwork = work->ctx;
  624. struct wpa_supplicant *wpa_s = work->wpa_s;
  625. if (deinit) {
  626. if (work->started)
  627. wpa_s->connect_work = NULL;
  628. wpas_connect_work_free(cwork);
  629. return;
  630. }
  631. wpa_s->connect_work = work;
  632. if (cwork->bss_removed ||
  633. !wpas_valid_bss_ssid(wpa_s, cwork->bss, cwork->ssid) ||
  634. wpas_network_disabled(wpa_s, cwork->ssid)) {
  635. wpa_dbg(wpa_s, MSG_DEBUG, "SME: BSS/SSID entry for authentication not valid anymore - drop connection attempt");
  636. wpas_connect_work_done(wpa_s);
  637. return;
  638. }
  639. /* Starting new connection, so clear the possibly used WPA IE from the
  640. * previous association. */
  641. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
  642. sme_send_authentication(wpa_s, cwork->bss, cwork->ssid, 1);
  643. }
  644. void sme_authenticate(struct wpa_supplicant *wpa_s,
  645. struct wpa_bss *bss, struct wpa_ssid *ssid)
  646. {
  647. struct wpa_connect_work *cwork;
  648. if (bss == NULL || ssid == NULL)
  649. return;
  650. if (wpa_s->connect_work) {
  651. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reject sme_authenticate() call since connect_work exist");
  652. return;
  653. }
  654. if (radio_work_pending(wpa_s, "sme-connect")) {
  655. /*
  656. * The previous sme-connect work might no longer be valid due to
  657. * the fact that the BSS list was updated. In addition, it makes
  658. * sense to adhere to the 'newer' decision.
  659. */
  660. wpa_dbg(wpa_s, MSG_DEBUG,
  661. "SME: Remove previous pending sme-connect");
  662. radio_remove_works(wpa_s, "sme-connect", 0);
  663. }
  664. wpas_abort_ongoing_scan(wpa_s);
  665. cwork = os_zalloc(sizeof(*cwork));
  666. if (cwork == NULL)
  667. return;
  668. cwork->bss = bss;
  669. cwork->ssid = ssid;
  670. cwork->sme = 1;
  671. #ifdef CONFIG_SAE
  672. wpa_s->sme.sae.state = SAE_NOTHING;
  673. wpa_s->sme.sae.send_confirm = 0;
  674. wpa_s->sme.sae_group_index = 0;
  675. #endif /* CONFIG_SAE */
  676. if (radio_add_work(wpa_s, bss->freq, "sme-connect", 1,
  677. sme_auth_start_cb, cwork) < 0)
  678. wpas_connect_work_free(cwork);
  679. }
  680. #ifdef CONFIG_SAE
  681. static int sme_sae_auth(struct wpa_supplicant *wpa_s, u16 auth_transaction,
  682. u16 status_code, const u8 *data, size_t len)
  683. {
  684. int *groups;
  685. wpa_dbg(wpa_s, MSG_DEBUG, "SME: SAE authentication transaction %u "
  686. "status code %u", auth_transaction, status_code);
  687. if (auth_transaction == 1 &&
  688. status_code == WLAN_STATUS_ANTI_CLOGGING_TOKEN_REQ &&
  689. wpa_s->sme.sae.state == SAE_COMMITTED &&
  690. wpa_s->current_bss && wpa_s->current_ssid) {
  691. int default_groups[] = { 19, 20, 21, 25, 26, 0 };
  692. u16 group;
  693. groups = wpa_s->conf->sae_groups;
  694. if (!groups || groups[0] <= 0)
  695. groups = default_groups;
  696. if (len < sizeof(le16)) {
  697. wpa_dbg(wpa_s, MSG_DEBUG,
  698. "SME: Too short SAE anti-clogging token request");
  699. return -1;
  700. }
  701. group = WPA_GET_LE16(data);
  702. wpa_dbg(wpa_s, MSG_DEBUG,
  703. "SME: SAE anti-clogging token requested (group %u)",
  704. group);
  705. if (sae_group_allowed(&wpa_s->sme.sae, groups, group) !=
  706. WLAN_STATUS_SUCCESS) {
  707. wpa_dbg(wpa_s, MSG_ERROR,
  708. "SME: SAE group %u of anti-clogging request is invalid",
  709. group);
  710. return -1;
  711. }
  712. wpabuf_free(wpa_s->sme.sae_token);
  713. wpa_s->sme.sae_token = wpabuf_alloc_copy(data + sizeof(le16),
  714. len - sizeof(le16));
  715. sme_send_authentication(wpa_s, wpa_s->current_bss,
  716. wpa_s->current_ssid, 1);
  717. return 0;
  718. }
  719. if (auth_transaction == 1 &&
  720. status_code == WLAN_STATUS_FINITE_CYCLIC_GROUP_NOT_SUPPORTED &&
  721. wpa_s->sme.sae.state == SAE_COMMITTED &&
  722. wpa_s->current_bss && wpa_s->current_ssid) {
  723. wpa_dbg(wpa_s, MSG_DEBUG, "SME: SAE group not supported");
  724. wpa_s->sme.sae_group_index++;
  725. if (sme_set_sae_group(wpa_s) < 0)
  726. return -1; /* no other groups enabled */
  727. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Try next enabled SAE group");
  728. sme_send_authentication(wpa_s, wpa_s->current_bss,
  729. wpa_s->current_ssid, 1);
  730. return 0;
  731. }
  732. if (status_code != WLAN_STATUS_SUCCESS)
  733. return -1;
  734. if (auth_transaction == 1) {
  735. u16 res;
  736. groups = wpa_s->conf->sae_groups;
  737. wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE commit");
  738. if (wpa_s->current_bss == NULL ||
  739. wpa_s->current_ssid == NULL)
  740. return -1;
  741. if (wpa_s->sme.sae.state != SAE_COMMITTED)
  742. return -1;
  743. if (groups && groups[0] <= 0)
  744. groups = NULL;
  745. res = sae_parse_commit(&wpa_s->sme.sae, data, len, NULL, NULL,
  746. groups);
  747. if (res == SAE_SILENTLY_DISCARD) {
  748. wpa_printf(MSG_DEBUG,
  749. "SAE: Drop commit message due to reflection attack");
  750. return 0;
  751. }
  752. if (res != WLAN_STATUS_SUCCESS)
  753. return -1;
  754. if (sae_process_commit(&wpa_s->sme.sae) < 0) {
  755. wpa_printf(MSG_DEBUG, "SAE: Failed to process peer "
  756. "commit");
  757. return -1;
  758. }
  759. wpabuf_free(wpa_s->sme.sae_token);
  760. wpa_s->sme.sae_token = NULL;
  761. sme_send_authentication(wpa_s, wpa_s->current_bss,
  762. wpa_s->current_ssid, 0);
  763. return 0;
  764. } else if (auth_transaction == 2) {
  765. wpa_dbg(wpa_s, MSG_DEBUG, "SME SAE confirm");
  766. if (wpa_s->sme.sae.state != SAE_CONFIRMED)
  767. return -1;
  768. if (sae_check_confirm(&wpa_s->sme.sae, data, len) < 0)
  769. return -1;
  770. wpa_s->sme.sae.state = SAE_ACCEPTED;
  771. sae_clear_temp_data(&wpa_s->sme.sae);
  772. return 1;
  773. }
  774. return -1;
  775. }
  776. #endif /* CONFIG_SAE */
  777. void sme_event_auth(struct wpa_supplicant *wpa_s, union wpa_event_data *data)
  778. {
  779. struct wpa_ssid *ssid = wpa_s->current_ssid;
  780. if (ssid == NULL) {
  781. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
  782. "when network is not selected");
  783. return;
  784. }
  785. if (wpa_s->wpa_state != WPA_AUTHENTICATING) {
  786. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication event "
  787. "when not in authenticating state");
  788. return;
  789. }
  790. if (os_memcmp(wpa_s->pending_bssid, data->auth.peer, ETH_ALEN) != 0) {
  791. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Ignore authentication with "
  792. "unexpected peer " MACSTR,
  793. MAC2STR(data->auth.peer));
  794. return;
  795. }
  796. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication response: peer=" MACSTR
  797. " auth_type=%d auth_transaction=%d status_code=%d",
  798. MAC2STR(data->auth.peer), data->auth.auth_type,
  799. data->auth.auth_transaction, data->auth.status_code);
  800. wpa_hexdump(MSG_MSGDUMP, "SME: Authentication response IEs",
  801. data->auth.ies, data->auth.ies_len);
  802. eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
  803. #ifdef CONFIG_SAE
  804. if (data->auth.auth_type == WLAN_AUTH_SAE) {
  805. int res;
  806. res = sme_sae_auth(wpa_s, data->auth.auth_transaction,
  807. data->auth.status_code, data->auth.ies,
  808. data->auth.ies_len);
  809. if (res < 0) {
  810. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  811. wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
  812. }
  813. if (res != 1)
  814. return;
  815. wpa_printf(MSG_DEBUG, "SME: SAE completed - setting PMK for "
  816. "4-way handshake");
  817. wpa_sm_set_pmk(wpa_s->wpa, wpa_s->sme.sae.pmk, PMK_LEN,
  818. wpa_s->sme.sae.pmkid, wpa_s->pending_bssid);
  819. }
  820. #endif /* CONFIG_SAE */
  821. if (data->auth.status_code != WLAN_STATUS_SUCCESS) {
  822. char *ie_txt = NULL;
  823. if (data->auth.ies && data->auth.ies_len) {
  824. size_t buflen = 2 * data->auth.ies_len + 1;
  825. ie_txt = os_malloc(buflen);
  826. if (ie_txt) {
  827. wpa_snprintf_hex(ie_txt, buflen, data->auth.ies,
  828. data->auth.ies_len);
  829. }
  830. }
  831. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_AUTH_REJECT MACSTR
  832. " auth_type=%u auth_transaction=%u status_code=%u%s%s",
  833. MAC2STR(data->auth.peer), data->auth.auth_type,
  834. data->auth.auth_transaction, data->auth.status_code,
  835. ie_txt ? " ie=" : "",
  836. ie_txt ? ie_txt : "");
  837. os_free(ie_txt);
  838. if (data->auth.status_code !=
  839. WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG ||
  840. wpa_s->sme.auth_alg == data->auth.auth_type ||
  841. wpa_s->current_ssid->auth_alg == WPA_AUTH_ALG_LEAP) {
  842. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  843. wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
  844. return;
  845. }
  846. wpas_connect_work_done(wpa_s);
  847. switch (data->auth.auth_type) {
  848. case WLAN_AUTH_OPEN:
  849. wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_SHARED;
  850. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying SHARED auth");
  851. wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
  852. wpa_s->current_ssid);
  853. return;
  854. case WLAN_AUTH_SHARED_KEY:
  855. wpa_s->current_ssid->auth_alg = WPA_AUTH_ALG_LEAP;
  856. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Trying LEAP auth");
  857. wpa_supplicant_associate(wpa_s, wpa_s->current_bss,
  858. wpa_s->current_ssid);
  859. return;
  860. default:
  861. return;
  862. }
  863. }
  864. #ifdef CONFIG_IEEE80211R
  865. if (data->auth.auth_type == WLAN_AUTH_FT) {
  866. const u8 *ric_ies = NULL;
  867. size_t ric_ies_len = 0;
  868. if (wpa_s->ric_ies) {
  869. ric_ies = wpabuf_head(wpa_s->ric_ies);
  870. ric_ies_len = wpabuf_len(wpa_s->ric_ies);
  871. }
  872. if (wpa_ft_process_response(wpa_s->wpa, data->auth.ies,
  873. data->auth.ies_len, 0,
  874. data->auth.peer,
  875. ric_ies, ric_ies_len) < 0) {
  876. wpa_dbg(wpa_s, MSG_DEBUG,
  877. "SME: FT Authentication response processing failed");
  878. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
  879. MACSTR
  880. " reason=%d locally_generated=1",
  881. MAC2STR(wpa_s->pending_bssid),
  882. WLAN_REASON_DEAUTH_LEAVING);
  883. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  884. wpa_supplicant_mark_disassoc(wpa_s);
  885. return;
  886. }
  887. }
  888. #endif /* CONFIG_IEEE80211R */
  889. #ifdef CONFIG_FILS
  890. if (data->auth.auth_type == WLAN_AUTH_FILS_SK ||
  891. data->auth.auth_type == WLAN_AUTH_FILS_SK_PFS) {
  892. u16 expect_auth_type;
  893. expect_auth_type = wpa_s->sme.auth_alg ==
  894. WPA_AUTH_ALG_FILS_SK_PFS ? WLAN_AUTH_FILS_SK_PFS :
  895. WLAN_AUTH_FILS_SK;
  896. if (data->auth.auth_type != expect_auth_type) {
  897. wpa_dbg(wpa_s, MSG_DEBUG,
  898. "SME: FILS Authentication response used different auth alg (%u; expected %u)",
  899. data->auth.auth_type, expect_auth_type);
  900. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
  901. MACSTR
  902. " reason=%d locally_generated=1",
  903. MAC2STR(wpa_s->pending_bssid),
  904. WLAN_REASON_DEAUTH_LEAVING);
  905. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  906. wpa_supplicant_mark_disassoc(wpa_s);
  907. return;
  908. }
  909. if (fils_process_auth(wpa_s->wpa, wpa_s->pending_bssid,
  910. data->auth.ies, data->auth.ies_len) < 0) {
  911. wpa_dbg(wpa_s, MSG_DEBUG,
  912. "SME: FILS Authentication response processing failed");
  913. wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_DISCONNECTED "bssid="
  914. MACSTR
  915. " reason=%d locally_generated=1",
  916. MAC2STR(wpa_s->pending_bssid),
  917. WLAN_REASON_DEAUTH_LEAVING);
  918. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  919. wpa_supplicant_mark_disassoc(wpa_s);
  920. return;
  921. }
  922. }
  923. #endif /* CONFIG_FILS */
  924. sme_associate(wpa_s, ssid->mode, data->auth.peer,
  925. data->auth.auth_type);
  926. }
  927. #ifdef CONFIG_FILS
  928. #ifdef CONFIG_IEEE80211R
  929. static void remove_ie(u8 *buf, size_t *len, u8 eid)
  930. {
  931. u8 *pos, *next, *end;
  932. pos = (u8 *) get_ie(buf, *len, eid);
  933. if (pos) {
  934. next = pos + 2 + pos[1];
  935. end = buf + *len;
  936. *len -= 2 + pos[1];
  937. os_memmove(pos, next, end - next);
  938. }
  939. }
  940. #endif /* CONFIG_IEEE80211R */
  941. #endif /* CONFIG_FILS */
  942. void sme_associate(struct wpa_supplicant *wpa_s, enum wpas_mode mode,
  943. const u8 *bssid, u16 auth_type)
  944. {
  945. struct wpa_driver_associate_params params;
  946. struct ieee802_11_elems elems;
  947. #ifdef CONFIG_FILS
  948. u8 nonces[2 * FILS_NONCE_LEN];
  949. #endif /* CONFIG_FILS */
  950. #ifdef CONFIG_HT_OVERRIDES
  951. struct ieee80211_ht_capabilities htcaps;
  952. struct ieee80211_ht_capabilities htcaps_mask;
  953. #endif /* CONFIG_HT_OVERRIDES */
  954. #ifdef CONFIG_VHT_OVERRIDES
  955. struct ieee80211_vht_capabilities vhtcaps;
  956. struct ieee80211_vht_capabilities vhtcaps_mask;
  957. #endif /* CONFIG_VHT_OVERRIDES */
  958. os_memset(&params, 0, sizeof(params));
  959. #ifdef CONFIG_FILS
  960. if (auth_type == WLAN_AUTH_FILS_SK ||
  961. auth_type == WLAN_AUTH_FILS_SK_PFS) {
  962. struct wpabuf *buf;
  963. const u8 *snonce, *anonce;
  964. const unsigned int max_hlp = 20;
  965. struct wpabuf *hlp[max_hlp];
  966. unsigned int i, num_hlp = 0;
  967. struct fils_hlp_req *req;
  968. dl_list_for_each(req, &wpa_s->fils_hlp_req, struct fils_hlp_req,
  969. list) {
  970. hlp[num_hlp] = wpabuf_alloc(2 * ETH_ALEN + 6 +
  971. wpabuf_len(req->pkt));
  972. if (!hlp[num_hlp])
  973. break;
  974. wpabuf_put_data(hlp[num_hlp], req->dst, ETH_ALEN);
  975. wpabuf_put_data(hlp[num_hlp], wpa_s->own_addr,
  976. ETH_ALEN);
  977. wpabuf_put_data(hlp[num_hlp],
  978. "\xaa\xaa\x03\x00\x00\x00", 6);
  979. wpabuf_put_buf(hlp[num_hlp], req->pkt);
  980. num_hlp++;
  981. if (num_hlp >= max_hlp)
  982. break;
  983. }
  984. buf = fils_build_assoc_req(wpa_s->wpa, &params.fils_kek,
  985. &params.fils_kek_len, &snonce,
  986. &anonce,
  987. (const struct wpabuf **) hlp,
  988. num_hlp);
  989. for (i = 0; i < num_hlp; i++)
  990. wpabuf_free(hlp[i]);
  991. if (!buf)
  992. return;
  993. wpa_hexdump(MSG_DEBUG, "FILS: assoc_req before FILS elements",
  994. wpa_s->sme.assoc_req_ie,
  995. wpa_s->sme.assoc_req_ie_len);
  996. #ifdef CONFIG_IEEE80211R
  997. if (wpa_key_mgmt_ft(wpa_s->key_mgmt)) {
  998. /* Remove RSNE and MDE to allow them to be overridden
  999. * with FILS+FT specific values from
  1000. * fils_build_assoc_req(). */
  1001. remove_ie(wpa_s->sme.assoc_req_ie,
  1002. &wpa_s->sme.assoc_req_ie_len,
  1003. WLAN_EID_RSN);
  1004. wpa_hexdump(MSG_DEBUG,
  1005. "FILS: assoc_req after RSNE removal",
  1006. wpa_s->sme.assoc_req_ie,
  1007. wpa_s->sme.assoc_req_ie_len);
  1008. remove_ie(wpa_s->sme.assoc_req_ie,
  1009. &wpa_s->sme.assoc_req_ie_len,
  1010. WLAN_EID_MOBILITY_DOMAIN);
  1011. wpa_hexdump(MSG_DEBUG,
  1012. "FILS: assoc_req after MDE removal",
  1013. wpa_s->sme.assoc_req_ie,
  1014. wpa_s->sme.assoc_req_ie_len);
  1015. }
  1016. #endif /* CONFIG_IEEE80211R */
  1017. /* TODO: Make wpa_s->sme.assoc_req_ie use dynamic allocation */
  1018. if (wpa_s->sme.assoc_req_ie_len + wpabuf_len(buf) >
  1019. sizeof(wpa_s->sme.assoc_req_ie)) {
  1020. wpa_printf(MSG_ERROR,
  1021. "FILS: Not enough buffer room for own AssocReq elements");
  1022. wpabuf_free(buf);
  1023. return;
  1024. }
  1025. os_memcpy(wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
  1026. wpabuf_head(buf), wpabuf_len(buf));
  1027. wpa_s->sme.assoc_req_ie_len += wpabuf_len(buf);
  1028. wpabuf_free(buf);
  1029. wpa_hexdump(MSG_DEBUG, "FILS: assoc_req after FILS elements",
  1030. wpa_s->sme.assoc_req_ie,
  1031. wpa_s->sme.assoc_req_ie_len);
  1032. os_memcpy(nonces, snonce, FILS_NONCE_LEN);
  1033. os_memcpy(nonces + FILS_NONCE_LEN, anonce, FILS_NONCE_LEN);
  1034. params.fils_nonces = nonces;
  1035. params.fils_nonces_len = sizeof(nonces);
  1036. }
  1037. #endif /* CONFIG_FILS */
  1038. #ifdef CONFIG_OWE
  1039. #ifdef CONFIG_TESTING_OPTIONS
  1040. if (get_ie_ext(wpa_s->sme.assoc_req_ie, wpa_s->sme.assoc_req_ie_len,
  1041. WLAN_EID_EXT_OWE_DH_PARAM)) {
  1042. wpa_printf(MSG_INFO, "TESTING: Override OWE DH element");
  1043. } else
  1044. #endif /* CONFIG_TESTING_OPTIONS */
  1045. if (auth_type == WLAN_AUTH_OPEN &&
  1046. wpa_s->key_mgmt == WPA_KEY_MGMT_OWE) {
  1047. struct wpabuf *owe_ie;
  1048. u16 group;
  1049. if (wpa_s->current_ssid && wpa_s->current_ssid->owe_group) {
  1050. group = wpa_s->current_ssid->owe_group;
  1051. } else {
  1052. if (wpa_s->last_owe_group == 19)
  1053. group = 20;
  1054. else if (wpa_s->last_owe_group == 20)
  1055. group = 21;
  1056. else
  1057. group = OWE_DH_GROUP;
  1058. }
  1059. wpa_s->last_owe_group = group;
  1060. wpa_printf(MSG_DEBUG, "OWE: Try to use group %u", group);
  1061. owe_ie = owe_build_assoc_req(wpa_s->wpa, group);
  1062. if (!owe_ie) {
  1063. wpa_printf(MSG_ERROR,
  1064. "OWE: Failed to build IE for Association Request frame");
  1065. return;
  1066. }
  1067. if (wpa_s->sme.assoc_req_ie_len + wpabuf_len(owe_ie) >
  1068. sizeof(wpa_s->sme.assoc_req_ie)) {
  1069. wpa_printf(MSG_ERROR,
  1070. "OWE: Not enough buffer room for own Association Request frame elements");
  1071. wpabuf_free(owe_ie);
  1072. return;
  1073. }
  1074. os_memcpy(wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len,
  1075. wpabuf_head(owe_ie), wpabuf_len(owe_ie));
  1076. wpa_s->sme.assoc_req_ie_len += wpabuf_len(owe_ie);
  1077. wpabuf_free(owe_ie);
  1078. }
  1079. #endif /* CONFIG_OWE */
  1080. params.bssid = bssid;
  1081. params.ssid = wpa_s->sme.ssid;
  1082. params.ssid_len = wpa_s->sme.ssid_len;
  1083. params.freq.freq = wpa_s->sme.freq;
  1084. params.bg_scan_period = wpa_s->current_ssid ?
  1085. wpa_s->current_ssid->bg_scan_period : -1;
  1086. params.wpa_ie = wpa_s->sme.assoc_req_ie_len ?
  1087. wpa_s->sme.assoc_req_ie : NULL;
  1088. params.wpa_ie_len = wpa_s->sme.assoc_req_ie_len;
  1089. params.pairwise_suite = wpa_s->pairwise_cipher;
  1090. params.group_suite = wpa_s->group_cipher;
  1091. params.mgmt_group_suite = wpa_s->mgmt_group_cipher;
  1092. params.key_mgmt_suite = wpa_s->key_mgmt;
  1093. params.wpa_proto = wpa_s->wpa_proto;
  1094. #ifdef CONFIG_HT_OVERRIDES
  1095. os_memset(&htcaps, 0, sizeof(htcaps));
  1096. os_memset(&htcaps_mask, 0, sizeof(htcaps_mask));
  1097. params.htcaps = (u8 *) &htcaps;
  1098. params.htcaps_mask = (u8 *) &htcaps_mask;
  1099. wpa_supplicant_apply_ht_overrides(wpa_s, wpa_s->current_ssid, &params);
  1100. #endif /* CONFIG_HT_OVERRIDES */
  1101. #ifdef CONFIG_VHT_OVERRIDES
  1102. os_memset(&vhtcaps, 0, sizeof(vhtcaps));
  1103. os_memset(&vhtcaps_mask, 0, sizeof(vhtcaps_mask));
  1104. params.vhtcaps = &vhtcaps;
  1105. params.vhtcaps_mask = &vhtcaps_mask;
  1106. wpa_supplicant_apply_vht_overrides(wpa_s, wpa_s->current_ssid, &params);
  1107. #endif /* CONFIG_VHT_OVERRIDES */
  1108. #ifdef CONFIG_IEEE80211R
  1109. if (auth_type == WLAN_AUTH_FT && wpa_s->sme.ft_ies) {
  1110. params.wpa_ie = wpa_s->sme.ft_ies;
  1111. params.wpa_ie_len = wpa_s->sme.ft_ies_len;
  1112. }
  1113. #endif /* CONFIG_IEEE80211R */
  1114. params.mode = mode;
  1115. params.mgmt_frame_protection = wpa_s->sme.mfp;
  1116. params.rrm_used = wpa_s->rrm.rrm_used;
  1117. if (wpa_s->sme.prev_bssid_set)
  1118. params.prev_bssid = wpa_s->sme.prev_bssid;
  1119. wpa_msg(wpa_s, MSG_INFO, "Trying to associate with " MACSTR
  1120. " (SSID='%s' freq=%d MHz)", MAC2STR(params.bssid),
  1121. params.ssid ? wpa_ssid_txt(params.ssid, params.ssid_len) : "",
  1122. params.freq.freq);
  1123. wpa_supplicant_set_state(wpa_s, WPA_ASSOCIATING);
  1124. if (params.wpa_ie == NULL ||
  1125. ieee802_11_parse_elems(params.wpa_ie, params.wpa_ie_len, &elems, 0)
  1126. < 0) {
  1127. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Could not parse own IEs?!");
  1128. os_memset(&elems, 0, sizeof(elems));
  1129. }
  1130. if (elems.rsn_ie) {
  1131. params.wpa_proto = WPA_PROTO_RSN;
  1132. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.rsn_ie - 2,
  1133. elems.rsn_ie_len + 2);
  1134. } else if (elems.wpa_ie) {
  1135. params.wpa_proto = WPA_PROTO_WPA;
  1136. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.wpa_ie - 2,
  1137. elems.wpa_ie_len + 2);
  1138. } else if (elems.osen) {
  1139. params.wpa_proto = WPA_PROTO_OSEN;
  1140. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, elems.osen - 2,
  1141. elems.osen_len + 2);
  1142. } else
  1143. wpa_sm_set_assoc_wpa_ie(wpa_s->wpa, NULL, 0);
  1144. if (wpa_s->current_ssid && wpa_s->current_ssid->p2p_group)
  1145. params.p2p = 1;
  1146. if (wpa_s->p2pdev->set_sta_uapsd)
  1147. params.uapsd = wpa_s->p2pdev->sta_uapsd;
  1148. else
  1149. params.uapsd = -1;
  1150. if (wpa_drv_associate(wpa_s, &params) < 0) {
  1151. wpa_msg(wpa_s, MSG_INFO, "SME: Association request to the "
  1152. "driver failed");
  1153. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  1154. wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
  1155. os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
  1156. return;
  1157. }
  1158. eloop_register_timeout(SME_ASSOC_TIMEOUT, 0, sme_assoc_timer, wpa_s,
  1159. NULL);
  1160. #ifdef CONFIG_TESTING_OPTIONS
  1161. wpabuf_free(wpa_s->last_assoc_req_wpa_ie);
  1162. wpa_s->last_assoc_req_wpa_ie = NULL;
  1163. if (params.wpa_ie)
  1164. wpa_s->last_assoc_req_wpa_ie =
  1165. wpabuf_alloc_copy(params.wpa_ie, params.wpa_ie_len);
  1166. #endif /* CONFIG_TESTING_OPTIONS */
  1167. }
  1168. int sme_update_ft_ies(struct wpa_supplicant *wpa_s, const u8 *md,
  1169. const u8 *ies, size_t ies_len)
  1170. {
  1171. if (md == NULL || ies == NULL) {
  1172. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Remove mobility domain");
  1173. os_free(wpa_s->sme.ft_ies);
  1174. wpa_s->sme.ft_ies = NULL;
  1175. wpa_s->sme.ft_ies_len = 0;
  1176. wpa_s->sme.ft_used = 0;
  1177. return 0;
  1178. }
  1179. os_memcpy(wpa_s->sme.mobility_domain, md, MOBILITY_DOMAIN_ID_LEN);
  1180. wpa_hexdump(MSG_DEBUG, "SME: FT IEs", ies, ies_len);
  1181. os_free(wpa_s->sme.ft_ies);
  1182. wpa_s->sme.ft_ies = os_memdup(ies, ies_len);
  1183. if (wpa_s->sme.ft_ies == NULL)
  1184. return -1;
  1185. wpa_s->sme.ft_ies_len = ies_len;
  1186. return 0;
  1187. }
  1188. static void sme_deauth(struct wpa_supplicant *wpa_s)
  1189. {
  1190. int bssid_changed;
  1191. bssid_changed = !is_zero_ether_addr(wpa_s->bssid);
  1192. if (wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid,
  1193. WLAN_REASON_DEAUTH_LEAVING) < 0) {
  1194. wpa_msg(wpa_s, MSG_INFO, "SME: Deauth request to the driver "
  1195. "failed");
  1196. }
  1197. wpa_s->sme.prev_bssid_set = 0;
  1198. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  1199. wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
  1200. os_memset(wpa_s->bssid, 0, ETH_ALEN);
  1201. os_memset(wpa_s->pending_bssid, 0, ETH_ALEN);
  1202. if (bssid_changed)
  1203. wpas_notify_bssid_changed(wpa_s);
  1204. }
  1205. void sme_event_assoc_reject(struct wpa_supplicant *wpa_s,
  1206. union wpa_event_data *data)
  1207. {
  1208. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association with " MACSTR " failed: "
  1209. "status code %d", MAC2STR(wpa_s->pending_bssid),
  1210. data->assoc_reject.status_code);
  1211. eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
  1212. #ifdef CONFIG_SAE
  1213. if (wpa_s->sme.sae_pmksa_caching && wpa_s->current_ssid &&
  1214. wpa_key_mgmt_sae(wpa_s->current_ssid->key_mgmt)) {
  1215. wpa_dbg(wpa_s, MSG_DEBUG,
  1216. "PMKSA caching attempt rejected - drop PMKSA cache entry and fall back to SAE authentication");
  1217. wpa_sm_aborted_cached(wpa_s->wpa);
  1218. wpa_sm_pmksa_cache_flush(wpa_s->wpa, wpa_s->current_ssid);
  1219. if (wpa_s->current_bss) {
  1220. struct wpa_bss *bss = wpa_s->current_bss;
  1221. struct wpa_ssid *ssid = wpa_s->current_ssid;
  1222. wpa_drv_deauthenticate(wpa_s, wpa_s->pending_bssid,
  1223. WLAN_REASON_DEAUTH_LEAVING);
  1224. wpas_connect_work_done(wpa_s);
  1225. wpa_supplicant_mark_disassoc(wpa_s);
  1226. wpa_supplicant_connect(wpa_s, bss, ssid);
  1227. return;
  1228. }
  1229. }
  1230. #endif /* CONFIG_SAE */
  1231. /*
  1232. * For now, unconditionally terminate the previous authentication. In
  1233. * theory, this should not be needed, but mac80211 gets quite confused
  1234. * if the authentication is left pending.. Some roaming cases might
  1235. * benefit from using the previous authentication, so this could be
  1236. * optimized in the future.
  1237. */
  1238. sme_deauth(wpa_s);
  1239. }
  1240. void sme_event_auth_timed_out(struct wpa_supplicant *wpa_s,
  1241. union wpa_event_data *data)
  1242. {
  1243. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Authentication timed out");
  1244. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  1245. wpa_supplicant_mark_disassoc(wpa_s);
  1246. }
  1247. void sme_event_assoc_timed_out(struct wpa_supplicant *wpa_s,
  1248. union wpa_event_data *data)
  1249. {
  1250. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association timed out");
  1251. wpas_connection_failed(wpa_s, wpa_s->pending_bssid);
  1252. wpa_supplicant_mark_disassoc(wpa_s);
  1253. }
  1254. void sme_event_disassoc(struct wpa_supplicant *wpa_s,
  1255. struct disassoc_info *info)
  1256. {
  1257. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Disassociation event received");
  1258. if (wpa_s->sme.prev_bssid_set) {
  1259. /*
  1260. * cfg80211/mac80211 can get into somewhat confused state if
  1261. * the AP only disassociates us and leaves us in authenticated
  1262. * state. For now, force the state to be cleared to avoid
  1263. * confusing errors if we try to associate with the AP again.
  1264. */
  1265. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Deauthenticate to clear "
  1266. "driver state");
  1267. wpa_drv_deauthenticate(wpa_s, wpa_s->sme.prev_bssid,
  1268. WLAN_REASON_DEAUTH_LEAVING);
  1269. }
  1270. }
  1271. static void sme_auth_timer(void *eloop_ctx, void *timeout_ctx)
  1272. {
  1273. struct wpa_supplicant *wpa_s = eloop_ctx;
  1274. if (wpa_s->wpa_state == WPA_AUTHENTICATING) {
  1275. wpa_msg(wpa_s, MSG_DEBUG, "SME: Authentication timeout");
  1276. sme_deauth(wpa_s);
  1277. }
  1278. }
  1279. static void sme_assoc_timer(void *eloop_ctx, void *timeout_ctx)
  1280. {
  1281. struct wpa_supplicant *wpa_s = eloop_ctx;
  1282. if (wpa_s->wpa_state == WPA_ASSOCIATING) {
  1283. wpa_msg(wpa_s, MSG_DEBUG, "SME: Association timeout");
  1284. sme_deauth(wpa_s);
  1285. }
  1286. }
  1287. void sme_state_changed(struct wpa_supplicant *wpa_s)
  1288. {
  1289. /* Make sure timers are cleaned up appropriately. */
  1290. if (wpa_s->wpa_state != WPA_ASSOCIATING)
  1291. eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
  1292. if (wpa_s->wpa_state != WPA_AUTHENTICATING)
  1293. eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
  1294. }
  1295. void sme_disassoc_while_authenticating(struct wpa_supplicant *wpa_s,
  1296. const u8 *prev_pending_bssid)
  1297. {
  1298. /*
  1299. * mac80211-workaround to force deauth on failed auth cmd,
  1300. * requires us to remain in authenticating state to allow the
  1301. * second authentication attempt to be continued properly.
  1302. */
  1303. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Allow pending authentication "
  1304. "to proceed after disconnection event");
  1305. wpa_supplicant_set_state(wpa_s, WPA_AUTHENTICATING);
  1306. os_memcpy(wpa_s->pending_bssid, prev_pending_bssid, ETH_ALEN);
  1307. /*
  1308. * Re-arm authentication timer in case auth fails for whatever reason.
  1309. */
  1310. eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
  1311. eloop_register_timeout(SME_AUTH_TIMEOUT, 0, sme_auth_timer, wpa_s,
  1312. NULL);
  1313. }
  1314. void sme_clear_on_disassoc(struct wpa_supplicant *wpa_s)
  1315. {
  1316. wpa_s->sme.prev_bssid_set = 0;
  1317. #ifdef CONFIG_SAE
  1318. wpabuf_free(wpa_s->sme.sae_token);
  1319. wpa_s->sme.sae_token = NULL;
  1320. sae_clear_data(&wpa_s->sme.sae);
  1321. #endif /* CONFIG_SAE */
  1322. #ifdef CONFIG_IEEE80211R
  1323. if (wpa_s->sme.ft_ies)
  1324. sme_update_ft_ies(wpa_s, NULL, NULL, 0);
  1325. #endif /* CONFIG_IEEE80211R */
  1326. }
  1327. void sme_deinit(struct wpa_supplicant *wpa_s)
  1328. {
  1329. os_free(wpa_s->sme.ft_ies);
  1330. wpa_s->sme.ft_ies = NULL;
  1331. wpa_s->sme.ft_ies_len = 0;
  1332. #ifdef CONFIG_IEEE80211W
  1333. sme_stop_sa_query(wpa_s);
  1334. #endif /* CONFIG_IEEE80211W */
  1335. sme_clear_on_disassoc(wpa_s);
  1336. eloop_cancel_timeout(sme_assoc_timer, wpa_s, NULL);
  1337. eloop_cancel_timeout(sme_auth_timer, wpa_s, NULL);
  1338. eloop_cancel_timeout(sme_obss_scan_timeout, wpa_s, NULL);
  1339. }
  1340. static void sme_send_2040_bss_coex(struct wpa_supplicant *wpa_s,
  1341. const u8 *chan_list, u8 num_channels,
  1342. u8 num_intol)
  1343. {
  1344. struct ieee80211_2040_bss_coex_ie *bc_ie;
  1345. struct ieee80211_2040_intol_chan_report *ic_report;
  1346. struct wpabuf *buf;
  1347. wpa_printf(MSG_DEBUG, "SME: Send 20/40 BSS Coexistence to " MACSTR
  1348. " (num_channels=%u num_intol=%u)",
  1349. MAC2STR(wpa_s->bssid), num_channels, num_intol);
  1350. wpa_hexdump(MSG_DEBUG, "SME: 20/40 BSS Intolerant Channels",
  1351. chan_list, num_channels);
  1352. buf = wpabuf_alloc(2 + /* action.category + action_code */
  1353. sizeof(struct ieee80211_2040_bss_coex_ie) +
  1354. sizeof(struct ieee80211_2040_intol_chan_report) +
  1355. num_channels);
  1356. if (buf == NULL)
  1357. return;
  1358. wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC);
  1359. wpabuf_put_u8(buf, WLAN_PA_20_40_BSS_COEX);
  1360. bc_ie = wpabuf_put(buf, sizeof(*bc_ie));
  1361. bc_ie->element_id = WLAN_EID_20_40_BSS_COEXISTENCE;
  1362. bc_ie->length = 1;
  1363. if (num_intol)
  1364. bc_ie->coex_param |= WLAN_20_40_BSS_COEX_20MHZ_WIDTH_REQ;
  1365. if (num_channels > 0) {
  1366. ic_report = wpabuf_put(buf, sizeof(*ic_report));
  1367. ic_report->element_id = WLAN_EID_20_40_BSS_INTOLERANT;
  1368. ic_report->length = num_channels + 1;
  1369. ic_report->op_class = 0;
  1370. os_memcpy(wpabuf_put(buf, num_channels), chan_list,
  1371. num_channels);
  1372. }
  1373. if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
  1374. wpa_s->own_addr, wpa_s->bssid,
  1375. wpabuf_head(buf), wpabuf_len(buf), 0) < 0) {
  1376. wpa_msg(wpa_s, MSG_INFO,
  1377. "SME: Failed to send 20/40 BSS Coexistence frame");
  1378. }
  1379. wpabuf_free(buf);
  1380. }
  1381. int sme_proc_obss_scan(struct wpa_supplicant *wpa_s)
  1382. {
  1383. struct wpa_bss *bss;
  1384. const u8 *ie;
  1385. u16 ht_cap;
  1386. u8 chan_list[P2P_MAX_CHANNELS], channel;
  1387. u8 num_channels = 0, num_intol = 0, i;
  1388. if (!wpa_s->sme.sched_obss_scan)
  1389. return 0;
  1390. wpa_s->sme.sched_obss_scan = 0;
  1391. if (!wpa_s->current_bss || wpa_s->wpa_state != WPA_COMPLETED)
  1392. return 1;
  1393. /*
  1394. * Check whether AP uses regulatory triplet or channel triplet in
  1395. * country info. Right now the operating class of the BSS channel
  1396. * width trigger event is "unknown" (IEEE Std 802.11-2012 10.15.12),
  1397. * based on the assumption that operating class triplet is not used in
  1398. * beacon frame. If the First Channel Number/Operating Extension
  1399. * Identifier octet has a positive integer value of 201 or greater,
  1400. * then its operating class triplet.
  1401. *
  1402. * TODO: If Supported Operating Classes element is present in beacon
  1403. * frame, have to lookup operating class in Annex E and fill them in
  1404. * 2040 coex frame.
  1405. */
  1406. ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_COUNTRY);
  1407. if (ie && (ie[1] >= 6) && (ie[5] >= 201))
  1408. return 1;
  1409. os_memset(chan_list, 0, sizeof(chan_list));
  1410. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  1411. /* Skip other band bss */
  1412. enum hostapd_hw_mode mode;
  1413. mode = ieee80211_freq_to_chan(bss->freq, &channel);
  1414. if (mode != HOSTAPD_MODE_IEEE80211G &&
  1415. mode != HOSTAPD_MODE_IEEE80211B)
  1416. continue;
  1417. ie = wpa_bss_get_ie(bss, WLAN_EID_HT_CAP);
  1418. ht_cap = (ie && (ie[1] == 26)) ? WPA_GET_LE16(ie + 2) : 0;
  1419. wpa_printf(MSG_DEBUG, "SME OBSS scan BSS " MACSTR
  1420. " freq=%u chan=%u ht_cap=0x%x",
  1421. MAC2STR(bss->bssid), bss->freq, channel, ht_cap);
  1422. if (!ht_cap || (ht_cap & HT_CAP_INFO_40MHZ_INTOLERANT)) {
  1423. if (ht_cap & HT_CAP_INFO_40MHZ_INTOLERANT)
  1424. num_intol++;
  1425. /* Check whether the channel is already considered */
  1426. for (i = 0; i < num_channels; i++) {
  1427. if (channel == chan_list[i])
  1428. break;
  1429. }
  1430. if (i != num_channels)
  1431. continue;
  1432. chan_list[num_channels++] = channel;
  1433. }
  1434. }
  1435. sme_send_2040_bss_coex(wpa_s, chan_list, num_channels, num_intol);
  1436. return 1;
  1437. }
  1438. static void wpa_obss_scan_freqs_list(struct wpa_supplicant *wpa_s,
  1439. struct wpa_driver_scan_params *params)
  1440. {
  1441. /* Include only affected channels */
  1442. struct hostapd_hw_modes *mode;
  1443. int count, i;
  1444. int start, end;
  1445. mode = get_mode(wpa_s->hw.modes, wpa_s->hw.num_modes,
  1446. HOSTAPD_MODE_IEEE80211G);
  1447. if (mode == NULL) {
  1448. /* No channels supported in this band - use empty list */
  1449. params->freqs = os_zalloc(sizeof(int));
  1450. return;
  1451. }
  1452. if (wpa_s->sme.ht_sec_chan == HT_SEC_CHAN_UNKNOWN &&
  1453. wpa_s->current_bss) {
  1454. const u8 *ie;
  1455. ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_HT_OPERATION);
  1456. if (ie && ie[1] >= 2) {
  1457. u8 o;
  1458. o = ie[3] & HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK;
  1459. if (o == HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE)
  1460. wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_ABOVE;
  1461. else if (o == HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW)
  1462. wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_BELOW;
  1463. }
  1464. }
  1465. start = wpa_s->assoc_freq - 10;
  1466. end = wpa_s->assoc_freq + 10;
  1467. switch (wpa_s->sme.ht_sec_chan) {
  1468. case HT_SEC_CHAN_UNKNOWN:
  1469. /* HT40+ possible on channels 1..9 */
  1470. if (wpa_s->assoc_freq <= 2452)
  1471. start -= 20;
  1472. /* HT40- possible on channels 5-13 */
  1473. if (wpa_s->assoc_freq >= 2432)
  1474. end += 20;
  1475. break;
  1476. case HT_SEC_CHAN_ABOVE:
  1477. end += 20;
  1478. break;
  1479. case HT_SEC_CHAN_BELOW:
  1480. start -= 20;
  1481. break;
  1482. }
  1483. wpa_printf(MSG_DEBUG,
  1484. "OBSS: assoc_freq %d possible affected range %d-%d",
  1485. wpa_s->assoc_freq, start, end);
  1486. params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
  1487. if (params->freqs == NULL)
  1488. return;
  1489. for (count = 0, i = 0; i < mode->num_channels; i++) {
  1490. int freq;
  1491. if (mode->channels[i].flag & HOSTAPD_CHAN_DISABLED)
  1492. continue;
  1493. freq = mode->channels[i].freq;
  1494. if (freq - 10 >= end || freq + 10 <= start)
  1495. continue; /* not affected */
  1496. params->freqs[count++] = freq;
  1497. }
  1498. }
  1499. static void sme_obss_scan_timeout(void *eloop_ctx, void *timeout_ctx)
  1500. {
  1501. struct wpa_supplicant *wpa_s = eloop_ctx;
  1502. struct wpa_driver_scan_params params;
  1503. if (!wpa_s->current_bss) {
  1504. wpa_printf(MSG_DEBUG, "SME OBSS: Ignore scan request");
  1505. return;
  1506. }
  1507. os_memset(&params, 0, sizeof(params));
  1508. wpa_obss_scan_freqs_list(wpa_s, &params);
  1509. params.low_priority = 1;
  1510. wpa_printf(MSG_DEBUG, "SME OBSS: Request an OBSS scan");
  1511. if (wpa_supplicant_trigger_scan(wpa_s, &params))
  1512. wpa_printf(MSG_DEBUG, "SME OBSS: Failed to trigger scan");
  1513. else
  1514. wpa_s->sme.sched_obss_scan = 1;
  1515. os_free(params.freqs);
  1516. eloop_register_timeout(wpa_s->sme.obss_scan_int, 0,
  1517. sme_obss_scan_timeout, wpa_s, NULL);
  1518. }
  1519. void sme_sched_obss_scan(struct wpa_supplicant *wpa_s, int enable)
  1520. {
  1521. const u8 *ie;
  1522. struct wpa_bss *bss = wpa_s->current_bss;
  1523. struct wpa_ssid *ssid = wpa_s->current_ssid;
  1524. struct hostapd_hw_modes *hw_mode = NULL;
  1525. int i;
  1526. eloop_cancel_timeout(sme_obss_scan_timeout, wpa_s, NULL);
  1527. wpa_s->sme.sched_obss_scan = 0;
  1528. wpa_s->sme.ht_sec_chan = HT_SEC_CHAN_UNKNOWN;
  1529. if (!enable)
  1530. return;
  1531. /*
  1532. * Schedule OBSS scan if driver is using station SME in wpa_supplicant
  1533. * or it expects OBSS scan to be performed by wpa_supplicant.
  1534. */
  1535. if (!((wpa_s->drv_flags & WPA_DRIVER_FLAGS_SME) ||
  1536. (wpa_s->drv_flags & WPA_DRIVER_FLAGS_OBSS_SCAN)) ||
  1537. ssid == NULL || ssid->mode != IEEE80211_MODE_INFRA)
  1538. return;
  1539. if (!wpa_s->hw.modes)
  1540. return;
  1541. /* only HT caps in 11g mode are relevant */
  1542. for (i = 0; i < wpa_s->hw.num_modes; i++) {
  1543. hw_mode = &wpa_s->hw.modes[i];
  1544. if (hw_mode->mode == HOSTAPD_MODE_IEEE80211G)
  1545. break;
  1546. }
  1547. /* Driver does not support HT40 for 11g or doesn't have 11g. */
  1548. if (i == wpa_s->hw.num_modes || !hw_mode ||
  1549. !(hw_mode->ht_capab & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
  1550. return;
  1551. if (bss == NULL || bss->freq < 2400 || bss->freq > 2500)
  1552. return; /* Not associated on 2.4 GHz band */
  1553. /* Check whether AP supports HT40 */
  1554. ie = wpa_bss_get_ie(wpa_s->current_bss, WLAN_EID_HT_CAP);
  1555. if (!ie || ie[1] < 2 ||
  1556. !(WPA_GET_LE16(ie + 2) & HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET))
  1557. return; /* AP does not support HT40 */
  1558. ie = wpa_bss_get_ie(wpa_s->current_bss,
  1559. WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS);
  1560. if (!ie || ie[1] < 14)
  1561. return; /* AP does not request OBSS scans */
  1562. wpa_s->sme.obss_scan_int = WPA_GET_LE16(ie + 6);
  1563. if (wpa_s->sme.obss_scan_int < 10) {
  1564. wpa_printf(MSG_DEBUG, "SME: Invalid OBSS Scan Interval %u "
  1565. "replaced with the minimum 10 sec",
  1566. wpa_s->sme.obss_scan_int);
  1567. wpa_s->sme.obss_scan_int = 10;
  1568. }
  1569. wpa_printf(MSG_DEBUG, "SME: OBSS Scan Interval %u sec",
  1570. wpa_s->sme.obss_scan_int);
  1571. eloop_register_timeout(wpa_s->sme.obss_scan_int, 0,
  1572. sme_obss_scan_timeout, wpa_s, NULL);
  1573. }
  1574. #ifdef CONFIG_IEEE80211W
  1575. static const unsigned int sa_query_max_timeout = 1000;
  1576. static const unsigned int sa_query_retry_timeout = 201;
  1577. static int sme_check_sa_query_timeout(struct wpa_supplicant *wpa_s)
  1578. {
  1579. u32 tu;
  1580. struct os_reltime now, passed;
  1581. os_get_reltime(&now);
  1582. os_reltime_sub(&now, &wpa_s->sme.sa_query_start, &passed);
  1583. tu = (passed.sec * 1000000 + passed.usec) / 1024;
  1584. if (sa_query_max_timeout < tu) {
  1585. wpa_dbg(wpa_s, MSG_DEBUG, "SME: SA Query timed out");
  1586. sme_stop_sa_query(wpa_s);
  1587. wpa_supplicant_deauthenticate(
  1588. wpa_s, WLAN_REASON_PREV_AUTH_NOT_VALID);
  1589. return 1;
  1590. }
  1591. return 0;
  1592. }
  1593. static void sme_send_sa_query_req(struct wpa_supplicant *wpa_s,
  1594. const u8 *trans_id)
  1595. {
  1596. u8 req[2 + WLAN_SA_QUERY_TR_ID_LEN];
  1597. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Sending SA Query Request to "
  1598. MACSTR, MAC2STR(wpa_s->bssid));
  1599. wpa_hexdump(MSG_DEBUG, "SME: SA Query Transaction ID",
  1600. trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  1601. req[0] = WLAN_ACTION_SA_QUERY;
  1602. req[1] = WLAN_SA_QUERY_REQUEST;
  1603. os_memcpy(req + 2, trans_id, WLAN_SA_QUERY_TR_ID_LEN);
  1604. if (wpa_drv_send_action(wpa_s, wpa_s->assoc_freq, 0, wpa_s->bssid,
  1605. wpa_s->own_addr, wpa_s->bssid,
  1606. req, sizeof(req), 0) < 0)
  1607. wpa_msg(wpa_s, MSG_INFO, "SME: Failed to send SA Query "
  1608. "Request");
  1609. }
  1610. static void sme_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
  1611. {
  1612. struct wpa_supplicant *wpa_s = eloop_ctx;
  1613. unsigned int timeout, sec, usec;
  1614. u8 *trans_id, *nbuf;
  1615. if (wpa_s->sme.sa_query_count > 0 &&
  1616. sme_check_sa_query_timeout(wpa_s))
  1617. return;
  1618. nbuf = os_realloc_array(wpa_s->sme.sa_query_trans_id,
  1619. wpa_s->sme.sa_query_count + 1,
  1620. WLAN_SA_QUERY_TR_ID_LEN);
  1621. if (nbuf == NULL) {
  1622. sme_stop_sa_query(wpa_s);
  1623. return;
  1624. }
  1625. if (wpa_s->sme.sa_query_count == 0) {
  1626. /* Starting a new SA Query procedure */
  1627. os_get_reltime(&wpa_s->sme.sa_query_start);
  1628. }
  1629. trans_id = nbuf + wpa_s->sme.sa_query_count * WLAN_SA_QUERY_TR_ID_LEN;
  1630. wpa_s->sme.sa_query_trans_id = nbuf;
  1631. wpa_s->sme.sa_query_count++;
  1632. if (os_get_random(trans_id, WLAN_SA_QUERY_TR_ID_LEN) < 0) {
  1633. wpa_printf(MSG_DEBUG, "Could not generate SA Query ID");
  1634. sme_stop_sa_query(wpa_s);
  1635. return;
  1636. }
  1637. timeout = sa_query_retry_timeout;
  1638. sec = ((timeout / 1000) * 1024) / 1000;
  1639. usec = (timeout % 1000) * 1024;
  1640. eloop_register_timeout(sec, usec, sme_sa_query_timer, wpa_s, NULL);
  1641. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Association SA Query attempt %d",
  1642. wpa_s->sme.sa_query_count);
  1643. sme_send_sa_query_req(wpa_s, trans_id);
  1644. }
  1645. static void sme_start_sa_query(struct wpa_supplicant *wpa_s)
  1646. {
  1647. sme_sa_query_timer(wpa_s, NULL);
  1648. }
  1649. static void sme_stop_sa_query(struct wpa_supplicant *wpa_s)
  1650. {
  1651. eloop_cancel_timeout(sme_sa_query_timer, wpa_s, NULL);
  1652. os_free(wpa_s->sme.sa_query_trans_id);
  1653. wpa_s->sme.sa_query_trans_id = NULL;
  1654. wpa_s->sme.sa_query_count = 0;
  1655. }
  1656. void sme_event_unprot_disconnect(struct wpa_supplicant *wpa_s, const u8 *sa,
  1657. const u8 *da, u16 reason_code)
  1658. {
  1659. struct wpa_ssid *ssid;
  1660. struct os_reltime now;
  1661. if (wpa_s->wpa_state != WPA_COMPLETED)
  1662. return;
  1663. ssid = wpa_s->current_ssid;
  1664. if (wpas_get_ssid_pmf(wpa_s, ssid) == NO_MGMT_FRAME_PROTECTION)
  1665. return;
  1666. if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
  1667. return;
  1668. if (reason_code != WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA &&
  1669. reason_code != WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA)
  1670. return;
  1671. if (wpa_s->sme.sa_query_count > 0)
  1672. return;
  1673. os_get_reltime(&now);
  1674. if (wpa_s->sme.last_unprot_disconnect.sec &&
  1675. !os_reltime_expired(&now, &wpa_s->sme.last_unprot_disconnect, 10))
  1676. return; /* limit SA Query procedure frequency */
  1677. wpa_s->sme.last_unprot_disconnect = now;
  1678. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Unprotected disconnect dropped - "
  1679. "possible AP/STA state mismatch - trigger SA Query");
  1680. sme_start_sa_query(wpa_s);
  1681. }
  1682. void sme_sa_query_rx(struct wpa_supplicant *wpa_s, const u8 *sa,
  1683. const u8 *data, size_t len)
  1684. {
  1685. int i;
  1686. if (wpa_s->sme.sa_query_trans_id == NULL ||
  1687. len < 1 + WLAN_SA_QUERY_TR_ID_LEN ||
  1688. data[0] != WLAN_SA_QUERY_RESPONSE)
  1689. return;
  1690. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Received SA Query response from "
  1691. MACSTR " (trans_id %02x%02x)", MAC2STR(sa), data[1], data[2]);
  1692. if (os_memcmp(sa, wpa_s->bssid, ETH_ALEN) != 0)
  1693. return;
  1694. for (i = 0; i < wpa_s->sme.sa_query_count; i++) {
  1695. if (os_memcmp(wpa_s->sme.sa_query_trans_id +
  1696. i * WLAN_SA_QUERY_TR_ID_LEN,
  1697. data + 1, WLAN_SA_QUERY_TR_ID_LEN) == 0)
  1698. break;
  1699. }
  1700. if (i >= wpa_s->sme.sa_query_count) {
  1701. wpa_dbg(wpa_s, MSG_DEBUG, "SME: No matching SA Query "
  1702. "transaction identifier found");
  1703. return;
  1704. }
  1705. wpa_dbg(wpa_s, MSG_DEBUG, "SME: Reply to pending SA Query received "
  1706. "from " MACSTR, MAC2STR(sa));
  1707. sme_stop_sa_query(wpa_s);
  1708. }
  1709. #endif /* CONFIG_IEEE80211W */