]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: Random MAC address with two APs
authorJouni Malinen <j@w1.fi>
Sun, 27 Nov 2022 10:17:41 +0000 (12:17 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 27 Nov 2022 12:18:53 +0000 (14:18 +0200)
This verifies locally generated deauthentication determination when the
MAC address changes.

Signed-off-by: Jouni Malinen <j@w1.fi>
tests/hwsim/test_sta_dynamic.py

index a5bc82cded23efdd80d28b678da7b132dba80c7a..c5b256396b44d5025069fd8496a4f9a3f7251af1 100644 (file)
@@ -253,6 +253,67 @@ def test_sta_dynamic_random_mac_addr(dev, apdev):
     if addr1 == addr2:
         raise Exception("Random MAC address did not change")
 
+def test_sta_dynamic_random_mac_addr_two_aps(dev, apdev):
+    """Dynamically added wpa_supplicant interface and random MAC address with two APs"""
+    params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
+    hapd = hostapd.add_ap(apdev[0], params)
+    params = hostapd.wpa2_params(ssid="sta-dynamic2", passphrase="12345678")
+    hapd2 = hostapd.add_ap(apdev[1], params)
+
+    wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
+    wpas.interface_add("wlan5")
+    addr0 = wpas.get_driver_status_field("addr")
+    wpas.request("SET preassoc_mac_addr 1")
+    wpas.request("SET rand_addr_lifetime 0")
+
+    wpas.scan_for_bss(hapd.own_addr(), freq=2412)
+    wpas.scan_for_bss(hapd2.own_addr(), freq=2412)
+
+    id = wpas.connect("sta-dynamic", psk="12345678", mac_addr="1",
+                      scan_freq="2412")
+    addr1 = wpas.get_driver_status_field("addr")
+
+    if addr0 == addr1:
+        raise Exception("Random MAC address not used")
+
+    sta = hapd.get_sta(addr0)
+    if sta['addr'] != "FAIL":
+        raise Exception("Unexpected STA association with permanent address")
+    sta = hapd.get_sta(addr1)
+    if sta['addr'] != addr1:
+        raise Exception("STA association with random address not found")
+
+    id2 = wpas.connect("sta-dynamic2", psk="12345678", mac_addr="1",
+                      scan_freq="2412")
+    addr2 = wpas.get_driver_status_field("addr")
+    if addr0 == addr2:
+        raise Exception("Random MAC address not used(2)")
+    if addr1 == addr2:
+        raise Exception("Random MAC address not change for another ESS)")
+    sta = hapd2.get_sta(addr0)
+    if sta['addr'] != "FAIL":
+        raise Exception("Unexpected STA association with permanent address(2)")
+    sta = hapd2.get_sta(addr2)
+    if sta['addr'] != addr2:
+        raise Exception("STA association with random address not found(2)")
+
+    wpas.dump_monitor()
+    wpas.request("ENABLE_NETWORK " + str(id) + " no-connect")
+    hapd2.request("STOP_AP")
+    ev = wpas.wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=10)
+    if ev is None:
+        raise Exception("Disconnection due to beacon loss not reported")
+    if "bssid=" + hapd2.own_addr() + " reason=4 locally_generated=1" not in ev:
+        raise Exception("Unexpected disconnection event values")
+    wpas.wait_connected()
+    addr3 = wpas.get_driver_status_field("addr")
+    if addr3 == addr0 or addr3 == addr2:
+        raise Exception("Random MAC address not changed on return to previous AP")
+    hapd2.disable()
+    sta = hapd.get_sta(addr3)
+    if sta['addr'] != addr3:
+        raise Exception("STA association with random address not found(3)")
+
 def test_sta_dynamic_random_mac_addr_keep_oui(dev, apdev):
     """Dynamically added wpa_supplicant interface and random MAC address (keep OUI)"""
     params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")