test_ap_params.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. # Test various AP mode parameters
  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. from remotehost import remote_compatible
  7. import logging
  8. logger = logging.getLogger()
  9. import os
  10. import subprocess
  11. import hwsim_utils
  12. import hostapd
  13. from tshark import run_tshark
  14. from utils import alloc_fail, HwsimSkip
  15. @remote_compatible
  16. def test_ap_fragmentation_rts_set_high(dev, apdev):
  17. """WPA2-PSK AP with fragmentation and RTS thresholds larger than frame length"""
  18. ssid = "test-wpa2-psk"
  19. passphrase = 'qwertyuiop'
  20. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  21. params['rts_threshold'] = "1000"
  22. params['fragm_threshold'] = "2000"
  23. hapd = hostapd.add_ap(apdev[0], params)
  24. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  25. hwsim_utils.test_connectivity(dev[0], hapd)
  26. @remote_compatible
  27. def test_ap_fragmentation_open(dev, apdev):
  28. """Open AP with fragmentation threshold"""
  29. ssid = "fragmentation"
  30. params = {}
  31. params['ssid'] = ssid
  32. params['fragm_threshold'] = "1000"
  33. hapd = hostapd.add_ap(apdev[0], params)
  34. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  35. hwsim_utils.test_connectivity(dev[0], hapd)
  36. @remote_compatible
  37. def test_ap_fragmentation_wpa2(dev, apdev):
  38. """WPA2-PSK AP with fragmentation threshold"""
  39. ssid = "test-wpa2-psk"
  40. passphrase = 'qwertyuiop'
  41. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  42. params['fragm_threshold'] = "1000"
  43. hapd = hostapd.add_ap(apdev[0], params)
  44. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  45. hwsim_utils.test_connectivity(dev[0], hapd)
  46. def test_ap_vendor_elements(dev, apdev):
  47. """WPA2-PSK AP with vendor elements added"""
  48. bssid = apdev[0]['bssid']
  49. ssid = "test-wpa2-psk"
  50. passphrase = 'qwertyuiop'
  51. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  52. params['vendor_elements'] = "dd0411223301"
  53. params['assocresp_elements'] = "dd0411223302"
  54. hapd = hostapd.add_ap(apdev[0], params)
  55. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  56. bss = dev[0].get_bss(bssid)
  57. if "dd0411223301" not in bss['ie']:
  58. raise Exception("Vendor element not shown in scan results")
  59. hapd.set('vendor_elements', 'dd051122330203dd0400137400dd04001374ff')
  60. if "OK" not in hapd.request("UPDATE_BEACON"):
  61. raise Exception("UPDATE_BEACON failed")
  62. dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
  63. bss = dev[1].get_bss(bssid)
  64. if "dd0411223301" in bss['ie']:
  65. raise Exception("Old vendor element still in scan results")
  66. if "dd051122330203" not in bss['ie']:
  67. raise Exception("New vendor element not shown in scan results")
  68. def test_ap_element_parse(dev, apdev):
  69. """Information element parsing - extra coverage"""
  70. bssid = apdev[0]['bssid']
  71. ssid = "test-wpa2-psk"
  72. params = { 'ssid': ssid,
  73. 'vendor_elements': "380501020304059e009e009e009e009e009e00" }
  74. hapd = hostapd.add_ap(apdev[0], params)
  75. dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
  76. bss = dev[0].get_bss(bssid)
  77. if "38050102030405" not in bss['ie']:
  78. raise Exception("Timeout element not shown in scan results")
  79. @remote_compatible
  80. def test_ap_element_parse_oom(dev, apdev):
  81. """Information element parsing OOM"""
  82. bssid = apdev[0]['bssid']
  83. ssid = "test-wpa2-psk"
  84. params = { 'ssid': ssid,
  85. 'vendor_elements': "dd0d506f9a0a00000600411c440028" }
  86. hapd = hostapd.add_ap(apdev[0], params)
  87. dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
  88. with alloc_fail(dev[0], 1, "wpabuf_alloc;ieee802_11_vendor_ie_concat"):
  89. bss = dev[0].get_bss(bssid)
  90. logger.info(str(bss))
  91. def test_ap_country(dev, apdev):
  92. """WPA2-PSK AP setting country code and using 5 GHz band"""
  93. try:
  94. hapd = None
  95. bssid = apdev[0]['bssid']
  96. ssid = "test-wpa2-psk"
  97. passphrase = 'qwertyuiop'
  98. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  99. params['country_code'] = 'FI'
  100. params['ieee80211d'] = '1'
  101. params['hw_mode'] = 'a'
  102. params['channel'] = '36'
  103. hapd = hostapd.add_ap(apdev[0], params)
  104. dev[0].connect(ssid, psk=passphrase, scan_freq="5180")
  105. hwsim_utils.test_connectivity(dev[0], hapd)
  106. finally:
  107. dev[0].request("DISCONNECT")
  108. if hapd:
  109. hapd.request("DISABLE")
  110. hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
  111. dev[0].flush_scan_cache()
  112. def test_ap_acl_accept(dev, apdev):
  113. """MAC ACL accept list"""
  114. ssid = "acl"
  115. params = {}
  116. params['ssid'] = ssid
  117. params['accept_mac_file'] = "hostapd.macaddr"
  118. hapd = hostapd.add_ap(apdev[0], params)
  119. dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
  120. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  121. dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
  122. dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  123. dev[0].request("REMOVE_NETWORK all")
  124. dev[1].request("REMOVE_NETWORK all")
  125. hapd.request("SET macaddr_acl 1")
  126. dev[1].dump_monitor()
  127. dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
  128. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  129. ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  130. if ev is not None:
  131. raise Exception("Unexpected association")
  132. def test_ap_acl_deny(dev, apdev):
  133. """MAC ACL deny list"""
  134. ssid = "acl"
  135. params = {}
  136. params['ssid'] = ssid
  137. params['deny_mac_file'] = "hostapd.macaddr"
  138. hapd = hostapd.add_ap(apdev[0], params)
  139. dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
  140. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
  141. dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
  142. dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  143. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  144. if ev is not None:
  145. raise Exception("Unexpected association")
  146. @remote_compatible
  147. def test_ap_wds_sta(dev, apdev):
  148. """WPA2-PSK AP with STA using 4addr mode"""
  149. ssid = "test-wpa2-psk"
  150. passphrase = 'qwertyuiop'
  151. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  152. params['wds_sta'] = "1"
  153. params['wds_bridge'] = "wds-br0"
  154. hapd = hostapd.add_ap(apdev[0], params)
  155. try:
  156. dev[0].cmd_execute(['brctl', 'addbr', 'wds-br0'])
  157. dev[0].cmd_execute(['brctl', 'setfd', 'wds-br0', '0'])
  158. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
  159. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'on'])
  160. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  161. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  162. max_tries=15)
  163. dev[0].request("REATTACH")
  164. dev[0].wait_connected()
  165. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  166. max_tries=15)
  167. dev[0].request("SET reassoc_same_bss_optim 1")
  168. dev[0].request("REATTACH")
  169. dev[0].wait_connected()
  170. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  171. max_tries=5, timeout=1)
  172. finally:
  173. dev[0].request("SET reassoc_same_bss_optim 0")
  174. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'off'])
  175. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
  176. dev[0].cmd_execute(['brctl', 'delbr', 'wds-br0'])
  177. def test_ap_wds_sta_open(dev, apdev):
  178. """Open AP with STA using 4addr mode"""
  179. ssid = "test-wds-open"
  180. params = {}
  181. params['ssid'] = ssid
  182. params['wds_sta'] = "1"
  183. params['wds_bridge'] = "wds-br0"
  184. hapd = hostapd.add_ap(apdev[0], params)
  185. try:
  186. dev[0].cmd_execute(['brctl', 'addbr', 'wds-br0'])
  187. dev[0].cmd_execute(['brctl', 'setfd', 'wds-br0', '0'])
  188. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
  189. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'on'])
  190. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  191. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  192. max_tries=15)
  193. dev[0].request("REATTACH")
  194. dev[0].wait_connected()
  195. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  196. max_tries=15)
  197. dev[0].request("SET reassoc_same_bss_optim 1")
  198. dev[0].request("REATTACH")
  199. dev[0].wait_connected()
  200. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  201. max_tries=5, timeout=1)
  202. finally:
  203. dev[0].request("SET reassoc_same_bss_optim 0")
  204. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'off'])
  205. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
  206. dev[0].cmd_execute(['brctl', 'delbr', 'wds-br0'])
  207. def test_ap_wds_sta_wep(dev, apdev):
  208. """WEP AP with STA using 4addr mode"""
  209. ssid = "test-wds-wep"
  210. params = {}
  211. params['ssid'] = ssid
  212. params['wep_key0'] = '"hello"'
  213. params['wds_sta'] = "1"
  214. params['wds_bridge'] = "wds-br0"
  215. hapd = hostapd.add_ap(apdev[0], params)
  216. try:
  217. dev[0].cmd_execute(['brctl', 'addbr', 'wds-br0'])
  218. dev[0].cmd_execute(['brctl', 'setfd', 'wds-br0', '0'])
  219. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
  220. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'on'])
  221. dev[0].connect(ssid, key_mgmt="NONE", wep_key0='"hello"',
  222. scan_freq="2412")
  223. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  224. max_tries=15)
  225. dev[0].request("REATTACH")
  226. dev[0].wait_connected()
  227. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  228. max_tries=15)
  229. dev[0].request("SET reassoc_same_bss_optim 1")
  230. dev[0].request("REATTACH")
  231. dev[0].wait_connected()
  232. hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
  233. max_tries=5, timeout=1)
  234. finally:
  235. dev[0].request("SET reassoc_same_bss_optim 0")
  236. dev[0].cmd_execute(['iw', dev[0].ifname, 'set', '4addr', 'off'])
  237. dev[0].cmd_execute(['ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
  238. dev[0].cmd_execute(['brctl', 'delbr', 'wds-br0'])
  239. @remote_compatible
  240. def test_ap_inactivity_poll(dev, apdev):
  241. """AP using inactivity poll"""
  242. ssid = "test-wpa2-psk"
  243. passphrase = 'qwertyuiop'
  244. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  245. params['ap_max_inactivity'] = "1"
  246. hapd = hostapd.add_ap(apdev[0], params)
  247. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  248. hapd.set("ext_mgmt_frame_handling", "1")
  249. dev[0].request("DISCONNECT")
  250. ev = hapd.wait_event(["MGMT-RX"], timeout=5)
  251. if ev is None:
  252. raise Exception("MGMT RX wait timed out for Deauth")
  253. hapd.set("ext_mgmt_frame_handling", "0")
  254. ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=30)
  255. if ev is None:
  256. raise Exception("STA disconnection on inactivity was not reported")
  257. @remote_compatible
  258. def test_ap_inactivity_disconnect(dev, apdev):
  259. """AP using inactivity disconnect"""
  260. ssid = "test-wpa2-psk"
  261. passphrase = 'qwertyuiop'
  262. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  263. params['ap_max_inactivity'] = "1"
  264. params['skip_inactivity_poll'] = "1"
  265. hapd = hostapd.add_ap(apdev[0], params)
  266. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  267. hapd.set("ext_mgmt_frame_handling", "1")
  268. dev[0].request("DISCONNECT")
  269. ev = hapd.wait_event(["MGMT-RX"], timeout=5)
  270. if ev is None:
  271. raise Exception("MGMT RX wait timed out for Deauth")
  272. hapd.set("ext_mgmt_frame_handling", "0")
  273. ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=30)
  274. if ev is None:
  275. raise Exception("STA disconnection on inactivity was not reported")
  276. @remote_compatible
  277. def test_ap_basic_rates(dev, apdev):
  278. """Open AP with lots of basic rates"""
  279. ssid = "basic rates"
  280. params = {}
  281. params['ssid'] = ssid
  282. params['basic_rates'] = "10 20 55 110 60 90 120 180 240 360 480 540"
  283. hostapd.add_ap(apdev[0], params)
  284. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  285. @remote_compatible
  286. def test_ap_short_preamble(dev, apdev):
  287. """Open AP with short preamble"""
  288. ssid = "short preamble"
  289. params = {}
  290. params['ssid'] = ssid
  291. params['preamble'] = "1"
  292. hostapd.add_ap(apdev[0], params)
  293. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  294. def test_ap_spectrum_management_required(dev, apdev):
  295. """Open AP with spectrum management required"""
  296. ssid = "spectrum mgmt"
  297. params = {}
  298. params['ssid'] = ssid
  299. params["country_code"] = "JP"
  300. params["hw_mode"] = "a"
  301. params["channel"] = "36"
  302. params["ieee80211d"] = "1"
  303. params["local_pwr_constraint"] = "3"
  304. params['spectrum_mgmt_required'] = "1"
  305. try:
  306. hapd = None
  307. hapd = hostapd.add_ap(apdev[0], params)
  308. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180")
  309. finally:
  310. dev[0].request("DISCONNECT")
  311. if hapd:
  312. hapd.request("DISABLE")
  313. hostapd.cmd_execute(apdev[0], ['iw', 'reg', 'set', '00'])
  314. dev[0].flush_scan_cache()
  315. @remote_compatible
  316. def test_ap_max_listen_interval(dev, apdev):
  317. """Open AP with maximum listen interval limit"""
  318. ssid = "listen"
  319. params = {}
  320. params['ssid'] = ssid
  321. params['max_listen_interval'] = "1"
  322. hostapd.add_ap(apdev[0], params)
  323. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
  324. ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
  325. if ev is None:
  326. raise Exception("Association rejection not reported")
  327. if "status_code=51" not in ev:
  328. raise Exception("Unexpected ASSOC-REJECT reason")
  329. @remote_compatible
  330. def test_ap_max_num_sta(dev, apdev):
  331. """Open AP with maximum STA count"""
  332. ssid = "max"
  333. params = {}
  334. params['ssid'] = ssid
  335. params['max_num_sta'] = "1"
  336. hostapd.add_ap(apdev[0], params)
  337. dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  338. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
  339. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
  340. if ev is not None:
  341. raise Exception("Unexpected association")
  342. def test_ap_max_num_sta_no_probe_resp(dev, apdev, params):
  343. """Maximum STA count and limit on Probe Response frames"""
  344. logdir = params['logdir']
  345. dev[0].flush_scan_cache()
  346. ssid = "max"
  347. params = {}
  348. params['ssid'] = ssid
  349. params['beacon_int'] = "2000"
  350. params['max_num_sta'] = "1"
  351. params['no_probe_resp_if_max_sta'] = "1"
  352. hostapd.add_ap(apdev[0], params)
  353. dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  354. dev[0].scan(freq=2412, type="ONLY")
  355. dev[0].scan(freq=2412, type="ONLY")
  356. seen = dev[0].get_bss(apdev[0]['bssid']) != None
  357. dev[1].scan(freq=2412, type="ONLY")
  358. if seen:
  359. out = run_tshark(os.path.join(logdir, "hwsim0.pcapng"),
  360. "wlan.fc.type_subtype == 5", ["wlan.da" ])
  361. if out:
  362. if dev[0].own_addr() not in out:
  363. # Discovery happened through Beacon frame reception. That's not
  364. # an error case.
  365. seen = False
  366. if dev[1].own_addr() not in out:
  367. raise Exception("No Probe Response frames to dev[1] seen")
  368. if seen:
  369. raise Exception("AP found unexpectedly")
  370. @remote_compatible
  371. def test_ap_tx_queue_params(dev, apdev):
  372. """Open AP with TX queue params set"""
  373. ssid = "tx"
  374. params = {}
  375. params['ssid'] = ssid
  376. params['tx_queue_data2_aifs'] = "4"
  377. params['tx_queue_data2_cwmin'] = "7"
  378. params['tx_queue_data2_cwmax'] = "1023"
  379. params['tx_queue_data2_burst'] = "4.2"
  380. params['tx_queue_data1_aifs'] = "4"
  381. params['tx_queue_data1_cwmin'] = "7"
  382. params['tx_queue_data1_cwmax'] = "1023"
  383. params['tx_queue_data1_burst'] = "2"
  384. hapd = hostapd.add_ap(apdev[0], params)
  385. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  386. hwsim_utils.test_connectivity(dev[0], hapd)
  387. def test_ap_beacon_rate_legacy(dev, apdev):
  388. """Open AP with Beacon frame TX rate 5.5 Mbps"""
  389. hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' })
  390. res = hapd.get_driver_status_field('capa.flags')
  391. if (int(res, 0) & 0x0000080000000000) == 0:
  392. raise HwsimSkip("Setting Beacon frame TX rate not supported")
  393. hapd.disable()
  394. hapd.set('beacon_rate', '55')
  395. hapd.enable()
  396. dev[0].connect('beacon-rate', key_mgmt="NONE", scan_freq="2412")
  397. def test_ap_beacon_rate_legacy2(dev, apdev):
  398. """Open AP with Beacon frame TX rate 12 Mbps in VHT BSS"""
  399. hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' })
  400. res = hapd.get_driver_status_field('capa.flags')
  401. if (int(res, 0) & 0x0000080000000000) == 0:
  402. raise HwsimSkip("Setting Beacon frame TX rate not supported")
  403. hapd.disable()
  404. hapd.set('beacon_rate', '120')
  405. hapd.set("country_code", "DE")
  406. hapd.set("hw_mode", "a")
  407. hapd.set("channel", "36")
  408. hapd.set("ieee80211n", "1")
  409. hapd.set("ieee80211ac", "1")
  410. hapd.set("ht_capab", "[HT40+]")
  411. hapd.set("vht_capab", "")
  412. hapd.set("vht_oper_chwidth", "0")
  413. hapd.set("vht_oper_centr_freq_seg0_idx", "0")
  414. try:
  415. hapd.enable()
  416. dev[0].scan_for_bss(hapd.own_addr(), freq="5180")
  417. dev[0].connect('beacon-rate', key_mgmt="NONE", scan_freq="5180")
  418. finally:
  419. dev[0].request("DISCONNECT")
  420. hapd.request("DISABLE")
  421. subprocess.call(['iw', 'reg', 'set', '00'])
  422. dev[0].flush_scan_cache()
  423. def test_ap_beacon_rate_ht(dev, apdev):
  424. """Open AP with Beacon frame TX rate HT-MCS 0"""
  425. hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' })
  426. res = hapd.get_driver_status_field('capa.flags')
  427. if (int(res, 0) & 0x0000100000000000) == 0:
  428. raise HwsimSkip("Setting Beacon frame TX rate not supported")
  429. hapd.disable()
  430. hapd.set('beacon_rate', 'ht:0')
  431. hapd.enable()
  432. dev[0].connect('beacon-rate', key_mgmt="NONE", scan_freq="2412")
  433. def test_ap_beacon_rate_ht2(dev, apdev):
  434. """Open AP with Beacon frame TX rate HT-MCS 1 in VHT BSS"""
  435. hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' })
  436. res = hapd.get_driver_status_field('capa.flags')
  437. if (int(res, 0) & 0x0000100000000000) == 0:
  438. raise HwsimSkip("Setting Beacon frame TX rate not supported")
  439. hapd.disable()
  440. hapd.set('beacon_rate', 'ht:1')
  441. hapd.set("country_code", "DE")
  442. hapd.set("hw_mode", "a")
  443. hapd.set("channel", "36")
  444. hapd.set("ieee80211n", "1")
  445. hapd.set("ieee80211ac", "1")
  446. hapd.set("ht_capab", "[HT40+]")
  447. hapd.set("vht_capab", "")
  448. hapd.set("vht_oper_chwidth", "0")
  449. hapd.set("vht_oper_centr_freq_seg0_idx", "0")
  450. try:
  451. hapd.enable()
  452. dev[0].scan_for_bss(hapd.own_addr(), freq="5180")
  453. dev[0].connect('beacon-rate', key_mgmt="NONE", scan_freq="5180")
  454. finally:
  455. dev[0].request("DISCONNECT")
  456. hapd.request("DISABLE")
  457. subprocess.call(['iw', 'reg', 'set', '00'])
  458. dev[0].flush_scan_cache()
  459. def test_ap_beacon_rate_vht(dev, apdev):
  460. """Open AP with Beacon frame TX rate VHT-MCS 0"""
  461. hapd = hostapd.add_ap(apdev[0], { 'ssid': 'beacon-rate' })
  462. res = hapd.get_driver_status_field('capa.flags')
  463. if (int(res, 0) & 0x0000200000000000) == 0:
  464. raise HwsimSkip("Setting Beacon frame TX rate not supported")
  465. hapd.disable()
  466. hapd.set('beacon_rate', 'vht:0')
  467. hapd.set("country_code", "DE")
  468. hapd.set("hw_mode", "a")
  469. hapd.set("channel", "36")
  470. hapd.set("ieee80211n", "1")
  471. hapd.set("ieee80211ac", "1")
  472. hapd.set("ht_capab", "[HT40+]")
  473. hapd.set("vht_capab", "")
  474. hapd.set("vht_oper_chwidth", "0")
  475. hapd.set("vht_oper_centr_freq_seg0_idx", "0")
  476. try:
  477. hapd.enable()
  478. dev[0].scan_for_bss(hapd.own_addr(), freq="5180")
  479. dev[0].connect('beacon-rate', key_mgmt="NONE", scan_freq="5180")
  480. finally:
  481. dev[0].request("DISCONNECT")
  482. hapd.request("DISABLE")
  483. subprocess.call(['iw', 'reg', 'set', '00'])
  484. dev[0].flush_scan_cache()