DPP: Extend NFC bootstrapping script for more control by caller
Add more parameters to dpp-nfc.py to allow it to be used with more detailed control by the caller. This allows Enrollee/Configurator roles to be selected and Configurator parameters to be specified on the command line. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
890ae336c0
commit
0086c14528
1 changed files with 40 additions and 8 deletions
|
@ -255,18 +255,28 @@ def dpp_handover_client(llc):
|
||||||
success_report("DPP handover reported successfully (initiator)")
|
success_report("DPP handover reported successfully (initiator)")
|
||||||
print("peer_id=" + res)
|
print("peer_id=" + res)
|
||||||
peer_id = int(res)
|
peer_id = int(res)
|
||||||
# TODO: Single Configurator instance
|
|
||||||
wpas = wpas_connect()
|
wpas = wpas_connect()
|
||||||
if wpas is None:
|
if wpas is None:
|
||||||
break
|
break
|
||||||
res = wpas.request("DPP_CONFIGURATOR_ADD")
|
|
||||||
if "FAIL" in res:
|
global enrollee_only
|
||||||
print("Failed to initiate Configurator")
|
global config_params
|
||||||
break
|
if enrollee_only:
|
||||||
conf_id = int(res)
|
extra = " role=enrollee"
|
||||||
|
elif config_params:
|
||||||
|
extra = " role=configurator " + config_params
|
||||||
|
else:
|
||||||
|
# TODO: Single Configurator instance
|
||||||
|
res = wpas.request("DPP_CONFIGURATOR_ADD")
|
||||||
|
if "FAIL" in res:
|
||||||
|
print("Failed to initiate Configurator")
|
||||||
|
break
|
||||||
|
conf_id = int(res)
|
||||||
|
extra = " conf=sta-dpp configurator=%d" % conf_id
|
||||||
global own_id
|
global own_id
|
||||||
print("Initiate DPP authentication")
|
print("Initiate DPP authentication")
|
||||||
cmd = "DPP_AUTH_INIT peer=%d own=%d conf=sta-dpp configurator=%d" % (peer_id, own_id, conf_id)
|
cmd = "DPP_AUTH_INIT peer=%d own=%d" % (peer_id, own_id)
|
||||||
|
cmd += extra
|
||||||
res = wpas.request(cmd)
|
res = wpas.request(cmd)
|
||||||
if "FAIL" in res:
|
if "FAIL" in res:
|
||||||
print("Failed to initiate DPP authentication")
|
print("Failed to initiate DPP authentication")
|
||||||
|
@ -356,7 +366,14 @@ class HandoverServer(nfc.handover.HandoverServer):
|
||||||
if freq is None:
|
if freq is None:
|
||||||
print("No channel negotiated over NFC - use channel 1")
|
print("No channel negotiated over NFC - use channel 1")
|
||||||
freq = 2412
|
freq = 2412
|
||||||
res = wpas.request("DPP_LISTEN %d" % freq)
|
cmd = "DPP_LISTEN %d" % freq
|
||||||
|
global enrollee_only
|
||||||
|
global configurator_only
|
||||||
|
if enrollee_only:
|
||||||
|
cmd += " role=enrollee"
|
||||||
|
elif configurator_only:
|
||||||
|
cmd += " role=configurator"
|
||||||
|
res = wpas.request(cmd)
|
||||||
if "OK" not in res:
|
if "OK" not in res:
|
||||||
print("Failed to start DPP listen")
|
print("Failed to start DPP listen")
|
||||||
break
|
break
|
||||||
|
@ -592,6 +609,12 @@ def main():
|
||||||
help='tag read only (do not allow connection handover)')
|
help='tag read only (do not allow connection handover)')
|
||||||
parser.add_argument('--handover-only', action='store_true',
|
parser.add_argument('--handover-only', action='store_true',
|
||||||
help='connection handover only (do not allow tag read)')
|
help='connection handover only (do not allow tag read)')
|
||||||
|
parser.add_argument('--enrollee', action='store_true',
|
||||||
|
help='run as Enrollee-only')
|
||||||
|
parser.add_argument('--configurator', action='store_true',
|
||||||
|
help='run as Configurator-only')
|
||||||
|
parser.add_argument('--config-params', default='',
|
||||||
|
help='configurator parameters')
|
||||||
parser.add_argument('--summary',
|
parser.add_argument('--summary',
|
||||||
help='summary file for writing status updates')
|
help='summary file for writing status updates')
|
||||||
parser.add_argument('--success',
|
parser.add_argument('--success',
|
||||||
|
@ -618,6 +641,15 @@ def main():
|
||||||
global init_on_touch
|
global init_on_touch
|
||||||
init_on_touch = args.init_on_touch
|
init_on_touch = args.init_on_touch
|
||||||
|
|
||||||
|
global enrollee_only
|
||||||
|
enrollee_only = args.enrollee
|
||||||
|
|
||||||
|
global configurator_only
|
||||||
|
configurator_only = args.configurator
|
||||||
|
|
||||||
|
global config_params
|
||||||
|
config_params = args.config_params
|
||||||
|
|
||||||
if args.ifname:
|
if args.ifname:
|
||||||
global ifname
|
global ifname
|
||||||
ifname = args.ifname
|
ifname = args.ifname
|
||||||
|
|
Loading…
Add table
Reference in a new issue