From: Jouni Malinen Date: Thu, 13 Aug 2020 21:11:44 +0000 (+0300) Subject: dpp-nfc: Fix handover client wait for receiving handover select X-Git-Tag: hostap_2_10~1003 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1733e356e42166bbe2481ac4c41be335ac5fe7c1;p=thirdparty%2Fhostap.git dpp-nfc: Fix handover client wait for receiving handover select This was supposed to wait for up to 3.0 seconds for the handover select, but the incorrect loop terminated ended up limiting this to a single iteration of 0.1 second wait. This was too fast for some cases like the AP mode operation where it may take significant time to enable the radio for listening to DPP authentication messages. Fix the loop to allow that full three second wait for the response to be used. In addition, report the amount of time it takes to receive the response. Signed-off-by: Jouni Malinen --- diff --git a/wpa_supplicant/examples/dpp-nfc.py b/wpa_supplicant/examples/dpp-nfc.py index e0d11f412..83241330d 100755 --- a/wpa_supplicant/examples/dpp-nfc.py +++ b/wpa_supplicant/examples/dpp-nfc.py @@ -278,8 +278,15 @@ class HandoverClient(nfc.handover.HandoverClient): def recv_octets(self, timeout=None): start = time.time() msg = bytearray() - poll_timeout = 0.1 if timeout is None or timeout > 0.1 else timeout - while self.socket.poll('recv', poll_timeout): + while True: + poll_timeout = 0.1 if timeout is None or timeout > 0.1 else timeout + if self.socket.poll('recv', poll_timeout) is None: + if timeout: + timeout -= time.time() - start + if timeout <= 0: + return None + start = time.time() + continue try: r = self.socket.recv() if r is None: @@ -372,7 +379,10 @@ def run_dpp_handover_client(handover, alt=False): summary("Receiving handover response") try: + start = time.time() message = client.recv_records(timeout=3.0) + end = time.time() + summary("Received {} record(s) in {} seconds".format(len(message) if message is not None else -1, end - start)) except Exception as e: # This is fine if we are the handover selector if handover.hs_sent: