test_ap_open.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Open mode AP 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 hostapd
  7. import hwsim_utils
  8. def test_ap_open(dev, apdev):
  9. """AP with open mode (no security) configuration"""
  10. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
  11. dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
  12. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  13. ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
  14. if ev is None:
  15. raise Exception("No connection event received from hostapd")
  16. dev[0].request("DISCONNECT")
  17. ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5)
  18. if ev is None:
  19. raise Exception("No disconnection event received from hostapd")
  20. def test_ap_open_packet_loss(dev, apdev):
  21. """AP with open mode configuration and large packet loss"""
  22. params = { "ssid": "open",
  23. "ignore_probe_probability": "0.5",
  24. "ignore_auth_probability": "0.5",
  25. "ignore_assoc_probability": "0.5",
  26. "ignore_reassoc_probability": "0.5" }
  27. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  28. for i in range(0, 3):
  29. dev[i].connect("open", key_mgmt="NONE", scan_freq="2412",
  30. wait_connect=False)
  31. for i in range(0, 3):
  32. ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
  33. if ev is None:
  34. raise Exception("Association with the AP timed out")
  35. def test_ap_open_unknown_action(dev, apdev):
  36. """AP with open mode configuration and unknown Action frame"""
  37. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
  38. dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
  39. bssid = apdev[0]['bssid']
  40. cmd = "MGMT_TX {} {} freq=2412 action=765432".format(bssid, bssid)
  41. if "FAIL" in dev[0].request(cmd):
  42. raise Exception("Could not send test Action frame")
  43. ev = dev[0].wait_event(["MGMT-TX-STATUS"], timeout=10)
  44. if ev is None:
  45. raise Exception("Timeout on MGMT-TX-STATUS")
  46. if "result=SUCCESS" not in ev:
  47. raise Exception("AP did not ack Action frame")
  48. def test_ap_open_reconnect_on_inactivity_disconnect(dev, apdev):
  49. """Reconnect to open mode AP after inactivity related disconnection"""
  50. hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
  51. dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
  52. hapd.request("DEAUTHENTICATE " + dev[0].p2p_interface_addr() + " reason=4")
  53. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
  54. if ev is None:
  55. raise Exception("Timeout on disconnection")
  56. ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=2)
  57. if ev is None:
  58. raise Exception("Timeout on reconnection")