test_p2p_grpform.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. # P2P group formation test cases
  2. # Copyright (c) 2013-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 time
  9. import threading
  10. import Queue
  11. import os
  12. import hostapd
  13. import hwsim_utils
  14. import utils
  15. from wpasupplicant import WpaSupplicant
  16. def check_grpform_results(i_res, r_res):
  17. if i_res['result'] != 'success' or r_res['result'] != 'success':
  18. raise Exception("Failed group formation")
  19. if i_res['ssid'] != r_res['ssid']:
  20. raise Exception("SSID mismatch")
  21. if i_res['freq'] != r_res['freq']:
  22. raise Exception("freq mismatch")
  23. if 'go_neg_freq' in r_res and i_res['go_neg_freq'] != r_res['go_neg_freq']:
  24. raise Exception("go_neg_freq mismatch")
  25. if i_res['freq'] != i_res['go_neg_freq']:
  26. raise Exception("freq/go_neg_freq mismatch")
  27. if i_res['role'] != i_res['go_neg_role']:
  28. raise Exception("role/go_neg_role mismatch")
  29. if 'go_neg_role' in r_res and r_res['role'] != r_res['go_neg_role']:
  30. raise Exception("role/go_neg_role mismatch")
  31. if i_res['go_dev_addr'] != r_res['go_dev_addr']:
  32. raise Exception("GO Device Address mismatch")
  33. def go_neg_init(i_dev, r_dev, pin, i_method, i_intent, res):
  34. logger.debug("Initiate GO Negotiation from i_dev")
  35. try:
  36. i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=20, go_intent=i_intent)
  37. logger.debug("i_res: " + str(i_res))
  38. except Exception, e:
  39. i_res = None
  40. logger.info("go_neg_init thread caught an exception from p2p_go_neg_init: " + str(e))
  41. res.put(i_res)
  42. def go_neg_pin(i_dev, r_dev, i_intent=None, r_intent=None, i_method='enter', r_method='display'):
  43. r_dev.p2p_listen()
  44. i_dev.p2p_listen()
  45. pin = r_dev.wps_read_pin()
  46. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  47. r_dev.dump_monitor()
  48. res = Queue.Queue()
  49. t = threading.Thread(target=go_neg_init, args=(i_dev, r_dev, pin, i_method, i_intent, res))
  50. t.start()
  51. logger.debug("Wait for GO Negotiation Request on r_dev")
  52. ev = r_dev.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  53. if ev is None:
  54. raise Exception("GO Negotiation timed out")
  55. r_dev.dump_monitor()
  56. logger.debug("Re-initiate GO Negotiation from r_dev")
  57. r_res = r_dev.p2p_go_neg_init(i_dev.p2p_dev_addr(), pin, r_method, go_intent=r_intent, timeout=20)
  58. logger.debug("r_res: " + str(r_res))
  59. r_dev.dump_monitor()
  60. t.join()
  61. i_res = res.get()
  62. if i_res is None:
  63. raise Exception("go_neg_init thread failed")
  64. logger.debug("i_res: " + str(i_res))
  65. logger.info("Group formed")
  66. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  67. i_dev.dump_monitor()
  68. return [i_res, r_res]
  69. def go_neg_pin_authorized(i_dev, r_dev, i_intent=None, r_intent=None, expect_failure=False, i_go_neg_status=None, i_method='enter', r_method='display', test_data=True, i_freq=None, r_freq=None):
  70. i_dev.p2p_listen()
  71. pin = r_dev.wps_read_pin()
  72. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  73. r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), pin, r_method, go_intent=r_intent, freq=r_freq)
  74. r_dev.p2p_listen()
  75. i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=20, go_intent=i_intent, expect_failure=expect_failure, freq=i_freq)
  76. r_res = r_dev.p2p_go_neg_auth_result(expect_failure=expect_failure)
  77. logger.debug("i_res: " + str(i_res))
  78. logger.debug("r_res: " + str(r_res))
  79. r_dev.dump_monitor()
  80. i_dev.dump_monitor()
  81. if i_go_neg_status:
  82. if i_res['result'] != 'go-neg-failed':
  83. raise Exception("Expected GO Negotiation failure not reported")
  84. if i_res['status'] != i_go_neg_status:
  85. raise Exception("Expected GO Negotiation status not seen")
  86. if expect_failure:
  87. return
  88. logger.info("Group formed")
  89. if test_data:
  90. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  91. return [i_res, r_res]
  92. def go_neg_init_pbc(i_dev, r_dev, i_intent, res, freq, provdisc):
  93. logger.debug("Initiate GO Negotiation from i_dev")
  94. try:
  95. i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), None, "pbc",
  96. timeout=20, go_intent=i_intent, freq=freq,
  97. provdisc=provdisc)
  98. logger.debug("i_res: " + str(i_res))
  99. except Exception, e:
  100. i_res = None
  101. logger.info("go_neg_init_pbc thread caught an exception from p2p_go_neg_init: " + str(e))
  102. res.put(i_res)
  103. def go_neg_pbc(i_dev, r_dev, i_intent=None, r_intent=None, i_freq=None, r_freq=None, provdisc=False, r_listen=False):
  104. if r_listen:
  105. r_dev.p2p_listen()
  106. else:
  107. r_dev.p2p_find(social=True)
  108. i_dev.p2p_find(social=True)
  109. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  110. r_dev.dump_monitor()
  111. res = Queue.Queue()
  112. t = threading.Thread(target=go_neg_init_pbc, args=(i_dev, r_dev, i_intent, res, i_freq, provdisc))
  113. t.start()
  114. logger.debug("Wait for GO Negotiation Request on r_dev")
  115. ev = r_dev.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  116. if ev is None:
  117. raise Exception("GO Negotiation timed out")
  118. r_dev.dump_monitor()
  119. # Allow some time for the GO Neg Resp to go out before initializing new
  120. # GO Negotiation.
  121. time.sleep(0.2)
  122. logger.debug("Re-initiate GO Negotiation from r_dev")
  123. r_res = r_dev.p2p_go_neg_init(i_dev.p2p_dev_addr(), None, "pbc",
  124. go_intent=r_intent, timeout=20, freq=r_freq)
  125. logger.debug("r_res: " + str(r_res))
  126. r_dev.dump_monitor()
  127. t.join()
  128. i_res = res.get()
  129. if i_res is None:
  130. raise Exception("go_neg_init_pbc thread failed")
  131. logger.debug("i_res: " + str(i_res))
  132. logger.info("Group formed")
  133. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  134. i_dev.dump_monitor()
  135. return [i_res, r_res]
  136. def remove_group(dev1, dev2):
  137. dev1.remove_group()
  138. try:
  139. dev2.remove_group()
  140. except:
  141. pass
  142. def test_grpform(dev):
  143. """P2P group formation using PIN and authorized connection (init -> GO)"""
  144. try:
  145. dev[0].request("SET p2p_group_idle 2")
  146. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  147. r_dev=dev[1], r_intent=0)
  148. check_grpform_results(i_res, r_res)
  149. dev[1].remove_group()
  150. ev = dev[0].wait_global_event(["P2P-GROUP-REMOVED"], timeout=10)
  151. if ev is None:
  152. raise Exception("GO did not remove group on idle timeout")
  153. if "GO reason=IDLE" not in ev:
  154. raise Exception("Unexpected group removal event: " + ev)
  155. finally:
  156. dev[0].request("SET p2p_group_idle 0")
  157. def test_grpform_a(dev):
  158. """P2P group formation using PIN and authorized connection (init -> GO) (init: group iface)"""
  159. dev[0].request("SET p2p_no_group_iface 0")
  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. if "p2p-wlan" not in i_res['ifname']:
  163. raise Exception("Unexpected group interface name")
  164. check_grpform_results(i_res, r_res)
  165. remove_group(dev[0], dev[1])
  166. if i_res['ifname'] in utils.get_ifnames():
  167. raise Exception("Group interface netdev was not removed")
  168. def test_grpform_b(dev):
  169. """P2P group formation using PIN and authorized connection (init -> GO) (resp: group iface)"""
  170. dev[1].request("SET p2p_no_group_iface 0")
  171. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  172. r_dev=dev[1], r_intent=0)
  173. if "p2p-wlan" not in r_res['ifname']:
  174. raise Exception("Unexpected group interface name")
  175. check_grpform_results(i_res, r_res)
  176. remove_group(dev[0], dev[1])
  177. if r_res['ifname'] in utils.get_ifnames():
  178. raise Exception("Group interface netdev was not removed")
  179. def test_grpform_c(dev):
  180. """P2P group formation using PIN and authorized connection (init -> GO) (group iface)"""
  181. dev[0].request("SET p2p_no_group_iface 0")
  182. dev[1].request("SET p2p_no_group_iface 0")
  183. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  184. r_dev=dev[1], r_intent=0)
  185. if "p2p-wlan" not in i_res['ifname']:
  186. raise Exception("Unexpected group interface name")
  187. if "p2p-wlan" not in r_res['ifname']:
  188. raise Exception("Unexpected group interface name")
  189. check_grpform_results(i_res, r_res)
  190. remove_group(dev[0], dev[1])
  191. if i_res['ifname'] in utils.get_ifnames():
  192. raise Exception("Group interface netdev was not removed")
  193. if r_res['ifname'] in utils.get_ifnames():
  194. raise Exception("Group interface netdev was not removed")
  195. def test_grpform2(dev):
  196. """P2P group formation using PIN and authorized connection (resp -> GO)"""
  197. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
  198. remove_group(dev[0], dev[1])
  199. def test_grpform2_c(dev):
  200. """P2P group formation using PIN and authorized connection (resp -> GO) (group iface)"""
  201. dev[0].request("SET p2p_no_group_iface 0")
  202. dev[1].request("SET p2p_no_group_iface 0")
  203. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
  204. remove_group(dev[0], dev[1])
  205. if i_res['ifname'] in utils.get_ifnames():
  206. raise Exception("Group interface netdev was not removed")
  207. if r_res['ifname'] in utils.get_ifnames():
  208. raise Exception("Group interface netdev was not removed")
  209. def test_grpform3(dev):
  210. """P2P group formation using PIN and re-init GO Negotiation"""
  211. go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  212. remove_group(dev[0], dev[1])
  213. def test_grpform3_c(dev):
  214. """P2P group formation using PIN and re-init GO Negotiation (group iface)"""
  215. dev[0].request("SET p2p_no_group_iface 0")
  216. dev[1].request("SET p2p_no_group_iface 0")
  217. [i_res, r_res] = go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  218. remove_group(dev[0], dev[1])
  219. if i_res['ifname'] in utils.get_ifnames():
  220. raise Exception("Group interface netdev was not removed")
  221. if r_res['ifname'] in utils.get_ifnames():
  222. raise Exception("Group interface netdev was not removed")
  223. def test_grpform_pbc(dev):
  224. """P2P group formation using PBC and re-init GO Negotiation"""
  225. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  226. check_grpform_results(i_res, r_res)
  227. if i_res['role'] != 'GO' or r_res['role'] != 'client':
  228. raise Exception("Unexpected device roles")
  229. remove_group(dev[0], dev[1])
  230. def test_grpform_pd(dev):
  231. """P2P group formation with PD-before-GO-Neg workaround"""
  232. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], provdisc=True, r_dev=dev[1], r_listen=True)
  233. check_grpform_results(i_res, r_res)
  234. remove_group(dev[0], dev[1])
  235. def test_grpform_ext_listen(dev):
  236. """P2P group formation with extended listen timing enabled"""
  237. try:
  238. if "FAIL" not in dev[0].global_request("P2P_EXT_LISTEN 100"):
  239. raise Exception("Invalid P2P_EXT_LISTEN accepted")
  240. if "OK" not in dev[0].global_request("P2P_EXT_LISTEN 100 50000"):
  241. raise Exception("Failed to set extended listen timing")
  242. if "OK" not in dev[1].global_request("P2P_EXT_LISTEN 200 40000"):
  243. raise Exception("Failed to set extended listen timing")
  244. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], provdisc=True, r_dev=dev[1], r_listen=True)
  245. check_grpform_results(i_res, r_res)
  246. peer1 = dev[0].get_peer(dev[1].p2p_dev_addr())
  247. if peer1['ext_listen_interval'] != "40000":
  248. raise Exception("Extended listen interval not discovered correctly")
  249. if peer1['ext_listen_period'] != "200":
  250. raise Exception("Extended listen period not discovered correctly")
  251. peer0 = dev[1].get_peer(dev[0].p2p_dev_addr())
  252. if peer0['ext_listen_interval'] != "50000":
  253. raise Exception("Extended listen interval not discovered correctly")
  254. if peer0['ext_listen_period'] != "100":
  255. raise Exception("Extended listen period not discovered correctly")
  256. remove_group(dev[0], dev[1])
  257. finally:
  258. if "OK" not in dev[0].global_request("P2P_EXT_LISTEN"):
  259. raise Exception("Failed to clear extended listen timing")
  260. if "OK" not in dev[1].global_request("P2P_EXT_LISTEN"):
  261. raise Exception("Failed to clear extended listen timing")
  262. def test_both_go_intent_15(dev):
  263. """P2P GO Negotiation with both devices using GO intent 15"""
  264. go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=15, expect_failure=True, i_go_neg_status=9)
  265. def test_both_go_neg_display(dev):
  266. """P2P GO Negotiation with both devices trying to display PIN"""
  267. go_neg_pin_authorized(i_dev=dev[0], r_dev=dev[1], expect_failure=True, i_go_neg_status=10, i_method='display', r_method='display')
  268. def test_both_go_neg_enter(dev):
  269. """P2P GO Negotiation with both devices trying to enter PIN"""
  270. go_neg_pin_authorized(i_dev=dev[0], r_dev=dev[1], expect_failure=True, i_go_neg_status=10, i_method='enter', r_method='enter')
  271. def test_go_neg_pbc_vs_pin(dev):
  272. """P2P GO Negotiation with one device using PBC and the other PIN"""
  273. addr0 = dev[0].p2p_dev_addr()
  274. addr1 = dev[1].p2p_dev_addr()
  275. dev[1].p2p_listen()
  276. if not dev[0].discover_peer(addr1):
  277. raise Exception("Could not discover peer")
  278. dev[0].p2p_listen()
  279. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " pbc auth"):
  280. raise Exception("Failed to authorize GO Neg")
  281. if not dev[1].discover_peer(addr0):
  282. raise Exception("Could not discover peer")
  283. if "OK" not in dev[1].request("P2P_CONNECT " + addr0 + " 12345670 display"):
  284. raise Exception("Failed to initiate GO Neg")
  285. ev = dev[1].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=10)
  286. if ev is None:
  287. raise Exception("GO Negotiation failure timed out")
  288. if "status=10" not in ev:
  289. raise Exception("Unexpected failure reason: " + ev)
  290. def test_go_neg_pin_vs_pbc(dev):
  291. """P2P GO Negotiation with one device using PIN and the other PBC"""
  292. addr0 = dev[0].p2p_dev_addr()
  293. addr1 = dev[1].p2p_dev_addr()
  294. dev[1].p2p_listen()
  295. if not dev[0].discover_peer(addr1):
  296. raise Exception("Could not discover peer")
  297. dev[0].p2p_listen()
  298. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " 12345670 display auth"):
  299. raise Exception("Failed to authorize GO Neg")
  300. if not dev[1].discover_peer(addr0):
  301. raise Exception("Could not discover peer")
  302. if "OK" not in dev[1].request("P2P_CONNECT " + addr0 + " pbc"):
  303. raise Exception("Failed to initiate GO Neg")
  304. ev = dev[1].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=10)
  305. if ev is None:
  306. raise Exception("GO Negotiation failure timed out")
  307. if "status=10" not in ev:
  308. raise Exception("Unexpected failure reason: " + ev)
  309. def test_grpform_per_sta_psk(dev):
  310. """P2P group formation with per-STA PSKs"""
  311. dev[0].request("P2P_SET per_sta_psk 1")
  312. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  313. check_grpform_results(i_res, r_res)
  314. pin = dev[2].wps_read_pin()
  315. dev[0].p2p_go_authorize_client(pin)
  316. c_res = dev[2].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60)
  317. check_grpform_results(i_res, c_res)
  318. if r_res['psk'] == c_res['psk']:
  319. raise Exception("Same PSK assigned for both clients")
  320. hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
  321. dev[0].remove_group()
  322. dev[1].wait_go_ending_session()
  323. dev[2].wait_go_ending_session()
  324. def test_grpform_per_sta_psk_wps(dev):
  325. """P2P group formation with per-STA PSKs with non-P2P WPS STA"""
  326. dev[0].request("P2P_SET per_sta_psk 1")
  327. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  328. check_grpform_results(i_res, r_res)
  329. dev[0].p2p_go_authorize_client_pbc()
  330. dev[2].request("WPS_PBC")
  331. dev[2].wait_connected(timeout=30)
  332. hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
  333. dev[0].remove_group()
  334. dev[2].request("DISCONNECT")
  335. dev[1].wait_go_ending_session()
  336. def test_grpform_force_chan_go(dev):
  337. """P2P group formation forced channel selection by GO"""
  338. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  339. i_freq=2432,
  340. r_dev=dev[1], r_intent=0,
  341. test_data=False)
  342. check_grpform_results(i_res, r_res)
  343. if i_res['freq'] != "2432":
  344. raise Exception("Unexpected channel - did not follow GO's forced channel")
  345. remove_group(dev[0], dev[1])
  346. def test_grpform_force_chan_cli(dev):
  347. """P2P group formation forced channel selection by client"""
  348. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  349. i_freq=2417,
  350. r_dev=dev[1], r_intent=15,
  351. test_data=False)
  352. check_grpform_results(i_res, r_res)
  353. if i_res['freq'] != "2417":
  354. raise Exception("Unexpected channel - did not follow GO's forced channel")
  355. remove_group(dev[0], dev[1])
  356. def test_grpform_force_chan_conflict(dev):
  357. """P2P group formation fails due to forced channel mismatch"""
  358. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, i_freq=2422,
  359. r_dev=dev[1], r_intent=15, r_freq=2427,
  360. expect_failure=True, i_go_neg_status=7)
  361. def test_grpform_pref_chan_go(dev):
  362. """P2P group formation preferred channel selection by GO"""
  363. dev[0].request("SET p2p_pref_chan 81:7")
  364. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  365. r_dev=dev[1], r_intent=0,
  366. test_data=False)
  367. check_grpform_results(i_res, r_res)
  368. if i_res['freq'] != "2442":
  369. raise Exception("Unexpected channel - did not follow GO's p2p_pref_chan")
  370. remove_group(dev[0], dev[1])
  371. def test_grpform_pref_chan_go_overridden(dev):
  372. """P2P group formation preferred channel selection by GO overridden by client"""
  373. dev[1].request("SET p2p_pref_chan 81:7")
  374. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  375. i_freq=2422,
  376. r_dev=dev[1], r_intent=15,
  377. test_data=False)
  378. check_grpform_results(i_res, r_res)
  379. if i_res['freq'] != "2422":
  380. raise Exception("Unexpected channel - did not follow client's forced channel")
  381. remove_group(dev[0], dev[1])
  382. def test_grpform_no_go_freq_forcing_chan(dev):
  383. """P2P group formation with no-GO freq forcing channel"""
  384. dev[1].request("SET p2p_no_go_freq 100-200,300,4000-6000")
  385. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  386. r_dev=dev[1], r_intent=15,
  387. test_data=False)
  388. check_grpform_results(i_res, r_res)
  389. if int(i_res['freq']) > 4000:
  390. raise Exception("Unexpected channel - did not follow no-GO freq")
  391. remove_group(dev[0], dev[1])
  392. def test_grpform_no_go_freq_conflict(dev):
  393. """P2P group formation fails due to no-GO range forced by client"""
  394. dev[1].request("SET p2p_no_go_freq 2000-3000")
  395. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, i_freq=2422,
  396. r_dev=dev[1], r_intent=15,
  397. expect_failure=True, i_go_neg_status=7)
  398. def test_grpform_no_5ghz_world_roaming(dev):
  399. """P2P group formation with world roaming regulatory"""
  400. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  401. r_dev=dev[1], r_intent=15,
  402. test_data=False)
  403. check_grpform_results(i_res, r_res)
  404. if int(i_res['freq']) > 4000:
  405. raise Exception("Unexpected channel - did not follow world roaming rules")
  406. remove_group(dev[0], dev[1])
  407. def test_grpform_no_5ghz_add_cli(dev):
  408. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1"""
  409. dev[0].request("SET p2p_add_cli_chan 1")
  410. dev[1].request("SET p2p_add_cli_chan 1")
  411. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  412. r_dev=dev[1], r_intent=14,
  413. test_data=False)
  414. check_grpform_results(i_res, r_res)
  415. if int(i_res['freq']) > 4000:
  416. raise Exception("Unexpected channel - did not follow world roaming rules")
  417. remove_group(dev[0], dev[1])
  418. def test_grpform_no_5ghz_add_cli2(dev):
  419. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (reverse)"""
  420. dev[0].request("SET p2p_add_cli_chan 1")
  421. dev[1].request("SET p2p_add_cli_chan 1")
  422. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=14,
  423. r_dev=dev[1], r_intent=0,
  424. test_data=False)
  425. check_grpform_results(i_res, r_res)
  426. if int(i_res['freq']) > 4000:
  427. raise Exception("Unexpected channel - did not follow world roaming rules")
  428. remove_group(dev[0], dev[1])
  429. def test_grpform_no_5ghz_add_cli3(dev):
  430. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (intent 15)"""
  431. dev[0].request("SET p2p_add_cli_chan 1")
  432. dev[1].request("SET p2p_add_cli_chan 1")
  433. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  434. r_dev=dev[1], r_intent=15,
  435. test_data=False)
  436. check_grpform_results(i_res, r_res)
  437. if int(i_res['freq']) > 4000:
  438. raise Exception("Unexpected channel - did not follow world roaming rules")
  439. remove_group(dev[0], dev[1])
  440. def test_grpform_no_5ghz_add_cli4(dev):
  441. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (reverse; intent 15)"""
  442. dev[0].request("SET p2p_add_cli_chan 1")
  443. dev[1].request("SET p2p_add_cli_chan 1")
  444. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  445. r_dev=dev[1], r_intent=0,
  446. test_data=False)
  447. check_grpform_results(i_res, r_res)
  448. if int(i_res['freq']) > 4000:
  449. raise Exception("Unexpected channel - did not follow world roaming rules")
  450. remove_group(dev[0], dev[1])
  451. def test_grpform_incorrect_pin(dev):
  452. """P2P GO Negotiation with incorrect PIN"""
  453. dev[1].p2p_listen()
  454. addr1 = dev[1].p2p_dev_addr()
  455. if not dev[0].discover_peer(addr1):
  456. raise Exception("Peer not found")
  457. res = dev[1].request("P2P_CONNECT " + dev[0].p2p_dev_addr() + " pin auth go_intent=0")
  458. if "FAIL" in res:
  459. raise Exception("P2P_CONNECT failed to generate PIN")
  460. logger.info("PIN from P2P_CONNECT: " + res)
  461. dev[0].request("P2P_CONNECT " + addr1 + " 00000000 enter go_intent=15")
  462. ev = dev[0].wait_global_event(["P2P-GO-NEG-SUCCESS"], timeout=15)
  463. if ev is None:
  464. raise Exception("GO Negotiation did not complete successfully(0)")
  465. ev = dev[1].wait_global_event(["P2P-GO-NEG-SUCCESS"], timeout=15)
  466. if ev is None:
  467. raise Exception("GO Negotiation did not complete successfully(1)")
  468. ev = dev[1].wait_event(["WPS-FAIL"], timeout=15)
  469. if ev is None:
  470. raise Exception("WPS failure not reported(1)")
  471. if "msg=8 config_error=18" not in ev:
  472. raise Exception("Unexpected WPS failure(1): " + ev)
  473. ev = dev[0].wait_event(["WPS-FAIL"], timeout=15)
  474. if ev is None:
  475. raise Exception("WPS failure not reported")
  476. if "msg=8 config_error=18" not in ev:
  477. raise Exception("Unexpected WPS failure: " + ev)
  478. ev = dev[1].wait_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=10)
  479. if ev is None:
  480. raise Exception("Group formation failure timed out")
  481. ev = dev[0].wait_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=5)
  482. if ev is None:
  483. raise Exception("Group formation failure timed out")
  484. def test_grpform_reject(dev):
  485. """User rejecting group formation attempt by a P2P peer"""
  486. addr0 = dev[0].p2p_dev_addr()
  487. dev[0].p2p_listen()
  488. dev[1].p2p_go_neg_init(addr0, None, "pbc")
  489. ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  490. if ev is None:
  491. raise Exception("GO Negotiation timed out")
  492. if "OK" in dev[0].global_request("P2P_REJECT foo"):
  493. raise Exception("Invalid P2P_REJECT accepted")
  494. if "FAIL" in dev[0].global_request("P2P_REJECT " + ev.split(' ')[1]):
  495. raise Exception("P2P_REJECT failed")
  496. dev[1].request("P2P_STOP_FIND")
  497. dev[1].p2p_go_neg_init(addr0, None, "pbc")
  498. ev = dev[1].wait_global_event(["GO-NEG-FAILURE"], timeout=10)
  499. if ev is None:
  500. raise Exception("Rejection not reported")
  501. if "status=11" not in ev:
  502. raise Exception("Unexpected status code in rejection")
  503. def test_grpform_pd_no_probe_resp(dev):
  504. """GO Negotiation after PD, but no Probe Response"""
  505. addr0 = dev[0].p2p_dev_addr()
  506. addr1 = dev[1].p2p_dev_addr()
  507. dev[0].p2p_listen()
  508. if not dev[1].discover_peer(addr0):
  509. raise Exception("Peer not found")
  510. dev[1].p2p_stop_find()
  511. dev[0].p2p_stop_find()
  512. peer = dev[0].get_peer(addr1)
  513. if peer['listen_freq'] == '0':
  514. raise Exception("Peer listen frequency not learned from Probe Request")
  515. time.sleep(0.3)
  516. dev[0].request("P2P_FLUSH")
  517. dev[0].p2p_listen()
  518. dev[1].global_request("P2P_PROV_DISC " + addr0 + " display")
  519. ev = dev[0].wait_global_event(["P2P-PROV-DISC-SHOW-PIN"], timeout=5)
  520. if ev is None:
  521. raise Exception("PD Request timed out")
  522. ev = dev[1].wait_global_event(["P2P-PROV-DISC-ENTER-PIN"], timeout=5)
  523. if ev is None:
  524. raise Exception("PD Response timed out")
  525. peer = dev[0].get_peer(addr1)
  526. if peer['listen_freq'] != '0':
  527. raise Exception("Peer listen frequency learned unexpectedly from PD Request")
  528. pin = dev[0].wps_read_pin()
  529. if "FAIL" in dev[1].request("P2P_CONNECT " + addr0 + " " + pin + " enter"):
  530. raise Exception("P2P_CONNECT on initiator failed")
  531. ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=5)
  532. if ev is None:
  533. raise Exception("GO Negotiation start timed out")
  534. peer = dev[0].get_peer(addr1)
  535. if peer['listen_freq'] == '0':
  536. raise Exception("Peer listen frequency not learned from PD followed by GO Neg Req")
  537. if "FAIL" in dev[0].request("P2P_CONNECT " + addr1 + " " + pin + " display"):
  538. raise Exception("P2P_CONNECT on responder failed")
  539. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  540. if ev is None:
  541. raise Exception("Group formation timed out")
  542. ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  543. if ev is None:
  544. raise Exception("Group formation timed out")
  545. def test_go_neg_two_peers(dev):
  546. """P2P GO Negotiation rejected due to already started negotiation with another peer"""
  547. addr0 = dev[0].p2p_dev_addr()
  548. addr1 = dev[1].p2p_dev_addr()
  549. addr2 = dev[2].p2p_dev_addr()
  550. dev[1].p2p_listen()
  551. dev[2].p2p_listen()
  552. if not dev[0].discover_peer(addr1):
  553. raise Exception("Could not discover peer")
  554. if not dev[0].discover_peer(addr2):
  555. raise Exception("Could not discover peer")
  556. if "OK" not in dev[0].request("P2P_CONNECT " + addr2 + " pbc auth"):
  557. raise Exception("Failed to authorize GO Neg")
  558. dev[0].p2p_listen()
  559. if not dev[2].discover_peer(addr0):
  560. raise Exception("Could not discover peer")
  561. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " pbc"):
  562. raise Exception("Failed to initiate GO Neg")
  563. ev = dev[1].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=5)
  564. if ev is None:
  565. raise Exception("timeout on GO Neg RX event")
  566. dev[2].request("P2P_CONNECT " + addr0 + " pbc")
  567. ev = dev[2].wait_global_event(["GO-NEG-FAILURE"], timeout=10)
  568. if ev is None:
  569. raise Exception("Rejection not reported")
  570. if "status=5" not in ev:
  571. raise Exception("Unexpected status code in rejection: " + ev)
  572. def clear_pbc_overlap(dev, ifname):
  573. hapd_global = hostapd.HostapdGlobal()
  574. hapd_global.remove(ifname)
  575. dev[0].request("P2P_CANCEL")
  576. dev[1].request("P2P_CANCEL")
  577. dev[0].p2p_stop_find()
  578. dev[1].p2p_stop_find()
  579. dev[0].dump_monitor()
  580. dev[1].dump_monitor()
  581. time.sleep(0.1)
  582. dev[0].flush_scan_cache()
  583. dev[1].flush_scan_cache()
  584. time.sleep(0.1)
  585. def test_grpform_pbc_overlap(dev, apdev):
  586. """P2P group formation during PBC overlap"""
  587. params = { "ssid": "wps", "eap_server": "1", "wps_state": "1" }
  588. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  589. hapd.request("WPS_PBC")
  590. time.sleep(0.1)
  591. # Since P2P Client scan case is now optimzied to use a specific SSID, the
  592. # WPS AP will not reply to that and the scan after GO Negotiation can quite
  593. # likely miss the AP due to dwell time being short enoguh to miss the Beacon
  594. # frame. This has made the test case somewhat pointless, but keep it here
  595. # for now with an additional scan to confirm that PBC detection works if
  596. # there is a BSS entry for a overlapping AP.
  597. for i in range(0, 5):
  598. dev[0].scan(freq="2412")
  599. if dev[0].get_bss(apdev[0]['bssid']) is not None:
  600. break
  601. addr0 = dev[0].p2p_dev_addr()
  602. addr1 = dev[1].p2p_dev_addr()
  603. dev[0].p2p_listen()
  604. if not dev[1].discover_peer(addr0):
  605. raise Exception("Could not discover peer")
  606. dev[1].p2p_listen()
  607. if not dev[0].discover_peer(addr1):
  608. raise Exception("Could not discover peer")
  609. dev[0].p2p_listen()
  610. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " pbc auth go_intent=0"):
  611. raise Exception("Failed to authorize GO Neg")
  612. if "OK" not in dev[1].request("P2P_CONNECT " + addr0 + " pbc go_intent=15 freq=2412"):
  613. raise Exception("Failed to initiate GO Neg")
  614. ev = dev[0].wait_global_event(["WPS-OVERLAP-DETECTED"], timeout=15)
  615. if ev is None:
  616. raise Exception("PBC overlap not reported")
  617. clear_pbc_overlap(dev, apdev[0]['ifname'])
  618. def test_grpform_pbc_overlap_group_iface(dev, apdev):
  619. """P2P group formation during PBC overlap using group interfaces"""
  620. # Note: Need to include P2P IE from the AP to get the P2P interface BSS
  621. # update use this information.
  622. params = { "ssid": "wps", "eap_server": "1", "wps_state": "1",
  623. "beacon_int": "15", 'manage_p2p': '1' }
  624. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  625. hapd.request("WPS_PBC")
  626. dev[0].request("SET p2p_no_group_iface 0")
  627. dev[1].request("SET p2p_no_group_iface 0")
  628. addr0 = dev[0].p2p_dev_addr()
  629. addr1 = dev[1].p2p_dev_addr()
  630. dev[0].p2p_listen()
  631. if not dev[1].discover_peer(addr0):
  632. raise Exception("Could not discover peer")
  633. dev[1].p2p_listen()
  634. if not dev[0].discover_peer(addr1):
  635. raise Exception("Could not discover peer")
  636. dev[0].p2p_stop_find()
  637. dev[0].scan(freq="2412")
  638. dev[0].p2p_listen()
  639. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " pbc auth go_intent=0"):
  640. raise Exception("Failed to authorize GO Neg")
  641. if "OK" not in dev[1].request("P2P_CONNECT " + addr0 + " pbc go_intent=15 freq=2412"):
  642. raise Exception("Failed to initiate GO Neg")
  643. ev = dev[0].wait_global_event(["WPS-OVERLAP-DETECTED",
  644. "P2P-GROUP-FORMATION-SUCCESS"], timeout=15)
  645. if ev is None or "WPS-OVERLAP-DETECTED" not in ev:
  646. # Do not report this as failure since the P2P group formation case
  647. # using a separate group interface has limited chances of "seeing" the
  648. # overlapping AP due to a per-SSID scan and no prior scan operations on
  649. # the group interface.
  650. logger.info("PBC overlap not reported")
  651. clear_pbc_overlap(dev, apdev[0]['ifname'])
  652. def test_grpform_goneg_fail_with_group_iface(dev):
  653. """P2P group formation fails while using group interface"""
  654. dev[0].request("SET p2p_no_group_iface 0")
  655. dev[1].p2p_listen()
  656. peer = dev[1].p2p_dev_addr()
  657. if not dev[0].discover_peer(peer):
  658. raise Exception("Peer " + peer + " not found")
  659. if "OK" not in dev[1].request("P2P_REJECT " + dev[0].p2p_dev_addr()):
  660. raise Exception("P2P_REJECT failed")
  661. if "OK" not in dev[0].request("P2P_CONNECT " + peer + " pbc"):
  662. raise Exception("P2P_CONNECT failed")
  663. ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=10)
  664. if ev is None:
  665. raise Exception("GO Negotiation failure timed out")
  666. def test_grpform_cred_ready_timeout(dev, apdev, params):
  667. """P2P GO Negotiation wait for credentials to become ready [long]"""
  668. if not params['long']:
  669. logger.info("Skip test case with long duration due to --long not specified")
  670. return "skip"
  671. dev[1].p2p_listen()
  672. addr1 = dev[1].p2p_dev_addr()
  673. if not dev[0].discover_peer(addr1):
  674. raise Exception("Peer " + addr1 + " not found")
  675. if not dev[2].discover_peer(addr1):
  676. raise Exception("Peer " + addr1 + " not found(2)")
  677. start = os.times()[4]
  678. cmd = "P2P_CONNECT " + addr1 + " 12345670 display"
  679. if "OK" not in dev[0].global_request(cmd):
  680. raise Exception("Failed to initiate GO Neg")
  681. if "OK" not in dev[2].global_request(cmd):
  682. raise Exception("Failed to initiate GO Neg(2)")
  683. # First, check with p2p_find
  684. ev = dev[2].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=30)
  685. if ev is not None:
  686. raise Exception("Too early GO Negotiation timeout reported(2)")
  687. dev[2].dump_monitor()
  688. logger.info("Starting p2p_find to change state")
  689. dev[2].p2p_find()
  690. ev = dev[2].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=100)
  691. if ev is None:
  692. raise Exception("GO Negotiation failure timed out(2)")
  693. dev[2].dump_monitor()
  694. end = os.times()[4]
  695. logger.info("GO Negotiation wait time: {} seconds(2)".format(end - start))
  696. if end - start < 120:
  697. raise Exception("Too short GO Negotiation wait time(2): {}".format(end - start))
  698. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  699. wpas.interface_add("wlan5")
  700. wpas.p2p_listen()
  701. ev = dev[2].wait_global_event(["P2P-DEVICE-FOUND"], timeout=10)
  702. if ev is None:
  703. raise Exception("Did not discover new device after GO Negotiation failure")
  704. if wpas.p2p_dev_addr() not in ev:
  705. raise Exception("Unexpected device found: " + ev)
  706. dev[2].p2p_stop_find()
  707. wpas.p2p_stop_find()
  708. # Finally, verify without p2p_find
  709. ev = dev[0].wait_global_event(["P2P-GO-NEG-FAILURE"], timeout=120)
  710. if ev is None:
  711. raise Exception("GO Negotiation failure timed out")
  712. end = os.times()[4]
  713. logger.info("GO Negotiation wait time: {} seconds".format(end - start))
  714. if end - start < 120:
  715. raise Exception("Too short GO Negotiation wait time: {}".format(end - start))
  716. def test_grpform_no_wsc_done(dev):
  717. """P2P group formation with WSC-Done not sent"""
  718. addr0 = dev[0].p2p_dev_addr()
  719. addr1 = dev[1].p2p_dev_addr()
  720. for i in range(0, 2):
  721. dev[0].request("SET ext_eapol_frame_io 1")
  722. dev[1].request("SET ext_eapol_frame_io 1")
  723. dev[0].p2p_listen()
  724. dev[1].p2p_go_neg_auth(addr0, "12345670", "display", 0)
  725. dev[1].p2p_listen()
  726. dev[0].p2p_go_neg_init(addr1, "12345670", "enter", timeout=20,
  727. go_intent=15, wait_group=False)
  728. mode = None
  729. while True:
  730. ev = dev[0].wait_event(["EAPOL-TX"], timeout=15)
  731. if ev is None:
  732. raise Exception("Timeout on EAPOL-TX from GO")
  733. if not mode:
  734. mode = dev[0].get_status_field("mode")
  735. res = dev[1].request("EAPOL_RX " + addr0 + " " + ev.split(' ')[2])
  736. if "OK" not in res:
  737. raise Exception("EAPOL_RX failed")
  738. ev = dev[1].wait_event(["EAPOL-TX"], timeout=15)
  739. if ev is None:
  740. raise Exception("Timeout on EAPOL-TX from P2P Client")
  741. msg = ev.split(' ')[2]
  742. if msg[46:56] == "102200010f":
  743. logger.info("Drop WSC_Done")
  744. dev[0].request("SET ext_eapol_frame_io 0")
  745. dev[1].request("SET ext_eapol_frame_io 0")
  746. # Fake EAP-Failure to complete session on the client
  747. id = msg[10:12]
  748. dev[1].request("EAPOL_RX " + addr0 + " 0300000404" + id + "0004")
  749. break
  750. res = dev[0].request("EAPOL_RX " + addr1 + " " + msg)
  751. if "OK" not in res:
  752. raise Exception("EAPOL_RX failed")
  753. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  754. if ev is None:
  755. raise Exception("Group formation timed out on GO")
  756. ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  757. if ev is None:
  758. raise Exception("Group formation timed out on P2P Client")
  759. dev[0].remove_group()
  760. if mode != "P2P GO - group formation":
  761. raise Exception("Unexpected mode on GO during group formation: " + mode)
  762. def test_grpform_wait_peer(dev):
  763. """P2P group formation wait for peer to become ready"""
  764. addr0 = dev[0].p2p_dev_addr()
  765. addr1 = dev[1].p2p_dev_addr()
  766. dev[1].p2p_listen()
  767. if not dev[0].discover_peer(addr1):
  768. raise Exception("Peer " + addr1 + " not found")
  769. dev[0].request("SET extra_roc_dur 500")
  770. if "OK" not in dev[0].request("P2P_CONNECT " + addr1 + " 12345670 display go_intent=15"):
  771. raise Exception("Failed to initiate GO Neg")
  772. time.sleep(3)
  773. dev[1].request("P2P_CONNECT " + addr0 + " 12345670 enter go_intent=0")
  774. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  775. if ev is None:
  776. raise Exception("Group formation timed out")
  777. dev[0].request("SET extra_roc_dur 0")
  778. ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  779. if ev is None:
  780. raise Exception("Group formation timed out")
  781. dev[0].remove_group()
  782. def test_invalid_p2p_connect_command(dev):
  783. """P2P_CONNECT error cases"""
  784. id = dev[0].add_network()
  785. for cmd in [ "foo",
  786. "00:11:22:33:44:55",
  787. "00:11:22:33:44:55 pbc persistent=123",
  788. "00:11:22:33:44:55 pbc persistent=%d" % id,
  789. "00:11:22:33:44:55 pbc go_intent=-1",
  790. "00:11:22:33:44:55 pbc go_intent=16",
  791. "00:11:22:33:44:55 pin",
  792. "00:11:22:33:44:55 pbc freq=0" ]:
  793. if "FAIL" not in dev[0].request("P2P_CONNECT " + cmd):
  794. raise Exception("Invalid P2P_CONNECT command accepted: " + cmd)
  795. if "FAIL-INVALID-PIN" not in dev[0].request("P2P_CONNECT 00:11:22:33:44:55 1234567"):
  796. raise Exception("Invalid PIN was not rejected")
  797. if "FAIL-CHANNEL-UNSUPPORTED" not in dev[0].request("P2P_CONNECT 00:11:22:33:44:55 pin freq=3000"):
  798. raise Exception("Unsupported channel not reported")
  799. def test_p2p_unauthorize(dev):
  800. """P2P_UNAUTHORIZE to unauthorize a peer"""
  801. if "FAIL" not in dev[0].request("P2P_UNAUTHORIZE foo"):
  802. raise Exception("Invalid P2P_UNAUTHORIZE accepted")
  803. if "FAIL" not in dev[0].request("P2P_UNAUTHORIZE 00:11:22:33:44:55"):
  804. raise Exception("P2P_UNAUTHORIZE for unknown peer accepted")
  805. addr0 = dev[0].p2p_dev_addr()
  806. addr1 = dev[1].p2p_dev_addr()
  807. dev[1].p2p_listen()
  808. pin = dev[0].wps_read_pin()
  809. dev[0].p2p_go_neg_auth(addr1, pin, "display")
  810. dev[0].p2p_listen()
  811. if "OK" not in dev[0].request("P2P_UNAUTHORIZE " + addr1):
  812. raise Exception("P2P_UNAUTHORIZE failed")
  813. dev[1].p2p_go_neg_init(addr0, pin, "keypad", timeout=0)
  814. ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=10)
  815. if ev is None:
  816. raise Exception("No GO Negotiation Request RX reported")