[PATCH 4/6] P2P: Add p2p group formation tiemout after p2p invitation result

Sane, Jayant jayant.sane
Thu Jun 9 09:40:58 PDT 2011


Register timeout after a successful p2p invitation result
cancel timeout when p2p client is connected.
Timeout expires if STA is not authorized ( authorized = 0 in sta_authorized_cb)
Timeout value is 15 seconds as for the GO negociation timeout.

Signed-off-by: Jean-Michel.Bachot <jean-michelx.bachot at intel.com>
Signed-off-by: Jayant Sane <jayant.sane at intel.com>
---
Note: This patch set applies on top of earlier submitted "DBus-add-support-for-P2P" series 
of patches

 wpa_supplicant/ap.c               |    4 ++++
 wpa_supplicant/p2p_supplicant.c   |   19 +++++++++++++++++++
 wpa_supplicant/p2p_supplicant.h   |    1 +
 wpa_supplicant/wpa_supplicant_i.h |    7 +++++++
 4 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 95279d3..3dbbfe3 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -248,6 +248,10 @@ static void ap_sta_authorized_cb(void *ctx, const u8 *mac_addr,
 				 int authorized)
 {
 	wpas_notify_sta_authorized(ctx, mac_addr, authorized);
+#ifdef CONFIG_P2P
+	if (authorized)
+		wpas_p2p_cancel_connect_timeout_after_invite(ctx);
+#endif /*CONFIG_P2P*/
 }
 
 
diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c
index 0626684..e5534f4 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/wpa_supplicant/p2p_supplicant.c
@@ -1102,6 +1102,15 @@ static void wpas_p2p_group_formation_timeout(void *eloop_ctx,
 	wpas_group_formation_completed(wpa_s, 0);
 }
 
+void wpas_p2p_cancel_connect_timeout_after_invite(void *ctx)
+{
+	struct wpa_supplicant *wpa_s = ctx;
+	if (wpa_s->connect_timeout_after_invite) {
+		eloop_cancel_timeout(wpas_p2p_group_formation_timeout,
+				     wpa_s->parent, NULL);
+		wpa_s->connect_timeout_after_invite = 0;
+	}
+}
 
 void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
 {
@@ -2156,6 +2165,16 @@ static void wpas_invitation_result(void *ctx, int status, const u8 *bssid)
 
 	wpas_p2p_group_add_persistent(wpa_s, ssid,
 				      ssid->mode == WPAS_MODE_P2P_GO, 0);
+
+	/*
+	 * Allow the same timeout for re-invoking a persistent group than
+	 * normal 15 second group formation timeout.
+	 */
+	wpa_s->connect_timeout_after_invite = 1;
+	eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
+	eloop_register_timeout(15, 0, wpas_p2p_group_formation_timeout, wpa_s,
+				   NULL);
+
 }
 
 
diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h
index 69df475..e6486eb 100644
--- a/wpa_supplicant/p2p_supplicant.h
+++ b/wpa_supplicant/p2p_supplicant.h
@@ -124,5 +124,6 @@ void wpas_p2p_update_best_channels(struct wpa_supplicant *wpa_s,
 				   int freq_24, int freq_5, int freq_overall);
 int wpas_p2p_unauthorize(struct wpa_supplicant *wpa_s, const char *addr);
 int wpas_p2p_disconnect(struct wpa_supplicant *wpa_s);
+void wpas_p2p_cancel_connect_timeout_after_invite(void *ctx);
 
 #endif /* P2P_SUPPLICANT_H */
diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h
index 281c5f6..1dc2594 100644
--- a/wpa_supplicant/wpa_supplicant_i.h
+++ b/wpa_supplicant/wpa_supplicant_i.h
@@ -543,6 +543,13 @@ struct wpa_supplicant {
 		P2P_GROUP_REMOVAL_IDLE_TIMEOUT,
 		P2P_GROUP_REMOVAL_UNAVAILABLE
 	} removal_reason;
+
+	/*
+	 * Set connect_timeout_after_invite after invitation result has been
+	 * received. Allows to cancel timeout when p2p client (STA) connection
+	 * has been done successfully
+	 */
+	int connect_timeout_after_invite;
 #endif /* CONFIG_P2P */
 
 	struct wpa_ssid *bgscan_ssid;
-- 
1.7.1





More information about the Hostap mailing list