2 * wpa_supplicant / WPS integration
3 * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
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.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
18 #include "ieee802_11_defs.h"
19 #include "wpa_common.h"
21 #include "eap_peer/eap.h"
22 #include "wpa_supplicant_i.h"
26 #include "ctrl_iface_dbus.h"
27 #include "eap_common/eap_wsc_common.h"
28 #include "blacklist.h"
29 #include "wps_supplicant.h"
30 #include "dh_groups.h"
32 #define WPS_PIN_SCAN_IGNORE_SEL_REG 3
34 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx);
35 static void wpas_clear_wps(struct wpa_supplicant *wpa_s);
38 int wpas_wps_eapol_cb(struct wpa_supplicant *wpa_s)
40 if (!wpa_s->wps_success &&
41 wpa_s->current_ssid &&
42 eap_is_wps_pin_enrollee(&wpa_s->current_ssid->eap)) {
43 const u8 *bssid = wpa_s->bssid;
44 if (is_zero_ether_addr(bssid))
45 bssid = wpa_s->pending_bssid;
47 wpa_printf(MSG_DEBUG, "WPS: PIN registration with " MACSTR
48 " did not succeed - continue trying to find "
49 "suitable AP", MAC2STR(bssid));
50 wpa_blacklist_add(wpa_s, bssid);
52 wpa_supplicant_deauthenticate(wpa_s,
53 WLAN_REASON_DEAUTH_LEAVING);
54 wpa_s->reassociate = 1;
55 wpa_supplicant_req_scan(wpa_s,
56 wpa_s->blacklist_cleared ? 5 : 0, 0);
57 wpa_s->blacklist_cleared = 0;
61 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 wpa_printf(MSG_DEBUG, "WPS: Network configuration replaced - "
66 "try to associate with the received credential");
67 wpa_supplicant_deauthenticate(wpa_s,
68 WLAN_REASON_DEAUTH_LEAVING);
69 wpa_s->reassociate = 1;
70 wpa_supplicant_req_scan(wpa_s, 0, 0);
74 if (wpa_s->key_mgmt == WPA_KEY_MGMT_WPS && wpa_s->current_ssid) {
75 wpa_printf(MSG_DEBUG, "WPS: Registration completed - waiting "
76 "for external credential processing");
77 wpas_clear_wps(wpa_s);
78 wpa_supplicant_deauthenticate(wpa_s,
79 WLAN_REASON_DEAUTH_LEAVING);
87 static int wpa_supplicant_wps_cred(void *ctx,
88 const struct wps_credential *cred)
90 struct wpa_supplicant *wpa_s = ctx;
91 struct wpa_ssid *ssid = wpa_s->current_ssid;
94 if ((wpa_s->conf->wps_cred_processing == 1 ||
95 wpa_s->conf->wps_cred_processing == 2) && cred->cred_attr) {
96 size_t blen = cred->cred_attr_len * 2 + 1;
97 char *buf = os_malloc(blen);
99 wpa_snprintf_hex(buf, blen,
100 cred->cred_attr, cred->cred_attr_len);
101 wpa_msg(wpa_s, MSG_INFO, "%s%s",
102 WPS_EVENT_CRED_RECEIVED, buf);
105 wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
107 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_CRED_RECEIVED);
109 wpa_hexdump_key(MSG_DEBUG, "WPS: Received Credential attribute",
110 cred->cred_attr, cred->cred_attr_len);
112 if (wpa_s->conf->wps_cred_processing == 1)
115 if (cred->auth_type != WPS_AUTH_OPEN &&
116 cred->auth_type != WPS_AUTH_SHARED &&
117 cred->auth_type != WPS_AUTH_WPAPSK &&
118 cred->auth_type != WPS_AUTH_WPA2PSK) {
119 wpa_printf(MSG_DEBUG, "WPS: Ignored credentials for "
120 "unsupported authentication type %d",
125 if (ssid && (ssid->key_mgmt & WPA_KEY_MGMT_WPS)) {
126 wpa_printf(MSG_DEBUG, "WPS: Replace WPS network block based "
127 "on the received credential");
128 os_free(ssid->eap.identity);
129 ssid->eap.identity = NULL;
130 ssid->eap.identity_len = 0;
131 os_free(ssid->eap.phase1);
132 ssid->eap.phase1 = NULL;
133 os_free(ssid->eap.eap_methods);
134 ssid->eap.eap_methods = NULL;
136 wpa_printf(MSG_DEBUG, "WPS: Create a new network based on the "
137 "received credential");
138 ssid = wpa_config_add_network(wpa_s->conf);
143 wpa_config_set_network_defaults(ssid);
146 ssid->ssid = os_malloc(cred->ssid_len);
148 os_memcpy(ssid->ssid, cred->ssid, cred->ssid_len);
149 ssid->ssid_len = cred->ssid_len;
152 switch (cred->encr_type) {
156 if (cred->key_len <= 0)
158 if (cred->key_len != 5 && cred->key_len != 13 &&
159 cred->key_len != 10 && cred->key_len != 26) {
160 wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key length "
161 "%lu", (unsigned long) cred->key_len);
164 if (cred->key_idx > NUM_WEP_KEYS) {
165 wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key index %d",
170 key_idx = cred->key_idx - 1;
171 if (cred->key_len == 10 || cred->key_len == 26) {
172 if (hexstr2bin((char *) cred->key,
173 ssid->wep_key[key_idx],
174 cred->key_len / 2) < 0) {
175 wpa_printf(MSG_ERROR, "WPS: Invalid WEP Key "
179 ssid->wep_key_len[key_idx] = cred->key_len / 2;
181 os_memcpy(ssid->wep_key[key_idx], cred->key,
183 ssid->wep_key_len[key_idx] = cred->key_len;
185 ssid->wep_tx_keyidx = key_idx;
188 ssid->pairwise_cipher = WPA_CIPHER_TKIP;
191 ssid->pairwise_cipher = WPA_CIPHER_CCMP;
195 switch (cred->auth_type) {
197 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
198 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
201 case WPS_AUTH_SHARED:
202 ssid->auth_alg = WPA_AUTH_ALG_SHARED;
203 ssid->key_mgmt = WPA_KEY_MGMT_NONE;
206 case WPS_AUTH_WPAPSK:
207 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
208 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
209 ssid->proto = WPA_PROTO_WPA;
212 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
213 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
214 ssid->proto = WPA_PROTO_WPA;
217 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
218 ssid->key_mgmt = WPA_KEY_MGMT_IEEE8021X;
219 ssid->proto = WPA_PROTO_RSN;
221 case WPS_AUTH_WPA2PSK:
222 ssid->auth_alg = WPA_AUTH_ALG_OPEN;
223 ssid->key_mgmt = WPA_KEY_MGMT_PSK;
224 ssid->proto = WPA_PROTO_RSN;
228 if (ssid->key_mgmt == WPA_KEY_MGMT_PSK) {
229 if (cred->key_len == 2 * PMK_LEN) {
230 if (hexstr2bin((const char *) cred->key, ssid->psk,
232 wpa_printf(MSG_ERROR, "WPS: Invalid Network "
237 } else if (cred->key_len >= 8 && cred->key_len < 2 * PMK_LEN) {
238 os_free(ssid->passphrase);
239 ssid->passphrase = os_malloc(cred->key_len + 1);
240 if (ssid->passphrase == NULL)
242 os_memcpy(ssid->passphrase, cred->key, cred->key_len);
243 ssid->passphrase[cred->key_len] = '\0';
244 wpa_config_update_psk(ssid);
246 wpa_printf(MSG_ERROR, "WPS: Invalid Network Key "
248 (unsigned long) cred->key_len);
253 #ifndef CONFIG_NO_CONFIG_WRITE
254 if (wpa_s->conf->update_config &&
255 wpa_config_write(wpa_s->confname, wpa_s->conf)) {
256 wpa_printf(MSG_DEBUG, "WPS: Failed to update configuration");
259 #endif /* CONFIG_NO_CONFIG_WRITE */
265 static void wpa_supplicant_wps_event_m2d(struct wpa_supplicant *wpa_s,
266 struct wps_event_m2d *m2d)
268 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_M2D
269 "dev_password_id=%d config_error=%d",
270 m2d->dev_password_id, m2d->config_error);
274 static void wpa_supplicant_wps_event_fail(struct wpa_supplicant *wpa_s,
275 struct wps_event_fail *fail)
277 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_FAIL "msg=%d", fail->msg);
278 wpas_clear_wps(wpa_s);
282 static void wpa_supplicant_wps_event_success(struct wpa_supplicant *wpa_s)
284 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_SUCCESS);
285 wpa_s->wps_success = 1;
289 static void wpa_supplicant_wps_event(void *ctx, enum wps_event event,
290 union wps_event_data *data)
292 struct wpa_supplicant *wpa_s = ctx;
295 wpa_supplicant_wps_event_m2d(wpa_s, &data->m2d);
298 wpa_supplicant_wps_event_fail(wpa_s, &data->fail);
301 wpa_supplicant_wps_event_success(wpa_s);
303 case WPS_EV_PWD_AUTH_FAIL:
309 enum wps_request_type wpas_wps_get_req_type(struct wpa_ssid *ssid)
311 if (eap_is_wps_pbc_enrollee(&ssid->eap) ||
312 eap_is_wps_pin_enrollee(&ssid->eap))
313 return WPS_REQ_ENROLLEE;
315 return WPS_REQ_REGISTRAR;
319 static void wpas_clear_wps(struct wpa_supplicant *wpa_s)
322 struct wpa_ssid *ssid;
324 eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
326 /* Remove any existing WPS network from configuration */
327 ssid = wpa_s->conf->ssid;
329 if (ssid->key_mgmt & WPA_KEY_MGMT_WPS) {
330 if (ssid == wpa_s->current_ssid)
331 wpa_s->current_ssid = NULL;
337 wpa_config_remove_network(wpa_s->conf, id);
342 static void wpas_wps_timeout(void *eloop_ctx, void *timeout_ctx)
344 struct wpa_supplicant *wpa_s = eloop_ctx;
345 wpa_printf(MSG_INFO, WPS_EVENT_TIMEOUT "Requested operation timed "
347 wpas_clear_wps(wpa_s);
351 static struct wpa_ssid * wpas_wps_add_network(struct wpa_supplicant *wpa_s,
352 int registrar, const u8 *bssid)
354 struct wpa_ssid *ssid;
356 ssid = wpa_config_add_network(wpa_s->conf);
359 wpa_config_set_network_defaults(ssid);
360 if (wpa_config_set(ssid, "key_mgmt", "WPS", 0) < 0 ||
361 wpa_config_set(ssid, "eap", "WSC", 0) < 0 ||
362 wpa_config_set(ssid, "identity", registrar ?
363 "\"" WSC_ID_REGISTRAR "\"" :
364 "\"" WSC_ID_ENROLLEE "\"", 0) < 0) {
365 wpa_config_remove_network(wpa_s->conf, ssid->id);
371 struct wpa_scan_res *res;
373 os_memcpy(ssid->bssid, bssid, ETH_ALEN);
376 /* Try to get SSID from scan results */
377 if (wpa_s->scan_res == NULL &&
378 wpa_supplicant_get_scan_results(wpa_s) < 0)
379 return ssid; /* Could not find any scan results */
381 for (i = 0; i < wpa_s->scan_res->num; i++) {
384 res = wpa_s->scan_res->res[i];
385 if (os_memcmp(bssid, res->bssid, ETH_ALEN) != 0)
388 ie = wpa_scan_get_ie(res, WLAN_EID_SSID);
392 ssid->ssid = os_malloc(ie[1]);
393 if (ssid->ssid == NULL)
395 os_memcpy(ssid->ssid, ie + 2, ie[1]);
396 ssid->ssid_len = ie[1];
405 static void wpas_wps_reassoc(struct wpa_supplicant *wpa_s,
406 struct wpa_ssid *selected)
408 struct wpa_ssid *ssid;
410 /* Mark all other networks disabled and trigger reassociation */
411 ssid = wpa_s->conf->ssid;
413 ssid->disabled = ssid != selected;
416 wpa_s->disconnected = 0;
417 wpa_s->reassociate = 1;
418 wpa_s->scan_runs = 0;
419 wpa_s->wps_success = 0;
420 wpa_s->blacklist_cleared = 0;
421 wpa_supplicant_req_scan(wpa_s, 0, 0);
425 int wpas_wps_start_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid)
427 struct wpa_ssid *ssid;
428 wpas_clear_wps(wpa_s);
429 ssid = wpas_wps_add_network(wpa_s, 0, bssid);
432 wpa_config_set(ssid, "phase1", "\"pbc=1\"", 0);
433 eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
435 wpas_wps_reassoc(wpa_s, ssid);
440 int wpas_wps_start_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
443 struct wpa_ssid *ssid;
445 unsigned int rpin = 0;
447 wpas_clear_wps(wpa_s);
448 ssid = wpas_wps_add_network(wpa_s, 0, bssid);
452 os_snprintf(val, sizeof(val), "\"pin=%s\"", pin);
454 rpin = wps_generate_pin();
455 os_snprintf(val, sizeof(val), "\"pin=%08d\"", rpin);
457 wpa_config_set(ssid, "phase1", val, 0);
458 eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
460 wpas_wps_reassoc(wpa_s, ssid);
465 int wpas_wps_start_oob(struct wpa_supplicant *wpa_s, char *device_type,
466 char *path, char *method)
468 struct wps_context *wps = wpa_s->wps;
470 wps->oob_dev = wps_get_oob_device(device_type);
471 if (wps->oob_dev == NULL)
473 wps->oob_dev->device_path = path;
474 wps->oob_conf.oob_method = wps_get_oob_method(method);
476 if (wps->oob_conf.oob_method == OOB_METHOD_CRED)
477 wpas_clear_wps(wpa_s);
479 if (wps_process_oob(wps, 0) < 0)
482 if ((wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_E ||
483 wps->oob_conf.oob_method == OOB_METHOD_DEV_PWD_R) &&
484 wpas_wps_start_pin(wpa_s, NULL,
485 wpabuf_head(wps->oob_conf.dev_password)) < 0)
492 int wpas_wps_start_reg(struct wpa_supplicant *wpa_s, const u8 *bssid,
495 struct wpa_ssid *ssid;
500 wpas_clear_wps(wpa_s);
501 ssid = wpas_wps_add_network(wpa_s, 1, bssid);
504 os_snprintf(val, sizeof(val), "\"pin=%s\"", pin);
505 wpa_config_set(ssid, "phase1", val, 0);
506 eloop_register_timeout(WPS_PBC_WALK_TIME, 0, wpas_wps_timeout,
508 wpas_wps_reassoc(wpa_s, ssid);
513 static int wpas_wps_new_psk_cb(void *ctx, const u8 *mac_addr, const u8 *psk,
516 wpa_printf(MSG_DEBUG, "WPS: Received new WPA/WPA2-PSK from WPS for "
517 "STA " MACSTR, MAC2STR(mac_addr));
518 wpa_hexdump_key(MSG_DEBUG, "Per-device PSK", psk, psk_len);
526 static void wpas_wps_pin_needed_cb(void *ctx, const u8 *uuid_e,
527 const struct wps_device_data *dev)
529 char uuid[40], txt[400];
531 if (uuid_bin2str(uuid_e, uuid, sizeof(uuid)))
533 wpa_printf(MSG_DEBUG, "WPS: PIN needed for UUID-E %s", uuid);
534 len = os_snprintf(txt, sizeof(txt), "WPS-EVENT-PIN-NEEDED %s " MACSTR
535 " [%s|%s|%s|%s|%s|%d-%08X-%d]",
536 uuid, MAC2STR(dev->mac_addr), dev->device_name,
537 dev->manufacturer, dev->model_name,
538 dev->model_number, dev->serial_number,
539 dev->categ, dev->oui, dev->sub_categ);
540 if (len > 0 && len < (int) sizeof(txt))
541 wpa_printf(MSG_INFO, "%s", txt);
545 int wpas_wps_init(struct wpa_supplicant *wpa_s)
547 struct wps_context *wps;
548 struct wps_registrar_config rcfg;
550 wps = os_zalloc(sizeof(*wps));
554 wps->cred_cb = wpa_supplicant_wps_cred;
555 wps->event_cb = wpa_supplicant_wps_event;
558 wps->dev.device_name = wpa_s->conf->device_name;
559 wps->dev.manufacturer = wpa_s->conf->manufacturer;
560 wps->dev.model_name = wpa_s->conf->model_name;
561 wps->dev.model_number = wpa_s->conf->model_number;
562 wps->dev.serial_number = wpa_s->conf->serial_number;
563 if (wpa_s->conf->device_type) {
566 /* <categ>-<OUI>-<subcateg> */
567 wps->dev.categ = atoi(wpa_s->conf->device_type);
568 pos = os_strchr(wpa_s->conf->device_type, '-');
570 wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
575 if (hexstr2bin(pos, oui, 4)) {
576 wpa_printf(MSG_ERROR, "WPS: Invalid device_type OUI");
580 wps->dev.oui = WPA_GET_BE32(oui);
581 pos = os_strchr(pos, '-');
583 wpa_printf(MSG_ERROR, "WPS: Invalid device_type");
588 wps->dev.sub_categ = atoi(pos);
590 wps->dev.os_version = WPA_GET_BE32(wpa_s->conf->os_version);
591 wps->dev.rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ; /* TODO: config */
592 os_memcpy(wps->dev.mac_addr, wpa_s->own_addr, ETH_ALEN);
593 if (is_nil_uuid(wpa_s->conf->uuid)) {
594 uuid_gen_mac_addr(wpa_s->own_addr, wps->uuid);
595 wpa_hexdump(MSG_DEBUG, "WPS: UUID based on MAC address",
596 wps->uuid, WPS_UUID_LEN);
598 os_memcpy(wps->uuid, wpa_s->conf->uuid, WPS_UUID_LEN);
600 wps->auth_types = WPS_AUTH_WPA2PSK | WPS_AUTH_WPAPSK;
601 wps->encr_types = WPS_ENCR_AES | WPS_ENCR_TKIP;
603 os_memset(&rcfg, 0, sizeof(rcfg));
604 rcfg.new_psk_cb = wpas_wps_new_psk_cb;
605 rcfg.pin_needed_cb = wpas_wps_pin_needed_cb;
608 wps->registrar = wps_registrar_init(wps, &rcfg);
609 if (wps->registrar == NULL) {
610 wpa_printf(MSG_DEBUG, "Failed to initialize WPS Registrar");
615 wps->dh_pubkey = dh_init(dh_groups_get(WPS_DH_GROUP),
617 wps->dh_pubkey = wpabuf_zeropad(wps->dh_pubkey, 192);
618 if (wps->dh_pubkey == NULL) {
619 wpa_printf(MSG_ERROR, "WPS: Failed to initialize "
620 "Diffie-Hellman handshake");
631 void wpas_wps_deinit(struct wpa_supplicant *wpa_s)
633 eloop_cancel_timeout(wpas_wps_timeout, wpa_s, NULL);
635 if (wpa_s->wps == NULL)
638 wps_registrar_deinit(wpa_s->wps->registrar);
639 wpabuf_free(wpa_s->wps->dh_pubkey);
640 wpabuf_free(wpa_s->wps->dh_privkey);
641 wpabuf_free(wpa_s->wps->oob_conf.pubkey_hash);
642 wpabuf_free(wpa_s->wps->oob_conf.dev_password);
643 os_free(wpa_s->wps->network_key);
649 int wpas_wps_ssid_bss_match(struct wpa_supplicant *wpa_s,
650 struct wpa_ssid *ssid, struct wpa_scan_res *bss)
652 struct wpabuf *wps_ie;
654 if (!(ssid->key_mgmt & WPA_KEY_MGMT_WPS))
657 wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
658 if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
660 wpa_printf(MSG_DEBUG, " skip - non-WPS AP");
664 if (!wps_is_selected_pbc_registrar(wps_ie)) {
665 wpa_printf(MSG_DEBUG, " skip - WPS AP "
666 "without active PBC Registrar");
671 /* TODO: overlap detection */
672 wpa_printf(MSG_DEBUG, " selected based on WPS IE "
678 if (eap_is_wps_pin_enrollee(&ssid->eap)) {
680 wpa_printf(MSG_DEBUG, " skip - non-WPS AP");
685 * Start with WPS APs that advertise active PIN Registrar and
686 * allow any WPS AP after third scan since some APs do not set
687 * Selected Registrar attribute properly when using external
690 if (!wps_is_selected_pin_registrar(wps_ie)) {
691 if (wpa_s->scan_runs < WPS_PIN_SCAN_IGNORE_SEL_REG) {
692 wpa_printf(MSG_DEBUG, " skip - WPS AP "
693 "without active PIN Registrar");
697 wpa_printf(MSG_DEBUG, " selected based on WPS IE");
699 wpa_printf(MSG_DEBUG, " selected based on WPS IE "
707 wpa_printf(MSG_DEBUG, " selected based on WPS IE");
716 int wpas_wps_ssid_wildcard_ok(struct wpa_supplicant *wpa_s,
717 struct wpa_ssid *ssid,
718 struct wpa_scan_res *bss)
720 struct wpabuf *wps_ie = NULL;
723 if (eap_is_wps_pbc_enrollee(&ssid->eap)) {
724 wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
725 if (wps_ie && wps_is_selected_pbc_registrar(wps_ie)) {
726 /* allow wildcard SSID for WPS PBC */
729 } else if (eap_is_wps_pin_enrollee(&ssid->eap)) {
730 wps_ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
732 (wps_is_selected_pin_registrar(wps_ie) ||
733 wpa_s->scan_runs >= WPS_PIN_SCAN_IGNORE_SEL_REG)) {
734 /* allow wildcard SSID for WPS PIN */
739 if (!ret && ssid->bssid_set &&
740 os_memcmp(ssid->bssid, bss->bssid, ETH_ALEN) == 0) {
741 /* allow wildcard SSID due to hardcoded BSSID match */
751 int wpas_wps_scan_pbc_overlap(struct wpa_supplicant *wpa_s,
752 struct wpa_scan_res *selected,
753 struct wpa_ssid *ssid)
755 const u8 *sel_uuid, *uuid;
757 struct wpabuf *wps_ie;
760 if (!eap_is_wps_pbc_enrollee(&ssid->eap))
763 /* Make sure that only one AP is in active PBC mode */
764 wps_ie = wpa_scan_get_vendor_ie_multi(selected, WPS_IE_VENDOR_TYPE);
766 sel_uuid = wps_get_uuid_e(wps_ie);
770 for (i = 0; i < wpa_s->scan_res->num; i++) {
771 struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
775 ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
778 if (!wps_is_selected_pbc_registrar(ie)) {
782 uuid = wps_get_uuid_e(ie);
783 if (sel_uuid == NULL || uuid == NULL ||
784 os_memcmp(sel_uuid, uuid, 16) != 0) {
785 ret = 1; /* PBC overlap */
790 /* TODO: verify that this is reasonable dual-band situation */
801 void wpas_wps_notify_scan_results(struct wpa_supplicant *wpa_s)
805 if (wpa_s->disconnected || wpa_s->wpa_state >= WPA_ASSOCIATED)
808 for (i = 0; i < wpa_s->scan_res->num; i++) {
809 struct wpa_scan_res *bss = wpa_s->scan_res->res[i];
811 ie = wpa_scan_get_vendor_ie_multi(bss, WPS_IE_VENDOR_TYPE);
814 if (wps_is_selected_pbc_registrar(ie))
815 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PBC);
816 else if (wps_is_selected_pin_registrar(ie))
817 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE_PIN);
819 wpa_msg(wpa_s, MSG_INFO, WPS_EVENT_AP_AVAILABLE);
826 int wpas_wps_searching(struct wpa_supplicant *wpa_s)
828 struct wpa_ssid *ssid;
830 for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
831 if ((ssid->key_mgmt & WPA_KEY_MGMT_WPS) && !ssid->disabled)