[PATCH 3/3] tests: Extend MSCS testing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Daniel Gabay <daniel.gabay@xxxxxxxxx>

Add tests for new response handling logic:
1. Verify MSCS change response handling in association / action frame.
2. Verify MSCS unsolicited response handling.

Signed-off-by: Daniel Gabay <daniel.gabay@xxxxxxxxx>
---
 tests/hwsim/test_mscs.py | 189 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 186 insertions(+), 3 deletions(-)

diff --git a/tests/hwsim/test_mscs.py b/tests/hwsim/test_mscs.py
index 1a884074c8..50de4b7558 100644
--- a/tests/hwsim/test_mscs.py
+++ b/tests/hwsim/test_mscs.py
@@ -16,7 +16,13 @@ def register_mcsc_req(hapd):
     if "OK" not in hapd.request("REGISTER_FRAME %04x %s" % (type, match)):
         raise Exception("Could not register frame reception for Robust AV Streaming")
 
-def handle_mscs_req(hapd, wrong_dialog=False, status_code=0):
+def fill_change_params(dialog_token, status_code, params):
+    req_type = params['req_type'] if 'req_type' in params else 2
+    return struct.pack('<BBBHBBBBBBI', 19, 5, dialog_token, status_code,
+                       255, 8, 88, req_type, params['up_bitmap'], params['up_limit'],
+                       params['stream_timeout'])
+
+def handle_mscs_req(hapd, wrong_dialog=False, status_code=0, change_params=None):
     msg = hapd.mgmt_rx()
     if msg['subtype'] != 13:
         logger.info("RX:" + str(msg))
@@ -30,18 +36,31 @@ def handle_mscs_req(hapd, wrong_dialog=False, status_code=0):
         dialog_token = (dialog_token + 1) % 256
     msg['da'] = msg['sa']
     msg['sa'] = hapd.own_addr()
-    msg['payload'] = struct.pack('<BBBH', 19, 5, dialog_token, status_code)
+
+    if change_params is not None:
+        msg['payload'] = fill_change_params(dialog_token, status_code, change_params)
+    else:
+        msg['payload'] = struct.pack('<BBBH', 19, 5, dialog_token, status_code)
+
     hapd.mgmt_tx(msg)
     ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5)
     if ev is None or "stype=13 ok=1" not in ev:
         raise Exception("No TX status reported")
 
-def wait_mscs_result(dev, expect_status=0):
+def wait_mscs_result(dev, expect_status=0, change_params=None):
     ev = dev.wait_event(["CTRL-EVENT-MSCS-RESULT"], timeout=1)
     if ev is None:
         raise Exception("No MSCS result reported")
     if "status_code=%d" % expect_status not in ev:
         raise Exception("Unexpected MSCS result: " + ev)
+    if change_params is None and 'change' in ev:
+        raise Exception("Unexpected 'change' in MSCS result: " + ev)
+    if change_params is not None and \
+        ("change" not in ev or
+         "up_limit=%d" % change_params['up_limit'] not in ev or
+         "up_bitmap=%d" % change_params['up_bitmap'] not in ev or
+         "stream_timeout=%d" % change_params['stream_timeout'] not in ev):
+        raise Exception("Unexpected MSCS result: " + ev)
 
 def add_mscs_ap(apdev, reg_mscs_req=True, mscs_supported=True, assocresp_elements=None):
     params = {"ssid": "mscs"}
@@ -223,3 +242,167 @@ def run_mscs_local_errors(dev, apdev):
             cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
             if "FAIL" not in dev[0].request(cmd):
                 raise Exception("MSCS add succeeded in error case")
+
+def test_mscs_assoc_change_response(dev, apdev):
+    """MSCS configuration failure during assoc - AP response with change request"""
+    run(dev, apdev, run_mscs_assoc_change_response)
+
+def run_mscs_assoc_change_response(dev, apdev):
+    ies = "ff0c5802060701000000" + "01020001"
+    hapd = add_mscs_ap(apdev[0], assocresp_elements=ies)
+
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    dev[0].connect("mscs", key_mgmt="NONE", scan_freq="2412",
+                   wait_connect=False)
+
+    # based on the assoc_resp elements above
+    change_params = {
+        'up_bitmap': 6,
+        'up_limit': 7,
+        'stream_timeout': 1
+    }
+    wait_mscs_result(dev[0], expect_status=256, change_params=change_params)
+    dev[0].wait_connected()
+
+    hapd.dump_monitor()
+    hapd.set("ext_mgmt_frame_handling", "1")
+
+    # verify we're able to send new MSCS request
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345` frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    handle_mscs_req(hapd)
+    wait_mscs_result(dev[0])
+
+def test_mscs_post_assoc_change_response(dev, apdev):
+    """MSCS configuration failure post assoc - AP response with action frame change request"""
+    run(dev, apdev, run_mscs_post_assoc_change_response)
+
+def run_mscs_post_assoc_change_response(dev, apdev):
+    hapd = add_mscs_ap(apdev[0])
+    dev[0].connect("mscs", key_mgmt="NONE", scan_freq="2412")
+
+    hapd.dump_monitor()
+    hapd.set("ext_mgmt_frame_handling", "1")
+
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    change_params = {
+        'up_bitmap': 6,
+        'up_limit': 7,
+        'stream_timeout': 1
+    }
+
+    handle_mscs_req(hapd, status_code=256, change_params=change_params)
+    wait_mscs_result(dev[0], expect_status=256, change_params=change_params)
+
+    # verify we're able to send new valid MSCS request
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    handle_mscs_req(hapd)
+    wait_mscs_result(dev[0])
+
+def test_mscs_invalid_req_type_response(dev, apdev):
+    """MSCS AP response with invalid request type"""
+    run(dev, apdev, run_mscs_invalid_req_type_response)
+
+def run_mscs_invalid_req_type_response(dev, apdev):
+    hapd = add_mscs_ap(apdev[0])
+    dev[0].connect("mscs", key_mgmt="NONE", scan_freq="2412")
+
+    hapd.dump_monitor()
+    hapd.set("ext_mgmt_frame_handling", "1")
+
+    change_params = {
+        'up_bitmap': 6,
+        'up_limit': 7,
+        'stream_timeout': 1
+    }
+
+    # verify frames with invalid MSCS decriptor request type dropped
+    for req_type in [3, 4, 10]:
+        cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+        if "OK" not in dev[0].request(cmd):
+            raise Exception("MSCS add failed")
+
+        change_params['req_type'] = req_type
+        handle_mscs_req(hapd, status_code=256, change_params=change_params)
+        ev = dev[0].wait_event(["CTRL-EVENT-MSCS-RESULT"], timeout=1)
+        if ev is not None:
+            raise Exception("Unexpected MSCS result reported")
+
+def send_unsolicited_mscs_response(dev, hapd, status_code, params=None, wrong_dialog=False):
+    dialog_token = 0 if not wrong_dialog else 10
+    if params is not None:
+        payload = fill_change_params(dialog_token, status_code, params)
+    else:
+        payload = struct.pack('<BBBH', 19, 5, dialog_token, status_code)
+
+    msg = {
+        'fc': 0xd0,
+        'sa': hapd.own_addr(),
+        'da': dev.own_addr(),
+        'bssid': hapd.own_addr(),
+        'payload': payload,
+    }
+
+    hapd.mgmt_tx(msg)
+    ev = hapd.wait_event(["MGMT-TX-STATUS"], timeout=5)
+    if ev is None or "stype=13 ok=1" not in ev:
+        raise Exception("No TX status reported")
+
+def test_mscs_unsolicited_response(dev, apdev):
+    """MSCS configured and AP sends unsolicited response to terminate / change the session"""
+    run(dev, apdev, run_mscs_unsolicited_response)
+
+def run_mscs_unsolicited_response(dev, apdev):
+    hapd = add_mscs_ap(apdev[0])
+    dev[0].connect("mscs", key_mgmt="NONE", scan_freq="2412")
+
+    hapd.dump_monitor()
+    hapd.set("ext_mgmt_frame_handling", "1")
+
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    handle_mscs_req(hapd)
+    wait_mscs_result(dev[0])
+
+    status_code = 256
+
+    # verify unsolicited response with wrong dialog token (othar than 0) is dropped
+    send_unsolicited_mscs_response(dev[0], hapd, status_code=status_code, wrong_dialog=True)
+    ev = dev[0].wait_event(["CTRL-EVENT-MSCS-RESULT"], timeout=1)
+    if ev is not None:
+        raise Exception("Unexpected MSCS result reported")
+
+    # verify unsolicited response without change request (termination)
+    send_unsolicited_mscs_response(dev[0], hapd, status_code=status_code)
+    wait_mscs_result(dev[0], expect_status=status_code)
+
+    # send new MSCS request
+    cmd = "MSCS add up_bitmap=F0 up_limit=7 stream_timeout=12345 frame_classifier=045F"
+    if "OK" not in dev[0].request(cmd):
+        raise Exception("MSCS add failed")
+
+    handle_mscs_req(hapd)
+    wait_mscs_result(dev[0])
+
+    params = {
+        'up_bitmap': 6,
+        'up_limit': 7,
+        'stream_timeout': 1
+    }
+
+    # verify unsolicited response handling with change request
+    send_unsolicited_mscs_response(dev[0], hapd, status_code=status_code, params=params)
+    wait_mscs_result(dev[0], expect_status=status_code, change_params=params)
-- 
2.43.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux