diff mbox

For P2P_EVENT_PROV_DISC_SHOW_PIN, store the generated PIN.

Message ID 6C370B347C3FE8438C9692873287D2E1195AE35D5F@SJEXCHCCR01.corp.ad.broadcom.com
State Superseded, archived
Headers show

Commit Message

Jithu Jance Nov. 21, 2011, 10:08 a.m. UTC
If p2p_connect join is issued with pin display option, the p2p_connect context generates a pin and stores it. In addition to this PIN, 
Provision discovery response also generates another PIN which is different from the original PIN. This patch avoids generating a new
pin, if the PIN is already set. If PIN is not present, then it uses the newly generated pin and stores it.


Signed-hostap: Jithu Jance <jithu@broadcom.com>

---
 wpa_supplicant/p2p_supplicant.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

Comments

Jouni Malinen Nov. 21, 2011, 4:34 p.m. UTC | #1
On Mon, Nov 21, 2011 at 02:08:06AM -0800, Jithu Jance wrote:
> If p2p_connect join is issued with pin display option, the p2p_connect context generates a pin and stores it. In addition to this PIN, 
> Provision discovery response also generates another PIN which is different from the original PIN. This patch avoids generating a new
> pin, if the PIN is already set. If PIN is not present, then it uses the newly generated pin and stores it.

The generated PIN here is available just to make it easier for an UI to
to generate a new PIN, i.e., it was not really designed to be the only
PIN that could be used in the P2P connection. I'm not completely sure I
understand what you are trying to achieve with this patch. Could you
please give some more details on the sequence of commands in which this
stored (or remembered?) PIN would be used? Provision discovery would be
used prior to the p2p_connect command and p2p_connect overrided
wpa_s->p2p_pin anyway..

In addition, this change would result in different PIN getting passed in
the ctrl_iface event and D-Bus event
(wpas_notify_p2p_provision_discovery call at the end of
wpas_prov_disc_req). This does not sound correct.
diff mbox

Patch

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c6484af..7a2bd4f 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -1670,8 +1670,13 @@  static void wpas_prov_disc_local_display(struct wpa_supplicant *wpa_s,
 					 const u8 *peer, const char *params,
 					 unsigned int generated_pin)
 {
-	wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_SHOW_PIN MACSTR " %08d%s",
-		MAC2STR(peer), generated_pin, params);
+	if(wpa_s->p2p_pin[0] == '\0') {
+		/* If PIN hasn't been generated in the p2p_connect context, set it now. */
+		os_snprintf(wpa_s->p2p_pin, sizeof(wpa_s->p2p_pin), " %08d", generated_pin);
+	}
+
+	wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_SHOW_PIN MACSTR " %s%s",
+			MAC2STR(peer), wpa_s->p2p_pin, params);
 }