]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_p2p_channel.py
1 # P2P channel selection test cases
2 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
7 from remotehost
import remote_compatible
9 logger
= logging
.getLogger()
16 from tshark
import run_tshark
17 from wpasupplicant
import WpaSupplicant
18 from hwsim
import HWSimRadio
19 from p2p_utils
import *
20 from utils
import clear_regdom_dev
22 def set_country(country
, dev
=None):
23 subprocess
.call(['iw', 'reg', 'set', country
])
27 ev
= dev
.wait_global_event(["CTRL-EVENT-REGDOM-CHANGE"], timeout
=15)
29 raise Exception("No regdom change event seen")
30 if "type=COUNTRY alpha2=" + country
in ev
:
32 raise Exception("No matching regdom event seen for set_country(%s)" % country
)
34 def test_p2p_channel_5ghz(dev
):
35 """P2P group formation with 5 GHz preference"""
37 set_country("US", dev
[0])
38 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
39 r_dev
=dev
[1], r_intent
=0,
41 check_grpform_results(i_res
, r_res
)
42 freq
= int(i_res
['freq'])
44 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
45 remove_group(dev
[0], dev
[1])
48 dev
[1].flush_scan_cache()
50 def test_p2p_channel_5ghz_no_vht(dev
):
51 """P2P group formation with 5 GHz preference when VHT channels are disallowed"""
53 set_country("US", dev
[0])
54 dev
[0].global_request("P2P_SET disallow_freq 5180-5240")
55 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
56 r_dev
=dev
[1], r_intent
=0,
58 check_grpform_results(i_res
, r_res
)
59 freq
= int(i_res
['freq'])
61 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
62 remove_group(dev
[0], dev
[1])
65 dev
[0].global_request("P2P_SET disallow_freq ")
66 dev
[1].flush_scan_cache()
68 def test_p2p_channel_random_social(dev
):
69 """P2P group formation with 5 GHz preference but all 5 GHz channels disabled"""
71 set_country("US", dev
[0])
72 dev
[0].global_request("SET p2p_oper_channel 11")
73 dev
[0].global_request("P2P_SET disallow_freq 5000-6000,2462")
74 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
75 r_dev
=dev
[1], r_intent
=0,
77 check_grpform_results(i_res
, r_res
)
78 freq
= int(i_res
['freq'])
79 if freq
not in [2412, 2437, 2462]:
80 raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq
)
81 remove_group(dev
[0], dev
[1])
84 dev
[0].global_request("P2P_SET disallow_freq ")
85 dev
[1].flush_scan_cache()
87 def test_p2p_channel_random(dev
):
88 """P2P group formation with 5 GHz preference but all 5 GHz channels and all social channels disabled"""
90 set_country("US", dev
[0])
91 dev
[0].global_request("SET p2p_oper_channel 11")
92 dev
[0].global_request("P2P_SET disallow_freq 5000-6000,2412,2437,2462")
93 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
94 r_dev
=dev
[1], r_intent
=0,
96 check_grpform_results(i_res
, r_res
)
97 freq
= int(i_res
['freq'])
98 if freq
> 2500 or freq
in [2412, 2437, 2462]:
99 raise Exception("Unexpected channel %d MHz" % freq
)
100 remove_group(dev
[0], dev
[1])
103 dev
[0].global_request("P2P_SET disallow_freq ")
104 dev
[1].flush_scan_cache()
106 def test_p2p_channel_random_social_with_op_class_change(dev
, apdev
, params
):
107 """P2P group formation using random social channel with oper class change needed"""
109 set_country("US", dev
[0])
110 logger
.info("Start group on 5 GHz")
111 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
112 r_dev
=dev
[1], r_intent
=0,
114 check_grpform_results(i_res
, r_res
)
115 freq
= int(i_res
['freq'])
117 raise Exception("Unexpected channel %d MHz - did not pick 5 GHz preference" % freq
)
118 remove_group(dev
[0], dev
[1])
120 logger
.info("Disable 5 GHz and try to re-start group based on 5 GHz preference")
121 dev
[0].global_request("SET p2p_oper_reg_class 115")
122 dev
[0].global_request("SET p2p_oper_channel 36")
123 dev
[0].global_request("P2P_SET disallow_freq 5000-6000")
124 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
125 r_dev
=dev
[1], r_intent
=0,
127 check_grpform_results(i_res
, r_res
)
128 freq
= int(i_res
['freq'])
129 if freq
not in [2412, 2437, 2462]:
130 raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq
)
131 remove_group(dev
[0], dev
[1])
133 out
= run_tshark(os
.path
.join(params
['logdir'], "hwsim0.pcapng"),
134 "wifi_p2p.public_action.subtype == 0")
137 for l
in out
.splitlines():
138 if "Operating Channel:" not in l
:
142 raise Exception("Could not find GO Negotiation Request")
143 if "Operating Class 81" not in last
:
144 raise Exception("Unexpected operating class: " + last
.strip())
147 dev
[0].global_request("P2P_SET disallow_freq ")
148 dev
[0].global_request("SET p2p_oper_reg_class 0")
149 dev
[0].global_request("SET p2p_oper_channel 0")
150 dev
[1].flush_scan_cache()
152 def test_p2p_channel_avoid(dev
):
153 """P2P and avoid frequencies driver event"""
155 set_country("US", dev
[0])
156 if "OK" not in dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES 5000-6000,2412,2437,2462"):
157 raise Exception("Could not simulate driver event")
158 ev
= dev
[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout
=10)
160 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
161 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
162 r_dev
=dev
[1], r_intent
=0,
164 check_grpform_results(i_res
, r_res
)
165 freq
= int(i_res
['freq'])
166 if freq
> 2500 or freq
in [2412, 2437, 2462]:
167 raise Exception("Unexpected channel %d MHz" % freq
)
169 if "OK" not in dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES"):
170 raise Exception("Could not simulate driver event(2)")
171 ev
= dev
[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout
=10)
173 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
174 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
175 "AP-CSA-FINISHED"], timeout
=1)
177 raise Exception("Unexpected + " + ev
+ " event")
179 if "OK" not in dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES " + str(freq
)):
180 raise Exception("Could not simulate driver event(3)")
181 ev
= dev
[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout
=10)
183 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
184 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
188 raise Exception("No P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED event")
191 dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
192 dev
[1].flush_scan_cache()
194 def test_p2p_channel_avoid2(dev
):
195 """P2P and avoid frequencies driver event on 5 GHz"""
197 set_country("US", dev
[0])
198 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
199 r_dev
=dev
[1], r_intent
=0,
201 i_max_oper_chwidth
=80,
202 i_ht40
=True, i_vht
=True)
203 check_grpform_results(i_res
, r_res
)
204 freq
= int(i_res
['freq'])
206 raise Exception("Unexpected channel %d MHz" % freq
)
208 if "OK" not in dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES " + str(freq
)):
209 raise Exception("Could not simulate driver event(2)")
210 ev
= dev
[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout
=10)
212 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
213 ev
= dev
[0].wait_group_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=10)
215 raise Exception("No channel switch event seen")
216 if "ch_width=80 MHz" not in ev
:
217 raise Exception("Could not move to a VHT80 channel")
218 ev
= dev
[0].wait_group_event(["AP-CSA-FINISHED"], timeout
=1)
220 raise Exception("No AP-CSA-FINISHED event seen")
223 dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
224 dev
[1].flush_scan_cache()
226 def test_p2p_channel_avoid3(dev
):
227 """P2P and avoid frequencies driver event on 5 GHz"""
229 set_country("CN", dev
[0])
231 set_country("CN", dev
[0])
232 [i_res
, r_res
] = invite_from_go(dev
[0], dev
[1], terminate
=False,
234 freq
= int(i_res
['freq'])
236 raise Exception("Unexpected channel %d MHz" % freq
)
238 if "OK" not in dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES 5180-5320,5500-5640"):
239 raise Exception("Could not simulate driver event(2)")
240 ev
= dev
[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout
=10)
242 raise Exception("No CTRL-EVENT-AVOID-FREQ event")
243 ev
= dev
[0].wait_group_event(["CTRL-EVENT-CHANNEL-SWITCH"], timeout
=10)
245 raise Exception("No channel switch event seen")
246 if "ch_width=80 MHz" not in ev
:
247 raise Exception("Could not move to a VHT80 channel")
248 ev
= dev
[0].wait_group_event(["AP-CSA-FINISHED"], timeout
=1)
250 raise Exception("No AP-CSA-FINISHED event seen")
253 dev
[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
254 dev
[1].flush_scan_cache()
257 def test_autogo_following_bss(dev
, apdev
):
258 """P2P autonomous GO operate on the same channel as station interface"""
259 if dev
[0].get_mcc() > 1:
260 logger
.info("test mode: MCC")
262 dev
[0].global_request("SET p2p_no_group_iface 0")
264 channels
= {3: "2422", 5: "2432", 9: "2452"}
266 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test',
267 "channel": str(key
)})
268 dev
[0].connect("ap-test", key_mgmt
="NONE",
269 scan_freq
=str(channels
[key
]))
270 res_go
= autogo(dev
[0])
271 if res_go
['freq'] != channels
[key
]:
272 raise Exception("Group operation channel is not the same as on connected station interface")
273 hwsim_utils
.test_connectivity(dev
[0], hapd
)
274 dev
[0].remove_group(res_go
['ifname'])
277 def test_go_neg_with_bss_connected(dev
, apdev
):
278 """P2P channel selection: GO negotiation when station interface is connected"""
280 dev
[0].flush_scan_cache()
281 dev
[1].flush_scan_cache()
282 dev
[0].global_request("SET p2p_no_group_iface 0")
284 hapd
= hostapd
.add_ap(apdev
[0],
285 {"ssid": 'bss-2.4ghz', "channel": '5'})
286 dev
[0].connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2432")
288 [i_res
, r_res
] = go_neg_pbc(i_dev
=dev
[0], i_intent
=10, r_dev
=dev
[1],
290 check_grpform_results(i_res
, r_res
)
291 if i_res
['role'] != "GO":
292 raise Exception("GO not selected according to go_intent")
293 if i_res
['freq'] != "2432":
294 raise Exception("Group formed on a different frequency than BSS")
295 hwsim_utils
.test_connectivity(dev
[0], hapd
)
296 dev
[0].remove_group(i_res
['ifname'])
297 dev
[1].wait_go_ending_session()
299 if dev
[0].get_mcc() > 1:
300 logger
.info("Skip as-client case due to MCC being enabled")
304 [i_res2
, r_res2
] = go_neg_pbc(i_dev
=dev
[0], i_intent
=1, r_dev
=dev
[1],
306 check_grpform_results(i_res2
, r_res2
)
307 if i_res2
['role'] != "client":
308 raise Exception("GO not selected according to go_intent")
309 if i_res2
['freq'] != "2432":
310 raise Exception("Group formed on a different frequency than BSS")
311 hwsim_utils
.test_connectivity(dev
[0], hapd
)
312 dev
[1].remove_group(r_res2
['ifname'])
313 dev
[0].wait_go_ending_session()
314 dev
[0].request("DISCONNECT")
316 dev
[0].flush_scan_cache()
317 dev
[1].flush_scan_cache()
319 def test_autogo_with_bss_on_disallowed_chan(dev
, apdev
):
320 """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
322 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
323 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
324 wpas
.interface_add(iface
)
326 wpas
.global_request("SET p2p_no_group_iface 0")
328 if wpas
.get_mcc() < 2:
329 raise Exception("New radio does not support MCC")
332 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'bss-2.4ghz',
334 wpas
.global_request("P2P_SET disallow_freq 2412")
335 wpas
.connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2412")
337 if res
['freq'] == "2412":
338 raise Exception("GO set on a disallowed channel")
339 hwsim_utils
.test_connectivity(wpas
, hapd
)
341 wpas
.global_request("P2P_SET disallow_freq ")
343 def test_go_neg_with_bss_on_disallowed_chan(dev
, apdev
):
344 """P2P channel selection: GO negotiation with station interface on a disallowed channel"""
346 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
347 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
348 wpas
.interface_add(iface
)
350 wpas
.global_request("SET p2p_no_group_iface 0")
352 if wpas
.get_mcc() < 2:
353 raise Exception("New radio does not support MCC")
356 hapd
= hostapd
.add_ap(apdev
[0],
357 {"ssid": 'bss-2.4ghz', "channel": '1'})
358 # make sure PBC overlap from old test cases is not maintained
359 dev
[1].flush_scan_cache()
360 wpas
.connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2412")
361 wpas
.global_request("P2P_SET disallow_freq 2412")
364 [i_res
, r_res
] = go_neg_pbc(i_dev
=wpas
, i_intent
=10, r_dev
=dev
[1],
366 check_grpform_results(i_res
, r_res
)
367 if i_res
['role'] != "GO":
368 raise Exception("GO not selected according to go_intent")
369 if i_res
['freq'] == "2412":
370 raise Exception("Group formed on a disallowed channel")
371 hwsim_utils
.test_connectivity(wpas
, hapd
)
372 wpas
.remove_group(i_res
['ifname'])
373 dev
[1].wait_go_ending_session()
374 dev
[1].flush_scan_cache()
377 dev
[1].dump_monitor()
380 [i_res2
, r_res2
] = go_neg_pbc(i_dev
=wpas
, i_intent
=1, r_dev
=dev
[1],
382 check_grpform_results(i_res2
, r_res2
)
383 if i_res2
['role'] != "client":
384 raise Exception("GO not selected according to go_intent")
385 if i_res2
['freq'] == "2412":
386 raise Exception("Group formed on a disallowed channel")
387 hwsim_utils
.test_connectivity(wpas
, hapd
)
388 dev
[1].remove_group(r_res2
['ifname'])
389 wpas
.wait_go_ending_session()
390 ev
= dev
[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout
=5)
392 raise Exception("Group removal not indicated")
393 wpas
.request("DISCONNECT")
396 wpas
.global_request("P2P_SET disallow_freq ")
398 def test_autogo_force_diff_channel(dev
, apdev
):
399 """P2P autonomous GO and station interface operate on different channels"""
400 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
401 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
402 wpas
.interface_add(iface
)
404 if wpas
.get_mcc() < 2:
405 raise Exception("New radio does not support MCC")
407 wpas
.global_request("SET p2p_no_group_iface 0")
409 hapd
= hostapd
.add_ap(apdev
[0],
410 {"ssid": 'ap-test', "channel": '1'})
411 wpas
.connect("ap-test", key_mgmt
="NONE", scan_freq
="2412")
413 channels
= {2: 2417, 5: 2432, 9: 2452}
415 res_go
= autogo(wpas
, channels
[key
])
417 hwsim_utils
.test_connectivity(wpas
, hapd
)
418 if int(res_go
['freq']) == 2412:
419 raise Exception("Group operation channel is: 2412 excepted: " + res_go
['freq'])
420 wpas
.remove_group(res_go
['ifname'])
423 def test_go_neg_forced_freq_diff_than_bss_freq(dev
, apdev
):
424 """P2P channel selection: GO negotiation with forced freq different than station interface"""
425 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
426 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
427 wpas
.interface_add(iface
)
429 if wpas
.get_mcc() < 2:
430 raise Exception("New radio does not support MCC")
432 # Clear possible PBC session overlap from previous test case
433 dev
[1].flush_scan_cache()
435 wpas
.global_request("SET p2p_no_group_iface 0")
437 hapd
= hostapd
.add_ap(apdev
[0],
438 {"country_code": 'US',
439 "ssid": 'bss-5ghz', "hw_mode": 'a',
441 wpas
.connect("bss-5ghz", key_mgmt
="NONE", scan_freq
="5200")
443 # GO and peer force the same freq, different than BSS freq,
445 [i_res
, r_res
] = go_neg_pbc(i_dev
=dev
[1], i_intent
=1, i_freq
=5180,
446 r_dev
=wpas
, r_intent
=14, r_freq
=5180)
447 check_grpform_results(i_res
, r_res
)
448 if i_res
['freq'] != "5180":
449 raise Exception("P2P group formed on unexpected frequency: " + i_res
['freq'])
450 if r_res
['role'] != "GO":
451 raise Exception("GO not selected according to go_intent")
452 hwsim_utils
.test_connectivity(wpas
, hapd
)
453 wpas
.remove_group(r_res
['ifname'])
454 dev
[1].wait_go_ending_session()
455 dev
[1].flush_scan_cache()
457 # GO and peer force the same freq, different than BSS freq, wpas to
459 [i_res2
, r_res2
] = go_neg_pbc(i_dev
=dev
[1], i_intent
=14, i_freq
=2422,
460 r_dev
=wpas
, r_intent
=1, r_freq
=2422)
461 check_grpform_results(i_res2
, r_res2
)
462 if i_res2
['freq'] != "2422":
463 raise Exception("P2P group formed on unexpected frequency: " + i_res2
['freq'])
464 if r_res2
['role'] != "client":
465 raise Exception("GO not selected according to go_intent")
466 hwsim_utils
.test_connectivity(wpas
, hapd
)
468 hapd
.request("DISABLE")
469 wpas
.request("DISCONNECT")
470 wpas
.request("ABORT_SCAN")
471 wpas
.wait_disconnected()
472 subprocess
.call(['iw', 'reg', 'set', '00'])
473 wpas
.flush_scan_cache()
476 def test_go_pref_chan_bss_on_diff_chan(dev
, apdev
):
477 """P2P channel selection: Station on different channel than GO configured pref channel"""
479 dev
[0].global_request("SET p2p_no_group_iface 0")
482 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'bss-2.4ghz',
484 dev
[0].global_request("SET p2p_pref_chan 81:2")
485 dev
[0].connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2412")
487 if res
['freq'] != "2412":
488 raise Exception("GO channel did not follow BSS")
489 hwsim_utils
.test_connectivity(dev
[0], hapd
)
491 dev
[0].global_request("SET p2p_pref_chan ")
493 def test_go_pref_chan_bss_on_disallowed_chan(dev
, apdev
):
494 """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
495 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
496 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
497 wpas
.interface_add(iface
)
499 if wpas
.get_mcc() < 2:
500 raise Exception("New radio does not support MCC")
502 wpas
.global_request("SET p2p_no_group_iface 0")
505 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'bss-2.4ghz',
507 wpas
.global_request("P2P_SET disallow_freq 2412")
508 wpas
.global_request("SET p2p_pref_chan 81:2")
509 wpas
.connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2412")
511 if res2
['freq'] != "2417":
512 raise Exception("GO channel did not follow pref_chan configuration")
513 hwsim_utils
.test_connectivity(wpas
, hapd
)
515 wpas
.global_request("P2P_SET disallow_freq ")
516 wpas
.global_request("SET p2p_pref_chan ")
519 def test_no_go_freq(dev
, apdev
):
520 """P2P channel selection: no GO freq"""
522 dev
[0].global_request("SET p2p_no_go_freq 2412")
523 # dev[0] as client, channel 1 is ok
524 [i_res
, r_res
] = go_neg_pbc(i_dev
=dev
[0], i_intent
=1,
525 r_dev
=dev
[1], r_intent
=14, r_freq
=2412)
526 check_grpform_results(i_res
, r_res
)
527 if i_res
['freq'] != "2412":
528 raise Exception("P2P group not formed on forced freq")
530 dev
[1].remove_group(r_res
['ifname'])
531 dev
[0].wait_go_ending_session()
532 dev
[0].flush_scan_cache()
535 # dev[0] as GO, channel 1 is not allowed
537 dev
[0].global_request("SET p2p_no_go_freq 2412")
538 [i_res2
, r_res2
] = go_neg_pbc(i_dev
=dev
[0], i_intent
=14,
539 r_dev
=dev
[1], r_intent
=1, r_freq
=2412)
540 check_grpform_results(i_res2
, r_res2
)
545 raise Exception("GO set on a disallowed freq")
547 dev
[0].global_request("SET p2p_no_go_freq ")
550 def test_go_neg_peers_force_diff_freq(dev
, apdev
):
551 """P2P channel selection when peers for different frequency"""
553 [i_res2
, r_res2
] = go_neg_pbc(i_dev
=dev
[0], i_intent
=14, i_freq
=5180,
554 r_dev
=dev
[1], r_intent
=0, r_freq
=5200)
555 except Exception as e
:
557 raise Exception("Unexpected group formation success")
560 def test_autogo_random_channel(dev
, apdev
):
561 """P2P channel selection: GO instantiated on random channel 1, 6, 11"""
563 go_freqs
= ["2412", "2437", "2462"]
564 for i
in range(0, 20):
565 result
= autogo(dev
[0])
566 if result
['freq'] not in go_freqs
:
567 raise Exception("Unexpected frequency selected: " + result
['freq'])
568 if result
['freq'] not in freqs
:
569 freqs
.append(result
['freq'])
572 dev
[0].remove_group(result
['ifname'])
574 raise Exception("GO created 20 times and not all social channels were selected. freqs not selected: " + str(list(set(go_freqs
) - set(freqs
))))
577 def test_p2p_autogo_pref_chan_disallowed(dev
, apdev
):
578 """P2P channel selection: GO preferred channels are disallowed"""
580 dev
[0].global_request("SET p2p_pref_chan 81:1,81:3,81:6,81:9,81:11")
581 dev
[0].global_request("P2P_SET disallow_freq 2412,2422,2437,2452,2462")
582 for i
in range(0, 5):
584 if res
['freq'] in ["2412", "2422", "2437", "2452", "2462"]:
585 raise Exception("GO channel is disallowed")
586 dev
[0].remove_group(res
['ifname'])
588 dev
[0].global_request("P2P_SET disallow_freq ")
589 dev
[0].global_request("SET p2p_pref_chan ")
591 def test_p2p_autogo_pref_chan_not_in_regulatory(dev
, apdev
):
592 """P2P channel selection: GO preferred channel not allowed in the regulatory rules"""
594 set_country("US", dev
[0])
595 dev
[0].global_request("SET p2p_pref_chan 124:149")
596 res
= autogo(dev
[0], persistent
=True)
597 if res
['freq'] != "5745":
598 raise Exception("Unexpected channel selected: " + res
['freq'])
599 dev
[0].remove_group(res
['ifname'])
601 netw
= dev
[0].list_networks(p2p
=True)
603 raise Exception("Unexpected number of network blocks: " + str(netw
))
606 set_country("SE", dev
[0])
607 res
= autogo(dev
[0], persistent
=id)
608 if res
['freq'] == "5745":
609 raise Exception("Unexpected channel selected(2): " + res
['freq'])
610 dev
[0].remove_group(res
['ifname'])
612 dev
[0].global_request("SET p2p_pref_chan ")
613 clear_regdom_dev(dev
)
615 def run_autogo(dev
, param
):
616 if "OK" not in dev
.global_request("P2P_GROUP_ADD " + param
):
617 raise Exception("P2P_GROUP_ADD failed: " + param
)
618 ev
= dev
.wait_global_event(["P2P-GROUP-STARTED"], timeout
=10)
620 raise Exception("GO start up timed out")
621 res
= dev
.group_form_result(ev
)
625 def _test_autogo_ht_vht(dev
):
626 res
= run_autogo(dev
[0], "ht40")
628 res
= run_autogo(dev
[0], "vht")
630 res
= run_autogo(dev
[0], "freq=2")
631 freq
= int(res
['freq'])
632 if freq
< 2412 or freq
> 2462:
633 raise Exception("Unexpected freq=2 channel: " + str(freq
))
635 res
= run_autogo(dev
[0], "freq=5")
636 freq
= int(res
['freq'])
637 if freq
< 5000 or freq
>= 6000:
638 raise Exception("Unexpected freq=5 channel: " + str(freq
))
640 res
= run_autogo(dev
[0], "freq=5 ht40 vht")
641 logger
.info(str(res
))
642 freq
= int(res
['freq'])
643 if freq
< 5000 or freq
>= 6000:
644 raise Exception("Unexpected freq=5 ht40 vht channel: " + str(freq
))
646 def test_autogo_ht_vht(dev
):
647 """P2P autonomous GO with HT/VHT parameters"""
649 set_country("US", dev
[0])
650 _test_autogo_ht_vht(dev
)
652 clear_regdom_dev(dev
)
654 def test_p2p_listen_chan_optimize(dev
, apdev
):
655 """P2P listen channel optimization"""
656 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
657 wpas
.interface_add("wlan5")
658 addr5
= wpas
.p2p_dev_addr()
660 if "OK" not in wpas
.global_request("SET p2p_optimize_listen_chan 1"):
661 raise Exception("Failed to set p2p_optimize_listen_chan")
663 if not dev
[0].discover_peer(addr5
):
664 raise Exception("Could not discover peer")
665 peer
= dev
[0].get_peer(addr5
)
666 lfreq
= peer
['listen_freq']
668 dev
[0].p2p_stop_find()
670 channel
= "1" if lfreq
!= '2412' else "6"
671 freq
= "2412" if lfreq
!= '2412' else "2437"
672 params
= {"ssid": "test-open", "channel": channel
}
673 hapd
= hostapd
.add_ap(apdev
[0], params
)
675 id = wpas
.connect("test-open", key_mgmt
="NONE", scan_freq
=freq
)
678 if "OK" not in dev
[0].global_request("P2P_FLUSH"):
679 raise Exception("P2P_FLUSH failed")
680 if not dev
[0].discover_peer(addr5
):
681 raise Exception("Could not discover peer")
682 peer
= dev
[0].get_peer(addr5
)
683 lfreq2
= peer
['listen_freq']
685 raise Exception("Listen channel did not change")
687 raise Exception("Listen channel not on AP's operating channel")
689 dev
[0].p2p_stop_find()
691 wpas
.request("DISCONNECT")
692 wpas
.wait_disconnected()
694 # for larger coverage, cover case of current channel matching
695 wpas
.select_network(id)
696 wpas
.wait_connected()
697 wpas
.request("DISCONNECT")
698 wpas
.wait_disconnected()
700 lchannel
= "1" if channel
!= "1" else "6"
701 lfreq3
= "2412" if channel
!= "1" else "2437"
702 if "OK" not in wpas
.global_request("P2P_SET listen_channel " + lchannel
):
703 raise Exception("Failed to set listen channel")
705 wpas
.select_network(id)
706 wpas
.wait_connected()
709 if "OK" not in dev
[0].global_request("P2P_FLUSH"):
710 raise Exception("P2P_FLUSH failed")
711 if not dev
[0].discover_peer(addr5
):
712 raise Exception("Could not discover peer")
713 peer
= dev
[0].get_peer(addr5
)
714 lfreq4
= peer
['listen_freq']
716 raise Exception("Unexpected Listen channel after configuration")
718 dev
[0].p2p_stop_find()
720 wpas
.global_request("SET p2p_optimize_listen_chan 0")
722 def test_p2p_channel_5ghz_only(dev
):
723 """P2P GO start with only 5 GHz band allowed"""
725 set_country("US", dev
[0])
726 dev
[0].global_request("P2P_SET disallow_freq 2400-2500")
728 freq
= int(res
['freq'])
730 raise Exception("Unexpected channel %d MHz" % freq
)
731 dev
[0].remove_group()
733 dev
[0].global_request("P2P_SET disallow_freq ")
734 clear_regdom_dev(dev
)
736 def test_p2p_channel_5ghz_165_169_us(dev
):
737 """P2P GO and 5 GHz channels 165 (allowed) and 169 (disallowed) in US"""
739 set_country("US", dev
[0])
740 res
= dev
[0].p2p_start_go(freq
=5825)
741 if res
['freq'] != "5825":
742 raise Exception("Unexpected frequency: " + res
['freq'])
743 dev
[0].remove_group()
745 res
= dev
[0].global_request("P2P_GROUP_ADD freq=5845")
746 if "FAIL" not in res
:
747 raise Exception("GO on channel 169 allowed unexpectedly")
749 clear_regdom_dev(dev
)
751 def wait_go_down_up(dev
):
752 ev
= dev
.wait_group_event(["AP-DISABLED"], timeout
=5)
754 raise Exception("AP-DISABLED not seen after P2P-REMOVE-AND-REFORM-GROUP")
755 ev
= dev
.wait_group_event(["AP-ENABLED"], timeout
=5)
757 raise Exception("AP-ENABLED not seen after P2P-REMOVE-AND-REFORM-GROUP")
759 def test_p2p_go_move_reg_change(dev
, apdev
):
760 """P2P GO move due to regulatory change"""
763 dev
[0].global_request("P2P_SET disallow_freq 2400-5000,5700-6000")
765 freq1
= int(res
['freq'])
767 raise Exception("Unexpected channel %d MHz" % freq1
)
768 dev
[0].dump_monitor()
770 dev
[0].global_request("P2P_SET disallow_freq ")
772 # GO move is not allowed while waiting for initial client connection
773 connect_cli(dev
[0], dev
[1], freq
=freq1
)
774 dev
[1].remove_group()
775 ev
= dev
[1].wait_global_event(["P2P-GROUP-REMOVED"], timeout
=5)
777 raise Exception("P2P-GROUP-REMOVED not reported on client")
778 dev
[1].dump_monitor()
779 dev
[0].dump_monitor()
781 freq
= dev
[0].get_group_status_field('freq')
783 raise Exception("Unexpected freq after initial client: " + freq
)
784 dev
[0].dump_monitor()
786 dev
[0].request("NOTE Setting country=BD")
788 dev
[0].request("NOTE Waiting for GO channel change")
789 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
793 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
794 if "P2P-REMOVE-AND-REFORM-GROUP" in ev
:
795 wait_go_down_up(dev
[0])
797 freq2
= dev
[0].get_group_status_field('freq')
799 raise Exception("Unexpected freq after group reform=" + freq2
)
801 dev
[0].remove_group()
803 dev
[0].global_request("P2P_SET disallow_freq ")
806 def test_p2p_go_move_active(dev
, apdev
):
807 """P2P GO stays in freq although SCM is possible"""
808 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
809 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
810 wpas
.interface_add(iface
)
812 if wpas
.get_mcc() < 2:
813 raise Exception("New radio does not support MCC")
815 ndev
= [wpas
, dev
[1]]
816 _test_p2p_go_move_active(ndev
, apdev
)
818 def _test_p2p_go_move_active(dev
, apdev
):
819 dev
[0].global_request("SET p2p_no_group_iface 0")
821 dev
[0].global_request("P2P_SET disallow_freq 2430-6000")
822 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test',
824 dev
[0].connect("ap-test", key_mgmt
="NONE",
828 freq
= int(res
['freq'])
830 raise Exception("Unexpected channel %d MHz" % freq
)
832 # GO move is not allowed while waiting for initial client connection
833 connect_cli(dev
[0], dev
[1], freq
=freq
)
834 dev
[1].remove_group()
836 freq
= dev
[0].get_group_status_field('freq')
838 raise Exception("Unexpected freq after initial client: " + freq
)
840 dev
[0].dump_monitor()
841 dev
[0].global_request("P2P_SET disallow_freq ")
843 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
847 raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED seen")
849 dev
[0].remove_group()
851 dev
[0].global_request("P2P_SET disallow_freq ")
853 def test_p2p_go_move_scm(dev
, apdev
):
854 """P2P GO move due to SCM operation preference"""
855 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
856 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
857 wpas
.interface_add(iface
)
859 if wpas
.get_mcc() < 2:
860 raise Exception("New radio does not support MCC")
862 ndev
= [wpas
, dev
[1]]
863 _test_p2p_go_move_scm(ndev
, apdev
)
865 def _test_p2p_go_move_scm(dev
, apdev
):
866 dev
[0].global_request("SET p2p_no_group_iface 0")
868 dev
[0].global_request("P2P_SET disallow_freq 2430-6000")
869 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test',
871 dev
[0].connect("ap-test", key_mgmt
="NONE",
874 dev
[0].global_request("SET p2p_go_freq_change_policy 0")
876 freq
= int(res
['freq'])
878 raise Exception("Unexpected channel %d MHz" % freq
)
880 # GO move is not allowed while waiting for initial client connection
881 connect_cli(dev
[0], dev
[1], freq
=freq
)
882 dev
[1].remove_group()
884 freq
= dev
[0].get_group_status_field('freq')
886 raise Exception("Unexpected freq after initial client: " + freq
)
888 dev
[0].dump_monitor()
889 dev
[0].global_request("P2P_SET disallow_freq ")
891 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
892 "AP-CSA-FINISHED"], timeout
=3)
894 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
895 if "P2P-REMOVE-AND-REFORM-GROUP" in ev
:
896 wait_go_down_up(dev
[0])
898 freq
= dev
[0].get_group_status_field('freq')
900 raise Exception("Unexpected freq after group reform=" + freq
)
902 dev
[0].remove_group()
904 dev
[0].global_request("P2P_SET disallow_freq ")
905 dev
[0].global_request("SET p2p_go_freq_change_policy 2")
907 def test_p2p_go_move_scm_peer_supports(dev
, apdev
):
908 """P2P GO move due to SCM operation preference (peer supports)"""
909 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
910 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
911 wpas
.interface_add(iface
)
913 if wpas
.get_mcc() < 2:
914 raise Exception("New radio does not support MCC")
916 ndev
= [wpas
, dev
[1]]
917 _test_p2p_go_move_scm_peer_supports(ndev
, apdev
)
919 def _test_p2p_go_move_scm_peer_supports(dev
, apdev
):
921 dev
[0].global_request("SET p2p_go_freq_change_policy 1")
922 set_country("US", dev
[0])
924 dev
[0].global_request("SET p2p_no_group_iface 0")
925 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
926 r_dev
=dev
[1], r_intent
=0,
928 check_grpform_results(i_res
, r_res
)
929 freq
= int(i_res
['freq'])
931 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
933 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test',
935 logger
.info('Connecting client to to an AP on channel 11')
936 dev
[0].connect("ap-test", key_mgmt
="NONE",
939 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
940 "AP-CSA-FINISHED"], timeout
=3)
942 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
943 if "P2P-REMOVE-AND-REFORM-GROUP" in ev
:
944 wait_go_down_up(dev
[0])
946 freq
= dev
[0].get_group_status_field('freq')
948 raise Exception("Unexpected freq after group reform=" + freq
)
950 dev
[0].remove_group()
952 dev
[0].global_request("SET p2p_go_freq_change_policy 2")
955 def test_p2p_go_move_scm_peer_does_not_support(dev
, apdev
):
956 """No P2P GO move due to SCM operation (peer does not supports)"""
957 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
958 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
959 wpas
.interface_add(iface
)
961 if wpas
.get_mcc() < 2:
962 raise Exception("New radio does not support MCC")
964 ndev
= [wpas
, dev
[1]]
965 _test_p2p_go_move_scm_peer_does_not_support(ndev
, apdev
)
967 def _test_p2p_go_move_scm_peer_does_not_support(dev
, apdev
):
969 dev
[0].global_request("SET p2p_go_freq_change_policy 1")
970 set_country("US", dev
[0])
972 dev
[0].global_request("SET p2p_no_group_iface 0")
973 if "OK" not in dev
[1].request("DRIVER_EVENT AVOID_FREQUENCIES 2400-2500"):
974 raise Exception("Could not simulate driver event")
975 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
976 r_dev
=dev
[1], r_intent
=0,
978 check_grpform_results(i_res
, r_res
)
979 freq
= int(i_res
['freq'])
981 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
983 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test',
985 logger
.info('Connecting client to to an AP on channel 11')
986 dev
[0].connect("ap-test", key_mgmt
="NONE",
989 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
993 raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED seen")
995 dev
[0].remove_group()
997 dev
[0].global_request("SET p2p_go_freq_change_policy 2")
998 dev
[1].request("DRIVER_EVENT AVOID_FREQUENCIES")
999 clear_regdom_dev(dev
, 2)
1001 def test_p2p_go_move_scm_multi(dev
, apdev
):
1002 """P2P GO move due to SCM operation preference multiple times"""
1003 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
1004 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
1005 wpas
.interface_add(iface
)
1007 if wpas
.get_mcc() < 2:
1008 raise Exception("New radio does not support MCC")
1010 ndev
= [wpas
, dev
[1]]
1011 _test_p2p_go_move_scm_multi(ndev
, apdev
)
1013 def _test_p2p_go_move_scm_multi(dev
, apdev
):
1014 dev
[0].request("SET p2p_no_group_iface 0")
1016 dev
[0].global_request("P2P_SET disallow_freq 2430-6000")
1017 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test-1',
1019 dev
[0].connect("ap-test-1", key_mgmt
="NONE",
1022 dev
[0].global_request("SET p2p_go_freq_change_policy 0")
1023 res
= autogo(dev
[0])
1024 freq
= int(res
['freq'])
1026 raise Exception("Unexpected channel %d MHz" % freq
)
1028 # GO move is not allowed while waiting for initial client connection
1029 connect_cli(dev
[0], dev
[1], freq
=freq
)
1030 dev
[1].remove_group()
1032 freq
= dev
[0].get_group_status_field('freq')
1033 if int(freq
) > 2430:
1034 raise Exception("Unexpected freq after initial client: " + freq
)
1036 dev
[0].dump_monitor()
1037 dev
[0].global_request("P2P_SET disallow_freq ")
1039 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
1040 "AP-CSA-FINISHED"], timeout
=3)
1042 raise Exception("P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
1043 if "P2P-REMOVE-AND-REFORM-GROUP" in ev
:
1044 wait_go_down_up(dev
[0])
1046 freq
= dev
[0].get_group_status_field('freq')
1048 raise Exception("Unexpected freq after group reform=" + freq
)
1050 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'ap-test-2',
1052 dev
[0].connect("ap-test-2", key_mgmt
="NONE",
1055 ev
= dev
[0].wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
1056 "AP-CSA-FINISHED"], timeout
=5)
1058 raise Exception("(2) P2P-REMOVE-AND-REFORM-GROUP or AP-CSA-FINISHED not seen")
1059 if "P2P-REMOVE-AND-REFORM-GROUP" in ev
:
1060 wait_go_down_up(dev
[0])
1062 freq
= dev
[0].get_group_status_field('freq')
1064 raise Exception("(2) Unexpected freq after group reform=" + freq
)
1066 dev
[0].remove_group()
1068 dev
[0].global_request("P2P_SET disallow_freq ")
1069 dev
[0].global_request("SET p2p_go_freq_change_policy 2")
1071 def test_p2p_delay_go_csa(dev
, apdev
, params
):
1072 """P2P GO CSA delayed when inviting a P2P Device to an active P2P Group"""
1073 with
HWSimRadio(n_channels
=2) as (radio
, iface
):
1074 wpas
= WpaSupplicant(global_iface
='/tmp/wpas-wlan5')
1075 wpas
.interface_add(iface
)
1077 wpas
.global_request("SET p2p_no_group_iface 0")
1079 if wpas
.get_mcc() < 2:
1080 raise Exception("New radio does not support MCC")
1082 addr0
= wpas
.p2p_dev_addr()
1083 addr1
= dev
[1].p2p_dev_addr()
1087 if not wpas
.discover_peer(addr1
, social
=True):
1088 raise Exception("Peer " + addr1
+ " not found")
1089 wpas
.p2p_stop_find()
1091 hapd
= hostapd
.add_ap(apdev
[0], {"ssid": 'bss-2.4ghz',
1094 wpas
.connect("bss-2.4ghz", key_mgmt
="NONE", scan_freq
="2412")
1096 wpas
.global_request("SET p2p_go_freq_change_policy 0")
1099 logger
.info("Start GO on channel 6")
1100 res
= autogo(wpas
, freq
=2437)
1101 if res
['freq'] != "2437":
1102 raise Exception("GO set on a freq=%s instead of 2437" % res
['freq'])
1104 # Start find on dev[1] to run scans with dev[2] in parallel
1105 dev
[1].p2p_find(social
=True)
1107 # Use another client device to stop the initial client connection
1109 if not dev
[2].discover_peer(addr0
, social
=True):
1110 raise Exception("Peer2 did not find the GO")
1111 dev
[2].p2p_stop_find()
1112 pin
= dev
[2].wps_read_pin()
1113 wpas
.p2p_go_authorize_client(pin
)
1114 dev
[2].global_request("P2P_CONNECT " + addr0
+ " " + pin
+ " join freq=2437")
1115 ev
= dev
[2].wait_global_event(["P2P-GROUP-STARTED"], timeout
=10)
1117 raise Exception("Peer2 did not get connected")
1119 if not dev
[1].discover_peer(addr0
, social
=True):
1120 raise Exception("Peer did not find the GO")
1122 pin
= dev
[1].wps_read_pin()
1123 dev
[1].global_request("P2P_CONNECT " + addr0
+ " " + pin
+ " join auth")
1126 # Force P2P GO channel switch on successful invitation signaling
1127 wpas
.group_request("SET p2p_go_csa_on_inv 1")
1129 logger
.info("Starting invitation")
1130 wpas
.p2p_go_authorize_client(pin
)
1131 wpas
.global_request("P2P_INVITE group=" + wpas
.group_ifname
+ " peer=" + addr1
)
1132 ev
= dev
[1].wait_global_event(["P2P-INVITATION-RECEIVED",
1133 "P2P-GROUP-STARTED"], timeout
=10)
1136 raise Exception("Timeout on invitation on peer")
1137 if "P2P-INVITATION-RECEIVED" in ev
:
1138 raise Exception("Unexpected request to accept pre-authorized invitation")
1140 # A P2P GO move is not expected at this stage, as during the
1141 # invitation signaling, the P2P GO includes only its current
1142 # operating channel in the channel list, and as the invitation
1143 # response can only include channels that were also in the
1144 # invitation request channel list, the group common channels
1145 # includes only the current P2P GO operating channel.
1146 ev
= wpas
.wait_group_event(["P2P-REMOVE-AND-REFORM-GROUP",
1147 "AP-CSA-FINISHED"], timeout
=1)
1149 raise Exception("Unexpected + " + ev
+ " event")
1152 wpas
.global_request("SET p2p_go_freq_change_policy 2")
1154 def test_p2p_channel_vht80(dev
):
1155 """P2P group formation with VHT 80 MHz"""
1157 set_country("FI", dev
[0])
1158 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1160 i_max_oper_chwidth
=80,
1161 i_ht40
=True, i_vht
=True,
1162 r_dev
=dev
[1], r_intent
=0,
1164 check_grpform_results(i_res
, r_res
)
1165 freq
= int(i_res
['freq'])
1167 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
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])
1176 dev
[1].flush_scan_cache()
1178 def test_p2p_channel_vht80p80(dev
):
1179 """P2P group formation and VHT 80+80 MHz channel"""
1181 set_country("US", dev
[0])
1182 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1185 i_max_oper_chwidth
=160,
1186 i_ht40
=True, i_vht
=True,
1187 r_dev
=dev
[1], r_intent
=0,
1189 check_grpform_results(i_res
, r_res
)
1190 freq
= int(i_res
['freq'])
1192 raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq
)
1193 sig
= dev
[1].group_request("SIGNAL_POLL").splitlines()
1194 if "FREQUENCY=5180" not in sig
:
1195 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1196 if "WIDTH=80+80 MHz" not in sig
:
1197 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1198 if "CENTER_FRQ1=5210" not in sig
:
1199 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1200 if "CENTER_FRQ2=5775" not in sig
:
1201 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
1202 remove_group(dev
[0], dev
[1])
1205 dev
[1].flush_scan_cache()
1207 def test_p2p_channel_vht80p80_autogo(dev
):
1208 """P2P autonomous GO and VHT 80+80 MHz channel"""
1209 addr0
= dev
[0].p2p_dev_addr()
1212 set_country("US", dev
[0])
1213 if "OK" not in dev
[0].global_request("P2P_GROUP_ADD vht freq=5180 freq2=5775"):
1214 raise Exception("Could not start GO")
1215 ev
= dev
[0].wait_global_event(["P2P-GROUP-STARTED"], timeout
=5)
1217 raise Exception("GO start up timed out")
1218 dev
[0].group_form_result(ev
)
1220 pin
= dev
[1].wps_read_pin()
1221 dev
[0].p2p_go_authorize_client(pin
)
1223 dev
[1].global_request("P2P_CONNECT " + addr0
+ " " + pin
+ " join freq=5180")
1224 ev
= dev
[1].wait_global_event(["P2P-GROUP-STARTED"], timeout
=10)
1226 raise Exception("Peer did not get connected")
1228 dev
[1].group_form_result(ev
)
1229 sig
= dev
[1].group_request("SIGNAL_POLL").splitlines()
1230 if "FREQUENCY=5180" not in sig
:
1231 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1232 if "WIDTH=80+80 MHz" not in sig
:
1233 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1234 if "CENTER_FRQ1=5210" not in sig
:
1235 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1236 if "CENTER_FRQ2=5775" not in sig
:
1237 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
1238 remove_group(dev
[0], dev
[1])
1241 dev
[1].flush_scan_cache()
1243 def test_p2p_channel_vht80_autogo(dev
):
1244 """P2P autonomous GO and VHT 80 MHz channel"""
1245 addr0
= dev
[0].p2p_dev_addr()
1248 set_country("US", dev
[0])
1249 if "OK" not in dev
[0].global_request("P2P_GROUP_ADD vht freq=5180 max_oper_chwidth=80"):
1250 raise Exception("Could not start GO")
1251 ev
= dev
[0].wait_global_event(["P2P-GROUP-STARTED"], timeout
=5)
1253 raise Exception("GO start up timed out")
1254 dev
[0].group_form_result(ev
)
1256 pin
= dev
[1].wps_read_pin()
1257 dev
[0].p2p_go_authorize_client(pin
)
1259 dev
[1].global_request("P2P_CONNECT " + addr0
+ " " + pin
+ " join freq=5180")
1260 ev
= dev
[1].wait_global_event(["P2P-GROUP-STARTED"], timeout
=10)
1262 raise Exception("Peer did not get connected")
1264 dev
[1].group_form_result(ev
)
1265 sig
= dev
[1].group_request("SIGNAL_POLL").splitlines()
1266 if "FREQUENCY=5180" not in sig
:
1267 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1268 if "WIDTH=80 MHz" not in sig
:
1269 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1270 remove_group(dev
[0], dev
[1])
1273 dev
[1].flush_scan_cache()
1275 def test_p2p_channel_vht80p80_persistent(dev
):
1276 """P2P persistent group re-invocation and VHT 80+80 MHz channel"""
1277 addr0
= dev
[0].p2p_dev_addr()
1278 form(dev
[0], dev
[1])
1281 set_country("US", dev
[0])
1282 invite(dev
[0], dev
[1], extra
="vht freq=5745 freq2=5210")
1283 [go_res
, cli_res
] = check_result(dev
[0], dev
[1])
1285 sig
= dev
[1].group_request("SIGNAL_POLL").splitlines()
1286 if "FREQUENCY=5745" not in sig
:
1287 raise Exception("Unexpected SIGNAL_POLL value(1): " + str(sig
))
1288 if "WIDTH=80+80 MHz" not in sig
:
1289 raise Exception("Unexpected SIGNAL_POLL value(2): " + str(sig
))
1290 if "CENTER_FRQ1=5775" not in sig
:
1291 raise Exception("Unexpected SIGNAL_POLL value(3): " + str(sig
))
1292 if "CENTER_FRQ2=5210" not in sig
:
1293 raise Exception("Unexpected SIGNAL_POLL value(4): " + str(sig
))
1294 remove_group(dev
[0], dev
[1])
1297 dev
[1].flush_scan_cache()
1299 def test_p2p_channel_drv_pref_go_neg(dev
):
1300 """P2P GO Negotiation with GO device channel preference"""
1301 dev
[0].global_request("SET get_pref_freq_list_override 3:2417 4:2422")
1302 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1303 r_dev
=dev
[1], r_intent
=0,
1305 check_grpform_results(i_res
, r_res
)
1306 freq
= int(i_res
['freq'])
1308 raise Exception("Unexpected channel selected: %d" % freq
)
1309 remove_group(dev
[0], dev
[1])
1311 def test_p2p_channel_drv_pref_go_neg2(dev
):
1312 """P2P GO Negotiation with P2P client device channel preference"""
1313 dev
[0].global_request("SET get_pref_freq_list_override 3:2417,2422")
1314 dev
[1].global_request("SET get_pref_freq_list_override 4:2422")
1315 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1316 r_dev
=dev
[1], r_intent
=0,
1318 check_grpform_results(i_res
, r_res
)
1319 freq
= int(i_res
['freq'])
1321 raise Exception("Unexpected channel selected: %d" % freq
)
1322 remove_group(dev
[0], dev
[1])
1324 def test_p2p_channel_drv_pref_go_neg3(dev
):
1325 """P2P GO Negotiation with GO device channel preference"""
1326 dev
[1].global_request("SET get_pref_freq_list_override 3:2417,2427 4:2422")
1327 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=0,
1328 r_dev
=dev
[1], r_intent
=15,
1330 check_grpform_results(i_res
, r_res
)
1331 freq
= int(i_res
['freq'])
1333 raise Exception("Unexpected channel selected: %d" % freq
)
1334 remove_group(dev
[0], dev
[1])
1336 def test_p2p_channel_drv_pref_go_neg4(dev
):
1337 """P2P GO Negotiation with P2P client device channel preference"""
1338 dev
[0].global_request("SET get_pref_freq_list_override 3:2417,2422,5180")
1339 dev
[1].global_request("P2P_SET override_pref_op_chan 115:36")
1340 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1341 r_dev
=dev
[1], r_intent
=0,
1343 check_grpform_results(i_res
, r_res
)
1344 freq
= int(i_res
['freq'])
1346 raise Exception("Unexpected channel selected: %d" % freq
)
1347 remove_group(dev
[0], dev
[1])
1349 def test_p2p_channel_drv_pref_go_neg5(dev
):
1350 """P2P GO Negotiation with P2P client device channel preference"""
1351 dev
[0].global_request("SET get_pref_freq_list_override 3:2417")
1352 dev
[1].global_request("SET get_pref_freq_list_override 4:2422")
1353 dev
[1].global_request("P2P_SET override_pref_op_chan 115:36")
1354 [i_res
, r_res
] = go_neg_pin_authorized(i_dev
=dev
[0], i_intent
=15,
1355 r_dev
=dev
[1], r_intent
=0,
1357 check_grpform_results(i_res
, r_res
)
1358 freq
= int(i_res
['freq'])
1360 raise Exception("Unexpected channel selected: %d" % freq
)
1361 remove_group(dev
[0], dev
[1])
1363 def test_p2p_channel_drv_pref_autogo(dev
):
1364 """P2P autonomous GO with driver channel preference"""
1365 dev
[0].global_request("SET get_pref_freq_list_override 3:2417,2422,5180")
1366 res_go
= autogo(dev
[0])
1367 if res_go
['freq'] != "2417":
1368 raise Exception("Unexpected operating frequency: " + res_go
['freq'])