wps_supplicant.c 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. /*
  2. * wpa_supplicant / WPS integration
  3. * Copyright (c) 2008-2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #include "includes.h"
  15. #include "common.h"
  16. #include "eloop.h"
  17. #include "uuid.h"
  18. #include "crypto/dh_group5.h"
  19. #include "common/ieee802_11_defs.h"
  20. #include "common/ieee802_11_common.h"
  21. #include "common/wpa_common.h"
  22. #include "common/wpa_ctrl.h"
  23. #include "eap_common/eap_wsc_common.h"
  24. #include "eap_peer/eap.h"
  25. #include "rsn_supp/wpa.h"
  26. #include "config.h"
  27. #include "wpa_supplicant_i.h"
  28. #include "driver_i.h"
  29. #include "notify.h"
  30. #include "blacklist.h"
  31. #include "bss.h"
  32. #include "scan.h"
  33. #include "ap.h"
  34. #include "p2p/p2p.h"
  35. #include "p2p_supplicant.h"
  36. #include "wps_supplicant.h"
  37. #ifndef WPS_PIN_SCAN_IGNORE_SEL_REG
  38. #define WPS_PIN_SCAN_IGNORE_SEL_REG 3
  39. #endif /* WPS_PIN_SCAN_IGNORE_SEL_REG */
  40. static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx);
  41. static void wpas_clear_wps(struct wpa_supplicant *wpa_s);
  42. int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
  43. {
  44. if (!wpa_s->wps_success &&
  45. wpa_s->current_ssid &&
  46. eap_is_wps_pin_enrollee(&wpa_s->current_ssid->eap)) {
  47. const u8 *bssid = wpa_s->bssid;
  48. if (is_zero_ether_addr(bssid))
  49. bssid = wpa_s->pending_bssid;
  50. wpa_printf(MSG_DEBUG, "WPS: PIN registration with " MACSTR
  51. " did not succeed - continue trying to find "
  52. "suitable AP", MAC2STR(bssid));
  53. wpa_blacklist_add(wpa_s, bssid);
  54. wpa_supplicant_deauthenticate(wpa_s,
  55. WLAN_REASON_DEAUTH_LEAVING);
  56. wpa_s->reassociate = 1;
  57. wpa_supplicant_req_scan(wpa_s,
  58. wpa_s->blacklist_cleared ? 5 : 0, 0);
  59. wpa_s->blacklist_cleared = 0;
  60. return 1;
  61. }
  62. eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
  63. if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid &&
  64. !(wpa_s->current_ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
  65. int disabled = wpa_s->current_ssid->disabled;
  66. wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
  67. "try to associate with the received credential");
  68. wpa_supplicant_deauthenticate(wpa_s,
  69. WLAN_REASON_DEAUTH_LEAVING);
  70. if (disabled) {
  71. wpa_printf(MSG_DEBUG, "WPS: Current network is "
  72. "disabled - wait for user to enable");
  73. return 1;
  74. }
  75. wpa_s->after_wps = 5;
  76. wpa_s->wps_freq = wpa_s->assoc_freq;
  77. wpa_s->reassociate = 1;
  78. wpa_supplicant_req_scan(wpa_s, 0, 0);
  79. return 1;
  80. }
  81. if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid) {
  82. wpa_printf(MSG_DEBUG, "WPS: Registration completed - waiting "
  83. "for external credential processing");
  84. wpas_clear_wps(wpa_s);
  85. wpa_supplicant_deauthenticate(wpa_s,
  86. WLAN_REASON_DEAUTH_LEAVING);
  87. return 1;
  88. }
  89. return 0;
  90. }
  91. static void wpas_wps_security_workaround(struct wpa_supplicant *wpa_s,
  92. struct wpa_ssid *ssid,
  93. const struct wps_credential *cred)
  94. {
  95. struct wpa_driver_capa capa;
  96. struct wpa_bss *bss;
  97. const u8 *ie;
  98. struct wpa_ie_data adv;
  99. int wpa2 = 0, ccmp = 0;
  100. /*
  101. * Many existing WPS APs do not know how to negotiate WPA2 or CCMP in
  102. * case they are configured for mixed mode operation (WPA+WPA2 and
  103. * TKIP+CCMP). Try to use scan results to figure out whether the AP
  104. * actually supports stronger security and select that if the client
  105. * has support for it, too.
  106. */
  107. if (wpa_drv_get_capa(wpa_s, &capa))
  108. return; /* Unknown what driver supports */
  109. bss = wpa_bss_get(wpa_s, cred->mac_addr, ssid->ssid, ssid->ssid_len);
  110. if (bss == NULL) {
  111. wpa_printf(MSG_DEBUG, "WPS: The AP was not found from BSS "
  112. "table - use credential as-is");
  113. return;
  114. }
  115. wpa_printf(MSG_DEBUG, "WPS: AP found from BSS table");
  116. ie = wpa_bss_get_ie(bss, WLAN_EID_RSN);
  117. if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &adv) == 0) {
  118. wpa2 = 1;
  119. if (adv.pairwise_cipher & WPA_CIPHER_CCMP)
  120. ccmp = 1;
  121. } else {
  122. ie = wpa_bss_get_vendor_ie(bss, WPA_IE_VENDOR_TYPE);
  123. if (ie && wpa_parse_wpa_ie(ie, 2 + ie[1], &adv) == 0 &&
  124. adv.pairwise_cipher & WPA_CIPHER_CCMP)
  125. ccmp = 1;
  126. }
  127. if (ie == NULL && (ssid->proto & WPA_PROTO_WPA) &&
  128. (ssid->pairwise_cipher & WPA_CIPHER_TKIP)) {
  129. /*
  130. * TODO: This could be the initial AP configuration and the
  131. * Beacon contents could change shortly. Should request a new
  132. * scan and delay addition of the network until the updated
  133. * scan results are available.
  134. */
  135. wpa_printf(MSG_DEBUG, "WPS: The AP did not yet advertise WPA "
  136. "support - use credential as-is");
  137. return;
  138. }
  139. if (ccmp && !(ssid->pairwise_cipher & WPA_CIPHER_CCMP) &&
  140. (ssid->pairwise_cipher & WPA_CIPHER_TKIP) &&
  141. (capa.key_mgmt & WPA_DRIVER_CAPA_KEY_MGMT_WPA2_PSK)) {
  142. wpa_printf(MSG_DEBUG, "WPS: Add CCMP into the credential "
  143. "based on scan results");
  144. if (wpa_s->conf->ap_scan == 1)
  145. ssid->pairwise_cipher |= WPA_CIPHER_CCMP;
  146. else
  147. ssid->pairwise_cipher = WPA_CIPHER_CCMP;
  148. }
  149. if (wpa2 && !(ssid->proto & WPA_PROTO_RSN) &&
  150. (ssid->proto & WPA_PROTO_WPA) &&
  151. (capa.enc & WPA_DRIVER_CAPA_ENC_CCMP)) {
  152. wpa_printf(MSG_DEBUG, "WPS: Add WPA2 into the credential "
  153. "based on scan results");
  154. if (wpa_s->conf->ap_scan == 1)
  155. ssid->proto |= WPA_PROTO_RSN;
  156. else
  157. ssid->proto = WPA_PROTO_RSN;
  158. }
  159. }
  160. static int wpa_supplicant_wps_cred(void *ctx,
  161. const struct wps_credential *cred)
  162. {
  163. struct wpa_supplicant *wpa_s = ctx;
  164. struct wpa_ssid *ssid = wpa_s->current_ssid;
  165. u8 key_idx = 0;
  166. u16 auth_type;
  167. int registrar = 0;
  168. if ((wpa_s->conf->wps_cred_processing == 1 ||
  169. wpa_s->conf->wps_cred_processing == 2) && cred->cred_attr) {
  170. size_t blen = cred->cred_attr_len * 2 + 1;
  171. char *buf = os_malloc(blen);
  172. if (buf) {
  173. wpa_snprintf_hex(buf, blen,
  174. cred->cred_attr, cred->cred_attr_len);
  175. wpa_msg(wpa_s, MSG_INFO, "%s%s",
  176. WPS_EVENT_CRED_RECEIVED, buf);
  177. os_free(buf);
  178. }
  179. wpas_notify_wps_credential(wpa_s, cred);
  180. } else
  181. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
  182. wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
  183. cred->cred_attr, cred->cred_attr_len);
  184. if (wpa_s->conf->wps_cred_processing == 1)
  185. return 0;
  186. wpa_hexdump_ascii(MSG_DEBUG, "WPS: SSID", cred->ssid, cred->ssid_len);
  187. wpa_printf(MSG_DEBUG, "WPS: Authentication Type 0x%x",
  188. cred->auth_type);
  189. wpa_printf(MSG_DEBUG, "WPS: Encryption Type 0x%x", cred->encr_type);
  190. wpa_printf(MSG_DEBUG, "WPS: Network Key Index %d", cred->key_idx);
  191. wpa_hexdump_key(MSG_DEBUG, "WPS: Network Key",
  192. cred->key, cred->key_len);
  193. wpa_printf(MSG_DEBUG, "WPS: MAC Address " MACSTR,
  194. MAC2STR(cred->mac_addr));
  195. auth_type = cred->auth_type;
  196. if (auth_type == (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK)) {
  197. wpa_printf(MSG_DEBUG, "WPS: Workaround - convert mixed-mode "
  198. "auth_type into WPA2PSK");
  199. auth_type = WPS_AUTH_WPA2PSK;
  200. }
  201. if (auth_type != WPS_AUTH_OPEN &&
  202. auth_type != WPS_AUTH_SHARED &&
  203. auth_type != WPS_AUTH_WPAPSK &&
  204. auth_type != WPS_AUTH_WPA2PSK) {
  205. wpa_printf(MSG_DEBUG, "WPS: Ignored credentials for "
  206. "unsupported authentication type 0x%x",
  207. auth_type);
  208. return 0;
  209. }
  210. if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
  211. wpa_printf(MSG_DEBUG, "WPS: Replace WPS network block based "
  212. "on the received credential");
  213. if (ssid->eap.identity &&
  214. ssid->eap.identity_len == WSC_ID_REGISTRAR_LEN &&
  215. os_memcmp(ssid->eap.identity, WSC_ID_REGISTRAR,
  216. WSC_ID_REGISTRAR_LEN) == 0)
  217. registrar = 1;
  218. os_free(ssid->eap.identity);
  219. ssid->eap.identity = NULL;
  220. ssid->eap.identity_len = 0;
  221. os_free(ssid->eap.phase1);
  222. ssid->eap.phase1 = NULL;
  223. os_free(ssid->eap.eap_methods);
  224. ssid->eap.eap_methods = NULL;
  225. if (!ssid->p2p_group)
  226. ssid->temporary = 0;
  227. } else {
  228. wpa_printf(MSG_DEBUG, "WPS: Create a new network based on the "
  229. "received credential");
  230. ssid = wpa_config_add_network(wpa_s->conf);
  231. if (ssid == NULL)
  232. return -1;
  233. wpas_notify_network_added(wpa_s, ssid);
  234. }
  235. wpa_config_set_network_defaults(ssid);
  236. os_free(ssid->ssid);
  237. ssid->ssid = os_malloc(cred->ssid_len);
  238. if (ssid->ssid) {
  239. os_memcpy(ssid->ssid, cred->ssid, cred->ssid_len);
  240. ssid->ssid_len = cred->ssid_len;
  241. }
  242. switch (cred->encr_type) {
  243. case WPS_ENCR_NONE:
  244. break;
  245. case WPS_ENCR_WEP:
  246. if (cred->key_len <= 0)
  247. break;
  248. if (cred->key_len != 5 && cred->key_len != 13 &&
  249. cred->key_len != 10 && cred->key_len != 26) {
  250. wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key length "
  251. "%lu", (unsigned long) cred->key_len);
  252. return -1;
  253. }
  254. if (cred->key_idx > NUM_WEP_KEYS) {
  255. wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key index %d",
  256. cred->key_idx);
  257. return -1;
  258. }
  259. if (cred->key_idx)
  260. key_idx = cred->key_idx - 1;
  261. if (cred->key_len == 10 || cred->key_len == 26) {
  262. if (hexstr2bin((char *) cred->key,
  263. ssid->wep_key[key_idx],
  264. cred->key_len / 2) < 0) {
  265. wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key "
  266. "%d", key_idx);
  267. return -1;
  268. }
  269. ssid->wep_key_len[key_idx] = cred->key_len / 2;
  270. } else {
  271. os_memcpy(ssid->wep_key[key_idx], cred->key,
  272. cred->key_len);
  273. ssid->wep_key_len[key_idx] = cred->key_len;
  274. }
  275. ssid->wep_tx_keyidx = key_idx;
  276. break;
  277. case WPS_ENCR_TKIP:
  278. ssid->pairwise_cipher = WPA_CIPHER_TKIP;
  279. break;
  280. case WPS_ENCR_AES:
  281. ssid->pairwise_cipher = WPA_CIPHER_CCMP;
  282. break;
  283. }
  284. switch (auth_type) {
  285. case WPS_AUTH_OPEN:
  286. ssid->auth_alg = WPA_AUTH_ALG_OPEN;
  287. ssid->key_mgmt = WPA_KEY_MGMT_NONE;
  288. ssid->proto = 0;
  289. #ifdef CONFIG_WPS_REG_DISABLE_OPEN
  290. if (registrar) {
  291. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_OPEN_NETWORK
  292. "id=%d - Credentials for an open "
  293. "network disabled by default - use "
  294. "'select_network %d' to enable",
  295. ssid->id, ssid->id);
  296. ssid->disabled = 1;
  297. }
  298. #endif /* CONFIG_WPS_REG_DISABLE_OPEN */
  299. break;
  300. case WPS_AUTH_SHARED:
  301. ssid->auth_alg = WPA_AUTH_ALG_SHARED;
  302. ssid->key_mgmt = WPA_KEY_MGMT_NONE;
  303. ssid->proto = 0;
  304. break;
  305. case WPS_AUTH_WPAPSK:
  306. ssid->auth_alg = WPA_AUTH_ALG_OPEN;
  307. ssid->key_mgmt = WPA_KEY_MGMT_PSK;
  308. ssid->proto = WPA_PROTO_WPA;
  309. break;
  310. case WPS_AUTH_WPA:
  311. ssid->auth_alg = WPA_AUTH_ALG_OPEN;
  312. ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
  313. ssid->proto = WPA_PROTO_WPA;
  314. break;
  315. case WPS_AUTH_WPA2:
  316. ssid->auth_alg = WPA_AUTH_ALG_OPEN;
  317. ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
  318. ssid->proto = WPA_PROTO_RSN;
  319. break;
  320. case WPS_AUTH_WPA2PSK:
  321. ssid->auth_alg = WPA_AUTH_ALG_OPEN;
  322. ssid->key_mgmt = WPA_KEY_MGMT_PSK;
  323. ssid->proto = WPA_PROTO_RSN;
  324. break;
  325. }
  326. if (ssid->key_mgmt == WPA_KEY_MGMT_PSK) {
  327. if (cred->key_len == 2 * PMK_LEN) {
  328. if (hexstr2bin((const char *) cred->key, ssid->psk,
  329. PMK_LEN)) {
  330. wpa_printf(MSG_ERROR, "WPS: Invalid Network "
  331. "Key");
  332. return -1;
  333. }
  334. ssid->psk_set = 1;
  335. } else if (cred->key_len >= 8 && cred->key_len < 2 * PMK_LEN) {
  336. os_free(ssid->passphrase);
  337. ssid->passphrase = os_malloc(cred->key_len + 1);
  338. if (ssid->passphrase == NULL)
  339. return -1;
  340. os_memcpy(ssid->passphrase, cred->key, cred->key_len);
  341. ssid->passphrase[cred->key_len] = '\0';
  342. wpa_config_update_psk(ssid);
  343. } else {
  344. wpa_printf(MSG_ERROR, "WPS: Invalid Network Key "
  345. "length %lu",
  346. (unsigned long) cred->key_len);
  347. return -1;
  348. }
  349. }
  350. wpas_wps_security_workaround(wpa_s, ssid, cred);
  351. #ifndef CONFIG_NO_CONFIG_WRITE
  352. if (wpa_s->conf->update_config &&
  353. wpa_config_write(wpa_s->confname, wpa_s->conf)) {
  354. wpa_printf(MSG_DEBUG, "WPS: Failed to update configuration");
  355. return -1;
  356. }
  357. #endif /* CONFIG_NO_CONFIG_WRITE */
  358. return 0;
  359. }
  360. static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s,
  361. struct wps_event_m2d *m2d)
  362. {
  363. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D
  364. "dev_password_id=%d config_error=%d",
  365. m2d->dev_password_id, m2d->config_error);
  366. wpas_notify_wps_event_m2d(wpa_s, m2d);
  367. }
  368. static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
  369. struct wps_event_fail *fail)
  370. {
  371. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_FAIL "msg=%d config_error=%d",
  372. fail->msg, fail->config_error);
  373. if (wpa_s->parent && wpa_s->parent != wpa_s)
  374. wpa_msg(wpa_s->parent, MSG_INFO, WPS_EVENT_FAIL
  375. "msg=%d config_error=%d",
  376. fail->msg, fail->config_error);
  377. wpas_clear_wps(wpa_s);
  378. wpas_notify_wps_event_fail(wpa_s, fail);
  379. }
  380. static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
  381. {
  382. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
  383. wpa_s->wps_success = 1;
  384. wpas_notify_wps_event_success(wpa_s);
  385. #ifdef CONFIG_P2P
  386. wpas_p2p_wps_success(wpa_s, wpa_s->bssid, 0);
  387. #endif /* CONFIG_P2P */
  388. }
  389. static void wpa_supplicant_wps_event_er_ap_add(struct wpa_supplicant *wpa_s,
  390. struct wps_event_er_ap *ap)
  391. {
  392. char uuid_str[100];
  393. char dev_type[WPS_DEV_TYPE_BUFSIZE];
  394. uuid_bin2str(ap->uuid, uuid_str, sizeof(uuid_str));
  395. if (ap->pri_dev_type)
  396. wps_dev_type_bin2str(ap->pri_dev_type, dev_type,
  397. sizeof(dev_type));
  398. else
  399. dev_type[0] = '\0';
  400. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_ADD "%s " MACSTR
  401. " pri_dev_type=%s wps_state=%d |%s|%s|%s|%s|%s|%s|",
  402. uuid_str, MAC2STR(ap->mac_addr), dev_type, ap->wps_state,
  403. ap->friendly_name ? ap->friendly_name : "",
  404. ap->manufacturer ? ap->manufacturer : "",
  405. ap->model_description ? ap->model_description : "",
  406. ap->model_name ? ap->model_name : "",
  407. ap->manufacturer_url ? ap->manufacturer_url : "",
  408. ap->model_url ? ap->model_url : "");
  409. }
  410. static void wpa_supplicant_wps_event_er_ap_remove(struct wpa_supplicant *wpa_s,
  411. struct wps_event_er_ap *ap)
  412. {
  413. char uuid_str[100];
  414. uuid_bin2str(ap->uuid, uuid_str, sizeof(uuid_str));
  415. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_REMOVE "%s", uuid_str);
  416. }
  417. static void wpa_supplicant_wps_event_er_enrollee_add(
  418. struct wpa_supplicant *wpa_s, struct wps_event_er_enrollee *enrollee)
  419. {
  420. char uuid_str[100];
  421. char dev_type[WPS_DEV_TYPE_BUFSIZE];
  422. uuid_bin2str(enrollee->uuid, uuid_str, sizeof(uuid_str));
  423. if (enrollee->pri_dev_type)
  424. wps_dev_type_bin2str(enrollee->pri_dev_type, dev_type,
  425. sizeof(dev_type));
  426. else
  427. dev_type[0] = '\0';
  428. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_ENROLLEE_ADD "%s " MACSTR
  429. " M1=%d config_methods=0x%x dev_passwd_id=%d pri_dev_type=%s "
  430. "|%s|%s|%s|%s|%s|",
  431. uuid_str, MAC2STR(enrollee->mac_addr), enrollee->m1_received,
  432. enrollee->config_methods, enrollee->dev_passwd_id, dev_type,
  433. enrollee->dev_name ? enrollee->dev_name : "",
  434. enrollee->manufacturer ? enrollee->manufacturer : "",
  435. enrollee->model_name ? enrollee->model_name : "",
  436. enrollee->model_number ? enrollee->model_number : "",
  437. enrollee->serial_number ? enrollee->serial_number : "");
  438. }
  439. static void wpa_supplicant_wps_event_er_enrollee_remove(
  440. struct wpa_supplicant *wpa_s, struct wps_event_er_enrollee *enrollee)
  441. {
  442. char uuid_str[100];
  443. uuid_bin2str(enrollee->uuid, uuid_str, sizeof(uuid_str));
  444. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_ENROLLEE_REMOVE "%s " MACSTR,
  445. uuid_str, MAC2STR(enrollee->mac_addr));
  446. }
  447. static void wpa_supplicant_wps_event_er_ap_settings(
  448. struct wpa_supplicant *wpa_s,
  449. struct wps_event_er_ap_settings *ap_settings)
  450. {
  451. char uuid_str[100];
  452. char key_str[65];
  453. const struct wps_credential *cred = ap_settings->cred;
  454. key_str[0] = '\0';
  455. if (cred->auth_type & (WPS_AUTH_WPAPSK | WPS_AUTH_WPA2PSK)) {
  456. if (cred->key_len >= 8 && cred->key_len <= 64) {
  457. os_memcpy(key_str, cred->key, cred->key_len);
  458. key_str[cred->key_len] = '\0';
  459. }
  460. }
  461. uuid_bin2str(ap_settings->uuid, uuid_str, sizeof(uuid_str));
  462. /* Use wpa_msg_ctrl to avoid showing the key in debug log */
  463. wpa_msg_ctrl(wpa_s, MSG_INFO, WPS_EVENT_ER_AP_SETTINGS
  464. "uuid=%s ssid=%s auth_type=0x%04x encr_type=0x%04x "
  465. "key=%s",
  466. uuid_str, wpa_ssid_txt(cred->ssid, cred->ssid_len),
  467. cred->auth_type, cred->encr_type, key_str);
  468. }
  469. static void wpa_supplicant_wps_event_er_set_sel_reg(
  470. struct wpa_supplicant *wpa_s,
  471. struct wps_event_er_set_selected_registrar *ev)
  472. {
  473. char uuid_str[100];
  474. uuid_bin2str(ev->uuid, uuid_str, sizeof(uuid_str));
  475. switch (ev->state) {
  476. case WPS_ER_SET_SEL_REG_START:
  477. wpa_msg(wpa_s, MSG_DEBUG, WPS_EVENT_ER_SET_SEL_REG
  478. "uuid=%s state=START sel_reg=%d dev_passwd_id=%u "
  479. "sel_reg_config_methods=0x%x",
  480. uuid_str, ev->sel_reg, ev->dev_passwd_id,
  481. ev->sel_reg_config_methods);
  482. break;
  483. case WPS_ER_SET_SEL_REG_DONE:
  484. wpa_msg(wpa_s, MSG_DEBUG, WPS_EVENT_ER_SET_SEL_REG
  485. "uuid=%s state=DONE", uuid_str);
  486. break;
  487. case WPS_ER_SET_SEL_REG_FAILED:
  488. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_ER_SET_SEL_REG
  489. "uuid=%s state=FAILED", uuid_str);
  490. break;
  491. }
  492. }
  493. static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
  494. union wps_event_data *data)
  495. {
  496. struct wpa_supplicant *wpa_s = ctx;
  497. switch (event) {
  498. case WPS_EV_M2D:
  499. wpa_supplicant_wps_event_m2d(wpa_s, &data->m2d);
  500. break;
  501. case WPS_EV_FAIL:
  502. wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
  503. break;
  504. case WPS_EV_SUCCESS:
  505. wpa_supplicant_wps_event_success(wpa_s);
  506. break;
  507. case WPS_EV_PWD_AUTH_FAIL:
  508. #ifdef CONFIG_AP
  509. if (wpa_s->ap_iface && data->pwd_auth_fail.enrollee)
  510. wpa_supplicant_ap_pwd_auth_fail(wpa_s);
  511. #endif /* CONFIG_AP */
  512. break;
  513. case WPS_EV_PBC_OVERLAP:
  514. break;
  515. case WPS_EV_PBC_TIMEOUT:
  516. break;
  517. case WPS_EV_ER_AP_ADD:
  518. wpa_supplicant_wps_event_er_ap_add(wpa_s, &data->ap);
  519. break;
  520. case WPS_EV_ER_AP_REMOVE:
  521. wpa_supplicant_wps_event_er_ap_remove(wpa_s, &data->ap);
  522. break;
  523. case WPS_EV_ER_ENROLLEE_ADD:
  524. wpa_supplicant_wps_event_er_enrollee_add(wpa_s,
  525. &data->enrollee);
  526. break;
  527. case WPS_EV_ER_ENROLLEE_REMOVE:
  528. wpa_supplicant_wps_event_er_enrollee_remove(wpa_s,
  529. &data->enrollee);
  530. break;
  531. case WPS_EV_ER_AP_SETTINGS:
  532. wpa_supplicant_wps_event_er_ap_settings(wpa_s,
  533. &data->ap_settings);
  534. break;
  535. case WPS_EV_ER_SET_SELECTED_REGISTRAR:
  536. wpa_supplicant_wps_event_er_set_sel_reg(wpa_s,
  537. &data->set_sel_reg);
  538. break;
  539. }
  540. }
  541. enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid)
  542. {
  543. if (eap_is_wps_pbc_enrollee(&ssid->eap) ||
  544. eap_is_wps_pin_enrollee(&ssid->eap))
  545. return WPS_REQ_ENROLLEE;
  546. else
  547. return WPS_REQ_REGISTRAR;
  548. }
  549. static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
  550. {
  551. int id;
  552. struct wpa_ssid *ssid, *remove_ssid = NULL;
  553. eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
  554. /* Remove any existing WPS network from configuration */
  555. ssid = wpa_s->conf->ssid;
  556. while (ssid) {
  557. if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
  558. if (ssid == wpa_s->current_ssid) {
  559. wpa_s->current_ssid = NULL;
  560. if (ssid != NULL)
  561. wpas_notify_network_changed(wpa_s);
  562. }
  563. id = ssid->id;
  564. remove_ssid = ssid;
  565. } else
  566. id = -1;
  567. ssid = ssid->next;
  568. if (id >= 0) {
  569. wpas_notify_network_removed(wpa_s, remove_ssid);
  570. wpa_config_remove_network(wpa_s->conf, id);
  571. }
  572. }
  573. }
  574. static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
  575. {
  576. struct wpa_supplicant *wpa_s = eloop_ctx;
  577. wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_TIMEOUT "Requested operation timed "
  578. "out");
  579. wpas_clear_wps(wpa_s);
  580. }
  581. static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
  582. int registrar, const u8 *bssid)
  583. {
  584. struct wpa_ssid *ssid;
  585. ssid = wpa_config_add_network(wpa_s->conf);
  586. if (ssid == NULL)
  587. return NULL;
  588. wpas_notify_network_added(wpa_s, ssid);
  589. wpa_config_set_network_defaults(ssid);
  590. ssid->temporary = 1;
  591. if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
  592. wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
  593. wpa_config_set(ssid, "identity", registrar ?
  594. "\"" WSC_ID_REGISTRAR "\"" :
  595. "\"" WSC_ID_ENROLLEE "\"", 0) < 0) {
  596. wpas_notify_network_removed(wpa_s, ssid);
  597. wpa_config_remove_network(wpa_s->conf, ssid->id);
  598. return NULL;
  599. }
  600. if (bssid) {
  601. #ifndef CONFIG_P2P
  602. struct wpa_bss *bss;
  603. int count = 0;
  604. #endif /* CONFIG_P2P */
  605. os_memcpy(ssid->bssid, bssid, ETH_ALEN);
  606. ssid->bssid_set = 1;
  607. /*
  608. * Note: With P2P, the SSID may change at the time the WPS
  609. * provisioning is started, so better not filter the AP based
  610. * on the current SSID in the scan results.
  611. */
  612. #ifndef CONFIG_P2P
  613. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  614. if (os_memcmp(bssid, bss->bssid, ETH_ALEN) != 0)
  615. continue;
  616. os_free(ssid->ssid);
  617. ssid->ssid = os_malloc(bss->ssid_len);
  618. if (ssid->ssid == NULL)
  619. break;
  620. os_memcpy(ssid->ssid, bss->ssid, bss->ssid_len);
  621. ssid->ssid_len = bss->ssid_len;
  622. wpa_hexdump_ascii(MSG_DEBUG, "WPS: Picked SSID from "
  623. "scan results",
  624. ssid->ssid, ssid->ssid_len);
  625. count++;
  626. }
  627. if (count > 1) {
  628. wpa_printf(MSG_DEBUG, "WPS: More than one SSID found "
  629. "for the AP; use wildcard");
  630. os_free(ssid->ssid);
  631. ssid->ssid = NULL;
  632. ssid->ssid_len = 0;
  633. }
  634. #endif /* CONFIG_P2P */
  635. }
  636. return ssid;
  637. }
  638. static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
  639. struct wpa_ssid *selected)
  640. {
  641. struct wpa_ssid *ssid;
  642. /* Mark all other networks disabled and trigger reassociation */
  643. ssid = wpa_s->conf->ssid;
  644. while (ssid) {
  645. int was_disabled = ssid->disabled;
  646. ssid->disabled = ssid != selected;
  647. if (was_disabled != ssid->disabled)
  648. wpas_notify_network_enabled_changed(wpa_s, ssid);
  649. ssid = ssid->next;
  650. }
  651. wpa_s->disconnected = 0;
  652. wpa_s->reassociate = 1;
  653. wpa_s->scan_runs = 0;
  654. wpa_s->wps_success = 0;
  655. wpa_s->blacklist_cleared = 0;
  656. wpa_supplicant_req_scan(wpa_s, 0, 0);
  657. }
  658. int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
  659. int p2p_group)
  660. {
  661. struct wpa_ssid *ssid;
  662. wpas_clear_wps(wpa_s);
  663. ssid = wpas_wps_add_network(wpa_s, 0, bssid);
  664. if (ssid == NULL)
  665. return -1;
  666. ssid->temporary = 1;
  667. ssid->p2p_group = p2p_group;
  668. #ifdef CONFIG_P2P
  669. if (p2p_group && wpa_s->go_params && wpa_s->go_params->ssid_len) {
  670. ssid->ssid = os_zalloc(wpa_s->go_params->ssid_len + 1);
  671. if (ssid->ssid) {
  672. ssid->ssid_len = wpa_s->go_params->ssid_len;
  673. os_memcpy(ssid->ssid, wpa_s->go_params->ssid,
  674. ssid->ssid_len);
  675. wpa_hexdump_ascii(MSG_DEBUG, "WPS: Use specific AP "
  676. "SSID", ssid->ssid, ssid->ssid_len);
  677. }
  678. }
  679. #endif /* CONFIG_P2P */
  680. wpa_config_set(ssid, "phase1", "\"pbc=1\"", 0);
  681. if (wpa_s->wps_fragment_size)
  682. ssid->eap.fragment_size = wpa_s->wps_fragment_size;
  683. eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
  684. wpa_s, NULL);
  685. wpas_wps_reassoc(wpa_s, ssid);
  686. return 0;
  687. }
  688. int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
  689. const char *pin, int p2p_group, u16 dev_pw_id)
  690. {
  691. struct wpa_ssid *ssid;
  692. char val[128];
  693. unsigned int rpin = 0;
  694. wpas_clear_wps(wpa_s);
  695. ssid = wpas_wps_add_network(wpa_s, 0, bssid);
  696. if (ssid == NULL)
  697. return -1;
  698. ssid->temporary = 1;
  699. ssid->p2p_group = p2p_group;
  700. #ifdef CONFIG_P2P
  701. if (p2p_group && wpa_s->go_params && wpa_s->go_params->ssid_len) {
  702. ssid->ssid = os_zalloc(wpa_s->go_params->ssid_len + 1);
  703. if (ssid->ssid) {
  704. ssid->ssid_len = wpa_s->go_params->ssid_len;
  705. os_memcpy(ssid->ssid, wpa_s->go_params->ssid,
  706. ssid->ssid_len);
  707. wpa_hexdump_ascii(MSG_DEBUG, "WPS: Use specific AP "
  708. "SSID", ssid->ssid, ssid->ssid_len);
  709. }
  710. }
  711. #endif /* CONFIG_P2P */
  712. if (pin)
  713. os_snprintf(val, sizeof(val), "\"pin=%s dev_pw_id=%u\"",
  714. pin, dev_pw_id);
  715. else {
  716. rpin = wps_generate_pin();
  717. os_snprintf(val, sizeof(val), "\"pin=%08d dev_pw_id=%u\"",
  718. rpin, dev_pw_id);
  719. }
  720. wpa_config_set(ssid, "phase1", val, 0);
  721. if (wpa_s->wps_fragment_size)
  722. ssid->eap.fragment_size = wpa_s->wps_fragment_size;
  723. eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
  724. wpa_s, NULL);
  725. wpas_wps_reassoc(wpa_s, ssid);
  726. return rpin;
  727. }
  728. /* Cancel the wps pbc/pin requests */
  729. int wpas_wps_cancel(struct wpa_supplicant *wpa_s)
  730. {
  731. #ifdef CONFIG_AP
  732. if (wpa_s->ap_iface) {
  733. wpa_printf(MSG_DEBUG, "WPS: Cancelling in AP mode");
  734. return wpa_supplicant_ap_wps_cancel(wpa_s);
  735. }
  736. #endif /* CONFIG_AP */
  737. if (wpa_s->wpa_state == WPA_SCANNING) {
  738. wpa_printf(MSG_DEBUG, "WPS: Cancel operation - cancel scan");
  739. wpa_supplicant_cancel_scan(wpa_s);
  740. wpas_clear_wps(wpa_s);
  741. } else if (wpa_s->wpa_state >= WPA_ASSOCIATED) {
  742. wpa_printf(MSG_DEBUG, "WPS: Cancel operation - "
  743. "deauthenticate");
  744. wpa_supplicant_deauthenticate(wpa_s,
  745. WLAN_REASON_DEAUTH_LEAVING);
  746. wpas_clear_wps(wpa_s);
  747. }
  748. return 0;
  749. }
  750. #ifdef CONFIG_WPS_OOB
  751. int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
  752. char *path, char *method, char *name)
  753. {
  754. struct wps_context *wps = wpa_s->wps;
  755. struct oob_device_data *oob_dev;
  756. oob_dev = wps_get_oob_device(device_type);
  757. if (oob_dev == NULL)
  758. return -1;
  759. oob_dev->device_path = path;
  760. oob_dev->device_name = name;
  761. wps->oob_conf.oob_method = wps_get_oob_method(method);
  762. if (wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E) {
  763. /*
  764. * Use pre-configured DH keys in order to be able to write the
  765. * key hash into the OOB file.
  766. */
  767. wpabuf_free(wps->dh_pubkey);
  768. wpabuf_free(wps->dh_privkey);
  769. wps->dh_privkey = NULL;
  770. wps->dh_pubkey = NULL;
  771. dh5_free(wps->dh_ctx);
  772. wps->dh_ctx = dh5_init(&wps->dh_privkey, &wps->dh_pubkey);
  773. wps->dh_pubkey = wpabuf_zeropad(wps->dh_pubkey, 192);
  774. if (wps->dh_ctx == NULL || wps->dh_pubkey == NULL) {
  775. wpa_printf(MSG_ERROR, "WPS: Failed to initialize "
  776. "Diffie-Hellman handshake");
  777. return -1;
  778. }
  779. }
  780. if (wps->oob_conf.oob_method == OOB_METHOD_CRED)
  781. wpas_clear_wps(wpa_s);
  782. if (wps_process_oob(wps, oob_dev, 0) < 0)
  783. return -1;
  784. if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
  785. wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) &&
  786. wpas_wps_start_pin(wpa_s, NULL,
  787. wpabuf_head(wps->oob_conf.dev_password), 0,
  788. DEV_PW_DEFAULT) < 0)
  789. return -1;
  790. return 0;
  791. }
  792. #endif /* CONFIG_WPS_OOB */
  793. int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
  794. const char *pin, struct wps_new_ap_settings *settings)
  795. {
  796. struct wpa_ssid *ssid;
  797. char val[200];
  798. char *pos, *end;
  799. int res;
  800. if (!pin)
  801. return -1;
  802. wpas_clear_wps(wpa_s);
  803. ssid = wpas_wps_add_network(wpa_s, 1, bssid);
  804. if (ssid == NULL)
  805. return -1;
  806. ssid->temporary = 1;
  807. pos = val;
  808. end = pos + sizeof(val);
  809. res = os_snprintf(pos, end - pos, "\"pin=%s", pin);
  810. if (res < 0 || res >= end - pos)
  811. return -1;
  812. pos += res;
  813. if (settings) {
  814. res = os_snprintf(pos, end - pos, " new_ssid=%s new_auth=%s "
  815. "new_encr=%s new_key=%s",
  816. settings->ssid_hex, settings->auth,
  817. settings->encr, settings->key_hex);
  818. if (res < 0 || res >= end - pos)
  819. return -1;
  820. pos += res;
  821. }
  822. res = os_snprintf(pos, end - pos, "\"");
  823. if (res < 0 || res >= end - pos)
  824. return -1;
  825. wpa_config_set(ssid, "phase1", val, 0);
  826. if (wpa_s->wps_fragment_size)
  827. ssid->eap.fragment_size = wpa_s->wps_fragment_size;
  828. eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
  829. wpa_s, NULL);
  830. wpas_wps_reassoc(wpa_s, ssid);
  831. return 0;
  832. }
  833. static int wpas_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
  834. size_t psk_len)
  835. {
  836. wpa_printf(MSG_DEBUG, "WPS: Received new WPA/WPA2-PSK from WPS for "
  837. "STA " MACSTR, MAC2STR(mac_addr));
  838. wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len);
  839. /* TODO */
  840. return 0;
  841. }
  842. static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
  843. const struct wps_device_data *dev)
  844. {
  845. char uuid[40], txt[400];
  846. int len;
  847. char devtype[WPS_DEV_TYPE_BUFSIZE];
  848. if (uuid_bin2str(uuid_e, uuid, sizeof(uuid)))
  849. return;
  850. wpa_printf(MSG_DEBUG, "WPS: PIN needed for UUID-E %s", uuid);
  851. len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED %s " MACSTR
  852. " [%s|%s|%s|%s|%s|%s]",
  853. uuid, MAC2STR(dev->mac_addr), dev->device_name,
  854. dev->manufacturer, dev->model_name,
  855. dev->model_number, dev->serial_number,
  856. wps_dev_type_bin2str(dev->pri_dev_type, devtype,
  857. sizeof(devtype)));
  858. if (len > 0 && len < (int) sizeof(txt))
  859. wpa_printf(MSG_INFO, "%s", txt);
  860. }
  861. static void wpas_wps_set_sel_reg_cb(void *ctx, int sel_reg, u16 dev_passwd_id,
  862. u16 sel_reg_config_methods)
  863. {
  864. #ifdef CONFIG_WPS_ER
  865. struct wpa_supplicant *wpa_s = ctx;
  866. if (wpa_s->wps_er == NULL)
  867. return;
  868. wpa_printf(MSG_DEBUG, "WPS ER: SetSelectedRegistrar - sel_reg=%d "
  869. "dev_password_id=%u sel_reg_config_methods=0x%x",
  870. sel_reg, dev_passwd_id, sel_reg_config_methods);
  871. wps_er_set_sel_reg(wpa_s->wps_er, sel_reg, dev_passwd_id,
  872. sel_reg_config_methods);
  873. #endif /* CONFIG_WPS_ER */
  874. }
  875. static u16 wps_fix_config_methods(u16 config_methods)
  876. {
  877. #ifdef CONFIG_WPS2
  878. if ((config_methods &
  879. (WPS_CONFIG_DISPLAY | WPS_CONFIG_VIRT_DISPLAY |
  880. WPS_CONFIG_PHY_DISPLAY)) == WPS_CONFIG_DISPLAY) {
  881. wpa_printf(MSG_INFO, "WPS: Converting display to "
  882. "virtual_display for WPS 2.0 compliance");
  883. config_methods |= WPS_CONFIG_VIRT_DISPLAY;
  884. }
  885. if ((config_methods &
  886. (WPS_CONFIG_PUSHBUTTON | WPS_CONFIG_VIRT_PUSHBUTTON |
  887. WPS_CONFIG_PHY_PUSHBUTTON)) == WPS_CONFIG_PUSHBUTTON) {
  888. wpa_printf(MSG_INFO, "WPS: Converting push_button to "
  889. "virtual_push_button for WPS 2.0 compliance");
  890. config_methods |= WPS_CONFIG_VIRT_PUSHBUTTON;
  891. }
  892. #endif /* CONFIG_WPS2 */
  893. return config_methods;
  894. }
  895. int wpas_wps_init(struct wpa_supplicant *wpa_s)
  896. {
  897. struct wps_context *wps;
  898. struct wps_registrar_config rcfg;
  899. wps = os_zalloc(sizeof(*wps));
  900. if (wps == NULL)
  901. return -1;
  902. wps->cred_cb = wpa_supplicant_wps_cred;
  903. wps->event_cb = wpa_supplicant_wps_event;
  904. wps->cb_ctx = wpa_s;
  905. wps->dev.device_name = wpa_s->conf->device_name;
  906. wps->dev.manufacturer = wpa_s->conf->manufacturer;
  907. wps->dev.model_name = wpa_s->conf->model_name;
  908. wps->dev.model_number = wpa_s->conf->model_number;
  909. wps->dev.serial_number = wpa_s->conf->serial_number;
  910. wps->config_methods =
  911. wps_config_methods_str2bin(wpa_s->conf->config_methods);
  912. if ((wps->config_methods & (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) ==
  913. (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) {
  914. wpa_printf(MSG_ERROR, "WPS: Both Label and Display config "
  915. "methods are not allowed at the same time");
  916. os_free(wps);
  917. return -1;
  918. }
  919. wps->config_methods = wps_fix_config_methods(wps->config_methods);
  920. if (wpa_s->conf->device_type &&
  921. wps_dev_type_str2bin(wpa_s->conf->device_type,
  922. wps->dev.pri_dev_type) < 0) {
  923. wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
  924. os_free(wps);
  925. return -1;
  926. }
  927. wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
  928. wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */
  929. os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN);
  930. if (is_nil_uuid(wpa_s->conf->uuid)) {
  931. uuid_gen_mac_addr(wpa_s->own_addr, wps->uuid);
  932. wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC address",
  933. wps->uuid, WPS_UUID_LEN);
  934. } else
  935. os_memcpy(wps->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
  936. wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
  937. wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
  938. os_memset(&rcfg, 0, sizeof(rcfg));
  939. rcfg.new_psk_cb = wpas_wps_new_psk_cb;
  940. rcfg.pin_needed_cb = wpas_wps_pin_needed_cb;
  941. rcfg.set_sel_reg_cb = wpas_wps_set_sel_reg_cb;
  942. rcfg.cb_ctx = wpa_s;
  943. wps->registrar = wps_registrar_init(wps, &rcfg);
  944. if (wps->registrar == NULL) {
  945. wpa_printf(MSG_DEBUG, "Failed to initialize WPS Registrar");
  946. os_free(wps);
  947. return -1;
  948. }
  949. wpa_s->wps = wps;
  950. return 0;
  951. }
  952. void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
  953. {
  954. eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
  955. if (wpa_s->wps == NULL)
  956. return;
  957. #ifdef CONFIG_WPS_ER
  958. wps_er_deinit(wpa_s->wps_er, NULL, NULL);
  959. wpa_s->wps_er = NULL;
  960. #endif /* CONFIG_WPS_ER */
  961. wps_registrar_deinit(wpa_s->wps->registrar);
  962. wpabuf_free(wpa_s->wps->dh_pubkey);
  963. wpabuf_free(wpa_s->wps->dh_privkey);
  964. wpabuf_free(wpa_s->wps->oob_conf.pubkey_hash);
  965. wpabuf_free(wpa_s->wps->oob_conf.dev_password);
  966. os_free(wpa_s->wps->network_key);
  967. os_free(wpa_s->wps);
  968. wpa_s->wps = NULL;
  969. }
  970. int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
  971. struct wpa_ssid *ssid, struct wpa_scan_res *bss)
  972. {
  973. struct wpabuf *wps_ie;
  974. if (!(ssid->key_mgmt & WPA_KEY_MGMT_WPS))
  975. return -1;
  976. wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
  977. if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
  978. if (!wps_ie) {
  979. wpa_printf(MSG_DEBUG, " skip - non-WPS AP");
  980. return 0;
  981. }
  982. if (!wps_is_selected_pbc_registrar(wps_ie)) {
  983. wpa_printf(MSG_DEBUG, " skip - WPS AP "
  984. "without active PBC Registrar");
  985. wpabuf_free(wps_ie);
  986. return 0;
  987. }
  988. /* TODO: overlap detection */
  989. wpa_printf(MSG_DEBUG, " selected based on WPS IE "
  990. "(Active PBC)");
  991. wpabuf_free(wps_ie);
  992. return 1;
  993. }
  994. if (eap_is_wps_pin_enrollee(&ssid->eap)) {
  995. if (!wps_ie) {
  996. wpa_printf(MSG_DEBUG, " skip - non-WPS AP");
  997. return 0;
  998. }
  999. /*
  1000. * Start with WPS APs that advertise our address as an
  1001. * authorized MAC (v2.0) or active PIN Registrar (v1.0) and
  1002. * allow any WPS AP after couple of scans since some APs do not
  1003. * set Selected Registrar attribute properly when using
  1004. * external Registrar.
  1005. */
  1006. if (!wps_is_addr_authorized(wps_ie, wpa_s->own_addr, 1)) {
  1007. if (wpa_s->scan_runs < WPS_PIN_SCAN_IGNORE_SEL_REG) {
  1008. wpa_printf(MSG_DEBUG, " skip - WPS AP "
  1009. "without active PIN Registrar");
  1010. wpabuf_free(wps_ie);
  1011. return 0;
  1012. }
  1013. wpa_printf(MSG_DEBUG, " selected based on WPS IE");
  1014. } else {
  1015. wpa_printf(MSG_DEBUG, " selected based on WPS IE "
  1016. "(Authorized MAC or Active PIN)");
  1017. }
  1018. wpabuf_free(wps_ie);
  1019. return 1;
  1020. }
  1021. if (wps_ie) {
  1022. wpa_printf(MSG_DEBUG, " selected based on WPS IE");
  1023. wpabuf_free(wps_ie);
  1024. return 1;
  1025. }
  1026. return -1;
  1027. }
  1028. int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
  1029. struct wpa_ssid *ssid,
  1030. struct wpa_scan_res *bss)
  1031. {
  1032. struct wpabuf *wps_ie = NULL;
  1033. int ret = 0;
  1034. if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
  1035. wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
  1036. if (wps_ie && wps_is_selected_pbc_registrar(wps_ie)) {
  1037. /* allow wildcard SSID for WPS PBC */
  1038. ret = 1;
  1039. }
  1040. } else if (eap_is_wps_pin_enrollee(&ssid->eap)) {
  1041. wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
  1042. if (wps_ie &&
  1043. (wps_is_addr_authorized(wps_ie, wpa_s->own_addr, 1) ||
  1044. wpa_s->scan_runs >= WPS_PIN_SCAN_IGNORE_SEL_REG)) {
  1045. /* allow wildcard SSID for WPS PIN */
  1046. ret = 1;
  1047. }
  1048. }
  1049. if (!ret && ssid->bssid_set &&
  1050. os_memcmp(ssid->bssid, bss->bssid, ETH_ALEN) == 0) {
  1051. /* allow wildcard SSID due to hardcoded BSSID match */
  1052. ret = 1;
  1053. }
  1054. #ifdef CONFIG_WPS_STRICT
  1055. if (wps_ie) {
  1056. if (wps_validate_beacon_probe_resp(wps_ie, bss->beacon_ie_len >
  1057. 0, bss->bssid) < 0)
  1058. ret = 0;
  1059. if (bss->beacon_ie_len) {
  1060. struct wpabuf *bcn_wps;
  1061. bcn_wps = wpa_scan_get_vendor_ie_multi_beacon(
  1062. bss, WPS_IE_VENDOR_TYPE);
  1063. if (bcn_wps == NULL) {
  1064. wpa_printf(MSG_DEBUG, "WPS: Mandatory WPS IE "
  1065. "missing from AP Beacon");
  1066. ret = 0;
  1067. } else {
  1068. if (wps_validate_beacon(wps_ie) < 0)
  1069. ret = 0;
  1070. wpabuf_free(bcn_wps);
  1071. }
  1072. }
  1073. }
  1074. #endif /* CONFIG_WPS_STRICT */
  1075. wpabuf_free(wps_ie);
  1076. return ret;
  1077. }
  1078. int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
  1079. struct wpa_bss *selected, struct wpa_ssid *ssid)
  1080. {
  1081. const u8 *sel_uuid, *uuid;
  1082. struct wpabuf *wps_ie;
  1083. int ret = 0;
  1084. struct wpa_bss *bss;
  1085. if (!eap_is_wps_pbc_enrollee(&ssid->eap))
  1086. return 0;
  1087. wpa_printf(MSG_DEBUG, "WPS: Check whether PBC session overlap is "
  1088. "present in scan results; selected BSSID " MACSTR,
  1089. MAC2STR(selected->bssid));
  1090. /* Make sure that only one AP is in active PBC mode */
  1091. wps_ie = wpa_bss_get_vendor_ie_multi(selected, WPS_IE_VENDOR_TYPE);
  1092. if (wps_ie) {
  1093. sel_uuid = wps_get_uuid_e(wps_ie);
  1094. wpa_hexdump(MSG_DEBUG, "WPS: UUID of the selected BSS",
  1095. sel_uuid, UUID_LEN);
  1096. } else {
  1097. wpa_printf(MSG_DEBUG, "WPS: Selected BSS does not include "
  1098. "WPS IE?!");
  1099. sel_uuid = NULL;
  1100. }
  1101. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  1102. struct wpabuf *ie;
  1103. if (bss == selected)
  1104. continue;
  1105. ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
  1106. if (!ie)
  1107. continue;
  1108. if (!wps_is_selected_pbc_registrar(ie)) {
  1109. wpabuf_free(ie);
  1110. continue;
  1111. }
  1112. wpa_printf(MSG_DEBUG, "WPS: Another BSS in active PBC mode: "
  1113. MACSTR, MAC2STR(bss->bssid));
  1114. uuid = wps_get_uuid_e(ie);
  1115. wpa_hexdump(MSG_DEBUG, "WPS: UUID of the other BSS",
  1116. uuid, UUID_LEN);
  1117. if (sel_uuid == NULL || uuid == NULL ||
  1118. os_memcmp(sel_uuid, uuid, UUID_LEN) != 0) {
  1119. ret = 1; /* PBC overlap */
  1120. wpa_msg(wpa_s, MSG_INFO, "WPS: PBC overlap detected: "
  1121. MACSTR " and " MACSTR,
  1122. MAC2STR(selected->bssid),
  1123. MAC2STR(bss->bssid));
  1124. wpabuf_free(ie);
  1125. break;
  1126. }
  1127. /* TODO: verify that this is reasonable dual-band situation */
  1128. wpabuf_free(ie);
  1129. }
  1130. wpabuf_free(wps_ie);
  1131. return ret;
  1132. }
  1133. void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s)
  1134. {
  1135. struct wpa_bss *bss;
  1136. if (wpa_s->disconnected || wpa_s->wpa_state >= WPA_ASSOCIATED)
  1137. return;
  1138. dl_list_for_each(bss, &wpa_s->bss, struct wpa_bss, list) {
  1139. struct wpabuf *ie;
  1140. ie = wpa_bss_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
  1141. if (!ie)
  1142. continue;
  1143. if (wps_is_selected_pbc_registrar(ie))
  1144. wpa_msg_ctrl(wpa_s, MSG_INFO,
  1145. WPS_EVENT_AP_AVAILABLE_PBC);
  1146. else if (wps_is_addr_authorized(ie, wpa_s->own_addr, 0))
  1147. wpa_msg_ctrl(wpa_s, MSG_INFO,
  1148. WPS_EVENT_AP_AVAILABLE_AUTH);
  1149. else if (wps_is_selected_pin_registrar(ie))
  1150. wpa_msg_ctrl(wpa_s, MSG_INFO,
  1151. WPS_EVENT_AP_AVAILABLE_PIN);
  1152. else
  1153. wpa_msg_ctrl(wpa_s, MSG_INFO,
  1154. WPS_EVENT_AP_AVAILABLE);
  1155. wpabuf_free(ie);
  1156. break;
  1157. }
  1158. }
  1159. int wpas_wps_searching(struct wpa_supplicant *wpa_s)
  1160. {
  1161. struct wpa_ssid *ssid;
  1162. for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
  1163. if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && !ssid->disabled)
  1164. return 1;
  1165. }
  1166. return 0;
  1167. }
  1168. int wpas_wps_scan_result_text(const u8 *ies, size_t ies_len, char *buf,
  1169. char *end)
  1170. {
  1171. struct wpabuf *wps_ie;
  1172. int ret;
  1173. wps_ie = ieee802_11_vendor_ie_concat(ies, ies_len, WPS_DEV_OUI_WFA);
  1174. if (wps_ie == NULL)
  1175. return 0;
  1176. ret = wps_attr_text(wps_ie, buf, end);
  1177. wpabuf_free(wps_ie);
  1178. return ret;
  1179. }
  1180. int wpas_wps_er_start(struct wpa_supplicant *wpa_s, const char *filter)
  1181. {
  1182. #ifdef CONFIG_WPS_ER
  1183. if (wpa_s->wps_er) {
  1184. wps_er_refresh(wpa_s->wps_er);
  1185. return 0;
  1186. }
  1187. wpa_s->wps_er = wps_er_init(wpa_s->wps, wpa_s->ifname, filter);
  1188. if (wpa_s->wps_er == NULL)
  1189. return -1;
  1190. return 0;
  1191. #else /* CONFIG_WPS_ER */
  1192. return 0;
  1193. #endif /* CONFIG_WPS_ER */
  1194. }
  1195. int wpas_wps_er_stop(struct wpa_supplicant *wpa_s)
  1196. {
  1197. #ifdef CONFIG_WPS_ER
  1198. wps_er_deinit(wpa_s->wps_er, NULL, NULL);
  1199. wpa_s->wps_er = NULL;
  1200. #endif /* CONFIG_WPS_ER */
  1201. return 0;
  1202. }
  1203. #ifdef CONFIG_WPS_ER
  1204. int wpas_wps_er_add_pin(struct wpa_supplicant *wpa_s, const u8 *addr,
  1205. const char *uuid, const char *pin)
  1206. {
  1207. u8 u[UUID_LEN];
  1208. int any = 0;
  1209. if (os_strcmp(uuid, "any") == 0)
  1210. any = 1;
  1211. else if (uuid_str2bin(uuid, u))
  1212. return -1;
  1213. return wps_registrar_add_pin(wpa_s->wps->registrar, addr,
  1214. any ? NULL : u,
  1215. (const u8 *) pin, os_strlen(pin), 300);
  1216. }
  1217. int wpas_wps_er_pbc(struct wpa_supplicant *wpa_s, const char *uuid)
  1218. {
  1219. u8 u[UUID_LEN];
  1220. if (uuid_str2bin(uuid, u))
  1221. return -1;
  1222. return wps_er_pbc(wpa_s->wps_er, u);
  1223. }
  1224. int wpas_wps_er_learn(struct wpa_supplicant *wpa_s, const char *uuid,
  1225. const char *pin)
  1226. {
  1227. u8 u[UUID_LEN];
  1228. if (uuid_str2bin(uuid, u))
  1229. return -1;
  1230. return wps_er_learn(wpa_s->wps_er, u, (const u8 *) pin,
  1231. os_strlen(pin));
  1232. }
  1233. int wpas_wps_er_set_config(struct wpa_supplicant *wpa_s, const char *uuid,
  1234. int id)
  1235. {
  1236. u8 u[UUID_LEN];
  1237. struct wpa_ssid *ssid;
  1238. struct wps_credential cred;
  1239. if (uuid_str2bin(uuid, u))
  1240. return -1;
  1241. ssid = wpa_config_get_network(wpa_s->conf, id);
  1242. if (ssid == NULL || ssid->ssid == NULL)
  1243. return -1;
  1244. os_memset(&cred, 0, sizeof(cred));
  1245. if (ssid->ssid_len > 32)
  1246. return -1;
  1247. os_memcpy(cred.ssid, ssid->ssid, ssid->ssid_len);
  1248. cred.ssid_len = ssid->ssid_len;
  1249. if (ssid->key_mgmt & WPA_KEY_MGMT_PSK) {
  1250. cred.auth_type = (ssid->proto & WPA_PROTO_RSN) ?
  1251. WPS_AUTH_WPA2PSK : WPS_AUTH_WPAPSK;
  1252. if (ssid->pairwise_cipher & WPA_CIPHER_CCMP)
  1253. cred.encr_type = WPS_ENCR_AES;
  1254. else
  1255. cred.encr_type = WPS_ENCR_TKIP;
  1256. if (ssid->passphrase) {
  1257. cred.key_len = os_strlen(ssid->passphrase);
  1258. if (cred.key_len >= 64)
  1259. return -1;
  1260. os_memcpy(cred.key, ssid->passphrase, cred.key_len);
  1261. } else if (ssid->psk_set) {
  1262. cred.key_len = 32;
  1263. os_memcpy(cred.key, ssid->psk, 32);
  1264. } else
  1265. return -1;
  1266. } else {
  1267. cred.auth_type = WPS_AUTH_OPEN;
  1268. cred.encr_type = WPS_ENCR_NONE;
  1269. }
  1270. return wps_er_set_config(wpa_s->wps_er, u, &cred);
  1271. }
  1272. int wpas_wps_er_config(struct wpa_supplicant *wpa_s, const char *uuid,
  1273. const char *pin, struct wps_new_ap_settings *settings)
  1274. {
  1275. u8 u[UUID_LEN];
  1276. struct wps_credential cred;
  1277. size_t len;
  1278. if (uuid_str2bin(uuid, u))
  1279. return -1;
  1280. if (settings->ssid_hex == NULL || settings->auth == NULL ||
  1281. settings->encr == NULL || settings->key_hex == NULL)
  1282. return -1;
  1283. os_memset(&cred, 0, sizeof(cred));
  1284. len = os_strlen(settings->ssid_hex);
  1285. if ((len & 1) || len > 2 * sizeof(cred.ssid) ||
  1286. hexstr2bin(settings->ssid_hex, cred.ssid, len / 2))
  1287. return -1;
  1288. cred.ssid_len = len / 2;
  1289. len = os_strlen(settings->key_hex);
  1290. if ((len & 1) || len > 2 * sizeof(cred.key) ||
  1291. hexstr2bin(settings->key_hex, cred.key, len / 2))
  1292. return -1;
  1293. cred.key_len = len / 2;
  1294. if (os_strcmp(settings->auth, "OPEN") == 0)
  1295. cred.auth_type = WPS_AUTH_OPEN;
  1296. else if (os_strcmp(settings->auth, "WPAPSK") == 0)
  1297. cred.auth_type = WPS_AUTH_WPAPSK;
  1298. else if (os_strcmp(settings->auth, "WPA2PSK") == 0)
  1299. cred.auth_type = WPS_AUTH_WPA2PSK;
  1300. else
  1301. return -1;
  1302. if (os_strcmp(settings->encr, "NONE") == 0)
  1303. cred.encr_type = WPS_ENCR_NONE;
  1304. else if (os_strcmp(settings->encr, "WEP") == 0)
  1305. cred.encr_type = WPS_ENCR_WEP;
  1306. else if (os_strcmp(settings->encr, "TKIP") == 0)
  1307. cred.encr_type = WPS_ENCR_TKIP;
  1308. else if (os_strcmp(settings->encr, "CCMP") == 0)
  1309. cred.encr_type = WPS_ENCR_AES;
  1310. else
  1311. return -1;
  1312. return wps_er_config(wpa_s->wps_er, u, (const u8 *) pin,
  1313. os_strlen(pin), &cred);
  1314. }
  1315. static void wpas_wps_terminate_cb(void *ctx)
  1316. {
  1317. wpa_printf(MSG_DEBUG, "WPS ER: Terminated");
  1318. eloop_terminate();
  1319. }
  1320. #endif /* CONFIG_WPS_ER */
  1321. int wpas_wps_terminate_pending(struct wpa_supplicant *wpa_s)
  1322. {
  1323. #ifdef CONFIG_WPS_ER
  1324. if (wpa_s->wps_er) {
  1325. wps_er_deinit(wpa_s->wps_er, wpas_wps_terminate_cb, wpa_s);
  1326. wpa_s->wps_er = NULL;
  1327. return 1;
  1328. }
  1329. #endif /* CONFIG_WPS_ER */
  1330. return 0;
  1331. }
  1332. int wpas_wps_in_progress(struct wpa_supplicant *wpa_s)
  1333. {
  1334. struct wpa_ssid *ssid;
  1335. for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
  1336. if (!ssid->disabled && ssid->key_mgmt == WPA_KEY_MGMT_WPS)
  1337. return 1;
  1338. }
  1339. return 0;
  1340. }
  1341. void wpas_wps_update_config(struct wpa_supplicant *wpa_s)
  1342. {
  1343. struct wps_context *wps = wpa_s->wps;
  1344. if (wps == NULL)
  1345. return;
  1346. if (wpa_s->conf->changed_parameters & CFG_CHANGED_CONFIG_METHODS) {
  1347. wps->config_methods = wps_config_methods_str2bin(
  1348. wpa_s->conf->config_methods);
  1349. if ((wps->config_methods &
  1350. (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) ==
  1351. (WPS_CONFIG_DISPLAY | WPS_CONFIG_LABEL)) {
  1352. wpa_printf(MSG_ERROR, "WPS: Both Label and Display "
  1353. "config methods are not allowed at the "
  1354. "same time");
  1355. wps->config_methods &= ~WPS_CONFIG_LABEL;
  1356. }
  1357. }
  1358. wps->config_methods = wps_fix_config_methods(wps->config_methods);
  1359. if (wpa_s->conf->changed_parameters & CFG_CHANGED_DEVICE_TYPE) {
  1360. if (wpa_s->conf->device_type &&
  1361. wps_dev_type_str2bin(wpa_s->conf->device_type,
  1362. wps->dev.pri_dev_type) < 0)
  1363. wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
  1364. }
  1365. if (wpa_s->conf->changed_parameters & CFG_CHANGED_OS_VERSION)
  1366. wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
  1367. if (wpa_s->conf->changed_parameters & CFG_CHANGED_UUID) {
  1368. if (is_nil_uuid(wpa_s->conf->uuid)) {
  1369. uuid_gen_mac_addr(wpa_s->own_addr, wps->uuid);
  1370. wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC "
  1371. "address", wps->uuid, WPS_UUID_LEN);
  1372. } else
  1373. os_memcpy(wps->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
  1374. }
  1375. if (wpa_s->conf->changed_parameters &
  1376. (CFG_CHANGED_DEVICE_NAME | CFG_CHANGED_WPS_STRING)) {
  1377. /* Update pointers to make sure they refer current values */
  1378. wps->dev.device_name = wpa_s->conf->device_name;
  1379. wps->dev.manufacturer = wpa_s->conf->manufacturer;
  1380. wps->dev.model_name = wpa_s->conf->model_name;
  1381. wps->dev.model_number = wpa_s->conf->model_number;
  1382. wps->dev.serial_number = wpa_s->conf->serial_number;
  1383. }
  1384. }