]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
tests: WPA2-PSK and STA using 4addr mode
authorJouni Malinen <quic_jouni@quicinc.com>
Mon, 20 Feb 2023 22:12:22 +0000 (00:12 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 20 Feb 2023 22:12:34 +0000 (00:12 +0200)
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
tests/hwsim/test_ap_psk.py
tests/hwsim/wpasupplicant.py

index 4d7fcce44b109f45860da4347511900b1341c640..b035c6ee2fccf12ad1503457699c3bb57e48dd23 100644 (file)
@@ -3663,3 +3663,34 @@ def run_ap_wpa2_psk_ext_key_id_ptk_rekey_sta(dev, apdev, ext_key_id):
         hwsim_utils.test_connectivity(dev[0], hapd)
     finally:
         dev[0].set("extended_key_id", "0")
+
+def test_ap_wpa2_psk_4addr(dev, apdev):
+    """WPA2-PSK and STA using 4addr mode"""
+    br_ifname = 'sta-br0'
+    ssid = "test-wpa2-psk"
+    passphrase = 'qwertyuiop'
+    params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
+    hapd = hostapd.add_ap(apdev[0], params)
+    dev[0].connect(ssid, psk=passphrase, scan_freq="2412",
+                   enable_4addr_mode="1")
+
+    # Verify that the station interface can be added into a bridge.
+    ifname = dev[0].ifname
+    try:
+        subprocess.check_call(['brctl', 'addbr', br_ifname])
+        subprocess.check_call(['ip', 'link', 'set', 'dev', br_ifname, 'up'])
+        subprocess.check_call(['brctl', 'addif', br_ifname, ifname])
+        cmd = subprocess.Popen(['brctl', 'show'], stdout=subprocess.PIPE)
+        res = cmd.stdout.read().decode()
+    finally:
+        subprocess.call(['brctl', 'delif', br_ifname, ifname])
+        subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'down'])
+        subprocess.call(['brctl', 'delbr', br_ifname])
+
+    found = False
+    for s in res.splitlines():
+        vals = s.split()
+        if br_ifname in vals and ifname in vals:
+            found = True
+    if not found:
+        raise Exception("Station interface was not seen in the bridge")
index d6b4c48917d8a079b6d5e0dd8544778c0d2822f5..bd53a1ec0991b085029d018b981231a4a1b0254d 100644 (file)
@@ -1116,7 +1116,8 @@ class WpaSupplicant:
                       "multi_ap_backhaul_sta", "rx_stbc", "tx_stbc",
                       "ft_eap_pmksa_caching", "beacon_prot",
                       "mac_value",
-                      "wpa_deny_ptk0_rekey"]
+                      "wpa_deny_ptk0_rekey",
+                      "enable_4addr_mode"]
         for field in not_quoted:
             if field in kwargs and kwargs[field]:
                 self.set_network(id, field, kwargs[field])