]>
Commit | Line | Data |
---|---|---|
68157c06 JL |
1 | #!/usr/bin/python |
2 | # | |
3 | # wpa_supplicant mesh mode tests | |
4 | # Copyright (c) 2014, cozybit Inc. | |
5 | # | |
6 | # This software may be distributed under the terms of the BSD license. | |
7 | # See README for more details. | |
8 | ||
7e3614df JM |
9 | import logging |
10 | logger = logging.getLogger() | |
11 | ||
12 | import hwsim_utils | |
13 | from wpasupplicant import WpaSupplicant | |
68157c06 | 14 | |
31705bf4 JM |
15 | def mesh_supported(dev): |
16 | flags = int(dev.get_driver_status_field('capa.flags'), 16) | |
17 | if flags & 0x100000000: | |
18 | return True | |
19 | return False | |
20 | ||
8b260032 | 21 | def check_mesh_scan(dev, params, other_started=False, beacon_int=0): |
68157c06 JL |
22 | if not other_started: |
23 | dev.dump_monitor() | |
24 | id = dev.request("SCAN " + params) | |
25 | if "FAIL" in id: | |
26 | raise Exception("Failed to start scan") | |
27 | id = int(id) | |
28 | ||
29 | if other_started: | |
30 | ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"]) | |
31 | if ev is None: | |
32 | raise Exception("Other scan did not start") | |
33 | if "id=" + str(id) in ev: | |
34 | raise Exception("Own scan id unexpectedly included in start event") | |
35 | ||
36 | ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"]) | |
37 | if ev is None: | |
38 | raise Exception("Other scan did not complete") | |
39 | if "id=" + str(id) in ev: | |
40 | raise Exception( | |
41 | "Own scan id unexpectedly included in completed event") | |
42 | ||
43 | ev = dev.wait_event(["CTRL-EVENT-SCAN-STARTED"]) | |
44 | if ev is None: | |
45 | raise Exception("Scan did not start") | |
46 | if "id=" + str(id) not in ev: | |
47 | raise Exception("Scan id not included in start event") | |
48 | ||
49 | ev = dev.wait_event(["CTRL-EVENT-SCAN-RESULTS"]) | |
50 | if ev is None: | |
51 | raise Exception("Scan did not complete") | |
52 | if "id=" + str(id) not in ev: | |
53 | raise Exception("Scan id not included in completed event") | |
54 | ||
55 | res = dev.request("SCAN_RESULTS") | |
56 | ||
f54b926b | 57 | if res.find("[MESH]") < 0: |
68157c06 JL |
58 | raise Exception("Scan did not contain a MESH network") |
59 | ||
fba65f72 JM |
60 | bssid = res.splitlines()[1].split(' ')[0] |
61 | bss = dev.get_bss(bssid) | |
62 | if bss is None: | |
63 | raise Exception("Could not get BSS entry for mesh") | |
64 | if 'mesh_capability' not in bss: | |
65 | raise Exception("mesh_capability missing from BSS entry") | |
8b260032 JM |
66 | if beacon_int: |
67 | if 'beacon_int' not in bss: | |
68 | raise Exception("beacon_int missing from BSS entry") | |
69 | if str(beacon_int) != bss['beacon_int']: | |
70 | raise Exception("Unexpected beacon_int in BSS entry: " + bss['beacon_int']) | |
68157c06 JL |
71 | |
72 | def check_mesh_group_added(dev): | |
73 | ev = dev.wait_event(["MESH-GROUP-STARTED"]) | |
74 | if ev is None: | |
75 | raise Exception("Test exception: Couldn't join mesh") | |
76 | ||
77 | ||
78 | def check_mesh_group_removed(dev): | |
79 | ev = dev.wait_event(["MESH-GROUP-REMOVED"]) | |
80 | if ev is None: | |
81 | raise Exception("Test exception: Couldn't leave mesh") | |
82 | ||
83 | ||
e0cfd223 JM |
84 | def check_mesh_peer_connected(dev, timeout=10): |
85 | ev = dev.wait_event(["MESH-PEER-CONNECTED"], timeout=timeout) | |
68157c06 JL |
86 | if ev is None: |
87 | raise Exception("Test exception: Remote peer did not connect.") | |
88 | ||
89 | ||
90 | def check_mesh_peer_disconnected(dev): | |
91 | ev = dev.wait_event(["MESH-PEER-DISCONNECTED"]) | |
92 | if ev is None: | |
93 | raise Exception("Test exception: Peer disconnect event not detected.") | |
94 | ||
95 | ||
96 | def test_wpas_add_set_remove_support(dev): | |
97 | """wpa_supplicant MESH add/set/remove network support""" | |
98 | id = dev[0].add_network() | |
99 | dev[0].set_network(id, "mode", "5") | |
100 | dev[0].remove_network(id) | |
101 | ||
8b260032 JM |
102 | def add_open_mesh_network(dev, ht_mode=False, freq="2412", start=True, |
103 | beacon_int=0): | |
7e3614df JM |
104 | id = dev.add_network() |
105 | dev.set_network(id, "mode", "5") | |
106 | dev.set_network_quoted(id, "ssid", "wpas-mesh-open") | |
107 | dev.set_network(id, "key_mgmt", "NONE") | |
f1381f99 | 108 | dev.set_network(id, "frequency", freq) |
d48b64ba JM |
109 | if ht_mode: |
110 | dev.set_network(id, "mesh_ht_mode", ht_mode) | |
8b260032 JM |
111 | if beacon_int: |
112 | dev.set_network(id, "beacon_int", str(beacon_int)) | |
d48b64ba JM |
113 | if start: |
114 | dev.mesh_group_add(id) | |
7e3614df | 115 | return id |
68157c06 JL |
116 | |
117 | def test_wpas_mesh_group_added(dev): | |
118 | """wpa_supplicant MESH group add""" | |
31705bf4 JM |
119 | if not mesh_supported(dev[0]): |
120 | return "skip" | |
d48b64ba | 121 | add_open_mesh_network(dev[0]) |
68157c06 JL |
122 | |
123 | # Check for MESH-GROUP-STARTED event | |
124 | check_mesh_group_added(dev[0]) | |
125 | ||
126 | ||
127 | def test_wpas_mesh_group_remove(dev): | |
128 | """wpa_supplicant MESH group remove""" | |
31705bf4 JM |
129 | if not mesh_supported(dev[0]): |
130 | return "skip" | |
f1381f99 | 131 | add_open_mesh_network(dev[0], ht_mode="NOHT") |
68157c06 JL |
132 | # Check for MESH-GROUP-STARTED event |
133 | check_mesh_group_added(dev[0]) | |
134 | dev[0].mesh_group_remove() | |
135 | # Check for MESH-GROUP-REMOVED event | |
136 | check_mesh_group_removed(dev[0]) | |
7e3614df | 137 | dev[0].mesh_group_remove() |
68157c06 JL |
138 | |
139 | def test_wpas_mesh_peer_connected(dev): | |
140 | """wpa_supplicant MESH peer connected""" | |
31705bf4 JM |
141 | if not mesh_supported(dev[0]): |
142 | return "skip" | |
8b260032 JM |
143 | add_open_mesh_network(dev[0], ht_mode="HT20", beacon_int=160) |
144 | add_open_mesh_network(dev[1], ht_mode="HT20", beacon_int=160) | |
68157c06 JL |
145 | |
146 | # Check for mesh joined | |
147 | check_mesh_group_added(dev[0]) | |
148 | check_mesh_group_added(dev[1]) | |
149 | ||
150 | # Check for peer connected | |
151 | check_mesh_peer_connected(dev[0]) | |
152 | check_mesh_peer_connected(dev[1]) | |
153 | ||
154 | ||
155 | def test_wpas_mesh_peer_disconnected(dev): | |
156 | """wpa_supplicant MESH peer disconnected""" | |
31705bf4 JM |
157 | if not mesh_supported(dev[0]): |
158 | return "skip" | |
d48b64ba JM |
159 | add_open_mesh_network(dev[0]) |
160 | add_open_mesh_network(dev[1]) | |
68157c06 JL |
161 | |
162 | # Check for mesh joined | |
163 | check_mesh_group_added(dev[0]) | |
164 | check_mesh_group_added(dev[1]) | |
165 | ||
166 | # Check for peer connected | |
167 | check_mesh_peer_connected(dev[0]) | |
168 | check_mesh_peer_connected(dev[1]) | |
169 | ||
170 | # Remove group on dev 1 | |
171 | dev[1].mesh_group_remove() | |
172 | # Device 0 should get a disconnection event | |
173 | check_mesh_peer_disconnected(dev[0]) | |
174 | ||
175 | ||
176 | def test_wpas_mesh_mode_scan(dev): | |
177 | """wpa_supplicant MESH scan support""" | |
31705bf4 JM |
178 | if not mesh_supported(dev[0]): |
179 | return "skip" | |
d48b64ba | 180 | add_open_mesh_network(dev[0], ht_mode="HT40+") |
8b260032 | 181 | add_open_mesh_network(dev[1], ht_mode="HT40+", beacon_int=175) |
68157c06 JL |
182 | |
183 | # Check for mesh joined | |
184 | check_mesh_group_added(dev[0]) | |
185 | check_mesh_group_added(dev[1]) | |
186 | ||
187 | # Check for Mesh scan | |
8b260032 | 188 | check_mesh_scan(dev[0], "use_id=1", beacon_int=175) |
68157c06 | 189 | |
4b9481bc JM |
190 | def test_wpas_mesh_open(dev, apdev): |
191 | """wpa_supplicant open MESH network connectivity""" | |
31705bf4 JM |
192 | if not mesh_supported(dev[0]): |
193 | return "skip" | |
f1381f99 JM |
194 | add_open_mesh_network(dev[0], ht_mode="HT40-", freq="2462") |
195 | add_open_mesh_network(dev[1], ht_mode="HT40-", freq="2462") | |
68157c06 JL |
196 | |
197 | # Check for mesh joined | |
198 | check_mesh_group_added(dev[0]) | |
199 | check_mesh_group_added(dev[1]) | |
200 | ||
201 | # Check for peer connected | |
202 | check_mesh_peer_connected(dev[0]) | |
203 | check_mesh_peer_connected(dev[1]) | |
204 | ||
205 | # Test connectivity 0->1 and 1->0 | |
4b9481bc | 206 | hwsim_utils.test_connectivity(dev[0], dev[1]) |
68157c06 | 207 | |
4b9481bc | 208 | def test_wpas_mesh_open_no_auto(dev, apdev): |
14637401 | 209 | """wpa_supplicant open MESH network connectivity""" |
31705bf4 JM |
210 | if not mesh_supported(dev[0]): |
211 | return "skip" | |
d48b64ba | 212 | id = add_open_mesh_network(dev[0], start=False) |
73a2f828 JM |
213 | dev[0].set_network(id, "dot11MeshMaxRetries", "16") |
214 | dev[0].set_network(id, "dot11MeshRetryTimeout", "255") | |
68157c06 JL |
215 | dev[0].mesh_group_add(id) |
216 | ||
d48b64ba | 217 | id = add_open_mesh_network(dev[1], start=False) |
68157c06 JL |
218 | dev[1].set_network(id, "no_auto_peer", "1") |
219 | dev[1].mesh_group_add(id) | |
220 | ||
221 | # Check for mesh joined | |
222 | check_mesh_group_added(dev[0]) | |
223 | check_mesh_group_added(dev[1]) | |
224 | ||
225 | # Check for peer connected | |
e0cfd223 | 226 | check_mesh_peer_connected(dev[0], timeout=30) |
68157c06 JL |
227 | check_mesh_peer_connected(dev[1]) |
228 | ||
229 | # Test connectivity 0->1 and 1->0 | |
4b9481bc | 230 | hwsim_utils.test_connectivity(dev[0], dev[1]) |
68157c06 | 231 | |
11ace2ed | 232 | def add_mesh_secure_net(dev, psk=True): |
54cacef5 JM |
233 | id = dev.add_network() |
234 | dev.set_network(id, "mode", "5") | |
235 | dev.set_network_quoted(id, "ssid", "wpas-mesh-sec") | |
236 | dev.set_network(id, "key_mgmt", "SAE") | |
237 | dev.set_network(id, "frequency", "2412") | |
11ace2ed JM |
238 | if psk: |
239 | dev.set_network_quoted(id, "psk", "thisismypassphrase!") | |
54cacef5 | 240 | return id |
68157c06 | 241 | |
4b9481bc JM |
242 | def test_wpas_mesh_secure(dev, apdev): |
243 | """wpa_supplicant secure MESH network connectivity""" | |
31705bf4 JM |
244 | if not mesh_supported(dev[0]): |
245 | return "skip" | |
17ffdf39 | 246 | dev[0].request("SET sae_groups ") |
54cacef5 | 247 | id = add_mesh_secure_net(dev[0]) |
68157c06 JL |
248 | dev[0].mesh_group_add(id) |
249 | ||
17ffdf39 | 250 | dev[1].request("SET sae_groups ") |
54cacef5 | 251 | id = add_mesh_secure_net(dev[1]) |
68157c06 JL |
252 | dev[1].mesh_group_add(id) |
253 | ||
254 | # Check for mesh joined | |
255 | check_mesh_group_added(dev[0]) | |
256 | check_mesh_group_added(dev[1]) | |
257 | ||
258 | # Check for peer connected | |
259 | check_mesh_peer_connected(dev[0]) | |
260 | check_mesh_peer_connected(dev[1]) | |
261 | ||
262 | # Test connectivity 0->1 and 1->0 | |
4b9481bc | 263 | hwsim_utils.test_connectivity(dev[0], dev[1]) |
68157c06 | 264 | |
54cacef5 JM |
265 | def test_wpas_mesh_secure_sae_group_mismatch(dev, apdev): |
266 | """wpa_supplicant secure MESH and SAE group mismatch""" | |
31705bf4 JM |
267 | if not mesh_supported(dev[0]): |
268 | return "skip" | |
54cacef5 JM |
269 | addr0 = dev[0].p2p_interface_addr() |
270 | addr1 = dev[1].p2p_interface_addr() | |
271 | addr2 = dev[2].p2p_interface_addr() | |
68157c06 | 272 | |
54cacef5 JM |
273 | dev[0].request("SET sae_groups 19 25") |
274 | id = add_mesh_secure_net(dev[0]) | |
68157c06 JL |
275 | dev[0].mesh_group_add(id) |
276 | ||
54cacef5 JM |
277 | dev[1].request("SET sae_groups 19") |
278 | id = add_mesh_secure_net(dev[1]) | |
279 | dev[1].mesh_group_add(id) | |
280 | ||
281 | dev[2].request("SET sae_groups 26") | |
282 | id = add_mesh_secure_net(dev[2]) | |
283 | dev[2].mesh_group_add(id) | |
284 | ||
285 | check_mesh_group_added(dev[0]) | |
286 | check_mesh_group_added(dev[1]) | |
287 | check_mesh_group_added(dev[2]) | |
288 | ||
289 | ev = dev[0].wait_event(["MESH-PEER-CONNECTED"]) | |
290 | if ev is None: | |
291 | raise Exception("Remote peer did not connect") | |
292 | if addr1 not in ev: | |
293 | raise Exception("Unexpected peer connected: " + ev) | |
294 | ||
295 | ev = dev[1].wait_event(["MESH-PEER-CONNECTED"]) | |
296 | if ev is None: | |
297 | raise Exception("Remote peer did not connect") | |
298 | if addr0 not in ev: | |
299 | raise Exception("Unexpected peer connected: " + ev) | |
300 | ||
301 | ev = dev[2].wait_event(["MESH-PEER-CONNECTED"], timeout=1) | |
302 | if ev is not None: | |
303 | raise Exception("Unexpected peer connection at dev[2]: " + ev) | |
304 | ||
305 | ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1) | |
306 | if ev is not None: | |
307 | raise Exception("Unexpected peer connection: " + ev) | |
308 | ||
309 | ev = dev[1].wait_event(["MESH-PEER-CONNECTED"], timeout=0.1) | |
310 | if ev is not None: | |
311 | raise Exception("Unexpected peer connection: " + ev) | |
312 | ||
313 | dev[0].request("SET sae_groups ") | |
17ffdf39 | 314 | dev[1].request("SET sae_groups ") |
54cacef5 JM |
315 | dev[2].request("SET sae_groups ") |
316 | ||
11ace2ed JM |
317 | def test_wpas_mesh_secure_sae_missing_password(dev, apdev): |
318 | """wpa_supplicant secure MESH and missing SAE password""" | |
31705bf4 JM |
319 | if not mesh_supported(dev[0]): |
320 | return "skip" | |
11ace2ed JM |
321 | id = add_mesh_secure_net(dev[0], psk=False) |
322 | dev[0].set_network(id, "psk", "8f20b381f9b84371d61b5080ad85cac3c61ab3ca9525be5b2d0f4da3d979187a") | |
323 | dev[0].mesh_group_add(id) | |
324 | ev = dev[0].wait_event(["MESH-GROUP-STARTED", "Could not join mesh"], | |
325 | timeout=5) | |
326 | if ev is None: | |
327 | raise Exception("Timeout on mesh start event") | |
328 | if "MESH-GROUP-STARTED" in ev: | |
329 | raise Exception("Unexpected mesh group start") | |
330 | ev = dev[0].wait_event(["MESH-GROUP-STARTED"], timeout=0.1) | |
331 | if ev is not None: | |
332 | raise Exception("Unexpected mesh group start") | |
333 | ||
4b9481bc JM |
334 | def test_wpas_mesh_secure_no_auto(dev, apdev): |
335 | """wpa_supplicant secure MESH network connectivity""" | |
31705bf4 JM |
336 | if not mesh_supported(dev[0]): |
337 | return "skip" | |
54cacef5 JM |
338 | dev[0].request("SET sae_groups 19") |
339 | id = add_mesh_secure_net(dev[0]) | |
340 | dev[0].mesh_group_add(id) | |
341 | ||
342 | dev[1].request("SET sae_groups 19") | |
343 | id = add_mesh_secure_net(dev[1]) | |
68157c06 JL |
344 | dev[1].set_network(id, "no_auto_peer", "1") |
345 | dev[1].mesh_group_add(id) | |
346 | ||
347 | # Check for mesh joined | |
348 | check_mesh_group_added(dev[0]) | |
349 | check_mesh_group_added(dev[1]) | |
350 | ||
351 | # Check for peer connected | |
e0cfd223 | 352 | check_mesh_peer_connected(dev[0], timeout=30) |
68157c06 JL |
353 | check_mesh_peer_connected(dev[1]) |
354 | ||
355 | # Test connectivity 0->1 and 1->0 | |
4b9481bc | 356 | hwsim_utils.test_connectivity(dev[0], dev[1]) |
68157c06 | 357 | |
54cacef5 JM |
358 | dev[0].request("SET sae_groups ") |
359 | dev[1].request("SET sae_groups ") | |
68157c06 | 360 | |
5e2a8ec9 JM |
361 | def test_wpas_mesh_ctrl(dev): |
362 | """wpa_supplicant ctrl_iface mesh command error cases""" | |
31705bf4 JM |
363 | if not mesh_supported(dev[0]): |
364 | return "skip" | |
5e2a8ec9 JM |
365 | if "FAIL" not in dev[0].request("MESH_GROUP_ADD 123"): |
366 | raise Exception("Unexpected MESH_GROUP_ADD success") | |
367 | id = dev[0].add_network() | |
368 | if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id): | |
369 | raise Exception("Unexpected MESH_GROUP_ADD success") | |
370 | dev[0].set_network(id, "mode", "5") | |
371 | dev[0].set_network(id, "key_mgmt", "WPA-PSK") | |
372 | if "FAIL" not in dev[0].request("MESH_GROUP_ADD %d" % id): | |
373 | raise Exception("Unexpected MESH_GROUP_ADD success") | |
374 | ||
375 | if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE foo"): | |
376 | raise Exception("Unexpected MESH_GROUP_REMOVE success") | |
7e3614df JM |
377 | |
378 | def test_wpas_mesh_dynamic_interface(dev): | |
379 | """wpa_supplicant mesh with dynamic interface""" | |
31705bf4 JM |
380 | if not mesh_supported(dev[0]): |
381 | return "skip" | |
7e3614df JM |
382 | mesh0 = None |
383 | mesh1 = None | |
384 | try: | |
385 | mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0") | |
386 | if "FAIL" in mesh0: | |
387 | raise Exception("MESH_INTERFACE_ADD failed") | |
388 | mesh1 = dev[1].request("MESH_INTERFACE_ADD") | |
389 | if "FAIL" in mesh1: | |
390 | raise Exception("MESH_INTERFACE_ADD failed") | |
391 | ||
392 | wpas0 = WpaSupplicant(ifname=mesh0) | |
393 | wpas1 = WpaSupplicant(ifname=mesh1) | |
394 | logger.info(mesh0 + " address " + wpas0.get_status_field("address")) | |
395 | logger.info(mesh1 + " address " + wpas1.get_status_field("address")) | |
396 | ||
397 | add_open_mesh_network(wpas0) | |
398 | add_open_mesh_network(wpas1) | |
399 | check_mesh_group_added(wpas0) | |
400 | check_mesh_group_added(wpas1) | |
401 | check_mesh_peer_connected(wpas0) | |
402 | check_mesh_peer_connected(wpas1) | |
403 | hwsim_utils.test_connectivity(wpas0, wpas1) | |
404 | ||
405 | # Must not allow MESH_GROUP_REMOVE on dynamic interface | |
406 | if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh0): | |
407 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
408 | if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh1): | |
409 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
410 | ||
411 | # Must not allow MESH_GROUP_REMOVE on another radio interface | |
412 | if "FAIL" not in wpas0.request("MESH_GROUP_REMOVE " + mesh1): | |
413 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
414 | if "FAIL" not in wpas1.request("MESH_GROUP_REMOVE " + mesh0): | |
415 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
416 | ||
417 | wpas0.remove_ifname() | |
418 | wpas1.remove_ifname() | |
419 | ||
420 | if "OK" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0): | |
421 | raise Exception("MESH_GROUP_REMOVE failed") | |
422 | if "OK" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1): | |
423 | raise Exception("MESH_GROUP_REMOVE failed") | |
424 | ||
425 | if "FAIL" not in dev[0].request("MESH_GROUP_REMOVE " + mesh0): | |
426 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
427 | if "FAIL" not in dev[1].request("MESH_GROUP_REMOVE " + mesh1): | |
428 | raise Exception("Invalid MESH_GROUP_REMOVE accepted") | |
429 | ||
430 | logger.info("Make sure another dynamic group can be added") | |
431 | mesh0 = dev[0].request("MESH_INTERFACE_ADD ifname=mesh0") | |
432 | if "FAIL" in mesh0: | |
433 | raise Exception("MESH_INTERFACE_ADD failed") | |
434 | mesh1 = dev[1].request("MESH_INTERFACE_ADD") | |
435 | if "FAIL" in mesh1: | |
436 | raise Exception("MESH_INTERFACE_ADD failed") | |
437 | ||
438 | wpas0 = WpaSupplicant(ifname=mesh0) | |
439 | wpas1 = WpaSupplicant(ifname=mesh1) | |
440 | logger.info(mesh0 + " address " + wpas0.get_status_field("address")) | |
441 | logger.info(mesh1 + " address " + wpas1.get_status_field("address")) | |
442 | ||
443 | add_open_mesh_network(wpas0) | |
444 | add_open_mesh_network(wpas1) | |
445 | check_mesh_group_added(wpas0) | |
446 | check_mesh_group_added(wpas1) | |
447 | check_mesh_peer_connected(wpas0) | |
448 | check_mesh_peer_connected(wpas1) | |
449 | hwsim_utils.test_connectivity(wpas0, wpas1) | |
450 | finally: | |
451 | if mesh0: | |
452 | dev[0].request("MESH_GROUP_REMOVE " + mesh0) | |
453 | if mesh1: | |
454 | dev[1].request("MESH_GROUP_REMOVE " + mesh1) | |
9be2b811 JM |
455 | |
456 | def test_wpas_mesh_max_peering(dev, apdev): | |
457 | """Mesh max peering limit""" | |
31705bf4 JM |
458 | if not mesh_supported(dev[0]): |
459 | return "skip" | |
9be2b811 JM |
460 | try: |
461 | dev[0].request("SET max_peer_links 1") | |
462 | for i in range(3): | |
463 | add_open_mesh_network(dev[i]) | |
464 | ||
465 | for i in range(3): | |
466 | ev = dev[i].wait_event(["MESH-PEER-CONNECTED"]) | |
467 | if ev is None: | |
468 | raise Exception("dev%d did not connect with any peer" % i) | |
469 | ||
470 | for i in range(1, 3): | |
471 | ev = dev[i].wait_event(["MESH-PEER-CONNECTED"]) | |
472 | if ev is None: | |
473 | raise Exception("dev%d did not connect the second peer" % i) | |
474 | ||
475 | ev = dev[0].wait_event(["MESH-PEER-CONNECTED"], timeout=1) | |
476 | if ev is not None: | |
477 | raise Exception("dev0 connection beyond max peering limit") | |
478 | ||
479 | for i in range(3): | |
480 | dev[i].mesh_group_remove() | |
481 | check_mesh_group_removed(dev[i]) | |
482 | finally: | |
483 | dev[0].request("SET max_peer_links 99") |