[PATCH 2/2] tests: WPS MAC address change

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

 



Verify that MAC address of WPS M1 message use correct address
after address change.

Signed-off-by: Mikael Kanstrup <mikael.kanstrup@xxxxxxxx>
---
 tests/hwsim/test_ap_wps.py | 45 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/tests/hwsim/test_ap_wps.py b/tests/hwsim/test_ap_wps.py
index 60b36c251..dabe805c0 100644
--- a/tests/hwsim/test_ap_wps.py
+++ b/tests/hwsim/test_ap_wps.py
@@ -5,6 +5,7 @@
 # See README for more details.
 
 from remotehost import remote_compatible
+from tshark import run_tshark
 import base64
 import binascii
 from Crypto.Cipher import AES
@@ -9981,6 +9982,50 @@ def test_ap_wps_pbc_in_m1(dev, apdev):
     dev[0].dump_monitor()
     dev[0].flush_scan_cache()
 
+def test_ap_wps_pbc_mac_addr_change(dev, apdev, params):
+    """WPS M1 with MAC address change"""
+    ssid = "test-wps-mac-addr-change"
+    hapd = hostapd.add_ap(apdev[0],
+                          {"ssid": ssid, "eap_server": "1", "wps_state": "1"})
+    hapd.request("WPS_PBC")
+    if "PBC Status: Active" not in hapd.request("WPS_GET_STATUS"):
+        raise Exception("PBC status not shown correctly")
+
+    addr = dev[0].get_status_field("address")
+    if addr == '02:11:22:33:44:55':
+        raise Exception("Unexpected initial MAC address")
+
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'down'])
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'address',
+                     '02:11:22:33:44:55'])
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'up'])
+    addr1 = dev[0].get_status_field("address")
+    if addr1 != '02:11:22:33:44:55':
+        raise Exception("Failed to change MAC address")
+
+    dev[0].request("WPS_PBC")
+    dev[0].wait_connected(timeout=30)
+    status = dev[0].get_status()
+    if status['wpa_state'] != 'COMPLETED' or status['bssid'] != apdev[0]['bssid']:
+        raise Exception("Not fully connected")
+
+    out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"),
+                     "wps.message_type == 0x04",
+                     display=["wps.mac_address"])
+    res = out.splitlines()
+
+    if len(res) < 1:
+        raise Exception("No M1 message with MAC address found")
+    if res[0] != addr1:
+        raise Exception("Wrong M1 MAC address")
+
+    # Reset MAC address
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'down'])
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'address',
+                     addr])
+    subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'up'])
+
+
 def test_ap_wps_pin_start_failure(dev, apdev):
     """WPS_PIN start failure"""
     with alloc_fail(dev[0], 1, "wpas_wps_start_dev_pw"):
-- 
2.17.1


_______________________________________________
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