diff --git a/wpa_supplicant/README-WPS b/wpa_supplicant/README-WPS index 313e87349..bf75cb4d1 100644 --- a/wpa_supplicant/README-WPS +++ b/wpa_supplicant/README-WPS @@ -127,6 +127,11 @@ This starts the WPS negotiation in the same way as above with the generated PIN. +If a random PIN is needed for a user interface, "wpa_cli wps_pin get" +can be used to generate a new PIN without starting WPS negotiation. +This random PIN can then be passed as an argument to another wps_pin +call when the actual operation should be started. + If the client design wants to support optional WPS PBC mode, this can be enabled by either a physical button in the client device or a virtual button in the user interface. The PBC operation requires that diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index b58d40d7e..2b0b08190 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -340,7 +340,10 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s, if (os_strcmp(cmd, "any") == 0) _bssid = NULL; - else if (hwaddr_aton(cmd, bssid)) { + else if (os_strcmp(cmd, "get") == 0) { + ret = wps_generate_pin(); + goto done; + } else if (hwaddr_aton(cmd, bssid)) { wpa_printf(MSG_DEBUG, "CTRL_IFACE WPS_PIN: invalid BSSID '%s'", cmd); return -1; @@ -367,6 +370,7 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s, if (ret < 0) return -1; +done: /* Return the generated PIN */ ret = os_snprintf(buf, buflen, "%08d", ret); if (ret < 0 || (size_t) ret >= buflen)