]>
Commit | Line | Data |
---|---|---|
b47750be JM |
1 | #!/usr/bin/python |
2 | # | |
3 | # Test cases for automatic channel selection with hostapd | |
4 | # Copyright (c) 2013, Jouni Malinen <j@w1.fi> | |
5 | # | |
6 | # This software may be distributed under the terms of the BSD license. | |
7 | # See README for more details. | |
8 | ||
9 | import logging | |
10 | logger = logging.getLogger() | |
11 | ||
12 | import hostapd | |
13 | ||
14 | def wait_acs(hapd): | |
15 | ev = hapd.wait_event(["ACS-STARTED", "ACS-COMPLETED", "ACS-FAILED", | |
16 | "AP-ENABLED"], timeout=5) | |
17 | if not ev: | |
18 | raise Exception("ACS start timed out") | |
19 | if "ACS-STARTED" not in ev: | |
20 | raise Exception("Unexpected ACS event") | |
21 | ||
22 | state = hapd.get_status_field("state") | |
23 | if state != "ACS": | |
24 | raise Exception("Unexpected interface state") | |
25 | ||
26 | ev = hapd.wait_event(["ACS-COMPLETED", "ACS-FAILED", "AP-ENABLED"], | |
27 | timeout=20) | |
28 | if not ev: | |
29 | raise Exception("ACS timed out") | |
30 | if "ACS-COMPLETED" not in ev: | |
31 | raise Exception("Unexpected ACS event") | |
32 | ||
33 | ev = hapd.wait_event(["AP-ENABLED"], timeout=5) | |
34 | if not ev: | |
35 | raise Exception("AP setup timed out") | |
36 | ||
37 | state = hapd.get_status_field("state") | |
38 | if state != "ENABLED": | |
39 | raise Exception("Unexpected interface state") | |
40 | ||
41 | def test_ap_acs(dev, apdev): | |
42 | """Automatic channel selection""" | |
43 | params = hostapd.wpa2_params(ssid="test-acs", passphrase="12345678") | |
44 | params['channel'] = '0' | |
45 | hapd = hostapd.add_ap(apdev[0]['ifname'], params) | |
46 | wait_acs(hapd) | |
47 | ||
48 | freq = hapd.get_status_field("freq") | |
49 | if int(freq) < 2400: | |
50 | raise Exception("Unexpected frequency") | |
51 | ||
52 | dev[0].connect("test-acs", psk="12345678", scan_freq=freq) | |
53 | ||
54 | def test_ap_multi_bss_acs(dev, apdev): | |
55 | """hostapd start with a multi-BSS configuration file using ACS""" | |
56 | ifname = apdev[0]['ifname'] | |
57 | hostapd.add_iface(ifname, 'multi-bss-acs.conf') | |
58 | hapd = hostapd.Hostapd(ifname) | |
59 | hapd.enable() | |
60 | wait_acs(hapd) | |
61 | ||
62 | freq = hapd.get_status_field("freq") | |
63 | if int(freq) < 2400: | |
64 | raise Exception("Unexpected frequency") | |
65 | ||
66 | dev[0].connect("bss-1", key_mgmt="NONE", scan_freq=freq) | |
67 | dev[1].connect("bss-2", psk="12345678", scan_freq=freq) | |
68 | dev[2].connect("bss-3", psk="qwertyuiop", scan_freq=freq) |