]>
Commit | Line | Data |
---|---|---|
5a92bda6 JM |
1 | # Open mode AP tests |
2 | # Copyright (c) 2014, Qualcomm Atheros, Inc. | |
3 | # | |
4 | # This software may be distributed under the terms of the BSD license. | |
5 | # See README for more details. | |
6 | ||
9fd6804d | 7 | from remotehost import remote_compatible |
f0b7218f JM |
8 | import logging |
9 | logger = logging.getLogger() | |
10 | import struct | |
9a921f9a JM |
11 | import subprocess |
12 | import time | |
d0007ac9 | 13 | import os |
f0b7218f | 14 | |
5a92bda6 JM |
15 | import hostapd |
16 | import hwsim_utils | |
d0007ac9 | 17 | from tshark import run_tshark |
9aac7312 | 18 | from utils import * |
a1512a0c | 19 | from wpasupplicant import WpaSupplicant |
62a766f3 | 20 | from test_ap_ht import set_world_reg |
5a92bda6 | 21 | |
9fd6804d | 22 | @remote_compatible |
5a92bda6 JM |
23 | def test_ap_open(dev, apdev): |
24 | """AP with open mode (no security) configuration""" | |
10a15590 JB |
25 | _test_ap_open(dev, apdev) |
26 | ||
27 | def _test_ap_open(dev, apdev): | |
8b8a1864 | 28 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
a42f88f8 JM |
29 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", |
30 | bg_scan_period="0") | |
5a92bda6 JM |
31 | ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) |
32 | if ev is None: | |
33 | raise Exception("No connection event received from hostapd") | |
ce9c8c40 JM |
34 | hwsim_utils.test_connectivity(dev[0], hapd) |
35 | ||
5a92bda6 JM |
36 | dev[0].request("DISCONNECT") |
37 | ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5) | |
38 | if ev is None: | |
39 | raise Exception("No disconnection event received from hostapd") | |
eebad214 JM |
40 | |
41 | def test_ap_open_packet_loss(dev, apdev): | |
42 | """AP with open mode configuration and large packet loss""" | |
43 | params = { "ssid": "open", | |
44 | "ignore_probe_probability": "0.5", | |
45 | "ignore_auth_probability": "0.5", | |
46 | "ignore_assoc_probability": "0.5", | |
47 | "ignore_reassoc_probability": "0.5" } | |
8b8a1864 | 48 | hapd = hostapd.add_ap(apdev[0], params) |
eebad214 JM |
49 | for i in range(0, 3): |
50 | dev[i].connect("open", key_mgmt="NONE", scan_freq="2412", | |
51 | wait_connect=False) | |
52 | for i in range(0, 3): | |
5f35a5e2 | 53 | dev[i].wait_connected(timeout=20) |
81699e2e | 54 | |
9fd6804d | 55 | @remote_compatible |
81699e2e JM |
56 | def test_ap_open_unknown_action(dev, apdev): |
57 | """AP with open mode configuration and unknown Action frame""" | |
8b8a1864 | 58 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
81699e2e JM |
59 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") |
60 | bssid = apdev[0]['bssid'] | |
61 | cmd = "MGMT_TX {} {} freq=2412 action=765432".format(bssid, bssid) | |
62 | if "FAIL" in dev[0].request(cmd): | |
63 | raise Exception("Could not send test Action frame") | |
64 | ev = dev[0].wait_event(["MGMT-TX-STATUS"], timeout=10) | |
65 | if ev is None: | |
66 | raise Exception("Timeout on MGMT-TX-STATUS") | |
67 | if "result=SUCCESS" not in ev: | |
68 | raise Exception("AP did not ack Action frame") | |
c8503088 | 69 | |
6838452d JM |
70 | def test_ap_open_invalid_wmm_action(dev, apdev): |
71 | """AP with open mode configuration and invalid WMM Action frame""" | |
8b8a1864 | 72 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
6838452d JM |
73 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") |
74 | bssid = apdev[0]['bssid'] | |
75 | cmd = "MGMT_TX {} {} freq=2412 action=1100".format(bssid, bssid) | |
76 | if "FAIL" in dev[0].request(cmd): | |
77 | raise Exception("Could not send test Action frame") | |
78 | ev = dev[0].wait_event(["MGMT-TX-STATUS"], timeout=10) | |
79 | if ev is None or "result=SUCCESS" not in ev: | |
80 | raise Exception("AP did not ack Action frame") | |
81 | ||
9fd6804d | 82 | @remote_compatible |
c8503088 JM |
83 | def test_ap_open_reconnect_on_inactivity_disconnect(dev, apdev): |
84 | """Reconnect to open mode AP after inactivity related disconnection""" | |
8b8a1864 | 85 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
c8503088 JM |
86 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") |
87 | hapd.request("DEAUTHENTICATE " + dev[0].p2p_interface_addr() + " reason=4") | |
5f35a5e2 JM |
88 | dev[0].wait_disconnected(timeout=5) |
89 | dev[0].wait_connected(timeout=2, error="Timeout on reconnection") | |
f0b7218f | 90 | |
9fd6804d | 91 | @remote_compatible |
f0b7218f JM |
92 | def test_ap_open_assoc_timeout(dev, apdev): |
93 | """AP timing out association""" | |
94 | ssid = "test" | |
8b8a1864 | 95 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
f0b7218f JM |
96 | dev[0].scan(freq="2412") |
97 | hapd.set("ext_mgmt_frame_handling", "1") | |
98 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
99 | wait_connect=False) | |
100 | for i in range(0, 10): | |
101 | req = hapd.mgmt_rx() | |
102 | if req is None: | |
103 | raise Exception("MGMT RX wait timed out") | |
104 | if req['subtype'] == 11: | |
105 | break | |
106 | req = None | |
107 | if not req: | |
108 | raise Exception("Authentication frame not received") | |
109 | ||
110 | resp = {} | |
111 | resp['fc'] = req['fc'] | |
112 | resp['da'] = req['sa'] | |
113 | resp['sa'] = req['da'] | |
114 | resp['bssid'] = req['bssid'] | |
115 | resp['payload'] = struct.pack('<HHH', 0, 2, 0) | |
116 | hapd.mgmt_tx(resp) | |
117 | ||
118 | assoc = 0 | |
119 | for i in range(0, 10): | |
120 | req = hapd.mgmt_rx() | |
121 | if req is None: | |
122 | raise Exception("MGMT RX wait timed out") | |
123 | if req['subtype'] == 0: | |
124 | assoc += 1 | |
125 | if assoc == 3: | |
126 | break | |
127 | if assoc != 3: | |
128 | raise Exception("Association Request frames not received: assoc=%d" % assoc) | |
129 | hapd.set("ext_mgmt_frame_handling", "0") | |
5f35a5e2 | 130 | dev[0].wait_connected(timeout=15) |
26cf800d | 131 | |
9fd6804d | 132 | @remote_compatible |
26cf800d JM |
133 | def test_ap_open_id_str(dev, apdev): |
134 | """AP with open mode and id_str""" | |
8b8a1864 | 135 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
26cf800d JM |
136 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", id_str="foo", |
137 | wait_connect=False) | |
5f35a5e2 | 138 | ev = dev[0].wait_connected(timeout=10) |
26cf800d JM |
139 | if "id_str=foo" not in ev: |
140 | raise Exception("CTRL-EVENT-CONNECT did not have matching id_str: " + ev) | |
141 | if dev[0].get_status_field("id_str") != "foo": | |
142 | raise Exception("id_str mismatch") | |
4bf1413e | 143 | |
9fd6804d | 144 | @remote_compatible |
4bf1413e JM |
145 | def test_ap_open_select_any(dev, apdev): |
146 | """AP with open mode and select any network""" | |
8b8a1864 | 147 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
4bf1413e JM |
148 | id = dev[0].connect("unknown", key_mgmt="NONE", scan_freq="2412", |
149 | only_add_network=True) | |
150 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
151 | only_add_network=True) | |
152 | dev[0].select_network(id) | |
a3704b2a JM |
153 | ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND", |
154 | "CTRL-EVENT-CONNECTED"], timeout=10) | |
155 | if ev is None: | |
156 | raise Exception("No result reported") | |
157 | if "CTRL-EVENT-CONNECTED" in ev: | |
4bf1413e JM |
158 | raise Exception("Unexpected connection") |
159 | ||
160 | dev[0].select_network("any") | |
5f35a5e2 | 161 | dev[0].wait_connected(timeout=10) |
9a921f9a | 162 | |
9fd6804d | 163 | @remote_compatible |
9a921f9a JM |
164 | def test_ap_open_unexpected_assoc_event(dev, apdev): |
165 | """AP with open mode and unexpected association event""" | |
8b8a1864 | 166 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
9a921f9a JM |
167 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") |
168 | dev[0].request("DISCONNECT") | |
5f35a5e2 | 169 | dev[0].wait_disconnected(timeout=15) |
9a921f9a JM |
170 | dev[0].dump_monitor() |
171 | # This will be accepted due to matching network | |
12129dda JA |
172 | dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412", |
173 | apdev[0]['bssid']]) | |
5f35a5e2 | 174 | dev[0].wait_connected(timeout=15) |
9a921f9a JM |
175 | dev[0].dump_monitor() |
176 | ||
177 | dev[0].request("REMOVE_NETWORK all") | |
5f35a5e2 | 178 | dev[0].wait_disconnected(timeout=5) |
9a921f9a JM |
179 | dev[0].dump_monitor() |
180 | # This will result in disconnection due to no matching network | |
12129dda JA |
181 | dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'connect', 'open', "2412", |
182 | apdev[0]['bssid']]) | |
5f35a5e2 | 183 | dev[0].wait_disconnected(timeout=15) |
4181c396 | 184 | |
d1ea8036 JM |
185 | def test_ap_open_external_assoc(dev, apdev): |
186 | """AP with open mode and external association""" | |
187 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open-ext-assoc" }) | |
188 | try: | |
189 | dev[0].request("STA_AUTOCONNECT 0") | |
190 | id = dev[0].connect("open-ext-assoc", key_mgmt="NONE", scan_freq="2412", | |
191 | only_add_network=True) | |
192 | dev[0].request("ENABLE_NETWORK %s no-connect" % id) | |
193 | dev[0].dump_monitor() | |
194 | # This will be accepted due to matching network | |
195 | dev[0].cmd_execute(['iw', 'dev', dev[0].ifname, 'connect', | |
196 | 'open-ext-assoc', "2412", apdev[0]['bssid']]) | |
197 | ev = dev[0].wait_event([ "CTRL-EVENT-DISCONNECTED", | |
198 | "CTRL-EVENT-CONNECTED" ], timeout=10) | |
199 | if ev is None: | |
200 | raise Exception("Connection timed out") | |
201 | if "CTRL-EVENT-DISCONNECTED" in ev: | |
202 | raise Exception("Unexpected disconnection event") | |
203 | dev[0].dump_monitor() | |
204 | dev[0].request("DISCONNECT") | |
205 | dev[0].wait_disconnected(timeout=5) | |
206 | finally: | |
207 | dev[0].request("STA_AUTOCONNECT 1") | |
208 | ||
9fd6804d | 209 | @remote_compatible |
4181c396 JM |
210 | def test_ap_bss_load(dev, apdev): |
211 | """AP with open mode (no security) configuration""" | |
8b8a1864 | 212 | hapd = hostapd.add_ap(apdev[0], |
4181c396 | 213 | { "ssid": "open", |
a1f06d0d JM |
214 | "bss_load_update_period": "10", |
215 | "chan_util_avg_period": "20" }) | |
4181c396 JM |
216 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") |
217 | # this does not really get much useful output with mac80211_hwsim currently, | |
218 | # but run through the channel survey update couple of times | |
219 | for i in range(0, 10): | |
220 | hwsim_utils.test_connectivity(dev[0], hapd) | |
221 | hwsim_utils.test_connectivity(dev[0], hapd) | |
222 | hwsim_utils.test_connectivity(dev[0], hapd) | |
223 | time.sleep(0.15) | |
a1f06d0d JM |
224 | avg = hapd.get_status_field("chan_util_avg") |
225 | if avg is None: | |
226 | raise Exception("No STATUS chan_util_avg seen") | |
fff95bb6 | 227 | |
95497a5f JM |
228 | def test_ap_bss_load_fail(dev, apdev): |
229 | """BSS Load update failing to get survey data""" | |
230 | hapd = hostapd.add_ap(apdev[0], | |
231 | { "ssid": "open", | |
232 | "bss_load_update_period": "1" }) | |
233 | with fail_test(hapd, 1, "wpa_driver_nl80211_get_survey"): | |
234 | wait_fail_trigger(hapd, "GET_FAIL") | |
235 | ||
fff95bb6 JM |
236 | def hapd_out_of_mem(hapd, apdev, count, func): |
237 | with alloc_fail(hapd, count, func): | |
238 | started = False | |
239 | try: | |
afc26df2 | 240 | hostapd.add_ap(apdev, { "ssid": "open" }) |
fff95bb6 JM |
241 | started = True |
242 | except: | |
243 | pass | |
244 | if started: | |
6f225261 | 245 | raise Exception("hostapd interface started even with memory allocation failure: %d:%s" % (count, func)) |
fff95bb6 JM |
246 | |
247 | def test_ap_open_out_of_memory(dev, apdev): | |
248 | """hostapd failing to setup interface due to allocation failure""" | |
8b8a1864 | 249 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
fff95bb6 JM |
250 | hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_alloc_bss_data") |
251 | ||
252 | for i in range(1, 3): | |
253 | hapd_out_of_mem(hapd, apdev[1], i, "hostapd_iface_alloc") | |
254 | ||
255 | for i in range(1, 5): | |
256 | hapd_out_of_mem(hapd, apdev[1], i, "hostapd_config_defaults;hostapd_config_alloc") | |
257 | ||
258 | hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_config_alloc") | |
259 | ||
260 | hapd_out_of_mem(hapd, apdev[1], 1, "hostapd_driver_init") | |
261 | ||
9f052d80 | 262 | for i in range(1, 3): |
fff95bb6 JM |
263 | hapd_out_of_mem(hapd, apdev[1], i, "=wpa_driver_nl80211_drv_init") |
264 | ||
265 | # eloop_register_read_sock() call from i802_init() | |
9b35afd6 | 266 | hapd_out_of_mem(hapd, apdev[1], 1, "eloop_sock_table_add_sock;?eloop_register_sock;?eloop_register_read_sock;=i802_init") |
fff95bb6 JM |
267 | |
268 | # verify that a new interface can still be added when memory allocation does | |
269 | # not fail | |
8b8a1864 | 270 | hostapd.add_ap(apdev[1], { "ssid": "open" }) |
c2096d99 JM |
271 | |
272 | def test_bssid_black_white_list(dev, apdev): | |
273 | """BSSID black/white list""" | |
8b8a1864 JD |
274 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
275 | hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" }) | |
c2096d99 JM |
276 | |
277 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
278 | bssid_whitelist=apdev[1]['bssid']) | |
279 | dev[1].connect("open", key_mgmt="NONE", scan_freq="2412", | |
280 | bssid_blacklist=apdev[1]['bssid']) | |
281 | dev[2].connect("open", key_mgmt="NONE", scan_freq="2412", | |
282 | bssid_whitelist="00:00:00:00:00:00/00:00:00:00:00:00", | |
283 | bssid_blacklist=apdev[1]['bssid']) | |
284 | if dev[0].get_status_field('bssid') != apdev[1]['bssid']: | |
285 | raise Exception("dev[0] connected to unexpected AP") | |
286 | if dev[1].get_status_field('bssid') != apdev[0]['bssid']: | |
287 | raise Exception("dev[1] connected to unexpected AP") | |
288 | if dev[2].get_status_field('bssid') != apdev[0]['bssid']: | |
289 | raise Exception("dev[2] connected to unexpected AP") | |
290 | dev[0].request("REMOVE_NETWORK all") | |
291 | dev[1].request("REMOVE_NETWORK all") | |
292 | dev[2].request("REMOVE_NETWORK all") | |
293 | ||
294 | dev[2].connect("open", key_mgmt="NONE", scan_freq="2412", | |
295 | bssid_whitelist="00:00:00:00:00:00", wait_connect=False) | |
296 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
297 | bssid_whitelist="11:22:33:44:55:66/ff:00:00:00:00:00 " + apdev[1]['bssid'] + " aa:bb:cc:dd:ee:ff") | |
298 | dev[1].connect("open", key_mgmt="NONE", scan_freq="2412", | |
299 | bssid_blacklist="11:22:33:44:55:66/ff:00:00:00:00:00 " + apdev[1]['bssid'] + " aa:bb:cc:dd:ee:ff") | |
300 | if dev[0].get_status_field('bssid') != apdev[1]['bssid']: | |
301 | raise Exception("dev[0] connected to unexpected AP") | |
302 | if dev[1].get_status_field('bssid') != apdev[0]['bssid']: | |
303 | raise Exception("dev[1] connected to unexpected AP") | |
304 | dev[0].request("REMOVE_NETWORK all") | |
305 | dev[1].request("REMOVE_NETWORK all") | |
306 | ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) | |
307 | if ev is not None: | |
308 | raise Exception("Unexpected dev[2] connectin") | |
309 | dev[2].request("REMOVE_NETWORK all") | |
a1512a0c JM |
310 | |
311 | def test_ap_open_wpas_in_bridge(dev, apdev): | |
312 | """Open mode AP and wpas interface in a bridge""" | |
313 | br_ifname='sta-br0' | |
314 | ifname='wlan5' | |
315 | try: | |
316 | _test_ap_open_wpas_in_bridge(dev, apdev) | |
317 | finally: | |
318 | subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'down']) | |
319 | subprocess.call(['brctl', 'delif', br_ifname, ifname]) | |
320 | subprocess.call(['brctl', 'delbr', br_ifname]) | |
f245b450 | 321 | subprocess.call(['iw', ifname, 'set', '4addr', 'off']) |
a1512a0c JM |
322 | |
323 | def _test_ap_open_wpas_in_bridge(dev, apdev): | |
8b8a1864 | 324 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
a1512a0c JM |
325 | |
326 | br_ifname='sta-br0' | |
327 | ifname='wlan5' | |
328 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
329 | # First, try a failure case of adding an interface | |
330 | try: | |
331 | wpas.interface_add(ifname, br_ifname=br_ifname) | |
332 | raise Exception("Interface addition succeeded unexpectedly") | |
bab493b9 | 333 | except Exception as e: |
a1512a0c JM |
334 | if "Failed to add" in str(e): |
335 | logger.info("Ignore expected interface_add failure due to missing bridge interface: " + str(e)) | |
336 | else: | |
337 | raise | |
338 | ||
339 | # Next, add the bridge interface and add the interface again | |
340 | subprocess.call(['brctl', 'addbr', br_ifname]) | |
341 | subprocess.call(['brctl', 'setfd', br_ifname, '0']) | |
342 | subprocess.call(['ip', 'link', 'set', 'dev', br_ifname, 'up']) | |
343 | subprocess.call(['iw', ifname, 'set', '4addr', 'on']) | |
344 | subprocess.check_call(['brctl', 'addif', br_ifname, ifname]) | |
345 | wpas.interface_add(ifname, br_ifname=br_ifname) | |
346 | ||
347 | wpas.connect("open", key_mgmt="NONE", scan_freq="2412") | |
c5b535ed | 348 | |
9fd6804d | 349 | @remote_compatible |
c5b535ed JM |
350 | def test_ap_open_start_disabled(dev, apdev): |
351 | """AP with open mode and beaconing disabled""" | |
8b8a1864 JD |
352 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open", |
353 | "start_disabled": "1" }) | |
c5b535ed JM |
354 | bssid = apdev[0]['bssid'] |
355 | ||
356 | dev[0].flush_scan_cache() | |
357 | dev[0].scan(freq=2412, only_new=True) | |
358 | if dev[0].get_bss(bssid) is not None: | |
359 | raise Exception("AP was seen beaconing") | |
360 | if "OK" not in hapd.request("RELOAD"): | |
361 | raise Exception("RELOAD failed") | |
362 | dev[0].scan_for_bss(bssid, freq=2412) | |
363 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
364 | ||
9fd6804d | 365 | @remote_compatible |
c5b535ed JM |
366 | def test_ap_open_start_disabled2(dev, apdev): |
367 | """AP with open mode and beaconing disabled (2)""" | |
8b8a1864 JD |
368 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open", |
369 | "start_disabled": "1" }) | |
c5b535ed JM |
370 | bssid = apdev[0]['bssid'] |
371 | ||
372 | dev[0].flush_scan_cache() | |
373 | dev[0].scan(freq=2412, only_new=True) | |
374 | if dev[0].get_bss(bssid) is not None: | |
375 | raise Exception("AP was seen beaconing") | |
376 | if "OK" not in hapd.request("UPDATE_BEACON"): | |
377 | raise Exception("UPDATE_BEACON failed") | |
378 | dev[0].scan_for_bss(bssid, freq=2412) | |
379 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
380 | if "OK" not in hapd.request("UPDATE_BEACON"): | |
381 | raise Exception("UPDATE_BEACON failed") | |
382 | dev[0].request("DISCONNECT") | |
383 | dev[0].wait_disconnected() | |
384 | dev[0].request("RECONNECT") | |
385 | dev[0].wait_connected() | |
eb88a5ba | 386 | |
9fd6804d | 387 | @remote_compatible |
eb88a5ba JM |
388 | def test_ap_open_ifdown(dev, apdev): |
389 | """AP with open mode and external ifconfig down""" | |
390 | params = { "ssid": "open", | |
391 | "ap_max_inactivity": "1" } | |
8b8a1864 | 392 | hapd = hostapd.add_ap(apdev[0], params) |
eb88a5ba JM |
393 | bssid = apdev[0]['bssid'] |
394 | ||
395 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
396 | dev[1].connect("open", key_mgmt="NONE", scan_freq="2412") | |
10e09d83 | 397 | hapd.cmd_execute(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'down']) |
eb88a5ba JM |
398 | ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=10) |
399 | if ev is None: | |
400 | raise Exception("Timeout on AP-STA-DISCONNECTED (1)") | |
401 | ev = hapd.wait_event(["AP-STA-DISCONNECTED"], timeout=5) | |
402 | if ev is None: | |
403 | raise Exception("Timeout on AP-STA-DISCONNECTED (2)") | |
404 | ev = hapd.wait_event(["INTERFACE-DISABLED"], timeout=5) | |
405 | if ev is None: | |
406 | raise Exception("No INTERFACE-DISABLED event") | |
407 | # The following wait tests beacon loss detection in mac80211 on dev0. | |
408 | # dev1 is used to test stopping of AP side functionality on client polling. | |
409 | dev[1].request("REMOVE_NETWORK all") | |
10e09d83 | 410 | hapd.cmd_execute(['ip', 'link', 'set', 'dev', apdev[0]['ifname'], 'up']) |
eb88a5ba JM |
411 | dev[0].wait_disconnected() |
412 | dev[1].wait_disconnected() | |
413 | ev = hapd.wait_event(["INTERFACE-ENABLED"], timeout=10) | |
414 | if ev is None: | |
415 | raise Exception("No INTERFACE-ENABLED event") | |
416 | dev[0].wait_connected() | |
417 | hwsim_utils.test_connectivity(dev[0], hapd) | |
d0007ac9 JB |
418 | |
419 | def test_ap_open_disconnect_in_ps(dev, apdev, params): | |
420 | """Disconnect with the client in PS to regression-test a kernel bug""" | |
8b8a1864 | 421 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
d0007ac9 JB |
422 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", |
423 | bg_scan_period="0") | |
424 | ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) | |
425 | if ev is None: | |
426 | raise Exception("No connection event received from hostapd") | |
427 | ||
428 | time.sleep(0.2) | |
946ed13c AA |
429 | # enable power save mode |
430 | hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_ENABLED) | |
431 | time.sleep(0.1) | |
d0007ac9 JB |
432 | try: |
433 | # inject some traffic | |
434 | sa = hapd.own_addr() | |
435 | da = dev[0].own_addr() | |
436 | hapd.request('DATA_TEST_CONFIG 1') | |
437 | hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa)) | |
438 | hapd.request('DATA_TEST_CONFIG 0') | |
439 | ||
440 | # let the AP send couple of Beacon frames | |
441 | time.sleep(0.3) | |
442 | ||
443 | # disconnect - with traffic pending - shouldn't cause kernel warnings | |
444 | dev[0].request("DISCONNECT") | |
445 | finally: | |
446 | hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_DISABLED) | |
447 | ||
448 | time.sleep(0.2) | |
449 | out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), | |
450 | "wlan_mgt.tim.partial_virtual_bitmap", | |
451 | ["wlan_mgt.tim.partial_virtual_bitmap"]) | |
452 | if out is not None: | |
453 | state = 0 | |
454 | for l in out.splitlines(): | |
455 | pvb = int(l, 16) | |
456 | if pvb > 0 and state == 0: | |
457 | state = 1 | |
458 | elif pvb == 0 and state == 1: | |
459 | state = 2 | |
460 | if state != 2: | |
461 | raise Exception("Didn't observe TIM bit getting set and unset (state=%d)" % state) | |
7041c16d | 462 | |
9fd6804d | 463 | @remote_compatible |
7041c16d JM |
464 | def test_ap_open_select_network(dev, apdev): |
465 | """Open mode connection and SELECT_NETWORK to change network""" | |
8b8a1864 | 466 | hapd1 = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
7041c16d | 467 | bssid1 = apdev[0]['bssid'] |
8b8a1864 | 468 | hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open2" }) |
7041c16d JM |
469 | bssid2 = apdev[1]['bssid'] |
470 | ||
471 | id1 = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
472 | only_add_network=True) | |
473 | id2 = dev[0].connect("open2", key_mgmt="NONE", scan_freq="2412") | |
474 | hwsim_utils.test_connectivity(dev[0], hapd2) | |
475 | ||
476 | dev[0].select_network(id1) | |
477 | dev[0].wait_connected() | |
478 | res = dev[0].request("BLACKLIST") | |
479 | if bssid1 in res or bssid2 in res: | |
480 | raise Exception("Unexpected blacklist entry") | |
481 | hwsim_utils.test_connectivity(dev[0], hapd1) | |
482 | ||
483 | dev[0].select_network(id2) | |
484 | dev[0].wait_connected() | |
485 | hwsim_utils.test_connectivity(dev[0], hapd2) | |
486 | res = dev[0].request("BLACKLIST") | |
487 | if bssid1 in res or bssid2 in res: | |
488 | raise Exception("Unexpected blacklist entry(2)") | |
a14a5f24 | 489 | |
9fd6804d | 490 | @remote_compatible |
a14a5f24 JM |
491 | def test_ap_open_disable_enable(dev, apdev): |
492 | """AP with open mode getting disabled and re-enabled""" | |
8b8a1864 | 493 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
a14a5f24 JM |
494 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", |
495 | bg_scan_period="0") | |
496 | ||
497 | for i in range(2): | |
498 | hapd.request("DISABLE") | |
499 | dev[0].wait_disconnected() | |
500 | hapd.request("ENABLE") | |
501 | dev[0].wait_connected() | |
502 | hwsim_utils.test_connectivity(dev[0], hapd) | |
f59b946e JM |
503 | |
504 | def sta_enable_disable(dev, bssid): | |
505 | dev.scan_for_bss(bssid, freq=2412) | |
506 | work_id = dev.request("RADIO_WORK add block-work") | |
507 | ev = dev.wait_event(["EXT-RADIO-WORK-START"]) | |
508 | if ev is None: | |
509 | raise Exception("Timeout while waiting radio work to start") | |
510 | id = dev.connect("open", key_mgmt="NONE", scan_freq="2412", | |
511 | only_add_network=True) | |
512 | dev.request("ENABLE_NETWORK %d" % id) | |
513 | if "connect@" not in dev.request("RADIO_WORK show"): | |
514 | raise Exception("connect radio work missing") | |
515 | dev.request("DISABLE_NETWORK %d" % id) | |
516 | dev.request("RADIO_WORK done " + work_id) | |
517 | ||
518 | ok = False | |
519 | for i in range(30): | |
520 | if "connect@" not in dev.request("RADIO_WORK show"): | |
521 | ok = True | |
522 | break | |
523 | time.sleep(0.1) | |
524 | if not ok: | |
525 | raise Exception("connect radio work not completed") | |
526 | ev = dev.wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) | |
527 | if ev is not None: | |
528 | raise Exception("Unexpected connection") | |
529 | dev.request("DISCONNECT") | |
530 | ||
531 | def test_ap_open_sta_enable_disable(dev, apdev): | |
532 | """AP with open mode and wpa_supplicant ENABLE/DISABLE_NETWORK""" | |
8b8a1864 | 533 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
f59b946e JM |
534 | bssid = apdev[0]['bssid'] |
535 | ||
536 | sta_enable_disable(dev[0], bssid) | |
537 | ||
538 | wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5') | |
539 | wpas.interface_add("wlan5", drv_params="force_connect_cmd=1") | |
540 | sta_enable_disable(wpas, bssid) | |
6fb8b4bf | 541 | |
9fd6804d | 542 | @remote_compatible |
6fb8b4bf JM |
543 | def test_ap_open_select_twice(dev, apdev): |
544 | """AP with open mode and select network twice""" | |
545 | id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
546 | only_add_network=True) | |
547 | dev[0].select_network(id) | |
e1246a6e | 548 | ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10) |
6fb8b4bf JM |
549 | if ev is None: |
550 | raise Exception("No result reported") | |
8b8a1864 | 551 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) |
6fb8b4bf JM |
552 | # Verify that the second SELECT_NETWORK starts a new scan immediately by |
553 | # waiting less than the default scan period. | |
554 | dev[0].select_network(id) | |
555 | dev[0].wait_connected(timeout=3) | |
bcf4e38c | 556 | |
9fd6804d | 557 | @remote_compatible |
bcf4e38c JM |
558 | def test_ap_open_reassoc_not_found(dev, apdev): |
559 | """AP with open mode and REASSOCIATE not finding a match""" | |
560 | id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
561 | only_add_network=True) | |
562 | dev[0].select_network(id) | |
563 | ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10) | |
564 | if ev is None: | |
565 | raise Exception("No result reported") | |
566 | dev[0].request("DISCONNECT") | |
567 | ||
568 | time.sleep(0.1) | |
569 | dev[0].dump_monitor() | |
570 | ||
571 | dev[0].request("REASSOCIATE") | |
572 | ev = dev[0].wait_event(["CTRL-EVENT-NETWORK-NOT-FOUND"], timeout=10) | |
573 | if ev is None: | |
574 | raise Exception("No result reported") | |
575 | dev[0].request("DISCONNECT") | |
6545398a | 576 | |
9fd6804d | 577 | @remote_compatible |
6545398a JM |
578 | def test_ap_open_sta_statistics(dev, apdev): |
579 | """AP with open mode and STA statistics""" | |
580 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
581 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
582 | addr = dev[0].own_addr() | |
583 | ||
584 | stats1 = hapd.get_sta(addr) | |
585 | logger.info("stats1: " + str(stats1)) | |
586 | time.sleep(0.4) | |
587 | stats2 = hapd.get_sta(addr) | |
588 | logger.info("stats2: " + str(stats2)) | |
589 | hwsim_utils.test_connectivity(dev[0], hapd) | |
590 | stats3 = hapd.get_sta(addr) | |
591 | logger.info("stats3: " + str(stats3)) | |
592 | ||
593 | # Cannot require specific inactive_msec changes without getting rid of all | |
594 | # unrelated traffic, so for now, just print out the results in the log for | |
595 | # manual checks. | |
cb285151 | 596 | |
9fd6804d | 597 | @remote_compatible |
cb285151 JM |
598 | def test_ap_open_poll_sta(dev, apdev): |
599 | """AP with open mode and STA poll""" | |
600 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
601 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
602 | addr = dev[0].own_addr() | |
603 | ||
604 | if "OK" not in hapd.request("POLL_STA " + addr): | |
605 | raise Exception("POLL_STA failed") | |
606 | ev = hapd.wait_event(["AP-STA-POLL-OK"], timeout=5) | |
607 | if ev is None: | |
608 | raise Exception("Poll response not seen") | |
609 | if addr not in ev: | |
610 | raise Exception("Unexpected poll response: " + ev) | |
9524e7e5 JM |
611 | |
612 | def test_ap_open_pmf_default(dev, apdev): | |
613 | """AP with open mode (no security) configuration and pmf=2""" | |
614 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
615 | dev[1].connect("open", key_mgmt="NONE", scan_freq="2412", | |
616 | ieee80211w="2", wait_connect=False) | |
617 | dev[2].connect("open", key_mgmt="NONE", scan_freq="2412", | |
618 | ieee80211w="1") | |
619 | try: | |
620 | dev[0].request("SET pmf 2") | |
621 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
622 | ||
623 | dev[0].request("DISCONNECT") | |
624 | dev[0].wait_disconnected() | |
625 | finally: | |
626 | dev[0].request("SET pmf 0") | |
627 | dev[2].request("DISCONNECT") | |
628 | dev[2].wait_disconnected() | |
629 | ||
630 | ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=0.1) | |
631 | if ev is not None: | |
632 | raise Exception("Unexpected dev[1] connection") | |
633 | dev[1].request("DISCONNECT") | |
674af173 JM |
634 | |
635 | def test_ap_open_drv_fail(dev, apdev): | |
636 | """AP with open mode and driver operations failing""" | |
637 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
638 | ||
639 | with fail_test(dev[0], 1, "wpa_driver_nl80211_authenticate"): | |
640 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
641 | wait_connect=False) | |
642 | wait_fail_trigger(dev[0], "GET_FAIL") | |
643 | dev[0].request("REMOVE_NETWORK all") | |
644 | ||
645 | with fail_test(dev[0], 1, "wpa_driver_nl80211_associate"): | |
646 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", | |
647 | wait_connect=False) | |
648 | wait_fail_trigger(dev[0], "GET_FAIL") | |
649 | dev[0].request("REMOVE_NETWORK all") | |
80fe420a MB |
650 | |
651 | def run_multicast_to_unicast(dev, apdev, convert): | |
652 | params = { "ssid": "open" } | |
653 | params["multicast_to_unicast"] = "1" if convert else "0" | |
654 | hapd = hostapd.add_ap(apdev[0], params) | |
655 | dev[0].scan_for_bss(hapd.own_addr(), freq=2412) | |
656 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
657 | ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) | |
658 | if ev is None: | |
659 | raise Exception("No connection event received from hostapd") | |
660 | hwsim_utils.test_connectivity(dev[0], hapd, multicast_to_unicast=convert) | |
661 | dev[0].request("DISCONNECT") | |
662 | ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5) | |
663 | if ev is None: | |
664 | raise Exception("No disconnection event received from hostapd") | |
665 | ||
666 | def test_ap_open_multicast_to_unicast(dev, apdev): | |
667 | """Multicast-to-unicast conversion enabled""" | |
668 | run_multicast_to_unicast(dev, apdev, True) | |
669 | ||
670 | def test_ap_open_multicast_to_unicast_disabled(dev, apdev): | |
671 | """Multicast-to-unicast conversion disabled""" | |
672 | run_multicast_to_unicast(dev, apdev, False) | |
f38de833 JM |
673 | |
674 | def test_ap_open_drop_duplicate(dev, apdev, params): | |
675 | """AP dropping duplicate management frames""" | |
676 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open", | |
677 | "interworking": "1" }) | |
678 | hapd.set("ext_mgmt_frame_handling", "1") | |
679 | bssid = hapd.own_addr().replace(':', '') | |
680 | addr = "020304050607" | |
681 | auth = "b0003a01" + bssid + addr + bssid + '1000000001000000' | |
682 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % auth): | |
683 | raise Exception("MGMT_RX_PROCESS failed") | |
684 | auth = "b0083a01" + bssid + addr + bssid + '1000000001000000' | |
685 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % auth): | |
686 | raise Exception("MGMT_RX_PROCESS failed") | |
687 | ||
688 | ies = "00046f70656e010802040b160c12182432043048606c2d1a3c101bffff0000000000000000000001000000000000000000007f0a04000a020140004000013b155151525354737475767778797a7b7c7d7e7f808182dd070050f202000100" | |
689 | assoc_req = "00003a01" + bssid + addr + bssid + "2000" + "21040500" + ies | |
690 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % assoc_req): | |
691 | raise Exception("MGMT_RX_PROCESS failed") | |
692 | assoc_req = "00083a01" + bssid + addr + bssid + "2000" + "21040500" + ies | |
693 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % assoc_req): | |
694 | raise Exception("MGMT_RX_PROCESS failed") | |
695 | reassoc_req = "20083a01" + bssid + addr + bssid + "2000" + "21040500" + ies | |
696 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % reassoc_req): | |
697 | raise Exception("MGMT_RX_PROCESS failed") | |
698 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % reassoc_req): | |
699 | raise Exception("MGMT_RX_PROCESS failed") | |
700 | ||
701 | action = "d0003a01" + bssid + addr + bssid + "1000" + "040a006c0200000600000102000101" | |
702 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % action): | |
703 | raise Exception("MGMT_RX_PROCESS failed") | |
704 | ||
705 | action = "d0083a01" + bssid + addr + bssid + "1000" + "040a006c0200000600000102000101" | |
706 | if "OK" not in hapd.request("MGMT_RX_PROCESS freq=2412 datarate=0 ssi_signal=-30 frame=%s" % action): | |
707 | raise Exception("MGMT_RX_PROCESS failed") | |
708 | ||
709 | out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), | |
710 | "wlan.fc.type == 0", ["wlan.fc.subtype"]) | |
711 | num_auth = 0 | |
712 | num_assoc = 0 | |
713 | num_reassoc = 0 | |
714 | num_action = 0 | |
715 | for subtype in out.splitlines(): | |
716 | val = int(subtype) | |
717 | if val == 11: | |
718 | num_auth += 1 | |
719 | elif val == 1: | |
720 | num_assoc += 1 | |
721 | elif val == 3: | |
722 | num_reassoc += 1 | |
723 | elif val == 13: | |
724 | num_action += 1 | |
725 | if num_auth != 1: | |
726 | raise Exception("Unexpected number of Authentication frames: %d" % num_auth) | |
727 | if num_assoc != 1: | |
728 | raise Exception("Unexpected number of association frames: %d" % num_assoc) | |
729 | if num_reassoc != 1: | |
730 | raise Exception("Unexpected number of reassociation frames: %d" % num_reassoc) | |
731 | if num_action != 1: | |
732 | raise Exception("Unexpected number of Action frames: %d" % num_action) | |
47e14859 JM |
733 | |
734 | def test_ap_open_select_network_freq(dev, apdev): | |
735 | """AP with open mode and use for SELECT_NETWORK freq parameter""" | |
736 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
737 | id = dev[0].connect("open", key_mgmt="NONE", only_add_network=True) | |
738 | dev[0].select_network(id, freq=2412) | |
739 | start = os.times()[4] | |
740 | ev = dev[0].wait_event(["CTRL-EVENT-SCAN-STARTED"], timeout=5) | |
741 | if ev is None: | |
742 | raise Exception("Scan not started") | |
743 | ev = dev[0].wait_event(["CTRL-EVENT-SCAN-RESULTS"], timeout=15) | |
744 | if ev is None: | |
745 | raise Exception("Scan not completed") | |
746 | end = os.times()[4] | |
747 | logger.info("Scan duration: {} seconds".format(end - start)) | |
748 | if end - start > 3: | |
749 | raise Exception("Scan took unexpectedly long time") | |
750 | dev[0].wait_connected() | |
62a766f3 JM |
751 | |
752 | def test_ap_open_noncountry(dev, apdev): | |
753 | """AP with open mode and noncountry entity as Country String""" | |
754 | _test_ap_open_country(dev, apdev, "XX", "0x58") | |
755 | ||
756 | def test_ap_open_country_table_e4(dev, apdev): | |
757 | """AP with open mode and Table E-4 Country String""" | |
758 | _test_ap_open_country(dev, apdev, "DE", "0x04") | |
759 | ||
760 | def test_ap_open_country_indoor(dev, apdev): | |
761 | """AP with open mode and indoor country code""" | |
762 | _test_ap_open_country(dev, apdev, "DE", "0x49") | |
763 | ||
764 | def test_ap_open_country_outdoor(dev, apdev): | |
765 | """AP with open mode and outdoor country code""" | |
766 | _test_ap_open_country(dev, apdev, "DE", "0x4f") | |
767 | ||
768 | def _test_ap_open_country(dev, apdev, country_code, country3): | |
769 | try: | |
b586054f JM |
770 | hapd = None |
771 | hapd = run_ap_open_country(dev, apdev, country_code, country3) | |
62a766f3 | 772 | finally: |
9aac7312 | 773 | clear_regdom(hapd, dev) |
62a766f3 JM |
774 | |
775 | def run_ap_open_country(dev, apdev, country_code, country3): | |
776 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open", | |
777 | "country_code": country_code, | |
778 | "country3": country3, | |
779 | "ieee80211d": "1" }) | |
780 | dev[0].scan_for_bss(hapd.own_addr(), freq=2412) | |
781 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
b586054f JM |
782 | dev[0].wait_regdom(country_ie=True) |
783 | return hapd | |
6abde545 JM |
784 | |
785 | def test_ap_open_disable_select(dev, apdev): | |
786 | """DISABLE_NETWORK for connected AP followed by SELECT_NETWORK""" | |
787 | hapd1 = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
788 | hapd2 = hostapd.add_ap(apdev[1], { "ssid": "open" }) | |
789 | id = dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
790 | ||
791 | dev[0].request("DISABLE_NETWORK %d" % id) | |
792 | dev[0].wait_disconnected() | |
793 | res = dev[0].request("BLACKLIST") | |
794 | if hapd1.own_addr() in res or hapd2.own_addr() in res: | |
795 | raise Exception("Unexpected blacklist entry added") | |
796 | dev[0].request("SELECT_NETWORK %d" % id) | |
797 | dev[0].wait_connected() | |
7b111c04 JM |
798 | |
799 | def test_ap_open_reassoc_same(dev, apdev): | |
800 | """AP with open mode and STA reassociating back to same AP without auth exchange""" | |
801 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
802 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
803 | try: | |
804 | dev[0].request("SET reassoc_same_bss_optim 1") | |
805 | dev[0].request("REATTACH") | |
806 | dev[0].wait_connected() | |
807 | hwsim_utils.test_connectivity(dev[0], hapd) | |
808 | finally: | |
809 | dev[0].request("SET reassoc_same_bss_optim 0") | |
7afbbcd2 JB |
810 | |
811 | def test_ap_open_no_reflection(dev, apdev): | |
812 | """AP with open mode, STA sending packets to itself""" | |
813 | hapd = hostapd.add_ap(apdev[0], { "ssid": "open" }) | |
814 | dev[0].connect("open", key_mgmt="NONE", scan_freq="2412") | |
815 | ||
816 | ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) | |
817 | if ev is None: | |
818 | raise Exception("No connection event received from hostapd") | |
819 | # test normal connectivity is OK | |
820 | hwsim_utils.test_connectivity(dev[0], hapd) | |
821 | ||
822 | # test that we can't talk to ourselves | |
823 | addr = dev[0].own_addr() | |
824 | res = dev[0].request('DATA_TEST_CONFIG 1') | |
825 | try: | |
826 | assert 'OK' in res | |
827 | ||
828 | cmd = "DATA_TEST_TX {} {} {}".format(addr, addr, 0) | |
829 | dev[0].request(cmd) | |
830 | ||
831 | ev = dev[0].wait_event(["DATA-TEST-RX"], timeout=1) | |
832 | ||
833 | if ev is not None and "DATA-TEST-RX {} {}".format(addr, addr) in ev: | |
834 | raise Exception("STA can unexpectedly talk to itself") | |
835 | finally: | |
836 | dev[0].request('DATA_TEST_CONFIG 0') |