tests: Invitation Request retry and duplicated response

This verifies that the corner case of a duplicated, retransmitted
Invitation Response frame ends up being dropped instead of being
processed twice for the case of Invitation Request getting resend with
social channel as an operating channel in case of no common channels
found.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2014-12-09 01:56:57 +02:00 committed by Jouni Malinen
parent 36b5c3335a
commit 1ede3d2268

View file

@ -1014,6 +1014,66 @@ def test_p2p_msg_invitation_resend(dev, apdev):
if ev is None: if ev is None:
raise Exception("Group was not started on dev1") raise Exception("Group was not started on dev1")
def test_p2p_msg_invitation_resend_duplicate(dev, apdev):
"""P2P protocol tests for invitation resending on no-common-channels and duplicated response"""
form(dev[0], dev[1])
dev[0].dump_monitor()
dev[1].dump_monitor()
addr0 = dev[0].p2p_dev_addr()
addr1 = dev[1].p2p_dev_addr()
if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 1"):
raise Exception("Failed to enable external management frame handling")
logger.info("Any channel allowed, only preference provided in invitation");
invite(dev[0], dev[1], extra="pref=2422")
rx_msg = dev[1].mgmt_rx()
if rx_msg is None:
raise Exception("MGMT-RX timeout")
p2p = parse_p2p_public_action(rx_msg['payload'])
if p2p is None:
raise Exception("Not a P2P Public Action frame " + str(dialog_token))
if p2p['subtype'] != P2P_INVITATION_REQ:
raise Exception("Unexpected subtype %d" % p2p['subtype'])
msg = p2p_hdr(addr0, addr1, type=P2P_INVITATION_RESP,
dialog_token=p2p['dialog_token'])
attrs = p2p_attr_status(status=P2P_SC_FAIL_NO_COMMON_CHANNELS)
msg['payload'] += ie_p2p(attrs)
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
rx_msg = dev[1].mgmt_rx()
if rx_msg is None:
raise Exception("MGMT-RX timeout")
p2p = parse_p2p_public_action(rx_msg['payload'])
if p2p is None:
raise Exception("Not a P2P Public Action frame " + str(dialog_token))
if p2p['subtype'] != P2P_INVITATION_REQ:
raise Exception("Unexpected subtype %d" % p2p['subtype'])
logger.info("Retransmit duplicate of previous response")
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
logger.info("Transmit real response")
msg = p2p_hdr(addr0, addr1, type=P2P_INVITATION_RESP,
dialog_token=p2p['dialog_token'])
attrs = p2p_attr_status(status=P2P_SC_SUCCESS)
attrs += p2p_attr_channel_list()
msg['payload'] += ie_p2p(attrs)
if "FAIL" in dev[1].request("MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload']))):
raise Exception("Failed to transmit real response")
dev[1].request("SET ext_mgmt_frame_handling 0")
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
if ev is None:
raise Exception("Timeout on invitation result");
if "status=0" not in ev:
raise Exception("Unexpected invitation result: " + ev)
ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
if ev is None:
raise Exception("Group formation timed out")
dev[0].group_form_result(ev)
dev[0].remove_group()
def test_p2p_msg_pd_req(dev, apdev): def test_p2p_msg_pd_req(dev, apdev):
"""P2P protocol tests for provision discovery request processing""" """P2P protocol tests for provision discovery request processing"""
dst, src, hapd, channel = start_p2p(dev, apdev) dst, src, hapd, channel = start_p2p(dev, apdev)