2 # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
10 logger = logging.getLogger()
15 def test_ap_roam_open(dev, apdev):
16 """Roam between two open APs"""
17 hapd0 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
18 dev[0].connect("test-open", key_mgmt="NONE")
19 hwsim_utils.test_connectivity(dev[0], hapd0)
20 hapd1 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
21 dev[0].scan(type="ONLY")
22 dev[0].roam(apdev[1]['bssid'])
23 hwsim_utils.test_connectivity(dev[0], hapd1)
24 dev[0].roam(apdev[0]['bssid'])
25 hwsim_utils.test_connectivity(dev[0], hapd0)
27 def test_ap_roam_wpa2_psk(dev, apdev):
28 """Roam between two WPA2-PSK APs"""
29 params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
30 hapd0 = hostapd.add_ap(apdev[0]['ifname'], params)
31 dev[0].connect("test-wpa2-psk", psk="12345678")
32 hwsim_utils.test_connectivity(dev[0], hapd0)
33 hapd1 = hostapd.add_ap(apdev[1]['ifname'], params)
34 dev[0].scan(type="ONLY")
35 dev[0].roam(apdev[1]['bssid'])
36 hwsim_utils.test_connectivity(dev[0], hapd1)
37 dev[0].roam(apdev[0]['bssid'])
38 hwsim_utils.test_connectivity(dev[0], hapd0)
40 def test_ap_reassociation_to_same_bss(dev, apdev):
41 """Reassociate to the same BSS"""
42 hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
43 dev[0].connect("test-open", key_mgmt="NONE")
45 dev[0].request("REASSOCIATE")
46 dev[0].wait_connected(timeout=10, error="Reassociation timed out")
47 hwsim_utils.test_connectivity(dev[0], hapd)
49 dev[0].request("REATTACH")
50 dev[0].wait_connected(timeout=10, error="Reattach timed out")
51 hwsim_utils.test_connectivity(dev[0], hapd)
53 def test_ap_roam_set_bssid(dev, apdev):
55 hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
56 hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
57 id = dev[0].connect("test-open", key_mgmt="NONE", bssid=apdev[1]['bssid'],
59 if dev[0].get_status_field('bssid') != apdev[1]['bssid']:
60 raise Exception("Unexpected BSS")
61 # for now, these are just verifying that the code path to indicate
62 # within-ESS roaming changes can be executed; the actual results of those
63 # operations are not currently verified (that would require a test driver
64 # that does BSS selection)
65 dev[0].set_network(id, "bssid", "")
66 dev[0].set_network(id, "bssid", apdev[0]['bssid'])
67 dev[0].set_network(id, "bssid", apdev[1]['bssid'])