[PATCH 2/2] tests: Add hapd_ctrl_send_action

Raphaël Mélotte raphael.melotte at mind.be
Fri Dec 2 04:11:45 PST 2022


The test checks that when using the SEND_ACTION command, the action
frame is actually sent to and received by the station. For that, the
action frame sent is a CSA because they are easy to check for on the
station side.

Signed-off-by: Raphaël Mélotte <raphael.melotte at mind.be>
---
 tests/hwsim/test_hapd_ctrl.py | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/tests/hwsim/test_hapd_ctrl.py b/tests/hwsim/test_hapd_ctrl.py
index 9cf8ac73c..28904c379 100644
--- a/tests/hwsim/test_hapd_ctrl.py
+++ b/tests/hwsim/test_hapd_ctrl.py
@@ -1075,3 +1075,28 @@ def test_hapd_ctrl_attach_errors(dev, apdev):
     with alloc_fail(hapd, 1, "ctrl_iface_attach"):
         if "FAIL" not in hglobal.request("ATTACH foo"):
             raise Exception("Invalid ATTACH accepted")
+
+def test_hapd_ctrl_send_action(dev, apdev):
+    """hostapd SEND_ACTION control interface command."""
+    ssid = "hapd-send-action"
+    passphrase = "12345678"
+    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
+    hapd = hostapd.add_ap(apdev[0], params)
+    dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
+    addr = dev[0].own_addr()
+
+    # Send a CSA to be able to check that the station received it:
+    frame = ("00"  # Action
+             "04"  # CSA
+             "25"  # element ID
+             "03"  # length
+             "00"  # mode
+             "06"  # channel number
+             "00")  # count
+
+    if "OK" not in hapd.request("SEND_ACTION " + addr + " " + frame):
+        raise Exception("SEND_ACTION failed")
+
+    ev = dev[0].wait_event(["CTRL-EVENT-STARTED-CHANNEL-SWITCH"], timeout=2)
+    if ev is None:
+        raise Exception("Action frame was not received by the station")
-- 
2.37.3




More information about the Hostap mailing list