WPS: Reduce client timeout with EAP-WSC to avoid long wait
authorJouni Malinen <jouni.malinen@atheros.com>
Tue, 6 Jul 2010 19:58:15 +0000 (12:58 -0700)
committerJouni Malinen <j@w1.fi>
Sun, 18 Jul 2010 23:09:30 +0000 (16:09 -0700)
This works around issues with EAP-Failure getting lost for some reason.
Instead of waiting up to 60 seconds on a timeout, 30 second timeout is
now used and whenever the provisioning step has been completed (either
successfully or unsuccessfully), this timeout is reduced to 2 seconds.

src/eap_peer/eap_wsc.c

index 9a0354e..8317f72 100644 (file)
@@ -226,6 +226,10 @@ static void * eap_wsc_init(struct eap_sm *sm)
                                      cfg.pin, cfg.pin_len, 0);
        }
 
+       /* Use reduced client timeout for WPS to avoid long wait */
+       if (sm->ClientTimeout > 30)
+               sm->ClientTimeout = 30;
+
        return data;
 }
 
@@ -381,6 +385,7 @@ static struct wpabuf * eap_wsc_process(struct eap_sm *sm, void *priv,
        u16 message_length = 0;
        enum wps_process_res res;
        struct wpabuf tmpbuf;
+       struct wpabuf *r;
 
        pos = eap_hdr_validate(EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC, reqData,
                               &len);
@@ -506,7 +511,13 @@ send_msg:
        }
 
        eap_wsc_state(data, MESG);
-       return eap_wsc_build_msg(data, ret, id);
+       r = eap_wsc_build_msg(data, ret, id);
+       if (data->state == FAIL && ret->methodState == METHOD_DONE) {
+               /* Use reduced client timeout for WPS to avoid long wait */
+               if (sm->ClientTimeout > 2)
+                       sm->ClientTimeout = 2;
+       }
+       return r;
 }