test_p2p_channel.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  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. import logging
  7. logger = logging.getLogger()
  8. import os
  9. import subprocess
  10. import time
  11. import hostapd
  12. import hwsim_utils
  13. from wpasupplicant import WpaSupplicant
  14. from hwsim import HWSimRadio
  15. from test_p2p_grpform import go_neg_pin_authorized
  16. from test_p2p_grpform import check_grpform_results
  17. from test_p2p_grpform import remove_group
  18. from test_p2p_grpform import go_neg_pbc
  19. from test_p2p_autogo import autogo
  20. def set_country(country):
  21. subprocess.call(['sudo', 'iw', 'reg', 'set', country])
  22. time.sleep(0.1)
  23. def test_p2p_channel_5ghz(dev):
  24. """P2P group formation with 5 GHz preference"""
  25. try:
  26. set_country("US")
  27. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  28. r_dev=dev[1], r_intent=0,
  29. test_data=False)
  30. check_grpform_results(i_res, r_res)
  31. freq = int(i_res['freq'])
  32. if freq < 5000:
  33. raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
  34. remove_group(dev[0], dev[1])
  35. finally:
  36. set_country("00")
  37. def test_p2p_channel_5ghz_no_vht(dev):
  38. """P2P group formation with 5 GHz preference when VHT channels are disallowed"""
  39. try:
  40. set_country("US")
  41. dev[0].request("P2P_SET disallow_freq 5180-5240")
  42. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  43. r_dev=dev[1], r_intent=0,
  44. test_data=False)
  45. check_grpform_results(i_res, r_res)
  46. freq = int(i_res['freq'])
  47. if freq < 5000:
  48. raise Exception("Unexpected channel %d MHz - did not follow 5 GHz preference" % freq)
  49. remove_group(dev[0], dev[1])
  50. finally:
  51. set_country("00")
  52. dev[0].request("P2P_SET disallow_freq ")
  53. def test_p2p_channel_random_social(dev):
  54. """P2P group formation with 5 GHz preference but all 5 GHz channels disabled"""
  55. try:
  56. set_country("US")
  57. dev[0].request("SET p2p_oper_channel 11")
  58. dev[0].request("P2P_SET disallow_freq 5000-6000,2462")
  59. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  60. r_dev=dev[1], r_intent=0,
  61. test_data=False)
  62. check_grpform_results(i_res, r_res)
  63. freq = int(i_res['freq'])
  64. if freq not in [ 2412, 2437, 2462 ]:
  65. raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
  66. remove_group(dev[0], dev[1])
  67. finally:
  68. set_country("00")
  69. dev[0].request("P2P_SET disallow_freq ")
  70. def test_p2p_channel_random(dev):
  71. """P2P group formation with 5 GHz preference but all 5 GHz channels and all social channels disabled"""
  72. try:
  73. set_country("US")
  74. dev[0].request("SET p2p_oper_channel 11")
  75. dev[0].request("P2P_SET disallow_freq 5000-6000,2412,2437,2462")
  76. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  77. r_dev=dev[1], r_intent=0,
  78. test_data=False)
  79. check_grpform_results(i_res, r_res)
  80. freq = int(i_res['freq'])
  81. if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
  82. raise Exception("Unexpected channel %d MHz" % freq)
  83. remove_group(dev[0], dev[1])
  84. finally:
  85. set_country("00")
  86. dev[0].request("P2P_SET disallow_freq ")
  87. def test_p2p_channel_random_social_with_op_class_change(dev, apdev, params):
  88. """P2P group formation using random social channel with oper class change needed"""
  89. try:
  90. set_country("US")
  91. logger.info("Start group on 5 GHz")
  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 < 5000:
  98. raise Exception("Unexpected channel %d MHz - did not pick 5 GHz preference" % freq)
  99. remove_group(dev[0], dev[1])
  100. logger.info("Disable 5 GHz and try to re-start group based on 5 GHz preference")
  101. dev[0].request("SET p2p_oper_reg_class 115")
  102. dev[0].request("SET p2p_oper_channel 36")
  103. dev[0].request("P2P_SET disallow_freq 5000-6000")
  104. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  105. r_dev=dev[1], r_intent=0,
  106. test_data=False)
  107. check_grpform_results(i_res, r_res)
  108. freq = int(i_res['freq'])
  109. if freq not in [ 2412, 2437, 2462 ]:
  110. raise Exception("Unexpected channel %d MHz - did not pick random social channel" % freq)
  111. remove_group(dev[0], dev[1])
  112. try:
  113. arg = [ "tshark",
  114. "-r", os.path.join(params['logdir'], "hwsim0.pcapng"),
  115. "-Y", "wifi_p2p.public_action.subtype == 0",
  116. "-V" ]
  117. cmd = subprocess.Popen(arg, stdout=subprocess.PIPE,
  118. stderr=open('/dev/null', 'w'))
  119. except Exception, e:
  120. logger.info("Could run run tshark check: " + str(e))
  121. cmd = None
  122. pass
  123. if cmd:
  124. last = None
  125. for l in cmd.stdout.read().splitlines():
  126. if "Operating Channel:" not in l:
  127. continue
  128. last = l
  129. if last is None:
  130. raise Exception("Could not find GO Negotiation Request")
  131. if "Operating Class 81" not in last:
  132. raise Exception("Unexpected operating class: " + last.strip())
  133. finally:
  134. set_country("00")
  135. dev[0].request("P2P_SET disallow_freq ")
  136. dev[0].request("SET p2p_oper_reg_class 0")
  137. dev[0].request("SET p2p_oper_channel 0")
  138. def test_p2p_channel_avoid(dev):
  139. """P2P and avoid frequencies driver event"""
  140. try:
  141. set_country("US")
  142. if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES 5000-6000,2412,2437,2462"):
  143. raise Exception("Could not simulate driver event")
  144. ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
  145. if ev is None:
  146. raise Exception("No CTRL-EVENT-AVOID-FREQ event")
  147. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  148. r_dev=dev[1], r_intent=0,
  149. test_data=False)
  150. check_grpform_results(i_res, r_res)
  151. freq = int(i_res['freq'])
  152. if freq > 2500 or freq in [ 2412, 2437, 2462 ]:
  153. raise Exception("Unexpected channel %d MHz" % freq)
  154. if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES"):
  155. raise Exception("Could not simulate driver event(2)")
  156. ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
  157. if ev is None:
  158. raise Exception("No CTRL-EVENT-AVOID-FREQ event")
  159. ev = dev[0].wait_event(["P2P-REMOVE-AND-REFORM-GROUP"], timeout=1)
  160. if ev is not None:
  161. raise Exception("Unexpected P2P-REMOVE-AND-REFORM-GROUP event")
  162. if "OK" not in dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES " + str(freq)):
  163. raise Exception("Could not simulate driver event(3)")
  164. ev = dev[0].wait_event(["CTRL-EVENT-AVOID-FREQ"], timeout=10)
  165. if ev is None:
  166. raise Exception("No CTRL-EVENT-AVOID-FREQ event")
  167. ev = dev[0].wait_event(["P2P-REMOVE-AND-REFORM-GROUP"], timeout=10)
  168. if ev is None:
  169. raise Exception("No P2P-REMOVE-AND-REFORM-GROUP event")
  170. finally:
  171. set_country("00")
  172. dev[0].request("DRIVER_EVENT AVOID_FREQUENCIES")
  173. def test_autogo_following_bss(dev, apdev):
  174. """P2P autonomous GO operate on the same channel as station interface"""
  175. if dev[0].get_mcc() > 1:
  176. logger.info("test mode: MCC")
  177. dev[0].request("SET p2p_no_group_iface 0")
  178. channels = { 3 : "2422", 5 : "2432", 9 : "2452" }
  179. for key in channels:
  180. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid" : 'ap-test',
  181. "channel" : str(key) })
  182. dev[0].connect("ap-test", key_mgmt="NONE",
  183. scan_freq=str(channels[key]))
  184. res_go = autogo(dev[0])
  185. if res_go['freq'] != channels[key]:
  186. raise Exception("Group operation channel is not the same as on connected station interface")
  187. hwsim_utils.test_connectivity(dev[0], hapd)
  188. dev[0].remove_group(res_go['ifname'])
  189. def test_go_neg_with_bss_connected(dev, apdev):
  190. """P2P channel selection: GO negotiation when station interface is connected"""
  191. dev[0].request("BSS_FLUSH 0")
  192. dev[0].request("SCAN freq=2412 only_new=1")
  193. dev[1].request("BSS_FLUSH 0")
  194. dev[1].request("SCAN freq=2412 only_new=1")
  195. dev[0].request("SET p2p_no_group_iface 0")
  196. hapd = hostapd.add_ap(apdev[0]['ifname'],
  197. { "ssid": 'bss-2.4ghz', "channel": '5' })
  198. dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432")
  199. #dev[0] as GO
  200. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1],
  201. r_intent=1)
  202. check_grpform_results(i_res, r_res)
  203. if i_res['role'] != "GO":
  204. raise Exception("GO not selected according to go_intent")
  205. if i_res['freq'] != "2432":
  206. raise Exception("Group formed on a different frequency than BSS")
  207. hwsim_utils.test_connectivity(dev[0], hapd)
  208. dev[0].remove_group(i_res['ifname'])
  209. if dev[0].get_mcc() > 1:
  210. logger.info("Skip as-client case due to MCC being enabled")
  211. return;
  212. #dev[0] as client
  213. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=1, r_dev=dev[1],
  214. r_intent=10)
  215. check_grpform_results(i_res2, r_res2)
  216. if i_res2['role'] != "client":
  217. raise Exception("GO not selected according to go_intent")
  218. if i_res2['freq'] != "2432":
  219. raise Exception("Group formed on a different frequency than BSS")
  220. hwsim_utils.test_connectivity(dev[0], hapd)
  221. def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
  222. """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
  223. with HWSimRadio(n_channels=2) as (radio, iface):
  224. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  225. wpas.interface_add(iface)
  226. wpas.request("SET p2p_no_group_iface 0")
  227. if wpas.get_mcc() < 2:
  228. raise Exception("New radio does not support MCC")
  229. try:
  230. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  231. "channel": '1' })
  232. wpas.request("P2P_SET disallow_freq 2412")
  233. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  234. res = autogo(wpas)
  235. if res['freq'] == "2412":
  236. raise Exception("GO set on a disallowed channel")
  237. hwsim_utils.test_connectivity(wpas, hapd)
  238. finally:
  239. wpas.request("P2P_SET disallow_freq ")
  240. def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
  241. """P2P channel selection: GO negotiation with station interface on a disallowed channel"""
  242. with HWSimRadio(n_channels=2) as (radio, iface):
  243. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  244. wpas.interface_add(iface)
  245. wpas.request("SET p2p_no_group_iface 0")
  246. if wpas.get_mcc() < 2:
  247. raise Exception("New radio does not support MCC")
  248. try:
  249. hapd = hostapd.add_ap(apdev[0]['ifname'],
  250. { "ssid": 'bss-2.4ghz', "channel": '1' })
  251. # make sure PBC overlap from old test cases is not maintained
  252. dev[0].request("BSS_FLUSH 0")
  253. dev[0].request("SCAN freq=2412 only_new=1")
  254. dev[1].request("BSS_FLUSH 0")
  255. dev[1].request("SCAN freq=2412 only_new=1")
  256. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  257. wpas.request("P2P_SET disallow_freq 2412")
  258. #wpas as GO
  259. [i_res, r_res] = go_neg_pbc(i_dev=wpas, i_intent=10, r_dev=dev[1],
  260. r_intent=1)
  261. check_grpform_results(i_res, r_res)
  262. if i_res['role'] != "GO":
  263. raise Exception("GO not selected according to go_intent")
  264. if i_res['freq'] == "2412":
  265. raise Exception("Group formed on a disallowed channel")
  266. hwsim_utils.test_connectivity(wpas, hapd)
  267. wpas.remove_group(i_res['ifname'])
  268. #wpas as client
  269. [i_res2, r_res2] = go_neg_pbc(i_dev=wpas, i_intent=1, r_dev=dev[1],
  270. r_intent=10)
  271. check_grpform_results(i_res2, r_res2)
  272. if i_res2['role'] != "client":
  273. raise Exception("GO not selected according to go_intent")
  274. if i_res2['freq'] == "2412":
  275. raise Exception("Group formed on a disallowed channel")
  276. hwsim_utils.test_connectivity(wpas, hapd)
  277. finally:
  278. wpas.request("P2P_SET disallow_freq ")
  279. def test_autogo_force_diff_channel(dev, apdev):
  280. """P2P autonomous GO and station interface operate on different channels"""
  281. with HWSimRadio(n_channels=2) as (radio, iface):
  282. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  283. wpas.interface_add(iface)
  284. if wpas.get_mcc() < 2:
  285. raise Exception("New radio does not support MCC")
  286. wpas.request("SET p2p_no_group_iface 0")
  287. hapd = hostapd.add_ap(apdev[0]['ifname'],
  288. {"ssid" : 'ap-test', "channel" : '1'})
  289. wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
  290. channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
  291. for key in channels:
  292. res_go = autogo(wpas, channels[key])
  293. hwsim_utils.test_connectivity(wpas, hapd)
  294. if int(res_go['freq']) == 2412:
  295. raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
  296. wpas.remove_group(res_go['ifname'])
  297. def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
  298. """P2P channel selection: GO negotiation with forced freq different than station interface"""
  299. with HWSimRadio(n_channels=2) as (radio, iface):
  300. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  301. wpas.interface_add(iface)
  302. if wpas.get_mcc() < 2:
  303. raise Exception("New radio does not support MCC")
  304. # Clear possible PBC session overlap from previous test case
  305. dev[1].request("BSS_FLUSH 0")
  306. dev[1].request("SCAN freq=2412 only_new=1")
  307. wpas.request("SET p2p_no_group_iface 0")
  308. hapd = hostapd.add_ap(apdev[0]['ifname'],
  309. { "country_code": 'US',
  310. "ssid": 'bss-5ghz', "hw_mode": 'a',
  311. "channel": '40' })
  312. wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
  313. # GO and peer force the same freq, different than BSS freq,
  314. # wpas to become GO
  315. [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
  316. r_dev=wpas, r_intent=14, r_freq=5180)
  317. check_grpform_results(i_res, r_res)
  318. if i_res['freq'] != "5180":
  319. raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
  320. if r_res['role'] != "GO":
  321. raise Exception("GO not selected according to go_intent")
  322. hwsim_utils.test_connectivity(wpas, hapd)
  323. wpas.remove_group(r_res['ifname'])
  324. # GO and peer force the same freq, different than BSS freq, wpas to
  325. # become client
  326. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
  327. r_dev=wpas, r_intent=1, r_freq=2422)
  328. check_grpform_results(i_res2, r_res2)
  329. if i_res2['freq'] != "2422":
  330. raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
  331. if r_res2['role'] != "client":
  332. raise Exception("GO not selected according to go_intent")
  333. hwsim_utils.test_connectivity(wpas, hapd)
  334. def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
  335. """P2P channel selection: Station on different channel than GO configured pref channel"""
  336. dev[0].request("SET p2p_no_group_iface 0")
  337. try:
  338. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  339. "channel": '1' })
  340. dev[0].request("SET p2p_pref_chan 81:2")
  341. dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  342. res = autogo(dev[0])
  343. if res['freq'] != "2412":
  344. raise Exception("GO channel did not follow BSS")
  345. hwsim_utils.test_connectivity(dev[0], hapd)
  346. finally:
  347. dev[0].request("SET p2p_pref_chan ")
  348. def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
  349. """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
  350. with HWSimRadio(n_channels=2) as (radio, iface):
  351. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  352. wpas.interface_add(iface)
  353. if wpas.get_mcc() < 2:
  354. raise Exception("New radio does not support MCC")
  355. wpas.request("SET p2p_no_group_iface 0")
  356. try:
  357. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  358. "channel": '1' })
  359. wpas.request("P2P_SET disallow_freq 2412")
  360. wpas.request("SET p2p_pref_chan 81:2")
  361. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  362. res2 = autogo(wpas)
  363. if res2['freq'] != "2417":
  364. raise Exception("GO channel did not follow pref_chan configuration")
  365. hwsim_utils.test_connectivity(wpas, hapd)
  366. finally:
  367. wpas.request("P2P_SET disallow_freq ")
  368. wpas.request("SET p2p_pref_chan ")
  369. def test_no_go_freq(dev, apdev):
  370. """P2P channel selection: no GO freq"""
  371. try:
  372. dev[0].request("SET p2p_no_go_freq 2412")
  373. # dev[0] as client, channel 1 is ok
  374. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=1,
  375. r_dev=dev[1], r_intent=14, r_freq=2412)
  376. check_grpform_results(i_res, r_res)
  377. if i_res['freq'] != "2412":
  378. raise Exception("P2P group not formed on forced freq")
  379. dev[1].remove_group(r_res['ifname'])
  380. fail = False
  381. # dev[0] as GO, channel 1 is not allowed
  382. try:
  383. dev[0].request("SET p2p_no_go_freq 2412")
  384. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14,
  385. r_dev=dev[1], r_intent=1, r_freq=2412)
  386. check_grpform_results(i_res2, r_res2)
  387. fail = True
  388. except:
  389. pass
  390. if fail:
  391. raise Exception("GO set on a disallowed freq")
  392. finally:
  393. dev[0].request("SET p2p_no_go_freq ")
  394. def test_go_neg_peers_force_diff_freq(dev, apdev):
  395. try:
  396. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14, i_freq=5180,
  397. r_dev=dev[1], r_intent=0, r_freq=5200)
  398. except Exception, e:
  399. return
  400. raise Exception("Unexpected group formation success")
  401. def test_autogo_random_channel(dev, apdev):
  402. """P2P channel selection: GO instantiated on random channel 1, 6, 11"""
  403. freqs = []
  404. go_freqs = ["2412", "2437", "2462"]
  405. for i in range(0, 20):
  406. result = autogo(dev[0])
  407. if result['freq'] not in go_freqs:
  408. raise Exception("Unexpected frequency selected: " + result['freq'])
  409. if result['freq'] not in freqs:
  410. freqs.append(result['freq'])
  411. if len(freqs) == 3:
  412. break
  413. dev[0].remove_group(result['ifname'])
  414. if i == 20:
  415. raise Exception("GO created 20 times and not all social channels were selected. freqs not selected: " + str(list(set(go_freqs) - set(freqs))))
  416. def test_p2p_autogo_pref_chan_disallowed(dev, apdev):
  417. """P2P channel selection: GO preferred channels are disallowed"""
  418. try:
  419. dev[0].request("SET p2p_pref_chan 81:1,81:3,81:6,81:9,81:11")
  420. dev[0].request("P2P_SET disallow_freq 2412,2422,2437,2452,2462")
  421. for i in range(0, 5):
  422. res = autogo(dev[0])
  423. if res['freq'] in [ "2412", "2422", "2437", "2452", "2462" ]:
  424. raise Exception("GO channel is disallowed")
  425. dev[0].remove_group(res['ifname'])
  426. finally:
  427. dev[0].request("P2P_SET disallow_freq ")
  428. dev[0].request("SET p2p_pref_chan ")
  429. def test_p2p_autogo_pref_chan_not_in_regulatory(dev, apdev):
  430. """P2P channel selection: GO preferred channel not allowed in the regulatory rules"""
  431. try:
  432. set_country("US")
  433. dev[0].request("SET p2p_pref_chan 124:149")
  434. res = autogo(dev[0], persistent=True)
  435. if res['freq'] != "5745":
  436. raise Exception("Unexpected channel selected: " + res['freq'])
  437. dev[0].remove_group(res['ifname'])
  438. netw = dev[0].list_networks()
  439. if len(netw) != 1:
  440. raise Exception("Unexpected number of network blocks: " + str(netw))
  441. id = netw[0]['id']
  442. set_country("DE")
  443. res = autogo(dev[0], persistent=id)
  444. if res['freq'] == "5745":
  445. raise Exception("Unexpected channel selected(2): " + res['freq'])
  446. dev[0].remove_group(res['ifname'])
  447. finally:
  448. dev[0].request("SET p2p_pref_chan ")
  449. set_country("00")