hs20_supplicant.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  1. /*
  2. * Copyright (c) 2009, Atheros Communications, Inc.
  3. * Copyright (c) 2011-2013, Qualcomm Atheros, Inc.
  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 <sys/stat.h>
  10. #include "common.h"
  11. #include "eloop.h"
  12. #include "common/ieee802_11_common.h"
  13. #include "common/ieee802_11_defs.h"
  14. #include "common/gas.h"
  15. #include "common/wpa_ctrl.h"
  16. #include "rsn_supp/wpa.h"
  17. #include "wpa_supplicant_i.h"
  18. #include "driver_i.h"
  19. #include "config.h"
  20. #include "scan.h"
  21. #include "bss.h"
  22. #include "blacklist.h"
  23. #include "gas_query.h"
  24. #include "interworking.h"
  25. #include "hs20_supplicant.h"
  26. #include "base64.h"
  27. #define OSU_MAX_ITEMS 10
  28. struct osu_lang_string {
  29. char lang[4];
  30. char text[253];
  31. };
  32. struct osu_icon {
  33. u16 width;
  34. u16 height;
  35. char lang[4];
  36. char icon_type[256];
  37. char filename[256];
  38. unsigned int id;
  39. unsigned int failed:1;
  40. };
  41. struct osu_provider {
  42. u8 bssid[ETH_ALEN];
  43. u8 osu_ssid[SSID_MAX_LEN];
  44. u8 osu_ssid_len;
  45. char server_uri[256];
  46. u32 osu_methods; /* bit 0 = OMA-DM, bit 1 = SOAP-XML SPP */
  47. char osu_nai[256];
  48. struct osu_lang_string friendly_name[OSU_MAX_ITEMS];
  49. size_t friendly_name_count;
  50. struct osu_lang_string serv_desc[OSU_MAX_ITEMS];
  51. size_t serv_desc_count;
  52. struct osu_icon icon[OSU_MAX_ITEMS];
  53. size_t icon_count;
  54. };
  55. void hs20_configure_frame_filters(struct wpa_supplicant *wpa_s)
  56. {
  57. struct wpa_bss *bss = wpa_s->current_bss;
  58. u8 *bssid = wpa_s->bssid;
  59. const u8 *ie;
  60. const u8 *ext_capa;
  61. u32 filter = 0;
  62. if (!bss || !is_hs20_network(wpa_s, wpa_s->current_ssid, bss)) {
  63. wpa_printf(MSG_DEBUG,
  64. "Not configuring frame filtering - BSS " MACSTR
  65. " is not a Hotspot 2.0 network", MAC2STR(bssid));
  66. return;
  67. }
  68. ie = wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE);
  69. /* Check if DGAF disabled bit is zero (5th byte in the IE) */
  70. if (!ie || ie[1] < 5)
  71. wpa_printf(MSG_DEBUG,
  72. "Not configuring frame filtering - Can't extract DGAF bit");
  73. else if (!(ie[6] & HS20_DGAF_DISABLED))
  74. filter |= WPA_DATA_FRAME_FILTER_FLAG_GTK;
  75. ext_capa = wpa_bss_get_ie(bss, WLAN_EID_EXT_CAPAB);
  76. if (!ext_capa || ext_capa[1] < 2) {
  77. wpa_printf(MSG_DEBUG,
  78. "Not configuring frame filtering - Can't extract Proxy ARP bit");
  79. return;
  80. }
  81. /* Check if Proxy ARP is enabled (2nd byte in the IE) */
  82. if (ext_capa[3] & BIT(4))
  83. filter |= WPA_DATA_FRAME_FILTER_FLAG_ARP |
  84. WPA_DATA_FRAME_FILTER_FLAG_NA;
  85. wpa_drv_configure_frame_filters(wpa_s, filter);
  86. }
  87. void wpas_hs20_add_indication(struct wpabuf *buf, int pps_mo_id)
  88. {
  89. u8 conf;
  90. wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
  91. wpabuf_put_u8(buf, pps_mo_id >= 0 ? 7 : 5);
  92. wpabuf_put_be24(buf, OUI_WFA);
  93. wpabuf_put_u8(buf, HS20_INDICATION_OUI_TYPE);
  94. conf = HS20_VERSION;
  95. if (pps_mo_id >= 0)
  96. conf |= HS20_PPS_MO_ID_PRESENT;
  97. wpabuf_put_u8(buf, conf);
  98. if (pps_mo_id >= 0)
  99. wpabuf_put_le16(buf, pps_mo_id);
  100. }
  101. int is_hs20_network(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
  102. struct wpa_bss *bss)
  103. {
  104. if (!wpa_s->conf->hs20 || !ssid)
  105. return 0;
  106. if (ssid->parent_cred)
  107. return 1;
  108. if (bss && !wpa_bss_get_vendor_ie(bss, HS20_IE_VENDOR_TYPE))
  109. return 0;
  110. /*
  111. * This may catch some non-Hotspot 2.0 cases, but it is safer to do that
  112. * than cause Hotspot 2.0 connections without indication element getting
  113. * added. Non-Hotspot 2.0 APs should ignore the unknown vendor element.
  114. */
  115. if (!(ssid->key_mgmt & WPA_KEY_MGMT_IEEE8021X))
  116. return 0;
  117. if (!(ssid->pairwise_cipher & WPA_CIPHER_CCMP))
  118. return 0;
  119. if (ssid->proto != WPA_PROTO_RSN)
  120. return 0;
  121. return 1;
  122. }
  123. int hs20_get_pps_mo_id(struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
  124. {
  125. struct wpa_cred *cred;
  126. if (ssid == NULL)
  127. return 0;
  128. if (ssid->update_identifier)
  129. return ssid->update_identifier;
  130. if (ssid->parent_cred == NULL)
  131. return 0;
  132. for (cred = wpa_s->conf->cred; cred; cred = cred->next) {
  133. if (ssid->parent_cred == cred)
  134. return cred->update_identifier;
  135. }
  136. return 0;
  137. }
  138. void hs20_put_anqp_req(u32 stypes, const u8 *payload, size_t payload_len,
  139. struct wpabuf *buf)
  140. {
  141. u8 *len_pos;
  142. if (buf == NULL)
  143. return;
  144. len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC);
  145. wpabuf_put_be24(buf, OUI_WFA);
  146. wpabuf_put_u8(buf, HS20_ANQP_OUI_TYPE);
  147. if (stypes == BIT(HS20_STYPE_NAI_HOME_REALM_QUERY)) {
  148. wpabuf_put_u8(buf, HS20_STYPE_NAI_HOME_REALM_QUERY);
  149. wpabuf_put_u8(buf, 0); /* Reserved */
  150. if (payload)
  151. wpabuf_put_data(buf, payload, payload_len);
  152. } else if (stypes == BIT(HS20_STYPE_ICON_REQUEST)) {
  153. wpabuf_put_u8(buf, HS20_STYPE_ICON_REQUEST);
  154. wpabuf_put_u8(buf, 0); /* Reserved */
  155. if (payload)
  156. wpabuf_put_data(buf, payload, payload_len);
  157. } else {
  158. u8 i;
  159. wpabuf_put_u8(buf, HS20_STYPE_QUERY_LIST);
  160. wpabuf_put_u8(buf, 0); /* Reserved */
  161. for (i = 0; i < 32; i++) {
  162. if (stypes & BIT(i))
  163. wpabuf_put_u8(buf, i);
  164. }
  165. }
  166. gas_anqp_set_element_len(buf, len_pos);
  167. gas_anqp_set_len(buf);
  168. }
  169. struct wpabuf * hs20_build_anqp_req(u32 stypes, const u8 *payload,
  170. size_t payload_len)
  171. {
  172. struct wpabuf *buf;
  173. buf = gas_anqp_build_initial_req(0, 100 + payload_len);
  174. if (buf == NULL)
  175. return NULL;
  176. hs20_put_anqp_req(stypes, payload, payload_len, buf);
  177. return buf;
  178. }
  179. int hs20_anqp_send_req(struct wpa_supplicant *wpa_s, const u8 *dst, u32 stypes,
  180. const u8 *payload, size_t payload_len, int inmem)
  181. {
  182. struct wpabuf *buf;
  183. int ret = 0;
  184. int freq;
  185. struct wpa_bss *bss;
  186. int res;
  187. struct icon_entry *icon_entry;
  188. bss = wpa_bss_get_bssid(wpa_s, dst);
  189. if (!bss) {
  190. wpa_printf(MSG_WARNING,
  191. "ANQP: Cannot send query to unknown BSS "
  192. MACSTR, MAC2STR(dst));
  193. return -1;
  194. }
  195. wpa_bss_anqp_unshare_alloc(bss);
  196. freq = bss->freq;
  197. wpa_printf(MSG_DEBUG, "HS20: ANQP Query Request to " MACSTR " for "
  198. "subtypes 0x%x", MAC2STR(dst), stypes);
  199. buf = hs20_build_anqp_req(stypes, payload, payload_len);
  200. if (buf == NULL)
  201. return -1;
  202. res = gas_query_req(wpa_s->gas, dst, freq, buf, anqp_resp_cb, wpa_s);
  203. if (res < 0) {
  204. wpa_printf(MSG_DEBUG, "ANQP: Failed to send Query Request");
  205. wpabuf_free(buf);
  206. return -1;
  207. } else
  208. wpa_printf(MSG_DEBUG, "ANQP: Query started with dialog token "
  209. "%u", res);
  210. if (inmem) {
  211. icon_entry = os_zalloc(sizeof(struct icon_entry));
  212. if (!icon_entry)
  213. return -1;
  214. os_memcpy(icon_entry->bssid, dst, ETH_ALEN);
  215. icon_entry->file_name = os_malloc(payload_len + 1);
  216. if (!icon_entry->file_name) {
  217. os_free(icon_entry);
  218. return -1;
  219. }
  220. os_memcpy(icon_entry->file_name, payload, payload_len);
  221. icon_entry->file_name[payload_len] = '\0';
  222. icon_entry->dialog_token = res;
  223. dl_list_add(&wpa_s->icon_head, &icon_entry->list);
  224. }
  225. return ret;
  226. }
  227. static struct icon_entry * hs20_find_icon(struct wpa_supplicant *wpa_s,
  228. const u8 *bssid,
  229. const char *file_name)
  230. {
  231. struct icon_entry *icon;
  232. dl_list_for_each(icon, &wpa_s->icon_head, struct icon_entry, list) {
  233. if (os_memcmp(icon->bssid, bssid, ETH_ALEN) == 0 &&
  234. os_strcmp(icon->file_name, file_name) == 0 && icon->image)
  235. return icon;
  236. }
  237. return NULL;
  238. }
  239. int hs20_get_icon(struct wpa_supplicant *wpa_s, const u8 *bssid,
  240. const char *file_name, size_t offset, size_t size,
  241. char *reply, size_t buf_len)
  242. {
  243. struct icon_entry *icon;
  244. size_t out_size;
  245. unsigned char *b64;
  246. size_t b64_size;
  247. int reply_size;
  248. wpa_printf(MSG_DEBUG, "HS20: Get icon " MACSTR " %s @ %u +%u (%u)",
  249. MAC2STR(bssid), file_name, (unsigned int) offset,
  250. (unsigned int) size, (unsigned int) buf_len);
  251. icon = hs20_find_icon(wpa_s, bssid, file_name);
  252. if (!icon || !icon->image || offset >= icon->image_len)
  253. return -1;
  254. if (size > icon->image_len - offset)
  255. size = icon->image_len - offset;
  256. out_size = buf_len - 3 /* max base64 padding */;
  257. if (size * 4 > out_size * 3)
  258. size = out_size * 3 / 4;
  259. if (size == 0)
  260. return -1;
  261. b64 = base64_encode(&icon->image[offset], size, &b64_size);
  262. if (buf_len >= b64_size) {
  263. os_memcpy(reply, b64, b64_size);
  264. reply_size = b64_size;
  265. } else {
  266. reply_size = -1;
  267. }
  268. os_free(b64);
  269. return reply_size;
  270. }
  271. static void hs20_free_icon_entry(struct icon_entry *icon)
  272. {
  273. wpa_printf(MSG_DEBUG, "HS20: Free stored icon from " MACSTR
  274. " dialog_token=%u file_name=%s image_len=%u",
  275. MAC2STR(icon->bssid), icon->dialog_token,
  276. icon->file_name ? icon->file_name : "N/A",
  277. (unsigned int) icon->image_len);
  278. os_free(icon->file_name);
  279. os_free(icon->image);
  280. os_free(icon);
  281. }
  282. int hs20_del_icon(struct wpa_supplicant *wpa_s, const u8 *bssid,
  283. const char *file_name)
  284. {
  285. struct icon_entry *icon, *tmp;
  286. int count = 0;
  287. if (!bssid)
  288. wpa_printf(MSG_DEBUG, "HS20: Delete all stored icons");
  289. else if (!file_name)
  290. wpa_printf(MSG_DEBUG, "HS20: Delete all stored icons for "
  291. MACSTR, MAC2STR(bssid));
  292. else
  293. wpa_printf(MSG_DEBUG, "HS20: Delete stored icons for "
  294. MACSTR " file name %s", MAC2STR(bssid), file_name);
  295. dl_list_for_each_safe(icon, tmp, &wpa_s->icon_head, struct icon_entry,
  296. list) {
  297. if ((!bssid || os_memcmp(icon->bssid, bssid, ETH_ALEN) == 0) &&
  298. (!file_name ||
  299. os_strcmp(icon->file_name, file_name) == 0)) {
  300. dl_list_del(&icon->list);
  301. hs20_free_icon_entry(icon);
  302. count++;
  303. }
  304. }
  305. return count == 0 ? -1 : 0;
  306. }
  307. static void hs20_set_osu_access_permission(const char *osu_dir,
  308. const char *fname)
  309. {
  310. struct stat statbuf;
  311. /* Get OSU directory information */
  312. if (stat(osu_dir, &statbuf) < 0) {
  313. wpa_printf(MSG_WARNING, "Cannot stat the OSU directory %s",
  314. osu_dir);
  315. return;
  316. }
  317. if (chmod(fname, statbuf.st_mode) < 0) {
  318. wpa_printf(MSG_WARNING,
  319. "Cannot change the permissions for %s", fname);
  320. return;
  321. }
  322. if (chown(fname, statbuf.st_uid, statbuf.st_gid) < 0) {
  323. wpa_printf(MSG_WARNING, "Cannot change the ownership for %s",
  324. fname);
  325. }
  326. }
  327. static void hs20_remove_duplicate_icons(struct wpa_supplicant *wpa_s,
  328. struct icon_entry *new_icon)
  329. {
  330. struct icon_entry *icon, *tmp;
  331. dl_list_for_each_safe(icon, tmp, &wpa_s->icon_head, struct icon_entry,
  332. list) {
  333. if (icon == new_icon)
  334. continue;
  335. if (os_memcmp(icon->bssid, new_icon->bssid, ETH_ALEN) == 0 &&
  336. os_strcmp(icon->file_name, new_icon->file_name) == 0) {
  337. dl_list_del(&icon->list);
  338. hs20_free_icon_entry(icon);
  339. }
  340. }
  341. }
  342. static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
  343. const u8 *sa, const u8 *pos,
  344. size_t slen, u8 dialog_token)
  345. {
  346. char fname[256];
  347. int png;
  348. FILE *f;
  349. u16 data_len;
  350. struct icon_entry *icon;
  351. dl_list_for_each(icon, &wpa_s->icon_head, struct icon_entry, list) {
  352. if (icon->dialog_token == dialog_token && !icon->image &&
  353. os_memcmp(icon->bssid, sa, ETH_ALEN) == 0) {
  354. icon->image = os_malloc(slen);
  355. if (!icon->image)
  356. return -1;
  357. os_memcpy(icon->image, pos, slen);
  358. icon->image_len = slen;
  359. hs20_remove_duplicate_icons(wpa_s, icon);
  360. wpa_msg(wpa_s, MSG_INFO,
  361. "RX-HS20-ICON " MACSTR " %s %u",
  362. MAC2STR(sa), icon->file_name,
  363. (unsigned int) icon->image_len);
  364. return 0;
  365. }
  366. }
  367. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR " Icon Binary File",
  368. MAC2STR(sa));
  369. if (slen < 4) {
  370. wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
  371. "value from " MACSTR, MAC2STR(sa));
  372. return -1;
  373. }
  374. wpa_printf(MSG_DEBUG, "HS 2.0: Download Status Code %u", *pos);
  375. if (*pos != 0)
  376. return -1;
  377. pos++;
  378. slen--;
  379. if ((size_t) 1 + pos[0] > slen) {
  380. wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
  381. "value from " MACSTR, MAC2STR(sa));
  382. return -1;
  383. }
  384. wpa_hexdump_ascii(MSG_DEBUG, "Icon Type", pos + 1, pos[0]);
  385. png = os_strncasecmp((char *) pos + 1, "image/png", 9) == 0;
  386. slen -= 1 + pos[0];
  387. pos += 1 + pos[0];
  388. if (slen < 2) {
  389. wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
  390. "value from " MACSTR, MAC2STR(sa));
  391. return -1;
  392. }
  393. data_len = WPA_GET_LE16(pos);
  394. pos += 2;
  395. slen -= 2;
  396. if (data_len > slen) {
  397. wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short Icon Binary File "
  398. "value from " MACSTR, MAC2STR(sa));
  399. return -1;
  400. }
  401. wpa_printf(MSG_DEBUG, "Icon Binary Data: %u bytes", data_len);
  402. if (wpa_s->conf->osu_dir == NULL)
  403. return -1;
  404. wpa_s->osu_icon_id++;
  405. if (wpa_s->osu_icon_id == 0)
  406. wpa_s->osu_icon_id++;
  407. snprintf(fname, sizeof(fname), "%s/osu-icon-%u.%s",
  408. wpa_s->conf->osu_dir, wpa_s->osu_icon_id,
  409. png ? "png" : "icon");
  410. f = fopen(fname, "wb");
  411. if (f == NULL)
  412. return -1;
  413. hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
  414. if (fwrite(pos, slen, 1, f) != 1) {
  415. fclose(f);
  416. unlink(fname);
  417. return -1;
  418. }
  419. fclose(f);
  420. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP-ICON %s", fname);
  421. return 0;
  422. }
  423. static void hs20_continue_icon_fetch(void *eloop_ctx, void *sock_ctx)
  424. {
  425. struct wpa_supplicant *wpa_s = eloop_ctx;
  426. if (wpa_s->fetch_osu_icon_in_progress)
  427. hs20_next_osu_icon(wpa_s);
  428. }
  429. static void hs20_osu_icon_fetch_result(struct wpa_supplicant *wpa_s, int res)
  430. {
  431. size_t i, j;
  432. struct os_reltime now, tmp;
  433. int dur;
  434. os_get_reltime(&now);
  435. os_reltime_sub(&now, &wpa_s->osu_icon_fetch_start, &tmp);
  436. dur = tmp.sec * 1000 + tmp.usec / 1000;
  437. wpa_printf(MSG_DEBUG, "HS 2.0: Icon fetch dur=%d ms res=%d",
  438. dur, res);
  439. for (i = 0; i < wpa_s->osu_prov_count; i++) {
  440. struct osu_provider *osu = &wpa_s->osu_prov[i];
  441. for (j = 0; j < osu->icon_count; j++) {
  442. struct osu_icon *icon = &osu->icon[j];
  443. if (icon->id || icon->failed)
  444. continue;
  445. if (res < 0)
  446. icon->failed = 1;
  447. else
  448. icon->id = wpa_s->osu_icon_id;
  449. return;
  450. }
  451. }
  452. }
  453. void hs20_parse_rx_hs20_anqp_resp(struct wpa_supplicant *wpa_s,
  454. struct wpa_bss *bss, const u8 *sa,
  455. const u8 *data, size_t slen, u8 dialog_token)
  456. {
  457. const u8 *pos = data;
  458. u8 subtype;
  459. struct wpa_bss_anqp *anqp = NULL;
  460. int ret;
  461. if (slen < 2)
  462. return;
  463. if (bss)
  464. anqp = bss->anqp;
  465. subtype = *pos++;
  466. slen--;
  467. pos++; /* Reserved */
  468. slen--;
  469. switch (subtype) {
  470. case HS20_STYPE_CAPABILITY_LIST:
  471. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  472. " HS Capability List", MAC2STR(sa));
  473. wpa_hexdump_ascii(MSG_DEBUG, "HS Capability List", pos, slen);
  474. if (anqp) {
  475. wpabuf_free(anqp->hs20_capability_list);
  476. anqp->hs20_capability_list =
  477. wpabuf_alloc_copy(pos, slen);
  478. }
  479. break;
  480. case HS20_STYPE_OPERATOR_FRIENDLY_NAME:
  481. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  482. " Operator Friendly Name", MAC2STR(sa));
  483. wpa_hexdump_ascii(MSG_DEBUG, "oper friendly name", pos, slen);
  484. if (anqp) {
  485. wpabuf_free(anqp->hs20_operator_friendly_name);
  486. anqp->hs20_operator_friendly_name =
  487. wpabuf_alloc_copy(pos, slen);
  488. }
  489. break;
  490. case HS20_STYPE_WAN_METRICS:
  491. wpa_hexdump(MSG_DEBUG, "WAN Metrics", pos, slen);
  492. if (slen < 13) {
  493. wpa_dbg(wpa_s, MSG_DEBUG, "HS 2.0: Too short WAN "
  494. "Metrics value from " MACSTR, MAC2STR(sa));
  495. break;
  496. }
  497. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  498. " WAN Metrics %02x:%u:%u:%u:%u:%u", MAC2STR(sa),
  499. pos[0], WPA_GET_LE32(pos + 1), WPA_GET_LE32(pos + 5),
  500. pos[9], pos[10], WPA_GET_LE16(pos + 11));
  501. if (anqp) {
  502. wpabuf_free(anqp->hs20_wan_metrics);
  503. anqp->hs20_wan_metrics = wpabuf_alloc_copy(pos, slen);
  504. }
  505. break;
  506. case HS20_STYPE_CONNECTION_CAPABILITY:
  507. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  508. " Connection Capability", MAC2STR(sa));
  509. wpa_hexdump_ascii(MSG_DEBUG, "conn capability", pos, slen);
  510. if (anqp) {
  511. wpabuf_free(anqp->hs20_connection_capability);
  512. anqp->hs20_connection_capability =
  513. wpabuf_alloc_copy(pos, slen);
  514. }
  515. break;
  516. case HS20_STYPE_OPERATING_CLASS:
  517. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  518. " Operating Class", MAC2STR(sa));
  519. wpa_hexdump_ascii(MSG_DEBUG, "Operating Class", pos, slen);
  520. if (anqp) {
  521. wpabuf_free(anqp->hs20_operating_class);
  522. anqp->hs20_operating_class =
  523. wpabuf_alloc_copy(pos, slen);
  524. }
  525. break;
  526. case HS20_STYPE_OSU_PROVIDERS_LIST:
  527. wpa_msg(wpa_s, MSG_INFO, "RX-HS20-ANQP " MACSTR
  528. " OSU Providers list", MAC2STR(sa));
  529. wpa_s->num_prov_found++;
  530. if (anqp) {
  531. wpabuf_free(anqp->hs20_osu_providers_list);
  532. anqp->hs20_osu_providers_list =
  533. wpabuf_alloc_copy(pos, slen);
  534. }
  535. break;
  536. case HS20_STYPE_ICON_BINARY_FILE:
  537. ret = hs20_process_icon_binary_file(wpa_s, sa, pos, slen,
  538. dialog_token);
  539. if (wpa_s->fetch_osu_icon_in_progress) {
  540. hs20_osu_icon_fetch_result(wpa_s, ret);
  541. eloop_cancel_timeout(hs20_continue_icon_fetch,
  542. wpa_s, NULL);
  543. eloop_register_timeout(0, 0, hs20_continue_icon_fetch,
  544. wpa_s, NULL);
  545. }
  546. break;
  547. default:
  548. wpa_printf(MSG_DEBUG, "HS20: Unsupported subtype %u", subtype);
  549. break;
  550. }
  551. }
  552. void hs20_notify_parse_done(struct wpa_supplicant *wpa_s)
  553. {
  554. if (!wpa_s->fetch_osu_icon_in_progress)
  555. return;
  556. if (eloop_is_timeout_registered(hs20_continue_icon_fetch, wpa_s, NULL))
  557. return;
  558. /*
  559. * We are going through icon fetch, but no icon response was received.
  560. * Assume this means the current AP could not provide an answer to avoid
  561. * getting stuck in fetch iteration.
  562. */
  563. hs20_icon_fetch_failed(wpa_s);
  564. }
  565. static void hs20_free_osu_prov_entry(struct osu_provider *prov)
  566. {
  567. }
  568. void hs20_free_osu_prov(struct wpa_supplicant *wpa_s)
  569. {
  570. size_t i;
  571. for (i = 0; i < wpa_s->osu_prov_count; i++)
  572. hs20_free_osu_prov_entry(&wpa_s->osu_prov[i]);
  573. os_free(wpa_s->osu_prov);
  574. wpa_s->osu_prov = NULL;
  575. wpa_s->osu_prov_count = 0;
  576. }
  577. static void hs20_osu_fetch_done(struct wpa_supplicant *wpa_s)
  578. {
  579. char fname[256];
  580. FILE *f;
  581. size_t i, j;
  582. wpa_s->fetch_osu_info = 0;
  583. wpa_s->fetch_osu_icon_in_progress = 0;
  584. if (wpa_s->conf->osu_dir == NULL) {
  585. hs20_free_osu_prov(wpa_s);
  586. wpa_s->fetch_anqp_in_progress = 0;
  587. return;
  588. }
  589. snprintf(fname, sizeof(fname), "%s/osu-providers.txt",
  590. wpa_s->conf->osu_dir);
  591. f = fopen(fname, "w");
  592. if (f == NULL) {
  593. hs20_free_osu_prov(wpa_s);
  594. wpa_s->fetch_anqp_in_progress = 0;
  595. return;
  596. }
  597. hs20_set_osu_access_permission(wpa_s->conf->osu_dir, fname);
  598. for (i = 0; i < wpa_s->osu_prov_count; i++) {
  599. struct osu_provider *osu = &wpa_s->osu_prov[i];
  600. if (i > 0)
  601. fprintf(f, "\n");
  602. fprintf(f, "OSU-PROVIDER " MACSTR "\n"
  603. "uri=%s\n"
  604. "methods=%08x\n",
  605. MAC2STR(osu->bssid), osu->server_uri, osu->osu_methods);
  606. if (osu->osu_ssid_len) {
  607. fprintf(f, "osu_ssid=%s\n",
  608. wpa_ssid_txt(osu->osu_ssid,
  609. osu->osu_ssid_len));
  610. }
  611. if (osu->osu_nai[0])
  612. fprintf(f, "osu_nai=%s\n", osu->osu_nai);
  613. for (j = 0; j < osu->friendly_name_count; j++) {
  614. fprintf(f, "friendly_name=%s:%s\n",
  615. osu->friendly_name[j].lang,
  616. osu->friendly_name[j].text);
  617. }
  618. for (j = 0; j < osu->serv_desc_count; j++) {
  619. fprintf(f, "desc=%s:%s\n",
  620. osu->serv_desc[j].lang,
  621. osu->serv_desc[j].text);
  622. }
  623. for (j = 0; j < osu->icon_count; j++) {
  624. struct osu_icon *icon = &osu->icon[j];
  625. if (icon->failed)
  626. continue; /* could not fetch icon */
  627. fprintf(f, "icon=%u:%u:%u:%s:%s:%s\n",
  628. icon->id, icon->width, icon->height, icon->lang,
  629. icon->icon_type, icon->filename);
  630. }
  631. }
  632. fclose(f);
  633. hs20_free_osu_prov(wpa_s);
  634. wpa_msg(wpa_s, MSG_INFO, "OSU provider fetch completed");
  635. wpa_s->fetch_anqp_in_progress = 0;
  636. }
  637. void hs20_next_osu_icon(struct wpa_supplicant *wpa_s)
  638. {
  639. size_t i, j;
  640. wpa_printf(MSG_DEBUG, "HS 2.0: Ready to fetch next icon");
  641. for (i = 0; i < wpa_s->osu_prov_count; i++) {
  642. struct osu_provider *osu = &wpa_s->osu_prov[i];
  643. for (j = 0; j < osu->icon_count; j++) {
  644. struct osu_icon *icon = &osu->icon[j];
  645. if (icon->id || icon->failed)
  646. continue;
  647. wpa_printf(MSG_DEBUG, "HS 2.0: Try to fetch icon '%s' "
  648. "from " MACSTR, icon->filename,
  649. MAC2STR(osu->bssid));
  650. os_get_reltime(&wpa_s->osu_icon_fetch_start);
  651. if (hs20_anqp_send_req(wpa_s, osu->bssid,
  652. BIT(HS20_STYPE_ICON_REQUEST),
  653. (u8 *) icon->filename,
  654. os_strlen(icon->filename),
  655. 0) < 0) {
  656. icon->failed = 1;
  657. continue;
  658. }
  659. return;
  660. }
  661. }
  662. wpa_printf(MSG_DEBUG, "HS 2.0: No more icons to fetch");
  663. hs20_osu_fetch_done(wpa_s);
  664. }
  665. static void hs20_osu_add_prov(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
  666. const u8 *osu_ssid, u8 osu_ssid_len,
  667. const u8 *pos, size_t len)
  668. {
  669. struct osu_provider *prov;
  670. const u8 *end = pos + len;
  671. u16 len2;
  672. const u8 *pos2;
  673. u8 uri_len, osu_method_len, osu_nai_len;
  674. wpa_hexdump(MSG_DEBUG, "HS 2.0: Parsing OSU Provider", pos, len);
  675. prov = os_realloc_array(wpa_s->osu_prov,
  676. wpa_s->osu_prov_count + 1,
  677. sizeof(*prov));
  678. if (prov == NULL)
  679. return;
  680. wpa_s->osu_prov = prov;
  681. prov = &prov[wpa_s->osu_prov_count];
  682. os_memset(prov, 0, sizeof(*prov));
  683. os_memcpy(prov->bssid, bss->bssid, ETH_ALEN);
  684. os_memcpy(prov->osu_ssid, osu_ssid, osu_ssid_len);
  685. prov->osu_ssid_len = osu_ssid_len;
  686. /* OSU Friendly Name Length */
  687. if (end - pos < 2) {
  688. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
  689. "Friendly Name Length");
  690. return;
  691. }
  692. len2 = WPA_GET_LE16(pos);
  693. pos += 2;
  694. if (len2 > end - pos) {
  695. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
  696. "Friendly Name Duples");
  697. return;
  698. }
  699. pos2 = pos;
  700. pos += len2;
  701. /* OSU Friendly Name Duples */
  702. while (pos - pos2 >= 4 && prov->friendly_name_count < OSU_MAX_ITEMS) {
  703. struct osu_lang_string *f;
  704. if (1 + pos2[0] > pos - pos2 || pos2[0] < 3) {
  705. wpa_printf(MSG_DEBUG, "Invalid OSU Friendly Name");
  706. break;
  707. }
  708. f = &prov->friendly_name[prov->friendly_name_count++];
  709. os_memcpy(f->lang, pos2 + 1, 3);
  710. os_memcpy(f->text, pos2 + 1 + 3, pos2[0] - 3);
  711. pos2 += 1 + pos2[0];
  712. }
  713. /* OSU Server URI */
  714. if (end - pos < 1) {
  715. wpa_printf(MSG_DEBUG,
  716. "HS 2.0: Not enough room for OSU Server URI length");
  717. return;
  718. }
  719. uri_len = *pos++;
  720. if (uri_len > end - pos) {
  721. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Server "
  722. "URI");
  723. return;
  724. }
  725. os_memcpy(prov->server_uri, pos, uri_len);
  726. pos += uri_len;
  727. /* OSU Method list */
  728. if (end - pos < 1) {
  729. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Method "
  730. "list length");
  731. return;
  732. }
  733. osu_method_len = pos[0];
  734. if (osu_method_len > end - pos - 1) {
  735. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU Method "
  736. "list");
  737. return;
  738. }
  739. pos2 = pos + 1;
  740. pos += 1 + osu_method_len;
  741. while (pos2 < pos) {
  742. if (*pos2 < 32)
  743. prov->osu_methods |= BIT(*pos2);
  744. pos2++;
  745. }
  746. /* Icons Available Length */
  747. if (end - pos < 2) {
  748. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for Icons "
  749. "Available Length");
  750. return;
  751. }
  752. len2 = WPA_GET_LE16(pos);
  753. pos += 2;
  754. if (len2 > end - pos) {
  755. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for Icons "
  756. "Available");
  757. return;
  758. }
  759. pos2 = pos;
  760. pos += len2;
  761. /* Icons Available */
  762. while (pos2 < pos) {
  763. struct osu_icon *icon = &prov->icon[prov->icon_count];
  764. u8 flen;
  765. if (2 + 2 + 3 + 1 + 1 > pos - pos2) {
  766. wpa_printf(MSG_DEBUG, "HS 2.0: Invalid Icon Metadata");
  767. break;
  768. }
  769. icon->width = WPA_GET_LE16(pos2);
  770. pos2 += 2;
  771. icon->height = WPA_GET_LE16(pos2);
  772. pos2 += 2;
  773. os_memcpy(icon->lang, pos2, 3);
  774. pos2 += 3;
  775. flen = *pos2++;
  776. if (flen > pos - pos2) {
  777. wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon Type");
  778. break;
  779. }
  780. os_memcpy(icon->icon_type, pos2, flen);
  781. pos2 += flen;
  782. if (pos - pos2 < 1) {
  783. wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon "
  784. "Filename length");
  785. break;
  786. }
  787. flen = *pos2++;
  788. if (flen > pos - pos2) {
  789. wpa_printf(MSG_DEBUG, "HS 2.0: Not room for Icon "
  790. "Filename");
  791. break;
  792. }
  793. os_memcpy(icon->filename, pos2, flen);
  794. pos2 += flen;
  795. prov->icon_count++;
  796. }
  797. /* OSU_NAI */
  798. if (end - pos < 1) {
  799. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU_NAI");
  800. return;
  801. }
  802. osu_nai_len = *pos++;
  803. if (osu_nai_len > end - pos) {
  804. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU_NAI");
  805. return;
  806. }
  807. os_memcpy(prov->osu_nai, pos, osu_nai_len);
  808. pos += osu_nai_len;
  809. /* OSU Service Description Length */
  810. if (end - pos < 2) {
  811. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
  812. "Service Description Length");
  813. return;
  814. }
  815. len2 = WPA_GET_LE16(pos);
  816. pos += 2;
  817. if (len2 > end - pos) {
  818. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for OSU "
  819. "Service Description Duples");
  820. return;
  821. }
  822. pos2 = pos;
  823. pos += len2;
  824. /* OSU Service Description Duples */
  825. while (pos - pos2 >= 4 && prov->serv_desc_count < OSU_MAX_ITEMS) {
  826. struct osu_lang_string *f;
  827. u8 descr_len;
  828. descr_len = *pos2++;
  829. if (descr_len > pos - pos2 || descr_len < 3) {
  830. wpa_printf(MSG_DEBUG, "Invalid OSU Service "
  831. "Description");
  832. break;
  833. }
  834. f = &prov->serv_desc[prov->serv_desc_count++];
  835. os_memcpy(f->lang, pos2, 3);
  836. os_memcpy(f->text, pos2 + 3, descr_len - 3);
  837. pos2 += descr_len;
  838. }
  839. wpa_printf(MSG_DEBUG, "HS 2.0: Added OSU Provider through " MACSTR,
  840. MAC2STR(bss->bssid));
  841. wpa_s->osu_prov_count++;
  842. }
  843. void hs20_osu_icon_fetch(struct wpa_supplicant *wpa_s)
  844. {
  845. struct wpa_bss *bss;
  846. struct wpabuf *prov_anqp;
  847. const u8 *pos, *end;
  848. u16 len;
  849. const u8 *osu_ssid;
  850. u8 osu_ssid_len;
  851. u8 num_providers;
  852. hs20_free_osu_prov(wpa_s);
  853. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  854. if (bss->anqp == NULL)
  855. continue;
  856. prov_anqp = bss->anqp->hs20_osu_providers_list;
  857. if (prov_anqp == NULL)
  858. continue;
  859. wpa_printf(MSG_DEBUG, "HS 2.0: Parsing OSU Providers list from "
  860. MACSTR, MAC2STR(bss->bssid));
  861. wpa_hexdump_buf(MSG_DEBUG, "HS 2.0: OSU Providers list",
  862. prov_anqp);
  863. pos = wpabuf_head(prov_anqp);
  864. end = pos + wpabuf_len(prov_anqp);
  865. /* OSU SSID */
  866. if (end - pos < 1)
  867. continue;
  868. if (1 + pos[0] > end - pos) {
  869. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for "
  870. "OSU SSID");
  871. continue;
  872. }
  873. osu_ssid_len = *pos++;
  874. if (osu_ssid_len > SSID_MAX_LEN) {
  875. wpa_printf(MSG_DEBUG, "HS 2.0: Invalid OSU SSID "
  876. "Length %u", osu_ssid_len);
  877. continue;
  878. }
  879. osu_ssid = pos;
  880. pos += osu_ssid_len;
  881. if (end - pos < 1) {
  882. wpa_printf(MSG_DEBUG, "HS 2.0: Not enough room for "
  883. "Number of OSU Providers");
  884. continue;
  885. }
  886. num_providers = *pos++;
  887. wpa_printf(MSG_DEBUG, "HS 2.0: Number of OSU Providers: %u",
  888. num_providers);
  889. /* OSU Providers */
  890. while (end - pos > 2 && num_providers > 0) {
  891. num_providers--;
  892. len = WPA_GET_LE16(pos);
  893. pos += 2;
  894. if (len > (unsigned int) (end - pos))
  895. break;
  896. hs20_osu_add_prov(wpa_s, bss, osu_ssid,
  897. osu_ssid_len, pos, len);
  898. pos += len;
  899. }
  900. if (pos != end) {
  901. wpa_printf(MSG_DEBUG, "HS 2.0: Ignored %d bytes of "
  902. "extra data after OSU Providers",
  903. (int) (end - pos));
  904. }
  905. }
  906. wpa_s->fetch_osu_icon_in_progress = 1;
  907. hs20_next_osu_icon(wpa_s);
  908. }
  909. static void hs20_osu_scan_res_handler(struct wpa_supplicant *wpa_s,
  910. struct wpa_scan_results *scan_res)
  911. {
  912. wpa_printf(MSG_DEBUG, "OSU provisioning fetch scan completed");
  913. if (!wpa_s->fetch_osu_waiting_scan) {
  914. wpa_printf(MSG_DEBUG, "OSU fetch have been canceled");
  915. return;
  916. }
  917. wpa_s->network_select = 0;
  918. wpa_s->fetch_all_anqp = 1;
  919. wpa_s->fetch_osu_info = 1;
  920. wpa_s->fetch_osu_icon_in_progress = 0;
  921. interworking_start_fetch_anqp(wpa_s);
  922. }
  923. int hs20_fetch_osu(struct wpa_supplicant *wpa_s)
  924. {
  925. if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {
  926. wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
  927. "interface disabled");
  928. return -1;
  929. }
  930. if (wpa_s->scanning) {
  931. wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
  932. "scanning");
  933. return -1;
  934. }
  935. if (wpa_s->conf->osu_dir == NULL) {
  936. wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
  937. "osu_dir not configured");
  938. return -1;
  939. }
  940. if (wpa_s->fetch_anqp_in_progress || wpa_s->network_select) {
  941. wpa_printf(MSG_DEBUG, "HS 2.0: Cannot start fetch_osu - "
  942. "fetch in progress (%d, %d)",
  943. wpa_s->fetch_anqp_in_progress,
  944. wpa_s->network_select);
  945. return -1;
  946. }
  947. wpa_msg(wpa_s, MSG_INFO, "Starting OSU provisioning information fetch");
  948. wpa_s->num_osu_scans = 0;
  949. wpa_s->num_prov_found = 0;
  950. hs20_start_osu_scan(wpa_s);
  951. return 0;
  952. }
  953. void hs20_start_osu_scan(struct wpa_supplicant *wpa_s)
  954. {
  955. wpa_s->fetch_osu_waiting_scan = 1;
  956. wpa_s->num_osu_scans++;
  957. wpa_s->scan_req = MANUAL_SCAN_REQ;
  958. wpa_s->scan_res_handler = hs20_osu_scan_res_handler;
  959. wpa_supplicant_req_scan(wpa_s, 0, 0);
  960. }
  961. void hs20_cancel_fetch_osu(struct wpa_supplicant *wpa_s)
  962. {
  963. wpa_printf(MSG_DEBUG, "Cancel OSU fetch");
  964. interworking_stop_fetch_anqp(wpa_s);
  965. wpa_s->fetch_osu_waiting_scan = 0;
  966. wpa_s->network_select = 0;
  967. wpa_s->fetch_osu_info = 0;
  968. wpa_s->fetch_osu_icon_in_progress = 0;
  969. }
  970. void hs20_icon_fetch_failed(struct wpa_supplicant *wpa_s)
  971. {
  972. hs20_osu_icon_fetch_result(wpa_s, -1);
  973. eloop_cancel_timeout(hs20_continue_icon_fetch, wpa_s, NULL);
  974. eloop_register_timeout(0, 0, hs20_continue_icon_fetch, wpa_s, NULL);
  975. }
  976. void hs20_rx_subscription_remediation(struct wpa_supplicant *wpa_s,
  977. const char *url, u8 osu_method)
  978. {
  979. if (url)
  980. wpa_msg(wpa_s, MSG_INFO, HS20_SUBSCRIPTION_REMEDIATION "%u %s",
  981. osu_method, url);
  982. else
  983. wpa_msg(wpa_s, MSG_INFO, HS20_SUBSCRIPTION_REMEDIATION);
  984. }
  985. void hs20_rx_deauth_imminent_notice(struct wpa_supplicant *wpa_s, u8 code,
  986. u16 reauth_delay, const char *url)
  987. {
  988. if (!wpa_sm_pmf_enabled(wpa_s->wpa)) {
  989. wpa_printf(MSG_DEBUG, "HS 2.0: Ignore deauthentication imminent notice since PMF was not enabled");
  990. return;
  991. }
  992. wpa_msg(wpa_s, MSG_INFO, HS20_DEAUTH_IMMINENT_NOTICE "%u %u %s",
  993. code, reauth_delay, url);
  994. if (code == HS20_DEAUTH_REASON_CODE_BSS) {
  995. wpa_printf(MSG_DEBUG, "HS 2.0: Add BSS to blacklist");
  996. wpa_blacklist_add(wpa_s, wpa_s->bssid);
  997. /* TODO: For now, disable full ESS since some drivers may not
  998. * support disabling per BSS. */
  999. if (wpa_s->current_ssid) {
  1000. struct os_reltime now;
  1001. os_get_reltime(&now);
  1002. if (now.sec + reauth_delay <=
  1003. wpa_s->current_ssid->disabled_until.sec)
  1004. return;
  1005. wpa_printf(MSG_DEBUG, "HS 2.0: Disable network for %u seconds (BSS)",
  1006. reauth_delay);
  1007. wpa_s->current_ssid->disabled_until.sec =
  1008. now.sec + reauth_delay;
  1009. }
  1010. }
  1011. if (code == HS20_DEAUTH_REASON_CODE_ESS && wpa_s->current_ssid) {
  1012. struct os_reltime now;
  1013. os_get_reltime(&now);
  1014. if (now.sec + reauth_delay <=
  1015. wpa_s->current_ssid->disabled_until.sec)
  1016. return;
  1017. wpa_printf(MSG_DEBUG, "HS 2.0: Disable network for %u seconds",
  1018. reauth_delay);
  1019. wpa_s->current_ssid->disabled_until.sec =
  1020. now.sec + reauth_delay;
  1021. }
  1022. }
  1023. void hs20_init(struct wpa_supplicant *wpa_s)
  1024. {
  1025. dl_list_init(&wpa_s->icon_head);
  1026. }
  1027. void hs20_deinit(struct wpa_supplicant *wpa_s)
  1028. {
  1029. eloop_cancel_timeout(hs20_continue_icon_fetch, wpa_s, NULL);
  1030. hs20_free_osu_prov(wpa_s);
  1031. if (wpa_s->icon_head.next)
  1032. hs20_del_icon(wpa_s, NULL, NULL);
  1033. }