]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_fst_module.py
tests: FST AP setup failing due to OOM
[thirdparty/hostap.git] / tests / hwsim / test_fst_module.py
1 # FST functionality tests
2 # Copyright (c) 2015, Qualcomm Atheros, Inc.
3 #
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
6
7 import logging
8 logger = logging.getLogger()
9 import subprocess
10 import time
11 import os
12
13 import hwsim_utils
14 from hwsim import HWSimRadio
15 import hostapd
16 import fst_test_common
17 import fst_module_aux
18 from utils import alloc_fail
19
20 #enum - bad parameter types
21 bad_param_none = 0
22 bad_param_session_add_no_params = 1
23 bad_param_group_id = 2
24 bad_param_session_set_no_params = 3
25 bad_param_session_set_unknown_param = 4
26 bad_param_session_id = 5
27 bad_param_old_iface = 6
28 bad_param_new_iface = 7
29 bad_param_negative_llt = 8
30 bad_param_zero_llt = 9
31 bad_param_llt_too_big = 10
32 bad_param_llt_nan = 11
33 bad_param_peer_addr = 12
34 bad_param_session_initiate_no_params = 13
35 bad_param_session_initiate_bad_session_id = 14
36 bad_param_session_initiate_with_no_new_iface_set = 15
37 bad_param_session_initiate_with_bad_peer_addr_set = 16
38 bad_param_session_initiate_request_with_bad_stie = 17
39 bad_param_session_initiate_response_with_reject = 18
40 bad_param_session_initiate_response_with_bad_stie = 19
41 bad_param_session_initiate_response_with_zero_llt = 20
42 bad_param_session_initiate_stt_no_response = 21
43 bad_param_session_initiate_concurrent_setup_request = 22
44 bad_param_session_transfer_no_params = 23
45 bad_param_session_transfer_bad_session_id = 24
46 bad_param_session_transfer_setup_skipped = 25
47 bad_param_session_teardown_no_params = 26
48 bad_param_session_teardown_bad_session_id = 27
49 bad_param_session_teardown_setup_skipped = 28
50 bad_param_session_teardown_bad_fsts_id = 29
51
52 bad_param_names = ("None",
53 "No params passed to session add",
54 "Group ID",
55 "No params passed to session set",
56 "Unknown param passed to session set",
57 "Session ID",
58 "Old interface name",
59 "New interface name",
60 "Negative LLT",
61 "Zero LLT",
62 "LLT too big",
63 "LLT is not a number",
64 "Peer address",
65 "No params passed to session initiate",
66 "Session ID",
67 "No new_iface was set",
68 "Peer address",
69 "Request with bad st ie",
70 "Response with reject",
71 "Response with bad st ie",
72 "Response with zero llt",
73 "No response, STT",
74 "Concurrent setup request",
75 "No params passed to session transfer",
76 "Session ID",
77 "Session setup skipped",
78 "No params passed to session teardown",
79 "Bad session",
80 "Session setup skipped",
81 "Bad fsts_id")
82
83 def fst_start_session(apdev, test_params, bad_param_type, start_on_ap,
84 peer_addr = None):
85 """This function makes the necessary preparations and the adds and sets a
86 session using either correct or incorrect parameters depending on the value
87 of bad_param_type. If the call ends as expected (with session being
88 successfully added and set in case of correct parameters or with the
89 expected exception in case of incorrect parameters), the function silently
90 exits. Otherwise, it throws an exception thus failing the test."""
91
92 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
93 bad_parameter_detected = False
94 exception_already_raised = False
95 try:
96 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
97 if start_on_ap:
98 initiator = ap1
99 responder = sta1
100 new_iface = ap2.ifname()
101 new_peer_addr = ap2.get_actual_peer_addr()
102 else:
103 initiator = sta1
104 responder = ap1
105 new_iface = sta2.ifname()
106 new_peer_addr = sta2.get_actual_peer_addr()
107 initiator.add_peer(responder, peer_addr, new_peer_addr)
108 group_id = None
109 if bad_param_type == bad_param_group_id:
110 group_id = '-1'
111 elif bad_param_type == bad_param_session_add_no_params:
112 group_id = ''
113 initiator.set_fst_parameters(group_id=group_id)
114 sid = initiator.add_session()
115 if bad_param_type == bad_param_session_set_no_params:
116 res = initiator.set_session_param(None)
117 if not res.startswith("OK"):
118 raise Exception("Session set operation failed")
119 elif bad_param_type == bad_param_session_set_unknown_param:
120 res = initiator.set_session_param("bad_param=1")
121 if not res.startswith("OK"):
122 raise Exception("Session set operation failed")
123 else:
124 if bad_param_type == bad_param_session_initiate_with_no_new_iface_set:
125 new_iface = None
126 elif bad_param_type == bad_param_new_iface:
127 new_iface = 'wlan12'
128 old_iface = None if bad_param_type != bad_param_old_iface else 'wlan12'
129 llt = None
130 if bad_param_type == bad_param_negative_llt:
131 llt = '-1'
132 elif bad_param_type == bad_param_zero_llt:
133 llt = '0'
134 elif bad_param_type == bad_param_llt_too_big:
135 llt = '4294967296' #0x100000000
136 elif bad_param_type == bad_param_llt_nan:
137 llt = 'nan'
138 elif bad_param_type == bad_param_session_id:
139 sid = '-1'
140 initiator.set_fst_parameters(llt=llt)
141 initiator.configure_session(sid, new_iface, old_iface)
142 except Exception, e:
143 if e.args[0].startswith("Cannot add FST session with groupid"):
144 if bad_param_type == bad_param_group_id or bad_param_type == bad_param_session_add_no_params:
145 bad_parameter_detected = True
146 elif e.args[0].startswith("Cannot set FST session new_ifname:"):
147 if bad_param_type == bad_param_new_iface:
148 bad_parameter_detected = True
149 elif e.args[0].startswith("Session set operation failed"):
150 if (bad_param_type == bad_param_session_set_no_params or
151 bad_param_type == bad_param_session_set_unknown_param):
152 bad_parameter_detected = True
153 elif e.args[0].startswith("Cannot set FST session old_ifname:"):
154 if (bad_param_type == bad_param_old_iface or
155 bad_param_type == bad_param_session_id or
156 bad_param_type == bad_param_session_set_no_params):
157 bad_parameter_detected = True
158 elif e.args[0].startswith("Cannot set FST session llt:"):
159 if (bad_param_type == bad_param_negative_llt or
160 bad_param_type == bad_param_llt_too_big or
161 bad_param_type == bad_param_llt_nan):
162 bad_parameter_detected = True
163 elif e.args[0].startswith("Cannot set FST session peer address:"):
164 if bad_param_type == bad_param_peer_addr:
165 bad_parameter_detected = True
166 if not bad_parameter_detected:
167 # The exception was unexpected
168 logger.info(e)
169 exception_already_raised = True
170 raise
171 finally:
172 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
173 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
174 if not exception_already_raised:
175 if bad_parameter_detected:
176 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
177 else:
178 if bad_param_type == bad_param_none or bad_param_type == bad_param_zero_llt:
179 logger.info("Success. Session added and set")
180 else:
181 exception_text = ""
182 if bad_param_type == bad_param_peer_addr:
183 exception_text = "Failure. Bad parameter was not detected (Peer address == %s)" % ap1.get_new_peer_addr()
184 else:
185 exception_text = "Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type]
186 raise Exception(exception_text)
187 else:
188 print "Failure. Unexpected exception"
189
190 def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap):
191 """This function makes the necessary preparations and then adds, sets and
192 initiates a session using either correct or incorrect parameters at each
193 stage depending on the value of bad_param_type. If the call ends as expected
194 (with session being successfully added, set and initiated in case of correct
195 parameters or with the expected exception in case of incorrect parameters),
196 the function silently exits. Otherwise it throws an exception thus failing
197 the test."""
198 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
199 bad_parameter_detected = False
200 exception_already_raised = False
201 try:
202 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
203 # This call makes sure FstHostapd singleton object is created and, as a
204 # result, the global control interface is registered (this is done from
205 # the constructor).
206 ap1.get_global_instance()
207 if init_on_ap:
208 initiator = ap1
209 responder = sta1
210 new_iface = ap2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
211 new_peer_addr = ap2.get_actual_peer_addr()
212 resp_newif = sta2.ifname()
213 else:
214 initiator = sta1
215 responder = ap1
216 new_iface = sta2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
217 new_peer_addr = sta2.get_actual_peer_addr()
218 resp_newif = ap2.ifname()
219 peeraddr = None if bad_param_type != bad_param_session_initiate_with_bad_peer_addr_set else '10:DE:AD:DE:AD:11'
220 initiator.add_peer(responder, peeraddr, new_peer_addr)
221 if bad_param_type == bad_param_session_initiate_response_with_zero_llt:
222 initiator.set_fst_parameters(llt='0')
223 sid = initiator.add_session()
224 initiator.configure_session(sid, new_iface)
225 if bad_param_type == bad_param_session_initiate_no_params:
226 sid = ''
227 elif bad_param_type == bad_param_session_initiate_bad_session_id:
228 sid = '-1'
229 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
230 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
231 initiator.send_test_session_setup_request(str(actual_fsts_id), "bad_new_band")
232 responder.wait_for_session_event(5)
233 elif bad_param_type == bad_param_session_initiate_response_with_reject:
234 initiator.send_session_setup_request(sid)
235 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
236 setup_event = responder.wait_for_session_event(5, [],
237 ['EVENT_FST_SETUP'])
238 if not 'id' in setup_event:
239 raise Exception("No session id in FST setup event")
240 responder.send_session_setup_response(str(setup_event['id']),
241 "reject")
242 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
243 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_REJECT":
244 raise Exception("Response with reject not handled as expected")
245 bad_parameter_detected = True
246 elif bad_param_type == bad_param_session_initiate_response_with_bad_stie:
247 initiator.send_session_setup_request(sid)
248 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
249 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
250 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
251 responder.send_test_session_setup_response(str(actual_fsts_id),
252 "accept", "bad_new_band")
253 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
254 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_ERROR_PARAMS":
255 raise Exception("Response with bad STIE not handled as expected")
256 bad_parameter_detected = True
257 elif bad_param_type == bad_param_session_initiate_response_with_zero_llt:
258 initiator.initiate_session(sid, "accept")
259 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
260 if event['new_state'] != "TRANSITION_DONE":
261 raise Exception("Response reception for a session with llt=0 not handled as expected")
262 bad_parameter_detected = True
263 elif bad_param_type == bad_param_session_initiate_stt_no_response:
264 initiator.send_session_setup_request(sid)
265 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
266 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
267 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
268 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
269 raise Exception("No response scenario not handled as expected")
270 bad_parameter_detected = True
271 elif bad_param_type == bad_param_session_initiate_concurrent_setup_request:
272 responder.add_peer(initiator)
273 resp_sid = responder.add_session()
274 responder.configure_session(resp_sid, resp_newif)
275 initiator.send_session_setup_request(sid)
276 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
277 responder.send_test_session_setup_request(str(actual_fsts_id))
278 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
279 initiator_addr = initiator.get_own_mac_address()
280 responder_addr = responder.get_own_mac_address()
281 if initiator_addr < responder_addr:
282 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
283 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_SETUP":
284 raise Exception("Concurrent setup scenario not handled as expected")
285 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SETUP"])
286 # The incoming setup request received by the initiator has
287 # priority over the one sent previously by the initiator itself
288 # because the initiator's MAC address is numerically lower than
289 # the one of the responder. Thus, the initiator should generate
290 # an FST_SETUP event.
291 else:
292 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
293 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
294 raise Exception("Concurrent setup scenario not handled as expected")
295 # The incoming setup request was dropped at the initiator
296 # because its MAC address is numerically bigger than the one of
297 # the responder. Thus, the initiator continue to wait for a
298 # setup response until the STT event fires.
299 bad_parameter_detected = True
300 else:
301 initiator.initiate_session(sid, "accept")
302 except Exception, e:
303 if e.args[0].startswith("Cannot initiate fst session"):
304 if bad_param_type != bad_param_none:
305 bad_parameter_detected = True
306 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
307 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
308 bad_parameter_detected = True
309 if not bad_parameter_detected:
310 #The exception was unexpected
311 logger.info(e)
312 exception_already_raised = True
313 raise
314 finally:
315 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
316 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
317 if not exception_already_raised:
318 if bad_parameter_detected:
319 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
320 else:
321 if bad_param_type == bad_param_none:
322 logger.info("Success. Session initiated")
323 else:
324 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
325 else:
326 print "Failure. Unexpected exception"
327
328 def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap):
329 """This function makes the necessary preparations and then adds, sets,
330 initiates and attempts to transfer a session using either correct or
331 incorrect parameters at each stage depending on the value of bad_param_type.
332 If the call ends as expected the function silently exits. Otherwise, it
333 throws an exception thus failing the test."""
334 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
335 bad_parameter_detected = False
336 exception_already_raised = False
337 try:
338 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
339 # This call makes sure FstHostapd singleton object is created and, as a
340 # result, the global control interface is registered (this is done from
341 # the constructor).
342 ap1.get_global_instance()
343 if init_on_ap:
344 initiator = ap1
345 responder = sta1
346 new_iface = ap2.ifname()
347 new_peer_addr = ap2.get_actual_peer_addr()
348 else:
349 initiator = sta1
350 responder = ap1
351 new_iface = sta2.ifname()
352 new_peer_addr = sta2.get_actual_peer_addr()
353 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
354 sid = initiator.add_session()
355 initiator.configure_session(sid, new_iface)
356 if bad_param_type != bad_param_session_transfer_setup_skipped:
357 initiator.initiate_session(sid, "accept")
358 if bad_param_type == bad_param_session_transfer_no_params:
359 sid = ''
360 elif bad_param_type == bad_param_session_transfer_bad_session_id:
361 sid = '-1'
362 initiator.transfer_session(sid)
363 except Exception, e:
364 if e.args[0].startswith("Cannot transfer fst session"):
365 if bad_param_type != bad_param_none:
366 bad_parameter_detected = True
367 if not bad_parameter_detected:
368 # The exception was unexpected
369 logger.info(e)
370 exception_already_raised = True
371 raise
372 finally:
373 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
374 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
375 if not exception_already_raised:
376 if bad_parameter_detected:
377 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
378 else:
379 if bad_param_type == bad_param_none:
380 logger.info("Success. Session transferred")
381 else:
382 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
383 else:
384 print "Failure. Unexpected exception"
385
386
387 def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap):
388 """This function makes the necessary preparations and then adds, sets, and
389 initiates a session. It then issues a tear down command using either
390 correct or incorrect parameters at each stage. If the call ends as expected,
391 the function silently exits. Otherwise, it throws an exception thus failing
392 the test."""
393 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
394 bad_parameter_detected = False
395 exception_already_raised = False
396 try:
397 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
398 # This call makes sure FstHostapd singleton object is created and, as a
399 # result, the global control interface is registered (this is done from
400 # the constructor).
401 ap1.get_global_instance()
402 if init_on_ap:
403 initiator = ap1
404 responder = sta1
405 new_iface = ap2.ifname()
406 new_peer_addr = ap2.get_actual_peer_addr()
407 else:
408 initiator = sta1
409 responder = ap1
410 new_iface = sta2.ifname()
411 new_peer_addr = sta2.get_actual_peer_addr()
412 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
413 sid = initiator.add_session()
414 initiator.configure_session(sid, new_iface)
415 if bad_param_type != bad_param_session_teardown_setup_skipped:
416 initiator.initiate_session(sid, "accept")
417 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
418 initiator.send_test_tear_down('-1')
419 responder.wait_for_session_event(5)
420 else:
421 if bad_param_type == bad_param_session_teardown_no_params:
422 sid = ''
423 elif bad_param_type == bad_param_session_teardown_bad_session_id:
424 sid = '-1'
425 initiator.teardown_session(sid)
426 except Exception, e:
427 if e.args[0].startswith("Cannot tear down fst session"):
428 if (bad_param_type == bad_param_session_teardown_no_params or
429 bad_param_type == bad_param_session_teardown_bad_session_id or
430 bad_param_type == bad_param_session_teardown_setup_skipped):
431 bad_parameter_detected = True
432 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
433 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
434 bad_parameter_detected = True
435 if not bad_parameter_detected:
436 # The exception was unexpected
437 logger.info(e)
438 exception_already_raised = True
439 raise
440 finally:
441 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
442 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
443 if not exception_already_raised:
444 if bad_parameter_detected:
445 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
446 else:
447 if bad_param_type == bad_param_none:
448 logger.info("Success. Session torn down")
449 else:
450 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
451 else:
452 print "Failure. Unexpected exception"
453
454
455 #enum - remove session scenarios
456 remove_scenario_no_params = 0
457 remove_scenario_bad_session_id = 1
458 remove_scenario_non_established_session = 2
459 remove_scenario_established_session = 3
460
461 remove_scenario_names = ("No params",
462 "Bad session id",
463 "Remove non-established session",
464 "Remove established session")
465
466
467 def fst_remove_session(apdev, test_params, remove_session_scenario, init_on_ap):
468 """This function attempts to remove a session at various stages of its
469 formation, depending on the value of remove_session_scenario. If the call
470 ends as expected, the function silently exits. Otherwise, it throws an
471 exception thus failing the test."""
472 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
473 bad_parameter_detected = False
474 exception_already_raised = False
475 try:
476 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
477 # This call makes sure FstHostapd singleton object is created and, as a
478 # result, the global control interface is registered (this is done from
479 # the constructor).
480 ap1.get_global_instance()
481 if init_on_ap:
482 initiator = ap1
483 responder = sta1
484 new_iface = ap2.ifname()
485 new_peer_addr = ap2.get_actual_peer_addr()
486 else:
487 initiator = sta1
488 responder = ap1
489 new_iface = sta2.ifname()
490 new_peer_addr = sta2.get_actual_peer_addr()
491 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
492 sid = initiator.add_session()
493 initiator.configure_session(sid, new_iface)
494 if remove_session_scenario != remove_scenario_no_params:
495 if remove_session_scenario != remove_scenario_non_established_session:
496 initiator.initiate_session(sid, "accept")
497 if remove_session_scenario == remove_scenario_no_params:
498 sid = ''
499 elif remove_session_scenario == remove_scenario_bad_session_id:
500 sid = '-1'
501 initiator.remove_session(sid)
502 except Exception, e:
503 if e.args[0].startswith("Cannot remove fst session"):
504 if (remove_session_scenario == remove_scenario_no_params or
505 remove_session_scenario == remove_scenario_bad_session_id):
506 bad_parameter_detected = True
507 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
508 if remove_session_scenario == remove_scenario_non_established_session:
509 bad_parameter_detected = True
510 if not bad_parameter_detected:
511 #The exception was unexpected
512 logger.info(e)
513 exception_already_raised = True
514 raise
515 finally:
516 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
517 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
518 if not exception_already_raised:
519 if bad_parameter_detected:
520 logger.info("Success. Remove scenario ended as expected (%s)" % remove_scenario_names[remove_session_scenario])
521 else:
522 if remove_session_scenario == remove_scenario_established_session:
523 logger.info("Success. Session removed")
524 else:
525 raise Exception("Failure. Remove scenario ended in an unexpected way (%s)" % remove_scenario_names[remove_session_scenario])
526 else:
527 print "Failure. Unexpected exception"
528
529
530 #enum - frame types
531 frame_type_session_request = 0
532 frame_type_session_response = 1
533 frame_type_ack_request = 2
534 frame_type_ack_response = 3
535 frame_type_tear_down = 4
536
537 frame_type_names = ("Session request",
538 "Session Response",
539 "Ack request",
540 "Ack response",
541 "Tear down")
542
543 def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, additional_param = ''):
544 """This function creates two pairs of APs and stations, makes them connect
545 and then causes one side to send an unexpected FST frame of the specified
546 type to the other. The other side should then identify and ignore the
547 frame."""
548 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
549 exception_already_raised = False
550 frame_receive_timeout = False
551 try:
552 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
553 # This call makes sure FstHostapd singleton object is created and, as a
554 # result, the global control interface is registered (this is done from
555 # the constructor).
556 ap1.get_global_instance()
557 if send_from_ap:
558 sender = ap1
559 receiver = sta1
560 new_iface = ap2.ifname()
561 new_peer_addr = ap2.get_actual_peer_addr()
562 else:
563 sender = sta1
564 receiver = ap1
565 new_iface = sta2.ifname()
566 new_peer_addr = sta2.get_actual_peer_addr()
567 sender.add_peer(receiver, new_peer_addr = new_peer_addr)
568 sid=sender.add_session()
569 sender.configure_session(sid, new_iface)
570 if frame_type == frame_type_session_request:
571 sender.send_session_setup_request(sid)
572 event = receiver.wait_for_session_event(5)
573 if event['type'] != 'EVENT_FST_SETUP':
574 raise Exception("Unexpected indication: " + event['type'])
575 elif frame_type == frame_type_session_response:
576 #fsts_id doesn't matter, no actual session exists
577 sender.send_test_session_setup_response('0', additional_param)
578 receiver.wait_for_session_event(5)
579 elif frame_type == frame_type_ack_request:
580 #fsts_id doesn't matter, no actual session exists
581 sender.send_test_ack_request('0')
582 receiver.wait_for_session_event(5)
583 elif frame_type == frame_type_ack_response:
584 #fsts_id doesn't matter, no actual session exists
585 sender.send_test_ack_response('0')
586 receiver.wait_for_session_event(5)
587 elif frame_type == frame_type_tear_down:
588 #fsts_id doesn't matter, no actual session exists
589 sender.send_test_tear_down('0')
590 receiver.wait_for_session_event(5)
591 except Exception, e:
592 if e.args[0].startswith("No FST-EVENT-SESSION received"):
593 if frame_type != frame_type_session_request:
594 frame_receive_timeout = True
595 else:
596 logger.info(e)
597 exception_already_raised = True
598 raise
599 finally:
600 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
601 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
602 if not exception_already_raised:
603 if frame_receive_timeout:
604 logger.info("Success. Frame was ignored (%s)" % frame_type_names[frame_type])
605 else:
606 if frame_type == frame_type_session_request:
607 logger.info("Success. Frame received, session created")
608 else:
609 raise Exception("Failure. Frame was not ignored (%s)" % frame_type_names[frame_type])
610 else:
611 print "Failure. Unexpected exception"
612
613
614 #enum - bad session transfer scenarios
615 bad_scenario_none = 0
616 bad_scenario_ack_req_session_not_set_up = 1
617 bad_scenario_ack_req_session_not_established_init_side = 2
618 bad_scenario_ack_req_session_not_established_resp_side = 3
619 bad_scenario_ack_req_bad_fsts_id = 4
620 bad_scenario_ack_resp_session_not_set_up = 5
621 bad_scenario_ack_resp_session_not_established_init_side = 6
622 bad_scenario_ack_resp_session_not_established_resp_side = 7
623 bad_scenario_ack_resp_no_ack_req = 8
624 bad_scenario_ack_resp_bad_fsts_id = 9
625
626 bad_scenario_names = ("None",
627 "Ack request received before the session was set up",
628 "Ack request received on the initiator side before session was established",
629 "Ack request received on the responder side before session was established",
630 "Ack request received with bad fsts_id",
631 "Ack response received before the session was set up",
632 "Ack response received on the initiator side before session was established",
633 "Ack response received on the responder side before session was established",
634 "Ack response received before ack request was sent",
635 "Ack response received with bad fsts_id")
636
637 def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap):
638 """This function makes the necessary preparations and then adds and sets a
639 session. It then initiates and it unless instructed otherwise) and attempts
640 to send one of the frames involved in the session transfer protocol,
641 skipping or distorting one of the stages according to the value of
642 bad_scenario_type parameter."""
643 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
644 bad_parameter_detected = False
645 exception_already_raised = False
646 try:
647 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
648 # This call makes sure FstHostapd singleton object is created and, as a
649 # result, the global control interface is registered (this is done from
650 # the constructor).
651 ap1.get_global_instance()
652 if init_on_ap:
653 initiator = ap1
654 responder = sta1
655 new_iface = ap2.ifname()
656 new_peer_addr = ap2.get_actual_peer_addr()
657 else:
658 initiator = sta1
659 responder = ap1
660 new_iface = sta2.ifname()
661 new_peer_addr = sta2.get_actual_peer_addr()
662 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
663 sid = initiator.add_session()
664 initiator.configure_session(sid, new_iface)
665 if (bad_scenario_type != bad_scenario_ack_req_session_not_set_up and
666 bad_scenario_type != bad_scenario_ack_resp_session_not_set_up):
667 if (bad_scenario_type != bad_scenario_ack_req_session_not_established_init_side and
668 bad_scenario_type != bad_scenario_ack_resp_session_not_established_init_side and
669 bad_scenario_type != bad_scenario_ack_req_session_not_established_resp_side and
670 bad_scenario_type != bad_scenario_ack_resp_session_not_established_resp_side):
671 response = "accept"
672 else:
673 response = ''
674 initiator.initiate_session(sid, response)
675 if bad_scenario_type == bad_scenario_ack_req_session_not_set_up:
676 #fsts_id doesn't matter, no actual session exists
677 responder.send_test_ack_request('0')
678 initiator.wait_for_session_event(5)
679 # We want to send the unexpected frame to the side that already has
680 # a session created
681 elif bad_scenario_type == bad_scenario_ack_resp_session_not_set_up:
682 #fsts_id doesn't matter, no actual session exists
683 responder.send_test_ack_response('0')
684 initiator.wait_for_session_event(5)
685 # We want to send the unexpected frame to the side that already has
686 # a session created
687 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_init_side:
688 #fsts_id doesn't matter, no actual session exists
689 initiator.send_test_ack_request('0')
690 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
691 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_resp_side:
692 #fsts_id doesn't matter, no actual session exists
693 responder.send_test_ack_request('0')
694 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
695 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_init_side:
696 #fsts_id doesn't matter, no actual session exists
697 initiator.send_test_ack_response('0')
698 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
699 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_resp_side:
700 #fsts_id doesn't matter, no actual session exists
701 responder.send_test_ack_response('0')
702 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
703 elif bad_scenario_type == bad_scenario_ack_req_bad_fsts_id:
704 initiator.send_test_ack_request('-1')
705 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
706 elif bad_scenario_type == bad_scenario_ack_resp_bad_fsts_id:
707 initiator.send_test_ack_response('-1')
708 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
709 elif bad_scenario_type == bad_scenario_ack_resp_no_ack_req:
710 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
711 initiator.send_test_ack_response(str(actual_fsts_id))
712 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
713 else:
714 raise Exception("Unknown bad scenario identifier")
715 except Exception, e:
716 if e.args[0].startswith("No FST-EVENT-SESSION received"):
717 bad_parameter_detected = True
718 if not bad_parameter_detected:
719 # The exception was unexpected
720 logger.info(e)
721 exception_already_raised = True
722 raise
723 finally:
724 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
725 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
726 if not exception_already_raised:
727 if bad_parameter_detected:
728 logger.info("Success. Bad scenario was handled correctly (%s)" % bad_scenario_names[bad_scenario_type])
729 else:
730 raise Exception("Failure. Bad scenario was handled incorrectly (%s)" % bad_scenario_names[bad_scenario_type])
731 else:
732 print "Failure. Unexpected exception"
733
734 def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params):
735 """FST STA connecting to non-FST AP"""
736 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
737 with HWSimRadio() as (radio, iface):
738 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
739 try:
740 orig_sta1_mbies = sta1.get_local_mbies()
741 orig_sta2_mbies = sta2.get_local_mbies()
742 vals = sta2.scan()
743 freq = vals['freq']
744 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g",
745 key_mgmt="NONE", scan_freq=freq)
746 time.sleep(2)
747 res_sta1_mbies = sta1.get_local_mbies()
748 res_sta2_mbies = sta2.get_local_mbies()
749 if (orig_sta1_mbies.startswith("FAIL") or
750 orig_sta2_mbies.startswith("FAIL") or
751 not res_sta1_mbies.startswith("FAIL") or
752 not res_sta2_mbies.startswith("FAIL")):
753 raise Exception("Failure. MB IEs have not been removed on the stations")
754 except Exception, e:
755 logger.info(e)
756 raise
757 finally:
758 sta2.disconnect_from_external_ap()
759 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
760
761 def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params):
762 """FST STA connecting to FST AP"""
763 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
764 try:
765 orig_sta2_mbies = sta2.get_local_mbies()
766 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
767 sta1.connect(ap1, key_mgmt="NONE",
768 scan_freq=fst_test_common.fst_test_def_freq_a)
769 time.sleep(2)
770 res_sta2_mbies = sta2.get_local_mbies()
771 if res_sta2_mbies == orig_sta2_mbies:
772 raise Exception("Failure. MB IEs have not been updated")
773 except Exception, e:
774 logger.info(e)
775 raise
776 finally:
777 sta1.disconnect()
778 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
779
780 def test_fst_ap_connect_to_fst_sta(dev, apdev, test_params):
781 """FST AP connecting to FST STA"""
782 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
783 try:
784 orig_ap_mbies = ap1.get_local_mbies()
785 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
786 sta1.connect(ap1, key_mgmt="NONE",
787 scan_freq=fst_test_common.fst_test_def_freq_a)
788 time.sleep(2)
789 res_ap_mbies = ap1.get_local_mbies()
790 if res_ap_mbies != orig_ap_mbies:
791 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
792 except Exception, e:
793 logger.info(e)
794 raise
795 finally:
796 sta1.disconnect()
797 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
798
799 def test_fst_ap_connect_to_non_fst_sta(dev, apdev, test_params):
800 """FST AP connecting to non-FST STA"""
801 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
802 try:
803 orig_ap_mbies = ap2.get_local_mbies()
804 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
805 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
806 scan_freq=fst_test_common.fst_test_def_freq_g)
807 time.sleep(2)
808 res_ap_mbies = ap2.get_local_mbies()
809 if res_ap_mbies != orig_ap_mbies:
810 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
811 except Exception, e:
812 logger.info(e)
813 raise
814 finally:
815 fst_module_aux.disconnect_external_sta(dev[0], ap2)
816 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
817
818 def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params):
819 """FST STA 2nd connecting to non-FST AP"""
820 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
821 with HWSimRadio() as (radio, iface):
822 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
823 try:
824 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
825 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
826 time.sleep(2)
827 orig_sta1_mbies = sta1.get_local_mbies()
828 orig_sta2_mbies = sta2.get_local_mbies()
829 vals = sta2.scan()
830 freq = vals['freq']
831 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
832 time.sleep(2)
833 res_sta1_mbies = sta1.get_local_mbies()
834 res_sta2_mbies = sta2.get_local_mbies()
835 if (orig_sta1_mbies.startswith("FAIL") or
836 orig_sta2_mbies.startswith("FAIL") or
837 not res_sta1_mbies.startswith("FAIL") or
838 not res_sta2_mbies.startswith("FAIL")):
839 raise Exception("Failure. MB IEs have not been removed on the stations")
840 except Exception, e:
841 logger.info(e)
842 raise
843 finally:
844 sta1.disconnect()
845 sta2.disconnect_from_external_ap()
846 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
847
848
849 def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params):
850 """FST STA 2nd connecting to FST AP"""
851 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
852 with HWSimRadio() as (radio, iface):
853 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
854 try:
855 vals = sta2.scan()
856 freq = vals['freq']
857 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
858 time.sleep(2)
859 orig_sta1_mbies = sta1.get_local_mbies()
860 orig_sta2_mbies = sta2.get_local_mbies()
861 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
862 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
863 time.sleep(2)
864 res_sta1_mbies = sta1.get_local_mbies()
865 res_sta2_mbies = sta2.get_local_mbies()
866 if (not orig_sta1_mbies.startswith("FAIL") or
867 not orig_sta2_mbies.startswith("FAIL") or
868 not res_sta1_mbies.startswith("FAIL") or
869 not res_sta2_mbies.startswith("FAIL")):
870 raise Exception("Failure. MB IEs should have stayed non-present on the stations")
871 except Exception, e:
872 logger.info(e)
873 raise
874 finally:
875 sta1.disconnect()
876 sta2.disconnect_from_external_ap()
877 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
878
879 def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
880 """FST disconnect 1 of 2 STAs from non-FST AP"""
881 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
882 with HWSimRadio() as (radio, iface):
883 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
884 try:
885 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
886 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
887 vals = sta2.scan()
888 freq = vals['freq']
889 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
890 time.sleep(2)
891 orig_sta1_mbies = sta1.get_local_mbies()
892 orig_sta2_mbies = sta2.get_local_mbies()
893 sta2.disconnect_from_external_ap()
894 time.sleep(2)
895 res_sta1_mbies = sta1.get_local_mbies()
896 res_sta2_mbies = sta2.get_local_mbies()
897 if (not orig_sta1_mbies.startswith("FAIL") or
898 not orig_sta2_mbies.startswith("FAIL") or
899 res_sta1_mbies.startswith("FAIL") or
900 res_sta2_mbies.startswith("FAIL")):
901 raise Exception("Failure. MB IEs haven't reappeared on the stations")
902 except Exception, e:
903 logger.info(e)
904 raise
905 finally:
906 sta1.disconnect()
907 sta2.disconnect_from_external_ap()
908 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
909
910
911 def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params):
912 """FST disconnect 1 of 2 STAs from FST AP"""
913 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
914 with HWSimRadio() as (radio, iface):
915 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
916 try:
917 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
918 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
919 vals = sta2.scan()
920 freq = vals['freq']
921 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
922 time.sleep(2)
923 orig_sta1_mbies = sta1.get_local_mbies()
924 orig_sta2_mbies = sta2.get_local_mbies()
925 sta1.disconnect()
926 time.sleep(2)
927 res_sta1_mbies = sta1.get_local_mbies()
928 res_sta2_mbies = sta2.get_local_mbies()
929 if (not orig_sta1_mbies.startswith("FAIL") or
930 not orig_sta2_mbies.startswith("FAIL") or
931 not res_sta1_mbies.startswith("FAIL") or
932 not res_sta2_mbies.startswith("FAIL")):
933 raise Exception("Failure. MB IEs should have stayed non-present on the stations")
934 except Exception, e:
935 logger.info(e)
936 raise
937 finally:
938 sta1.disconnect()
939 sta2.disconnect_from_external_ap()
940 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
941
942 def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
943 """FST disconnect 2 of 2 STAs from non-FST AP"""
944 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
945 with HWSimRadio() as (radio, iface):
946 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
947 try:
948 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
949 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
950 vals = sta2.scan()
951 freq = vals['freq']
952 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
953 time.sleep(2)
954 sta1.disconnect()
955 time.sleep(2)
956 orig_sta1_mbies = sta1.get_local_mbies()
957 orig_sta2_mbies = sta2.get_local_mbies()
958 sta2.disconnect_from_external_ap()
959 time.sleep(2)
960 res_sta1_mbies = sta1.get_local_mbies()
961 res_sta2_mbies = sta2.get_local_mbies()
962 if (not orig_sta1_mbies.startswith("FAIL") or
963 not orig_sta2_mbies.startswith("FAIL") or
964 res_sta1_mbies.startswith("FAIL") or
965 res_sta2_mbies.startswith("FAIL")):
966 raise Exception("Failure. MB IEs haven't reappeared on the stations")
967 except Exception, e:
968 logger.info(e)
969 raise
970 finally:
971 sta1.disconnect()
972 sta2.disconnect_from_external_ap()
973 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
974
975 def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params):
976 """FST disconnect 2 of 2 STAs from FST AP"""
977 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
978 with HWSimRadio() as (radio, iface):
979 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g"})
980 try:
981 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
982 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
983 vals = sta2.scan()
984 freq = vals['freq']
985 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
986 time.sleep(2)
987 sta2.disconnect_from_external_ap()
988 time.sleep(2)
989 orig_sta1_mbies = sta1.get_local_mbies()
990 orig_sta2_mbies = sta2.get_local_mbies()
991 sta1.disconnect()
992 time.sleep(2)
993 res_sta1_mbies = sta1.get_local_mbies()
994 res_sta2_mbies = sta2.get_local_mbies()
995 if (orig_sta1_mbies.startswith("FAIL") or
996 orig_sta2_mbies.startswith("FAIL") or
997 res_sta1_mbies.startswith("FAIL") or
998 res_sta2_mbies.startswith("FAIL")):
999 raise Exception("Failure. MB IEs should have stayed present on both stations")
1000 # Mandatory part of 8.4.2.140 Multi-band element is 24 bytes = 48 hex chars
1001 basic_sta1_mbies = res_sta1_mbies[0:48] + res_sta1_mbies[60:108]
1002 basic_sta2_mbies = res_sta2_mbies[0:48] + res_sta2_mbies[60:108]
1003 if (basic_sta1_mbies != basic_sta2_mbies):
1004 raise Exception("Failure. Basic MB IEs should have become identical on both stations")
1005 addr_sta1_str = sta1.get_own_mac_address().replace(":", "")
1006 addr_sta2_str = sta2.get_own_mac_address().replace(":", "")
1007 # Mandatory part of 8.4.2.140 Multi-band element is followed by STA MAC Address field (6 bytes = 12 hex chars)
1008 addr_sta1_mbie1 = res_sta1_mbies[48:60]
1009 addr_sta1_mbie2 = res_sta1_mbies[108:120]
1010 addr_sta2_mbie1 = res_sta2_mbies[48:60]
1011 addr_sta2_mbie2 = res_sta2_mbies[108:120]
1012 if (addr_sta1_mbie1 != addr_sta1_mbie2 or
1013 addr_sta1_mbie1 != addr_sta2_str or
1014 addr_sta2_mbie1 != addr_sta2_mbie2 or
1015 addr_sta2_mbie1 != addr_sta1_str):
1016 raise Exception("Failure. STA Address in MB IEs should have been same as the other STA's")
1017 except Exception, e:
1018 logger.info(e)
1019 raise
1020 finally:
1021 sta1.disconnect()
1022 sta2.disconnect_from_external_ap()
1023 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
1024
1025 def test_fst_disconnect_non_fst_sta(dev, apdev, test_params):
1026 """FST disconnect non-FST STA"""
1027 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1028 external_sta_connected = False
1029 try:
1030 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1031 fst_sta1.connect(ap1, key_mgmt="NONE",
1032 scan_freq=fst_test_common.fst_test_def_freq_a)
1033 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1034 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1035 scan_freq=fst_test_common.fst_test_def_freq_g)
1036 external_sta_connected = True
1037 time.sleep(2)
1038 fst_sta1.disconnect()
1039 time.sleep(2)
1040 orig_ap_mbies = ap2.get_local_mbies()
1041 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1042 external_sta_connected = False
1043 time.sleep(2)
1044 res_ap_mbies = ap2.get_local_mbies()
1045 if res_ap_mbies != orig_ap_mbies:
1046 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1047 except Exception, e:
1048 logger.info(e)
1049 raise
1050 finally:
1051 fst_sta1.disconnect()
1052 if external_sta_connected:
1053 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1054 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1055
1056 def test_fst_disconnect_fst_sta(dev, apdev, test_params):
1057 """FST disconnect FST STA"""
1058 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1059 external_sta_connected = False;
1060 try:
1061 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1062 fst_sta1.connect(ap1, key_mgmt="NONE",
1063 scan_freq=fst_test_common.fst_test_def_freq_a)
1064 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1065 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1066 scan_freq=fst_test_common.fst_test_def_freq_g)
1067 external_sta_connected = True
1068 time.sleep(2)
1069 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1070 external_sta_connected = False
1071 time.sleep(2)
1072 orig_ap_mbies = ap2.get_local_mbies()
1073 fst_sta1.disconnect()
1074 time.sleep(2)
1075 res_ap_mbies = ap2.get_local_mbies()
1076 if res_ap_mbies != orig_ap_mbies:
1077 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1078 except Exception, e:
1079 logger.info(e)
1080 raise
1081 finally:
1082 fst_sta1.disconnect()
1083 if external_sta_connected:
1084 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1085 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1086
1087 def test_fst_dynamic_iface_attach(dev, apdev, test_params):
1088 """FST dynamic interface attach"""
1089 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1090 fst_test_common.fst_test_def_chan_a,
1091 fst_test_common.fst_test_def_group,
1092 fst_test_common.fst_test_def_prio_low,
1093 fst_test_common.fst_test_def_llt)
1094 ap1.start()
1095 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1096 fst_test_common.fst_test_def_chan_g,
1097 '', '', '')
1098 ap2.start()
1099
1100 sta1 = fst_module_aux.FstSTA('wlan5',
1101 fst_module_aux.fst_test_common.fst_test_def_group,
1102 fst_test_common.fst_test_def_prio_low,
1103 fst_test_common.fst_test_def_llt)
1104 sta1.start()
1105 sta2 = fst_module_aux.FstSTA('wlan6', '', '', '')
1106 sta2.start()
1107
1108 try:
1109 orig_sta2_mbies = sta2.get_local_mbies()
1110 orig_ap2_mbies = ap2.get_local_mbies()
1111 sta2.send_iface_attach_request(sta2.ifname(),
1112 fst_module_aux.fst_test_common.fst_test_def_group,
1113 '52', '27')
1114 event = sta2.wait_for_iface_event(5)
1115 if event['event_type'] != 'attached':
1116 raise Exception("Failure. Iface was not properly attached")
1117 ap2.send_iface_attach_request(ap2.ifname(),
1118 fst_module_aux.fst_test_common.fst_test_def_group,
1119 '102', '77')
1120 event = ap2.wait_for_iface_event(5)
1121 if event['event_type'] != 'attached':
1122 raise Exception("Failure. Iface was not properly attached")
1123 time.sleep(2)
1124 res_sta2_mbies = sta2.get_local_mbies()
1125 res_ap2_mbies = ap2.get_local_mbies()
1126 sta2.send_iface_detach_request(sta2.ifname())
1127 event = sta2.wait_for_iface_event(5)
1128 if event['event_type'] != 'detached':
1129 raise Exception("Failure. Iface was not properly detached")
1130 ap2.send_iface_detach_request(ap2.ifname())
1131 event = ap2.wait_for_iface_event(5)
1132 if event['event_type'] != 'detached':
1133 raise Exception("Failure. Iface was not properly detached")
1134 if (not orig_sta2_mbies.startswith("FAIL") or
1135 not orig_ap2_mbies.startswith("FAIL") or
1136 res_sta2_mbies.startswith("FAIL") or
1137 res_ap2_mbies.startswith("FAIL")):
1138 raise Exception("Failure. MB IEs should have appeared on the station and on the AP")
1139 except Exception, e:
1140 logger.info(e)
1141 raise
1142 finally:
1143 ap1.stop()
1144 ap2.stop()
1145 sta1.stop()
1146 sta2.stop()
1147
1148 # AP side FST module tests
1149
1150 def test_fst_ap_start_session(dev, apdev, test_params):
1151 """FST AP start session"""
1152 fst_start_session(apdev, test_params, bad_param_none, True)
1153
1154 def test_fst_ap_start_session_no_add_params(dev, apdev, test_params):
1155 """FST AP start session - no add params"""
1156 fst_start_session(apdev, test_params, bad_param_session_add_no_params, True)
1157
1158 def test_fst_ap_start_session_bad_group_id(dev, apdev, test_params):
1159 """FST AP start session - bad group id"""
1160 fst_start_session(apdev, test_params, bad_param_group_id, True)
1161
1162 def test_fst_ap_start_session_no_set_params(dev, apdev, test_params):
1163 """FST AP start session - no set params"""
1164 fst_start_session(apdev, test_params, bad_param_session_set_no_params, True)
1165
1166 def test_fst_ap_start_session_set_unknown_param(dev, apdev, test_params):
1167 """FST AP start session - set unknown param"""
1168 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1169 True)
1170
1171 def test_fst_ap_start_session_bad_session_id(dev, apdev, test_params):
1172 """FST AP start session - bad session id"""
1173 fst_start_session(apdev, test_params, bad_param_session_id, True)
1174
1175 def test_fst_ap_start_session_bad_new_iface(dev, apdev, test_params):
1176 """FST AP start session - bad new iface"""
1177 fst_start_session(apdev, test_params, bad_param_new_iface, True)
1178
1179 def test_fst_ap_start_session_bad_old_iface(dev, apdev, test_params):
1180 """FST AP start session - bad old iface"""
1181 fst_start_session(apdev, test_params, bad_param_old_iface, True)
1182
1183 def test_fst_ap_start_session_negative_llt(dev, apdev, test_params):
1184 """FST AP start session - negative llt"""
1185 fst_start_session(apdev, test_params, bad_param_negative_llt, True)
1186
1187 def test_fst_ap_start_session_zero_llt(dev, apdev, test_params):
1188 """FST AP start session - zero llt"""
1189 fst_start_session(apdev, test_params, bad_param_zero_llt, True)
1190
1191 def test_fst_ap_start_session_llt_too_big(dev, apdev, test_params):
1192 """FST AP start session - llt too large"""
1193 fst_start_session(apdev, test_params, bad_param_llt_too_big, True)
1194
1195 def test_fst_ap_start_session_invalid_peer_addr(dev, apdev, test_params):
1196 """FST AP start session - invalid peer address"""
1197 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1198 'GG:GG:GG:GG:GG:GG')
1199
1200 def test_fst_ap_start_session_multicast_peer_addr(dev, apdev, test_params):
1201 """FST AP start session - multicast peer address"""
1202 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1203 '01:00:11:22:33:44')
1204
1205 def test_fst_ap_start_session_broadcast_peer_addr(dev, apdev, test_params):
1206 """FST AP start session - broadcast peer address"""
1207 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1208 'FF:FF:FF:FF:FF:FF')
1209
1210 def test_fst_ap_initiate_session(dev, apdev, test_params):
1211 """FST AP initiate session"""
1212 fst_initiate_session(apdev, test_params, bad_param_none, True)
1213
1214 def test_fst_ap_initiate_session_no_params(dev, apdev, test_params):
1215 """FST AP initiate session - no params"""
1216 fst_initiate_session(apdev, test_params,
1217 bad_param_session_initiate_no_params, True)
1218
1219 def test_fst_ap_initiate_session_invalid_session_id(dev, apdev, test_params):
1220 """FST AP initiate session - invalid session id"""
1221 fst_initiate_session(apdev, test_params,
1222 bad_param_session_initiate_bad_session_id, True)
1223
1224 def test_fst_ap_initiate_session_no_new_iface(dev, apdev, test_params):
1225 """FST AP initiate session - no new iface"""
1226 fst_initiate_session(apdev, test_params,
1227 bad_param_session_initiate_with_no_new_iface_set, True)
1228
1229 def test_fst_ap_initiate_session_bad_peer_addr(dev, apdev, test_params):
1230 """FST AP initiate session - bad peer address"""
1231 fst_initiate_session(apdev, test_params,
1232 bad_param_session_initiate_with_bad_peer_addr_set,
1233 True)
1234
1235 def test_fst_ap_initiate_session_request_with_bad_stie(dev, apdev, test_params):
1236 """FST AP initiate session - request with bad stie"""
1237 fst_initiate_session(apdev, test_params,
1238 bad_param_session_initiate_request_with_bad_stie, True)
1239
1240 def test_fst_ap_initiate_session_response_with_reject(dev, apdev, test_params):
1241 """FST AP initiate session - response with reject"""
1242 fst_initiate_session(apdev, test_params,
1243 bad_param_session_initiate_response_with_reject, True)
1244
1245 def test_fst_ap_initiate_session_response_with_bad_stie(dev, apdev,
1246 test_params):
1247 """FST AP initiate session - response with bad stie"""
1248 fst_initiate_session(apdev, test_params,
1249 bad_param_session_initiate_response_with_bad_stie,
1250 True)
1251
1252 def test_fst_ap_initiate_session_response_with_zero_llt(dev, apdev,
1253 test_params):
1254 """FST AP initiate session - zero llt"""
1255 fst_initiate_session(apdev, test_params,
1256 bad_param_session_initiate_response_with_zero_llt,
1257 True)
1258
1259 def test_fst_ap_initiate_session_stt_no_response(dev, apdev, test_params):
1260 """FST AP initiate session - stt no response"""
1261 fst_initiate_session(apdev, test_params,
1262 bad_param_session_initiate_stt_no_response, True)
1263
1264 def test_fst_ap_initiate_session_concurrent_setup_request(dev, apdev,
1265 test_params):
1266 """FST AP initiate session - concurrent setup request"""
1267 fst_initiate_session(apdev, test_params,
1268 bad_param_session_initiate_concurrent_setup_request,
1269 True)
1270
1271 def test_fst_ap_session_request_with_no_session(dev, apdev, test_params):
1272 """FST AP session request with no session"""
1273 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1274 True)
1275
1276 def test_fst_ap_session_response_accept_with_no_session(dev, apdev,
1277 test_params):
1278 """FST AP session response accept with no session"""
1279 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1280 True, "accept")
1281
1282 def test_fst_ap_session_response_reject_with_no_session(dev, apdev,
1283 test_params):
1284 """FST AP session response reject with no session"""
1285 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1286 True, "reject")
1287
1288 def test_fst_ap_ack_request_with_no_session(dev, apdev, test_params):
1289 """FST AP ack request with no session"""
1290 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, True)
1291
1292 def test_fst_ap_ack_response_with_no_session(dev, apdev, test_params):
1293 """FST AP ack response with no session"""
1294 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response, True)
1295
1296 def test_fst_ap_tear_down_response_with_no_session(dev, apdev, test_params):
1297 """FST AP tear down response with no session"""
1298 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, True)
1299
1300 def test_fst_ap_transfer_session(dev, apdev, test_params):
1301 """FST AP transfer session"""
1302 fst_transfer_session(apdev, test_params, bad_param_none, True)
1303
1304 def test_fst_ap_transfer_session_no_params(dev, apdev, test_params):
1305 """FST AP transfer session - no params"""
1306 fst_transfer_session(apdev, test_params,
1307 bad_param_session_transfer_no_params, True)
1308
1309 def test_fst_ap_transfer_session_bad_session_id(dev, apdev, test_params):
1310 """FST AP transfer session - bad session id"""
1311 fst_transfer_session(apdev, test_params,
1312 bad_param_session_transfer_bad_session_id, True)
1313
1314 def test_fst_ap_transfer_session_setup_skipped(dev, apdev, test_params):
1315 """FST AP transfer session - setup skipped"""
1316 fst_transfer_session(apdev, test_params,
1317 bad_param_session_transfer_setup_skipped, True)
1318
1319 def test_fst_ap_ack_request_with_session_not_set_up(dev, apdev, test_params):
1320 """FST AP ack request with session not set up"""
1321 fst_bad_transfer(apdev, test_params,
1322 bad_scenario_ack_req_session_not_set_up, True)
1323
1324 def test_fst_ap_ack_request_with_session_not_established_init_side(dev, apdev,
1325 test_params):
1326 """FST AP ack request with session not established init side"""
1327 fst_bad_transfer(apdev, test_params,
1328 bad_scenario_ack_req_session_not_established_init_side,
1329 True)
1330
1331 def test_fst_ap_ack_request_with_session_not_established_resp_side(dev, apdev,
1332 test_params):
1333 """FST AP ack request with session not established resp side"""
1334 fst_bad_transfer(apdev, test_params,
1335 bad_scenario_ack_req_session_not_established_resp_side,
1336 True)
1337
1338 def test_fst_ap_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1339 """FST AP ack request with bad fsts id"""
1340 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id, True)
1341
1342 def test_fst_ap_ack_response_with_session_not_set_up(dev, apdev, test_params):
1343 """FST AP ack response with session not set up"""
1344 fst_bad_transfer(apdev, test_params,
1345 bad_scenario_ack_resp_session_not_set_up, True)
1346
1347 def test_fst_ap_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1348 """FST AP ack response with session not established init side"""
1349 fst_bad_transfer(apdev, test_params,
1350 bad_scenario_ack_resp_session_not_established_init_side,
1351 True)
1352
1353 def test_fst_ap_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1354 """FST AP ack response with session not established resp side"""
1355 fst_bad_transfer(apdev, test_params,
1356 bad_scenario_ack_resp_session_not_established_resp_side,
1357 True)
1358
1359 def test_fst_ap_ack_response_with_no_ack_request(dev, apdev, test_params):
1360 """FST AP ack response with no ack request"""
1361 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req, True)
1362
1363 def test_fst_ap_tear_down_session(dev, apdev, test_params):
1364 """FST AP tear down session"""
1365 fst_tear_down_session(apdev, test_params, bad_param_none, True)
1366
1367 def test_fst_ap_tear_down_session_no_params(dev, apdev, test_params):
1368 """FST AP tear down session - no params"""
1369 fst_tear_down_session(apdev, test_params,
1370 bad_param_session_teardown_no_params, True)
1371
1372 def test_fst_ap_tear_down_session_bad_session_id(dev, apdev, test_params):
1373 """FST AP tear down session - bad session id"""
1374 fst_tear_down_session(apdev, test_params,
1375 bad_param_session_teardown_bad_session_id, True)
1376
1377 def test_fst_ap_tear_down_session_setup_skipped(dev, apdev, test_params):
1378 """FST AP tear down session - setup skipped"""
1379 fst_tear_down_session(apdev, test_params,
1380 bad_param_session_teardown_setup_skipped, True)
1381
1382 def test_fst_ap_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1383 """FST AP tear down session - bad fsts id"""
1384 fst_tear_down_session(apdev, test_params,
1385 bad_param_session_teardown_bad_fsts_id, True)
1386
1387 def test_fst_ap_remove_session_not_established(dev, apdev, test_params):
1388 """FST AP remove session - not established"""
1389 fst_remove_session(apdev, test_params,
1390 remove_scenario_non_established_session, True)
1391
1392 def test_fst_ap_remove_session_established(dev, apdev, test_params):
1393 """FST AP remove session - established"""
1394 fst_remove_session(apdev, test_params,
1395 remove_scenario_established_session, True)
1396
1397 def test_fst_ap_remove_session_no_params(dev, apdev, test_params):
1398 """FST AP remove session - no params"""
1399 fst_remove_session(apdev, test_params, remove_scenario_no_params, True)
1400
1401 def test_fst_ap_remove_session_bad_session_id(dev, apdev, test_params):
1402 """FST AP remove session - bad session id"""
1403 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id, True)
1404
1405 def test_fst_ap_ctrl_iface(dev, apdev, test_params):
1406 """FST control interface behavior"""
1407 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1408 try:
1409 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1410 initiator = ap1
1411 responder = sta1
1412 initiator.add_peer(responder, None)
1413 initiator.set_fst_parameters(group_id=None)
1414 sid = initiator.add_session()
1415 res = initiator.get_session_params(sid)
1416 logger.info("Initial session params:\n" + str(res))
1417 if res['state'] != 'INITIAL':
1418 raise Exception("Unexpected state: " + res['state'])
1419 initiator.set_fst_parameters(llt=None)
1420 initiator.configure_session(sid, ap2.ifname(), None)
1421 res = initiator.get_session_params(sid)
1422 logger.info("Session params after configuration:\n" + str(res))
1423 res = initiator.iface_peers(initiator.ifname())
1424 logger.info("Interface peers: " + str(res))
1425 if len(res) != 1:
1426 raise Exception("Unexpected number of peers")
1427 res = initiator.get_peer_mbies(initiator.ifname(),
1428 initiator.get_new_peer_addr())
1429 logger.info("Peer MB IEs: " + str(res))
1430 res = initiator.list_ifaces()
1431 logger.info("Interfaces: " + str(res))
1432 if len(res) != 2:
1433 raise Exception("Unexpected number of interfaces")
1434 res = initiator.list_groups()
1435 logger.info("Groups: " + str(res))
1436 if len(res) != 1:
1437 raise Exception("Unexpected number of groups")
1438
1439 tests = [ "LIST_IFACES unknown",
1440 "LIST_IFACES unknown2",
1441 "SESSION_GET 12345678",
1442 "SESSION_SET " + sid + " unknown=foo",
1443 "SESSION_RESPOND 12345678 foo",
1444 "SESSION_RESPOND " + sid,
1445 "SESSION_RESPOND " + sid + " foo",
1446 "TEST_REQUEST foo",
1447 "GET_PEER_MBIES",
1448 "GET_PEER_MBIES ",
1449 "GET_PEER_MBIES unknown",
1450 "GET_PEER_MBIES unknown unknown",
1451 "GET_PEER_MBIES unknown " + initiator.get_new_peer_addr(),
1452 "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff",
1453 "IFACE_PEERS",
1454 "IFACE_PEERS ",
1455 "IFACE_PEERS unknown",
1456 "IFACE_PEERS unknown unknown",
1457 "IFACE_PEERS " + initiator.fst_group,
1458 "IFACE_PEERS " + initiator.fst_group + " unknown" ]
1459 for t in tests:
1460 if "FAIL" not in initiator.grequest("FST-MANAGER " + t):
1461 raise Exception("Unexpected response for invalid FST-MANAGER command " + t)
1462 if "UNKNOWN FST COMMAND" not in initiator.grequest("FST-MANAGER unknown"):
1463 raise Exception("Unexpected response for unknown FST-MANAGER command")
1464
1465 tests = [ "FST-DETACH", "FST-DETACH ", "FST-DETACH unknown",
1466 "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown",
1467 "FST-ATTACH unknown unknown" ]
1468 for t in tests:
1469 if "FAIL" not in initiator.grequest(t):
1470 raise Exception("Unexpected response for invalid command " + t)
1471
1472 try:
1473 # Trying to add same interface again needs to fail.
1474 ap1.send_iface_attach_request(ap1.iface, ap1.fst_group,
1475 ap1.fst_llt, ap1.fst_pri)
1476 raise Exception("Duplicate FST-ATTACH succeeded")
1477 except Exception, e:
1478 if not str(e).startswith("Cannot attach"):
1479 raise
1480 finally:
1481 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1482 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1483
1484 def test_fst_ap_start_session_oom(dev, apdev, test_params):
1485 """FST AP setup failing due to OOM"""
1486 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1487 fst_test_common.fst_test_def_chan_a,
1488 fst_test_common.fst_test_def_group,
1489 fst_test_common.fst_test_def_prio_low,
1490 fst_test_common.fst_test_def_llt)
1491 ap1.start()
1492 with alloc_fail(ap1, 1, "fst_iface_create"):
1493 ap2_started = False
1494 try:
1495 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1496 fst_test_common.fst_test_def_chan_g,
1497 fst_test_common.fst_test_def_group,
1498 fst_test_common.fst_test_def_prio_high,
1499 fst_test_common.fst_test_def_llt)
1500 try:
1501 # This will fail in fst_iface_create() OOM
1502 ap2.start()
1503 except:
1504 pass
1505 finally:
1506 ap1.stop()
1507 try:
1508 ap2.stop()
1509 except:
1510 pass
1511
1512 # STA side FST module tests
1513
1514 def test_fst_sta_start_session(dev, apdev, test_params):
1515 """FST STA start session"""
1516 fst_start_session(apdev, test_params, bad_param_none, False)
1517
1518 def test_fst_sta_start_session_no_add_params(dev, apdev, test_params):
1519 """FST STA start session - no add params"""
1520 fst_start_session(apdev, test_params, bad_param_session_add_no_params,
1521 False)
1522
1523 def test_fst_sta_start_session_bad_group_id(dev, apdev, test_params):
1524 """FST STA start session - bad group id"""
1525 fst_start_session(apdev, test_params, bad_param_group_id, False)
1526
1527 def test_fst_sta_start_session_no_set_params(dev, apdev, test_params):
1528 """FST STA start session - no set params"""
1529 fst_start_session(apdev, test_params, bad_param_session_set_no_params,
1530 False)
1531
1532 def test_fst_sta_start_session_set_unknown_param(dev, apdev, test_params):
1533 """FST STA start session - set unknown param"""
1534 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1535 False)
1536
1537 def test_fst_sta_start_session_bad_session_id(dev, apdev, test_params):
1538 """FST STA start session - bad session id"""
1539 fst_start_session(apdev, test_params, bad_param_session_id, False)
1540
1541 def test_fst_sta_start_session_bad_new_iface(dev, apdev, test_params):
1542 """FST STA start session - bad new iface"""
1543 fst_start_session(apdev, test_params, bad_param_new_iface, False)
1544
1545 def test_fst_sta_start_session_bad_old_iface(dev, apdev, test_params):
1546 """FST STA start session - bad old iface"""
1547 fst_start_session(apdev, test_params, bad_param_old_iface, False)
1548
1549 def test_fst_sta_start_session_negative_llt(dev, apdev, test_params):
1550 """FST STA start session - negative llt"""
1551 fst_start_session(apdev, test_params, bad_param_negative_llt, False)
1552
1553 def test_fst_sta_start_session_zero_llt(dev, apdev, test_params):
1554 """FST STA start session - zero llt"""
1555 fst_start_session(apdev, test_params, bad_param_zero_llt, False)
1556
1557 def test_fst_sta_start_session_llt_too_big(dev, apdev, test_params):
1558 """FST STA start session - llt too large"""
1559 fst_start_session(apdev, test_params, bad_param_llt_too_big, False)
1560
1561 def test_fst_sta_start_session_invalid_peer_addr(dev, apdev, test_params):
1562 """FST STA start session - invalid peer address"""
1563 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1564 'GG:GG:GG:GG:GG:GG')
1565
1566 def test_fst_sta_start_session_multicast_peer_addr(dev, apdev, test_params):
1567 """FST STA start session - multicast peer address"""
1568 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1569 '11:00:11:22:33:44')
1570
1571 def test_fst_sta_start_session_broadcast_peer_addr(dev, apdev, test_params):
1572 """FST STA start session - broadcast peer addr"""
1573 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1574 'FF:FF:FF:FF:FF:FF')
1575
1576 def test_fst_sta_initiate_session(dev, apdev, test_params):
1577 """FST STA initiate session"""
1578 fst_initiate_session(apdev, test_params, bad_param_none, False)
1579
1580 def test_fst_sta_initiate_session_no_params(dev, apdev, test_params):
1581 """FST STA initiate session - no params"""
1582 fst_initiate_session(apdev, test_params,
1583 bad_param_session_initiate_no_params, False)
1584
1585 def test_fst_sta_initiate_session_invalid_session_id(dev, apdev, test_params):
1586 """FST STA initiate session - invalid session id"""
1587 fst_initiate_session(apdev, test_params,
1588 bad_param_session_initiate_bad_session_id, False)
1589
1590 def test_fst_sta_initiate_session_no_new_iface(dev, apdev, test_params):
1591 """FST STA initiate session - no new iface"""
1592 fst_initiate_session(apdev, test_params,
1593 bad_param_session_initiate_with_no_new_iface_set,
1594 False)
1595
1596 def test_fst_sta_initiate_session_bad_peer_addr(dev, apdev, test_params):
1597 """FST STA initiate session - bad peer address"""
1598 fst_initiate_session(apdev, test_params,
1599 bad_param_session_initiate_with_bad_peer_addr_set,
1600 False)
1601
1602 def test_fst_sta_initiate_session_request_with_bad_stie(dev, apdev,
1603 test_params):
1604 """FST STA initiate session - request with bad stie"""
1605 fst_initiate_session(apdev, test_params,
1606 bad_param_session_initiate_request_with_bad_stie,
1607 False)
1608
1609 def test_fst_sta_initiate_session_response_with_reject(dev, apdev, test_params):
1610 """FST STA initiate session - response with reject"""
1611 fst_initiate_session(apdev, test_params, bad_param_session_initiate_response_with_reject, False)
1612
1613 def test_fst_sta_initiate_session_response_with_bad_stie(dev, apdev, test_params):
1614 """FST STA initiate session - response with bad stie"""
1615 fst_initiate_session(apdev, test_params,
1616 bad_param_session_initiate_response_with_bad_stie,
1617 False)
1618
1619 def test_fst_sta_initiate_session_response_with_zero_llt(dev, apdev,
1620 test_params):
1621 """FST STA initiate session - response with zero llt"""
1622 fst_initiate_session(apdev, test_params,
1623 bad_param_session_initiate_response_with_zero_llt,
1624 False)
1625
1626 def test_fst_sta_initiate_session_stt_no_response(dev, apdev, test_params):
1627 """FST STA initiate session - stt no response"""
1628 fst_initiate_session(apdev, test_params,
1629 bad_param_session_initiate_stt_no_response, False)
1630
1631 def test_fst_sta_initiate_session_concurrent_setup_request(dev, apdev,
1632 test_params):
1633 """FST STA initiate session - concurrent setup request"""
1634 fst_initiate_session(apdev, test_params,
1635 bad_param_session_initiate_concurrent_setup_request,
1636 False)
1637
1638 def test_fst_sta_session_request_with_no_session(dev, apdev, test_params):
1639 """FST STA session request with no session"""
1640 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1641 False)
1642
1643 def test_fst_sta_session_response_accept_with_no_session(dev, apdev,
1644 test_params):
1645 """FST STA session response accept with no session"""
1646 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1647 False, "accept")
1648
1649 def test_fst_sta_session_response_reject_with_no_session(dev, apdev,
1650 test_params):
1651 """FST STA session response reject with no session"""
1652 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1653 False, "reject")
1654
1655 def test_fst_sta_ack_request_with_no_session(dev, apdev, test_params):
1656 """FST STA ack request with no session"""
1657 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, False)
1658
1659 def test_fst_sta_ack_response_with_no_session(dev, apdev, test_params):
1660 """FST STA ack response with no session"""
1661 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response,
1662 False)
1663
1664 def test_fst_sta_tear_down_response_with_no_session(dev, apdev, test_params):
1665 """FST STA tear down response with no session"""
1666 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, False)
1667
1668 def test_fst_sta_transfer_session(dev, apdev, test_params):
1669 """FST STA transfer session"""
1670 fst_transfer_session(apdev, test_params, bad_param_none, False)
1671
1672 def test_fst_sta_transfer_session_no_params(dev, apdev, test_params):
1673 """FST STA transfer session - no params"""
1674 fst_transfer_session(apdev, test_params,
1675 bad_param_session_transfer_no_params, False)
1676
1677 def test_fst_sta_transfer_session_bad_session_id(dev, apdev, test_params):
1678 """FST STA transfer session - bad session id"""
1679 fst_transfer_session(apdev, test_params,
1680 bad_param_session_transfer_bad_session_id, False)
1681
1682 def test_fst_sta_transfer_session_setup_skipped(dev, apdev, test_params):
1683 """FST STA transfer session - setup skipped"""
1684 fst_transfer_session(apdev, test_params,
1685 bad_param_session_transfer_setup_skipped, False)
1686
1687 def test_fst_sta_ack_request_with_session_not_set_up(dev, apdev, test_params):
1688 """FST STA ack request with session not set up"""
1689 fst_bad_transfer(apdev, test_params,
1690 bad_scenario_ack_req_session_not_set_up, False)
1691
1692 def test_fst_sta_ack_request_with_session_not_established_init_side(dev, apdev, test_params):
1693 """FST STA ack request with session not established init side"""
1694 fst_bad_transfer(apdev, test_params,
1695 bad_scenario_ack_req_session_not_established_init_side,
1696 False)
1697
1698 def test_fst_sta_ack_request_with_session_not_established_resp_side(dev, apdev, test_params):
1699 """FST STA ack request with session not established resp side"""
1700 fst_bad_transfer(apdev, test_params,
1701 bad_scenario_ack_req_session_not_established_resp_side,
1702 False)
1703
1704 def test_fst_sta_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1705 """FST STA ack request with bad fsts id"""
1706 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id,
1707 False)
1708
1709 def test_fst_sta_ack_response_with_session_not_set_up(dev, apdev, test_params):
1710 """FST STA ack response with session not set up"""
1711 fst_bad_transfer(apdev, test_params,
1712 bad_scenario_ack_resp_session_not_set_up, False)
1713
1714 def test_fst_sta_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1715 """FST STA ack response with session not established init side"""
1716 fst_bad_transfer(apdev, test_params,
1717 bad_scenario_ack_resp_session_not_established_init_side,
1718 False)
1719
1720 def test_fst_sta_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1721 """FST STA ack response with session not established resp side"""
1722 fst_bad_transfer(apdev, test_params,
1723 bad_scenario_ack_resp_session_not_established_resp_side,
1724 False)
1725
1726 def test_fst_sta_ack_response_with_no_ack_request(dev, apdev, test_params):
1727 """FST STA ack response with no ack request"""
1728 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req,
1729 False)
1730
1731 def test_fst_sta_tear_down_session(dev, apdev, test_params):
1732 """FST STA tear down session"""
1733 fst_tear_down_session(apdev, test_params, bad_param_none, False)
1734
1735 def test_fst_sta_tear_down_session_no_params(dev, apdev, test_params):
1736 """FST STA tear down session - no params"""
1737 fst_tear_down_session(apdev, test_params,
1738 bad_param_session_teardown_no_params, False)
1739
1740 def test_fst_sta_tear_down_session_bad_session_id(dev, apdev, test_params):
1741 """FST STA tear down session - bad session id"""
1742 fst_tear_down_session(apdev, test_params,
1743 bad_param_session_teardown_bad_session_id, False)
1744
1745 def test_fst_sta_tear_down_session_setup_skipped(dev, apdev, test_params):
1746 """FST STA tear down session - setup skipped"""
1747 fst_tear_down_session(apdev, test_params,
1748 bad_param_session_teardown_setup_skipped, False)
1749
1750 def test_fst_sta_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1751 """FST STA tear down session - bad fsts id"""
1752 fst_tear_down_session(apdev, test_params,
1753 bad_param_session_teardown_bad_fsts_id, False)
1754
1755 def test_fst_sta_remove_session_not_established(dev, apdev, test_params):
1756 """FST STA tear down session - not established"""
1757 fst_remove_session(apdev, test_params,
1758 remove_scenario_non_established_session, False)
1759
1760 def test_fst_sta_remove_session_established(dev, apdev, test_params):
1761 """FST STA remove session - established"""
1762 fst_remove_session(apdev, test_params,
1763 remove_scenario_established_session, False)
1764
1765 def test_fst_sta_remove_session_no_params(dev, apdev, test_params):
1766 """FST STA remove session - no params"""
1767 fst_remove_session(apdev, test_params, remove_scenario_no_params, False)
1768
1769 def test_fst_sta_remove_session_bad_session_id(dev, apdev, test_params):
1770 """FST STA remove session - bad session id"""
1771 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id,
1772 False)