1 # FST functionality tests
2 # Copyright (c) 2015, Qualcomm Atheros, Inc.
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
8 logger = logging.getLogger()
15 from hwsim import HWSimRadio
17 import fst_test_common
19 from utils import alloc_fail
21 #enum - bad parameter types
23 bad_param_session_add_no_params = 1
24 bad_param_group_id = 2
25 bad_param_session_set_no_params = 3
26 bad_param_session_set_unknown_param = 4
27 bad_param_session_id = 5
28 bad_param_old_iface = 6
29 bad_param_new_iface = 7
30 bad_param_negative_llt = 8
31 bad_param_zero_llt = 9
32 bad_param_llt_too_big = 10
33 bad_param_llt_nan = 11
34 bad_param_peer_addr = 12
35 bad_param_session_initiate_no_params = 13
36 bad_param_session_initiate_bad_session_id = 14
37 bad_param_session_initiate_with_no_new_iface_set = 15
38 bad_param_session_initiate_with_bad_peer_addr_set = 16
39 bad_param_session_initiate_request_with_bad_stie = 17
40 bad_param_session_initiate_response_with_reject = 18
41 bad_param_session_initiate_response_with_bad_stie = 19
42 bad_param_session_initiate_response_with_zero_llt = 20
43 bad_param_session_initiate_stt_no_response = 21
44 bad_param_session_initiate_concurrent_setup_request = 22
45 bad_param_session_transfer_no_params = 23
46 bad_param_session_transfer_bad_session_id = 24
47 bad_param_session_transfer_setup_skipped = 25
48 bad_param_session_teardown_no_params = 26
49 bad_param_session_teardown_bad_session_id = 27
50 bad_param_session_teardown_setup_skipped = 28
51 bad_param_session_teardown_bad_fsts_id = 29
53 bad_param_names = ("None",
54 "No params passed to session add",
56 "No params passed to session set",
57 "Unknown param passed to session set",
64 "LLT is not a number",
66 "No params passed to session initiate",
68 "No new_iface was set",
70 "Request with bad st ie",
71 "Response with reject",
72 "Response with bad st ie",
73 "Response with zero llt",
75 "Concurrent setup request",
76 "No params passed to session transfer",
78 "Session setup skipped",
79 "No params passed to session teardown",
81 "Session setup skipped",
84 def fst_start_session(apdev, test_params, bad_param_type, start_on_ap,
86 """This function makes the necessary preparations and the adds and sets a
87 session using either correct or incorrect parameters depending on the value
88 of bad_param_type. If the call ends as expected (with session being
89 successfully added and set in case of correct parameters or with the
90 expected exception in case of incorrect parameters), the function silently
91 exits. Otherwise, it throws an exception thus failing the test."""
93 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
94 bad_parameter_detected = False
95 exception_already_raised = False
97 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
101 new_iface = ap2.ifname()
102 new_peer_addr = ap2.get_actual_peer_addr()
106 new_iface = sta2.ifname()
107 new_peer_addr = sta2.get_actual_peer_addr()
108 initiator.add_peer(responder, peer_addr, new_peer_addr)
110 if bad_param_type == bad_param_group_id:
112 elif bad_param_type == bad_param_session_add_no_params:
114 initiator.set_fst_parameters(group_id=group_id)
115 sid = initiator.add_session()
116 if bad_param_type == bad_param_session_set_no_params:
117 res = initiator.set_session_param(None)
118 if not res.startswith("OK"):
119 raise Exception("Session set operation failed")
120 elif bad_param_type == bad_param_session_set_unknown_param:
121 res = initiator.set_session_param("bad_param=1")
122 if not res.startswith("OK"):
123 raise Exception("Session set operation failed")
125 if bad_param_type == bad_param_session_initiate_with_no_new_iface_set:
127 elif bad_param_type == bad_param_new_iface:
129 old_iface = None if bad_param_type != bad_param_old_iface else 'wlan12'
131 if bad_param_type == bad_param_negative_llt:
133 elif bad_param_type == bad_param_zero_llt:
135 elif bad_param_type == bad_param_llt_too_big:
136 llt = '4294967296' #0x100000000
137 elif bad_param_type == bad_param_llt_nan:
139 elif bad_param_type == bad_param_session_id:
141 initiator.set_fst_parameters(llt=llt)
142 initiator.configure_session(sid, new_iface, old_iface)
144 if e.args[0].startswith("Cannot add FST session with groupid"):
145 if bad_param_type == bad_param_group_id or bad_param_type == bad_param_session_add_no_params:
146 bad_parameter_detected = True
147 elif e.args[0].startswith("Cannot set FST session new_ifname:"):
148 if bad_param_type == bad_param_new_iface:
149 bad_parameter_detected = True
150 elif e.args[0].startswith("Session set operation failed"):
151 if (bad_param_type == bad_param_session_set_no_params or
152 bad_param_type == bad_param_session_set_unknown_param):
153 bad_parameter_detected = True
154 elif e.args[0].startswith("Cannot set FST session old_ifname:"):
155 if (bad_param_type == bad_param_old_iface or
156 bad_param_type == bad_param_session_id or
157 bad_param_type == bad_param_session_set_no_params):
158 bad_parameter_detected = True
159 elif e.args[0].startswith("Cannot set FST session llt:"):
160 if (bad_param_type == bad_param_negative_llt or
161 bad_param_type == bad_param_llt_too_big or
162 bad_param_type == bad_param_llt_nan):
163 bad_parameter_detected = True
164 elif e.args[0].startswith("Cannot set FST session peer address:"):
165 if bad_param_type == bad_param_peer_addr:
166 bad_parameter_detected = True
167 if not bad_parameter_detected:
168 # The exception was unexpected
170 exception_already_raised = True
173 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
174 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
175 if not exception_already_raised:
176 if bad_parameter_detected:
177 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
179 if bad_param_type == bad_param_none or bad_param_type == bad_param_zero_llt:
180 logger.info("Success. Session added and set")
183 if bad_param_type == bad_param_peer_addr:
184 exception_text = "Failure. Bad parameter was not detected (Peer address == %s)" % ap1.get_new_peer_addr()
186 exception_text = "Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type]
187 raise Exception(exception_text)
189 print "Failure. Unexpected exception"
191 def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap):
192 """This function makes the necessary preparations and then adds, sets and
193 initiates a session using either correct or incorrect parameters at each
194 stage depending on the value of bad_param_type. If the call ends as expected
195 (with session being successfully added, set and initiated in case of correct
196 parameters or with the expected exception in case of incorrect parameters),
197 the function silently exits. Otherwise it throws an exception thus failing
199 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
200 bad_parameter_detected = False
201 exception_already_raised = False
203 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
204 # This call makes sure FstHostapd singleton object is created and, as a
205 # result, the global control interface is registered (this is done from
207 ap1.get_global_instance()
211 new_iface = ap2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
212 new_peer_addr = ap2.get_actual_peer_addr()
213 resp_newif = sta2.ifname()
217 new_iface = sta2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
218 new_peer_addr = sta2.get_actual_peer_addr()
219 resp_newif = ap2.ifname()
220 peeraddr = None if bad_param_type != bad_param_session_initiate_with_bad_peer_addr_set else '10:DE:AD:DE:AD:11'
221 initiator.add_peer(responder, peeraddr, new_peer_addr)
222 if bad_param_type == bad_param_session_initiate_response_with_zero_llt:
223 initiator.set_fst_parameters(llt='0')
224 sid = initiator.add_session()
225 initiator.configure_session(sid, new_iface)
226 if bad_param_type == bad_param_session_initiate_no_params:
228 elif bad_param_type == bad_param_session_initiate_bad_session_id:
230 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
231 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
232 initiator.send_test_session_setup_request(str(actual_fsts_id), "bad_new_band")
233 responder.wait_for_session_event(5)
234 elif bad_param_type == bad_param_session_initiate_response_with_reject:
235 initiator.send_session_setup_request(sid)
236 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
237 setup_event = responder.wait_for_session_event(5, [],
239 if not 'id' in setup_event:
240 raise Exception("No session id in FST setup event")
241 responder.send_session_setup_response(str(setup_event['id']),
243 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
244 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_REJECT":
245 raise Exception("Response with reject not handled as expected")
246 bad_parameter_detected = True
247 elif bad_param_type == bad_param_session_initiate_response_with_bad_stie:
248 initiator.send_session_setup_request(sid)
249 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
250 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
251 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
252 responder.send_test_session_setup_response(str(actual_fsts_id),
253 "accept", "bad_new_band")
254 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
255 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_ERROR_PARAMS":
256 raise Exception("Response with bad STIE not handled as expected")
257 bad_parameter_detected = True
258 elif bad_param_type == bad_param_session_initiate_response_with_zero_llt:
259 initiator.initiate_session(sid, "accept")
260 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
261 if event['new_state'] != "TRANSITION_DONE":
262 raise Exception("Response reception for a session with llt=0 not handled as expected")
263 bad_parameter_detected = True
264 elif bad_param_type == bad_param_session_initiate_stt_no_response:
265 initiator.send_session_setup_request(sid)
266 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
267 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
268 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
269 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
270 raise Exception("No response scenario not handled as expected")
271 bad_parameter_detected = True
272 elif bad_param_type == bad_param_session_initiate_concurrent_setup_request:
273 responder.add_peer(initiator)
274 resp_sid = responder.add_session()
275 responder.configure_session(resp_sid, resp_newif)
276 initiator.send_session_setup_request(sid)
277 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
278 responder.send_test_session_setup_request(str(actual_fsts_id))
279 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
280 initiator_addr = initiator.get_own_mac_address()
281 responder_addr = responder.get_own_mac_address()
282 if initiator_addr < responder_addr:
283 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
284 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_SETUP":
285 raise Exception("Concurrent setup scenario not handled as expected")
286 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SETUP"])
287 # The incoming setup request received by the initiator has
288 # priority over the one sent previously by the initiator itself
289 # because the initiator's MAC address is numerically lower than
290 # the one of the responder. Thus, the initiator should generate
291 # an FST_SETUP event.
293 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
294 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
295 raise Exception("Concurrent setup scenario not handled as expected")
296 # The incoming setup request was dropped at the initiator
297 # because its MAC address is numerically bigger than the one of
298 # the responder. Thus, the initiator continue to wait for a
299 # setup response until the STT event fires.
300 bad_parameter_detected = True
302 initiator.initiate_session(sid, "accept")
304 if e.args[0].startswith("Cannot initiate fst session"):
305 if bad_param_type != bad_param_none:
306 bad_parameter_detected = True
307 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
308 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
309 bad_parameter_detected = True
310 if not bad_parameter_detected:
311 #The exception was unexpected
313 exception_already_raised = True
316 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
317 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
318 if not exception_already_raised:
319 if bad_parameter_detected:
320 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
322 if bad_param_type == bad_param_none:
323 logger.info("Success. Session initiated")
325 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
327 print "Failure. Unexpected exception"
329 def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap,
331 """This function makes the necessary preparations and then adds, sets,
332 initiates and attempts to transfer a session using either correct or
333 incorrect parameters at each stage depending on the value of bad_param_type.
334 If the call ends as expected the function silently exits. Otherwise, it
335 throws an exception thus failing the test."""
336 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev, rsn=rsn)
337 bad_parameter_detected = False
338 exception_already_raised = False
340 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2, rsn=rsn)
341 # This call makes sure FstHostapd singleton object is created and, as a
342 # result, the global control interface is registered (this is done from
344 ap1.get_global_instance()
348 new_iface = ap2.ifname()
349 new_peer_addr = ap2.get_actual_peer_addr()
353 new_iface = sta2.ifname()
354 new_peer_addr = sta2.get_actual_peer_addr()
355 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
356 sid = initiator.add_session()
357 initiator.configure_session(sid, new_iface)
358 if bad_param_type != bad_param_session_transfer_setup_skipped:
359 initiator.initiate_session(sid, "accept")
360 if bad_param_type == bad_param_session_transfer_no_params:
362 elif bad_param_type == bad_param_session_transfer_bad_session_id:
364 initiator.transfer_session(sid)
366 if e.args[0].startswith("Cannot transfer fst session"):
367 if bad_param_type != bad_param_none:
368 bad_parameter_detected = True
369 if not bad_parameter_detected:
370 # The exception was unexpected
372 exception_already_raised = True
375 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
376 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
377 if not exception_already_raised:
378 if bad_parameter_detected:
379 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
381 if bad_param_type == bad_param_none:
382 logger.info("Success. Session transferred")
384 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
386 print "Failure. Unexpected exception"
389 def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap):
390 """This function makes the necessary preparations and then adds, sets, and
391 initiates a session. It then issues a tear down command using either
392 correct or incorrect parameters at each stage. If the call ends as expected,
393 the function silently exits. Otherwise, it throws an exception thus failing
395 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
396 bad_parameter_detected = False
397 exception_already_raised = False
399 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
400 # This call makes sure FstHostapd singleton object is created and, as a
401 # result, the global control interface is registered (this is done from
403 ap1.get_global_instance()
407 new_iface = ap2.ifname()
408 new_peer_addr = ap2.get_actual_peer_addr()
412 new_iface = sta2.ifname()
413 new_peer_addr = sta2.get_actual_peer_addr()
414 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
415 sid = initiator.add_session()
416 initiator.configure_session(sid, new_iface)
417 if bad_param_type != bad_param_session_teardown_setup_skipped:
418 initiator.initiate_session(sid, "accept")
419 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
420 initiator.send_test_tear_down('-1')
421 responder.wait_for_session_event(5)
423 if bad_param_type == bad_param_session_teardown_no_params:
425 elif bad_param_type == bad_param_session_teardown_bad_session_id:
427 initiator.teardown_session(sid)
429 if e.args[0].startswith("Cannot tear down fst session"):
430 if (bad_param_type == bad_param_session_teardown_no_params or
431 bad_param_type == bad_param_session_teardown_bad_session_id or
432 bad_param_type == bad_param_session_teardown_setup_skipped):
433 bad_parameter_detected = True
434 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
435 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
436 bad_parameter_detected = True
437 if not bad_parameter_detected:
438 # The exception was unexpected
440 exception_already_raised = True
443 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
444 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
445 if not exception_already_raised:
446 if bad_parameter_detected:
447 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
449 if bad_param_type == bad_param_none:
450 logger.info("Success. Session torn down")
452 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
454 print "Failure. Unexpected exception"
457 #enum - remove session scenarios
458 remove_scenario_no_params = 0
459 remove_scenario_bad_session_id = 1
460 remove_scenario_non_established_session = 2
461 remove_scenario_established_session = 3
463 remove_scenario_names = ("No params",
465 "Remove non-established session",
466 "Remove established session")
469 def fst_remove_session(apdev, test_params, remove_session_scenario, init_on_ap):
470 """This function attempts to remove a session at various stages of its
471 formation, depending on the value of remove_session_scenario. If the call
472 ends as expected, the function silently exits. Otherwise, it throws an
473 exception thus failing the test."""
474 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
475 bad_parameter_detected = False
476 exception_already_raised = False
478 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
479 # This call makes sure FstHostapd singleton object is created and, as a
480 # result, the global control interface is registered (this is done from
482 ap1.get_global_instance()
486 new_iface = ap2.ifname()
487 new_peer_addr = ap2.get_actual_peer_addr()
491 new_iface = sta2.ifname()
492 new_peer_addr = sta2.get_actual_peer_addr()
493 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
494 sid = initiator.add_session()
495 initiator.configure_session(sid, new_iface)
496 if remove_session_scenario != remove_scenario_no_params:
497 if remove_session_scenario != remove_scenario_non_established_session:
498 initiator.initiate_session(sid, "accept")
499 if remove_session_scenario == remove_scenario_no_params:
501 elif remove_session_scenario == remove_scenario_bad_session_id:
503 initiator.remove_session(sid)
505 if e.args[0].startswith("Cannot remove fst session"):
506 if (remove_session_scenario == remove_scenario_no_params or
507 remove_session_scenario == remove_scenario_bad_session_id):
508 bad_parameter_detected = True
509 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
510 if remove_session_scenario == remove_scenario_non_established_session:
511 bad_parameter_detected = True
512 if not bad_parameter_detected:
513 #The exception was unexpected
515 exception_already_raised = True
518 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
519 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
520 if not exception_already_raised:
521 if bad_parameter_detected:
522 logger.info("Success. Remove scenario ended as expected (%s)" % remove_scenario_names[remove_session_scenario])
524 if remove_session_scenario == remove_scenario_established_session:
525 logger.info("Success. Session removed")
527 raise Exception("Failure. Remove scenario ended in an unexpected way (%s)" % remove_scenario_names[remove_session_scenario])
529 print "Failure. Unexpected exception"
533 frame_type_session_request = 0
534 frame_type_session_response = 1
535 frame_type_ack_request = 2
536 frame_type_ack_response = 3
537 frame_type_tear_down = 4
539 frame_type_names = ("Session request",
545 def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, additional_param = ''):
546 """This function creates two pairs of APs and stations, makes them connect
547 and then causes one side to send an unexpected FST frame of the specified
548 type to the other. The other side should then identify and ignore the
550 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
551 exception_already_raised = False
552 frame_receive_timeout = False
554 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
555 # This call makes sure FstHostapd singleton object is created and, as a
556 # result, the global control interface is registered (this is done from
558 ap1.get_global_instance()
562 new_iface = ap2.ifname()
563 new_peer_addr = ap2.get_actual_peer_addr()
567 new_iface = sta2.ifname()
568 new_peer_addr = sta2.get_actual_peer_addr()
569 sender.add_peer(receiver, new_peer_addr = new_peer_addr)
570 sid=sender.add_session()
571 sender.configure_session(sid, new_iface)
572 if frame_type == frame_type_session_request:
573 sender.send_session_setup_request(sid)
574 event = receiver.wait_for_session_event(5)
575 if event['type'] != 'EVENT_FST_SETUP':
576 raise Exception("Unexpected indication: " + event['type'])
577 elif frame_type == frame_type_session_response:
578 #fsts_id doesn't matter, no actual session exists
579 sender.send_test_session_setup_response('0', additional_param)
580 receiver.wait_for_session_event(5)
581 elif frame_type == frame_type_ack_request:
582 #fsts_id doesn't matter, no actual session exists
583 sender.send_test_ack_request('0')
584 receiver.wait_for_session_event(5)
585 elif frame_type == frame_type_ack_response:
586 #fsts_id doesn't matter, no actual session exists
587 sender.send_test_ack_response('0')
588 receiver.wait_for_session_event(5)
589 elif frame_type == frame_type_tear_down:
590 #fsts_id doesn't matter, no actual session exists
591 sender.send_test_tear_down('0')
592 receiver.wait_for_session_event(5)
594 if e.args[0].startswith("No FST-EVENT-SESSION received"):
595 if frame_type != frame_type_session_request:
596 frame_receive_timeout = True
599 exception_already_raised = True
602 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
603 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
604 if not exception_already_raised:
605 if frame_receive_timeout:
606 logger.info("Success. Frame was ignored (%s)" % frame_type_names[frame_type])
608 if frame_type == frame_type_session_request:
609 logger.info("Success. Frame received, session created")
611 raise Exception("Failure. Frame was not ignored (%s)" % frame_type_names[frame_type])
613 print "Failure. Unexpected exception"
616 #enum - bad session transfer scenarios
617 bad_scenario_none = 0
618 bad_scenario_ack_req_session_not_set_up = 1
619 bad_scenario_ack_req_session_not_established_init_side = 2
620 bad_scenario_ack_req_session_not_established_resp_side = 3
621 bad_scenario_ack_req_bad_fsts_id = 4
622 bad_scenario_ack_resp_session_not_set_up = 5
623 bad_scenario_ack_resp_session_not_established_init_side = 6
624 bad_scenario_ack_resp_session_not_established_resp_side = 7
625 bad_scenario_ack_resp_no_ack_req = 8
626 bad_scenario_ack_resp_bad_fsts_id = 9
628 bad_scenario_names = ("None",
629 "Ack request received before the session was set up",
630 "Ack request received on the initiator side before session was established",
631 "Ack request received on the responder side before session was established",
632 "Ack request received with bad fsts_id",
633 "Ack response received before the session was set up",
634 "Ack response received on the initiator side before session was established",
635 "Ack response received on the responder side before session was established",
636 "Ack response received before ack request was sent",
637 "Ack response received with bad fsts_id")
639 def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap):
640 """This function makes the necessary preparations and then adds and sets a
641 session. It then initiates and it unless instructed otherwise) and attempts
642 to send one of the frames involved in the session transfer protocol,
643 skipping or distorting one of the stages according to the value of
644 bad_scenario_type parameter."""
645 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
646 bad_parameter_detected = False
647 exception_already_raised = False
649 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
650 # This call makes sure FstHostapd singleton object is created and, as a
651 # result, the global control interface is registered (this is done from
653 ap1.get_global_instance()
657 new_iface = ap2.ifname()
658 new_peer_addr = ap2.get_actual_peer_addr()
662 new_iface = sta2.ifname()
663 new_peer_addr = sta2.get_actual_peer_addr()
664 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
665 sid = initiator.add_session()
666 initiator.configure_session(sid, new_iface)
667 if (bad_scenario_type != bad_scenario_ack_req_session_not_set_up and
668 bad_scenario_type != bad_scenario_ack_resp_session_not_set_up):
669 if (bad_scenario_type != bad_scenario_ack_req_session_not_established_init_side and
670 bad_scenario_type != bad_scenario_ack_resp_session_not_established_init_side and
671 bad_scenario_type != bad_scenario_ack_req_session_not_established_resp_side and
672 bad_scenario_type != bad_scenario_ack_resp_session_not_established_resp_side):
676 initiator.initiate_session(sid, response)
677 if bad_scenario_type == bad_scenario_ack_req_session_not_set_up:
678 #fsts_id doesn't matter, no actual session exists
679 responder.send_test_ack_request('0')
680 initiator.wait_for_session_event(5)
681 # We want to send the unexpected frame to the side that already has
683 elif bad_scenario_type == bad_scenario_ack_resp_session_not_set_up:
684 #fsts_id doesn't matter, no actual session exists
685 responder.send_test_ack_response('0')
686 initiator.wait_for_session_event(5)
687 # We want to send the unexpected frame to the side that already has
689 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_init_side:
690 #fsts_id doesn't matter, no actual session exists
691 initiator.send_test_ack_request('0')
692 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
693 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_resp_side:
694 #fsts_id doesn't matter, no actual session exists
695 responder.send_test_ack_request('0')
696 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
697 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_init_side:
698 #fsts_id doesn't matter, no actual session exists
699 initiator.send_test_ack_response('0')
700 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
701 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_resp_side:
702 #fsts_id doesn't matter, no actual session exists
703 responder.send_test_ack_response('0')
704 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
705 elif bad_scenario_type == bad_scenario_ack_req_bad_fsts_id:
706 initiator.send_test_ack_request('-1')
707 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
708 elif bad_scenario_type == bad_scenario_ack_resp_bad_fsts_id:
709 initiator.send_test_ack_response('-1')
710 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
711 elif bad_scenario_type == bad_scenario_ack_resp_no_ack_req:
712 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
713 initiator.send_test_ack_response(str(actual_fsts_id))
714 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
716 raise Exception("Unknown bad scenario identifier")
718 if e.args[0].startswith("No FST-EVENT-SESSION received"):
719 bad_parameter_detected = True
720 if not bad_parameter_detected:
721 # The exception was unexpected
723 exception_already_raised = True
726 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
727 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
728 if not exception_already_raised:
729 if bad_parameter_detected:
730 logger.info("Success. Bad scenario was handled correctly (%s)" % bad_scenario_names[bad_scenario_type])
732 raise Exception("Failure. Bad scenario was handled incorrectly (%s)" % bad_scenario_names[bad_scenario_type])
734 print "Failure. Unexpected exception"
736 def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params):
737 """FST STA connecting to non-FST AP"""
738 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
739 with HWSimRadio() as (radio, iface):
740 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
742 orig_sta1_mbies = sta1.get_local_mbies()
743 orig_sta2_mbies = sta2.get_local_mbies()
746 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g",
747 key_mgmt="NONE", scan_freq=freq)
749 res_sta1_mbies = sta1.get_local_mbies()
750 res_sta2_mbies = sta2.get_local_mbies()
751 if (orig_sta1_mbies.startswith("FAIL") or
752 orig_sta2_mbies.startswith("FAIL") or
753 not res_sta1_mbies.startswith("FAIL") or
754 not res_sta2_mbies.startswith("FAIL")):
755 raise Exception("Failure. MB IEs have not been removed on the stations")
760 sta2.disconnect_from_external_ap()
761 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
763 def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params):
764 """FST STA connecting to FST AP"""
765 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
767 orig_sta2_mbies = sta2.get_local_mbies()
768 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
769 sta1.connect(ap1, key_mgmt="NONE",
770 scan_freq=fst_test_common.fst_test_def_freq_a)
772 res_sta2_mbies = sta2.get_local_mbies()
773 if res_sta2_mbies == orig_sta2_mbies:
774 raise Exception("Failure. MB IEs have not been updated")
780 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
782 def test_fst_ap_connect_to_fst_sta(dev, apdev, test_params):
783 """FST AP connecting to FST STA"""
784 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
786 orig_ap_mbies = ap1.get_local_mbies()
787 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
788 sta1.connect(ap1, key_mgmt="NONE",
789 scan_freq=fst_test_common.fst_test_def_freq_a)
791 res_ap_mbies = ap1.get_local_mbies()
792 if res_ap_mbies != orig_ap_mbies:
793 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
799 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
801 def test_fst_ap_connect_to_non_fst_sta(dev, apdev, test_params):
802 """FST AP connecting to non-FST STA"""
803 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
805 orig_ap_mbies = ap2.get_local_mbies()
806 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
807 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
808 scan_freq=fst_test_common.fst_test_def_freq_g)
810 res_ap_mbies = ap2.get_local_mbies()
811 if res_ap_mbies != orig_ap_mbies:
812 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
817 fst_module_aux.disconnect_external_sta(dev[0], ap2)
818 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
820 def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params):
821 """FST STA 2nd connecting to non-FST AP"""
822 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
823 with HWSimRadio() as (radio, iface):
824 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
826 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
827 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
829 orig_sta1_mbies = sta1.get_local_mbies()
830 orig_sta2_mbies = sta2.get_local_mbies()
833 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
835 res_sta1_mbies = sta1.get_local_mbies()
836 res_sta2_mbies = sta2.get_local_mbies()
837 if (orig_sta1_mbies.startswith("FAIL") or
838 orig_sta2_mbies.startswith("FAIL") or
839 not res_sta1_mbies.startswith("FAIL") or
840 not res_sta2_mbies.startswith("FAIL")):
841 raise Exception("Failure. MB IEs have not been removed on the stations")
847 sta2.disconnect_from_external_ap()
848 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
851 def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params):
852 """FST STA 2nd connecting to FST AP"""
853 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
854 with HWSimRadio() as (radio, iface):
855 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
859 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
861 orig_sta1_mbies = sta1.get_local_mbies()
862 orig_sta2_mbies = sta2.get_local_mbies()
863 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
864 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
866 res_sta1_mbies = sta1.get_local_mbies()
867 res_sta2_mbies = sta2.get_local_mbies()
868 if (not orig_sta1_mbies.startswith("FAIL") or
869 not orig_sta2_mbies.startswith("FAIL") or
870 not res_sta1_mbies.startswith("FAIL") or
871 not res_sta2_mbies.startswith("FAIL")):
872 raise Exception("Failure. MB IEs should have stayed non-present on the stations")
878 sta2.disconnect_from_external_ap()
879 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
881 def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
882 """FST disconnect 1 of 2 STAs from non-FST AP"""
883 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
884 with HWSimRadio() as (radio, iface):
885 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
887 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
888 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
891 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
893 orig_sta1_mbies = sta1.get_local_mbies()
894 orig_sta2_mbies = sta2.get_local_mbies()
895 sta2.disconnect_from_external_ap()
897 res_sta1_mbies = sta1.get_local_mbies()
898 res_sta2_mbies = sta2.get_local_mbies()
899 if (not orig_sta1_mbies.startswith("FAIL") or
900 not orig_sta2_mbies.startswith("FAIL") or
901 res_sta1_mbies.startswith("FAIL") or
902 res_sta2_mbies.startswith("FAIL")):
903 raise Exception("Failure. MB IEs haven't reappeared on the stations")
909 sta2.disconnect_from_external_ap()
910 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
913 def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params):
914 """FST disconnect 1 of 2 STAs from FST AP"""
915 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
916 with HWSimRadio() as (radio, iface):
917 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
919 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
920 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
923 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
925 orig_sta1_mbies = sta1.get_local_mbies()
926 orig_sta2_mbies = sta2.get_local_mbies()
929 res_sta1_mbies = sta1.get_local_mbies()
930 res_sta2_mbies = sta2.get_local_mbies()
931 if (not orig_sta1_mbies.startswith("FAIL") or
932 not orig_sta2_mbies.startswith("FAIL") or
933 not res_sta1_mbies.startswith("FAIL") or
934 not res_sta2_mbies.startswith("FAIL")):
935 raise Exception("Failure. MB IEs should have stayed non-present on the stations")
941 sta2.disconnect_from_external_ap()
942 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
944 def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
945 """FST disconnect 2 of 2 STAs from non-FST AP"""
946 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
947 with HWSimRadio() as (radio, iface):
948 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
950 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
951 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
954 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
958 orig_sta1_mbies = sta1.get_local_mbies()
959 orig_sta2_mbies = sta2.get_local_mbies()
960 sta2.disconnect_from_external_ap()
962 res_sta1_mbies = sta1.get_local_mbies()
963 res_sta2_mbies = sta2.get_local_mbies()
964 if (not orig_sta1_mbies.startswith("FAIL") or
965 not orig_sta2_mbies.startswith("FAIL") or
966 res_sta1_mbies.startswith("FAIL") or
967 res_sta2_mbies.startswith("FAIL")):
968 raise Exception("Failure. MB IEs haven't reappeared on the stations")
974 sta2.disconnect_from_external_ap()
975 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
977 def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params):
978 """FST disconnect 2 of 2 STAs from FST AP"""
979 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
980 with HWSimRadio() as (radio, iface):
981 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g"})
983 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
984 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
987 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
989 sta2.disconnect_from_external_ap()
991 orig_sta1_mbies = sta1.get_local_mbies()
992 orig_sta2_mbies = sta2.get_local_mbies()
995 res_sta1_mbies = sta1.get_local_mbies()
996 res_sta2_mbies = sta2.get_local_mbies()
997 if (orig_sta1_mbies.startswith("FAIL") or
998 orig_sta2_mbies.startswith("FAIL") or
999 res_sta1_mbies.startswith("FAIL") or
1000 res_sta2_mbies.startswith("FAIL")):
1001 raise Exception("Failure. MB IEs should have stayed present on both stations")
1002 # Mandatory part of 8.4.2.140 Multi-band element is 24 bytes = 48 hex chars
1003 basic_sta1_mbies = res_sta1_mbies[0:48] + res_sta1_mbies[60:108]
1004 basic_sta2_mbies = res_sta2_mbies[0:48] + res_sta2_mbies[60:108]
1005 if (basic_sta1_mbies != basic_sta2_mbies):
1006 raise Exception("Failure. Basic MB IEs should have become identical on both stations")
1007 addr_sta1_str = sta1.get_own_mac_address().replace(":", "")
1008 addr_sta2_str = sta2.get_own_mac_address().replace(":", "")
1009 # Mandatory part of 8.4.2.140 Multi-band element is followed by STA MAC Address field (6 bytes = 12 hex chars)
1010 addr_sta1_mbie1 = res_sta1_mbies[48:60]
1011 addr_sta1_mbie2 = res_sta1_mbies[108:120]
1012 addr_sta2_mbie1 = res_sta2_mbies[48:60]
1013 addr_sta2_mbie2 = res_sta2_mbies[108:120]
1014 if (addr_sta1_mbie1 != addr_sta1_mbie2 or
1015 addr_sta1_mbie1 != addr_sta2_str or
1016 addr_sta2_mbie1 != addr_sta2_mbie2 or
1017 addr_sta2_mbie1 != addr_sta1_str):
1018 raise Exception("Failure. STA Address in MB IEs should have been same as the other STA's")
1019 except Exception, e:
1024 sta2.disconnect_from_external_ap()
1025 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
1027 def test_fst_disconnect_non_fst_sta(dev, apdev, test_params):
1028 """FST disconnect non-FST STA"""
1029 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1030 external_sta_connected = False
1032 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1033 fst_sta1.connect(ap1, key_mgmt="NONE",
1034 scan_freq=fst_test_common.fst_test_def_freq_a)
1035 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1036 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1037 scan_freq=fst_test_common.fst_test_def_freq_g)
1038 external_sta_connected = True
1040 fst_sta1.disconnect()
1042 orig_ap_mbies = ap2.get_local_mbies()
1043 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1044 external_sta_connected = False
1046 res_ap_mbies = ap2.get_local_mbies()
1047 if res_ap_mbies != orig_ap_mbies:
1048 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1049 except Exception, e:
1053 fst_sta1.disconnect()
1054 if external_sta_connected:
1055 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1056 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1058 def test_fst_disconnect_fst_sta(dev, apdev, test_params):
1059 """FST disconnect FST STA"""
1060 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1061 external_sta_connected = False;
1063 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1064 fst_sta1.connect(ap1, key_mgmt="NONE",
1065 scan_freq=fst_test_common.fst_test_def_freq_a)
1066 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1067 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1068 scan_freq=fst_test_common.fst_test_def_freq_g)
1069 external_sta_connected = True
1071 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1072 external_sta_connected = False
1074 orig_ap_mbies = ap2.get_local_mbies()
1075 fst_sta1.disconnect()
1077 res_ap_mbies = ap2.get_local_mbies()
1078 if res_ap_mbies != orig_ap_mbies:
1079 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1080 except Exception, e:
1084 fst_sta1.disconnect()
1085 if external_sta_connected:
1086 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1087 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1089 def test_fst_dynamic_iface_attach(dev, apdev, test_params):
1090 """FST dynamic interface attach"""
1091 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1092 fst_test_common.fst_test_def_chan_a,
1093 fst_test_common.fst_test_def_group,
1094 fst_test_common.fst_test_def_prio_low,
1095 fst_test_common.fst_test_def_llt)
1097 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1098 fst_test_common.fst_test_def_chan_g,
1102 sta1 = fst_module_aux.FstSTA('wlan5',
1103 fst_test_common.fst_test_def_group,
1104 fst_test_common.fst_test_def_prio_low,
1105 fst_test_common.fst_test_def_llt)
1107 sta2 = fst_module_aux.FstSTA('wlan6', '', '', '')
1111 orig_sta2_mbies = sta2.get_local_mbies()
1112 orig_ap2_mbies = ap2.get_local_mbies()
1113 sta2.send_iface_attach_request(sta2.ifname(),
1114 fst_test_common.fst_test_def_group,
1116 event = sta2.wait_for_iface_event(5)
1117 if event['event_type'] != 'attached':
1118 raise Exception("Failure. Iface was not properly attached")
1119 ap2.send_iface_attach_request(ap2.ifname(),
1120 fst_test_common.fst_test_def_group,
1122 event = ap2.wait_for_iface_event(5)
1123 if event['event_type'] != 'attached':
1124 raise Exception("Failure. Iface was not properly attached")
1126 res_sta2_mbies = sta2.get_local_mbies()
1127 res_ap2_mbies = ap2.get_local_mbies()
1128 sta2.send_iface_detach_request(sta2.ifname())
1129 event = sta2.wait_for_iface_event(5)
1130 if event['event_type'] != 'detached':
1131 raise Exception("Failure. Iface was not properly detached")
1132 ap2.send_iface_detach_request(ap2.ifname())
1133 event = ap2.wait_for_iface_event(5)
1134 if event['event_type'] != 'detached':
1135 raise Exception("Failure. Iface was not properly detached")
1136 if (not orig_sta2_mbies.startswith("FAIL") or
1137 not orig_ap2_mbies.startswith("FAIL") or
1138 res_sta2_mbies.startswith("FAIL") or
1139 res_ap2_mbies.startswith("FAIL")):
1140 raise Exception("Failure. MB IEs should have appeared on the station and on the AP")
1141 except Exception, e:
1150 # AP side FST module tests
1152 def test_fst_ap_start_session(dev, apdev, test_params):
1153 """FST AP start session"""
1154 fst_start_session(apdev, test_params, bad_param_none, True)
1156 def test_fst_ap_start_session_no_add_params(dev, apdev, test_params):
1157 """FST AP start session - no add params"""
1158 fst_start_session(apdev, test_params, bad_param_session_add_no_params, True)
1160 def test_fst_ap_start_session_bad_group_id(dev, apdev, test_params):
1161 """FST AP start session - bad group id"""
1162 fst_start_session(apdev, test_params, bad_param_group_id, True)
1164 def test_fst_ap_start_session_no_set_params(dev, apdev, test_params):
1165 """FST AP start session - no set params"""
1166 fst_start_session(apdev, test_params, bad_param_session_set_no_params, True)
1168 def test_fst_ap_start_session_set_unknown_param(dev, apdev, test_params):
1169 """FST AP start session - set unknown param"""
1170 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1173 def test_fst_ap_start_session_bad_session_id(dev, apdev, test_params):
1174 """FST AP start session - bad session id"""
1175 fst_start_session(apdev, test_params, bad_param_session_id, True)
1177 def test_fst_ap_start_session_bad_new_iface(dev, apdev, test_params):
1178 """FST AP start session - bad new iface"""
1179 fst_start_session(apdev, test_params, bad_param_new_iface, True)
1181 def test_fst_ap_start_session_bad_old_iface(dev, apdev, test_params):
1182 """FST AP start session - bad old iface"""
1183 fst_start_session(apdev, test_params, bad_param_old_iface, True)
1185 def test_fst_ap_start_session_negative_llt(dev, apdev, test_params):
1186 """FST AP start session - negative llt"""
1187 fst_start_session(apdev, test_params, bad_param_negative_llt, True)
1189 def test_fst_ap_start_session_zero_llt(dev, apdev, test_params):
1190 """FST AP start session - zero llt"""
1191 fst_start_session(apdev, test_params, bad_param_zero_llt, True)
1193 def test_fst_ap_start_session_llt_too_big(dev, apdev, test_params):
1194 """FST AP start session - llt too large"""
1195 fst_start_session(apdev, test_params, bad_param_llt_too_big, True)
1197 def test_fst_ap_start_session_invalid_peer_addr(dev, apdev, test_params):
1198 """FST AP start session - invalid peer address"""
1199 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1200 'GG:GG:GG:GG:GG:GG')
1202 def test_fst_ap_start_session_multicast_peer_addr(dev, apdev, test_params):
1203 """FST AP start session - multicast peer address"""
1204 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1205 '01:00:11:22:33:44')
1207 def test_fst_ap_start_session_broadcast_peer_addr(dev, apdev, test_params):
1208 """FST AP start session - broadcast peer address"""
1209 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1210 'FF:FF:FF:FF:FF:FF')
1212 def test_fst_ap_initiate_session(dev, apdev, test_params):
1213 """FST AP initiate session"""
1214 fst_initiate_session(apdev, test_params, bad_param_none, True)
1216 def test_fst_ap_initiate_session_no_params(dev, apdev, test_params):
1217 """FST AP initiate session - no params"""
1218 fst_initiate_session(apdev, test_params,
1219 bad_param_session_initiate_no_params, True)
1221 def test_fst_ap_initiate_session_invalid_session_id(dev, apdev, test_params):
1222 """FST AP initiate session - invalid session id"""
1223 fst_initiate_session(apdev, test_params,
1224 bad_param_session_initiate_bad_session_id, True)
1226 def test_fst_ap_initiate_session_no_new_iface(dev, apdev, test_params):
1227 """FST AP initiate session - no new iface"""
1228 fst_initiate_session(apdev, test_params,
1229 bad_param_session_initiate_with_no_new_iface_set, True)
1231 def test_fst_ap_initiate_session_bad_peer_addr(dev, apdev, test_params):
1232 """FST AP initiate session - bad peer address"""
1233 fst_initiate_session(apdev, test_params,
1234 bad_param_session_initiate_with_bad_peer_addr_set,
1237 def test_fst_ap_initiate_session_request_with_bad_stie(dev, apdev, test_params):
1238 """FST AP initiate session - request with bad stie"""
1239 fst_initiate_session(apdev, test_params,
1240 bad_param_session_initiate_request_with_bad_stie, True)
1242 def test_fst_ap_initiate_session_response_with_reject(dev, apdev, test_params):
1243 """FST AP initiate session - response with reject"""
1244 fst_initiate_session(apdev, test_params,
1245 bad_param_session_initiate_response_with_reject, True)
1247 def test_fst_ap_initiate_session_response_with_bad_stie(dev, apdev,
1249 """FST AP initiate session - response with bad stie"""
1250 fst_initiate_session(apdev, test_params,
1251 bad_param_session_initiate_response_with_bad_stie,
1254 def test_fst_ap_initiate_session_response_with_zero_llt(dev, apdev,
1256 """FST AP initiate session - zero llt"""
1257 fst_initiate_session(apdev, test_params,
1258 bad_param_session_initiate_response_with_zero_llt,
1261 def test_fst_ap_initiate_session_stt_no_response(dev, apdev, test_params):
1262 """FST AP initiate session - stt no response"""
1263 fst_initiate_session(apdev, test_params,
1264 bad_param_session_initiate_stt_no_response, True)
1266 def test_fst_ap_initiate_session_concurrent_setup_request(dev, apdev,
1268 """FST AP initiate session - concurrent setup request"""
1269 fst_initiate_session(apdev, test_params,
1270 bad_param_session_initiate_concurrent_setup_request,
1273 def test_fst_ap_session_request_with_no_session(dev, apdev, test_params):
1274 """FST AP session request with no session"""
1275 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1278 def test_fst_ap_session_response_accept_with_no_session(dev, apdev,
1280 """FST AP session response accept with no session"""
1281 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1284 def test_fst_ap_session_response_reject_with_no_session(dev, apdev,
1286 """FST AP session response reject with no session"""
1287 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1290 def test_fst_ap_ack_request_with_no_session(dev, apdev, test_params):
1291 """FST AP ack request with no session"""
1292 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, True)
1294 def test_fst_ap_ack_response_with_no_session(dev, apdev, test_params):
1295 """FST AP ack response with no session"""
1296 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response, True)
1298 def test_fst_ap_tear_down_response_with_no_session(dev, apdev, test_params):
1299 """FST AP tear down response with no session"""
1300 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, True)
1302 def test_fst_ap_transfer_session(dev, apdev, test_params):
1303 """FST AP transfer session"""
1304 fst_transfer_session(apdev, test_params, bad_param_none, True)
1306 def test_fst_ap_transfer_session_no_params(dev, apdev, test_params):
1307 """FST AP transfer session - no params"""
1308 fst_transfer_session(apdev, test_params,
1309 bad_param_session_transfer_no_params, True)
1311 def test_fst_ap_transfer_session_bad_session_id(dev, apdev, test_params):
1312 """FST AP transfer session - bad session id"""
1313 fst_transfer_session(apdev, test_params,
1314 bad_param_session_transfer_bad_session_id, True)
1316 def test_fst_ap_transfer_session_setup_skipped(dev, apdev, test_params):
1317 """FST AP transfer session - setup skipped"""
1318 fst_transfer_session(apdev, test_params,
1319 bad_param_session_transfer_setup_skipped, True)
1321 def test_fst_ap_ack_request_with_session_not_set_up(dev, apdev, test_params):
1322 """FST AP ack request with session not set up"""
1323 fst_bad_transfer(apdev, test_params,
1324 bad_scenario_ack_req_session_not_set_up, True)
1326 def test_fst_ap_ack_request_with_session_not_established_init_side(dev, apdev,
1328 """FST AP ack request with session not established init side"""
1329 fst_bad_transfer(apdev, test_params,
1330 bad_scenario_ack_req_session_not_established_init_side,
1333 def test_fst_ap_ack_request_with_session_not_established_resp_side(dev, apdev,
1335 """FST AP ack request with session not established resp side"""
1336 fst_bad_transfer(apdev, test_params,
1337 bad_scenario_ack_req_session_not_established_resp_side,
1340 def test_fst_ap_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1341 """FST AP ack request with bad fsts id"""
1342 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id, True)
1344 def test_fst_ap_ack_response_with_session_not_set_up(dev, apdev, test_params):
1345 """FST AP ack response with session not set up"""
1346 fst_bad_transfer(apdev, test_params,
1347 bad_scenario_ack_resp_session_not_set_up, True)
1349 def test_fst_ap_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1350 """FST AP ack response with session not established init side"""
1351 fst_bad_transfer(apdev, test_params,
1352 bad_scenario_ack_resp_session_not_established_init_side,
1355 def test_fst_ap_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1356 """FST AP ack response with session not established resp side"""
1357 fst_bad_transfer(apdev, test_params,
1358 bad_scenario_ack_resp_session_not_established_resp_side,
1361 def test_fst_ap_ack_response_with_no_ack_request(dev, apdev, test_params):
1362 """FST AP ack response with no ack request"""
1363 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req, True)
1365 def test_fst_ap_tear_down_session(dev, apdev, test_params):
1366 """FST AP tear down session"""
1367 fst_tear_down_session(apdev, test_params, bad_param_none, True)
1369 def test_fst_ap_tear_down_session_no_params(dev, apdev, test_params):
1370 """FST AP tear down session - no params"""
1371 fst_tear_down_session(apdev, test_params,
1372 bad_param_session_teardown_no_params, True)
1374 def test_fst_ap_tear_down_session_bad_session_id(dev, apdev, test_params):
1375 """FST AP tear down session - bad session id"""
1376 fst_tear_down_session(apdev, test_params,
1377 bad_param_session_teardown_bad_session_id, True)
1379 def test_fst_ap_tear_down_session_setup_skipped(dev, apdev, test_params):
1380 """FST AP tear down session - setup skipped"""
1381 fst_tear_down_session(apdev, test_params,
1382 bad_param_session_teardown_setup_skipped, True)
1384 def test_fst_ap_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1385 """FST AP tear down session - bad fsts id"""
1386 fst_tear_down_session(apdev, test_params,
1387 bad_param_session_teardown_bad_fsts_id, True)
1389 def test_fst_ap_remove_session_not_established(dev, apdev, test_params):
1390 """FST AP remove session - not established"""
1391 fst_remove_session(apdev, test_params,
1392 remove_scenario_non_established_session, True)
1394 def test_fst_ap_remove_session_established(dev, apdev, test_params):
1395 """FST AP remove session - established"""
1396 fst_remove_session(apdev, test_params,
1397 remove_scenario_established_session, True)
1399 def test_fst_ap_remove_session_no_params(dev, apdev, test_params):
1400 """FST AP remove session - no params"""
1401 fst_remove_session(apdev, test_params, remove_scenario_no_params, True)
1403 def test_fst_ap_remove_session_bad_session_id(dev, apdev, test_params):
1404 """FST AP remove session - bad session id"""
1405 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id, True)
1407 def test_fst_ap_ctrl_iface(dev, apdev, test_params):
1408 """FST control interface behavior"""
1409 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1411 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1414 initiator.add_peer(responder, None)
1415 initiator.set_fst_parameters(group_id=None)
1416 sid = initiator.add_session()
1417 res = initiator.get_session_params(sid)
1418 logger.info("Initial session params:\n" + str(res))
1419 if res['state'] != 'INITIAL':
1420 raise Exception("Unexpected state: " + res['state'])
1421 initiator.set_fst_parameters(llt=None)
1422 initiator.configure_session(sid, ap2.ifname(), None)
1423 res = initiator.get_session_params(sid)
1424 logger.info("Session params after configuration:\n" + str(res))
1425 res = initiator.iface_peers(initiator.ifname())
1426 logger.info("Interface peers: " + str(res))
1428 raise Exception("Unexpected number of peers")
1429 res = initiator.get_peer_mbies(initiator.ifname(),
1430 initiator.get_new_peer_addr())
1431 logger.info("Peer MB IEs: " + str(res))
1432 res = initiator.list_ifaces()
1433 logger.info("Interfaces: " + str(res))
1435 raise Exception("Unexpected number of interfaces")
1436 res = initiator.list_groups()
1437 logger.info("Groups: " + str(res))
1439 raise Exception("Unexpected number of groups")
1441 tests = [ "LIST_IFACES unknown",
1442 "LIST_IFACES unknown2",
1443 "SESSION_GET 12345678",
1444 "SESSION_SET " + sid + " unknown=foo",
1445 "SESSION_RESPOND 12345678 foo",
1446 "SESSION_RESPOND " + sid,
1447 "SESSION_RESPOND " + sid + " foo",
1451 "GET_PEER_MBIES unknown",
1452 "GET_PEER_MBIES unknown unknown",
1453 "GET_PEER_MBIES unknown " + initiator.get_new_peer_addr(),
1454 "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff",
1457 "IFACE_PEERS unknown",
1458 "IFACE_PEERS unknown unknown",
1459 "IFACE_PEERS " + initiator.fst_group,
1460 "IFACE_PEERS " + initiator.fst_group + " unknown" ]
1462 if "FAIL" not in initiator.grequest("FST-MANAGER " + t):
1463 raise Exception("Unexpected response for invalid FST-MANAGER command " + t)
1464 if "UNKNOWN FST COMMAND" not in initiator.grequest("FST-MANAGER unknown"):
1465 raise Exception("Unexpected response for unknown FST-MANAGER command")
1467 tests = [ "FST-DETACH", "FST-DETACH ", "FST-DETACH unknown",
1468 "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown",
1469 "FST-ATTACH unknown unknown" ]
1471 if "FAIL" not in initiator.grequest(t):
1472 raise Exception("Unexpected response for invalid command " + t)
1475 # Trying to add same interface again needs to fail.
1476 ap1.send_iface_attach_request(ap1.iface, ap1.fst_group,
1477 ap1.fst_llt, ap1.fst_pri)
1478 raise Exception("Duplicate FST-ATTACH succeeded")
1479 except Exception, e:
1480 if not str(e).startswith("Cannot attach"):
1483 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1484 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1486 def test_fst_ap_start_session_oom(dev, apdev, test_params):
1487 """FST AP setup failing due to OOM"""
1488 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1489 fst_test_common.fst_test_def_chan_a,
1490 fst_test_common.fst_test_def_group,
1491 fst_test_common.fst_test_def_prio_low,
1492 fst_test_common.fst_test_def_llt)
1494 with alloc_fail(ap1, 1, "fst_iface_create"):
1497 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1498 fst_test_common.fst_test_def_chan_g,
1499 fst_test_common.fst_test_def_group,
1500 fst_test_common.fst_test_def_prio_high,
1501 fst_test_common.fst_test_def_llt)
1503 # This will fail in fst_iface_create() OOM
1514 # STA side FST module tests
1516 def test_fst_sta_start_session(dev, apdev, test_params):
1517 """FST STA start session"""
1518 fst_start_session(apdev, test_params, bad_param_none, False)
1520 def test_fst_sta_start_session_no_add_params(dev, apdev, test_params):
1521 """FST STA start session - no add params"""
1522 fst_start_session(apdev, test_params, bad_param_session_add_no_params,
1525 def test_fst_sta_start_session_bad_group_id(dev, apdev, test_params):
1526 """FST STA start session - bad group id"""
1527 fst_start_session(apdev, test_params, bad_param_group_id, False)
1529 def test_fst_sta_start_session_no_set_params(dev, apdev, test_params):
1530 """FST STA start session - no set params"""
1531 fst_start_session(apdev, test_params, bad_param_session_set_no_params,
1534 def test_fst_sta_start_session_set_unknown_param(dev, apdev, test_params):
1535 """FST STA start session - set unknown param"""
1536 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1539 def test_fst_sta_start_session_bad_session_id(dev, apdev, test_params):
1540 """FST STA start session - bad session id"""
1541 fst_start_session(apdev, test_params, bad_param_session_id, False)
1543 def test_fst_sta_start_session_bad_new_iface(dev, apdev, test_params):
1544 """FST STA start session - bad new iface"""
1545 fst_start_session(apdev, test_params, bad_param_new_iface, False)
1547 def test_fst_sta_start_session_bad_old_iface(dev, apdev, test_params):
1548 """FST STA start session - bad old iface"""
1549 fst_start_session(apdev, test_params, bad_param_old_iface, False)
1551 def test_fst_sta_start_session_negative_llt(dev, apdev, test_params):
1552 """FST STA start session - negative llt"""
1553 fst_start_session(apdev, test_params, bad_param_negative_llt, False)
1555 def test_fst_sta_start_session_zero_llt(dev, apdev, test_params):
1556 """FST STA start session - zero llt"""
1557 fst_start_session(apdev, test_params, bad_param_zero_llt, False)
1559 def test_fst_sta_start_session_llt_too_big(dev, apdev, test_params):
1560 """FST STA start session - llt too large"""
1561 fst_start_session(apdev, test_params, bad_param_llt_too_big, False)
1563 def test_fst_sta_start_session_invalid_peer_addr(dev, apdev, test_params):
1564 """FST STA start session - invalid peer address"""
1565 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1566 'GG:GG:GG:GG:GG:GG')
1568 def test_fst_sta_start_session_multicast_peer_addr(dev, apdev, test_params):
1569 """FST STA start session - multicast peer address"""
1570 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1571 '11:00:11:22:33:44')
1573 def test_fst_sta_start_session_broadcast_peer_addr(dev, apdev, test_params):
1574 """FST STA start session - broadcast peer addr"""
1575 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1576 'FF:FF:FF:FF:FF:FF')
1578 def test_fst_sta_initiate_session(dev, apdev, test_params):
1579 """FST STA initiate session"""
1580 fst_initiate_session(apdev, test_params, bad_param_none, False)
1582 def test_fst_sta_initiate_session_no_params(dev, apdev, test_params):
1583 """FST STA initiate session - no params"""
1584 fst_initiate_session(apdev, test_params,
1585 bad_param_session_initiate_no_params, False)
1587 def test_fst_sta_initiate_session_invalid_session_id(dev, apdev, test_params):
1588 """FST STA initiate session - invalid session id"""
1589 fst_initiate_session(apdev, test_params,
1590 bad_param_session_initiate_bad_session_id, False)
1592 def test_fst_sta_initiate_session_no_new_iface(dev, apdev, test_params):
1593 """FST STA initiate session - no new iface"""
1594 fst_initiate_session(apdev, test_params,
1595 bad_param_session_initiate_with_no_new_iface_set,
1598 def test_fst_sta_initiate_session_bad_peer_addr(dev, apdev, test_params):
1599 """FST STA initiate session - bad peer address"""
1600 fst_initiate_session(apdev, test_params,
1601 bad_param_session_initiate_with_bad_peer_addr_set,
1604 def test_fst_sta_initiate_session_request_with_bad_stie(dev, apdev,
1606 """FST STA initiate session - request with bad stie"""
1607 fst_initiate_session(apdev, test_params,
1608 bad_param_session_initiate_request_with_bad_stie,
1611 def test_fst_sta_initiate_session_response_with_reject(dev, apdev, test_params):
1612 """FST STA initiate session - response with reject"""
1613 fst_initiate_session(apdev, test_params, bad_param_session_initiate_response_with_reject, False)
1615 def test_fst_sta_initiate_session_response_with_bad_stie(dev, apdev, test_params):
1616 """FST STA initiate session - response with bad stie"""
1617 fst_initiate_session(apdev, test_params,
1618 bad_param_session_initiate_response_with_bad_stie,
1621 def test_fst_sta_initiate_session_response_with_zero_llt(dev, apdev,
1623 """FST STA initiate session - response with zero llt"""
1624 fst_initiate_session(apdev, test_params,
1625 bad_param_session_initiate_response_with_zero_llt,
1628 def test_fst_sta_initiate_session_stt_no_response(dev, apdev, test_params):
1629 """FST STA initiate session - stt no response"""
1630 fst_initiate_session(apdev, test_params,
1631 bad_param_session_initiate_stt_no_response, False)
1633 def test_fst_sta_initiate_session_concurrent_setup_request(dev, apdev,
1635 """FST STA initiate session - concurrent setup request"""
1636 fst_initiate_session(apdev, test_params,
1637 bad_param_session_initiate_concurrent_setup_request,
1640 def test_fst_sta_session_request_with_no_session(dev, apdev, test_params):
1641 """FST STA session request with no session"""
1642 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1645 def test_fst_sta_session_response_accept_with_no_session(dev, apdev,
1647 """FST STA session response accept with no session"""
1648 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1651 def test_fst_sta_session_response_reject_with_no_session(dev, apdev,
1653 """FST STA session response reject with no session"""
1654 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1657 def test_fst_sta_ack_request_with_no_session(dev, apdev, test_params):
1658 """FST STA ack request with no session"""
1659 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, False)
1661 def test_fst_sta_ack_response_with_no_session(dev, apdev, test_params):
1662 """FST STA ack response with no session"""
1663 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response,
1666 def test_fst_sta_tear_down_response_with_no_session(dev, apdev, test_params):
1667 """FST STA tear down response with no session"""
1668 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, False)
1670 def test_fst_sta_transfer_session(dev, apdev, test_params):
1671 """FST STA transfer session"""
1672 fst_transfer_session(apdev, test_params, bad_param_none, False)
1674 def test_fst_sta_transfer_session_no_params(dev, apdev, test_params):
1675 """FST STA transfer session - no params"""
1676 fst_transfer_session(apdev, test_params,
1677 bad_param_session_transfer_no_params, False)
1679 def test_fst_sta_transfer_session_bad_session_id(dev, apdev, test_params):
1680 """FST STA transfer session - bad session id"""
1681 fst_transfer_session(apdev, test_params,
1682 bad_param_session_transfer_bad_session_id, False)
1684 def test_fst_sta_transfer_session_setup_skipped(dev, apdev, test_params):
1685 """FST STA transfer session - setup skipped"""
1686 fst_transfer_session(apdev, test_params,
1687 bad_param_session_transfer_setup_skipped, False)
1689 def test_fst_sta_ack_request_with_session_not_set_up(dev, apdev, test_params):
1690 """FST STA ack request with session not set up"""
1691 fst_bad_transfer(apdev, test_params,
1692 bad_scenario_ack_req_session_not_set_up, False)
1694 def test_fst_sta_ack_request_with_session_not_established_init_side(dev, apdev, test_params):
1695 """FST STA ack request with session not established init side"""
1696 fst_bad_transfer(apdev, test_params,
1697 bad_scenario_ack_req_session_not_established_init_side,
1700 def test_fst_sta_ack_request_with_session_not_established_resp_side(dev, apdev, test_params):
1701 """FST STA ack request with session not established resp side"""
1702 fst_bad_transfer(apdev, test_params,
1703 bad_scenario_ack_req_session_not_established_resp_side,
1706 def test_fst_sta_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1707 """FST STA ack request with bad fsts id"""
1708 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id,
1711 def test_fst_sta_ack_response_with_session_not_set_up(dev, apdev, test_params):
1712 """FST STA ack response with session not set up"""
1713 fst_bad_transfer(apdev, test_params,
1714 bad_scenario_ack_resp_session_not_set_up, False)
1716 def test_fst_sta_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1717 """FST STA ack response with session not established init side"""
1718 fst_bad_transfer(apdev, test_params,
1719 bad_scenario_ack_resp_session_not_established_init_side,
1722 def test_fst_sta_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1723 """FST STA ack response with session not established resp side"""
1724 fst_bad_transfer(apdev, test_params,
1725 bad_scenario_ack_resp_session_not_established_resp_side,
1728 def test_fst_sta_ack_response_with_no_ack_request(dev, apdev, test_params):
1729 """FST STA ack response with no ack request"""
1730 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req,
1733 def test_fst_sta_tear_down_session(dev, apdev, test_params):
1734 """FST STA tear down session"""
1735 fst_tear_down_session(apdev, test_params, bad_param_none, False)
1737 def test_fst_sta_tear_down_session_no_params(dev, apdev, test_params):
1738 """FST STA tear down session - no params"""
1739 fst_tear_down_session(apdev, test_params,
1740 bad_param_session_teardown_no_params, False)
1742 def test_fst_sta_tear_down_session_bad_session_id(dev, apdev, test_params):
1743 """FST STA tear down session - bad session id"""
1744 fst_tear_down_session(apdev, test_params,
1745 bad_param_session_teardown_bad_session_id, False)
1747 def test_fst_sta_tear_down_session_setup_skipped(dev, apdev, test_params):
1748 """FST STA tear down session - setup skipped"""
1749 fst_tear_down_session(apdev, test_params,
1750 bad_param_session_teardown_setup_skipped, False)
1752 def test_fst_sta_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1753 """FST STA tear down session - bad fsts id"""
1754 fst_tear_down_session(apdev, test_params,
1755 bad_param_session_teardown_bad_fsts_id, False)
1757 def test_fst_sta_remove_session_not_established(dev, apdev, test_params):
1758 """FST STA tear down session - not established"""
1759 fst_remove_session(apdev, test_params,
1760 remove_scenario_non_established_session, False)
1762 def test_fst_sta_remove_session_established(dev, apdev, test_params):
1763 """FST STA remove session - established"""
1764 fst_remove_session(apdev, test_params,
1765 remove_scenario_established_session, False)
1767 def test_fst_sta_remove_session_no_params(dev, apdev, test_params):
1768 """FST STA remove session - no params"""
1769 fst_remove_session(apdev, test_params, remove_scenario_no_params, False)
1771 def test_fst_sta_remove_session_bad_session_id(dev, apdev, test_params):
1772 """FST STA remove session - bad session id"""
1773 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id,
1776 def test_fst_rsn_ap_transfer_session(dev, apdev, test_params):
1777 """FST RSN AP transfer session"""
1778 fst_transfer_session(apdev, test_params, bad_param_none, True, rsn=True)
1780 MGMT_SUBTYPE_ACTION = 13
1781 ACTION_CATEG_FST = 18
1782 FST_ACTION_SETUP_REQUEST = 0
1783 FST_ACTION_SETUP_RESPONSE = 1
1784 FST_ACTION_TEAR_DOWN = 2
1785 FST_ACTION_ACK_REQUEST = 3
1786 FST_ACTION_ACK_RESPONSE = 4
1787 FST_ACTION_ON_CHANNEL_TUNNEL = 5
1789 def test_fst_proto(dev, apdev, test_params):
1790 """FST protocol testing"""
1791 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1793 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1794 hapd = ap1.get_instance()
1795 sta = sta1.get_instance()
1796 dst = sta.own_addr()
1797 src = apdev[0]['bssid']
1800 msg['fc'] = MGMT_SUBTYPE_ACTION << 4
1805 # unknown FST Action (255) received!
1806 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST, 255)
1810 # FST Request dropped: too short
1811 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1812 FST_ACTION_SETUP_REQUEST)
1816 # FST Request dropped: new and old band IDs are the same
1817 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1818 FST_ACTION_SETUP_REQUEST, 0, 0,
1819 164, 11, 0, 0, 0, 0, 0, 0, 0, 0)
1823 ifaces = sta1.list_ifaces()
1824 id = int(ifaces[0]['name'].split('|')[1])
1825 # FST Request dropped: new iface not found (new_band_id mismatch)
1826 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1827 FST_ACTION_SETUP_REQUEST, 0, 0,
1828 164, 11, 0, 0, id + 1, 0, 0, 0, 0, 0)
1832 # FST Action 'Setup Response' dropped: no session in progress found
1833 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1834 FST_ACTION_SETUP_RESPONSE)
1840 new_iface = ap2.ifname()
1841 new_peer_addr = ap2.get_actual_peer_addr()
1842 resp_newif = sta2.ifname()
1844 initiator.add_peer(responder, peeraddr, new_peer_addr)
1845 sid = initiator.add_session()
1846 initiator.configure_session(sid, new_iface)
1847 initiator.initiate_session(sid, "accept")
1849 # FST Response dropped due to wrong state: SETUP_COMPLETION
1850 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1851 FST_ACTION_SETUP_RESPONSE)
1855 # Too short FST Tear Down dropped
1856 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1857 FST_ACTION_TEAR_DOWN)
1861 # tear down for wrong FST Setup ID (0)
1862 msg['payload'] = struct.pack("<BBL", ACTION_CATEG_FST,
1863 FST_ACTION_TEAR_DOWN, 0)
1867 # Ack received on wrong interface
1868 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1869 FST_ACTION_ACK_REQUEST)
1873 # Ack Response in inappropriate session state (SETUP_COMPLETION)
1874 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1875 FST_ACTION_ACK_RESPONSE)
1879 # Unsupported FST Action frame (On channel tunnel)
1880 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1881 FST_ACTION_ON_CHANNEL_TUNNEL)
1885 # FST Request dropped: new iface not found (new_band_id match)
1886 # FST Request dropped due to MAC comparison
1887 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1888 FST_ACTION_SETUP_REQUEST, 0, 0,
1889 164, 11, 0, 0, id, 0, 0, 0, 0, 0)
1893 hapd2 = ap2.get_instance()
1894 dst2 = sta2.get_instance().own_addr()
1895 src2 = apdev[1]['bssid']
1898 msg2['fc'] = MGMT_SUBTYPE_ACTION << 4
1901 msg2['bssid'] = src2
1902 # FST Response dropped: wlan6 is not the old iface
1903 msg2['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1904 FST_ACTION_SETUP_RESPONSE)
1910 group = ap1.fst_group
1911 ap1.send_iface_detach_request(ap1.iface)
1913 sta.flush_scan_cache()
1914 sta.request("REASSOCIATE")
1915 sta.wait_connected()
1917 # FST Request dropped due to no interface connection
1918 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1919 FST_ACTION_SETUP_REQUEST, 0, 0,
1920 164, 11, 0, 0, id, 0, 0, 0, 0, 0)
1923 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1925 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1929 def test_fst_ap_config_oom(dev, apdev, test_params):
1930 """FST AP configuration and OOM"""
1931 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1932 fst_test_common.fst_test_def_chan_a,
1933 fst_test_common.fst_test_def_group,
1934 fst_test_common.fst_test_def_prio_low)
1935 hapd = ap1.start(return_early=True)
1936 with alloc_fail(hapd, 1, "fst_group_create"):
1937 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
1938 if not res.startswith("FAIL"):
1939 raise Exception("FST-ATTACH succeeded unexpectedly")
1941 with alloc_fail(hapd, 1, "fst_iface_create"):
1942 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
1943 if not res.startswith("FAIL"):
1944 raise Exception("FST-ATTACH succeeded unexpectedly")
1946 with alloc_fail(hapd, 1, "fst_group_create_mb_ie"):
1947 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
1948 # This is allowed to complete currently
1952 def test_fst_send_oom(dev, apdev, test_params):
1953 """FST send action OOM"""
1954 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1956 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1957 hapd = ap1.get_instance()
1958 sta = sta1.get_instance()
1959 dst = sta.own_addr()
1960 src = apdev[0]['bssid']
1965 new_iface = ap2.ifname()
1966 new_peer_addr = ap2.get_actual_peer_addr()
1967 resp_newif = sta2.ifname()
1969 initiator.add_peer(responder, peeraddr, new_peer_addr)
1970 sid = initiator.add_session()
1971 initiator.configure_session(sid, new_iface)
1972 with alloc_fail(hapd, 1, "fst_session_send_action"):
1973 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
1974 if not res.startswith("FAIL"):
1975 raise Exception("Unexpected SESSION_INITIATE result")
1977 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
1978 if not res.startswith("OK"):
1979 raise Exception("SESSION_INITIATE failed")
1981 tests = [ "", "foo", sid, sid + " foo", sid + " foo=bar" ]
1983 res = initiator.grequest("FST-MANAGER SESSION_SET " + t)
1984 if not res.startswith("FAIL"):
1985 raise Exception("Invalid SESSION_SET accepted")
1987 with alloc_fail(hapd, 1, "fst_session_send_action"):
1988 res = initiator.grequest("FST-MANAGER SESSION_TEARDOWN " + sid)
1989 if not res.startswith("FAIL"):
1990 raise Exception("Unexpected SESSION_TEARDOWN result")
1992 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1993 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1995 def test_fst_session_oom(dev, apdev, test_params):
1996 """FST session create OOM"""
1997 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1999 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2000 hapd = ap1.get_instance()
2001 sta = sta1.get_instance()
2002 dst = sta.own_addr()
2003 src = apdev[0]['bssid']
2008 new_iface = ap2.ifname()
2009 new_peer_addr = ap2.get_actual_peer_addr()
2010 resp_newif = sta2.ifname()
2012 initiator.add_peer(responder, peeraddr, new_peer_addr)
2013 with alloc_fail(hapd, 1, "fst_session_create"):
2014 sid = initiator.grequest("FST-MANAGER SESSION_ADD " + initiator.fst_group)
2015 if not sid.startswith("FAIL"):
2016 raise Exception("Unexpected SESSION_ADD success")
2017 sid = initiator.add_session()
2018 initiator.configure_session(sid, new_iface)
2019 with alloc_fail(sta, 1, "fst_session_create"):
2020 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
2021 if not res.startswith("OK"):
2022 raise Exception("Unexpected SESSION_INITIATE result")
2024 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2025 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2027 def test_fst_attach_zero_llt(dev, apdev):
2028 """FST attach with llt=0"""
2029 sta1 = fst_module_aux.FstSTA('wlan5', fst_test_common.fst_test_def_group,