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