]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NFC: Workaround nfcpy message debug exception
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 13 Feb 2014 14:14:04 +0000 (16:14 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 13 Feb 2014 14:37:43 +0000 (16:37 +0200)
The current nfcpy version does not support new WSC connection handover
message format and the handover server fails to process the request due
to a debug print. As a temporary workaround, override
HandoverServer::_process_request() with a version that avoids pretty()
print of the handover messages. This can be removed once nfcpy has been
updated to support the new format.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
hostapd/wps-ap-nfc.py
wpa_supplicant/examples/p2p-nfc.py
wpa_supplicant/examples/wps-nfc.py

index aa75d5bca6711325cabcbce2532148f7cc81492c..2fc301296e882dfe113e085154fa7d6818df5445 100755 (executable)
@@ -113,6 +113,23 @@ class HandoverServer(nfc.handover.HandoverServer):
         self.ho_server_processing = False
         self.success = False
 
+    # override to avoid parser error in request/response.pretty() in nfcpy
+    # due to new WSC handover format
+    def _process_request(self, request):
+        summary("received handover request {}".format(request.type))
+        response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
+        if not request.type == 'urn:nfc:wkt:Hr':
+            summary("not a handover request")
+        else:
+            try:
+                request = nfc.ndef.HandoverRequestMessage(request)
+            except nfc.ndef.DecodeError as e:
+                summary("error decoding 'Hr' message: {}".format(e))
+            else:
+                response = self.process_request(request)
+        summary("send handover response {}".format(response.type))
+        return response
+
     def process_request(self, request):
         summary("HandoverServer - request received")
         try:
index 94edca1dce2799177cc9006b6736c1f0c607aa5c..91eba28908edca9177a87a2925f8d19ac70a21e0 100755 (executable)
@@ -263,6 +263,23 @@ class HandoverServer(nfc.handover.HandoverServer):
         self.ho_server_processing = False
         self.success = False
 
+    # override to avoid parser error in request/response.pretty() in nfcpy
+    # due to new WSC handover format
+    def _process_request(self, request):
+        summary("received handover request {}".format(request.type))
+        response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
+        if not request.type == 'urn:nfc:wkt:Hr':
+            summary("not a handover request")
+        else:
+            try:
+                request = nfc.ndef.HandoverRequestMessage(request)
+            except nfc.ndef.DecodeError as e:
+                summary("error decoding 'Hr' message: {}".format(e))
+            else:
+                response = self.process_request(request)
+        summary("send handover response {}".format(response.type))
+        return response
+
     def process_request(self, request):
         self.ho_server_processing = True
         clear_raw_mode()
index e57eded8fb3fefb875b0e524bc4f8132c5097e99..7459eb9ae5744b6adaa5fbd9724723f299fbf285 100755 (executable)
@@ -142,6 +142,23 @@ class HandoverServer(nfc.handover.HandoverServer):
         self.ho_server_processing = False
         self.success = False
 
+    # override to avoid parser error in request/response.pretty() in nfcpy
+    # due to new WSC handover format
+    def _process_request(self, request):
+        summary("received handover request {}".format(request.type))
+        response = nfc.ndef.Message("\xd1\x02\x01Hs\x12")
+        if not request.type == 'urn:nfc:wkt:Hr':
+            summary("not a handover request")
+        else:
+            try:
+                request = nfc.ndef.HandoverRequestMessage(request)
+            except nfc.ndef.DecodeError as e:
+                summary("error decoding 'Hr' message: {}".format(e))
+            else:
+                response = self.process_request(request)
+        summary("send handover response {}".format(response.type))
+        return response
+
     def process_request(self, request):
         self.ho_server_processing = True
         summary("HandoverServer - request received")