From 134ad50b0e4c2db4e2880c6e76810fb66bfc7a08 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 15 May 2020 14:20:26 +0300 Subject: [PATCH] dpp-nfc: Clean up debug prints when handover select is received If the local device becomes the handover selector, make the debug log entries about client functionality not receiving the response clearer since that is not really an error case. Signed-off-by: Jouni Malinen --- wpa_supplicant/examples/dpp-nfc.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/wpa_supplicant/examples/dpp-nfc.py b/wpa_supplicant/examples/dpp-nfc.py index 1dbf47ad7..abda8216c 100755 --- a/wpa_supplicant/examples/dpp-nfc.py +++ b/wpa_supplicant/examples/dpp-nfc.py @@ -37,6 +37,7 @@ success_file = None my_crn_ready = False my_crn = None peer_crn = None +hs_sent = False mutex = threading.Lock() def summary(txt): @@ -257,7 +258,7 @@ def dpp_handover_client(llc): summary("Sending handover request") - global my_crn, my_crn_ready + global my_crn, my_crn_ready, hs_sent my_crn_ready = True if not client.send_records(message): @@ -269,9 +270,20 @@ def dpp_handover_client(llc): my_crn, = struct.unpack('>H', crn) summary("Receiving handover response") - message = client.recv_records(timeout=3.0) + try: + message = client.recv_records(timeout=3.0) + except Exception as e: + # This is fine if we are the handover selector + if hs_sent: + summary("Client receive failed as expected since I'm the handover server: %s" % str(e)) + else: + summary("Client receive failed: %s" % str(e)) + message = None if message is None: - summary("No response received") + if hs_sent: + summary("No response received as expected since I'm the handover server") + else: + summary("No response received") client.close() return summary("Received message: " + str(message)) @@ -461,6 +473,7 @@ class HandoverServer(nfc.handover.HandoverServer): cmd += " role=enrollee" elif configurator_only: cmd += " role=configurator" + summary(cmd) res = wpas.request(cmd) if "OK" not in res: summary("Failed to start DPP listen") @@ -477,6 +490,8 @@ class HandoverServer(nfc.handover.HandoverServer): self.success = True else: self.try_own = True + global hs_sent + hs_sent = True return sel def clear_raw_mode(): @@ -660,11 +675,12 @@ def llcp_startup(llc): def llcp_connected(llc): summary("P2P LLCP connected") - global wait_connection, my_crn, peer_crn, my_crn_ready + global wait_connection, my_crn, peer_crn, my_crn_ready, hs_sent wait_connection = False my_crn_ready = False my_crn = None peer_crn = None + hs_sent = False global srv srv.start() if init_on_touch or not no_input: