tests: Random MAC addresses while maintaining OUI

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-09-29 23:25:43 +03:00
parent a313d17de9
commit b5db69197a

View file

@ -147,6 +147,48 @@ 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_keep_oui(dev, apdev):
"""Dynamically added wpa_supplicant interface and random MAC address (keep OUI)"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
hapd = hostapd.add_ap(apdev[0]['ifname'], 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 2")
wpas.request("SET rand_addr_lifetime 0")
id = wpas.connect("sta-dynamic", psk="12345678", mac_addr="2",
scan_freq="2412")
addr1 = wpas.get_driver_status_field("addr")
if addr0 == addr1:
raise Exception("Random MAC address not used")
if addr1[3:8] != addr0[3:8]:
raise Exception("OUI was not kept")
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")
wpas.request("DISCONNECT")
wpas.connect_network(id)
addr2 = wpas.get_driver_status_field("addr")
if addr1 != addr2:
raise Exception("Random MAC address changed unexpectedly")
wpas.remove_network(id)
id = wpas.connect("sta-dynamic", psk="12345678", mac_addr="2",
scan_freq="2412")
addr2 = wpas.get_driver_status_field("addr")
if addr1 == addr2:
raise Exception("Random MAC address did not change")
if addr2[3:8] != addr0[3:8]:
raise Exception("OUI was not kept")
def test_sta_dynamic_random_mac_addr_scan(dev, apdev):
"""Dynamically added wpa_supplicant interface and random MAC address for scan"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
@ -163,3 +205,20 @@ def test_sta_dynamic_random_mac_addr_scan(dev, apdev):
if addr0 != addr1:
raise Exception("Random MAC address used unexpectedly")
def test_sta_dynamic_random_mac_addr_scan_keep_oui(dev, apdev):
"""Dynamically added wpa_supplicant interface and random MAC address for scan (keep OUI)"""
params = hostapd.wpa2_params(ssid="sta-dynamic", passphrase="12345678")
hapd = hostapd.add_ap(apdev[0]['ifname'], 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 2")
wpas.request("SET rand_addr_lifetime 0")
id = wpas.connect("sta-dynamic", psk="12345678", scan_freq="2412")
addr1 = wpas.get_driver_status_field("addr")
if addr0 != addr1:
raise Exception("Random MAC address used unexpectedly")