[PATCH] Add an option to suppress provision discovery during P2P Join

Jithu Jance jithu at broadcom.com
Mon Nov 21 05:54:27 EST 2011


This patch adds an option to suppress provision discovery req during P2P Join. This is required in scenarios where a P2P client is connecting to a P2P GO that supports only PIN DISPLAY option. 
The client side has to use the PIN displayed by the GO and we can't issue a p2p_connect on the client side till the PIN is known(since pin has to be entered along with p2p_connect command).

so in this case, we have to issue an explicit Provision Discovery before issuing connect command so that the GO can display its PIN and we can use the displayed pin in the subsequent p2p_connect command. 
Since we have already done the PD, the "p2p_connect join" command shouldn't initiate another provision discovery.

Please see whether the patch is okay.

Also, Please share your thoughts on adding an extra "no_pd" argument to p2p_connect command. 


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

---
 wpa_supplicant/config.c                     |    1 +
 wpa_supplicant/config.h                     |    5 +++++
 wpa_supplicant/config_file.c                |    3 +++
 wpa_supplicant/config_winreg.c              |    4 ++++
 wpa_supplicant/dbus/dbus_new_handlers_p2p.c |    8 ++++++++
 wpa_supplicant/p2p_supplicant.c             |   12 ++++++++++++
 6 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index b446a3f..9a4f452 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -2480,6 +2480,7 @@ static const struct global_parse_data global_fields[] = {
 	{ INT_RANGE(persistent_reconnect, 0, 1), 0 },
 	{ INT_RANGE(p2p_intra_bss, 0, 1), CFG_CHANGED_P2P_INTRA_BSS },
 	{ INT(p2p_group_idle), 0 },
+	{ INT(p2p_suppress_pd), 0 },
 #endif /* CONFIG_P2P */
 	{ FUNC(country), CFG_CHANGED_COUNTRY },
 	{ INT(bss_max_count), 0 },
diff --git a/wpa_supplicant/config.h b/wpa_supplicant/config.h
index ae496ff..5080a7e 100644
--- a/wpa_supplicant/config.h
+++ b/wpa_supplicant/config.h
@@ -382,6 +382,11 @@ struct wpa_config {
 	unsigned int p2p_group_idle;
 
 	/**
+	 * p2p_suppress_pd - Suppress Provision Discovery during P2P Join.
+	 */
+	unsigned int p2p_suppress_pd;
+
+	/**
 	 * bss_max_count - Maximum number of BSS entries to keep in memory
 	 */
 	unsigned int bss_max_count;
diff --git a/wpa_supplicant/config_file.c b/wpa_supplicant/config_file.c
index ee8b451..6fda669 100644
--- a/wpa_supplicant/config_file.c
+++ b/wpa_supplicant/config_file.c
@@ -683,6 +683,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
 		fprintf(f, "p2p_intra_bss=%u\n", config->p2p_intra_bss);
 	if (config->p2p_group_idle)
 		fprintf(f, "p2p_group_idle=%u\n", config->p2p_group_idle);
+	if (config->p2p_suppress_pd)
+		fprintf(f, "p2p_suppress_pd=%u\n",
+			config->p2p_suppress_pd);
 #endif /* CONFIG_P2P */
 	if (config->country[0] && config->country[1]) {
 		fprintf(f, "country=%c%c\n",
diff --git a/wpa_supplicant/config_winreg.c b/wpa_supplicant/config_winreg.c
index ea3a2ac..104d6b7 100644
--- a/wpa_supplicant/config_winreg.c
+++ b/wpa_supplicant/config_winreg.c
@@ -266,6 +266,8 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
 		hk, TEXT("p2p_ssid_postfix"));
 	wpa_config_read_reg_dword(hk, TEXT("p2p_group_idle"),
 				  (int *) &config->p2p_group_idle);
+	wpa_config_read_reg_dword(hk, TEXT("p2p_suppress_pd"),
+				  (int *) &config->p2p_suppress_pd);
 #endif /* CONFIG_P2P */
 
 	wpa_config_read_reg_dword(hk, TEXT("bss_max_count"),
@@ -612,6 +614,8 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
 				    config->p2p_ssid_postfix);
 	wpa_config_write_reg_dword(hk, TEXT("p2p_group_idle"),
 				   config->p2p_group_idle, 0);
+	wpa_config_write_reg_dword(hk, TEXT("p2p_suppress_pd"),
+				   config->p2p_suppress_pd, 0);
 #endif /* CONFIG_P2P */
 
 	wpa_config_write_reg_dword(hk, TEXT("bss_max_count"),
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index f2c5a18..cb336a3 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -822,6 +822,11 @@ dbus_bool_t wpas_dbus_getter_p2p_device_properties(DBusMessageIter *iter,
 					 wpa_s->conf->p2p_group_idle))
 		goto err_no_mem;
 
+	/* Enable Provision Discovery for P2P Join */
+	if (!wpa_dbus_dict_append_uint32(&dict_iter, "SuppressPd",
+					 wpa_s->conf->p2p_suppress_pd))
+		goto err_no_mem;
+
 	/* Dissasociation low ack */
 	if (!wpa_dbus_dict_append_uint32(&dict_iter, "disassoc_low_ack",
 					 wpa_s->conf->disassoc_low_ack))
@@ -973,6 +978,9 @@ dbus_bool_t wpas_dbus_setter_p2p_device_properties(DBusMessageIter *iter,
 		} else if ((os_strcmp(entry.key, "GroupIdle") == 0) &&
 			   (entry.type == DBUS_TYPE_UINT32))
 			wpa_s->conf->p2p_group_idle = entry.uint32_value;
+		} else if ((os_strcmp(entry.key, "SuppressPd") == 0) &&
+			   (entry.type == DBUS_TYPE_UINT32))
+			wpa_s->conf->p2p_suppress_pd = entry.uint32_value;
 		else if (os_strcmp(entry.key, "disassoc_low_ack") == 0 &&
 			 entry.type == DBUS_TYPE_UINT32)
 			wpa_s->conf->disassoc_low_ack = entry.uint32_value;
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index c6484af..2382953 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -763,6 +763,7 @@ static void wpas_p2p_clone_config(struct wpa_supplicant *dst,
 	d->num_sec_device_types = s->num_sec_device_types;
 
 	d->p2p_group_idle = s->p2p_group_idle;
+	d->p2p_suppress_pd = s->p2p_suppress_pd;
 	d->p2p_intra_bss = s->p2p_intra_bss;
 	d->persistent_reconnect = s->persistent_reconnect;
 }
@@ -2503,6 +2504,17 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
 			break;
 		}
 
+		if (wpa_s->conf->p2p_suppress_pd) {
+			/* If Provision Discovery is suppressed,
+			 * Start join operation immediately. The Provision
+			 * discovery in this case would have been explicitly
+			 * initiated before the p2p_connect command.
+			 */
+			wpa_printf(MSG_DEBUG, "P2P: Provision "
+				"Discovery Request from Join context suppressed");
+			goto start;
+		}
+
 		if (p2p_prov_disc_req(wpa_s->global->p2p,
 				      wpa_s->pending_join_dev_addr, method, 1)
 		    < 0) {
-- 
1.7.4.1





-- Jithu Jance


More information about the HostAP mailing list