test_hapd_ctrl.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # hostapd control interface
  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. def test_hapd_ctrl_status(dev, apdev):
  8. """hostapd ctrl_iface STATUS commands"""
  9. ssid = "hapd-ctrl"
  10. bssid = apdev[0]['bssid']
  11. params = hostapd.wpa2_params(ssid=ssid, passphrase="12345678")
  12. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  13. status = hapd.get_status()
  14. driver = hapd.get_driver_status()
  15. if status['bss[0]'] != apdev[0]['ifname']:
  16. raise Exception("Unexpected bss[0]")
  17. if status['ssid[0]'] != ssid:
  18. raise Exception("Unexpected ssid[0]")
  19. if status['bssid[0]'] != bssid:
  20. raise Exception("Unexpected bssid[0]")
  21. if status['freq'] != "2412":
  22. raise Exception("Unexpected freq")
  23. if driver['beacon_set'] != "1":
  24. raise Exception("Unexpected beacon_set")
  25. if driver['addr'] != bssid:
  26. raise Exception("Unexpected addr")
  27. def test_hapd_ctrl_p2p_manager(dev, apdev):
  28. """hostapd as P2P Device manager"""
  29. ssid = "hapd-p2p-mgr"
  30. passphrase = "12345678"
  31. params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
  32. params['manage_p2p'] = '1'
  33. params['allow_cross_connection'] = '0'
  34. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  35. dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
  36. addr = dev[0].p2p_dev_addr()
  37. if "OK" not in hapd.request("DEAUTHENTICATE " + addr + " p2p=2"):
  38. raise Exception("DEAUTHENTICATE command failed")
  39. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
  40. if ev is None:
  41. raise Exception("Disconnection event timed out")