]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: WNM BSS max idle period management
authorJouni Malinen <quic_jouni@quicinc.com>
Wed, 29 May 2024 18:43:26 +0000 (21:43 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 29 May 2024 20:46:02 +0000 (23:46 +0300)
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
tests/hwsim/test_wnm.py
tests/hwsim/wpasupplicant.py

index 4eae99fa47016be395a691cb30617c10b17acbc4..bf7a0ab219b895adb4cf9c25040198da58dcb0e2 100644 (file)
@@ -39,7 +39,8 @@ def start_wnm_ap(apdev, bss_transition=True, time_adv=False, ssid=None,
                  hw_mode=None, channel=None, country_code=None, country3=None,
                  pmf=True, passphrase=None, ht=True, vht=False, mbo=False,
                  beacon_prot=False, he=False, bss_max_idle=None,
-                 wpa_group_rekey=None, no_disconnect_on_group_keyerror=False):
+                 wpa_group_rekey=None, no_disconnect_on_group_keyerror=False,
+                 max_acceptable_idle_period=None):
     if rsn:
         if not ssid:
             ssid = "test-wnm-rsn"
@@ -94,6 +95,8 @@ def start_wnm_ap(apdev, bss_transition=True, time_adv=False, ssid=None,
         params["wpa_group_rekey"] = str(wpa_group_rekey)
     if no_disconnect_on_group_keyerror:
         params["no_disconnect_on_group_keyerror"] = "1"
+    if max_acceptable_idle_period is not None:
+        params["max_acceptable_idle_period"] = str(max_acceptable_idle_period)
     try:
         hapd = hostapd.add_ap(apdev, params)
     except Exception as e:
@@ -823,6 +826,34 @@ def run_wnm_bss_keep_alive(dev, apdev, protected):
     if int(sta['tx_packets']) <= int(end['tx_packets']):
         raise Exception("No client poll packet seen")
 
+def test_wnm_bss_max_idle_period_management(dev, apdev):
+    """WNM BSS max idle period management"""
+    hapd = start_wnm_ap(apdev[0], bss_transition=False, ap_max_inactivity=10,
+                        max_acceptable_idle_period=1000, rsn=True)
+    addr = dev[0].own_addr()
+    dev[0].connect("test-wnm-rsn", psk="12345678", ieee80211w="2",
+                   key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412",
+                   max_idle="1500")
+    addr1 = dev[1].own_addr()
+    dev[1].connect("test-wnm-rsn", psk="12345678", ieee80211w="2",
+                   key_mgmt="WPA-PSK-SHA256", proto="WPA2", scan_freq="2412")
+
+    ap_val = hapd.get_sta(addr)['max_idle_period']
+    if ap_val != '1000':
+        raise Exception("AP reported unexpected value: " + ap_val)
+
+    sta_val = dev[0].get_status_field("bss_max_idle_period")
+    if sta_val != '1000':
+        raise Exception("STA reported unexpected value: " + sta_val)
+
+    sta = hapd.get_sta(addr1)
+    if 'max_idle_period' in sta:
+        raise Exception("AP reported unexpected value(2): " + sta['max_idle_period'])
+
+    sta_val = dev[1].get_status_field("bss_max_idle_period")
+    if sta_val != '9':
+        raise Exception("STA reported unexpected value(2): " + sta_val)
+
 def test_wnm_bss_group_rekey(dev, apdev):
     """WNM BSS max idle period and group rekey"""
     hapd = start_wnm_ap(apdev[0], bss_transition=False, ap_max_inactivity=100,
index 8912310b956f78d9e6e589bf8213d2d7a120ef47..1b3fd09488d649705eea32a64c1e226666044ba9 100644 (file)
@@ -1115,6 +1115,7 @@ class WpaSupplicant:
                       "ft_eap_pmksa_caching", "beacon_prot",
                       "mac_value",
                       "wpa_deny_ptk0_rekey",
+                      "max_idle",
                       "enable_4addr_mode"]
         for field in not_quoted:
             if field in kwargs and kwargs[field]: