]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Postpone concurrent scans when waiting for first client as GO
authorJouni Malinen <jouni@qca.qualcomm.com>
Tue, 27 Aug 2013 09:23:10 +0000 (12:23 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 27 Aug 2013 09:23:10 +0000 (12:23 +0300)
Previously, concurrent station mode scans were postponed during an
ongoing P2P group formation up to the point of completed WPS
provisioning step. This would allow a scan to be started before the P2P
client has completed association for the data connection if a scan
request were timed to hit the window between the provisioning step and
the following association. Avoid this by extending P2P-in-progress state
to continue until the first data connection has been completed as part
of group formation. Use a ten second timeout for this to avoid leaving
scans disabled indefinitely if the client fails to connect completely.

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

wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index e280cf73cdf6fe3d18ae254e7ed18584d3479b32..aad12bb3f52b76d72e0ee2a5c23de87b5681da57 100644 (file)
 #define P2P_MAX_INITIAL_CONN_WAIT 10
 #endif /* P2P_MAX_INITIAL_CONN_WAIT */
 
+#ifndef P2P_MAX_INITIAL_CONN_WAIT_GO
+/*
+ * How many seconds to wait for initial 4-way handshake to get completed after
+ * WPS provisioning step on the GO. This controls the extra time the P2P
+ * operation is considered to be in progress (e.g., to delay other scans) after
+ * WPS provisioning has been completed on the GO during group formation.
+ */
+#define P2P_MAX_INITIAL_CONN_WAIT_GO 10
+#endif /* P2P_MAX_INITIAL_CONN_WAIT_GO */
+
 #ifndef P2P_CONCURRENT_SEARCH_DELAY
 #define P2P_CONCURRENT_SEARCH_DELAY 500
 #endif /* P2P_CONCURRENT_SEARCH_DELAY */
@@ -767,8 +777,10 @@ static void wpas_group_formation_completed(struct wpa_supplicant *wpa_s,
                                                             ssid, go_dev_addr);
        if (network_id < 0 && ssid)
                network_id = ssid->id;
-       if (!client)
+       if (!client) {
                wpas_notify_p2p_group_started(wpa_s, ssid, network_id, 0);
+               os_get_time(&wpa_s->global->p2p_go_wait_client);
+       }
 }
 
 
@@ -5769,6 +5781,19 @@ int wpas_p2p_in_progress(struct wpa_supplicant *wpa_s)
                }
        }
 
+       if (!ret && wpa_s->global->p2p_go_wait_client.sec) {
+               struct os_time now;
+               os_get_time(&now);
+               if (now.sec > wpa_s->global->p2p_go_wait_client.sec +
+                   P2P_MAX_INITIAL_CONN_WAIT_GO) {
+                       /* Wait for the first client has expired */
+                       wpa_s->global->p2p_go_wait_client.sec = 0;
+               } else {
+                       wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Waiting for initial client connection during group formation");
+                       ret = 1;
+               }
+       }
+
        return ret;
 }
 
@@ -5828,6 +5853,7 @@ struct wpa_ssid * wpas_p2p_get_persistent(struct wpa_supplicant *wpa_s,
 void wpas_p2p_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
                                       const u8 *addr)
 {
+       wpa_s->global->p2p_go_wait_client.sec = 0;
        if (addr == NULL)
                return;
        wpas_p2p_add_persistent_group_client(wpa_s, addr);
index 0858bbc0ef3a8682288b8c9aa0873f534fedfd57..604997e57ee19de1b71fc2aead229acd6a08e053 100644 (file)
@@ -252,6 +252,7 @@ struct wpa_global {
        struct wpa_supplicant *p2p_group_formation;
        struct wpa_supplicant *p2p_invite_group;
        u8 p2p_dev_addr[ETH_ALEN];
+       struct os_time p2p_go_wait_client;
        struct dl_list p2p_srv_bonjour; /* struct p2p_srv_bonjour */
        struct dl_list p2p_srv_upnp; /* struct p2p_srv_upnp */
        int p2p_disabled;