From 8edd9f10589010a690f045b5bd898eb156f47c29 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 30 Dec 2015 19:12:38 +0200 Subject: [PATCH] P2P: Add an option to specify group SSID in P2P_CONNECT join case The new optional ssid= argument to P2P_CONNECT can be used to make P2P Client operations during join-an-existing-group more robust by filtering out scan results based on the SSID in addition to the P2P Device/Interface Address. This can help if the same MAC address has been used in multiple groups recently and the cached scan results may still include an older BSS. Signed-off-by: Jouni Malinen --- wpa_supplicant/README-P2P | 7 +++++++ wpa_supplicant/ctrl_iface.c | 23 +++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/README-P2P b/wpa_supplicant/README-P2P index 6a5b032..19cf155 100644 --- a/wpa_supplicant/README-P2P +++ b/wpa_supplicant/README-P2P @@ -151,6 +151,7 @@ join-a-group style PD instead of GO Negotiation style PD. p2p_connect [display|keypad|p2ps] [persistent|persistent=] [join|auth] [go_intent=<0..15>] [freq=] [ht40] [vht] [provdisc] [auto] + [ssid=] Start P2P group formation with a discovered P2P peer. This includes optional group owner negotiation, group interface setup, provisioning, @@ -195,6 +196,12 @@ connection. out whether the peer device is operating as a GO and if so, use join-a-group operation rather than GO Negotiation. +"ssid=" can be used to specify the Group SSID for join +operations. This allows the P2P Client interface to filter scan results +based on SSID to avoid selecting an incorrect BSS entry in case the same +P2P Device or Interface address have been used in multiple groups +recently. + P2PS attribute changes to p2p_connect command: P2PS supports two WPS provisioning methods namely PIN method and P2PS default. diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index a3849eb..58b8db4 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -4911,6 +4911,8 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, int freq = 0; int pd; int ht40, vht, max_oper_chwidth, chwidth = 0, freq2 = 0; + u8 _group_ssid[SSID_MAX_LEN], *group_ssid = NULL; + size_t group_ssid_len = 0; if (!wpa_s->global->p2p_init_wpa_s) return -1; @@ -4923,7 +4925,7 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, /* <"pbc" | "pin" | PIN> [label|display|keypad|p2ps] * [persistent|persistent=] * [join] [auth] [go_intent=<0..15>] [freq=] [provdisc] - * [ht40] [vht] [auto] */ + * [ht40] [vht] [auto] [ssid=] */ if (hwaddr_aton(cmd, addr)) return -1; @@ -4983,6 +4985,22 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, if (max_oper_chwidth < 0) return -1; + pos2 = os_strstr(pos, " ssid="); + if (pos2) { + char *end; + + pos2 += 6; + end = os_strchr(pos2, ' '); + if (!end) + group_ssid_len = os_strlen(pos2) / 2; + else + group_ssid_len = (end - pos2) / 2; + if (group_ssid_len == 0 || group_ssid_len > SSID_MAX_LEN || + hexstr2bin(pos2, _group_ssid, group_ssid_len) < 0) + return -1; + group_ssid = _group_ssid; + } + if (os_strncmp(pos, "pin", 3) == 0) { /* Request random PIN (to be displayed) and enable the PIN */ wps_method = WPS_PIN_DISPLAY; @@ -5008,7 +5026,8 @@ static int p2p_ctrl_connect(struct wpa_supplicant *wpa_s, char *cmd, new_pin = wpas_p2p_connect(wpa_s, addr, pin, wps_method, persistent_group, automatic, join, auth, go_intent, freq, freq2, persistent_id, - pd, ht40, vht, max_oper_chwidth, NULL, 0); + pd, ht40, vht, max_oper_chwidth, + group_ssid, group_ssid_len); if (new_pin == -2) { os_memcpy(buf, "FAIL-CHANNEL-UNAVAILABLE\n", 25); return 25; -- 2.1.4