]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dpp-nfc: Clean up debug prints when handover select is received
authorJouni Malinen <jouni@codeaurora.org>
Fri, 15 May 2020 11:20:26 +0000 (14:20 +0300)
committerJouni Malinen <j@w1.fi>
Fri, 15 May 2020 11:20:26 +0000 (14:20 +0300)
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 <jouni@codeaurora.org>
wpa_supplicant/examples/dpp-nfc.py

index 1dbf47ad737d4b678e4df3c76e4f655c625a4191..abda8216c367c283b95ad68d97fa1eefaf575d92 100755 (executable)
@@ -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: