tests: WDS STA mode
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
5bdac4abce
commit
8a9a3b34dd
2 changed files with 38 additions and 9 deletions
|
@ -1,15 +1,16 @@
|
||||||
# hwsim testing utilities
|
# hwsim testing utilities
|
||||||
# Copyright (c) 2013, Jouni Malinen <j@w1.fi>
|
# Copyright (c) 2013-2014, Jouni Malinen <j@w1.fi>
|
||||||
#
|
#
|
||||||
# This software may be distributed under the terms of the BSD license.
|
# This software may be distributed under the terms of the BSD license.
|
||||||
# See README for more details.
|
# See README for more details.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import time
|
||||||
import logging
|
import logging
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
def test_connectivity(ifname1, ifname2, dscp=None, tos=None):
|
def test_connectivity(ifname1, ifname2, dscp=None, tos=None, max_tries=1):
|
||||||
if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"):
|
if os.path.isfile("../../mac80211_hwsim/tools/hwsim_test"):
|
||||||
hwsim_test = "../../mac80211_hwsim/tools/hwsim_test"
|
hwsim_test = "../../mac80211_hwsim/tools/hwsim_test"
|
||||||
else:
|
else:
|
||||||
|
@ -24,13 +25,20 @@ def test_connectivity(ifname1, ifname2, dscp=None, tos=None):
|
||||||
elif tos:
|
elif tos:
|
||||||
cmd.append('-t')
|
cmd.append('-t')
|
||||||
cmd.append(str(tos))
|
cmd.append(str(tos))
|
||||||
|
success = False
|
||||||
|
for i in range(0, max_tries):
|
||||||
try:
|
try:
|
||||||
s = subprocess.check_output(cmd)
|
s = subprocess.check_output(cmd)
|
||||||
logger.debug(s)
|
logger.debug(s)
|
||||||
|
success = True
|
||||||
|
break
|
||||||
except subprocess.CalledProcessError, e:
|
except subprocess.CalledProcessError, e:
|
||||||
logger.info("hwsim failed: " + str(e.returncode))
|
logger.info("hwsim failed: " + str(e.returncode))
|
||||||
logger.info(e.output)
|
logger.info(e.output)
|
||||||
raise
|
if i + 1 < max_tries:
|
||||||
|
time.sleep(1)
|
||||||
|
if not success:
|
||||||
|
raise Exception("hwsim_test failed")
|
||||||
|
|
||||||
def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None):
|
def test_connectivity_p2p(dev1, dev2, dscp=None, tos=None):
|
||||||
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
|
ifname1 = dev1.group_ifname if dev1.group_ifname else dev1.ifname
|
||||||
|
|
|
@ -103,3 +103,24 @@ def test_ap_acl_deny(dev, apdev):
|
||||||
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
||||||
if ev is not None:
|
if ev is not None:
|
||||||
raise Exception("Unexpected association")
|
raise Exception("Unexpected association")
|
||||||
|
|
||||||
|
def test_ap_wds_sta(dev, apdev):
|
||||||
|
"""WPA2-PSK AP with STA using 4addr mode"""
|
||||||
|
ssid = "test-wpa2-psk"
|
||||||
|
passphrase = 'qwertyuiop'
|
||||||
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
||||||
|
params['wds_sta'] = "1"
|
||||||
|
params['wds_bridge'] = "wds-br0"
|
||||||
|
hostapd.add_ap(apdev[0]['ifname'], params)
|
||||||
|
|
||||||
|
try:
|
||||||
|
subprocess.call(['sudo', 'brctl', 'addbr', 'wds-br0'])
|
||||||
|
subprocess.call(['sudo', 'brctl', 'setfd', 'wds-br0', '0'])
|
||||||
|
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
|
||||||
|
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'on'])
|
||||||
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
||||||
|
hwsim_utils.test_connectivity(dev[0].ifname, "wds-br0", max_tries=15)
|
||||||
|
finally:
|
||||||
|
subprocess.call(['sudo', 'iw', dev[0].ifname, 'set', '4addr', 'off'])
|
||||||
|
subprocess.call(['sudo', 'ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
|
||||||
|
subprocess.call(['sudo', 'brctl', 'delbr', 'wds-br0'])
|
||||||
|
|
Loading…
Reference in a new issue