From d9fee38658a256843fe8dc4f3df4248ccaa23e20 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 28 Nov 2014 17:47:09 +0200 Subject: [PATCH] tests: P2P invitation resend on no-common-channels Signed-off-by: Jouni Malinen --- tests/hwsim/test_p2p_messages.py | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/hwsim/test_p2p_messages.py b/tests/hwsim/test_p2p_messages.py index a0a22c9b5..def2d5f58 100644 --- a/tests/hwsim/test_p2p_messages.py +++ b/tests/hwsim/test_p2p_messages.py @@ -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)