2013-03-30 10:28:39 +01:00
|
|
|
# Roaming tests
|
|
|
|
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
|
|
|
import time
|
|
|
|
import subprocess
|
|
|
|
import logging
|
2013-10-31 11:46:42 +01:00
|
|
|
logger = logging.getLogger()
|
2013-03-30 10:28:39 +01:00
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
import hostapd
|
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_roam_open(dev, apdev):
|
2013-03-30 10:28:39 +01:00
|
|
|
"""Roam between two open APs"""
|
2013-03-31 15:16:37 +02:00
|
|
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
|
2013-03-30 10:28:39 +01:00
|
|
|
dev[0].connect("test-open", key_mgmt="NONE")
|
2013-03-31 15:16:37 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
|
|
|
hostapd.add_ap(apdev[1]['ifname'], { "ssid": "test-open" })
|
2013-03-30 10:28:39 +01:00
|
|
|
dev[0].scan(type="ONLY")
|
2013-03-31 15:16:37 +02:00
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname'])
|
|
|
|
dev[0].roam(apdev[0]['bssid'])
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
2013-03-30 10:28:39 +01:00
|
|
|
|
2013-03-31 15:16:37 +02:00
|
|
|
def test_ap_roam_wpa2_psk(dev, apdev):
|
2013-03-30 10:28:39 +01:00
|
|
|
"""Roam between two WPA2-PSK APs"""
|
|
|
|
params = hostapd.wpa2_params(ssid="test-wpa2-psk", passphrase="12345678")
|
2013-03-31 15:16:37 +02:00
|
|
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
2013-03-30 10:28:39 +01:00
|
|
|
dev[0].connect("test-wpa2-psk", psk="12345678")
|
2013-03-31 15:16:37 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
|
|
|
hostapd.add_ap(apdev[1]['ifname'], params)
|
2013-03-30 10:28:39 +01:00
|
|
|
dev[0].scan(type="ONLY")
|
2013-03-31 15:16:37 +02:00
|
|
|
dev[0].roam(apdev[1]['bssid'])
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[1]['ifname'])
|
|
|
|
dev[0].roam(apdev[0]['bssid'])
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
2014-03-11 19:08:18 +01:00
|
|
|
|
|
|
|
def test_ap_reassociation_to_same_bss(dev, apdev):
|
|
|
|
"""Reassociate to the same BSS"""
|
|
|
|
hostapd.add_ap(apdev[0]['ifname'], { "ssid": "test-open" })
|
|
|
|
dev[0].connect("test-open", key_mgmt="NONE")
|
|
|
|
|
|
|
|
dev[0].request("REASSOCIATE")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Reassociation with the AP timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|
|
|
|
|
|
|
|
dev[0].request("REATTACH")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Reassociation (reattach) with the AP timed out")
|
|
|
|
hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
|