From 31d7fb14af96aa745b5acdf03d8b4f0569c964e5 Mon Sep 17 00:00:00 2001 From: Purushottam Kushwaha Date: Fri, 29 Apr 2016 16:20:12 +0530 Subject: [PATCH] P2PS: Allow P2P_CONNECT command for P2PS connection with/without PIN This allows using P2PS config method with or without PIN for connection. wpa_supplicant should internally handle the default PIN "12345670" and shall also allow connection irrespective of PIN used in P2P_CONNECT. For example, 1. P2P_CONNECT 02:2a:fb:22:22:33 p2ps 2. P2P_CONNECT 02:2a:fb:22:22:33 xxxxxxxx p2ps Where the second one is maintained for backwards compatibility. Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 4 ++-- wpa_supplicant/p2p_supplicant.c | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index ea8ceccb8..e75f1ae44 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -5098,6 +5098,8 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, wps_method = WPS_PIN_DISPLAY; } else if (os_strncmp(pos, "pbc", 3) == 0) { wps_method = WPS_PBC; + } else if (os_strstr(pos, "p2ps") != NULL) { + wps_method = WPS_P2PS; } else { pin = pos; pos = os_strchr(pin, ' '); @@ -5106,8 +5108,6 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, *pos++ = '\0'; if (os_strncmp(pos, "display", 7) == 0) wps_method = WPS_PIN_DISPLAY; - else if (os_strncmp(pos, "p2ps", 4) == 0) - wps_method = WPS_P2PS; } if (!wps_pin_str_valid(pin)) { os_memcpy(buf, "FAIL-INVALID-PIN\n", 17); diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index a9443f3d0..8f6acd6ce 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -5383,6 +5383,9 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr, wpa_s->p2p_pin[sizeof(wpa_s->p2p_pin) - 1] = '\0'; wpa_printf(MSG_DEBUG, "P2P: Randomly generated PIN: %s", wpa_s->p2p_pin); + } else if (wps_method == WPS_P2PS) { + /* Force the P2Ps default PIN to be used */ + os_strlcpy(wpa_s->p2p_pin, "12345670", sizeof(wpa_s->p2p_pin)); } else wpa_s->p2p_pin[0] = '\0';