]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_ap_open.py
ad24cdd38bf63461ac3e2b55795e3adecf5c1f2c
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger
= logging
.getLogger()
16 def test_ap_open(dev
, apdev
):
17 """AP with open mode (no security) configuration"""
18 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
19 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
20 ev
= hapd
.wait_event([ "AP-STA-CONNECTED" ], timeout
=5)
22 raise Exception("No connection event received from hostapd")
23 hwsim_utils
.test_connectivity(dev
[0], hapd
)
25 dev
[0].request("DISCONNECT")
26 ev
= hapd
.wait_event([ "AP-STA-DISCONNECTED" ], timeout
=5)
28 raise Exception("No disconnection event received from hostapd")
30 def test_ap_open_packet_loss(dev
, apdev
):
31 """AP with open mode configuration and large packet loss"""
32 params
= { "ssid": "open",
33 "ignore_probe_probability": "0.5",
34 "ignore_auth_probability": "0.5",
35 "ignore_assoc_probability": "0.5",
36 "ignore_reassoc_probability": "0.5" }
37 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], params
)
39 dev
[i
].connect("open", key_mgmt
="NONE", scan_freq
="2412",
42 ev
= dev
[i
].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=20)
44 raise Exception("Association with the AP timed out")
46 def test_ap_open_unknown_action(dev
, apdev
):
47 """AP with open mode configuration and unknown Action frame"""
48 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
49 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
50 bssid
= apdev
[0]['bssid']
51 cmd
= "MGMT_TX {} {} freq=2412 action=765432".format(bssid
, bssid
)
52 if "FAIL" in dev
[0].request(cmd
):
53 raise Exception("Could not send test Action frame")
54 ev
= dev
[0].wait_event(["MGMT-TX-STATUS"], timeout
=10)
56 raise Exception("Timeout on MGMT-TX-STATUS")
57 if "result=SUCCESS" not in ev
:
58 raise Exception("AP did not ack Action frame")
60 def test_ap_open_reconnect_on_inactivity_disconnect(dev
, apdev
):
61 """Reconnect to open mode AP after inactivity related disconnection"""
62 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
63 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
64 hapd
.request("DEAUTHENTICATE " + dev
[0].p2p_interface_addr() + " reason=4")
65 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=5)
67 raise Exception("Timeout on disconnection")
68 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=2)
70 raise Exception("Timeout on reconnection")
72 def test_ap_open_assoc_timeout(dev
, apdev
):
73 """AP timing out association"""
75 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
76 dev
[0].scan(freq
="2412")
77 hapd
.set("ext_mgmt_frame_handling", "1")
78 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412",
80 for i
in range(0, 10):
83 raise Exception("MGMT RX wait timed out")
84 if req
['subtype'] == 11:
88 raise Exception("Authentication frame not received")
91 resp
['fc'] = req
['fc']
92 resp
['da'] = req
['sa']
93 resp
['sa'] = req
['da']
94 resp
['bssid'] = req
['bssid']
95 resp
['payload'] = struct
.pack('<HHH', 0, 2, 0)
99 for i
in range(0, 10):
102 raise Exception("MGMT RX wait timed out")
103 if req
['subtype'] == 0:
108 raise Exception("Association Request frames not received: assoc=%d" % assoc
)
109 hapd
.set("ext_mgmt_frame_handling", "0")
110 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
112 raise Exception("Timeout on connection")
114 def test_ap_open_id_str(dev
, apdev
):
115 """AP with open mode and id_str"""
116 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
117 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412", id_str
="foo",
119 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"])
121 raise Exception("Association with the AP timed out")
122 if "id_str=foo" not in ev
:
123 raise Exception("CTRL-EVENT-CONNECT did not have matching id_str: " + ev
)
124 if dev
[0].get_status_field("id_str") != "foo":
125 raise Exception("id_str mismatch")
127 def test_ap_open_select_any(dev
, apdev
):
128 """AP with open mode and select any network"""
129 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
130 id = dev
[0].connect("unknown", key_mgmt
="NONE", scan_freq
="2412",
131 only_add_network
=True)
132 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412",
133 only_add_network
=True)
134 dev
[0].select_network(id)
135 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=1)
137 raise Exception("Unexpected connection")
139 dev
[0].select_network("any")
140 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"])
142 raise Exception("Association with the AP timed out")
144 def test_ap_open_unexpected_assoc_event(dev
, apdev
):
145 """AP with open mode and unexpected association event"""
146 hapd
= hostapd
.add_ap(apdev
[0]['ifname'], { "ssid": "open" })
147 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
148 dev
[0].request("DISCONNECT")
149 dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=15)
150 dev
[0].dump_monitor()
151 # This will be accepted due to matching network
152 subprocess
.call(['iw', 'dev', dev
[0].ifname
, 'connect', 'open', "2412",
154 ev
= dev
[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout
=15)
156 raise Exception("Association with the AP timed out")
157 dev
[0].dump_monitor()
159 dev
[0].request("REMOVE_NETWORK all")
160 dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=5)
161 dev
[0].dump_monitor()
162 # This will result in disconnection due to no matching network
163 subprocess
.call(['iw', 'dev', dev
[0].ifname
, 'connect', 'open', "2412",
165 ev
= dev
[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout
=15)
167 raise Exception("Disconnection with the AP timed out")
169 def test_ap_bss_load(dev
, apdev
):
170 """AP with open mode (no security) configuration"""
171 hapd
= hostapd
.add_ap(apdev
[0]['ifname'],
173 "bss_load_update_period": "10" })
174 dev
[0].connect("open", key_mgmt
="NONE", scan_freq
="2412")
175 # this does not really get much useful output with mac80211_hwsim currently,
176 # but run through the channel survey update couple of times
177 for i
in range(0, 10):
178 hwsim_utils
.test_connectivity(dev
[0], hapd
)
179 hwsim_utils
.test_connectivity(dev
[0], hapd
)
180 hwsim_utils
.test_connectivity(dev
[0], hapd
)