[PATCH] P2P: Fix inconsistency in displaying wps pin

Jithu Jance jithu at broadcom.com
Fri Dec 9 06:28:35 EST 2011


When "p2p_connect <devaddr> pin display join" command is issued, the pin generated in the p2p_connect context and the SHOW-PIN event are 
different. The PIN generated in the p2p_connect context is the one in use. The provision discovery response pin generation is useful when explicit
provision discovery is done and then the generated PIN is entered via the subsequent p2p_connect command. The attached patch doesn't generate PIN,
if the pin is already generated in the p2p_connect context. Kindly see whether the patch is okay.


> p2p_connect 02:90:4c:12:34:56 pin display join
78292024 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< PIN Generated in the connect context
<3>P2P-PROV-DISC-SHOW-PIN 02:90:4c:12:34:56 23612945 <<<<<<<< Show Pin event.
<3>CTRL-EVENT-SCAN-RESULTS 
<3>WPS-AP-AVAILABLE 
<3>CTRL-EVENT-SCAN-RESULTS 

In case the below copy is whitespace damaged, please use the attached patch file.


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

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

diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 4ce0432..43eff2f 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -1727,7 +1727,12 @@ void wpas_prov_disc_req(void *ctx, const u8 *peer, u16 config_methods,
 	params[sizeof(params) - 1] = '\0';
 
 	if (config_methods & WPS_CONFIG_DISPLAY) {
-		generated_pin = wps_generate_pin();
+		/* If p2p_pin is already populated, use it*/
+		if(wpa_s->p2p_pin[0] == '\0') {
+			generated_pin = wps_generate_pin();
+		} else {
+			generated_pin = atoi(wpa_s->p2p_pin);
+		}
 		wpas_prov_disc_local_display(wpa_s, peer, params,
 					     generated_pin);
 	} else if (config_methods & WPS_CONFIG_KEYPAD)
@@ -1750,7 +1755,12 @@ void wpas_prov_disc_resp(void *ctx, const u8 *peer, u16 config_methods)
 	if (config_methods & WPS_CONFIG_DISPLAY)
 		wpas_prov_disc_local_keypad(wpa_s, peer, "");
 	else if (config_methods & WPS_CONFIG_KEYPAD) {
-		generated_pin = wps_generate_pin();
+		/* If p2p_pin is already populated, use it*/
+		if(wpa_s->p2p_pin[0] == '\0') {
+			generated_pin = wps_generate_pin();
+		} else {
+			generated_pin = atoi(wpa_s->p2p_pin);
+		}
 		wpas_prov_disc_local_display(wpa_s, peer, "", generated_pin);
 	} else if (config_methods & WPS_CONFIG_PUSHBUTTON)
 		wpa_msg(wpa_s, MSG_INFO, P2P_EVENT_PROV_DISC_PBC_RESP MACSTR,
-- 
1.7.4.1


- Jithu Jance
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fix_display_pin.patch
Url: http://lists.shmoo.com/pipermail/hostap/attachments/20111209/8654b3ff/attachment.txt 


More information about the HostAP mailing list