]>
Commit | Line | Data |
---|---|---|
5126138c JM |
1 | # Roaming tests |
2 | # Copyright (c) 2013, Jouni Malinen <j@w1.fi> | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
7 | import time | |
8 | import subprocess | |
9 | import logging | |
c9aa4308 | 10 | logger = logging.getLogger() |
5126138c JM |
11 | |
12 | import hwsim_utils | |
13 | import hostapd | |
14 | ||
ae3ad328 | 15 | def test_ap_roam_open(dev, apdev): |
5126138c | 16 | """Roam between two open APs""" |
a8375c94 | 17 | hapd0 = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) |
5126138c | 18 | dev[0].connect("test-open", key_mgmt="NONE") |
a8375c94 JM |
19 | hwsim_utils.test_connectivity(dev[0], hapd0) |
20 | hapd1 = hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" }) | |
5126138c | 21 | dev[0].scan(type="ONLY") |
ae3ad328 | 22 | dev[0].roam(apdev[1]['bssid']) |
a8375c94 | 23 | hwsim_utils.test_connectivity(dev[0], hapd1) |
ae3ad328 | 24 | dev[0].roam(apdev[0]['bssid']) |
a8375c94 | 25 | hwsim_utils.test_connectivity(dev[0], hapd0) |
5126138c | 26 | |
ae3ad328 | 27 | def test_ap_roam_wpa2_psk(dev, apdev): |
5126138c JM |
28 | """Roam between two WPA2-PSK APs""" |
29 | params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678") | |
a8375c94 | 30 | hapd0 = hostapd.add_ap(apdev[0]['ifname'], params) |
5126138c | 31 | dev[0].connect("test-wpa2-psk", psk="12345678") |
a8375c94 JM |
32 | hwsim_utils.test_connectivity(dev[0], hapd0) |
33 | hapd1 = hostapd.add_ap(apdev[1]['ifname'], params) | |
5126138c | 34 | dev[0].scan(type="ONLY") |
ae3ad328 | 35 | dev[0].roam(apdev[1]['bssid']) |
a8375c94 | 36 | hwsim_utils.test_connectivity(dev[0], hapd1) |
ae3ad328 | 37 | dev[0].roam(apdev[0]['bssid']) |
a8375c94 | 38 | hwsim_utils.test_connectivity(dev[0], hapd0) |
99cd77a8 JM |
39 | |
40 | def test_ap_reassociation_to_same_bss(dev, apdev): | |
41 | """Reassociate to the same BSS""" | |
a8375c94 | 42 | hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" }) |
99cd77a8 JM |
43 | dev[0].connect("test-open", key_mgmt="NONE") |
44 | ||
45 | dev[0].request("REASSOCIATE") | |
5f35a5e2 | 46 | dev[0].wait_connected(timeout=10, error="Reassociation timed out") |
a8375c94 | 47 | hwsim_utils.test_connectivity(dev[0], hapd) |
99cd77a8 JM |
48 | |
49 | dev[0].request("REATTACH") | |
5f35a5e2 | 50 | dev[0].wait_connected(timeout=10, error="Reattach timed out") |
a8375c94 | 51 | hwsim_utils.test_connectivity(dev[0], hapd) |
a567aae4 JM |
52 | |
53 | def test_ap_roam_set_bssid(dev, apdev): | |
54 | """Roam control""" | |
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'], | |
58 | scan_freq="2412") | |
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']) |