tests: P2P invitation resend on no-common-channels

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2014-11-28 17:47:09 +02:00 committed by Jouni Malinen
parent cff6eed75b
commit d9fee38658

View file

@ -952,6 +952,68 @@ def test_p2p_msg_invitation_resp(dev, apdev):
if ev is None:
raise Exception("Group was not started")
def test_p2p_msg_invitation_resend(dev, apdev):
"""P2P protocol tests for invitation resending on no-common-channels"""
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("Forced channel in invitation")
invite(dev[0], dev[1], extra="freq=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'])))
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
if ev is None:
raise Exception("Timeout on invitation result");
if "status=7" not in ev:
raise Exception("Unexpected invitation result: " + ev)
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)
if "FAIL" in dev[1].request("SET ext_mgmt_frame_handling 0"):
raise Exception("Failed to disable external management frame handling")
mgmt_tx(dev[1], "MGMT_TX {} {} freq={} wait_time=200 no_cck=1 action={}".format(addr0, addr0, rx_msg['freq'], binascii.hexlify(msg['payload'])))
ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=15)
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=15);
if ev is None:
raise Exception("Group was not started on dev0")
ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15);
if ev is None:
raise Exception("Group was not started on dev1")
def test_p2p_msg_pd_req(dev, apdev):
"""P2P protocol tests for provision discovery request processing"""
dst, src, hapd, channel = start_p2p(dev, apdev)