]>
Commit | Line | Data |
---|---|---|
d7257de6 | 1 | # cfg80211 P2P Device |
5de945fc | 2 | # Copyright (c) 2013-2015, Jouni Malinen <j@w1.fi> |
d7257de6 JM |
3 | # |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
7 | import logging | |
8 | logger = logging.getLogger() | |
9 | import time | |
10 | ||
11 | from wpasupplicant import WpaSupplicant | |
9cb34130 | 12 | from p2p_utils import * |
31b7ecb6 | 13 | from test_nfc_p2p import set_ip_addr_info, check_ip_addr, grpform_events |
5a8d165c | 14 | from hwsim import HWSimRadio |
53b2100a | 15 | from utils import HwsimSkip |
5de945fc | 16 | import hostapd |
31b7ecb6 | 17 | import hwsim_utils |
d7257de6 JM |
18 | |
19 | def test_p2p_device_grpform(dev, apdev): | |
20 | """P2P group formation with driver using cfg80211 P2P Device""" | |
5a8d165c JB |
21 | with HWSimRadio(use_p2p_device=True) as (radio, iface): |
22 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
23 | wpas.interface_add(iface) | |
24 | [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, | |
25 | r_dev=wpas, r_intent=0) | |
26 | check_grpform_results(i_res, r_res) | |
4b9d79b6 | 27 | wpas.dump_monitor() |
5a8d165c | 28 | remove_group(dev[0], wpas) |
4b9d79b6 | 29 | wpas.dump_monitor() |
23355114 JM |
30 | if not r_res['ifname'].startswith('p2p-' + iface): |
31 | raise Exception("Unexpected group ifname: " + r_res['ifname']) | |
d7257de6 | 32 | |
f86868c2 JM |
33 | res = wpas.global_request("IFNAME=p2p-dev-" + iface + " STATUS-DRIVER") |
34 | lines = res.splitlines() | |
35 | found = False | |
36 | for l in lines: | |
37 | try: | |
38 | [name,value] = l.split('=', 1) | |
39 | if name == "wdev_id": | |
40 | found = True | |
41 | break | |
42 | except ValueError: | |
43 | pass | |
44 | if not found: | |
45 | raise Exception("wdev_id not found") | |
46 | ||
d7257de6 JM |
47 | def test_p2p_device_grpform2(dev, apdev): |
48 | """P2P group formation with driver using cfg80211 P2P Device (reverse)""" | |
5a8d165c JB |
49 | with HWSimRadio(use_p2p_device=True) as (radio, iface): |
50 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
51 | wpas.interface_add(iface) | |
52 | [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15, | |
53 | r_dev=dev[0], r_intent=0) | |
54 | check_grpform_results(i_res, r_res) | |
4b9d79b6 | 55 | wpas.dump_monitor() |
5a8d165c | 56 | remove_group(wpas, dev[0]) |
4b9d79b6 | 57 | wpas.dump_monitor() |
23355114 JM |
58 | if not i_res['ifname'].startswith('p2p-' + iface): |
59 | raise Exception("Unexpected group ifname: " + i_res['ifname']) | |
60 | ||
61 | def test_p2p_device_grpform_no_group_iface(dev, apdev): | |
62 | """P2P group formation with driver using cfg80211 P2P Device but no separate group interface""" | |
63 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
64 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
65 | wpas.interface_add(iface) | |
66 | wpas.global_request("SET p2p_no_group_iface 1") | |
67 | [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, | |
68 | r_dev=wpas, r_intent=0) | |
69 | check_grpform_results(i_res, r_res) | |
70 | wpas.dump_monitor() | |
71 | remove_group(dev[0], wpas) | |
72 | wpas.dump_monitor() | |
73 | if r_res['ifname'] != iface: | |
74 | raise Exception("Unexpected group ifname: " + r_res['ifname']) | |
75 | ||
76 | def test_p2p_device_grpform_no_group_iface2(dev, apdev): | |
77 | """P2P group formation with driver using cfg80211 P2P Device but no separate group interface (reverse)""" | |
78 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
79 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
80 | wpas.interface_add(iface) | |
81 | wpas.global_request("SET p2p_no_group_iface 1") | |
82 | [i_res, r_res] = go_neg_pin_authorized(i_dev=wpas, i_intent=15, | |
83 | r_dev=dev[0], r_intent=0) | |
84 | check_grpform_results(i_res, r_res) | |
85 | wpas.dump_monitor() | |
86 | remove_group(dev[0], wpas) | |
87 | wpas.dump_monitor() | |
88 | if i_res['ifname'] != iface: | |
89 | raise Exception("Unexpected group ifname: " + i_res['ifname']) | |
fd177653 TG |
90 | |
91 | def test_p2p_device_group_remove(dev, apdev): | |
92 | """P2P group removal via the P2P ctrl interface with driver using cfg80211 P2P Device""" | |
5a8d165c JB |
93 | with HWSimRadio(use_p2p_device=True) as (radio, iface): |
94 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
95 | wpas.interface_add(iface) | |
96 | [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, | |
97 | r_dev=wpas, r_intent=0) | |
98 | check_grpform_results(i_res, r_res) | |
99 | # Issue the remove request on the interface which will be removed | |
100 | p2p_iface_wpas = WpaSupplicant(ifname=r_res['ifname']) | |
101 | res = p2p_iface_wpas.request("P2P_GROUP_REMOVE *") | |
102 | if "OK" not in res: | |
103 | raise Exception("Failed to remove P2P group") | |
104 | ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=10) | |
105 | if ev is None: | |
106 | raise Exception("Group removal event not received") | |
107 | if not wpas.global_ping(): | |
108 | raise Exception("Could not ping global ctrl_iface after group removal") | |
96a6c4c0 JM |
109 | |
110 | def test_p2p_device_concurrent_scan(dev, apdev): | |
111 | """Concurrent P2P and station mode scans with driver using cfg80211 P2P Device""" | |
112 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
113 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
114 | wpas.interface_add(iface) | |
115 | wpas.p2p_find() | |
116 | time.sleep(0.1) | |
117 | wpas.request("SCAN") | |
118 | ev = wpas.wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=15) | |
119 | if ev is None: | |
120 | raise Exception("Station mode scan did not start") | |
31b7ecb6 JM |
121 | |
122 | def test_p2p_device_nfc_invite(dev, apdev): | |
7c7fa52f JM |
123 | """P2P NFC invitation with driver using cfg80211 P2P Device""" |
124 | run_p2p_device_nfc_invite(dev, apdev, 0) | |
125 | ||
126 | def test_p2p_device_nfc_invite_no_group_iface(dev, apdev): | |
127 | """P2P NFC invitation with driver using cfg80211 P2P Device (no separate group interface)""" | |
128 | run_p2p_device_nfc_invite(dev, apdev, 1) | |
129 | ||
130 | def run_p2p_device_nfc_invite(dev, apdev, no_group_iface): | |
31b7ecb6 JM |
131 | with HWSimRadio(use_p2p_device=True) as (radio, iface): |
132 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
133 | wpas.interface_add(iface) | |
7c7fa52f | 134 | wpas.global_request("SET p2p_no_group_iface %d" % no_group_iface) |
31b7ecb6 JM |
135 | |
136 | set_ip_addr_info(dev[0]) | |
137 | logger.info("Start autonomous GO") | |
138 | dev[0].p2p_start_go() | |
139 | ||
140 | logger.info("Write NFC Tag on the P2P Client") | |
141 | res = wpas.global_request("P2P_LISTEN") | |
142 | if "FAIL" in res: | |
143 | raise Exception("Failed to start Listen mode") | |
4b9d79b6 | 144 | wpas.dump_monitor() |
31b7ecb6 JM |
145 | pw = wpas.global_request("WPS_NFC_TOKEN NDEF").rstrip() |
146 | if "FAIL" in pw: | |
147 | raise Exception("Failed to generate password token") | |
148 | res = wpas.global_request("P2P_SET nfc_tag 1").rstrip() | |
149 | if "FAIL" in res: | |
150 | raise Exception("Failed to enable NFC Tag for P2P static handover") | |
151 | sel = wpas.global_request("NFC_GET_HANDOVER_SEL NDEF P2P-CR-TAG").rstrip() | |
152 | if "FAIL" in sel: | |
153 | raise Exception("Failed to generate NFC connection handover select") | |
4b9d79b6 | 154 | wpas.dump_monitor() |
31b7ecb6 JM |
155 | |
156 | logger.info("Read NFC Tag on the GO to trigger invitation") | |
cf5d768b | 157 | res = dev[0].global_request("WPS_NFC_TAG_READ " + sel) |
31b7ecb6 JM |
158 | if "FAIL" in res: |
159 | raise Exception("Failed to provide NFC tag contents to wpa_supplicant") | |
160 | ||
161 | ev = wpas.wait_global_event(grpform_events, timeout=20) | |
162 | if ev is None: | |
163 | raise Exception("Joining the group timed out") | |
164 | res = wpas.group_form_result(ev) | |
4b9d79b6 | 165 | wpas.dump_monitor() |
31b7ecb6 JM |
166 | hwsim_utils.test_connectivity_p2p(dev[0], wpas) |
167 | check_ip_addr(res) | |
4b9d79b6 | 168 | wpas.dump_monitor() |
5de945fc JM |
169 | |
170 | def test_p2p_device_misuses(dev, apdev): | |
171 | """cfg80211 P2P Device misuses""" | |
8b8a1864 | 172 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
5de945fc JM |
173 | with HWSimRadio(use_p2p_device=True) as (radio, iface): |
174 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
175 | wpas.interface_add(iface) | |
176 | ||
177 | # Add a normal network profile to the P2P Device management only | |
178 | # interface to verify that it does not get used. | |
179 | id = int(wpas.global_request('IFNAME=p2p-dev-%s ADD_NETWORK' % iface).strip()) | |
180 | wpas.global_request('IFNAME=p2p-dev-%s SET_NETWORK %d ssid "open"' % (iface, id)) | |
181 | wpas.global_request('IFNAME=p2p-dev-%s SET_NETWORK %d key_mgmt NONE' % (iface, id)) | |
182 | wpas.global_request('IFNAME=p2p-dev-%s ENABLE_NETWORK %d' % (iface, id)) | |
183 | ||
184 | # Scan requests get ignored on p2p-dev | |
185 | wpas.global_request('IFNAME=p2p-dev-%s SCAN' % iface) | |
186 | ||
187 | dev[0].p2p_start_go(freq=2412) | |
188 | addr = dev[0].p2p_interface_addr() | |
189 | wpas.scan_for_bss(addr, freq=2412) | |
190 | wpas.connect("open", key_mgmt="NONE", scan_freq="2412") | |
191 | hwsim_utils.test_connectivity(wpas, hapd) | |
192 | ||
193 | pin = wpas.wps_read_pin() | |
194 | dev[0].p2p_go_authorize_client(pin) | |
195 | res = wpas.p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60, | |
196 | social=True, freq=2412) | |
197 | hwsim_utils.test_connectivity_p2p(dev[0], wpas) | |
198 | ||
199 | # Optimize scan-after-disconnect | |
200 | wpas.group_request("SET_NETWORK 0 scan_freq 2412") | |
201 | ||
cc259e26 | 202 | dev[0].group_request("DISASSOCIATE " + wpas.p2p_interface_addr()) |
5de945fc JM |
203 | ev = wpas.wait_group_event(["CTRL-EVENT-DISCONNECT"]) |
204 | if ev is None: | |
205 | raise Exception("Did not see disconnect event on P2P group interface") | |
206 | dev[0].remove_group() | |
207 | ||
208 | ev = wpas.wait_group_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5) | |
209 | if ev is None: | |
210 | raise Exception("Scan not started") | |
211 | ev = wpas.wait_group_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=15) | |
212 | if ev is None: | |
213 | raise Exception("Scan not completed") | |
214 | time.sleep(1) | |
215 | hwsim_utils.test_connectivity(wpas, hapd) | |
216 | ||
217 | ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=0.1) | |
218 | if ev is not None: | |
219 | raise Exception("Unexpected disconnection event received from hostapd") | |
220 | ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=0.1) | |
221 | if ev is not None: | |
222 | raise Exception("Unexpected disconnection event received from wpa_supplicant") | |
223 | ||
224 | wpas.request("DISCONNECT") | |
225 | wpas.wait_disconnected() | |
6acca705 JM |
226 | |
227 | def test_p2p_device_incorrect_command_interface(dev, apdev): | |
228 | """cfg80211 P2P Device and P2P_* command on incorrect interface""" | |
229 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
230 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
231 | wpas.interface_add(iface) | |
232 | ||
233 | dev[0].p2p_listen() | |
234 | wpas.request('P2P_FIND type=social') | |
235 | ev = wpas.wait_global_event(["P2P-DEVICE-FOUND"], timeout=10) | |
236 | if ev is None: | |
237 | raise Exception("Peer not found") | |
238 | ev = wpas.wait_event(["P2P-DEVICE-FOUND"], timeout=0.1) | |
239 | if ev is not None: | |
240 | raise Exception("Unexpected P2P-DEVICE-FOUND event on station interface") | |
4b9d79b6 | 241 | wpas.dump_monitor() |
6acca705 JM |
242 | |
243 | pin = wpas.wps_read_pin() | |
244 | dev[0].p2p_go_neg_auth(wpas.p2p_dev_addr(), pin, "enter", go_intent=14, | |
245 | freq=2412) | |
246 | wpas.request('P2P_STOP_FIND') | |
4b9d79b6 | 247 | wpas.dump_monitor() |
6acca705 JM |
248 | if "OK" not in wpas.request('P2P_CONNECT ' + dev[0].p2p_dev_addr() + ' ' + pin + ' display go_intent=1'): |
249 | raise Exception("P2P_CONNECT failed") | |
250 | ||
251 | ev = wpas.wait_global_event(["P2P-GROUP-STARTED"], timeout=15) | |
252 | if ev is None: | |
253 | raise Exception("Group formation timed out") | |
254 | wpas.group_form_result(ev) | |
4b9d79b6 | 255 | wpas.dump_monitor() |
6acca705 JM |
256 | |
257 | ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15) | |
258 | if ev is None: | |
259 | raise Exception("Group formation timed out(2)") | |
260 | dev[0].group_form_result(ev) | |
261 | ||
262 | dev[0].remove_group() | |
263 | wpas.wait_go_ending_session() | |
4b9d79b6 | 264 | wpas.dump_monitor() |
6acca705 JM |
265 | |
266 | def test_p2p_device_incorrect_command_interface2(dev, apdev): | |
267 | """cfg80211 P2P Device and P2P_GROUP_ADD command on incorrect interface""" | |
268 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
269 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
270 | wpas.interface_add(iface) | |
271 | ||
4b9d79b6 JM |
272 | if "OK" not in wpas.request('P2P_GROUP_ADD'): |
273 | raise Exception("P2P_GROUP_ADD failed") | |
6acca705 JM |
274 | ev = wpas.wait_global_event(["P2P-GROUP-STARTED"], timeout=15) |
275 | if ev is None: | |
276 | raise Exception("Group formation timed out") | |
277 | res = wpas.group_form_result(ev) | |
4b9d79b6 | 278 | wpas.dump_monitor() |
6acca705 JM |
279 | logger.info("Group results: " + str(res)) |
280 | wpas.remove_group() | |
281 | if not res['ifname'].startswith('p2p-' + iface + '-'): | |
282 | raise Exception("Unexpected group ifname: " + res['ifname']) | |
4b9d79b6 | 283 | wpas.dump_monitor() |
53b2100a JM |
284 | |
285 | def test_p2p_device_grpform_timeout_client(dev, apdev): | |
286 | """P2P group formation timeout on client with cfg80211 P2P Device""" | |
287 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
288 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
289 | wpas.interface_add(iface) | |
290 | addr0 = dev[0].p2p_dev_addr() | |
291 | addr5 = wpas.p2p_dev_addr() | |
292 | wpas.p2p_listen() | |
293 | dev[0].discover_peer(addr5) | |
294 | dev[0].p2p_listen() | |
295 | wpas.discover_peer(addr0) | |
296 | wpas.p2p_ext_listen(100, 150) | |
297 | dev[0].global_request("P2P_CONNECT " + addr5 + " 12345670 enter go_intent=15 auth") | |
298 | wpas.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=0") | |
299 | ev = dev[0].wait_global_event(["P2P-GO-NEG-SUCCESS"], timeout=5) | |
300 | if ev is None: | |
301 | raise Exception("GO Negotiation did not succeed") | |
302 | ev = dev[0].wait_global_event(["WPS-SUCCESS"], timeout=10) | |
303 | if ev is None: | |
304 | raise Exception("WPS did not succeed (GO)") | |
305 | if "OK" not in dev[0].global_request("P2P_CANCEL"): | |
306 | wpas.global_request("P2P_CANCEL") | |
307 | del wpas | |
308 | raise HwsimSkip("Did not manage to cancel group formation") | |
309 | dev[0].dump_monitor() | |
310 | ev = wpas.wait_global_event(["WPS-SUCCESS"], timeout=10) | |
311 | if ev is None: | |
312 | raise Exception("WPS did not succeed (Client)") | |
313 | dev[0].dump_monitor() | |
314 | ev = wpas.wait_global_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=20) | |
315 | if ev is None: | |
316 | raise Exception("Group formation timeout not seen on client") | |
317 | ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=5) | |
318 | if ev is None: | |
319 | raise Exception("Group removal not seen on client") | |
320 | wpas.p2p_cancel_ext_listen() | |
321 | time.sleep(0.1) | |
322 | ifaces = wpas.global_request("INTERFACES") | |
323 | logger.info("Remaining interfaces: " + ifaces) | |
324 | del wpas | |
325 | if "p2p-" + iface + "-" in ifaces: | |
326 | raise Exception("Group interface still present after failure") | |
327 | ||
328 | def test_p2p_device_grpform_timeout_go(dev, apdev): | |
329 | """P2P group formation timeout on GO with cfg80211 P2P Device""" | |
330 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
331 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
332 | wpas.interface_add(iface) | |
333 | addr0 = dev[0].p2p_dev_addr() | |
334 | addr5 = wpas.p2p_dev_addr() | |
335 | wpas.p2p_listen() | |
336 | dev[0].discover_peer(addr5) | |
337 | dev[0].p2p_listen() | |
338 | wpas.discover_peer(addr0) | |
339 | wpas.p2p_ext_listen(100, 150) | |
340 | dev[0].global_request("P2P_CONNECT " + addr5 + " 12345670 enter go_intent=0 auth") | |
341 | wpas.global_request("P2P_CONNECT " + addr0 + " 12345670 display go_intent=15") | |
342 | ev = dev[0].wait_global_event(["P2P-GO-NEG-SUCCESS"], timeout=5) | |
343 | if ev is None: | |
344 | raise Exception("GO Negotiation did not succeed") | |
345 | ev = dev[0].wait_global_event(["WPS-SUCCESS"], timeout=10) | |
346 | if ev is None: | |
347 | raise Exception("WPS did not succeed (Client)") | |
348 | if "OK" not in dev[0].global_request("P2P_CANCEL"): | |
349 | if "OK" not in dev[0].global_request("P2P_GROUP_REMOVE *"): | |
350 | wpas.global_request("P2P_CANCEL") | |
351 | del wpas | |
352 | raise HwsimSkip("Did not manage to cancel group formation") | |
353 | dev[0].dump_monitor() | |
354 | ev = wpas.wait_global_event(["WPS-SUCCESS"], timeout=10) | |
355 | if ev is None: | |
356 | raise Exception("WPS did not succeed (GO)") | |
357 | dev[0].dump_monitor() | |
358 | ev = wpas.wait_global_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=20) | |
359 | if ev is None: | |
360 | raise Exception("Group formation timeout not seen on GO") | |
361 | ev = wpas.wait_global_event(["P2P-GROUP-REMOVED"], timeout=5) | |
362 | if ev is None: | |
363 | raise Exception("Group removal not seen on GO") | |
364 | wpas.p2p_cancel_ext_listen() | |
365 | time.sleep(0.1) | |
366 | ifaces = wpas.global_request("INTERFACES") | |
367 | logger.info("Remaining interfaces: " + ifaces) | |
368 | del wpas | |
369 | if "p2p-" + iface + "-" in ifaces: | |
370 | raise Exception("Group interface still present after failure") | |
b17f8f17 JM |
371 | |
372 | def test_p2p_device_autogo(dev, apdev): | |
373 | """P2P autogo using cfg80211 P2P Device""" | |
374 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
375 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
376 | wpas.interface_add(iface) | |
377 | ||
378 | res = wpas.p2p_start_go() | |
379 | if not res['ifname'].startswith('p2p-' + iface): | |
380 | raise Exception("Unexpected group ifname: " + res['ifname']) | |
381 | bssid = wpas.get_group_status_field('bssid') | |
382 | ||
383 | dev[0].scan_for_bss(bssid, res['freq']) | |
384 | connect_cli(wpas, dev[0], freq=res['freq']) | |
385 | terminate_group(wpas, dev[0]) | |
386 | ||
387 | def test_p2p_device_autogo_no_group_iface(dev, apdev): | |
388 | """P2P autogo using cfg80211 P2P Device (no separate group interface)""" | |
389 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
390 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
391 | wpas.interface_add(iface) | |
392 | wpas.global_request("SET p2p_no_group_iface 1") | |
393 | ||
394 | res = wpas.p2p_start_go() | |
395 | if res['ifname'] != iface: | |
396 | raise Exception("Unexpected group ifname: " + res['ifname']) | |
397 | bssid = wpas.get_group_status_field('bssid') | |
398 | ||
399 | dev[0].scan_for_bss(bssid, res['freq']) | |
400 | connect_cli(wpas, dev[0], freq=res['freq']) | |
401 | terminate_group(wpas, dev[0]) | |
ebbf660c JM |
402 | |
403 | def test_p2p_device_join(dev, apdev): | |
404 | """P2P join-group using cfg80211 P2P Device""" | |
405 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
406 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
407 | wpas.interface_add(iface) | |
408 | ||
409 | res = dev[0].p2p_start_go() | |
410 | bssid = dev[0].get_group_status_field('bssid') | |
411 | ||
412 | wpas.scan_for_bss(bssid, res['freq']) | |
413 | res2 = connect_cli(dev[0], wpas, freq=res['freq']) | |
414 | if not res2['ifname'].startswith('p2p-' + iface): | |
415 | raise Exception("Unexpected group ifname: " + res2['ifname']) | |
416 | ||
417 | terminate_group(dev[0], wpas) | |
418 | ||
419 | def test_p2p_device_join_no_group_iface(dev, apdev): | |
420 | """P2P join-group using cfg80211 P2P Device (no separate group interface)""" | |
421 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
422 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
423 | wpas.interface_add(iface) | |
424 | wpas.global_request("SET p2p_no_group_iface 1") | |
425 | ||
426 | res = dev[0].p2p_start_go() | |
427 | bssid = dev[0].get_group_status_field('bssid') | |
428 | ||
429 | wpas.scan_for_bss(bssid, res['freq']) | |
430 | res2 = connect_cli(dev[0], wpas, freq=res['freq']) | |
431 | if res2['ifname'] != iface: | |
432 | raise Exception("Unexpected group ifname: " + res2['ifname']) | |
433 | ||
434 | terminate_group(dev[0], wpas) | |
cd9a0bd0 JM |
435 | |
436 | def test_p2p_device_persistent_group(dev): | |
437 | """P2P persistent group formation and re-invocation with cfg80211 P2P Device""" | |
438 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
439 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
440 | wpas.interface_add(iface) | |
441 | wpas.global_request("SET p2p_no_group_iface 0") | |
442 | ||
443 | form(dev[0], wpas) | |
444 | invite_from_cli(dev[0], wpas) | |
445 | invite_from_go(dev[0], wpas) | |
446 | ||
447 | def test_p2p_device_persistent_group_no_group_iface(dev): | |
448 | """P2P persistent group formation and re-invocation with cfg80211 P2P Device (no separate group interface)""" | |
449 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
450 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
451 | wpas.interface_add(iface) | |
452 | wpas.global_request("SET p2p_no_group_iface 1") | |
453 | ||
454 | form(dev[0], wpas) | |
455 | invite_from_cli(dev[0], wpas) | |
456 | invite_from_go(dev[0], wpas) | |
457 | ||
458 | def test_p2p_device_persistent_group2(dev): | |
459 | """P2P persistent group formation and re-invocation (reverse) with cfg80211 P2P Device""" | |
460 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
461 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
462 | wpas.interface_add(iface) | |
463 | wpas.global_request("SET p2p_no_group_iface 0") | |
464 | ||
465 | form(wpas, dev[0]) | |
466 | invite_from_cli(wpas, dev[0]) | |
467 | invite_from_go(wpas, dev[0]) | |
468 | ||
469 | def test_p2p_device_persistent_group2_no_group_iface(dev): | |
470 | """P2P persistent group formation and re-invocation (reverse) with cfg80211 P2P Device (no separate group interface)""" | |
471 | with HWSimRadio(use_p2p_device=True) as (radio, iface): | |
472 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
473 | wpas.interface_add(iface) | |
474 | wpas.global_request("SET p2p_no_group_iface 1") | |
475 | ||
476 | form(wpas, dev[0]) | |
477 | invite_from_cli(wpas, dev[0]) | |
478 | invite_from_go(wpas, dev[0]) |