WPS: Allow PIN timeout to be specified with wpa_supplicant AP/GO

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>
This commit is contained in:
Jouni Malinen 2012-10-10 17:22:35 +03:00 committed by Jouni Malinen
parent 7a808c7eb7
commit c423708f02
6 changed files with 27 additions and 7 deletions

View 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.

View 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;

View 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);

View 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) {

View 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 */
{

View 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;
}