]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_p2p_channel.py
tests: Mark 525 tests as remote compatible
[thirdparty/hostap.git] / tests / hwsim / test_p2p_channel.py
1 # P2P channel selection test cases
2 # Copyright (c) 2014, 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 from remotehost import remote_compatible
8 import logging
9 logger = logging.getLogger()
10 import os
11 import subprocess
12 import time
13
14 import hostapd
15 import hwsim_utils
16 from tshark import run_tshark
17 from wpasupplicant import WpaSupplicant
18 from hwsim import HWSimRadio
19 from p2p_utils import *
20
21 def set_country(country, dev=None):
22 subprocess.call(['iw', 'reg', 'set', country])
23 time.sleep(0.1)
24 if dev:
25 for i in range(10):
26 ev = dev.wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout=15)
27 if ev is None:
28 raise Exception("No regdom change event seen")
29 if "type=COUNTRY alpha2=" + country in ev:
30 return
31 raise Exception("No matching regdom event seen for set_country(%s)" % country)
32
33 def test_p2p_channel_5ghz(dev):
34 """P2P group formation with 5 GHz preference"""
35 try:
36 set_country("US", dev[0])
37 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
38 r_dev=dev[1], r_intent=0,
39 test_data=False)
40 check_grpform_results(i_res, r_res)
41 freq = int(i_res['freq'])
42 if freq < 5000:
43 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
44 remove_group(dev[0], dev[1])
45 finally:
46 set_country("00")
47 dev[1].flush_scan_cache()
48
49 def test_p2p_channel_5ghz_no_vht(dev):
50 """P2P group formation with 5 GHz preference when VHT channels are disallowed"""
51 try:
52 set_country("US", dev[0])
53 dev[0].global_request("P2P_SET disallow_freq 5180-5240")
54 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
55 r_dev=dev[1], r_intent=0,
56 test_data=False)
57 check_grpform_results(i_res, r_res)
58 freq = int(i_res['freq'])
59 if freq < 5000:
60 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
61 remove_group(dev[0], dev[1])
62 finally:
63 set_country("00")
64 dev[0].global_request("P2P_SET disallow_freq ")
65 dev[1].flush_scan_cache()
66
67 def test_p2p_channel_random_social(dev):
68 """P2P group formation with 5 GHz preference but all 5 GHz channels disabled"""
69 try:
70 set_country("US", dev[0])
71 dev[0].global_request("SET p2p_oper_channel 11")
72 dev[0].global_request("P2P_SET disallow_freq 5000-6000,2462")
73 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
74 r_dev=dev[1], r_intent=0,
75 test_data=False)
76 check_grpform_results(i_res, r_res)
77 freq = int(i_res['freq'])
78 if freq not in [ 2412, 2437, 2462 ]:
79 raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
80 remove_group(dev[0], dev[1])
81 finally:
82 set_country("00")
83 dev[0].global_request("P2P_SET disallow_freq ")
84 dev[1].flush_scan_cache()
85
86 def test_p2p_channel_random(dev):
87 """P2P group formation with 5 GHz preference but all 5 GHz channels and all social channels disabled"""
88 try:
89 set_country("US", dev[0])
90 dev[0].global_request("SET p2p_oper_channel 11")
91 dev[0].global_request("P2P_SET disallow_freq 5000-6000,2412,2437,2462")
92 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
93 r_dev=dev[1], r_intent=0,
94 test_data=False)
95 check_grpform_results(i_res, r_res)
96 freq = int(i_res['freq'])
97 if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
98 raise Exception("Unexpected channel %d MHz" % freq)
99 remove_group(dev[0], dev[1])
100 finally:
101 set_country("00")
102 dev[0].global_request("P2P_SET disallow_freq ")
103 dev[1].flush_scan_cache()
104
105 def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
106 """P2P group formation using random social channel with oper class change needed"""
107 try:
108 set_country("US", dev[0])
109 logger.info("Start group on 5 GHz")
110 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
111 r_dev=dev[1], r_intent=0,
112 test_data=False)
113 check_grpform_results(i_res, r_res)
114 freq = int(i_res['freq'])
115 if freq < 5000:
116 raise Exception("Unexpected channel %d MHz - did not pick 5 GHz preference" % freq)
117 remove_group(dev[0], dev[1])
118
119 logger.info("Disable 5 GHz and try to re-start group based on 5 GHz preference")
120 dev[0].global_request("SET p2p_oper_reg_class 115")
121 dev[0].global_request("SET p2p_oper_channel 36")
122 dev[0].global_request("P2P_SET disallow_freq 5000-6000")
123 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
124 r_dev=dev[1], r_intent=0,
125 test_data=False)
126 check_grpform_results(i_res, r_res)
127 freq = int(i_res['freq'])
128 if freq not in [ 2412, 2437, 2462 ]:
129 raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
130 remove_group(dev[0], dev[1])
131
132 out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
133 "wifi_p2p.public_action.subtype == 0")
134 if out is not None:
135 last = None
136 for l in out.splitlines():
137 if "Operating Channel:" not in l:
138 continue
139 last = l
140 if last is None:
141 raise Exception("Could not find GO Negotiation Request")
142 if "Operating Class 81" not in last:
143 raise Exception("Unexpected operating class: " + last.strip())
144 finally:
145 set_country("00")
146 dev[0].global_request("P2P_SET disallow_freq ")
147 dev[0].global_request("SET p2p_oper_reg_class 0")
148 dev[0].global_request("SET p2p_oper_channel 0")
149 dev[1].flush_scan_cache()
150
151 def test_p2p_channel_avoid(dev):
152 """P2P and avoid frequencies driver event"""
153 try:
154 set_country("US", dev[0])
155 if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES 5000-6000,2412,2437,2462"):
156 raise Exception("Could not simulate driver event")
157 ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
158 if ev is None:
159 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
160 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
161 r_dev=dev[1], r_intent=0,
162 test_data=False)
163 check_grpform_results(i_res, r_res)
164 freq = int(i_res['freq'])
165 if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
166 raise Exception("Unexpected channel %d MHz" % freq)
167
168 if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES"):
169 raise Exception("Could not simulate driver event(2)")
170 ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
171 if ev is None:
172 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
173 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
174 "AP-CSA-FINISHED"], timeout=1)
175 if ev is not None:
176 raise Exception("Unexpected + " + ev + " event")
177
178 if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES " + str(freq)):
179 raise Exception("Could not simulate driver event(3)")
180 ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
181 if ev is None:
182 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
183 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
184 "AP-CSA-FINISHED"],
185 timeout=10)
186 if ev is None:
187 raise Exception("No P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED event")
188 finally:
189 set_country("00")
190 dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
191 dev[1].flush_scan_cache()
192
193 @remote_compatible
194 def test_autogo_following_bss(dev, apdev):
195 """P2P autonomous GO operate on the same channel as station interface"""
196 if dev[0].get_mcc() > 1:
197 logger.info("test mode: MCC")
198
199 dev[0].global_request("SET p2p_no_group_iface 0")
200
201 channels = { 3 : "2422", 5 : "2432", 9 : "2452" }
202 for key in channels:
203 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
204 "channel" : str(key) })
205 dev[0].connect("ap-test", key_mgmt="NONE",
206 scan_freq=str(channels[key]))
207 res_go = autogo(dev[0])
208 if res_go['freq'] != channels[key]:
209 raise Exception("Group operation channel is not the same as on connected station interface")
210 hwsim_utils.test_connectivity(dev[0], hapd)
211 dev[0].remove_group(res_go['ifname'])
212
213 @remote_compatible
214 def test_go_neg_with_bss_connected(dev, apdev):
215 """P2P channel selection: GO negotiation when station interface is connected"""
216
217 dev[0].flush_scan_cache()
218 dev[1].flush_scan_cache()
219 dev[0].global_request("SET p2p_no_group_iface 0")
220
221 hapd = hostapd.add_ap(apdev[0],
222 { "ssid": 'bss-2.4ghz', "channel": '5' })
223 dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432")
224 #dev[0] as GO
225 [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1],
226 r_intent=1)
227 check_grpform_results(i_res, r_res)
228 if i_res['role'] != "GO":
229 raise Exception("GO not selected according to go_intent")
230 if i_res['freq'] != "2432":
231 raise Exception("Group formed on a different frequency than BSS")
232 hwsim_utils.test_connectivity(dev[0], hapd)
233 dev[0].remove_group(i_res['ifname'])
234 dev[1].wait_go_ending_session()
235
236 if dev[0].get_mcc() > 1:
237 logger.info("Skip as-client case due to MCC being enabled")
238 return;
239
240 #dev[0] as client
241 [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=1, r_dev=dev[1],
242 r_intent=10)
243 check_grpform_results(i_res2, r_res2)
244 if i_res2['role'] != "client":
245 raise Exception("GO not selected according to go_intent")
246 if i_res2['freq'] != "2432":
247 raise Exception("Group formed on a different frequency than BSS")
248 hwsim_utils.test_connectivity(dev[0], hapd)
249 dev[1].remove_group(r_res2['ifname'])
250 dev[0].wait_go_ending_session()
251 dev[0].request("DISCONNECT")
252 hapd.disable()
253 dev[0].flush_scan_cache()
254 dev[1].flush_scan_cache()
255
256 def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
257 """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
258
259 with HWSimRadio(n_channels=2) as (radio, iface):
260 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
261 wpas.interface_add(iface)
262
263 wpas.global_request("SET p2p_no_group_iface 0")
264
265 if wpas.get_mcc() < 2:
266 raise Exception("New radio does not support MCC")
267
268 try:
269 hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz',
270 "channel": '1' })
271 wpas.global_request("P2P_SET disallow_freq 2412")
272 wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
273 res = autogo(wpas)
274 if res['freq'] == "2412":
275 raise Exception("GO set on a disallowed channel")
276 hwsim_utils.test_connectivity(wpas, hapd)
277 finally:
278 wpas.global_request("P2P_SET disallow_freq ")
279
280 def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
281 """P2P channel selection: GO negotiation with station interface on a disallowed channel"""
282
283 with HWSimRadio(n_channels=2) as (radio, iface):
284 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
285 wpas.interface_add(iface)
286
287 wpas.global_request("SET p2p_no_group_iface 0")
288
289 if wpas.get_mcc() < 2:
290 raise Exception("New radio does not support MCC")
291
292 try:
293 hapd = hostapd.add_ap(apdev[0],
294 { "ssid": 'bss-2.4ghz', "channel": '1' })
295 # make sure PBC overlap from old test cases is not maintained
296 dev[1].flush_scan_cache()
297 wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
298 wpas.global_request("P2P_SET disallow_freq 2412")
299
300 #wpas as GO
301 [i_res, r_res] = go_neg_pbc(i_dev=wpas, i_intent=10, r_dev=dev[1],
302 r_intent=1)
303 check_grpform_results(i_res, r_res)
304 if i_res['role'] != "GO":
305 raise Exception("GO not selected according to go_intent")
306 if i_res['freq'] == "2412":
307 raise Exception("Group formed on a disallowed channel")
308 hwsim_utils.test_connectivity(wpas, hapd)
309 wpas.remove_group(i_res['ifname'])
310 dev[1].wait_go_ending_session()
311 dev[1].flush_scan_cache()
312
313 wpas.dump_monitor()
314 dev[1].dump_monitor()
315
316 #wpas as client
317 [i_res2, r_res2] = go_neg_pbc(i_dev=wpas, i_intent=1, r_dev=dev[1],
318 r_intent=10)
319 check_grpform_results(i_res2, r_res2)
320 if i_res2['role'] != "client":
321 raise Exception("GO not selected according to go_intent")
322 if i_res2['freq'] == "2412":
323 raise Exception("Group formed on a disallowed channel")
324 hwsim_utils.test_connectivity(wpas, hapd)
325 dev[1].remove_group(r_res2['ifname'])
326 wpas.wait_go_ending_session()
327 ev = dev[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout=5)
328 if ev is None:
329 raise Exception("Group removal not indicated")
330 wpas.request("DISCONNECT")
331 hapd.disable()
332 finally:
333 wpas.global_request("P2P_SET disallow_freq ")
334
335 def test_autogo_force_diff_channel(dev, apdev):
336 """P2P autonomous GO and station interface operate on different channels"""
337 with HWSimRadio(n_channels=2) as (radio, iface):
338 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
339 wpas.interface_add(iface)
340
341 if wpas.get_mcc() < 2:
342 raise Exception("New radio does not support MCC")
343
344 wpas.global_request("SET p2p_no_group_iface 0")
345
346 hapd = hostapd.add_ap(apdev[0],
347 {"ssid" : 'ap-test', "channel" : '1'})
348 wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
349 wpas.dump_monitor()
350 channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
351 for key in channels:
352 res_go = autogo(wpas, channels[key])
353 wpas.dump_monitor()
354 hwsim_utils.test_connectivity(wpas, hapd)
355 if int(res_go['freq']) == 2412:
356 raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
357 wpas.remove_group(res_go['ifname'])
358 wpas.dump_monitor()
359
360 def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
361 """P2P channel selection: GO negotiation with forced freq different than station interface"""
362 with HWSimRadio(n_channels=2) as (radio, iface):
363 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
364 wpas.interface_add(iface)
365
366 if wpas.get_mcc() < 2:
367 raise Exception("New radio does not support MCC")
368
369 # Clear possible PBC session overlap from previous test case
370 dev[1].flush_scan_cache()
371
372 wpas.global_request("SET p2p_no_group_iface 0")
373
374 hapd = hostapd.add_ap(apdev[0],
375 { "country_code": 'US',
376 "ssid": 'bss-5ghz', "hw_mode": 'a',
377 "channel": '40' })
378 wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
379
380 # GO and peer force the same freq, different than BSS freq,
381 # wpas to become GO
382 [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
383 r_dev=wpas, r_intent=14, r_freq=5180)
384 check_grpform_results(i_res, r_res)
385 if i_res['freq'] != "5180":
386 raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
387 if r_res['role'] != "GO":
388 raise Exception("GO not selected according to go_intent")
389 hwsim_utils.test_connectivity(wpas, hapd)
390 wpas.remove_group(r_res['ifname'])
391 dev[1].wait_go_ending_session()
392 dev[1].flush_scan_cache()
393
394 # GO and peer force the same freq, different than BSS freq, wpas to
395 # become client
396 [i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
397 r_dev=wpas, r_intent=1, r_freq=2422)
398 check_grpform_results(i_res2, r_res2)
399 if i_res2['freq'] != "2422":
400 raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
401 if r_res2['role'] != "client":
402 raise Exception("GO not selected according to go_intent")
403 hwsim_utils.test_connectivity(wpas, hapd)
404
405 wpas.request("DISCONNECT")
406 hapd.request("DISABLE")
407 subprocess.call(['iw', 'reg', 'set', '00'])
408 wpas.flush_scan_cache()
409
410 @remote_compatible
411 def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
412 """P2P channel selection: Station on different channel than GO configured pref channel"""
413
414 dev[0].global_request("SET p2p_no_group_iface 0")
415
416 try:
417 hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz',
418 "channel": '1' })
419 dev[0].global_request("SET p2p_pref_chan 81:2")
420 dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
421 res = autogo(dev[0])
422 if res['freq'] != "2412":
423 raise Exception("GO channel did not follow BSS")
424 hwsim_utils.test_connectivity(dev[0], hapd)
425 finally:
426 dev[0].global_request("SET p2p_pref_chan ")
427
428 def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
429 """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
430 with HWSimRadio(n_channels=2) as (radio, iface):
431 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
432 wpas.interface_add(iface)
433
434 if wpas.get_mcc() < 2:
435 raise Exception("New radio does not support MCC")
436
437 wpas.global_request("SET p2p_no_group_iface 0")
438
439 try:
440 hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz',
441 "channel": '1' })
442 wpas.global_request("P2P_SET disallow_freq 2412")
443 wpas.global_request("SET p2p_pref_chan 81:2")
444 wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
445 res2 = autogo(wpas)
446 if res2['freq'] != "2417":
447 raise Exception("GO channel did not follow pref_chan configuration")
448 hwsim_utils.test_connectivity(wpas, hapd)
449 finally:
450 wpas.global_request("P2P_SET disallow_freq ")
451 wpas.global_request("SET p2p_pref_chan ")
452
453 @remote_compatible
454 def test_no_go_freq(dev, apdev):
455 """P2P channel selection: no GO freq"""
456 try:
457 dev[0].global_request("SET p2p_no_go_freq 2412")
458 # dev[0] as client, channel 1 is ok
459 [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=1,
460 r_dev=dev[1], r_intent=14, r_freq=2412)
461 check_grpform_results(i_res, r_res)
462 if i_res['freq'] != "2412":
463 raise Exception("P2P group not formed on forced freq")
464
465 dev[1].remove_group(r_res['ifname'])
466 dev[0].wait_go_ending_session()
467 dev[0].flush_scan_cache()
468
469 fail = False
470 # dev[0] as GO, channel 1 is not allowed
471 try:
472 dev[0].global_request("SET p2p_no_go_freq 2412")
473 [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14,
474 r_dev=dev[1], r_intent=1, r_freq=2412)
475 check_grpform_results(i_res2, r_res2)
476 fail = True
477 except:
478 pass
479 if fail:
480 raise Exception("GO set on a disallowed freq")
481 finally:
482 dev[0].global_request("SET p2p_no_go_freq ")
483
484 @remote_compatible
485 def test_go_neg_peers_force_diff_freq(dev, apdev):
486 """P2P channel selection when peers for different frequency"""
487 try:
488 [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14, i_freq=5180,
489 r_dev=dev[1], r_intent=0, r_freq=5200)
490 except Exception, e:
491 return
492 raise Exception("Unexpected group formation success")
493
494 @remote_compatible
495 def test_autogo_random_channel(dev, apdev):
496 """P2P channel selection: GO instantiated on random channel 1, 6, 11"""
497 freqs = []
498 go_freqs = ["2412", "2437", "2462"]
499 for i in range(0, 20):
500 result = autogo(dev[0])
501 if result['freq'] not in go_freqs:
502 raise Exception("Unexpected frequency selected: " + result['freq'])
503 if result['freq'] not in freqs:
504 freqs.append(result['freq'])
505 if len(freqs) == 3:
506 break
507 dev[0].remove_group(result['ifname'])
508 if i == 20:
509 raise Exception("GO created 20 times and not all social channels were selected. freqs not selected: " + str(list(set(go_freqs) - set(freqs))))
510
511 @remote_compatible
512 def test_p2p_autogo_pref_chan_disallowed(dev, apdev):
513 """P2P channel selection: GO preferred channels are disallowed"""
514 try:
515 dev[0].global_request("SET p2p_pref_chan 81:1,81:3,81:6,81:9,81:11")
516 dev[0].global_request("P2P_SET disallow_freq 2412,2422,2437,2452,2462")
517 for i in range(0, 5):
518 res = autogo(dev[0])
519 if res['freq'] in [ "2412", "2422", "2437", "2452", "2462" ]:
520 raise Exception("GO channel is disallowed")
521 dev[0].remove_group(res['ifname'])
522 finally:
523 dev[0].global_request("P2P_SET disallow_freq ")
524 dev[0].global_request("SET p2p_pref_chan ")
525
526 def test_p2p_autogo_pref_chan_not_in_regulatory(dev, apdev):
527 """P2P channel selection: GO preferred channel not allowed in the regulatory rules"""
528 try:
529 set_country("US", dev[0])
530 dev[0].global_request("SET p2p_pref_chan 124:149")
531 res = autogo(dev[0], persistent=True)
532 if res['freq'] != "5745":
533 raise Exception("Unexpected channel selected: " + res['freq'])
534 dev[0].remove_group(res['ifname'])
535
536 netw = dev[0].list_networks(p2p=True)
537 if len(netw) != 1:
538 raise Exception("Unexpected number of network blocks: " + str(netw))
539 id = netw[0]['id']
540
541 set_country("DE", dev[0])
542 res = autogo(dev[0], persistent=id)
543 if res['freq'] == "5745":
544 raise Exception("Unexpected channel selected(2): " + res['freq'])
545 dev[0].remove_group(res['ifname'])
546 finally:
547 dev[0].global_request("SET p2p_pref_chan ")
548 set_country("00")
549
550 def run_autogo(dev, param):
551 if "OK" not in dev.global_request("P2P_GROUP_ADD " + param):
552 raise Exception("P2P_GROUP_ADD failed: " + param)
553 ev = dev.wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
554 if ev is None:
555 raise Exception("GO start up timed out")
556 res = dev.group_form_result(ev)
557 dev.remove_group()
558 return res
559
560 def _test_autogo_ht_vht(dev):
561 res = run_autogo(dev[0], "ht40")
562
563 res = run_autogo(dev[0], "vht")
564
565 res = run_autogo(dev[0], "freq=2")
566 freq = int(res['freq'])
567 if freq < 2412 or freq > 2462:
568 raise Exception("Unexpected freq=2 channel: " + str(freq))
569
570 res = run_autogo(dev[0], "freq=5")
571 freq = int(res['freq'])
572 if freq < 5000 or freq >= 6000:
573 raise Exception("Unexpected freq=5 channel: " + str(freq))
574
575 res = run_autogo(dev[0], "freq=5 ht40 vht")
576 logger.info(str(res))
577 freq = int(res['freq'])
578 if freq < 5000 or freq >= 6000:
579 raise Exception("Unexpected freq=5 ht40 vht channel: " + str(freq))
580
581 def test_autogo_ht_vht(dev):
582 """P2P autonomous GO with HT/VHT parameters"""
583 try:
584 set_country("US", dev[0])
585 _test_autogo_ht_vht(dev)
586 finally:
587 set_country("00")
588
589 def test_p2p_listen_chan_optimize(dev, apdev):
590 """P2P listen channel optimization"""
591 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
592 wpas.interface_add("wlan5")
593 addr5 = wpas.p2p_dev_addr()
594 try:
595 if "OK" not in wpas.global_request("SET p2p_optimize_listen_chan 1"):
596 raise Exception("Failed to set p2p_optimize_listen_chan")
597 wpas.p2p_listen()
598 if not dev[0].discover_peer(addr5):
599 raise Exception("Could not discover peer")
600 peer = dev[0].get_peer(addr5)
601 lfreq = peer['listen_freq']
602 wpas.p2p_stop_find()
603 dev[0].p2p_stop_find()
604
605 channel = "1" if lfreq != '2412' else "6"
606 freq = "2412" if lfreq != '2412' else "2437"
607 params = { "ssid": "test-open", "channel": channel }
608 hapd = hostapd.add_ap(apdev[0], params)
609
610 id = wpas.connect("test-open", key_mgmt="NONE", scan_freq=freq)
611 wpas.p2p_listen()
612
613 if "OK" not in dev[0].global_request("P2P_FLUSH"):
614 raise Exception("P2P_FLUSH failed")
615 if not dev[0].discover_peer(addr5):
616 raise Exception("Could not discover peer")
617 peer = dev[0].get_peer(addr5)
618 lfreq2 = peer['listen_freq']
619 if lfreq == lfreq2:
620 raise Exception("Listen channel did not change")
621 if lfreq2 != freq:
622 raise Exception("Listen channel not on AP's operating channel")
623 wpas.p2p_stop_find()
624 dev[0].p2p_stop_find()
625
626 wpas.request("DISCONNECT")
627 wpas.wait_disconnected()
628
629 # for larger coverage, cover case of current channel matching
630 wpas.select_network(id)
631 wpas.wait_connected()
632 wpas.request("DISCONNECT")
633 wpas.wait_disconnected()
634
635 lchannel = "1" if channel != "1" else "6"
636 lfreq3 = "2412" if channel != "1" else "2437"
637 if "OK" not in wpas.global_request("P2P_SET listen_channel " + lchannel):
638 raise Exception("Failed to set listen channel")
639
640 wpas.select_network(id)
641 wpas.wait_connected()
642 wpas.p2p_listen()
643
644 if "OK" not in dev[0].global_request("P2P_FLUSH"):
645 raise Exception("P2P_FLUSH failed")
646 if not dev[0].discover_peer(addr5):
647 raise Exception("Could not discover peer")
648 peer = dev[0].get_peer(addr5)
649 lfreq4 = peer['listen_freq']
650 if lfreq4 != lfreq3:
651 raise Exception("Unexpected Listen channel after configuration")
652 wpas.p2p_stop_find()
653 dev[0].p2p_stop_find()
654 finally:
655 wpas.global_request("SET p2p_optimize_listen_chan 0")
656
657 def test_p2p_channel_5ghz_only(dev):
658 """P2P GO start with only 5 GHz band allowed"""
659 try:
660 set_country("US", dev[0])
661 dev[0].global_request("P2P_SET disallow_freq 2400-2500")
662 res = autogo(dev[0])
663 freq = int(res['freq'])
664 if freq < 5000:
665 raise Exception("Unexpected channel %d MHz" % freq)
666 dev[0].remove_group()
667 finally:
668 set_country("00")
669 dev[0].global_request("P2P_SET disallow_freq ")
670
671 def test_p2p_channel_5ghz_165_169_us(dev):
672 """P2P GO and 5 GHz channels 165 (allowed) and 169 (disallowed) in US"""
673 try:
674 set_country("US", dev[0])
675 res = dev[0].p2p_start_go(freq=5825)
676 if res['freq'] != "5825":
677 raise Exception("Unexpected frequency: " + res['freq'])
678 dev[0].remove_group()
679
680 res = dev[0].global_request("P2P_GROUP_ADD freq=5845")
681 if "FAIL" not in res:
682 raise Exception("GO on channel 169 allowed unexpectedly")
683 finally:
684 set_country("00")
685
686 def wait_go_down_up(dev):
687 ev = dev.wait_group_event(["AP-DISABLED"], timeout=5)
688 if ev is None:
689 raise Exception("AP-DISABLED not seen after P2P-REMOVE-AND-REFORM-GROUP")
690 ev = dev.wait_group_event(["AP-ENABLED"], timeout=5)
691 if ev is None:
692 raise Exception("AP-ENABLED not seen after P2P-REMOVE-AND-REFORM-GROUP")
693
694 def test_p2p_go_move_reg_change(dev, apdev):
695 """P2P GO move due to regulatory change"""
696 try:
697 set_country("US")
698 dev[0].global_request("P2P_SET disallow_freq 2400-5000")
699 res = autogo(dev[0])
700 freq1 = int(res['freq'])
701 if freq1 < 5000:
702 raise Exception("Unexpected channel %d MHz" % freq1)
703
704 dev[0].global_request("P2P_SET disallow_freq ")
705
706 # GO move is not allowed while waiting for initial client connection
707 connect_cli(dev[0], dev[1], freq=freq1)
708 dev[1].remove_group()
709
710 freq = dev[0].get_group_status_field('freq')
711 if int(freq) < 5000:
712 raise Exception("Unexpected freq after initial client: " + freq)
713 dev[0].dump_monitor()
714
715 set_country("00")
716 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
717 "AP-CSA-FINISHED"],
718 timeout=10)
719 if ev is None:
720 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
721 if "P2P-REMOVE-AND-REFORM-GROUP" in ev:
722 wait_go_down_up(dev[0])
723
724 freq2 = dev[0].get_group_status_field('freq')
725 if freq1 == freq2:
726 raise Exception("Unexpected freq after group reform=" + freq2)
727
728 dev[0].remove_group()
729 finally:
730 dev[0].global_request("P2P_SET disallow_freq ")
731 set_country("00")
732
733 def test_p2p_go_move_active(dev, apdev):
734 """P2P GO stays in freq although SCM is possible"""
735 with HWSimRadio(n_channels=2) as (radio, iface):
736 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
737 wpas.interface_add(iface)
738
739 if wpas.get_mcc() < 2:
740 raise Exception("New radio does not support MCC")
741
742 ndev = [ wpas, dev[1] ]
743 _test_p2p_go_move_active(ndev, apdev)
744
745 def _test_p2p_go_move_active(dev, apdev):
746 dev[0].global_request("SET p2p_no_group_iface 0")
747 try:
748 dev[0].global_request("P2P_SET disallow_freq 2430-6000")
749 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
750 "channel" : '11' })
751 dev[0].connect("ap-test", key_mgmt="NONE",
752 scan_freq="2462")
753
754 res = autogo(dev[0])
755 freq = int(res['freq'])
756 if freq > 2430:
757 raise Exception("Unexpected channel %d MHz" % freq)
758
759 # GO move is not allowed while waiting for initial client connection
760 connect_cli(dev[0], dev[1], freq=freq)
761 dev[1].remove_group()
762
763 freq = dev[0].get_group_status_field('freq')
764 if int(freq) > 2430:
765 raise Exception("Unexpected freq after initial client: " + freq)
766
767 dev[0].dump_monitor()
768 dev[0].global_request("P2P_SET disallow_freq ")
769
770 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
771 "AP-CSA-FINISHED"],
772 timeout=10)
773 if ev is not None:
774 raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED seen")
775
776 dev[0].remove_group()
777 finally:
778 dev[0].global_request("P2P_SET disallow_freq ")
779
780 def test_p2p_go_move_scm(dev, apdev):
781 """P2P GO move due to SCM operation preference"""
782 with HWSimRadio(n_channels=2) as (radio, iface):
783 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
784 wpas.interface_add(iface)
785
786 if wpas.get_mcc() < 2:
787 raise Exception("New radio does not support MCC")
788
789 ndev = [ wpas, dev[1] ]
790 _test_p2p_go_move_scm(ndev, apdev)
791
792 def _test_p2p_go_move_scm(dev, apdev):
793 dev[0].global_request("SET p2p_no_group_iface 0")
794 try:
795 dev[0].global_request("P2P_SET disallow_freq 2430-6000")
796 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
797 "channel" : '11' })
798 dev[0].connect("ap-test", key_mgmt="NONE",
799 scan_freq="2462")
800
801 dev[0].global_request("SET p2p_go_freq_change_policy 0")
802 res = autogo(dev[0])
803 freq = int(res['freq'])
804 if freq > 2430:
805 raise Exception("Unexpected channel %d MHz" % freq)
806
807 # GO move is not allowed while waiting for initial client connection
808 connect_cli(dev[0], dev[1], freq=freq)
809 dev[1].remove_group()
810
811 freq = dev[0].get_group_status_field('freq')
812 if int(freq) > 2430:
813 raise Exception("Unexpected freq after initial client: " + freq)
814
815 dev[0].dump_monitor()
816 dev[0].global_request("P2P_SET disallow_freq ")
817
818 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
819 "AP-CSA-FINISHED"], timeout=3)
820 if ev is None:
821 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
822 if "P2P-REMOVE-AND-REFORM-GROUP" in ev:
823 wait_go_down_up(dev[0])
824
825 freq = dev[0].get_group_status_field('freq')
826 if freq != '2462':
827 raise Exception("Unexpected freq after group reform=" + freq)
828
829 dev[0].remove_group()
830 finally:
831 dev[0].global_request("P2P_SET disallow_freq ")
832 dev[0].global_request("SET p2p_go_freq_change_policy 2")
833
834 def test_p2p_go_move_scm_peer_supports(dev, apdev):
835 """P2P GO move due to SCM operation preference (peer supports)"""
836 with HWSimRadio(n_channels=2) as (radio, iface):
837 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
838 wpas.interface_add(iface)
839
840 if wpas.get_mcc() < 2:
841 raise Exception("New radio does not support MCC")
842
843 ndev = [ wpas, dev[1] ]
844 _test_p2p_go_move_scm_peer_supports(ndev, apdev)
845
846 def _test_p2p_go_move_scm_peer_supports(dev, apdev):
847 try:
848 dev[0].global_request("SET p2p_go_freq_change_policy 1")
849 set_country("US", dev[0])
850
851 dev[0].global_request("SET p2p_no_group_iface 0")
852 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
853 r_dev=dev[1], r_intent=0,
854 test_data=False)
855 check_grpform_results(i_res, r_res)
856 freq = int(i_res['freq'])
857 if freq < 5000:
858 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
859
860 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
861 "channel" : '11' })
862 logger.info('Connecting client to to an AP on channel 11');
863 dev[0].connect("ap-test", key_mgmt="NONE",
864 scan_freq="2462")
865
866 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
867 "AP-CSA-FINISHED"], timeout=3)
868 if ev is None:
869 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
870 if "P2P-REMOVE-AND-REFORM-GROUP" in ev:
871 wait_go_down_up(dev[0])
872
873 freq = dev[0].get_group_status_field('freq')
874 if freq != '2462':
875 raise Exception("Unexpected freq after group reform=" + freq)
876
877 dev[0].remove_group()
878 finally:
879 dev[0].global_request("SET p2p_go_freq_change_policy 2")
880 set_country("00")
881
882 def test_p2p_go_move_scm_peer_does_not_support(dev, apdev):
883 """No P2P GO move due to SCM operation (peer does not supports)"""
884 with HWSimRadio(n_channels=2) as (radio, iface):
885 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
886 wpas.interface_add(iface)
887
888 if wpas.get_mcc() < 2:
889 raise Exception("New radio does not support MCC")
890
891 ndev = [ wpas, dev[1] ]
892 _test_p2p_go_move_scm_peer_does_not_support(ndev, apdev)
893
894 def _test_p2p_go_move_scm_peer_does_not_support(dev, apdev):
895 try:
896 dev[0].global_request("SET p2p_go_freq_change_policy 1")
897 set_country("US", dev[0])
898
899 dev[0].global_request("SET p2p_no_group_iface 0")
900 if "OK" not in dev[1].request("DRIVER_EVENT AVOID_FREQUENCIES 2400-2500"):
901 raise Exception("Could not simulate driver event")
902 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
903 r_dev=dev[1], r_intent=0,
904 test_data=False)
905 check_grpform_results(i_res, r_res)
906 freq = int(i_res['freq'])
907 if freq < 5000:
908 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
909
910 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test',
911 "channel" : '11' })
912 logger.info('Connecting client to to an AP on channel 11');
913 dev[0].connect("ap-test", key_mgmt="NONE",
914 scan_freq="2462")
915
916 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
917 "AP-CSA-FINISHED"],
918 timeout=10)
919 if ev is not None:
920 raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED seen")
921
922 dev[0].remove_group()
923 finally:
924 dev[0].global_request("SET p2p_go_freq_change_policy 2")
925 dev[1].request("DRIVER_EVENT AVOID_FREQUENCIES")
926 set_country("00")
927
928 def test_p2p_go_move_scm_multi(dev, apdev):
929 """P2P GO move due to SCM operation preference multiple times"""
930 with HWSimRadio(n_channels=2) as (radio, iface):
931 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
932 wpas.interface_add(iface)
933
934 if wpas.get_mcc() < 2:
935 raise Exception("New radio does not support MCC")
936
937 ndev = [ wpas, dev[1] ]
938 _test_p2p_go_move_scm_multi(ndev, apdev)
939
940 def _test_p2p_go_move_scm_multi(dev, apdev):
941 dev[0].request("SET p2p_no_group_iface 0")
942 try:
943 dev[0].global_request("P2P_SET disallow_freq 2430-6000")
944 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test-1',
945 "channel" : '11' })
946 dev[0].connect("ap-test-1", key_mgmt="NONE",
947 scan_freq="2462")
948
949 dev[0].global_request("SET p2p_go_freq_change_policy 0")
950 res = autogo(dev[0])
951 freq = int(res['freq'])
952 if freq > 2430:
953 raise Exception("Unexpected channel %d MHz" % freq)
954
955 # GO move is not allowed while waiting for initial client connection
956 connect_cli(dev[0], dev[1], freq=freq)
957 dev[1].remove_group()
958
959 freq = dev[0].get_group_status_field('freq')
960 if int(freq) > 2430:
961 raise Exception("Unexpected freq after initial client: " + freq)
962
963 dev[0].dump_monitor()
964 dev[0].global_request("P2P_SET disallow_freq ")
965
966 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
967 "AP-CSA-FINISHED"], timeout=3)
968 if ev is None:
969 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
970 if "P2P-REMOVE-AND-REFORM-GROUP" in ev:
971 wait_go_down_up(dev[0])
972
973 freq = dev[0].get_group_status_field('freq')
974 if freq != '2462':
975 raise Exception("Unexpected freq after group reform=" + freq)
976
977 hapd = hostapd.add_ap(apdev[0], { "ssid" : 'ap-test-2',
978 "channel" : '6' })
979 dev[0].connect("ap-test-2", key_mgmt="NONE",
980 scan_freq="2437")
981
982 ev = dev[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
983 "AP-CSA-FINISHED"], timeout=5)
984 if ev is None:
985 raise Exception("(2) P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
986 if "P2P-REMOVE-AND-REFORM-GROUP" in ev:
987 wait_go_down_up(dev[0])
988
989 freq = dev[0].get_group_status_field('freq')
990 if freq != '2437':
991 raise Exception("(2) Unexpected freq after group reform=" + freq)
992
993 dev[0].remove_group()
994 finally:
995 dev[0].global_request("P2P_SET disallow_freq ")
996 dev[0].global_request("SET p2p_go_freq_change_policy 2")
997
998 def test_p2p_delay_go_csa(dev, apdev, params):
999 """P2P GO CSA delayed when inviting a P2P Device to an active P2P Group"""
1000 with HWSimRadio(n_channels=2) as (radio, iface):
1001 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
1002 wpas.interface_add(iface)
1003
1004 wpas.global_request("SET p2p_no_group_iface 0")
1005
1006 if wpas.get_mcc() < 2:
1007 raise Exception("New radio does not support MCC")
1008
1009 addr0 = wpas.p2p_dev_addr()
1010 addr1 = dev[1].p2p_dev_addr()
1011
1012 try:
1013 dev[1].p2p_listen();
1014 if not wpas.discover_peer(addr1, social=True):
1015 raise Exception("Peer " + addr1 + " not found")
1016 wpas.p2p_stop_find()
1017
1018 hapd = hostapd.add_ap(apdev[0], { "ssid": 'bss-2.4ghz',
1019 "channel": '1' })
1020
1021 wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
1022
1023 wpas.global_request("SET p2p_go_freq_change_policy 0")
1024 wpas.dump_monitor()
1025
1026 logger.info("Start GO on channel 6")
1027 res = autogo(wpas, freq=2437)
1028 if res['freq'] != "2437":
1029 raise Exception("GO set on a freq=%s instead of 2437" % res['freq'])
1030
1031 # Start find on dev[1] to run scans with dev[2] in parallel
1032 dev[1].p2p_find(social=True)
1033
1034 # Use another client device to stop the initial client connection
1035 # timeout on the GO
1036 if not dev[2].discover_peer(addr0, social=True):
1037 raise Exception("Peer2 did not find the GO")
1038 dev[2].p2p_stop_find()
1039 pin = dev[2].wps_read_pin()
1040 wpas.p2p_go_authorize_client(pin)
1041 dev[2].global_request("P2P_CONNECT " + addr0 + " " + pin + " join freq=2437")
1042 ev = dev[2].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
1043 if ev is None:
1044 raise Exception("Peer2 did not get connected")
1045
1046 if not dev[1].discover_peer(addr0, social=True):
1047 raise Exception("Peer did not find the GO")
1048
1049 pin = dev[1].wps_read_pin()
1050 dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join auth")
1051 dev[1].p2p_listen();
1052
1053 # Force P2P GO channel switch on successful invitation signaling
1054 wpas.group_request("SET p2p_go_csa_on_inv 1")
1055
1056 logger.info("Starting invitation")
1057 wpas.p2p_go_authorize_client(pin)
1058 wpas.global_request("P2P_INVITE group=" + wpas.group_ifname + " peer=" + addr1)
1059 ev = dev[1].wait_global_event(["P2P-INVITATION-RECEIVED",
1060 "P2P-GROUP-STARTED"], timeout=10)
1061
1062 if ev is None:
1063 raise Exception("Timeout on invitation on peer")
1064 if "P2P-INVITATION-RECEIVED" in ev:
1065 raise Exception("Unexpected request to accept pre-authorized invitation")
1066
1067 # A P2P GO move is not expected at this stage, as during the
1068 # invitation signaling, the P2P GO includes only its current
1069 # operating channel in the channel list, and as the invitation
1070 # response can only include channels that were also in the
1071 # invitation request channel list, the group common channels
1072 # includes only the current P2P GO operating channel.
1073 ev = wpas.wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
1074 "AP-CSA-FINISHED"], timeout=1)
1075 if ev is not None:
1076 raise Exception("Unexpected + " + ev + " event")
1077
1078 finally:
1079 wpas.global_request("SET p2p_go_freq_change_policy 2")
1080
1081 def test_p2p_channel_vht80p80(dev):
1082 """P2P group formation and VHT 80+80 MHz channel"""
1083 try:
1084 set_country("US", dev[0])
1085 [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
1086 i_freq=5180,
1087 i_freq2=5775,
1088 i_max_oper_chwidth=160,
1089 i_ht40=True, i_vht=True,
1090 r_dev=dev[1], r_intent=0,
1091 test_data=False)
1092 check_grpform_results(i_res, r_res)
1093 freq = int(i_res['freq'])
1094 if freq < 5000:
1095 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
1096 sig = dev[1].group_request("SIGNAL_POLL").splitlines()
1097 if "FREQUENCY=5180" not in sig:
1098 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
1099 if "WIDTH=80+80 MHz" not in sig:
1100 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
1101 if "CENTER_FRQ1=5210" not in sig:
1102 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
1103 if "CENTER_FRQ2=5775" not in sig:
1104 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
1105 remove_group(dev[0], dev[1])
1106 finally:
1107 set_country("00")
1108 dev[1].flush_scan_cache()
1109
1110 def test_p2p_channel_vht80p80_autogo(dev):
1111 """P2P autonomous GO and VHT 80+80 MHz channel"""
1112 addr0 = dev[0].p2p_dev_addr()
1113
1114 try:
1115 set_country("US", dev[0])
1116 if "OK" not in dev[0].global_request("P2P_GROUP_ADD vht freq=5180 freq2=5775"):
1117 raise Exception("Could not start GO")
1118 ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
1119 if ev is None:
1120 raise Exception("GO start up timed out")
1121 dev[0].group_form_result(ev)
1122
1123 pin = dev[1].wps_read_pin()
1124 dev[0].p2p_go_authorize_client(pin)
1125
1126 dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join freq=5180")
1127 ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
1128 if ev is None:
1129 raise Exception("Peer did not get connected")
1130
1131 dev[1].group_form_result(ev)
1132 sig = dev[1].group_request("SIGNAL_POLL").splitlines()
1133 if "FREQUENCY=5180" not in sig:
1134 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
1135 if "WIDTH=80+80 MHz" not in sig:
1136 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
1137 if "CENTER_FRQ1=5210" not in sig:
1138 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
1139 if "CENTER_FRQ2=5775" not in sig:
1140 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
1141 remove_group(dev[0], dev[1])
1142 finally:
1143 set_country("00")
1144 dev[1].flush_scan_cache()
1145
1146 def test_p2p_channel_vht80_autogo(dev):
1147 """P2P autonomous GO and VHT 80 MHz channel"""
1148 addr0 = dev[0].p2p_dev_addr()
1149
1150 try:
1151 set_country("US", dev[0])
1152 if "OK" not in dev[0].global_request("P2P_GROUP_ADD vht freq=5180 max_oper_chwidth=80"):
1153 raise Exception("Could not start GO")
1154 ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=5)
1155 if ev is None:
1156 raise Exception("GO start up timed out")
1157 dev[0].group_form_result(ev)
1158
1159 pin = dev[1].wps_read_pin()
1160 dev[0].p2p_go_authorize_client(pin)
1161
1162 dev[1].global_request("P2P_CONNECT " + addr0 + " " + pin + " join freq=5180")
1163 ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=10)
1164 if ev is None:
1165 raise Exception("Peer did not get connected")
1166
1167 dev[1].group_form_result(ev)
1168 sig = dev[1].group_request("SIGNAL_POLL").splitlines()
1169 if "FREQUENCY=5180" not in sig:
1170 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
1171 if "WIDTH=80 MHz" not in sig:
1172 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
1173 remove_group(dev[0], dev[1])
1174 finally:
1175 set_country("00")
1176 dev[1].flush_scan_cache()
1177
1178 def test_p2p_channel_vht80p80_persistent(dev):
1179 """P2P persistent group re-invocation and VHT 80+80 MHz channel"""
1180 addr0 = dev[0].p2p_dev_addr()
1181 form(dev[0], dev[1])
1182
1183 try:
1184 set_country("US", dev[0])
1185 invite(dev[0], dev[1], extra="vht freq=5745 freq2=5210")
1186 [go_res, cli_res] = check_result(dev[0], dev[1])
1187
1188 sig = dev[1].group_request("SIGNAL_POLL").splitlines()
1189 if "FREQUENCY=5745" not in sig:
1190 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig))
1191 if "WIDTH=80+80 MHz" not in sig:
1192 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig))
1193 if "CENTER_FRQ1=5775" not in sig:
1194 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig))
1195 if "CENTER_FRQ2=5210" not in sig:
1196 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig))
1197 remove_group(dev[0], dev[1])
1198 finally:
1199 set_country("00")
1200 dev[1].flush_scan_cache()