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()
16 from hwsim import HWSimRadio
18 from wpasupplicant import WpaSupplicant
19 import fst_test_common
21 from utils import alloc_fail, HwsimSkip
23 #enum - bad parameter types
25 bad_param_session_add_no_params = 1
26 bad_param_group_id = 2
27 bad_param_session_set_no_params = 3
28 bad_param_session_set_unknown_param = 4
29 bad_param_session_id = 5
30 bad_param_old_iface = 6
31 bad_param_new_iface = 7
32 bad_param_negative_llt = 8
33 bad_param_zero_llt = 9
34 bad_param_llt_too_big = 10
35 bad_param_llt_nan = 11
36 bad_param_peer_addr = 12
37 bad_param_session_initiate_no_params = 13
38 bad_param_session_initiate_bad_session_id = 14
39 bad_param_session_initiate_with_no_new_iface_set = 15
40 bad_param_session_initiate_with_bad_peer_addr_set = 16
41 bad_param_session_initiate_request_with_bad_stie = 17
42 bad_param_session_initiate_response_with_reject = 18
43 bad_param_session_initiate_response_with_bad_stie = 19
44 bad_param_session_initiate_response_with_zero_llt = 20
45 bad_param_session_initiate_stt_no_response = 21
46 bad_param_session_initiate_concurrent_setup_request = 22
47 bad_param_session_transfer_no_params = 23
48 bad_param_session_transfer_bad_session_id = 24
49 bad_param_session_transfer_setup_skipped = 25
50 bad_param_session_teardown_no_params = 26
51 bad_param_session_teardown_bad_session_id = 27
52 bad_param_session_teardown_setup_skipped = 28
53 bad_param_session_teardown_bad_fsts_id = 29
55 bad_param_names = ("None",
56 "No params passed to session add",
58 "No params passed to session set",
59 "Unknown param passed to session set",
66 "LLT is not a number",
68 "No params passed to session initiate",
70 "No new_iface was set",
72 "Request with bad st ie",
73 "Response with reject",
74 "Response with bad st ie",
75 "Response with zero llt",
77 "Concurrent setup request",
78 "No params passed to session transfer",
80 "Session setup skipped",
81 "No params passed to session teardown",
83 "Session setup skipped",
86 def fst_start_session(apdev, test_params, bad_param_type, start_on_ap,
88 """This function makes the necessary preparations and the adds and sets a
89 session using either correct or incorrect parameters depending on the value
90 of bad_param_type. If the call ends as expected (with session being
91 successfully added and set in case of correct parameters or with the
92 expected exception in case of incorrect parameters), the function silently
93 exits. Otherwise, it throws an exception thus failing the test."""
95 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
96 bad_parameter_detected = False
97 exception_already_raised = False
99 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
103 new_iface = ap2.ifname()
104 new_peer_addr = ap2.get_actual_peer_addr()
108 new_iface = sta2.ifname()
109 new_peer_addr = sta2.get_actual_peer_addr()
110 initiator.add_peer(responder, peer_addr, new_peer_addr)
112 if bad_param_type == bad_param_group_id:
114 elif bad_param_type == bad_param_session_add_no_params:
116 initiator.set_fst_parameters(group_id=group_id)
117 sid = initiator.add_session()
118 if bad_param_type == bad_param_session_set_no_params:
119 res = initiator.set_session_param(None)
120 if not res.startswith("OK"):
121 raise Exception("Session set operation failed")
122 elif bad_param_type == bad_param_session_set_unknown_param:
123 res = initiator.set_session_param("bad_param=1")
124 if not res.startswith("OK"):
125 raise Exception("Session set operation failed")
127 if bad_param_type == bad_param_session_initiate_with_no_new_iface_set:
129 elif bad_param_type == bad_param_new_iface:
131 old_iface = None if bad_param_type != bad_param_old_iface else 'wlan12'
133 if bad_param_type == bad_param_negative_llt:
135 elif bad_param_type == bad_param_zero_llt:
137 elif bad_param_type == bad_param_llt_too_big:
138 llt = '4294967296' #0x100000000
139 elif bad_param_type == bad_param_llt_nan:
141 elif bad_param_type == bad_param_session_id:
143 initiator.set_fst_parameters(llt=llt)
144 initiator.configure_session(sid, new_iface, old_iface)
146 if e.args[0].startswith("Cannot add FST session with groupid"):
147 if bad_param_type == bad_param_group_id or bad_param_type == bad_param_session_add_no_params:
148 bad_parameter_detected = True
149 elif e.args[0].startswith("Cannot set FST session new_ifname:"):
150 if bad_param_type == bad_param_new_iface:
151 bad_parameter_detected = True
152 elif e.args[0].startswith("Session set operation failed"):
153 if (bad_param_type == bad_param_session_set_no_params or
154 bad_param_type == bad_param_session_set_unknown_param):
155 bad_parameter_detected = True
156 elif e.args[0].startswith("Cannot set FST session old_ifname:"):
157 if (bad_param_type == bad_param_old_iface or
158 bad_param_type == bad_param_session_id or
159 bad_param_type == bad_param_session_set_no_params):
160 bad_parameter_detected = True
161 elif e.args[0].startswith("Cannot set FST session llt:"):
162 if (bad_param_type == bad_param_negative_llt or
163 bad_param_type == bad_param_llt_too_big or
164 bad_param_type == bad_param_llt_nan):
165 bad_parameter_detected = True
166 elif e.args[0].startswith("Cannot set FST session peer address:"):
167 if bad_param_type == bad_param_peer_addr:
168 bad_parameter_detected = True
169 if not bad_parameter_detected:
170 # The exception was unexpected
172 exception_already_raised = True
175 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
176 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
177 if not exception_already_raised:
178 if bad_parameter_detected:
179 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
181 if bad_param_type == bad_param_none or bad_param_type == bad_param_zero_llt:
182 logger.info("Success. Session added and set")
185 if bad_param_type == bad_param_peer_addr:
186 exception_text = "Failure. Bad parameter was not detected (Peer address == %s)" % ap1.get_new_peer_addr()
188 exception_text = "Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type]
189 raise Exception(exception_text)
191 logger.info("Failure. Unexpected exception")
193 def fst_initiate_session(apdev, test_params, bad_param_type, init_on_ap):
194 """This function makes the necessary preparations and then adds, sets and
195 initiates a session using either correct or incorrect parameters at each
196 stage depending on the value of bad_param_type. If the call ends as expected
197 (with session being successfully added, set and initiated in case of correct
198 parameters or with the expected exception in case of incorrect parameters),
199 the function silently exits. Otherwise it throws an exception thus failing
201 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
202 bad_parameter_detected = False
203 exception_already_raised = False
205 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
206 # This call makes sure FstHostapd singleton object is created and, as a
207 # result, the global control interface is registered (this is done from
209 ap1.get_global_instance()
213 new_iface = ap2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
214 new_peer_addr = ap2.get_actual_peer_addr()
215 resp_newif = sta2.ifname()
219 new_iface = sta2.ifname() if bad_param_type != bad_param_session_initiate_with_no_new_iface_set else None
220 new_peer_addr = sta2.get_actual_peer_addr()
221 resp_newif = ap2.ifname()
222 peeraddr = None if bad_param_type != bad_param_session_initiate_with_bad_peer_addr_set else '10:DE:AD:DE:AD:11'
223 initiator.add_peer(responder, peeraddr, new_peer_addr)
224 if bad_param_type == bad_param_session_initiate_response_with_zero_llt:
225 initiator.set_fst_parameters(llt='0')
226 sid = initiator.add_session()
227 initiator.configure_session(sid, new_iface)
228 if bad_param_type == bad_param_session_initiate_no_params:
230 elif bad_param_type == bad_param_session_initiate_bad_session_id:
232 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
233 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
234 initiator.send_test_session_setup_request(str(actual_fsts_id), "bad_new_band")
235 responder.wait_for_session_event(5)
236 elif bad_param_type == bad_param_session_initiate_response_with_reject:
237 initiator.send_session_setup_request(sid)
238 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
239 setup_event = responder.wait_for_session_event(5, [],
241 if not 'id' in setup_event:
242 raise Exception("No session id in FST setup event")
243 responder.send_session_setup_response(str(setup_event['id']),
245 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
246 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_REJECT":
247 raise Exception("Response with reject not handled as expected")
248 bad_parameter_detected = True
249 elif bad_param_type == bad_param_session_initiate_response_with_bad_stie:
250 initiator.send_session_setup_request(sid)
251 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
252 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
253 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
254 responder.send_test_session_setup_response(str(actual_fsts_id),
255 "accept", "bad_new_band")
256 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
257 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_ERROR_PARAMS":
258 raise Exception("Response with bad STIE not handled as expected")
259 bad_parameter_detected = True
260 elif bad_param_type == bad_param_session_initiate_response_with_zero_llt:
261 initiator.initiate_session(sid, "accept")
262 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
263 if event['new_state'] != "TRANSITION_DONE":
264 raise Exception("Response reception for a session with llt=0 not handled as expected")
265 bad_parameter_detected = True
266 elif bad_param_type == bad_param_session_initiate_stt_no_response:
267 initiator.send_session_setup_request(sid)
268 initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
269 responder.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
270 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
271 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
272 raise Exception("No response scenario not handled as expected")
273 bad_parameter_detected = True
274 elif bad_param_type == bad_param_session_initiate_concurrent_setup_request:
275 responder.add_peer(initiator)
276 resp_sid = responder.add_session()
277 responder.configure_session(resp_sid, resp_newif)
278 initiator.send_session_setup_request(sid)
279 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
280 responder.send_test_session_setup_request(str(actual_fsts_id))
281 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
282 initiator_addr = initiator.get_own_mac_address()
283 responder_addr = responder.get_own_mac_address()
284 if initiator_addr < responder_addr:
285 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
286 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_SETUP":
287 raise Exception("Concurrent setup scenario not handled as expected")
288 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SETUP"])
289 # The incoming setup request received by the initiator has
290 # priority over the one sent previously by the initiator itself
291 # because the initiator's MAC address is numerically lower than
292 # the one of the responder. Thus, the initiator should generate
293 # an FST_SETUP event.
295 event = initiator.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
296 if event['new_state'] != "INITIAL" or event['reason'] != "REASON_STT":
297 raise Exception("Concurrent setup scenario not handled as expected")
298 # The incoming setup request was dropped at the initiator
299 # because its MAC address is numerically bigger than the one of
300 # the responder. Thus, the initiator continue to wait for a
301 # setup response until the STT event fires.
302 bad_parameter_detected = True
304 initiator.initiate_session(sid, "accept")
306 if e.args[0].startswith("Cannot initiate fst session"):
307 if bad_param_type != bad_param_none:
308 bad_parameter_detected = True
309 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
310 if bad_param_type == bad_param_session_initiate_request_with_bad_stie:
311 bad_parameter_detected = True
312 if not bad_parameter_detected:
313 #The exception was unexpected
315 exception_already_raised = True
318 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
319 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
320 if not exception_already_raised:
321 if bad_parameter_detected:
322 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
324 if bad_param_type == bad_param_none:
325 logger.info("Success. Session initiated")
327 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
329 logger.info("Failure. Unexpected exception")
331 def fst_transfer_session(apdev, test_params, bad_param_type, init_on_ap,
333 """This function makes the necessary preparations and then adds, sets,
334 initiates and attempts to transfer a session using either correct or
335 incorrect parameters at each stage depending on the value of bad_param_type.
336 If the call ends as expected the function silently exits. Otherwise, it
337 throws an exception thus failing the test."""
338 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev, rsn=rsn)
339 bad_parameter_detected = False
340 exception_already_raised = False
342 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2, rsn=rsn)
343 # This call makes sure FstHostapd singleton object is created and, as a
344 # result, the global control interface is registered (this is done from
346 ap1.get_global_instance()
350 new_iface = ap2.ifname()
351 new_peer_addr = ap2.get_actual_peer_addr()
355 new_iface = sta2.ifname()
356 new_peer_addr = sta2.get_actual_peer_addr()
357 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
358 sid = initiator.add_session()
359 initiator.configure_session(sid, new_iface)
360 if bad_param_type != bad_param_session_transfer_setup_skipped:
361 initiator.initiate_session(sid, "accept")
362 if bad_param_type == bad_param_session_transfer_no_params:
364 elif bad_param_type == bad_param_session_transfer_bad_session_id:
366 initiator.transfer_session(sid)
368 if e.args[0].startswith("Cannot transfer fst session"):
369 if bad_param_type != bad_param_none:
370 bad_parameter_detected = True
371 if not bad_parameter_detected:
372 # The exception was unexpected
374 exception_already_raised = True
377 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
378 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
379 if not exception_already_raised:
380 if bad_parameter_detected:
381 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
383 if bad_param_type == bad_param_none:
384 logger.info("Success. Session transferred")
386 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
388 logger.info("Failure. Unexpected exception")
391 def fst_tear_down_session(apdev, test_params, bad_param_type, init_on_ap):
392 """This function makes the necessary preparations and then adds, sets, and
393 initiates a session. It then issues a tear down command using either
394 correct or incorrect parameters at each stage. If the call ends as expected,
395 the function silently exits. Otherwise, it throws an exception thus failing
397 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
398 bad_parameter_detected = False
399 exception_already_raised = False
401 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
402 # This call makes sure FstHostapd singleton object is created and, as a
403 # result, the global control interface is registered (this is done from
405 ap1.get_global_instance()
409 new_iface = ap2.ifname()
410 new_peer_addr = ap2.get_actual_peer_addr()
414 new_iface = sta2.ifname()
415 new_peer_addr = sta2.get_actual_peer_addr()
416 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
417 sid = initiator.add_session()
418 initiator.configure_session(sid, new_iface)
419 if bad_param_type != bad_param_session_teardown_setup_skipped:
420 initiator.initiate_session(sid, "accept")
421 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
422 initiator.send_test_tear_down('-1')
423 responder.wait_for_session_event(5)
425 if bad_param_type == bad_param_session_teardown_no_params:
427 elif bad_param_type == bad_param_session_teardown_bad_session_id:
429 initiator.teardown_session(sid)
431 if e.args[0].startswith("Cannot tear down fst session"):
432 if (bad_param_type == bad_param_session_teardown_no_params or
433 bad_param_type == bad_param_session_teardown_bad_session_id or
434 bad_param_type == bad_param_session_teardown_setup_skipped):
435 bad_parameter_detected = True
436 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
437 if bad_param_type == bad_param_session_teardown_bad_fsts_id:
438 bad_parameter_detected = True
439 if not bad_parameter_detected:
440 # The exception was unexpected
442 exception_already_raised = True
445 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
446 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
447 if not exception_already_raised:
448 if bad_parameter_detected:
449 logger.info("Success. Bad parameter was detected (%s)" % bad_param_names[bad_param_type])
451 if bad_param_type == bad_param_none:
452 logger.info("Success. Session torn down")
454 raise Exception("Failure. Bad parameter was not detected (%s)" % bad_param_names[bad_param_type])
456 logger.info("Failure. Unexpected exception")
459 #enum - remove session scenarios
460 remove_scenario_no_params = 0
461 remove_scenario_bad_session_id = 1
462 remove_scenario_non_established_session = 2
463 remove_scenario_established_session = 3
465 remove_scenario_names = ("No params",
467 "Remove non-established session",
468 "Remove established session")
471 def fst_remove_session(apdev, test_params, remove_session_scenario, init_on_ap):
472 """This function attempts to remove a session at various stages of its
473 formation, depending on the value of remove_session_scenario. If the call
474 ends as expected, the function silently exits. Otherwise, it throws an
475 exception thus failing the test."""
476 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
477 bad_parameter_detected = False
478 exception_already_raised = False
480 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
481 # This call makes sure FstHostapd singleton object is created and, as a
482 # result, the global control interface is registered (this is done from
484 ap1.get_global_instance()
488 new_iface = ap2.ifname()
489 new_peer_addr = ap2.get_actual_peer_addr()
493 new_iface = sta2.ifname()
494 new_peer_addr = sta2.get_actual_peer_addr()
495 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
496 sid = initiator.add_session()
497 initiator.configure_session(sid, new_iface)
498 if remove_session_scenario != remove_scenario_no_params:
499 if remove_session_scenario != remove_scenario_non_established_session:
500 initiator.initiate_session(sid, "accept")
501 if remove_session_scenario == remove_scenario_no_params:
503 elif remove_session_scenario == remove_scenario_bad_session_id:
505 initiator.remove_session(sid)
507 if e.args[0].startswith("Cannot remove fst session"):
508 if (remove_session_scenario == remove_scenario_no_params or
509 remove_session_scenario == remove_scenario_bad_session_id):
510 bad_parameter_detected = True
511 elif e.args[0].startswith("No FST-EVENT-SESSION received"):
512 if remove_session_scenario == remove_scenario_non_established_session:
513 bad_parameter_detected = True
514 if not bad_parameter_detected:
515 #The exception was unexpected
517 exception_already_raised = True
520 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
521 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
522 if not exception_already_raised:
523 if bad_parameter_detected:
524 logger.info("Success. Remove scenario ended as expected (%s)" % remove_scenario_names[remove_session_scenario])
526 if remove_session_scenario == remove_scenario_established_session:
527 logger.info("Success. Session removed")
529 raise Exception("Failure. Remove scenario ended in an unexpected way (%s)" % remove_scenario_names[remove_session_scenario])
531 logger.info("Failure. Unexpected exception")
535 frame_type_session_request = 0
536 frame_type_session_response = 1
537 frame_type_ack_request = 2
538 frame_type_ack_response = 3
539 frame_type_tear_down = 4
541 frame_type_names = ("Session request",
547 def fst_send_unexpected_frame(apdev, test_params, frame_type, send_from_ap, additional_param = ''):
548 """This function creates two pairs of APs and stations, makes them connect
549 and then causes one side to send an unexpected FST frame of the specified
550 type to the other. The other side should then identify and ignore the
552 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
553 exception_already_raised = False
554 frame_receive_timeout = False
556 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
557 # This call makes sure FstHostapd singleton object is created and, as a
558 # result, the global control interface is registered (this is done from
560 ap1.get_global_instance()
564 new_iface = ap2.ifname()
565 new_peer_addr = ap2.get_actual_peer_addr()
569 new_iface = sta2.ifname()
570 new_peer_addr = sta2.get_actual_peer_addr()
571 sender.add_peer(receiver, new_peer_addr = new_peer_addr)
572 sid=sender.add_session()
573 sender.configure_session(sid, new_iface)
574 if frame_type == frame_type_session_request:
575 sender.send_session_setup_request(sid)
576 event = receiver.wait_for_session_event(5)
577 if event['type'] != 'EVENT_FST_SETUP':
578 raise Exception("Unexpected indication: " + event['type'])
579 elif frame_type == frame_type_session_response:
580 #fsts_id doesn't matter, no actual session exists
581 sender.send_test_session_setup_response('0', additional_param)
582 receiver.wait_for_session_event(5)
583 elif frame_type == frame_type_ack_request:
584 #fsts_id doesn't matter, no actual session exists
585 sender.send_test_ack_request('0')
586 receiver.wait_for_session_event(5)
587 elif frame_type == frame_type_ack_response:
588 #fsts_id doesn't matter, no actual session exists
589 sender.send_test_ack_response('0')
590 receiver.wait_for_session_event(5)
591 elif frame_type == frame_type_tear_down:
592 #fsts_id doesn't matter, no actual session exists
593 sender.send_test_tear_down('0')
594 receiver.wait_for_session_event(5)
596 if e.args[0].startswith("No FST-EVENT-SESSION received"):
597 if frame_type != frame_type_session_request:
598 frame_receive_timeout = True
601 exception_already_raised = True
604 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
605 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
606 if not exception_already_raised:
607 if frame_receive_timeout:
608 logger.info("Success. Frame was ignored (%s)" % frame_type_names[frame_type])
610 if frame_type == frame_type_session_request:
611 logger.info("Success. Frame received, session created")
613 raise Exception("Failure. Frame was not ignored (%s)" % frame_type_names[frame_type])
615 logger.info("Failure. Unexpected exception")
618 #enum - bad session transfer scenarios
619 bad_scenario_none = 0
620 bad_scenario_ack_req_session_not_set_up = 1
621 bad_scenario_ack_req_session_not_established_init_side = 2
622 bad_scenario_ack_req_session_not_established_resp_side = 3
623 bad_scenario_ack_req_bad_fsts_id = 4
624 bad_scenario_ack_resp_session_not_set_up = 5
625 bad_scenario_ack_resp_session_not_established_init_side = 6
626 bad_scenario_ack_resp_session_not_established_resp_side = 7
627 bad_scenario_ack_resp_no_ack_req = 8
628 bad_scenario_ack_resp_bad_fsts_id = 9
630 bad_scenario_names = ("None",
631 "Ack request received before the session was set up",
632 "Ack request received on the initiator side before session was established",
633 "Ack request received on the responder side before session was established",
634 "Ack request received with bad fsts_id",
635 "Ack response received before the session was set up",
636 "Ack response received on the initiator side before session was established",
637 "Ack response received on the responder side before session was established",
638 "Ack response received before ack request was sent",
639 "Ack response received with bad fsts_id")
641 def fst_bad_transfer(apdev, test_params, bad_scenario_type, init_on_ap):
642 """This function makes the necessary preparations and then adds and sets a
643 session. It then initiates and it unless instructed otherwise) and attempts
644 to send one of the frames involved in the session transfer protocol,
645 skipping or distorting one of the stages according to the value of
646 bad_scenario_type parameter."""
647 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
648 bad_parameter_detected = False
649 exception_already_raised = False
651 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
652 # This call makes sure FstHostapd singleton object is created and, as a
653 # result, the global control interface is registered (this is done from
655 ap1.get_global_instance()
659 new_iface = ap2.ifname()
660 new_peer_addr = ap2.get_actual_peer_addr()
664 new_iface = sta2.ifname()
665 new_peer_addr = sta2.get_actual_peer_addr()
666 initiator.add_peer(responder, new_peer_addr = new_peer_addr)
667 sid = initiator.add_session()
668 initiator.configure_session(sid, new_iface)
669 if (bad_scenario_type != bad_scenario_ack_req_session_not_set_up and
670 bad_scenario_type != bad_scenario_ack_resp_session_not_set_up):
671 if (bad_scenario_type != bad_scenario_ack_req_session_not_established_init_side and
672 bad_scenario_type != bad_scenario_ack_resp_session_not_established_init_side and
673 bad_scenario_type != bad_scenario_ack_req_session_not_established_resp_side and
674 bad_scenario_type != bad_scenario_ack_resp_session_not_established_resp_side):
678 initiator.initiate_session(sid, response)
679 if bad_scenario_type == bad_scenario_ack_req_session_not_set_up:
680 #fsts_id doesn't matter, no actual session exists
681 responder.send_test_ack_request('0')
682 initiator.wait_for_session_event(5)
683 # We want to send the unexpected frame to the side that already has
685 elif bad_scenario_type == bad_scenario_ack_resp_session_not_set_up:
686 #fsts_id doesn't matter, no actual session exists
687 responder.send_test_ack_response('0')
688 initiator.wait_for_session_event(5)
689 # We want to send the unexpected frame to the side that already has
691 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_init_side:
692 #fsts_id doesn't matter, no actual session exists
693 initiator.send_test_ack_request('0')
694 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
695 elif bad_scenario_type == bad_scenario_ack_req_session_not_established_resp_side:
696 #fsts_id doesn't matter, no actual session exists
697 responder.send_test_ack_request('0')
698 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
699 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_init_side:
700 #fsts_id doesn't matter, no actual session exists
701 initiator.send_test_ack_response('0')
702 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
703 elif bad_scenario_type == bad_scenario_ack_resp_session_not_established_resp_side:
704 #fsts_id doesn't matter, no actual session exists
705 responder.send_test_ack_response('0')
706 initiator.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
707 elif bad_scenario_type == bad_scenario_ack_req_bad_fsts_id:
708 initiator.send_test_ack_request('-1')
709 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
710 elif bad_scenario_type == bad_scenario_ack_resp_bad_fsts_id:
711 initiator.send_test_ack_response('-1')
712 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
713 elif bad_scenario_type == bad_scenario_ack_resp_no_ack_req:
714 actual_fsts_id = initiator.get_fsts_id_by_sid(sid)
715 initiator.send_test_ack_response(str(actual_fsts_id))
716 responder.wait_for_session_event(5, ["EVENT_FST_SESSION_STATE"])
718 raise Exception("Unknown bad scenario identifier")
720 if e.args[0].startswith("No FST-EVENT-SESSION received"):
721 bad_parameter_detected = True
722 if not bad_parameter_detected:
723 # The exception was unexpected
725 exception_already_raised = True
728 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
729 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
730 if not exception_already_raised:
731 if bad_parameter_detected:
732 logger.info("Success. Bad scenario was handled correctly (%s)" % bad_scenario_names[bad_scenario_type])
734 raise Exception("Failure. Bad scenario was handled incorrectly (%s)" % bad_scenario_names[bad_scenario_type])
736 logger.info("Failure. Unexpected exception")
738 def test_fst_sta_connect_to_non_fst_ap(dev, apdev, test_params):
739 """FST STA connecting to non-FST AP"""
740 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
741 with HWSimRadio() as (radio, iface):
742 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
744 orig_sta1_mbies = sta1.get_local_mbies()
745 orig_sta2_mbies = sta2.get_local_mbies()
748 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g",
749 key_mgmt="NONE", scan_freq=freq)
751 res_sta1_mbies = sta1.get_local_mbies()
752 res_sta2_mbies = sta2.get_local_mbies()
753 if (orig_sta1_mbies.startswith("FAIL") or
754 orig_sta2_mbies.startswith("FAIL") or
755 res_sta1_mbies.startswith("FAIL") or
756 res_sta2_mbies.startswith("FAIL")):
757 raise Exception("Failure. MB IEs must be present on the stations")
762 sta2.disconnect_from_external_ap()
763 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
764 hostapd.HostapdGlobal().remove(iface)
766 def test_fst_sta_connect_to_fst_ap(dev, apdev, test_params):
767 """FST STA connecting to FST AP"""
768 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
770 orig_sta2_mbies = sta2.get_local_mbies()
771 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
772 sta1.connect(ap1, key_mgmt="NONE",
773 scan_freq=fst_test_common.fst_test_def_freq_a)
775 res_sta2_mbies = sta2.get_local_mbies()
776 if res_sta2_mbies == orig_sta2_mbies:
777 raise Exception("Failure. MB IEs have not been updated")
783 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
785 def test_fst_ap_connect_to_fst_sta(dev, apdev, test_params):
786 """FST AP connecting to FST STA"""
787 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
789 orig_ap_mbies = ap1.get_local_mbies()
790 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
791 sta1.connect(ap1, key_mgmt="NONE",
792 scan_freq=fst_test_common.fst_test_def_freq_a)
794 res_ap_mbies = ap1.get_local_mbies()
795 if res_ap_mbies != orig_ap_mbies:
796 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
802 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
804 def test_fst_ap_connect_to_non_fst_sta(dev, apdev, test_params):
805 """FST AP connecting to non-FST STA"""
806 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
808 orig_ap_mbies = ap2.get_local_mbies()
809 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
810 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
811 scan_freq=fst_test_common.fst_test_def_freq_g)
813 res_ap_mbies = ap2.get_local_mbies()
814 if res_ap_mbies != orig_ap_mbies:
815 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
820 fst_module_aux.disconnect_external_sta(dev[0], ap2)
821 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
823 def test_fst_second_sta_connect_to_non_fst_ap(dev, apdev, test_params):
824 """FST STA 2nd connecting to non-FST AP"""
825 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
826 with HWSimRadio() as (radio, iface):
827 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
829 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
830 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
832 orig_sta1_mbies = sta1.get_local_mbies()
833 orig_sta2_mbies = sta2.get_local_mbies()
836 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
838 res_sta1_mbies = sta1.get_local_mbies()
839 res_sta2_mbies = sta2.get_local_mbies()
840 if (orig_sta1_mbies.startswith("FAIL") or
841 orig_sta2_mbies.startswith("FAIL") or
842 res_sta1_mbies.startswith("FAIL") or
843 res_sta2_mbies.startswith("FAIL")):
844 raise Exception("Failure. MB IEs must be present on the stations")
850 sta2.disconnect_from_external_ap()
851 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
852 hostapd.HostapdGlobal().remove(iface)
854 def test_fst_second_sta_connect_to_fst_ap(dev, apdev, test_params):
855 """FST STA 2nd connecting to FST AP"""
856 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
857 with HWSimRadio() as (radio, iface):
858 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
862 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
864 orig_sta1_mbies = sta1.get_local_mbies()
865 orig_sta2_mbies = sta2.get_local_mbies()
866 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
867 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
869 res_sta1_mbies = sta1.get_local_mbies()
870 res_sta2_mbies = sta2.get_local_mbies()
871 if (orig_sta1_mbies.startswith("FAIL") or
872 orig_sta2_mbies.startswith("FAIL") or
873 res_sta1_mbies.startswith("FAIL") or
874 res_sta2_mbies.startswith("FAIL")):
875 raise Exception("Failure. MB IEs must be present on the stations")
881 sta2.disconnect_from_external_ap()
882 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
883 hostapd.HostapdGlobal().remove(iface)
885 def test_fst_disconnect_1_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
886 """FST disconnect 1 of 2 STAs from non-FST AP"""
887 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
888 with HWSimRadio() as (radio, iface):
889 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
891 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
892 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
895 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
897 orig_sta1_mbies = sta1.get_local_mbies()
898 orig_sta2_mbies = sta2.get_local_mbies()
899 sta2.disconnect_from_external_ap()
901 res_sta1_mbies = sta1.get_local_mbies()
902 res_sta2_mbies = sta2.get_local_mbies()
903 if (orig_sta1_mbies.startswith("FAIL") or
904 orig_sta2_mbies.startswith("FAIL") or
905 res_sta1_mbies.startswith("FAIL") or
906 res_sta2_mbies.startswith("FAIL")):
907 raise Exception("Failure. MB IEs must be present on the stations")
913 sta2.disconnect_from_external_ap()
914 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
915 hostapd.HostapdGlobal().remove(iface)
917 def test_fst_disconnect_1_of_2_stas_from_fst_ap(dev, apdev, test_params):
918 """FST disconnect 1 of 2 STAs from FST AP"""
919 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
920 with HWSimRadio() as (radio, iface):
921 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
923 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
924 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
927 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
929 orig_sta1_mbies = sta1.get_local_mbies()
930 orig_sta2_mbies = sta2.get_local_mbies()
933 res_sta1_mbies = sta1.get_local_mbies()
934 res_sta2_mbies = sta2.get_local_mbies()
935 if (orig_sta1_mbies.startswith("FAIL") or
936 orig_sta2_mbies.startswith("FAIL") or
937 res_sta1_mbies.startswith("FAIL") or
938 res_sta2_mbies.startswith("FAIL")):
939 raise Exception("Failure. MB IEs must be present on the stations")
945 sta2.disconnect_from_external_ap()
946 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
947 hostapd.HostapdGlobal().remove(iface)
949 def test_fst_disconnect_2_of_2_stas_from_non_fst_ap(dev, apdev, test_params):
950 """FST disconnect 2 of 2 STAs from non-FST AP"""
951 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
952 with HWSimRadio() as (radio, iface):
953 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g" })
955 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
956 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
959 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
963 orig_sta1_mbies = sta1.get_local_mbies()
964 orig_sta2_mbies = sta2.get_local_mbies()
965 sta2.disconnect_from_external_ap()
967 res_sta1_mbies = sta1.get_local_mbies()
968 res_sta2_mbies = sta2.get_local_mbies()
969 if (orig_sta1_mbies.startswith("FAIL") or
970 orig_sta2_mbies.startswith("FAIL") or
971 res_sta1_mbies.startswith("FAIL") or
972 res_sta2_mbies.startswith("FAIL")):
973 raise Exception("Failure. MB IEs must be present on the stations")
979 sta2.disconnect_from_external_ap()
980 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
981 hostapd.HostapdGlobal().remove(iface)
983 def test_fst_disconnect_2_of_2_stas_from_fst_ap(dev, apdev, test_params):
984 """FST disconnect 2 of 2 STAs from FST AP"""
985 fst_ap1, fst_ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
986 with HWSimRadio() as (radio, iface):
987 non_fst_ap = hostapd.add_ap(iface, { "ssid": "non_fst_11g"})
989 vals = sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
990 sta1.connect(fst_ap1, key_mgmt="NONE", scan_freq=fst_test_common.fst_test_def_freq_a)
993 sta2.connect_to_external_ap(non_fst_ap, ssid="non_fst_11g", key_mgmt="NONE", scan_freq=freq)
995 sta2.disconnect_from_external_ap()
997 orig_sta1_mbies = sta1.get_local_mbies()
998 orig_sta2_mbies = sta2.get_local_mbies()
1001 res_sta1_mbies = sta1.get_local_mbies()
1002 res_sta2_mbies = sta2.get_local_mbies()
1003 if (orig_sta1_mbies.startswith("FAIL") or
1004 orig_sta2_mbies.startswith("FAIL") or
1005 res_sta1_mbies.startswith("FAIL") or
1006 res_sta2_mbies.startswith("FAIL")):
1007 raise Exception("Failure. MB IEs should have stayed present on both stations")
1008 # Mandatory part of 8.4.2.140 Multi-band element is 24 bytes = 48 hex chars
1009 basic_sta1_mbies = res_sta1_mbies[0:48] + res_sta1_mbies[60:108]
1010 basic_sta2_mbies = res_sta2_mbies[0:48] + res_sta2_mbies[60:108]
1011 if (basic_sta1_mbies != basic_sta2_mbies):
1012 raise Exception("Failure. Basic MB IEs should have become identical on both stations")
1013 addr_sta1_str = sta1.get_own_mac_address().replace(":", "")
1014 addr_sta2_str = sta2.get_own_mac_address().replace(":", "")
1015 # Mandatory part of 8.4.2.140 Multi-band element is followed by STA MAC Address field (6 bytes = 12 hex chars)
1016 addr_sta1_mbie1 = res_sta1_mbies[48:60]
1017 addr_sta1_mbie2 = res_sta1_mbies[108:120]
1018 addr_sta2_mbie1 = res_sta2_mbies[48:60]
1019 addr_sta2_mbie2 = res_sta2_mbies[108:120]
1020 if (addr_sta1_mbie1 != addr_sta1_mbie2 or
1021 addr_sta1_mbie1 != addr_sta2_str or
1022 addr_sta2_mbie1 != addr_sta2_mbie2 or
1023 addr_sta2_mbie1 != addr_sta1_str):
1024 raise Exception("Failure. STA Address in MB IEs should have been same as the other STA's")
1025 except Exception, e:
1030 sta2.disconnect_from_external_ap()
1031 fst_module_aux.stop_two_ap_sta_pairs(fst_ap1, fst_ap2, sta1, sta2)
1032 hostapd.HostapdGlobal().remove(iface)
1034 def test_fst_disconnect_non_fst_sta(dev, apdev, test_params):
1035 """FST disconnect non-FST STA"""
1036 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1037 external_sta_connected = False
1039 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1040 fst_sta1.connect(ap1, key_mgmt="NONE",
1041 scan_freq=fst_test_common.fst_test_def_freq_a)
1042 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1043 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1044 scan_freq=fst_test_common.fst_test_def_freq_g)
1045 external_sta_connected = True
1047 fst_sta1.disconnect()
1049 orig_ap_mbies = ap2.get_local_mbies()
1050 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1051 external_sta_connected = False
1053 res_ap_mbies = ap2.get_local_mbies()
1054 if res_ap_mbies != orig_ap_mbies:
1055 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1056 except Exception, e:
1060 fst_sta1.disconnect()
1061 if external_sta_connected:
1062 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1063 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1065 def test_fst_disconnect_fst_sta(dev, apdev, test_params):
1066 """FST disconnect FST STA"""
1067 ap1, ap2, fst_sta1, fst_sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1068 external_sta_connected = False
1070 vals = fst_sta1.scan(freq=fst_test_common.fst_test_def_freq_a)
1071 fst_sta1.connect(ap1, key_mgmt="NONE",
1072 scan_freq=fst_test_common.fst_test_def_freq_a)
1073 vals = dev[0].scan(None, fst_test_common.fst_test_def_freq_g)
1074 fst_module_aux.external_sta_connect(dev[0], ap2, key_mgmt="NONE",
1075 scan_freq=fst_test_common.fst_test_def_freq_g)
1076 external_sta_connected = True
1078 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1079 external_sta_connected = False
1081 orig_ap_mbies = ap2.get_local_mbies()
1082 fst_sta1.disconnect()
1084 res_ap_mbies = ap2.get_local_mbies()
1085 if res_ap_mbies != orig_ap_mbies:
1086 raise Exception("Failure. MB IEs have been unexpectedly updated on the AP")
1087 except Exception, e:
1091 fst_sta1.disconnect()
1092 if external_sta_connected:
1093 fst_module_aux.disconnect_external_sta(dev[0], ap2)
1094 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, fst_sta1, fst_sta2)
1096 def test_fst_dynamic_iface_attach(dev, apdev, test_params):
1097 """FST dynamic interface attach"""
1098 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1099 fst_test_common.fst_test_def_chan_a,
1100 fst_test_common.fst_test_def_group,
1101 fst_test_common.fst_test_def_prio_low,
1102 fst_test_common.fst_test_def_llt)
1104 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1105 fst_test_common.fst_test_def_chan_g,
1109 sta1 = fst_module_aux.FstSTA('wlan5',
1110 fst_test_common.fst_test_def_group,
1111 fst_test_common.fst_test_def_prio_low,
1112 fst_test_common.fst_test_def_llt)
1114 sta2 = fst_module_aux.FstSTA('wlan6', '', '', '')
1118 orig_sta2_mbies = sta2.get_local_mbies()
1119 orig_ap2_mbies = ap2.get_local_mbies()
1120 sta2.send_iface_attach_request(sta2.ifname(),
1121 fst_test_common.fst_test_def_group,
1123 event = sta2.wait_for_iface_event(5)
1124 if event['event_type'] != 'attached':
1125 raise Exception("Failure. Iface was not properly attached")
1126 ap2.send_iface_attach_request(ap2.ifname(),
1127 fst_test_common.fst_test_def_group,
1129 event = ap2.wait_for_iface_event(5)
1130 if event['event_type'] != 'attached':
1131 raise Exception("Failure. Iface was not properly attached")
1133 res_sta2_mbies = sta2.get_local_mbies()
1134 res_ap2_mbies = ap2.get_local_mbies()
1135 sta2.send_iface_detach_request(sta2.ifname())
1136 event = sta2.wait_for_iface_event(5)
1137 if event['event_type'] != 'detached':
1138 raise Exception("Failure. Iface was not properly detached")
1139 ap2.send_iface_detach_request(ap2.ifname())
1140 event = ap2.wait_for_iface_event(5)
1141 if event['event_type'] != 'detached':
1142 raise Exception("Failure. Iface was not properly detached")
1143 if (not orig_sta2_mbies.startswith("FAIL") or
1144 not orig_ap2_mbies.startswith("FAIL") or
1145 res_sta2_mbies.startswith("FAIL") or
1146 res_ap2_mbies.startswith("FAIL")):
1147 raise Exception("Failure. MB IEs should have appeared on the station and on the AP")
1148 except Exception, e:
1157 # AP side FST module tests
1159 def test_fst_ap_start_session(dev, apdev, test_params):
1160 """FST AP start session"""
1161 fst_start_session(apdev, test_params, bad_param_none, True)
1163 def test_fst_ap_start_session_no_add_params(dev, apdev, test_params):
1164 """FST AP start session - no add params"""
1165 fst_start_session(apdev, test_params, bad_param_session_add_no_params, True)
1167 def test_fst_ap_start_session_bad_group_id(dev, apdev, test_params):
1168 """FST AP start session - bad group id"""
1169 fst_start_session(apdev, test_params, bad_param_group_id, True)
1171 def test_fst_ap_start_session_no_set_params(dev, apdev, test_params):
1172 """FST AP start session - no set params"""
1173 fst_start_session(apdev, test_params, bad_param_session_set_no_params, True)
1175 def test_fst_ap_start_session_set_unknown_param(dev, apdev, test_params):
1176 """FST AP start session - set unknown param"""
1177 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1180 def test_fst_ap_start_session_bad_session_id(dev, apdev, test_params):
1181 """FST AP start session - bad session id"""
1182 fst_start_session(apdev, test_params, bad_param_session_id, True)
1184 def test_fst_ap_start_session_bad_new_iface(dev, apdev, test_params):
1185 """FST AP start session - bad new iface"""
1186 fst_start_session(apdev, test_params, bad_param_new_iface, True)
1188 def test_fst_ap_start_session_bad_old_iface(dev, apdev, test_params):
1189 """FST AP start session - bad old iface"""
1190 fst_start_session(apdev, test_params, bad_param_old_iface, True)
1192 def test_fst_ap_start_session_negative_llt(dev, apdev, test_params):
1193 """FST AP start session - negative llt"""
1194 fst_start_session(apdev, test_params, bad_param_negative_llt, True)
1196 def test_fst_ap_start_session_zero_llt(dev, apdev, test_params):
1197 """FST AP start session - zero llt"""
1198 fst_start_session(apdev, test_params, bad_param_zero_llt, True)
1200 def test_fst_ap_start_session_llt_too_big(dev, apdev, test_params):
1201 """FST AP start session - llt too large"""
1202 fst_start_session(apdev, test_params, bad_param_llt_too_big, True)
1204 def test_fst_ap_start_session_invalid_peer_addr(dev, apdev, test_params):
1205 """FST AP start session - invalid peer address"""
1206 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1207 'GG:GG:GG:GG:GG:GG')
1209 def test_fst_ap_start_session_multicast_peer_addr(dev, apdev, test_params):
1210 """FST AP start session - multicast peer address"""
1211 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1212 '01:00:11:22:33:44')
1214 def test_fst_ap_start_session_broadcast_peer_addr(dev, apdev, test_params):
1215 """FST AP start session - broadcast peer address"""
1216 fst_start_session(apdev, test_params, bad_param_peer_addr, True,
1217 'FF:FF:FF:FF:FF:FF')
1219 def test_fst_ap_initiate_session(dev, apdev, test_params):
1220 """FST AP initiate session"""
1221 fst_initiate_session(apdev, test_params, bad_param_none, True)
1223 def test_fst_ap_initiate_session_no_params(dev, apdev, test_params):
1224 """FST AP initiate session - no params"""
1225 fst_initiate_session(apdev, test_params,
1226 bad_param_session_initiate_no_params, True)
1228 def test_fst_ap_initiate_session_invalid_session_id(dev, apdev, test_params):
1229 """FST AP initiate session - invalid session id"""
1230 fst_initiate_session(apdev, test_params,
1231 bad_param_session_initiate_bad_session_id, True)
1233 def test_fst_ap_initiate_session_no_new_iface(dev, apdev, test_params):
1234 """FST AP initiate session - no new iface"""
1235 fst_initiate_session(apdev, test_params,
1236 bad_param_session_initiate_with_no_new_iface_set, True)
1238 def test_fst_ap_initiate_session_bad_peer_addr(dev, apdev, test_params):
1239 """FST AP initiate session - bad peer address"""
1240 fst_initiate_session(apdev, test_params,
1241 bad_param_session_initiate_with_bad_peer_addr_set,
1244 def test_fst_ap_initiate_session_request_with_bad_stie(dev, apdev, test_params):
1245 """FST AP initiate session - request with bad stie"""
1246 fst_initiate_session(apdev, test_params,
1247 bad_param_session_initiate_request_with_bad_stie, True)
1249 def test_fst_ap_initiate_session_response_with_reject(dev, apdev, test_params):
1250 """FST AP initiate session - response with reject"""
1251 fst_initiate_session(apdev, test_params,
1252 bad_param_session_initiate_response_with_reject, True)
1254 def test_fst_ap_initiate_session_response_with_bad_stie(dev, apdev,
1256 """FST AP initiate session - response with bad stie"""
1257 fst_initiate_session(apdev, test_params,
1258 bad_param_session_initiate_response_with_bad_stie,
1261 def test_fst_ap_initiate_session_response_with_zero_llt(dev, apdev,
1263 """FST AP initiate session - zero llt"""
1264 fst_initiate_session(apdev, test_params,
1265 bad_param_session_initiate_response_with_zero_llt,
1268 def test_fst_ap_initiate_session_stt_no_response(dev, apdev, test_params):
1269 """FST AP initiate session - stt no response"""
1270 fst_initiate_session(apdev, test_params,
1271 bad_param_session_initiate_stt_no_response, True)
1273 def test_fst_ap_initiate_session_concurrent_setup_request(dev, apdev,
1275 """FST AP initiate session - concurrent setup request"""
1276 fst_initiate_session(apdev, test_params,
1277 bad_param_session_initiate_concurrent_setup_request,
1280 def test_fst_ap_session_request_with_no_session(dev, apdev, test_params):
1281 """FST AP session request with no session"""
1282 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1285 def test_fst_ap_session_response_accept_with_no_session(dev, apdev,
1287 """FST AP session response accept with no session"""
1288 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1291 def test_fst_ap_session_response_reject_with_no_session(dev, apdev,
1293 """FST AP session response reject with no session"""
1294 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1297 def test_fst_ap_ack_request_with_no_session(dev, apdev, test_params):
1298 """FST AP ack request with no session"""
1299 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, True)
1301 def test_fst_ap_ack_response_with_no_session(dev, apdev, test_params):
1302 """FST AP ack response with no session"""
1303 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response, True)
1305 def test_fst_ap_tear_down_response_with_no_session(dev, apdev, test_params):
1306 """FST AP tear down response with no session"""
1307 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, True)
1309 def test_fst_ap_transfer_session(dev, apdev, test_params):
1310 """FST AP transfer session"""
1311 fst_transfer_session(apdev, test_params, bad_param_none, True)
1313 def test_fst_ap_transfer_session_no_params(dev, apdev, test_params):
1314 """FST AP transfer session - no params"""
1315 fst_transfer_session(apdev, test_params,
1316 bad_param_session_transfer_no_params, True)
1318 def test_fst_ap_transfer_session_bad_session_id(dev, apdev, test_params):
1319 """FST AP transfer session - bad session id"""
1320 fst_transfer_session(apdev, test_params,
1321 bad_param_session_transfer_bad_session_id, True)
1323 def test_fst_ap_transfer_session_setup_skipped(dev, apdev, test_params):
1324 """FST AP transfer session - setup skipped"""
1325 fst_transfer_session(apdev, test_params,
1326 bad_param_session_transfer_setup_skipped, True)
1328 def test_fst_ap_ack_request_with_session_not_set_up(dev, apdev, test_params):
1329 """FST AP ack request with session not set up"""
1330 fst_bad_transfer(apdev, test_params,
1331 bad_scenario_ack_req_session_not_set_up, True)
1333 def test_fst_ap_ack_request_with_session_not_established_init_side(dev, apdev,
1335 """FST AP ack request with session not established init side"""
1336 fst_bad_transfer(apdev, test_params,
1337 bad_scenario_ack_req_session_not_established_init_side,
1340 def test_fst_ap_ack_request_with_session_not_established_resp_side(dev, apdev,
1342 """FST AP ack request with session not established resp side"""
1343 fst_bad_transfer(apdev, test_params,
1344 bad_scenario_ack_req_session_not_established_resp_side,
1347 def test_fst_ap_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1348 """FST AP ack request with bad fsts id"""
1349 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id, True)
1351 def test_fst_ap_ack_response_with_session_not_set_up(dev, apdev, test_params):
1352 """FST AP ack response with session not set up"""
1353 fst_bad_transfer(apdev, test_params,
1354 bad_scenario_ack_resp_session_not_set_up, True)
1356 def test_fst_ap_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1357 """FST AP ack response with session not established init side"""
1358 fst_bad_transfer(apdev, test_params,
1359 bad_scenario_ack_resp_session_not_established_init_side,
1362 def test_fst_ap_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1363 """FST AP ack response with session not established resp side"""
1364 fst_bad_transfer(apdev, test_params,
1365 bad_scenario_ack_resp_session_not_established_resp_side,
1368 def test_fst_ap_ack_response_with_no_ack_request(dev, apdev, test_params):
1369 """FST AP ack response with no ack request"""
1370 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req, True)
1372 def test_fst_ap_tear_down_session(dev, apdev, test_params):
1373 """FST AP tear down session"""
1374 fst_tear_down_session(apdev, test_params, bad_param_none, True)
1376 def test_fst_ap_tear_down_session_no_params(dev, apdev, test_params):
1377 """FST AP tear down session - no params"""
1378 fst_tear_down_session(apdev, test_params,
1379 bad_param_session_teardown_no_params, True)
1381 def test_fst_ap_tear_down_session_bad_session_id(dev, apdev, test_params):
1382 """FST AP tear down session - bad session id"""
1383 fst_tear_down_session(apdev, test_params,
1384 bad_param_session_teardown_bad_session_id, True)
1386 def test_fst_ap_tear_down_session_setup_skipped(dev, apdev, test_params):
1387 """FST AP tear down session - setup skipped"""
1388 fst_tear_down_session(apdev, test_params,
1389 bad_param_session_teardown_setup_skipped, True)
1391 def test_fst_ap_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1392 """FST AP tear down session - bad fsts id"""
1393 fst_tear_down_session(apdev, test_params,
1394 bad_param_session_teardown_bad_fsts_id, True)
1396 def test_fst_ap_remove_session_not_established(dev, apdev, test_params):
1397 """FST AP remove session - not established"""
1398 fst_remove_session(apdev, test_params,
1399 remove_scenario_non_established_session, True)
1401 def test_fst_ap_remove_session_established(dev, apdev, test_params):
1402 """FST AP remove session - established"""
1403 fst_remove_session(apdev, test_params,
1404 remove_scenario_established_session, True)
1406 def test_fst_ap_remove_session_no_params(dev, apdev, test_params):
1407 """FST AP remove session - no params"""
1408 fst_remove_session(apdev, test_params, remove_scenario_no_params, True)
1410 def test_fst_ap_remove_session_bad_session_id(dev, apdev, test_params):
1411 """FST AP remove session - bad session id"""
1412 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id, True)
1414 def test_fst_ap_ctrl_iface(dev, apdev, test_params):
1415 """FST control interface behavior"""
1416 hglobal = hostapd.HostapdGlobal()
1417 start_num_groups = 0
1418 res = hglobal.request("FST-MANAGER LIST_GROUPS")
1420 if "FAIL" not in res:
1421 start_num_groups = len(res.splitlines())
1423 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1425 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1428 initiator.add_peer(responder, None)
1429 initiator.set_fst_parameters(group_id=None)
1430 sid = initiator.add_session()
1431 res = initiator.get_session_params(sid)
1432 logger.info("Initial session params:\n" + str(res))
1433 if res['state'] != 'INITIAL':
1434 raise Exception("Unexpected state: " + res['state'])
1435 initiator.set_fst_parameters(llt=None)
1436 initiator.configure_session(sid, ap2.ifname(), None)
1437 res = initiator.get_session_params(sid)
1438 logger.info("Session params after configuration:\n" + str(res))
1439 res = initiator.iface_peers(initiator.ifname())
1440 logger.info("Interface peers: " + str(res))
1442 raise Exception("Unexpected number of peers")
1443 res = initiator.get_peer_mbies(initiator.ifname(),
1444 initiator.get_new_peer_addr())
1445 logger.info("Peer MB IEs: " + str(res))
1446 res = initiator.list_ifaces()
1447 logger.info("Interfaces: " + str(res))
1449 raise Exception("Unexpected number of interfaces")
1450 res = initiator.list_groups()
1451 logger.info("Groups: " + str(res))
1452 if len(res) != 1 + start_num_groups:
1453 raise Exception("Unexpected number of groups")
1455 tests = [ "LIST_IFACES unknown",
1456 "LIST_IFACES unknown2",
1457 "SESSION_GET 12345678",
1458 "SESSION_SET " + sid + " unknown=foo",
1459 "SESSION_RESPOND 12345678 foo",
1460 "SESSION_RESPOND " + sid,
1461 "SESSION_RESPOND " + sid + " foo",
1463 "TEST_REQUEST SEND_SETUP_REQUEST",
1464 "TEST_REQUEST SEND_SETUP_REQUEST foo",
1465 "TEST_REQUEST SEND_SETUP_RESPONSE",
1466 "TEST_REQUEST SEND_SETUP_RESPONSE foo",
1467 "TEST_REQUEST SEND_ACK_REQUEST",
1468 "TEST_REQUEST SEND_ACK_REQUEST foo",
1469 "TEST_REQUEST SEND_ACK_RESPONSE",
1470 "TEST_REQUEST SEND_ACK_RESPONSE foo",
1471 "TEST_REQUEST SEND_TEAR_DOWN",
1472 "TEST_REQUEST SEND_TEAR_DOWN foo",
1473 "TEST_REQUEST GET_FSTS_ID",
1474 "TEST_REQUEST GET_FSTS_ID foo",
1475 "TEST_REQUEST GET_LOCAL_MBIES",
1476 "TEST_REQUEST GET_LOCAL_MBIES foo",
1479 "GET_PEER_MBIES unknown",
1480 "GET_PEER_MBIES unknown unknown",
1481 "GET_PEER_MBIES unknown " + initiator.get_new_peer_addr(),
1482 "GET_PEER_MBIES " + initiator.ifname() + " 01:ff:ff:ff:ff:ff",
1483 "GET_PEER_MBIES " + initiator.ifname() + " 00:ff:ff:ff:ff:ff",
1484 "GET_PEER_MBIES " + initiator.ifname() + " 00:00:00:00:00:00",
1487 "IFACE_PEERS unknown",
1488 "IFACE_PEERS unknown unknown",
1489 "IFACE_PEERS " + initiator.fst_group,
1490 "IFACE_PEERS " + initiator.fst_group + " unknown" ]
1492 if "FAIL" not in initiator.grequest("FST-MANAGER " + t):
1493 raise Exception("Unexpected response for invalid FST-MANAGER command " + t)
1494 if "UNKNOWN FST COMMAND" not in initiator.grequest("FST-MANAGER unknown"):
1495 raise Exception("Unexpected response for unknown FST-MANAGER command")
1497 tests = [ "FST-DETACH", "FST-DETACH ", "FST-DETACH unknown",
1498 "FST-ATTACH", "FST-ATTACH ", "FST-ATTACH unknown",
1499 "FST-ATTACH unknown unknown" ]
1501 if "FAIL" not in initiator.grequest(t):
1502 raise Exception("Unexpected response for invalid command " + t)
1505 # Trying to add same interface again needs to fail.
1506 ap1.send_iface_attach_request(ap1.iface, ap1.fst_group,
1507 ap1.fst_llt, ap1.fst_pri)
1508 raise Exception("Duplicate FST-ATTACH succeeded")
1509 except Exception, e:
1510 if not str(e).startswith("Cannot attach"):
1514 ap1.get_fsts_id_by_sid("123")
1515 except Exception, e:
1516 if not str(e).startswith("Cannot get fsts_id for sid"):
1519 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1520 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1522 def test_fst_ap_start_session_oom(dev, apdev, test_params):
1523 """FST AP setup failing due to OOM"""
1524 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
1525 fst_test_common.fst_test_def_chan_a,
1526 fst_test_common.fst_test_def_group,
1527 fst_test_common.fst_test_def_prio_low,
1528 fst_test_common.fst_test_def_llt)
1531 run_fst_ap_start_session_oom(apdev, ap1)
1535 def run_fst_ap_start_session_oom(apdev, ap1):
1536 with alloc_fail(ap1, 1, "fst_iface_create"):
1539 ap2 = fst_module_aux.FstAP(apdev[1]['ifname'], 'fst_11g', 'b',
1540 fst_test_common.fst_test_def_chan_g,
1541 fst_test_common.fst_test_def_group,
1542 fst_test_common.fst_test_def_prio_high,
1543 fst_test_common.fst_test_def_llt)
1545 # This will fail in fst_iface_create() OOM
1555 # STA side FST module tests
1557 def test_fst_sta_start_session(dev, apdev, test_params):
1558 """FST STA start session"""
1559 fst_start_session(apdev, test_params, bad_param_none, False)
1561 def test_fst_sta_start_session_no_add_params(dev, apdev, test_params):
1562 """FST STA start session - no add params"""
1563 fst_start_session(apdev, test_params, bad_param_session_add_no_params,
1566 def test_fst_sta_start_session_bad_group_id(dev, apdev, test_params):
1567 """FST STA start session - bad group id"""
1568 fst_start_session(apdev, test_params, bad_param_group_id, False)
1570 def test_fst_sta_start_session_no_set_params(dev, apdev, test_params):
1571 """FST STA start session - no set params"""
1572 fst_start_session(apdev, test_params, bad_param_session_set_no_params,
1575 def test_fst_sta_start_session_set_unknown_param(dev, apdev, test_params):
1576 """FST STA start session - set unknown param"""
1577 fst_start_session(apdev, test_params, bad_param_session_set_unknown_param,
1580 def test_fst_sta_start_session_bad_session_id(dev, apdev, test_params):
1581 """FST STA start session - bad session id"""
1582 fst_start_session(apdev, test_params, bad_param_session_id, False)
1584 def test_fst_sta_start_session_bad_new_iface(dev, apdev, test_params):
1585 """FST STA start session - bad new iface"""
1586 fst_start_session(apdev, test_params, bad_param_new_iface, False)
1588 def test_fst_sta_start_session_bad_old_iface(dev, apdev, test_params):
1589 """FST STA start session - bad old iface"""
1590 fst_start_session(apdev, test_params, bad_param_old_iface, False)
1592 def test_fst_sta_start_session_negative_llt(dev, apdev, test_params):
1593 """FST STA start session - negative llt"""
1594 fst_start_session(apdev, test_params, bad_param_negative_llt, False)
1596 def test_fst_sta_start_session_zero_llt(dev, apdev, test_params):
1597 """FST STA start session - zero llt"""
1598 fst_start_session(apdev, test_params, bad_param_zero_llt, False)
1600 def test_fst_sta_start_session_llt_too_big(dev, apdev, test_params):
1601 """FST STA start session - llt too large"""
1602 fst_start_session(apdev, test_params, bad_param_llt_too_big, False)
1604 def test_fst_sta_start_session_invalid_peer_addr(dev, apdev, test_params):
1605 """FST STA start session - invalid peer address"""
1606 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1607 'GG:GG:GG:GG:GG:GG')
1609 def test_fst_sta_start_session_multicast_peer_addr(dev, apdev, test_params):
1610 """FST STA start session - multicast peer address"""
1611 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1612 '11:00:11:22:33:44')
1614 def test_fst_sta_start_session_broadcast_peer_addr(dev, apdev, test_params):
1615 """FST STA start session - broadcast peer addr"""
1616 fst_start_session(apdev, test_params, bad_param_peer_addr, False,
1617 'FF:FF:FF:FF:FF:FF')
1619 def test_fst_sta_initiate_session(dev, apdev, test_params):
1620 """FST STA initiate session"""
1621 fst_initiate_session(apdev, test_params, bad_param_none, False)
1623 def test_fst_sta_initiate_session_no_params(dev, apdev, test_params):
1624 """FST STA initiate session - no params"""
1625 fst_initiate_session(apdev, test_params,
1626 bad_param_session_initiate_no_params, False)
1628 def test_fst_sta_initiate_session_invalid_session_id(dev, apdev, test_params):
1629 """FST STA initiate session - invalid session id"""
1630 fst_initiate_session(apdev, test_params,
1631 bad_param_session_initiate_bad_session_id, False)
1633 def test_fst_sta_initiate_session_no_new_iface(dev, apdev, test_params):
1634 """FST STA initiate session - no new iface"""
1635 fst_initiate_session(apdev, test_params,
1636 bad_param_session_initiate_with_no_new_iface_set,
1639 def test_fst_sta_initiate_session_bad_peer_addr(dev, apdev, test_params):
1640 """FST STA initiate session - bad peer address"""
1641 fst_initiate_session(apdev, test_params,
1642 bad_param_session_initiate_with_bad_peer_addr_set,
1645 def test_fst_sta_initiate_session_request_with_bad_stie(dev, apdev,
1647 """FST STA initiate session - request with bad stie"""
1648 fst_initiate_session(apdev, test_params,
1649 bad_param_session_initiate_request_with_bad_stie,
1652 def test_fst_sta_initiate_session_response_with_reject(dev, apdev, test_params):
1653 """FST STA initiate session - response with reject"""
1654 fst_initiate_session(apdev, test_params, bad_param_session_initiate_response_with_reject, False)
1656 def test_fst_sta_initiate_session_response_with_bad_stie(dev, apdev, test_params):
1657 """FST STA initiate session - response with bad stie"""
1658 fst_initiate_session(apdev, test_params,
1659 bad_param_session_initiate_response_with_bad_stie,
1662 def test_fst_sta_initiate_session_response_with_zero_llt(dev, apdev,
1664 """FST STA initiate session - response with zero llt"""
1665 fst_initiate_session(apdev, test_params,
1666 bad_param_session_initiate_response_with_zero_llt,
1669 def test_fst_sta_initiate_session_stt_no_response(dev, apdev, test_params):
1670 """FST STA initiate session - stt no response"""
1671 fst_initiate_session(apdev, test_params,
1672 bad_param_session_initiate_stt_no_response, False)
1674 def test_fst_sta_initiate_session_concurrent_setup_request(dev, apdev,
1676 """FST STA initiate session - concurrent setup request"""
1677 fst_initiate_session(apdev, test_params,
1678 bad_param_session_initiate_concurrent_setup_request,
1681 def test_fst_sta_session_request_with_no_session(dev, apdev, test_params):
1682 """FST STA session request with no session"""
1683 fst_send_unexpected_frame(apdev, test_params, frame_type_session_request,
1686 def test_fst_sta_session_response_accept_with_no_session(dev, apdev,
1688 """FST STA session response accept with no session"""
1689 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1692 def test_fst_sta_session_response_reject_with_no_session(dev, apdev,
1694 """FST STA session response reject with no session"""
1695 fst_send_unexpected_frame(apdev, test_params, frame_type_session_response,
1698 def test_fst_sta_ack_request_with_no_session(dev, apdev, test_params):
1699 """FST STA ack request with no session"""
1700 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_request, False)
1702 def test_fst_sta_ack_response_with_no_session(dev, apdev, test_params):
1703 """FST STA ack response with no session"""
1704 fst_send_unexpected_frame(apdev, test_params, frame_type_ack_response,
1707 def test_fst_sta_tear_down_response_with_no_session(dev, apdev, test_params):
1708 """FST STA tear down response with no session"""
1709 fst_send_unexpected_frame(apdev, test_params, frame_type_tear_down, False)
1711 def test_fst_sta_transfer_session(dev, apdev, test_params):
1712 """FST STA transfer session"""
1713 fst_transfer_session(apdev, test_params, bad_param_none, False)
1715 def test_fst_sta_transfer_session_no_params(dev, apdev, test_params):
1716 """FST STA transfer session - no params"""
1717 fst_transfer_session(apdev, test_params,
1718 bad_param_session_transfer_no_params, False)
1720 def test_fst_sta_transfer_session_bad_session_id(dev, apdev, test_params):
1721 """FST STA transfer session - bad session id"""
1722 fst_transfer_session(apdev, test_params,
1723 bad_param_session_transfer_bad_session_id, False)
1725 def test_fst_sta_transfer_session_setup_skipped(dev, apdev, test_params):
1726 """FST STA transfer session - setup skipped"""
1727 fst_transfer_session(apdev, test_params,
1728 bad_param_session_transfer_setup_skipped, False)
1730 def test_fst_sta_ack_request_with_session_not_set_up(dev, apdev, test_params):
1731 """FST STA ack request with session not set up"""
1732 fst_bad_transfer(apdev, test_params,
1733 bad_scenario_ack_req_session_not_set_up, False)
1735 def test_fst_sta_ack_request_with_session_not_established_init_side(dev, apdev, test_params):
1736 """FST STA ack request with session not established init side"""
1737 fst_bad_transfer(apdev, test_params,
1738 bad_scenario_ack_req_session_not_established_init_side,
1741 def test_fst_sta_ack_request_with_session_not_established_resp_side(dev, apdev, test_params):
1742 """FST STA ack request with session not established resp side"""
1743 fst_bad_transfer(apdev, test_params,
1744 bad_scenario_ack_req_session_not_established_resp_side,
1747 def test_fst_sta_ack_request_with_bad_fsts_id(dev, apdev, test_params):
1748 """FST STA ack request with bad fsts id"""
1749 fst_bad_transfer(apdev, test_params, bad_scenario_ack_req_bad_fsts_id,
1752 def test_fst_sta_ack_response_with_session_not_set_up(dev, apdev, test_params):
1753 """FST STA ack response with session not set up"""
1754 fst_bad_transfer(apdev, test_params,
1755 bad_scenario_ack_resp_session_not_set_up, False)
1757 def test_fst_sta_ack_response_with_session_not_established_init_side(dev, apdev, test_params):
1758 """FST STA ack response with session not established init side"""
1759 fst_bad_transfer(apdev, test_params,
1760 bad_scenario_ack_resp_session_not_established_init_side,
1763 def test_fst_sta_ack_response_with_session_not_established_resp_side(dev, apdev, test_params):
1764 """FST STA ack response with session not established resp side"""
1765 fst_bad_transfer(apdev, test_params,
1766 bad_scenario_ack_resp_session_not_established_resp_side,
1769 def test_fst_sta_ack_response_with_no_ack_request(dev, apdev, test_params):
1770 """FST STA ack response with no ack request"""
1771 fst_bad_transfer(apdev, test_params, bad_scenario_ack_resp_no_ack_req,
1774 def test_fst_sta_tear_down_session(dev, apdev, test_params):
1775 """FST STA tear down session"""
1776 fst_tear_down_session(apdev, test_params, bad_param_none, False)
1778 def test_fst_sta_tear_down_session_no_params(dev, apdev, test_params):
1779 """FST STA tear down session - no params"""
1780 fst_tear_down_session(apdev, test_params,
1781 bad_param_session_teardown_no_params, False)
1783 def test_fst_sta_tear_down_session_bad_session_id(dev, apdev, test_params):
1784 """FST STA tear down session - bad session id"""
1785 fst_tear_down_session(apdev, test_params,
1786 bad_param_session_teardown_bad_session_id, False)
1788 def test_fst_sta_tear_down_session_setup_skipped(dev, apdev, test_params):
1789 """FST STA tear down session - setup skipped"""
1790 fst_tear_down_session(apdev, test_params,
1791 bad_param_session_teardown_setup_skipped, False)
1793 def test_fst_sta_tear_down_session_bad_fsts_id(dev, apdev, test_params):
1794 """FST STA tear down session - bad fsts id"""
1795 fst_tear_down_session(apdev, test_params,
1796 bad_param_session_teardown_bad_fsts_id, False)
1798 def test_fst_sta_remove_session_not_established(dev, apdev, test_params):
1799 """FST STA tear down session - not established"""
1800 fst_remove_session(apdev, test_params,
1801 remove_scenario_non_established_session, False)
1803 def test_fst_sta_remove_session_established(dev, apdev, test_params):
1804 """FST STA remove session - established"""
1805 fst_remove_session(apdev, test_params,
1806 remove_scenario_established_session, False)
1808 def test_fst_sta_remove_session_no_params(dev, apdev, test_params):
1809 """FST STA remove session - no params"""
1810 fst_remove_session(apdev, test_params, remove_scenario_no_params, False)
1812 def test_fst_sta_remove_session_bad_session_id(dev, apdev, test_params):
1813 """FST STA remove session - bad session id"""
1814 fst_remove_session(apdev, test_params, remove_scenario_bad_session_id,
1817 def test_fst_rsn_ap_transfer_session(dev, apdev, test_params):
1818 """FST RSN AP transfer session"""
1819 fst_transfer_session(apdev, test_params, bad_param_none, True, rsn=True)
1821 MGMT_SUBTYPE_ACTION = 13
1822 ACTION_CATEG_FST = 18
1823 FST_ACTION_SETUP_REQUEST = 0
1824 FST_ACTION_SETUP_RESPONSE = 1
1825 FST_ACTION_TEAR_DOWN = 2
1826 FST_ACTION_ACK_REQUEST = 3
1827 FST_ACTION_ACK_RESPONSE = 4
1828 FST_ACTION_ON_CHANNEL_TUNNEL = 5
1830 def hostapd_tx_and_status(hapd, msg):
1831 hapd.set("ext_mgmt_frame_handling", "1")
1833 ev = hapd.wait_event([ "MGMT-TX-STATUS" ], timeout=1)
1834 if ev is None or "ok=1" not in ev:
1835 raise Exception("No ACK")
1836 hapd.set("ext_mgmt_frame_handling", "0")
1838 def test_fst_proto(dev, apdev, test_params):
1839 """FST protocol testing"""
1840 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1842 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1843 hapd = ap1.get_instance()
1844 sta = sta1.get_instance()
1845 dst = sta.own_addr()
1846 src = apdev[0]['bssid']
1849 msg['fc'] = MGMT_SUBTYPE_ACTION << 4
1854 # unknown FST Action (255) received!
1855 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST, 255)
1856 hostapd_tx_and_status(hapd, msg)
1858 # FST Request dropped: too short
1859 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1860 FST_ACTION_SETUP_REQUEST)
1861 hostapd_tx_and_status(hapd, msg)
1863 # FST Request dropped: invalid STIE (EID)
1864 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1865 FST_ACTION_SETUP_REQUEST, 0, 0,
1866 163, 11, 0, 0, 0, 0, 0, 0, 0, 0)
1867 hostapd_tx_and_status(hapd, msg)
1869 # FST Request dropped: invalid STIE (Len)
1870 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1871 FST_ACTION_SETUP_REQUEST, 0, 0,
1872 164, 10, 0, 0, 0, 0, 0, 0, 0, 0)
1873 hostapd_tx_and_status(hapd, msg)
1875 # FST Request dropped: new and old band IDs are the same
1876 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1877 FST_ACTION_SETUP_REQUEST, 0, 0,
1878 164, 11, 0, 0, 0, 0, 0, 0, 0, 0)
1879 hostapd_tx_and_status(hapd, msg)
1881 ifaces = sta1.list_ifaces()
1882 id = int(ifaces[0]['name'].split('|')[1])
1883 # FST Request dropped: new iface not found (new_band_id mismatch)
1884 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1885 FST_ACTION_SETUP_REQUEST, 0, 0,
1886 164, 11, 0, 0, id + 1, 0, 0, 0, 0, 0)
1887 hostapd_tx_and_status(hapd, msg)
1889 # FST Action 'Setup Response' dropped: no session in progress found
1890 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1891 FST_ACTION_SETUP_RESPONSE)
1892 hostapd_tx_and_status(hapd, msg)
1897 new_iface = ap2.ifname()
1898 new_peer_addr = ap2.get_actual_peer_addr()
1899 resp_newif = sta2.ifname()
1901 initiator.add_peer(responder, peeraddr, new_peer_addr)
1902 sid = initiator.add_session()
1903 initiator.configure_session(sid, new_iface)
1904 initiator.initiate_session(sid, "accept")
1906 # FST Response dropped due to wrong state: SETUP_COMPLETION
1907 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1908 FST_ACTION_SETUP_RESPONSE)
1909 hostapd_tx_and_status(hapd, msg)
1911 # Too short FST Tear Down dropped
1912 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1913 FST_ACTION_TEAR_DOWN)
1914 hostapd_tx_and_status(hapd, msg)
1916 # tear down for wrong FST Setup ID (0)
1917 msg['payload'] = struct.pack("<BBL", ACTION_CATEG_FST,
1918 FST_ACTION_TEAR_DOWN, 0)
1919 hostapd_tx_and_status(hapd, msg)
1921 # Ack received on wrong interface
1922 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1923 FST_ACTION_ACK_REQUEST)
1924 hostapd_tx_and_status(hapd, msg)
1926 # Ack Response in inappropriate session state (SETUP_COMPLETION)
1927 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1928 FST_ACTION_ACK_RESPONSE)
1929 hostapd_tx_and_status(hapd, msg)
1931 # Unsupported FST Action frame (On channel tunnel)
1932 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1933 FST_ACTION_ON_CHANNEL_TUNNEL)
1934 hostapd_tx_and_status(hapd, msg)
1936 # FST Request dropped: new iface not found (new_band_id match)
1937 # FST Request dropped due to MAC comparison
1938 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1939 FST_ACTION_SETUP_REQUEST, 0, 0,
1940 164, 11, 0, 0, id, 0, 0, 0, 0, 0)
1941 hostapd_tx_and_status(hapd, msg)
1943 hapd2 = ap2.get_instance()
1944 dst2 = sta2.get_instance().own_addr()
1945 src2 = apdev[1]['bssid']
1948 msg2['fc'] = MGMT_SUBTYPE_ACTION << 4
1951 msg2['bssid'] = src2
1952 # FST Response dropped: wlan6 is not the old iface
1953 msg2['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
1954 FST_ACTION_SETUP_RESPONSE)
1955 hostapd_tx_and_status(hapd2, msg2)
1959 group = ap1.fst_group
1960 ap1.send_iface_detach_request(ap1.iface)
1962 sta.flush_scan_cache()
1963 sta.request("REASSOCIATE")
1964 sta.wait_connected()
1966 # FST Request dropped due to no interface connection
1967 msg['payload'] = struct.pack("<BBBLBBLBBBBBBB", ACTION_CATEG_FST,
1968 FST_ACTION_SETUP_REQUEST, 0, 0,
1969 164, 11, 0, 0, id, 0, 0, 0, 0, 0)
1970 hostapd_tx_and_status(hapd, msg)
1972 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1974 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1978 def test_fst_setup_response_proto(dev, apdev, test_params):
1979 """FST protocol testing for Setup Response"""
1980 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
1982 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
1983 hapd = ap1.get_instance()
1984 sta = sta1.get_instance()
1985 dst = sta.own_addr()
1986 src = apdev[0]['bssid']
1988 sta1.add_peer(ap1, None, sta2.get_actual_peer_addr())
1989 sta1.set_fst_parameters(llt='0')
1990 sid = sta1.add_session()
1991 sta1.configure_session(sid, sta2.ifname())
1992 sta1.initiate_session(sid, "")
1995 msg['fc'] = MGMT_SUBTYPE_ACTION << 4
2000 # Too short FST Response dropped
2001 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
2002 FST_ACTION_SETUP_RESPONSE)
2003 hostapd_tx_and_status(hapd, msg)
2005 # FST Response dropped: invalid STIE (EID)
2009 msg['payload'] = struct.pack("<BBBBBBLBBBBBBB", ACTION_CATEG_FST,
2010 FST_ACTION_SETUP_RESPONSE, dialog_token,
2012 163, 11, 0, 0, id, 0, 0, 0, 0, 0)
2013 hostapd_tx_and_status(hapd, msg)
2015 # FST Response dropped: invalid STIE (Len)
2019 msg['payload'] = struct.pack("<BBBBBBLBBBBBBB", ACTION_CATEG_FST,
2020 FST_ACTION_SETUP_RESPONSE, dialog_token,
2022 164, 10, 0, 0, id, 0, 0, 0, 0, 0)
2023 hostapd_tx_and_status(hapd, msg)
2025 # FST Response dropped due to wrong dialog token
2029 msg['payload'] = struct.pack("<BBBBBBLBBBBBBB", ACTION_CATEG_FST,
2030 FST_ACTION_SETUP_RESPONSE, dialog_token,
2032 164, 11, 0, 0, id, 0, 0, 0, 0, 0)
2033 hostapd_tx_and_status(hapd, msg)
2035 # FST Response dropped due to wrong FST Session ID
2039 msg['payload'] = struct.pack("<BBBBBBLBBBBBBB", ACTION_CATEG_FST,
2040 FST_ACTION_SETUP_RESPONSE, dialog_token,
2042 164, 11, int(sid) + 123456,
2043 0, id, 0, 0, 0, 0, 0)
2044 hostapd_tx_and_status(hapd, msg)
2046 # FST Response with non-zero status code
2050 msg['payload'] = struct.pack("<BBBBBBLBBBBBBB", ACTION_CATEG_FST,
2051 FST_ACTION_SETUP_RESPONSE, dialog_token,
2053 164, 11, int(sid), 0, id, 0, 0, 0, 0, 0)
2054 hostapd_tx_and_status(hapd, msg)
2056 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2057 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2059 def test_fst_ack_response_proto(dev, apdev, test_params):
2060 """FST protocol testing for Ack Response"""
2061 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
2063 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2064 hapd = ap2.get_instance()
2065 sta = sta2.get_instance()
2066 dst = sta.own_addr()
2067 src = apdev[1]['bssid']
2069 sta1.add_peer(ap1, None, sta2.get_actual_peer_addr())
2070 sta1.set_fst_parameters(llt='0')
2071 sid = sta1.add_session()
2072 sta1.configure_session(sid, sta2.ifname())
2074 s = sta1.grequest("FST-MANAGER SESSION_INITIATE "+ sid)
2075 if not s.startswith('OK'):
2076 raise Exception("Cannot initiate fst session: %s" % s)
2077 ev = sta1.peer_obj.wait_gevent([ "FST-EVENT-SESSION" ], timeout=5)
2079 raise Exception("No FST-EVENT-SESSION received")
2080 event = fst_module_aux.parse_fst_session_event(ev)
2082 raise Exception("Unrecognized FST event: " % ev)
2083 if event['type'] != 'EVENT_FST_SETUP':
2084 raise Exception("Expected FST_SETUP event, got: " + event['type'])
2085 ev = sta1.peer_obj.wait_gevent(["FST-EVENT-SESSION"], timeout=5)
2087 raise Exception("No FST-EVENT-SESSION received")
2088 event = fst_module_aux.parse_fst_session_event(ev)
2090 raise Exception("Unrecognized FST event: " % ev)
2091 if event['type'] != 'EVENT_FST_SESSION_STATE':
2092 raise Exception("Expected EVENT_FST_SESSION_STATE event, got: " + event['type'])
2093 if event['new_state'] != "SETUP_COMPLETION":
2094 raise Exception("Expected new state SETUP_COMPLETION, got: " + event['new_state'])
2096 hapd.set("ext_mgmt_frame_handling", "1")
2097 s = sta1.peer_obj.grequest("FST-MANAGER SESSION_RESPOND "+ event['id'] + " accept")
2098 if not s.startswith('OK'):
2099 raise Exception("Error session_respond: %s" % s)
2100 req = hapd.mgmt_rx()
2102 raise Exception("No Ack Request seen")
2104 msg['fc'] = MGMT_SUBTYPE_ACTION << 4
2109 # Too short FST Ack Response dropped
2110 msg['payload'] = struct.pack("<BB", ACTION_CATEG_FST,
2111 FST_ACTION_ACK_RESPONSE)
2113 ev = hapd.wait_event([ "MGMT-TX-STATUS" ], timeout=1)
2114 if ev is None or "ok=1" not in ev:
2115 raise Exception("No ACK")
2117 # Ack Response for wrong FSt Setup ID
2118 msg['payload'] = struct.pack("<BBBL", ACTION_CATEG_FST,
2119 FST_ACTION_ACK_RESPONSE,
2120 0, int(sid) + 123456)
2121 hostapd_tx_and_status(hapd, msg)
2123 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2124 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2126 def test_fst_ap_config_oom(dev, apdev, test_params):
2127 """FST AP configuration and OOM"""
2128 ap1 = fst_module_aux.FstAP(apdev[0]['ifname'], 'fst_11a', 'a',
2129 fst_test_common.fst_test_def_chan_a,
2130 fst_test_common.fst_test_def_group,
2131 fst_test_common.fst_test_def_prio_low)
2132 hapd = ap1.start(return_early=True)
2133 with alloc_fail(hapd, 1, "fst_group_create"):
2134 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
2135 if not res.startswith("FAIL"):
2136 raise Exception("FST-ATTACH succeeded unexpectedly")
2138 with alloc_fail(hapd, 1, "fst_iface_create"):
2139 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
2140 if not res.startswith("FAIL"):
2141 raise Exception("FST-ATTACH succeeded unexpectedly")
2143 with alloc_fail(hapd, 1, "fst_group_create_mb_ie"):
2144 res = ap1.grequest("FST-ATTACH %s %s" % (ap1.iface, ap1.fst_group))
2145 # This is allowed to complete currently
2149 def test_fst_send_oom(dev, apdev, test_params):
2150 """FST send action OOM"""
2151 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
2153 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2154 hapd = ap1.get_instance()
2155 sta = sta1.get_instance()
2156 dst = sta.own_addr()
2157 src = apdev[0]['bssid']
2162 new_iface = ap2.ifname()
2163 new_peer_addr = ap2.get_actual_peer_addr()
2164 resp_newif = sta2.ifname()
2166 initiator.add_peer(responder, peeraddr, new_peer_addr)
2167 sid = initiator.add_session()
2168 initiator.configure_session(sid, new_iface)
2169 with alloc_fail(hapd, 1, "fst_session_send_action"):
2170 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
2171 if not res.startswith("FAIL"):
2172 raise Exception("Unexpected SESSION_INITIATE result")
2174 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
2175 if not res.startswith("OK"):
2176 raise Exception("SESSION_INITIATE failed")
2178 tests = [ "", "foo", sid, sid + " foo", sid + " foo=bar" ]
2180 res = initiator.grequest("FST-MANAGER SESSION_SET " + t)
2181 if not res.startswith("FAIL"):
2182 raise Exception("Invalid SESSION_SET accepted")
2184 with alloc_fail(hapd, 1, "fst_session_send_action"):
2185 res = initiator.grequest("FST-MANAGER SESSION_TEARDOWN " + sid)
2186 if not res.startswith("FAIL"):
2187 raise Exception("Unexpected SESSION_TEARDOWN result")
2189 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2190 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2192 def test_fst_session_oom(dev, apdev, test_params):
2193 """FST session create OOM"""
2194 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
2196 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2197 hapd = ap1.get_instance()
2198 sta = sta1.get_instance()
2199 dst = sta.own_addr()
2200 src = apdev[0]['bssid']
2205 new_iface = ap2.ifname()
2206 new_peer_addr = ap2.get_actual_peer_addr()
2207 resp_newif = sta2.ifname()
2209 initiator.add_peer(responder, peeraddr, new_peer_addr)
2210 with alloc_fail(hapd, 1, "fst_session_create"):
2211 sid = initiator.grequest("FST-MANAGER SESSION_ADD " + initiator.fst_group)
2212 if not sid.startswith("FAIL"):
2213 raise Exception("Unexpected SESSION_ADD success")
2214 sid = initiator.add_session()
2215 initiator.configure_session(sid, new_iface)
2216 with alloc_fail(sta, 1, "fst_session_create"):
2217 res = initiator.grequest("FST-MANAGER SESSION_INITIATE " + sid)
2218 if not res.startswith("OK"):
2219 raise Exception("Unexpected SESSION_INITIATE result")
2221 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2222 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2224 def test_fst_attach_zero_llt(dev, apdev):
2225 """FST attach with llt=0"""
2226 sta1 = fst_module_aux.FstSTA('wlan5', fst_test_common.fst_test_def_group,
2231 def test_fst_session_respond_fail(dev, apdev, test_params):
2232 """FST-MANAGER SESSION_RESPOND failure"""
2233 ap1, ap2, sta1, sta2 = fst_module_aux.start_two_ap_sta_pairs(apdev)
2235 fst_module_aux.connect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2236 sta1.add_peer(ap1, None, sta2.get_actual_peer_addr())
2237 sid = sta1.add_session()
2238 sta1.configure_session(sid, sta2.ifname())
2239 sta1.send_session_setup_request(sid)
2240 sta1.wait_for_session_event(5, [], ["EVENT_FST_SESSION_STATE"])
2241 ev = ap1.wait_for_session_event(5, [], ['EVENT_FST_SETUP'])
2243 raise Exception("No session id in FST setup event")
2244 # Disconnect STA to make SESSION_RESPOND fail due to no peer found
2245 sta = sta1.get_instance()
2246 sta.request("DISCONNECT")
2247 sta.wait_disconnected()
2248 req = "FST-MANAGER SESSION_RESPOND %s reject" % ev['id']
2249 s = ap1.grequest(req)
2250 if not s.startswith("FAIL"):
2251 raise Exception("SESSION_RESPOND succeeded unexpectedly")
2253 fst_module_aux.disconnect_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2254 fst_module_aux.stop_two_ap_sta_pairs(ap1, ap2, sta1, sta2)
2256 def fst_session_set(dev, sid, param, value):
2257 cmd = "FST-MANAGER SESSION_SET %s %s=%s" % (sid, param, value)
2258 if "OK" not in dev.global_request(cmd):
2259 raise Exception(cmd + " failed")
2261 def fst_session_set_ap(dev, sid, param, value):
2262 cmd = "FST-MANAGER SESSION_SET %s %s=%s" % (sid, param, value)
2263 if "OK" not in dev.request(cmd):
2264 raise Exception(cmd + " failed")
2266 def fst_attach_ap(dev, ifname, group):
2267 cmd = "FST-ATTACH %s %s" % (ifname, group)
2268 if "OK" not in dev.request(cmd):
2269 raise Exception("FST-ATTACH (AP) failed")
2270 ev = dev.wait_event(['FST-EVENT-IFACE'], timeout=5)
2272 raise Exception("No FST-EVENT-IFACE attached (AP)")
2273 for t in [ "attached", "ifname=" + ifname, "group=" + group ]:
2275 raise Exception("Unexpected FST-EVENT-IFACE data (AP): " + ev)
2277 def fst_attach_sta(dev, ifname, group):
2278 if "OK" not in dev.global_request("FST-ATTACH %s %s" % (ifname, group)):
2279 raise Exception("FST-ATTACH (STA) failed")
2280 ev = dev.wait_global_event(['FST-EVENT-IFACE'], timeout=5)
2282 raise Exception("No FST-EVENT-IFACE attached (STA)")
2283 for t in [ "attached", "ifname=" + ifname, "group=" + group ]:
2285 raise Exception("Unexpected FST-EVENT-IFACE data (STA): " + ev)
2287 def fst_detach_ap(dev, ifname, group):
2288 if "OK" not in dev.request("FST-DETACH " + ifname):
2289 raise Exception("FST-DETACH (AP) failed for " + ifname)
2290 ev = dev.wait_event(['FST-EVENT-IFACE'], timeout=5)
2292 raise Exception("No FST-EVENT-IFACE detached (AP) for " + ifname)
2293 for t in [ "detached", "ifname=" + ifname, "group=" + group ]:
2295 raise Exception("Unexpected FST-EVENT-IFACE data (AP): " + ev)
2297 def fst_detach_sta(dev, ifname, group):
2299 if "OK" not in dev.global_request("FST-DETACH " + ifname):
2300 raise Exception("FST-DETACH (STA) failed for " + ifname)
2301 ev = dev.wait_global_event(['FST-EVENT-IFACE'], timeout=5)
2303 raise Exception("No FST-EVENT-IFACE detached (STA) for " + ifname)
2304 for t in [ "detached", "ifname=" + ifname, "group=" + group ]:
2306 raise Exception("Unexpected FST-EVENT-IFACE data (STA): " + ev)
2308 def fst_wait_event_peer_ap(dev, event, ifname, addr):
2309 ev = dev.wait_event(['FST-EVENT-PEER'], timeout=5)
2311 raise Exception("No FST-EVENT-PEER connected (AP)")
2312 for t in [ " " + event + " ", "ifname=" + ifname, "peer_addr=" + addr ]:
2314 raise Exception("Unexpected FST-EVENT-PEER data (AP): " + ev)
2316 def fst_wait_event_peer_sta(dev, event, ifname, addr):
2317 ev = dev.wait_global_event(['FST-EVENT-PEER'], timeout=5)
2319 raise Exception("No FST-EVENT-PEER connected (STA)")
2320 for t in [ " " + event + " ", "ifname=" + ifname, "peer_addr=" + addr ]:
2322 raise Exception("Unexpected FST-EVENT-PEER data (STA): " + ev)
2324 def fst_setup_req(dev, hglobal, freq, dst, req, stie, mbie="", no_wait=False):
2325 act = req + stie + mbie
2326 dev.request("MGMT_TX %s %s freq=%d action=%s" % (dst, dst, freq, act))
2327 ev = dev.wait_event(['MGMT-TX-STATUS'], timeout=5)
2328 if ev is None or "result=SUCCESS" not in ev:
2329 raise Exception("FST Action frame not ACKed")
2334 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2336 raise Exception("No FST-EVENT-SESSION (AP)")
2337 if "new_state=SETUP_COMPLETION" in ev:
2340 def fst_start_and_connect(apdev, group, sgroup):
2341 hglobal = hostapd.HostapdGlobal()
2342 if "OK" not in hglobal.request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
2343 raise HwsimSkip("No FST testing support")
2345 params = { "ssid": "fst_11a", "hw_mode": "a", "channel": "36",
2346 "country_code": "US" }
2347 hapd = hostapd.add_ap(apdev[0], params)
2349 fst_attach_ap(hglobal, apdev[0]['ifname'], group)
2351 cmd = "FST-ATTACH %s %s" % (apdev[0]['ifname'], group)
2352 if "FAIL" not in hglobal.request(cmd):
2353 raise Exception("Duplicated FST-ATTACH (AP) accepted")
2355 params = { "ssid": "fst_11g", "hw_mode": "g", "channel": "1",
2356 "country_code": "US" }
2357 hapd2 = hostapd.add_ap(apdev[1], params)
2358 fst_attach_ap(hglobal, apdev[1]['ifname'], group)
2360 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
2361 wpas.interface_add("wlan5")
2362 fst_attach_sta(wpas, wpas.ifname, sgroup)
2364 wpas.interface_add("wlan6", set_ifname=False)
2365 wpas2 = WpaSupplicant(ifname="wlan6")
2366 fst_attach_sta(wpas, wpas2.ifname, sgroup)
2368 wpas.connect("fst_11a", key_mgmt="NONE", scan_freq="5180",
2370 wpas.wait_connected()
2372 fst_wait_event_peer_sta(wpas, "connected", wpas.ifname, apdev[0]['bssid'])
2373 fst_wait_event_peer_ap(hglobal, "connected", apdev[0]['ifname'],
2376 wpas2.connect("fst_11g", key_mgmt="NONE", scan_freq="2412",
2378 wpas2.wait_connected()
2380 fst_wait_event_peer_sta(wpas, "connected", wpas2.ifname, apdev[1]['bssid'])
2381 fst_wait_event_peer_ap(hglobal, "connected", apdev[1]['ifname'],
2383 return hglobal, wpas, wpas2, hapd, hapd2
2385 def test_fst_test_setup(dev, apdev, test_params):
2386 """FST setup using separate commands"""
2388 _test_fst_test_setup(dev, apdev, test_params)
2390 subprocess.call(['iw', 'reg', 'set', '00'])
2391 dev[0].flush_scan_cache()
2392 dev[1].flush_scan_cache()
2394 def _test_fst_test_setup(dev, apdev, test_params):
2397 hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
2399 sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
2401 raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
2403 fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
2404 fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
2405 fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
2406 fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
2408 if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2409 raise Exception("FST-MANAGER SESSION_INITIATE failed")
2412 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2414 raise Exception("No FST-EVENT-SESSION (AP)")
2415 if "new_state=SETUP_COMPLETION" in ev:
2416 f = re.search("session_id=(\d+)", ev)
2418 raise Exception("No session_id in FST-EVENT-SESSION")
2420 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2421 if "OK" not in hglobal.request(cmd):
2422 raise Exception("FST-MANAGER SESSION_RESPOND failed on AP")
2425 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2427 raise Exception("No FST-EVENT-SESSION")
2428 if "new_state=SETUP_COMPLETION" not in ev:
2429 raise Exception("Unexpected FST-EVENT-SESSION data: " + ev)
2431 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2433 raise Exception("No FST-EVENT-SESSION")
2434 if "event_type=EVENT_FST_ESTABLISHED" not in ev:
2435 raise Exception("Unexpected FST-EVENT-SESSION data: " + ev)
2437 cmd = "FST-MANAGER SESSION_REMOVE " + sid
2438 if "OK" not in wpas.global_request(cmd):
2439 raise Exception("FST-MANAGER SESSION_REMOVE failed")
2440 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2442 raise Exception("No FST-EVENT-SESSION")
2443 if "new_state=INITIAL" not in ev:
2444 raise Exception("Unexpected FST-EVENT-SESSION data (STA): " + ev)
2446 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2448 raise Exception("No FST-EVENT-SESSION (AP)")
2449 if "new_state=INITIAL" not in ev:
2450 raise Exception("Unexpected FST-EVENT-SESSION data (AP): " + ev)
2452 if "FAIL" not in wpas.global_request(cmd):
2453 raise Exception("Duplicated FST-MANAGER SESSION_REMOVE accepted")
2455 hglobal.request("FST-MANAGER SESSION_REMOVE " + sid_ap)
2457 wpas.request("DISCONNECT")
2458 wpas.wait_disconnected()
2459 fst_wait_event_peer_sta(wpas, "disconnected", wpas.ifname,
2461 fst_wait_event_peer_ap(hglobal, "disconnected", apdev[0]['ifname'],
2464 wpas2.request("DISCONNECT")
2465 wpas2.wait_disconnected()
2466 fst_wait_event_peer_sta(wpas, "disconnected", wpas2.ifname,
2468 fst_wait_event_peer_ap(hglobal, "disconnected", apdev[1]['ifname'],
2471 fst_detach_ap(hglobal, apdev[0]['ifname'], group)
2472 if "FAIL" not in hglobal.request("FST-DETACH " + apdev[0]['ifname']):
2473 raise Exception("Duplicated FST-DETACH (AP) accepted")
2476 fst_detach_ap(hglobal, apdev[1]['ifname'], group)
2479 fst_detach_sta(wpas, wpas.ifname, sgroup)
2480 fst_detach_sta(wpas, wpas2.ifname, sgroup)
2482 def test_fst_setup_mbie_diff(dev, apdev, test_params):
2483 """FST setup and different MBIE in FST Setup Request"""
2485 _test_fst_setup_mbie_diff(dev, apdev, test_params)
2487 subprocess.call(['iw', 'reg', 'set', '00'])
2488 dev[0].flush_scan_cache()
2489 dev[1].flush_scan_cache()
2491 def _test_fst_setup_mbie_diff(dev, apdev, test_params):
2494 hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
2496 # FST Setup Request: Category, FST Action, Dialog Token (non-zero),
2497 # LLT (32 bits, see 10.32), Session Transition (see 8.4.2.147),
2498 # Multi-band element (optional, see 8.4.2.140)
2500 # Session Transition: EID, Len, FSTS ID(4), Session Control,
2501 # New Band (Band ID, Setup, Operation), Old Band (Band ID, Setup, Operation)
2503 # Multi-band element: EID, Len, Multi-band Control, Band ID,
2504 # Operating Class, Channel Number, BSSID (6), Beacon Interval (2),
2505 # TSF Offset (8), Multi-band Connection Capability, FSTSessionTimeOut,
2506 # STA MAC Address (6, optional), Pairwise Cipher Suite Count (2, optional),
2507 # Pairwise Cipher Suite List (4xm, optional)
2509 # MBIE with the non-matching STA MAC Address:
2510 req = "1200011a060000"
2511 stie = "a40b0100000000020001040001"
2512 mbie = "9e1c0c0200010200000004000000000000000000000000ff0200000006ff"
2513 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie, mbie)
2515 # MBIE without the STA MAC Address:
2516 req = "1200011a060000"
2517 stie = "a40b0100000000020001040001"
2518 mbie = "9e16040200010200000004000000000000000000000000ff"
2519 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie, mbie)
2521 # MBIE with unsupported STA Role:
2522 req = "1200011a060000"
2523 stie = "a40b0100000000020001040001"
2524 mbie = "9e16070200010200000004000000000000000000000000ff"
2525 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie, mbie)
2527 # MBIE with unsupported Band ID:
2528 req = "1200011a060000"
2529 stie = "a40b0100000000020001040001"
2530 mbie = "9e1604ff00010200000004000000000000000000000000ff"
2531 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie, mbie)
2533 # FST Setup Request without MBIE (different FSTS ID):
2534 req = "1200011a060000"
2535 stie = "a40b0200000000020001040001"
2536 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie)
2538 # MBIE update OOM on AP
2539 req = "1200011a060000"
2540 stie = "a40b0100000000020001040001"
2541 mbie = "9e16040200010200000004000000000000000000000000ff"
2543 with alloc_fail(hapd, 1, "mb_ies_by_info"):
2544 fst_setup_req(wpas, hglobal, 5180, apdev[0]['bssid'], req, stie,
2546 except HwsimSkip, e:
2547 # Skip exception to allow proper cleanup
2550 # Remove sessions to avoid causing issues to following test ases
2551 s = hglobal.request("FST-MANAGER LIST_SESSIONS " + group)
2552 if not s.startswith("FAIL"):
2553 for sid in s.split(' '):
2555 hglobal.request("FST-MANAGER SESSION_REMOVE " + sid)
2557 def test_fst_many_setup(dev, apdev, test_params):
2558 """FST setup multiple times"""
2560 _test_fst_many_setup(dev, apdev, test_params)
2562 subprocess.call(['iw', 'reg', 'set', '00'])
2563 dev[0].flush_scan_cache()
2564 dev[1].flush_scan_cache()
2566 def _test_fst_many_setup(dev, apdev, test_params):
2569 hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
2571 sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
2573 raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
2575 fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
2576 fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
2577 fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
2578 fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
2580 for i in range(257):
2581 if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2582 raise Exception("FST-MANAGER SESSION_INITIATE failed")
2585 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2587 raise Exception("No FST-EVENT-SESSION (AP)")
2588 if "new_state=SETUP_COMPLETION" in ev:
2589 f = re.search("session_id=(\d+)", ev)
2591 raise Exception("No session_id in FST-EVENT-SESSION")
2593 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2594 if "OK" not in hglobal.request(cmd):
2595 raise Exception("FST-MANAGER SESSION_RESPOND failed on AP")
2598 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2600 raise Exception("No FST-EVENT-SESSION (STA)")
2601 if "new_state=SETUP_COMPLETION" not in ev:
2602 raise Exception("Unexpected FST-EVENT-SESSION data: " + ev)
2604 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2606 raise Exception("No FST-EVENT-SESSION (STA)")
2607 if "event_type=EVENT_FST_ESTABLISHED" not in ev:
2608 raise Exception("Unexpected FST-EVENT-SESSION data: " + ev)
2610 if "OK" not in wpas.global_request("FST-MANAGER SESSION_TEARDOWN " + sid):
2611 raise Exception("FST-MANAGER SESSION_INITIATE failed")
2614 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_TEARDOWN " + sid):
2615 raise Exception("Duplicate FST-MANAGER SESSION_TEARDOWN accepted")
2617 ev = wpas.wait_global_event(["FST-EVENT-SESSION"], timeout=5)
2619 raise Exception("No FST-EVENT-SESSION (STA teardown -->initial)")
2620 if "new_state=INITIAL" not in ev:
2621 raise Exception("Unexpected FST-EVENT-SESSION data (STA): " + ev)
2623 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2625 raise Exception("No FST-EVENT-SESSION (AP teardown -->initial)")
2626 if "new_state=INITIAL" not in ev:
2627 raise Exception("Unexpected FST-EVENT-SESSION data (AP): " + ev)
2629 if "OK" not in hglobal.request("FST-MANAGER SESSION_REMOVE " + sid_ap):
2630 raise Exception("FST-MANAGER SESSION_REMOVE (AP) failed")
2632 if "OK" not in wpas.global_request("FST-MANAGER SESSION_REMOVE " + sid):
2633 raise Exception("FST-MANAGER SESSION_REMOVE failed")
2635 wpas.request("DISCONNECT")
2636 wpas.wait_disconnected()
2637 fst_wait_event_peer_sta(wpas, "disconnected", wpas.ifname,
2639 fst_wait_event_peer_ap(hglobal, "disconnected", apdev[0]['ifname'],
2642 wpas2.request("DISCONNECT")
2643 wpas2.wait_disconnected()
2644 fst_wait_event_peer_sta(wpas, "disconnected", wpas2.ifname,
2646 fst_wait_event_peer_ap(hglobal, "disconnected", apdev[1]['ifname'],
2649 fst_detach_ap(hglobal, apdev[0]['ifname'], group)
2650 fst_detach_ap(hglobal, apdev[1]['ifname'], group)
2654 fst_detach_sta(wpas, wpas.ifname, sgroup)
2655 fst_detach_sta(wpas, wpas2.ifname, sgroup)
2657 def test_fst_attach_wpas_error(dev, apdev, test_params):
2658 """FST attach errors in wpa_supplicant"""
2659 if "OK" not in dev[0].global_request("FST-MANAGER TEST_REQUEST IS_SUPPORTED"):
2660 raise HwsimSkip("No FST testing support")
2662 wpas = WpaSupplicant(global_iface='/tmp/wpas-wlan5')
2663 wpas.interface_add("wlan5")
2664 fst_attach_sta(wpas, wpas.ifname, group)
2665 if "FAIL" not in wpas.global_request("FST-ATTACH %s %s" % (wpas.ifname,
2667 raise Exception("Duplicated FST-ATTACH accepted")
2668 if "FAIL" not in wpas.global_request("FST-ATTACH %s %s" % ("foofoo",
2670 raise Exception("FST-ATTACH for unknown interface accepted")
2672 def test_fst_session_initiate_errors(dev, apdev, test_params):
2673 """FST SESSION_INITIATE error cases"""
2675 _test_fst_session_initiate_errors(dev, apdev, test_params)
2677 subprocess.call(['iw', 'reg', 'set', '00'])
2678 dev[0].flush_scan_cache()
2679 dev[1].flush_scan_cache()
2681 def _test_fst_session_initiate_errors(dev, apdev, test_params):
2684 hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
2686 sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
2688 raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
2690 # No old peer MAC address
2691 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2692 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2694 fst_session_set(wpas, sid, "old_peer_addr", "00:ff:ff:ff:ff:ff")
2695 # No new peer MAC address
2696 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2697 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2699 fst_session_set(wpas, sid, "new_peer_addr", "00:ff:ff:ff:ff:fe")
2700 # No old interface defined
2701 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2702 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2704 fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
2705 # No new interface defined
2706 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2707 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2709 fst_session_set(wpas, sid, "new_ifname", wpas.ifname)
2710 # Same interface set as old and new
2711 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2712 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2714 fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
2715 # The preset old peer address is not connected
2716 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2717 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2719 fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
2720 # The preset new peer address is not connected
2721 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2722 raise Exception("Invalid FST-MANAGER SESSION_INITIATE accepted")
2724 fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
2725 # Initiate session setup
2726 if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2727 raise Exception("FST-MANAGER SESSION_INITIATE failed")
2729 # Session in progress
2730 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2731 raise Exception("Duplicated FST-MANAGER SESSION_INITIATE accepted")
2733 sid2 = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
2735 raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
2736 fst_session_set(wpas, sid2, "old_ifname", wpas.ifname)
2737 fst_session_set(wpas, sid2, "old_peer_addr", apdev[0]['bssid'])
2738 fst_session_set(wpas, sid2, "new_ifname", wpas2.ifname)
2739 fst_session_set(wpas, sid2, "new_peer_addr", apdev[1]['bssid'])
2741 # There is another session in progress (old)
2742 if "FAIL" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid2):
2743 raise Exception("Duplicated FST-MANAGER SESSION_INITIATE accepted")
2745 if "OK" not in wpas.global_request("FST-MANAGER SESSION_REMOVE " + sid):
2746 raise Exception("FST-MANAGER SESSION_REMOVE failed")
2749 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2751 raise Exception("No FST-EVENT-SESSION (AP)")
2752 if "new_state=SETUP_COMPLETION" in ev:
2753 f = re.search("session_id=(\d+)", ev)
2755 raise Exception("No session_id in FST-EVENT-SESSION")
2758 if "OK" not in hglobal.request("FST-MANAGER SESSION_REMOVE " + sid_ap):
2759 raise Exception("FST-MANAGER SESSION_REMOVE (AP) failed")
2761 if "OK" not in wpas.global_request("FST-MANAGER SESSION_REMOVE " + sid2):
2762 raise Exception("FST-MANAGER SESSION_REMOVE failed")
2764 def test_fst_session_respond_errors(dev, apdev, test_params):
2765 """FST SESSION_RESPOND error cases"""
2767 _test_fst_session_respond_errors(dev, apdev, test_params)
2769 subprocess.call(['iw', 'reg', 'set', '00'])
2770 dev[0].flush_scan_cache()
2771 dev[1].flush_scan_cache()
2773 def _test_fst_session_respond_errors(dev, apdev, test_params):
2776 hglobal, wpas, wpas2, hapd, hapd2 = fst_start_and_connect(apdev, group, sgroup)
2778 sid = wpas.global_request("FST-MANAGER SESSION_ADD " + sgroup).strip()
2780 raise Exception("FST-MANAGER SESSION_ADD (STA) failed")
2782 fst_session_set(wpas, sid, "old_ifname", wpas.ifname)
2783 fst_session_set(wpas, sid, "old_peer_addr", apdev[0]['bssid'])
2784 fst_session_set(wpas, sid, "new_ifname", wpas2.ifname)
2785 fst_session_set(wpas, sid, "new_peer_addr", apdev[1]['bssid'])
2787 if "OK" not in wpas.global_request("FST-MANAGER SESSION_INITIATE " + sid):
2788 raise Exception("FST-MANAGER SESSION_INITIATE failed")
2791 ev = hglobal.wait_event(['FST-EVENT-SESSION'], timeout=5)
2793 raise Exception("No FST-EVENT-SESSION (AP)")
2794 if "new_state=SETUP_COMPLETION" in ev:
2795 f = re.search("session_id=(\d+)", ev)
2797 raise Exception("No session_id in FST-EVENT-SESSION")
2801 # The preset peer address is not in the peer list
2802 fst_session_set_ap(hglobal, sid_ap, "old_peer_addr", "00:00:00:00:00:01")
2803 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2804 if "FAIL" not in hglobal.request(cmd):
2805 raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
2807 # Same interface set as old and new
2808 fst_session_set_ap(hglobal, sid_ap, "old_peer_addr", wpas.own_addr())
2809 fst_session_set_ap(hglobal, sid_ap, "old_ifname", apdev[1]['ifname'])
2810 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2811 if "FAIL" not in hglobal.request(cmd):
2812 raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
2815 fst_session_set_ap(hglobal, sid_ap, "old_ifname", apdev[0]['ifname'])
2816 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2817 if "OK" not in hglobal.request(cmd):
2818 raise Exception("FST-MANAGER SESSION_RESPOND failed")
2821 cmd = "FST-MANAGER SESSION_RESPOND %s accept" % sid_ap
2822 if "FAIL" not in hglobal.request(cmd):
2823 raise Exception("Invalid FST-MANAGER SESSION_RESPOND accepted")
2825 cmd = "FST-MANAGER SESSION_REMOVE " + sid
2826 if "OK" not in wpas.global_request(cmd):
2827 raise Exception("FST-MANAGER SESSION_REMOVE (STA) failed")
2829 cmd = "FST-MANAGER SESSION_REMOVE %s" % sid_ap
2830 if "OK" not in hglobal.request(cmd):
2831 raise Exception("FST-MANAGER SESSION_REMOVE (AP) failed")