test_wpas_ap.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. # wpa_supplicant AP mode tests
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import time
  7. import logging
  8. logger = logging.getLogger()
  9. import hwsim_utils
  10. from utils import HwsimSkip, alloc_fail
  11. from wpasupplicant import WpaSupplicant
  12. from test_p2p_channel import set_country
  13. def wait_ap_ready(dev):
  14. ev = dev.wait_event(["CTRL-EVENT-CONNECTED"])
  15. if ev is None:
  16. raise Exception("AP failed to start")
  17. def test_wpas_ap_open(dev):
  18. """wpa_supplicant AP mode - open network"""
  19. if "FAIL" not in dev[0].request("DEAUTHENTICATE 00:11:22:33:44:55"):
  20. raise Exception("Unexpected DEAUTHENTICATE accepted")
  21. if "FAIL" not in dev[0].request("DISASSOCIATE 00:11:22:33:44:55"):
  22. raise Exception("Unexpected DISASSOCIATE accepted")
  23. if "FAIL" not in dev[0].request("CHAN_SWITCH 0 2432"):
  24. raise Exception("Unexpected CHAN_SWITCH accepted")
  25. id = dev[0].add_network()
  26. dev[0].set_network(id, "mode", "2")
  27. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  28. dev[0].set_network(id, "key_mgmt", "NONE")
  29. dev[0].set_network(id, "frequency", "2412")
  30. dev[0].set_network(id, "scan_freq", "2412")
  31. dev[0].select_network(id)
  32. wait_ap_ready(dev[0])
  33. if "FAIL" not in dev[0].request("DEAUTHENTICATE foo"):
  34. raise Exception("Invalid DEAUTHENTICATE accepted")
  35. if "FAIL" not in dev[0].request("DISASSOCIATE foo"):
  36. raise Exception("Invalid DISASSOCIATE accepted")
  37. dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
  38. dev[2].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
  39. hwsim_utils.test_connectivity(dev[0], dev[1])
  40. hwsim_utils.test_connectivity(dev[1], dev[2])
  41. addr1 = dev[1].p2p_interface_addr()
  42. addr2 = dev[2].p2p_interface_addr()
  43. addrs = [ addr1, addr2 ]
  44. sta = dev[0].get_sta(None)
  45. if sta['addr'] not in addrs:
  46. raise Exception("Unexpected STA address")
  47. sta1 = dev[0].get_sta(sta['addr'])
  48. if sta1['addr'] not in addrs:
  49. raise Exception("Unexpected STA address")
  50. sta2 = dev[0].get_sta(sta['addr'], next=True)
  51. if sta2['addr'] not in addrs:
  52. raise Exception("Unexpected STA2 address")
  53. sta3 = dev[0].get_sta(sta2['addr'], next=True)
  54. if len(sta3) != 0:
  55. raise Exception("Unexpected STA iteration result (did not stop)")
  56. status = dev[0].get_status()
  57. if status['mode'] != "AP":
  58. raise Exception("Unexpected status mode")
  59. dev[1].dump_monitor()
  60. dev[2].dump_monitor()
  61. dev[0].request("DEAUTHENTICATE " + addr1)
  62. dev[0].request("DISASSOCIATE " + addr2)
  63. dev[1].wait_disconnected(timeout=10)
  64. dev[2].wait_disconnected(timeout=10)
  65. dev[1].wait_connected(timeout=10, error="Reconnection timed out")
  66. dev[2].wait_connected(timeout=10, error="Reconnection timed out")
  67. dev[1].request("DISCONNECT")
  68. dev[2].request("DISCONNECT")
  69. def test_wpas_ap_wep(dev):
  70. """wpa_supplicant AP mode - WEP"""
  71. id = dev[0].add_network()
  72. dev[0].set_network(id, "mode", "2")
  73. dev[0].set_network_quoted(id, "ssid", "wpas-ap-wep")
  74. dev[0].set_network(id, "key_mgmt", "NONE")
  75. dev[0].set_network(id, "frequency", "2412")
  76. dev[0].set_network(id, "scan_freq", "2412")
  77. dev[0].set_network_quoted(id, "wep_key0", "hello")
  78. dev[0].select_network(id)
  79. wait_ap_ready(dev[0])
  80. dev[1].connect("wpas-ap-wep", key_mgmt="NONE", wep_key0='"hello"',
  81. scan_freq="2412")
  82. hwsim_utils.test_connectivity(dev[0], dev[1])
  83. dev[1].request("DISCONNECT")
  84. def test_wpas_ap_no_ssid(dev):
  85. """wpa_supplicant AP mode - invalid network configuration"""
  86. id = dev[0].add_network()
  87. dev[0].set_network(id, "mode", "2")
  88. dev[0].set_network(id, "key_mgmt", "NONE")
  89. dev[0].set_network(id, "frequency", "2412")
  90. dev[0].set_network(id, "scan_freq", "2412")
  91. dev[0].select_network(id)
  92. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  93. if ev is not None:
  94. raise Exception("Unexpected AP start")
  95. def test_wpas_ap_default_frequency(dev):
  96. """wpa_supplicant AP mode - default frequency"""
  97. id = dev[0].add_network()
  98. dev[0].set_network(id, "mode", "2")
  99. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  100. dev[0].set_network(id, "key_mgmt", "NONE")
  101. dev[0].set_network(id, "scan_freq", "2412")
  102. dev[0].select_network(id)
  103. wait_ap_ready(dev[0])
  104. dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2462")
  105. dev[1].request("DISCONNECT")
  106. def test_wpas_ap_invalid_frequency(dev):
  107. """wpa_supplicant AP mode - invalid frequency configuration"""
  108. id = dev[0].add_network()
  109. dev[0].set_network(id, "mode", "2")
  110. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  111. dev[0].set_network(id, "key_mgmt", "NONE")
  112. dev[0].set_network(id, "frequency", "2413")
  113. dev[0].set_network(id, "scan_freq", "2412")
  114. dev[0].select_network(id)
  115. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  116. if ev is not None:
  117. raise Exception("Unexpected AP start")
  118. def test_wpas_ap_wps(dev):
  119. """wpa_supplicant AP mode - WPS operations"""
  120. id = dev[0].add_network()
  121. dev[0].set_network(id, "mode", "2")
  122. dev[0].set_network_quoted(id, "ssid", "wpas-ap-wps")
  123. dev[0].set_network_quoted(id, "psk", "1234567890")
  124. dev[0].set_network(id, "frequency", "2412")
  125. dev[0].set_network(id, "scan_freq", "2412")
  126. dev[0].select_network(id)
  127. wait_ap_ready(dev[0])
  128. bssid = dev[0].p2p_interface_addr()
  129. logger.info("Test PBC mode start/stop")
  130. if "FAIL" not in dev[0].request("WPS_CANCEL"):
  131. raise Exception("Unexpected WPS_CANCEL success")
  132. dev[0].request("WPS_PBC")
  133. ev = dev[0].wait_event(["WPS-PBC-ACTIVE"])
  134. if ev is None:
  135. raise Exception("PBC mode start timeout")
  136. if "OK" not in dev[0].request("WPS_CANCEL"):
  137. raise Exception("Unexpected WPS_CANCEL failure")
  138. ev = dev[0].wait_event(["WPS-TIMEOUT"])
  139. if ev is None:
  140. raise Exception("PBC mode disabling timeout")
  141. logger.info("Test PBC protocol run")
  142. dev[0].request("WPS_PBC")
  143. ev = dev[0].wait_event(["WPS-PBC-ACTIVE"])
  144. if ev is None:
  145. raise Exception("PBC mode start timeout")
  146. dev[1].request("WPS_PBC")
  147. dev[1].wait_connected(timeout=30, error="WPS PBC operation timed out")
  148. hwsim_utils.test_connectivity(dev[0], dev[1])
  149. logger.info("Test AP PIN to learn configuration")
  150. pin = dev[0].request("WPS_AP_PIN random")
  151. if "FAIL" in pin:
  152. raise Exception("Could not generate random AP PIN")
  153. if pin not in dev[0].request("WPS_AP_PIN get"):
  154. raise Exception("Could not fetch current AP PIN")
  155. dev[2].wps_reg(bssid, pin)
  156. hwsim_utils.test_connectivity(dev[1], dev[2])
  157. dev[1].request("REMOVE_NETWORK all")
  158. dev[2].request("REMOVE_NETWORK all")
  159. logger.info("Test AP PIN operations")
  160. dev[0].request("WPS_AP_PIN disable")
  161. dev[0].request("WPS_AP_PIN set " + pin + " 1")
  162. time.sleep(1.1)
  163. if "FAIL" not in dev[0].request("WPS_AP_PIN get"):
  164. raise Exception("AP PIN unexpectedly still enabled")
  165. pin = dev[1].wps_read_pin()
  166. dev[0].request("WPS_PIN any " + pin)
  167. dev[1].request("WPS_PIN any " + pin)
  168. dev[1].wait_connected(timeout=30)
  169. dev[1].request("REMOVE_NETWORK all")
  170. dev[1].dump_monitor()
  171. dev[0].request("WPS_PIN any " + pin + " 100")
  172. dev[1].request("WPS_PIN any " + pin)
  173. dev[1].wait_connected(timeout=30)
  174. dev[1].request("REMOVE_NETWORK all")
  175. dev[1].dump_monitor()
  176. dev[0].request("WPS_AP_PIN set 12345670")
  177. dev[0].dump_monitor()
  178. runs = ("88887777", "12340000", "00000000", "12345670")
  179. for pin in runs:
  180. logger.info("Try AP PIN " + pin)
  181. dev[2].dump_monitor()
  182. dev[2].request("WPS_REG " + bssid + " " + pin)
  183. ev = dev[2].wait_event(["WPS-SUCCESS", "WPS-FAIL msg"], timeout=15)
  184. if ev is None:
  185. raise Exception("WPS operation timed out")
  186. if "WPS-SUCCESS" in ev:
  187. raise Exception("WPS operation succeeded unexpectedly")
  188. dev[2].wait_disconnected(timeout=10)
  189. dev[2].request("WPS_CANCEL")
  190. dev[2].request("REMOVE_NETWORK all")
  191. ev = dev[0].wait_event(["WPS-AP-SETUP-LOCKED"])
  192. if ev is None:
  193. raise Exception("WPS AP PIN not locked")
  194. dev[0].dump_monitor()
  195. logger.info("Test random AP PIN timeout")
  196. pin = dev[0].request("WPS_AP_PIN random 1")
  197. if "FAIL" in pin:
  198. raise Exception("Could not generate random AP PIN")
  199. res = dev[0].request("WPS_AP_PIN get")
  200. if pin not in res:
  201. raise Exception("Could not fetch current AP PIN")
  202. for i in range(10):
  203. time.sleep(0.2)
  204. res = dev[0].request("WPS_AP_PIN get")
  205. if "FAIL" in res:
  206. break
  207. if "FAIL" not in res:
  208. raise Exception("WPS_AP_PIN random timeout did not work")
  209. if "FAIL" not in dev[0].request("WPS_AP_PIN foo"):
  210. raise Exception("Invalid WPS_AP_PIN command not rejected")
  211. if "FAIL" not in dev[0].request("WPS_AP_PIN set"):
  212. raise Exception("Invalid WPS_AP_PIN command not rejected")
  213. def test_wpas_ap_wps_pbc_overlap(dev):
  214. """wpa_supplicant AP mode - WPS operations with PBC overlap"""
  215. id = dev[0].add_network()
  216. dev[0].set_network(id, "mode", "2")
  217. dev[0].set_network_quoted(id, "ssid", "wpas-ap-wps")
  218. dev[0].set_network_quoted(id, "psk", "1234567890")
  219. dev[0].set_network(id, "frequency", "2412")
  220. dev[0].set_network(id, "scan_freq", "2412")
  221. dev[0].select_network(id)
  222. wait_ap_ready(dev[0])
  223. bssid = dev[0].p2p_interface_addr()
  224. dev[1].scan_for_bss(bssid, freq="2412")
  225. dev[1].dump_monitor()
  226. dev[2].scan_for_bss(bssid, freq="2412")
  227. dev[2].dump_monitor()
  228. dev[0].request("WPS_PBC")
  229. dev[1].request("WPS_PBC " + bssid)
  230. dev[2].request("WPS_PBC " + bssid)
  231. ev = dev[1].wait_event(["WPS-M2D"], timeout=15)
  232. if ev is None:
  233. raise Exception("PBC session overlap not detected (dev1)")
  234. if "config_error=12" not in ev:
  235. raise Exception("PBC session overlap not correctly reported (dev1)")
  236. ev = dev[2].wait_event(["WPS-M2D"], timeout=15)
  237. if ev is None:
  238. raise Exception("PBC session overlap not detected (dev2)")
  239. if "config_error=12" not in ev:
  240. raise Exception("PBC session overlap not correctly reported (dev2)")
  241. if "FAIL-PBC-OVERLAP" not in dev[0].request("WPS_PBC"):
  242. raise Exception("WPS_PBC(AP) accepted during overlap")
  243. if "FAIL-PBC-OVERLAP" not in dev[0].request("WPS_PBC any"):
  244. raise Exception("WPS_PBC(AP) accepted during overlap")
  245. dev[0].request("WPS_CANCEL")
  246. dev[1].request("WPS_CANCEL")
  247. dev[2].request("WPS_CANCEL")
  248. def test_wpas_ap_wps_disabled(dev):
  249. """wpa_supplicant AP mode - WPS disabled"""
  250. id = dev[0].add_network()
  251. dev[0].set_network(id, "mode", "2")
  252. dev[0].set_network_quoted(id, "ssid", "wpas-ap-no-wps")
  253. dev[0].set_network_quoted(id, "psk", "12345678")
  254. dev[0].set_network(id, "frequency", "2412")
  255. dev[0].set_network(id, "scan_freq", "2412")
  256. dev[0].set_network(id, "wps_disabled", "1")
  257. dev[0].select_network(id)
  258. wait_ap_ready(dev[0])
  259. dev[1].connect("wpas-ap-no-wps", psk="12345678", scan_freq="2412")
  260. dev[1].request("DISCONNECT")
  261. dev[1].wait_disconnected()
  262. def test_wpas_ap_dfs(dev):
  263. """wpa_supplicant AP mode - DFS"""
  264. try:
  265. _test_wpas_ap_dfs(dev)
  266. finally:
  267. set_country("00")
  268. dev[0].request("SET country 00")
  269. dev[1].flush_scan_cache()
  270. def _test_wpas_ap_dfs(dev):
  271. set_country("US")
  272. dev[0].request("SET country US")
  273. id = dev[0].add_network()
  274. dev[0].set_network(id, "mode", "2")
  275. dev[0].set_network_quoted(id, "ssid", "wpas-ap-dfs")
  276. dev[0].set_network(id, "key_mgmt", "NONE")
  277. dev[0].set_network(id, "frequency", "5260")
  278. dev[0].set_network(id, "scan_freq", "5260")
  279. dev[0].select_network(id)
  280. ev = dev[0].wait_event(["DFS-CAC-START"])
  281. if ev is None:
  282. # For now, assume DFS is not supported by all kernel builds.
  283. raise HwsimSkip("CAC did not start - assume not supported")
  284. ev = dev[0].wait_event(["DFS-CAC-COMPLETED"], timeout=70)
  285. if ev is None:
  286. raise Exception("CAC did not complete")
  287. if "success=1" not in ev:
  288. raise Exception("CAC failed")
  289. if "freq=5260" not in ev:
  290. raise Exception("Unexpected DFS freq result")
  291. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"])
  292. if ev is None:
  293. raise Exception("AP failed to start")
  294. dev[1].connect("wpas-ap-dfs", key_mgmt="NONE")
  295. def test_wpas_ap_disable(dev):
  296. """wpa_supplicant AP mode - DISABLE_NETWORK"""
  297. id = dev[0].add_network()
  298. dev[0].set_network(id, "mode", "2")
  299. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  300. dev[0].set_network(id, "key_mgmt", "NONE")
  301. dev[0].set_network(id, "scan_freq", "2412")
  302. dev[0].select_network(id)
  303. ev = dev[0].wait_event(["AP-ENABLED"])
  304. if ev is None:
  305. raise Exception("AP-ENABLED event not seen")
  306. wait_ap_ready(dev[0])
  307. dev[0].request("DISABLE_NETWORK %d" % id)
  308. ev = dev[0].wait_event(["AP-DISABLED"])
  309. if ev is None:
  310. raise Exception("AP-DISABLED event not seen")
  311. dev[0].wait_disconnected()
  312. def test_wpas_ap_acs(dev):
  313. """wpa_supplicant AP mode - ACS"""
  314. res = dev[0].get_capability("acs")
  315. if res is None or "ACS" not in res:
  316. raise HwsimSkip("ACS not supported")
  317. id = dev[0].add_network()
  318. dev[0].set_network(id, "mode", "2")
  319. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  320. dev[0].set_network(id, "key_mgmt", "NONE")
  321. dev[0].set_network(id, "frequency", "2417")
  322. dev[0].set_network(id, "scan_freq", "2417")
  323. dev[0].set_network(id, "acs", "1")
  324. dev[0].select_network(id)
  325. wait_ap_ready(dev[0])
  326. # ACS prefers channels 1, 6, 11
  327. freq = dev[0].get_status_field('freq')
  328. if freq == "2417":
  329. raise Exception("Unexpected operating channel selected")
  330. dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq=freq)
  331. def test_wpas_ap_and_assoc_req_p2p_ie(dev):
  332. """wpa_supplicant AP mode - unexpected P2P IE in Association Request"""
  333. try:
  334. _test_wpas_ap_and_assoc_req_p2p_ie(dev)
  335. finally:
  336. dev[1].request("VENDOR_ELEM_REMOVE 13 *")
  337. dev[0].request("P2P_SET disabled 0")
  338. def _test_wpas_ap_and_assoc_req_p2p_ie(dev):
  339. dev[0].request("P2P_SET disabled 1")
  340. id = dev[0].add_network()
  341. dev[0].set_network(id, "mode", "2")
  342. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  343. dev[0].set_network(id, "key_mgmt", "NONE")
  344. dev[0].set_network(id, "frequency", "2412")
  345. dev[0].set_network(id, "scan_freq", "2412")
  346. dev[0].select_network(id)
  347. wait_ap_ready(dev[0])
  348. dev[1].request("VENDOR_ELEM_ADD 13 dd04506f9a09")
  349. dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
  350. dev[1].request("DISCONNECT")
  351. dev[1].wait_disconnected()
  352. dev[0].request("DISCONNECT")
  353. dev[0].wait_disconnected()
  354. def test_wpas_ap_open_ht_disabled(dev):
  355. """wpa_supplicant AP mode - open network and HT disabled"""
  356. id = dev[0].add_network()
  357. dev[0].set_network(id, "mode", "2")
  358. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  359. dev[0].set_network(id, "key_mgmt", "NONE")
  360. dev[0].set_network(id, "frequency", "2412")
  361. dev[0].set_network(id, "scan_freq", "2412")
  362. dev[0].set_network(id, "disable_ht", "1")
  363. dev[0].select_network(id)
  364. wait_ap_ready(dev[0])
  365. dev[1].connect("wpas-ap-open", key_mgmt="NONE", scan_freq="2412")
  366. hwsim_utils.test_connectivity(dev[0], dev[1])
  367. def test_wpas_ap_failures(dev):
  368. """wpa_supplicant AP mode - failures"""
  369. # No SSID configured for AP mode
  370. id = dev[0].add_network()
  371. dev[0].set_network(id, "mode", "2")
  372. dev[0].set_network(id, "key_mgmt", "NONE")
  373. dev[0].set_network(id, "frequency", "2412")
  374. dev[0].set_network(id, "scan_freq", "2412")
  375. dev[0].select_network(id)
  376. ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED" ], timeout=0.1)
  377. if ev is not None:
  378. raise Exception("Unexpected connection event")
  379. dev[0].request("REMOVE_NETWORK all")
  380. # Invalid pbss value(2) for AP mode
  381. dev[0].dump_monitor()
  382. id = dev[0].add_network()
  383. dev[0].set_network(id, "mode", "2")
  384. dev[0].set_network_quoted(id, "ssid", "wpas-ap-open")
  385. dev[0].set_network(id, "key_mgmt", "NONE")
  386. dev[0].set_network(id, "frequency", "2412")
  387. dev[0].set_network(id, "scan_freq", "2412")
  388. dev[0].set_network(id, "pbss", "2")
  389. dev[0].select_network(id)
  390. ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED",
  391. "CTRL-EVENT-DISCONNECTED" ], timeout=0.1)
  392. if ev is not None and "CTRL-EVENT-CONNECTED" in ev:
  393. raise Exception("Unexpected connection event(2)")
  394. dev[0].request("REMOVE_NETWORK all")
  395. def test_wpas_ap_oom(dev):
  396. """wpa_supplicant AP mode - OOM"""
  397. id = dev[0].add_network()
  398. dev[0].set_network(id, "mode", "2")
  399. dev[0].set_network_quoted(id, "ssid", "wpas-ap")
  400. dev[0].set_network_quoted(id, "psk", "1234567890")
  401. dev[0].set_network(id, "frequency", "2412")
  402. dev[0].set_network(id, "scan_freq", "2412")
  403. with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
  404. dev[0].select_network(id)
  405. dev[0].wait_disconnected()
  406. dev[0].request("REMOVE_NETWORK all")
  407. id = dev[0].add_network()
  408. dev[0].set_network(id, "mode", "2")
  409. dev[0].set_network_quoted(id, "ssid", "wpas-ap")
  410. dev[0].set_network(id, "psk", "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
  411. dev[0].set_network(id, "frequency", "2412")
  412. dev[0].set_network(id, "scan_freq", "2412")
  413. with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
  414. dev[0].select_network(id)
  415. dev[0].wait_disconnected()
  416. dev[0].request("REMOVE_NETWORK all")
  417. id = dev[0].add_network()
  418. dev[0].set_network(id, "mode", "2")
  419. dev[0].set_network_quoted(id, "ssid", "wpas-ap")
  420. dev[0].set_network(id, "key_mgmt", "NONE")
  421. dev[0].set_network_quoted(id, "wep_key0", "hello")
  422. dev[0].set_network(id, "frequency", "2412")
  423. dev[0].set_network(id, "scan_freq", "2412")
  424. with alloc_fail(dev[0], 1, "=wpa_supplicant_conf_ap"):
  425. dev[0].select_network(id)
  426. dev[0].wait_disconnected()
  427. dev[0].request("REMOVE_NETWORK all")
  428. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  429. wpas.interface_add("wlan5")
  430. wpas.request("SET manufacturer test")
  431. wpas.request("SET model_name test")
  432. wpas.request("SET model_number test")
  433. wpas.request("SET serial_number test")
  434. wpas.request("SET serial_number test")
  435. wpas.request("SET serial_number test")
  436. wpas.request("SET ap_vendor_elements dd0411223301")
  437. id = wpas.add_network()
  438. wpas.set_network(id, "mode", "2")
  439. wpas.set_network_quoted(id, "ssid", "wpas-ap")
  440. wpas.set_network(id, "key_mgmt", "NONE")
  441. wpas.set_network(id, "frequency", "2412")
  442. wpas.set_network(id, "scan_freq", "2412")
  443. for i in range(5):
  444. with alloc_fail(wpas, i, "=wpa_supplicant_conf_ap"):
  445. wpas.select_network(id)
  446. ev = dev[0].wait_event([ "CTRL-EVENT-CONNECTED",
  447. "CTRL-EVENT-DISCONNECTED" ], timeout=1)
  448. wpas.request("DISCONNECT")
  449. wpas.wait_disconnected()
  450. def test_wpas_ap_params(dev):
  451. """wpa_supplicant AP mode - parameters"""
  452. wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
  453. wpas.interface_add("wlan5")
  454. wpas.request("SET manufacturer test")
  455. wpas.request("SET model_name test")
  456. wpas.request("SET model_number test")
  457. wpas.request("SET serial_number test")
  458. wpas.request("SET serial_number test")
  459. wpas.request("SET serial_number test")
  460. wpas.request("SET ap_vendor_elements dd0411223301")
  461. id = wpas.add_network()
  462. wpas.set_network(id, "mode", "2")
  463. wpas.set_network_quoted(id, "ssid", "wpas-ap")
  464. wpas.set_network(id, "key_mgmt", "NONE")
  465. wpas.set_network(id, "frequency", "2412")
  466. wpas.set_network(id, "scan_freq", "2412")
  467. wpas.select_network(id)
  468. wpas.wait_connected()
  469. wpas.request("DISCONNECT")
  470. wpas.wait_disconnected()
  471. wpas.request("SET beacon_int 200 3")
  472. wpas.request("SET dtim_period 3")
  473. wpas.select_network(id)
  474. wpas.wait_connected()
  475. wpas.request("DISCONNECT")
  476. wpas.wait_disconnected()
  477. wpas.set_network(id, "beacon_int", "300")
  478. wpas.set_network(id, "dtim_period", "2")
  479. wpas.select_network(id)
  480. wpas.wait_connected()
  481. if "---- AP ----" not in wpas.request("PMKSA"):
  482. raise Exception("AP section missing from PMKSA output")
  483. if "OK" not in wpas.request("PMKSA_FLUSH"):
  484. raise Exception("PMKSA_FLUSH failed")
  485. wpas.request("DISCONNECT")
  486. wpas.wait_disconnected()