WPS: Add 'wpa_cli wps_pin get' for generating random PINs
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 2 Sep 2011 18:29:06 +0000 (21:29 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 2 Sep 2011 18:29:06 +0000 (21:29 +0300)
This can be used, e.g., in a UI to generate a PIN without
starting WPS (or P2P) operation.

wpa_supplicant/README-WPS
wpa_supplicant/ctrl_iface.c

index 313e873..bf75cb4 100644 (file)
@@ -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
index b58d40d..2b0b081 100644 (file)
@@ -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)