]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Allow PIN timeout to be specified with wpa_supplicant AP/GO
authorJouni Malinen <jouni@qca.qualcomm.com>
Wed, 10 Oct 2012 14:22:35 +0000 (17:22 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 10 Oct 2012 14:22:35 +0000 (17:22 +0300)
Extend the wpa_cli wps_pin command to support specification of the PIN
expiration time in seconds similarly to hostapd_cli wps_pin command when
using wpa_supplicant for AP mode (including P2P GO).

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/README-WPS
wpa_supplicant/ap.c
wpa_supplicant/ap.h
wpa_supplicant/ctrl_iface.c
wpa_supplicant/dbus/dbus_new_handlers_wps.c
wpa_supplicant/p2p_supplicant.c

index 692d5f556fa8bef336281dcbb83820d97522d623..35be3576e5c590b6503af2f52748d20d70b300f0 100644 (file)
@@ -130,6 +130,12 @@ wpa_cli wps_pin any 12345670
 This starts the WPS negotiation in the same way as above with the
 generated PIN.
 
+When the wps_pin command is issued for an AP (including P2P GO) mode
+interface, an optional timeout parameter can be used to specify
+expiration timeout for the PIN in seconds. For example:
+
+wpa_cli wps_pin any 12345670 300
+
 
 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.
index 3798f5a63f09e94eba6f8995046fb2c217ff904a..088f57d349f4ea983bb96c1db6458db996ee601e 100644 (file)
@@ -724,7 +724,8 @@ int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s)
 
 
 int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
-                             const char *pin, char *buf, size_t buflen)
+                             const char *pin, char *buf, size_t buflen,
+                             int timeout)
 {
        int ret, ret_len = 0;
 
@@ -739,7 +740,7 @@ int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
                ret_len = os_snprintf(buf, buflen, "%s", pin);
 
        ret = hostapd_wps_add_pin(wpa_s->ap_iface->bss[0], bssid, "any", pin,
-                                 0);
+                                 timeout);
        if (ret)
                return -1;
        return ret_len;
index bc953d9bcd56bd66074d7587a04ccb2da6b66d3c..536064f7c74f4de0e7dfff7e25881a88c6d6a5fb 100644 (file)
@@ -18,7 +18,8 @@ void wpa_supplicant_ap_rx_eapol(struct wpa_supplicant *wpa_s,
 int wpa_supplicant_ap_wps_pbc(struct wpa_supplicant *wpa_s, const u8 *bssid,
                              const u8 *p2p_dev_addr);
 int wpa_supplicant_ap_wps_pin(struct wpa_supplicant *wpa_s, const u8 *bssid,
-                             const char *pin, char *buf, size_t buflen);
+                             const char *pin, char *buf, size_t buflen,
+                             int timeout);
 int wpa_supplicant_ap_wps_cancel(struct wpa_supplicant *wpa_s);
 void wpas_wps_ap_pin_disable(struct wpa_supplicant *wpa_s);
 const char * wpas_wps_ap_pin_random(struct wpa_supplicant *wpa_s, int timeout);
index 75e92a945828f778ad5423b2437ec7b043439165..8038b9c28ba45807ca17c3972139b1a1578806c1 100644 (file)
@@ -664,9 +664,21 @@ static int wpa_supplicant_ctrl_iface_wps_pin(struct wpa_supplicant *wpa_s,
        }
 
 #ifdef CONFIG_AP
-       if (wpa_s->ap_iface)
+       if (wpa_s->ap_iface) {
+               int timeout = 0;
+               char *pos;
+
+               if (pin) {
+                       pos = os_strchr(pin, ' ');
+                       if (pos) {
+                               *pos++ = '\0';
+                               timeout = atoi(pos);
+                       }
+               }
+
                return wpa_supplicant_ap_wps_pin(wpa_s, _bssid, pin,
-                                                buf, buflen);
+                                                buf, buflen, timeout);
+       }
 #endif /* CONFIG_AP */
 
        if (pin) {
index 8489ce77c56a2eafa5e35b1260704c88bb226c1e..4ad5e7e0bd40763b401d1c3ec56ffbffd4183388 100644 (file)
@@ -273,7 +273,7 @@ DBusMessage * wpas_dbus_handler_wps_start(DBusMessage *message,
                        ret = wpa_supplicant_ap_wps_pin(wpa_s,
                                                        params.bssid,
                                                        params.pin,
-                                                       npin, sizeof(npin));
+                                                       npin, sizeof(npin), 0);
                else
 #endif /* CONFIG_AP */
                {
index 06cbaf58430b9e894fd678a40555cca91bfd2878..39924b17e2ca76a103a47f1ed8a7417e94238942 100644 (file)
@@ -837,7 +837,7 @@ static void p2p_go_configured(void *ctx, void *data)
                                          params->peer_device_addr);
        else if (wpa_s->p2p_pin[0])
                wpa_supplicant_ap_wps_pin(wpa_s, params->peer_interface_addr,
-                                         wpa_s->p2p_pin, NULL, 0);
+                                         wpa_s->p2p_pin, NULL, 0, 0);
        os_free(wpa_s->go_params);
        wpa_s->go_params = NULL;
 }