dpp-nfc: Fix connection handover renegotiation
The use of the alternative channel list did not work properly for the case were both ends were trying to initiate the negotiated connection handover. Fix this by always starting a new connection handover client thread for sending the alternative proposal and ignoring peer messages (likely something from the first attempt) during this modified attempt. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
d0819a11cc
commit
c9dc075fcd
1 changed files with 16 additions and 11 deletions
|
@ -241,7 +241,7 @@ def dpp_handover_client(llc, alt=False):
|
||||||
summary("NFC Handover Request message for DPP: " + str(message))
|
summary("NFC Handover Request message for DPP: " + str(message))
|
||||||
|
|
||||||
global peer_crn
|
global peer_crn
|
||||||
if peer_crn is not None:
|
if peer_crn is not None and not alt:
|
||||||
summary("NFC handover request from peer was already received - do not send own")
|
summary("NFC handover request from peer was already received - do not send own")
|
||||||
return
|
return
|
||||||
client = nfc.handover.HandoverClient(llc)
|
client = nfc.handover.HandoverClient(llc)
|
||||||
|
@ -258,7 +258,7 @@ def dpp_handover_client(llc, alt=False):
|
||||||
client.close()
|
client.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
if peer_crn is not None:
|
if peer_crn is not None and not alt:
|
||||||
summary("NFC handover request from peer was already received - do not send own")
|
summary("NFC handover request from peer was already received - do not send own")
|
||||||
client.close()
|
client.close()
|
||||||
return
|
return
|
||||||
|
@ -507,18 +507,17 @@ class HandoverServer(nfc.handover.HandoverServer):
|
||||||
sel = [hs, carrier]
|
sel = [hs, carrier]
|
||||||
break
|
break
|
||||||
|
|
||||||
|
global hs_sent
|
||||||
summary("Sending handover select: " + str(sel))
|
summary("Sending handover select: " + str(sel))
|
||||||
if found:
|
if found:
|
||||||
summary("Handover completed successfully")
|
summary("Handover completed successfully")
|
||||||
self.success = True
|
self.success = True
|
||||||
|
hs_sent = True
|
||||||
else:
|
else:
|
||||||
summary("Try to initiate with alternative parameters")
|
summary("Try to initiate with alternative parameters")
|
||||||
self.try_own = True
|
self.try_own = True
|
||||||
if not init_on_touch and no_input:
|
hs_sent = False
|
||||||
# Need to start client thread now
|
threading.Thread(target=llcp_worker, args=(self.llc, True)).start()
|
||||||
threading.Thread(target=llcp_worker, args=(self.llc,)).start()
|
|
||||||
global hs_sent
|
|
||||||
hs_sent = True
|
|
||||||
return sel
|
return sel
|
||||||
|
|
||||||
def clear_raw_mode():
|
def clear_raw_mode():
|
||||||
|
@ -651,12 +650,18 @@ def rdwr_connected(tag):
|
||||||
|
|
||||||
return not no_wait
|
return not no_wait
|
||||||
|
|
||||||
def llcp_worker(llc):
|
def llcp_worker(llc, try_alt):
|
||||||
|
print("Start of llcp_worker()")
|
||||||
|
if try_alt:
|
||||||
|
summary("Starting handover client (try_alt)")
|
||||||
|
dpp_handover_client(llc, alt=True)
|
||||||
|
summary("Exiting llcp_worker thread (try_alt)")
|
||||||
|
return
|
||||||
global init_on_touch
|
global init_on_touch
|
||||||
if init_on_touch:
|
if init_on_touch:
|
||||||
summary("Starting handover client")
|
summary("Starting handover client (init_on_touch)")
|
||||||
dpp_handover_client(llc)
|
dpp_handover_client(llc)
|
||||||
summary("Exiting llcp_worker thread (init_in_touch)")
|
summary("Exiting llcp_worker thread (init_on_touch)")
|
||||||
return
|
return
|
||||||
|
|
||||||
global no_input
|
global no_input
|
||||||
|
@ -716,7 +721,7 @@ def llcp_connected(llc):
|
||||||
global srv
|
global srv
|
||||||
srv.start()
|
srv.start()
|
||||||
if init_on_touch or not no_input:
|
if init_on_touch or not no_input:
|
||||||
threading.Thread(target=llcp_worker, args=(llc,)).start()
|
threading.Thread(target=llcp_worker, args=(llc, False)).start()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def llcp_release(llc):
|
def llcp_release(llc):
|
||||||
|
|
Loading…
Reference in a new issue