P2P: Extend use of group formation timeout until end of 4-way handshake

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>
This commit is contained in:
Jouni Malinen 2012-04-13 17:01:15 +03:00 committed by Jouni Malinen
parent 205e6474a1
commit 361cdf3400

View file

@ -47,6 +47,14 @@
#define P2P_MAX_CLIENT_IDLE 10 #define P2P_MAX_CLIENT_IDLE 10
#endif /* P2P_MAX_CLIENT_IDLE */ #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 void wpas_p2p_long_listen_timeout(void *eloop_ctx, void *timeout_ctx);
static struct wpa_supplicant * 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, eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->parent,
NULL); 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) if (wpa_s->global->p2p)
p2p_wps_success_cb(wpa_s->global->p2p, peer_addr); p2p_wps_success_cb(wpa_s->global->p2p, peer_addr);
else if (wpa_s->drv_flags & WPA_DRIVER_FLAGS_P2P_MGMT) 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 persistent;
int freq; int freq;
eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s->parent,
NULL);
if (!wpa_s->show_group_started || !ssid) if (!wpa_s->show_group_started || !ssid)
return; return;
@ -4129,6 +4151,19 @@ static void wpas_p2p_set_group_idle_timeout(struct wpa_supplicant *wpa_s)
return; 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", wpa_printf(MSG_DEBUG, "P2P: Set P2P group idle timeout to %u seconds",
timeout); timeout);
eloop_register_timeout(timeout, 0, wpas_p2p_group_idle_timeout, eloop_register_timeout(timeout, 0, wpas_p2p_group_idle_timeout,