test_p2p_grpform.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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 hwsim_utils
  12. import utils
  13. def check_grpform_results(i_res, r_res):
  14. if i_res['result'] != 'success' or r_res['result'] != 'success':
  15. raise Exception("Failed group formation")
  16. if i_res['ssid'] != r_res['ssid']:
  17. raise Exception("SSID mismatch")
  18. if i_res['freq'] != r_res['freq']:
  19. raise Exception("freq mismatch")
  20. if 'go_neg_freq' in r_res and i_res['go_neg_freq'] != r_res['go_neg_freq']:
  21. raise Exception("go_neg_freq mismatch")
  22. if i_res['freq'] != i_res['go_neg_freq']:
  23. raise Exception("freq/go_neg_freq mismatch")
  24. if i_res['role'] != i_res['go_neg_role']:
  25. raise Exception("role/go_neg_role mismatch")
  26. if 'go_neg_role' in r_res and r_res['role'] != r_res['go_neg_role']:
  27. raise Exception("role/go_neg_role mismatch")
  28. if i_res['go_dev_addr'] != r_res['go_dev_addr']:
  29. raise Exception("GO Device Address mismatch")
  30. def go_neg_init(i_dev, r_dev, pin, i_method, i_intent, res):
  31. logger.debug("Initiate GO Negotiation from i_dev")
  32. try:
  33. i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), pin, i_method, timeout=20, go_intent=i_intent)
  34. logger.debug("i_res: " + str(i_res))
  35. except Exception, e:
  36. i_res = None
  37. logger.info("go_neg_init thread caught an exception from p2p_go_neg_init: " + str(e))
  38. res.put(i_res)
  39. def go_neg_pin(i_dev, r_dev, i_intent=None, r_intent=None, i_method='enter', r_method='display'):
  40. r_dev.p2p_listen()
  41. i_dev.p2p_listen()
  42. pin = r_dev.wps_read_pin()
  43. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  44. r_dev.dump_monitor()
  45. res = Queue.Queue()
  46. t = threading.Thread(target=go_neg_init, args=(i_dev, r_dev, pin, i_method, i_intent, res))
  47. t.start()
  48. logger.debug("Wait for GO Negotiation Request on r_dev")
  49. ev = r_dev.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  50. if ev is None:
  51. raise Exception("GO Negotiation timed out")
  52. r_dev.dump_monitor()
  53. logger.debug("Re-initiate GO Negotiation from r_dev")
  54. r_res = r_dev.p2p_go_neg_init(i_dev.p2p_dev_addr(), pin, r_method, go_intent=r_intent, timeout=20)
  55. logger.debug("r_res: " + str(r_res))
  56. r_dev.dump_monitor()
  57. t.join()
  58. i_res = res.get()
  59. if i_res is None:
  60. raise Exception("go_neg_init thread failed")
  61. logger.debug("i_res: " + str(i_res))
  62. logger.info("Group formed")
  63. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  64. i_dev.dump_monitor()
  65. return [i_res, r_res]
  66. 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):
  67. r_dev.p2p_listen()
  68. i_dev.p2p_listen()
  69. pin = r_dev.wps_read_pin()
  70. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  71. r_dev.p2p_go_neg_auth(i_dev.p2p_dev_addr(), pin, r_method, go_intent=r_intent, freq=r_freq)
  72. 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)
  73. r_res = r_dev.p2p_go_neg_auth_result(expect_failure=expect_failure)
  74. logger.debug("i_res: " + str(i_res))
  75. logger.debug("r_res: " + str(r_res))
  76. r_dev.dump_monitor()
  77. i_dev.dump_monitor()
  78. if i_go_neg_status:
  79. if i_res['result'] != 'go-neg-failed':
  80. raise Exception("Expected GO Negotiation failure not reported")
  81. if i_res['status'] != i_go_neg_status:
  82. raise Exception("Expected GO Negotiation status not seen")
  83. if expect_failure:
  84. return
  85. logger.info("Group formed")
  86. if test_data:
  87. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  88. return [i_res, r_res]
  89. def go_neg_init_pbc(i_dev, r_dev, i_intent, res, freq):
  90. logger.debug("Initiate GO Negotiation from i_dev")
  91. try:
  92. i_res = i_dev.p2p_go_neg_init(r_dev.p2p_dev_addr(), None, "pbc",
  93. timeout=20, go_intent=i_intent, freq=freq)
  94. logger.debug("i_res: " + str(i_res))
  95. except Exception, e:
  96. i_res = None
  97. logger.info("go_neg_init_pbc thread caught an exception from p2p_go_neg_init: " + str(e))
  98. res.put(i_res)
  99. def go_neg_pbc(i_dev, r_dev, i_intent=None, r_intent=None, i_freq=None, r_freq=None):
  100. r_dev.p2p_find(social=True)
  101. i_dev.p2p_find(social=True)
  102. logger.info("Start GO negotiation " + i_dev.ifname + " -> " + r_dev.ifname)
  103. r_dev.dump_monitor()
  104. res = Queue.Queue()
  105. t = threading.Thread(target=go_neg_init_pbc, args=(i_dev, r_dev, i_intent, res, i_freq))
  106. t.start()
  107. logger.debug("Wait for GO Negotiation Request on r_dev")
  108. ev = r_dev.wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  109. if ev is None:
  110. raise Exception("GO Negotiation timed out")
  111. r_dev.dump_monitor()
  112. logger.debug("Re-initiate GO Negotiation from r_dev")
  113. r_res = r_dev.p2p_go_neg_init(i_dev.p2p_dev_addr(), None, "pbc",
  114. go_intent=r_intent, timeout=20, freq=r_freq)
  115. logger.debug("r_res: " + str(r_res))
  116. r_dev.dump_monitor()
  117. t.join()
  118. i_res = res.get()
  119. if i_res is None:
  120. raise Exception("go_neg_init_pbc thread failed")
  121. logger.debug("i_res: " + str(i_res))
  122. logger.info("Group formed")
  123. hwsim_utils.test_connectivity_p2p(r_dev, i_dev)
  124. i_dev.dump_monitor()
  125. return [i_res, r_res]
  126. def remove_group(dev1, dev2):
  127. dev1.remove_group()
  128. try:
  129. dev2.remove_group()
  130. except:
  131. pass
  132. def test_grpform(dev):
  133. """P2P group formation using PIN and authorized connection (init -> GO)"""
  134. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  135. r_dev=dev[1], r_intent=0)
  136. check_grpform_results(i_res, r_res)
  137. remove_group(dev[0], dev[1])
  138. def test_grpform_a(dev):
  139. """P2P group formation using PIN and authorized connection (init -> GO) (init: group iface)"""
  140. dev[0].request("SET p2p_no_group_iface 0")
  141. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  142. r_dev=dev[1], r_intent=0)
  143. if "p2p-wlan" not in i_res['ifname']:
  144. raise Exception("Unexpected group interface name")
  145. check_grpform_results(i_res, r_res)
  146. remove_group(dev[0], dev[1])
  147. if i_res['ifname'] in utils.get_ifnames():
  148. raise Exception("Group interface netdev was not removed")
  149. def test_grpform_b(dev):
  150. """P2P group formation using PIN and authorized connection (init -> GO) (resp: group iface)"""
  151. dev[1].request("SET p2p_no_group_iface 0")
  152. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  153. r_dev=dev[1], r_intent=0)
  154. if "p2p-wlan" not in r_res['ifname']:
  155. raise Exception("Unexpected group interface name")
  156. check_grpform_results(i_res, r_res)
  157. remove_group(dev[0], dev[1])
  158. if r_res['ifname'] in utils.get_ifnames():
  159. raise Exception("Group interface netdev was not removed")
  160. def test_grpform_c(dev):
  161. """P2P group formation using PIN and authorized connection (init -> GO) (group iface)"""
  162. dev[0].request("SET p2p_no_group_iface 0")
  163. dev[1].request("SET p2p_no_group_iface 0")
  164. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  165. r_dev=dev[1], r_intent=0)
  166. if "p2p-wlan" not in i_res['ifname']:
  167. raise Exception("Unexpected group interface name")
  168. if "p2p-wlan" not in r_res['ifname']:
  169. raise Exception("Unexpected group interface name")
  170. check_grpform_results(i_res, r_res)
  171. remove_group(dev[0], dev[1])
  172. if i_res['ifname'] in utils.get_ifnames():
  173. raise Exception("Group interface netdev was not removed")
  174. if r_res['ifname'] in utils.get_ifnames():
  175. raise Exception("Group interface netdev was not removed")
  176. def test_grpform2(dev):
  177. """P2P group formation using PIN and authorized connection (resp -> GO)"""
  178. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
  179. remove_group(dev[0], dev[1])
  180. def test_grpform2_c(dev):
  181. """P2P group formation using PIN and authorized connection (resp -> GO) (group iface)"""
  182. dev[0].request("SET p2p_no_group_iface 0")
  183. dev[1].request("SET p2p_no_group_iface 0")
  184. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0, r_dev=dev[1], r_intent=15)
  185. remove_group(dev[0], dev[1])
  186. if i_res['ifname'] in utils.get_ifnames():
  187. raise Exception("Group interface netdev was not removed")
  188. if r_res['ifname'] in utils.get_ifnames():
  189. raise Exception("Group interface netdev was not removed")
  190. def test_grpform3(dev):
  191. """P2P group formation using PIN and re-init GO Negotiation"""
  192. go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  193. remove_group(dev[0], dev[1])
  194. def test_grpform3_c(dev):
  195. """P2P group formation using PIN and re-init GO Negotiation (group iface)"""
  196. dev[0].request("SET p2p_no_group_iface 0")
  197. dev[1].request("SET p2p_no_group_iface 0")
  198. [i_res, r_res] = go_neg_pin(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  199. remove_group(dev[0], dev[1])
  200. if i_res['ifname'] in utils.get_ifnames():
  201. raise Exception("Group interface netdev was not removed")
  202. if r_res['ifname'] in utils.get_ifnames():
  203. raise Exception("Group interface netdev was not removed")
  204. def test_grpform_pbc(dev):
  205. """P2P group formation using PBC and re-init GO Negotiation"""
  206. [i_res, r_res] = go_neg_pbc(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  207. check_grpform_results(i_res, r_res)
  208. if i_res['role'] != 'GO' or r_res['role'] != 'client':
  209. raise Exception("Unexpected device roles")
  210. remove_group(dev[0], dev[1])
  211. def test_both_go_intent_15(dev):
  212. """P2P GO Negotiation with both devices using GO intent 15"""
  213. 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)
  214. def test_both_go_neg_display(dev):
  215. """P2P GO Negotiation with both devices trying to display PIN"""
  216. 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')
  217. def test_both_go_neg_enter(dev):
  218. """P2P GO Negotiation with both devices trying to enter PIN"""
  219. 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')
  220. def test_grpform_per_sta_psk(dev):
  221. """P2P group formation with per-STA PSKs"""
  222. dev[0].request("P2P_SET per_sta_psk 1")
  223. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  224. check_grpform_results(i_res, r_res)
  225. pin = dev[2].wps_read_pin()
  226. dev[0].p2p_go_authorize_client(pin)
  227. c_res = dev[2].p2p_connect_group(dev[0].p2p_dev_addr(), pin, timeout=60)
  228. check_grpform_results(i_res, c_res)
  229. if r_res['psk'] == c_res['psk']:
  230. raise Exception("Same PSK assigned for both clients")
  231. hwsim_utils.test_connectivity_p2p(dev[1], dev[2])
  232. dev[0].remove_group()
  233. dev[1].wait_go_ending_session()
  234. dev[2].wait_go_ending_session()
  235. def test_grpform_per_sta_psk_wps(dev):
  236. """P2P group formation with per-STA PSKs with non-P2P WPS STA"""
  237. dev[0].request("P2P_SET per_sta_psk 1")
  238. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15, r_dev=dev[1], r_intent=0)
  239. check_grpform_results(i_res, r_res)
  240. dev[0].p2p_go_authorize_client_pbc()
  241. dev[2].request("WPS_PBC")
  242. ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=30)
  243. if ev is None:
  244. raise Exception("Association with the GO timed out")
  245. hwsim_utils.test_connectivity_p2p_sta(dev[1], dev[2])
  246. dev[0].remove_group()
  247. dev[2].request("DISCONNECT")
  248. dev[1].wait_go_ending_session()
  249. def test_grpform_force_chan_go(dev):
  250. """P2P group formation forced channel selection by GO"""
  251. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  252. i_freq=2432,
  253. r_dev=dev[1], r_intent=0,
  254. test_data=False)
  255. check_grpform_results(i_res, r_res)
  256. if i_res['freq'] != "2432":
  257. raise Exception("Unexpected channel - did not follow GO's forced channel")
  258. remove_group(dev[0], dev[1])
  259. def test_grpform_force_chan_cli(dev):
  260. """P2P group formation forced channel selection by client"""
  261. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  262. i_freq=2417,
  263. r_dev=dev[1], r_intent=15,
  264. test_data=False)
  265. check_grpform_results(i_res, r_res)
  266. if i_res['freq'] != "2417":
  267. raise Exception("Unexpected channel - did not follow GO's forced channel")
  268. remove_group(dev[0], dev[1])
  269. def test_grpform_force_chan_conflict(dev):
  270. """P2P group formation fails due to forced channel mismatch"""
  271. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, i_freq=2422,
  272. r_dev=dev[1], r_intent=15, r_freq=2427,
  273. expect_failure=True, i_go_neg_status=7)
  274. def test_grpform_pref_chan_go(dev):
  275. """P2P group formation preferred channel selection by GO"""
  276. dev[0].request("SET p2p_pref_chan 81:7")
  277. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  278. r_dev=dev[1], r_intent=0,
  279. test_data=False)
  280. check_grpform_results(i_res, r_res)
  281. if i_res['freq'] != "2442":
  282. raise Exception("Unexpected channel - did not follow GO's p2p_pref_chan")
  283. remove_group(dev[0], dev[1])
  284. def test_grpform_pref_chan_go_overridden(dev):
  285. """P2P group formation preferred channel selection by GO overridden by client"""
  286. dev[1].request("SET p2p_pref_chan 81:7")
  287. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  288. i_freq=2422,
  289. r_dev=dev[1], r_intent=15,
  290. test_data=False)
  291. check_grpform_results(i_res, r_res)
  292. if i_res['freq'] != "2422":
  293. raise Exception("Unexpected channel - did not follow client's forced channel")
  294. remove_group(dev[0], dev[1])
  295. def test_grpform_no_go_freq_forcing_chan(dev):
  296. """P2P group formation with no-GO freq forcing channel"""
  297. dev[1].request("SET p2p_no_go_freq 100-200,300,4000-6000")
  298. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  299. r_dev=dev[1], r_intent=15,
  300. test_data=False)
  301. check_grpform_results(i_res, r_res)
  302. if int(i_res['freq']) > 4000:
  303. raise Exception("Unexpected channel - did not follow no-GO freq")
  304. remove_group(dev[0], dev[1])
  305. def test_grpform_no_go_freq_conflict(dev):
  306. """P2P group formation fails due to no-GO range forced by client"""
  307. dev[1].request("SET p2p_no_go_freq 2000-3000")
  308. go_neg_pin_authorized(i_dev=dev[0], i_intent=0, i_freq=2422,
  309. r_dev=dev[1], r_intent=15,
  310. expect_failure=True, i_go_neg_status=7)
  311. def test_grpform_no_5ghz_world_roaming(dev):
  312. """P2P group formation with world roaming regulatory"""
  313. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  314. r_dev=dev[1], r_intent=15,
  315. test_data=False)
  316. check_grpform_results(i_res, r_res)
  317. if int(i_res['freq']) > 4000:
  318. raise Exception("Unexpected channel - did not follow world roaming rules")
  319. remove_group(dev[0], dev[1])
  320. def test_grpform_no_5ghz_add_cli(dev):
  321. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1"""
  322. dev[0].request("SET p2p_add_cli_chan 1")
  323. dev[1].request("SET p2p_add_cli_chan 1")
  324. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  325. r_dev=dev[1], r_intent=14,
  326. test_data=False)
  327. check_grpform_results(i_res, r_res)
  328. if int(i_res['freq']) > 4000:
  329. raise Exception("Unexpected channel - did not follow world roaming rules")
  330. remove_group(dev[0], dev[1])
  331. def test_grpform_no_5ghz_add_cli2(dev):
  332. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (reverse)"""
  333. dev[0].request("SET p2p_add_cli_chan 1")
  334. dev[1].request("SET p2p_add_cli_chan 1")
  335. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=14,
  336. r_dev=dev[1], r_intent=0,
  337. test_data=False)
  338. check_grpform_results(i_res, r_res)
  339. if int(i_res['freq']) > 4000:
  340. raise Exception("Unexpected channel - did not follow world roaming rules")
  341. remove_group(dev[0], dev[1])
  342. def test_grpform_no_5ghz_add_cli3(dev):
  343. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (intent 15)"""
  344. dev[0].request("SET p2p_add_cli_chan 1")
  345. dev[1].request("SET p2p_add_cli_chan 1")
  346. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=0,
  347. r_dev=dev[1], r_intent=15,
  348. test_data=False)
  349. check_grpform_results(i_res, r_res)
  350. if int(i_res['freq']) > 4000:
  351. raise Exception("Unexpected channel - did not follow world roaming rules")
  352. remove_group(dev[0], dev[1])
  353. def test_grpform_no_5ghz_add_cli4(dev):
  354. """P2P group formation with passive scan 5 GHz and p2p_add_cli_chan=1 (reverse; intent 15)"""
  355. dev[0].request("SET p2p_add_cli_chan 1")
  356. dev[1].request("SET p2p_add_cli_chan 1")
  357. [i_res, r_res] = go_neg_pin_authorized(i_dev=dev[0], i_intent=15,
  358. r_dev=dev[1], r_intent=0,
  359. test_data=False)
  360. check_grpform_results(i_res, r_res)
  361. if int(i_res['freq']) > 4000:
  362. raise Exception("Unexpected channel - did not follow world roaming rules")
  363. remove_group(dev[0], dev[1])
  364. def test_grpform_incorrect_pin(dev):
  365. """P2P GO Negotiation with incorrect PIN"""
  366. dev[1].p2p_listen()
  367. pin = dev[1].wps_read_pin()
  368. addr1 = dev[1].p2p_dev_addr()
  369. if not dev[0].discover_peer(addr1):
  370. raise Exception("Peer not found")
  371. dev[1].p2p_go_neg_auth(dev[0].p2p_dev_addr(), pin, 'display', go_intent=0)
  372. dev[0].request("P2P_CONNECT " + addr1 + " 00000000 enter go_intent=15")
  373. ev = dev[1].wait_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=10)
  374. if ev is None:
  375. raise Exception("Group formation failure timed out")
  376. ev = dev[0].wait_event(["P2P-GROUP-FORMATION-FAILURE"], timeout=5)
  377. if ev is None:
  378. raise Exception("Group formation failure timed out")
  379. def test_grpform_reject(dev):
  380. """User rejecting group formation attempt by a P2P peer"""
  381. addr0 = dev[0].p2p_dev_addr()
  382. dev[0].p2p_listen()
  383. dev[1].p2p_go_neg_init(addr0, None, "pbc")
  384. ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=15)
  385. if ev is None:
  386. raise Exception("GO Negotiation timed out")
  387. if "FAIL" in dev[0].global_request("P2P_REJECT " + ev.split(' ')[1]):
  388. raise Exception("P2P_REJECT failed")
  389. dev[1].request("P2P_STOP_FIND")
  390. dev[1].p2p_go_neg_init(addr0, None, "pbc")
  391. ev = dev[1].wait_global_event(["GO-NEG-FAILURE"], timeout=10)
  392. if ev is None:
  393. raise Exception("Rejection not reported")
  394. if "status=11" not in ev:
  395. raise Exception("Unexpected status code in rejection")
  396. def test_grpform_pd_no_probe_resp(dev):
  397. """GO Negotiation after PD, but no Probe Response"""
  398. addr0 = dev[0].p2p_dev_addr()
  399. addr1 = dev[1].p2p_dev_addr()
  400. dev[0].p2p_listen()
  401. if not dev[1].discover_peer(addr0):
  402. raise Exception("Peer not found")
  403. dev[1].p2p_stop_find()
  404. dev[0].p2p_stop_find()
  405. peer = dev[0].get_peer(addr1)
  406. if peer['listen_freq'] == '0':
  407. raise Exception("Peer listen frequency not learned from Probe Request")
  408. time.sleep(0.3)
  409. dev[0].request("P2P_FLUSH")
  410. dev[0].p2p_listen()
  411. dev[1].global_request("P2P_PROV_DISC " + addr0 + " display")
  412. ev = dev[0].wait_global_event(["P2P-PROV-DISC-SHOW-PIN"], timeout=5)
  413. if ev is None:
  414. raise Exception("PD Request timed out")
  415. ev = dev[1].wait_global_event(["P2P-PROV-DISC-ENTER-PIN"], timeout=5)
  416. if ev is None:
  417. raise Exception("PD Response timed out")
  418. peer = dev[0].get_peer(addr1)
  419. if peer['listen_freq'] != '0':
  420. raise Exception("Peer listen frequency learned unexpectedly from PD Request")
  421. pin = dev[0].wps_read_pin()
  422. if "FAIL" in dev[1].request("P2P_CONNECT " + addr0 + " " + pin + " enter"):
  423. raise Exception("P2P_CONNECT on initiator failed")
  424. ev = dev[0].wait_global_event(["P2P-GO-NEG-REQUEST"], timeout=5)
  425. if ev is None:
  426. raise Exception("GO Negotiation start timed out")
  427. peer = dev[0].get_peer(addr1)
  428. if peer['listen_freq'] == '0':
  429. raise Exception("Peer listen frequency not learned from PD followed by GO Neg Req")
  430. if "FAIL" in dev[0].request("P2P_CONNECT " + addr1 + " " + pin + " display"):
  431. raise Exception("P2P_CONNECT on responder failed")
  432. ev = dev[0].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  433. if ev is None:
  434. raise Exception("Group formation timed out")
  435. ev = dev[1].wait_global_event(["P2P-GROUP-STARTED"], timeout=15)
  436. if ev is None:
  437. raise Exception("Group formation timed out")