From 9c47624fc8f96ac9dacaa8f43646f5b2f4acb231 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 7 Mar 2021 11:51:54 +0200 Subject: [PATCH] tests: VENDOR command Signed-off-by: Jouni Malinen --- tests/hwsim/test_hapd_ctrl.py | 30 ++++++++++++++++++++++++++++++ tests/hwsim/test_wpas_ctrl.py | 26 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/tests/hwsim/test_hapd_ctrl.py b/tests/hwsim/test_hapd_ctrl.py index 92a16dd4c..9dec65d5a 100644 --- a/tests/hwsim/test_hapd_ctrl.py +++ b/tests/hwsim/test_hapd_ctrl.py @@ -911,6 +911,36 @@ def test_hapd_ctrl_ext_io_errors(dev, apdev): if "FAIL" not in hapd.request("DATA_TEST_FRAME 112233445566778899aabbccddeeff"): raise Exception("DATA_TEST_FRAME accepted during OOM") +def test_hapd_ctrl_vendor_test(dev, apdev): + """hostapd and VENDOR test command""" + ssid = "hapd-ctrl" + params = {"ssid": ssid} + hapd = hostapd.add_ap(apdev[0], params) + + OUI_QCA = 0x001374 + QCA_NL80211_VENDOR_SUBCMD_TEST = 1 + QCA_WLAN_VENDOR_ATTR_TEST = 8 + attr = struct.pack("@HHI", 4 + 4, QCA_WLAN_VENDOR_ATTR_TEST, 123) + cmd = "VENDOR %x %d %s" % (OUI_QCA, QCA_NL80211_VENDOR_SUBCMD_TEST, binascii.hexlify(attr).decode()) + + res = hapd.request(cmd) + if "FAIL" in res: + raise Exception("VENDOR command failed") + val, = struct.unpack("@I", binascii.unhexlify(res)) + if val != 125: + raise Exception("Incorrect response value") + + res = hapd.request(cmd + " nested=1") + if "FAIL" in res: + raise Exception("VENDOR command failed") + val, = struct.unpack("@I", binascii.unhexlify(res)) + if val != 125: + raise Exception("Incorrect response value") + + res = hapd.request(cmd + " nested=0") + if "FAIL" not in res: + raise Exception("VENDOR command with invalid (not nested) data accepted") + def test_hapd_ctrl_vendor_errors(dev, apdev): """hostapd and VENDOR errors""" ssid = "hapd-ctrl" diff --git a/tests/hwsim/test_wpas_ctrl.py b/tests/hwsim/test_wpas_ctrl.py index bb8ca1a2a..a99e2f49a 100644 --- a/tests/hwsim/test_wpas_ctrl.py +++ b/tests/hwsim/test_wpas_ctrl.py @@ -1344,6 +1344,32 @@ def test_wpas_ctrl_rsp(dev, apdev): if "OK" not in dev[0].request("CTRL-RSP-%s-%d:" % (req, id)): raise Exception("Request failed unexpectedly") +def test_wpas_ctrl_vendor_test(dev, apdev): + """wpas_supplicant and VENDOR test command""" + OUI_QCA = 0x001374 + QCA_NL80211_VENDOR_SUBCMD_TEST = 1 + QCA_WLAN_VENDOR_ATTR_TEST = 8 + attr = struct.pack("@HHI", 4 + 4, QCA_WLAN_VENDOR_ATTR_TEST, 123) + cmd = "VENDOR %x %d %s" % (OUI_QCA, QCA_NL80211_VENDOR_SUBCMD_TEST, binascii.hexlify(attr).decode()) + + res = dev[0].request(cmd) + if "FAIL" in res: + raise Exception("VENDOR command failed") + val, = struct.unpack("@I", binascii.unhexlify(res)) + if val != 125: + raise Exception("Incorrect response value") + + res = dev[0].request(cmd + " nested=1") + if "FAIL" in res: + raise Exception("VENDOR command failed") + val, = struct.unpack("@I", binascii.unhexlify(res)) + if val != 125: + raise Exception("Incorrect response value") + + res = dev[0].request(cmd + " nested=0") + if "FAIL" not in res: + raise Exception("VENDOR command with invalid (not nested) data accepted") + @remote_compatible def test_wpas_ctrl_vendor(dev, apdev): """wpa_supplicant ctrl_iface VENDOR""" -- 2.47.3