test_mbo.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # MBO tests
  2. # Copyright (c) 2016, Intel Deutschland GmbH
  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 hostapd
  9. import os
  10. from tshark import run_tshark
  11. def test_mbo_assoc_disallow(dev, apdev, params):
  12. hapd1 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "MBO", "mbo": "1" })
  13. hapd2 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "MBO", "mbo": "1" })
  14. logger.debug("Set mbo_assoc_disallow with invalid value")
  15. if "FAIL" not in hapd1.request("SET mbo_assoc_disallow 2"):
  16. raise Exception("Set mbo_assoc_disallow for AP1 succeeded unexpectedly with value 2")
  17. logger.debug("Disallow associations to AP1 and allow association to AP2")
  18. if "OK" not in hapd1.request("SET mbo_assoc_disallow 1"):
  19. raise Exception("Failed to set mbo_assoc_disallow for AP1")
  20. if "OK" not in hapd2.request("SET mbo_assoc_disallow 0"):
  21. raise Exception("Failed to set mbo_assoc_disallow for AP2")
  22. dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
  23. out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
  24. "wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00",
  25. wait=False)
  26. if "Destination address: " + hapd1.own_addr() in out:
  27. raise Exception("Association request sent to disallowed AP")
  28. timestamp = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
  29. "wlan.fc.type_subtype == 0x00",
  30. display=['frame.time'], wait=False)
  31. logger.debug("Allow associations to AP1 and disallow assications to AP2")
  32. if "OK" not in hapd1.request("SET mbo_assoc_disallow 0"):
  33. raise Exception("Failed to set mbo_assoc_disallow for AP1")
  34. if "OK" not in hapd2.request("SET mbo_assoc_disallow 1"):
  35. raise Exception("Failed to set mbo_assoc_disallow for AP2")
  36. dev[0].request("DISCONNECT")
  37. dev[0].wait_disconnected()
  38. # Force new scan, so the assoc_disallowed indication is updated */
  39. dev[0].request("FLUSH")
  40. dev[0].connect("MBO", key_mgmt="NONE", scan_freq="2412")
  41. filter = 'wlan.fc.type == 0 && wlan.fc.type_subtype == 0x00 && frame.time > "' + timestamp.rstrip() + '"'
  42. out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
  43. filter, wait=False)
  44. if "Destination address: " + hapd2.own_addr() in out:
  45. raise Exception("Association request sent to disallowed AP 2")