test_p2p_channel.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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].flush_scan_cache()
  192. dev[1].flush_scan_cache()
  193. dev[0].request("SET p2p_no_group_iface 0")
  194. hapd = hostapd.add_ap(apdev[0]['ifname'],
  195. { "ssid": 'bss-2.4ghz', "channel": '5' })
  196. dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2432")
  197. #dev[0] as GO
  198. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=10, r_dev=dev[1],
  199. r_intent=1)
  200. check_grpform_results(i_res, r_res)
  201. if i_res['role'] != "GO":
  202. raise Exception("GO not selected according to go_intent")
  203. if i_res['freq'] != "2432":
  204. raise Exception("Group formed on a different frequency than BSS")
  205. hwsim_utils.test_connectivity(dev[0], hapd)
  206. dev[0].remove_group(i_res['ifname'])
  207. if dev[0].get_mcc() > 1:
  208. logger.info("Skip as-client case due to MCC being enabled")
  209. return;
  210. #dev[0] as client
  211. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=1, r_dev=dev[1],
  212. r_intent=10)
  213. check_grpform_results(i_res2, r_res2)
  214. if i_res2['role'] != "client":
  215. raise Exception("GO not selected according to go_intent")
  216. if i_res2['freq'] != "2432":
  217. raise Exception("Group formed on a different frequency than BSS")
  218. hwsim_utils.test_connectivity(dev[0], hapd)
  219. def test_autogo_with_bss_on_disallowed_chan(dev, apdev):
  220. """P2P channel selection: Autonomous GO with BSS on a disallowed channel"""
  221. with HWSimRadio(n_channels=2) as (radio, iface):
  222. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  223. wpas.interface_add(iface)
  224. wpas.request("SET p2p_no_group_iface 0")
  225. if wpas.get_mcc() < 2:
  226. raise Exception("New radio does not support MCC")
  227. try:
  228. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  229. "channel": '1' })
  230. wpas.request("P2P_SET disallow_freq 2412")
  231. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  232. res = autogo(wpas)
  233. if res['freq'] == "2412":
  234. raise Exception("GO set on a disallowed channel")
  235. hwsim_utils.test_connectivity(wpas, hapd)
  236. finally:
  237. wpas.request("P2P_SET disallow_freq ")
  238. def test_go_neg_with_bss_on_disallowed_chan(dev, apdev):
  239. """P2P channel selection: GO negotiation with station interface on a disallowed channel"""
  240. with HWSimRadio(n_channels=2) as (radio, iface):
  241. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  242. wpas.interface_add(iface)
  243. wpas.request("SET p2p_no_group_iface 0")
  244. if wpas.get_mcc() < 2:
  245. raise Exception("New radio does not support MCC")
  246. try:
  247. hapd = hostapd.add_ap(apdev[0]['ifname'],
  248. { "ssid": 'bss-2.4ghz', "channel": '1' })
  249. # make sure PBC overlap from old test cases is not maintained
  250. dev[0].flush_scan_cache()
  251. dev[1].flush_scan_cache()
  252. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  253. wpas.request("P2P_SET disallow_freq 2412")
  254. #wpas as GO
  255. [i_res, r_res] = go_neg_pbc(i_dev=wpas, i_intent=10, r_dev=dev[1],
  256. r_intent=1)
  257. check_grpform_results(i_res, r_res)
  258. if i_res['role'] != "GO":
  259. raise Exception("GO not selected according to go_intent")
  260. if i_res['freq'] == "2412":
  261. raise Exception("Group formed on a disallowed channel")
  262. hwsim_utils.test_connectivity(wpas, hapd)
  263. wpas.remove_group(i_res['ifname'])
  264. #wpas as client
  265. [i_res2, r_res2] = go_neg_pbc(i_dev=wpas, i_intent=1, r_dev=dev[1],
  266. r_intent=10)
  267. check_grpform_results(i_res2, r_res2)
  268. if i_res2['role'] != "client":
  269. raise Exception("GO not selected according to go_intent")
  270. if i_res2['freq'] == "2412":
  271. raise Exception("Group formed on a disallowed channel")
  272. hwsim_utils.test_connectivity(wpas, hapd)
  273. finally:
  274. wpas.request("P2P_SET disallow_freq ")
  275. def test_autogo_force_diff_channel(dev, apdev):
  276. """P2P autonomous GO and station interface operate on different channels"""
  277. with HWSimRadio(n_channels=2) as (radio, iface):
  278. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  279. wpas.interface_add(iface)
  280. if wpas.get_mcc() < 2:
  281. raise Exception("New radio does not support MCC")
  282. wpas.request("SET p2p_no_group_iface 0")
  283. hapd = hostapd.add_ap(apdev[0]['ifname'],
  284. {"ssid" : 'ap-test', "channel" : '1'})
  285. wpas.connect("ap-test", key_mgmt = "NONE", scan_freq = "2412")
  286. channels = { 2 : 2417, 5 : 2432, 9 : 2452 }
  287. for key in channels:
  288. res_go = autogo(wpas, channels[key])
  289. hwsim_utils.test_connectivity(wpas, hapd)
  290. if int(res_go['freq']) == 2412:
  291. raise Exception("Group operation channel is: 2412 excepted: " + res_go['freq'])
  292. wpas.remove_group(res_go['ifname'])
  293. def test_go_neg_forced_freq_diff_than_bss_freq(dev, apdev):
  294. """P2P channel selection: GO negotiation with forced freq different than station interface"""
  295. with HWSimRadio(n_channels=2) as (radio, iface):
  296. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  297. wpas.interface_add(iface)
  298. if wpas.get_mcc() < 2:
  299. raise Exception("New radio does not support MCC")
  300. # Clear possible PBC session overlap from previous test case
  301. dev[1].flush_scan_cache()
  302. wpas.request("SET p2p_no_group_iface 0")
  303. hapd = hostapd.add_ap(apdev[0]['ifname'],
  304. { "country_code": 'US',
  305. "ssid": 'bss-5ghz', "hw_mode": 'a',
  306. "channel": '40' })
  307. wpas.connect("bss-5ghz", key_mgmt="NONE", scan_freq="5200")
  308. # GO and peer force the same freq, different than BSS freq,
  309. # wpas to become GO
  310. [i_res, r_res] = go_neg_pbc(i_dev=dev[1], i_intent=1, i_freq=5180,
  311. r_dev=wpas, r_intent=14, r_freq=5180)
  312. check_grpform_results(i_res, r_res)
  313. if i_res['freq'] != "5180":
  314. raise Exception("P2P group formed on unexpected frequency: " + i_res['freq'])
  315. if r_res['role'] != "GO":
  316. raise Exception("GO not selected according to go_intent")
  317. hwsim_utils.test_connectivity(wpas, hapd)
  318. wpas.remove_group(r_res['ifname'])
  319. # GO and peer force the same freq, different than BSS freq, wpas to
  320. # become client
  321. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[1], i_intent=14, i_freq=2422,
  322. r_dev=wpas, r_intent=1, r_freq=2422)
  323. check_grpform_results(i_res2, r_res2)
  324. if i_res2['freq'] != "2422":
  325. raise Exception("P2P group formed on unexpected frequency: " + i_res2['freq'])
  326. if r_res2['role'] != "client":
  327. raise Exception("GO not selected according to go_intent")
  328. hwsim_utils.test_connectivity(wpas, hapd)
  329. def test_go_pref_chan_bss_on_diff_chan(dev, apdev):
  330. """P2P channel selection: Station on different channel than GO configured pref channel"""
  331. dev[0].request("SET p2p_no_group_iface 0")
  332. try:
  333. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  334. "channel": '1' })
  335. dev[0].request("SET p2p_pref_chan 81:2")
  336. dev[0].connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  337. res = autogo(dev[0])
  338. if res['freq'] != "2412":
  339. raise Exception("GO channel did not follow BSS")
  340. hwsim_utils.test_connectivity(dev[0], hapd)
  341. finally:
  342. dev[0].request("SET p2p_pref_chan ")
  343. def test_go_pref_chan_bss_on_disallowed_chan(dev, apdev):
  344. """P2P channel selection: Station interface on different channel than GO configured pref channel, and station channel is disallowed"""
  345. with HWSimRadio(n_channels=2) as (radio, iface):
  346. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  347. wpas.interface_add(iface)
  348. if wpas.get_mcc() < 2:
  349. raise Exception("New radio does not support MCC")
  350. wpas.request("SET p2p_no_group_iface 0")
  351. try:
  352. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": 'bss-2.4ghz',
  353. "channel": '1' })
  354. wpas.request("P2P_SET disallow_freq 2412")
  355. wpas.request("SET p2p_pref_chan 81:2")
  356. wpas.connect("bss-2.4ghz", key_mgmt="NONE", scan_freq="2412")
  357. res2 = autogo(wpas)
  358. if res2['freq'] != "2417":
  359. raise Exception("GO channel did not follow pref_chan configuration")
  360. hwsim_utils.test_connectivity(wpas, hapd)
  361. finally:
  362. wpas.request("P2P_SET disallow_freq ")
  363. wpas.request("SET p2p_pref_chan ")
  364. def test_no_go_freq(dev, apdev):
  365. """P2P channel selection: no GO freq"""
  366. try:
  367. dev[0].request("SET p2p_no_go_freq 2412")
  368. # dev[0] as client, channel 1 is ok
  369. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=1,
  370. r_dev=dev[1], r_intent=14, r_freq=2412)
  371. check_grpform_results(i_res, r_res)
  372. if i_res['freq'] != "2412":
  373. raise Exception("P2P group not formed on forced freq")
  374. dev[1].remove_group(r_res['ifname'])
  375. fail = False
  376. # dev[0] as GO, channel 1 is not allowed
  377. try:
  378. dev[0].request("SET p2p_no_go_freq 2412")
  379. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14,
  380. r_dev=dev[1], r_intent=1, r_freq=2412)
  381. check_grpform_results(i_res2, r_res2)
  382. fail = True
  383. except:
  384. pass
  385. if fail:
  386. raise Exception("GO set on a disallowed freq")
  387. finally:
  388. dev[0].request("SET p2p_no_go_freq ")
  389. def test_go_neg_peers_force_diff_freq(dev, apdev):
  390. """P2P channel selection when peers for different frequency"""
  391. try:
  392. [i_res2, r_res2] = go_neg_pbc(i_dev=dev[0], i_intent=14, i_freq=5180,
  393. r_dev=dev[1], r_intent=0, r_freq=5200)
  394. except Exception, e:
  395. return
  396. raise Exception("Unexpected group formation success")
  397. def test_autogo_random_channel(dev, apdev):
  398. """P2P channel selection: GO instantiated on random channel 1, 6, 11"""
  399. freqs = []
  400. go_freqs = ["2412", "2437", "2462"]
  401. for i in range(0, 20):
  402. result = autogo(dev[0])
  403. if result['freq'] not in go_freqs:
  404. raise Exception("Unexpected frequency selected: " + result['freq'])
  405. if result['freq'] not in freqs:
  406. freqs.append(result['freq'])
  407. if len(freqs) == 3:
  408. break
  409. dev[0].remove_group(result['ifname'])
  410. if i == 20:
  411. raise Exception("GO created 20 times and not all social channels were selected. freqs not selected: " + str(list(set(go_freqs) - set(freqs))))
  412. def test_p2p_autogo_pref_chan_disallowed(dev, apdev):
  413. """P2P channel selection: GO preferred channels are disallowed"""
  414. try:
  415. dev[0].request("SET p2p_pref_chan 81:1,81:3,81:6,81:9,81:11")
  416. dev[0].request("P2P_SET disallow_freq 2412,2422,2437,2452,2462")
  417. for i in range(0, 5):
  418. res = autogo(dev[0])
  419. if res['freq'] in [ "2412", "2422", "2437", "2452", "2462" ]:
  420. raise Exception("GO channel is disallowed")
  421. dev[0].remove_group(res['ifname'])
  422. finally:
  423. dev[0].request("P2P_SET disallow_freq ")
  424. dev[0].request("SET p2p_pref_chan ")
  425. def test_p2p_autogo_pref_chan_not_in_regulatory(dev, apdev):
  426. """P2P channel selection: GO preferred channel not allowed in the regulatory rules"""
  427. try:
  428. set_country("US")
  429. dev[0].request("SET p2p_pref_chan 124:149")
  430. res = autogo(dev[0], persistent=True)
  431. if res['freq'] != "5745":
  432. raise Exception("Unexpected channel selected: " + res['freq'])
  433. dev[0].remove_group(res['ifname'])
  434. netw = dev[0].list_networks()
  435. if len(netw) != 1:
  436. raise Exception("Unexpected number of network blocks: " + str(netw))
  437. id = netw[0]['id']
  438. set_country("DE")
  439. res = autogo(dev[0], persistent=id)
  440. if res['freq'] == "5745":
  441. raise Exception("Unexpected channel selected(2): " + res['freq'])
  442. dev[0].remove_group(res['ifname'])
  443. finally:
  444. dev[0].request("SET p2p_pref_chan ")
  445. set_country("00")