2014-01-31 15:59:41 +01:00
|
|
|
# Test various AP mode parameters
|
|
|
|
# Copyright (c) 2014, Qualcomm Atheros, Inc.
|
|
|
|
#
|
|
|
|
# This software may be distributed under the terms of the BSD license.
|
|
|
|
# See README for more details.
|
|
|
|
|
|
|
|
import logging
|
|
|
|
logger = logging.getLogger()
|
2015-12-06 12:35:40 +01:00
|
|
|
import os
|
2014-03-10 09:49:49 +01:00
|
|
|
import subprocess
|
2014-01-31 15:59:41 +01:00
|
|
|
|
|
|
|
import hwsim_utils
|
|
|
|
import hostapd
|
2015-12-06 12:35:40 +01:00
|
|
|
from tshark import run_tshark
|
2016-03-26 18:22:44 +01:00
|
|
|
from utils import alloc_fail
|
2014-01-31 15:59:41 +01:00
|
|
|
|
|
|
|
def test_ap_fragmentation_rts_set_high(dev, apdev):
|
|
|
|
"""WPA2-PSK AP with fragmentation and RTS thresholds larger than frame length"""
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['rts_threshold'] = "1000"
|
|
|
|
params['fragm_threshold'] = "2000"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-01-31 15:59:41 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-01-31 15:59:41 +01:00
|
|
|
|
|
|
|
def test_ap_fragmentation_open(dev, apdev):
|
|
|
|
"""Open AP with fragmentation threshold"""
|
|
|
|
ssid = "fragmentation"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['fragm_threshold'] = "1000"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-01-31 15:59:41 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-01-31 15:59:41 +01:00
|
|
|
|
|
|
|
def test_ap_fragmentation_wpa2(dev, apdev):
|
|
|
|
"""WPA2-PSK AP with fragmentation threshold"""
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['fragm_threshold'] = "1000"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-01-31 15:59:41 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-03-10 09:42:41 +01:00
|
|
|
|
|
|
|
def test_ap_vendor_elements(dev, apdev):
|
|
|
|
"""WPA2-PSK AP with vendor elements added"""
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['vendor_elements'] = "dd0411223301"
|
2016-04-20 12:22:32 +02:00
|
|
|
params['assocresp_elements'] = "dd0411223302"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-10 09:42:41 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
if "dd0411223301" not in bss['ie']:
|
|
|
|
raise Exception("Vendor element not shown in scan results")
|
2014-03-10 09:49:49 +01:00
|
|
|
|
2016-03-26 18:07:49 +01:00
|
|
|
hapd.set('vendor_elements', 'dd051122330203dd0400137400dd04001374ff')
|
2015-05-18 00:21:50 +02:00
|
|
|
if "OK" not in hapd.request("UPDATE_BEACON"):
|
|
|
|
raise Exception("UPDATE_BEACON failed")
|
|
|
|
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
|
|
|
bss = dev[1].get_bss(bssid)
|
|
|
|
if "dd0411223301" in bss['ie']:
|
|
|
|
raise Exception("Old vendor element still in scan results")
|
|
|
|
if "dd051122330203" not in bss['ie']:
|
|
|
|
raise Exception("New vendor element not shown in scan results")
|
|
|
|
|
2016-03-26 18:16:39 +01:00
|
|
|
def test_ap_element_parse(dev, apdev):
|
|
|
|
"""Information element parsing - extra coverage"""
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
params = { 'ssid': ssid,
|
|
|
|
'vendor_elements': "380501020304059e009e009e009e009e009e00" }
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2016-03-26 18:16:39 +01:00
|
|
|
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
if "38050102030405" not in bss['ie']:
|
|
|
|
raise Exception("Timeout element not shown in scan results")
|
|
|
|
|
2016-03-26 18:22:44 +01:00
|
|
|
def test_ap_element_parse_oom(dev, apdev):
|
|
|
|
"""Information element parsing OOM"""
|
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
params = { 'ssid': ssid,
|
|
|
|
'vendor_elements': "dd0d506f9a0a00000600411c440028" }
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2016-03-26 18:22:44 +01:00
|
|
|
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
|
|
|
with alloc_fail(dev[0], 1, "wpabuf_alloc;ieee802_11_vendor_ie_concat"):
|
|
|
|
bss = dev[0].get_bss(bssid)
|
|
|
|
logger.info(str(bss))
|
|
|
|
|
2014-03-10 09:49:49 +01:00
|
|
|
def test_ap_country(dev, apdev):
|
|
|
|
"""WPA2-PSK AP setting country code and using 5 GHz band"""
|
|
|
|
try:
|
2014-12-15 00:32:01 +01:00
|
|
|
hapd = None
|
2014-03-10 09:49:49 +01:00
|
|
|
bssid = apdev[0]['bssid']
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['country_code'] = 'FI'
|
|
|
|
params['ieee80211d'] = '1'
|
|
|
|
params['hw_mode'] = 'a'
|
|
|
|
params['channel'] = '36'
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-10 09:49:49 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="5180")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|
2014-03-10 09:49:49 +01:00
|
|
|
finally:
|
2014-12-15 00:32:01 +01:00
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
if hapd:
|
|
|
|
hapd.request("DISABLE")
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['iw', 'reg', 'set', '00'])
|
2014-12-15 00:32:01 +01:00
|
|
|
dev[0].flush_scan_cache()
|
2014-03-13 22:27:11 +01:00
|
|
|
|
|
|
|
def test_ap_acl_accept(dev, apdev):
|
|
|
|
"""MAC ACL accept list"""
|
|
|
|
ssid = "acl"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['accept_mac_file'] = "hostapd.macaddr"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-05-15 17:04:59 +02:00
|
|
|
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
2014-03-13 22:27:11 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
2014-05-15 17:04:59 +02:00
|
|
|
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
2014-03-13 22:27:11 +01:00
|
|
|
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
dev[0].request("REMOVE_NETWORK all")
|
|
|
|
dev[1].request("REMOVE_NETWORK all")
|
|
|
|
hapd.request("SET macaddr_acl 1")
|
|
|
|
dev[1].dump_monitor()
|
|
|
|
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
|
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Unexpected association")
|
|
|
|
|
|
|
|
def test_ap_acl_deny(dev, apdev):
|
|
|
|
"""MAC ACL deny list"""
|
|
|
|
ssid = "acl"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['deny_mac_file'] = "hostapd.macaddr"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-05-15 17:04:59 +02:00
|
|
|
dev[0].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
2014-03-13 22:27:11 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
|
2014-05-15 17:04:59 +02:00
|
|
|
dev[1].scan_for_bss(apdev[0]['bssid'], freq="2412")
|
2014-03-13 22:27:11 +01:00
|
|
|
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Unexpected association")
|
2014-03-15 09:42:46 +01:00
|
|
|
|
|
|
|
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"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-15 09:42:46 +01:00
|
|
|
|
|
|
|
try:
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['brctl', 'addbr', 'wds-br0'])
|
|
|
|
subprocess.call(['brctl', 'setfd', 'wds-br0', '0'])
|
|
|
|
subprocess.call(['ip', 'link', 'set', 'dev', 'wds-br0', 'up'])
|
|
|
|
subprocess.call(['iw', dev[0].ifname, 'set', '4addr', 'on'])
|
2014-03-15 09:42:46 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
2014-11-27 13:04:51 +01:00
|
|
|
hwsim_utils.test_connectivity_iface(dev[0], hapd, "wds-br0",
|
|
|
|
max_tries=15)
|
2014-03-15 09:42:46 +01:00
|
|
|
finally:
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['iw', dev[0].ifname, 'set', '4addr', 'off'])
|
|
|
|
subprocess.call(['ip', 'link', 'set', 'dev', 'wds-br0', 'down'])
|
|
|
|
subprocess.call(['brctl', 'delbr', 'wds-br0'])
|
2014-03-15 12:46:01 +01:00
|
|
|
|
|
|
|
def test_ap_inactivity_poll(dev, apdev):
|
|
|
|
"""AP using inactivity poll"""
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['ap_max_inactivity'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-15 12:46:01 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "1")
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
ev = hapd.wait_event(["MGMT-RX"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("MGMT RX wait timed out for Deauth")
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "0")
|
|
|
|
ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=30)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("STA disconnection on inactivity was not reported")
|
|
|
|
|
|
|
|
def test_ap_inactivity_disconnect(dev, apdev):
|
|
|
|
"""AP using inactivity disconnect"""
|
|
|
|
ssid = "test-wpa2-psk"
|
|
|
|
passphrase = 'qwertyuiop'
|
|
|
|
params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)
|
|
|
|
params['ap_max_inactivity'] = "1"
|
|
|
|
params['skip_inactivity_poll'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-15 12:46:01 +01:00
|
|
|
dev[0].connect(ssid, psk=passphrase, scan_freq="2412")
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "1")
|
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
ev = hapd.wait_event(["MGMT-RX"], timeout=5)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("MGMT RX wait timed out for Deauth")
|
|
|
|
hapd.set("ext_mgmt_frame_handling", "0")
|
|
|
|
ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=30)
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("STA disconnection on inactivity was not reported")
|
2014-03-23 18:31:35 +01:00
|
|
|
|
|
|
|
def test_ap_basic_rates(dev, apdev):
|
|
|
|
"""Open AP with lots of basic rates"""
|
|
|
|
ssid = "basic rates"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['basic_rates'] = "10 20 55 110 60 90 120 180 240 360 480 540"
|
2016-03-30 10:55:56 +02:00
|
|
|
hostapd.add_ap(apdev[0], params)
|
2014-03-23 18:31:35 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
|
|
|
|
def test_ap_short_preamble(dev, apdev):
|
|
|
|
"""Open AP with short preamble"""
|
|
|
|
ssid = "short preamble"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['preamble'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hostapd.add_ap(apdev[0], params)
|
2014-03-23 18:31:35 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
|
|
|
|
def test_ap_spectrum_management_required(dev, apdev):
|
|
|
|
"""Open AP with spectrum management required"""
|
|
|
|
ssid = "spectrum mgmt"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params["country_code"] = "JP"
|
|
|
|
params["hw_mode"] = "a"
|
|
|
|
params["channel"] = "36"
|
|
|
|
params["ieee80211d"] = "1"
|
|
|
|
params["local_pwr_constraint"] = "3"
|
|
|
|
params['spectrum_mgmt_required'] = "1"
|
|
|
|
try:
|
2014-12-15 00:32:01 +01:00
|
|
|
hapd = None
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-23 18:31:35 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="5180")
|
|
|
|
finally:
|
2014-12-15 00:32:01 +01:00
|
|
|
dev[0].request("DISCONNECT")
|
|
|
|
if hapd:
|
|
|
|
hapd.request("DISABLE")
|
2015-02-06 23:22:32 +01:00
|
|
|
subprocess.call(['iw', 'reg', 'set', '00'])
|
2014-12-15 00:32:01 +01:00
|
|
|
dev[0].flush_scan_cache()
|
2014-03-29 15:56:14 +01:00
|
|
|
|
|
|
|
def test_ap_max_listen_interval(dev, apdev):
|
|
|
|
"""Open AP with maximum listen interval limit"""
|
|
|
|
ssid = "listen"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['max_listen_interval'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hostapd.add_ap(apdev[0], params)
|
2014-03-29 15:56:14 +01:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
|
|
|
|
if ev is None:
|
|
|
|
raise Exception("Association rejection not reported")
|
|
|
|
if "status_code=51" not in ev:
|
|
|
|
raise Exception("Unexpected ASSOC-REJECT reason")
|
2014-03-29 16:00:02 +01:00
|
|
|
|
|
|
|
def test_ap_max_num_sta(dev, apdev):
|
|
|
|
"""Open AP with maximum STA count"""
|
|
|
|
ssid = "max"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['max_num_sta'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hostapd.add_ap(apdev[0], params)
|
2014-03-29 16:00:02 +01:00
|
|
|
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412", wait_connect=False)
|
|
|
|
ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=1)
|
|
|
|
if ev is not None:
|
|
|
|
raise Exception("Unexpected association")
|
2014-03-30 11:42:16 +02:00
|
|
|
|
2015-12-06 12:35:40 +01:00
|
|
|
def test_ap_max_num_sta_no_probe_resp(dev, apdev, params):
|
2015-10-17 18:31:17 +02:00
|
|
|
"""Maximum STA count and limit on Probe Response frames"""
|
2015-12-06 12:35:40 +01:00
|
|
|
logdir = params['logdir']
|
2015-10-17 18:31:17 +02:00
|
|
|
dev[0].flush_scan_cache()
|
|
|
|
ssid = "max"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['beacon_int'] = "2000"
|
|
|
|
params['max_num_sta'] = "1"
|
|
|
|
params['no_probe_resp_if_max_sta'] = "1"
|
2016-03-30 10:55:56 +02:00
|
|
|
hostapd.add_ap(apdev[0], params)
|
2015-10-17 18:31:17 +02:00
|
|
|
dev[1].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
|
|
|
dev[0].scan(freq=2412, type="ONLY")
|
|
|
|
dev[0].scan(freq=2412, type="ONLY")
|
2015-12-06 12:35:40 +01:00
|
|
|
seen = dev[0].get_bss(apdev[0]['bssid']) != None
|
2015-10-17 18:31:17 +02:00
|
|
|
dev[1].scan(freq=2412, type="ONLY")
|
2015-12-06 12:35:40 +01:00
|
|
|
if seen:
|
|
|
|
out = run_tshark(os.path.join(logdir, "hwsim0.pcapng"),
|
|
|
|
"wlan.fc.type_subtype == 5", ["wlan.da" ])
|
|
|
|
if out:
|
|
|
|
if dev[0].own_addr() not in out:
|
|
|
|
# Discovery happened through Beacon frame reception. That's not
|
|
|
|
# an error case.
|
|
|
|
seen = False
|
|
|
|
if dev[1].own_addr() not in out:
|
|
|
|
raise Exception("No Probe Response frames to dev[1] seen")
|
|
|
|
if seen:
|
|
|
|
raise Exception("AP found unexpectedly")
|
2015-10-17 18:31:17 +02:00
|
|
|
|
2014-03-30 11:42:16 +02:00
|
|
|
def test_ap_tx_queue_params(dev, apdev):
|
|
|
|
"""Open AP with TX queue params set"""
|
|
|
|
ssid = "tx"
|
|
|
|
params = {}
|
|
|
|
params['ssid'] = ssid
|
|
|
|
params['tx_queue_data2_aifs'] = "4"
|
|
|
|
params['tx_queue_data2_cwmin'] = "7"
|
|
|
|
params['tx_queue_data2_cwmax'] = "1023"
|
|
|
|
params['tx_queue_data2_burst'] = "4.2"
|
|
|
|
params['tx_queue_data1_aifs'] = "4"
|
|
|
|
params['tx_queue_data1_cwmin'] = "7"
|
|
|
|
params['tx_queue_data1_cwmax'] = "1023"
|
|
|
|
params['tx_queue_data1_burst'] = "2"
|
2016-03-30 10:55:56 +02:00
|
|
|
hapd = hostapd.add_ap(apdev[0], params)
|
2014-03-30 11:42:16 +02:00
|
|
|
dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
|
2014-10-19 16:54:49 +02:00
|
|
|
hwsim_utils.test_connectivity(dev[0], hapd)
|