1 # P2P invitation test cases
2 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
12 def test_p2p_go_invite(dev):
13 """P2P GO inviting a client to join"""
14 addr0 = dev[0].p2p_dev_addr()
15 addr1 = dev[1].p2p_dev_addr()
17 logger.info("Generate BSS table entry for old group")
18 # this adds more coverage to testing by forcing the GO to be found with an
19 # older entry in the BSS table and with that entry having a different
21 dev[0].p2p_start_go(freq=2422)
25 logger.info("Discover peer")
27 if not dev[0].discover_peer(addr1, social=True):
28 raise Exception("Peer " + addr1 + " not found")
30 logger.info("Start GO on non-social channel")
31 res = dev[0].p2p_start_go(freq=2417)
32 logger.debug("res: " + str(res))
34 logger.info("Invite peer to join the group")
35 dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1)
36 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED"], timeout=10)
38 raise Exception("Timeout on invitation on peer")
39 ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10)
41 raise Exception("Timeout on invitation on GO")
42 if "status=1" not in ev:
43 raise Exception("Unexpected invitation result")
45 logger.info("Join the group")
46 pin = dev[1].wps_read_pin()
47 dev[0].p2p_go_authorize_client(pin)
48 dev[1].p2p_connect_group(addr0, pin, timeout=60)
49 logger.info("Client connected")
50 hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
52 logger.info("Terminate group")
54 dev[1].wait_go_ending_session()
56 def test_p2p_go_invite_auth(dev):
57 """P2P GO inviting a client to join (authorized invitation)"""
58 addr0 = dev[0].p2p_dev_addr()
59 addr1 = dev[1].p2p_dev_addr()
61 logger.info("Generate BSS table entry for old group")
62 # this adds more coverage to testing by forcing the GO to be found with an
63 # older entry in the BSS table and with that entry having a different
65 dev[0].p2p_start_go(freq=2432)
71 logger.info("Discover peer")
73 if not dev[0].discover_peer(addr1, social=True):
74 raise Exception("Peer " + addr1 + " not found")
76 if not dev[1].discover_peer(addr0, social=True):
77 raise Exception("Peer " + addr0 + " not found")
80 logger.info("Authorize invitation")
81 pin = dev[1].wps_read_pin()
82 dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
84 logger.info("Start GO on non-social channel")
85 res = dev[0].p2p_start_go(freq=2427)
86 logger.debug("res: " + str(res))
88 logger.info("Invite peer to join the group")
89 dev[0].p2p_go_authorize_client(pin)
90 dev[0].global_request("P2P_INVITE group=" + dev[0].group_ifname + " peer=" + addr1)
91 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED",
92 "P2P-GROUP-STARTED"], timeout=20)
94 raise Exception("Timeout on invitation on peer")
95 if "P2P-INVITATION-RECEIVED" in ev:
96 raise Exception("Unexpected request to accept pre-authorized invitaton")
99 logger.info("Client connected")
100 hwsim_utils.test_connectivity_p2p(dev[0], dev[1])
102 logger.info("Terminate group")
103 dev[0].remove_group()
104 dev[1].wait_go_ending_session()