aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/examples
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2013-02-10 16:19:59 (GMT)
committerJouni Malinen <j@w1.fi>2013-02-10 16:19:59 (GMT)
commitbbaaaee17193abdebb862d43f3d7541906005eec (patch)
tree1dd8ef62bd5d8a9f31856ed69de9b7d776f9f0d3 /wpa_supplicant/examples
parent51e985dd8457c4d3ad72a2e044d39d038a047ca8 (diff)
downloadhostap-bbaaaee17193abdebb862d43f3d7541906005eec.zip
hostap-bbaaaee17193abdebb862d43f3d7541906005eec.tar.gz
hostap-bbaaaee17193abdebb862d43f3d7541906005eec.tar.bz2
WPS: Fetch only the carrier record from wpa_supplicant for NFC
Since there could be multiple carrier records, it is cleaner to build only the WPS carrier record instead of full NFC connection handover request within wpa_supplicant. Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/examples')
-rwxr-xr-xwpa_supplicant/examples/wps-nfc.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/wpa_supplicant/examples/wps-nfc.py b/wpa_supplicant/examples/wps-nfc.py
index f6c9e60..a2e8df4 100755
--- a/wpa_supplicant/examples/wps-nfc.py
+++ b/wpa_supplicant/examples/wps-nfc.py
@@ -9,6 +9,8 @@
import os
import sys
import time
+import random
+import StringIO
import nfc
import nfc.ndef
@@ -56,7 +58,7 @@ def wpas_get_handover_req():
wpas = wpas_connect()
if (wpas == None):
return None
- return wpas.request("NFC_GET_HANDOVER_REQ NDEF WPS").rstrip().decode("hex")
+ return wpas.request("NFC_GET_HANDOVER_REQ NDEF WPS-CR").rstrip().decode("hex")
def wpas_put_handover_sel(message):
@@ -71,11 +73,21 @@ def wps_handover_init(peer):
data = wpas_get_handover_req()
if (data == None):
- print "Could not get handover request message from wpa_supplicant"
+ print "Could not get handover request carrier record from wpa_supplicant"
return
- print "Handover request from wpa_supplicant: " + data.encode("hex")
- message = nfc.ndef.Message(data)
- print "Parsed handover request:"
+ print "Handover request carrier record from wpa_supplicant: " + data.encode("hex")
+ record = nfc.ndef.Record()
+ f = StringIO.StringIO(data)
+ record._read(f)
+ record = nfc.ndef.HandoverCarrierRecord(record)
+ print "Parsed handover request carrier record:"
+ print record.pretty()
+
+ message = nfc.ndef.HandoverRequestMessage(version="1.2")
+ message.nonce = random.randint(0, 0xffff)
+ message.add_carrier(record, "active")
+
+ print "Handover request:"
print message.pretty()
nfc.llcp.activate(peer);