]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Extend use of group formation timeout until end of 4-way handshake
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 13 Apr 2012 14:01:15 +0000 (17:01 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 13 Apr 2012 14:01:15 +0000 (17:01 +0300)
Instead of relying on the P2P group idle timeout before the group
connection has been fully established, re-start the group formation
timeout in the end of the WPS provisioning step and clear it at the
successful completion of the initial 4-way handshake. This allows the
P2P group idle timeout to be set to a small value without triggering it
during the initial scan and connection attempt.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/p2p_supplicant.c

index e4f9d9b8517d6448b980c9a39543cc715a1b295e..0b1801eb35b3fd799b7f0652d77d68c380e22105 100644 (file)
 #define P2P_MAX_CLIENT_IDLE 10
 #endif /* P2P_MAX_CLIENT_IDLE */
 
+#ifndef P2P_MAX_INITIAL_CONN_WAIT
+/*
+ * How many seconds to wait for initial 4-way handshake to get completed after
+ * WPS provisioning step.
+ */
+#define P2P_MAX_INITIAL_CONN_WAIT 10
+#endif /* P2P_MAX_INITIAL_CONN_WAIT */
+
 
 static void wpas_p2p_long_listen_timeout(void *eloop_ctx, void *timeout_ctx);
 static struct wpa_supplicant *
@@ -3617,6 +3625,17 @@ void wpas_p2p_wps_success(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
 
        eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->parent,
                             NULL);
+       if (ssid && ssid->mode == WPAS_MODE_INFRA) {
+               /*
+                * Use a separate timeout for initial data connection to
+                * complete to allow the group to be removed automatically if
+                * something goes wrong in this step before the P2P group idle
+                * timeout mechanism is taken into use.
+                */
+               eloop_register_timeout(P2P_MAX_INITIAL_CONN_WAIT, 0,
+                                      wpas_p2p_group_formation_timeout,
+                                      wpa_s, NULL);
+       }
        if (wpa_s->global->p2p)
                p2p_wps_success_cb(wpa_s->global->p2p, peer_addr);
        else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT)
@@ -3997,6 +4016,9 @@ void wpas_p2p_completed(struct wpa_supplicant *wpa_s)
        int persistent;
        int freq;
 
+       eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->parent,
+                            NULL);
+
        if (!wpa_s->show_group_started || !ssid)
                return;
 
@@ -4129,6 +4151,19 @@ static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s)
                return;
        }
 
+       if (wpa_s->show_group_started) {
+               /*
+                * Use the normal group formation timeout between the end of
+                * the provisioning phase and completion of 4-way handshake to
+                * avoid terminating this process too early due to group idle
+                * timeout.
+                */
+               wpa_printf(MSG_DEBUG, "P2P: Do not use P2P group idle timeout "
+                          "while waiting for initial 4-way handshake to "
+                          "complete");
+               return;
+       }
+
        wpa_printf(MSG_DEBUG, "P2P: Set P2P group idle timeout to %u seconds",
                   timeout);
        eloop_register_timeout(timeout, 0, wpas_p2p_group_idle_timeout,