]>
Commit | Line | Data |
---|---|---|
ef2bd5a3 JM |
1 | # P2P invitation test cases |
2 | # Copyright (c) 2013, Jouni Malinen <j@w1.fi> | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
7 | import logging | |
c9aa4308 | 8 | logger = logging.getLogger() |
ef2bd5a3 JM |
9 | |
10 | import hwsim_utils | |
11 | ||
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() | |
16 | ||
033e48ee JM |
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 | |
20 | # operating channel. | |
21 | dev[0].p2p_start_go(freq=2422) | |
22 | dev[1].scan() | |
23 | dev[0].remove_group() | |
24 | ||
ef2bd5a3 JM |
25 | logger.info("Discover peer") |
26 | dev[1].p2p_listen() | |
27 | if not dev[0].discover_peer(addr1, social=True): | |
28 | raise Exception("Peer " + addr1 + " not found") | |
29 | ||
30 | logger.info("Start GO on non-social channel") | |
31 | res = dev[0].p2p_start_go(freq=2417) | |
32 | logger.debug("res: " + str(res)) | |
33 | ||
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) | |
37 | if ev is None: | |
38 | raise Exception("Timeout on invitation on peer") | |
39 | ev = dev[0].wait_global_event(["P2P-INVITATION-RESULT"], timeout=10) | |
40 | if ev is None: | |
41 | raise Exception("Timeout on invitation on GO") | |
42 | if "status=1" not in ev: | |
43 | raise Exception("Unexpected invitation result") | |
44 | ||
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]) | |
51 | ||
52 | logger.info("Terminate group") | |
53 | dev[0].remove_group() | |
54 | dev[1].wait_go_ending_session() | |
b9ab2f2e JM |
55 | |
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() | |
60 | ||
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 | |
64 | # operating channel. | |
65 | dev[0].p2p_start_go(freq=2432) | |
66 | dev[1].scan() | |
67 | dev[0].remove_group() | |
68 | dev[0].dump_monitor() | |
69 | dev[1].dump_monitor() | |
70 | ||
71 | logger.info("Discover peer") | |
72 | dev[1].p2p_listen() | |
73 | if not dev[0].discover_peer(addr1, social=True): | |
74 | raise Exception("Peer " + addr1 + " not found") | |
75 | dev[0].p2p_listen() | |
76 | if not dev[1].discover_peer(addr0, social=True): | |
77 | raise Exception("Peer " + addr0 + " not found") | |
78 | dev[1].p2p_listen() | |
79 | ||
80 | logger.info("Authorize invitation") | |
81 | pin = dev[1].wps_read_pin() | |
82 | dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth") | |
83 | ||
84 | logger.info("Start GO on non-social channel") | |
85 | res = dev[0].p2p_start_go(freq=2427) | |
86 | logger.debug("res: " + str(res)) | |
87 | ||
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) | |
93 | if ev is None: | |
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") | |
97 | dev[0].dump_monitor() | |
98 | ||
99 | logger.info("Client connected") | |
100 | hwsim_utils.test_connectivity_p2p(dev[0], dev[1]) | |
101 | ||
102 | logger.info("Terminate group") | |
103 | dev[0].remove_group() | |
104 | dev[1].wait_go_ending_session() |