P2P: Add peer timeout into group formation 15 second timeout
authorJouni Malinen <jouni.malinen@atheros.com>
Mon, 6 Sep 2010 18:04:01 +0000 (21:04 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 10 Sep 2010 17:30:25 +0000 (10:30 -0700)
This adds some more time for WPS provisioning step in case the peer
takes long time to start group interface operations.

src/p2p/p2p.c
src/p2p/p2p.h
src/p2p/p2p_go_neg.c
src/p2p/p2p_i.h
wpa_supplicant/p2p_supplicant.c

index 5d45811..e4d967f 100644 (file)
@@ -1121,6 +1121,8 @@ void p2p_go_complete(struct p2p_data *p2p, struct p2p_device *peer)
                }
        }
 
+       res.peer_config_timeout = go ? peer->client_timeout : peer->go_timeout;
+
        p2p_clear_timeout(p2p);
        peer->go_neg_req_sent = 0;
        peer->wps_method = WPS_NOT_READY;
index 46a4e29..8d7985b 100644 (file)
@@ -122,6 +122,11 @@ struct p2p_go_neg_results {
         * persistent_group - Whether the group should be made persistent
         */
        int persistent_group;
+
+       /**
+        * peer_config_timeout - Peer configuration timeout (in 10 msec units)
+        */
+       unsigned int peer_config_timeout;
 };
 
 struct p2p_data;
index 1e64047..0a3d0c4 100644 (file)
@@ -567,6 +567,11 @@ void p2p_process_go_neg_req(struct p2p_data *p2p, const u8 *sa,
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG, "P2P: Peer operating "
                        "channel preference: %d MHz", dev->oper_freq);
 
+               if (msg.config_timeout) {
+                       dev->go_timeout = msg.config_timeout[0];
+                       dev->client_timeout = msg.config_timeout[1];
+               }
+
                wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
                        "P2P: GO Negotiation with " MACSTR, MAC2STR(sa));
                if (p2p->state != P2P_IDLE)
@@ -810,6 +815,9 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
                status = P2P_SC_FAIL_INVALID_PARAMS;
                goto fail;
 #endif /* CONFIG_P2P_STRICT */
+       } else {
+               dev->go_timeout = msg.config_timeout[0];
+               dev->client_timeout = msg.config_timeout[1];
        }
 
        if (!msg.operating_channel && !go) {
index 8225d64..6119b60 100644 (file)
@@ -101,6 +101,9 @@ struct p2p_device {
 
        u16 ext_listen_period;
        u16 ext_listen_interval;
+
+       u8 go_timeout;
+       u8 client_timeout;
 };
 
 struct p2p_sd_query {
index b2faf35..c9a38a1 100644 (file)
@@ -985,9 +985,9 @@ void wpas_go_neg_completed(void *ctx, struct p2p_go_neg_results *res)
        eloop_cancel_timeout(wpas_p2p_long_listen_timeout, wpa_s, NULL);
 
        eloop_cancel_timeout(wpas_p2p_group_formation_timeout, wpa_s, NULL);
-       /* TODO: add peer Config Timeout */
-       eloop_register_timeout(15, 0, wpas_p2p_group_formation_timeout, wpa_s,
-                              NULL);
+       eloop_register_timeout(15 + res->peer_config_timeout / 100,
+                              (res->peer_config_timeout % 100) * 10000,
+                              wpas_p2p_group_formation_timeout, wpa_s, NULL);
 }