summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Carré2012-04-05 13:59:25 +0200
committerThierry Carré2012-05-10 17:02:57 +0200
commit87f9cac07558b7ba4515dcf7bf93f9778d24bf1c (patch)
treea2a5f9a58772b34894e6306091eab4820a888270
parentb9816688dcf600e2ac65357691dd2e58ee47435d (diff)
cesar: AV code move to cp/av directory, refs #2928
-rw-r--r--cesar/ce/rx/bitloading/test/fsm-Makefile3
-rw-r--r--cesar/ce/rx/bitloading/test/host-Makefile2
-rw-r--r--cesar/ce/rx/bitloading/test/sparc-Makefile1
-rw-r--r--cesar/ce/rx/cp/test/Makefile8
-rw-r--r--cesar/ce/rx/test/Config1
-rw-r--r--cesar/ce/rx/test/Makefile13
-rw-r--r--cesar/ce/tx/test/Config2
-rw-r--r--cesar/ce/tx/test/Makefile15
-rw-r--r--cesar/ce/tx/test/src/cp_sta_mgr_stub.c59
-rw-r--r--cesar/ce/tx/test/src/test_expiration.c12
-rw-r--r--cesar/ce/tx/test/src/test_mme.c13
-rw-r--r--cesar/cp/Module6
-rw-r--r--cesar/cp/av/Config0
-rw-r--r--cesar/cp/av/Module8
-rw-r--r--cesar/cp/av/beacon/Module3
-rw-r--r--cesar/cp/av/beacon/beacon.h48
-rw-r--r--cesar/cp/av/beacon/discover.h45
-rw-r--r--cesar/cp/av/beacon/src/beacon.c84
-rw-r--r--cesar/cp/av/beacon/src/discover.c (renamed from cesar/cp/beacon/src/beacon_discover.c)29
-rw-r--r--cesar/cp/av/beacon/stub/Module3
-rw-r--r--cesar/cp/av/beacon/stub/src/beacon.c50
-rw-r--r--cesar/cp/av/beacon/test/utest/Config3
-rw-r--r--cesar/cp/av/beacon/test/utest/Makefile36
-rw-r--r--cesar/cp/av/beacon/test/utest/ecos.ecc.sh (renamed from cesar/cp/beacon/test/ecos.ecc.sh)0
-rw-r--r--cesar/cp/av/beacon/test/utest/override/cl/inc/context.h (renamed from cesar/cp/beacon/test/override/cl/inc/context.h)0
-rw-r--r--cesar/cp/av/beacon/test/utest/override/cp/inc/context.h (renamed from cesar/cp/beacon/test/override/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/beacon/test/utest/override/mac/sar/inc/context.h (renamed from cesar/cp/beacon/test/override/mac/sar/inc/context.h)0
-rw-r--r--cesar/cp/av/beacon/test/utest/src/beacon.c960
-rw-r--r--cesar/cp/av/beacon/test/utest/src/beacon_utest.c61
-rw-r--r--cesar/cp/av/beacon/test/utest/src/discover.c (renamed from cesar/cp/beacon/test/src/discover.c)16
-rw-r--r--cesar/cp/av/beacon/test/utest/src/stubs.c103
-rw-r--r--cesar/cp/av/beacon/test/utest/src/test_beacon.c291
-rw-r--r--cesar/cp/av/beacon/test/utest2/Config (renamed from cesar/cp/beacon/test/Config)1
-rw-r--r--cesar/cp/av/beacon/test/utest2/Makefile20
-rw-r--r--cesar/cp/av/beacon/test/utest2/inc/scenario_defs.h (renamed from cesar/cp/beacon/test/inc/scenario_defs.h)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/override/cp/inc/context.h (renamed from cesar/cp/beacon/test/override-scenario/cp/inc/context.h)3
-rw-r--r--cesar/cp/av/beacon/test/utest2/override/cp/sta/core/defs.h (renamed from cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/beacon.c (renamed from cesar/cp/beacon/test/src/beacon.c)6
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c (renamed from cesar/cp/beacon/test/src/beacon_scenario.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/bsu_beacon_stub.c (renamed from cesar/cp/beacon/test/src/bsu_beacon_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/bsu_stub.c (renamed from cesar/cp/beacon/test/src/bsu_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/bsu_stub_scenario.c (renamed from cesar/cp/beacon/test/src/bsu_stub_scenario.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/ca_stub.c (renamed from cesar/cp/beacon/test/src/ca_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/fsm_stub.c (renamed from cesar/cp/beacon/test/src/fsm_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/phy_stub.c (renamed from cesar/cp/beacon/test/src/phy_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/scenario_actions.c (renamed from cesar/cp/beacon/test/src/scenario_actions.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/secu_stub.c (renamed from cesar/cp/beacon/test/src/secu_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/sta_mgr_stub.c (renamed from cesar/cp/beacon/test/src/sta_mgr_stub.c)0
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/stubs.c101
-rw-r--r--cesar/cp/av/cco/action/Module3
-rw-r--r--cesar/cp/av/cco/action/cco_action.h361
-rw-r--r--cesar/cp/av/cco/action/cco_conn/Module1
-rw-r--r--cesar/cp/av/cco/action/cco_conn/cco_action.h (renamed from cesar/cp/cco/action/cco_conn/cco_action.h)0
-rwxr-xr-xcesar/cp/av/cco/action/cco_conn/doc/CCo Con.odt (renamed from cesar/cp/cco/action/cco_conn/doc/CCo Con.odt)bin304722 -> 304722 bytes
-rw-r--r--cesar/cp/av/cco/action/cco_conn/doc/cco_conn.xmi (renamed from cesar/cp/cco/action/cco_conn/doc/cco_conn.xmi)0
-rw-r--r--cesar/cp/av/cco/action/cco_conn/inc/cco_action.h (renamed from cesar/cp/cco/action/cco_conn/inc/cco_action.h)0
-rw-r--r--cesar/cp/av/cco/action/cco_conn/src/action.c (renamed from cesar/cp/cco/action/cco_conn/src/action.c)0
-rw-r--r--cesar/cp/av/cco/action/cco_conn/test/Makefile (renamed from cesar/cp/cco/action/cco_conn/test/Makefile)2
-rw-r--r--cesar/cp/av/cco/action/cco_conn/test/ecos.ecc.sh (renamed from cesar/cp/cco/action/cco_conn/test/ecos.ecc.sh)0
-rw-r--r--cesar/cp/av/cco/action/cco_conn/test/src/cco_action_conn_test.c (renamed from cesar/cp/cco/action/cco_conn/test/src/cco_action_conn_test.c)0
-rw-r--r--cesar/cp/av/cco/action/cco_conn/test/src/msg_stub.c (renamed from cesar/cp/cco/action/cco_conn/test/src/msg_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/doc/Makefile (renamed from cesar/cp/cco/action/doc/Makefile)10
-rw-r--r--cesar/cp/av/cco/action/doc/assoc_procedure.sdl (renamed from cesar/cp/cco/action/doc/assoc_procedure.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/auth_procedure.sdl (renamed from cesar/cp/cco/action/doc/auth_procedure.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/cco_action.odt (renamed from cesar/cp/cco/action/doc/cco_action.odt)bin787089 -> 787089 bytes
-rw-r--r--cesar/cp/av/cco/action/doc/cco_action.xmi (renamed from cesar/cp/cco/action/doc/cco_action.xmi)0
-rw-r--r--cesar/cp/av/cco/action/doc/cco_selection.sdl (renamed from cesar/cp/cco/action/doc/cco_selection.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_cco.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_cco.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_cco_appoint.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_cco_appoint.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_cco_leave.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_cco_leave.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_selection.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_selection.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_sta.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_sta.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/fsm_handover_sta_appoint.sdl (renamed from cesar/cp/cco/action/doc/fsm_handover_sta_appoint.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/handover_cco.sdl (renamed from cesar/cp/cco/action/doc/handover_cco.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/handover_sta.sdl (renamed from cesar/cp/cco/action/doc/handover_sta.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/leave.sdl (renamed from cesar/cp/cco/action/doc/leave.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/nek_change.sdl (renamed from cesar/cp/cco/action/doc/nek_change.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/snid.sdl (renamed from cesar/cp/cco/action/doc/snid.sdl)0
-rw-r--r--cesar/cp/av/cco/action/doc/tei.sdl (renamed from cesar/cp/cco/action/doc/tei.sdl)0
-rw-r--r--cesar/cp/av/cco/action/handover.h (renamed from cesar/cp/cco/action/handover.h)20
-rw-r--r--cesar/cp/av/cco/action/inc/cco_action.h77
-rw-r--r--cesar/cp/av/cco/action/src/cco_action.c1509
-rw-r--r--cesar/cp/av/cco/action/src/handover.c (renamed from cesar/cp/cco/action/src/handover.c)64
-rw-r--r--cesar/cp/av/cco/action/stub/Module3
-rw-r--r--cesar/cp/av/cco/action/stub/src/cco_action.c283
-rw-r--r--cesar/cp/av/cco/action/test/utest/Config2
-rw-r--r--cesar/cp/av/cco/action/test/utest/Makefile20
-rw-r--r--cesar/cp/av/cco/action/test/utest/inc/scenario_defs.h (renamed from cesar/cp/cco/action/test/utest/inc/scenario_defs.h)16
-rw-r--r--cesar/cp/av/cco/action/test/utest/inc/test_cco_action.h (renamed from cesar/cp/cco/action/test/utest/inc/test_cco_action.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/override/cp/inc/context.h (renamed from cesar/cp/cco/action/test/utest/override/cp/inc/context.h)3
-rw-r--r--cesar/cp/av/cco/action/test/utest/override/cp/sta/core/defs.h (renamed from cesar/cp/cco/action/test/overide/cp/sta/core/defs.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/override/mac/sar/inc/sar_context.h (renamed from cesar/cp/cco/action/test/utest/override/mac/sar/inc/sar_context.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/assoc.c (renamed from cesar/cp/cco/action/test/utest/src/assoc.c)16
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/beacon_stub.c (renamed from cesar/cp/cco/action/test/utest/src/beacon_stub.c)12
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/bsu_stub.c (renamed from cesar/cp/cco/action/test/utest/src/bsu_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/cp_stub.c (renamed from cesar/cp/cco/action/test/utest/src/cp_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/dataplane_stub.c (renamed from cesar/cp/cco/action/test/utest/src/dataplane_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/discover_list.c (renamed from cesar/cp/cco/action/test/utest/src/discover_list.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/fsm_stub.c (renamed from cesar/cp/cco/action/test/utest/src/fsm_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/garbage.c (renamed from cesar/cp/cco/action/test/utest/src/garbage.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/handover.c (renamed from cesar/cp/cco/action/test/utest/src/handover.c)21
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/msg_stub.c (renamed from cesar/cp/cco/action/test/utest/src/msg_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/nek.c (renamed from cesar/cp/cco/action/test/utest/src/nek.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/scenario_actions.c (renamed from cesar/cp/cco/action/test/utest/src/scenario_actions.c)16
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/secu.c (renamed from cesar/cp/cco/action/test/utest/src/secu.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/sta_action.c (renamed from cesar/cp/cco/action/test/utest/src/sta_action.c)4
-rw-r--r--cesar/cp/av/cco/action/test/utest/src/test_cco_action.c (renamed from cesar/cp/cco/action/test/utest/src/test_cco_action.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/Config1
-rw-r--r--cesar/cp/av/cco/action/test/utest2/Makefile52
-rw-r--r--cesar/cp/av/cco/action/test/utest2/doc/Makefile (renamed from cesar/cp/cco/action/test/doc/Makefile)4
-rw-r--r--cesar/cp/av/cco/action/test/utest2/doc/cco_action.txt (renamed from cesar/cp/cco/action/test/doc/cco_action.txt)10
-rw-r--r--cesar/cp/av/cco/action/test/utest2/ecos.ecc.sh (renamed from cesar/cp/cco/action/test/ecos.ecc.sh)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/override/cp/inc/context.h (renamed from cesar/cp/cco/action/test/overide/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/override/cp/sta/core/defs.h (renamed from cesar/cp/cco/action/test/utest/override/cp/sta/core/defs.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/override/mac/sar/inc/context.h (renamed from cesar/cp/cco/action/test/overide/mac/sar/inc/context.h)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/action-test.c (renamed from cesar/cp/cco/action/test/src/action-test.c)89
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/action_gen_nek.c (renamed from cesar/cp/cco/action/test/src/action_gen_nek.c)3
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/core_stub.c (renamed from cesar/cp/cco/action/test/src/core_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/fsm_handover.c (renamed from cesar/cp/cco/action/test/src/fsm_handover.c)25
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/garbage.c (renamed from cesar/cp/cco/action/test/src/garbage.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/pbproc_stub.c (renamed from cesar/cp/cco/action/test/src/pbproc_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/sar_stub.c (renamed from cesar/cp/cco/action/test/src/sar_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/secu_stub.c (renamed from cesar/cp/cco/action/test/src/secu_stub.c)0
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/sta_action.c (renamed from cesar/cp/cco/action/test/src/sta_action.c)2
-rw-r--r--cesar/cp/av/cco/action/test/utest2/src/status.c (renamed from cesar/cp/cco/action/test/src/status.c)9
-rw-r--r--cesar/cp/av/cco/bw/Module4
-rw-r--r--cesar/cp/av/cco/bw/stub/Module4
-rw-r--r--cesar/cp/av/cco/region/Module4
-rw-r--r--cesar/cp/av/cco/region/stub/Module4
-rw-r--r--cesar/cp/av/cl_interf/test/utest/Config2
-rw-r--r--cesar/cp/av/cl_interf/test/utest/Makefile15
-rw-r--r--cesar/cp/av/cl_interf/test/utest/doc/Makefile (renamed from cesar/cp/cl_interf/test/doc/Makefile)4
-rw-r--r--cesar/cp/av/cl_interf/test/utest/doc/cl-interf.txt (renamed from cesar/cp/cl_interf/test/doc/cl-interf.txt)22
-rw-r--r--cesar/cp/av/cl_interf/test/utest/override/cp/inc/context.h (renamed from cesar/cp/cl_interf/test/override/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/core.h (renamed from cesar/cp/cl_interf/test/override/cp/sta/core/core.h)0
-rw-r--r--cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/defs.h (renamed from cesar/cp/cl_interf/test/override/cp/sta/core/defs.h)0
-rw-r--r--cesar/cp/av/cl_interf/test/utest/override/mac/sar/inc/context.h (renamed from cesar/cp/cl_interf/test/override/mac/sar/inc/context.h)0
-rw-r--r--cesar/cp/av/cl_interf/test/utest/src/test-cl-interf.c (renamed from cesar/cp/cl_interf/test/src/test-cl-interf.c)2
-rw-r--r--cesar/cp/av/cl_interf/test/utest/src/test.c (renamed from cesar/cp/cl_interf/test/src/test.c)0
-rw-r--r--cesar/cp/av/cl_interf/test/utest/test.h (renamed from cesar/cp/cl_interf/test/test.h)0
-rw-r--r--cesar/cp/av/fsm/Config1
-rw-r--r--cesar/cp/av/fsm/Module40
-rw-r--r--cesar/cp/av/fsm/src/fsm/cp.conf (renamed from cesar/cp/fsm/src/fsm/cp.conf)0
-rw-r--r--cesar/cp/av/fsm/src/fsm/cp.fsm (renamed from cesar/cp/fsm/src/fsm/cp.fsm)268
-rw-r--r--cesar/cp/av/fsm/src/fsm/template_defs.h (renamed from cesar/cp/fsm/src/fsm/template_defs.h)0
-rw-r--r--cesar/cp/av/fsm/src/fsm/template_tables.h (renamed from cesar/cp/fsm/src/fsm/template_tables.h)0
-rw-r--r--cesar/cp/av/fsm/src/tables.c (renamed from cesar/cp/fsm/src/tables.c)11
-rw-r--r--cesar/cp/av/fsm/stub/Module4
-rw-r--r--cesar/cp/av/fsm/stub/src/fsm_stub.c (renamed from cesar/cp/fsm/stub/src/fsm_stub.c)2
-rw-r--r--cesar/cp/av/fsm/test/utest/Config2
-rw-r--r--cesar/cp/av/fsm/test/utest/Makefile (renamed from cesar/cp/fsm/test/utest/Makefile)10
-rw-r--r--cesar/cp/av/fsm/test/utest/inc/scenario_defs.h (renamed from cesar/cp/fsm/test/utest/inc/scenario_defs.h)0
-rw-r--r--cesar/cp/av/fsm/test/utest/override/cp/inc/context.h (renamed from cesar/cp/fsm/test/utest/override/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/fsm/test/utest/override/cp/sta/core/core.h (renamed from cesar/cp/fsm/test/utest/override/cp/sta/core/core.h)0
-rw-r--r--cesar/cp/av/fsm/test/utest/src/actions.c (renamed from cesar/cp/fsm/test/utest/src/actions.c)0
-rw-r--r--cesar/cp/av/fsm/test/utest/src/fsm_stub.c (renamed from cesar/cp/fsm/test/utest/src/fsm_stub.c)0
-rw-r--r--cesar/cp/av/fsm/test/utest/src/test_fsm.c (renamed from cesar/cp/fsm/test/utest/src/test_fsm.c)0
-rw-r--r--cesar/cp/av/fsm/test/utest/src/utest.fsm (renamed from cesar/cp/fsm/test/utest/src/utest.fsm)0
-rw-r--r--cesar/cp/av/msg/test/utest/Config3
-rw-r--r--cesar/cp/av/msg/test/utest/Makefile78
-rw-r--r--cesar/cp/av/msg/test/utest/doc/Makefile (renamed from cesar/cp/msg/test/doc/Makefile)4
-rw-r--r--cesar/cp/av/msg/test/utest/doc/read-header.txt (renamed from cesar/cp/msg/test/doc/read-header.txt)4
-rw-r--r--cesar/cp/av/msg/test/utest/override/cp/inc/context.h (renamed from cesar/cp/msg/test/overide/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/msg/test/utest/override/cyg/kernel/kapi.h (renamed from cesar/cp/msg/test/overide/cyg/kernel/kapi.h)0
-rw-r--r--cesar/cp/av/msg/test/utest/override/mac/sar/inc/context.h (renamed from cesar/cp/msg/test/overide/mac/sar/inc/context.h)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/cc_discover_list.c (renamed from cesar/cp/msg/test/src/cc_discover_list.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/cp_cl_interface_stub.c (renamed from cesar/cp/msg/test/src/cp_cl_interface_stub.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/cp_cl_interface_vs_stub.c (renamed from cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/interface_stub.c27
-rw-r--r--cesar/cp/av/msg/test/utest/src/mac_sar_interface_stub.c (renamed from cesar/cp/msg/test/src/mac_sar_interface_stub.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/misc_stub.c (renamed from cesar/cp/msg/test/src/misc_stub.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/mme_frag.c (renamed from cesar/cp/msg/test/src/mme_frag.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/msg.c (renamed from cesar/cp/msg/test/src/msg.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/msg_cc.c (renamed from cesar/cp/msg/test/src/msg_cc.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/msg_cm.c (renamed from cesar/cp/msg/test/src/msg_cm.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/msg_drv.c (renamed from cesar/cp/msg/test/src/msg_drv.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/msg_vs.c (renamed from cesar/cp/msg/test/src/msg_vs.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/relay.c (renamed from cesar/cp/msg/test/src/relay.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/test-msg-read-header.c (renamed from cesar/cp/msg/test/src/test-msg-read-header.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/src/test_msg_allowed_mme.c (renamed from cesar/cp/msg/test/src/test_msg_allowed_mme.c)0
-rw-r--r--cesar/cp/av/msg/test/utest/test.h (renamed from cesar/cp/msg/test/test.h)0
-rw-r--r--cesar/cp/av/sta/action/Config0
-rw-r--r--cesar/cp/av/sta/action/Module4
-rw-r--r--cesar/cp/av/sta/action/action.h28
-rw-r--r--cesar/cp/av/sta/action/assoc.h489
-rw-r--r--cesar/cp/av/sta/action/drv.h65
-rw-r--r--cesar/cp/av/sta/action/handover.h (renamed from cesar/cp/sta/action/handover.h)12
-rw-r--r--cesar/cp/av/sta/action/inc/action.h (renamed from cesar/cp/sta/action/inc/action.h)2
-rw-r--r--cesar/cp/av/sta/action/info.h (renamed from cesar/cp/sta/action/info.h)14
-rw-r--r--cesar/cp/av/sta/action/misc.h41
-rw-r--r--cesar/cp/av/sta/action/poweron.h240
-rw-r--r--cesar/cp/av/sta/action/sc.h (renamed from cesar/cp/sta/action/sc.h)52
-rw-r--r--cesar/cp/av/sta/action/src/action.c122
-rw-r--r--cesar/cp/av/sta/action/src/assoc.c815
-rw-r--r--cesar/cp/av/sta/action/src/drv.c182
-rw-r--r--cesar/cp/av/sta/action/src/handover.c (renamed from cesar/cp/sta/action/src/handover.c)37
-rw-r--r--cesar/cp/av/sta/action/src/info.c (renamed from cesar/cp/sta/action/src/info.c)9
-rw-r--r--cesar/cp/av/sta/action/src/key.c (renamed from cesar/cp/sta/action/src/key.c)13
-rw-r--r--cesar/cp/av/sta/action/src/misc.c172
-rw-r--r--cesar/cp/av/sta/action/src/poweron.c390
-rw-r--r--cesar/cp/av/sta/action/src/sc.c (renamed from cesar/cp/sta/action/src/sc.c)101
-rw-r--r--cesar/cp/av/sta/action/test/utest/Config1
-rw-r--r--cesar/cp/av/sta/action/test/utest/Makefile26
-rw-r--r--cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h (renamed from cesar/cp/sta/action/test/utest/inc/scenario_defs.h)40
-rw-r--r--cesar/cp/av/sta/action/test/utest/inc/test_sta_action.h (renamed from cesar/cp/sta/action/test/utest/inc/test_sta_action.h)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/override/cp/inc/context.h (renamed from cesar/cp/sta/action/test/utest/override/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/override/cp/sta/core/core.h (renamed from cesar/cp/sta/action/test/utest/override/cp/sta/core/core.h)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/assoc.c (renamed from cesar/cp/sta/action/test/utest/src/assoc.c)8
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/beacon_stub.c (renamed from cesar/cp/sta/action/test/utest/src/beacon_stub.c)6
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/bridge.c (renamed from cesar/cp/sta/action/test/utest/src/bridge.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/cco_stub.c166
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/ce_stub.c (renamed from cesar/cp/sta/action/test/utest/src/ce_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/core_stub.c (renamed from cesar/cp/sta/action/test/utest/src/core_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/cp_stub.c (renamed from cesar/cp/sta/action/test/utest/src/cp_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/dataplane_stub.c (renamed from cesar/cp/sta/action/test/utest/src/dataplane_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/drv.c (renamed from cesar/cp/sta/action/test/utest/src/drv.c)4
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/fsm_stub.c (renamed from cesar/cp/sta/action/test/utest/src/fsm_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/handover.c (renamed from cesar/cp/sta/action/test/utest/src/handover.c)8
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/info.c (renamed from cesar/cp/sta/action/test/utest/src/info.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/key.c (renamed from cesar/cp/sta/action/test/utest/src/key.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/mac_sar_interface_stub.c (renamed from cesar/cp/sta/action/test/utest/src/mac_sar_interface_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/misc.c (renamed from cesar/cp/sta/action/test/utest/src/misc.c)2
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/msg_stub.c (renamed from cesar/cp/sta/action/test/utest/src/msg_stub.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/poweron.c (renamed from cesar/cp/sta/action/test/utest/src/poweron.c)16
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/sc.c (renamed from cesar/cp/sta/action/test/utest/src/sc.c)6
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/sc_test.c (renamed from cesar/cp/sta/action/test/utest/src/sc_test.c)0
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/scenario_actions.c (renamed from cesar/cp/sta/action/test/utest/src/scenario_actions.c)183
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/test_sta_action.c (renamed from cesar/cp/sta/action/test/utest/src/test_sta_action.c)12
-rw-r--r--cesar/cp/av/sta/action/test/utest/src/vs.c (renamed from cesar/cp/sta/action/test/utest/src/vs.c)0
-rw-r--r--cesar/cp/av/sta/mgr/Module3
-rw-r--r--cesar/cp/av/sta/mgr/src/sta_mgr.c388
-rw-r--r--cesar/cp/av/sta/mgr/src/sta_own_data.c87
-rw-r--r--cesar/cp/av/sta/mgr/sta_mgr.h35
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/Config (renamed from cesar/cp/sta/mgr/test/Config)1
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/Makefile15
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/Makefile (renamed from cesar/cp/sta/mgr/test/doc/Makefile)4
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/net.txt (renamed from cesar/cp/sta/mgr/test/doc/net.txt)9
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/net_list.txt (renamed from cesar/cp/sta/mgr/test/doc/net_list.txt)13
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/sta.txt (renamed from cesar/cp/sta/mgr/test/doc/sta.txt)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/sta_mgr.txt (renamed from cesar/cp/sta/mgr/test/doc/sta_mgr.txt)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/doc/sta_own_data.txt (renamed from cesar/cp/sta/mgr/test/doc/sta_own_data.txt)18
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/override/cp/cco/action/inc/context.h (renamed from cesar/cp/sta/mgr/test/overide/cp/cco/action/inc/context.h)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/override/cp/inc/context.h (renamed from cesar/cp/sta/mgr/test/overide/cp/inc/context.h)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/override/cp/sta/core/core.h (renamed from cesar/cp/sta/mgr/test/overide/cp/sta/core/core.h)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/override/mac/sar/inc/context.h (renamed from cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/core_stub.c (renamed from cesar/cp/sta/mgr/test/src/core_stub.c)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/net_test.c (renamed from cesar/cp/sta/mgr/test/src/net_test.c)2
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/sar_stub.c (renamed from cesar/cp/sta/mgr/test/src/sar_stub.c)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/sta-test.c (renamed from cesar/cp/sta/mgr/test/src/sta-test.c)0
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/sta_mgr.c (renamed from cesar/cp/sta/mgr/test/src/sta_mgr.c)5
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/station_test.c (renamed from cesar/cp/sta/mgr/test/src/station_test.c)2
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/src/test_sta_mgr.c (renamed from cesar/cp/sta/mgr/test/src/test_sta_mgr.c)2
-rw-r--r--cesar/cp/av/sta/mgr/test/utest/test_sta_mgr.h (renamed from cesar/cp/sta/mgr/test/test_sta_mgr.h)0
-rw-r--r--cesar/cp/beacon/Config2
-rw-r--r--cesar/cp/beacon/Module2
-rw-r--r--cesar/cp/beacon/beacon.h99
-rw-r--r--cesar/cp/beacon/discover.h58
-rw-r--r--cesar/cp/beacon/inc/beacon.h42
-rw-r--r--cesar/cp/beacon/src/beacon.c245
-rw-r--r--cesar/cp/beacon/stub/src/beacon.c117
-rw-r--r--cesar/cp/beacon/test/Makefile7
-rw-r--r--cesar/cp/beacon/test/Makefile-ecos28
-rw-r--r--cesar/cp/beacon/test/Makefile-scenario17
-rw-r--r--cesar/cp/beacon/test/doc/Makefile20
-rw-r--r--cesar/cp/beacon/test/doc/beacon-discover.txt129
-rw-r--r--cesar/cp/beacon/test/doc/beacon.txt42
-rw-r--r--cesar/cp/beacon/test/doc/bentry.txt159
-rw-r--r--cesar/cp/beacon/test/doc/default-schedules.txt44
-rw-r--r--cesar/cp/beacon/test/doc/recv-beacon.txt81
-rw-r--r--cesar/cp/beacon/test/doc/send-beacon.txt85
-rw-r--r--cesar/cp/cco/action/Module2
-rw-r--r--cesar/cp/cco/action/cco_action.h344
-rw-r--r--cesar/cp/cco/action/cco_conn/Module1
-rw-r--r--cesar/cp/cco/action/inc/cco_action.h54
-rw-r--r--cesar/cp/cco/action/src/cco_action.c1470
-rw-r--r--cesar/cp/cco/action/stub/src/cco_action.c274
-rw-r--r--cesar/cp/cco/action/test/Makefile47
-rw-r--r--cesar/cp/cco/action/test/utest/Makefile17
-rw-r--r--cesar/cp/cco/region/Module2
-rw-r--r--cesar/cp/cl_interf/test/Makefile14
-rw-r--r--cesar/cp/conn/test/Makefile10
-rw-r--r--cesar/cp/fsm/Config1
-rw-r--r--cesar/cp/fsm/Module38
-rw-r--r--cesar/cp/fsm/stub/Module3
-rw-r--r--cesar/cp/fsm/test/utest/Config2
-rw-r--r--cesar/cp/msg/src/msg.c6
-rw-r--r--cesar/cp/msg/src/msg_cm.c2
-rw-r--r--cesar/cp/msg/test/Config1
-rw-r--r--cesar/cp/msg/test/Makefile66
-rw-r--r--cesar/cp/sta/action/Module3
-rw-r--r--cesar/cp/sta/action/action.h6
-rw-r--r--cesar/cp/sta/action/assoc.h361
-rw-r--r--cesar/cp/sta/action/drv.h50
-rw-r--r--cesar/cp/sta/action/key.h9
-rw-r--r--cesar/cp/sta/action/misc.h19
-rw-r--r--cesar/cp/sta/action/poweron.h210
-rw-r--r--cesar/cp/sta/action/src/action.c101
-rw-r--r--cesar/cp/sta/action/src/assoc.c789
-rw-r--r--cesar/cp/sta/action/src/drv.c160
-rw-r--r--cesar/cp/sta/action/src/misc.c146
-rw-r--r--cesar/cp/sta/action/src/poweron.c364
-rw-r--r--cesar/cp/sta/action/test/utest/Config1
-rw-r--r--cesar/cp/sta/action/test/utest/Makefile23
-rw-r--r--cesar/cp/sta/action/test/utest/src/cco_stub.c166
-rw-r--r--cesar/cp/sta/core/src/core.c1
-rw-r--r--cesar/cp/sta/core/test/Config2
-rw-r--r--cesar/cp/sta/core/test/Makefile.mk33
-rw-r--r--cesar/cp/sta/core/test/src/beacon_stub.c22
-rw-r--r--cesar/cp/sta/core/test/src/core_thread.c3
-rw-r--r--cesar/cp/sta/core/test/src/core_timer.c7
-rw-r--r--cesar/cp/sta/core/test/src/sta_mgr_stub.c2
-rw-r--r--cesar/cp/sta/mgr/inc/net.h13
-rw-r--r--cesar/cp/sta/mgr/inc/sta_mgr.h15
-rw-r--r--cesar/cp/sta/mgr/src/net.c9
-rw-r--r--cesar/cp/sta/mgr/src/sta_mgr.c390
-rw-r--r--cesar/cp/sta/mgr/src/sta_own_data.c58
-rw-r--r--cesar/cp/sta/mgr/sta_mgr.h54
-rw-r--r--cesar/cp/sta/mgr/sta_own_data.h5
-rw-r--r--cesar/cp/sta/mgr/test/Makefile14
-rw-r--r--cesar/projects/plc/Makefile4
-rw-r--r--cesar/test_general/station/compliance/board-Config1
-rw-r--r--cesar/test_general/station/compliance/simu-Config1
-rw-r--r--cesar/test_general/station/fcall/src/beacon.c6
-rw-r--r--cesar/test_general/station/fcall/src/cc_leave.c3
-rw-r--r--cesar/test_general/station/maximus/Config1
-rw-r--r--cesar/test_general/station/scenario/Makefile31
-rw-r--r--cesar/test_general/station/scenario/av/Config1
-rw-r--r--cesar/test_general/station/scenario/av/Makefile31
-rw-r--r--cesar/test_general/station/scenario/av/ecos.ecc.sh (renamed from cesar/test_general/station/scenario/ecos.ecc.sh)0
-rw-r--r--cesar/test_general/station/scenario/av/lib/association_protocol.py (renamed from cesar/test_general/station/scenario/lib/association_protocol.py)0
-rw-r--r--cesar/test_general/station/scenario/av/lib/handover_protocol.py (renamed from cesar/test_general/station/scenario/lib/handover_protocol.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc01_assoc_auth.py (renamed from cesar/test_general/station/scenario/py/sc01_assoc_auth.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc02_stas_communication.py (renamed from cesar/test_general/station/scenario/py/sc02_stas_communication.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc03_two_avln_coexisting.py (renamed from cesar/test_general/station/scenario/py/sc03_two_avln_coexisting.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc04_cc_whoru.py (renamed from cesar/test_general/station/scenario/py/sc04_cc_whoru.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc05_cc_leave.py (renamed from cesar/test_general/station/scenario/py/sc05_cc_leave.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc06_discover_procedure.py (renamed from cesar/test_general/station/scenario/py/sc06_discover_procedure.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc07_bridge.py (renamed from cesar/test_general/station/scenario/py/sc07_bridge.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc08_bentry_change.py (renamed from cesar/test_general/station/scenario/py/sc08_bentry_change.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc09_simple_connect.py (renamed from cesar/test_general/station/scenario/py/sc09_simple_connect.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc10_short_messages.py (renamed from cesar/test_general/station/scenario/py/sc10_short_messages.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc11_cm_nw_info.py (renamed from cesar/test_general/station/scenario/py/sc11_cm_nw_info.py)0
-rw-r--r--cesar/test_general/station/scenario/av/py/sc12_change_nmk.py (renamed from cesar/test_general/station/scenario/py/sc12_change_nmk.py)2
-rw-r--r--cesar/test_general/station/scenario/av/py/sc14_igmp.py (renamed from cesar/test_general/station/scenario/py/sc14_igmp.py)2
-rw-r--r--cesar/test_general/station/scenario/av/py/scenario_init.py (renamed from cesar/test_general/station/scenario/py/scenario_init.py)10
-rw-r--r--cesar/test_general/station/scenario/av/py/testtemplate.py (renamed from cesar/test_general/station/scenario/py/testtemplate.py)0
-rw-r--r--cesar/test_general/station/scenario/av/testbook.py (renamed from cesar/test_general/station/scenario/testbook.py)0
-rw-r--r--cesar/test_general/station/tonemap/host-Config1
-rw-r--r--cesar/test_general/station/tonemap/sparc-Config1
-rw-r--r--common/tests/tests25
351 files changed, 8811 insertions, 6885 deletions
diff --git a/cesar/ce/rx/bitloading/test/fsm-Makefile b/cesar/ce/rx/bitloading/test/fsm-Makefile
index 8735a7a9e2..a1eca3729e 100644
--- a/cesar/ce/rx/bitloading/test/fsm-Makefile
+++ b/cesar/ce/rx/bitloading/test/fsm-Makefile
@@ -8,8 +8,9 @@ include common-define.mk
HOST_PROGRAMS = test_ce_fsm
test_ce_fsm_SOURCES = scenario_actions.c test_fsm.c scenario_events.c \
- ce_rx_bl_stub.c ecos_stub.c
+ ce_rx_bl_stub.c ecos_stub.c
test_ce_fsm_MODULES = $(ce_rx_bl_modules_common) lib/scenario
+test_ce_fsm_CONFIG_MODULES = cp
ce_rx_bitloading_MODULE_SOURCES = transition.c intervals.c
mac_common_MODULE_SOURCES = interval.c
diff --git a/cesar/ce/rx/bitloading/test/host-Makefile b/cesar/ce/rx/bitloading/test/host-Makefile
index f50f12d6b8..856652f3d6 100644
--- a/cesar/ce/rx/bitloading/test/host-Makefile
+++ b/cesar/ce/rx/bitloading/test/host-Makefile
@@ -11,9 +11,11 @@ HOST_PROGRAMS = test_ce_host test_ce_intervals
test_ce_host_SOURCES = $(ce_rx_bl_test_sources_common) ecos_stub.c
test_ce_host_MODULES = $(ce_rx_bl_modules_common)
+test_ce_host_CONFIG_MODULES = cp
test_ce_intervals_SOURCES = test_intervals.c ecos_stub.c
test_ce_intervals_MODULES = $(ce_rx_bl_modules_common)
+test_ce_intervals_CONFIG_MODULES = cp
INCLUDES += ce/rx/bitloading/test/override
diff --git a/cesar/ce/rx/bitloading/test/sparc-Makefile b/cesar/ce/rx/bitloading/test/sparc-Makefile
index 2c0d8990f8..ccaa7e1633 100644
--- a/cesar/ce/rx/bitloading/test/sparc-Makefile
+++ b/cesar/ce/rx/bitloading/test/sparc-Makefile
@@ -16,6 +16,7 @@ TARGET_PROGRAMS = test_ce_sparc
test_ce_sparc_SOURCES = $(ce_rx_bl_test_sources_common)
test_ce_sparc_MODULES = $(ce_rx_bl_modules_common) hal/arch
+test_ce_sparc_CONFIG_MODULES = cp
# Include base makefile.
include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/rx/cp/test/Makefile b/cesar/ce/rx/cp/test/Makefile
index 80f8c51d7b..743840fced 100644
--- a/cesar/ce/rx/cp/test/Makefile
+++ b/cesar/ce/rx/cp/test/Makefile
@@ -14,14 +14,18 @@ HOST_PROGRAMS = test_mbox
# Test MME.
test_mme_SOURCES = test_mme.c stub.c
test_mme_MODULES = lib mac/common ce/rx/cp ce/common cp/msg/stub cp/sta/mgr \
- cp/fsm/stub
+ cp/av/fsm/stub
+test_mme_CONFIG_MODULES = cp
# Test mailbox.
test_mbox_SOURCES = test_mbox.c stub_mbox.c
-test_mbox_MODULES = lib mac/common ce/rx/cp ce/common cp/fsm/stub cp/msg/stub
+test_mbox_MODULES = lib mac/common ce/rx/cp ce/common cp/msg/stub \
+ cp/av/fsm/stub
+test_mbox_CONFIG_MODULES = cp
# Remove sta.c to prevent multiple definition of cp_sta_get_peer.
cp_sta_mgr_MODULE_SOURCES = net.c sta_mgr.c sta_own_data.c
+cp_sta_mgr_CONFIG_MODULES = cp
# Include main Makefile.
include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/rx/test/Config b/cesar/ce/rx/test/Config
index 79114fce7f..2d62cd39d5 100644
--- a/cesar/ce/rx/test/Config
+++ b/cesar/ce/rx/test/Config
@@ -1,2 +1,3 @@
CONFIG_DEBUG_FATAL_CATCH = y
CONFIG_SLAB_ALLOC_SCRAMBLE = y
+CONFIG_CP_AV = y
diff --git a/cesar/ce/rx/test/Makefile b/cesar/ce/rx/test/Makefile
index 5c2ede2792..ca9c515f69 100644
--- a/cesar/ce/rx/test/Makefile
+++ b/cesar/ce/rx/test/Makefile
@@ -9,12 +9,12 @@ INCLUDES = ce/rx/test/override
# Common modules.
common_MODULES = ce/rx ce/rx/cp ce/common \
- ce/rx/bitloading/fsm \
- ce/rx/bitloading \
- lib \
- mac/common cp/msg/stub \
- mac/sar/stub cp/sta/mgr cp/fsm/stub cp/cco/action/stub \
- cp/sta/core/stub cl/stub bsu/stub
+ ce/rx/bitloading/fsm \
+ ce/rx/bitloading \
+ lib \
+ mac/common cp/msg/stub \
+ mac/sar/stub cp/av/sta/mgr cp/av/fsm/stub cp/av/cco/action/stub \
+ cp/sta/core/stub cl/stub bsu/stub
# Override sources for BL (we only want our stubbed handle event for the FSM).
ce_rx_bitloading_fsm_MODULE_SOURCES =
@@ -25,6 +25,7 @@ TARGET_PROGRAMS = test_rx
# Test CE RX.
test_rx_SOURCES = test_rx.c pbproc_stub.c
test_rx_MODULES = $(common_MODULES)
+test_rx_CONFIG_MODULES = cp
# Include main Makefile.
include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/tx/test/Config b/cesar/ce/tx/test/Config
new file mode 100644
index 0000000000..285d42d151
--- /dev/null
+++ b/cesar/ce/tx/test/Config
@@ -0,0 +1,2 @@
+CONFIG_CP_AV = n
+CONFIG_CP_EOC = n
diff --git a/cesar/ce/tx/test/Makefile b/cesar/ce/tx/test/Makefile
index a8a655d3af..8e1d4d671a 100644
--- a/cesar/ce/tx/test/Makefile
+++ b/cesar/ce/tx/test/Makefile
@@ -5,21 +5,24 @@ BASE = ../../..
INCLUDES = ce/tx/test/override cp/sta/core/stub
# Common modules.
-common_MODULES = lib mac/common ce/tx cp/sta/mgr \
- cp/fsm/stub cl/stub cp/sta/core/stub mac/sar/stub \
- cp/cco/action/stub ce/common cp/msg/stub bsu/stub
+common_MODULES = lib mac/common ce/tx \
+ cl/stub cp/sta/core/stub mac/sar/stub \
+ ce/common cp/msg/stub bsu/stub cp/av/fsm/stub
# For host program.
HOST_PROGRAMS = test_expiration test_mme test_tm
-test_expiration_SOURCES = test_expiration.c mme.c
+test_expiration_SOURCES = test_expiration.c mme.c cp_sta_mgr_stub.c
test_expiration_MODULES = $(common_MODULES)
+test_expiration_CONFIG_MODULES = cp
-test_mme_SOURCES = test_mme.c mme.c
+test_mme_SOURCES = test_mme.c mme.c cp_sta_mgr_stub.c
test_mme_MODULES = $(common_MODULES)
+test_mme_CONFIG_MODULES = cp
-test_tm_SOURCES = test_tm.c
+test_tm_SOURCES = test_tm.c cp_sta_mgr_stub.c
test_tm_MODULES = $(common_MODULES)
+test_tm_CONFIG_MODULES = cp
# Include main Makefile.
include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/tx/test/src/cp_sta_mgr_stub.c b/cesar/ce/tx/test/src/cp_sta_mgr_stub.c
new file mode 100644
index 0000000000..522be6971c
--- /dev/null
+++ b/cesar/ce/tx/test/src/cp_sta_mgr_stub.c
@@ -0,0 +1,59 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/tx/test/src/cp_sta_mgr_stub.c
+ * \brief Test MME used by the CE TX.
+ * \ingroup ce_tx_test
+ *
+ */
+#include "common/std.h"
+
+#include "cp/inc/context.h"
+#include "mac/common/defs.h"
+
+static cp_sta_t test_sta;
+static cp_tei_t tei_tested = 0;
+
+cp_sta_t *
+cp_sta_mgr_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address)
+{
+ tei_tested = tei;
+ mac_store_sta_add (ctx->mac_store, tei);
+ return NULL;
+}
+
+
+cp_tei_t
+cp_sta_own_data_get_tei (cp_t *ctx)
+{
+ return MAC_TEI_STA_MIN;
+}
+
+cp_net_t *
+cp_sta_mgr_get_our_avln (cp_t *ctx)
+{
+ return (cp_net_t *)0xDEADBEAF;
+}
+
+cp_sta_t *
+cp_net_sta_get_first (cp_t *ctx, cp_net_t *net, cp_net_sta_status_t assoc)
+{
+ return &test_sta;
+}
+
+cp_tei_t
+cp_sta_get_tei (cp_sta_t *ctx)
+{
+ return tei_tested;
+}
+
+cp_sta_t *
+cp_net_sta_get_next (cp_t *ctx, cp_net_t *net, cp_sta_t *prev_sta)
+{
+ return NULL;
+}
diff --git a/cesar/ce/tx/test/src/test_expiration.c b/cesar/ce/tx/test/src/test_expiration.c
index a96340972c..9585b9b154 100644
--- a/cesar/ce/tx/test/src/test_expiration.c
+++ b/cesar/ce/tx/test/src/test_expiration.c
@@ -28,7 +28,6 @@ expiration_test_suite (test_t t)
/* Initialise CP. */
cp_t cp;
memset (&cp, 0, sizeof (cp));
- cp_sta_mgr_init (&cp);
cl_t cl;
memset (&cl, 0, sizeof (cl));
sar_t sar;
@@ -43,16 +42,8 @@ expiration_test_suite (test_t t)
cp.sar = &sar;
/* Create our net/AVLN. */
- const cp_tei_t my_tei = 42;
- cp_net_t *my_net = cp_sta_mgr_add_avln (&cp, 0xAB, my_tei);
- cp_sta_own_data_set_snid (&cp, 0xAB);
- cp_sta_own_data_set_tei (&cp, my_tei);
- cp_sta_mgr_set_our_avln (&cp, my_net);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
const cp_tei_t peer_tei = 10;
- cp_sta_t *sta_tmp = cp_sta_mgr_sta_add (&cp, my_net, peer_tei, 0xCBA987654321ull);
- if (sta_tmp)
- slab_release (sta_tmp);
+ cp_sta_mgr_sta_add (&cp, NULL, peer_tei, 0xCBA987654321ull);
sta_t *sta = mac_store_sta_get (cp.mac_store, peer_tei);
/* Initialize CE TX. */
@@ -128,7 +119,6 @@ expiration_test_suite (test_t t)
/* Clean. */
blk_release (sta);
dbg_check (mac_store_sta_remove (cp.mac_store, peer_tei));
- cp_sta_mgr_uninit (&cp);
mac_store_uninit (cp.mac_store);
}
diff --git a/cesar/ce/tx/test/src/test_mme.c b/cesar/ce/tx/test/src/test_mme.c
index 044725c2aa..5de5346158 100644
--- a/cesar/ce/tx/test/src/test_mme.c
+++ b/cesar/ce/tx/test/src/test_mme.c
@@ -173,7 +173,6 @@ mme_test_suite (test_t t, tonemask_info_t *default_tone_mask)
/* Initialise CP. */
cp_t cp;
memset (&cp, 0, sizeof (cp));
- cp_sta_mgr_init (&cp);
cl_t cl;
memset (&cl, 0, sizeof (cl));
sar_t sar;
@@ -192,16 +191,9 @@ mme_test_suite (test_t t, tonemask_info_t *default_tone_mask)
cp.bsu_aclf = &bsu_aclf;
/* Create our net/AVLN. */
- const cp_tei_t my_tei = 42;
- cp_net_t *my_net = cp_sta_mgr_add_avln (&cp, 0xAB, my_tei);
- cp_sta_own_data_set_snid (&cp, 0xAB);
- cp_sta_own_data_set_tei (&cp, my_tei);
- cp_sta_mgr_set_our_avln (&cp, my_net);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
const cp_tei_t peer_tei = 10;
- cp_sta_t *sta_tmp = cp_sta_mgr_sta_add (&cp, my_net, peer_tei, 0xCBA987654321ull);
- if (sta_tmp)
- slab_release (sta_tmp);
+ cp_sta_mgr_sta_add (&cp, NULL, peer_tei, 0xCBA987654321ull);
+ mac_store_sta_add (cp.mac_store, peer_tei);
sta_t *sta = mac_store_sta_get (cp.mac_store, peer_tei);
/* Initialize CE TX. */
@@ -701,7 +693,6 @@ mme_test_suite (test_t t, tonemask_info_t *default_tone_mask)
dbg_check (mac_store_sta_remove (cp.mac_store, peer_tei));
while (!tonemap_release_list_clean (&cp.ce_tx.tonemap_release_list))
;
- cp_sta_mgr_uninit (&cp);
mac_store_uninit (cp.mac_store);
}
diff --git a/cesar/cp/Module b/cesar/cp/Module
index 2e716ded54..2e18c2d9ff 100644
--- a/cesar/cp/Module
+++ b/cesar/cp/Module
@@ -1,7 +1,7 @@
SOURCES := cp.c
+
ifeq ($(CONFIG_TRACE),y)
SOURCES += trace.c
endif
-MODULES := cp/beacon cp/cco/action cp/cco/bw cp/cco/region cp/cl_interf \
- cp/fsm cp/msg cp/secu cp/sta/action cp/sta/core \
- cp/sta/mgr
+
+MODULES := cp/cl_interf cp/secu cp/sta/core
diff --git a/cesar/cp/av/Config b/cesar/cp/av/Config
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cesar/cp/av/Config
diff --git a/cesar/cp/av/Module b/cesar/cp/av/Module
index 560867b12e..be533b7b3e 100644
--- a/cesar/cp/av/Module
+++ b/cesar/cp/av/Module
@@ -1 +1,7 @@
-MODULES=cp/av/cco/bw cp/av/cco/region
+MODULES := cp
+
+MODULES += cp/msg
+MODULES += cp/av/beacon
+MODULES += cp/av/cco/bw cp/av/cco/region cp/av/cco/action
+MODULES += cp/av/sta/action cp/av/sta/mgr
+MODULES += cp/av/fsm
diff --git a/cesar/cp/av/beacon/Module b/cesar/cp/av/beacon/Module
new file mode 100644
index 0000000000..91568a7cdc
--- /dev/null
+++ b/cesar/cp/av/beacon/Module
@@ -0,0 +1,3 @@
+SOURCES:= beacon.c discover.c
+
+MODULES += cp/beacon
diff --git a/cesar/cp/av/beacon/beacon.h b/cesar/cp/av/beacon/beacon.h
new file mode 100644
index 0000000000..65a5a86883
--- /dev/null
+++ b/cesar/cp/av/beacon/beacon.h
@@ -0,0 +1,48 @@
+#ifndef _cesar_cp_av_beacon_beacon_h
+#define _cesar_cp_av_beacon_beacon_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cesar/cp/av/beacon/beacon.h
+ * \brief Special AV beacon functions.
+ * \ingroup cp_av_beacon
+ */
+#include "cp/beacon/beacon.h"
+
+BEGIN_DECLS
+
+/** Set the Handover in progress flag in the central beacon.
+ * \param ctx the module context.
+ * \param flag the handover flag value.
+ */
+void
+cp_av_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag);
+
+/**
+ * Generate beacon data when station acts as STA.
+ * \param ctx the module context.
+ */
+void
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx);
+
+/**
+ * Handover.
+ * \param ctx the CP context.
+ * \param tei the TEI of the new CCo on the AVLN.
+ *
+ * This function will set the handover in progress flag in the central beacon
+ * and all beacon produce by this module.
+ * It shall set the hccd bentry countdown to a finite value (in a define) to
+ * change indicate to all the station in the AVLN, the CCo will change.
+ */
+void
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t tei);
+
+END_DECLS
+
+#endif /* _cesar_cp_av_beacon_beacon_h */
diff --git a/cesar/cp/av/beacon/discover.h b/cesar/cp/av/beacon/discover.h
new file mode 100644
index 0000000000..57a5ac81aa
--- /dev/null
+++ b/cesar/cp/av/beacon/discover.h
@@ -0,0 +1,45 @@
+#ifndef cp_av_beacon_discover_h
+#define cp_av_beacon_discover_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/beacon/discover.h
+ * \brief AV Discover procedure functions for the beacon.
+ * \ingroup cp_av_beacon
+ *
+ */
+
+BEGIN_DECLS
+
+/** Initialise
+ * \param ctx the module context.
+ */
+void
+cp_av_beacon_discover_init (cp_t *ctx);
+
+/**
+ * Uninitialise the discover procedure.
+ * \param ctx the module context.
+ */
+void
+cp_av_beacon_discover_uninit (cp_t *ctx);
+
+/**
+ * Verify if any request shall be done.
+ * \param ctx the module context.
+ * \param tei The TEI to request. 0 = The CCo shall send a discover beacon.
+ * \return true if a discover bentry shall be added to the beacon, false
+ * otherwise.
+ *
+ */
+bool
+cp_av_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei);
+
+END_DECLS
+
+#endif /* cp_av_beacon_discover_h */
diff --git a/cesar/cp/av/beacon/src/beacon.c b/cesar/cp/av/beacon/src/beacon.c
new file mode 100644
index 0000000000..9049f56cc4
--- /dev/null
+++ b/cesar/cp/av/beacon/src/beacon.c
@@ -0,0 +1,84 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/beacon/src/beacon.c
+ * \brief AV Dedicated functions.
+ * \ingroup cp_av_beacon
+ *
+ * Behavior of the CP beacon for the AV project.
+ */
+#include "common/std.h"
+/* Public headers. */
+#include "cp/beacon/beacon.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/fsm/fsm.h"
+#include "cp/av/beacon/discover.h"
+#include "bsu/bsu.h"
+/* CP Private headers. */
+#include "cp/sta/mgr/inc/net.h"
+#include "cp/inc/context.h"
+#include "cp/inc/trace.h"
+
+void
+cp_av_beacon_change_hm (cp_t *ctx, uint hybrid_mode)
+{
+ dbg_assert (ctx);
+ dbg_assert (cp_sta_own_data_get_cco_status (ctx));
+
+ if (!ctx->beacon.hm.hmcd)
+ {
+ ctx->beacon.hm.hm = hybrid_mode;
+ ctx->beacon.hm.hmcd = CP_BEACON_COUNTDOWN_HM;
+ }
+}
+
+void
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t cco)
+{
+ dbg_assert (ctx);
+
+ if (!ctx->beacon.hoip.hoipcd)
+ {
+ ctx->beacon.hoip.cco = cco;
+ ctx->beacon.hoip.hoipcd = CP_BEACON_COUNTDOWN_HOIP;
+ }
+}
+
+void
+cp_av_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag)
+{
+ dbg_assert (ctx);
+ dbg_assert (flag < CP_BEACON_HOIP_MAX);
+
+ ctx->beacon.hoip.hoip_flag = flag;
+}
+
+void
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ bsu_beacon_bmi_discover_info_t discover;
+ cp_beacon_fill_discover_info (ctx, &discover);
+ bsu_update_discover_info (ctx->bsu, &discover);
+}
+
+void
+cp_av_beacon_fill_discovery_bentries (cp_t *ctx, bsu_beacon_t *beacon)
+{
+ cp_tei_t tei;
+ if (cp_sta_own_data_get_cco_status (ctx)
+ && cp_av_beacon_discover_need_to_request (ctx, &tei))
+ {
+ beacon->bmis.discover.present = true;
+ beacon->bmis.discover.tei = tei;
+ }
+ else
+ beacon->bmis.discover.present = false;
+
+ cp_beacon_fill_discover_info (ctx, &beacon->bmis.discover_info);
+}
diff --git a/cesar/cp/beacon/src/beacon_discover.c b/cesar/cp/av/beacon/src/discover.c
index cab6264007..b964f4d895 100644
--- a/cesar/cp/beacon/src/beacon_discover.c
+++ b/cesar/cp/av/beacon/src/discover.c
@@ -6,9 +6,9 @@
*
* }}} */
/**
- * \file cp/beacon/src/beacon_discover.c
+ * \file cp/av/beacon/src/discover.c
* \brief Beacon discover process.
- * \ingroup cp_beacon
+ * \ingroup cp_av_beacon
*
* Function to compute the interval between the one no request shall be done.
* In this max discover period, all the station including the CCo shall send a
@@ -25,7 +25,7 @@
#include "cp/fsm/fsm.h"
#include "cp/beacon/inc/beacon.h"
-#include "cp/beacon/discover.h"
+#include "cp/av/beacon/discover.h"
#include "cp/inc/context.h"
/**
@@ -43,7 +43,7 @@
* module.
*/
void
-cp_beacon_discover_compute_interval (cp_t *ctx)
+cp_av_beacon_discover_compute_interval (cp_t *ctx)
{
dbg_assert (ctx);
cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
@@ -54,19 +54,16 @@ cp_beacon_discover_compute_interval (cp_t *ctx)
(bp * (cp_net_get_num_stas (ctx, our_net) + 1));
}
-/** Initialise
- * \param ctx the module context.
- */
void
-cp_beacon_discover_init (cp_t *ctx)
+cp_av_beacon_discover_init (cp_t *ctx)
{
dbg_assert (ctx);
memset (&ctx->beacon.discover, 0, sizeof (cp_beacon_discover_t));
- cp_beacon_discover_compute_interval (ctx);
+ cp_av_beacon_discover_compute_interval (ctx);
}
void
-cp_beacon_discover_uninit (cp_t *ctx)
+cp_av_beacon_discover_uninit (cp_t *ctx)
{
dbg_assert (ctx);
}
@@ -82,8 +79,8 @@ cp_beacon_discover_uninit (cp_t *ctx)
* range (discover.tei_last, MAC_TEI_STA_MAX).
*/
static inline bool
-cp_beacon_discover_need_to_request__find_next_sta (cp_t *ctx, cp_net_t *net,
- cp_tei_t * tei)
+cp_av_beacon_discover_need_to_request__find_next_sta (
+ cp_t *ctx, cp_net_t *net, cp_tei_t * tei)
{
cp_beacon_discover_t *discover = &ctx->beacon.discover;
bool sta_found = false;
@@ -115,7 +112,7 @@ cp_beacon_discover_need_to_request__find_next_sta (cp_t *ctx, cp_net_t *net,
*
*/
bool
-cp_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei)
+cp_av_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei)
{
cp_beacon_discover_t *discover;
dbg_assert (ctx);
@@ -134,7 +131,7 @@ cp_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei)
cp_sta_t *sta;
/* Compute the interval to request the discover beacon from the
* stations of our AVLN. */
- cp_beacon_discover_compute_interval (ctx);
+ cp_av_beacon_discover_compute_interval (ctx);
discover->countdown_bp = discover->discover_interval_bp;
cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
if (discover->tei_last == own_tei)
@@ -163,11 +160,11 @@ cp_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei)
}
else
sta_found =
- cp_beacon_discover_need_to_request__find_next_sta (
+ cp_av_beacon_discover_need_to_request__find_next_sta (
ctx, net, tei);
}
else
- sta_found = cp_beacon_discover_need_to_request__find_next_sta (
+ sta_found = cp_av_beacon_discover_need_to_request__find_next_sta (
ctx, net, tei);
/* Last station of the AVLN has been requested and no more stations
* are available i.e. there is no station in the AVLN with a greater
diff --git a/cesar/cp/av/beacon/stub/Module b/cesar/cp/av/beacon/stub/Module
new file mode 100644
index 0000000000..677337e1ab
--- /dev/null
+++ b/cesar/cp/av/beacon/stub/Module
@@ -0,0 +1,3 @@
+SOURCES:=beacon.c
+
+MODULES := cp/beacon/stub
diff --git a/cesar/cp/av/beacon/stub/src/beacon.c b/cesar/cp/av/beacon/stub/src/beacon.c
new file mode 100644
index 0000000000..0a808b7f74
--- /dev/null
+++ b/cesar/cp/av/beacon/stub/src/beacon.c
@@ -0,0 +1,50 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/beacon.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp/cp.h"
+#include "cp/av/beacon/beacon.h"
+#include "bsu/beacon/beacon.h"
+
+void
+cp_av_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag)
+ __attribute__ ((weak));
+
+void
+cp_av_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag)
+{}
+
+void
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx) __attribute__((weak));
+
+void
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx) {}
+
+void
+cp_av_beacon_discover_init (cp_t *ctx) __attribute__ ((weak));
+
+void
+cp_av_beacon_discover_init (cp_t *ctx) {};
+
+void
+cp_av_beacon_discover_uninit (cp_t *ctx) __attribute__ ((weak));
+
+void
+cp_av_beacon_discover_uninit (cp_t *ctx) {};
+
+void
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t tei) __attribute__ ((weak));
+
+void
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t tei) {}
diff --git a/cesar/cp/av/beacon/test/utest/Config b/cesar/cp/av/beacon/test/utest/Config
new file mode 100644
index 0000000000..9a1a22bd7c
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/Config
@@ -0,0 +1,3 @@
+CONFIG_CP_AV = y
+CONFIG_CP_EOC = n
+CONFIG_RESTRACK = y
diff --git a/cesar/cp/av/beacon/test/utest/Makefile b/cesar/cp/av/beacon/test/utest/Makefile
new file mode 100644
index 0000000000..95f9b2f738
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/Makefile
@@ -0,0 +1,36 @@
+BASE = ../../../../..
+INCLUDES = cp/av/beacon/test/utest/override
+ECOS = y
+
+TARGET_PROGRAMS = test_beacon test_discover_process beacon
+test_beacon_SOURCES = test_beacon.c stubs.c
+test_beacon_MODULES = bsu/beacon lib cp/av/beacon cp/av/sta/mgr mac/common \
+ cp/av/cco/bw cp/av/cco/region \
+ cp/av/fsm/stub cp/av/cco/action/stub hal/timer/stub \
+ cp/sta/core/stub mac/sar/stub cl/stub \
+ interface/stub bsu/stub cp/msg/stub mac/ca/stub \
+ hal/phy/spoc/stub
+test_beacon_CONFIG_MODULES = cp
+
+test_discover_process_SOURCES = discover.c stubs.c
+test_discover_process_MODULES = lib cp/av/beacon mac/common cp/av/sta/mgr \
+ bsu/beacon cp/av/cco/region \
+ cp/av/fsm/stub cp/av/cco/action/stub \
+ hal/timer/stub cp/sta/core/stub mac/sar/stub \
+ cl/stub cp/av/cco/bw interface/stub bsu/stub \
+ cp/msg/stub
+test_discover_process_CONFIG_MODULES = cp
+
+beacon_SOURCES = beacon.c stubs.c
+beacon_MODULES = bsu/beacon lib cp/av/beacon cp/av/sta/mgr mac/common \
+ cp/av/cco/region cp/av/cco/bw \
+ cp/av/fsm/stub cp/av/cco/action/stub hal/timer/stub \
+ cp/sta/core/stub mac/sar/stub cl/stub \
+ interface/stub bsu/stub cp/msg/stub hal/phy/spoc/stub \
+ mac/ca/stub
+beacon_CONFIG_MODULES = cp
+
+mac_common_MODULE_SOURCES = config.c mfs.c store.c tonemap.c tonemask.c \
+ sta.c interval.c
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/ecos.ecc.sh b/cesar/cp/av/beacon/test/utest/ecos.ecc.sh
index 8253d98c9a..8253d98c9a 100644
--- a/cesar/cp/beacon/test/ecos.ecc.sh
+++ b/cesar/cp/av/beacon/test/utest/ecos.ecc.sh
diff --git a/cesar/cp/beacon/test/override/cl/inc/context.h b/cesar/cp/av/beacon/test/utest/override/cl/inc/context.h
index 80b83f47a9..80b83f47a9 100644
--- a/cesar/cp/beacon/test/override/cl/inc/context.h
+++ b/cesar/cp/av/beacon/test/utest/override/cl/inc/context.h
diff --git a/cesar/cp/beacon/test/override/cp/inc/context.h b/cesar/cp/av/beacon/test/utest/override/cp/inc/context.h
index c6055bf6f7..c6055bf6f7 100644
--- a/cesar/cp/beacon/test/override/cp/inc/context.h
+++ b/cesar/cp/av/beacon/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/beacon/test/override/mac/sar/inc/context.h b/cesar/cp/av/beacon/test/utest/override/mac/sar/inc/context.h
index 9e7c6f07ca..9e7c6f07ca 100644
--- a/cesar/cp/beacon/test/override/mac/sar/inc/context.h
+++ b/cesar/cp/av/beacon/test/utest/override/mac/sar/inc/context.h
diff --git a/cesar/cp/av/beacon/test/utest/src/beacon.c b/cesar/cp/av/beacon/test/utest/src/beacon.c
new file mode 100644
index 0000000000..0c327f8341
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/src/beacon.c
@@ -0,0 +1,960 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/beacon.c
+ * \brief Unit test for the beacon module.
+ * \ingroup cp_beacon
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "lib/slist.h"
+#include "lib/test.h"
+#include "lib/circular_buffer.h"
+
+#include "mac/common/ntb.h"
+#include "mac/common/store.h"
+
+#include "cp/beacon/beacon.h"
+#include "cp/av/beacon/beacon.h"
+#include "cp/av/beacon/discover.h"
+
+#include "cp/cp.h"
+#include "cp/inc/context.h"
+
+#include "cl/inc/context.h"
+#include "mac/sar/inc/context.h"
+
+/* Headers to test the beacon generation. */
+#include "cp/av/cco/region/region.h"
+#include "cp/av/cco/bw/bw.h"
+
+void
+cp_beacon_receive (cp_t *ctx, bsu_beacon_t *beacon);
+
+void
+cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon_data);
+
+struct test_beacon_t
+{
+ cp_t cp;
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
+ bsu_aclf_t aclf;
+ uint ca;
+ bool bsu_updated;
+};
+typedef struct test_beacon_t test_beacon_t;
+
+void
+test_beacon_init (test_beacon_t *ctx)
+{
+ memset (ctx, 0, sizeof (test_beacon_t));
+ lib_stats_init ();
+ lib_rnd_init (&ctx->cp.rnd, 0x1234);
+ ctx->cp.mac_config = &ctx->mac_config;
+ ctx->cp.sar = &ctx->sar;
+ ctx->cp.cl = &ctx->cl;
+ ctx->cp.bsu_aclf = &ctx->aclf;
+ ctx->cp.bsu = (bsu_t *) &ctx->bsu_updated;
+ *((bsu_aclf_frequency_t*) &ctx->aclf.frequency) = BSU_ACLF_FREQ_50HZ;
+ *((bsu_aclf_bp_t*) &ctx->aclf.beacon_period_theo_tck) =
+ BSU_ACLF_BP_50HZ_TCK;
+ ctx->aclf.beacon_period_tck = ctx->aclf.beacon_period_theo_tck;
+ ctx->cp.mac_store = mac_store_init();
+ ctx->cp.ca = (ca_t*) &ctx->ca;
+ cp_sta_mgr_init (&ctx->cp);
+ cp_cco_bw_init (&ctx->cp);
+ cp_cco_region_init (&ctx->cp);
+ cp_beacon_init (&ctx->cp);
+ ctx->cp.beacon.last_countdown_call_date_active = true;
+}
+
+void
+test_beacon_uninit (test_beacon_t *ctx)
+{
+ cp_beacon_uninit (&ctx->cp);
+ cp_cco_bw_uninit (&ctx->cp);
+ cp_cco_region_uninit (&ctx->cp);
+ cp_sta_mgr_uninit (&ctx->cp);
+ mac_store_uninit (ctx->cp.mac_store);
+ lib_stats_uninit ();
+}
+
+bsu_beacon_t*
+test_new_beacon (void)
+{
+ /** Create a central beacon. */
+ bsu_beacon_t *beacon = blk_alloc ();
+ beacon->vf.nid = 1;
+ beacon->vf.stei = 1;
+ beacon->vf.bt = BSU_BEACON_TYPE_CENTRAL;
+ beacon->vf.hm = MAC_COEXISTENCE_FULL_HYBRID_MODE;
+ beacon->vf.ncnr = false;
+ beacon->vf.npsm = false;
+ beacon->vf.numslots = 0;
+ beacon->vf.slotusage = 0;
+ beacon->vf.slotid = 0;
+ beacon->vf.aclsss = true;
+ beacon->vf.hoip = false;
+ beacon->vf.rtsbf = false;
+ beacon->vf.nm = MAC_NM_CSMA_ONLY;
+ beacon->vf.ccocap = 0;
+ beacon->bmis.change_snid.present = true;
+ beacon->bmis.change_snid.snidccd = 3;
+ beacon->bmis.change_snid.new_snid = 0xC;
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.region.nb = 1;
+ beacon->bmis.region.region[0].end_time_atu = 3907;
+ beacon->bmis.region.region[0].rt = CP_CCO_REGION_TYPE_BEACON;
+ beacon->bmis.nps.ns = 1;
+ beacon->bmis.nps.sais[0].end_time_atu = 3907;
+ beacon->bmis.nps.sais[0].glid = 0x45;
+ beacon->bmis.nps.sais[0].stpf = false;
+ beacon->bmis.nbe = 4;
+ beacon->params.rx_parameters.snid = 0;
+ beacon->params.rx_parameters.access = HPAV_ACCESS_IN_HOME;
+ beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
+ beacon->params.frequency_error_valid = false;
+ return beacon;
+}
+
+/** Uninitialise
+ * \param test the test object.
+ *
+ * The uninit procedure, shall stop the timers and release all the object
+ * referenced by the beacon module.
+ *
+ * * Stop the HAL timer
+ * * Stop the eCos timer
+ * * Release all beacon received and not processed yet.
+ * * Call the uninit function for the common sub context.
+ *
+ * Environment
+ * This test shall insert some data in the pointers and the context.
+ *
+ * 1. Add at least two beacon in the received list.
+ * 2. Add a central beacon in the central sub context.
+ * 3. Add a discover beacon in the discover sub context.
+ * 4. Add a proxy beacon in the discover sub context.
+ *
+ * Result
+ * At the end the beacon module shall not have any referenced on any object.
+ */
+void
+test_case_beacon_uninit (test_t test)
+{
+ test_case_begin (test, "Beacon uninit");
+ test_begin (test, "remove beacons received")
+ {
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ bsu_beacon_t *b;
+ uint i;
+ for (i = 0; i < 2; i++)
+ {
+ b = blk_alloc ();
+ b->next = NULL;
+ b->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
+ cp_beacon_receive (&ctx.cp, b);
+ }
+ test_beacon_uninit (&ctx);
+ test_fail_unless (slist_empty (ctx.cp.beacon.list., bare));
+ }
+ test_end;
+}
+
+void
+test_case_beacon__deactivate (test_t test)
+{
+ test_case_begin (test, "Deactivate");
+ test_begin (test, "Deactivate beacon module")
+ {
+ test_beacon_t ctx;
+ uint nb_beacons = 2;
+ test_beacon_init (&ctx);
+ /* Still configuring the test... */
+ ctx.cp.beacon.leon_timer.status = true;
+ /* Allocate some beacons. */
+ uint i;
+ for (i = 0; i < nb_beacons; i++)
+ {
+ bsu_beacon_t *beacon = blk_alloc ();
+ beacon->next = NULL;
+ slist_push_back (ctx.cp.beacon.list., beacon, bare);
+ }
+ /* test. */
+ cp_beacon_deactivate (&ctx.cp);
+ test_fail_unless (slist_empty (ctx.cp.beacon.list., bare));
+ test_beacon_uninit (&ctx);
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
+ }
+ test_end;
+}
+
+void
+test_suite_beacon__beacon_generation (test_t test)
+{
+ test_beacon_t ctx;
+ bsu_beacon_t beacon;
+ test_suite_begin (test, "Beacon generation");
+ test_case_begin (test, "Central beacon for AV");
+ test_begin (test, "AV")
+ {
+ memset (&beacon, 0, sizeof (bsu_beacon_t));
+ test_beacon_init (&ctx);
+ /* Configure some parts. */
+ cp_net_t *net = cp_sta_mgr_add_avln (&ctx.cp, 1, 1);
+ /* Station own data first. */
+ cp_sta_mgr_set_our_avln (&ctx.cp , net);
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_sta_own_data_set_authenticated_status (&ctx.cp, true);
+ cp_sta_own_data_set_cco_status (&ctx.cp, true);
+ /* Region manager in second place. */
+ cp_av_cco_region_default (&ctx.cp);
+ /* Bandwidth manager. */
+ cp_av_cco_bw_schedules_default (&ctx.cp);
+ /* Configuration ended. */
+ cp_beacon_fill (&ctx.cp, &beacon);
+ /* Test the beacon. */
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ test_fail_unless (beacon.vf.nid
+ == cp_sta_own_data_get_nid (&ctx.cp));
+ test_fail_unless (beacon.vf.hm == own->hybrid_mode);
+ test_fail_unless (beacon.vf.stei ==
+ cp_sta_own_data_get_tei (&ctx.cp));
+ /* Beacon type is stored by the BSU when it prepare the beacon to be
+ * sent. */
+ test_fail_unless (beacon.vf.ncnr == 0);
+ test_fail_unless (beacon.vf.npsm == 0);
+ test_fail_unless (beacon.vf.numslots == 0);
+ test_fail_unless (beacon.vf.slotusage == 0);
+ test_fail_unless (beacon.vf.slotid == 0);
+ test_fail_unless (beacon.vf.aclsss == 0);
+ test_fail_unless (beacon.vf.hoip == 0);
+ test_fail_unless (beacon.vf.rtsbf == 0);
+ test_fail_unless (beacon.vf.nm == MAC_NM_CSMA_ONLY);
+ test_fail_unless (beacon.vf.ccocap == CP_CCO_LEVEL);
+ /* Variant fields. */
+ test_fail_unless (beacon.bmis.region.nb == 2);
+ test_fail_unless (beacon.bmis.region.region[0].rt =
+ BSU_BEACON_REGION_BEACON);
+ test_fail_unless (beacon.bmis.region.region[1].rt =
+ BSU_BEACON_REGION_SHARED_CSMA);
+ /* Persistent schedule. */
+ test_fail_unless (beacon.bmis.ps.nb == 1);
+ test_fail_unless (
+ BSU_BEACON_PERSISTENT_ALLOC_IS_PERMANENT(beacon.bmis.ps.ps[0]));
+ test_fail_unless (!beacon.bmis.ps.ps[0].sais[0].stpf);
+ test_fail_unless (beacon.bmis.ps.ps[0].sais[0].glid ==
+ (MAC_LID_SHARED_CSMA & 0x7f));
+ test_fail_unless (beacon.bmis.ps.ps[0].sais[0].end_time_atu >= 3907);
+ /* Non persistent schedules. */
+ test_fail_unless (beacon.bmis.nps.ns == 0);
+ test_fail_unless (beacon.bmis.discover.present);
+ test_fail_unless (beacon.bmis.bpsto.present);
+ test_fail_unless (beacon.bmis.discover_info.present);
+ test_fail_unless (!beacon.bmis.eks.present);
+ test_fail_unless (!beacon.bmis.handover.present);
+ test_fail_unless (!beacon.bmis.relocation.present);
+ test_fail_unless (!beacon.bmis.aclsc.present);
+ test_fail_unless (!beacon.bmis.cns.present);
+ test_fail_unless (!beacon.bmis.change_hm.present);
+ test_fail_unless (!beacon.bmis.change_snid.present);
+ test_fail_unless (beacon.bmis.mac_address.present);
+ test_fail_unless (beacon.bmis.mac_address.mac_address ==
+ cp_sta_own_data_get_mac_address (&ctx.cp));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_case_beacon_snid_change_cco (test_t test)
+{
+ uint snid;
+ cp_net_t *net;
+ test_beacon_t ctx;
+
+ test_case_begin (test, "CCo");
+ test_beacon_init (&ctx);
+
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0xA, 1);
+ cp_sta_own_data_set_snid (&ctx.cp, 0xA);
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ cp_sta_own_data_set_cco_status (&ctx.cp, true);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x123456789ABCull);
+
+
+ test_begin (test, "Change SNID")
+ {
+ /* Process the test. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+
+ snid = 1;
+ cp_beacon_change_snid (&ctx.cp, snid);
+
+ test_fail_unless (ctx.cp.beacon.snids.snid == snid);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == CP_BEACON_COUNTDOWN_SNID);
+ }
+ test_end;
+
+ test_begin (test, "Change SNID, check bentry in Central beacon")
+ {
+ cp_cco_region_alloc_t *region;
+ cp_cco_bw_alloc_t *alloc;
+ set_t set_schedules;
+ set_t set_regions;
+ bsu_beacon_t beacon;
+
+ set_init (&set_schedules, cp_cco_bw_alloc_less);
+ set_init (&set_regions, cp_cco_region_alloc_less);
+ cp_cco_region_init (&ctx.cp);
+ cp_cco_bw_init (&ctx.cp);
+
+ /* Regions. */
+ region = cp_cco_region_alloc_init (&ctx.cp);
+ region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
+ region->end_time_atu = 3907;
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
+ slab_release (region);
+
+ /* Schedules. */
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
+ alloc->pscd = 7;
+ alloc->cscd = 7;
+ alloc->stpf = false;
+ alloc->glid = 0x45;
+ alloc->end_time_atu = 3907;
+ alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT;
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
+ slab_release (alloc);
+
+ cp_beacon_fill (&ctx.cp, &beacon);
+
+ test_fail_unless (beacon.bmis.change_snid.present == true);
+ test_fail_unless (beacon.bmis.change_snid.snidccd == ctx.cp.beacon.snids.snidcd);
+ test_fail_unless (beacon.bmis.change_snid.new_snid == ctx.cp.beacon.snids.snid);
+
+ cp_cco_bw_alloc_clean (&ctx.cp, &set_schedules);
+ cp_cco_region_alloc_clean (&ctx.cp, &set_regions);
+
+ cp_beacon_sta_compute_schedules (&ctx.cp, &beacon);
+ alloc = cp_cco_bw_alloc_get_first (&ctx.cp, &ctx.cp.bw.alloc_list);
+ test_fail_unless (alloc->persistence ==
+ CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT);
+ alloc = cp_cco_bw_alloc_get_next (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
+ test_fail_unless (!alloc);
+ cp_cco_region_alloc_clean (&ctx.cp, &set_regions);
+ cp_cco_bw_alloc_clean (&ctx.cp, &set_schedules);
+ cp_cco_bw_uninit (&ctx.cp);
+ cp_cco_region_uninit (&ctx.cp);
+ }
+ test_end;
+
+ /* Uninit all the data. */
+ test_beacon_uninit (&ctx);
+}
+
+
+void
+test_case_beacon_snid_change_sta (test_t test)
+{
+ test_case_begin (test, "Station");
+ u32 last_countdown_call_date = phy_date () - BSU_ACLF_BP_60HZ_TCK - 100;
+ test_begin (test, "Beacon reception")
+ {
+ bsu_beacon_t *beacon;
+ cp_net_t *net;
+ cp_sta_own_data_t *own;
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ /** Init the context. */
+ ctx.cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
+ ctx.cp.beacon.last_countdown_call_date_active = true;
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ /* Configure station own data. */
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ own->nid_track = 1;
+ own->tei_track = 1;
+ /** Check snid default values. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
+ /** Create a central beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_snid.present = true;
+ beacon->bmis.change_snid.new_snid = 0xC;
+ beacon->bmis.change_snid.snidccd = 3;
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check snid values are taken. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 3);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
+ /** Create the next beacon (countdown decreased). */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_snid.snidccd = 2;
+ /** launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check countdown. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 2);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
+ /** Create the next beacon (countdown decreased). */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_snid.snidccd = 1;
+ /** launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check countdown. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 1);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0x0);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0x0);
+ /* Create the beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_snid.present = false;
+ beacon->bmis.nbe--;
+ beacon->params.rx_parameters.snid = 0xC;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check new snid is 0xC. */
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xC);
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0xC);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0xC);
+
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+
+ test_begin (test, "Beacon missed")
+ {
+ test_beacon_t ctx;
+ cp_net_t *net;
+ cp_cco_region_alloc_t *region;
+ cp_cco_bw_alloc_t *alloc;
+ test_beacon_init (&ctx);
+ /* Regions. */
+ region = cp_cco_region_alloc_init (&ctx.cp);
+ region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
+ region->end_time_atu = 3907;
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
+ slab_release (region);
+
+ /* Schedules. */
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
+ alloc->stpf = false;
+ alloc->glid = 0x45;
+ alloc->end_time_atu = 3907;
+ alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
+ slab_release (alloc);
+
+ /* Configure station own data. */
+ net = cp_sta_mgr_add_avln (&ctx.cp, 1, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+
+ /* Configure the test. */
+ ctx.cp.beacon.snids.snidcd = 2;
+ ctx.cp.beacon.snids.snid = 0xc;
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 1);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xc);
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.snids.snidcd == 0);
+ test_fail_unless (ctx.cp.beacon.snids.snid == 0xc);
+ test_fail_unless (cp_net_get_snid (&ctx.cp, net) == 0xC);
+ test_fail_unless (cp_sta_own_data_get_snid (&ctx.cp) == 0xC);
+
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_suite_beacon_snid_change (test_t test)
+{
+ test_suite_begin (test, "Change SNID");
+
+ test_case_beacon_snid_change_cco (test);
+ test_case_beacon_snid_change_sta (test);
+}
+
+void
+test_case_beacon_eks_change_cco (test_t test)
+{
+ cp_key_t nek;
+ cp_net_t *net;
+ test_beacon_t ctx;
+ test_case_begin (test, "CCo");
+
+ /** Configure the context. */
+ test_beacon_init (&ctx);
+
+ /** Configure our station. */
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0xA, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 1);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ cp_sta_own_data_set_cco_status (&ctx.cp, true);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x123456789ABCull);
+
+ test_begin (test, "Change EKS")
+ {
+ uint i;
+ /** Check default values. */
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == 0);
+
+ /** Change nek. */
+ for (i = 0; i < COUNT (nek.key); i++)
+ nek.key[i] = i;
+ cp_beacon_change_nek (&ctx.cp, MAC_EKS_MIN, nek, false /* not now*/);
+
+ /** Check new values. */
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == CP_BEACON_COUNTDOWN_EKS);
+ }
+ test_end;
+
+ /* Uninit all the data. */
+ test_beacon_uninit (&ctx);
+}
+
+void
+test_case_beacon_eks_change_sta (test_t test)
+{
+ test_case_begin (test, "Station");
+ u32 last_countdown_call_date = phy_date () - BSU_ACLF_BP_60HZ_TCK - 100;
+ test_begin (test, "Beacon reception")
+ {
+ bsu_beacon_t *beacon;
+ cp_net_t *net;
+ cp_sta_own_data_t *own;
+ test_beacon_t ctx;
+ /** Init the context. */
+ test_beacon_init (&ctx);
+ /** Configure station own data. */
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ own->nid_track = 1;
+ own->tei_track = 1;
+ /** Create a central beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = 2;
+ beacon->bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ beacon->bmis.eks.new_eks = MAC_EKS_MIN + 1;
+ mac_eks_t ref_eks_current = MAC_EKS_MIN + 2;
+ mac_eks_t ref_eks_next = MAC_EKS_MIN + 3;
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks =
+ ref_eks_current;
+ ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks = ref_eks_next;
+ /** Check default values. */
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN);
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 2);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ref_eks_current);
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ ref_eks_next);
+ /* Create the beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.eks.kccd = 1;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 1);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ref_eks_current);
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ ref_eks_next);
+ /* Create the beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.eks.present = false;
+ beacon->bmis.nbe--;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (
+ ctx.mac_config.nek[bsu_nek_index_current (INVALID_PTR)].eks ==
+ ref_eks_current);
+ test_fail_unless (ctx.mac_config.nek[bsu_nek_index_next (INVALID_PTR)].eks ==
+ MAC_EKS_CLEAR);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+
+ test_begin (test, "Beacon missed")
+ {
+ cp_net_t *net;
+ cp_cco_region_alloc_t *region;
+ cp_cco_bw_alloc_t *alloc;
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ /* Regions. */
+ region = cp_cco_region_alloc_init (&ctx.cp);
+ region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
+ region->end_time_atu = 3907;
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
+ slab_release (region);
+
+ /* Schedules. */
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
+ alloc->stpf = false;
+ alloc->glid = 0x45;
+ alloc->end_time_atu = 3907;
+ alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
+ slab_release (alloc);
+
+ /* Configure station own data. */
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+
+ /* Configure the test. */
+ ctx.cp.beacon.eks.kccd = 2;
+ ctx.cp.beacon.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ ctx.cp.beacon.eks.new_eks = MAC_EKS_MIN + 1;
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 1);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.eks.kccd == 0);
+ test_fail_unless (ctx.cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NB);
+ test_fail_unless (ctx.cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_suite_beacon_eks_change (test_t test)
+{
+ test_suite_begin (test, "Encryption key change");
+
+ test_case_beacon_eks_change_cco (test);
+ test_case_beacon_eks_change_sta (test);
+}
+
+void
+test_suite_beacon_mac_address_bentry (test_t test)
+{
+ test_suite_begin (test, "Central beacon");
+ test_case_begin (test, "Mac address bentry missing");
+ test_begin (test, "Beacon reception")
+ {
+ bsu_beacon_t *beacon;
+ cp_net_t *net;
+ cp_sta_own_data_t *own;
+ test_beacon_t ctx;
+ /** Init the context. */
+ test_beacon_init (&ctx);
+ ctx.cp.beacon.last_countdown_call_date_active = false;
+ /** Configure station own data. */
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own->nid_track = 1;
+ own->tei_track = 1;
+ own->cco_mac_addr_track = MAC_ZERO;
+ /** Create a central beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.mac_address.present = false;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cp_sta_t *cco = cp_net_get_cco (&ctx.cp, net);
+ test_fail_unless (cco);
+ test_fail_unless (cp_sta_get_mac_address (cco) == MAC_BROADCAST);
+ test_fail_unless (cp_sta_get_cco_status (cco) == true);
+ slab_release (cco);
+ /* Mac address in the central beacon is present, but our track on the
+ * mac address is still MAC_ZERO. */
+ beacon = test_new_beacon ();
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.mac_address.mac_address =
+ MAC_ADDRESS (0x01, 0x23, 0x45, 0x67, 0x8a, 0xbc);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
+ test_fail_unless (cco);
+ /* The beacon is not processed. */
+ test_fail_unless (cp_sta_get_mac_address (cco)
+ != beacon->bmis.mac_address.mac_address);
+ test_fail_unless (cp_sta_get_cco_status (cco) == true);
+ slab_release (cco);
+ /* MAC address tracked is different from our CCo. */
+ beacon = test_new_beacon ();
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.mac_address.mac_address =
+ MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
+ test_fail_unless (cco);
+ test_fail_unless (cp_sta_get_mac_address (cco)
+ != beacon->bmis.mac_address.mac_address);
+ test_fail_unless (cp_sta_get_cco_status (cco) == true);
+ slab_release (cco);
+ /* Set the track mac address. */
+ own->cco_mac_addr_track =
+ MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
+ /* This beacon should be processed as our CCo's central beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.mac_address.mac_address =
+ MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
+ test_fail_unless (cco);
+ test_fail_unless (cp_sta_get_mac_address (cco)
+ == beacon->bmis.mac_address.mac_address);
+ test_fail_unless (cp_sta_get_cco_status (cco) == true);
+ slab_release (cco);
+ /* This one should no be processed as our CCo's central beacon. It
+ * comes from another one. */
+ beacon = test_new_beacon ();
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.mac_address.mac_address =
+ MAC_ADDRESS (0x01, 0x23, 0x45, 0x67, 0x8a, 0xbc);
+ cp_beacon_receive (&ctx.cp, beacon);
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ cco = cp_net_get_cco (&ctx.cp, net);
+ test_fail_unless (cco);
+ test_fail_unless (cp_sta_get_mac_address (cco) ==
+ MAC_ADDRESS (0x00, 0x13, 0xd7, 0x00, 0x00, 0x01));
+ test_fail_unless (cp_sta_get_cco_status (cco) == true);
+ slab_release (cco);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_suite_beacon_no_net (test_t t)
+{
+ test_suite_begin (t, "No net for beacon processing");
+ test_case_begin (t, "Beacon process");
+ u32 last_countdown_call_date = phy_date () - BSU_ACLF_BP_60HZ_TCK - 100;
+ test_begin (t, "let's go")
+ {
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ bsu_beacon_t *beacon = blk_alloc ();
+ cp_beacon_fill (&ctx.cp, beacon);
+ uint i;
+ for (i = 0; i < HPAV_AVLNS_NB_MAX; i++)
+ cp_sta_mgr_add_avln (&ctx.cp, i + 1, i);
+ test_fail_unless (!cp_sta_mgr_add_avln (&ctx.cp, 15, 30));
+ beacon->params.rx_parameters.snid = 0xf;
+ beacon->vf.nid = 0x1234;
+ beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (!cp_sta_mgr_get_avln (&ctx.cp, 15, 30));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_suite_beacon_spoc_update (test_t test)
+{
+ test_beacon_t ctx;
+ u32 last_countdown_call_date = phy_date () - BSU_ACLF_BP_60HZ_TCK - 100;
+ test_beacon_init (&ctx);
+ test_suite_begin (test, "SPOC update");
+ test_case_begin (test, "Frequency error invalid and valid");
+ test_begin (test, "SPOC only updated if F.E. is valid")
+ {
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ ctx.cp.beacon.spoc_update_interval_ms = 1;
+ bsu_beacon_t *beacon = test_new_beacon ();
+ cp_sta_mgr_add_avln (&ctx.cp, beacon->params.rx_parameters.snid,
+ beacon->vf.nid);
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_sta_own_data_set_nid (&ctx.cp, beacon->vf.nid);
+ own->nid_track = beacon->vf.nid;
+ own->tei_track = beacon->vf.stei;
+ beacon->params.rx_parameters.snid =
+ cp_sta_own_data_get_snid (&ctx.cp);
+ /* Process a received beacon with a frequency error invalid. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (!ctx.cp.beacon.spoc_updated);
+ /* This received beacon has a valid frequency error, SPOC should be
+ * updated. */
+ beacon = test_new_beacon ();
+ beacon->params.frequency_error_valid = true;
+ beacon->params.rx_parameters.snid =
+ cp_sta_own_data_get_snid (&ctx.cp);
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.spoc_updated);
+ /* This received beacon has a invalid frequency error. SPOC updated
+ * flag stay at true. */
+ beacon = test_new_beacon ();
+ beacon->params.frequency_error_valid = false;
+ ctx.cp.beacon.spoc_update_date = phy_date () - 1;
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.spoc_updated);
+ }
+ test_end;
+ test_beacon_uninit (&ctx);
+}
+
+void
+test_suite_beacon_hoip_ended (test_t t)
+{
+ test_suite_begin (t, "Handover ended, avoid to send the last beacon");
+ test_case_begin (t, "Handover in progress");
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ test_begin (t, "Handover not ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 2;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (ctx.bsu_updated);
+ }
+ test_end;
+ test_begin (t, "Handover Ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 1;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (!ctx.bsu_updated);
+ }
+ test_end;
+ test_beacon_uninit (&ctx);
+}
+
+
+void
+test_suite_beacon_update_tracking (test_t t)
+{
+ test_suite_begin (t, "Update tracking");
+ test_case_begin (t, "Update tracking");
+ test_begin (t, "update tracking")
+ {
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ u8 tei = MAC_TEI_STA_MAX;
+ mac_t mac = MAC_ADDRESS (0x00, 0x13, 0xd7, 0x78, 0x79, 0x80);
+ cp_net_t *net = cp_sta_mgr_add_avln (&ctx.cp, 1, 1);
+ cp_sta_t *sta = cp_sta_mgr_sta_add (&ctx.cp, net, tei, mac);
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ test_fail_unless (own->tei_track != tei);
+ test_fail_unless (own->cco_mac_addr_track != mac);
+ cp_beacon_update_tracking (&ctx.cp, sta);
+ test_fail_unless (own->tei_track == tei);
+ test_fail_unless (own->cco_mac_addr_track == mac);
+ slab_release (sta);
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+int
+main (void)
+{
+ test_t test;
+ test_init (test, 0, NULL);
+
+ test_case_beacon_uninit (test);
+ test_case_beacon__deactivate (test);
+ test_suite_beacon__beacon_generation (test);
+ test_suite_beacon_snid_change (test);
+ test_suite_beacon_eks_change (test);
+ test_suite_beacon_mac_address_bentry (test);
+ test_suite_beacon_no_net (test);
+ test_suite_beacon_spoc_update (test);
+ test_suite_beacon_hoip_ended (test);
+ test_suite_beacon_update_tracking (test);
+
+ test_case_begin (test, "Memory allocation");
+ test_begin (test, "memory leaks")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
+ }
+ test_end;
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
diff --git a/cesar/cp/av/beacon/test/utest/src/beacon_utest.c b/cesar/cp/av/beacon/test/utest/src/beacon_utest.c
new file mode 100644
index 0000000000..2e2cab2f1d
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/src/beacon_utest.c
@@ -0,0 +1,61 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/beacon_utest.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp/cp.h"
+#include "cp/beacon/defs.h"
+#include "cp/beacon/beacon.h"
+#include "cp/sta/mgr/net.h"
+#include "cp/sta/mgr/sta_mgr.h"
+
+void
+cp_av_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon)
+{
+ cp_net_t *net = cp_sta_mgr_add_avln (
+ ctx, beacon->params.rx_parameters.snid, beacon->vf.nid);
+ if (net && MAC_TEI_IS_STA (beacon->vf.stei))
+ {
+ cp_sta_t *sta = cp_beacon_process_beacon_central (ctx, beacon, net);
+ if (sta)
+ slab_release (sta);
+ }
+}
+
+void
+cp_av_beacon_change_hm (cp_t *ctx, uint hybrid_mode) {}
+
+void
+cp_av_beacon_cco_handover (cp_t *ctx, cp_tei_t tei) {}
+
+void
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t tei) {}
+
+void
+cp_av_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag) {}
+
+void
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx) {}
+
+void
+cp_av_beacon_beacon_not_received (cp_t *ctx)
+{
+ cp_beacon_countdowns (ctx);
+}
+
+void
+cp_av_beacon_fill_discover_info (
+ cp_t *ctx, bsu_beacon_bmi_discover_info_t *discover) {}
+
+void
+cp_av_beacon_fill_discovery_bentries (cp_t *ctx, bsu_beacon_t *beacon) {}
diff --git a/cesar/cp/beacon/test/src/discover.c b/cesar/cp/av/beacon/test/utest/src/discover.c
index a94032fa4c..2a2ea8aee9 100644
--- a/cesar/cp/beacon/test/src/discover.c
+++ b/cesar/cp/av/beacon/test/utest/src/discover.c
@@ -22,12 +22,12 @@
#include "cp/cp.h"
#include "cp/inc/context.h"
-#include "cp/beacon/discover.h"
+#include "cp/av/beacon/discover.h"
#include "cl/inc/context.h"
#include "mac/sar/inc/context.h"
void
-cp_beacon_discover_compute_interval (cp_t *ctx);
+cp_av_beacon_discover_compute_interval (cp_t *ctx);
static test_t test;
static bool event_posted;
@@ -77,7 +77,7 @@ test_case_discover_init (test_t test)
{
test_discover_t t;
test_discover_init (&t);
- cp_beacon_discover_init (&t.cp);
+ cp_av_beacon_discover_init (&t.cp);
test_case_begin (test, "Discover init");
test_begin (test, "Verify data")
{
@@ -117,8 +117,8 @@ test_case_discover_compute_interval (test_t test)
sta = cp_sta_mgr_sta_add (&t.cp, net, i, i);
slab_release (sta);
}
- cp_beacon_discover_init (&t.cp);
- cp_beacon_discover_compute_interval (&t.cp);
+ cp_av_beacon_discover_init (&t.cp);
+ cp_av_beacon_discover_compute_interval (&t.cp);
int interval =
MAC_MS_TO_TCK (MAC_SEC_TO_MS (CP_DISCOVER_PERIOD_MAX_S))
/ i / t.aclf.beacon_period_tck;
@@ -150,8 +150,8 @@ test_case_discover_need_to_request (test_t test)
cp_sta_mgr_set_our_avln (&t.cp, net);
cp_sta_own_data_set_tei (&t.cp, 1);
cp_sta_own_data_set_cco_status (&t.cp, true);
- cp_beacon_discover_init (&t.cp);
- cp_beacon_discover_compute_interval (&t.cp);
+ cp_av_beacon_discover_init (&t.cp);
+ cp_av_beacon_discover_compute_interval (&t.cp);
for (i = 2; i <= 10; i++)
{
sta = cp_sta_mgr_sta_add (&t.cp, net, i, i);
@@ -160,7 +160,7 @@ test_case_discover_need_to_request (test_t test)
/* Start the test simulating 20s. */
for (i = 2, bp = 0; bp < 20; bp++)
{
- cp_beacon_discover_need_to_request (&t.cp, &tei);
+ cp_av_beacon_discover_need_to_request (&t.cp, &tei);
t.cp.beacon.discover.countdown_bp = 0;
test_fail_unless (tei == i);
if (i == 10)
diff --git a/cesar/cp/av/beacon/test/utest/src/stubs.c b/cesar/cp/av/beacon/test/utest/src/stubs.c
new file mode 100644
index 0000000000..f3b7eb72ca
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/src/stubs.c
@@ -0,0 +1,103 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/beacon/test/utest/src/stubs.c
+ * \brief Stubs functions.
+ * \ingroup cp_av_beacon
+ */
+#include "common/std.h"
+#include "cp/secu/secu.h"
+#include "bsu/beacon/beacon.h"
+#include "bsu/aclf/aclf.h"
+#include "bsu/bsu.h"
+#include "hal/phy/spoc/spoc.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/ca/ca.h"
+
+static ca_schedule_t _casched[8];
+
+ca_schedule_t *
+ca_alloc_get_schedule (ca_t *ctx, uint index)
+{
+ if (index < 8)
+ {
+ return &_casched[index];
+ }
+
+ return NULL;
+}
+
+
+
+void
+cp_secu_pbb_dec_gen (cp_key_t enc, cp_key_t *dec)
+{
+ dec->key[0] = 0xdeaddead;
+ dec->key[1] = 0xdeaddead;
+ dec->key[2] = 0xdeaddead;
+ dec->key[3] = 0xdeaddead;
+}
+
+void
+bsu_aclf_beacon_period_start_date (bsu_aclf_t *ctx, u32 *bpsd, uint nb)
+{
+ uint i;
+
+ bpsd[0] = BSU_ACLF_BP_50HZ_TCK;
+
+ for (i = 1; i < nb; i++)
+ bpsd[i] = bpsd[i - 1] + BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_start_date_next (bsu_aclf_t *ctx)
+{
+ return BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_tck (bsu_aclf_t *ctx)
+{
+ return BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx)
+{
+ return MAC_TCK_TO_ATU (ctx->beacon_period_tck);
+}
+
+
+void
+bsu_update (bsu_t *ctx, bsu_beacon_t *beacon, bsu_update_sta_type_t sta)
+{
+ bool *updated = (bool*) ctx;
+ *updated = true;
+}
+
+u32
+phy_clock_get_zero_cross_captured_date (phy_t *phy)
+{
+ return 0;
+}
+
+u32
+phy_date ()
+{
+ return BSU_ACLF_BP_60HZ_TCK+1;
+}
+
+void
+pbproc_spoc_coeff_set (pbproc_t *pbproc, bool sync, phy_spoc_coeff_t *coeff)
+{
+ dbg_assert (coeff);
+
+ blk_release (coeff->part2);
+ blk_release (coeff);
+}
+
diff --git a/cesar/cp/av/beacon/test/utest/src/test_beacon.c b/cesar/cp/av/beacon/test/utest/src/test_beacon.c
new file mode 100644
index 0000000000..6bc6810e10
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest/src/test_beacon.c
@@ -0,0 +1,291 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/beacon/test/src/test_beacon.c
+ * \brief Specific AV unit tests.
+ * \ingroup cp_av_beacon
+ */
+#include "common/std.h"
+#include "lib/test.h"
+#include "cp/cp.h"
+#include "cp/beacon/beacon.h"
+#include "cp/av/beacon/beacon.h"
+
+#include "cp/inc/context.h"
+#include "cl/inc/context.h"
+#include "mac/sar/inc/context.h"
+
+void
+cp_beacon_receive (cp_t *ctx, bsu_beacon_t *beacon);
+
+void
+cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon_data);
+
+struct test_beacon_t
+{
+ cp_t cp;
+ mac_config_t mac_config;
+ cl_t cl;
+ sar_t sar;
+ bsu_aclf_t aclf;
+ uint ca;
+ bool bsu_updated;
+};
+typedef struct test_beacon_t test_beacon_t;
+
+void
+test_beacon_init (test_beacon_t *ctx)
+{
+ memset (ctx, 0, sizeof (test_beacon_t));
+ lib_rnd_init (&ctx->cp.rnd, 0x1234);
+ ctx->cp.mac_config = &ctx->mac_config;
+ ctx->cp.sar = &ctx->sar;
+ ctx->cp.cl = &ctx->cl;
+ ctx->cp.bsu_aclf = &ctx->aclf;
+ ctx->cp.bsu = (bsu_t *) &ctx->bsu_updated;
+ *((bsu_aclf_frequency_t*) &ctx->aclf.frequency) = BSU_ACLF_FREQ_50HZ;
+ *((bsu_aclf_bp_t*) &ctx->aclf.beacon_period_theo_tck) =
+ BSU_ACLF_BP_50HZ_TCK;
+ ctx->aclf.beacon_period_tck = ctx->aclf.beacon_period_theo_tck;
+ ctx->cp.mac_store = mac_store_init();
+ ctx->cp.ca = (ca_t*) &ctx->ca;
+ cp_sta_mgr_init (&ctx->cp);
+ cp_cco_bw_init (&ctx->cp);
+ cp_cco_region_init (&ctx->cp);
+ cp_beacon_init (&ctx->cp);
+ ctx->cp.beacon.last_countdown_call_date_active = true;
+}
+
+void
+test_beacon_uninit (test_beacon_t *ctx)
+{
+ cp_beacon_uninit (&ctx->cp);
+ cp_cco_bw_uninit (&ctx->cp);
+ cp_cco_region_uninit (&ctx->cp);
+ cp_sta_mgr_uninit (&ctx->cp);
+ mac_store_uninit (ctx->cp.mac_store);
+}
+
+bsu_beacon_t*
+test_new_beacon (void)
+{
+ /** Create a central beacon. */
+ bsu_beacon_t *beacon = blk_alloc ();
+ beacon->vf.nid = 1;
+ beacon->vf.stei = 1;
+ beacon->vf.bt = BSU_BEACON_TYPE_CENTRAL;
+ beacon->vf.hm = MAC_COEXISTENCE_FULL_HYBRID_MODE;
+ beacon->vf.ncnr = false;
+ beacon->vf.npsm = false;
+ beacon->vf.numslots = 0;
+ beacon->vf.slotusage = 0;
+ beacon->vf.slotid = 0;
+ beacon->vf.aclsss = true;
+ beacon->vf.hoip = false;
+ beacon->vf.rtsbf = false;
+ beacon->vf.nm = MAC_NM_CSMA_ONLY;
+ beacon->vf.ccocap = 0;
+ beacon->bmis.change_snid.present = true;
+ beacon->bmis.change_snid.snidccd = 3;
+ beacon->bmis.change_snid.new_snid = 0xC;
+ beacon->bmis.mac_address.present = true;
+ beacon->bmis.region.nb = 1;
+ beacon->bmis.region.region[0].end_time_atu = 3907;
+ beacon->bmis.region.region[0].rt = CP_CCO_REGION_TYPE_BEACON;
+ beacon->bmis.nps.ns = 1;
+ beacon->bmis.nps.sais[0].end_time_atu = 3907;
+ beacon->bmis.nps.sais[0].glid = 0x45;
+ beacon->bmis.nps.sais[0].stpf = false;
+ beacon->bmis.nbe = 4;
+ beacon->params.rx_parameters.snid = 0;
+ beacon->params.rx_parameters.access = HPAV_ACCESS_IN_HOME;
+ beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
+ beacon->params.frequency_error_valid = false;
+ return beacon;
+}
+
+void
+test_suite_beacon_hm_change (test_t test)
+{
+ test_suite_begin (test, "Hybrid mode change");
+ test_case_begin (test, "Station");
+ u32 last_countdown_call_date = phy_date () - BSU_ACLF_BP_60HZ_TCK - 100;
+ test_begin (test, "Beacon reception")
+ {
+ test_beacon_t ctx;
+ bsu_beacon_t *beacon;
+ cp_net_t *net;
+ cp_sta_own_data_t *own;
+ /** Init the context. */
+ test_beacon_init (&ctx);
+ ctx.cp.bsu_aclf->beacon_period_tck = BSU_ACLF_BP_60HZ_TCK;
+ /** Configure station own data. */
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ own->nid_track = 1;
+ own->tei_track = 1;
+ own->hybrid_mode = 0;
+ /** Create a central beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_hm.present = true;
+ beacon->bmis.change_hm.newhm = 1;
+ beacon->bmis.change_hm.hmccd = 3;
+ beacon->bmis.nbe = 4;
+ /** Check default values. */
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
+ test_fail_unless (own->hybrid_mode == 0);
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check values are taken. */
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 3);
+ test_fail_unless (own->hybrid_mode == 0);
+ /** Create the new beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_hm.hmccd = 2;
+ /** launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ /** Check values are taken. */
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 2);
+ test_fail_unless (own->hybrid_mode == 0);
+ /** Create the new beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_hm.hmccd = 1;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 1);
+ test_fail_unless (own->hybrid_mode == 0);
+ /* Create the beacon. */
+ beacon = test_new_beacon ();
+ beacon->bmis.change_hm.present = false;
+ beacon->bmis.nbe = 3;
+ /* launch the test. */
+ cp_beacon_receive (&ctx.cp, beacon);
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_get_and_process_beacon (&ctx.cp);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
+ test_fail_unless (own->hybrid_mode == 0x1);
+ dbg_check (mac_store_sta_remove (ctx.cp.mac_store, 1));
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+
+ test_begin (test, "Beacon missed")
+ {
+ test_beacon_t ctx;
+ cp_net_t *net;
+ cp_cco_region_alloc_t *region;
+ cp_cco_bw_alloc_t *alloc;
+ cp_sta_own_data_t *own;
+ test_beacon_init (&ctx);
+ /* Regions. */
+ region = cp_cco_region_alloc_init (&ctx.cp);
+ region->type = CP_BEACON_REGION_TYPE_SHARED_CSMA;
+ region->end_time_atu = 3907;
+ cp_cco_region_alloc_add (&ctx.cp, &ctx.cp.region.region_list, region);
+ slab_release (region);
+
+ /* Schedules. */
+ alloc = cp_cco_bw_alloc_init (&ctx.cp);
+ alloc->stpf = false;
+ alloc->glid = 0x45;
+ alloc->end_time_atu = 3907;
+ alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT;
+ cp_cco_bw_alloc_add (&ctx.cp, &ctx.cp.bw.alloc_list, alloc);
+ slab_release (alloc);
+
+ /* Configure station own data. */
+ own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ net = cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
+ cp_sta_own_data_set_tei (&ctx.cp, 2);
+ cp_sta_own_data_set_mac_address (&ctx.cp, 0x23456789abcull);
+ cp_sta_mgr_set_our_avln (&ctx.cp, net);
+
+ /* Configure the test. */
+ ctx.cp.beacon.hm.hmcd = 2;
+ ctx.cp.beacon.hm.hm = 0x1;
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 1);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+
+ ctx.cp.beacon.last_countdown_call_date = last_countdown_call_date;
+ cp_beacon_beacon_not_received (&ctx.cp);
+
+ test_fail_unless (ctx.cp.beacon.hm.hmcd == 0);
+ test_fail_unless (ctx.cp.beacon.hm.hm == 0x1);
+ test_fail_unless (own->hybrid_mode == 0x1);
+
+ test_beacon_uninit (&ctx);
+ }
+ test_end;
+}
+
+void
+test_suite_beacon_hoip_ended (test_t t)
+{
+ test_suite_begin (t, "Handover ended, avoid to send the last beacon");
+ test_case_begin (t, "Handover in progress");
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ test_begin (t, "Handover not ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 2;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (ctx.bsu_updated);
+ }
+ test_end;
+ test_begin (t, "Handover Ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 1;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (!ctx.bsu_updated);
+ }
+ test_end;
+ test_beacon_uninit (&ctx);
+}
+
+int
+main (void)
+{
+ test_t test;
+ test_init (test, 0, NULL);
+ lib_stats_init ();
+
+ test_suite_beacon_hm_change (test);
+ test_suite_beacon_hoip_ended (test);
+
+ lib_stats_uninit ();
+ test_case_begin (test, "Memory allocation");
+ test_begin (test, "memory leaks")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory leaks");
+ }
+ test_end;
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
diff --git a/cesar/cp/beacon/test/Config b/cesar/cp/av/beacon/test/utest2/Config
index b711c51e0f..22ca949503 100644
--- a/cesar/cp/beacon/test/Config
+++ b/cesar/cp/av/beacon/test/utest2/Config
@@ -1 +1,2 @@
CONFIG_STATS = n
+CONFIG_CP_AV = y
diff --git a/cesar/cp/av/beacon/test/utest2/Makefile b/cesar/cp/av/beacon/test/utest2/Makefile
new file mode 100644
index 0000000000..1efd01b985
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest2/Makefile
@@ -0,0 +1,20 @@
+BASE = ../../../../..
+
+INCLUDES = cp/av/beacon/test/utest2/override cp/av/beacon/test/utest2
+
+HOST_PROGRAMS = beacon_scenario
+
+beacon_scenario_SOURCES = beacon_scenario.c scenario_actions.c \
+ bsu_stub_scenario.c bsu_beacon_stub.c fsm_stub.c \
+ phy_stub.c secu_stub.c sta_mgr_stub.c
+
+beacon_scenario_MODULES = cp/av/beacon cp/av/cco/region/stub \
+ cp/av/cco/bw/stub cp/av/cco/action/stub \
+ lib lib/scenario cp/av/fsm/stub interface/stub \
+ bsu/stub cp/msg/stub cp/sta/core/stub \
+ hal/timer/stub mac/sar/stub cl/stub \
+ mac/common bsu/stub
+
+beacon_scenario_CONFIG_MODULES = cp
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/inc/scenario_defs.h b/cesar/cp/av/beacon/test/utest2/inc/scenario_defs.h
index 9d4711305e..9d4711305e 100644
--- a/cesar/cp/beacon/test/inc/scenario_defs.h
+++ b/cesar/cp/av/beacon/test/utest2/inc/scenario_defs.h
diff --git a/cesar/cp/beacon/test/override-scenario/cp/inc/context.h b/cesar/cp/av/beacon/test/utest2/override/cp/inc/context.h
index 3fd3d33850..0977eadc07 100644
--- a/cesar/cp/beacon/test/override-scenario/cp/inc/context.h
+++ b/cesar/cp/av/beacon/test/utest2/override/cp/inc/context.h
@@ -34,6 +34,9 @@
#include "lib/rnd.h"
#include "lib/trace.h"
+/** Forward declaration. */
+typedef struct cp_beacon_t cp_beacon_t;
+
struct cp_t
{
cp_beacon_t beacon;
diff --git a/cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h b/cesar/cp/av/beacon/test/utest2/override/cp/sta/core/defs.h
index 9698b44e93..9698b44e93 100644
--- a/cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h
+++ b/cesar/cp/av/beacon/test/utest2/override/cp/sta/core/defs.h
diff --git a/cesar/cp/beacon/test/src/beacon.c b/cesar/cp/av/beacon/test/utest2/src/beacon.c
index 556bd936ac..62146069b0 100644
--- a/cesar/cp/beacon/test/src/beacon.c
+++ b/cesar/cp/av/beacon/test/utest2/src/beacon.c
@@ -21,7 +21,7 @@
#include "mac/common/store.h"
#include "cp/beacon/beacon.h"
-#include "cp/beacon/discover.h"
+#include "cp/av/beacon/discover.h"
#include "cp/cp.h"
#include "cp/inc/context.h"
@@ -337,7 +337,7 @@ test_suite_beacon__beacon_generation (test_t test)
cp_sta_own_data_set_tei (&ctx.cp, tei_1);
cp_net_set_slot_id_and_usage (&ctx.cp, net_1, slot_id_1, 0);
cp_sta_mgr_set_our_avln (&ctx.cp, net_1);
- cp_beacon_handover_hoipflag (&ctx.cp, hoip_flag_1);
+ cp_av_beacon_handover_hoipflag (&ctx.cp, hoip_flag_1);
cp_sta_own_data_set_cco_status (&ctx.cp, cco_flag_1);
cp_sta_own_data_set_pco_status (&ctx.cp, pco_flag_1);
cp_sta_own_data_set_authenticated_status (&ctx.cp, authen_1);
@@ -418,7 +418,7 @@ test_suite_beacon__beacon_generation (test_t test)
cp_sta_own_data_set_tei (&ctx.cp, tei_2);
cp_net_set_slot_id_and_usage (&ctx.cp, net_2, slot_id_2, 0);
cp_sta_mgr_set_our_avln (&ctx.cp, net_2);
- cp_beacon_handover_hoipflag (&ctx.cp, hoip_flag_2);
+ cp_av_beacon_handover_hoipflag (&ctx.cp, hoip_flag_2);
cp_sta_own_data_set_cco_status (&ctx.cp, cco_flag_2);
cp_sta_own_data_set_pco_status (&ctx.cp, pco_flag_2);
cp_sta_own_data_set_authenticated_status (&ctx.cp, authen_2);
diff --git a/cesar/cp/beacon/test/src/beacon_scenario.c b/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c
index 99920a8a0f..99920a8a0f 100644
--- a/cesar/cp/beacon/test/src/beacon_scenario.c
+++ b/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c
diff --git a/cesar/cp/beacon/test/src/bsu_beacon_stub.c b/cesar/cp/av/beacon/test/utest2/src/bsu_beacon_stub.c
index 20123664fd..20123664fd 100644
--- a/cesar/cp/beacon/test/src/bsu_beacon_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/bsu_beacon_stub.c
diff --git a/cesar/cp/beacon/test/src/bsu_stub.c b/cesar/cp/av/beacon/test/utest2/src/bsu_stub.c
index 1b2fd6fc3f..1b2fd6fc3f 100644
--- a/cesar/cp/beacon/test/src/bsu_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/bsu_stub.c
diff --git a/cesar/cp/beacon/test/src/bsu_stub_scenario.c b/cesar/cp/av/beacon/test/utest2/src/bsu_stub_scenario.c
index 05689be7a6..05689be7a6 100644
--- a/cesar/cp/beacon/test/src/bsu_stub_scenario.c
+++ b/cesar/cp/av/beacon/test/utest2/src/bsu_stub_scenario.c
diff --git a/cesar/cp/beacon/test/src/ca_stub.c b/cesar/cp/av/beacon/test/utest2/src/ca_stub.c
index 61a67cb290..61a67cb290 100644
--- a/cesar/cp/beacon/test/src/ca_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/ca_stub.c
diff --git a/cesar/cp/beacon/test/src/fsm_stub.c b/cesar/cp/av/beacon/test/utest2/src/fsm_stub.c
index 6d09863df4..6d09863df4 100644
--- a/cesar/cp/beacon/test/src/fsm_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/fsm_stub.c
diff --git a/cesar/cp/beacon/test/src/phy_stub.c b/cesar/cp/av/beacon/test/utest2/src/phy_stub.c
index cfd499e743..cfd499e743 100644
--- a/cesar/cp/beacon/test/src/phy_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/phy_stub.c
diff --git a/cesar/cp/beacon/test/src/scenario_actions.c b/cesar/cp/av/beacon/test/utest2/src/scenario_actions.c
index 1e71f46112..1e71f46112 100644
--- a/cesar/cp/beacon/test/src/scenario_actions.c
+++ b/cesar/cp/av/beacon/test/utest2/src/scenario_actions.c
diff --git a/cesar/cp/beacon/test/src/secu_stub.c b/cesar/cp/av/beacon/test/utest2/src/secu_stub.c
index 89f0605a3e..89f0605a3e 100644
--- a/cesar/cp/beacon/test/src/secu_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/secu_stub.c
diff --git a/cesar/cp/beacon/test/src/sta_mgr_stub.c b/cesar/cp/av/beacon/test/utest2/src/sta_mgr_stub.c
index 6554aa77af..6554aa77af 100644
--- a/cesar/cp/beacon/test/src/sta_mgr_stub.c
+++ b/cesar/cp/av/beacon/test/utest2/src/sta_mgr_stub.c
diff --git a/cesar/cp/av/beacon/test/utest2/src/stubs.c b/cesar/cp/av/beacon/test/utest2/src/stubs.c
new file mode 100644
index 0000000000..845efce34a
--- /dev/null
+++ b/cesar/cp/av/beacon/test/utest2/src/stubs.c
@@ -0,0 +1,101 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/beacon/test/utest/src/stubs.c
+ * \brief Stubs functions.
+ * \ingroup cp_av_beacon
+ */
+#include "common/std.h"
+#include "cp/secu/secu.h"
+#include "bsu/beacon/beacon.h"
+#include "bsu/aclf/aclf.h"
+#include "bsu/bsu.h"
+#include "hal/phy/spoc/spoc.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/ca/ca.h"
+
+static ca_schedule_t _casched[8];
+
+ca_schedule_t *
+ca_alloc_get_schedule (ca_t *ctx, uint index)
+{
+ if (index < 8)
+ {
+ return &_casched[index];
+ }
+
+ return NULL;
+}
+
+void
+cp_secu_pbb_dec_gen (cp_key_t enc, cp_key_t *dec)
+{
+ dec->key[0] = 0xdeaddead;
+ dec->key[1] = 0xdeaddead;
+ dec->key[2] = 0xdeaddead;
+ dec->key[3] = 0xdeaddead;
+}
+
+void
+bsu_aclf_beacon_period_start_date (bsu_aclf_t *ctx, u32 *bpsd, uint nb)
+{
+ uint i;
+
+ bpsd[0] = BSU_ACLF_BP_50HZ_TCK;
+
+ for (i = 1; i < nb; i++)
+ bpsd[i] = bpsd[i - 1] + BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_start_date_next (bsu_aclf_t *ctx)
+{
+ return BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_tck (bsu_aclf_t *ctx)
+{
+ return BSU_ACLF_BP_50HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx)
+{
+ return MAC_TCK_TO_ATU (ctx->beacon_period_tck);
+}
+
+
+void
+bsu_update (bsu_t *ctx, bsu_beacon_t *beacon, bsu_update_sta_type_t sta)
+{
+ bool *updated = (bool*) ctx;
+ *updated = true;
+}
+
+u32
+phy_clock_get_zero_cross_captured_date (phy_t *phy)
+{
+ return 0;
+}
+
+u32
+phy_date ()
+{
+ return BSU_ACLF_BP_60HZ_TCK+1;
+}
+
+void
+pbproc_spoc_coeff_set (pbproc_t *pbproc, bool sync, phy_spoc_coeff_t *coeff)
+{
+ dbg_assert (coeff);
+
+ blk_release (coeff->part2);
+ blk_release (coeff);
+}
+
diff --git a/cesar/cp/av/cco/action/Module b/cesar/cp/av/cco/action/Module
new file mode 100644
index 0000000000..72ff1ad41f
--- /dev/null
+++ b/cesar/cp/av/cco/action/Module
@@ -0,0 +1,3 @@
+SOURCES := cco_action.c handover.c
+
+MODULES := cp/cco/action
diff --git a/cesar/cp/av/cco/action/cco_action.h b/cesar/cp/av/cco/action/cco_action.h
new file mode 100644
index 0000000000..db26a47e02
--- /dev/null
+++ b/cesar/cp/av/cco/action/cco_action.h
@@ -0,0 +1,361 @@
+#ifndef cp_av_cco_action_h
+#define cp_av_cco_action_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/cco/cco_action.h
+ * \brief CCo Public functions.
+ * \ingroup cp_cco
+ *
+ */
+
+#include "cp/cco/action/cco_action.h"
+#include "cp/cp.h"
+#include "cp/mme.h"
+#include "cp/av/beacon/beacon.h"
+#include "cp/sta/mgr/sta.h"
+
+
+BEGIN_DECLS
+
+/**
+ * Start UCCo role.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_ucco_start (cp_t *ctx);
+
+/**
+ * Stop UCCo role.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_ucco_stop (cp_t *ctx);
+
+/**
+ * Move from UCCO to CCO.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_ucco__to_cco (cp_t *ctx);
+
+/**
+ * Move from CCO to UCCO.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco__to_ucco (cp_t *ctx);
+
+/**
+ * Move from USTA to CCO.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco__unassoc_start (cp_t *ctx);
+
+/**
+ * Move from CCO to USTA.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx);
+
+/**
+ * Move from STA to CCO.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco__assoc_start (cp_t *ctx);
+
+/**
+ * Move from CCO to STA.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco__assoc_stop (cp_t *ctx);
+
+/**
+ * Change the SNID using the beacon module.
+ * \param ctx the module context.
+ *
+ * It shall request the SNIDs in use from the station manager to choose
+ * one randomly in the available SNIDs
+ */
+void
+cp_av_cco_action_cco__cco_snid_conflict (cp_t *ctx);
+
+/**
+ * generate a new NEK value.
+ * \param ctx the module context.
+ *
+ * NEK shall be used no more than 1 hour, so must be changed after 1
+ * hour for that purpose, NEK expiration date is checked at every occurrence
+ * of the global garbage collector timer and if current NEK expiration
+ * date reached, a new NEK value shall be generated by calling this function
+ */
+void
+cp_av_cco_action_cco__cco_nek_change (cp_t *ctx);
+
+/**
+ * Send the TEI map with the data corresponding to the station leaving.
+ * \param ctx the CP context.
+ * \param sta the station which leaves the AVLN.
+ *
+ * It will not add a reference on the station and will not release it.
+ */
+void
+cp_av_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta);
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
+
+/**
+ * manage authentication of a station.
+ * \param ctx the module context.
+ * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
+ */
+void
+cp_av_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * get_key_req);
+
+/**
+ * manage key request from authenticated station.
+ * \param ctx the module context.
+ * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
+ */
+void
+cp_av_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * get_key_req);
+
+/**
+ * Release a station.
+ * \param ctx the CP context.
+ * \param mme the MME received.
+ */
+void
+cp_av_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Stop acting as a CCo and become a unassociated station.
+ * \param ctx the module context.
+ *
+ * This function shall:
+ * - Change the station status.
+ * - Reprogram the beacon timer to expire a few time after the beacon period
+ * start date.
+ * - Stop the NEK generation.
+ * - Delete the AVLN.
+ * - Change the station authenticated status to not authenticated.
+ */
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx);
+
+/**
+ * The Handover can not be done cause of a countdown in the central beacon.
+ * \param ctx the module context.
+ *
+ * This function will be called on each beacon timer expiration to send a
+ * central beacon and try to handover the CCo functionality to stop.
+ */
+void
+cp_av_cco_action_drv_mac_stop_suspend (cp_t *ctx);
+
+/**
+ * Stop the CCo activity.
+ * \param ctx the module context.
+ *
+ * Post event to_leave.
+ */
+void
+cp_av_cco_action_drv_mac_stop_ended (cp_t *ctx);
+
+/**
+ * Stop the UCCo activity.
+ * \param ctx the module context.
+ *
+ * Post event left.
+ */
+void
+cp_av_cco_action_ucco__to_stop (cp_t *ctx);
+
+/**
+ * Set the TEI in use.
+ * \param ctx the module context.
+ * \param tei the TEI already in use.
+ *
+ * Use this function for the handover to disallow the new CCo to use a TEI
+ * already in use.
+ */
+void
+cp_av_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei);
+
+/**
+ * Clear the TEI compute mechanism.
+ * \param ctx the module context.
+ *
+ * Use this function on the CCO stop.
+ */
+void
+cp_av_cco_action_tei_clear (cp_t *ctx);
+
+/**
+ * CCo STOP on the DRV_MAC_STOP MME.
+ * \param ctx the module context.
+ *
+ * This function shall produce a handover on the network to allow another
+ * station to become the network CCo. So it shall inform the beacon module to
+ * set the hoip flag in the central beacon and provide a handover in progress
+ * bentry in the central beacon.
+ *
+ * \warn This function will not stop the CCo. This shall be done once the
+ * handover has been done on the network.
+ */
+void
+cp_av_cco_action_drv_mac_stop (cp_t *ctx);
+
+/**
+ * CCo selection for the drv mac stop request.
+ * \param ctx the module context.
+ * \param sta the station to add.
+ */
+void
+cp_av_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta);
+
+/**
+ * Clear the selection context.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_cco_selection__clear (cp_t *ctx);
+
+/**
+ * Add a station to the CCo selection procedure.
+ * \param ctx the module context.
+ * \param net the station's NET.
+ * \param sta the station to add.
+ *
+ * This function shall add the station only if it can be a better CCo and if
+ * out station is not CCo User appointed.
+ */
+void
+cp_av_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * Handle SC_CCO => CC_ASSOC_REQ.
+ * \param ctx control plane context.
+ * \param mme the handled MME.
+ *
+ * If it's the STA with which we are doing the SC assoc, reply with ok,
+ * otherwise, reply with temporary failure.
+ */
+void
+cp_av_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * The handover is ended.
+ * \param ctx control plane context.
+ *
+ * Allow the ASSOC FSM to go to the authenticated state
+ */
+void
+cp_av_cco_action_handover__ended (cp_t *ctx);
+
+/**
+ * Start providing the NEK to the authenticated stations.
+ * \param ctx control plane context.
+ *
+ * CCO_NEK_CHANGE_IDLE -> CCO_NEK_CHANGE_WAIT_STA_CNF.
+ * This function should start a timer to check the timeout.
+ */
+void
+cp_av_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx);
+
+/**
+ * Timeout NEK exchange with a station.
+ * \param ctx control plane context.
+ *
+ * This should try to provide the nek to another station if the peered station
+ * was not the last of the AVLN, in the other case it should stop the FSM
+ * going to the IDLE state.
+ */
+void
+cp_av_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx);
+
+/**
+ * Timeout NEK exchange with a station.
+ * \param ctx control plane context.
+ *
+ * This should try to provide the nek to another station if the peered station
+ * was not the last of the AVLN, in the other case it should stop the FSM
+ * going to the IDLE state.
+ */
+void
+cp_av_cco_action_cco__cco_nek_change__timeout (cp_t *ctx);
+
+/**
+ * Received the CM_SET_KEY.CNF from the station.
+ * \param ctx control plane context.
+ * \param mme the handled MME.
+ *
+ * CCO_NEK_CHANGE_WAIT_STA_CNF -> CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF
+ * Check the security parameters and the prn.
+ */
+void
+cp_av_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Call the beacon module to start inserting the EKS bentry in the central
+ * beacon.
+ * \param ctx control plane context.
+ */
+void
+cp_av_cco_action_nek_change_prevent (cp_t *ctx);
+
+/**
+ * Request a CC_DISCOVER_LIST.REQ to a station.
+ * \param ctx the module context.
+ * \param net the concerned network.
+ * \param sta the station to request the list.
+ */
+void
+cp_av_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net,
+ cp_sta_t *sta);
+
+/**
+ * CCo receives a beacon from the same NID.
+ * \param ctx the module context.
+ * \param beacon the beacon.
+ * \param net the beacon's network.
+ * \param sta the source emitter.
+ */
+void
+cp_av_cco_action_beacon_with_same_nid (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
+
+END_DECLS
+
+#endif /* cp_av_cco_action_h */
diff --git a/cesar/cp/av/cco/action/cco_conn/Module b/cesar/cp/av/cco/action/cco_conn/Module
new file mode 100644
index 0000000000..01a15a16d5
--- /dev/null
+++ b/cesar/cp/av/cco/action/cco_conn/Module
@@ -0,0 +1 @@
+SOURCES := action.c
diff --git a/cesar/cp/cco/action/cco_conn/cco_action.h b/cesar/cp/av/cco/action/cco_conn/cco_action.h
index 08a4ccf76b..08a4ccf76b 100644
--- a/cesar/cp/cco/action/cco_conn/cco_action.h
+++ b/cesar/cp/av/cco/action/cco_conn/cco_action.h
diff --git a/cesar/cp/cco/action/cco_conn/doc/CCo Con.odt b/cesar/cp/av/cco/action/cco_conn/doc/CCo Con.odt
index aed8db1cab..aed8db1cab 100755
--- a/cesar/cp/cco/action/cco_conn/doc/CCo Con.odt
+++ b/cesar/cp/av/cco/action/cco_conn/doc/CCo Con.odt
Binary files differ
diff --git a/cesar/cp/cco/action/cco_conn/doc/cco_conn.xmi b/cesar/cp/av/cco/action/cco_conn/doc/cco_conn.xmi
index 2e98a9400e..2e98a9400e 100644
--- a/cesar/cp/cco/action/cco_conn/doc/cco_conn.xmi
+++ b/cesar/cp/av/cco/action/cco_conn/doc/cco_conn.xmi
diff --git a/cesar/cp/cco/action/cco_conn/inc/cco_action.h b/cesar/cp/av/cco/action/cco_conn/inc/cco_action.h
index 4e9e50473f..4e9e50473f 100644
--- a/cesar/cp/cco/action/cco_conn/inc/cco_action.h
+++ b/cesar/cp/av/cco/action/cco_conn/inc/cco_action.h
diff --git a/cesar/cp/cco/action/cco_conn/src/action.c b/cesar/cp/av/cco/action/cco_conn/src/action.c
index 93326ce549..93326ce549 100644
--- a/cesar/cp/cco/action/cco_conn/src/action.c
+++ b/cesar/cp/av/cco/action/cco_conn/src/action.c
diff --git a/cesar/cp/cco/action/cco_conn/test/Makefile b/cesar/cp/av/cco/action/cco_conn/test/Makefile
index d7950bcb50..19fcd181d9 100644
--- a/cesar/cp/cco/action/cco_conn/test/Makefile
+++ b/cesar/cp/av/cco/action/cco_conn/test/Makefile
@@ -7,7 +7,7 @@ TARGET_PROGRAMS = cco_action_conn_test
cco_action_conn_test_SOURCES = cco_action_conn_test.c msg_stub.c
cco_action_conn_test_MODULES = lib cp/cco/bw cp/cco/action/cco_conn cp/conn \
- cp/sta/mgr cp/fsm/stub mac/common cl
+ cp/sta/mgr cp/av/fsm/stub mac/common cl
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cco/action/cco_conn/test/ecos.ecc.sh b/cesar/cp/av/cco/action/cco_conn/test/ecos.ecc.sh
index 8253d98c9a..8253d98c9a 100644
--- a/cesar/cp/cco/action/cco_conn/test/ecos.ecc.sh
+++ b/cesar/cp/av/cco/action/cco_conn/test/ecos.ecc.sh
diff --git a/cesar/cp/cco/action/cco_conn/test/src/cco_action_conn_test.c b/cesar/cp/av/cco/action/cco_conn/test/src/cco_action_conn_test.c
index b38b32dd12..b38b32dd12 100644
--- a/cesar/cp/cco/action/cco_conn/test/src/cco_action_conn_test.c
+++ b/cesar/cp/av/cco/action/cco_conn/test/src/cco_action_conn_test.c
diff --git a/cesar/cp/cco/action/cco_conn/test/src/msg_stub.c b/cesar/cp/av/cco/action/cco_conn/test/src/msg_stub.c
index bdd3aa078f..bdd3aa078f 100644
--- a/cesar/cp/cco/action/cco_conn/test/src/msg_stub.c
+++ b/cesar/cp/av/cco/action/cco_conn/test/src/msg_stub.c
diff --git a/cesar/cp/cco/action/doc/Makefile b/cesar/cp/av/cco/action/doc/Makefile
index cbaa4d1743..16174f2ce6 100644
--- a/cesar/cp/cco/action/doc/Makefile
+++ b/cesar/cp/av/cco/action/doc/Makefile
@@ -1,9 +1,9 @@
PAGES = tei snid assoc_procedure auth_procedure leave \
- handover_cco handover_sta cco_selection \
- fsm_handover_selection fsm_handover_cco \
- fsm_handover_cco_leave fsm_handover_cco_appoint \
- fsm_handover_sta fsm_handover_sta_appoint \
- fsm_handover nek_change
+ handover_cco handover_sta cco_selection \
+ fsm_handover_selection fsm_handover_cco \
+ fsm_handover_cco_leave fsm_handover_cco_appoint \
+ fsm_handover_sta fsm_handover_sta_appoint \
+ fsm_handover nek_change
TOOLS_DIR = ../../../../common/tools
DOTFLAGS = -Gbgcolor='\#f7f7f7' -Nstyle=filled -Nfillcolor=white
diff --git a/cesar/cp/cco/action/doc/assoc_procedure.sdl b/cesar/cp/av/cco/action/doc/assoc_procedure.sdl
index 898ef270ed..898ef270ed 100644
--- a/cesar/cp/cco/action/doc/assoc_procedure.sdl
+++ b/cesar/cp/av/cco/action/doc/assoc_procedure.sdl
diff --git a/cesar/cp/cco/action/doc/auth_procedure.sdl b/cesar/cp/av/cco/action/doc/auth_procedure.sdl
index bc14ccab05..bc14ccab05 100644
--- a/cesar/cp/cco/action/doc/auth_procedure.sdl
+++ b/cesar/cp/av/cco/action/doc/auth_procedure.sdl
diff --git a/cesar/cp/cco/action/doc/cco_action.odt b/cesar/cp/av/cco/action/doc/cco_action.odt
index d5454d9159..d5454d9159 100644
--- a/cesar/cp/cco/action/doc/cco_action.odt
+++ b/cesar/cp/av/cco/action/doc/cco_action.odt
Binary files differ
diff --git a/cesar/cp/cco/action/doc/cco_action.xmi b/cesar/cp/av/cco/action/doc/cco_action.xmi
index ad3bbf1ee9..ad3bbf1ee9 100644
--- a/cesar/cp/cco/action/doc/cco_action.xmi
+++ b/cesar/cp/av/cco/action/doc/cco_action.xmi
diff --git a/cesar/cp/cco/action/doc/cco_selection.sdl b/cesar/cp/av/cco/action/doc/cco_selection.sdl
index 1d6d5d17a5..1d6d5d17a5 100644
--- a/cesar/cp/cco/action/doc/cco_selection.sdl
+++ b/cesar/cp/av/cco/action/doc/cco_selection.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover.sdl b/cesar/cp/av/cco/action/doc/fsm_handover.sdl
index ac4f490e9b..ac4f490e9b 100644
--- a/cesar/cp/cco/action/doc/fsm_handover.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_cco.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_cco.sdl
index e12c51230e..e12c51230e 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_cco.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_cco.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_cco_appoint.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_cco_appoint.sdl
index 0906a256d0..0906a256d0 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_cco_appoint.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_cco_appoint.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_cco_leave.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_cco_leave.sdl
index 497afb8e7b..497afb8e7b 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_cco_leave.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_cco_leave.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_selection.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_selection.sdl
index f2f7649a1c..f2f7649a1c 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_selection.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_selection.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_sta.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_sta.sdl
index 3617e483f6..3617e483f6 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_sta.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_sta.sdl
diff --git a/cesar/cp/cco/action/doc/fsm_handover_sta_appoint.sdl b/cesar/cp/av/cco/action/doc/fsm_handover_sta_appoint.sdl
index 1230377829..1230377829 100644
--- a/cesar/cp/cco/action/doc/fsm_handover_sta_appoint.sdl
+++ b/cesar/cp/av/cco/action/doc/fsm_handover_sta_appoint.sdl
diff --git a/cesar/cp/cco/action/doc/handover_cco.sdl b/cesar/cp/av/cco/action/doc/handover_cco.sdl
index d52883fb2d..d52883fb2d 100644
--- a/cesar/cp/cco/action/doc/handover_cco.sdl
+++ b/cesar/cp/av/cco/action/doc/handover_cco.sdl
diff --git a/cesar/cp/cco/action/doc/handover_sta.sdl b/cesar/cp/av/cco/action/doc/handover_sta.sdl
index 30c53276ee..30c53276ee 100644
--- a/cesar/cp/cco/action/doc/handover_sta.sdl
+++ b/cesar/cp/av/cco/action/doc/handover_sta.sdl
diff --git a/cesar/cp/cco/action/doc/leave.sdl b/cesar/cp/av/cco/action/doc/leave.sdl
index 75a83c35c5..75a83c35c5 100644
--- a/cesar/cp/cco/action/doc/leave.sdl
+++ b/cesar/cp/av/cco/action/doc/leave.sdl
diff --git a/cesar/cp/cco/action/doc/nek_change.sdl b/cesar/cp/av/cco/action/doc/nek_change.sdl
index 1af935d7e0..1af935d7e0 100644
--- a/cesar/cp/cco/action/doc/nek_change.sdl
+++ b/cesar/cp/av/cco/action/doc/nek_change.sdl
diff --git a/cesar/cp/cco/action/doc/snid.sdl b/cesar/cp/av/cco/action/doc/snid.sdl
index c8b1edce9a..c8b1edce9a 100644
--- a/cesar/cp/cco/action/doc/snid.sdl
+++ b/cesar/cp/av/cco/action/doc/snid.sdl
diff --git a/cesar/cp/cco/action/doc/tei.sdl b/cesar/cp/av/cco/action/doc/tei.sdl
index c372d320b0..c372d320b0 100644
--- a/cesar/cp/cco/action/doc/tei.sdl
+++ b/cesar/cp/av/cco/action/doc/tei.sdl
diff --git a/cesar/cp/cco/action/handover.h b/cesar/cp/av/cco/action/handover.h
index a585498b9f..064b3abd09 100644
--- a/cesar/cp/cco/action/handover.h
+++ b/cesar/cp/av/cco/action/handover.h
@@ -1,5 +1,5 @@
-#ifndef cp_cco_action_handover_h
-#define cp_cco_action_handover_h
+#ifndef cp_av_cco_action_handover_h
+#define cp_av_cco_action_handover_h
/* Cesar project {{{
*
* Copyright (C) 2009 Spidcom
@@ -38,14 +38,14 @@ BEGIN_DECLS
* In the other case a hard handover is initiated.
*/
void
-cp_cco_action_handover__start (cp_t *ctx);
+cp_av_cco_action_handover__start (cp_t *ctx);
/**
* Start the handover.
* \param ctx the module context.
*/
void
-cp_cco_action_handover__discover_done (cp_t *ctx);
+cp_av_cco_action_handover__discover_done (cp_t *ctx);
/**
* Received the cc_handover_cnf from the peer station.
@@ -56,7 +56,7 @@ cp_cco_action_handover__discover_done (cp_t *ctx);
* request or abort it.
*/
void
-cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
+cp_av_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
cp_mme_rx_t *mme);
/**
@@ -64,14 +64,14 @@ cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
* \param ctx the module context.
*/
void
-cp_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx);
+cp_av_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx);
/**
* The procedure timeout for the cc_handover_cnf.
* \param ctx the module context.
*/
void
-cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx);
+cp_av_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx);
/**
* Receives a CC_HANDOVER.RSP from the peer station.
@@ -82,7 +82,7 @@ cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx);
* countdown and insert it in the central beacon.
*/
void
-cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
+cp_av_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
cp_mme_rx_t *mme);
/**
@@ -93,8 +93,8 @@ cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
* selection set.
*/
void
-cp_cco_action_handover__hoip_countdown_expired (cp_t *ctx);
+cp_av_cco_action_handover__hoip_countdown_expired (cp_t *ctx);
END_DECLS
-#endif /* cp_cco_action_handover_h */
+#endif /* cp_av_cco_action_handover_h */
diff --git a/cesar/cp/av/cco/action/inc/cco_action.h b/cesar/cp/av/cco/action/inc/cco_action.h
new file mode 100644
index 0000000000..f47bca7a93
--- /dev/null
+++ b/cesar/cp/av/cco/action/inc/cco_action.h
@@ -0,0 +1,77 @@
+#ifndef cp_av_cco_inc_cco_action_h
+#define cp_av_cco_inc_cco_action_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/cco/inc/cco_action.h
+ * \brief CCo private functions.
+ * \ingroup cp_cco
+ *
+ */
+#include "lib/set.h"
+#include "lib/rnd.h"
+
+#include "cp/msg/msg.h"
+#include "cp/sta/core/core.h"
+#include "cp/sta/core/defs.h"
+#include "cp/cco/action/cco_action.h"
+
+/* Timeout value for the EKS exchange MME. */
+#define CP_CCO_ACTION_EKS_TIMEOUT_MS 1000
+
+BEGIN_DECLS
+
+/**
+ * Search for an available TEI in the AVLN list.
+ * \param ctx the module context.
+ * \return return the TEI found.
+ *
+ * Get the AVLN from the station manager (our AVLN). Lookup in the station
+ * a hole of TEIs. It no hole is found and no more STAs are available
+ * it means that all the TEIs are used in the AVLN. \Warn The TEI = 0
+ * is reserved and 255 too
+ */
+cp_tei_t
+cp_av_cco_action_tei_compute (cp_t *ctx);
+
+/**
+ * Return true if the left node is lesser than the right node.
+ * \param left The left node.
+ * \param right The right node.
+ * \return true if left is lesser than right.
+ *
+ * This function shall compare the expiration lease of the stations
+ */
+bool
+cp_av_cco_action_tei_lease_less (set_node_t * left, set_node_t * right);
+
+
+/**
+ * Removes a station from the CCo selection procedure.
+ * \param ctx the module context.
+ * \param sta the station to remove.
+ *
+ * This function shall remove a station from the CCO selection procedure. It
+ * shall be called when the station refuse to become the New CCo or a timeout
+ * on the handover procedure.
+ */
+void
+cp_av_cco_action_cco_selection__sta_remove (cp_t *ctx, cp_sta_t *sta);
+
+/**
+ * Selects the Next CCo on the AVLN.
+ * \param ctx the module context.
+ * \return the station elected or NULL.
+ */
+cp_sta_t *
+cp_av_cco_action_cco_selection__selection (cp_t *ctx);
+
+END_DECLS
+
+#endif /* cp_av_cco_inc_cco_action_h */
+
diff --git a/cesar/cp/av/cco/action/src/cco_action.c b/cesar/cp/av/cco/action/src/cco_action.c
new file mode 100644
index 0000000000..0bba780ee6
--- /dev/null
+++ b/cesar/cp/av/cco/action/src/cco_action.c
@@ -0,0 +1,1509 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/cco/action/src/cco_action.c
+ * \brief CCo Action functions.
+ * \ingroup cp_av_cco
+ *
+ */
+#include <string.h>
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+
+#include "lib/set.h"
+#include "lib/utils.h"
+#include "lib/rnd.h"
+#include "lib/slab.h"
+
+#include "common/defs/ethernet.h"
+
+#include "cl/cl_mactotei.h"
+
+#include "mac/common/timings.h"
+
+#include "cp/defs.h"
+#include "cp/cp.h"
+#include "cp/fsm/fsm.h"
+#include "cp/msg/msg.h"
+
+#include "cp/cco/action/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/sta/mgr/net.h"
+#include "cp/sta/mgr/sta.h"
+#include "cp/beacon/beacon.h"
+#include "cp/av/beacon/discover.h"
+#include "cp/sta/core/core.h"
+#include "cp/beacon/beacon.h"
+#include "cp/cco/region/region.h"
+#include "cp/av/cco/region/region.h"
+#include "cp/cco/bw/bw.h"
+#include "cp/av/cco/bw/bw.h"
+#include "cp/av/beacon/beacon.h"
+
+#include "cp/inc/context.h"
+#include "cp/inc/trace.h"
+#include "cp/cco/action/inc/cco_action.h"
+#include "cp/av/cco/action/inc/cco_action.h"
+
+#include "bsu/bsu.h"
+
+/**
+ * Progam a timer to post a cco__nek_change event
+ * \param ctx the module context.
+ */
+static void
+cp_av_cco_action_nek_change_timer_program (cp_t *ctx)
+{
+ /* Prepare next change. */
+ cp_fsm_event_t *event =
+ cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_cco__nek_change);
+ cp_sta_core_gen_timed_event (ctx, &ctx->cco_action.nek_change,
+ event, HPAV_NEK_CHANGE_MS);
+}
+
+/**
+ * Choose a SNID between the ones available.
+ * \param ctx the CP context.
+ */
+static cp_snid_t
+cp_av_cco_action_snid_choose (cp_t *ctx)
+{
+ u16 flags;
+ u16 table [16];
+ uint nb_elem;
+ uint i;
+ dbg_assert (ctx);
+
+ // Get the present flags.
+ flags = ~cp_sta_mgr_get_present_snids (ctx);
+
+ // fill the table.
+ for (i = 0, nb_elem = 0; i < 16; i++)
+ {
+ if ((flags >> i) & true)
+ {
+ table[nb_elem] = i;
+ nb_elem ++;
+ }
+ }
+
+
+ // Chose the new SNID.
+ i = lib_rnd32 (&ctx->rnd) % nb_elem;
+
+ return table[i];
+}
+
+/**
+ * Function to sort the station in the CCo selection set.
+ * \param left the left node.
+ * \param right the right node.
+ */
+static inline bool
+cp_av_cco_action_cco_selection__less (heap_node_t *left, heap_node_t *right)
+{
+ cp_sta_t *stal;
+ cp_sta_t *star;
+
+ dbg_assert (left);
+ dbg_assert (right);
+
+ stal = PARENT_OF (cp_sta_t, cco_selection_node, left);
+ star = PARENT_OF (cp_sta_t, cco_selection_node, right);
+
+ if (stal->cco_cap > star->cco_cap)
+ return true;
+ return false;
+}
+
+
+/**
+ * Search for an available TEI in the AVLN list.
+ * \param ctx the module context.
+ * \return return the TEI found.
+ *
+ */
+cp_tei_t
+cp_av_cco_action_tei_compute (cp_t *ctx)
+{
+ uint row;
+ uint tei;
+ uint i;
+ dbg_assert (ctx);
+
+ for (i = MAC_TEI_STA_MIN; MAC_TEI_IS_STA (i); i++)
+ {
+ row = i / CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS;
+ tei = ctx->cco_action.tei_flags[row] >>
+ ((i % CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS)- 1);
+ if ((tei & true) == false)
+ {
+ tei = i;
+ cp_av_cco_action_tei_in_use (ctx, tei);
+ break;
+ }
+ else
+ tei = MAC_TEI_UNASSOCIATED;
+ }
+
+ // No TEI are available.
+ return tei;
+}
+
+void
+cp_av_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei)
+{
+ uint row;
+
+ dbg_assert (ctx);
+ dbg_assert (MAC_TEI_IS_STA (tei));
+
+ row = tei / CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS;
+
+ ctx->cco_action.tei_flags[row] |= (1 << ((tei
+ % CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS) - 1));
+}
+
+void
+cp_av_cco_action_tei_clear (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ memset (&ctx->cco_action.tei_flags, 0,
+ sizeof (uint) * CP_CCO_ACTION_TEI_FLAGS_ROW);
+}
+
+/**
+ * Start common operations.
+ * \param ctx the CP context.
+ *
+ * This should promote the station as CCo.
+ * Program the nek change timer.
+ * Untrack the old CCo.
+ * Update beacon module.
+ * Initialise the discover procedure.
+ */
+static void
+cp_av_cco_action_cco_start_common (cp_t *ctx)
+{
+ /* Set the CCo status in the station own data. */
+ cp_sta_own_data_set_authenticated_status (ctx, true);
+ cp_sta_own_data_set_cco_status (ctx, true);
+ // Program the timer to change the NEKs.
+ cp_av_cco_action_nek_change_timer_program (ctx);
+ cp_beacon_process_untracked_avln (ctx);
+ cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
+ bsu_update_nid_snid (ctx->bsu, cp_net_get_nid (ctx, net),
+ cp_net_get_snid (ctx, net));
+ cp_beacon_cco_update_beacon_data (ctx);
+ cp_beacon_reconfigure_timer (ctx, true);
+ cp_av_beacon_discover_init (ctx);
+}
+
+/**
+ * Start to act as a CCo coming from the unassociated state.
+ * \param ctx the module context.
+ *
+ * This function shall:
+ * - Choose a TEI if the station don't have one yet.
+ * - Create and set our AVLN in the station manager.
+ * - Generate the current NEK and order to change it.
+ * - Clear schedules and set the network mode to CSMA_ONLY.
+ * - Set the station's CCo and authenticate status.
+ * - Program the NEK change timer.
+ * - Clear tracking data.
+ * - Update the beacon for BSU.
+ * - Initialise the discover procedure context.
+ */
+static void
+cp_av_cco_action_start (cp_t *ctx)
+{
+ cp_tei_t tei;
+ cp_net_t *net;
+ cp_nid_t nid;
+ cp_snid_t snid;
+ dbg_assert (ctx);
+ /* Verify if the station does not already have a TEI. */
+ snid = cp_sta_own_data_get_snid (ctx);
+ nid = cp_sta_own_data_get_nid (ctx);
+ if (!cp_sta_own_data_get_tei(ctx))
+ {
+ tei = cp_av_cco_action_tei_compute (ctx);
+ cp_sta_own_data_set_tei (ctx, tei);
+ /* Clear the AVLN. */
+ cp_sta_mgr_remove_avln (ctx, snid, nid);
+ }
+ /* Set our AVLN. */
+ net = cp_sta_mgr_add_avln (ctx, snid, nid);
+ cp_sta_mgr_set_our_avln (ctx, net);
+ cp_cco_action_gen_nek_now (ctx);
+ /* Reinitialise schedules and regions. */
+ cp_cco_region_alloc_clean (ctx, &ctx->region.region_list);
+ cp_av_cco_region_default (ctx);
+ cp_cco_bw_alloc_clean (ctx, &ctx->bw.alloc_list);
+ cp_av_cco_bw_schedules_default (ctx);
+ /* Set network mode as CSMA only mode. */
+ cp_net_set_nm (ctx, net, MAC_NM_CSMA_ONLY);
+ /* Set hybrid mode to Full hybrid mode. */
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (ctx);
+ own->hybrid_mode = MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
+ cp_av_cco_action_cco_start_common (ctx);
+}
+
+/**
+ * Stop acting as a CCo and become a simple station.
+ * \param ctx the module context.
+ *
+ * This function shall:
+ * - Change the station CCo status.
+ * - Stop the NEK timer.
+ * - Clear the TEI table attribution.
+ * - Clear the CCo selection context (handover).
+ * - Reconfigure becon timer.
+ * - Update the beacon to act as a STA.
+ * - Uninitialise discover procedure.
+ */
+static void
+cp_av_cco_action_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Change the CCo status to false, the station leave the CCo status. */
+ cp_sta_own_data_set_cco_status (ctx, false);
+ /* Stop the timer for the NEK generation keys. */
+ cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.nek_change);
+ /* clear the TEI list. */
+ cp_av_cco_action_tei_clear (ctx);
+ cp_av_cco_action_cco_selection__clear (ctx);
+ cp_beacon_reconfigure_timer (ctx, false);
+ cp_av_beacon_sta_update_beacon_data (ctx);
+ cp_av_beacon_discover_uninit (ctx);
+}
+
+
+/**
+ * initialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_av_cco_action_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ memset (&ctx->cco_action, 0, sizeof (cp_cco_action_t));
+
+ /* Initialise the SET. */
+ heap_init (&ctx->cco_action.selection_heap,
+ cp_av_cco_action_cco_selection__less);
+ /* Create default region. */
+ cp_av_cco_region_default (ctx);
+}
+
+/**
+ * Uninitialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_av_cco_action_uninit (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ cp_av_cco_action_cco_selection__clear (ctx);
+}
+
+void
+cp_av_cco_action_ucco_start (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_cco_action_start (ctx);
+}
+
+void
+cp_av_cco_action_ucco_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_cco_action_stop (ctx);
+ cp_sta_own_data_set_authenticated_status (ctx, false);
+ /* Set our AVLN as null. */
+ cp_sta_mgr_set_our_avln (ctx, NULL);
+ /* Leave our TEI. */
+ cp_sta_own_data_set_tei (ctx, MAC_TEI_UNASSOCIATED);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
+}
+
+void
+cp_av_cco_action_ucco__to_cco (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
+}
+
+void
+cp_av_cco_action_cco__to_ucco (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_ucco);
+}
+
+void
+cp_av_cco_action_cco__unassoc_start (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Take a snid. */
+ cp_snid_t snid = cp_av_cco_action_snid_choose (ctx);
+ cp_sta_own_data_set_snid (ctx, snid);
+ bsu_power_on (ctx->bsu, snid);
+ cp_av_cco_action_start (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
+}
+
+void
+cp_av_cco_action_cco__assoc_start (cp_t *ctx)
+{
+ cp_av_cco_action_cco_start_common (ctx);
+ /* Clear tracking data. */
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
+}
+
+void
+cp_av_cco_action_cco__assoc_stop (cp_t *ctx)
+{
+ cp_av_cco_action_stop (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_become_sta);
+}
+
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_cco_action_stop (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
+}
+
+/**
+ * Change the SNID.
+ * \param ctx the module context.
+ *
+ * It shall request the SNIDs in use from the station manager to choose
+ * one randomly in the available SNIDs
+ */
+void
+cp_av_cco_action_cco__cco_snid_conflict (cp_t *ctx)
+{
+ cp_snid_t snid;
+ dbg_assert (ctx);
+
+ snid = cp_av_cco_action_snid_choose (ctx);
+
+ // Provide the SNID to the beacon module.
+ cp_beacon_change_snid (ctx, snid);
+}
+
+/**
+ * manage explicit leave request of a station.
+ * \param ctx the module context.
+ * \param sta provided by the garbage function to send a CC_LEAVE_IND.
+ *
+ * Remove the station from the station manager.
+ * \warn It does not release the reference of the station provided
+ * in parameters.
+ */
+void
+cp_av_cco_action_tei_expired (cp_t *ctx, cp_sta_t *sta)
+{
+ cp_mme_peer_t peer;
+ cp_net_t *net;
+
+ dbg_assert (ctx);
+
+ /* Get the network of the station. */
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ cp_sta_get_peer (sta, &peer);
+
+ cp_msg_cc_leave_ind_send (ctx, &peer,
+ CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
+ cp_net_get_nid(ctx, net));
+ CP_TRACE (CCO_TEI_EXPIRED, TRACE_U64 (peer.mac), peer.tei);
+
+ cp_av_cco_action_cco_sta_leave_send_tei_map (ctx, sta);
+ cp_sta_mgr_release_station (ctx, cp_sta_get_tei (sta));
+}
+
+/**
+ * perform garbage actions of CCo's responsibility.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_garbage (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ cp_sta_t *sta_next;
+ cp_net_t *net;
+ dbg_assert (ctx);
+
+ if (cp_sta_own_data_get_tei (ctx))
+ {
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ while (sta)
+ {
+ slab_addref (sta);
+ sta_next = cp_net_sta_get_next (ctx, net, sta);
+ u32 date_ms = cp_sta_core_get_date_ms (ctx);
+ if (less_mod2p32(sta->tei_lease_date_ms, date_ms)
+ || less_mod2p32 (sta->expired_date_ms, date_ms))
+ {
+ // Remove the node from the tei lease.
+ cp_av_cco_action_tei_expired (ctx, sta);
+ }
+ slab_release (sta);
+ sta = sta_next;
+ }
+
+ cp_sta_mgr__assoc__timeout (ctx, cp_sta_core_get_date_ms (ctx));
+ }
+}
+
+/**
+ * generate a new NEK value.
+ * \param ctx the module context.
+ *
+ * NEK shall be used no more than 1 hour, so must be changed after 1
+ * hour for that purpose, NEK expiration date is checked at every occurrence
+ * of the global garbage collector timer and if current NEK expiration
+ * date reached, a new NEK value shall be generated by calling this function
+ */
+void
+cp_av_cco_action_cco__cco_nek_change (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_secu_generate_key (ctx, lib_rnd32 (&ctx->rnd),
+ CP_SECU_PBKDF1_ITERATION_NEK,
+ &ctx->cco_action.nek_new);
+
+ /* Prepare next change. */
+ cp_av_cco_action_nek_change_timer_program (ctx);
+ /* POST the FSM event. */
+ cp_fsm_post_new_event (ctx, bare, cco_nek_change__nek_provide);
+}
+
+/**
+ * Send the SET tei map IND to all the station with the TEI of the new one.
+ * \param ctx the CP context.
+ * \param tei the tei of the station which has joined the AVLN.
+ * \param mac the station mac address.
+ */
+static void
+cp_av_cco_action_send_set_tei_map_to_new_sta (cp_t *ctx, cp_tei_t tei,
+ mac_t mac)
+{
+ cp_mme_tx_t *mme_tx;
+ cp_sta_t *sta_list;
+ cp_mme_peer_t *peer;
+ cp_net_t *net;
+
+ dbg_assert (ctx);
+ dbg_assert (tei);
+ dbg_assert (mac);
+
+ // Send unicast.
+ // It will send all the TEI MAP to the station just associated.
+ net = cp_sta_mgr_get_our_avln (ctx);
+ peer = &CP_MME_PEER (mac, tei);
+
+ // +1 For our own station which is not in the AVLN.
+ mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
+ CP_MSG_CC_SET_TEI_MAP_IND_MODE_UPDATE,
+ cp_net_get_num_stas (ctx, net) + 1);
+
+ // Add our station first.
+ cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
+ cp_sta_own_data_get_tei(ctx),
+ cp_sta_own_data_get_mac_address (ctx),
+ CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED);
+
+ sta_list = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ while (sta_list)
+ {
+ enum cp_msg_cc_set_tei_map_ind_status_t station_status;
+
+ if (cp_sta_get_authenticated (ctx, sta_list))
+ {
+ station_status =
+ CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED;
+ }
+ else if (cp_sta_get_tei (sta_list))
+ {
+ station_status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED;
+ }
+ else
+ {
+ station_status =
+ CP_MSG_CC_SET_TEI_MAP_IND_STATUS_DISASSOCIATED;
+ }
+ cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
+ cp_sta_get_tei (sta_list),
+ cp_sta_get_mac_address (sta_list),
+ station_status);
+
+ sta_list = cp_net_sta_get_next (ctx, net, sta_list);
+
+ }
+ cp_msg_cc_set_tei_map_ind_send_end (ctx, mme_tx);
+}
+
+/**
+ * Send the SET TEI MAP to all the station of the NET.
+ * \param ctx the CP context.
+ * \param tei the new station tei.
+ * \param mac the station mac address.
+ */
+static void
+cp_av_cco_action_send_set_tei_map_to_all_sta (cp_t *ctx, cp_tei_t tei,
+ mac_t mac)
+{
+ cp_mme_peer_t *peer;
+ cp_mme_tx_t *mme_tx;
+ dbg_assert (ctx);
+ dbg_assert (tei);
+ dbg_assert (mac);
+
+ peer = &CP_MME_PEER_ALL_STA;
+ mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
+ CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD, 1);
+
+ cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
+ tei, mac,
+ CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED);
+
+ cp_msg_cc_set_tei_map_ind_send_end (ctx, mme_tx);
+}
+
+/**
+ * Assoc type join.
+ * \param ctx the CP context.
+ * \param msg the assoc MME message.
+ * \param assoc the assoc data read from the MME.
+ */
+static void
+cp_av_cco_action__assoc__join (cp_t *ctx, cp_mme_rx_t *msg,
+ cp_msg_cc_assoc_req_t *assoc)
+{
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cp_tei_t tei = MAC_TEI_UNASSOCIATED;
+ cp_msg_cc_assoc_cnf_t cnf;
+
+ dbg_assert (ctx);
+ dbg_assert (msg);
+ dbg_assert (assoc);
+
+ /* Add the station to the AVLN. */
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ cnf.nid = cp_net_get_nid (ctx, net);
+ cnf.snid = cp_net_get_snid (ctx, net);
+
+ /* Try to get the TEI from the STA manager if we already know it. */
+ sta = cp_sta_mgr_sta_get_from_mac (ctx, msg->peer.mac);
+ /* If the station is known. */
+ if (sta)
+ {
+ /* If the station is currently in our AVLN/net. */
+ if (net == cp_sta_get_net (sta))
+ {
+ // The station already exists get the TEI.
+ tei = cp_sta_get_tei (sta);
+ }
+ /* Remove the station from the station manager and the mac store. */
+ cp_sta_mgr_sta_remove (ctx, sta);
+ slab_release (sta);
+ }
+ /* If the station has no TEI, try to generate one. */
+ if (!MAC_TEI_IS_STA (tei))
+ {
+ /* Try to get a TEI. */
+ tei = cp_av_cco_action_tei_compute (ctx);
+ }
+
+ /* If we manage to have a TEI, it's a success. */
+ if (MAC_TEI_IS_STA (tei))
+ {
+ cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS;
+ cnf.lease_time_min = CP_LEASE_ASSOC_MIN;
+ }
+ /* Otherwise, it's an error. */
+ else
+ {
+ cnf.result =
+ CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_TEMPORARY_RESSOURCE_EXHAUSTION;
+ }
+
+ /* Send the answer. */
+ cnf.sta_tei = tei;
+ cp_msg_cc_assoc_cnf_send (ctx, &msg->peer, &cnf);
+ CP_TRACE (CCO_ASSOC, TRACE_U64 (msg->peer.mac), tei);
+
+ if (tei)
+ {
+ /* Send TEI MAP to all STA except the new one (need to do it before
+ * adding the new STA to the STA manager). */
+ cp_av_cco_action_send_set_tei_map_to_all_sta (ctx, tei, msg->peer.mac);
+ sta = cp_sta_mgr_sta_add (ctx, net, tei, msg->peer.mac);
+ /* Add the TEI lease corresponding to an unassociated STA. */
+ cp_sta_mgr_commit_to_dataplane (ctx);
+ u32 date_ms = cp_sta_core_get_date_ms (ctx);
+ sta->tei_lease_date_ms = date_ms +
+ MAC_SEC_TO_MS(CP_LEASE_ASSOC_MIN * 60);
+
+ /* Update the last request date in the sta. */
+ cp_sta_set_assoc_confirmed (ctx, sta, false);
+ sta->assoc_req_last_ms = cp_sta_core_get_date_ms (ctx);
+ /* A new STA has joined an AVLN for the first time, generate an
+ * event. */
+ cp_fsm_event_t *event = cp_fsm_event_sta_new
+ (ctx, CP_FSM_EVENT_TYPE_new_sta_associated, net,
+ (cp_sta_t *) sta);
+ cp_fsm_post (ctx, event);
+
+ /* Release the reference on the station. */
+ slab_release (sta);
+ }
+ if (!tei)
+ {
+ sta = cp_sta_mgr_sta_add (ctx, net, 0, msg->peer.mac);
+ /* Release the reference on the station. */
+ slab_release (sta);
+ }
+}
+
+/**
+ * Assoc type renew.
+ * \param ctx the CP context.
+ * \param msg the assoc MME message.
+ * \param assoc the assoc data read from the MME.
+ */
+static void
+cp_av_cco_action__assoc__renew (cp_t *ctx, cp_mme_rx_t *msg,
+ cp_msg_cc_assoc_req_t *assoc)
+{
+ cp_net_t *net;
+ cp_sta_t *sta;
+ cp_msg_cc_assoc_cnf_t cnf;
+
+ dbg_assert (ctx);
+ dbg_assert (msg);
+ dbg_assert (assoc);
+
+ /* Add the station to the AVLN. */
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ cnf.nid = cp_net_get_nid (ctx, net);
+ cnf.snid = cp_net_get_snid (ctx, net);
+
+ /* Renew the TEI. */
+ sta = cp_sta_mgr_sta_get_assoc (ctx, net, msg->peer.tei);
+
+ if (sta)
+ {
+ /* Renew the TEI. */
+ u32 date_ms = cp_sta_core_get_date_ms (ctx);
+ sta->tei_lease_date_ms = date_ms +
+ MAC_SEC_TO_MS(CP_LEASE_AUTH_MIN * 60);
+ cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS;
+ cnf.sta_tei = cp_sta_get_tei (sta);
+ cnf.lease_time_min = CP_LEASE_AUTH_MIN;
+
+ slab_release (sta);
+ }
+ else
+ {
+ cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON;
+ cnf.sta_tei = 0;
+ cnf.lease_time_min = 0;
+ }
+
+ /* Send the answer. */
+ cp_msg_cc_assoc_cnf_send (ctx, &msg->peer, &cnf);
+ CP_TRACE (CCO_ASSOC_RENEW, TRACE_U64 (msg->peer.mac), msg->peer.tei);
+}
+
+/**
+ * Static function part.
+ * \param ctx the CP module context.
+ * \param assoc_req the MME context.
+ * \param assoc The mme in the processor format.
+ */
+static void
+cp_av_cco_action_manage_sta_assoc_common (cp_t *ctx, cp_mme_rx_t *assoc_req,
+ cp_msg_cc_assoc_req_t *assoc)
+{
+ dbg_assert (ctx);
+ dbg_assert (assoc_req);
+ dbg_assert (assoc);
+ dbg_assert (ctx->mac_store);
+
+
+ if (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
+ cp_av_cco_action__assoc__join (ctx, assoc_req, assoc);
+ else if (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_RENEW)
+ cp_av_cco_action__assoc__renew (ctx, assoc_req, assoc);
+ else
+ dbg_assert (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NB);
+}
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+ cp_msg_cc_assoc_req_t assoc;
+
+ dbg_assert (ctx);
+ dbg_assert (assoc_req);
+
+ /* Reading the data in the MME. */
+ if (cp_msg_cc_assoc_req_receive(ctx, assoc_req, &assoc))
+ cp_av_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
+}
+
+static void
+cp_av_cco_action_ucco__cc_assoc_req_common (
+ cp_t *ctx, cp_mme_rx_t * assoc_req, cp_fsm_branch_t branch_ok,
+ cp_fsm_branch_t branch_nok)
+{
+ cp_msg_cc_assoc_req_t assoc;
+ dbg_assert (ctx);
+ dbg_assert (assoc_req);
+ dbg_assert (cp_sta_own_data_get_tei (ctx));
+ dbg_assert (cp_sta_own_data_get_authenticated_status (ctx));
+ dbg_assert (cp_sta_own_data_get_cco_status (ctx));
+ /* Reading the data in the MME. */
+ cp_msg_cc_assoc_req_receive(ctx, assoc_req, &assoc);
+ /* The MME is not for the station, it shall answer to the source station
+ * with a Failure for others reason. */
+ if ((assoc.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
+ && (assoc.nid == cp_sta_own_data_get_nid (ctx)))
+ {
+ /* Become CCo. */
+ cp_av_cco_action_ucco__to_cco (ctx);
+ /* Continue the association procedure. */
+ cp_av_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
+ cp_fsm_branch_ (ctx, branch_ok);
+ }
+ else
+ cp_fsm_branch_ (ctx, branch_nok);
+}
+
+void
+cp_av_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+ cp_av_cco_action_ucco__cc_assoc_req_common (
+ ctx, assoc_req, CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, ok),
+ CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, nok));
+}
+
+void
+cp_av_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+ cp_av_cco_action_ucco__cc_assoc_req_common (
+ ctx, assoc_req, CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, ok),
+ CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, nok));
+}
+
+/**
+ * manage authentication of a station.
+ * \param ctx the module context.
+ * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
+ */
+void
+cp_av_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * get_key_req)
+{
+ cp_msg_cm_get_key_req_t req;
+ cp_msg_cm_get_key_cnf_t cnf;
+ cp_net_t *net;
+ cp_sta_t *sta;
+ memset (&cnf, 0, sizeof (cp_msg_cm_get_key_cnf_t));
+ cnf.eks = MAC_EKS_CLEAR;
+ dbg_assert (ctx);
+ dbg_assert (get_key_req);
+
+ // get the data in the payload of the mme.
+ if (cp_msg_cm_get_key_req_receive (ctx, get_key_req, &req)
+ && (cp_secu_protocol_check
+ (NULL, &get_key_req->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
+ && (req.key_type == CP_MSG_KEY_NEK)
+ && MAC_TEI_IS_STA (get_key_req->peer.tei))
+ {
+ // Get the network.
+ net = cp_sta_mgr_get_our_avln (ctx);
+ // Get the station.
+ sta = cp_sta_mgr_sta_get_assoc (ctx, net, get_key_req->peer.tei);
+
+ if (sta)
+ {
+ uint nb_sta;
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
+ cp_sta_set_assoc_confirmed (ctx, sta, true);
+
+ if (req.key_type == CP_MSG_KEY_NEK)
+ {
+ uint i;
+ uint index = bsu_nek_index_current (ctx->bsu);
+ cnf.eks = ctx->mac_config->nek[index].eks;
+ for (i = 0; i < COUNT (ctx->mac_config->nek[0].nek_enc); i++)
+ cnf.key.key[i] =
+ ctx->mac_config->nek[index].nek_enc[i];
+ }
+
+ /* Send the TEI map. */
+ nb_sta = cp_net_get_num_stas (ctx, net);
+ if (nb_sta)
+ {
+ cp_av_cco_action_send_set_tei_map_to_new_sta (ctx,
+ cp_sta_get_tei(sta),
+ get_key_req->peer.mac);
+ }
+
+ slab_release (sta);
+ }
+ else
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
+ }
+ // Refuse the request.
+ else
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
+
+ cnf.key_type = req.key_type;
+ cnf.nid = req.nid;
+ cp_secu_protocol_next (&get_key_req->prun, &ctx->rnd, true);
+ cp_msg_cm_get_key_cnf_send (ctx, &get_key_req->peer, get_key_req->peks,
+ &get_key_req->prun, &cnf);
+}
+
+void
+cp_av_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * get_key_req)
+{
+ dbg_assert (ctx);
+ dbg_assert (get_key_req);
+
+ cp_msg_cm_get_key_req_t req;
+ cp_msg_cm_get_key_cnf_t cnf;
+ memset (&cnf, 0, sizeof (cp_msg_cm_get_key_cnf_t));
+ cnf.eks = MAC_EKS_CLEAR;
+
+ if (cp_msg_cm_get_key_req_receive (ctx, get_key_req, &req)
+ && (cp_secu_protocol_check
+ (NULL, &get_key_req->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
+ && MAC_TEI_IS_STA (get_key_req->peer.tei))
+ {
+ if (req.key_type == CP_MSG_KEY_NEK)
+ {
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
+
+ uint i;
+ uint index = bsu_nek_index_next (ctx->bsu);
+ cnf.eks = ctx->mac_config->nek[index].eks;
+ for (i = 0; i < COUNT (ctx->mac_config->nek[0].nek_enc); i++)
+ cnf.key.key[i] =
+ ctx->mac_config->nek[index].nek_enc[i];
+ }
+ else
+ cnf.result =
+ CP_MSG_CM_GET_KEY_CNF_RESULT_UNSUPPORTED_METHOD_KEY_TYPE;
+ }
+ else
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
+
+ cnf.key_type = req.key_type;
+ cnf.nid = req.nid;
+ cp_secu_protocol_next (&get_key_req->prun, &ctx->rnd, true);
+ cp_msg_cm_get_key_cnf_send (ctx, &get_key_req->peer, get_key_req->peks,
+ &get_key_req->prun, &cnf);
+}
+
+void
+cp_av_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta)
+{
+ cp_mme_peer_t *peer;
+ cp_net_t *net = NULL;
+ uint status;
+ cp_mme_tx_t *mme;
+
+ dbg_assert (ctx);
+ dbg_assert (sta);
+
+ // Send the TEI MAP to the station.
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ if (!cp_net_is_empty (ctx, net))
+ {
+ peer = &CP_MME_PEER_ALL_STA;
+
+ if (cp_sta_get_authenticated (ctx, sta))
+ {
+ status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED;
+ }
+ else if (cp_sta_get_tei (sta))
+ {
+ status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED;
+ }
+ else
+ status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_DISASSOCIATED;
+
+ mme = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
+ CP_MSG_CC_SET_TEI_MAP_IND_MODE_DELETE,
+ 1);
+ cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme, cp_sta_get_tei (sta),
+ cp_sta_get_mac_address (sta),
+ status);
+ cp_msg_cc_set_tei_map_ind_send_end (ctx, mme);
+ }
+}
+
+void
+cp_av_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ cp_sta_t *sta;
+ cp_net_t *net;
+ bool res_read;
+ enum cp_msg_cc_leave_req_reason_t reason_req;
+ cp_nid_t nid;
+ enum cp_msg_cc_leave_ind_reason_t reason_ind;
+
+
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ dbg_assert (mme->peer.tei);
+
+ switch (mme->mmtype)
+ {
+ case CC_LEAVE_REQ:
+ res_read = cp_msg_cc_leave_req_receive (ctx, mme, &reason_req);
+ break;
+ case CC_LEAVE_IND:
+ res_read = cp_msg_cc_leave_ind_receive (ctx, mme, &reason_ind,
+ &nid);
+ break;
+ default:
+ dbg_assert_default ();
+ }
+
+ if (res_read)
+ {
+ net = cp_sta_mgr_get_our_avln (ctx);
+ if (mme->mmtype == CC_LEAVE_REQ)
+ cp_msg_cc_leave_cnf_send (ctx, &mme->peer);
+ else
+ cp_msg_cc_leave_rsp_send (ctx, &mme->peer);
+ /* Get the station. */
+ sta = cp_sta_mgr_sta_get_assoc (ctx, net, mme->peer.tei);
+ if (sta)
+ {
+ cp_sta_mgr_release_station (ctx, cp_sta_get_tei (sta));
+ cp_av_cco_action_cco_sta_leave_send_tei_map (ctx, sta);
+ slab_release (sta);
+ }
+ }
+}
+
+void
+cp_av_cco_action_drv_mac_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ dbg_assert (cp_sta_own_data_get_cco_status (ctx));
+
+ if (!cp_net_is_empty (ctx, cp_sta_mgr_get_our_avln (ctx))
+ && (!cp_beacon_any_countdown_active (ctx)))
+ {
+ cp_sta_t *sta;
+ cp_net_t *net;
+
+ /* Clear the SET of cco selection. */
+ cp_av_cco_action_cco_selection__clear (ctx);
+ ctx->handover.reason = CP_HANDOVER_REASON_CCO_LEAVING;
+
+ net = cp_sta_mgr_get_our_avln (ctx);
+ for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ sta;
+ sta = cp_net_sta_get_next (ctx, net, sta))
+ {
+ if (cp_sta_get_authenticated (ctx, sta))
+ cp_av_cco_action_cco_selection__mac_stop_sta_add (ctx, sta);
+ }
+
+ /* Trigger the event to start the handover CCo FSM. */
+ cp_fsm_trigger_new_event (ctx, bare, CCO_HANDOVER_START);
+ /* Trigger an event to change the Main FSM to go to the
+ * CCO_LEAVING_HOIP state. */
+ cp_fsm_trigger_new_event (ctx, bare, CCO_LEAVING_HANDOVER);
+ }
+ else if (cp_net_is_empty (ctx, cp_sta_mgr_get_our_avln (ctx))
+ && (!cp_beacon_any_countdown_active (ctx)))
+ cp_fsm_trigger_new_event (ctx, bare, cco__all_sta_leaved);
+}
+
+void
+cp_av_cco_action_drv_mac_stop_suspend (cp_t *ctx)
+{
+ cp_beacon_cco_update_beacon_data (ctx);
+ cp_av_cco_action_drv_mac_stop (ctx);
+}
+
+void
+cp_av_cco_action_drv_mac_stop_ended (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_cco_action_cco__assoc_stop (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, to_stop);
+}
+
+void
+cp_av_cco_action_ucco__to_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_cco_action_ucco_stop (ctx);
+ cp_fsm_trigger_new_event (ctx, bare, to_stop);
+}
+
+void
+cp_av_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (sta);
+
+ slab_addref (sta);
+ heap_node_init (&sta->cco_selection_node);
+ heap_insert (&ctx->cco_action.selection_heap,
+ &sta->cco_selection_node);
+}
+
+
+void
+cp_av_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
+{
+ cp_sta_own_data_t *own;
+ dbg_assert (ctx);
+ dbg_assert (net);
+ dbg_assert (sta);
+
+ if ((net == cp_sta_mgr_get_our_avln (ctx))
+ && (MAC_TEI_IS_STA (cp_sta_get_tei (sta)))
+ && (cp_sta_get_authenticated (ctx, sta)))
+ {
+ own = cp_sta_mgr_get_sta_own_data (ctx);
+ if (own->cco_prefered == false
+ && sta->cco_cap > CP_CCO_LEVEL)
+ {
+ slab_addref (sta);
+ heap_node_init (&sta->cco_selection_node);
+ heap_insert (&ctx->cco_action.selection_heap,
+ &sta->cco_selection_node);
+ }
+ }
+}
+
+void
+cp_av_cco_action_cco_selection__sta_remove (cp_t *ctx, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (sta);
+
+ dbg_assert (!heap_empty (&ctx->cco_action.selection_heap));
+
+ heap_remove (&ctx->cco_action.selection_heap, &sta->cco_selection_node);
+ heap_node_init (&sta->cco_selection_node);
+ slab_release (sta);
+}
+
+void
+cp_av_cco_action_cco_selection__clear (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ heap_node_t *node;
+
+ dbg_assert (ctx);
+
+ /* Verify the set. */
+ while (!heap_empty (&ctx->cco_action.selection_heap))
+ {
+ node = heap_get_root (&ctx->cco_action.selection_heap);
+ dbg_assert (node);
+
+ sta = PARENT_OF (cp_sta_t, cco_selection_node, node);
+ dbg_assert (sta);
+
+ /* Remove the node from the heap. */
+ heap_remove (&ctx->cco_action.selection_heap, &sta->cco_selection_node);
+ heap_node_init (&sta->cco_selection_node);
+ slab_release (sta);
+ }
+}
+
+cp_sta_t *
+cp_av_cco_action_cco_selection__selection (cp_t *ctx)
+{
+ cp_sta_own_data_t *own;
+ cp_sta_t *sta = NULL;
+ heap_node_t *node;
+ dbg_assert (ctx);
+
+ own = cp_sta_mgr_get_sta_own_data (ctx);
+
+ if ((!own->cco_prefered)
+ && (!heap_empty (&ctx->cco_action.selection_heap)))
+ {
+ node = heap_get_root (&ctx->cco_action.selection_heap);
+ dbg_assert (node);
+
+ sta = PARENT_OF (cp_sta_t, cco_selection_node, node);
+ dbg_assert (sta);
+ slab_addref (sta);
+ }
+
+ return sta;
+}
+
+void
+cp_av_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ /* Check received MME. */
+ cp_msg_cc_assoc_req_t req;
+ if (!cp_msg_cc_assoc_req_receive (ctx, mme, &req))
+ {
+ /* Error in the MME, do nothing. */
+ }
+ else
+ {
+ if (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
+ {
+ /* Request of association. */
+ /* Peer is SC? */
+ if (mme->peer.mac == ctx->sta_action.sc.peer.mac)
+ {
+ /* Ok, reply */
+ cp_av_cco_action__assoc__join (ctx, mme, &req);
+ cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (ctx, ctx->sta_action.sc.peer.mac);
+ ctx->sta_action.sc.peer.tei = cp_sta_get_tei (sta);
+ slab_release (sta);
+ }
+ else
+ {
+ /* Deny assoc request. */
+ cp_msg_cc_assoc_cnf_t cnf;
+ cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON;
+ /* Get our net. */
+ cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
+ /* Set NID/SNID. */
+ cnf.nid = cp_net_get_nid (ctx, net);
+ cnf.snid = cp_net_get_snid (ctx, net);
+ /* No TEI for the STA. */
+ cnf.sta_tei = 0;
+ /* Lease default value. */
+ cnf.lease_time_min = CP_LEASE_ASSOC_MIN;
+ /* Send reply. */
+ cp_msg_cc_assoc_cnf_send (ctx, &mme->peer, &cnf);
+ }
+ }
+ else if (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_RENEW)
+ /* Renew is ok. */
+ cp_av_cco_action__assoc__renew (ctx, mme, &req);
+ else
+ /* Should not occur. */
+ dbg_assert (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NB);
+ }
+}
+
+void
+cp_av_cco_action_handover__ended (cp_t *ctx)
+{
+ cp_av_cco_action_cco_selection__clear (ctx);
+ cp_av_cco_action_cco__assoc_stop (ctx);
+}
+
+/**
+ * Last transaction ends try next STA.
+ * \param ctx the module context.
+ * \return The next station to start a transaction with.
+ */
+static cp_sta_t*
+cp_av_cco_action_nek_next_sta (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ cp_sta_t *sta_next;
+ cp_net_t *net;
+ dbg_assert (ctx);
+
+ net = cp_sta_mgr_get_our_avln (ctx);
+
+ if ((sta = cp_sta_mgr_sta_get_from_mac (ctx,
+ ctx->cco_action.eks_sta_current_peer.mac)))
+ {
+ sta_next = cp_net_sta_get_next (ctx, net, sta);
+
+ if (sta_next)
+ {
+ cp_sta_get_peer (sta_next, &ctx->cco_action.eks_sta_current_peer);
+ return sta_next;
+ }
+ return NULL;
+ }
+
+ return NULL;
+}
+
+/**
+ * Request the station for the NEK change.
+ * \param ctx the module context.
+ * \param sta the station to start the NEK exchange.
+ */
+static void
+cp_av_cco_action_nek_change_start_transaction (cp_t *ctx, cp_sta_t *sta)
+
+{
+ cp_msg_cm_set_key_req_t data;
+ cp_fsm_event_t *event;
+
+ dbg_assert (ctx);
+ dbg_assert (sta);
+
+ /* Get the station peer to send the MME. */
+ cp_sta_get_peer (sta, &ctx->cco_action.eks_sta_current_peer);
+
+ /* Initialise the protocol run. */
+ cp_secu_protocol_run_new (&ctx->cco_action.eks_prun, 1,
+ &ctx->rnd);
+
+ /* Fill the data structure with key type == NONCE_ONLY. */
+ memset (&data, 0, sizeof (cp_msg_cm_set_key_req_t));
+ data.key_type = CP_MSG_KEY_NONCE_ONLY;
+ data.cco_cap = CP_CCO_LEVEL;
+ data.nid = cp_sta_own_data_get_nid (ctx);
+
+ /* Send the MME. */
+ cp_msg_cm_set_key_req_send (ctx,
+ &ctx->cco_action.eks_sta_current_peer,
+ CP_MME_PEKS_NONE,
+ &ctx->cco_action.eks_prun,
+ &data);
+
+ /* Start the timeout timer. */
+ event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_cco_nek_change__nek_timeout);
+ cp_sta_core_gen_timed_event(ctx,
+ &ctx->cco_action.eks_timer,
+ event,
+ CP_CCO_ACTION_EKS_TIMEOUT_MS);
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx)
+{
+ cp_net_t *net;
+ cp_sta_t *sta;
+ dbg_assert (ctx);
+ net = cp_sta_mgr_get_our_avln (ctx);
+ sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
+ /* If the current STA is not authenticated, it is not necessary to send
+ * the MME. */
+ while (sta && !cp_sta_get_authenticated (ctx, sta))
+ sta = cp_net_sta_get_next (ctx, net, sta);
+ if (sta)
+ {
+ cp_av_cco_action_nek_change_start_transaction (ctx, sta);
+ slab_release (sta);
+ /* Change branch. */
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_IDLE, cco_nek_change__nek_provide, sta);
+ }
+ else
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_IDLE, cco_nek_change__nek_provide, nosta);
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ dbg_assert (ctx);
+
+ /* Stop the time out timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
+
+ if ((sta = cp_av_cco_action_nek_next_sta (ctx)))
+ {
+ cp_av_cco_action_nek_change_start_transaction (ctx, sta);
+ slab_release (sta);
+
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_WAIT_STA_CNF,
+ cco_nek_change__nek_timeout, yes);
+ }
+ else
+ {
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_WAIT_STA_CNF,
+ cco_nek_change__nek_timeout, no);
+ }
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__timeout (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ dbg_assert (ctx);
+
+ /* Stop the time out timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
+
+ if ((sta = cp_av_cco_action_nek_next_sta (ctx)))
+ {
+ cp_av_cco_action_nek_change_start_transaction (ctx, sta);
+ slab_release (sta);
+
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
+ cco_nek_change__nek_timeout, yes);
+ }
+ else
+ {
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
+ cco_nek_change__nek_timeout, no);
+ }
+}
+
+void
+cp_av_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ cp_msg_cm_set_key_cnf_t data;
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ /* Stop the time out timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
+
+ if ((cp_msg_cm_set_key_cnf_receive (ctx, mme, &data)
+ && (cp_secu_protocol_check
+ (&ctx->cco_action.eks_prun, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT)))
+ && ((mme->prun.pid == 1) && (mme->prun.pmn == 2)))
+ {
+ uint i;
+ cp_msg_cm_set_key_req_t data_req;
+ cp_fsm_event_t *event;
+
+ data_req.key_type = CP_MSG_KEY_NEK;
+ data_req.cco_cap = CP_CCO_LEVEL;
+ data_req.nid = cp_sta_own_data_get_nid (ctx);
+ data_req.new_eks = CP_CCO_ACTION_EKS_NEXT
+ (ctx->cco_action.eks_current);
+ for (i = 0; i < COUNT (ctx->cco_action.nek_new.key); i++)
+ data_req.new_key.key[i] = ctx->cco_action.nek_new.key[i];
+
+
+ /* Prepare the EKS NEK exchange. */
+ ctx->cco_action.eks_prun = mme->prun;
+ cp_secu_protocol_next (&ctx->cco_action.eks_prun, &ctx->rnd,
+ false /* not last*/);
+
+ cp_msg_cm_set_key_req_send (ctx,
+ &ctx->cco_action.eks_sta_current_peer,
+ CP_MME_PEKS_NMK,
+ &ctx->cco_action.eks_prun,
+ &data_req);
+
+ /* Start the timeout timer. */
+ event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_cco_nek_change__nek_timeout);
+ cp_sta_core_gen_timed_event(ctx,
+ &ctx->cco_action.eks_timer,
+ event,
+ CP_CCO_ACTION_EKS_TIMEOUT_MS);
+ }
+ /* Last message or error, try the next station.
+ * If it was an error the STA is responsible to request the key when it
+ * see the EKS bentry in the central beacon. */
+ else
+ {
+ cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (ctx, mme->peer.mac);
+ cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
+ sta = cp_net_sta_get_next (ctx, net, sta);
+ /* If the current STA is not authenticated, it is not necessary to send
+ * the MME. */
+ while (sta && !cp_sta_get_authenticated (ctx, sta))
+ sta = cp_net_sta_get_next (ctx, net, sta);
+ if (sta)
+ {
+ cp_av_cco_action_nek_change_start_transaction (ctx, sta);
+ slab_release (sta);
+
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
+ CM_SET_KEY_CNF_PID1, ok_continue);
+ }
+ else
+ {
+ cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
+ CM_SET_KEY_CNF_PID1, end);
+ }
+ }
+}
+
+void
+cp_av_cco_action_nek_change_prevent (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ /* If there is no new EKS then do not change it.
+ * This disallow the stations to store a false nek in mac config. */
+ if (cp_sta_own_data_get_cco_status (ctx))
+ {
+ cp_beacon_change_nek (ctx,
+ CP_CCO_ACTION_EKS_NEXT(ctx->cco_action.eks_current),
+ ctx->cco_action.nek_new,
+ false /* central beacon change. */);
+
+ /* Set the EKS_current to the new one. */
+ ctx->cco_action.eks_current =
+ CP_CCO_ACTION_EKS_NEXT(ctx->cco_action.eks_current);
+ }
+}
+
+void
+cp_av_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net,
+ cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ cp_mme_peer_t peer;
+ cp_sta_get_peer (sta, &peer);
+ cp_msg_cc_discover_list_req_send (ctx, &peer);
+}
+
+void
+cp_av_cco_action_beacon_with_same_nid (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (beacon);
+
+ /* If we have the highest mac address we do nothing. */
+ if (beacon->bmis.mac_address.present)
+ if (MAC_REVERSE (beacon->bmis.mac_address.mac_address) <
+ MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx)))
+ return;
+
+ /* To merge the two avlns we shut our network by turning the cco into
+ * an unassociated sta. */
+ cp_fsm_post_new_event (ctx, bare, cco_leave_merge_avln);
+}
diff --git a/cesar/cp/cco/action/src/handover.c b/cesar/cp/av/cco/action/src/handover.c
index 00182014c2..e1188e7d49 100644
--- a/cesar/cp/cco/action/src/handover.c
+++ b/cesar/cp/av/cco/action/src/handover.c
@@ -15,11 +15,15 @@
#include "common/std.h"
#include "cp/cp.h"
#include "cp/cco/action/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
+#include "cp/av/cco/action/inc/cco_action.h"
#include "cp/msg/msg.h"
#include "cp/sta/mgr/sta_mgr.h"
#include "cp/sta/action/action.h"
#include "cp/msg/msg.h"
#include "cp/fsm/fsm.h"
+#include "cp/av/beacon/beacon.h"
+#include "cp/av/sta/action/assoc.h"
#include "cp/inc/context.h"
@@ -31,7 +35,7 @@
* Prepare and send a cc_handover.req MME to the peer station.
*/
static inline void
-cp_cco_action_handover__cc_handover_req_prepare (cp_t *ctx,
+cp_av_cco_action_handover__cc_handover_req_prepare (cp_t *ctx,
cp_sta_t *sta)
{
dbg_assert (ctx);
@@ -88,17 +92,17 @@ cp_cco_action_handover__cc_handover_req_prepare (cp_t *ctx,
* selection set.
*/
static inline bool
-cp_cco_action_handover__try_next_sta (cp_t *ctx)
+cp_av_cco_action_handover__try_next_sta (cp_t *ctx)
{
cp_sta_t *cco;
dbg_assert (ctx);
/* Get the new station. */
- cco = cp_cco_action_cco_selection__selection (ctx);
+ cco = cp_av_cco_action_cco_selection__selection (ctx);
if (cco)
{
- cp_cco_action_handover__cc_handover_req_prepare (ctx, cco);
+ cp_av_cco_action_handover__cc_handover_req_prepare (ctx, cco);
slab_release (cco);
return true;
@@ -108,7 +112,7 @@ cp_cco_action_handover__try_next_sta (cp_t *ctx)
}
void
-cp_cco_action_handover__start (cp_t *ctx)
+cp_av_cco_action_handover__start (cp_t *ctx)
{
cp_sta_t *sta;
dbg_assert (ctx);
@@ -116,11 +120,11 @@ cp_cco_action_handover__start (cp_t *ctx)
if (!cp_beacon_any_countdown_active (ctx))
{
/* Get the best station to be elect as CCo. */
- sta = cp_cco_action_cco_selection__selection (ctx);
+ sta = cp_av_cco_action_cco_selection__selection (ctx);
if (sta)
{
- cp_cco_action_handover__cc_handover_req_prepare (ctx, sta);
+ cp_av_cco_action_handover__cc_handover_req_prepare (ctx, sta);
slab_release (sta);
cp_fsm_branch (ctx, CCO_HANDOVER_IDLE, CCO_HANDOVER_START, sta);
}
@@ -135,14 +139,14 @@ cp_cco_action_handover__start (cp_t *ctx)
}
else
{
- cp_cco_action_cco_selection__clear (ctx);
+ cp_av_cco_action_cco_selection__clear (ctx);
cp_fsm_branch (ctx, CCO_HANDOVER_IDLE, CCO_HANDOVER_START, no_sta);
}
}
void
-cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
{
cp_mme_tx_t *mme_tx;
cp_net_t *net;
@@ -165,7 +169,7 @@ cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
net = cp_sta_mgr_get_our_avln (ctx);
/* Set the handover flag in the central beacon. */
- cp_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_TRUE);
+ cp_av_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_TRUE);
/* All the AVLN stations without the new CCo STA.
* cp_net_num_sta_associated returns the number of associated stations
@@ -215,10 +219,10 @@ cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
else
{
if (sta)
- cp_cco_action_cco_selection__sta_remove (ctx, sta);
+ cp_av_cco_action_cco_selection__sta_remove (ctx, sta);
/* Try another station to become the new CCo. */
- res = cp_cco_action_handover__try_next_sta (ctx);
+ res = cp_av_cco_action_handover__try_next_sta (ctx);
if (res)
/* The new station has been requested, the current station shall
@@ -250,7 +254,7 @@ cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
* \return true if another station has been requested.
*/
static inline bool
-cp_cco_action_handover__timeout (cp_t *ctx)
+cp_av_cco_action_handover__timeout (cp_t *ctx)
{
bool res;
cp_sta_t *sta;
@@ -262,23 +266,23 @@ cp_cco_action_handover__timeout (cp_t *ctx)
&ctx->handover.handover_timeout);
/* Remove the first station of the selection set. This station timed out. */
- sta = cp_cco_action_cco_selection__selection (ctx);
- cp_cco_action_cco_selection__sta_remove (ctx, sta);
+ sta = cp_av_cco_action_cco_selection__selection (ctx);
+ cp_av_cco_action_cco_selection__sta_remove (ctx, sta);
slab_release (sta);
/* Reset the handover flag in the central beacon. */
- cp_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
+ cp_av_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
- res = cp_cco_action_handover__try_next_sta (ctx);
+ res = cp_av_cco_action_handover__try_next_sta (ctx);
return res;
}
void
-cp_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx)
+cp_av_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx)
{
dbg_assert (ctx);
- if (cp_cco_action_handover__timeout (ctx))
+ if (cp_av_cco_action_handover__timeout (ctx))
cp_fsm_branch (ctx, CCO_HANDOVER_WAIT_CC_HANDOVER_CNF,
HANDOVER_TIMEOUT, another_sta);
else
@@ -292,11 +296,11 @@ cp_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx)
}
void
-cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)
+cp_av_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)
{
dbg_assert (ctx);
- if (cp_cco_action_handover__timeout (ctx))
+ if (cp_av_cco_action_handover__timeout (ctx))
cp_fsm_branch (ctx, CCO_HANDOVER_WAIT_CC_HANDOVER_INFO_RSP,
HANDOVER_TIMEOUT, another_sta);
else
@@ -310,16 +314,16 @@ cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)
}
void
-cp_cco_action_handover__discover_done (cp_t *ctx)
+cp_av_cco_action_handover__discover_done (cp_t *ctx)
{
dbg_assert (ctx);
cp_sta_t *sta;
cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
- cp_cco_action_cco_selection__clear (ctx);
+ cp_av_cco_action_cco_selection__clear (ctx);
for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
sta;
sta = cp_net_sta_get_next (ctx, net, sta))
- cp_cco_action_cco_selection__sta_add (ctx, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (ctx, net, sta);
if (!heap_empty (&ctx->cco_action.selection_heap))
{
ctx->handover.reason = CP_HANDOVER_REASON_CCO_SELECTION;
@@ -332,7 +336,7 @@ cp_cco_action_handover__discover_done (cp_t *ctx)
void
-cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
+cp_av_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
cp_mme_rx_t *mme)
{
dbg_assert (ctx);
@@ -340,7 +344,7 @@ cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
if (cp_msg_cc_handover_info_rsp_receive (ctx, mme))
{
- cp_beacon_handover (ctx, mme->peer.tei);
+ cp_av_beacon_handover (ctx, mme->peer.tei);
}
/* Cancel the timer. */
@@ -349,15 +353,15 @@ cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
}
void
-cp_cco_action_handover__hoip_countdown_expired (cp_t *ctx)
+cp_av_cco_action_handover__hoip_countdown_expired (cp_t *ctx)
{
cp_fsm_event_t *event;
dbg_assert (ctx);
/* Reset the handover flag in the central beacon. */
- cp_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
- cp_cco_action_cco__assoc_stop (ctx);
+ cp_av_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
+ cp_av_cco_action_cco__assoc_stop (ctx);
if (ctx->handover.reason == CP_HANDOVER_REASON_CCO_SELECTION)
- cp_sta_action_assoc__authenticated__renew (ctx);
+ cp_av_sta_action_assoc__authenticated__renew (ctx);
event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_HANDOVER_SUCCESS);
cp_fsm_trigger (ctx, event);
}
diff --git a/cesar/cp/av/cco/action/stub/Module b/cesar/cp/av/cco/action/stub/Module
new file mode 100644
index 0000000000..bfa10465da
--- /dev/null
+++ b/cesar/cp/av/cco/action/stub/Module
@@ -0,0 +1,3 @@
+SOURCES := cco_action.c
+
+MODULES := cp/cco/action/stub
diff --git a/cesar/cp/av/cco/action/stub/src/cco_action.c b/cesar/cp/av/cco/action/stub/src/cco_action.c
new file mode 100644
index 0000000000..93f7bdb545
--- /dev/null
+++ b/cesar/cp/av/cco/action/stub/src/cco_action.c
@@ -0,0 +1,283 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cco_action.c
+ * \brief CCo functions stub.
+ * \ingroup cp_cco_action
+ *
+ * Stub function for the unit test of the other modules.
+ */
+#include "common/std.h"
+
+#include "cp/av/cco/action/cco_action.h"
+
+/**
+ * initialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_av_cco_action_init (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action_init (cp_t *ctx)
+{
+}
+
+/**
+ * Uninitialisation of CCo action module.
+ * \param ctx the module context.
+ *
+ */
+void
+cp_av_cco_action_uninit (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action_uninit (cp_t *ctx)
+{
+}
+
+/**
+ * Change the SNID.
+ * \param ctx the module context.
+ *
+ * It shall request the SNIDs in use from the station manager to choose
+ * one randomly in the available SNIDs
+ */
+void
+cp_av_cco_action_cco__cco_snid_conflict (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action_cco__cco_snid_conflict (cp_t *ctx)
+{
+}
+
+/**
+ * perform garbage actions of CCo's responsibility.
+ * \param ctx the module context.
+ */
+void
+cp_av_cco_action_garbage (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action_garbage (cp_t *ctx)
+{
+}
+
+/**
+ * generate a new NEK value.
+ * \param ctx the module context.
+ *
+ * NEK shall be used no more than 1 hour, so must be changed after 1
+ * hour for that purpose, NEK expiration date is checked at every occurrence
+ * of the global garbage collector timer and if current NEK expiration
+ * date reached, a new NEK value shall be generated by calling this function
+ */
+void
+cp_av_cco_action_cco__cco_nek_change (cp_t *ctx) __attribute__((weak));
+
+void
+cp_av_cco_action_cco__cco_nek_change (cp_t *ctx)
+{
+}
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_cco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req) __attribute__((weak));
+void
+cp_av_cco_action_cco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req)
+{
+}
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req) __attribute__((weak));
+void
+cp_av_cco_action_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req)
+{
+}
+
+/**
+ * manage association of a station.
+ * \param ctx the module context.
+ * \param assoc_req CM_ASSOC.REQ MME msg having being received
+ */
+void
+cp_av_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req) __attribute__((weak));
+void
+cp_av_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
+ cp_mme_rx_t * assoc_req)
+{
+}
+
+
+/**
+ * manage authentication of a station.
+ * \param ctx the module context.
+ * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
+ */
+void
+cp_av_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx,
+ cp_mme_rx_t * get_key_req) __attribute__((weak));
+void
+cp_av_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx,
+ cp_mme_rx_t * get_key_req)
+{
+}
+
+/**
+ * Release a station.
+ * \param ctx the CP context.
+ * \param mme the MME received.
+ */
+void
+cp_av_cco_action__cco__cc_leave_req (cp_t *ctx,
+ cp_mme_rx_t *mme) __attribute__((weak));
+void
+cp_av_cco_action__cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+}
+
+/**
+ * Start to act as a CCo coming from the unassociated state..
+ * \param ctx the module context.
+ *
+ * This function shall:
+ * - Change the station CCo status.
+ * - Generate the NEK.
+ * - Program the NEK change timer (to change in few minutes).
+ * - Program the beacon timer to send a central beacon at the beginning of
+ * the next beacon period.
+ */
+void
+cp_av_cco_action__assoc__cco_start (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action__assoc__cco_start (cp_t *ctx)
+{
+}
+
+/**
+ * Stop acting as a CCo and become a unassociated station.
+ * \param ctx the module context.
+ *
+ * This function shall:
+ * - Change the station status.
+ * - Reprogram the beacon timer to expire a few time after the beacon period
+ * start date.
+ * - Stop the NEK generation.
+ * - Delete the AVLN.
+ * - Change the station authenticated status to not authenticated.
+ */
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx) __attribute__((weak));
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_handover__discover_done (cp_t *ctx) __attribute__((weak));
+
+void
+cp_av_cco_action_handover__discover_done (cp_t *ctx) {}
+
+void
+cp_av_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
+ cp_mme_rx_t *mme) __attribute__((weak));
+
+void
+cp_av_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
+ cp_mme_rx_t *mme) {}
+
+void
+cp_av_cco_action_handover__timeout (cp_t *ctx)__attribute__((weak));
+
+void
+cp_av_cco_action_handover__timeout (cp_t *ctx) {}
+
+void
+cp_av_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
+ cp_mme_rx_t *mme)__attribute__((weak));
+
+void
+cp_av_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
+ cp_mme_rx_t *mme) {}
+
+void
+cp_av_cco_action_handover__hoip_countdown_expired (cp_t
+ *ctx)__attribute__((weak));
+
+void
+cp_av_cco_action_handover__hoip_countdown_expired (cp_t *ctx) {}
+
+void
+cp_av_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
+ __attribute__((weak));
+
+void
+cp_av_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
+{}
+
+void
+cp_av_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
+ __attribute__((weak));
+
+void
+cp_av_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+}
+
+void
+cp_av_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta) __attribute__((weak));
+
+void
+cp_av_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta) {}
+
+void
+cp_av_cco_action_drv_mac_stop (cp_t *ctx)__attribute__((weak));
+void
+cp_av_cco_action_drv_mac_stop_suspend (cp_t *ctx)__attribute__((weak));
+void
+cp_av_cco_action_drv_mac_stop_ended (cp_t *ctx)__attribute__((weak));
+void
+cp_av_cco_action_handover__ended (cp_t *ctx)__attribute__((weak));
+void
+cp_av_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx)__attribute__((weak));
+void
+cp_av_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)__attribute__((weak));
+
+void
+cp_av_cco_action_drv_mac_stop (cp_t *ctx){}
+void
+cp_av_cco_action_drv_mac_stop_suspend (cp_t *ctx){}
+void
+cp_av_cco_action_drv_mac_stop_ended (cp_t *ctx){}
+void
+cp_av_cco_action_handover__ended (cp_t *ctx){}
+void
+cp_av_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx){}
+void
+cp_av_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx){}
+
+void
+cp_av_cco_action_beacon_with_same_nid (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
+ __attribute__ ((weak));
+void
+cp_av_cco_action_beacon_with_same_nid (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta) { }
+
diff --git a/cesar/cp/av/cco/action/test/utest/Config b/cesar/cp/av/cco/action/test/utest/Config
new file mode 100644
index 0000000000..feb64caf5e
--- /dev/null
+++ b/cesar/cp/av/cco/action/test/utest/Config
@@ -0,0 +1,2 @@
+CONFIG_RESTRACK=y
+CONFIG_CP_AV = y
diff --git a/cesar/cp/av/cco/action/test/utest/Makefile b/cesar/cp/av/cco/action/test/utest/Makefile
new file mode 100644
index 0000000000..3d7a121f63
--- /dev/null
+++ b/cesar/cp/av/cco/action/test/utest/Makefile
@@ -0,0 +1,20 @@
+BASE = ../../../../../..
+
+INCLUDES = cp/av/cco/action/test/utest cp/av/cco/action/test/utest/override
+
+HOST_PROGRAMS = test_cco_action
+test_cco_action_SOURCES = test_cco_action.c handover.c nek.c discover_list.c \
+ assoc.c garbage.c msg_stub.c fsm_stub.c \
+ cp_stub.c scenario_actions.c \
+ dataplane_stub.c beacon_stub.c \
+ sta_action.c secu.c bsu_stub.c
+
+test_cco_action_MODULES = lib lib/scenario cp/av/cco/action cp/av/sta/mgr \
+ cp/av/fsm/stub mac/common cl/stub \
+ cp/av/beacon/stub cp/av/cco/region/stub cp/av/cco/bw/stub \
+ cp/sta/core/stub cp/msg/stub bsu/stub cp/av/beacon/stub \
+ cp/av/cco/region/stub cp/av/cco/bw/stub
+
+test_cco_action_CONFIG_MODULES = cp mac/sar
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h b/cesar/cp/av/cco/action/test/utest/inc/scenario_defs.h
index 5df38c494b..00c079b810 100644
--- a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/av/cco/action/test/utest/inc/scenario_defs.h
@@ -152,12 +152,12 @@ __n (cco_sta_leave_send_tei_map, cp_sta_t *sta)
cp_msg_cc_assoc_req_receive, \
cp_msg_cc_assoc_cnf_send, \
\
- cp_beacon_handover, \
- cp_beacon_discover_init, \
- cp_beacon_discover_uninit, \
+ cp_av_beacon_handover, \
+ cp_av_beacon_discover_init, \
+ cp_av_beacon_discover_uninit, \
cp_beacon_process_untracked_avln, \
\
- cp_sta_action_assoc__authenticated__renew, \
+ cp_av_sta_action_assoc__authenticated__renew, \
\
cp_msg_cm_set_key_req_send, \
cp_msg_cm_set_key_cnf_receive, \
@@ -293,12 +293,12 @@ __e (cp_fsm_event_bare_new, cp_fsm_event_type_t type)
__e (cp_fsm_event_mme_new, cp_fsm_event_type_t type)
__e (cp_fsm_branch, cp_fsm_branch_t branch)
-__e (cp_beacon_handover, cp_tei_t tei)
-__e (cp_beacon_discover_init)
-__e (cp_beacon_discover_uninit)
+__e (cp_av_beacon_handover, cp_tei_t tei)
+__e (cp_av_beacon_discover_init)
+__e (cp_av_beacon_discover_uninit)
__e (cp_beacon_process_untracked_avln)
-__e (cp_sta_action_assoc__authenticated__renew)
+__e (cp_av_sta_action_assoc__authenticated__renew)
__e (bsu_power_on, u8 snid)
diff --git a/cesar/cp/cco/action/test/utest/inc/test_cco_action.h b/cesar/cp/av/cco/action/test/utest/inc/test_cco_action.h
index 4f3d078a74..4f3d078a74 100644
--- a/cesar/cp/cco/action/test/utest/inc/test_cco_action.h
+++ b/cesar/cp/av/cco/action/test/utest/inc/test_cco_action.h
diff --git a/cesar/cp/cco/action/test/utest/override/cp/inc/context.h b/cesar/cp/av/cco/action/test/utest/override/cp/inc/context.h
index fb89c6bdd3..cf3999d855 100644
--- a/cesar/cp/cco/action/test/utest/override/cp/inc/context.h
+++ b/cesar/cp/av/cco/action/test/utest/override/cp/inc/context.h
@@ -29,6 +29,9 @@
#include "lib/rnd.h"
#include "lib/trace.h"
+/** Forward declaration. */
+typedef struct cp_beacon_t cp_beacon_t;
+
enum cp_handover_reason_t
{
CP_HANDOVER_REASON_CCO_SELECTION,
diff --git a/cesar/cp/cco/action/test/overide/cp/sta/core/defs.h b/cesar/cp/av/cco/action/test/utest/override/cp/sta/core/defs.h
index 9698b44e93..9698b44e93 100644
--- a/cesar/cp/cco/action/test/overide/cp/sta/core/defs.h
+++ b/cesar/cp/av/cco/action/test/utest/override/cp/sta/core/defs.h
diff --git a/cesar/cp/cco/action/test/utest/override/mac/sar/inc/sar_context.h b/cesar/cp/av/cco/action/test/utest/override/mac/sar/inc/sar_context.h
index ab2a656f3d..ab2a656f3d 100644
--- a/cesar/cp/cco/action/test/utest/override/mac/sar/inc/sar_context.h
+++ b/cesar/cp/av/cco/action/test/utest/override/mac/sar/inc/sar_context.h
diff --git a/cesar/cp/cco/action/test/utest/src/assoc.c b/cesar/cp/av/cco/action/test/utest/src/assoc.c
index 9f8a7d6a2a..9da8a2dbca 100644
--- a/cesar/cp/cco/action/test/utest/src/assoc.c
+++ b/cesar/cp/av/cco/action/test/utest/src/assoc.c
@@ -46,7 +46,7 @@ assoc_test_case_cco (test_t t)
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_cco__nek_change),
SCENARIO_EVENT (cp_beacon_process_untracked_avln),
- SCENARIO_EVENT (cp_beacon_discover_init),
+ SCENARIO_EVENT (cp_av_beacon_discover_init),
SCENARIO_END
};
scenario_run (t, ucco_enter, &globals);
@@ -178,7 +178,7 @@ assoc_test_case_cco (test_t t)
/* Leave CCo to STA. */
scenario_entry_t cco_leave[] = {
SCENARIO_ACTION (cco__assoc_stop),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_become_sta),
SCENARIO_END
@@ -201,7 +201,7 @@ assoc_test_case_cco (test_t t)
assoc_test_set_own_sta_as_cco (&ctx.cp, net, 1);
scenario_entry_t cco_unassoc [] = {
SCENARIO_ACTION (cco__unassoc_stop),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
SCENARIO_END
@@ -214,7 +214,7 @@ assoc_test_case_cco (test_t t)
assoc_test_set_own_sta_as_cco (&ctx.cp, net, 1);
scenario_entry_t ucco_stop [] = {
SCENARIO_ACTION (ucco_stop),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
SCENARIO_END
@@ -245,7 +245,7 @@ assoc_test_case_cco (test_t t)
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_cco__nek_change),
SCENARIO_EVENT (cp_beacon_process_untracked_avln),
- SCENARIO_EVENT (cp_beacon_discover_init),
+ SCENARIO_EVENT (cp_av_beacon_discover_init),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_become_cco),
SCENARIO_END
@@ -263,7 +263,7 @@ assoc_test_case_cco (test_t t)
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_cco__nek_change),
SCENARIO_EVENT (cp_beacon_process_untracked_avln),
- SCENARIO_EVENT (cp_beacon_discover_init),
+ SCENARIO_EVENT (cp_av_beacon_discover_init),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_become_cco),
SCENARIO_END
@@ -453,7 +453,7 @@ assoc_test_case_beacon_with_same_nid (test_t t)
SCENARIO_ACTION (cco_leave_merge_avln),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_sta_status_changed),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
SCENARIO_END
@@ -489,7 +489,7 @@ assoc_test_case_beacon_with_same_nid (test_t t)
SCENARIO_ACTION (cco_leave_merge_avln),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_sta_status_changed),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_cco_leave),
SCENARIO_END
diff --git a/cesar/cp/cco/action/test/utest/src/beacon_stub.c b/cesar/cp/av/cco/action/test/utest/src/beacon_stub.c
index 27e48ddf45..8fc0e93cb8 100644
--- a/cesar/cp/cco/action/test/utest/src/beacon_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/beacon_stub.c
@@ -17,12 +17,12 @@
#include "lib/scenario/scenario.h"
void
-cp_beacon_handover (cp_t *ctx, cp_tei_t tei)
+cp_av_beacon_handover (cp_t *ctx, cp_tei_t tei)
{
dbg_assert (ctx);
dbg_assert (MAC_TEI_IS_STA (tei));
- scenario_event (cp_beacon_handover);
+ scenario_event (cp_av_beacon_handover);
}
void
@@ -32,13 +32,13 @@ cp_beacon_process_untracked_avln (cp_t *ctx)
}
void
-cp_beacon_discover_init (cp_t *ctx)
+cp_av_beacon_discover_init (cp_t *ctx)
{
- scenario_event (cp_beacon_discover_init);
+ scenario_event (cp_av_beacon_discover_init);
}
void
-cp_beacon_discover_uninit (cp_t *ctx)
+cp_av_beacon_discover_uninit (cp_t *ctx)
{
- scenario_event (cp_beacon_discover_uninit);
+ scenario_event (cp_av_beacon_discover_uninit);
}
diff --git a/cesar/cp/cco/action/test/utest/src/bsu_stub.c b/cesar/cp/av/cco/action/test/utest/src/bsu_stub.c
index 633d65be5d..633d65be5d 100644
--- a/cesar/cp/cco/action/test/utest/src/bsu_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/bsu_stub.c
diff --git a/cesar/cp/cco/action/test/utest/src/cp_stub.c b/cesar/cp/av/cco/action/test/utest/src/cp_stub.c
index 241cbb23df..241cbb23df 100644
--- a/cesar/cp/cco/action/test/utest/src/cp_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/cp_stub.c
diff --git a/cesar/cp/cco/action/test/utest/src/dataplane_stub.c b/cesar/cp/av/cco/action/test/utest/src/dataplane_stub.c
index b350d9c457..b350d9c457 100644
--- a/cesar/cp/cco/action/test/utest/src/dataplane_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/dataplane_stub.c
diff --git a/cesar/cp/cco/action/test/utest/src/discover_list.c b/cesar/cp/av/cco/action/test/utest/src/discover_list.c
index c1fcc60e43..c1fcc60e43 100644
--- a/cesar/cp/cco/action/test/utest/src/discover_list.c
+++ b/cesar/cp/av/cco/action/test/utest/src/discover_list.c
diff --git a/cesar/cp/cco/action/test/utest/src/fsm_stub.c b/cesar/cp/av/cco/action/test/utest/src/fsm_stub.c
index c453b3bf30..c453b3bf30 100644
--- a/cesar/cp/cco/action/test/utest/src/fsm_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/fsm_stub.c
diff --git a/cesar/cp/cco/action/test/utest/src/garbage.c b/cesar/cp/av/cco/action/test/utest/src/garbage.c
index 89ee81d964..89ee81d964 100644
--- a/cesar/cp/cco/action/test/utest/src/garbage.c
+++ b/cesar/cp/av/cco/action/test/utest/src/garbage.c
diff --git a/cesar/cp/cco/action/test/utest/src/handover.c b/cesar/cp/av/cco/action/test/utest/src/handover.c
index d94afb4bbc..29361c3379 100644
--- a/cesar/cp/cco/action/test/utest/src/handover.c
+++ b/cesar/cp/av/cco/action/test/utest/src/handover.c
@@ -17,6 +17,7 @@
#include "lib/scenario/scenario.h"
#include "inc/test_cco_action.h"
#include "cp/cco/action/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
void
@@ -71,7 +72,7 @@ handover__handover_start (test_t test)
scenario_run (test, handover_entries2, &globals);
}
test_end;
- cp_cco_action_cco_selection__clear (&ctx.cp);
+ cp_av_cco_action_cco_selection__clear (&ctx.cp);
slab_release (sta);
test_cco_action_uninit (&ctx);
}
@@ -164,14 +165,14 @@ handover__handover_cc_handover_cnf_receive (test_t test)
cp_sta_t *new_cco = cp_sta_mgr_sta_add (&ctx.cp, net, 3, 3);
cp_sta_set_authenticated (&ctx.cp, new_cco, true);
/* Add the new CCo to the CCO selection heap. */
- cp_cco_action_cco_selection__mac_stop_sta_add (&ctx.cp, new_cco);
+ cp_av_cco_action_cco_selection__mac_stop_sta_add (&ctx.cp, new_cco);
test_begin (test, "HANDOVER_CNF received - No more stations available")
{
ctx.cp.handover.reason =
CP_HANDOVER_REASON_CCO_SELECTION;
scenario_run (test, handover_entries, &globals);
- cp_cco_action_cco_selection__clear (&ctx.cp);
+ cp_av_cco_action_cco_selection__clear (&ctx.cp);
}
test_end;
cp_sta_mgr_sta_remove (&ctx.cp, new_cco);
@@ -180,7 +181,7 @@ handover__handover_cc_handover_cnf_receive (test_t test)
sta = cp_sta_mgr_sta_add (&ctx.cp, net, 2, 2);
cp_sta_set_authenticated (&ctx.cp, sta, true);
sta->cco_cap = 1;
- cp_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
slab_release (sta);
test_begin (test, "HANDOVER_CNF received - More stations available")
@@ -251,7 +252,7 @@ handover__timeout (test_t test)
sta = cp_sta_mgr_sta_add (&ctx.cp, net, 4, 4);
sta->cco_cap = 1;
cp_sta_set_authenticated (&ctx.cp, sta, true);
- cp_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
slab_release (sta);
scenario_run (test, handover_entries, &globals);
@@ -264,12 +265,12 @@ handover__timeout (test_t test)
sta = cp_sta_mgr_sta_add (&ctx.cp, net, 4, 4);
cp_sta_set_authenticated (&ctx.cp, sta, true);
sta->cco_cap = 1;
- cp_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_add (&ctx.cp, net, 3, 3);
cp_sta_set_authenticated (&ctx.cp, sta, true);
sta->cco_cap = 1;
- cp_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&ctx.cp, net, sta);
slab_release (sta);
scenario_run (test, handover_entries2, &globals);
@@ -302,7 +303,7 @@ handover__handover_cc_handover_info_rsp_receive (test_t test)
SCENARIO_ACTION (handover__cc_handover_info_rsp_receive, .peer = CP_MME_PEER (3, 3)),
SCENARIO_EVENT (cp_msg_cc_handover_info_rsp_receive,
.ok = true),
- SCENARIO_EVENT (cp_beacon_handover, .tei = 3),
+ SCENARIO_EVENT (cp_av_beacon_handover, .tei = 3),
SCENARIO_END
};
@@ -337,7 +338,7 @@ handover__hoip_countdown_expired (test_t test)
scenario_entry_t handover_entries[] = {
SCENARIO_ACTION (handover__hoip_countdown_expired),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_become_sta),
SCENARIO_EVENT (cp_fsm_event_bare_new,
@@ -415,7 +416,7 @@ handover__cco_leave (test_t test)
scenario_entry_t handover_ended [] = {
SCENARIO_ACTION (handover__ended),
- SCENARIO_EVENT (cp_beacon_discover_uninit),
+ SCENARIO_EVENT (cp_av_beacon_discover_uninit),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_assoc_become_sta),
SCENARIO_END
diff --git a/cesar/cp/cco/action/test/utest/src/msg_stub.c b/cesar/cp/av/cco/action/test/utest/src/msg_stub.c
index b6e593005c..b6e593005c 100644
--- a/cesar/cp/cco/action/test/utest/src/msg_stub.c
+++ b/cesar/cp/av/cco/action/test/utest/src/msg_stub.c
diff --git a/cesar/cp/cco/action/test/utest/src/nek.c b/cesar/cp/av/cco/action/test/utest/src/nek.c
index 207cb75bc5..207cb75bc5 100644
--- a/cesar/cp/cco/action/test/utest/src/nek.c
+++ b/cesar/cp/av/cco/action/test/utest/src/nek.c
diff --git a/cesar/cp/cco/action/test/utest/src/scenario_actions.c b/cesar/cp/av/cco/action/test/utest/src/scenario_actions.c
index c21c520308..e0acffaac2 100644
--- a/cesar/cp/cco/action/test/utest/src/scenario_actions.c
+++ b/cesar/cp/av/cco/action/test/utest/src/scenario_actions.c
@@ -13,6 +13,8 @@
#include "common/std.h"
#include "cp/cco/action/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
+#include "cp/av/cco/action/handover.h"
#include "lib/scenario/scenario.h"
@@ -23,7 +25,7 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
{ \
static cp_mme_rx_t mme; \
mme.peer = params->action_ ## ACTION.peer; \
- cp_cco_action_ ## ACTION (globals->cp, &mme); \
+ cp_av_cco_action_ ## ACTION (globals->cp, &mme); \
}
#define __mp(ACTION) \
@@ -34,7 +36,7 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
ccotic cp_mme_rx_t mme; \
mme.peer = params->action_ ## ACTION.peer; \
mme.prun.pid = params->action_ ## ACTION.pid; \
- cp_cco_action_ ## ACTION (globals->cp, &mme); \
+ cp_av_cco_action_ ## ACTION (globals->cp, &mme); \
}
#define __me(ACTION) \
@@ -45,7 +47,7 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
ccotic cp_mme_rx_t mme; \
mme.peer = params->action_ ## ACTION.peer; \
mme.encrypt = params->action_ ## ACTION.encrypt; \
- cp_cco_action_ ## ACTION (globals->cp, &mme); \
+ cp_av_cco_action_ ## ACTION (globals->cp, &mme); \
}
#define __0(ACTION) \
@@ -53,7 +55,7 @@ void \
scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
scenario_params_t *params) \
{ \
- cp_cco_action_ ## ACTION (globals->cp); \
+ cp_av_cco_action_ ## ACTION (globals->cp); \
}
#define __n(ACTION, PARAMS...) \
@@ -62,7 +64,7 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
scenario_params_t *params) \
{ \
scenario_action_ ## ACTION ## _t *p = &params->action_ ## ACTION; \
- cp_cco_action_ ## ACTION (globals->cp \
+ cp_av_cco_action_ ## ACTION (globals->cp \
PREPROC_FOR_EACH_PARAM (PREPROC_CALL_UNPACK, \
__n_args, ## PARAMS) \
); \
@@ -108,12 +110,12 @@ scenario_action_BEACON_WITH_SAME_NID_cb (scenario_globals_t *globals,
{
scenario_action_BEACON_WITH_SAME_NID_t *p =
&params->action_BEACON_WITH_SAME_NID;
- cp_cco_action_beacon_with_same_nid (globals->cp, p->beacon, p->net, p->sta);
+ cp_av_cco_action_beacon_with_same_nid (globals->cp, p->beacon, p->net, p->sta);
}
void
scenario_action_cco_leave_merge_avln_cb (scenario_globals_t *globals,
scenario_params_t *params)
{
- cp_cco_action_cco__unassoc_stop (globals->cp);
+ cp_av_cco_action_cco__unassoc_stop (globals->cp);
}
diff --git a/cesar/cp/cco/action/test/utest/src/secu.c b/cesar/cp/av/cco/action/test/utest/src/secu.c
index 67e4db2a87..67e4db2a87 100644
--- a/cesar/cp/cco/action/test/utest/src/secu.c
+++ b/cesar/cp/av/cco/action/test/utest/src/secu.c
diff --git a/cesar/cp/cco/action/test/utest/src/sta_action.c b/cesar/cp/av/cco/action/test/utest/src/sta_action.c
index 4cbcf8ba8a..042ec41a77 100644
--- a/cesar/cp/cco/action/test/utest/src/sta_action.c
+++ b/cesar/cp/av/cco/action/test/utest/src/sta_action.c
@@ -18,9 +18,9 @@
#include "lib/scenario/scenario.h"
void
-cp_sta_action_assoc__authenticated__renew (cp_t *ctx)
+cp_av_sta_action_assoc__authenticated__renew (cp_t *ctx)
{
dbg_assert (ctx);
- scenario_event (cp_sta_action_assoc__authenticated__renew);
+ scenario_event (cp_av_sta_action_assoc__authenticated__renew);
}
diff --git a/cesar/cp/cco/action/test/utest/src/test_cco_action.c b/cesar/cp/av/cco/action/test/utest/src/test_cco_action.c
index 91e729acca..91e729acca 100644
--- a/cesar/cp/cco/action/test/utest/src/test_cco_action.c
+++ b/cesar/cp/av/cco/action/test/utest/src/test_cco_action.c
diff --git a/cesar/cp/av/cco/action/test/utest2/Config b/cesar/cp/av/cco/action/test/utest2/Config
new file mode 100644
index 0000000000..3ebfb2f0b9
--- /dev/null
+++ b/cesar/cp/av/cco/action/test/utest2/Config
@@ -0,0 +1 @@
+CONFIG_CP_AV = y
diff --git a/cesar/cp/av/cco/action/test/utest2/Makefile b/cesar/cp/av/cco/action/test/utest2/Makefile
new file mode 100644
index 0000000000..2b704c698f
--- /dev/null
+++ b/cesar/cp/av/cco/action/test/utest2/Makefile
@@ -0,0 +1,52 @@
+BASE = ../../../../../..
+
+ECOS = y
+
+INCLUDES = cp/av/cco/action/test/utest2/override
+
+HOST_PROGRAMS= fsm_handover
+TARGET_PROGRAMS = action garbage status keys
+
+action_SOURCES = action-test.c core_stub.c \
+ sar_stub.c pbproc_stub.c sta_action.c
+action_MODULES = lib cp/av/cco/action mac/common cp/av/sta/mgr \
+ cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/beacon/stub \
+ cp/av/fsm/stub cp/av/beacon/stub cl/stub\
+ cp/secu cp/msg/stub bsu/stub cp/av/cco/region/stub \
+ cp/av/cco/bw/stub
+action_CONFIG_MODULES = cp
+
+garbage_SOURCES = garbage.c core_stub.c \
+ sar_stub.c pbproc_stub.c sta_action.c
+garbage_MODULES = lib cp/av/cco/action mac/common cp/av/sta/mgr \
+ cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/beacon/stub \
+ cp/av/beacon/stub cl/stub cp/secu cp/msg/stub bsu/stub \
+ cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/fsm/stub
+garbage_CONFIG_MODULES = cp
+
+status_SOURCES = status.c pbproc_stub.c sar_stub.c sta_action.c
+status_MODULES = lib cp/av/cco/action mac/common cp/av/sta/mgr \
+ cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/beacon/stub \
+ cp/av/fsm/stub cp/beacon/stub cp/sta/core/stub \
+ cp/msg/stub cl/stub mac/sar/stub cp/secu/stub \
+ cp/secu bsu/stub cp/cco/region/stub cp/cco/bw/stub
+status_CONFIG_MODULES = cp
+
+keys_SOURCES = action_gen_nek.c pbproc_stub.c sar_stub.c \
+ sta_action.c
+keys_MODULES = lib cp/av/cco/action mac/common cp/av/sta/mgr \
+ cp/secu cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/beacon/stub \
+ cp/av/fsm/stub cp/beacon/stub cp/sta/core/stub \
+ cp/msg/stub cl/stub mac/sar/stub cl/stub \
+ bsu/stub cp/cco/region/stub cp/cco/bw/stub
+keys_CONFIG_MODULES = cp
+
+fsm_handover_SOURCES= fsm_handover.c sta_action.c
+fsm_handover_MODULES= lib cp/av/cco/action mac/common cp/secu cp/av/sta/mgr \
+ cp/av/cco/region/stub cp/av/cco/bw/stub cp/av/beacon/stub \
+ cp/av/fsm/stub cp/beacon/stub cp/sta/core/stub \
+ cp/msg/stub cl/stub mac/sar/stub \
+ bsu/stub cp/cco/region/stub cp/cco/bw/stub
+fsm_handover_CONFIG_MODULES = cp
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cco/action/test/doc/Makefile b/cesar/cp/av/cco/action/test/utest2/doc/Makefile
index fc8858cbcd..9c79b61892 100644
--- a/cesar/cp/cco/action/test/doc/Makefile
+++ b/cesar/cp/av/cco/action/test/utest2/doc/Makefile
@@ -9,12 +9,12 @@ odt: $(ODT)
html: $(HTML)
-%.odt: %.txt
+%.odt: %.txt
rst2odt.py $< $@
%.html: %.txt
rst2html $< $@
-clean:
+clean:
rm -f $(ODT)
rm -f $(HTML)
diff --git a/cesar/cp/cco/action/test/doc/cco_action.txt b/cesar/cp/av/cco/action/test/utest2/doc/cco_action.txt
index c844e602df..70f120e236 100644
--- a/cesar/cp/cco/action/test/doc/cco_action.txt
+++ b/cesar/cp/av/cco/action/test/utest2/doc/cco_action.txt
@@ -32,7 +32,7 @@ Test 1: Choosing SNID at the beginning.
This shall choose randomly a value of SNID. The random generator is
initialised with the mac_ntb date.
-Environment:
+Environment:
* The phy_date override in the test shall always return the same value in order to verify the SNID chosen.
* The all range of SNID values shall be available. The flags returned by the override of the get_snids function from the sta manager shall return 0x0.
@@ -79,7 +79,7 @@ Test 1: Receiving a CC_ASSOC.REQ join
First station to associate
The CCo shall try to associate the station to its AVLN.
- 1. Get an available TEI different from the one of the own Station's TEI.
+ 1. Get an available TEI different from the one of the own Station's TEI.
2. Add the station to the station list (use the station manager).
3. Answer the request.
@@ -127,10 +127,12 @@ Test 1: Station is not known.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Environment
- A MME is received with a authentication request and the Station is not known.
+ A MME is received with a authentication request and the Station is not
+ known.
Result
- A MME with the CM_GET_KEY.CNF containing the result "request refused" shall be sent.
+ A MME with the CM_GET_KEY.CNF containing the result "request refused" shall
+ be sent.
Test 2: Station is known.
~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/cesar/cp/cco/action/test/ecos.ecc.sh b/cesar/cp/av/cco/action/test/utest2/ecos.ecc.sh
index 8253d98c9a..8253d98c9a 100644
--- a/cesar/cp/cco/action/test/ecos.ecc.sh
+++ b/cesar/cp/av/cco/action/test/utest2/ecos.ecc.sh
diff --git a/cesar/cp/cco/action/test/overide/cp/inc/context.h b/cesar/cp/av/cco/action/test/utest2/override/cp/inc/context.h
index 573048df09..573048df09 100644
--- a/cesar/cp/cco/action/test/overide/cp/inc/context.h
+++ b/cesar/cp/av/cco/action/test/utest2/override/cp/inc/context.h
diff --git a/cesar/cp/cco/action/test/utest/override/cp/sta/core/defs.h b/cesar/cp/av/cco/action/test/utest2/override/cp/sta/core/defs.h
index 9698b44e93..9698b44e93 100644
--- a/cesar/cp/cco/action/test/utest/override/cp/sta/core/defs.h
+++ b/cesar/cp/av/cco/action/test/utest2/override/cp/sta/core/defs.h
diff --git a/cesar/cp/cco/action/test/overide/mac/sar/inc/context.h b/cesar/cp/av/cco/action/test/utest2/override/mac/sar/inc/context.h
index 9e7c6f07ca..9e7c6f07ca 100644
--- a/cesar/cp/cco/action/test/overide/mac/sar/inc/context.h
+++ b/cesar/cp/av/cco/action/test/utest2/override/mac/sar/inc/context.h
diff --git a/cesar/cp/cco/action/test/src/action-test.c b/cesar/cp/av/cco/action/test/utest2/src/action-test.c
index 86b856b6dc..4606dfefd7 100644
--- a/cesar/cp/cco/action/test/src/action-test.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/action-test.c
@@ -34,6 +34,9 @@
#include "cp/cco/action/cco_action.h"
#include "cp/cco/action/inc/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
+#include "cp/av/cco/action/inc/cco_action.h"
+
#include "cl/cl_mactotei.h"
@@ -45,10 +48,10 @@
#include "cl/inc/context.h"
cp_sta_t *
-cp_cco_action_cco_selection__selection (cp_t *ctx);
+cp_av_cco_action_cco_selection__selection (cp_t *ctx);
void
-cp_cco_action_tei_expired (cp_t *ctx, cp_sta_t *sta);
+cp_av_cco_action_tei_expired (cp_t *ctx, cp_sta_t *sta);
// The value provided to the module beacon.
u16 snid_compute;
@@ -118,7 +121,7 @@ test_case_tei_lease_create (test_t test)
test_action_init (&cp);
for (i = 0; i< 5; i++)
{
- tei = cp_cco_action_tei_compute (&cp);
+ tei = cp_av_cco_action_tei_compute (&cp);
test_fail_if (tei != i + 1);
}
test_action_uninit (&cp);
@@ -132,12 +135,12 @@ test_case_tei_lease_create (test_t test)
for (i = 0; i < 5; i++)
{
- tei = cp_cco_action_tei_compute (&cp);
+ tei = cp_av_cco_action_tei_compute (&cp);
test_fail_if (tei != i + 1);
}
cp_cco_action_tei_release (&cp, 2);
- tei = cp_cco_action_tei_compute (&cp);
+ tei = cp_av_cco_action_tei_compute (&cp);
test_fail_if (tei != 2);
test_action_uninit (&cp);
}
@@ -149,10 +152,10 @@ test_case_tei_lease_create (test_t test)
cp.cco_action.tei_flags[0] = 0x17;
- cp_cco_action_tei_in_use (&cp, 4);
+ cp_av_cco_action_tei_in_use (&cp, 4);
test_fail_unless (cp.cco_action.tei_flags[0] == 0x1F);
- test_fail_unless (cp_cco_action_tei_compute (&cp) == 6);
+ test_fail_unless (cp_av_cco_action_tei_compute (&cp) == 6);
test_action_uninit (&cp);
}
test_end;
@@ -191,7 +194,7 @@ test_case_tei_release (test_t test)
test_fail_if (cp.cco_action.tei_flags[0] != 0x124);
// Get TEI.
- tei = cp_cco_action_tei_compute (&cp);
+ tei = cp_av_cco_action_tei_compute (&cp);
test_fail_if (tei != 1);
test_fail_if (cp.cco_action.tei_flags[0] != 0x125);
@@ -205,7 +208,7 @@ test_case_tei_release (test_t test)
cp_cco_action_tei_release (&cp, 45);
test_fail_if (cp.cco_action.tei_flags[1] != 0xFFFFEFFF);
- tei = cp_cco_action_tei_compute (&cp);
+ tei = cp_av_cco_action_tei_compute (&cp);
test_fail_if (tei != 45);
test_fail_if (cp.cco_action.tei_flags[1] != 0xFFFFFFFF);
}
@@ -280,7 +283,7 @@ test_case_change_snid (test_t test)
/* Adding the AVLN. */
for (i = 0; i < COUNT (snids); i++)
cp_sta_mgr_add_avln (&cp, snids[i], i);
- cp_cco_action_cco__cco_snid_conflict (&cp);
+ cp_av_cco_action_cco__cco_snid_conflict (&cp);
test_begin (test, "Verify SNID chosen")
{
for (i = 0; i < COUNT (snids); i++)
@@ -307,7 +310,7 @@ test_case_cco_action_start (test_t test)
cp_sta_own_data_set_nid (&cp, 1);
test_fail_unless (!cp_sta_own_data_get_tei (&cp));
/* As an AVLN already exits, the CCo should not use the same snid. */
- cp_cco_action_cco__unassoc_start (&cp);
+ cp_av_cco_action_cco__unassoc_start (&cp);
test_fail_unless (net != cp_sta_mgr_get_our_avln (&cp));
test_fail_unless (cp_net_get_nid (&cp, net)
== cp_sta_own_data_get_nid (&cp));
@@ -327,7 +330,7 @@ test_case_cco_action_start (test_t test)
nid = cp_sta_own_data_get_nid (&cp);
net = cp_sta_mgr_get_avln (&cp, snid, nid);
test_fail_unless (net);
- cp_cco_action_cco__unassoc_stop(&cp);
+ cp_av_cco_action_cco__unassoc_stop(&cp);
snid = cp_sta_own_data_get_snid (&cp);
nid = cp_sta_own_data_get_nid (&cp);
net = cp_sta_mgr_get_avln (&cp, snid, nid);
@@ -437,7 +440,7 @@ test_case_sta_assoc_procedure (test_t test)
mme_rx.length, BITSTREAM_READ);
sta_tei = 0;
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
net = cp_sta_mgr_get_our_avln (&cp);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, sta_tei);
@@ -482,7 +485,7 @@ test_case_sta_assoc_procedure (test_t test)
mme_rx.length, BITSTREAM_READ);
sta_tei = 0;
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
net = cp_sta_mgr_get_our_avln (&cp);
sta = cp_sta_mgr_sta_get_assoc (&cp, net, sta_tei);
@@ -523,7 +526,7 @@ test_case_sta_assoc_procedure (test_t test)
/* Reset stub. */
sta_tei = 0;
/* Receive CC_ASSOC.REQ request. */
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
/* It must receive a TEI. */
test_fail_if (sta_tei == 0);
@@ -584,7 +587,7 @@ test_case_sta_assoc_procedure (test_t test)
mme_rx.length, BITSTREAM_READ);
sta_tei = 0;
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
net = cp_sta_mgr_get_our_avln (&cp);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 4);
@@ -626,7 +629,7 @@ test_case_sta_assoc_procedure (test_t test)
sta->tei_lease_date_ms = 10;
cp_sta_set_authenticated (&cp, sta, true);
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
test_fail_if (sta->tei_lease_date_ms !=
MAC_SEC_TO_MS(CP_LEASE_AUTH_MIN * 60) +
@@ -641,7 +644,7 @@ test_case_sta_assoc_procedure (test_t test)
bitstream_init (&mme_rx.bitstream, buffer + HPAV_MME_HEADER,
mme_rx.length, BITSTREAM_READ);
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
test_fail_unless (res_data.result
== CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON);
@@ -693,7 +696,7 @@ test_case_sta_assoc_procedure (test_t test)
cp_sta_own_data_set_tei (&cp, 244);
cp_sta_own_data_set_cco_status (&cp, true);
- cp_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_cco__cc_assoc_req (&cp, &mme_rx);
net = cp_sta_mgr_get_our_avln (&cp);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
@@ -720,7 +723,7 @@ test_case_sta_assoc_procedure_ucco_to_cco (test_t test)
cp_net_t *net;
test_action_init (&cp);
- cp_cco_action_ucco_start (&cp);
+ cp_av_cco_action_ucco_start (&cp);
net = cp_sta_mgr_add_avln (&cp, 1, nid);
cp_sta_mgr_set_our_avln (&cp, net);
@@ -753,7 +756,7 @@ test_case_sta_assoc_procedure_ucco_to_cco (test_t test)
mme_rx.length, BITSTREAM_READ);
fsm_event_posted = false;
- cp_cco_action_ucco__cc_assoc_req (&cp, &mme_rx);
+ cp_av_cco_action_ucco__cc_assoc_req (&cp, &mme_rx);
net = cp_sta_mgr_get_our_avln (&cp);
sta = cp_net_sta_get_first (&cp, net, CP_NET_STA_ASSOC);
@@ -766,7 +769,7 @@ test_case_sta_assoc_procedure_ucco_to_cco (test_t test)
}
test_end;
- cp_cco_action_cco__unassoc_stop (&cp);
+ cp_av_cco_action_cco__unassoc_stop (&cp);
test_action_uninit (&cp);
}
@@ -871,7 +874,7 @@ test_case_sta_authentication (test_t test)
mme.peer.tei = 0x2;
cp_secu_protocol_run_new (&mme.prun, 0, &cp.rnd);
- cp_cco_action_cco__cm_get_key_req_pid0 (&cp, &mme);
+ cp_av_cco_action_cco__cm_get_key_req_pid0 (&cp, &mme);
test_fail_if (cp_sta_get_assoc_confirmed (&cp, sta) != true);
@@ -903,7 +906,7 @@ test_case_sta_tei_expires (test_t test)
cp_sta_set_authenticated (&cp, sta, true);
cp_sta_own_data_set_tei (&cp, 244);
cp_sta_own_data_set_cco_status (&cp, true);
- cp_cco_action_tei_expired (&cp, sta);
+ cp_av_cco_action_tei_expired (&cp, sta);
slab_release (sta);
test_begin (test, "Verify the post event")
@@ -939,13 +942,13 @@ test_case_sta_cc_leave (test_t test)
msg.peer.vlan_tci = 0;
msg.mmtype = CC_LEAVE_REQ;
- cp_cco_action_cco__cc_leave_req (&cp, &msg);
+ cp_av_cco_action_cco__cc_leave_req (&cp, &msg);
test_fail_if (sta->tei_lease_date_ms != CP_STA_MGR_STATION_RELEASE_MS +
cp_sta_core_get_date_ms (&cp) - 10);
slab_release (sta);
- cp_cco_action_cco__cc_leave_req (&cp, &msg);
+ cp_av_cco_action_cco__cc_leave_req (&cp, &msg);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 1);
test_fail_unless (sta == NULL);
test_action_uninit (&cp);
@@ -968,7 +971,7 @@ test_case_sta_cc_leave (test_t test)
sta = cp_sta_mgr_sta_add (&cp, net, 1, 2);
sta->cco_cap = 1;
cp_sta_set_authenticated (&cp, sta, true);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) == false);
@@ -978,8 +981,8 @@ test_case_sta_cc_leave (test_t test)
msg.peer.vlan_tci = 0;
msg.mmtype = CC_LEAVE_REQ;
- cp_cco_action_cco__cc_leave_req (&cp, &msg);
- cp_cco_action_cco_selection__clear (&cp);
+ cp_av_cco_action_cco__cc_leave_req (&cp, &msg);
+ cp_av_cco_action_cco_selection__clear (&cp);
test_fail_if (sta->tei_lease_date_ms != CP_STA_MGR_STATION_RELEASE_MS +
cp_sta_core_get_date_ms (&cp) - 10);
@@ -1005,7 +1008,7 @@ test_case_sta_release_tei (test_t test)
cp_tei_t sta_tei;
test_action_init (&cp);
- sta_tei = cp_cco_action_tei_compute (&cp);
+ sta_tei = cp_av_cco_action_tei_compute (&cp);
net = cp_sta_mgr_add_avln (&cp, 1, 1);
cp_sta_own_data_set_tei (&cp, sta_tei + 1);
@@ -1020,7 +1023,7 @@ test_case_sta_release_tei (test_t test)
msg.peer.vlan_tci = 0;
msg.mmtype = CC_LEAVE_REQ;
- cp_cco_action_cco__cc_leave_req (&cp, &msg);
+ cp_av_cco_action_cco__cc_leave_req (&cp, &msg);
test_fail_if (sta->tei_lease_date_ms != CP_STA_MGR_STATION_RELEASE_MS +
cp_sta_core_get_date_ms (&cp) - 10);
@@ -1068,22 +1071,22 @@ test_case_cco_selection (test_t test)
cp_sta_own_data_set_mac_address (&cp, 1);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 3);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
- sta = cp_cco_action_cco_selection__selection (&cp);
+ sta = cp_av_cco_action_cco_selection__selection (&cp);
test_fail_unless (cp_sta_get_mac_address (sta) == 3);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 3);
- cp_cco_action_cco_selection__sta_remove (&cp, sta);
+ cp_av_cco_action_cco_selection__sta_remove (&cp, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
- cp_cco_action_cco_selection__sta_remove (&cp, sta);
+ cp_av_cco_action_cco_selection__sta_remove (&cp, sta);
slab_release (sta);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) ==
@@ -1096,33 +1099,33 @@ test_case_cco_selection (test_t test)
own->cco_prefered = true;
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 3);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
- sta = cp_cco_action_cco_selection__selection (&cp);
+ sta = cp_av_cco_action_cco_selection__selection (&cp);
test_fail_unless (sta == NULL);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) ==
true);
- /* Configure the test to choose station 3 as CCo cause of the CCo
+ /* Configure the test to choose station 3 as CCo cause of the CCo
* level. */
own->cco_prefered = false;
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
sta->cco_cap = 0;
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 3);
sta->cco_cap = 1;
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
- sta = cp_cco_action_cco_selection__selection (&cp);
+ sta = cp_av_cco_action_cco_selection__selection (&cp);
test_fail_unless (cp_sta_get_mac_address (sta) == 3);
slab_release (sta);
diff --git a/cesar/cp/cco/action/test/src/action_gen_nek.c b/cesar/cp/av/cco/action/test/utest2/src/action_gen_nek.c
index ea2f334c10..bd56e58785 100644
--- a/cesar/cp/cco/action/test/src/action_gen_nek.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/action_gen_nek.c
@@ -36,6 +36,7 @@
#include "cp/cco/action/cco_action.h"
#include "cp/cco/action/inc/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
#include "cp/inc/context.h"
#include "stdio.h"
@@ -57,7 +58,7 @@ test_case_gen_nek (test_t test)
cp_secu_generate_key(&cp, lib_rnd32 (&cp.rnd),
5, &computed_keys);
lib_rnd_init (&cp.rnd, 0x12345678);
- cp_cco_action_cco__cco_nek_change (&cp);
+ cp_av_cco_action_cco__cco_nek_change (&cp);
for (i = 0; i < COUNT (cp.cco_action.nek_new.key); i++)
{
test_fail_unless (cp.cco_action.nek_new.key[i]
diff --git a/cesar/cp/cco/action/test/src/core_stub.c b/cesar/cp/av/cco/action/test/utest2/src/core_stub.c
index 6f6ab9333e..6f6ab9333e 100644
--- a/cesar/cp/cco/action/test/src/core_stub.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/core_stub.c
diff --git a/cesar/cp/cco/action/test/src/fsm_handover.c b/cesar/cp/av/cco/action/test/utest2/src/fsm_handover.c
index f953e3bbf2..4d7de47039 100644
--- a/cesar/cp/cco/action/test/src/fsm_handover.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/fsm_handover.c
@@ -19,13 +19,15 @@
#include "cp/cp.h"
#include "cl/cl.h"
#include "mac/sar/sar.h"
-#include "cp/cco/action/handover.h"
+#include "cp/av/cco/action/handover.h"
+#include "cp/av/cco/action/cco_action.h"
#include "cp/msg/msg.h"
#include "cp/beacon/beacon.h"
#include "cp/inc/context.h"
#include "cl/inc/context.h"
#include "mac/sar/inc/context.h"
+#include "cp/av/cco/action/inc/cco_action.h"
static u8 buffer[ETH_PACKET_MAX_SIZE];
@@ -91,13 +93,13 @@ test_case__handover_discover_done (test_t test)
cp_sta_set_authenticated (&cp, sta, true);
sta->cco_cap = 1;
/* Add the station to the selection process. */
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
}
/* Launch the test. */
handover_req = false;
- cp_cco_action_handover__discover_done (&cp);
+ cp_av_cco_action_handover__discover_done (&cp);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) == true);
test_fail_unless (handover_req == false);
@@ -124,7 +126,6 @@ test_case__handover_discover_done (test_t test)
mac_config_t mac_config;
cp_net_t *net;
cp_sta_t *sta;
- cp_sta_own_data_t *own;
uint i;
/* Initialise the modules. */
@@ -152,7 +153,7 @@ test_case__handover_discover_done (test_t test)
cp_sta_own_data_set_tei (&cp, 1);
cp_sta_own_data_set_authenticated_status (&cp, true);
cp_sta_own_data_set_cco_status (&cp, true);
- own = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_mgr_get_sta_own_data (&cp);
/* Add some stations. */
for (i = 2; i < 10; i++)
@@ -162,7 +163,7 @@ test_case__handover_discover_done (test_t test)
if (i == 2)
sta->cco_cap = 1;
/* Add the station to the selection process. */
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
}
@@ -171,7 +172,7 @@ test_case__handover_discover_done (test_t test)
handover_req_peer_mac_addr = 0;
handover_req_peer_tei = 0;
- cp_cco_action_handover__start (&cp);
+ cp_av_cco_action_handover__start (&cp);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) == false);
test_fail_unless (handover_req == true);
test_fail_unless (handover_req_peer_tei == 2);
@@ -184,16 +185,16 @@ test_case__handover_discover_done (test_t test)
sta = cp_sta_mgr_sta_get_from_mac (&cp, 2);
sta->cco_cap = 0;
- cp_cco_action_cco_selection__sta_remove (&cp, sta);
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_remove (&cp, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
sta = cp_sta_mgr_sta_get_from_mac (&cp, 4);
sta->cco_cap = 1;
- cp_cco_action_cco_selection__sta_add (&cp, net, sta);
+ cp_av_cco_action_cco_selection__sta_add (&cp, net, sta);
slab_release (sta);
- cp_cco_action_handover__start (&cp);
+ cp_av_cco_action_handover__start (&cp);
test_fail_unless (heap_empty (&cp.cco_action.selection_heap) == false);
test_fail_unless (handover_req == true);
test_fail_unless (handover_req_peer_tei == 4);
@@ -273,7 +274,7 @@ cp_msg_cc_handover_info_ind_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
}
void
-cp_beacon_cco_handover (cp_t *ctx, cp_tei_t tei)
+cp_av_beacon_cco_handover (cp_t *ctx, cp_tei_t tei)
{
beacon_handover_cco_new_tei = tei;
}
diff --git a/cesar/cp/cco/action/test/src/garbage.c b/cesar/cp/av/cco/action/test/utest2/src/garbage.c
index 95e237118a..95e237118a 100644
--- a/cesar/cp/cco/action/test/src/garbage.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/garbage.c
diff --git a/cesar/cp/cco/action/test/src/pbproc_stub.c b/cesar/cp/av/cco/action/test/utest2/src/pbproc_stub.c
index 17f1ec5710..17f1ec5710 100644
--- a/cesar/cp/cco/action/test/src/pbproc_stub.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/pbproc_stub.c
diff --git a/cesar/cp/cco/action/test/src/sar_stub.c b/cesar/cp/av/cco/action/test/utest2/src/sar_stub.c
index 4a65d0b9c1..4a65d0b9c1 100644
--- a/cesar/cp/cco/action/test/src/sar_stub.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/sar_stub.c
diff --git a/cesar/cp/cco/action/test/src/secu_stub.c b/cesar/cp/av/cco/action/test/utest2/src/secu_stub.c
index afcdc3fbe1..afcdc3fbe1 100644
--- a/cesar/cp/cco/action/test/src/secu_stub.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/secu_stub.c
diff --git a/cesar/cp/cco/action/test/src/sta_action.c b/cesar/cp/av/cco/action/test/utest2/src/sta_action.c
index 94cc1a03eb..b871fb1786 100644
--- a/cesar/cp/cco/action/test/src/sta_action.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/sta_action.c
@@ -16,7 +16,7 @@
#include "cp/sta/action/action.h"
void
-cp_sta_action_assoc__authenticated__renew (cp_t *ctx)
+cp_av_sta_action_assoc__authenticated__renew (cp_t *ctx)
{
}
diff --git a/cesar/cp/cco/action/test/src/status.c b/cesar/cp/av/cco/action/test/utest2/src/status.c
index c625c8ffa9..ff79a69319 100644
--- a/cesar/cp/cco/action/test/src/status.c
+++ b/cesar/cp/av/cco/action/test/utest2/src/status.c
@@ -27,6 +27,7 @@
/* Public interfaces. */
#include "cp/cp.h"
#include "cp/cco/action/cco_action.h"
+#include "cp/av/cco/action/cco_action.h"
/* Override interfaces. */
#include "cp/inc/context.h"
@@ -64,7 +65,7 @@ test_suite__cco_action__case__Usta_to_cco (test_t test)
/* Starting the CCo. */
central_beacon = false;
- cp_cco_action_cco__unassoc_start (&cp);
+ cp_av_cco_action_cco__unassoc_start (&cp);
/* The station shall now have a TEI.
* It shall be authenticated.
@@ -126,7 +127,7 @@ test_suite__cco_action__case__sta_to_cco (test_t test)
/* Starting the CCo. */
central_beacon = false;
- cp_cco_action_cco__unassoc_start (&cp);
+ cp_av_cco_action_cco__unassoc_start (&cp);
/* The station shall now have a TEI.
* It shall be authenticated.
@@ -191,7 +192,7 @@ test_suite__cco_action__case__cco_to_station (test_t test)
cp_sta_own_data_set_cco_status (&cp, true);
/* Stopping the CCo. */
- cp_cco_action_cco__assoc_stop (&cp);
+ cp_av_cco_action_cco__assoc_stop (&cp);
/* The station shall keep it's TEI.
* It shall be authenticated.
@@ -261,7 +262,7 @@ test_suite__cco_action__case__cco_to_unassociated_station (test_t test)
slab_release (sta);
/* Launch the test. */
- cp_cco_action_cco__unassoc_stop (&cp);
+ cp_av_cco_action_cco__unassoc_stop (&cp);
/* TEI, auth and OUR AVLN are reseted by UNASSOCIATED enter function.
*/
diff --git a/cesar/cp/av/cco/bw/Module b/cesar/cp/av/cco/bw/Module
index 2ba12b179c..6d551d6d8b 100644
--- a/cesar/cp/av/cco/bw/Module
+++ b/cesar/cp/av/cco/bw/Module
@@ -1 +1,3 @@
-SOURCES:=bw.c
+SOURCES := bw.c
+
+MODULES := cp/cco/bw
diff --git a/cesar/cp/av/cco/bw/stub/Module b/cesar/cp/av/cco/bw/stub/Module
index 2ba12b179c..d76f250a93 100644
--- a/cesar/cp/av/cco/bw/stub/Module
+++ b/cesar/cp/av/cco/bw/stub/Module
@@ -1 +1,3 @@
-SOURCES:=bw.c
+SOURCES := bw.c
+
+MODULES := cp/cco/bw/stub
diff --git a/cesar/cp/av/cco/region/Module b/cesar/cp/av/cco/region/Module
index c320911efa..71bd970a97 100644
--- a/cesar/cp/av/cco/region/Module
+++ b/cesar/cp/av/cco/region/Module
@@ -1 +1,3 @@
-SOURCES:=region.c
+SOURCES := region.c
+
+MODULES := cp/cco/region
diff --git a/cesar/cp/av/cco/region/stub/Module b/cesar/cp/av/cco/region/stub/Module
index c320911efa..ba66049fea 100644
--- a/cesar/cp/av/cco/region/stub/Module
+++ b/cesar/cp/av/cco/region/stub/Module
@@ -1 +1,3 @@
-SOURCES:=region.c
+SOURCES := region.c
+
+MODULES := cp/cco/region/stub
diff --git a/cesar/cp/av/cl_interf/test/utest/Config b/cesar/cp/av/cl_interf/test/utest/Config
new file mode 100644
index 0000000000..bf964586c0
--- /dev/null
+++ b/cesar/cp/av/cl_interf/test/utest/Config
@@ -0,0 +1,2 @@
+CONFIG_CP_AV = y
+CONFIG_CP_EOC = n
diff --git a/cesar/cp/av/cl_interf/test/utest/Makefile b/cesar/cp/av/cl_interf/test/utest/Makefile
new file mode 100644
index 0000000000..08cbffd467
--- /dev/null
+++ b/cesar/cp/av/cl_interf/test/utest/Makefile
@@ -0,0 +1,15 @@
+BASE = ../../../../..
+
+INCLUDES = cp/av/cl_interf/test/utest/override
+
+HOST_PROGRAMS = test-cl-interf
+
+test-cl-interf_SOURCES = test-cl-interf.c test.c
+test-cl-interf_MODULES = lib cp/cl_interf cp/av/sta/mgr mac/common \
+ cp/secu cp/av/fsm/stub cp/av/cco/action/stub \
+ cp/sta/core/stub mac/sar/stub cl/stub \
+ bsu/stub cp/msg/stub hle/tools hal/ipmbox/stub \
+ bufmgr/stub cp/sta/core/stub
+test-cl-interf_CONFIG_MODULES = cp
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cl_interf/test/doc/Makefile b/cesar/cp/av/cl_interf/test/utest/doc/Makefile
index 27949031b7..7ead606995 100644
--- a/cesar/cp/cl_interf/test/doc/Makefile
+++ b/cesar/cp/av/cl_interf/test/utest/doc/Makefile
@@ -9,12 +9,12 @@ odt: $(ODT)
html: $(HTML)
-%.odt: %.txt
+%.odt: %.txt
rst2odt.py $< $@
%.html: %.txt
rst2html $< $@
-clean:
+clean:
rm -f $(ODT)
rm -f $(HTML)
diff --git a/cesar/cp/cl_interf/test/doc/cl-interf.txt b/cesar/cp/av/cl_interf/test/utest/doc/cl-interf.txt
index fd7607fba9..0fc5d0d248 100644
--- a/cesar/cp/cl_interf/test/doc/cl-interf.txt
+++ b/cesar/cp/av/cl_interf/test/utest/doc/cl-interf.txt
@@ -16,7 +16,8 @@ It shall initialise:
Environment
- Once the init function has be called all the callbacks function of the interface module shall be called to verify if the connectivity is done.
+ Once the init function has be called all the callbacks function of the
+ interface module shall be called to verify if the connectivity is done.
The eCos mailbox shall be empty as the buffer list.
Receiving a MME
@@ -27,7 +28,8 @@ Environment
Result
- It shall raise the flag in STA Core and create a message to post it in the mailbox.
+ It shall raise the flag in STA Core and create a message to post it in the
+ mailbox.
Processing a MME
----------------
@@ -38,15 +40,15 @@ of MME. This shall then call the msg dispatch function.
Test 1 : Non Fragmented MME.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+
Environment
Stub the function of the MSG to simulate the data of the MME.
Result
- The MSG function which read the header of the MME shall return the MME rx data.
- The MSG dispatch function is called.
+ The MSG function which read the header of the MME shall return the MME rx
+ data. The MSG dispatch function is called.
Test 2 : Fragmented MME.
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -57,20 +59,22 @@ Environment
Result
- The MSG function which read the header of the MME shall return the MME rx data.
-
+ The MSG function which read the header of the MME shall return the MME rx
+ data.
+
The MME shall be copied in some blocks.
Add and Get a TX buffer
-----------------------
Environment
-
+
Add a buffer to the list of buffer and get it.
Result
- The function shall return a cp_mme_tx_t object containing the address of the buffer instantiated in the test function.
+ The function shall return a cp_mme_tx_t object containing the address of the
+ buffer instantiated in the test function.
Sending a MME
-------------
diff --git a/cesar/cp/cl_interf/test/override/cp/inc/context.h b/cesar/cp/av/cl_interf/test/utest/override/cp/inc/context.h
index c22f6c513e..c22f6c513e 100644
--- a/cesar/cp/cl_interf/test/override/cp/inc/context.h
+++ b/cesar/cp/av/cl_interf/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/cl_interf/test/override/cp/sta/core/core.h b/cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/core.h
index 55c5f5a113..55c5f5a113 100644
--- a/cesar/cp/cl_interf/test/override/cp/sta/core/core.h
+++ b/cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/core.h
diff --git a/cesar/cp/cl_interf/test/override/cp/sta/core/defs.h b/cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/defs.h
index a4da58b467..a4da58b467 100644
--- a/cesar/cp/cl_interf/test/override/cp/sta/core/defs.h
+++ b/cesar/cp/av/cl_interf/test/utest/override/cp/sta/core/defs.h
diff --git a/cesar/cp/cl_interf/test/override/mac/sar/inc/context.h b/cesar/cp/av/cl_interf/test/utest/override/mac/sar/inc/context.h
index 9e7c6f07ca..9e7c6f07ca 100644
--- a/cesar/cp/cl_interf/test/override/mac/sar/inc/context.h
+++ b/cesar/cp/av/cl_interf/test/utest/override/mac/sar/inc/context.h
diff --git a/cesar/cp/cl_interf/test/src/test-cl-interf.c b/cesar/cp/av/cl_interf/test/utest/src/test-cl-interf.c
index 8f820da587..72339acea3 100644
--- a/cesar/cp/cl_interf/test/src/test-cl-interf.c
+++ b/cesar/cp/av/cl_interf/test/utest/src/test-cl-interf.c
@@ -23,7 +23,7 @@
#include "lib/swap.h"
#include "lib/bitstream.h"
-#include "cp/cl_interf/test/test.h"
+#include "test.h"
#include "cp/cl_interf/cl_interf.h"
#include "cp/cl_interf/inc/cl_interf.h"
#include "cp/cl_interf/inc/cl_interf_msg.h"
diff --git a/cesar/cp/cl_interf/test/src/test.c b/cesar/cp/av/cl_interf/test/utest/src/test.c
index e07322a9be..e07322a9be 100644
--- a/cesar/cp/cl_interf/test/src/test.c
+++ b/cesar/cp/av/cl_interf/test/utest/src/test.c
diff --git a/cesar/cp/cl_interf/test/test.h b/cesar/cp/av/cl_interf/test/utest/test.h
index baca0c178d..baca0c178d 100644
--- a/cesar/cp/cl_interf/test/test.h
+++ b/cesar/cp/av/cl_interf/test/utest/test.h
diff --git a/cesar/cp/av/fsm/Config b/cesar/cp/av/fsm/Config
new file mode 100644
index 0000000000..5c24cb95ea
--- /dev/null
+++ b/cesar/cp/av/fsm/Config
@@ -0,0 +1 @@
+CONFIG_CP_FSM_DEF = "cp/av/fsm/src/fsm/cp.fsm"
diff --git a/cesar/cp/av/fsm/Module b/cesar/cp/av/fsm/Module
new file mode 100644
index 0000000000..03e2018948
--- /dev/null
+++ b/cesar/cp/av/fsm/Module
@@ -0,0 +1,40 @@
+SOURCES := tables.c
+
+MODULES := cp/fsm
+
+ifndef $(MODULE_VAR)_ONCE
+$(MODULE_VAR)_ONCE := 1$(CONFIG_CP_FSM_DEF)
+
+cp_fsm_defs_h := $(OBJ_INC_DIR)/cp_fsm_defs.h
+cp_fsm_tables_h = $(OBJ_INC_DIR)/cp_fsm_tables.h
+CLEAN_FILES += $(cp_fsm_defs_h) $(cp_fsm_tables_h)
+
+COMPILE_DEPS += $(cp_fsm_defs_h)
+
+cp_fsm_deps = $(CONFIG_CP_FSM_DEF:"%"=%) \
+ $(call src2src,cp.conf template_defs.h \
+ template_tables.h,$(MODULE)/src/fsm)
+
+$(cp_fsm_defs_h) $(cp_fsm_tables_h): $(cp_fsm_deps) $(DFAGEN) \
+ $(OBJ_INC_DIR_STAMP)
+ echo $(cp_fsm_deps) ; \
+ python $(DFAGEN) -O $(OBJ_INC_DIR) \
+ -o c -d $< -c $(filter %.conf,$^) -p cp_fsm
+
+CLEAN_FILES += $(OBJ_DIR)/cp_fsm.png $(OBJ_DIR)/cp_fsm.dot
+
+$(OBJ_DIR)/cp_fsm.png: $(OBJ_DIR)/cp_fsm.dot $(OBJ_DIR_STAMP)
+ dot -Tpng -o $@ $<
+
+$(OBJ_DIR)/cp_fsm.dot: $(cp_fsm_deps) $(DFAGEN) $(OBJ_DIR_STAMP)
+ python $(DFAGEN) -O $(OBJ_DIR) -o dot -d $< -p cp_fsm
+
+$(call src2obj,cp/av/fsm/src/tables.c,target): $(cp_fsm_tables_h)
+
+else
+# This module rules depend on a configuration item, it need work to be used in
+# several build type.
+ifneq ($($(MODULE_VAR)_ONCE),1$(CONFIG_CP_FSM_DEF))
+$(error Module not safe for multiple build types)
+endif
+endif
diff --git a/cesar/cp/fsm/src/fsm/cp.conf b/cesar/cp/av/fsm/src/fsm/cp.conf
index 2c50e8d998..2c50e8d998 100644
--- a/cesar/cp/fsm/src/fsm/cp.conf
+++ b/cesar/cp/av/fsm/src/fsm/cp.conf
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/av/fsm/src/fsm/cp.fsm
index 7f75e68573..854d72e5ed 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/av/fsm/src/fsm/cp.fsm
@@ -2,12 +2,12 @@ Control Plane FSM
FSM for control plane.
States:
- UNASSOCIATED [enter=cp_sta_action_assoc__unassociated__enter]
+ UNASSOCIATED [enter=cp_av_sta_action_assoc__unassociated__enter]
WAIT_ASSOC_CONF [enter=cp_sta_action_assoc__start_retry_timer leave=cp_sta_action_assoc__stop_retry_timer]
ASSOCIATED [enter=cp_sta_action_assoc__start_retry_timer leave=cp_sta_action_assoc__stop_retry_timer]
- AUTHENTICATED [leave=cp_sta_action_assoc__authenticated__leave]
+ AUTHENTICATED [leave=cp_av_sta_action_assoc__authenticated__leave]
LEAVING
- LEAVE_WAIT [enter=cp_sta_action_assoc__leave_wait__enter]
+ LEAVE_WAIT [enter=cp_av_sta_action_assoc__leave_wait__enter]
ASSOC_CCO
ASSOC_UCCO
@@ -16,11 +16,11 @@ States:
SC_TEK_EXCHANGED
SC_NMK_EXCHANGED
- *SC_IDLE [enter=cp_sta_action_sc__sc_idle__enter leave=cp_sta_action_sc__sc_idle__leave]
+ *SC_IDLE [enter=cp_av_sta_action_sc__sc_idle__enter leave=cp_av_sta_action_sc__sc_idle__leave]
Idle state of the SC (simple connect) sub FSM.
SC_ADD
Wait for a CM_SC_JOIN_REQ MME.
- SC_JOIN [enter=cp_sta_action_sc__sc_join__enter leave=cp_sta_action_sc__sc_join__leave]
+ SC_JOIN [enter=cp_av_sta_action_sc__sc_join__enter leave=cp_av_sta_action_sc__sc_join__leave]
Send periodically CM_SC_JOIN_REQ MME.
SC_WAIT_BEACON
Wait for beacon to start association.
@@ -35,17 +35,17 @@ States:
STARTED
STOPPING
- *IDLE [enter=cp_sta_action_poweron__idle__enter]
- POWERON [enter=cp_sta_action_poweron__poweron__enter leave=cp_sta_action_poweron__poweron__leave]
+ *IDLE [enter=cp_av_sta_action_poweron__idle__enter]
+ POWERON [enter=cp_av_sta_action_poweron__poweron__enter leave=cp_av_sta_action_poweron__poweron__leave]
POWERON_JOINING
- USTA [enter=cp_sta_action_poweron__usta__enter leave=cp_sta_action_poweron__usta__leave]
- USTA_JOINING [enter=cp_sta_action_poweron__usta_joining__enter]
+ USTA [enter=cp_av_sta_action_poweron__usta__enter leave=cp_av_sta_action_poweron__usta__leave]
+ USTA_JOINING [enter=cp_av_sta_action_poweron__usta_joining__enter]
UCCO
STA
- CCO [enter=cp_sta_action_poweron_cco__enter leave=cp_sta_action_poweron_cco__leave]
+ CCO [enter=cp_av_sta_action_poweron_cco__enter leave=cp_av_sta_action_poweron_cco__leave]
CCO_LEAVING
CCO_LEAVING_HOIP
- UNASSOCIATING [enter=cp_sta_action_unassoc__unassoc__enter]
+ UNASSOCIATING [enter=cp_av_sta_action_unassoc__unassoc__enter]
SC_USTA
Same as USTA, but the STA is doing SC procedure at the same time.
@@ -79,7 +79,7 @@ States:
STA_HANDOVER_WAIT_COUNTDOWN_EXPIRES
The station is ready to become the new CCo and only waits the end of the HANDOVER countdown.
- *CCO_NEK_CHANGE_IDLE [enter=cp_cco_action_nek_change_prevent]
+ *CCO_NEK_CHANGE_IDLE [enter=cp_av_cco_action_nek_change_prevent]
NEK change FSM in IDLE state.
CCO_NEK_CHANGE_WAIT_STA_CNF
Wait for the station requested to answer the request of the first CM_SET_KEY.
@@ -248,18 +248,18 @@ Events:
CM_MME_ERROR_IND
UNASSOCIATED:
- to_assoc -> WAIT_ASSOC_CONF [cp_sta_action_assoc__unassociated__to_assoc]
+ to_assoc -> WAIT_ASSOC_CONF [cp_av_sta_action_assoc__unassociated__to_assoc]
send CC_ASSOC.REQ
- to_sc_assoc -> SC_WAIT_ASSOC_CONF [cp_sta_action_assoc__unassociated__to_assoc]
+ to_sc_assoc -> SC_WAIT_ASSOC_CONF [cp_av_sta_action_assoc__unassociated__to_assoc]
send CC_ASSOC.REQ
assoc_become_cco -> ASSOC_CCO [NULL]
WAIT_ASSOC_CONF:
- CC_ASSOC_CNF: ok -> ASSOCIATED [cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf]
+ CC_ASSOC_CNF: ok -> ASSOCIATED [cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf]
send CM_GET_KEY.REQ
CC_ASSOC_CNF: nok -> UNASSOCIATED
CC_ASSOC_CNF: unrelated -> .
- assoc_timeout: retry -> . [cp_sta_action_assoc__wait_assoc_cnf__timeout]
+ assoc_timeout: retry -> . [cp_av_sta_action_assoc__wait_assoc_cnf__timeout]
send CC_ASSOC.REQ
assoc_timeout: no retry -> UNASSOCIATED
to_leave -> UNASSOCIATED [NULL]
@@ -275,78 +275,78 @@ ASSOC_UCCO:
assoc_become_cco -> ASSOC_CCO [NULL]
SC_WAIT_ASSOC_CONF:
- CC_ASSOC_CNF: ok -> SC_ASSOCIATED [cp_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf]
+ CC_ASSOC_CNF: ok -> SC_ASSOCIATED [cp_av_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf]
send CM_GET_KEY.REQ
CC_ASSOC_CNF: nok -> UNASSOCIATED
CC_ASSOC_CNF: unrelated -> .
- assoc_timeout: retry -> . [cp_sta_action_assoc__sc_wait_assoc_cnf__timeout]
+ assoc_timeout: retry -> . [cp_av_sta_action_assoc__sc_wait_assoc_cnf__timeout]
send CC_ASSOC.REQ
assoc_timeout: no retry -> UNASSOCIATED
to_leave -> UNASSOCIATED [NULL]
ASSOCIATED:
- CM_GET_KEY_CNF_PID0: ok -> AUTHENTICATED [cp_sta_action_assoc__associated__cm_get_key_cnf_pid_0]
+ CM_GET_KEY_CNF_PID0: ok -> AUTHENTICATED [cp_av_sta_action_assoc__associated__cm_get_key_cnf_pid_0]
CM_GET_KEY_CNF_PID0: nok -> UNASSOCIATED
CM_GET_KEY_CNF_PID0: unrelated -> .
- assoc_timeout -> UNASSOCIATED [cp_sta_action_assoc__associated__timeout]
- to_leave -> UNASSOCIATED [cp_sta_action_assoc__associated__to_leave]
+ assoc_timeout -> UNASSOCIATED [cp_av_sta_action_assoc__associated__timeout]
+ to_leave -> UNASSOCIATED [cp_av_sta_action_assoc__associated__to_leave]
SC_ASSOCIATED:
- CM_GET_KEY_REQ_PID3: ok -> SC_TEK_EXCHANGED [cp_sta_action_assoc__sc_associated__cm_get_key_req_pid_3]
+ CM_GET_KEY_REQ_PID3: ok -> SC_TEK_EXCHANGED [cp_av_sta_action_assoc__sc_associated__cm_get_key_req_pid_3]
send CM_GET_KEY_CNF_PID3
CM_GET_KEY_REQ_PID3: unrelated -> .
assoc_timeout -> UNASSOCIATED [NULL]
- to_leave -> UNASSOCIATED [cp_sta_action_assoc__associated__to_leave]
+ to_leave -> UNASSOCIATED [cp_av_sta_action_assoc__associated__to_leave]
SC_TEK_EXCHANGED:
- CM_SET_KEY_REQ_PID3: ok -> SC_NMK_EXCHANGED [cp_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3]
+ CM_SET_KEY_REQ_PID3: ok -> SC_NMK_EXCHANGED [cp_av_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3]
send CM_SET_KEY_CNF_PID3 and CM_GET_KEY_CNF_PID0
CM_SET_KEY_REQ_PID3: unrelated -> .
assoc_timeout -> UNASSOCIATED [NULL]
- to_leave -> UNASSOCIATED [cp_sta_action_assoc__associated__to_leave]
+ to_leave -> UNASSOCIATED [cp_av_sta_action_assoc__associated__to_leave]
SC_NMK_EXCHANGED:
- CM_GET_KEY_CNF_PID0: ok -> AUTHENTICATED [cp_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0]
+ CM_GET_KEY_CNF_PID0: ok -> AUTHENTICATED [cp_av_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0]
CM_GET_KEY_CNF_PID0: unrelated -> .
CM_GET_KEY_CNF_PID0: nok -> UNASSOCIATED
assoc_timeout -> UNASSOCIATED [NULL]
- to_leave -> UNASSOCIATED [cp_sta_action_assoc__associated__to_leave]
+ to_leave -> UNASSOCIATED [cp_av_sta_action_assoc__associated__to_leave]
AUTHENTICATED:
- nek_request -> . [cp_sta_action_assoc__authenticated__nek_request]
- renew -> . [cp_sta_action_assoc__authenticated__renew]
+ nek_request -> . [cp_av_sta_action_assoc__authenticated__nek_request]
+ renew -> . [cp_av_sta_action_assoc__authenticated__renew]
send CC_ASSOC.REQ for renewal
- CC_ASSOC_CNF -> . [cp_sta_action_assoc__authenticated__cc_assoc_cnf]
- CM_SET_KEY_REQ_PID1 -> . [cp_sta_action_assoc__authenticated__cm_set_key_req_pid_1]
+ CC_ASSOC_CNF -> . [cp_av_sta_action_assoc__authenticated__cc_assoc_cnf]
+ CM_SET_KEY_REQ_PID1 -> . [cp_av_sta_action_assoc__authenticated__cm_set_key_req_pid_1]
send CM_SET_KEY.CNF
- CM_GET_KEY_CNF_PID1 -> . [cp_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1]
- to_leave:cco -> LEAVING [cp_sta_action_assoc__authenticated__to_leave]
+ CM_GET_KEY_CNF_PID1 -> . [cp_av_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1]
+ to_leave:cco -> LEAVING [cp_av_sta_action_assoc__authenticated__to_leave]
send CC_LEAVE.REQ
to_leave:no_cco -> UNASSOCIATED
No CCo is present to send a CC_LEAVE.REQ MME.
- CC_LEAVE_IND: ok -> LEAVE_WAIT [cp_sta_action_assoc__authenticated__cc_leave_ind]
+ CC_LEAVE_IND: ok -> LEAVE_WAIT [cp_av_sta_action_assoc__authenticated__cc_leave_ind]
send CC_LEAVE.RSP
CC_LEAVE_IND: nok -> .
- BEACON -> . [cp_sta_action_assoc__authenticated__beacon]
+ BEACON -> . [cp_av_sta_action_assoc__authenticated__beacon]
clear missed beacon counter
- BEACON_NOT_RECEIVED: avln failure -> UNASSOCIATED [cp_sta_action_assoc__authenticated__beacon_not_received]
+ BEACON_NOT_RECEIVED: avln failure -> UNASSOCIATED [cp_av_sta_action_assoc__authenticated__beacon_not_received]
cleanup data plane
BEACON_NOT_RECEIVED: else -> .
assoc_become_cco -> ASSOC_CCO [NULL]
ASSOCIATED, AUTHENTICATED:
- CC_SET_TEI_MAP_IND -> . [cp_sta_action_process_cc_set_tei_map_ind]
+ CC_SET_TEI_MAP_IND -> . [cp_av_sta_action_process_cc_set_tei_map_ind]
whoru_timeout -> . [cp_sta_action_whoru_timeout_process]
LEAVING:
- CC_LEAVE_CNF: ok -> UNASSOCIATED [cp_sta_action_assoc__leaving__cc_leave_cnf]
+ CC_LEAVE_CNF: ok -> UNASSOCIATED [cp_av_sta_action_assoc__leaving__cc_leave_cnf]
cleanup data plane
CC_LEAVE_CNF: unrelated -> .
- assoc_timeout -> LEAVE_WAIT [cp_sta_action_assoc__leaving__timeout]
+ assoc_timeout -> LEAVE_WAIT [cp_av_sta_action_assoc__leaving__timeout]
send CC_LEAVE.REQ
LEAVE_WAIT:
- assoc_timeout -> UNASSOCIATED [cp_sta_action_assoc__leave_wait__timeout]
+ assoc_timeout -> UNASSOCIATED [cp_av_sta_action_assoc__leave_wait__timeout]
cleanup data plane
@@ -380,7 +380,7 @@ STARTED:
DRV_STA_SET_KEY_REQ -> . [cp_sta_action_drv__stopped__drv_sta_set_key_req]
DRV_MCAST_SET_LIST_REQ -> . [cp_sta_action_drv__drv_mcast_set_list_req]
- CM_UNASSOCIATED_STA_IND -> . [cp_sta_action_process_cm_unassociated_sta_ind]
+ CM_UNASSOCIATED_STA_IND -> . [cp_av_sta_action_process_cm_unassociated_sta_ind]
CM_SET_KEY_REQ -> . [cp_sta_action_process_cm_set_key_req]
CM_SET_KEY_CNF -> . [cp_sta_action_process_cm_set_key_cnf]
CM_GET_KEY_REQ -> . [cp_sta_action_process_cm_get_key_req]
@@ -402,7 +402,7 @@ STARTED:
CM_NW_STATS_REQ -> . [cp_sta_action_process_cm_nw_stats_req]
CM_LINK_STATS_REQ -> . [cp_sta_action_process_cm_link_stats_req]
IMAC_GET_DISCOVER_LIST_REQ -> . [cp_sta_action_vs__started__imac_get_discover_list_req]
- CC_DISCOVER_LIST_REQ -> . [cp_sta_action_process_cc_discover_list_req]
+ CC_DISCOVER_LIST_REQ -> . [cp_av_sta_action_process_cc_discover_list_req]
STOPPING:
stopped -> STOPPED [cp_sta_action_drv__stopping__stopped]
@@ -417,35 +417,35 @@ IDLE:
POWERON:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
- ustt_timeout -> . [cp_sta_action_poweron__poweron__ustt_timeout]
+ ustt_timeout -> . [cp_av_sta_action_poweron__poweron__ustt_timeout]
send CM_UNASSOCIATED_STA.IND if an AVLN is present
- btt_timeout: nid match cco -> CCO [cp_sta_action_poweron__poweron__btt_timeout]
+ btt_timeout: nid match cco -> CCO [cp_av_sta_action_poweron__poweron__btt_timeout]
btt_timeout: avln -> USTA
btt_timeout: no avln -> UCCO
- BEACON: nid match -> POWERON_JOINING [cp_sta_action_poweron__poweron__beacon]
+ BEACON: nid match -> POWERON_JOINING [cp_av_sta_action_poweron__poweron__beacon]
BEACON: no nid match -> .
to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
USTA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
- ustt_timeout -> . [cp_sta_action_poweron__usta__ustt_timeout]
+ ustt_timeout -> . [cp_av_sta_action_poweron__usta__ustt_timeout]
send CM_UNASSOCIATED_STA.IND if an AVLN is present
- BEACON: nid match -> USTA_JOINING [cp_sta_action_poweron__usta__beacon]
+ BEACON: nid match -> USTA_JOINING [cp_av_sta_action_poweron__usta__beacon]
BEACON: no nid match -> .
- net_list_empty -> UCCO [cp_cco_action_ucco_start]
- usta_ind: nid match cco -> CCO [cp_sta_action_poweron__usta__usta_ind]
+ net_list_empty -> UCCO [cp_av_cco_action_ucco_start]
+ usta_ind: nid match cco -> CCO [cp_av_sta_action_poweron__usta__usta_ind]
usta_ind: else -> .
to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
- DRV_STA_SC_REQ -> SC_USTA [cp_sta_action_drv__usta__drv_sta_sc]
+ DRV_STA_SC_REQ -> SC_USTA [cp_av_sta_action_drv__usta__drv_sta_sc]
Start the SC FSM.
SC_USTA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
- BEACON -> . [cp_sta_action_sc__sc_usta_track_beacon]
+ BEACON -> . [cp_av_sta_action_sc__sc_usta_track_beacon]
track AVLN.
net_list_empty -> SC_UCCO [NULL]
no more AVLN to track, go to SC_UCCO.
- sc_get_cco_functionality -> SC_CCO [cp_cco_action_cco__unassoc_start]
+ sc_get_cco_functionality -> SC_CCO [cp_av_cco_action_cco__unassoc_start]
Get CCo functionality.
sc_succeed -> SC_USTA_JOINING [NULL]
SC procedure finished, start association.
@@ -453,12 +453,12 @@ SC_USTA:
to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
POWERON_JOINING:
- BEACON_TIMER_EXPIRES -> . [cp_beacon_sta_update_beacon_data]
- left -> POWERON [cp_sta_action_poweron__poweron_joining__left]
+ BEACON_TIMER_EXPIRES -> . [cp_av_beacon_sta_update_beacon_data]
+ left -> POWERON [cp_av_sta_action_poweron__poweron_joining__left]
USTA_JOINING:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
- left -> USTA [cp_sta_action_poweron__usta_joining__left]
+ left -> USTA [cp_av_sta_action_poweron__usta_joining__left]
SC_USTA_JOINING:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
@@ -466,116 +466,116 @@ SC_USTA_JOINING:
SC procedure (association part), finished, we are now a STA in the AVLN.
left -> USTA [NULL]
SC procedure (association part) failed.
- to_stop -> UNASSOCIATING [cp_sta_action_poweron__joining__to_stop]
+ to_stop -> UNASSOCIATING [cp_av_sta_action_poweron__joining__to_stop]
POWERON_JOINING, USTA_JOINING:
joined -> STA [NULL]
- to_stop -> UNASSOCIATING [cp_sta_action_poweron__joining__to_stop]
+ to_stop -> UNASSOCIATING [cp_av_sta_action_poweron__joining__to_stop]
UCCO:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
- BEACON: nid match -> USTA_JOINING [cp_sta_action_poweron__ucco__beacon]
+ BEACON: nid match -> USTA_JOINING [cp_av_sta_action_poweron__ucco__beacon]
BEACON: no nid match -> USTA
- BEACON_WITH_SAME_NID -> USTA [cp_cco_action_ucco_stop]
- to_stop -> USTA [cp_cco_action_ucco__to_stop]
+ BEACON_WITH_SAME_NID -> USTA [cp_av_cco_action_ucco_stop]
+ to_stop -> USTA [cp_av_cco_action_ucco__to_stop]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ:ok -> CCO [cp_cco_action_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:ok -> CCO [cp_av_cco_action_ucco__cc_assoc_req]
CC_ASSOC_REQ:nok -> .
- DRV_STA_SC_REQ -> SC_UCCO [cp_sta_action_drv__ucco__drv_sta_sc]
+ DRV_STA_SC_REQ -> SC_UCCO [cp_av_sta_action_drv__ucco__drv_sta_sc]
Start the SC FSM.
SC_UCCO:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
- BEACON -> SC_USTA [cp_sta_action_sc__sc_ucco_track_beacon]
+ BEACON -> SC_USTA [cp_av_sta_action_sc__sc_ucco_track_beacon]
Still doing SC procedure, but in SC_USTA.
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
to_stop -> IDLE [cp_sta_action_poweron__many__to_idle]
- sc_get_cco_functionality -> SC_CCO [cp_cco_action_ucco__to_cco]
+ sc_get_cco_functionality -> SC_CCO [cp_av_cco_action_ucco__to_cco]
Get CCo functionality.
sc_failed -> UCCO [NULL]
SC failed, go back to normal.
sc_succeed -> SC_USTA_JOINING [NULL]
SC procedure finished, start association.
- CC_ASSOC_REQ:nok -> . [cp_cco_action_sc_ucco__cc_assoc_req]
+ CC_ASSOC_REQ:nok -> . [cp_av_cco_action_sc_ucco__cc_assoc_req]
CC_ASSOC_REQ:ok -> CCO
STA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
avln_failure -> POWERON [NULL]
left -> USTA [NULL]
- to_stop -> UNASSOCIATING [cp_sta_action_poweron__sta__to_stop]
- CC_HANDOVER_REQ -> HANDOVER_STA [cp_sta_action_handover__handover]
- HOIP_EXPIRED -> . [cp_sta_action_handover__sta_handover]
+ to_stop -> UNASSOCIATING [cp_av_sta_action_poweron__sta__to_stop]
+ CC_HANDOVER_REQ -> HANDOVER_STA [cp_av_sta_action_handover__handover]
+ HOIP_EXPIRED -> . [cp_av_sta_action_handover__sta_handover]
CC_WHO_RU_CNF -> . [cp_sta_action_process_cc_who_ru_cnf]
- DRV_STA_SC_REQ: sc_add -> SC_STA [cp_sta_action_drv__sta__drv_sta_sc]
+ DRV_STA_SC_REQ: sc_add -> SC_STA [cp_av_sta_action_drv__sta__drv_sta_sc]
DRV_STA_SC_REQ: sc_join -> .
Start the SC FSM only for SC ADD.
SC_STA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
- avln_failure -> POWERON [cp_sta_action_sc__sc_sta__avln_failure]
+ avln_failure -> POWERON [cp_av_sta_action_sc__sc_sta__avln_failure]
Stop SC procedure.
left -> SC_USTA [NULL]
- to_stop -> UNASSOCIATING [cp_sta_action_poweron__sta__to_stop]
+ to_stop -> UNASSOCIATING [cp_av_sta_action_poweron__sta__to_stop]
sc_failed -> STA [NULL]
sc_succeed -> STA [NULL]
CCO:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
- BEACON_WITH_SAME_NID -> . [cp_cco_action_beacon_with_same_nid]
- join_timeout: sta -> . [cp_sta_action_poweron__cco__join_timeout]
+ BEACON_WITH_SAME_NID -> . [cp_av_cco_action_beacon_with_same_nid]
+ join_timeout: sta -> . [cp_av_sta_action_poweron__cco__join_timeout]
join_timeout: no sta avln -> USTA
join_timeout: no sta no avln -> UCCO
- cco__all_sta_leaved -> UCCO [cp_cco_action_cco__to_ucco]
- to_stop -> CCO_LEAVING [cp_cco_action_drv_mac_stop]
- discover_info_updated -> . [cp_cco_action_cco__cc_discover_list_req]
+ cco__all_sta_leaved -> UCCO [cp_av_cco_action_cco__to_ucco]
+ to_stop -> CCO_LEAVING [cp_av_cco_action_drv_mac_stop]
+ discover_info_updated -> . [cp_av_cco_action_cco__cc_discover_list_req]
- cco__nek_change -> . [cp_cco_action_cco__cco_nek_change]
- cco__snid_conflict -> . [cp_cco_action_cco__cco_snid_conflict]
- cco_leave_merge_avln -> USTA [cp_cco_action_cco__unassoc_stop]
+ cco__nek_change -> . [cp_av_cco_action_cco__cco_nek_change]
+ cco__snid_conflict -> . [cp_av_cco_action_cco__cco_snid_conflict]
+ cco_leave_merge_avln -> USTA [cp_av_cco_action_cco__unassoc_stop]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ -> . [cp_cco_action_cco__cc_assoc_req]
- CM_GET_KEY_REQ_PID0 -> . [cp_cco_action_cco__cm_get_key_req_pid0]
- CM_GET_KEY_REQ_PID1 -> . [cp_cco_action_cco__cm_get_key_req_pid1]
- CC_LEAVE_REQ -> . [cp_cco_action_cco__cc_leave_req]
+ CC_ASSOC_REQ -> . [cp_av_cco_action_cco__cc_assoc_req]
+ CM_GET_KEY_REQ_PID0 -> . [cp_av_cco_action_cco__cm_get_key_req_pid0]
+ CM_GET_KEY_REQ_PID1 -> . [cp_av_cco_action_cco__cm_get_key_req_pid1]
+ CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
- HANDOVER_DISCOVER_PROCESS_DONE:sta -> HANDOVER_CCO [cp_cco_action_handover__discover_done]
+ HANDOVER_DISCOVER_PROCESS_DONE:sta -> HANDOVER_CCO [cp_av_cco_action_handover__discover_done]
HANDOVER_DISCOVER_PROCESS_DONE:no_sta -> .
- DRV_STA_SC_REQ: sc_add -> SC_CCO [cp_sta_action_drv__cco__drv_sta_sc]
+ DRV_STA_SC_REQ: sc_add -> SC_CCO [cp_av_sta_action_drv__cco__drv_sta_sc]
DRV_STA_SC_REQ: sc_join -> .
Start the SC FSM only for SC ADD.
CCO_LEAVING:
CCO_LEAVING_HANDOVER -> CCO_LEAVING_HOIP [NULL]
- BEACON_TIMER_EXPIRES -> . [cp_cco_action_drv_mac_stop_suspend]
- cco__all_sta_leaved -> USTA [cp_cco_action_drv_mac_stop_ended]
+ BEACON_TIMER_EXPIRES -> . [cp_av_cco_action_drv_mac_stop_suspend]
+ cco__all_sta_leaved -> USTA [cp_av_cco_action_drv_mac_stop_ended]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ -> . [cp_cco_action_cco__cc_assoc_req]
- CM_GET_KEY_REQ_PID0 -> . [cp_cco_action_cco__cm_get_key_req_pid0]
- CC_LEAVE_REQ -> . [cp_cco_action_cco__cc_leave_req]
+ CC_ASSOC_REQ -> . [cp_av_cco_action_cco__cc_assoc_req]
+ CM_GET_KEY_REQ_PID0 -> . [cp_av_cco_action_cco__cm_get_key_req_pid0]
+ CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
CCO_LEAVING_HOIP:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
- HANDOVER_SUCCESS -> STA [cp_cco_action_drv_mac_stop_ended]
- HANDOVER_FAILURE -> STA [cp_cco_action_drv_mac_stop_ended]
+ HANDOVER_SUCCESS -> STA [cp_av_cco_action_drv_mac_stop_ended]
+ HANDOVER_FAILURE -> STA [cp_av_cco_action_drv_mac_stop_ended]
SC_CCO:
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
- to_stop -> CCO_LEAVING [cp_cco_action_drv_mac_stop]
- cco__nek_change -> . [cp_cco_action_cco__cco_nek_change]
- cco__snid_conflict -> . [cp_cco_action_cco__cco_snid_conflict]
+ to_stop -> CCO_LEAVING [cp_av_cco_action_drv_mac_stop]
+ cco__nek_change -> . [cp_av_cco_action_cco__cco_nek_change]
+ cco__snid_conflict -> . [cp_av_cco_action_cco__cco_snid_conflict]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- CC_ASSOC_REQ -> . [cp_cco_action_sc__sc_cco__cc_assoc_req]
+ CC_ASSOC_REQ -> . [cp_av_cco_action_sc__sc_cco__cc_assoc_req]
Refuse request for new association (except with the SC sta), reply to renew.
- CC_LEAVE_REQ -> . [cp_cco_action_cco__cc_leave_req]
+ CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
sc_succeed -> CCO [NULL]
- sc_failed: sta -> CCO [cp_sta_action_sc__sc_cco__sc_failed]
+ sc_failed: sta -> CCO [cp_av_sta_action_sc__sc_cco__sc_failed]
sc_failed: no sta avln -> USTA
sc_failed: no sta no avln -> UCCO
@@ -600,96 +600,96 @@ SC_IDLE:
Transition is handled by enter function of SC_IDLE.
SC_ADD:
- CM_SC_JOIN_REQ: ok -> SC_WAIT_PEER_ASSOCIATED [cp_sta_action_sc__sc_add__cm_sc_join_req]
+ CM_SC_JOIN_REQ: ok -> SC_WAIT_PEER_ASSOCIATED [cp_av_sta_action_sc__sc_add__cm_sc_join_req]
CM_SC_JOIN_REQ: nok -> .
Check CM_SC_JOIN.REQ. If ok, become CCo if we are not on AVLN, send CM_SC_JOIN.CNF.
SC_WAIT_PEER_ASSOCIATED:
- new_sta_associated: sta_is_sc_peer -> SC_BUILDING_TEK [cp_sta_action_sc__sc_wait_peer_associated__new_sta_associated]
+ new_sta_associated: sta_is_sc_peer -> SC_BUILDING_TEK [cp_av_sta_action_sc__sc_wait_peer_associated__new_sta_associated]
new_sta_associated: sta_not_sc_peer -> .
If it is the SC STA, start UKE protocol.
SC_JOIN:
- CM_SC_JOIN_REQ: ok_my_cco_cap_greater -> SC_WAIT_PEER_ASSOCIATED [cp_sta_action_sc__sc_join__cm_sc_join_req]
+ CM_SC_JOIN_REQ: ok_my_cco_cap_greater -> SC_WAIT_PEER_ASSOCIATED [cp_av_sta_action_sc__sc_join__cm_sc_join_req]
CM_SC_JOIN_REQ: ok_my_cco_cap_lower -> .
CM_SC_JOIN_REQ: nok -> .
Check MME. If ok, check CCo cap, and become CCo if needed. Otherwise, do
nothing.
- CM_SC_JOIN_CNF: ok -> SC_WAIT_BEACON [cp_sta_action_sc__sc_join__cm_sc_join_cnf]
+ CM_SC_JOIN_CNF: ok -> SC_WAIT_BEACON [cp_av_sta_action_sc__sc_join__cm_sc_join_cnf]
CM_SC_JOIN_CNF: nok -> .
Check MME. If ok, set NID and check avln_status of peer.
- sc_join_req_timeout -> . [cp_sta_action_sc__sc_join__sc_join_req_timeout]
+ sc_join_req_timeout -> . [cp_av_sta_action_sc__sc_join__sc_join_req_timeout]
Send a SC_JOIN.REQ MME.
SC_WAIT_BEACON:
- BEACON: nid_match -> SC_IDLE [cp_sta_action_sc__sc_wait_beacon__beacon]
+ BEACON: nid_match -> SC_IDLE [cp_av_sta_action_sc__sc_wait_beacon__beacon]
BEACON: nid_differs -> .
If the beacon has the right nid, make the top FSM move for association.
SC_BUILDING_TEK:
- CM_GET_KEY_CNF_PID3: ok -> SC_NMK_EXCHANGE [cp_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3]
+ CM_GET_KEY_CNF_PID3: ok -> SC_NMK_EXCHANGE [cp_av_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3]
CM_GET_KEY_CNF_PID3: unrelated -> .
CM_GET_KEY_CNF_PID3: nok -> SC_IDLE
Check MME, compute TEK, send NMK encrypted with TEK.
SC_NMK_EXCHANGE:
- CM_SET_KEY_CNF_PID3: ok -> SC_IDLE [cp_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3]
+ CM_SET_KEY_CNF_PID3: ok -> SC_IDLE [cp_av_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3]
CM_SET_KEY_CNF_PID3: unrelated -> .
CM_SET_KEY_CNF_PID3: nok -> SC_IDLE
Check MME. If ok, authentication can start.
SC_WAIT_PEER_ASSOCIATED, SC_JOIN, SC_BUILDING_TEK, SC_NMK_EXCHANGE, SC_WAIT_BEACON:
- sc_timeout -> SC_IDLE [cp_sta_action_sc__sc_timeout]
+ sc_timeout -> SC_IDLE [cp_av_sta_action_sc__sc_timeout]
SC Procedure is aborted, tell it to the CP FSM and stop association FSM.
- to_stop -> SC_IDLE [cp_sta_action_sc__to_stop]
+ to_stop -> SC_IDLE [cp_av_sta_action_sc__to_stop]
Timer stop is handled when going to SC_IDLE, just need to tell the top FSP
the SC procedure is abort.
SC_ADD:
- sc_timeout -> SC_IDLE [cp_sta_action_sc_add__sc_timeout]
+ sc_timeout -> SC_IDLE [cp_av_sta_action_sc_add__sc_timeout]
SC Procedure is aborted, tell it to the CP FSM but not to the association
FSM.
- to_stop -> SC_IDLE [cp_sta_action_sc__to_stop]
+ to_stop -> SC_IDLE [cp_av_sta_action_sc__to_stop]
Timer stop is handled when going to SC_IDLE, just need to tell the top FSM
the SC procedure is abort.
POWERON, POWERON_JOINING, USTA_JOINING, SC_USTA_JOINING, SC_USTA, SC_UCCO, SC_STA, SC_CCO:
- DRV_STA_SC_REQ -> . [cp_sta_action_drv__many__drv_sta_sc__failure]
+ DRV_STA_SC_REQ -> . [cp_av_sta_action_drv__many__drv_sta_sc__failure]
DRV_STA_SC_REQ is disable during poweron procedure.
HANDOVER_CCO:
- CC_ASSOC_REQ -> . [cp_cco_action_cco__cc_assoc_req]
- CM_GET_KEY_REQ_PID0 -> . [cp_cco_action_cco__cm_get_key_req_pid0]
- CM_GET_KEY_REQ_PID1 -> . [cp_cco_action_cco__cm_get_key_req_pid1]
- CC_LEAVE_REQ -> . [cp_cco_action_cco__cc_leave_req]
+ CC_ASSOC_REQ -> . [cp_av_cco_action_cco__cc_assoc_req]
+ CM_GET_KEY_REQ_PID0 -> . [cp_av_cco_action_cco__cm_get_key_req_pid0]
+ CM_GET_KEY_REQ_PID1 -> . [cp_av_cco_action_cco__cm_get_key_req_pid1]
+ CC_LEAVE_REQ -> . [cp_av_cco_action_cco__cc_leave_req]
BEACON_TIMER_EXPIRES -> . [cp_beacon_cco_update_beacon_data]
CC_WHO_RU_REQ -> . [cp_sta_action_process_cc_who_ru_req]
- HANDOVER_SUCCESS -> STA [cp_cco_action_handover__ended]
- HANDOVER_FAILURE -> CCO [cp_cco_action_cco_selection__clear]
+ HANDOVER_SUCCESS -> STA [cp_av_cco_action_handover__ended]
+ HANDOVER_FAILURE -> CCO [cp_av_cco_action_cco_selection__clear]
CCO_HANDOVER_IDLE:
- CCO_HANDOVER_START: sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF [cp_cco_action_handover__start]
+ CCO_HANDOVER_START: sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF [cp_av_cco_action_handover__start]
CCO_HANDOVER_START: no_sta -> .
Should call the handover_failure function.
CCO_HANDOVER_WAIT_CC_HANDOVER_CNF:
- HANDOVER_TIMEOUT: another_sta -> . [cp_cco_action_handover__timeout_cc_handover_cnf]
+ HANDOVER_TIMEOUT: another_sta -> . [cp_av_cco_action_handover__timeout_cc_handover_cnf]
HANDOVER_TIMEOUT: no_more_sta -> CCO_HANDOVER_IDLE
- Should call cp_cco_action_handover__failure
- CC_HANDOVER_CNF: hard_accept -> CCO_HANDOVER_WAIT_CC_HANDOVER_INFO_RSP [cp_cco_action_handover__cc_handover_cnf_receive]
+ Should call cp_av_cco_action_handover__failure
+ CC_HANDOVER_CNF: hard_accept -> CCO_HANDOVER_WAIT_CC_HANDOVER_INFO_RSP [cp_av_cco_action_handover__cc_handover_cnf_receive]
CC_HANDOVER_CNF: another_sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF
CC_HANDOVER_CNF: no_more_sta -> CCO_HANDOVER_IDLE
- Should call cp_cco_action_handover__failure
+ Should call cp_av_cco_action_handover__failure
CCO_HANDOVER_WAIT_CC_HANDOVER_INFO_RSP:
- CC_HANDOVER_INFO_RSP -> CCO_HANDOVER_WAIT_HANDOVER_COUNTDOWN [cp_cco_action_handover__cc_handover_info_rsp_receive]
- HANDOVER_TIMEOUT: another_sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF [cp_cco_action_handover__timeout_cc_handover_info_rsp]
+ CC_HANDOVER_INFO_RSP -> CCO_HANDOVER_WAIT_HANDOVER_COUNTDOWN [cp_av_cco_action_handover__cc_handover_info_rsp_receive]
+ HANDOVER_TIMEOUT: another_sta -> CCO_HANDOVER_WAIT_CC_HANDOVER_CNF [cp_av_cco_action_handover__timeout_cc_handover_info_rsp]
HANDOVER_TIMEOUT: no_more_sta -> CCO_HANDOVER_IDLE
Should call the handover_failure function.
CCO_HANDOVER_WAIT_HANDOVER_COUNTDOWN:
- HOIP_EXPIRED -> CCO_HANDOVER_IDLE [cp_cco_action_handover__hoip_countdown_expired]
+ HOIP_EXPIRED -> CCO_HANDOVER_IDLE [cp_av_cco_action_handover__hoip_countdown_expired]
HANDOVER_STA:
BEACON_TIMER_EXPIRES -> . [cp_beacon_beacon_not_received]
@@ -698,27 +698,27 @@ HANDOVER_STA:
HANDOVER_FAILURE -> STA [NULL]
STA_HANDOVER_IDLE:
- STA_HANDOVER_START:hard -> STA_HANDOVER_WAIT_CC_HANDOVER_INFO [cp_sta_action_handover__start]
+ STA_HANDOVER_START:hard -> STA_HANDOVER_WAIT_CC_HANDOVER_INFO [cp_av_sta_action_handover__start]
STA_HANDOVER_START:soft -> STA_HANDOVER_IDLE
STA_HANDOVER_WAIT_CC_HANDOVER_INFO:
- CC_HANDOVER_INFO_IND -> STA_HANDOVER_WAIT_COUNTDOWN_EXPIRES [cp_sta_action_handover__handover_info_ind_receive]
- HANDOVER_TIMEOUT -> STA_HANDOVER_IDLE [cp_sta_action_handover__failure]
+ CC_HANDOVER_INFO_IND -> STA_HANDOVER_WAIT_COUNTDOWN_EXPIRES [cp_av_sta_action_handover__handover_info_ind_receive]
+ HANDOVER_TIMEOUT -> STA_HANDOVER_IDLE [cp_av_sta_action_handover__failure]
STA_HANDOVER_WAIT_COUNTDOWN_EXPIRES:
- HOIP_EXPIRED -> STA_HANDOVER_IDLE [cp_sta_action_handover__handover_ended]
+ HOIP_EXPIRED -> STA_HANDOVER_IDLE [cp_av_sta_action_handover__handover_ended]
CCO_NEK_CHANGE_IDLE:
- cco_nek_change__nek_provide:sta -> CCO_NEK_CHANGE_WAIT_STA_CNF [cp_cco_action_cco__cco_nek_change__nek_provide]
+ cco_nek_change__nek_provide:sta -> CCO_NEK_CHANGE_WAIT_STA_CNF [cp_av_cco_action_cco__cco_nek_change__nek_provide]
cco_nek_change__nek_provide:nosta -> .
CCO_NEK_CHANGE_WAIT_STA_CNF:
- CM_SET_KEY_CNF_PID1 -> CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF [cp_cco_action_cm_set_key_cnf_receive]
- cco_nek_change__nek_timeout:no -> CCO_NEK_CHANGE_IDLE [cp_cco_action_cco__cco_nek_change__nek_timeout__wait]
+ CM_SET_KEY_CNF_PID1 -> CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF [cp_av_cco_action_cm_set_key_cnf_receive]
+ cco_nek_change__nek_timeout:no -> CCO_NEK_CHANGE_IDLE [cp_av_cco_action_cco__cco_nek_change__nek_timeout__wait]
cco_nek_change__nek_timeout:yes -> CCO_NEK_CHANGE_WAIT_STA_CNF
CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF:
- cco_nek_change__nek_timeout:no -> CCO_NEK_CHANGE_IDLE [cp_cco_action_cco__cco_nek_change__timeout]
+ cco_nek_change__nek_timeout:no -> CCO_NEK_CHANGE_IDLE [cp_av_cco_action_cco__cco_nek_change__timeout]
cco_nek_change__nek_timeout:yes -> CCO_NEK_CHANGE_WAIT_STA_CNF
- CM_SET_KEY_CNF_PID1:ok_continue -> CCO_NEK_CHANGE_WAIT_STA_CNF [cp_cco_action_cm_set_key_cnf_receive]
+ CM_SET_KEY_CNF_PID1:ok_continue -> CCO_NEK_CHANGE_WAIT_STA_CNF [cp_av_cco_action_cm_set_key_cnf_receive]
CM_SET_KEY_CNF_PID1:end -> CCO_NEK_CHANGE_IDLE
diff --git a/cesar/cp/fsm/src/fsm/template_defs.h b/cesar/cp/av/fsm/src/fsm/template_defs.h
index d61762c492..d61762c492 100644
--- a/cesar/cp/fsm/src/fsm/template_defs.h
+++ b/cesar/cp/av/fsm/src/fsm/template_defs.h
diff --git a/cesar/cp/fsm/src/fsm/template_tables.h b/cesar/cp/av/fsm/src/fsm/template_tables.h
index c13300cd28..c13300cd28 100644
--- a/cesar/cp/fsm/src/fsm/template_tables.h
+++ b/cesar/cp/av/fsm/src/fsm/template_tables.h
diff --git a/cesar/cp/fsm/src/tables.c b/cesar/cp/av/fsm/src/tables.c
index e0d749aca9..cfccd5ee2f 100644
--- a/cesar/cp/fsm/src/tables.c
+++ b/cesar/cp/av/fsm/src/tables.c
@@ -12,14 +12,15 @@
*/
#include "common/std.h"
-#include "fsm.h"
-#include "inc/tables.h"
+#include "cp/fsm/fsm.h"
+#include "cp/fsm/inc/tables.h"
-#include "cp/sta/action/action.h"
-#include "cp/beacon/beacon.h"
-#include "cp/cco/action/cco_action.h"
#include "ce/tx/tx.h"
+#include "cp/av/sta/action/action.h"
+#include "cp/av/cco/action/cco_action.h"
+#include "cp/av/cco/action/handover.h"
+
/* CE TX stub. */
void
ce_tx_process__cm_chan_est_ind (cp_t *ctx, cp_mme_rx_t *mme)
diff --git a/cesar/cp/av/fsm/stub/Module b/cesar/cp/av/fsm/stub/Module
new file mode 100644
index 0000000000..cb5e0cb944
--- /dev/null
+++ b/cesar/cp/av/fsm/stub/Module
@@ -0,0 +1,4 @@
+SOURCES := fsm_stub.c
+MODULES := cp/av/fsm
+cp_av_fsm_MODULE_SOURCES := $(call default,cp_av_fsm_MODULE_SOURCES,)
+cp_fsm_MODULE_SOURCES := $(call default,cp_fsm_MODULE_SOURCES,)
diff --git a/cesar/cp/fsm/stub/src/fsm_stub.c b/cesar/cp/av/fsm/stub/src/fsm_stub.c
index b0fa7c4157..5cf397e9e8 100644
--- a/cesar/cp/fsm/stub/src/fsm_stub.c
+++ b/cesar/cp/av/fsm/stub/src/fsm_stub.c
@@ -6,7 +6,7 @@
*
* }}} */
/**
- * \file cp/fsm/stub/src/fsm_stub.c
+ * \file cp/av/fsm/stub/src/fsm_stub.c
* \brief Generic FSM stub.
* \ingroup stub
*/
diff --git a/cesar/cp/av/fsm/test/utest/Config b/cesar/cp/av/fsm/test/utest/Config
new file mode 100644
index 0000000000..85c3a4a3b2
--- /dev/null
+++ b/cesar/cp/av/fsm/test/utest/Config
@@ -0,0 +1,2 @@
+CONFIG_DEBUG_FATAL_CATCH = y
+CONFIG_CP_FSM_DEF = "cp/av/fsm/test/utest/src/utest.fsm"
diff --git a/cesar/cp/fsm/test/utest/Makefile b/cesar/cp/av/fsm/test/utest/Makefile
index 5f1381e948..10710133f1 100644
--- a/cesar/cp/fsm/test/utest/Makefile
+++ b/cesar/cp/av/fsm/test/utest/Makefile
@@ -1,11 +1,13 @@
-BASE = ../../../..
+BASE = ../../../../..
-INCLUDES = cp/fsm/test/utest cp/fsm/test/utest/override
+INCLUDES = cp/av/fsm/test/utest cp/av/fsm/test/utest/override
HOST_PROGRAMS = test_fsm
test_fsm_SOURCES = test_fsm.c fsm_stub.c actions.c
-test_fsm_MODULES = lib lib/scenario cp/fsm cp
-cp_fsm_MODULE_SOURCES = fsm.c events.c
+test_fsm_MODULES = lib lib/scenario cp/av/fsm
+test_fsm_CONFIG_MODULES := cp
+cp_av_fsm_MODULE_SOURCES :=
+
cp_MODULE_MODULES =
cp_MODULE_SOURCES = $(if $(filter y,$(CONFIG_TRACE)),trace.c,)
diff --git a/cesar/cp/fsm/test/utest/inc/scenario_defs.h b/cesar/cp/av/fsm/test/utest/inc/scenario_defs.h
index a91c3fe4d8..a91c3fe4d8 100644
--- a/cesar/cp/fsm/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/av/fsm/test/utest/inc/scenario_defs.h
diff --git a/cesar/cp/fsm/test/utest/override/cp/inc/context.h b/cesar/cp/av/fsm/test/utest/override/cp/inc/context.h
index edc1fde804..edc1fde804 100644
--- a/cesar/cp/fsm/test/utest/override/cp/inc/context.h
+++ b/cesar/cp/av/fsm/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/fsm/test/utest/override/cp/sta/core/core.h b/cesar/cp/av/fsm/test/utest/override/cp/sta/core/core.h
index 352368b45b..352368b45b 100644
--- a/cesar/cp/fsm/test/utest/override/cp/sta/core/core.h
+++ b/cesar/cp/av/fsm/test/utest/override/cp/sta/core/core.h
diff --git a/cesar/cp/fsm/test/utest/src/actions.c b/cesar/cp/av/fsm/test/utest/src/actions.c
index b8d344a32f..b8d344a32f 100644
--- a/cesar/cp/fsm/test/utest/src/actions.c
+++ b/cesar/cp/av/fsm/test/utest/src/actions.c
diff --git a/cesar/cp/fsm/test/utest/src/fsm_stub.c b/cesar/cp/av/fsm/test/utest/src/fsm_stub.c
index ee8c8bea9e..ee8c8bea9e 100644
--- a/cesar/cp/fsm/test/utest/src/fsm_stub.c
+++ b/cesar/cp/av/fsm/test/utest/src/fsm_stub.c
diff --git a/cesar/cp/fsm/test/utest/src/test_fsm.c b/cesar/cp/av/fsm/test/utest/src/test_fsm.c
index 54a17abc6d..54a17abc6d 100644
--- a/cesar/cp/fsm/test/utest/src/test_fsm.c
+++ b/cesar/cp/av/fsm/test/utest/src/test_fsm.c
diff --git a/cesar/cp/fsm/test/utest/src/utest.fsm b/cesar/cp/av/fsm/test/utest/src/utest.fsm
index f251cb6708..f251cb6708 100644
--- a/cesar/cp/fsm/test/utest/src/utest.fsm
+++ b/cesar/cp/av/fsm/test/utest/src/utest.fsm
diff --git a/cesar/cp/av/msg/test/utest/Config b/cesar/cp/av/msg/test/utest/Config
new file mode 100644
index 0000000000..11cc49b2b2
--- /dev/null
+++ b/cesar/cp/av/msg/test/utest/Config
@@ -0,0 +1,3 @@
+CONFIG_DEBUG_FATAL_CATCH=y
+CONFIG_CP_AV = y
+CONFIG_CP_EOC = n
diff --git a/cesar/cp/av/msg/test/utest/Makefile b/cesar/cp/av/msg/test/utest/Makefile
new file mode 100644
index 0000000000..b8042d653e
--- /dev/null
+++ b/cesar/cp/av/msg/test/utest/Makefile
@@ -0,0 +1,78 @@
+BASE = ../../../../..
+
+DEFS = -DNO_PRIVATE
+
+INCLUDES = cp/av/msg/test/utest/override/ cp/sta/core/stub/
+
+HOST_PROGRAMS = test-msg-read-header test-msg-cc test-msg-cm \
+ test_drv_msg test_cc_discover_list test_frag_mme \
+ relay test_vs_msg test_allowed_mme msg
+
+test-msg-read-header_SOURCES = test-msg-read-header.c \
+ cp_cl_interface_stub.c misc_stub.c
+test-msg-read-header_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub cp/sta/core/stub \
+ cp/av/cco/action/stub mac/sar/stub cl/stub \
+ bsu/stub bufmgr/stub
+test-msg-read-header_CONFIG_MODULES = cp
+
+test-msg-cc_SOURCES = msg_cc.c misc_stub.c
+test-msg-cc_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/sta/core/stub cp/av/cco/action/stub mac/sar/stub \
+ cl/stub bsu/stub bufmgr/stub cp/av/fsm/stub
+test-msg-cc_CONFIG_MODULES = cp
+
+test-msg-cm_SOURCES = msg_cm.c misc_stub.c
+test-msg-cm_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub \
+ cp/sta/core/stub cp/av/cco/action/stub mac/sar/stub \
+ cl/stub bsu/stub bufmgr/stub
+test-msg-cm_CONFIG_MODULES = cp
+
+test_frag_mme_SOURCES = mme_frag.c misc_stub.c
+test_frag_mme_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub cp/sta/core/stub \
+ cp/av/cco/action/stub \
+ mac/sar/stub cl/stub bsu/stub bufmgr/stub
+test_frag_mme_CONFIG_MODULES = cp
+
+test_drv_msg_SOURCES = msg_drv.c cp_cl_interface_stub.c misc_stub.c
+test_drv_msg_MODULES = lib cp/msg cp/secu mac/common cp/av/fsm/stub \
+ cp/sta/core/stub cp/av/cco/action/stub mac/sar/stub \
+ cl/stub bsu/stub bufmgr/stub cp/av/sta/mgr
+test_drv_msg_CONFIG_MODULES = cp
+
+test_cc_discover_list_SOURCES = cc_discover_list.c misc_stub.c
+test_cc_discover_list_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub cp/sta/core/stub \
+ cp/av/cco/action/stub \
+ cl/stub bsu/stub mac/sar/stub bufmgr/stub
+test_cc_discover_list_CONFIG_MODULES = cp
+
+relay_SOURCES = relay.c misc_stub.c
+relay_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub cp/sta/core/stub cp/av/cco/action/stub \
+ cl/stub bsu/stub mac/sar/stub bufmgr/stub
+relay_CONFIG_MODULES = cp
+
+test_vs_msg_SOURCES = msg_vs.c misc_stub.c \
+ mac_sar_interface_stub.c cp_cl_interface_vs_stub.c
+test_vs_msg_MODULES = lib cp/msg cp/secu mac/common cp/av/sta/mgr \
+ cp/av/fsm/stub cp/sta/core/stub cp/av/cco/action/stub \
+ cl/stub bsu/stub mac/sar/stub bufmgr/stub
+test_va_msg_CONFIG_MODULES = cp
+
+test_allowed_mme_SOURCES = test_msg_allowed_mme.c \
+ cp_cl_interface_stub.c misc_stub.c
+test_allowed_mme_MODULES = lib cp/msg cp/sta/core/stub cp/av/sta/mgr \
+ cp/av/fsm/stub cp/secu mac/common mac/sar/stub \
+ cp/av/cco/action/stub cl/stub bsu/stub bufmgr/stub
+test_allowed_mme_CONFIG_MODULES = cp
+
+msg_SOURCES = msg.c cp_cl_interface_stub.c misc_stub.c
+msg_MODULES = lib cp/msg cp/av/sta/mgr cp/sta/core/stub cp/av/fsm/stub \
+ cp/secu mac/common mac/sar/stub cp/av/cco/action/stub cl/stub \
+ bsu/stub bufmgr/stub
+msg_CONFIG_MODULES = cp
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/msg/test/doc/Makefile b/cesar/cp/av/msg/test/utest/doc/Makefile
index 50006394a5..c70497dbd1 100644
--- a/cesar/cp/msg/test/doc/Makefile
+++ b/cesar/cp/av/msg/test/utest/doc/Makefile
@@ -9,12 +9,12 @@ odt: $(ODT)
html: $(HTML)
-%.odt: %.txt
+%.odt: %.txt
rst2odt.py $< $@
%.html: %.txt
rst2html $< $@
-clean:
+clean:
rm -f $(ODT)
rm -f $(HTML)
diff --git a/cesar/cp/msg/test/doc/read-header.txt b/cesar/cp/av/msg/test/utest/doc/read-header.txt
index 24eb81f982..f8beeefcb2 100644
--- a/cesar/cp/msg/test/doc/read-header.txt
+++ b/cesar/cp/av/msg/test/utest/doc/read-header.txt
@@ -39,7 +39,7 @@ The MME rx object returned shall not be NULL and shall contain:
* mac = 34:56:78:9A:BC:DE
* vlan = 0x12
* tei = 1 (provided in argument).
-
+
Test 2 : Read a MME without a VLAN tag.
---------------------------------------
@@ -55,7 +55,7 @@ The MME rx object returned shall not be NULL and shall contain:
* mac = 34:56:78:9A:BC:DE
* vlan = 0
* tei = 1 (provided in argument).
-
+
Test 3 : Read a MME with the MMV equal to 0
-------------------------------------------
diff --git a/cesar/cp/msg/test/overide/cp/inc/context.h b/cesar/cp/av/msg/test/utest/override/cp/inc/context.h
index 250877009e..250877009e 100644
--- a/cesar/cp/msg/test/overide/cp/inc/context.h
+++ b/cesar/cp/av/msg/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/msg/test/overide/cyg/kernel/kapi.h b/cesar/cp/av/msg/test/utest/override/cyg/kernel/kapi.h
index 019e5d3a07..019e5d3a07 100644
--- a/cesar/cp/msg/test/overide/cyg/kernel/kapi.h
+++ b/cesar/cp/av/msg/test/utest/override/cyg/kernel/kapi.h
diff --git a/cesar/cp/msg/test/overide/mac/sar/inc/context.h b/cesar/cp/av/msg/test/utest/override/mac/sar/inc/context.h
index 9e7c6f07ca..9e7c6f07ca 100644
--- a/cesar/cp/msg/test/overide/mac/sar/inc/context.h
+++ b/cesar/cp/av/msg/test/utest/override/mac/sar/inc/context.h
diff --git a/cesar/cp/msg/test/src/cc_discover_list.c b/cesar/cp/av/msg/test/utest/src/cc_discover_list.c
index 892779b44d..892779b44d 100644
--- a/cesar/cp/msg/test/src/cc_discover_list.c
+++ b/cesar/cp/av/msg/test/utest/src/cc_discover_list.c
diff --git a/cesar/cp/msg/test/src/cp_cl_interface_stub.c b/cesar/cp/av/msg/test/utest/src/cp_cl_interface_stub.c
index 7b8643aae0..7b8643aae0 100644
--- a/cesar/cp/msg/test/src/cp_cl_interface_stub.c
+++ b/cesar/cp/av/msg/test/utest/src/cp_cl_interface_stub.c
diff --git a/cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c b/cesar/cp/av/msg/test/utest/src/cp_cl_interface_vs_stub.c
index 7d185c9693..7d185c9693 100644
--- a/cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c
+++ b/cesar/cp/av/msg/test/utest/src/cp_cl_interface_vs_stub.c
diff --git a/cesar/cp/av/msg/test/utest/src/interface_stub.c b/cesar/cp/av/msg/test/utest/src/interface_stub.c
new file mode 100644
index 0000000000..68d5683537
--- /dev/null
+++ b/cesar/cp/av/msg/test/utest/src/interface_stub.c
@@ -0,0 +1,27 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/interface_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "cp/cp.h"
+
+/**
+ * Inform the Data plane when the MME as been processed by the CP.
+ * \param ctx the interface context
+ * \param mme_recv the cl data (as a void pointer).
+ */
+void
+interface_mme_recv_done (interface_t *ctx, void *mme_recv)
+{
+}
diff --git a/cesar/cp/msg/test/src/mac_sar_interface_stub.c b/cesar/cp/av/msg/test/utest/src/mac_sar_interface_stub.c
index 4bd80c7f26..4bd80c7f26 100644
--- a/cesar/cp/msg/test/src/mac_sar_interface_stub.c
+++ b/cesar/cp/av/msg/test/utest/src/mac_sar_interface_stub.c
diff --git a/cesar/cp/msg/test/src/misc_stub.c b/cesar/cp/av/msg/test/utest/src/misc_stub.c
index e7001746f1..e7001746f1 100644
--- a/cesar/cp/msg/test/src/misc_stub.c
+++ b/cesar/cp/av/msg/test/utest/src/misc_stub.c
diff --git a/cesar/cp/msg/test/src/mme_frag.c b/cesar/cp/av/msg/test/utest/src/mme_frag.c
index df9e66d5c0..df9e66d5c0 100644
--- a/cesar/cp/msg/test/src/mme_frag.c
+++ b/cesar/cp/av/msg/test/utest/src/mme_frag.c
diff --git a/cesar/cp/msg/test/src/msg.c b/cesar/cp/av/msg/test/utest/src/msg.c
index 99671088e4..99671088e4 100644
--- a/cesar/cp/msg/test/src/msg.c
+++ b/cesar/cp/av/msg/test/utest/src/msg.c
diff --git a/cesar/cp/msg/test/src/msg_cc.c b/cesar/cp/av/msg/test/utest/src/msg_cc.c
index 010700eeda..010700eeda 100644
--- a/cesar/cp/msg/test/src/msg_cc.c
+++ b/cesar/cp/av/msg/test/utest/src/msg_cc.c
diff --git a/cesar/cp/msg/test/src/msg_cm.c b/cesar/cp/av/msg/test/utest/src/msg_cm.c
index d5e4c0df98..d5e4c0df98 100644
--- a/cesar/cp/msg/test/src/msg_cm.c
+++ b/cesar/cp/av/msg/test/utest/src/msg_cm.c
diff --git a/cesar/cp/msg/test/src/msg_drv.c b/cesar/cp/av/msg/test/utest/src/msg_drv.c
index 9df1bf895a..9df1bf895a 100644
--- a/cesar/cp/msg/test/src/msg_drv.c
+++ b/cesar/cp/av/msg/test/utest/src/msg_drv.c
diff --git a/cesar/cp/msg/test/src/msg_vs.c b/cesar/cp/av/msg/test/utest/src/msg_vs.c
index c4d7860c81..c4d7860c81 100644
--- a/cesar/cp/msg/test/src/msg_vs.c
+++ b/cesar/cp/av/msg/test/utest/src/msg_vs.c
diff --git a/cesar/cp/msg/test/src/relay.c b/cesar/cp/av/msg/test/utest/src/relay.c
index c74184bff8..c74184bff8 100644
--- a/cesar/cp/msg/test/src/relay.c
+++ b/cesar/cp/av/msg/test/utest/src/relay.c
diff --git a/cesar/cp/msg/test/src/test-msg-read-header.c b/cesar/cp/av/msg/test/utest/src/test-msg-read-header.c
index efbaddc09c..efbaddc09c 100644
--- a/cesar/cp/msg/test/src/test-msg-read-header.c
+++ b/cesar/cp/av/msg/test/utest/src/test-msg-read-header.c
diff --git a/cesar/cp/msg/test/src/test_msg_allowed_mme.c b/cesar/cp/av/msg/test/utest/src/test_msg_allowed_mme.c
index c58eff9df5..c58eff9df5 100644
--- a/cesar/cp/msg/test/src/test_msg_allowed_mme.c
+++ b/cesar/cp/av/msg/test/utest/src/test_msg_allowed_mme.c
diff --git a/cesar/cp/msg/test/test.h b/cesar/cp/av/msg/test/utest/test.h
index 817d099f8c..817d099f8c 100644
--- a/cesar/cp/msg/test/test.h
+++ b/cesar/cp/av/msg/test/utest/test.h
diff --git a/cesar/cp/av/sta/action/Config b/cesar/cp/av/sta/action/Config
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/cesar/cp/av/sta/action/Config
diff --git a/cesar/cp/av/sta/action/Module b/cesar/cp/av/sta/action/Module
new file mode 100644
index 0000000000..79370ecb2e
--- /dev/null
+++ b/cesar/cp/av/sta/action/Module
@@ -0,0 +1,4 @@
+SOURCES := sc.c drv.c misc.c handover.c poweron.c action.c assoc.c info.c \
+ key.c
+
+MODULES := cp/sta/action
diff --git a/cesar/cp/av/sta/action/action.h b/cesar/cp/av/sta/action/action.h
new file mode 100644
index 0000000000..c230025749
--- /dev/null
+++ b/cesar/cp/av/sta/action/action.h
@@ -0,0 +1,28 @@
+#ifndef cp_av_sta_action_action_h
+#define cp_av_sta_action_action_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/action.h
+ * \brief AV_STA action.
+ * \ingroup cp_av_sta_action
+ *
+ */
+#include "cp/types.h"
+#include "cp/mme.h"
+#include "cp/sta/action/action.h"
+
+#include "cp/av/sta/action/sc.h"
+#include "cp/av/sta/action/handover.h"
+#include "cp/av/sta/action/poweron.h"
+#include "cp/av/sta/action/misc.h"
+#include "cp/av/sta/action/assoc.h"
+#include "cp/av/sta/action/info.h"
+#include "cp/av/sta/action/drv.h"
+
+#endif /* cp_av_sta_action_action_h */
diff --git a/cesar/cp/av/sta/action/assoc.h b/cesar/cp/av/sta/action/assoc.h
new file mode 100644
index 0000000000..d06fe01e3a
--- /dev/null
+++ b/cesar/cp/av/sta/action/assoc.h
@@ -0,0 +1,489 @@
+#ifndef cp_av_sta_action_assoc_h
+#define cp_av_sta_action_assoc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/sta/action/assoc.h
+ * \brief STA action, association related definitions.
+ * \ingroup cp_sta_action
+ *
+ * Association/disassociation
+ * ==========================
+ *
+ * This part relates to association and disassociation for a STA. A state
+ * machine is used to handle the association status of the station:
+ *
+ * \image html assoc.png "Association state machine"
+ *
+ * - (1) send CC_ASSOC.REQ
+ * - (2) send CM_GET_KEY.REQ
+ * - (3) send CC_ASSOC.REQ for renewal
+ * - (4) send CM_SET_KEY.CNF
+ * - (5) send CC_LEAVE.REQ
+ * - (6) send CC_LEAVE.RSP
+ * - (7) clear beacon not received counter if our beacon
+ * - (8) cleanup data plane
+ *
+ * For the moment, only one association scheme is supported: association with
+ * matching NID, without proxy network.
+ *
+ * Related: 7.3.2, 7.3.3, 7.3.4.1, 7.3.5.1, 7.3.6.
+ *
+ *
+ * Association
+ * -----------
+ *
+ * When the station wants to associate, it set the association parameters and
+ * trigger the "to assoc" event. This will send the CC_ASSOC.REQ message to
+ * the CCo and wait for response.
+ *
+ * If no response is received, retry. Retry is needed because we are not
+ * associated and broadcast is used.
+ *
+ * If a negative response is received, association has failed, this is
+ * remembered in order not to try to associate too often to the same CCo.
+ *
+ * If a positive response is received, go to associated state.
+ *
+ *
+ * Authentication
+ * --------------
+ *
+ * When entering this state, send a payload encrypted CM_GET_KEY.REQ to
+ * request the NEK.
+ *
+ * Once the station is authenticated, CC_SET_TEI_MAP.IND messages can be
+ * received.
+ *
+ * As unicast transmissions are used, a timeout will directly break the
+ * association sequence.
+ *
+ * If a negative response is received, association has failed, the CCo is
+ * using a different NMK. This is remembered in order not to associate with
+ * this CCo again (until keys are changed).
+ *
+ * If a positive response is received, the station is authenticated.
+ *
+ * Once authenticated, the CCo can change the NEK periodically.
+ *
+ *
+ * Lease renewal
+ * -------------
+ *
+ * Association is granted for a given time. When the station is associated,
+ * program a timer to renew the association. When this timer expires, send a
+ * CC_ASSOC.REQ for renewal and set the timer for a second chance.
+ *
+ * The station will not leave the AVLN by itself due to lease expiration. It
+ * will wait an eventual CC_LEAVE.IND message to do so.
+ *
+ * When the CCo confirms the renewal, the renew timer is reset to the value
+ * given in its confirmation message. Ignore renewal failure, will wait for
+ * the CC_LEAVE.IND message.
+ *
+ *
+ * Leaving
+ * -------
+ *
+ * If the request comes from the STA, trigger the "to leave" event. This will
+ * send the CC_LEAVE.REQ message to the CCo and wait for response. If no
+ * response cames for three beacon periods, resend and go to the "leave wait"
+ * state.
+ *
+ * If the request comes from the CCo (CC_LEAVE.IND), send a response and go to
+ * the "leave wait" state.
+ *
+ * The "leave wait" state is there to give time to the data plane to send the
+ * MME. After a fixed timer, go back to unassociated state and cleanup the
+ * data plane from all AVLN related parameters.
+ *
+ *
+ * Beacon monitoring
+ * -----------------
+ *
+ * If the central beacon is not received for several beacon period, this is a
+ * AVLN failure. The "avln failure" event is triggered and the station is
+ * unassociated.
+ *
+ * On each beacon reception, the beacon loss counter is reseted.
+ *
+ *
+ * Events
+ * ------
+ *
+ * When the authenticated state is entered, the join event is triggered.
+ *
+ * On AVLN failure, the "avln failure" event is triggered.
+ *
+ * When the unassociated state is entered, the left event is triggered. This
+ * event means that the station has left the AVLN or that the association
+ * request failed.
+ */
+#include "cp/sta/mgr/net.h"
+
+BEGIN_DECLS
+
+/**
+ * Start a association procedure.
+ * \param ctx control plane context
+ * \param cco_net AVLN of the CCo to associate with
+ * \param cco CCo to associate with
+ *
+ * Trigger TO_ASSOC event.
+ *
+ * Need:
+ * - CCo to associate to (MAC, TEI, NID).
+ * - our CCo cap and proxy network cap.
+ */
+void
+cp_av_sta_action_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco);
+
+/**
+ * Start an Simple Connect association procedure.
+ * \param ctx control plane context
+ * \param cco_net AVLN of the CCo to associate with
+ * \param cco CCo to associate with
+ * \param sc_peer the peer with which we are doing the SC procedure.
+ *
+ * Trigger TO_SC_ASSOC event.
+ */
+void
+cp_av_sta_action_sc_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco);
+
+/**
+ * Request to leave the current AVLN.
+ * \param ctx control plane context
+ *
+ * Trigger a TO_LEAVE event.
+ */
+void
+cp_av_sta_action_assoc_leave (cp_t *ctx);
+
+/**
+ * Handle entering UNASSOCIATED.
+ * \param ctx control plane context
+ *
+ * Trigger a LEFT event.
+ */
+void
+cp_av_sta_action_assoc__unassociated__enter (cp_t *ctx);
+
+/**
+ * Handle UNASSOCIATED => (TO_ASSOC or TO_SC_ASSOC) events.
+ * \param ctx control plane context
+ *
+ * Send a CC_ASSOC.REQ to the CCo.
+ * \note the transition is the same if we are in the SC procedure or not
+ * because the CC_ASSOC.REQ is sent to the CCo (in the SC procedure, the peer
+ * STA will act as the CCo).
+ */
+void
+cp_av_sta_action_assoc__unassociated__to_assoc (cp_t *ctx);
+
+/**
+ * Common handle (WAIT_ASSOC_CONF or SC_WAIT_ASSOC_CONF) => CC_ASSOC.CNF.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param sc true if we are in simple connect procedure.
+ * \
+ *
+ * If the CCo accepted our association and update association information.
+ * If we are not in SC procedure, send the CM_GET_KEY.REQ and go to the
+ * ASSOCIATED state. If we are in SC, do nothing and go to SC_ASSOCIATED.
+ * If the CCo refused, go back to UNASSOCIATED state and update the CCo
+ * information to remember the failure.
+ *
+ * Update:
+ * - our TEI.
+ * - our TEI lease time (update lease timer).
+ * - our AVLN.
+ * - our AVLN SNID.
+ * - CCo failure info.
+ */
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (cp_t *ctx,
+ cp_mme_rx_t *mme,
+ bool sc);
+
+/**
+ * Handle WAIT_ASSOC_CONF => CC_ASSOC.CNF.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle SC_WAIT_ASSOC_CONF => CC_ASSOC.CNF.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_av_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Common handle for {SC_,}WAIT_ASSOC_CONF => TIMEOUT.
+ * \param ctx control plane context.
+ * \param sc true if we are in simple connect procedure.
+ *
+ * If retry count is not zero, resend the CC_ASSOC.REQ.
+ *
+ * If retry count is zero, go back to UNASSOCIATED state.
+ */
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__timeout_common (cp_t *ctx, bool sc);
+
+/**
+ * Handle WAIT_ASSOC_CONF => TIMEOUT.
+ * \param ctx control plane context.
+ */
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__timeout (cp_t *ctx);
+
+/**
+ * Handle SC_WAIT_ASSOC_CONF => TIMEOUT.
+ * \param ctx control plane context.
+ */
+void
+cp_av_sta_action_assoc__sc_wait_assoc_cnf__timeout (cp_t *ctx);
+
+/**
+ * Common handle for ASSOCIATED or SC_NMK_EXCHANGED => CM_GET_KEY.CNF (PID=[0,3]).
+ * \param ctx control plane context
+ * \param mme received MME handle
+ * \param sc true if we are in simple connect procedure.
+ *
+ * If this is a success, go to AUTHENTICATED state, trigger JOINED event and
+ * update station status.
+ *
+ * If authentication has failed, remember this and go back to UNASSOCIATED
+ * state.
+ *
+ * Update:
+ * - authenticated status.
+ * - NEK.
+ * - CCo failure info.
+ */
+
+void
+cp_av_sta_action_assoc__cm_get_key_cnf__common (cp_t *ctx, cp_mme_rx_t
+ *mme, bool sc);
+
+/**
+ * Handle SC_NMK_EXCHANGED => CM_GET_KYE.CNF (PID=0)
+ * \param ctx control plane context.
+ * \param mme received MME to handle.
+ */
+void
+cp_av_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0 (cp_t *ctx,
+ cp_mme_rx_t *
+ mme);
+
+/**
+ * Handle ASSOCIATED => CM_GET_KEY.CNF (PID=0).
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_av_sta_action_assoc__associated__cm_get_key_cnf_pid_0 (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle AUTHENTICATED => CM_GET_KEY.CNF (PID=1).
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_av_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1 (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle ASSOCIATED => TIMEOUT.
+ * \param ctx control plane context
+ *
+ * Authentication failed, go back to UNASSOCIATED and update the CCo
+ * information to remember the failure.
+ *
+ * Stop lease timer.
+ */
+void
+cp_av_sta_action_assoc__associated__timeout (cp_t *ctx);
+
+/**
+ * Handle ASSOCIATED => TO_LEAVE.
+ * \param ctx control plane context
+ *
+ * Stop lease timer.
+ */
+void
+cp_av_sta_action_assoc__associated__to_leave (cp_t *ctx);
+
+/**
+ * Handle AUTHENTICATED => nek_request.
+ * \param ctx control plane context.
+ */
+void
+cp_av_sta_action_assoc__authenticated__nek_request (cp_t *ctx);
+
+/**
+ * Handle SC_ASSOCIATED => CM_GET_KEY.REQ (PID=3).
+ * \param ctx control plane context.
+ * \param mme received MME to handle.
+ */
+void
+cp_av_sta_action_assoc__sc_associated__cm_get_key_req_pid_3 (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle SC_TEK_EXCHANGED => CM_SET_KEY.REQ (PID=3).
+ * \param ctx control plane context.
+ * \param mme received MME to handle.
+ */
+void
+cp_av_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3 (cp_t *ctx,
+ cp_mme_rx_t *
+ mme);
+
+/**
+ * Handle leaving AUTHENTICATED.
+ * \param ctx control plane context
+ *
+ * Stop lease timer.
+ */
+void
+cp_av_sta_action_assoc__authenticated__leave (cp_t *ctx);
+
+/**
+ * Handle AUTHENTICATED => RENEW.
+ * \param ctx control plane context
+ *
+ * Time to renew our lease. Send a CC_ASSOC.REQ.
+ */
+void
+cp_av_sta_action_assoc__authenticated__renew (cp_t *ctx);
+
+/**
+ * Handle AUTHENTICATED => CC_ASSOC.CNF.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ *
+ * Update:
+ * - our TEI lease time (update lease timer).
+ */
+void
+cp_av_sta_action_assoc__authenticated__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle AUTHENTICATED => CM_SET_KEY.REQ (PID=1), NEK renewal.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ *
+ * Sent periodically by the CCo to change the NEK.
+ *
+ * Update:
+ * - NEK.
+ */
+void
+cp_av_sta_action_assoc__authenticated__cm_set_key_req_pid_1 (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle AUTHENTICATED => TO_LEAVE.
+ * \param ctx control plane context
+ *
+ * Send the CC_LEAVE.REQ message to the CCo. Set a timeout in three beacon
+ * periods.
+ */
+void
+cp_av_sta_action_assoc__authenticated__to_leave (cp_t *ctx);
+
+/**
+ * Handle AUTHENTICATED => CC_LEAVE.IND.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ *
+ * The CCo request us to leave the AVLN. Send a response and go to LEAVE_WAIT
+ * event.
+ */
+void
+cp_av_sta_action_assoc__authenticated__cc_leave_ind (cp_t *ctx,
+ cp_mme_rx_t *mme);
+
+/**
+ * Handle AUTHENTICATED => BEACON.
+ * \param ctx control plane context
+ * \param beacon received beacon
+ * \param net STA net
+ * \param sta STA emitting the beacon
+ *
+ * If the beacon is ours, reset the "beacon not received" counter.
+ */
+void
+cp_av_sta_action_assoc__authenticated__beacon (cp_t *ctx,
+ bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * Handle AUTHENTICATED => BEACON NOT RECEIVED.
+ * \param ctx control plane context
+ *
+ * Increment the "beacon not received" counter. If it reaches the limit,
+ * this is a AVLN failure.
+ */
+void
+cp_av_sta_action_assoc__authenticated__beacon_not_received (cp_t *ctx);
+
+/**
+ * Handle LEAVING => CC_LEAVE.CNF.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ *
+ * Leave the AVLN and cleanup data plane.
+ */
+void
+cp_av_sta_action_assoc__leaving__cc_leave_cnf (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Handle LEAVING => TIMEOUT.
+ * \param ctx control plane context
+ *
+ * Send a CC_LEAVE.REQ again.
+ */
+void
+cp_av_sta_action_assoc__leaving__timeout (cp_t *ctx);
+
+/**
+ * Handle entering LEAVE_WAIT.
+ * \param ctx control plane context
+ */
+void
+cp_av_sta_action_assoc__leave_wait__enter (cp_t *ctx);
+
+/**
+ * Handle LEAVE_WAIT => TIMEOUT.
+ * \param ctx control plane context
+ *
+ * Leave the AVLN and cleanup data plane.
+ */
+void
+cp_av_sta_action_assoc__leave_wait__timeout (cp_t *ctx);
+
+/**
+ * Enter in Unassociating state.
+ * \param ctx the module context.
+ * Update the BSU to act as STA.
+ */
+void
+cp_av_sta_action_unassoc__unassoc__enter (cp_t *ctx);
+
+END_DECLS
+
+#endif /* cp_av_sta_action_assoc_h */
diff --git a/cesar/cp/av/sta/action/drv.h b/cesar/cp/av/sta/action/drv.h
new file mode 100644
index 0000000000..08d8b59bd5
--- /dev/null
+++ b/cesar/cp/av/sta/action/drv.h
@@ -0,0 +1,65 @@
+#ifndef cp_av_sta_action_drv_h
+#define cp_av_sta_action_drv_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/drv.h
+ * \brief STA action, driver related definitions.
+ * \ingroup cp_av_sta_action
+ *
+ */
+
+#include "cp/sta/action/drv.h"
+
+BEGIN_DECLS
+
+/**
+ * Handle USTA => DRV_STA_SC.
+ * \param ctx control plane context.
+ * \param mme the MME to handle.
+ */
+void
+cp_av_sta_action_drv__usta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Handle UCCO => DRV_STA_SC.
+ * \param ctx control plane context.
+ * \param mme the MME to handle.
+ */
+void
+cp_av_sta_action_drv__ucco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Handle CCO => DRV_STA_SC.
+ * \param ctx control plane context.
+ * \param mme the MME to handle.
+ */
+void
+cp_av_sta_action_drv__cco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Handle STA => DRV_STA_SC.
+ * \param ctx control plane context.
+ * \param mme the MME to handle.
+ */
+void
+cp_av_sta_action_drv__sta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Handle many => DRV_STA_SC (failure).
+ * \param ctx control plane context.
+ * \param mme the MME received.
+ *
+ * Disable DRV_STA_SC, but reply to say it to the host.
+ */
+void
+cp_av_sta_action_drv__many__drv_sta_sc__failure (cp_t *ctx, cp_mme_rx_t *mme);
+
+END_DECLS
+
+#endif /* cp_sta_action_drv_h */
diff --git a/cesar/cp/sta/action/handover.h b/cesar/cp/av/sta/action/handover.h
index 29b45a625f..06396e5ab6 100644
--- a/cesar/cp/sta/action/handover.h
+++ b/cesar/cp/av/sta/action/handover.h
@@ -27,7 +27,7 @@ BEGIN_DECLS
* This is called by the FSM on a cc_handover_req MME.
*/
void
-cp_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Starts the handover process.
@@ -35,7 +35,7 @@ cp_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme);
* \param mme the MMe received.
*/
void
-cp_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Received the cc_handover_info_ind MME.
@@ -46,7 +46,7 @@ cp_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme);
* central beacon to become CCo.
*/
void
-cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
+cp_av_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
cp_mme_rx_t *mme);
/**
@@ -56,7 +56,7 @@ cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
* The station is shall now start acting as CCo.
*/
void
-cp_sta_action_handover__handover_ended (cp_t *ctx);
+cp_av_sta_action_handover__handover_ended (cp_t *ctx);
/**
* The countdown handover in the central beacon ended.
@@ -67,7 +67,7 @@ cp_sta_action_handover__handover_ended (cp_t *ctx);
* The new CCo took its functionalities.
*/
void
-cp_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net,
+cp_av_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net,
cp_sta_t *sta);
/**
@@ -75,7 +75,7 @@ cp_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net,
* \param ctx control plane context.
*/
void
-cp_sta_action_handover__failure (cp_t *ctx);
+cp_av_sta_action_handover__failure (cp_t *ctx);
END_DECLS
diff --git a/cesar/cp/sta/action/inc/action.h b/cesar/cp/av/sta/action/inc/action.h
index 6a72812951..61df44842f 100644
--- a/cesar/cp/sta/action/inc/action.h
+++ b/cesar/cp/av/sta/action/inc/action.h
@@ -27,7 +27,7 @@ BEGIN_DECLS
* \param branch_no_match branch taken in other cases
*/
void
-cp_sta_action_beacon_match_and_join (cp_t *ctx,
+cp_av_sta_action_beacon_match_and_join (cp_t *ctx,
bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta, bool sc,
cp_fsm_branch_t branch_match,
diff --git a/cesar/cp/sta/action/info.h b/cesar/cp/av/sta/action/info.h
index 74cbd62f95..b1fdfe03c9 100644
--- a/cesar/cp/sta/action/info.h
+++ b/cesar/cp/av/sta/action/info.h
@@ -1,5 +1,5 @@
-#ifndef cp_sta_action_info_h
-#define cp_sta_action_info_h
+#ifndef cp_av_sta_action_info_h
+#define cp_av_sta_action_info_h
/* Cesar project {{{
*
* Copyright (C) 2008 Spidcom
@@ -8,9 +8,9 @@
*
* }}} */
/**
- * \file cp/sta/action/info.h
+ * \file cp/av/sta/action/info.h
* \brief STA action, information gathering definitions.
- * \ingroup cp_sta_action
+ * \ingroup cp_av_sta_action
*
* Information gathering
* =====================
@@ -33,7 +33,7 @@ BEGIN_DECLS
* - STA mgr.
*/
void
-cp_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Process a CM_UNASSOCIATED_STA.IND, 11.5.1.
@@ -46,8 +46,8 @@ cp_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme);
* - STA mgr.
*/
void
-cp_sta_action_process_cm_unassociated_sta_ind (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_process_cm_unassociated_sta_ind (cp_t *ctx, cp_mme_rx_t *mme);
END_DECLS
-#endif /* cp_sta_action_info_h */
+#endif /* cp_av_sta_action_info_h */
diff --git a/cesar/cp/av/sta/action/misc.h b/cesar/cp/av/sta/action/misc.h
new file mode 100644
index 0000000000..c5095132d9
--- /dev/null
+++ b/cesar/cp/av/sta/action/misc.h
@@ -0,0 +1,41 @@
+#ifndef cp_av_sta_action_misc_h
+#define cp_av_sta_action_misc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/misc.h
+ * \brief STA action, miscellaneous definitions.
+ * \ingroup cp_av_sta_action
+ *
+ */
+#include "cp/sta/action/misc.h"
+
+BEGIN_DECLS
+
+void
+cp_av_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
+
+/**
+ * Join timeout expires or SC failed common function.
+ * \param ctx the module context.
+ * \param branch_no_sta_no_avln the branch to follow when no STA and no AVLN
+ * is present.
+ * \param branch_no_sta_avln the branch to follow when no STA is present but
+ * an AVLN exists.
+ * \param branch_sta the branch to follow when a STA is present.
+ */
+void
+cp_av_sta_action_poweron__cco__join_timeout_sc_failed (
+ cp_t *ctx,
+ cp_fsm_branch_t branch_no_sta_no_avln,
+ cp_fsm_branch_t branch_no_sta_avln,
+ cp_fsm_branch_t branch_sta);
+
+END_DECLS
+
+#endif /* cp_sta_action_misc_h */
diff --git a/cesar/cp/av/sta/action/poweron.h b/cesar/cp/av/sta/action/poweron.h
new file mode 100644
index 0000000000..158c7430de
--- /dev/null
+++ b/cesar/cp/av/sta/action/poweron.h
@@ -0,0 +1,240 @@
+#ifndef cp_av_sta_action_poweron_h
+#define cp_av_sta_action_poweron_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/poweron.h
+ * \brief STA action, power on procedure related definitions.
+ * \ingroup cp_av_sta_action
+ *
+ * Power-on procedure
+ * ==================
+ *
+ * This part handle power-on procedure, neighbourhood discovery and
+ * association decision. A state machine is used to handle the different
+ * states:
+ *
+ * \image html poweron.png "Power-on state machine"
+ *
+ * - (1) send CM_UNASSOCIATED_STA.IND
+ * - (2) select an AVLN to track
+ * - (3) restart join timer
+ *
+ * Related: 7.1.
+ */
+
+BEGIN_DECLS
+
+/**
+ * Handle entering POWERON.
+ * \param ctx control plane context
+ *
+ * Start the BTT and USTT timers.
+ */
+void
+cp_av_sta_action_poweron__poweron__enter (cp_t *ctx);
+
+/**
+ * Handle leaving POWERON.
+ * \param ctx control plane context
+ *
+ * Stop BTT and USTT timers.
+ */
+void
+cp_av_sta_action_poweron__poweron__leave (cp_t *ctx);
+
+/**
+ * Handle POWERON => USTT TIMEOUT.
+ * \param ctx control plane context
+ *
+ * If there is at least one AVLN in the discovered list, send a
+ * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
+ * (in the right range).
+ */
+void
+cp_av_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx);
+
+/**
+ * Handle POWERON => BTT TIMEOUT.
+ * \param ctx control plane context
+ *
+ * No beacon has been received during the BTT timer. Look in the discovered
+ * STA list to see if there is a NID match. If a NID match and the station
+ * should become CCo, go to CCO state.
+ *
+ * In other cases, if there is at least one AVLN in the discovered list, go to
+ * USTA state. If there is no AVLN discovered, go to UCCO state.
+ */
+void
+cp_av_sta_action_poweron__poweron__btt_timeout (cp_t *ctx);
+
+/**
+ * Handle POWERON => BEACON.
+ * \param ctx control plane context
+ * \param beacon received beacon
+ * \param net STA net
+ * \param sta STA emitting the beacon
+ *
+ * When a beacon is received, if NID matches, go to corresponding JOINING
+ * states and start the association procedure. In the other case, select an
+ * AVLN to track in the list of discovered AVLN and continue searching.
+ */
+void
+cp_av_sta_action_poweron__poweron__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * Handle POWERON_JOINING => LEFT.
+ * \param ctx control plane context
+ *
+ * Select an AVLN to track and continue searching.
+ */
+void
+cp_av_sta_action_poweron__poweron_joining__left (cp_t *ctx);
+
+/**
+ * Handle POWERON_JOINING, USTA_JOINING => TO_STOP.
+ * \param ctx control plane context
+ */
+void
+cp_av_sta_action_poweron__joining__to_stop (cp_t *ctx);
+
+/**
+ * Handle entering USTA.
+ * \param ctx control plane context
+ *
+ * Start the USTT timer.
+ */
+void
+cp_av_sta_action_poweron__usta__enter (cp_t *ctx);
+
+/**
+ * Handle entering USTA_JOINING.
+ * \param ctx control plane context
+ */
+void
+cp_av_sta_action_poweron__usta_joining__enter (cp_t *ctx);
+
+/**
+ * Handle leaving USTA.
+ * \param ctx control plane context
+ *
+ * Stop the USTT timer.
+ */
+void
+cp_av_sta_action_poweron__usta__leave (cp_t *ctx);
+
+/**
+ * Handle USTA => USTT TIMEOUT.
+ * \param ctx control plane context
+ *
+ * If there is at least one AVLN in the discovered list, send a
+ * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
+ * (in the right range).
+ */
+void
+cp_av_sta_action_poweron__usta__ustt_timeout (cp_t *ctx);
+
+/**
+ * Handle USTA => BEACON.
+ * \param ctx control plane context
+ * \param beacon received beacon
+ * \param net STA net
+ * \param sta STA emitting the beacon
+ *
+ * When a beacon is received, if NID matches, go to corresponding JOINING
+ * states and start the association procedure. In the other case, select an
+ * AVLN to track in the list of discovered AVLN and continue searching.
+ */
+void
+cp_av_sta_action_poweron__usta__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * Handle USTA => USTA IND.
+ * \param ctx control plane context
+ * \param net STA net
+ * \param sta STA emitting CM_UNASSOCIATED_STA.IND
+ *
+ * If the NID match and the station should become CCo go to CCO state.
+ */
+void
+cp_av_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
+ cp_sta_t *sta);
+
+/**
+ * Handle USTA_JOINING => LEFT.
+ * \param ctx control plane context
+ *
+ * Select an AVLN to track and continue searching.
+ */
+void
+cp_av_sta_action_poweron__usta_joining__left (cp_t *ctx);
+
+/**
+ * Handle UCCO => BEACON.
+ * \param ctx control plane context
+ * \param beacon received beacon
+ * \param net STA net
+ * \param sta STA emitting the beacon
+ *
+ * Disable discover beacon emission.
+ */
+void
+cp_av_sta_action_poweron__ucco__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta);
+
+/**
+ * Handle STA => TO_STOP.
+ * \param ctx control plane context
+ */
+void
+cp_av_sta_action_poweron__sta__to_stop (cp_t *ctx);
+
+/**
+ * Handle entering CCO.
+ * \param ctx control plane context
+ *
+ * Start join timer.
+ */
+void
+cp_av_sta_action_poweron_cco__enter (cp_t *ctx);
+
+/**
+ * Handle leaving CCO.
+ * \param ctx control plane context
+ *
+ * Stop join timer.
+ */
+void
+cp_av_sta_action_poweron_cco__leave (cp_t *ctx);
+
+/**
+ * Handle CCO => JOIN TIMEOUT.
+ * \param ctx control plane context
+ *
+ * If there is no associated STA, stop being a CCo. In this case, if there is
+ * at least one discovered AVLN, go to USTA state. Else, go to UCCO state.
+ */
+void
+cp_av_sta_action_poweron__cco__join_timeout (cp_t *ctx);
+
+void
+cp_av_sta_action_poweron__idle__enter (cp_t *ctx);
+
+/**
+ * Initialise poweron part.
+ * \param ctx control plane context
+ */
+void
+cp_av_sta_action_poweron_init (cp_t *ctx);
+
+
+END_DECLS
+
+#endif /* cp_av_sta_action_poweron_h */
diff --git a/cesar/cp/sta/action/sc.h b/cesar/cp/av/sta/action/sc.h
index c1db60745d..261a497bfc 100644
--- a/cesar/cp/sta/action/sc.h
+++ b/cesar/cp/av/sta/action/sc.h
@@ -1,5 +1,5 @@
-#ifndef cp_sta_action_sc_h
-#define cp_sta_action_sc_h
+#ifndef cp_av_sta_action_sc_h
+#define cp_av_sta_action_sc_h
/* Cesar project {{{
*
* Copyright (C) 2009 Spidcom
@@ -20,10 +20,12 @@
*
* The communication between this FSM and the main one, is handled by posting
* event. Basically, this FSM starts when you use the
- * cp_sta_action_sc__start_sc_join or cp_sta_action_sc__start_sc_add which
+ * cp_av_sta_action_sc__start_sc_join or cp_av_sta_action_sc__start_sc_add which
* posts the event sc_start_add or sc_start_join.
*/
+#include "cp/sta/mgr/sta_mgr.h"
+
BEGIN_DECLS
/**
@@ -31,42 +33,42 @@ BEGIN_DECLS
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__start_sc_join (cp_t *ctx);
+cp_av_sta_action_sc__start_sc_join (cp_t *ctx);
/**
* Start the SC FSM in SC_ADD.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__start_sc_add (cp_t *ctx);
+cp_av_sta_action_sc__start_sc_add (cp_t *ctx);
/**
* SC_IDLE enter function.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__sc_idle__enter (cp_t *ctx);
+cp_av_sta_action_sc__sc_idle__enter (cp_t *ctx);
/**
* SC_IDLE leave function.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__sc_idle__leave (cp_t *ctx);
+cp_av_sta_action_sc__sc_idle__leave (cp_t *ctx);
/**
* SC_JOIN enter function.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__sc_join__enter (cp_t *ctx);
+cp_av_sta_action_sc__sc_join__enter (cp_t *ctx);
/**
* SC_JOIN leave function.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__sc_join__leave (cp_t *ctx);
+cp_av_sta_action_sc__sc_join__leave (cp_t *ctx);
/**
* Handle * => SC_TIMEOUT.
@@ -75,7 +77,7 @@ cp_sta_action_sc__sc_join__leave (cp_t *ctx);
* SC Procedure is aborted, tell it to the CP FSM and stop association FSM.
*/
void
-cp_sta_action_sc__sc_timeout (cp_t *ctx);
+cp_av_sta_action_sc__sc_timeout (cp_t *ctx);
/**
* Handle SC_ADD => SC_TIMEOUT.
@@ -85,7 +87,7 @@ cp_sta_action_sc__sc_timeout (cp_t *ctx);
* FSM.
*/
void
-cp_sta_action_sc_add__sc_timeout (cp_t *ctx);
+cp_av_sta_action_sc_add__sc_timeout (cp_t *ctx);
/**
* Handle SC_ADD => CM_SC_JOIN.REQ.
@@ -95,7 +97,7 @@ cp_sta_action_sc_add__sc_timeout (cp_t *ctx);
* CM_SC_JOIN.CNF. Otherwise stay in this state.
*/
void
-cp_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Common handle anywhere => TO_STOP.
@@ -104,7 +106,7 @@ cp_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
* Stop timer.
*/
void
-cp_sta_action_sc__to_stop (cp_t *ctx);
+cp_av_sta_action_sc__to_stop (cp_t *ctx);
/**
* Handle SC_WAIT_PEER_ASSOCIATED => NEW_STA_ASSOCIATED.
@@ -115,7 +117,7 @@ cp_sta_action_sc__to_stop (cp_t *ctx);
* If STA is part of our AVLN, begin UKE, otherwise, stay here.
*/
void
-cp_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
+cp_av_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
cp_net_t *net,
cp_sta_t *sta);
@@ -125,7 +127,7 @@ cp_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
* \param mme the MME handle.
*/
void
-cp_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Handle SC_JOIN => CM_SC_JOIN.CNF
@@ -133,14 +135,14 @@ cp_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme);
* \param mme the MME handle.
*/
void
-cp_sta_action_sc__sc_join__cm_sc_join_cnf (cp_t *ctx, cp_mme_rx_t *mme);
+cp_av_sta_action_sc__sc_join__cm_sc_join_cnf (cp_t *ctx, cp_mme_rx_t *mme);
/**
* Handle SC_JOIN => SC_JOIN_REQ_TIMEOUT.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__sc_join__sc_join_req_timeout (cp_t *ctx);
+cp_av_sta_action_sc__sc_join__sc_join_req_timeout (cp_t *ctx);
/**
* Handle SC_WAIT_BEACON => BEACON.
@@ -150,7 +152,7 @@ cp_sta_action_sc__sc_join__sc_join_req_timeout (cp_t *ctx);
* \param sta STA emitting the beacon.
*/
void
-cp_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta);
/**
@@ -159,7 +161,7 @@ cp_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
* \param mme the MME handle.
*/
void
-cp_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
+cp_av_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
cp_mme_rx_t *mme);
/**
@@ -168,7 +170,7 @@ cp_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
* \param mme the MME handle.
*/
void
-cp_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
+cp_av_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
cp_mme_rx_t *mme);
/**
@@ -181,7 +183,7 @@ cp_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
* Track the AVLN if it is better to track this one.
*/
void
-cp_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta);
/**
@@ -195,7 +197,7 @@ cp_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
* track this one.
*/
void
-cp_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta);
/**
@@ -205,11 +207,11 @@ cp_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
* Emit event "to stop" to stop SC FSM.
*/
void
-cp_sta_action_sc__sc_sta__avln_failure (cp_t *ctx);
+cp_av_sta_action_sc__sc_sta__avln_failure (cp_t *ctx);
void
-cp_sta_action_sc__sc_cco__sc_failed (cp_t *ctx);
+cp_av_sta_action_sc__sc_cco__sc_failed (cp_t *ctx);
END_DECLS
-#endif /* cp_sta_action_sc_h */
+#endif /* cp_av_sta_action_sc_h */
diff --git a/cesar/cp/av/sta/action/src/action.c b/cesar/cp/av/sta/action/src/action.c
new file mode 100644
index 0000000000..f9f44be797
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/action.c
@@ -0,0 +1,122 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/action.c
+ * \brief STA action.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+
+#include "action.h"
+#include "cp/sta/action/action.h"
+
+#include "cp/inc/context.h" // cp_t
+#include "cp/av/cco/bw/bw.h"
+#include "cp/av/sta/mgr/sta_mgr.h"
+#include "ce/tx/tx.h"
+#include "cp/fsm/fsm.h"
+#include "cp/beacon/beacon.h"
+
+/** Delay after the one, the NET is considered worth than an other one.
+ * This delay should be added to the last beacon reception date from the CCo
+ * on the net. */
+#define CP_STA_ACTION_TRACK_EXPIRED_MS 400
+
+void
+cp_av_sta_action_beacon_match_and_join (cp_t *ctx,
+ bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta, bool sc,
+ cp_fsm_branch_t branch_match,
+ cp_fsm_branch_t branch_no_match)
+{
+ cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (ctx);
+ cp_nid_t our_nid = cp_sta_own_data_get_nid (ctx);
+ cp_nid_t its_nid = cp_net_get_nid (ctx, net);
+ u8 its_snid = cp_net_get_snid (ctx, net);
+ /* Does not support proxy networking for the moment, only handle CCo
+ * beacon. */
+ if (cp_sta_get_cco_status (sta))
+ {
+ cp_net_t *net_tracking =
+ cp_sta_mgr_get_avln (ctx, cp_sta_own_data_get_snid (ctx),
+ own_data->nid_track);
+ /* Should we track this beacon? */
+ if (!net_tracking /* Net tracking no more present. */
+ || (its_nid == our_nid /* New net nid match our nid. */
+ && !net->blacklisted /* New net is not blacklisted. */
+ && (own_data->nid_track != our_nid /* Not our nid.*/
+ || net_tracking->blacklisted
+ || less_mod2p32 (
+ net_tracking->beacon_recv_date
+ + MAC_MS_TO_TCK (CP_STA_ACTION_TRACK_EXPIRED_MS),
+ phy_date ()))
+ )
+ )
+ {
+ cp_av_sta_mgr_set_tracking (ctx, its_snid, its_nid);
+ cp_beacon_process_tracked_avln (ctx, beacon, net);
+ }
+ /* The CCo has changed. */
+ else if (net_tracking == net
+ && !beacon->bmis.change_snid.present
+ && cp_net_get_slot_id (ctx, net) == beacon->vf.slotid)
+ {
+ /* station manager stores MAC_BROADCAST if the mac address is
+ * unknown, the tracking system store MAC_ZERO if it does not
+ * track a CCo, so we need to adapt the station's MAC address to
+ * the tracked one. */
+ mac_t cco_mac = cp_sta_get_mac_address (sta) == MAC_BROADCAST ?
+ MAC_ZERO : cp_sta_get_mac_address (sta);
+ if (cco_mac != own_data->cco_mac_addr_track)
+ {
+ /* We can assume this CCo is the new one. */
+ cp_net_set_cco (ctx, net, cp_sta_get_tei (sta));
+ cp_beacon_process_tracked_avln (ctx, beacon, net);
+ }
+ }
+ /* Should we associate? */
+ if (its_nid == our_nid
+ && its_snid == cp_sta_own_data_get_snid (ctx)
+ && !net->blacklisted
+ && cp_beacon_synchronised (ctx))
+ {
+ if (!sc)
+ cp_av_sta_action_assoc_start (ctx, net, sta);
+ else
+ {
+ /* Start assoc procedure. */
+ cp_av_sta_action_sc_assoc_start (ctx, net, sta);
+ /* Inform main FSM we have start SC association procedure. */
+ cp_fsm_trigger_new_event (ctx, bare, sc_succeed);
+ }
+ cp_fsm_branch_ (ctx, branch_match);
+ }
+ else
+ {
+ cp_fsm_branch_ (ctx, branch_no_match);
+ }
+ }
+ else
+ {
+ cp_fsm_branch_ (ctx, branch_no_match);
+ }
+}
+
+void
+cp_av_sta_action_init (cp_t *ctx)
+{
+ cp_sta_action_assoc_init (ctx);
+ /* Initialize the STA action bridge module. */
+ cp_sta_action_bridge_init (ctx);
+ /* Initialize the STA action misc module. */
+ cp_sta_action_misc_init (ctx);
+ /* Create the default allocation schedules. */
+ cp_av_cco_bw_schedules_default (ctx);
+ /* Initialize the STA action poweron module. */
+ cp_av_sta_action_poweron_init (ctx);
+}
diff --git a/cesar/cp/av/sta/action/src/assoc.c b/cesar/cp/av/sta/action/src/assoc.c
new file mode 100644
index 0000000000..8d9cc7c7a0
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/assoc.c
@@ -0,0 +1,815 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/assoc.c
+ * \brief STA action, association related definitions.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+
+#include "action.h"
+#include "cp/sta/action/action.h"
+
+#include "cp/inc/context.h"
+#include "cp/fsm/fsm.h"
+#include "cp/msg/msg.h"
+#include "cp/beacon/beacon.h"
+#include "lib/rnd.h"
+#include "cp/secu/defs.h"
+#include "cp/beacon/beacon.h"
+#include "bsu/bsu.h"
+
+#define RETRY_TIMEOUT_MS 1000
+#define RENEW_MARGIN_MS (5 * 60 * 1000)
+#define LEAVING_TIMEOUT_MS (40 * 3)
+#define LEAVE_WAIT_TIMEOUT_MS 1000
+
+void
+cp_av_sta_action_assoc_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+void
+cp_av_sta_action_sc_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (cco_net);
+ /* cco can be NULL. */
+
+ /* Check NID. */
+ dbg_assert (cp_sta_own_data_get_nid (ctx)
+ == cp_net_get_nid (ctx, cco_net));
+
+ /* Do we know the CCo? */
+ if (cco)
+ /* Store CCo peer. */
+ cp_sta_get_peer (cco, &ctx->sta_action.assoc.peer);
+ else
+ {
+ /* Let's try to find the CCo from the net. */
+ cp_sta_t *cco_from_net = cp_net_get_cco (ctx, cco_net);
+ if (cco_from_net)
+ {
+ /* Get peer CCo. */
+ cp_sta_get_peer (cco_from_net, &ctx->sta_action.assoc.peer);
+ /* Release. */
+ slab_release (cco_from_net);
+ }
+ else
+ {
+ /* We do not know the CCo, broadcast to all STA. */
+ ctx->sta_action.assoc.peer = CP_MME_PEER (MAC_BROADCAST,
+ MAC_TEI_UNASSOCIATED);
+ }
+ }
+ ctx->sta_action.assoc.snid = cp_net_get_snid (ctx, cco_net);
+ ctx->sta_action.assoc.retry = 3;
+ /* Trigger to_sc_assoc event. */
+ cp_fsm_trigger_new_event (ctx, bare, to_sc_assoc);
+}
+
+void
+cp_av_sta_action_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco)
+{
+ dbg_assert (ctx);
+ dbg_assert (cco_net);
+ dbg_assert (cco);
+ /* Remember CCo to associate with. */
+ dbg_assert (cp_sta_own_data_get_nid (ctx)
+ == cp_net_get_nid (ctx, cco_net));
+ cp_sta_get_peer (cco, &ctx->sta_action.assoc.peer);
+ ctx->sta_action.assoc.snid = cp_net_get_snid (ctx, cco_net);
+ ctx->sta_action.assoc.retry = 3;
+ /* Trigger to_assoc event. */
+ cp_fsm_trigger_new_event (ctx, bare, to_assoc);
+}
+
+void
+cp_av_sta_action_assoc_leave (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Trigger to_leave event. */
+ cp_fsm_trigger_new_event (ctx, bare, to_leave);
+}
+
+void
+cp_av_sta_action_assoc__unassociated__enter (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_sta_own_data_set_authenticated_status (ctx, false);
+ cp_sta_mgr_set_our_avln (ctx, NULL);
+ cp_sta_own_data_set_tei (ctx, 0);
+ cp_fsm_trigger_new_event (ctx, bare, left);
+ /* Reset some parts. */
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (ctx);
+ own->hybrid_mode = MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
+}
+
+void
+cp_av_sta_action_assoc__unassociated__to_assoc (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Send association request. */
+ cp_msg_cc_assoc_req_t data = {
+ CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
+ cp_sta_own_data_get_nid (ctx),
+ CP_CCO_LEVEL,
+ CP_PCO_CAP
+ };
+ cp_msg_cc_assoc_req_send (ctx, &ctx->sta_action.assoc.peer, &data);
+}
+
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (cp_t *ctx,
+ cp_mme_rx_t *mme,
+ bool sc)
+{
+ cp_msg_cc_assoc_cnf_t cnf;
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ /* Check response. */
+ if ((mme->peer.mac != ctx->sta_action.assoc.peer.mac
+ && ctx->sta_action.assoc.peer.mac != MAC_BROADCAST)
+ || !cp_msg_cc_assoc_cnf_receive (ctx, mme, &cnf)
+ || cnf.nid != cp_sta_own_data_get_nid (ctx)
+ || cnf.snid != ctx->sta_action.assoc.snid)
+ {
+ /* Unrelated message, drop. */
+ if (!sc)
+ cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, unrelated);
+ else
+ cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, unrelated);
+ }
+ else if (cnf.result != CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS)
+ {
+ /* Failure indication. */
+ if (!sc)
+ cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, nok);
+ else
+ cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, nok);
+ }
+ else
+ {
+ cp_net_t *our_net;
+ /* Start lease timer, it can not expire before we go to authenticated
+ * state because authentication timeout is shorter. */
+ int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
+ if (lease_time_ms > 0)
+ {
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_renew);
+ cp_sta_core_gen_timed_event (ctx,
+ &ctx->sta_action.assoc.lease_timer,
+ event, lease_time_ms);
+ }
+ /* Update state. */
+ cp_sta_own_data_set_tei (ctx, cnf.sta_tei);
+ our_net = cp_sta_mgr_add_avln (ctx, cnf.snid, cnf.nid);
+ cp_sta_t *cco =
+ cp_sta_mgr_sta_add (ctx, our_net, mme->peer.tei, mme->peer.mac);
+ cp_net_set_cco (ctx, our_net, mme->peer.tei);
+ slab_release (cco);
+ ctx->sta_action.assoc.peer = mme->peer;
+ ctx->sta_action.assoc.snid = cnf.snid;
+ cp_sta_mgr_set_our_avln (ctx, our_net);
+ /* Not in SC procedure. */
+ if (!sc)
+ {
+ /* Send get key request. */
+ cp_msg_cm_get_key_req_t get_key = {
+ .relayed = false, .key_type = CP_MSG_KEY_NEK,
+ .nid = cp_sta_own_data_get_nid (ctx) };
+ cp_secu_protocol_run_new (&ctx->sta_action.assoc.prun, 0,
+ &ctx->rnd);
+ cp_msg_cm_get_key_req_send (ctx, &mme->peer, CP_MME_PEKS_NMK,
+ &ctx->sta_action.assoc.prun, &get_key);
+ /* Change state. */
+ cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, ok);
+ }
+ else
+ {
+ /* In SC procedure. */
+ /* Ensure SC peer is correct, so let's copy it back (to handle TEI
+ * change (UCCO to CCO) and/or MAC change (broadcast). */
+ ctx->sta_action.sc.peer = mme->peer;
+ /* Nothing to send. */
+ /* Change state. */
+ cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, ok);
+ }
+ }
+}
+
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (ctx, mme,
+ false);
+}
+
+void
+cp_av_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ cp_av_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (ctx, mme,
+ true);
+}
+
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__timeout_common (cp_t *ctx, bool sc)
+{
+ dbg_assert (ctx);
+ ctx->sta_action.assoc.retry--;
+ if (ctx->sta_action.assoc.retry)
+ {
+ /* Restart timer. */
+ cp_sta_action_assoc__start_retry_timer (ctx);
+ /* Resend association request. */
+
+ cp_av_sta_action_assoc__unassociated__to_assoc (ctx);
+ if (!sc)
+ cp_fsm_branch (ctx, WAIT_ASSOC_CONF, assoc_timeout, retry);
+ else
+ cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, assoc_timeout, retry);
+ }
+ else
+ {
+ /* Give up. */
+ if (!sc)
+ cp_fsm_branch (ctx, WAIT_ASSOC_CONF, assoc_timeout, no_retry);
+ else
+ cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, assoc_timeout, no_retry);
+ /* Black list the net. */
+ cp_sta_t *sta =
+ cp_sta_mgr_sta_get_from_mac (
+ ctx, ctx->sta_action.assoc.peer.mac);
+ if (sta)
+ {
+ cp_net_t *net = cp_sta_get_net (sta);
+ slab_release (sta);
+ cp_net_blacklisted_status_set (ctx, net, true);
+ }
+ }
+}
+
+void
+cp_av_sta_action_assoc__wait_assoc_cnf__timeout (cp_t *ctx)
+{
+ cp_av_sta_action_assoc__wait_assoc_cnf__timeout_common (ctx, false);
+}
+
+void
+cp_av_sta_action_assoc__sc_wait_assoc_cnf__timeout (cp_t *ctx)
+{
+ cp_av_sta_action_assoc__wait_assoc_cnf__timeout_common (ctx, true);
+}
+
+void
+cp_av_sta_action_assoc__cm_get_key_cnf__common (cp_t *ctx, cp_mme_rx_t
+ *mme, bool sc)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ cp_msg_cm_get_key_cnf_t cnf;
+ /* Check response. */
+ if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.assoc.peer)
+ || !cp_msg_cm_get_key_cnf_receive (ctx, mme, &cnf)
+ || (!cp_secu_protocol_check
+ (&ctx->sta_action.assoc.prun, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_LAST))
+ || cnf.nid != cp_sta_own_data_get_nid (ctx)
+ || cnf.key_type != CP_MSG_KEY_NEK
+ || (sc && mme->peks != CP_MME_PEKS_NMK))
+ {
+ /* Unrelated message, drop. */
+ if (!sc)
+ cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, unrelated);
+ else
+ cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, unrelated);
+ }
+ else if (cnf.result != CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED)
+ {
+ /* Failure indication. */
+ if (!sc)
+ cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, nok);
+ else
+ cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, nok);
+ /* Black list the net. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_net_blacklisted_status_set (ctx, our_net, true);
+ }
+ else
+ {
+ /* Use the new key. */
+ cp_sta_own_data_set_authenticated_status (ctx, true);
+ cp_beacon_change_nek (ctx, cnf.eks, cnf.key, true);
+ /* Signal joined state. */
+ cp_fsm_trigger_new_event (ctx, bare, joined);
+ /* Reset beacon loss counter. */
+ ctx->sta_action.assoc.beacon_loss = 0;
+ if (!sc)
+ cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, ok);
+ else
+ cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, ok);
+ }
+}
+
+void
+cp_av_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0 (cp_t *ctx,
+ cp_mme_rx_t *
+ mme)
+{
+ cp_av_sta_action_assoc__cm_get_key_cnf__common (ctx, mme, true);
+}
+
+void
+cp_av_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1 (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ cp_msg_cm_get_key_cnf_t cnf;
+
+ /* Get our cco peer. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+
+ /* Check response. */
+ if (cp_mme_peer_cmp (&mme->peer, &peer)
+ && cp_msg_cm_get_key_cnf_receive (ctx, mme, &cnf)
+ && (cp_secu_protocol_check
+ (&ctx->sta_action.nek_prun, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_LAST))
+ && cnf.nid == cp_sta_own_data_get_nid (ctx)
+ && cnf.key_type == CP_MSG_KEY_NEK
+ && mme->peks == CP_MME_PEKS_NMK
+ && cnf.result == CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED)
+ {
+ /* Use the new key. */
+ cp_beacon_change_nek (ctx, cnf.eks, cnf.key, false);
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__nek_request (cp_t *ctx)
+{
+ cp_msg_cm_get_key_req_t get_key = {
+ .relayed = false, .key_type = CP_MSG_KEY_NEK,
+ .nid = cp_sta_own_data_get_nid (ctx) };
+ cp_mme_peer_t cco_peer;
+ cp_net_get_cco_peer (ctx, cp_sta_mgr_get_our_avln (ctx),
+ &cco_peer);
+ cp_secu_protocol_run_new (&ctx->sta_action.nek_prun,
+ 1, &ctx->rnd);
+
+ cp_msg_cm_get_key_req_send (ctx, &cco_peer,
+ CP_MME_PEKS_NMK,
+ &ctx->sta_action.nek_prun,
+ &get_key);
+}
+
+void
+cp_av_sta_action_assoc__associated__cm_get_key_cnf_pid_0 (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ cp_av_sta_action_assoc__cm_get_key_cnf__common (ctx, mme, false);
+}
+
+void
+cp_av_sta_action_assoc__associated__timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Stop lease timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.assoc.lease_timer);
+}
+
+void
+cp_av_sta_action_assoc__associated__to_leave (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Stop lease timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.assoc.lease_timer);
+}
+
+void
+cp_av_sta_action_assoc__sc_associated__cm_get_key_req_pid_3 (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ cp_msg_cm_get_key_req_t req;
+ /* Check response (note, the MME should be sent by the STA with which are
+ * doing the SC (it can be different from the CCo); */
+ if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.sc.peer)
+ || !cp_msg_cm_get_key_req_receive (ctx, mme, &req)
+ || (!cp_secu_protocol_check
+ (NULL, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
+ || (req.nid != cp_sta_own_data_get_nid (ctx))
+ || (req.key_type != CP_MSG_KEY_HASH_KEY)
+ || (mme->peks != CP_MME_PEKS_SPC_NOT_EMBEDDED)
+ )
+ {
+ /* Unrelated message, drop it. */
+ cp_fsm_branch (ctx, SC_ASSOCIATED, CM_GET_KEY_REQ_PID3, unrelated);
+ }
+ else
+ {
+ /* Message is valid, reply. */
+ /* Copy security protocol run for authentication. */
+ ctx->sta_action.assoc.prun = mme->prun;
+ /* Prepare message. */
+ cp_msg_cm_get_key_cnf_t cnf;
+ cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
+ cnf.key_type = CP_MSG_KEY_HASH_KEY;
+ cnf.nid = cp_sta_own_data_get_nid (ctx);
+ cnf.eks = CP_MME_PEKS_TEK_MIN;
+ /* Generate an hash key. */
+ cp_secu_generate_hash (ctx, lib_rnd32 (&ctx->rnd), (u8 *) cnf.hash_key,
+ CP_SECU_HASH_KEY_FOR_TEK_SIZE);
+ /* Generate TEK with hash key from CM_HET_KEY REQ and CNF. */
+ cp_secu_tek_gen (req.hash_key, cnf.hash_key,
+ &ctx->sta_action.sc.tek);
+ /* Send CM_GET_KEY.CNF. */
+ cp_secu_protocol_next (&ctx->sta_action.assoc.prun, &ctx->rnd, false);
+ cp_msg_cm_get_key_cnf_send (ctx, &ctx->sta_action.sc.peer,
+ CP_MME_PEKS_SPC_NOT_EMBEDDED,
+ &ctx->sta_action.assoc.prun,
+ &cnf);
+ /* Set TEK for encryption/decryption of cm_encrypted payload. */
+ cp_sta_own_data_set_tek (ctx, ctx->sta_action.sc.tek);
+ cp_fsm_branch (ctx, SC_ASSOCIATED, CM_GET_KEY_REQ_PID3, ok);
+ }
+}
+
+void
+cp_av_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3 (cp_t *ctx,
+ cp_mme_rx_t
+ *mme)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ cp_msg_cm_set_key_req_t req;
+ /* Check response (note, the MME should be sent by the STA with which are
+ * doing the SC (it can be different from the CCo); */
+ if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.sc.peer)
+ || !cp_msg_cm_set_key_req_receive (ctx, mme, &req)
+ || (!cp_secu_protocol_check
+ (&ctx->sta_action.assoc.prun, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT))
+ || (req.nid != cp_sta_own_data_get_nid (ctx))
+ || (req.key_type != CP_MSG_KEY_NMK)
+ )
+ {
+ /* Unrelated message, drop it. */
+ cp_fsm_branch (ctx, SC_TEK_EXCHANGED, CM_SET_KEY_REQ_PID3, unrelated);
+ }
+ else
+ {
+ /* Message is valid. */
+ /* Set NMK. */
+ cp_sta_own_data_set_nmk (
+ ctx,
+ req.new_key,
+ CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL);
+ /* Copy security protocol run for authentication. */
+ ctx->sta_action.assoc.prun = mme->prun;
+ /* Prepare message for reply. */
+ cp_msg_cm_set_key_cnf_t cnf;
+ cnf.result = CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS;
+ cnf.cco_cap = CP_CCO_LEVEL;
+ /* Send CM_SET_KEY.CNF. */
+ cp_secu_protocol_next (&ctx->sta_action.assoc.prun, &ctx->rnd, true);
+ cp_msg_cm_set_key_cnf_send (ctx, &ctx->sta_action.sc.peer,
+ CP_MME_PEKS_NMK,
+ &ctx->sta_action.assoc.prun,
+ &cnf);
+ /* Start authentication. */
+ cp_msg_cm_get_key_req_t get_key = {
+ .relayed = false, .key_type = CP_MSG_KEY_NEK,
+ .nid = cp_sta_own_data_get_nid (ctx) };
+ cp_secu_protocol_run_new (&ctx->sta_action.assoc.prun, 0,
+ &ctx->rnd);
+ cp_msg_cm_get_key_req_send (ctx, &ctx->sta_action.assoc.peer,
+ CP_MME_PEKS_NMK,
+ &ctx->sta_action.assoc.prun, &get_key);
+ cp_fsm_branch (ctx, SC_TEK_EXCHANGED, CM_SET_KEY_REQ_PID3, ok);
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__leave (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Stop lease timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.assoc.lease_timer);
+}
+
+void
+cp_av_sta_action_assoc__authenticated__renew (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Restart timer. */
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_renew);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.lease_timer,
+ event, RENEW_MARGIN_MS / 2);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Send CC_ASSOC.REQ to renew lease. */
+ cp_msg_cc_assoc_req_t req = {
+ CP_MSG_CC_ASSOC_REQ_TYPE_RENEW,
+ cp_sta_own_data_get_nid (ctx),
+ CP_CCO_LEVEL, CP_PCO_CAP
+ };
+ cp_msg_cc_assoc_req_send (ctx, &peer, &req);
+}
+
+void
+cp_av_sta_action_assoc__authenticated__cc_assoc_cnf (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Check received message. */
+ cp_msg_cc_assoc_cnf_t cnf;
+ if (cp_mme_peer_cmp (&mme->peer, &peer)
+ && cp_msg_cc_assoc_cnf_receive (ctx, mme, &cnf)
+ && cnf.result == CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS
+ && cnf.nid == cp_sta_own_data_get_nid (ctx))
+ {
+ /* Update lease. */
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.assoc.lease_timer);
+ int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
+ if (lease_time_ms > 0)
+ {
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_renew);
+ cp_sta_core_gen_timed_event (ctx,
+ &ctx->sta_action.assoc.lease_timer,
+ event, lease_time_ms);
+ }
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__cm_set_key_req_pid_1 (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Check received message. */
+ cp_msg_cm_set_key_req_t req;
+
+ if (cp_mme_peer_cmp (&mme->peer, &peer)
+ && cp_msg_cm_set_key_req_receive (ctx, mme, &req)
+ && req.nid == cp_sta_own_data_get_nid (ctx))
+ {
+ if ((req.key_type == CP_MSG_KEY_NEK)
+ && (mme->peks == CP_MME_PEKS_NMK)
+ && (cp_secu_protocol_check
+ (&ctx->sta_action.nek_prun, &mme->prun,
+ CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT)))
+ {
+ ctx->sta_action.nek_prun = mme->prun;
+ /* Send response. */
+ cp_msg_cm_set_key_cnf_t cnf = {
+ CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
+ CP_CCO_LEVEL };
+ cp_secu_protocol_next (&ctx->sta_action.nek_prun, &ctx->rnd,
+ true);
+ cp_msg_cm_set_key_cnf_send (ctx, &peer, CP_MME_PEKS_NMK,
+ &ctx->sta_action.nek_prun,
+ &cnf);
+ /* Update NEK. */
+ cp_beacon_change_nek (ctx, req.new_eks, req.new_key, false);
+ }
+ else if ((req.key_type == CP_MSG_KEY_NONCE_ONLY)
+ && (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED
+ || mme->peks == CP_MME_PEKS_NONE)
+ && (cp_secu_protocol_check
+ (NULL, &mme->prun, CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW)))
+ {
+ /* Send response. */
+ cp_msg_cm_set_key_cnf_t cnf = {
+ CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
+ CP_CCO_LEVEL };
+
+ ctx->sta_action.nek_prun = mme->prun;
+ cp_secu_protocol_next (&ctx->sta_action.nek_prun, &ctx->rnd,
+ false);
+ ctx->sta_action.nek_prun.my_nonce = lib_rnd32 (&ctx->rnd);
+ cp_msg_cm_set_key_cnf_send (ctx, &peer, mme->peks,
+ &ctx->sta_action.nek_prun,
+ &cnf);
+ }
+ }
+ else
+ {
+ /* Send response. */
+ cp_msg_cm_set_key_cnf_t cnf = {
+ CP_MSG_CM_SET_KEY_CNF_RESULT_FAILURE,
+ CP_CCO_LEVEL };
+ cp_secu_protocol_run_t prun = mme->prun;
+ prun.my_nonce = lib_rnd32 (&ctx->rnd);
+ cp_secu_protocol_next (&prun, &ctx->rnd, true);
+ cp_msg_cm_set_key_cnf_send (ctx, &peer, CP_MME_PEKS_NONE, &prun,
+ &cnf);
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__to_leave (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ /* If we were the CCo and we cannot provide the CCo role to another
+ * station (Handover failure because no station were authenticated in the
+ * AVLN) we must not send any MME to the CCo. */
+ cp_sta_t *cco = cp_net_get_cco (ctx, our_net);
+ if (cco)
+ {
+ cp_mme_peer_t peer;
+ cp_sta_get_peer (cco, &peer);
+ /* Start timer. */
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
+ LEAVING_TIMEOUT_MS);
+ /* Send leave request. */
+ cp_msg_cc_leave_req_send (ctx, &peer,
+ CP_MSG_CC_LEAVE_REQ_REASON_USER_REQUEST);
+ slab_release (cco);
+ /* Branch to the LEAVING state. */
+ cp_fsm_branch (ctx, AUTHENTICATED, to_leave, cco);
+ }
+ else
+ {
+ /* Branch to the UNASSOCIATED state. */
+ cp_fsm_branch (ctx, AUTHENTICATED, to_leave, no_cco);
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__cc_leave_ind (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Check received message. */
+ enum cp_msg_cc_leave_ind_reason_t reason;
+ cp_nid_t nid;
+ if (cp_mme_peer_cmp (&mme->peer, &peer)
+ && cp_msg_cc_leave_ind_receive (ctx, mme, &reason, &nid)
+ && nid == cp_sta_own_data_get_nid (ctx))
+ {
+ cp_msg_cc_leave_rsp_send (ctx, &mme->peer);
+ cp_fsm_branch (ctx, AUTHENTICATED, CC_LEAVE_IND, ok);
+ }
+ else
+ {
+ cp_fsm_branch (ctx, AUTHENTICATED, CC_LEAVE_IND, nok);
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__beacon (cp_t *ctx,
+ bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon);
+ dbg_assert (net);
+ dbg_assert (sta);
+ if (cp_net_get_nid (ctx, net) == cp_sta_own_data_get_nid (ctx)
+ && cp_net_get_snid (ctx, net) == cp_sta_own_data_get_snid (ctx))
+ {
+ /* Only on central beacon, no support for proxy networking. */
+ if (cp_sta_get_cco_status (sta))
+ {
+ ctx->sta_action.assoc.beacon_loss = 0;
+ }
+ }
+}
+
+void
+cp_av_sta_action_assoc__authenticated__beacon_not_received (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ ctx->sta_action.assoc.beacon_loss++;
+ if (ctx->sta_action.assoc.beacon_loss > CP_MAX_NO_BEACON)
+ {
+ cp_fsm_trigger_new_event (ctx, bare, avln_failure);
+ cp_fsm_branch (ctx, AUTHENTICATED, BEACON_NOT_RECEIVED, avln_failure);
+ }
+ else
+ cp_fsm_branch (ctx, AUTHENTICATED, BEACON_NOT_RECEIVED, else);
+}
+
+void
+cp_av_sta_action_assoc__leaving__cc_leave_cnf (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (mme);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Check received message. */
+ if (cp_mme_peer_cmp (&mme->peer, &peer))
+ {
+ /* Ignore bad MME (confirmation is sufficient, we do not expect any
+ * parameter). */
+ cp_msg_cc_leave_cnf_receive (ctx, mme);
+ /* Stop timer. */
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.assoc.timer);
+ cp_fsm_branch (ctx, LEAVING, CC_LEAVE_CNF, ok);
+ }
+ else
+ {
+ cp_fsm_branch (ctx, LEAVING, CC_LEAVE_CNF, unrelated);
+ }
+}
+
+void
+cp_av_sta_action_assoc__leaving__timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Get our CCo. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_mme_peer_t peer;
+ cp_net_get_cco_peer (ctx, our_net, &peer);
+ /* Send leave request again. */
+ cp_msg_cc_leave_req_send (ctx, &peer,
+ CP_MSG_CC_LEAVE_REQ_REASON_USER_REQUEST);
+}
+
+void
+cp_av_sta_action_assoc__leave_wait__enter (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Start timer. */
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
+ LEAVE_WAIT_TIMEOUT_MS);
+}
+
+void
+cp_av_sta_action_assoc__leave_wait__timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+void
+cp_av_sta_action_unassoc__unassoc__enter (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ bsu_beacon_t beacon;
+ /* Update the BSU. */
+ cp_beacon_fill (ctx, &beacon);
+ bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
+}
+
+void
+cp_av_sta_action_assoc__start_retry_timer (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_fsm_event_t *event = cp_fsm_event_bare_new (
+ ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
+ RETRY_TIMEOUT_MS);
+}
+
diff --git a/cesar/cp/av/sta/action/src/drv.c b/cesar/cp/av/sta/action/src/drv.c
new file mode 100644
index 0000000000..739c04568d
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/drv.c
@@ -0,0 +1,182 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/drv.c
+ * \brief STA action, driver related definitions.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+
+#include "cp/inc/context.h"
+#include "cp/msg/msg.h"
+#include "cp/fsm/fsm.h"
+
+#include "cp/av/sta/action/sc.h"
+#include "cp/sta/action/drv.h"
+#include "cp/av/sta/action/drv.h"
+
+void
+cp_av_sta_action_drv__usta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ bool sc_join;
+
+ /* Decode driver MME. */
+ cp_sta_action_drv__drv_sta_sc_common (ctx, mme, true, &sc_join);
+ if (sc_join)
+ {
+ /* Start SC JOIN procedure. */
+ cp_av_sta_action_sc__start_sc_join (ctx);
+ }
+ else
+ {
+ /* Start SC ADD procedure. */
+ cp_av_sta_action_sc__start_sc_add (ctx);
+ }
+}
+
+void
+cp_av_sta_action_drv__ucco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ bool sc_join;
+
+ /* Decode driver MME. */
+ cp_sta_action_drv__drv_sta_sc_common (ctx, mme, true, &sc_join);
+ if (sc_join)
+ {
+ /* Start SC JOIN procedure. */
+ cp_av_sta_action_sc__start_sc_join (ctx);
+ }
+ else
+ {
+ /* Start SC ADD procedure. */
+ cp_av_sta_action_sc__start_sc_add (ctx);
+ }
+}
+
+void
+cp_av_sta_action_drv__cco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ bool sc_join;
+
+ /* Decode driver MME. */
+ cp_sta_action_drv__drv_sta_sc_common (ctx, mme, false, &sc_join);
+ if (!sc_join)
+ {
+ /* Start SC ADD procedure. */
+ cp_av_sta_action_sc__start_sc_add (ctx);
+ cp_fsm_branch (ctx, CCO, DRV_STA_SC_REQ, sc_add);
+ }
+ else
+ {
+ /* SC JOIN disabled. */
+ cp_fsm_branch (ctx, CCO, DRV_STA_SC_REQ, sc_join);
+ }
+}
+
+void
+cp_av_sta_action_drv__sta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ bool sc_join;
+
+ cp_sta_action_drv__drv_sta_sc_common (ctx, mme, false, &sc_join);
+ if (!sc_join)
+ {
+ /* Start SC ADD procedure. */
+ cp_av_sta_action_sc__start_sc_add (ctx);
+ cp_fsm_branch (ctx, STA, DRV_STA_SC_REQ, sc_add);
+ }
+ else
+ {
+ /* SC JOIN disabled. */
+ cp_fsm_branch (ctx, STA, DRV_STA_SC_REQ, sc_join);
+ }
+}
+
+void
+cp_av_sta_action_drv__many__drv_sta_sc__failure (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SC_CNF,
+ CP_MSG_DRV_RESULT_FAILURE);
+}
+
+void
+cp_av_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ u32 tonemask[PHY_TONEMASK_WORDS];
+ bool ok = cp_msg_drv_sta_set_tonemask_req_receive (ctx, mme, tonemask);
+ if (ok)
+ {
+ /* Commit to mac configuration and update tonemask informations. */
+ memcpy (ctx->mac_config->tonemask_info.tonemask, tonemask,
+ sizeof (tonemask));
+ tonemask_update (&ctx->mac_config->tonemask_info);
+ /* Tonemask will be programmed once the PBProc is activated. */
+ }
+ cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_TONEMASK_CNF,
+ ok ? CP_MSG_DRV_RESULT_SUCCESS
+ : CP_MSG_DRV_RESULT_FAILURE);
+}
+
+void
+cp_av_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx,
+ cp_mme_rx_t *mme)
+{
+ cp_key_t nmk;
+ enum cp_msg_drv_sta_set_key_type_t type;
+ cp_nid_t nid;
+ cp_security_level_t sl;
+
+ dbg_assert (ctx);
+ dbg_assert (mme);
+
+ /* Try to decode the DRV MME. */
+ if (cp_msg_drv_sta_set_key_req_receive (ctx, mme, &nmk, &type, &nid, &sl))
+ {
+ /* We need to have a NID; let's build it if we do not have one. */
+ if (type == CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL)
+ {
+ /* Build NID from SL and NMK. */
+ nid = cp_secu_nmk2nid (ctx, nmk, sl);
+ }
+
+ /* Set the NMK. */
+ uint i;
+ cp_key_t current_key = cp_sta_own_data_get_nmk (ctx);
+
+ for (i = 0; i < COUNT(nmk.key) ;i++)
+ if (nmk.key[i] != current_key.key[i])
+ break;
+
+ if ((i < COUNT(nmk.key)) || (nid != cp_sta_own_data_get_nid (ctx)))
+ {
+ /** save parameters as new ones. */
+ ctx->sta_action.poweron.enter.need_set = true;
+ ctx->sta_action.poweron.enter.nmk = nmk;
+ ctx->sta_action.poweron.enter.type = type;
+ ctx->sta_action.poweron.enter.nid = nid;
+
+ /* Leave current avln to restart association. */
+ cp_fsm_trigger_new_event (ctx, bare, to_stop);
+ }
+
+ /* Reply with success. */
+ cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_KEY_CNF,
+ CP_MSG_DRV_RESULT_SUCCESS);
+ }
+ else
+ {
+ /* Error in decoding, let's reply with an error. */
+ cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_KEY_CNF,
+ CP_MSG_DRV_RESULT_FAILURE);
+ }
+}
diff --git a/cesar/cp/sta/action/src/handover.c b/cesar/cp/av/sta/action/src/handover.c
index 3e874e3951..222f5ac983 100644
--- a/cesar/cp/sta/action/src/handover.c
+++ b/cesar/cp/av/sta/action/src/handover.c
@@ -6,27 +6,28 @@
*
* }}} */
/**
- * \file cp/sta/action/src/handover.c
+ * \file cp/av/sta/action/src/handover.c
* \brief Handover functions.
- * \ingroup cp_sta_action
+ * \ingroup cp_av_sta_action
*
*/
#include "common/std.h"
-#include "cp/sta/action/action.h"
#include "cp/sta/mgr/sta_mgr.h"
#include "cp/sta/core/core.h"
#include "cp/msg/msg.h"
-#include "cp/cco/action/cco_action.h"
#include "cp/fsm/fsm.h"
#include "cp/defs.h"
#include "cp/inc/context.h"
+#include "cp/cco/action/cco_action.h"
#include "cp/sta/action/inc/context.h"
-
-#include "cp/inc/context.h"
+#include "cp/av/sta/action/handover.h"
+#include "cp/av/sta/action/assoc.h"
+#include "cp/av/beacon/beacon.h"
+#include "cp/av/cco/action/cco_action.h"
void
-cp_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme)
{
cp_net_t *net;
cp_sta_t *sta;
@@ -44,7 +45,7 @@ cp_sta_action_handover__handover (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme)
{
cp_msg_cc_handover_req_soft_hard_t soft_hard = 0;
cp_msg_cc_handover_req_reason_t reason = 0;
@@ -112,7 +113,7 @@ cp_sta_action_handover__start (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
+cp_av_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
cp_mme_rx_t *mme)
{
cp_msg_cc_handover_info_ind_rsc_t rsc;
@@ -152,7 +153,7 @@ cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
sta->pco = ptei;
sta->tei_lease_date_ms = cp_sta_core_get_date_ms (ctx) +
MAC_SEC_TO_MS (CP_LEASE_ASSOC_MIN * 60);
- cp_cco_action_tei_in_use (ctx, tei);
+ cp_av_cco_action_tei_in_use (ctx, tei);
slab_release (sta);
}
@@ -162,7 +163,7 @@ cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
if (res)
{
- cp_cco_action_tei_in_use (ctx, cp_sta_own_data_get_tei (ctx));
+ cp_av_cco_action_tei_in_use (ctx, cp_sta_own_data_get_tei (ctx));
/* Send the confirmation. */
cp_msg_cc_handover_info_rsp_send (ctx, &mme->peer);
}
@@ -170,7 +171,7 @@ cp_sta_action_handover__handover_info_ind_receive (cp_t *ctx,
}
void
-cp_sta_action_handover__handover_ended (cp_t *ctx)
+cp_av_sta_action_handover__handover_ended (cp_t *ctx)
{
cp_net_t *net;
cp_sta_t *old_cco;
@@ -179,14 +180,14 @@ cp_sta_action_handover__handover_ended (cp_t *ctx)
old_cco = cp_net_get_cco (ctx, net);
cp_net_set_cco (ctx, net, MAC_TEI_UNASSOCIATED);
/* Reset the handover flag in the central beacon. */
- cp_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
- cp_cco_action_cco__assoc_start (ctx);
+ cp_av_beacon_handover_hoipflag (ctx, CP_BEACON_HOIP_FALSE);
+ cp_av_cco_action_cco__assoc_start (ctx);
/* Stop the lease timer. */
cp_sta_core_stop_timed_or_cyclic_event (ctx,
&ctx->sta_action.assoc.lease_timer);
if (ctx->handover.reason == CP_HANDOVER_REASON_CCO_LEAVING)
{
- cp_cco_action_cco_sta_leave_send_tei_map (ctx, old_cco);
+ cp_av_cco_action_cco_sta_leave_send_tei_map (ctx, old_cco);
cp_sta_mgr_release_station (ctx, cp_sta_get_tei (old_cco));
}
cp_fsm_trigger_new_event (ctx, bare, HANDOVER_SUCCESS);
@@ -194,7 +195,7 @@ cp_sta_action_handover__handover_ended (cp_t *ctx)
}
void
-cp_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
+cp_av_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
{
dbg_assert (ctx);
dbg_assert (net);
@@ -202,12 +203,12 @@ cp_sta_action_handover__sta_handover (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
if (sta)
{
cp_beacon_update_tracking (ctx, sta);
- cp_sta_action_assoc__authenticated__renew (ctx);
+ cp_av_sta_action_assoc__authenticated__renew (ctx);
}
}
void
-cp_sta_action_handover__failure (cp_t *ctx)
+cp_av_sta_action_handover__failure (cp_t *ctx)
{
dbg_assert (ctx);
diff --git a/cesar/cp/sta/action/src/info.c b/cesar/cp/av/sta/action/src/info.c
index 8d167c7564..d0b9c2d56b 100644
--- a/cesar/cp/sta/action/src/info.c
+++ b/cesar/cp/av/sta/action/src/info.c
@@ -6,13 +6,14 @@
*
* }}} */
/**
- * \file cp/sta/action/src/info.c
+ * \file cp/av/sta/action/src/info.c
* \brief STA action, information gathering definitions.
- * \ingroup cp_sta_action
+ * \ingroup cp_av_sta_action
*/
#include "common/std.h"
#include "action.h"
+#include "cp/sta/action/action.h"
#include "cp/msg/msg.h"
#include "cp/sta/mgr/sta_mgr.h"
@@ -20,7 +21,7 @@
#include "lib/slab.h"
void
-cp_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme)
{
enum cp_msg_cc_set_tei_map_ind_mode_t mode;
uint i, sta_nb;
@@ -94,7 +95,7 @@ cp_sta_action_process_cc_set_tei_map_ind (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_process_cm_unassociated_sta_ind (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cm_unassociated_sta_ind (cp_t *ctx, cp_mme_rx_t *mme)
{
cp_nid_t nid;
u8 cco_cap;
diff --git a/cesar/cp/sta/action/src/key.c b/cesar/cp/av/sta/action/src/key.c
index b54323e198..716fc722b9 100644
--- a/cesar/cp/sta/action/src/key.c
+++ b/cesar/cp/av/sta/action/src/key.c
@@ -6,19 +6,20 @@
*
* }}} */
/**
- * \file cp/sta/action/src/key.c
+ * \file cp/av/sta/action/src/key.c
* \brief STA action, key exchange messages.
- * \ingroup cp_sta_action
+ * \ingroup cp_av_sta_action
*/
#include "common/std.h"
#include "action.h"
+#include "cp/sta/action/action.h"
#include "cp/fsm/fsm.h"
#include "cp/msg/inc/msg_cm.h"
void
-cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
{
dbg_assert (ctx);
dbg_assert (mme);
@@ -42,7 +43,7 @@ cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
{
dbg_assert (ctx);
dbg_assert (mme);
@@ -66,7 +67,7 @@ cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_rx_t *mme)
{
dbg_assert (ctx);
dbg_assert (mme);
@@ -93,7 +94,7 @@ cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_process_cm_get_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_process_cm_get_key_cnf (cp_t *ctx, cp_mme_rx_t *mme)
{
dbg_assert (ctx);
dbg_assert (mme);
diff --git a/cesar/cp/av/sta/action/src/misc.c b/cesar/cp/av/sta/action/src/misc.c
new file mode 100644
index 0000000000..be065dd428
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/misc.c
@@ -0,0 +1,172 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/misc.c
+ * \brief STA action, miscellaneous definitions.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+#include "mac/common/store.h"
+
+#include "cp/inc/context.h"
+#include "cp/inc/trace.h"
+#include "cp/msg/msg.h"
+
+#include "hal/arch/arch.h" // for dsr lock and unlock
+
+#include "common/defs/spidcom.h"
+#include "mac/common/timings.h"
+#include "cp/fsm/fsm.h"
+#include "cp/cco/action/cco_action.h"
+#include "cp/av/sta/action/misc.h"
+#include "cp/av/cco/action/cco_action.h"
+
+void
+cp_av_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
+{
+ dbg_assert (ctx);
+ dbg_assert (rx_mme);
+
+ if (cp_msg_cc_discover_list_req_receive (ctx, rx_mme))
+ {
+ cp_mme_tx_t *tx_mme;
+ cp_msg_cc_discover_list_ctx_t disc_ctx;
+ cp_net_t *our_net = NULL;
+
+ /* Check if our station is associated in a network. */
+ if (cp_sta_own_data_get_tei (ctx) != MAC_TEI_UNASSOCIATED)
+ {
+ our_net = cp_sta_mgr_get_our_avln(ctx);
+ }
+
+ /* Prepare CC_DISCOVER_LIST.CNF */
+ tx_mme = cp_msg_cc_discover_list_cnf_send_begin (ctx, &rx_mme->peer,
+ cp_sta_mgr_get_num_discovered_stas (ctx),
+ cp_sta_mgr_get_num_discovered_net (ctx),
+ &disc_ctx);
+
+ /* Send NumStation */
+ cp_msg_cc_discover_list_cnf_send_stations_begin (ctx, tx_mme,
+ &disc_ctx);
+
+ /* Get stations informations for each existing network. */
+ cp_net_t *net;
+ for (net = cp_sta_mgr_get_first_avln (ctx); net;
+ net = cp_sta_mgr_get_next_avln (ctx, net))
+ {
+ /* Collect info valid for all stations of this net. */
+ cp_msg_cc_discover_list_sta_t list;
+
+ list.snid = cp_net_get_snid (ctx, net);
+ list.access = cp_net_get_access (ctx, net);
+
+ /* For all kind of association states we seek stations. */
+ cp_net_sta_status_t assoc;
+
+ for (assoc = 0; assoc < CP_NET_STA_NB; assoc++)
+ {
+ /* Check association. */
+ if ((assoc == CP_NET_STA_ASSOC) && (net == our_net))
+ list.same_network = CC_DISCOVER_LIST_NET_SAME_NETWORK;
+ else
+ list.same_network = CC_DISCOVER_LIST_NET_DIFFERENT_NETWORK;
+
+ cp_sta_t *cp_sta;
+
+ for (cp_sta = cp_net_sta_get_first (ctx, net, assoc);
+ cp_sta;
+ cp_sta = cp_net_sta_get_next (ctx, net, cp_sta))
+ {
+ list.mac_addr = cp_sta_get_mac_address (cp_sta);
+ list.tei = cp_sta_get_tei (cp_sta);
+ list.cco_cap = cp_sta->cco_cap;
+ list.proxy_cap = cp_sta->pco_cap;
+ list.backup_cco_cap = cp_sta->backup_cco_cap;
+ list.cco_status = cp_sta_get_cco_status (cp_sta);
+ list.pco_status = cp_sta_get_pco_status (cp_sta);
+ list.backup_cco_status = cp_sta->is_backup_cco;
+ list.signal_level = 0x00;
+
+ /** Compute average ble of the sta. */
+ if (list.same_network == CC_DISCOVER_LIST_NET_SAME_NETWORK)
+ list.average_ble =
+ cp_sta_action_get_average_ble (ctx, list.tei, true,
+ true);
+ else
+ list.average_ble = 0;
+
+ cp_msg_cc_discover_list_cnf_send_station (ctx, tx_mme,
+ &list);
+ }
+ }
+ }
+
+ /* Send NumNetwork */
+ cp_msg_cc_discover_list_cnf_send_net_begin (ctx, tx_mme, &disc_ctx);
+
+ /* For each present network but our network if we have one. */
+ for (net = cp_sta_mgr_get_first_avln (ctx); net;
+ net = cp_sta_mgr_get_next_avln (ctx, net))
+ {
+ if (our_net != net)
+ {
+ /* Collect info for all valid net */
+ cp_msg_cc_discover_list_net_t data;
+
+ data.nid = cp_net_get_nid (ctx, net);
+ data.snid = cp_net_get_snid (ctx, net);
+ data.access = cp_net_get_access (ctx, net);
+ data.hm = net->hm;
+ data.numslots = net->avln_num_slots;
+
+ if (net->network_mode == MAC_NM_COORDINATED)
+ /* Unsupported. */
+ data.coordinated_status =
+ CC_DISCOVER_LIST_COORD_COORDINATED_GROUP_UNKNOWN;
+ else
+ data.coordinated_status =
+ CC_DISCOVER_LIST_COORD_NON_COORDINATED;
+ data.offset = 0;
+
+ cp_msg_cc_discover_list_cnf_send_net (ctx, tx_mme, &data);
+ }
+ }
+
+ cp_msg_cc_discover_list_cnf_send_end (ctx, tx_mme);
+ }
+}
+
+void
+cp_av_sta_action_poweron__cco__join_timeout_sc_failed (
+ cp_t *ctx,
+ cp_fsm_branch_t branch_no_sta_no_avln,
+ cp_fsm_branch_t branch_no_sta_avln,
+ cp_fsm_branch_t branch_sta)
+{
+ dbg_assert (ctx);
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ if (cp_net_is_empty (ctx, our_net))
+ {
+ if (cp_sta_mgr_net_list_is_empty (ctx))
+ {
+ cp_av_cco_action_cco__to_ucco (ctx);
+ cp_fsm_branch_ (ctx, branch_no_sta_no_avln);
+ }
+ else
+ {
+ /* Leave CCo role. */
+ cp_av_cco_action_cco__unassoc_stop (ctx);
+ cp_fsm_branch_ (ctx, branch_no_sta_avln);
+ }
+ }
+ else
+ {
+ /* Ok, stay CCo. */
+ cp_fsm_branch_ (ctx, branch_sta);
+ }
+}
diff --git a/cesar/cp/av/sta/action/src/poweron.c b/cesar/cp/av/sta/action/src/poweron.c
new file mode 100644
index 0000000000..91a270cc6d
--- /dev/null
+++ b/cesar/cp/av/sta/action/src/poweron.c
@@ -0,0 +1,390 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/action/src/poweron.c
+ * \brief STA action, power on procedure related definitions.
+ * \ingroup cp_av_sta_action
+ */
+#include "common/std.h"
+
+#include "action.h"
+
+#include "cp/defs.h"
+#include "cp/msg/msg.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/fsm/fsm.h"
+#include "cp/beacon/beacon.h"
+#include "cp/cco/action/cco_action.h"
+#include "bsu/bsu.h"
+#include "lib/slab.h"
+#include "cp/inc/context.h"
+
+#include "cp/av/beacon/discover.h"
+#include "cp/av/sta/action/inc/action.h"
+#include "cp/av/cco/action/cco_action.h"
+
+#define ALL_STA_LEAVED_TIMEOUT_MS 1000
+
+void
+cp_av_sta_action_poweron_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ ctx->sta_action.poweron.enter.need_set = false;
+}
+
+void
+cp_av_sta_action_poweron__many__to_idle (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ /* Cleanup. */
+ pbproc_activate (ctx->pbproc, false);
+ sar_activate (ctx->sar, false);
+ sar_cleanup (ctx->sar);
+ bsu_activate (ctx->bsu, false);
+ cp_beacon_deactivate (ctx);
+ /* Signal station is stopped. */
+ cp_fsm_trigger_new_event (ctx, bare, stopped);
+}
+
+void
+cp_av_sta_action_poweron__idle__to_poweron (cp_t *ctx)
+{
+ cp_beacon_poweron_init (ctx);
+ bsu_power_on (ctx->bsu, cp_sta_own_data_get_snid (ctx));
+ /* Update beacon data program a timer is a wrong values beacon ACLF is
+ * still not initialised.*/
+ bsu_activate (ctx->bsu, true);
+ cp_beacon_reconfigure_timer (ctx, false);
+ sar_activate (ctx->sar, true);
+ pbproc_activate (ctx->pbproc, true);
+}
+
+void
+cp_av_sta_action_poweron__idle__enter (cp_t *ctx)
+{
+ if (ctx->sta_action.poweron.enter.need_set)
+ {
+ /* TODO: Changing the KEY should be handled by a new State in the
+ * Started FSM see #2800 */
+ cp_fsm_post_new_event (ctx, bare, to_poweron);
+ }
+}
+
+/**
+ * Start USTT timer.
+ * \param ctx control plane context
+ * \param ustt_ms USTT timer approximated value
+ */
+static void
+cp_av_sta_action_poweron_ustt_start (cp_t *ctx, uint ustt_ms)
+{
+ cp_fsm_event_t *event;
+ uint ustt_timeout_ms = ustt_ms / 2
+ + lib_rnd_uniform (&ctx->rnd, ustt_ms);
+ event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_ustt_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.ustt_timer,
+ event, ustt_timeout_ms);
+}
+
+/**
+ * Common handling of POWERON and USTA => USTT TIMEOUT.
+ * \param ctx control plane context
+ * \param ustt_ms USTT timer approximated value
+ */
+static void
+cp_av_sta_action_poweron_ustt_timeout (cp_t *ctx, uint ustt_ms)
+{
+ /* Send an CM_UNASSOCIATED_STA.IND. */
+ cp_msg_cm_unassociated_sta_ind_send (
+ ctx, &CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED),
+ cp_sta_own_data_get_nid (ctx), CP_CCO_LEVEL);
+ cp_av_sta_action_poweron_ustt_start (ctx, ustt_ms);
+}
+
+void
+cp_av_sta_action_poweron__poweron__enter (cp_t *ctx)
+{
+ cp_fsm_event_t *event;
+ /* BTT timer. */
+ uint btt_timeout_min_ms, btt_timeout_max_ms, btt_timeout_ms;
+ if (cp_sta_own_data_get_was_cco (ctx))
+ {
+ btt_timeout_min_ms = CP_CCO_BEACON_SCAN_MIN_MS;
+ btt_timeout_max_ms = CP_CCO_BEACON_SCAN_MAX_MS;
+ }
+ else
+ {
+ btt_timeout_min_ms = CP_BEACON_SCAN_MIN_MS;
+ btt_timeout_max_ms = CP_BEACON_SCAN_MAX_MS;
+ }
+ btt_timeout_ms = lib_rnd_uniform (
+ &ctx->rnd, btt_timeout_max_ms - btt_timeout_min_ms + 1)
+ + btt_timeout_min_ms;
+ event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_btt_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.btt_timer,
+ event, btt_timeout_ms);
+ /* USTT timer. */
+ cp_av_sta_action_poweron_ustt_start (ctx, CP_USTA_IND_INTERVAL_MS);
+
+ if (ctx->sta_action.poweron.enter.need_set)
+ {
+ cp_sta_own_data_set_nid (ctx, ctx->sta_action.poweron.enter.nid);
+ cp_sta_own_data_set_nmk (ctx, ctx->sta_action.poweron.enter.nmk,
+ ctx->sta_action.poweron.enter.type);
+
+ ctx->sta_action.poweron.enter.need_set = false;
+ }
+
+ bsu_beacon_t beacon;
+ cp_beacon_fill (ctx, &beacon);
+ /* Act as STA, for BSU corresponds to only hear the central beacon from
+ * the CCo. */
+ bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
+}
+
+void
+cp_av_sta_action_poweron__poweron__leave (cp_t *ctx)
+{
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.poweron.btt_timer);
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.poweron.ustt_timer);
+}
+
+void
+cp_av_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_sta_action_poweron_ustt_timeout (ctx, CP_USTA_IND_INTERVAL_MS);
+}
+
+/**
+ * Search for the first USTA with the mac address lesser than our own mac
+ * address.
+ * \param ctx the module context.
+ * \param net the AVLN to search in.
+ * \return true if a station with a bigger mac address than our own mac
+ * address.
+ */
+static bool
+cp_sta_action_btt_timeout_usta_with_mac_bigger (cp_t *ctx, cp_net_t *net)
+{
+ cp_sta_t *sta;
+ bool sta_found = false;
+ mac_t rmac = MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx));
+ for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_UNASSOC);
+ sta && !sta_found;
+ sta = cp_net_sta_get_next (ctx, net, sta))
+ {
+ if (sta->cco_cap > CP_CCO_LEVEL
+ || (sta->cco_cap == CP_CCO_LEVEL
+ && MAC_REVERSE (cp_sta_get_mac_address (sta)) > rmac))
+ sta_found = true;
+ }
+ return sta_found;
+}
+
+void
+cp_av_sta_action_poweron__poweron__btt_timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ bool iam_cco_on_my_nid = false, iam_cco_on_other_nid = true;
+ cp_nid_t nid = cp_sta_own_data_get_nid (ctx);
+ cp_net_t *net;
+ for (net = cp_sta_mgr_get_first_avln (ctx);
+ net;
+ net = cp_sta_mgr_get_next_avln (ctx, net))
+ {
+ /* Search for AVLN with our NID. */
+ if (cp_net_get_nid (ctx, net) == nid)
+ {
+ iam_cco_on_my_nid = iam_cco_on_other_nid =
+ !cp_sta_action_btt_timeout_usta_with_mac_bigger (
+ ctx, net)
+ && !net->num_associated_stas;
+ }
+ /* Search for AVLN with another NID. */
+ else if (iam_cco_on_other_nid)
+ {
+ iam_cco_on_other_nid = !net->num_associated_stas;
+ }
+ }
+ if (iam_cco_on_my_nid)
+ {
+ cp_av_cco_action_cco__unassoc_start (ctx);
+ cp_fsm_branch (ctx, POWERON, btt_timeout, nid_match_cco);
+ }
+ else if (iam_cco_on_other_nid)
+ {
+ cp_av_cco_action_ucco_start (ctx);
+ cp_fsm_branch (ctx, POWERON, btt_timeout, no_avln);
+ }
+ else
+ cp_fsm_branch (ctx, POWERON, btt_timeout, avln);
+}
+
+void
+cp_av_sta_action_poweron__poweron__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon);
+ dbg_assert (net);
+ dbg_assert (sta);
+ cp_av_sta_action_beacon_match_and_join (
+ ctx, beacon, net, sta, false /* not in SC */,
+ CP_FSM_BRANCH (POWERON, BEACON, nid_match),
+ CP_FSM_BRANCH (POWERON, BEACON, no_nid_match));
+}
+
+void
+cp_av_sta_action_poweron__poweron_joining__left (cp_t *ctx)
+{
+}
+
+void
+cp_av_sta_action_poweron__joining__to_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_sta_action_assoc_leave (ctx);
+}
+
+static inline void
+cp_av_sta_action_poweron__usta_usta_joining__enter (cp_t *ctx)
+{
+ bsu_beacon_t beacon;
+ if (MAC_TEI_IS_STA (cp_sta_own_data_get_tei (ctx)))
+ cp_av_cco_action_cco__unassoc_stop (ctx);
+ cp_beacon_fill (ctx, &beacon);
+ bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
+}
+
+void
+cp_av_sta_action_poweron__usta__enter (cp_t *ctx)
+{
+ cp_av_sta_action_poweron__usta_usta_joining__enter (ctx);
+ cp_av_sta_action_poweron_ustt_start (ctx, CP_DISCOVER_PERIOD_MAX_MS);
+}
+
+void
+cp_av_sta_action_poweron__usta_joining__enter (cp_t *ctx)
+{
+ cp_av_sta_action_poweron__usta_usta_joining__enter (ctx);
+}
+
+void
+cp_av_sta_action_poweron__usta__leave (cp_t *ctx)
+{
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.poweron.ustt_timer);
+}
+
+void
+cp_av_sta_action_poweron__usta__ustt_timeout (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_sta_action_poweron_ustt_timeout (ctx, CP_DISCOVER_PERIOD_MAX_MS);
+}
+
+void
+cp_av_sta_action_poweron__usta__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon);
+ dbg_assert (net);
+ dbg_assert (sta);
+ cp_av_sta_action_beacon_match_and_join (
+ ctx, beacon, net, sta, false /* not in SC */,
+ CP_FSM_BRANCH (USTA, BEACON, nid_match),
+ CP_FSM_BRANCH (USTA, BEACON, no_nid_match));
+}
+
+void
+cp_av_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
+ cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (net);
+ dbg_assert (sta);
+ if (cp_net_get_nid (ctx, net) != cp_sta_own_data_get_nid (ctx))
+ {
+ cp_fsm_branch (ctx, USTA, usta_ind, else);
+ }
+ else
+ {
+ if (sta->cco_cap > CP_CCO_LEVEL
+ || (sta->cco_cap == CP_CCO_LEVEL
+ && (MAC_REVERSE (cp_sta_get_mac_address (sta))
+ > MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx)))))
+ cp_fsm_branch (ctx, USTA, usta_ind, else);
+ else
+ {
+ cp_av_cco_action_cco__unassoc_start (ctx);
+ cp_fsm_branch (ctx, USTA, usta_ind, nid_match_cco);
+ }
+ }
+}
+
+void
+cp_av_sta_action_poweron__usta_joining__left (cp_t *ctx)
+{
+}
+
+void
+cp_av_sta_action_poweron__ucco__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+ cp_net_t *net, cp_sta_t *sta)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon);
+ dbg_assert (net);
+ dbg_assert (sta);
+ /* Stop UCCo behavior. */
+ cp_av_cco_action_ucco_stop (ctx);
+ /* Handle incoming beacon. */
+ cp_av_sta_action_beacon_match_and_join (
+ ctx, beacon, net, sta, false /* not in SC */,
+ CP_FSM_BRANCH (UCCO, BEACON, nid_match),
+ CP_FSM_BRANCH (UCCO, BEACON, no_nid_match));
+}
+
+void
+cp_av_sta_action_poweron__sta__to_stop (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_av_sta_action_assoc_leave (ctx);
+}
+
+void
+cp_av_sta_action_poweron_cco__enter (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_fsm_event_t *event;
+ event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_join_timeout);
+ cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.join_timer,
+ event, CP_DISCOVER_PERIOD_MAX_MS);
+}
+
+void
+cp_av_sta_action_poweron_cco__leave (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_sta_core_stop_timed_or_cyclic_event (
+ ctx, &ctx->sta_action.poweron.join_timer);
+}
+
+void
+cp_av_sta_action_poweron__cco__join_timeout (cp_t *ctx)
+{
+ cp_av_sta_action_poweron__cco__join_timeout_sc_failed (
+ ctx,
+ CP_FSM_BRANCH (CCO, join_timeout, no_sta_no_avln),
+ CP_FSM_BRANCH (CCO, join_timeout, no_sta_avln),
+ CP_FSM_BRANCH (CCO, join_timeout, sta)
+ );
+}
diff --git a/cesar/cp/sta/action/src/sc.c b/cesar/cp/av/sta/action/src/sc.c
index 8597a3b426..9439f6224f 100644
--- a/cesar/cp/sta/action/src/sc.c
+++ b/cesar/cp/av/sta/action/src/sc.c
@@ -6,15 +6,19 @@
*
* }}} */
/**
- * \file cp/sta/action/src/sc.c
+ * \file cp/av/sta/action/src/sc.c
* \brief STA action, Simple Connect procedure functions definitions.
- * \ingroup cp_sta_action
+ * \ingroup cp_av_sta_action
*/
#include "common/std.h"
#include "cp/inc/context.h"
#include "cp/sta/action/inc/context.h"
-#include "cp/sta/action/assoc.h"
+
+#include "action.h"
+#include "cp/sta/action/action.h"
+
#include "cp/sta/core/core.h"
+#include "cp/av/sta/mgr/sta_mgr.h"
#include "cp/msg/inc/msg_cm.h"
#include "cp/msg/inc/msg_drv.h"
#include "cp/fsm/inc/events.h"
@@ -22,9 +26,8 @@
#include "cp/cco/action/cco_action.h"
#include "cp/secu/defs.h"
-#include "cp/sta/action/sc.h"
-#include "cp/sta/action/inc/action.h"
-#include "cp/sta/action/misc.h"
+#include "cp/av/sta/action/inc/action.h"
+#include "cp/av/beacon/beacon.h"
/**
* SC timeout.
@@ -46,14 +49,14 @@
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__start_timer (cp_t *ctx);
+cp_av_sta_action_sc__start_timer (cp_t *ctx);
/**
* Stop SC timer.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__stop_timer (cp_t *ctx);
+cp_av_sta_action_sc__stop_timer (cp_t *ctx);
/**
* Start the SC procedure as the "add" STA.
@@ -64,24 +67,24 @@ cp_sta_action_sc__stop_timer (cp_t *ctx);
* needed.
*/
void
-cp_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer);
+cp_av_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer);
/**
* Send a CM_SC_JOIN.REQ to all STA in broadcast.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__send_cm_sc_join_req (cp_t *ctx);
+cp_av_sta_action_sc__send_cm_sc_join_req (cp_t *ctx);
/**
* Start the SC JOIN.REQ timer.
* \param ctx control plane context.
*/
void
-cp_sta_action_sc__start_sc_join_req_timer (cp_t *ctx);
+cp_av_sta_action_sc__start_sc_join_req_timer (cp_t *ctx);
void
-cp_sta_action_sc__start_timer (cp_t *ctx)
+cp_av_sta_action_sc__start_timer (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -94,7 +97,7 @@ cp_sta_action_sc__start_timer (cp_t *ctx)
}
void
-cp_sta_action_sc__stop_timer (cp_t *ctx)
+cp_av_sta_action_sc__stop_timer (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -104,7 +107,7 @@ cp_sta_action_sc__stop_timer (cp_t *ctx)
}
void
-cp_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer)
+cp_av_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer)
{
/* Check parameters. */
dbg_assert (ctx);
@@ -139,7 +142,7 @@ cp_sta_action_sc__start_sc_in_add (cp_t *ctx, cp_mme_peer_t *peer)
}
void
-cp_sta_action_sc__send_cm_sc_join_req (cp_t *ctx)
+cp_av_sta_action_sc__send_cm_sc_join_req (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -150,7 +153,7 @@ cp_sta_action_sc__send_cm_sc_join_req (cp_t *ctx)
}
void
-cp_sta_action_sc__start_sc_join_req_timer (cp_t *ctx)
+cp_av_sta_action_sc__start_sc_join_req_timer (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -170,7 +173,7 @@ cp_sta_action_sc__start_sc_join_req_timer (cp_t *ctx)
}
void
-cp_sta_action_sc__start_sc_join (cp_t *ctx)
+cp_av_sta_action_sc__start_sc_join (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -182,7 +185,7 @@ cp_sta_action_sc__start_sc_join (cp_t *ctx)
}
void
-cp_sta_action_sc__start_sc_add (cp_t *ctx)
+cp_av_sta_action_sc__start_sc_add (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -194,34 +197,34 @@ cp_sta_action_sc__start_sc_add (cp_t *ctx)
}
void
-cp_sta_action_sc__sc_idle__enter (cp_t *ctx)
+cp_av_sta_action_sc__sc_idle__enter (cp_t *ctx)
{
/* Stop SC timer. */
- cp_sta_action_sc__stop_timer (ctx);
+ cp_av_sta_action_sc__stop_timer (ctx);
cp_sta_own_data_set_sc (ctx, false);
}
void
-cp_sta_action_sc__sc_idle__leave (cp_t *ctx)
+cp_av_sta_action_sc__sc_idle__leave (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
/* Start SC timer. */
- cp_sta_action_sc__start_timer (ctx);
+ cp_av_sta_action_sc__start_timer (ctx);
cp_sta_own_data_set_sc (ctx, true);
}
void
-cp_sta_action_sc__sc_join__enter (cp_t *ctx)
+cp_av_sta_action_sc__sc_join__enter (cp_t *ctx)
{
/* Send a SC_JOIN.REQ. */
- cp_sta_action_sc__start_sc_join_req_timer (ctx);
+ cp_av_sta_action_sc__start_sc_join_req_timer (ctx);
/* Start the timer. */
- cp_sta_action_sc__send_cm_sc_join_req (ctx);
+ cp_av_sta_action_sc__send_cm_sc_join_req (ctx);
}
void
-cp_sta_action_sc__sc_join__leave (cp_t *ctx)
+cp_av_sta_action_sc__sc_join__leave (cp_t *ctx)
{
/* Check parameter. */
dbg_assert (ctx);
@@ -231,21 +234,21 @@ cp_sta_action_sc__sc_join__leave (cp_t *ctx)
}
void
-cp_sta_action_sc__sc_timeout (cp_t *ctx)
+cp_av_sta_action_sc__sc_timeout (cp_t *ctx)
{
/* Generate the event for the CP FSM. */
cp_fsm_post_new_event (ctx, bare, sc_failed);
}
void
-cp_sta_action_sc_add__sc_timeout (cp_t *ctx)
+cp_av_sta_action_sc_add__sc_timeout (cp_t *ctx)
{
/* Generate the event for the CP FSM. */
cp_fsm_post_new_event (ctx, bare, sc_failed);
}
void
-cp_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
{
/* Check parameters. */
dbg_assert (ctx);
@@ -264,14 +267,14 @@ cp_sta_action_sc__sc_add__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
else
{
/* Let's try SC procedure with peer. */
- cp_sta_action_sc__start_sc_in_add (ctx, &mme->peer);
+ cp_av_sta_action_sc__start_sc_in_add (ctx, &mme->peer);
/* Move FSM. */
cp_fsm_branch (ctx, SC_ADD, CM_SC_JOIN_REQ, ok);
}
}
void
-cp_sta_action_sc__to_stop (cp_t *ctx)
+cp_av_sta_action_sc__to_stop (cp_t *ctx)
{
/* Generate the event for the CP FSM. */
cp_fsm_event_t *event = cp_fsm_event_bare_new
@@ -280,7 +283,7 @@ cp_sta_action_sc__to_stop (cp_t *ctx)
}
void
-cp_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
+cp_av_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
cp_net_t *net,
cp_sta_t *sta)
{
@@ -324,7 +327,7 @@ cp_sta_action_sc__sc_wait_peer_associated__new_sta_associated (cp_t *ctx,
}
void
-cp_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
{
/* Check parameters. */
dbg_assert (ctx);
@@ -350,7 +353,7 @@ cp_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
{
/* My CCo capabilities are greater than the peer. */
/* Act if we were in SC_ADD procedure. */
- cp_sta_action_sc__start_sc_in_add (ctx, &mme->peer);
+ cp_av_sta_action_sc__start_sc_in_add (ctx, &mme->peer);
/* Update FSM. */
cp_fsm_branch (ctx, SC_JOIN, CM_SC_JOIN_REQ,
ok_my_cco_cap_greater);
@@ -365,7 +368,7 @@ cp_sta_action_sc__sc_join__cm_sc_join_req (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_sc__sc_join__cm_sc_join_cnf (cp_t *ctx, cp_mme_rx_t *mme)
+cp_av_sta_action_sc__sc_join__cm_sc_join_cnf (cp_t *ctx, cp_mme_rx_t *mme)
{
/* Check parameters. */
dbg_assert (ctx);
@@ -390,16 +393,16 @@ cp_sta_action_sc__sc_join__cm_sc_join_cnf (cp_t *ctx, cp_mme_rx_t *mme)
}
void
-cp_sta_action_sc__sc_join__sc_join_req_timeout (cp_t *ctx)
+cp_av_sta_action_sc__sc_join__sc_join_req_timeout (cp_t *ctx)
{
/* Send the SC_JOIN.REQ MME. */
- cp_sta_action_sc__start_sc_join_req_timer (ctx);
+ cp_av_sta_action_sc__start_sc_join_req_timer (ctx);
/* Restart timer. */
- cp_sta_action_sc__send_cm_sc_join_req (ctx);
+ cp_av_sta_action_sc__send_cm_sc_join_req (ctx);
}
void
-cp_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta)
{
/* Check parameters. */
@@ -407,14 +410,14 @@ cp_sta_action_sc__sc_wait_beacon__beacon (cp_t *ctx, bsu_beacon_t *beacon,
dbg_assert (beacon);
dbg_assert (net);
dbg_assert (sta);
- cp_sta_action_beacon_match_and_join (
+ cp_av_sta_action_beacon_match_and_join (
ctx, beacon, net, sta, true /* Simple Connect */,
CP_FSM_BRANCH (SC_WAIT_BEACON, BEACON, nid_match),
CP_FSM_BRANCH (SC_WAIT_BEACON, BEACON, nid_differs));
}
void
-cp_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
+cp_av_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
cp_mme_rx_t *mme)
{
/* Check parameters. */
@@ -473,7 +476,7 @@ cp_sta_action_sc__sc_building_tek__cm_get_key_cnf_pid3 (cp_t *ctx,
}
void
-cp_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
+cp_av_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
cp_mme_rx_t *mme)
{
/* Check parameters. */
@@ -515,7 +518,7 @@ cp_sta_action_sc__sc_nmk_exchange__cm_set_key_cnf_pid3 (cp_t *ctx,
}
void
-cp_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta)
{
/* Check parameters. */
@@ -537,14 +540,14 @@ cp_sta_action_sc__sc_usta_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
)
{
own_data->nid_track = its_nid;
- cp_sta_mgr_set_tracking (ctx, its_snid, its_nid);
+ cp_av_sta_mgr_set_tracking (ctx, its_snid, its_nid);
cp_beacon_process_tracked_avln (ctx, beacon, net);
}
}
}
void
-cp_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
+cp_av_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net, cp_sta_t *sta)
{
dbg_assert (ctx);
@@ -554,11 +557,11 @@ cp_sta_action_sc__sc_ucco_track_beacon (cp_t *ctx, bsu_beacon_t *beacon,
/* Change to STA behaviour. */
cp_beacon_reconfigure_timer (ctx, false);
/* Handle incoming beacon. */
- cp_sta_action_sc__sc_usta_track_beacon (ctx, beacon, net, sta);
+ cp_av_sta_action_sc__sc_usta_track_beacon (ctx, beacon, net, sta);
}
void
-cp_sta_action_sc__sc_sta__avln_failure (cp_t *ctx)
+cp_av_sta_action_sc__sc_sta__avln_failure (cp_t *ctx)
{
cp_fsm_event_t *event = cp_fsm_event_bare_new
(ctx, CP_FSM_EVENT_TYPE_to_stop);
@@ -566,9 +569,9 @@ cp_sta_action_sc__sc_sta__avln_failure (cp_t *ctx)
}
void
-cp_sta_action_sc__sc_cco__sc_failed (cp_t *ctx)
+cp_av_sta_action_sc__sc_cco__sc_failed (cp_t *ctx)
{
- cp_sta_action_poweron__cco__join_timeout_sc_failed (
+ cp_av_sta_action_poweron__cco__join_timeout_sc_failed (
ctx,
CP_FSM_BRANCH (SC_CCO, sc_failed, no_sta_no_avln),
CP_FSM_BRANCH (SC_CCO, sc_failed, no_sta_avln),
diff --git a/cesar/cp/av/sta/action/test/utest/Config b/cesar/cp/av/sta/action/test/utest/Config
new file mode 100644
index 0000000000..3ebfb2f0b9
--- /dev/null
+++ b/cesar/cp/av/sta/action/test/utest/Config
@@ -0,0 +1 @@
+CONFIG_CP_AV = y
diff --git a/cesar/cp/av/sta/action/test/utest/Makefile b/cesar/cp/av/sta/action/test/utest/Makefile
new file mode 100644
index 0000000000..ca1d30eda7
--- /dev/null
+++ b/cesar/cp/av/sta/action/test/utest/Makefile
@@ -0,0 +1,26 @@
+BASE = ../../../../../..
+
+INCLUDES = cp/av/sta/action/test/utest cp/av/sta/action/test/utest/override
+
+HOST_PROGRAMS = test_sta_action
+test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c info.c key.c \
+ bridge.c handover.c \
+ msg_stub.c dataplane_stub.c fsm_stub.c \
+ core_stub.c beacon_stub.c cp_stub.c \
+ cco_stub.c scenario_actions.c vs.c ce_stub.c \
+ mac_sar_interface_stub.c
+
+test_sta_action_MODULES = lib lib/scenario cp/av/sta/action cp/av/sta/mgr \
+ cp/av/fsm/stub cp/secu mac/common cl/stub cl \
+ cp/av/cco/action/stub cp/av/beacon/stub cp/msg/stub \
+ ce/stub mac/sar/stub cp/av/cco/bw/stub bsu/stub \
+ hal/ipmbox/stub
+
+test_sta_action_CONFIG_MODULES = cp
+cp_av_fsm_MODULE_SOURCES = tables.c
+
+# For bridging MME tests.
+cl_stub_MODULE_SOURCES = cl.c cl_mactotei.c brg_rx.c
+cl_MODULE_SOURCES = bridge_table.c data_rate.c
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/action/test/utest/inc/scenario_defs.h b/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h
index 2ab3dc6ea7..9e89572348 100644
--- a/cesar/cp/sta/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/av/sta/action/test/utest/inc/scenario_defs.h
@@ -435,16 +435,16 @@ __0 (whoru_timeout_process)
cp_beacon_deactivate, \
cp_beacon_synchronised, \
\
- cp_cco_action_cco__assoc_start, \
- cp_cco_action_cco__assoc_stop, \
- cp_cco_action_cco__unassoc_start, \
- cp_cco_action_cco__unassoc_stop, \
- cp_cco_action_ucco_start, \
- cp_cco_action_ucco_stop, \
- cp_cco_action_ucco__to_cco, \
- cp_cco_action_ucco__to_stop, \
- cp_cco_action_cco__to_ucco, \
- cp_cco_action_cco__cco_snid_conflict, \
+ cp_av_cco_action_cco__assoc_start, \
+ cp_av_cco_action_cco__assoc_stop, \
+ cp_av_cco_action_cco__unassoc_start, \
+ cp_av_cco_action_cco__unassoc_stop, \
+ cp_av_cco_action_ucco_start, \
+ cp_av_cco_action_ucco_stop, \
+ cp_av_cco_action_ucco__to_cco, \
+ cp_av_cco_action_ucco__to_stop, \
+ cp_av_cco_action_cco__to_ucco, \
+ cp_av_cco_action_cco__cco_snid_conflict, \
\
sar_activate, \
sar_cleanup, \
@@ -859,16 +859,16 @@ __e (cp_beacon_change_nek, u8 eks, cp_key_t *nek, bool now)
__e (cp_beacon_deactivate)
__er (cp_beacon_synchronised)
-__e (cp_cco_action_ucco_start)
-__e (cp_cco_action_ucco_stop)
-__e (cp_cco_action_ucco__to_cco)
-__e (cp_cco_action_ucco__to_stop)
-__e (cp_cco_action_cco__to_ucco)
-__e (cp_cco_action_cco__assoc_start)
-__e (cp_cco_action_cco__assoc_stop)
-__e (cp_cco_action_cco__unassoc_start)
-__e (cp_cco_action_cco__unassoc_stop)
-__e (cp_cco_action_cco__cco_snid_conflict)
+__e (cp_av_cco_action_ucco_start)
+__e (cp_av_cco_action_ucco_stop)
+__e (cp_av_cco_action_ucco__to_cco)
+__e (cp_av_cco_action_ucco__to_stop)
+__e (cp_av_cco_action_cco__to_ucco)
+__e (cp_av_cco_action_cco__assoc_start)
+__e (cp_av_cco_action_cco__assoc_stop)
+__e (cp_av_cco_action_cco__unassoc_start)
+__e (cp_av_cco_action_cco__unassoc_stop)
+__e (cp_av_cco_action_cco__cco_snid_conflict)
__e (sar_activate, bool flag)
__e (sar_cleanup)
diff --git a/cesar/cp/sta/action/test/utest/inc/test_sta_action.h b/cesar/cp/av/sta/action/test/utest/inc/test_sta_action.h
index 177f1ca7d1..177f1ca7d1 100644
--- a/cesar/cp/sta/action/test/utest/inc/test_sta_action.h
+++ b/cesar/cp/av/sta/action/test/utest/inc/test_sta_action.h
diff --git a/cesar/cp/sta/action/test/utest/override/cp/inc/context.h b/cesar/cp/av/sta/action/test/utest/override/cp/inc/context.h
index f47ea99def..f47ea99def 100644
--- a/cesar/cp/sta/action/test/utest/override/cp/inc/context.h
+++ b/cesar/cp/av/sta/action/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/sta/action/test/utest/override/cp/sta/core/core.h b/cesar/cp/av/sta/action/test/utest/override/cp/sta/core/core.h
index e7519405ee..e7519405ee 100644
--- a/cesar/cp/sta/action/test/utest/override/cp/sta/core/core.h
+++ b/cesar/cp/av/sta/action/test/utest/override/cp/sta/core/core.h
diff --git a/cesar/cp/sta/action/test/utest/src/assoc.c b/cesar/cp/av/sta/action/test/utest/src/assoc.c
index 4b33e3492c..bb0aa3ecf0 100644
--- a/cesar/cp/sta/action/test/utest/src/assoc.c
+++ b/cesar/cp/av/sta/action/test/utest/src/assoc.c
@@ -51,7 +51,7 @@ assoc_basic_test_cases (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
};
@@ -832,7 +832,7 @@ assoc_basic_test_cases_cco_unknow_mac_addr (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
};
@@ -899,7 +899,7 @@ assoc_basic_test_cases_nek_request (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
};
@@ -1136,7 +1136,7 @@ assoc_test_case_track (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
};
diff --git a/cesar/cp/sta/action/test/utest/src/beacon_stub.c b/cesar/cp/av/sta/action/test/utest/src/beacon_stub.c
index 952be7159f..5593dc7f24 100644
--- a/cesar/cp/sta/action/test/utest/src/beacon_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/beacon_stub.c
@@ -78,7 +78,7 @@ cp_beacon_poweron_init (cp_t *ctx)
}
void
-cp_beacon_sta_update_beacon_data (cp_t *ctx)
+cp_av_beacon_sta_update_beacon_data (cp_t *ctx)
{
}
@@ -89,10 +89,10 @@ cp_beacon_cco_update_beacon_data (cp_t *ctx)
void
-cp_beacon_discover_init (cp_t *ctx) {}
+cp_av_beacon_discover_init (cp_t *ctx) {}
void
-cp_beacon_discover_uninit (cp_t *ctx) {}
+cp_av_beacon_discover_uninit (cp_t *ctx) {}
bool
cp_beacon_synchronised (cp_t *ctx)
diff --git a/cesar/cp/sta/action/test/utest/src/bridge.c b/cesar/cp/av/sta/action/test/utest/src/bridge.c
index 0c215575e1..0c215575e1 100644
--- a/cesar/cp/sta/action/test/utest/src/bridge.c
+++ b/cesar/cp/av/sta/action/test/utest/src/bridge.c
diff --git a/cesar/cp/av/sta/action/test/utest/src/cco_stub.c b/cesar/cp/av/sta/action/test/utest/src/cco_stub.c
new file mode 100644
index 0000000000..444b0ba5ef
--- /dev/null
+++ b/cesar/cp/av/sta/action/test/utest/src/cco_stub.c
@@ -0,0 +1,166 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cco_stub.c
+ * \brief CCo stub.
+ * \ingroup test
+ */
+#include "common/std.h"
+#include "cp/cco/action/cco_action.h"
+
+#include "cp/sta/mgr/sta_mgr.h"
+#include "lib/scenario/scenario.h"
+
+void
+cp_av_cco_action_handover__start (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_cco__snid_conflict (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ scenario_event (cp_av_cco_action_cco__cco_snid_conflict);
+}
+
+void
+cp_av_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+}
+
+void
+cp_av_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+}
+
+void
+cp_av_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+}
+
+void
+cp_av_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change (cp_t *ctx)
+{
+}
+
+void
+cp_cco_action_tei_release (cp_t *ctx, u8 tei)
+{
+}
+
+void
+cp_av_cco_action__drv_mac_stop (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei)
+{
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
+{
+}
+
+void
+cp_av_cco_action_cco__cco_nek_change__timeout (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_nek_change_prevent (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_cco_selection__clear (cp_t *ctx)
+{
+}
+
+void
+cp_av_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * assoc_req)
+{
+}
+
+void
+cp_av_cco_action_cco__cc_discover_list_req (
+ cp_t *ctx, cp_net_t *net, cp_sta_t *sta) __attribute__ ((weak));
+
+void
+cp_av_cco_action_cco__cc_discover_list_req (
+ cp_t *ctx, cp_net_t *net, cp_sta_t *sta) {}
+
+void
+cp_av_cco_action_ucco_start (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_ucco_start);
+}
+
+void
+cp_av_cco_action_ucco_stop (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_ucco_stop);
+}
+
+void
+cp_av_cco_action_ucco__to_cco (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_ucco__to_cco);
+}
+
+void
+cp_av_cco_action_ucco__to_stop (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_ucco__to_stop);
+}
+
+void
+cp_av_cco_action_cco__to_ucco (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_cco__to_ucco);
+}
+
+void
+cp_av_cco_action_cco__unassoc_start (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_cco__unassoc_start);
+}
+
+void
+cp_av_cco_action_cco__unassoc_stop (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_cco__unassoc_stop);
+}
+
+void
+cp_av_cco_action_cco__assoc_start (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_cco__assoc_start);
+}
+
+void
+cp_av_cco_action_cco__assoc_stop (cp_t *ctx)
+{
+ scenario_event (cp_av_cco_action_cco__assoc_stop);
+}
diff --git a/cesar/cp/sta/action/test/utest/src/ce_stub.c b/cesar/cp/av/sta/action/test/utest/src/ce_stub.c
index ec7ff29510..ec7ff29510 100644
--- a/cesar/cp/sta/action/test/utest/src/ce_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/ce_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/core_stub.c b/cesar/cp/av/sta/action/test/utest/src/core_stub.c
index dae4a03060..dae4a03060 100644
--- a/cesar/cp/sta/action/test/utest/src/core_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/core_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/cp_stub.c b/cesar/cp/av/sta/action/test/utest/src/cp_stub.c
index 5309cd66bb..5309cd66bb 100644
--- a/cesar/cp/sta/action/test/utest/src/cp_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/cp_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/dataplane_stub.c b/cesar/cp/av/sta/action/test/utest/src/dataplane_stub.c
index 7ae91e0334..7ae91e0334 100644
--- a/cesar/cp/sta/action/test/utest/src/dataplane_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/dataplane_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/drv.c b/cesar/cp/av/sta/action/test/utest/src/drv.c
index 8bcbc31a9f..2fc811ccc1 100644
--- a/cesar/cp/sta/action/test/utest/src/drv.c
+++ b/cesar/cp/av/sta/action/test/utest/src/drv.c
@@ -13,7 +13,7 @@
#include "common/std.h"
#include "lib/scenario/scenario.h"
-#include "cp/sta/action/poweron.h"
+#include "cp/av/sta/action/poweron.h"
#include "inc/test_sta_action.h"
#include "lib/stats.h"
#include "cl/inc/context.h"
@@ -268,7 +268,7 @@ drv_basic_test_case (test_t t)
test_fail_if (my_param_u64 != 0x4242424242ull);
/* Check poweron init set neet_set to false. */
- cp_sta_action_poweron_init (&ctx.cp);
+ cp_av_sta_action_poweron_init (&ctx.cp);
test_fail_unless (false == ctx.cp.sta_action.poweron.enter.need_set);
enum cp_msg_drv_sta_set_key_type_t type =
diff --git a/cesar/cp/sta/action/test/utest/src/fsm_stub.c b/cesar/cp/av/sta/action/test/utest/src/fsm_stub.c
index 7b2085458b..7b2085458b 100644
--- a/cesar/cp/sta/action/test/utest/src/fsm_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/fsm_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/handover.c b/cesar/cp/av/sta/action/test/utest/src/handover.c
index ebc47ebb9e..b3130b587e 100644
--- a/cesar/cp/sta/action/test/utest/src/handover.c
+++ b/cesar/cp/av/sta/action/test/utest/src/handover.c
@@ -26,7 +26,7 @@ handover_test_case__handover (test_t t)
cp_sta_own_data_t *own;
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
@@ -151,7 +151,7 @@ handover_test_case__handover_info_recv (test_t t)
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
@@ -230,7 +230,7 @@ handover_test_case__handover_expires (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
@@ -240,7 +240,7 @@ handover_test_case__handover_expires (test_t t)
scenario_entry_t expires[] = {
SCENARIO_ACTION (handover__handover_ended),
- SCENARIO_EVENT (cp_cco_action_cco__assoc_start),
+ SCENARIO_EVENT (cp_av_cco_action_cco__assoc_start),
SCENARIO_EVENT (cp_sta_core_stop_timed_or_cyclic_event),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_HANDOVER_SUCCESS),
diff --git a/cesar/cp/sta/action/test/utest/src/info.c b/cesar/cp/av/sta/action/test/utest/src/info.c
index e90d4d45cd..e90d4d45cd 100644
--- a/cesar/cp/sta/action/test/utest/src/info.c
+++ b/cesar/cp/av/sta/action/test/utest/src/info.c
diff --git a/cesar/cp/sta/action/test/utest/src/key.c b/cesar/cp/av/sta/action/test/utest/src/key.c
index a8bc533007..a8bc533007 100644
--- a/cesar/cp/sta/action/test/utest/src/key.c
+++ b/cesar/cp/av/sta/action/test/utest/src/key.c
diff --git a/cesar/cp/sta/action/test/utest/src/mac_sar_interface_stub.c b/cesar/cp/av/sta/action/test/utest/src/mac_sar_interface_stub.c
index 7670aca0aa..7670aca0aa 100644
--- a/cesar/cp/sta/action/test/utest/src/mac_sar_interface_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/mac_sar_interface_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/misc.c b/cesar/cp/av/sta/action/test/utest/src/misc.c
index e2fb17f934..9f752f4db5 100644
--- a/cesar/cp/sta/action/test/utest/src/misc.c
+++ b/cesar/cp/av/sta/action/test/utest/src/misc.c
@@ -808,7 +808,7 @@ misc_hfid_test_case (test_t t)
{
test_sta_action_t ctx;
test_sta_action_init (&ctx);
- cp_sta_action_init (&ctx.cp);
+ cp_av_sta_action_init (&ctx.cp);
scenario_globals_t globals = {
.cp = &ctx.cp,
diff --git a/cesar/cp/sta/action/test/utest/src/msg_stub.c b/cesar/cp/av/sta/action/test/utest/src/msg_stub.c
index fb877baec5..fb877baec5 100644
--- a/cesar/cp/sta/action/test/utest/src/msg_stub.c
+++ b/cesar/cp/av/sta/action/test/utest/src/msg_stub.c
diff --git a/cesar/cp/sta/action/test/utest/src/poweron.c b/cesar/cp/av/sta/action/test/utest/src/poweron.c
index db906af646..49df7066d9 100644
--- a/cesar/cp/sta/action/test/utest/src/poweron.c
+++ b/cesar/cp/av/sta/action/test/utest/src/poweron.c
@@ -33,7 +33,7 @@ poweron_test_cases (test_t t)
/* Poweron start. */
test_case_begin (t, "poweron start");
test_sta_action_reset (&ctx);
- cp_sta_action_init (cp);
+ cp_av_sta_action_init (cp);
test_begin (t, "start")
{
@@ -343,7 +343,7 @@ poweron_test_cases (test_t t)
/* No AVLN. */
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__poweron__btt_timeout),
- SCENARIO_EVENT (cp_cco_action_ucco_start),
+ SCENARIO_EVENT (cp_av_cco_action_ucco_start),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (POWERON, btt_timeout,
no_avln)),
@@ -359,7 +359,7 @@ poweron_test_cases (test_t t)
slab_release (sta);
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__poweron__btt_timeout),
- SCENARIO_EVENT (cp_cco_action_ucco_start),
+ SCENARIO_EVENT (cp_av_cco_action_ucco_start),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (POWERON, btt_timeout,
no_avln)),
@@ -406,7 +406,7 @@ poweron_test_cases (test_t t)
slab_release (sta);
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__poweron__btt_timeout),
- SCENARIO_EVENT (cp_cco_action_cco__unassoc_start),
+ SCENARIO_EVENT (cp_av_cco_action_cco__unassoc_start),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (POWERON, btt_timeout,
nid_match_cco)),
@@ -502,7 +502,7 @@ poweron_test_cases (test_t t)
slab_release (sta);
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__usta__usta_ind, .net = net, .sta = sta),
- SCENARIO_EVENT (cp_cco_action_cco__unassoc_start),
+ SCENARIO_EVENT (cp_av_cco_action_cco__unassoc_start),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (USTA, usta_ind,
nid_match_cco)),
@@ -579,7 +579,7 @@ poweron_test_cases (test_t t)
.delay_max_ms = CP_DISCOVER_PERIOD_MAX_MS),
SCENARIO_ACTION (poweron__ucco__beacon, .beacon = &beacon,
.net = net, .sta = other_cco),
- SCENARIO_EVENT (cp_cco_action_ucco_stop),
+ SCENARIO_EVENT (cp_av_cco_action_ucco_stop),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (UCCO, BEACON,
no_nid_match)),
@@ -635,7 +635,7 @@ poweron_test_cases (test_t t)
test_sta_action_create_our_net (&ctx, nid, 1);
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__cco__join_timeout),
- SCENARIO_EVENT (cp_cco_action_cco__to_ucco),
+ SCENARIO_EVENT (cp_av_cco_action_cco__to_ucco),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (CCO, join_timeout,
no_sta_no_avln)),
@@ -649,7 +649,7 @@ poweron_test_cases (test_t t)
cp_sta_mgr_add_avln (cp, 2, 0x222222222222ull);
scenario_entry_t entries[] = {
SCENARIO_ACTION (poweron__cco__join_timeout),
- SCENARIO_EVENT (cp_cco_action_cco__unassoc_stop),
+ SCENARIO_EVENT (cp_av_cco_action_cco__unassoc_stop),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (CCO, join_timeout,
no_sta_avln)),
diff --git a/cesar/cp/sta/action/test/utest/src/sc.c b/cesar/cp/av/sta/action/test/utest/src/sc.c
index 32a6350a99..6bc83a5ceb 100644
--- a/cesar/cp/sta/action/test/utest/src/sc.c
+++ b/cesar/cp/av/sta/action/test/utest/src/sc.c
@@ -18,7 +18,7 @@
#include "inc/test_sta_action.h"
-#include "cp/sta/action/sc.h"
+#include "cp/av/sta/action/sc.h"
void
sc_basic_test_cases (test_t t)
@@ -142,7 +142,7 @@ sc_basic_test_cases (test_t t)
/* First, execute transition. */
SCENARIO_ACTION (sc__sc_cco__sc_failed),
/* Quit CCo role. */
- SCENARIO_EVENT (cp_cco_action_cco__to_ucco),
+ SCENARIO_EVENT (cp_av_cco_action_cco__to_ucco),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (SC_CCO, sc_failed,
no_sta_no_avln)),
@@ -163,7 +163,7 @@ sc_basic_test_cases (test_t t)
scenario_entry_t sc_main_timeout[] = {
/* First, execute transition. */
SCENARIO_ACTION (sc__sc_cco__sc_failed),
- SCENARIO_EVENT (cp_cco_action_cco__unassoc_stop),
+ SCENARIO_EVENT (cp_av_cco_action_cco__unassoc_stop),
SCENARIO_EVENT (cp_fsm_branch,
.branch = CP_FSM_BRANCH (SC_CCO, sc_failed,
no_sta_avln)),
diff --git a/cesar/cp/sta/action/test/utest/src/sc_test.c b/cesar/cp/av/sta/action/test/utest/src/sc_test.c
index 5d04f9fcab..5d04f9fcab 100644
--- a/cesar/cp/sta/action/test/utest/src/sc_test.c
+++ b/cesar/cp/av/sta/action/test/utest/src/sc_test.c
diff --git a/cesar/cp/sta/action/test/utest/src/scenario_actions.c b/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c
index 5107b89dbd..3a5c5ca97b 100644
--- a/cesar/cp/sta/action/test/utest/src/scenario_actions.c
+++ b/cesar/cp/av/sta/action/test/utest/src/scenario_actions.c
@@ -12,7 +12,7 @@
*/
#include "common/std.h"
-#include "cp/sta/action/action.h"
+#include "cp/av/sta/action/action.h"
#include "lib/scenario/scenario.h"
@@ -27,6 +27,17 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
cp_sta_action_ ## ACTION (globals->cp, &mme); \
}
+#define __m_av(ACTION) \
+void \
+scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
+ scenario_params_t *params) \
+{ \
+ static cp_mme_rx_t mme; \
+ mme.peer = params->action_ ## ACTION.peer; \
+ mme.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED; \
+ cp_av_sta_action_ ## ACTION (globals->cp, &mme); \
+}
+
#define __mp(ACTION) \
void \
scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
@@ -58,6 +69,14 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
cp_sta_action_ ## ACTION (globals->cp); \
}
+#define __0_av(ACTION) \
+void \
+scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
+ scenario_params_t *params) \
+{ \
+ cp_av_sta_action_ ## ACTION (globals->cp); \
+}
+
#define __n(ACTION, PARAMS...) \
void \
scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
@@ -70,41 +89,53 @@ scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
); \
}
+#define __n_av(ACTION, PARAMS...) \
+void \
+scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
+ scenario_params_t *params) \
+{ \
+ scenario_action_ ## ACTION ## _t *p = &params->action_ ## ACTION; \
+ cp_av_sta_action_ ## ACTION (globals->cp \
+ PREPROC_FOR_EACH_PARAM (PREPROC_CALL_UNPACK, \
+ __n_args, ## PARAMS) \
+ ); \
+}
+
#define __n_args(TYPE, PARAM) \
, p->PARAM
__0 (garbage)
-__n (assoc_start,
+__n_av (assoc_start,
(cp_net_t *, cco_net),
(cp_sta_t *, cco))
-__0 (assoc_leave)
-__0 (assoc__unassociated__enter)
-__0 (assoc__unassociated__to_assoc)
+__0_av (assoc_leave)
+__0_av (assoc__unassociated__enter)
+__0_av (assoc__unassociated__to_assoc)
__0 (assoc__start_retry_timer)
__0 (assoc__stop_retry_timer)
-__m (assoc__wait_assoc_cnf__cc_assoc_cnf)
-__0 (assoc__wait_assoc_cnf__timeout)
-__m (assoc__associated__cm_get_key_cnf_pid_0)
-__0 (assoc__associated__timeout)
-__0 (assoc__associated__to_leave)
-__0 (assoc__authenticated__leave)
-__0 (assoc__authenticated__renew)
-__m (assoc__authenticated__cc_assoc_cnf)
-__m (assoc__authenticated__cm_set_key_req_pid_1)
-__0 (assoc__authenticated__to_leave)
-__m (assoc__authenticated__cc_leave_ind)
-__n (assoc__authenticated__beacon,
+__m_av (assoc__wait_assoc_cnf__cc_assoc_cnf)
+__0_av (assoc__wait_assoc_cnf__timeout)
+__m_av (assoc__associated__cm_get_key_cnf_pid_0)
+__0_av (assoc__associated__timeout)
+__0_av (assoc__associated__to_leave)
+__0_av (assoc__authenticated__leave)
+__0_av (assoc__authenticated__renew)
+__m_av (assoc__authenticated__cc_assoc_cnf)
+__m_av (assoc__authenticated__cm_set_key_req_pid_1)
+__0_av (assoc__authenticated__to_leave)
+__m_av (assoc__authenticated__cc_leave_ind)
+__n_av (assoc__authenticated__beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__0 (assoc__authenticated__beacon_not_received)
-__0 (assoc__authenticated__nek_request)
-__m (assoc__authenticated__cm_get_key_cnf_pid_1)
-__m (assoc__leaving__cc_leave_cnf)
-__0 (assoc__leaving__timeout)
-__0 (assoc__leave_wait__enter)
-__0 (assoc__leave_wait__timeout)
+__0_av (assoc__authenticated__beacon_not_received)
+__0_av (assoc__authenticated__nek_request)
+__m_av (assoc__authenticated__cm_get_key_cnf_pid_1)
+__m_av (assoc__leaving__cc_leave_cnf)
+__0_av (assoc__leaving__timeout)
+__0_av (assoc__leave_wait__enter)
+__0_av (assoc__leave_wait__timeout)
__m (drv__stopped__drv_sta_set_mac_addr_req)
__m (drv__stopped__drv_sta_set_cco_pref_req)
@@ -127,8 +158,8 @@ __m (drv__drv_sta_status_req)
__m (drv__drv_sta_set_config_req)
__m (drv__drv_mcast_set_list_req)
-__m (process_cc_set_tei_map_ind)
-__m (process_cm_unassociated_sta_ind)
+__m_av (process_cc_set_tei_map_ind)
+__m_av (process_cm_unassociated_sta_ind)
__mp (process_cm_set_key_req)
__mp (process_cm_set_key_cnf)
@@ -137,7 +168,7 @@ __mp (process_cm_get_key_cnf)
__m (process_cc_who_ru_req)
__m (process_cc_who_ru_cnf)
-__m (process_cc_discover_list_req)
+__m_av (process_cc_discover_list_req)
__me (process_cc_relay_req)
__m (process_cm_hfid_req)
__m (process_cm_mme_error_ind)
@@ -146,82 +177,82 @@ __0 (poweron_start)
__0 (poweron_stop)
__0 (poweron__many__to_idle)
__0 (poweron__idle__to_poweron)
-__0 (poweron__poweron__enter)
-__0 (poweron__poweron__leave)
-__0 (poweron__poweron__ustt_timeout)
-__0 (poweron__poweron__btt_timeout)
-__n (poweron__poweron__beacon,
+__0_av (poweron__poweron__enter)
+__0_av (poweron__poweron__leave)
+__0_av (poweron__poweron__ustt_timeout)
+__0_av (poweron__poweron__btt_timeout)
+__n_av (poweron__poweron__beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__0 (poweron__poweron_joining__left)
-__0 (poweron__joining__to_stop)
-__0 (poweron__usta__enter)
-__0 (poweron__usta__leave)
-__0 (poweron__usta__ustt_timeout)
-__n (poweron__usta__beacon,
+__0_av (poweron__poweron_joining__left)
+__0_av (poweron__joining__to_stop)
+__0_av (poweron__usta__enter)
+__0_av (poweron__usta__leave)
+__0_av (poweron__usta__ustt_timeout)
+__n_av (poweron__usta__beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__n (poweron__usta__usta_ind,
+__n_av (poweron__usta__usta_ind,
(cp_net_t *, net),
(cp_sta_t *, sta))
-__0 (poweron__usta_joining__left)
-__n (poweron__ucco__beacon,
+__0_av (poweron__usta_joining__left)
+__n_av (poweron__ucco__beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__0 (poweron__sta__to_stop)
-__0 (poweron__cco__join_timeout)
-__0 (poweron_cco__enter)
-__0 (poweron_cco__leave)
+__0_av (poweron__sta__to_stop)
+__0_av (poweron__cco__join_timeout)
+__0_av (poweron_cco__enter)
+__0_av (poweron_cco__leave)
__m (process_cm_brg_info_cnf)
__m (process_cm_brg_info_req)
__0 (update_bridge_table)
-__m (drv__usta__drv_sta_sc)
-__m (drv__ucco__drv_sta_sc)
-__m (drv__cco__drv_sta_sc)
-__m (drv__sta__drv_sta_sc)
-__0 (sc__start_sc_join)
-__0 (sc__start_sc_add)
-__0 (sc__sc_idle__enter)
-__0 (sc__sc_idle__leave)
-__0 (sc__sc_join__enter)
-__0 (sc__sc_join__leave)
-__0 (sc__sc_join__sc_join_req_timeout)
-__0 (sc__sc_cco__sc_failed)
-__0 (sc__sc_timeout)
-__0 (sc_add__sc_timeout)
-__m (sc__sc_join__cm_sc_join_cnf)
-__m (sc__sc_join__cm_sc_join_req)
-__m (sc__sc_add__cm_sc_join_req)
-__n (sc__sc_wait_beacon__beacon,
+__m_av (drv__usta__drv_sta_sc)
+__m_av (drv__ucco__drv_sta_sc)
+__m_av (drv__cco__drv_sta_sc)
+__m_av (drv__sta__drv_sta_sc)
+__0_av (sc__start_sc_join)
+__0_av (sc__start_sc_add)
+__0_av (sc__sc_idle__enter)
+__0_av (sc__sc_idle__leave)
+__0_av (sc__sc_join__enter)
+__0_av (sc__sc_join__leave)
+__0_av (sc__sc_join__sc_join_req_timeout)
+__0_av (sc__sc_cco__sc_failed)
+__0_av (sc__sc_timeout)
+__0_av (sc_add__sc_timeout)
+__m_av (sc__sc_join__cm_sc_join_cnf)
+__m_av (sc__sc_join__cm_sc_join_req)
+__m_av (sc__sc_add__cm_sc_join_req)
+__n_av (sc__sc_wait_beacon__beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__n (sc__sc_wait_peer_associated__new_sta_associated,
+__n_av (sc__sc_wait_peer_associated__new_sta_associated,
(cp_net_t *, net),
(cp_sta_t *, sta))
-__m (sc__sc_building_tek__cm_get_key_cnf_pid3)
-__m (sc__sc_nmk_exchange__cm_set_key_cnf_pid3)
-__n (sc__sc_usta_track_beacon,
+__m_av (sc__sc_building_tek__cm_get_key_cnf_pid3)
+__m_av (sc__sc_nmk_exchange__cm_set_key_cnf_pid3)
+__n_av (sc__sc_usta_track_beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__n (sc__sc_ucco_track_beacon,
+__n_av (sc__sc_ucco_track_beacon,
(bsu_beacon_t *, beacon),
(cp_net_t *, net),
(cp_sta_t *, sta))
-__m (assoc__sc_wait_assoc_cnf__cc_assoc_cnf)
-__m (assoc__sc_associated__cm_get_key_req_pid_3)
-__m (assoc__sc_tek_exchanged__cm_set_key_req_pid_3)
-__m (assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0)
-
-__m (handover__start)
-__m (handover__handover_info_ind_receive)
-__0 (handover__handover_ended)
+__m_av (assoc__sc_wait_assoc_cnf__cc_assoc_cnf)
+__m_av (assoc__sc_associated__cm_get_key_req_pid_3)
+__m_av (assoc__sc_tek_exchanged__cm_set_key_req_pid_3)
+__m_av (assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0)
+
+__m_av (handover__start)
+__m_av (handover__handover_info_ind_receive)
+__0_av (handover__handover_ended)
__0 (whoru_timeout_process)
__m (process_cm_nw_stats_req)
__m (process_cm_nw_info_req)
diff --git a/cesar/cp/sta/action/test/utest/src/test_sta_action.c b/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c
index 4518ea0111..2cec42d3b9 100644
--- a/cesar/cp/sta/action/test/utest/src/test_sta_action.c
+++ b/cesar/cp/av/sta/action/test/utest/src/test_sta_action.c
@@ -29,18 +29,9 @@ void
key_test_suite (test_t t);
void
-misc_test_suite (test_t t);
-
-void
-poweron_test_suite (test_t t);
-
-void
bridge_test_suite (test_t t);
void
-sc_test_suite (test_t t);
-
-void
handover_test_suite (test_t t);
void
@@ -116,11 +107,8 @@ main (int argc, char **argv)
drv_test_suite (t);
info_test_suite (t);
key_test_suite (t);
- misc_test_suite (t);
vs_test_suite (t);
- poweron_test_suite (t);
bridge_test_suite (t);
- sc_test_suite (t);
handover_test_suite (t);
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
diff --git a/cesar/cp/sta/action/test/utest/src/vs.c b/cesar/cp/av/sta/action/test/utest/src/vs.c
index a918416577..a918416577 100644
--- a/cesar/cp/sta/action/test/utest/src/vs.c
+++ b/cesar/cp/av/sta/action/test/utest/src/vs.c
diff --git a/cesar/cp/av/sta/mgr/Module b/cesar/cp/av/sta/mgr/Module
new file mode 100644
index 0000000000..d6a9a3d666
--- /dev/null
+++ b/cesar/cp/av/sta/mgr/Module
@@ -0,0 +1,3 @@
+SOURCES := sta_own_data.c sta_mgr.c
+
+MODULES := cp/sta/mgr
diff --git a/cesar/cp/av/sta/mgr/src/sta_mgr.c b/cesar/cp/av/sta/mgr/src/sta_mgr.c
new file mode 100644
index 0000000000..543e97dfca
--- /dev/null
+++ b/cesar/cp/av/sta/mgr/src/sta_mgr.c
@@ -0,0 +1,388 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/mgr/src/sta_mgr.c
+ * \brief Station manager source.
+ * \ingroup cp_av_sta_mgr
+ *
+ */
+#include "common/std.h"
+
+#include "cp/defs.h"
+#include "cp/cp.h"
+#include "cp/fsm/fsm.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/sta/mgr/sta_own_data.h"
+#include "cp/sta/core/core.h"
+#include "cp/cco/action/cco_action.h"
+#include "cl/cl_mactotei.h"
+#include "cl/brg_rx.h"
+#include "mac/sar/sar.h"
+
+#include "cp/inc/context.h"
+#include "cp/sta/mgr/inc/sta.h"
+#include "cp/sta/mgr/inc/net.h"
+#include "cp/sta/mgr/inc/sta_mgr.h"
+#include "cp/sta/mgr/inc/sta_own_data.h"
+#include "cp/av/cco/action/cco_action.h"
+
+void
+cp_av_sta_mgr_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ memset (&ctx->sta_mgr, 0, sizeof (cp_sta_mgr_t));
+
+ // Initialise the station own data.
+ cp_sta_own_data_init (ctx);
+
+ // Initialise the list of releasing stations.
+ list_init (&ctx->sta_mgr.release_sta_list);
+
+ // Initialise the slab cache.
+ slab_cache_init (&ctx->sta_mgr.sta_slab_cache,
+ "Station cache",
+ sizeof (cp_sta_private_t),
+ (slab_object_destructor_t) cp_sta_uninit);
+
+ // Initialise the set of station sorted by mac addresses.
+ set_init (&ctx->sta_mgr.stas, cp_sta_mgr_sta_mac_address_less);
+}
+
+static void
+cp_av_sta_mgr_sta_remove_common (cp_t *ctx, cp_sta_t * station)
+{
+ set_t *set;
+ cp_sta_private_t *sta = (cp_sta_private_t *) station;
+ cp_net_t *net;
+
+ dbg_assert (ctx);
+ dbg_assert (sta);
+ dbg_assert (sta->net);
+
+ net = sta->net;
+
+ // If the station is CCo, modify the net CCo pointer to NULL.
+ if (cp_sta_get_cco_status(station))
+ net->cco = NULL;
+
+ // If the station is PCo to communicate with the CCo, modify the
+ // pointer in the net.
+ if (net->pco == station)
+ net->pco = NULL;
+
+ set = (cp_sta_get_tei (&sta->public_data)) ?
+ &sta->net->associated_stas : &sta->net->unassociated_stas;
+ /* Remove the station from its net. */
+ set_remove (set, &sta->public_data.node_net);
+
+ /* Remove the station from the station manager. If the mac address of the
+ * station is broadcast, the station is not in the set. */
+ if (sta->mac_address != MAC_BROADCAST)
+ set_remove (&ctx->sta_mgr.stas, &sta->public_data.node_sta_mgr);
+
+ /* decrease the visible counter. */
+ if (sta->visible)
+ sta->net->num_visible_stas --;
+
+ /* decrease the number of stations. */
+ sta->net->num_stas --;
+
+ if (MAC_TEI_IS_STA (cp_sta_get_tei (&sta->public_data)))
+ sta->net->num_associated_stas--;
+ if (net == ctx->sta_mgr.our_avln && sta->net->num_associated_stas == 0)
+ cp_fsm_post_new_event (ctx, bare, sta_status_changed);
+
+ cp_sta_mgr_elects_sta_partial_ack (ctx);
+}
+
+void
+cp_av_sta_mgr_release_station (cp_t *ctx, cp_tei_t tei)
+{
+ cp_sta_t *sta;
+ cp_net_t *net;
+
+ dbg_assert (ctx);
+ dbg_assert (tei);
+ dbg_assert (cp_sta_own_data_get_cco_status (ctx));
+
+ net = cp_sta_mgr_get_our_avln (ctx);
+ sta = cp_sta_mgr_sta_get_assoc (ctx, net, tei);
+ dbg_assert (sta);
+
+ list_init_node (&sta->release_node);
+ list_push (&ctx->sta_mgr.release_sta_list, &sta->release_node);
+
+ /* Set the station tei_lease_ms to 5 min as indicated in the HPAV
+ * specification. */
+ sta->tei_lease_date_ms = CP_STA_MGR_STATION_RELEASE_MS +
+ cp_sta_core_get_date_ms (ctx);
+
+ /* Remove the station. */
+ cp_av_sta_mgr_sta_remove_common (ctx, sta);
+ /* Remove the reference provided. */
+ slab_release (sta);
+
+ /* Check if our net is empty, if it is post an FSM event
+ * cco__all_sta_leaved */
+ if (cp_sta_own_data_get_tei (ctx)
+ && net == cp_sta_mgr_get_our_avln (ctx)
+ && cp_net_is_empty (ctx, net))
+ cp_fsm_trigger_new_event (ctx, bare, cco__all_sta_leaved);
+}
+
+void
+cp_av_sta_mgr_sta_remove (cp_t *ctx, cp_sta_t * station)
+{
+ cp_sta_private_t *sta = (cp_sta_private_t *) station;
+
+ dbg_assert (ctx);
+ dbg_assert (sta);
+
+ if ((sta->net == ctx->sta_mgr.our_avln)
+ && (MAC_TEI_IS_STA (sta->tei)))
+ {
+ sar_sta_remove (ctx->sar, sta->tei);
+ }
+
+ cp_av_sta_mgr_sta_remove_common (ctx, station);
+
+ /* Release the station. */
+ slab_release (sta);
+}
+
+void
+cp_av_sta_mgr_set_tracking (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
+{
+ dbg_assert (ctx);
+ dbg_assert (HPAV_NID_IS_VALID (nid));
+#if CONFIG_DEBUG
+ bool found = false;
+ cp_net_t *net;
+ for (net = cp_sta_mgr_get_first_avln (ctx);
+ net;
+ net = cp_sta_mgr_get_next_avln (ctx, net))
+ {
+ if (cp_net_get_snid (ctx, net) == snid
+ && cp_net_get_nid (ctx, net) == nid)
+ found = true;
+ }
+ dbg_assert (found);
+#endif
+ ctx->sta_mgr.sta_own_data.snid = snid;
+}
+
+void
+cp_av_sta_mgr_garbage (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ cp_net_t *net;
+ dbg_assert (ctx);
+ u32 now = cp_sta_core_get_date_ms (ctx);
+ for (net = cp_sta_mgr_get_first_avln (ctx);
+ net;
+ net = cp_sta_mgr_get_next_avln (ctx, net))
+ {
+ if (net != ctx->sta_mgr.our_avln)
+ cp_net_garbage_stations (ctx, net, now);
+ if (net->blacklisted
+ && less_mod2p32 ( net->blacklisted_reset_date, phy_date ()))
+ net->blacklisted = false;
+ }
+ /* Release the release stations if possible. */
+ while ((sta = cp_sta_mgr_release_sta_get_first (ctx))
+ && (less_mod2p32 (sta->tei_lease_date_ms, now)))
+ {
+ /* remove the station from the list. */
+ list_remove (&ctx->sta_mgr.release_sta_list,
+ &sta->release_node);
+
+ sar_sta_remove (ctx->sar, cp_sta_get_tei (sta));
+
+ if (cp_sta_own_data_get_cco_status (ctx))
+ {
+ /* Request the CCo to release the TEI. */
+ cp_cco_action_tei_release (ctx, cp_sta_get_tei (sta));
+ }
+ slab_release (sta);
+ }
+ cp_sta_mgr_elects_sta_partial_ack (ctx);
+ if (cp_sta_mgr_net_list_is_empty (ctx))
+ cp_fsm_trigger_new_event (ctx, bare, net_list_empty);
+ /* Recommit to dataplane. */
+ cp_sta_mgr_commit_to_dataplane (ctx);
+}
+
+cp_sta_t *
+cp_av_sta_mgr_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address)
+{
+ cp_sta_t *sta = NULL;
+ cp_sta_t *sta_from_tei = NULL;
+ dbg_assert (ctx);
+ dbg_assert (net);
+ dbg_assert ((tei && mac_address == MAC_BROADCAST)
+ || (mac_address & ~MAC_BROADCAST) == 0);
+ /* Try to get the station by the TEI. */
+ if (tei)
+ sta_from_tei = cp_sta_mgr_sta_get_assoc (ctx, net, tei);
+ /* Try to get the station by the mac address. */
+ if (MAC_IS_VALID(mac_address))
+ sta = cp_sta_mgr_sta_get_from_mac (ctx, mac_address);
+
+ /* Does the two station match ? */
+ if (sta && sta_from_tei)
+ {
+ if (sta != sta_from_tei)
+ /* remove the station got using the TEI. */
+ cp_sta_mgr_sta_remove_assoc (ctx, net, tei);
+ slab_release (sta_from_tei);
+ }
+ else if (!sta)
+ sta = sta_from_tei;
+
+ if (!sta)
+ {
+ sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
+ }
+ else
+ {
+ cp_tei_t sta_tei = cp_sta_get_tei (sta);
+ mac_t sta_mac = cp_sta_get_mac_address (sta);
+ cp_net_t *sta_net = cp_sta_get_net (sta);
+ /* Last case. The network change. */
+ if (sta_net != net)
+ {
+ cp_sta_mgr_sta_remove (ctx, sta);
+ slab_release (sta);
+ sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
+ }
+ /* Second case,
+ * - station's TEI == TEI and != MAC_TEI_UNASSOCIATED.
+ * - station's Mac address was broadcast. */
+ else if ((sta_tei == tei)
+ && (tei != MAC_TEI_UNASSOCIATED)
+ && (sta_mac != mac_address)
+ && (sta_mac == MAC_BROADCAST))
+ {
+ /* Add the station mgr node to the set. */
+ cp_sta_private_t *p = PARENT_OF (cp_sta_private_t, public_data,
+ sta);
+ p->mac_address = mac_address;
+ set_insert (&ctx->sta_mgr.stas, &sta->node_sta_mgr);
+ }
+ /* First case only the TEI change from the previous state. */
+ else if ((sta_tei == MAC_TEI_UNASSOCIATED
+ && tei != MAC_TEI_UNASSOCIATED
+ && sta_mac == mac_address)
+ /* Third case, only the station's TEI change. */
+ || (sta_tei != tei
+ && tei != MAC_TEI_UNASSOCIATED
+ && sta_mac == mac_address
+ && mac_address != MAC_BROADCAST)
+ /* Fourth case, only the station's TEI change from a
+ * associated tei to the unassociated TEI.. */
+ || (sta_tei != tei
+ && tei == MAC_TEI_UNASSOCIATED
+ && sta_mac == mac_address
+ && mac_address != MAC_BROADCAST)
+ /* Fifth case, Same TEI only the mac address change from A
+ * to B without being null or broadcast. */
+ || (sta_tei == tei
+ && sta_mac != mac_address
+ && MAC_IS_VALID (sta_mac)
+ && MAC_IS_VALID (mac_address))
+ )
+ {
+ /* Remove the station. */
+ cp_sta_mgr_sta_remove (ctx, sta);
+ slab_release (sta);
+ /* Add the station with the new TEI. */
+ sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
+ }
+ }
+ /* Update the last seen value. */
+ if (ctx->sta_mgr.sta_own_data.is_cco
+ && cp_sta_get_net (sta) == ctx->sta_mgr.our_avln)
+ sta->expired_date_ms = cp_sta_core_get_date_ms (ctx)
+ + HPAV_STA_PRESENCE_TIMEOUT_INSIDE_AVLN_MS;
+ else
+ sta->expired_date_ms = cp_sta_core_get_date_ms (ctx)
+ + HPAV_DISCOVERED_LIST_EXPIRE_TIME_MS;
+ return sta;
+}
+
+void
+cp_av_sta_mgr_commit_to_dataplane (cp_t *ctx)
+{
+ cp_sta_t *sta;
+ cl_mactotei_blk_t *mactotei;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->cl);
+
+ // If the net does not correspond to the AVLN, do not commit.
+ if (!ctx->sta_mgr.our_avln)
+ return;
+
+ // Get the first station from the set.
+ if (set_empty (&ctx->sta_mgr.our_avln->associated_stas))
+ {
+ cl_mactotei_release_table (ctx->cl);
+ }
+ else
+ {
+ // There is at least a station in the network list.
+ mactotei = cl_mactotei_new ();
+ uint i;
+
+ for (sta = cp_net_sta_get_first (
+ ctx, ctx->sta_mgr.our_avln, CP_NET_STA_ASSOC);
+ sta;
+ sta = cp_net_sta_get_next (ctx, ctx->sta_mgr.our_avln, sta))
+ {
+ cp_sta_private_t *sta_private =
+ PARENT_OF (cp_sta_private_t, public_data, sta);
+ // Copy all the bridge table from the previous list.
+ cl_mactotei_copy_tei_and_tag (ctx->cl, mactotei, sta_private->tei,
+ sta_private->tei);
+ // Add the current station.
+ cl_mactotei_addr_add (mactotei, sta_private->mac_address,
+ sta_private->tei, MAC_TEI_UNASSOCIATED);
+ }
+ /* Get the bridge RX table of the CL. */
+ cl_brg_rx_t *brg_rx_table = cl_brg_rx_get (ctx->cl);
+ if (brg_rx_table)
+ {
+ /* Add bridged Mac addresses to the mac to tei.
+ * If the bridged MAC address is already present in the mac2tei,
+ * the extra_info will be updated using the bridged tei. */
+ for (i = 0; i < brg_rx_table->nb_entry; i++)
+ {
+ sta = cp_sta_mgr_sta_get_assoc (
+ ctx, ctx->sta_mgr.our_avln,
+ brg_rx_table->entry[i].tei);
+ if (sta)
+ {
+ cl_mactotei_addr_add (
+ mactotei, brg_rx_table->entry[i].mac,
+ brg_rx_table->entry[i].tei,
+ brg_rx_table->entry[i].tei);
+ slab_release (sta);
+ }
+ }
+ blk_release (brg_rx_table);
+ }
+
+ // Copy all the groups list table from the previous list.
+ cl_mactotei_copy_tei (ctx->cl, mactotei, MAC_TEI_BCAST);
+
+ // Request the CL to use the table.
+ cl_mactotei_use_table (ctx->cl, mactotei);
+ cl_update_igmp_groups (ctx->cl);
+ }
+}
diff --git a/cesar/cp/av/sta/mgr/src/sta_own_data.c b/cesar/cp/av/sta/mgr/src/sta_own_data.c
new file mode 100644
index 0000000000..edeb0cf253
--- /dev/null
+++ b/cesar/cp/av/sta/mgr/src/sta_own_data.c
@@ -0,0 +1,87 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/sta/data/src/sta_own_data.c
+ * \brief Station data source.
+ * \ingroup cp_sta_data
+ *
+ */
+#include "common/std.h"
+#include "string.h"
+
+#include "lib/dbg.h"
+#include "lib/bitstream.h"
+#include "cp/fsm/fsm.h"
+#include "bsu/bsu.h"
+#include "hal/gpio/gpio.h"
+
+/* Public interfaces. */
+#include "cp/sta/mgr/sta_own_data.h"
+#include "cp/msg/msg.h"
+
+/* Private interfaces. */
+#include "cp/inc/context.h"
+#include "cp/sta/mgr/inc/sta_own_data.h"
+
+/**
+ * Initialise the station own data to default values.
+ * \param ctx the module context.
+ */
+void
+cp_av_sta_own_data_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ memset (&ctx->sta_mgr.sta_own_data, 0,
+ sizeof (cp_sta_own_data_private_t));
+ /* Store the hybrid mode. */
+ ctx->sta_mgr.sta_own_data.public.hybrid_mode =
+ MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
+ /* Get an snid. */
+ ctx->sta_mgr.sta_own_data.snid =
+ lib_rnd_uniform (&ctx->rnd, HPAV_SNID_NB);
+}
+
+bool
+cp_av_sta_own_data_set_nmk (cp_t *ctx, const cp_key_t nmk,
+ cp_msg_drv_sta_set_key_type_t type)
+{
+ dbg_assert (ctx);
+ dbg_assert (type < CP_MSG_DRV_STA_SET_KEY_TYPE_NB);
+
+ uint i;
+ cp_key_t current_key = cp_sta_own_data_get_nmk (ctx);
+
+ for (i = 0; i < COUNT(nmk.key) ;i++)
+ if (nmk.key[i] != current_key.key[i])
+ break;
+
+ if (i < COUNT(nmk.key))
+ {
+ ctx->sta_mgr.sta_own_data.nmk = nmk;
+
+ /* Report new computed values to HLE. */
+ cp_mme_peer_t peer = CP_MME_PEER (cp_sta_own_data_get_mac_address (ctx),
+ MAC_TEI_FOREIGN);
+ cp_nid_t nid = 0;
+ cp_security_level_t sl = 0;
+
+ if (type == CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID)
+ nid = cp_sta_own_data_get_nid (ctx);
+ else
+ sl = cp_sta_own_data_get_security_level (ctx);
+
+ cp_msg_drv_sta_set_key_ind_send (ctx, &peer,
+ nmk,
+ type,
+ nid,
+ sl);
+ return true;
+ }
+
+ return false;
+}
diff --git a/cesar/cp/av/sta/mgr/sta_mgr.h b/cesar/cp/av/sta/mgr/sta_mgr.h
new file mode 100644
index 0000000000..bd52c8ce8d
--- /dev/null
+++ b/cesar/cp/av/sta/mgr/sta_mgr.h
@@ -0,0 +1,35 @@
+#ifndef cp_av_sta_mgr_h
+#define cp_av_sta_mgr_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/av/sta/mgr/sta_mgr.h
+ * \brief Station Manager.
+ * \ingroup cp_av_sta_mgr
+ *
+ * Station and AVLN manager.
+ */
+#include "cp/sta/mgr/net.h"
+
+BEGIN_DECLS
+
+/**
+ * Set the SNID of the station to track the correct AVLN.
+ * \param ctx the module context.
+ * \param snid the station SNID.
+ * \param nid the network identifier to track.
+ *
+ * Be careful, this function does not modify our AVLN snid to do some use
+ * cp_sta_own_data_set_snid.
+ */
+void
+cp_av_sta_mgr_set_tracking (cp_t *ctx, cp_snid_t snid, cp_nid_t nid);
+
+END_DECLS
+
+#endif /* cp_av_sta_mgr_h */
diff --git a/cesar/cp/sta/mgr/test/Config b/cesar/cp/av/sta/mgr/test/utest/Config
index affc03c8c7..f720280e07 100644
--- a/cesar/cp/sta/mgr/test/Config
+++ b/cesar/cp/av/sta/mgr/test/utest/Config
@@ -1,2 +1,3 @@
+CONFIG_CP_AV = y
CONFIG_DEBUG_FATAL_CATCH = y
CONFIG_RESTRACK = y
diff --git a/cesar/cp/av/sta/mgr/test/utest/Makefile b/cesar/cp/av/sta/mgr/test/utest/Makefile
new file mode 100644
index 0000000000..71c6c9f850
--- /dev/null
+++ b/cesar/cp/av/sta/mgr/test/utest/Makefile
@@ -0,0 +1,15 @@
+BASE = ../../../../../..
+
+INCLUDES = cp/av/sta/mgr/test/utest/override
+
+HOST_PROGRAMS = test_sta_mgr
+test_sta_mgr_SOURCES = core_stub.c net_test.c sar_stub.c sta_mgr.c \
+ sta-test.c station_test.c test_sta_mgr.c
+test_sta_mgr_MODULES = lib cp/av/sta/mgr mac/common cp/av/fsm/stub \
+ cp/av/cco/action/stub bsu/stub cp/msg/stub \
+ cl cl/stub hal/ipmbox/stub
+test_sta_mgr_CONFIG_MODULES = cp
+
+cl_MODULE_SOURCES = cl_mactotei.c brg_rx.c
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/mgr/test/doc/Makefile b/cesar/cp/av/sta/mgr/test/utest/doc/Makefile
index 25c6b6b03d..bc8795eaad 100644
--- a/cesar/cp/sta/mgr/test/doc/Makefile
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/Makefile
@@ -9,12 +9,12 @@ odt: $(ODT)
html: $(HTML)
-%.odt: %.txt
+%.odt: %.txt
rst2odt.py $< $@
%.html: %.txt
rst2html $< $@
-clean:
+clean:
rm -f $(ODT)
rm -f $(HTML)
diff --git a/cesar/cp/sta/mgr/test/doc/net.txt b/cesar/cp/av/sta/mgr/test/utest/doc/net.txt
index 3424c2ba52..fa0017049c 100644
--- a/cesar/cp/sta/mgr/test/doc/net.txt
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/net.txt
@@ -15,7 +15,7 @@ TEI null and a known mac address.
The Station shall be added as unassociated stations and be added in the set of
unassociated stations.
-Their status shall be equal to CP_STA_STATE_EXISTS.
+Their status shall be equal to CP_STA_STATE_EXISTS.
The Mac address shall be set.
Test 2 : Associated STAs
@@ -68,7 +68,7 @@ CCo (TEI = 3 for examples).
At the beginning of the test, the station with the TEI = 3, shall have its
status cco flag setted and the network has its cco pointer corresponding to
-this station.
+this station.
At the end, the station shall not exist in the network and the pointer to the
CCo in the network shall be null.
@@ -82,7 +82,7 @@ PCo (TEI = 3 for examples).
At the beginning of the test, the station with the TEI = 3, shall have its
status pco flag setted and the network has its pco pointer corresponding to
-this station.
+this station.
At the end, the station shall not exist in the network and the pointer to the
PCo in the network shall be null.
@@ -156,7 +156,8 @@ AVLN.
Net configuration
After the initialization of the network the network mode is CSMA-Only.
- At the second modification the network mode shall be setted to coordinated mode.
+ At the second modification the network mode shall be setted to coordinated
+ mode.
Result
The network shall be in CSMA only mode at the first read of the network mode.
diff --git a/cesar/cp/sta/mgr/test/doc/net_list.txt b/cesar/cp/av/sta/mgr/test/utest/doc/net_list.txt
index 758b4754b5..913968df83 100644
--- a/cesar/cp/sta/mgr/test/doc/net_list.txt
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/net_list.txt
@@ -4,7 +4,8 @@ Network list
Initialise
-----------
-Shall initialise all the networks list (index greater than 1, the index 0 corresponds to the station AVLN):
+Shall initialise all the networks list (index greater than 1, the index 0
+corresponds to the station AVLN):
- present flag shall be false.
- snid = 0
- nid = 0
@@ -14,7 +15,8 @@ Shall initialise all the networks list (index greater than 1, the index 0 corres
- associated_stas shall be empty.
- unssociated_stas shall be empty.
-The AVLN with the index 0 (the Stations AVLN) shall be present, i.e. the present flag shall be setted.
+The AVLN with the index 0 (the Stations AVLN) shall be present, i.e. the
+present flag shall be setted.
Uninitialise
------------
@@ -39,7 +41,8 @@ AVLN 2:
- Station 3, TEI = 3, Mac @ = 33.
- Station 4, TEI = 4, Mac @ = 34.
-At the end of this test case, all the station list shall be empty and the CCo, PCo pointer reseted.
+At the end of this test case, all the station list shall be empty and the
+CCo, PCo pointer reseted.
Add an AVLN
@@ -59,7 +62,7 @@ The AVLN returned by the add function shall be in the following state:
- station_avln = false
- cco = null
- pco = null
- - expiration_ntb = CP_NET_EXPIRATION_DELAY (see cp/defs.h)
+ - expiration_ntb = CP_NET_EXPIRATION_DELAY (see cp/defs.h)
- associated_stas = empty (use set_empty function).
- unassociated_stas = empty (use set_empty function).
@@ -93,7 +96,7 @@ Return a flag indicating which SNID is currently in use.
Environment 3 AVLNs with SNID 1, 5, 10.
-At the end of the test the flag shall contain 0x211.
+At the end of the test the flag shall contain 0x211.
Get slot usage
--------------
diff --git a/cesar/cp/sta/mgr/test/doc/sta.txt b/cesar/cp/av/sta/mgr/test/utest/doc/sta.txt
index e711621277..e711621277 100644
--- a/cesar/cp/sta/mgr/test/doc/sta.txt
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/sta.txt
diff --git a/cesar/cp/sta/mgr/test/doc/sta_mgr.txt b/cesar/cp/av/sta/mgr/test/utest/doc/sta_mgr.txt
index 6fcf407725..6fcf407725 100644
--- a/cesar/cp/sta/mgr/test/doc/sta_mgr.txt
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/sta_mgr.txt
diff --git a/cesar/cp/sta/mgr/test/doc/sta_own_data.txt b/cesar/cp/av/sta/mgr/test/utest/doc/sta_own_data.txt
index ab302bcdd0..6f700f137f 100644
--- a/cesar/cp/sta/mgr/test/doc/sta_own_data.txt
+++ b/cesar/cp/av/sta/mgr/test/utest/doc/sta_own_data.txt
@@ -7,7 +7,7 @@ accessors.
Status
------
-Tested : under test.
+Tested : under test.
Initialise
----------
@@ -51,12 +51,12 @@ NPW
Shall set up the NPW in the station own data and request the module MSG to
send a MME to the PLC Driver to store the modification in the flash memory.
-*TODO* : Add the API in the MSG module.
+*TODO* : Add the API in the MSG module.
Result
~~~~~~
-- The NPW is stored correctly in the STA own data.
+- The NPW is stored correctly in the STA own data.
NMK
---
@@ -64,12 +64,12 @@ NMK
Shall set up the NMK in the station own data and request the module MSG to
send a MME to the PLC Driver to store the modification in the flash memory.
-*TODO* : Add the API in the MSG module.
+*TODO* : Add the API in the MSG module.
Result
~~~~~~
-- The NMK is stored correctly in the STA own data.
+- The NMK is stored correctly in the STA own data.
DPW
---
@@ -77,12 +77,12 @@ DPW
Shall set up the DPW in the station own data and request the module MSG to
send a MME to the PLC Driver to store the modification in the flash memory.
-*TODO* : Add the API in the MSG module.
+*TODO* : Add the API in the MSG module.
Result
~~~~~~
-- The DPW is stored correctly in the STA own data.
+- The DPW is stored correctly in the STA own data.
Security level
--------------
@@ -90,7 +90,7 @@ Security level
Shall set the security level of the station and send a message to the PLC
driver to store the SL in the flash memory.
-*TODO* : Add the API in the MSG module.
+*TODO* : Add the API in the MSG module.
Result
~~~~~~
@@ -103,7 +103,7 @@ Was CCo Status
Shall set the was CCo status and send a MME to the PLC driver to store the
station cco status in the flash memory.
-*TODO* : Add the API in the MSG module.
+*TODO* : Add the API in the MSG module.
Result
~~~~~~
diff --git a/cesar/cp/sta/mgr/test/overide/cp/cco/action/inc/context.h b/cesar/cp/av/sta/mgr/test/utest/override/cp/cco/action/inc/context.h
index ca3da3cf61..ca3da3cf61 100644
--- a/cesar/cp/sta/mgr/test/overide/cp/cco/action/inc/context.h
+++ b/cesar/cp/av/sta/mgr/test/utest/override/cp/cco/action/inc/context.h
diff --git a/cesar/cp/sta/mgr/test/overide/cp/inc/context.h b/cesar/cp/av/sta/mgr/test/utest/override/cp/inc/context.h
index f5bfbc4840..f5bfbc4840 100644
--- a/cesar/cp/sta/mgr/test/overide/cp/inc/context.h
+++ b/cesar/cp/av/sta/mgr/test/utest/override/cp/inc/context.h
diff --git a/cesar/cp/sta/mgr/test/overide/cp/sta/core/core.h b/cesar/cp/av/sta/mgr/test/utest/override/cp/sta/core/core.h
index a00e59f744..a00e59f744 100644
--- a/cesar/cp/sta/mgr/test/overide/cp/sta/core/core.h
+++ b/cesar/cp/av/sta/mgr/test/utest/override/cp/sta/core/core.h
diff --git a/cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h b/cesar/cp/av/sta/mgr/test/utest/override/mac/sar/inc/context.h
index 9e7c6f07ca..9e7c6f07ca 100644
--- a/cesar/cp/sta/mgr/test/overide/mac/sar/inc/context.h
+++ b/cesar/cp/av/sta/mgr/test/utest/override/mac/sar/inc/context.h
diff --git a/cesar/cp/sta/mgr/test/src/core_stub.c b/cesar/cp/av/sta/mgr/test/utest/src/core_stub.c
index c2dfaceccb..c2dfaceccb 100644
--- a/cesar/cp/sta/mgr/test/src/core_stub.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/core_stub.c
diff --git a/cesar/cp/sta/mgr/test/src/net_test.c b/cesar/cp/av/sta/mgr/test/utest/src/net_test.c
index 608c7fb2b6..c4ef480f26 100644
--- a/cesar/cp/sta/mgr/test/src/net_test.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/net_test.c
@@ -12,7 +12,7 @@
*
*/
#include "common/std.h"
-#include "cp/sta/mgr/test/test_sta_mgr.h"
+#include "test_sta_mgr.h"
bool
cp_net_station_assoc_less (set_node_t *left, set_node_t *right);
diff --git a/cesar/cp/sta/mgr/test/src/sar_stub.c b/cesar/cp/av/sta/mgr/test/utest/src/sar_stub.c
index 681e8dbdfd..681e8dbdfd 100644
--- a/cesar/cp/sta/mgr/test/src/sar_stub.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/sar_stub.c
diff --git a/cesar/cp/sta/mgr/test/src/sta-test.c b/cesar/cp/av/sta/mgr/test/utest/src/sta-test.c
index d8effc6c7d..d8effc6c7d 100644
--- a/cesar/cp/sta/mgr/test/src/sta-test.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/sta-test.c
diff --git a/cesar/cp/sta/mgr/test/src/sta_mgr.c b/cesar/cp/av/sta/mgr/test/utest/src/sta_mgr.c
index 846c768b28..d3fa8199e6 100644
--- a/cesar/cp/sta/mgr/test/src/sta_mgr.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/sta_mgr.c
@@ -15,6 +15,7 @@
#include "common/std.h"
#include "lib/test.h"
#include "test_sta_mgr.h"
+#include "cp/av/sta/mgr/sta_mgr.h"
void
cp_sta_mgr_elects_sta_partial_ack (cp_t *ctx);
@@ -1568,7 +1569,7 @@ test_case__set_tracking (test_t t)
{
/* No network is present and the debug mode is activated, this
* should assert. */
- cp_sta_mgr_set_tracking (&cp, 0x1, 0x1ll);
+ cp_av_sta_mgr_set_tracking (&cp, 0x1, 0x1ll);
}
dbg_fatal_try_catch (const char *fatal_message)
{
@@ -1579,7 +1580,7 @@ test_case__set_tracking (test_t t)
/* Add an AVLN. */
cp_net_t *net = cp_sta_mgr_add_avln (&cp, 0x10, 0x10ll);
/* Request to track this network. */
- cp_sta_mgr_set_tracking (
+ cp_av_sta_mgr_set_tracking (
&cp, cp_net_get_snid (&cp, net),
cp_net_get_nid (&cp, net));
test_fail_unless (
diff --git a/cesar/cp/sta/mgr/test/src/station_test.c b/cesar/cp/av/sta/mgr/test/utest/src/station_test.c
index 9b90f6c01b..d97cf8a890 100644
--- a/cesar/cp/sta/mgr/test/src/station_test.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/station_test.c
@@ -12,7 +12,7 @@
*
*/
#include "common/std.h"
-#include "cp/sta/mgr/test/test_sta_mgr.h"
+#include "test_sta_mgr.h"
#include "cp/sta/mgr/inc/sta.h"
diff --git a/cesar/cp/sta/mgr/test/src/test_sta_mgr.c b/cesar/cp/av/sta/mgr/test/utest/src/test_sta_mgr.c
index f1b69ff15a..8b25b6746f 100644
--- a/cesar/cp/sta/mgr/test/src/test_sta_mgr.c
+++ b/cesar/cp/av/sta/mgr/test/utest/src/test_sta_mgr.c
@@ -11,7 +11,7 @@
* \ingroup cp_sta_mgr
*/
#include "common/std.h"
-#include "cp/sta/mgr/test/test_sta_mgr.h"
+#include "test_sta_mgr.h"
void
test_sta_mgr_init (cp_t *cp)
diff --git a/cesar/cp/sta/mgr/test/test_sta_mgr.h b/cesar/cp/av/sta/mgr/test/utest/test_sta_mgr.h
index fa00768521..fa00768521 100644
--- a/cesar/cp/sta/mgr/test/test_sta_mgr.h
+++ b/cesar/cp/av/sta/mgr/test/utest/test_sta_mgr.h
diff --git a/cesar/cp/beacon/Config b/cesar/cp/beacon/Config
index 876dd03ed0..f5c3e6782b 100644
--- a/cesar/cp/beacon/Config
+++ b/cesar/cp/beacon/Config
@@ -1,3 +1,3 @@
CONFIG_GPIO_LED_BEACON_TX_RX = n
CONFIG_GPIO_LED_BEACON_TX_RX_GPIO = 0
-CONFIG_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS = 400
+CONFIG_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS = 400
diff --git a/cesar/cp/beacon/Module b/cesar/cp/beacon/Module
index f219a39a70..7a44e2095e 100644
--- a/cesar/cp/beacon/Module
+++ b/cesar/cp/beacon/Module
@@ -1 +1 @@
-SOURCES:= beacon.c beacon_discover.c
+SOURCES:= beacon.c
diff --git a/cesar/cp/beacon/beacon.h b/cesar/cp/beacon/beacon.h
index 15ad36840d..f621248037 100644
--- a/cesar/cp/beacon/beacon.h
+++ b/cesar/cp/beacon/beacon.h
@@ -44,12 +44,6 @@ cp_beacon_init (cp_t *ctx);
void
cp_beacon_uninit (cp_t *ctx);
-/**
- * Generate beacon data when station acts as STA.
- * \param ctx the module context.
- */
-void
-cp_beacon_sta_update_beacon_data (cp_t *ctx);
/**
* Generate beacon data when station acts as CCo.
@@ -80,6 +74,17 @@ void
cp_beacon_get_and_process_beacon (cp_t *ctx);
/**
+ * Process the central beacon received.
+ * \param ctx the module context.
+ * \param beacon the beacon to process.
+ * \param net the network associated with the beacon.
+ * \return the station from the sta_mgr if the beacon has been processed.
+ */
+cp_sta_t *
+cp_beacon_process_beacon_central (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net);
+
+/**
* Process a tracked network using the central beacon or the proxy beacon.
* \param ctx the CP module context.
* \param beacon the beacon received and tracked.
@@ -96,11 +101,8 @@ cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
void
cp_beacon_process_untracked_avln (cp_t *ctx);
-/**
- * Function to call once the beacon has not been received.
- * \param ctx the module context.
- *
- * The beacon timer has expired and this function had been called by the FSM.
+/** Handle the code when the beacon is not received.
+ * \param ctx the module context.
*/
void
cp_beacon_beacon_not_received (cp_t *ctx);
@@ -116,27 +118,6 @@ void
cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now);
/**
- * Handover.
- * \param ctx the CP context.
- * \param tei the TEI of the new CCo on the AVLN.
- *
- * This function will set the handover in progress flag in the central beacon
- * and all beacon produce by this module.
- * It shall set the hccd bentry countdown to a finite value (in a define) to
- * change indicate to all the station in the AVLN, the CCo will change.
- */
-void
-cp_beacon_handover (cp_t *ctx, cp_tei_t tei);
-
-/**
- * Handover in progress flag.
- * \param ctx the CP context.
- * \param flag the handover flag.
- */
-void
-cp_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag);
-
-/**
* Deactivate the Beacon module.
* \param ctx the CP context.
*/
@@ -152,23 +133,6 @@ void
cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid);
/**
- * Inform the module beacon the AVLN will change its hybrid mode.
- * \param ctx the module context.
- * \param hybrid_mode the new hybrid mode.
- */
-void
-cp_beacon_change_hm (cp_t *ctx, uint hybrid_mode);
-
-
-/**
- * Inform the beacon module to start an handover.
- * \param ctx the module context.
- * \param tei the new CCo's TEI.
- */
-void
-cp_beacon_cco_handover (cp_t *ctx, cp_tei_t tei);
-
-/**
* Compute the new date for the beacon timer.
* \param ctx the module context.
* \param cco the cco status of the station.
@@ -211,6 +175,43 @@ cp_beacon_synchronised (cp_t *ctx);
void
cp_beacon_update_tracking (cp_t *ctx, cp_sta_t *sta);
+/**
+ * Update the station in the station manager with the data contained in the
+ * beacon.
+ * \param ctx the module context.
+ * \param beacon_data the beacon data.
+ * \param net the network corresponding to the beacon.
+ * \param mac the station mac address.
+ * return the control plane station.
+ */
+cp_sta_t *
+cp_beacon_update_sta_peer (cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net,
+ mac_t mac);
+
+/**
+ * Call computation function to compute SPOC coefficients.
+ * \param ctx the module context.
+ * \param sync the sync status.
+ * \param fe the frequency error.
+ */
+void
+cp_beacon_clk_sync_call_spoc (cp_t *ctx, bool sync, u32 fe_q30);
+
+/**
+ * Add the allocation of the beacon to the bandwidth manager.
+ * \param ctx the Module context.
+ * \param beacon the beacon received.
+ */
+void
+cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon);
+
+/**
+ * Countdown decrement and process the necessary data.
+ * \param ctx the CP context.
+ */
+void
+cp_beacon_countdowns (cp_t *ctx);
+
END_DECLS
#endif /* cp_beacon_beacon_h */
diff --git a/cesar/cp/beacon/discover.h b/cesar/cp/beacon/discover.h
deleted file mode 100644
index 12e6f56fd8..0000000000
--- a/cesar/cp/beacon/discover.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef cp_beacon_discover_h
-#define cp_beacon_discover_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/beacon/inc/beacon_discover.h
- * \brief Beacon discover process.
- * \ingroup cp_beacon
- *
- * Function to compute the interval between the one no request shall be done.
- * In this max discover period, all the station including the CCo shall send a
- * discover beacon.
- * For the station their are choose by the CCo using the network of its AVLN.
- *
- * \warn At 50Hz only 250 beacon period exists in the interval of Max Discover
- * Period provided by the HP_AV specification which is equal to 10 seconds.
- * 10s / 40e-3s = 250.
- */
-#include "cp/types.h"
-#include "cp/cp.h"
-
-#include "cp/sta/mgr/sta.h"
-#include "cp/beacon/beacon.h"
-
-BEGIN_DECLS
-
-/** Initialise
- * \param ctx the module context.
- */
-void
-cp_beacon_discover_init (cp_t *ctx);
-
-/** Uninitialise
- * \param ctx the module context.
- */
-void
-cp_beacon_discover_uninit (cp_t *ctx);
-
-/**
- * Verify if any request shall be done.
- * \param ctx the module context.
- * \param tei The TEI to request. 0 = The CCo shall send a discover beacon.
- * \return true if a discover bentry shall be added to the beacon, false
- * otherwise.
- *
- */
-bool
-cp_beacon_discover_need_to_request (cp_t *ctx, cp_tei_t * tei);
-
-
-END_DECLS
-
-#endif /* cp_beacon_discover_h */
diff --git a/cesar/cp/beacon/inc/beacon.h b/cesar/cp/beacon/inc/beacon.h
index 58a098b849..92ccf008ab 100644
--- a/cesar/cp/beacon/inc/beacon.h
+++ b/cesar/cp/beacon/inc/beacon.h
@@ -20,6 +20,7 @@
#include "cp/sta/mgr/net.h"
#include "cp/beacon/defs.h"
#include "bsu/beacon/defs.h"
+#include "cp/inc/variant.h"
/* Countdown on 5 beacon periods. */
#define CP_BEACON_COUNTDOWN_DEFAULT 5
@@ -166,4 +167,45 @@ struct cp_beacon_t
bool spoc_updated;
};
+BEGIN_DECLS
+
+/**
+ * Process beacons.
+ * \param ctx the module context.
+ * \param beacon the beacon to process.
+ */
+void
+cp_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon);
+
+/**
+ * Inform the module beacon the AVLN will change its hybrid mode.
+ * \param ctx the module context.
+ * \param hybrid_mode the new hybrid mode.
+ */
+#define cp_beacon_change_hm CP_VARIANT_FUNCTION (beacon_change_hm)
+void
+cp_beacon_change_hm (cp_t *ctx, uint hybrid_mode);
+
+/**
+ * Handles the discovery procedure for the beacon data
+ * \param ctx the module context.
+ * \param beacon the bsu_beacon_t structure to fill the discover bentry and
+ * the discover info beacon entry.
+ */
+#define cp_beacon_fill_discovery_bentries \
+ CP_VARIANT_FUNCTION (beacon_fill_discovery_bentries)
+void
+cp_beacon_fill_discovery_bentries (cp_t *ctx, bsu_beacon_t *beacon);
+
+/**
+ * Fill the discover info beacon entry.
+ * \param ctx the module context.
+ * \param beacon the beacon to fill.
+ */
+void
+cp_beacon_fill_discover_info (cp_t *ctx,
+ bsu_beacon_bmi_discover_info_t *discover);
+
+END_DECLS
+
#endif /* cp_beacon_inc_beacon_h */
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 4e636e1937..b51be0b8d1 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -15,6 +15,7 @@
* - Create the central beacon.
* - Get the discover info from the others stations.
*/
+/* Public headers. */
#include "common/std.h"
#include "lib/fixed.h"
#include "lib/slist.h"
@@ -28,13 +29,14 @@
#include "cp/cco/bw/bw.h"
#include "mac/common/timings.h"
#include "mac/common/ntb.h"
-#include "cp/beacon/inc/beacon.h"
-#include "cp/beacon/discover.h"
-#include "cp/inc/context.h"
-#include "cp/inc/trace.h"
#include "hal/gpio/gpio.h"
#include "bsu/beacon/beacon.h"
#include "bsu/bsu.h"
+/* Private headers. */
+#include "cp/beacon/inc/beacon.h"
+#include "cp/inc/context.h"
+#include "cp/inc/trace.h"
+/* Config headers. */
#include "config/beacon.h"
/** Default interval between SPOC updates. */
@@ -49,18 +51,13 @@ cp_beacon_timer_expires (cp_t *ctx)
{
dbg_assert (ctx);
- // Post an event in the FSM beacon timer expires.
+ /* Post an event in the FSM beacon timer expires. */
cp_fsm_post_urgent_new_event (ctx, bare, BEACON_TIMER_EXPIRES);
}
-/**
- * Fill the discover info beacon entry.
- * \param ctx the module context.
- * \param beacon the beacon to fill.
- */
-static void
-cp_beacon_fill_discover_info (cp_t *ctx,
- bsu_beacon_bmi_discover_info_t *discover)
+void
+cp_beacon_fill_discover_info (
+ cp_t *ctx, bsu_beacon_bmi_discover_info_t *discover)
{
cp_sta_own_data_t *sta = cp_sta_mgr_get_sta_own_data (ctx);
bitstream_t stream;
@@ -87,13 +84,14 @@ cp_beacon_fill_discover_info (cp_t *ctx,
discover->present = true;
}
-static void
-cp_beacon_clk_sync_call_spoc (cp_t *ctx, bool sync, u32 fe)
+
+void
+cp_beacon_clk_sync_call_spoc (cp_t *ctx, bool sync, u32 fe_q30)
{
dbg_assert (ctx);
phy_spoc_coeff_t *coeff = blk_alloc ();
coeff->part2 = blk_alloc();
- phy_spoc_compute_all (fe, coeff);
+ phy_spoc_compute_all (fe_q30, coeff);
pbproc_spoc_coeff_set (ctx->pbproc, sync, coeff);
}
@@ -128,11 +126,12 @@ cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon)
/* regions. */
cp_cco_region_alloc_t *region;
- for (nb = 0, region = cp_cco_region_alloc_get_first (ctx,
- &ctx->region.region_list);
+ for (nb = 0,
+ region = cp_cco_region_alloc_get_first (
+ ctx, &ctx->region.region_list);
region;
- region = cp_cco_region_alloc_get_next (ctx,
- &ctx->region.region_list, region),
+ region = cp_cco_region_alloc_get_next (
+ ctx, &ctx->region.region_list, region),
nb++)
{
beacon->bmis.region.region[nb].rt = region->type;
@@ -146,11 +145,11 @@ cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon)
for (nb = 0; nb < 8; nb++)
{
- for (ns = 0, sched = cp_cco_bw_alloc_get_first_persistent (ctx,
- &ctx->bw.alloc_list, nb);
+ for (ns = 0, sched = cp_cco_bw_alloc_get_first_persistent (
+ ctx, &ctx->bw.alloc_list, nb);
sched;
- sched = cp_cco_bw_alloc_get_next_persistent (ctx,
- &ctx->bw.alloc_list, sched),
+ sched = cp_cco_bw_alloc_get_next_persistent (
+ ctx, &ctx->bw.alloc_list, sched),
ns++)
{
dbg_assert (sched_id < BSU_BEACON_BMI_PERSISTENT_SCHEDULE_MAX);
@@ -178,12 +177,12 @@ cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon)
beacon->bmis.ps.nb = sched_id;
/* Store the not persistent schedules. */
- for (ns = 0, sched = cp_cco_bw_alloc_get_first_with_persistence (ctx,
- &ctx->bw.alloc_list,
+ for (ns = 0, sched = cp_cco_bw_alloc_get_first_with_persistence (
+ ctx, &ctx->bw.alloc_list,
CP_CCO_BW_ALLOC_PERSISTENCE_NOT_PERSISTENT);
sched;
- sched = cp_cco_bw_alloc_get_next_with_persistence (ctx,
- &ctx->bw.alloc_list, sched),
+ sched = cp_cco_bw_alloc_get_next_with_persistence (
+ ctx, &ctx->bw.alloc_list, sched),
ns++)
{
dbg_assert (ns < BSU_BEACON_BMIS_SCHEDULES_SAI_MAX);
@@ -194,17 +193,7 @@ cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon)
}
beacon->bmis.nps.ns = ns;
- uint tei;
- if (cp_sta_own_data_get_cco_status (ctx)
- && cp_beacon_discover_need_to_request (ctx, &tei))
- {
- beacon->bmis.discover.present = true;
- beacon->bmis.discover.tei = tei;
- }
- else
- beacon->bmis.discover.present = false;
-
- cp_beacon_fill_discover_info (ctx, &beacon->bmis.discover_info);
+ cp_beacon_fill_discovery_bentries (ctx, beacon);
/* If the EKS countdown is not 0. */
if (ctx->beacon.eks.kccd)
@@ -287,8 +276,7 @@ cp_beacon_receive (void *ul, bsu_beacon_t *beacon)
/**
* Set the sai in the schedule.
*/
-static inline
-void
+static inline void
cp_beacon_set_sai_in_sched (cp_cco_bw_alloc_t *sched, bsu_beacon_sai_t* sai)
{
sched->end_time_atu = sai->end_time_atu;
@@ -296,11 +284,6 @@ cp_beacon_set_sai_in_sched (cp_cco_bw_alloc_t *sched, bsu_beacon_sai_t* sai)
sched->stpf = sai->stpf;
}
-/**
- * Add the allocation of the beacon to the bandwidth manager.
- * \param ctx the Module context.
- * \param beacon the beacon received.
- */
void
cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon)
{
@@ -369,16 +352,7 @@ cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon)
cp_cco_region_allocation_list_swap (ctx, &set_regions);
}
-/**
- * Update the station in the station manager with the data contained in the
- * beacon.
- * \param ctx the module context.
- * \param beacon_data the beacon data.
- * \param net the network corresponding to the beacon.
- * \param mac the station mac address.
- * return the control plane station.
- */
-static cp_sta_t *
+cp_sta_t *
cp_beacon_update_sta_peer (cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net,
mac_t mac)
{
@@ -416,11 +390,7 @@ cp_beacon_update_sta_peer (cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net,
return sta;
}
-/**
- * Countdown decrement and process the necessary data.
- * \param ctx the CP context.
- */
-PRIVATE void
+void
cp_beacon_countdowns (cp_t *ctx)
{
dbg_assert (ctx);
@@ -525,9 +495,9 @@ cp_beacon_init (cp_t *ctx)
memset (&ctx->beacon, 0, sizeof (cp_beacon_t));
slist_init (ctx->beacon.list., bare);
// Initialise the instance of the leon timer.
- hal_timer_instance_init (ctx->hal_timer, &ctx->beacon.leon_timer,
- ctx,
- (hal_timer_instance_cb_t)cp_beacon_timer_expires);
+ hal_timer_instance_init (
+ ctx->hal_timer, &ctx->beacon.leon_timer, ctx,
+ (hal_timer_instance_cb_t) cp_beacon_timer_expires);
/* Setup beacon indicator. */
GPIO_SETUP (LED_BEACON_TX_RX, GPIO_DIRECTION_OUT);
GPIO_SET (LED_BEACON_TX_RX, 0);
@@ -554,23 +524,6 @@ cp_beacon_uninit (cp_t *ctx)
hal_timer_instance_uninit (ctx->hal_timer, &ctx->beacon.leon_timer);
}
-/**
- * Prepare the beacon and reconfigure the timer of the beacon module.
- * \param ctx the module context.
- * \param beacon the bsu_beacon_t structure to fill.
- * \param cco the cco status.
- */
-static void
-cp_beacon_update_beacon_data (cp_t *ctx, bsu_beacon_t *beacon, bool cco)
-{
- cp_beacon_countdowns (ctx);
- /** Generate the beacon and send. */
- cp_beacon_fill (ctx, beacon);
- /** Program the timer to awake and send another central beacon. */
- cp_beacon_reconfigure_timer (ctx, cco);
- GPIO_TOGGLE (LED_BEACON_TX_RX);
-}
-
void
cp_beacon_cco_update_beacon_data (cp_t *ctx)
{
@@ -604,13 +557,36 @@ cp_beacon_poweron_init (cp_t *ctx)
}
/**
- * Process the central beacon received.
- * \param ctx the module context.
- * \param beacon the beacon to process.
- * \param net the network associated with the beacon.
- * \return the station from the sta_mgr if the beacon has been processed.
+ * Process the first beacon in the received list.
+ * \param ctx the control plane context.
*/
-static cp_sta_t*
+void
+cp_beacon_get_and_process_beacon (cp_t *ctx)
+{
+ dbg_assert (ctx);
+ bsu_beacon_t *beacon;
+ /** check the countdowns. */
+ cp_beacon_countdowns (ctx);
+ /* While beacon list is not empty and like beacons are urgent, it process
+ * all the beacons received. */
+ while (ctx->beacon.list.head)
+ {
+ arch_dsr_lock ();
+ beacon = slist_pop_front (ctx->beacon.list., bare);
+ arch_dsr_unlock ();
+ /** Beacon received ok. */
+ GPIO_TOGGLE (LED_BEACON_TX_RX);
+ CP_TRACE_VERBOSE (
+ BEACON_BEACON_PROCESS, phy_date(), beacon->vf.nid,
+ beacon->params.rx_parameters.snid, beacon->vf.stei,
+ beacon->vf.bt, beacon->params.rx_parameters.bts);
+ cp_beacon_process_beacon (ctx, beacon);
+ /** Release the beacon. */
+ blk_release (beacon);
+ }
+}
+
+cp_sta_t*
cp_beacon_process_beacon_central (
cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net)
{
@@ -684,9 +660,12 @@ cp_beacon_process_beacon_central (
}
/** Update the schedules. */
cp_beacon_sta_compute_schedules (ctx, beacon);
- bsu_beacon_bmi_discover_info_t discover;
- cp_beacon_fill_discover_info (ctx, &discover);
- bsu_update_discover_info (ctx->bsu, &discover);
+ if (CONFIG_CP_AV)
+ {
+ bsu_beacon_bmi_discover_info_t discover;
+ cp_beacon_fill_discover_info (ctx, &discover);
+ bsu_update_discover_info (ctx->bsu, &discover);
+ }
/** Program the timer. */
cp_beacon_reconfigure_timer (ctx, false);
}
@@ -763,12 +742,7 @@ cp_beacon_process_beacon_discover (
return sta;
}
-/**
- * Process beacons.
- * \param ctx the module context.
- * \param beacon the beacon to process.
- */
-static void
+void
cp_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon)
{
/** Add network and station info to local data. */
@@ -817,36 +791,6 @@ cp_beacon_process_beacon (cp_t *ctx, bsu_beacon_t *beacon)
}
}
-/**
- * Process the first beacon in the received list.
- * \param ctx the control plane context.
- */
-void
-cp_beacon_get_and_process_beacon (cp_t *ctx)
-{
- dbg_assert (ctx);
- bsu_beacon_t *beacon;
- /** check the countdowns. */
- cp_beacon_countdowns (ctx);
- /* While beacon list is not empty and like beacons are urgent, it process
- * all the beacons received. */
- while (ctx->beacon.list.head)
- {
- arch_dsr_lock ();
- beacon = slist_pop_front (ctx->beacon.list., bare);
- arch_dsr_unlock ();
- /** Beacon received ok. */
- GPIO_TOGGLE (LED_BEACON_TX_RX);
- CP_TRACE_VERBOSE (
- BEACON_BEACON_PROCESS, phy_date(), beacon->vf.nid,
- beacon->params.rx_parameters.snid, beacon->vf.stei,
- beacon->vf.bt, beacon->params.rx_parameters.bts);
- cp_beacon_process_beacon (ctx, beacon);
- /** Release the beacon. */
- blk_release (beacon);
- }
-}
-
void
cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net)
@@ -891,12 +835,6 @@ cp_beacon_process_untracked_avln (cp_t *ctx)
bsu_untrack_avln (ctx->bsu);
}
-/**
- * Function to call once the beacon has not been received.
- * \param ctx the module context.
- *
- * The beacon timer has expired and this function had been called by the FSM.
- */
void
cp_beacon_beacon_not_received (cp_t *ctx)
{
@@ -983,40 +921,6 @@ cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid)
}
void
-cp_beacon_change_hm (cp_t *ctx, uint hybrid_mode)
-{
- dbg_assert (ctx);
- dbg_assert (cp_sta_own_data_get_cco_status (ctx));
-
- if (!ctx->beacon.hm.hmcd)
- {
- ctx->beacon.hm.hm = hybrid_mode;
- ctx->beacon.hm.hmcd = CP_BEACON_COUNTDOWN_HM;
- }
-}
-
-void
-cp_beacon_handover (cp_t *ctx, cp_tei_t cco)
-{
- dbg_assert (ctx);
-
- if (!ctx->beacon.hoip.hoipcd)
- {
- ctx->beacon.hoip.cco = cco;
- ctx->beacon.hoip.hoipcd = CP_BEACON_COUNTDOWN_HOIP;
- }
-}
-
-void
-cp_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag)
-{
- dbg_assert (ctx);
- dbg_assert (flag < CP_BEACON_HOIP_MAX);
-
- ctx->beacon.hoip.hoip_flag = flag;
-}
-
-void
cp_beacon_reconfigure_timer (cp_t *ctx, bool cco)
{
dbg_assert (ctx);
@@ -1024,11 +928,12 @@ cp_beacon_reconfigure_timer (cp_t *ctx, bool cco)
u32 date;
if (cco)
- date = bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf) +
- bsu_aclf_beacon_period_tck (ctx->bsu_aclf) - CP_TIMER_OFFSET_CCO;
+ date = bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf)
+ + bsu_aclf_beacon_period_tck (ctx->bsu_aclf)
+ - CP_TIMER_OFFSET_CCO;
else
- date = bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf) +
- CP_TIMER_OFFSET_STA;
+ date = bsu_aclf_beacon_period_start_date_next (ctx->bsu_aclf)
+ + CP_TIMER_OFFSET_STA;
// Program the timer.
hal_timer_instance_cancel (ctx->hal_timer, &ctx->beacon.leon_timer);
diff --git a/cesar/cp/beacon/stub/src/beacon.c b/cesar/cp/beacon/stub/src/beacon.c
index 3efff69577..f73720b875 100644
--- a/cesar/cp/beacon/stub/src/beacon.c
+++ b/cesar/cp/beacon/stub/src/beacon.c
@@ -19,134 +19,123 @@
void
cp_beacon_init (cp_t *ctx) __attribute__((weak));
-
void
-cp_beacon_init (cp_t *ctx){}
+cp_beacon_init (cp_t *ctx) {}
void
cp_beacon_uninit (cp_t *ctx) __attribute__((weak));
-
void
-cp_beacon_uninit (cp_t *ctx){}
+cp_beacon_uninit (cp_t *ctx) {}
void
-cp_beacon_create_default_schedules (cp_t *ctx) __attribute__((weak));
-
+cp_beacon_cco_update_beacon_data (cp_t *ctx) __attribute__((weak));
void
-cp_beacon_create_default_schedules (cp_t *ctx){}
+cp_beacon_cco_update_beacon_data (cp_t *ctx) {}
void
-cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid) __attribute__((weak));
+cp_beacon_poweron_init (cp_t *ctx) __attribute__((weak));
+void
+cp_beacon_poweron_init (cp_t *ctx) {}
void
-cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid){}
+cp_beacon_create_default_schedules (cp_t *ctx) __attribute__((weak));
+void
+cp_beacon_create_default_schedules (cp_t *ctx) {}
void
cp_beacon_get_and_process_beacon (cp_t *ctx) __attribute__((weak));
-
void
-cp_beacon_get_and_process_beacon (cp_t *ctx){}
+cp_beacon_get_and_process_beacon (cp_t *ctx) {}
+
+cp_sta_t *
+cp_beacon_process_beacon_central (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net) __attribute__((weak));
+cp_sta_t *
+cp_beacon_process_beacon_central (
+ cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net)
+{ return NULL; }
void
cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
cp_net_t *net) __attribute__((weak));
-
void
cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net){}
+ cp_net_t *net) {}
void
cp_beacon_process_untracked_avln (cp_t *ctx) __attribute__((weak));
-
void
-cp_beacon_process_untracked_avln (cp_t *ctx){}
+cp_beacon_process_untracked_avln (cp_t *ctx) {}
void
cp_beacon_beacon_not_received (cp_t *ctx) __attribute__((weak));
-
void
-cp_beacon_beacon_not_received (cp_t *ctx){}
+cp_beacon_beacon_not_received (cp_t *ctx) {}
void
-cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now) __attribute__((weak));
-
+cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now)
+ __attribute__((weak));
void
cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now) {}
void
-cp_beacon__cco__handover (cp_t *ctx, cp_tei_t tei) __attribute__((weak));
-
+cp_beacon_deactivate (cp_t *ctx) __attribute__((weak));
void
-cp_beacon__cco__handover (cp_t *ctx, cp_tei_t tei) {}
+cp_beacon_deactivate (cp_t *ctx) {}
void
-cp_beacon_discover_sta_removed (cp_t *ctx, cp_sta_t *sta) __attribute__ ((weak));
-
-void
-cp_beacon_discover_sta_removed (cp_t *ctx, cp_sta_t *sta){}
-
-void
-cp_beacon_handover (cp_t *ctx, cp_tei_t tei) __attribute__ ((weak));
-
+cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid) __attribute__((weak));
void
-cp_beacon_handover (cp_t *ctx, cp_tei_t tei) {}
+cp_beacon_change_snid (cp_t *ctx, cp_snid_t snid) {}
void
cp_beacon_reconfigure_timer (cp_t *ctx, bool cco) __attribute__((weak));
-
void
cp_beacon_reconfigure_timer (cp_t *ctx, bool cco) {}
bool
cp_beacon_any_countdown_active (cp_t *ctx) __attribute__((weak));
-
bool
cp_beacon_any_countdown_active (cp_t *ctx)
-{
- return false;
-}
-
-
-void
-cp_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag) __attribute__((weak));
-
-void
-cp_beacon_handover_hoipflag (cp_t *ctx, enum cp_beacon_hoip_e flag) {}
+{ return false; }
void
-cp_beacon_cco_update_beacon_data (cp_t *ctx) __attribute__((weak));
-
+cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon) __attribute__ ((weak));
void
-cp_beacon_cco_update_beacon_data (cp_t *ctx) {}
+cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon) {}
-void
-cp_beacon_sta_update_beacon_data (cp_t *ctx) __attribute__((weak));
+bool
+cp_beacon_synchronised (cp_t *ctx) __attribute__ ((weak));
+bool
+cp_beacon_synchronised (cp_t *ctx)
+{ return true; }
void
-cp_beacon_sta_update_beacon_data (cp_t *ctx) {}
-
+cp_beacon_update_tracking (cp_t *ctx, cp_sta_t *sta) __attribute__ ((weak));
void
-cp_beacon_discover_init (cp_t *ctx) __attribute__ ((weak));
+cp_beacon_update_tracking (cp_t *ctx, cp_sta_t *sta) {}
-void
-cp_beacon_discover_init (cp_t *ctx) {};
+cp_sta_t *
+cp_beacon_update_sta_peer (cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net,
+ mac_t mac) __attribute__ ((weak));
+cp_sta_t *
+cp_beacon_update_sta_peer (cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net,
+ mac_t mac)
+{ return NULL; }
void
-cp_beacon_discover_uninit (cp_t *ctx) __attribute__ ((weak));
-
+cp_beacon_clk_sync_call_spoc (cp_t *ctx, bool sync, u32 fe_q30)
+ __attribute__ ((weak));
void
-cp_beacon_discover_uninit (cp_t *ctx) {};
+cp_beacon_clk_sync_call_spoc (cp_t *ctx, bool sync, u32 fe_q30) {}
void
-cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon) __attribute__ ((weak));
-
+cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon)
+ __attribute__ ((weak));
void
-cp_beacon_fill (cp_t *ctx, bsu_beacon_t *beacon) { };
+cp_beacon_sta_compute_schedules (cp_t *ctx, bsu_beacon_t *beacon) {}
void
-cp_beacon_update_tracking (cp_t *ctx, cp_sta_t *sta)
- __attribute__ ((weak));
-
+cp_beacon_countdowns (cp_t *ctx) __attribute__ ((weak));
void
-cp_beacon_update_tracking (cp_t *ctx, cp_sta_t *sta)
-{ }
+cp_beacon_countdowns (cp_t *ctx) {}
diff --git a/cesar/cp/beacon/test/Makefile b/cesar/cp/beacon/test/Makefile
deleted file mode 100644
index 835aa57bf0..0000000000
--- a/cesar/cp/beacon/test/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:
- make -f Makefile-scenario
- make -f Makefile-ecos
-
-clean:
- make clean -f Makefile-scenario
- make clean -f Makefile-ecos
diff --git a/cesar/cp/beacon/test/Makefile-ecos b/cesar/cp/beacon/test/Makefile-ecos
deleted file mode 100644
index a3c1c2a9bb..0000000000
--- a/cesar/cp/beacon/test/Makefile-ecos
+++ /dev/null
@@ -1,28 +0,0 @@
-BASE = ../../..
-
-INCLUDES = cp/beacon/test/override
-
-ECOS = y
-
-TARGET_PROGRAMS = beacon discover_process
-
-beacon_SOURCES = beacon.c \
- ca_stub.c secu_stub.c bsu_stub.c phy_stub.c
-beacon_MODULES = bsu/beacon lib cp/beacon cp/sta/mgr mac/common cp/cco/bw \
- cp/cco/region \
- cp/fsm/stub cp/cco/action/stub hal/timer/stub \
- cp/sta/core/stub mac/sar/stub cl/stub \
- interface/stub bsu/stub cp/msg/stub
-
-discover_process_SOURCES = discover.c \
- ca_stub.c secu_stub.c bsu_stub.c phy_stub.c
-discover_process_MODULES = lib cp/beacon mac/common cp/sta/mgr \
- bsu/beacon cp/cco/region \
- cp/fsm/stub cp/cco/action/stub hal/timer/stub \
- cp/sta/core/stub mac/sar/stub cl/stub cp/cco/bw \
- interface/stub bsu/stub cp/msg/stub
-
-mac_common_MODULE_SOURCES = config.c mfs.c store.c tonemap.c tonemask.c sta.c \
- interval.c
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/Makefile-scenario b/cesar/cp/beacon/test/Makefile-scenario
deleted file mode 100644
index 7712089ade..0000000000
--- a/cesar/cp/beacon/test/Makefile-scenario
+++ /dev/null
@@ -1,17 +0,0 @@
-BASE = ../../..
-
-INCLUDES = cp/beacon/test/override-scenario cp/beacon/test
-
-HOST_PROGRAMS = beacon_scenario
-
-beacon_scenario_SOURCES = beacon_scenario.c scenario_actions.c \
- bsu_stub_scenario.c bsu_beacon_stub.c fsm_stub.c \
- phy_stub.c secu_stub.c sta_mgr_stub.c
-
-beacon_scenario_MODULES = lib lib/scenario cp/fsm/stub cp/beacon \
- cp/cco/region/stub cp/cco/bw/stub interface/stub \
- bsu/stub cp/msg/stub cp/sta/core/stub \
- hal/timer/stub mac/sar/stub cl/stub \
- cp/cco/action/stub mac/common bsu/stub
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/doc/Makefile b/cesar/cp/beacon/test/doc/Makefile
deleted file mode 100644
index 03f14d7cb9..0000000000
--- a/cesar/cp/beacon/test/doc/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-PAGES= beacon.txt bentry.txt send-beacon.txt recv-beacon.txt default-schedules.txt beacon-discover.txt
-
-ODT=$(PAGES:%.txt=%.odt)
-HTML=$(PAGES:%.txt=%.html)
-
-all: $(ODT) $(HTML)
-
-odt: $(ODT)
-
-html: $(HTML)
-
-%.odt: %.txt
- rst2odt.py $< $@
-
-%.html: %.txt
- rst2html $< $@
-
-clean:
- rm -f $(ODT)
- rm -f $(HTML)
diff --git a/cesar/cp/beacon/test/doc/beacon-discover.txt b/cesar/cp/beacon/test/doc/beacon-discover.txt
deleted file mode 100644
index fef6fa13a3..0000000000
--- a/cesar/cp/beacon/test/doc/beacon-discover.txt
+++ /dev/null
@@ -1,129 +0,0 @@
-Beacon Discover
-===============
-
-Init
-----
-
-Shall initialise and add all parameters to 0
-
-Compute interval
-----------------
-
-Test 1 : AC Line 50 Hz
-~~~~~~~~~~~~~~~~~~~~~~
-
-Environment
-
-* Initialise the PWL module to correspond to an ACL frequency equal to 50 Hz.
-* Add 3 stations authenticated in the AVLN with TEI 1, 2 and 3.
-
-Result
- The value computed shall be 250 / 4 = 62.
-
-Test 2 : AC Line 60 Hz
-~~~~~~~~~~~~~~~~~~~~~~
-
-Environment
-
-* Initialise the PWL module to correspond to an ACL frequency equal to 50 Hz.
-* Add 3 stations authenticated in the AVLN with TEI 1, 2 and 3.
-
-Result
- The value computed shall be 300 / 4 = 75.
-
-Need to request
----------------
-
-This test shall verify the algorithm.
-
-Test 1 : Stable system
-~~~~~~~~~~~~~~~~~~~~~~
-
-This test is done with three stations in the station manager and it will not be modified.
-The objective is to verify the countdown and the TEI returned by the function.
-
-Environment
-
-* AC Line at 50 Hz.
-
-* Station own data
-
- * is cco = true
- * TEI = 1
-
-* Station 1, TEI = 2
-* Station 2, TEI = 3
-* Station 3, TEI = 4
-
-Result
-
-* First shot
-
- * The first shoot will return true, with TEI == 1.
- * Countdown shall be equal to 62 beacon periods.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-* Second shot
-
- * shall return false.
- * Countdown shall be equal to 61 beacon periods.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-* Countdown reach 0
-
- * Shall return true, with TEI == 1 indicate that the CCo shall send a discover beacon.
- * Countdown shall be equal to 62.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-* Countdown reach 0 again
-
- * Shall return true, with TEI == 2.
- * Countdown shall be equal to 62.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-Test 2 : Variable system (Add or remove STAs)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-This test is done with three stations in the station manager and ends with 5.
-The objective is to verify the countdown and the TEI returned by the function.
-
-Environment
-
-* AC Line at 50 Hz.
-
-* Station own data
-
- * is cco = true
- * TEI = 1
-
-* Station 1, TEI = 2
-* Station 2, TEI = 3
-* Station 3, TEI = 4
-* and so on...
-
-Result
-
-* First shot : only 3 stations.
-
- * The first shoot will return false.
- * Countdown shall be equal to 62 beacon periods.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-* Second shot : 5 stations
-
- * shall return false.
- * Countdown shall be equal to 40 beacon periods.
- * The previous disc interval bp = 62
- * The discover interval bp = 39
-
-* Countdown reach 0
-
- * Shall return true, with TEI == 1.
- * Countdown shall be equal to 41.
- * The previous disc interval bp shall be equal to the discover interval bp.
-
-* Countdown reach 0 again
-
- * Shall return true, with TEI == 2.
- * Countdown shall be equal to 41.
- * The previous disc interval bp shall be equal to the discover interval bp.
diff --git a/cesar/cp/beacon/test/doc/beacon.txt b/cesar/cp/beacon/test/doc/beacon.txt
deleted file mode 100644
index fc75e07877..0000000000
--- a/cesar/cp/beacon/test/doc/beacon.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Beacon test
-===========
-
-Initialise
-----------
-
-At the end of this test, all the variables present in the beacon context shall
-be equal to zero or null for the pointers.
-The hal_timer shall be initialised and the eCos alarm too.
-
-Uninitialise
-------------
-
-The uninit procedure, shall stop the timers and release all the object
-referenced by the beacon module.
-
- * Stop the HAL timer
- * Stop the eCos timer
- * Release all beacon received and not processed yet.
- * Call the uninit function for the common sub context.
-
-Environment
- This test shall insert some data in the pointers and the context.
-
- 1. Add at least two beacon in the received list.
- 2. Add a central beacon in the central sub context.
- 3. Add a discover beacon in the discover sub context.
- 4. Add a proxy beacon in the discover sub context.
-
-Result
- At the end the beacon module shall not have any referenced on any object.
- The memory leak test shall be positive i.e. no memory leaks.
-
-Init event call back
---------------------
-
-Environment
- call this function with user data context and a function.
-
-Result
- The envent_cb of the beacon module and the event_user_data shall correspond to the parameter provided.
-
diff --git a/cesar/cp/beacon/test/doc/bentry.txt b/cesar/cp/beacon/test/doc/bentry.txt
deleted file mode 100644
index 625fe023b7..0000000000
--- a/cesar/cp/beacon/test/doc/bentry.txt
+++ /dev/null
@@ -1,159 +0,0 @@
-Bentry
-======
-
-Test the bentry sub module.
-
-init
-----
-
-The init function shall set all the context to 0.
-
-Process Header
---------------
-
-Read
- Shall read the header of the bentry and the length of the bentry. It shall return the address of the payload.
-
-Write
- Shall write the header and the length of the bentry provided in parameters. It shall return the address to write the next bentry.
-
-Mgr Beacon
-----------
-
-Shall write the data necessary to the beacon.
-
-Region
-~~~~~~
-
-Read
-""""
-
-Environment
- Initialise the region manager, the stubbed function will return two regions.
-
-Result
- The result only consists to provide the address of the next bentry.
-
-Write
-"""""
-
-Environment
- Initialise the region manager, the stubbed function will return two regions:
-
-+-------------+----------+
-| Region Type | End time |
-+-------------+----------+
-| Beacon | 52 |
-+-------------+----------+
-| CSMA | 3905 |
-+-------------+----------+
-
-Result
- The address return shall be : 1 byte + 2 * 2 bytes.
-
- 1 byte for the Number of region.
-
- 2 bytes per region definition.
-
- The buffer shall contain the following data:
-
-+--------------+-------+-------------------------------+
-| Buffer index | Value | Type |
-+--------------+-------+-------------------------------+
-| 0 | 0x2 | Number of region |
-+--------------+-------+-------------------------------+
-| 1 | 0x40 | Beacon region |
-+--------------+-------+-------------------------------+
-| 2 | 0x03 | 52 * 10.24 us |
-+--------------+-------+-------------------------------+
-| 3 | 0x14 | CSMA + first byte of end time |
-+--------------+-------+-------------------------------+
-| 4 | 0xF4 | end of the end time region |
-+--------------+-------+-------------------------------+
-
-Persistent schedules
-~~~~~~~~~~~~~~~~~~~~
-
-Environment
- Request some allocation from the bandwidth manager and store it in the beacon payload.
-
-+--------+-------+------+------+------+
-| Number | STPF | GLID | ST | ET |
-+--------+-------+------+------+------+
-| 1 | true | 1 | 0 | 10 |
-+--------+-------+------+------+------+
-| 2 | false | 2 | | 50 |
-+--------+-------+------+------+------+
-| 3 | true | 3 | 1500 | 3000 |
-+--------+-------+------+------+------+
-
-Result
- At the end in the beacon payload it shall have 3 sessions of persistent schedules corresponding to the values indicated in the table above.
-
-Non Persistent schedules
-~~~~~~~~~~~~~~~~~~~~~~~~
-
-Write
-"""""
-
-Environment
- Request some allocation from the bandwidth manager and store it in the beacon payload.
-
-+--------+-------+------+------+------+
-| Number | STPF | GLID | ST | ET |
-+--------+-------+------+------+------+
-| 1 | true | 4 | 50 | 750 |
-+--------+-------+------+------+------+
-| 2 | false | 5 | | 850 |
-+--------+-------+------+------+------+
-| 3 | true | 6 | 900 | 1500 |
-+--------+-------+------+------+------+
-
-Result
- At the end in the beacon payload it shall have 3 sessions of non persistent schedules corresponding to the values indicated in the table above.
-
-Mac address
-~~~~~~~~~~~
-
-Read
-""""
-
-Store a mac address in with the bitstream in the buffer, and launch the
-function to read the mac address.
-
-Environment
- Mac address used : 12:32:56:78:9A:BC
-
-Result
- The buffer shall contain the mac address starting at the index 2.
-
-Write
-"""""
-
-Reads a mac address from the buffer.
-
-Environment
- Mac address used (and stored in the buffer) : 23:45:67:89:AB:CD
-
-Result
- The mac address read shall correspond to the mac address used.
-
-Discover bentry
-~~~~~~~~~~~~~~~
-
-Read
-""""
-
-Read a discover bentry.
-This shall read the TEI contained in the discover bentry.
-
-Write
-"""""
-
-Stores the TEI in the bentry.
-
-Discover info bentry
-~~~~~~~~~~~~~~~~~~~~
-
-Stores the element of the structure or read the bentry data and store it in
-the structure.
diff --git a/cesar/cp/beacon/test/doc/default-schedules.txt b/cesar/cp/beacon/test/doc/default-schedules.txt
deleted file mode 100644
index 4b76e6ef9f..0000000000
--- a/cesar/cp/beacon/test/doc/default-schedules.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-Default Schedules
-=================
-
-The default schedules in the beacon are used only when the station is
-considered as USTA and is in the Power and detect procedure.
-
-The test shall only verify that the schedules programmed in the CA are set and
-if the timer is programmed to post an event in the FSM before the default
-schedules expires.
-
-Test 1 : Station acting as USTA.
---------------------------------
-
-When the station is acting as unassociated station the default schedules are
-used until a decision to track an AVLN is taken, once this is done, it shall
-use the schedules contained in the central or proxy beacon of this ALVN.
-
-Test 2 : Station acting as UCCo.
---------------------------------
-
-When the station is acting as UCCo it shall send a discover beacon at most
-each 10 seconds.
-
-The discover beacon shall contain:
-
-* Regions bentry
-
- * number of regions : 1
- * regions type : Local CSMA
- * end time (ATU) : 3906
-
-* Persistent schedules
-
- * PSCD : 0x7 i.e. valid indefinitely
- * CSCD : 0x7 i.e. valid indefinitely
- * NS : 1
-
- * GLID = 0xFF Broadcast
- * end time (ATU) : 3906
-
-* Mac Address
-* Discover Info
-* Beacon Period Start Time Offset
-
diff --git a/cesar/cp/beacon/test/doc/recv-beacon.txt b/cesar/cp/beacon/test/doc/recv-beacon.txt
deleted file mode 100644
index fa54e55523..0000000000
--- a/cesar/cp/beacon/test/doc/recv-beacon.txt
+++ /dev/null
@@ -1,81 +0,0 @@
-Receive beacon
-==============
-
-Central beacon
---------------
-
-Read a central beacon containing the following data.
-
-Environment
-~~~~~~~~~~~
-
-Variant fields data:
-
-* nid = 0x12456789ABCDEF
-* hm = 2 i.e. full hybrid mode.
-* stei = 0xA i.e. station own TEI store in the station manager.
-* bt = 0x0 i.e. central beacon.
-* ncnr = 0x0 i.e. non coordinated network.
-* npsm = 0x0 i.e. not in saving mode.
-* num_slots = 0x1 i.e. only this AVLN is present.
-* slot_usage = 0x1, initialise the station manager network.
-* aclss = 0x0 i.e. not track the ACL.
-* hoip = 0x0 i.e. no handover.
-* rstbf = 0x0 i.e. no use.
-* nm = 0x2 i.e. CSMA ONLY
-* cco_cap = CCO_LEVEL defined in the cp/defs.h
-
-Beacon entries:
-
-* Regions:
-
- * end time : 52, type : beacon region.
- * end time : 3905, type : CSMA / CA
-
-* Schedules:
-
- * Persistent schedules:
-
- * stpf = true, glid = 0xFF, start time (ATU) = 0, end time (ATU) = 52
- * stpf = false, glid = 0x1, end time (ATU) = 3905
-
-* Mac Address = 00:FF:5F:1A:D0:5A
-* BPSTO = 50.
-
-Station unassociated result
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-.. Warning:: Event post in the FSM not tested yet.
-
-* The AVLN shall be created in the station manager using the SNID and NID in the beacon payload and frame control.
-* The station emitting the beacon shall be added in the station manager in the AVLN previously added.
-* If it is the first Beacon received it shall just post an event in the FSM.
-
-Station associated result
-~~~~~~~~~~~~~~~~~~~~~~~~~
-
-* The SNID and NID shall be compared with the one of our AVLN. (No collision in this test).
-* The Station shall be added in the station manager if it does not exists (with the MAC address if it exists in the beacon).
-* The slot id and slot usage shall be store in the network data.
-* The regions are skipped.
-* The schedules are read and provided to the CA.
-
-Station associated SNID change result
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Environment complement
- This test shall have one more bentry to simulated a previous SNID collision, for that a change SNID beacon entry shall be had with a countdown equal 2.
- This test shall received two beacon to verify that the event is correctly post in the FSM.
-
-
-* The SNID and NID correspond to the station i.e. no conflict detected.
-* The Station shall be added in the station manager if it does not exists (with the MAC address if it exists in the beacon).
-* The num slots and slot usage shall be store in the network data.
-* The regions are skipped.
-* The schedules are read and provided to the CA.
-
-First beacon
- The change SNID countdown is set to the value 1.
-
-Second beacon
- The change SNID countdown is set to the value 0. The new SNID value is store in the station own data.
diff --git a/cesar/cp/beacon/test/doc/send-beacon.txt b/cesar/cp/beacon/test/doc/send-beacon.txt
deleted file mode 100644
index 62d52a2342..0000000000
--- a/cesar/cp/beacon/test/doc/send-beacon.txt
+++ /dev/null
@@ -1,85 +0,0 @@
-Send Beacon
-===========
-
-Central beacon
---------------
-
-This function has for job to:
-
- * Generate a central beacon.
- * Compute the next for beacon periods.
- * Provide the beacon to the CA layer.
- * Compute the schedules to the CA.
-
-Environment
- Add the elements necessary to generate a full beacon and verify the data generated.
-
-Variant fields data:
-
- * nid = 0x12456789ABCDEF
- * hm = 2 i.e. full hybrid mode.
- * stei = 0xA i.e. station own TEI store in the station manager.
- * bt = 0x0 i.e. central beacon.
- * ncnr = 0x0 i.e. non coordinated network.
- * npsm = 0x0 i.e. not in saving mode.
- * num_slots = 0x1 i.e. only this AVLN is present.
- * slot_usage = 0x1, initialise the station manager network.
- * aclss = 0x0 i.e. not track the ACL.
- * hoip = 0x0 i.e. no handover.
- * rstbf = 0x0 i.e. no use.
- * nm = 0x2 i.e. CSMA ONLY
- * cco_cap = CCO_LEVEL defined in the cp/defs.h
-
-Beacon entries:
-
- * Regions:
-
- * end time : 52, type : beacon region.
- * end time : 3905, type : CSMA / CA
-
- * Schedules:
-
- * Persistent schedules:
-
- * stpf = true, glid = 0x1, start time (ATU) = 0, end time (ATU) = 10
- * stpf = false, glid = 0x2, end time (ATU) = 50
- * stpf = true, glid = 0x3, start time (ATU) = 1500, end time (ATU) = 3000
-
- * Non persistent schedules:
-
- * stpf = true, glid = 0x4, start time (ATU) = 50, end time (ATU) = 750
- * stpf = false, glid = 0x5, end time (ATU) = 850
- * stpf = true, glid = 0x6, start time (ATU) = 900, end time (ATU) = 1500
-
- * Mac Address = 12:34:56:78:9A:BC
- * BPSTO is only the address in the beacon to store the date.
-
-Result
-
- * The beacon generated shall correspond to the values indicated above.
- * Beacon period estimated = 1 000 000 ticks i.e. 50 Hz.
- * Beacon Time Offset = 0 for each one i.e. 50 Hz perfect.
- * Schedules for the CA :
-
-+------+----------------+
-| GLID | end time (TCK) |
-+------+----------------+
-| 0x1 | 2560 |
-+------+----------------+
-| 0x2 | 12 800 |
-+------+----------------+
-| 0x4 | 192 000 |
-+------+----------------+
-| 0x5 | 217 600 |
-+------+----------------+
-| HOLE | 230 400 |
-+------+----------------+
-| 0x6 | 384 000 |
-+------+----------------+
-| 0x3 | 768 000 |
-+------+----------------+
-| HOLE | 1 000 000 |
-+------+----------------+
-
-Discover beacon
----------------
diff --git a/cesar/cp/cco/action/Module b/cesar/cp/cco/action/Module
index 78135db6bb..9cde29712e 100644
--- a/cesar/cp/cco/action/Module
+++ b/cesar/cp/cco/action/Module
@@ -1 +1 @@
-SOURCES := cco_action.c handover.c
+SOURCES := cco_action.c
diff --git a/cesar/cp/cco/action/cco_action.h b/cesar/cp/cco/action/cco_action.h
index 417484f002..30bb151773 100644
--- a/cesar/cp/cco/action/cco_action.h
+++ b/cesar/cp/cco/action/cco_action.h
@@ -14,11 +14,8 @@
*
*/
+#include "cp/inc/variant.h"
#include "cp/cp.h"
-#include "cp/mme.h"
-#include "cp/beacon/beacon.h"
-#include "cp/sta/mgr/sta.h"
-#include "cp/cco/action/handover.h"
/** Forward declaration. */
typedef struct cp_cco_action_t cp_cco_action_t;
@@ -30,6 +27,8 @@ BEGIN_DECLS
* \param ctx the module context.
*
*/
+#define cp_cco_action_init \
+ CP_VARIANT_FUNCTION(cco_action_init)
void
cp_cco_action_init (cp_t *ctx);
@@ -38,358 +37,29 @@ cp_cco_action_init (cp_t *ctx);
* \param ctx the module context.
*
*/
+#define cp_cco_action_uninit \
+ CP_VARIANT_FUNCTION(cco_action_uninit)
void
cp_cco_action_uninit (cp_t *ctx);
-/**
- * Start UCCo role.
- * \param ctx the module context.
- */
-void
-cp_cco_action_ucco_start (cp_t *ctx);
-
-/**
- * Stop UCCo role.
- * \param ctx the module context.
- */
-void
-cp_cco_action_ucco_stop (cp_t *ctx);
-
-/**
- * Move from UCCO to CCO.
- * \param ctx the module context.
- */
-void
-cp_cco_action_ucco__to_cco (cp_t *ctx);
-
-/**
- * Move from CCO to UCCO.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco__to_ucco (cp_t *ctx);
-
-/**
- * Move from USTA to CCO.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco__unassoc_start (cp_t *ctx);
-
-/**
- * Move from CCO to USTA.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx);
-
-/**
- * Move from STA to CCO.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco__assoc_start (cp_t *ctx);
-
-/**
- * Move from CCO to STA.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco__assoc_stop (cp_t *ctx);
/**
* perform garbage actions of CCo's responsibility.
* \param ctx the module context.
*/
+#define cp_cco_action_garbage \
+ CP_VARIANT_FUNCTION(cco_action_garbage)
void
cp_cco_action_garbage (cp_t *ctx);
/**
- * Change the SNID using the beacon module.
- * \param ctx the module context.
- *
- * It shall request the SNIDs in use from the station manager to choose
- * one randomly in the available SNIDs
- */
-void
-cp_cco_action_cco__cco_snid_conflict (cp_t *ctx);
-
-/**
- * generate a new NEK value.
- * \param ctx the module context.
- *
- * NEK shall be used no more than 1 hour, so must be changed after 1
- * hour for that purpose, NEK expiration date is checked at every occurrence
- * of the global garbage collector timer and if current NEK expiration
- * date reached, a new NEK value shall be generated by calling this function
- */
-void
-cp_cco_action_cco__cco_nek_change (cp_t *ctx);
-
-/**
- * Send the TEI map with the data corresponding to the station leaving.
- * \param ctx the CP context.
- * \param sta the station which leaves the AVLN.
- *
- * It will not add a reference on the station and will not release it.
- */
-void
-cp_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta);
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
-
-/**
- * manage authentication of a station.
- * \param ctx the module context.
- * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
- */
-void
-cp_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * get_key_req);
-
-/**
- * manage key request from authenticated station.
- * \param ctx the module context.
- * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
- */
-void
-cp_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * get_key_req);
-
-/**
- * Release a station.
- * \param ctx the CP context.
- * \param mme the MME received.
- */
-void
-cp_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Stop acting as a CCo and become a unassociated station.
- * \param ctx the module context.
- *
- * This function shall:
- * - Change the station status.
- * - Reprogram the beacon timer to expire a few time after the beacon period
- * start date.
- * - Stop the NEK generation.
- * - Delete the AVLN.
- * - Change the station authenticated status to not authenticated.
- */
-void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx);
-
-/**
- * The Handover can not be done cause of a countdown in the central beacon.
- * \param ctx the module context.
- *
- * This function will be called on each beacon timer expiration to send a
- * central beacon and try to handover the CCo functionality to stop.
- */
-void
-cp_cco_action_drv_mac_stop_suspend (cp_t *ctx);
-
-/**
- * Stop the CCo activity.
- * \param ctx the module context.
- *
- * Post event to_leave.
- */
-void
-cp_cco_action_drv_mac_stop_ended (cp_t *ctx);
-
-/**
- * Stop the UCCo activity.
- * \param ctx the module context.
- *
- * Post event left.
- */
-void
-cp_cco_action_ucco__to_stop (cp_t *ctx);
-
-/**
* Release a TEI.
* \param ctx the module context.
* \param tei The TEI value to release.
- *
*/
void
cp_cco_action_tei_release (cp_t *ctx, u8 tei);
-/**
- * Set the TEI in use.
- * \param ctx the module context.
- * \param tei the TEI already in use.
- *
- * Use this function for the handover to disallow the new CCo to use a TEI
- * already in use.
- */
-void
-cp_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei);
-
-/**
- * Clear the TEI compute mechanism.
- * \param ctx the module context.
- *
- * Use this function on the CCO stop.
- */
-void
-cp_cco_action_tei_clear (cp_t *ctx);
-
-/**
- * CCo STOP on the DRV_MAC_STOP MME.
- * \param ctx the module context.
- *
- * This function shall produce a handover on the network to allow another
- * station to become the network CCo. So it shall inform the beacon module to
- * set the hoip flag in the central beacon and provide a handover in progress
- * bentry in the central beacon.
- *
- * \warn This function will not stop the CCo. This shall be done once the
- * handover has been done on the network.
- */
-void
-cp_cco_action_drv_mac_stop (cp_t *ctx);
-
-/**
- * CCo selection for the drv mac stop request.
- * \param ctx the module context.
- * \param sta the station to add.
- */
-void
-cp_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta);
-
-/**
- * Clear the selection context.
- * \param ctx the module context.
- */
-void
-cp_cco_action_cco_selection__clear (cp_t *ctx);
-
-/**
- * Add a station to the CCo selection procedure.
- * \param ctx the module context.
- * \param net the station's NET.
- * \param sta the station to add.
- *
- * This function shall add the station only if it can be a better CCo and if
- * out station is not CCo User appointed.
- */
-void
-cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta);
-
-/**
- * Handle SC_CCO => CC_ASSOC_REQ.
- * \param ctx control plane context.
- * \param mme the handled MME.
- *
- * If it's the STA with which we are doing the SC assoc, reply with ok,
- * otherwise, reply with temporary failure.
- */
-void
-cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * The handover is ended.
- * \param ctx control plane context.
- *
- * Allow the ASSOC FSM to go to the authenticated state
- */
-void
-cp_cco_action_handover__ended (cp_t *ctx);
-
-/**
- * Start providing the NEK to the authenticated stations.
- * \param ctx control plane context.
- *
- * CCO_NEK_CHANGE_IDLE -> CCO_NEK_CHANGE_WAIT_STA_CNF.
- * This function should start a timer to check the timeout.
- */
-void
-cp_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx);
-
-/**
- * Timeout NEK exchange with a station.
- * \param ctx control plane context.
- *
- * This should try to provide the nek to another station if the peered station
- * was not the last of the AVLN, in the other case it should stop the FSM
- * going to the IDLE state.
- */
-void
-cp_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx);
-
-/**
- * Timeout NEK exchange with a station.
- * \param ctx control plane context.
- *
- * This should try to provide the nek to another station if the peered station
- * was not the last of the AVLN, in the other case it should stop the FSM
- * going to the IDLE state.
- */
-void
-cp_cco_action_cco__cco_nek_change__timeout (cp_t *ctx);
-
-/**
- * Received the CM_SET_KEY.CNF from the station.
- * \param ctx control plane context.
- * \param mme the handled MME.
- *
- * CCO_NEK_CHANGE_WAIT_STA_CNF -> CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF
- * Check the security parameters and the prn.
- */
-void
-cp_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Call the beacon module to start inserting the EKS bentry in the central
- * beacon.
- * \param ctx control plane context.
- */
-void
-cp_cco_action_nek_change_prevent (cp_t *ctx);
-
-/**
- * Request a CC_DISCOVER_LIST.REQ to a station.
- * \param ctx the module context.
- * \param net the concerned network.
- * \param sta the station to request the list.
- */
-void
-cp_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net,
- cp_sta_t *sta);
-
-/**
- * CCo receives a beacon from the same NID.
- * \param ctx the module context.
- * \param beacon the beacon.
- * \param net the beacon's network.
- * \param sta the source emitter.
- */
-void
-cp_cco_action_beacon_with_same_nid (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req);
-
END_DECLS
#endif /* cp_cco_action_h */
diff --git a/cesar/cp/cco/action/cco_conn/Module b/cesar/cp/cco/action/cco_conn/Module
deleted file mode 100644
index cc9223a014..0000000000
--- a/cesar/cp/cco/action/cco_conn/Module
+++ /dev/null
@@ -1 +0,0 @@
-SOURCES:=action.c
diff --git a/cesar/cp/cco/action/inc/cco_action.h b/cesar/cp/cco/action/inc/cco_action.h
index 35efccba91..ebbef697e4 100644
--- a/cesar/cp/cco/action/inc/cco_action.h
+++ b/cesar/cp/cco/action/inc/cco_action.h
@@ -21,18 +21,16 @@
#include "cp/sta/core/defs.h"
#include "cp/cco/action/cco_action.h"
-#define CP_CCO_ACTION_TEI_FLAGS_ROW 8
#define CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS 32 /* 32 bits. */
-/* Conversion of minutes to eCos ticks. */
-#define MIN_TO_RTC(val) (val * 100)
-
/* Return the next EKS value from the previous one. */
#define CP_CCO_ACTION_EKS_NEXT(val) \
(((val) + 1 > MAC_EKS_MAX) ? MAC_EKS_MIN : val + 1)
-/* Timeout value for the EKS exchange MME. */
-#define CP_CCO_ACTION_EKS_TIMEOUT_MS 1000
+#define CP_CCO_ACTION_TEI_FLAGS_ROW 8
+
+/* Conversion of minutes to eCos ticks. */
+#define MIN_TO_RTC(val) (val * 100)
struct cp_cco_action_t
{
@@ -59,49 +57,13 @@ struct cp_cco_action_t
BEGIN_DECLS
/**
- * Search for an available TEI in the AVLN list.
- * \param ctx the module context.
- * \return return the TEI found.
- *
- * Get the AVLN from the station manager (our AVLN). Lookup in the station
- * a hole of TEIs. It no hole is found and no more STAs are available
- * it means that all the TEIs are used in the AVLN. \Warn The TEI = 0
- * is reserved and 255 too
- */
-cp_tei_t
-cp_cco_action_tei_compute (cp_t *ctx);
-
-/**
- * Return true if the left node is lesser than the right node.
- * \param left The left node.
- * \param right The right node.
- * \return true if left is lesser than right.
- *
- * This function shall compare the expiration lease of the stations
- */
-bool
-cp_cco_action_tei_lease_less (set_node_t * left, set_node_t * right);
-
-
-/**
- * Removes a station from the CCo selection procedure.
- * \param ctx the module context.
- * \param sta the station to remove.
+ * Generate the NEK to be used right now.
+ * \param ctx the CP context.
*
- * This function shall remove a station from the CCO selection procedure. It
- * shall be called when the station refuse to become the New CCo or a timeout
- * on the handover procedure.
+ * Called on CCo startup.
*/
void
-cp_cco_action_cco_selection__sta_remove (cp_t *ctx, cp_sta_t *sta);
-
-/**
- * Selects the Next CCo on the AVLN.
- * \param ctx the module context.
- * \return the station elected or NULL.
- */
-cp_sta_t *
-cp_cco_action_cco_selection__selection (cp_t *ctx);
+cp_cco_action_gen_nek_now (cp_t *ctx);
END_DECLS
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index 0e64e852a6..45db57a927 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -36,128 +36,15 @@
#include "cp/sta/mgr/net.h"
#include "cp/sta/mgr/sta.h"
#include "cp/beacon/beacon.h"
-#include "cp/beacon/discover.h"
#include "cp/sta/core/core.h"
#include "cp/beacon/beacon.h"
#include "cp/cco/region/region.h"
-#include "cp/av/cco/region/region.h"
#include "cp/cco/bw/bw.h"
-#include "cp/av/cco/bw/bw.h"
#include "cp/inc/context.h"
#include "cp/inc/trace.h"
#include "cp/cco/action/inc/cco_action.h"
-#include "bsu/bsu.h"
-
-/**
- * Progam a timer to post a cco__nek_change event
- * \param ctx the module context.
- */
-static void
-cp_cco_action_nek_change_timer_program (cp_t *ctx)
-{
- /* Prepare next change. */
- cp_fsm_event_t *event =
- cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_cco__nek_change);
- cp_sta_core_gen_timed_event (ctx, &ctx->cco_action.nek_change,
- event, HPAV_NEK_CHANGE_MS);
-}
-
-/**
- * Choose a SNID between the ones available.
- * \param ctx the CP context.
- */
-static cp_snid_t
-cp_cco_action_snid_choose (cp_t *ctx)
-{
- u16 flags;
- u16 table [16];
- uint nb_elem;
- uint i;
- dbg_assert (ctx);
-
- // Get the present flags.
- flags = ~cp_sta_mgr_get_present_snids (ctx);
-
- // fill the table.
- for (i = 0, nb_elem = 0; i < 16; i++)
- {
- if ((flags >> i) & true)
- {
- table[nb_elem] = i;
- nb_elem ++;
- }
- }
-
-
- // Chose the new SNID.
- i = lib_rnd32 (&ctx->rnd) % nb_elem;
-
- return table[i];
-}
-
-/**
- * Function to sort the station in the CCo selection set.
- * \param left the left node.
- * \param right the right node.
- */
-static inline bool
-cp_cco_action_cco_selection__less (heap_node_t *left, heap_node_t *right)
-{
- cp_sta_t *stal;
- cp_sta_t *star;
-
- dbg_assert (left);
- dbg_assert (right);
-
- stal = PARENT_OF (cp_sta_t, cco_selection_node, left);
- star = PARENT_OF (cp_sta_t, cco_selection_node, right);
-
- if (stal->cco_cap > star->cco_cap)
- return true;
- return false;
-}
-
-
-/**
- * Search for an available TEI in the AVLN list.
- * \param ctx the module context.
- * \return return the TEI found.
- *
- */
-cp_tei_t
-cp_cco_action_tei_compute (cp_t *ctx)
-{
- uint row;
- uint tei;
- uint i;
- dbg_assert (ctx);
-
- for (i = MAC_TEI_STA_MIN; MAC_TEI_IS_STA (i); i++)
- {
- row = i / CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS;
- tei = ctx->cco_action.tei_flags[row] >>
- ((i % CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS)- 1);
- if ((tei & true) == false)
- {
- tei = i;
- cp_cco_action_tei_in_use (ctx, tei);
- break;
- }
- else
- tei = MAC_TEI_UNASSOCIATED;
- }
-
- // No TEI are available.
- return tei;
-}
-
-/**
- * Release a TEI.
- * \param ctx the module context.
- * \param tei The TEI value to release.
- */
void
cp_cco_action_tei_release (cp_t *ctx, u8 tei)
{
@@ -173,35 +60,6 @@ cp_cco_action_tei_release (cp_t *ctx, u8 tei)
}
void
-cp_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei)
-{
- uint row;
-
- dbg_assert (ctx);
- dbg_assert (MAC_TEI_IS_STA (tei));
-
- row = tei / CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS;
-
- ctx->cco_action.tei_flags[row] |= (1 << ((tei
- % CP_CCO_ACTION_TEI_FLAGS_ROW_SIZE_BITS) - 1));
-}
-
-void
-cp_cco_action_tei_clear (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- memset (&ctx->cco_action.tei_flags, 0,
- sizeof (uint) * CP_CCO_ACTION_TEI_FLAGS_ROW);
-}
-
-/**
- * Generate the NEK to be used right now.
- * \param ctx the CP context.
- *
- * Called on CCo startup.
- */
-static void
cp_cco_action_gen_nek_now (cp_t *ctx)
{
cp_key_t key;
@@ -212,1331 +70,3 @@ cp_cco_action_gen_nek_now (cp_t *ctx)
cp_beacon_change_nek (ctx, 0, key, true /* now. */);
}
-/**
- * Start common operations.
- * \param ctx the CP context.
- *
- * This should promote the station as CCo.
- * Program the nek change timer.
- * Untrack the old CCo.
- * Update beacon module.
- * Initialise the discover procedure.
- */
-static void
-cp_cco_action_cco_start_common (cp_t *ctx)
-{
- /* Set the CCo status in the station own data. */
- cp_sta_own_data_set_authenticated_status (ctx, true);
- cp_sta_own_data_set_cco_status (ctx, true);
- // Program the timer to change the NEKs.
- cp_cco_action_nek_change_timer_program (ctx);
- cp_beacon_process_untracked_avln (ctx);
- cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
- bsu_update_nid_snid (ctx->bsu, cp_net_get_nid (ctx, net),
- cp_net_get_snid (ctx, net));
- cp_beacon_cco_update_beacon_data (ctx);
- cp_beacon_reconfigure_timer (ctx, true);
- cp_beacon_discover_init (ctx);
-}
-
-/**
- * Start to act as a CCo coming from the unassociated state.
- * \param ctx the module context.
- *
- * This function shall:
- * - Choose a TEI if the station don't have one yet.
- * - Create and set our AVLN in the station manager.
- * - Generate the current NEK and order to change it.
- * - Clear schedules and set the network mode to CSMA_ONLY.
- * - Set the station's CCo and authenticate status.
- * - Program the NEK change timer.
- * - Clear tracking data.
- * - Update the beacon for BSU.
- * - Initialise the discover procedure context.
- */
-static void
-cp_cco_action_start (cp_t *ctx)
-{
- cp_tei_t tei;
- cp_net_t *net;
- cp_nid_t nid;
- cp_snid_t snid;
- dbg_assert (ctx);
- /* Verify if the station does not already have a TEI. */
- snid = cp_sta_own_data_get_snid (ctx);
- nid = cp_sta_own_data_get_nid (ctx);
- if (!cp_sta_own_data_get_tei(ctx))
- {
- tei = cp_cco_action_tei_compute (ctx);
- cp_sta_own_data_set_tei (ctx, tei);
- /* Clear the AVLN. */
- cp_sta_mgr_remove_avln (ctx, snid, nid);
- }
- /* Set our AVLN. */
- net = cp_sta_mgr_add_avln (ctx, snid, nid);
- cp_sta_mgr_set_our_avln (ctx, net);
- cp_cco_action_gen_nek_now (ctx);
- /* Reinitialise schedules and regions. */
- cp_cco_region_alloc_clean (ctx, &ctx->region.region_list);
- cp_av_cco_region_default (ctx);
- cp_cco_bw_alloc_clean (ctx, &ctx->bw.alloc_list);
- cp_av_cco_bw_schedules_default (ctx);
- /* Set network mode as CSMA only mode. */
- cp_net_set_nm (ctx, net, MAC_NM_CSMA_ONLY);
- /* Set hybrid mode to Full hybrid mode. */
- cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (ctx);
- own->hybrid_mode = MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
- cp_cco_action_cco_start_common (ctx);
-}
-
-/**
- * Stop acting as a CCo and become a simple station.
- * \param ctx the module context.
- *
- * This function shall:
- * - Change the station CCo status.
- * - Stop the NEK timer.
- * - Clear the TEI table attribution.
- * - Clear the CCo selection context (handover).
- * - Reconfigure becon timer.
- * - Update the beacon to act as a STA.
- * - Uninitialise discover procedure.
- */
-static void
-cp_cco_action_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Change the CCo status to false, the station leave the CCo status. */
- cp_sta_own_data_set_cco_status (ctx, false);
- /* Stop the timer for the NEK generation keys. */
- cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.nek_change);
- /* clear the TEI list. */
- cp_cco_action_tei_clear (ctx);
- cp_cco_action_cco_selection__clear (ctx);
- cp_beacon_reconfigure_timer (ctx, false);
- cp_beacon_sta_update_beacon_data (ctx);
- cp_beacon_discover_uninit (ctx);
-}
-
-
-/**
- * initialisation of CCo action module.
- * \param ctx the module context.
- *
- */
-void
-cp_cco_action_init (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- memset (&ctx->cco_action, 0, sizeof (cp_cco_action_t));
-
- /* Initialise the SET. */
- heap_init (&ctx->cco_action.selection_heap,
- cp_cco_action_cco_selection__less);
- /* Create default region. */
- cp_av_cco_region_default (ctx);
-}
-
-/**
- * Uninitialisation of CCo action module.
- * \param ctx the module context.
- *
- */
-void
-cp_cco_action_uninit (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- cp_cco_action_cco_selection__clear (ctx);
-}
-
-void
-cp_cco_action_ucco_start (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_cco_action_start (ctx);
-}
-
-void
-cp_cco_action_ucco_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_cco_action_stop (ctx);
- cp_sta_own_data_set_authenticated_status (ctx, false);
- /* Set our AVLN as null. */
- cp_sta_mgr_set_our_avln (ctx, NULL);
- /* Leave our TEI. */
- cp_sta_own_data_set_tei (ctx, MAC_TEI_UNASSOCIATED);
- cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
-}
-
-void
-cp_cco_action_ucco__to_cco (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
-}
-
-void
-cp_cco_action_cco__to_ucco (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_become_ucco);
-}
-
-void
-cp_cco_action_cco__unassoc_start (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Take a snid. */
- cp_snid_t snid = cp_cco_action_snid_choose (ctx);
- cp_sta_own_data_set_snid (ctx, snid);
- bsu_power_on (ctx->bsu, snid);
- cp_cco_action_start (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
-}
-
-void
-cp_cco_action_cco__assoc_start (cp_t *ctx)
-{
- cp_cco_action_cco_start_common (ctx);
- /* Clear tracking data. */
- cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
-}
-
-void
-cp_cco_action_cco__assoc_stop (cp_t *ctx)
-{
- cp_cco_action_stop (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_become_sta);
-}
-
-void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_cco_action_stop (ctx);
- cp_fsm_trigger_new_event (ctx, bare, assoc_cco_leave);
-}
-
-/**
- * Change the SNID.
- * \param ctx the module context.
- *
- * It shall request the SNIDs in use from the station manager to choose
- * one randomly in the available SNIDs
- */
-void
-cp_cco_action_cco__cco_snid_conflict (cp_t *ctx)
-{
- cp_snid_t snid;
- dbg_assert (ctx);
-
- snid = cp_cco_action_snid_choose (ctx);
-
- // Provide the SNID to the beacon module.
- cp_beacon_change_snid (ctx, snid);
-}
-
-/**
- * manage explicit leave request of a station.
- * \param ctx the module context.
- * \param sta provided by the garbage function to send a CC_LEAVE_IND.
- *
- * Remove the station from the station manager.
- * \warn It does not release the reference of the station provided
- * in parameters.
- */
-void
-cp_cco_action_tei_expired (cp_t *ctx, cp_sta_t *sta)
-{
- cp_mme_peer_t peer;
- cp_net_t *net;
-
- dbg_assert (ctx);
-
- /* Get the network of the station. */
- net = cp_sta_mgr_get_our_avln (ctx);
-
- cp_sta_get_peer (sta, &peer);
-
- cp_msg_cc_leave_ind_send (ctx, &peer,
- CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
- cp_net_get_nid(ctx, net));
- CP_TRACE (CCO_TEI_EXPIRED, TRACE_U64 (peer.mac), peer.tei);
-
- cp_cco_action_cco_sta_leave_send_tei_map (ctx, sta);
- cp_sta_mgr_release_station (ctx, cp_sta_get_tei (sta));
-}
-
-/**
- * perform garbage actions of CCo's responsibility.
- * \param ctx the module context.
- */
-void
-cp_cco_action_garbage (cp_t *ctx)
-{
- cp_sta_t *sta;
- cp_sta_t *sta_next;
- cp_net_t *net;
- dbg_assert (ctx);
-
- if (cp_sta_own_data_get_tei (ctx))
- {
- net = cp_sta_mgr_get_our_avln (ctx);
-
- sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
- while (sta)
- {
- slab_addref (sta);
- sta_next = cp_net_sta_get_next (ctx, net, sta);
- u32 date_ms = cp_sta_core_get_date_ms (ctx);
- if (less_mod2p32(sta->tei_lease_date_ms, date_ms)
- || less_mod2p32 (sta->expired_date_ms, date_ms))
- {
- // Remove the node from the tei lease.
- cp_cco_action_tei_expired (ctx, sta);
- }
- slab_release (sta);
- sta = sta_next;
- }
-
- cp_sta_mgr__assoc__timeout (ctx, cp_sta_core_get_date_ms (ctx));
- }
-}
-
-/**
- * generate a new NEK value.
- * \param ctx the module context.
- *
- * NEK shall be used no more than 1 hour, so must be changed after 1
- * hour for that purpose, NEK expiration date is checked at every occurrence
- * of the global garbage collector timer and if current NEK expiration
- * date reached, a new NEK value shall be generated by calling this function
- */
-void
-cp_cco_action_cco__cco_nek_change (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_secu_generate_key (ctx, lib_rnd32 (&ctx->rnd),
- CP_SECU_PBKDF1_ITERATION_NEK,
- &ctx->cco_action.nek_new);
-
- /* Prepare next change. */
- cp_cco_action_nek_change_timer_program (ctx);
- /* POST the FSM event. */
- cp_fsm_post_new_event (ctx, bare, cco_nek_change__nek_provide);
-}
-
-/**
- * Send the SET tei map IND to all the station with the TEI of the new one.
- * \param ctx the CP context.
- * \param tei the tei of the station which has joined the AVLN.
- * \param mac the station mac address.
- */
-static void
-cp_cco_action_send_set_tei_map_to_new_sta (cp_t *ctx, cp_tei_t tei,
- mac_t mac)
-{
- cp_mme_tx_t *mme_tx;
- cp_sta_t *sta_list;
- cp_mme_peer_t *peer;
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (tei);
- dbg_assert (mac);
-
- // Send unicast.
- // It will send all the TEI MAP to the station just associated.
- net = cp_sta_mgr_get_our_avln (ctx);
- peer = &CP_MME_PEER (mac, tei);
-
- // +1 For our own station which is not in the AVLN.
- mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_UPDATE,
- cp_net_get_num_stas (ctx, net) + 1);
-
- // Add our station first.
- cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
- cp_sta_own_data_get_tei(ctx),
- cp_sta_own_data_get_mac_address (ctx),
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED);
-
- sta_list = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
- while (sta_list)
- {
- enum cp_msg_cc_set_tei_map_ind_status_t station_status;
-
- if (cp_sta_get_authenticated (ctx, sta_list))
- {
- station_status =
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED;
- }
- else if (cp_sta_get_tei (sta_list))
- {
- station_status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED;
- }
- else
- {
- station_status =
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_DISASSOCIATED;
- }
- cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
- cp_sta_get_tei (sta_list),
- cp_sta_get_mac_address (sta_list),
- station_status);
-
- sta_list = cp_net_sta_get_next (ctx, net, sta_list);
-
- }
- cp_msg_cc_set_tei_map_ind_send_end (ctx, mme_tx);
-}
-
-/**
- * Send the SET TEI MAP to all the station of the NET.
- * \param ctx the CP context.
- * \param tei the new station tei.
- * \param mac the station mac address.
- */
-static void
-cp_cco_action_send_set_tei_map_to_all_sta (cp_t *ctx, cp_tei_t tei,
- mac_t mac)
-{
- cp_mme_peer_t *peer;
- cp_mme_tx_t *mme_tx;
- dbg_assert (ctx);
- dbg_assert (tei);
- dbg_assert (mac);
-
- peer = &CP_MME_PEER_ALL_STA;
- mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD, 1);
-
- cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme_tx,
- tei, mac,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED);
-
- cp_msg_cc_set_tei_map_ind_send_end (ctx, mme_tx);
-}
-
-/**
- * Assoc type join.
- * \param ctx the CP context.
- * \param msg the assoc MME message.
- * \param assoc the assoc data read from the MME.
- */
-static void
-cp_cco_action__assoc__join (cp_t *ctx, cp_mme_rx_t *msg,
- cp_msg_cc_assoc_req_t *assoc)
-{
- cp_net_t *net;
- cp_sta_t *sta;
- cp_tei_t tei = MAC_TEI_UNASSOCIATED;
- cp_msg_cc_assoc_cnf_t cnf;
-
- dbg_assert (ctx);
- dbg_assert (msg);
- dbg_assert (assoc);
-
- /* Add the station to the AVLN. */
- net = cp_sta_mgr_get_our_avln (ctx);
-
- cnf.nid = cp_net_get_nid (ctx, net);
- cnf.snid = cp_net_get_snid (ctx, net);
-
- /* Try to get the TEI from the STA manager if we already know it. */
- sta = cp_sta_mgr_sta_get_from_mac (ctx, msg->peer.mac);
- /* If the station is known. */
- if (sta)
- {
- /* If the station is currently in our AVLN/net. */
- if (net == cp_sta_get_net (sta))
- {
- // The station already exists get the TEI.
- tei = cp_sta_get_tei (sta);
- }
- /* Remove the station from the station manager and the mac store. */
- cp_sta_mgr_sta_remove (ctx, sta);
- slab_release (sta);
- }
- /* If the station has no TEI, try to generate one. */
- if (!MAC_TEI_IS_STA (tei))
- {
- /* Try to get a TEI. */
- tei = cp_cco_action_tei_compute (ctx);
- }
-
- /* If we manage to have a TEI, it's a success. */
- if (MAC_TEI_IS_STA (tei))
- {
- cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS;
- cnf.lease_time_min = CP_LEASE_ASSOC_MIN;
- }
- /* Otherwise, it's an error. */
- else
- {
- cnf.result =
- CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_TEMPORARY_RESSOURCE_EXHAUSTION;
- }
-
- /* Send the answer. */
- cnf.sta_tei = tei;
- cp_msg_cc_assoc_cnf_send (ctx, &msg->peer, &cnf);
- CP_TRACE (CCO_ASSOC, TRACE_U64 (msg->peer.mac), tei);
-
- if (tei)
- {
- /* Send TEI MAP to all STA except the new one (need to do it before
- * adding the new STA to the STA manager). */
- cp_cco_action_send_set_tei_map_to_all_sta (ctx, tei, msg->peer.mac);
- sta = cp_sta_mgr_sta_add (ctx, net, tei, msg->peer.mac);
- /* Add the TEI lease corresponding to an unassociated STA. */
- cp_sta_mgr_commit_to_dataplane (ctx);
- u32 date_ms = cp_sta_core_get_date_ms (ctx);
- sta->tei_lease_date_ms = date_ms +
- MAC_SEC_TO_MS(CP_LEASE_ASSOC_MIN * 60);
-
- /* Update the last request date in the sta. */
- cp_sta_set_assoc_confirmed (ctx, sta, false);
- sta->assoc_req_last_ms = cp_sta_core_get_date_ms (ctx);
- /* A new STA has joined an AVLN for the first time, generate an
- * event. */
- cp_fsm_event_t *event = cp_fsm_event_sta_new
- (ctx, CP_FSM_EVENT_TYPE_new_sta_associated, net,
- (cp_sta_t *) sta);
- cp_fsm_post (ctx, event);
-
- /* Release the reference on the station. */
- slab_release (sta);
- }
- if (!tei)
- {
- sta = cp_sta_mgr_sta_add (ctx, net, 0, msg->peer.mac);
- /* Release the reference on the station. */
- slab_release (sta);
- }
-}
-
-/**
- * Assoc type renew.
- * \param ctx the CP context.
- * \param msg the assoc MME message.
- * \param assoc the assoc data read from the MME.
- */
-static void
-cp_cco_action__assoc__renew (cp_t *ctx, cp_mme_rx_t *msg,
- cp_msg_cc_assoc_req_t *assoc)
-{
- cp_net_t *net;
- cp_sta_t *sta;
- cp_msg_cc_assoc_cnf_t cnf;
-
- dbg_assert (ctx);
- dbg_assert (msg);
- dbg_assert (assoc);
-
- /* Add the station to the AVLN. */
- net = cp_sta_mgr_get_our_avln (ctx);
-
- cnf.nid = cp_net_get_nid (ctx, net);
- cnf.snid = cp_net_get_snid (ctx, net);
-
- /* Renew the TEI. */
- sta = cp_sta_mgr_sta_get_assoc (ctx, net, msg->peer.tei);
-
- if (sta)
- {
- /* Renew the TEI. */
- u32 date_ms = cp_sta_core_get_date_ms (ctx);
- sta->tei_lease_date_ms = date_ms +
- MAC_SEC_TO_MS(CP_LEASE_AUTH_MIN * 60);
- cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS;
- cnf.sta_tei = cp_sta_get_tei (sta);
- cnf.lease_time_min = CP_LEASE_AUTH_MIN;
-
- slab_release (sta);
- }
- else
- {
- cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON;
- cnf.sta_tei = 0;
- cnf.lease_time_min = 0;
- }
-
- /* Send the answer. */
- cp_msg_cc_assoc_cnf_send (ctx, &msg->peer, &cnf);
- CP_TRACE (CCO_ASSOC_RENEW, TRACE_U64 (msg->peer.mac), msg->peer.tei);
-}
-
-/**
- * Static function part.
- * \param ctx the CP module context.
- * \param assoc_req the MME context.
- * \param assoc The mme in the processor format.
- */
-static void
-cp_cco_action_manage_sta_assoc_common (cp_t *ctx, cp_mme_rx_t *assoc_req,
- cp_msg_cc_assoc_req_t *assoc)
-{
- dbg_assert (ctx);
- dbg_assert (assoc_req);
- dbg_assert (assoc);
- dbg_assert (ctx->mac_store);
-
-
- if (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
- cp_cco_action__assoc__join (ctx, assoc_req, assoc);
- else if (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_RENEW)
- cp_cco_action__assoc__renew (ctx, assoc_req, assoc);
- else
- dbg_assert (assoc->request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NB);
-}
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
- cp_msg_cc_assoc_req_t assoc;
-
- dbg_assert (ctx);
- dbg_assert (assoc_req);
-
- /* Reading the data in the MME. */
- if (cp_msg_cc_assoc_req_receive(ctx, assoc_req, &assoc))
- cp_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
-}
-
-static void
-cp_cco_action_ucco__cc_assoc_req_common (
- cp_t *ctx, cp_mme_rx_t * assoc_req, cp_fsm_branch_t branch_ok,
- cp_fsm_branch_t branch_nok)
-{
- cp_msg_cc_assoc_req_t assoc;
- dbg_assert (ctx);
- dbg_assert (assoc_req);
- dbg_assert (cp_sta_own_data_get_tei (ctx));
- dbg_assert (cp_sta_own_data_get_authenticated_status (ctx));
- dbg_assert (cp_sta_own_data_get_cco_status (ctx));
- /* Reading the data in the MME. */
- cp_msg_cc_assoc_req_receive(ctx, assoc_req, &assoc);
- /* The MME is not for the station, it shall answer to the source station
- * with a Failure for others reason. */
- if ((assoc.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
- && (assoc.nid == cp_sta_own_data_get_nid (ctx)))
- {
- /* Become CCo. */
- cp_cco_action_ucco__to_cco (ctx);
- /* Continue the association procedure. */
- cp_cco_action_manage_sta_assoc_common (ctx, assoc_req, &assoc);
- cp_fsm_branch_ (ctx, branch_ok);
- }
- else
- cp_fsm_branch_ (ctx, branch_nok);
-}
-
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
- cp_cco_action_ucco__cc_assoc_req_common (
- ctx, assoc_req, CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, ok),
- CP_FSM_BRANCH (UCCO, CC_ASSOC_REQ, nok));
-}
-
-void
-cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
- cp_cco_action_ucco__cc_assoc_req_common (
- ctx, assoc_req, CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, ok),
- CP_FSM_BRANCH (SC_UCCO, CC_ASSOC_REQ, nok));
-}
-
-/**
- * manage authentication of a station.
- * \param ctx the module context.
- * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
- */
-void
-cp_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * get_key_req)
-{
- cp_msg_cm_get_key_req_t req;
- cp_msg_cm_get_key_cnf_t cnf;
- cp_net_t *net;
- cp_sta_t *sta;
- memset (&cnf, 0, sizeof (cp_msg_cm_get_key_cnf_t));
- cnf.eks = MAC_EKS_CLEAR;
- dbg_assert (ctx);
- dbg_assert (get_key_req);
-
- // get the data in the payload of the mme.
- if (cp_msg_cm_get_key_req_receive (ctx, get_key_req, &req)
- && (cp_secu_protocol_check
- (NULL, &get_key_req->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
- && (req.key_type == CP_MSG_KEY_NEK)
- && MAC_TEI_IS_STA (get_key_req->peer.tei))
- {
- // Get the network.
- net = cp_sta_mgr_get_our_avln (ctx);
- // Get the station.
- sta = cp_sta_mgr_sta_get_assoc (ctx, net, get_key_req->peer.tei);
-
- if (sta)
- {
- uint nb_sta;
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- cp_sta_set_assoc_confirmed (ctx, sta, true);
-
- if (req.key_type == CP_MSG_KEY_NEK)
- {
- uint i;
- uint index = bsu_nek_index_current (ctx->bsu);
- cnf.eks = ctx->mac_config->nek[index].eks;
- for (i = 0; i < COUNT (ctx->mac_config->nek[0].nek_enc); i++)
- cnf.key.key[i] =
- ctx->mac_config->nek[index].nek_enc[i];
- }
-
- /* Send the TEI map. */
- nb_sta = cp_net_get_num_stas (ctx, net);
- if (nb_sta)
- {
- cp_cco_action_send_set_tei_map_to_new_sta (ctx,
- cp_sta_get_tei(sta),
- get_key_req->peer.mac);
- }
-
- slab_release (sta);
- }
- else
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
- }
- // Refuse the request.
- else
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
-
- cnf.key_type = req.key_type;
- cnf.nid = req.nid;
- cp_secu_protocol_next (&get_key_req->prun, &ctx->rnd, true);
- cp_msg_cm_get_key_cnf_send (ctx, &get_key_req->peer, get_key_req->peks,
- &get_key_req->prun, &cnf);
-}
-
-void
-cp_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * get_key_req)
-{
- dbg_assert (ctx);
- dbg_assert (get_key_req);
-
- cp_msg_cm_get_key_req_t req;
- cp_msg_cm_get_key_cnf_t cnf;
- memset (&cnf, 0, sizeof (cp_msg_cm_get_key_cnf_t));
- cnf.eks = MAC_EKS_CLEAR;
-
- if (cp_msg_cm_get_key_req_receive (ctx, get_key_req, &req)
- && (cp_secu_protocol_check
- (NULL, &get_key_req->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
- && MAC_TEI_IS_STA (get_key_req->peer.tei))
- {
- if (req.key_type == CP_MSG_KEY_NEK)
- {
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
-
- uint i;
- uint index = bsu_nek_index_next (ctx->bsu);
- cnf.eks = ctx->mac_config->nek[index].eks;
- for (i = 0; i < COUNT (ctx->mac_config->nek[0].nek_enc); i++)
- cnf.key.key[i] =
- ctx->mac_config->nek[index].nek_enc[i];
- }
- else
- cnf.result =
- CP_MSG_CM_GET_KEY_CNF_RESULT_UNSUPPORTED_METHOD_KEY_TYPE;
- }
- else
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED;
-
- cnf.key_type = req.key_type;
- cnf.nid = req.nid;
- cp_secu_protocol_next (&get_key_req->prun, &ctx->rnd, true);
- cp_msg_cm_get_key_cnf_send (ctx, &get_key_req->peer, get_key_req->peks,
- &get_key_req->prun, &cnf);
-}
-
-void
-cp_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta)
-{
- cp_mme_peer_t *peer;
- cp_net_t *net = NULL;
- uint status;
- cp_mme_tx_t *mme;
-
- dbg_assert (ctx);
- dbg_assert (sta);
-
- // Send the TEI MAP to the station.
- net = cp_sta_mgr_get_our_avln (ctx);
-
- if (!cp_net_is_empty (ctx, net))
- {
- peer = &CP_MME_PEER_ALL_STA;
-
- if (cp_sta_get_authenticated (ctx, sta))
- {
- status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED;
- }
- else if (cp_sta_get_tei (sta))
- {
- status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED;
- }
- else
- status = CP_MSG_CC_SET_TEI_MAP_IND_STATUS_DISASSOCIATED;
-
- mme = cp_msg_cc_set_tei_map_ind_send_begin (ctx, peer,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_DELETE,
- 1);
- cp_msg_cc_set_tei_map_ind_send_sta (ctx, mme, cp_sta_get_tei (sta),
- cp_sta_get_mac_address (sta),
- status);
- cp_msg_cc_set_tei_map_ind_send_end (ctx, mme);
- }
-}
-
-void
-cp_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
- cp_sta_t *sta;
- cp_net_t *net;
- bool res_read;
- enum cp_msg_cc_leave_req_reason_t reason_req;
- cp_nid_t nid;
- enum cp_msg_cc_leave_ind_reason_t reason_ind;
-
-
- dbg_assert (ctx);
- dbg_assert (mme);
-
- dbg_assert (mme->peer.tei);
-
- switch (mme->mmtype)
- {
- case CC_LEAVE_REQ:
- res_read = cp_msg_cc_leave_req_receive (ctx, mme, &reason_req);
- break;
- case CC_LEAVE_IND:
- res_read = cp_msg_cc_leave_ind_receive (ctx, mme, &reason_ind,
- &nid);
- break;
- default:
- dbg_assert_default ();
- }
-
- if (res_read)
- {
- net = cp_sta_mgr_get_our_avln (ctx);
- if (mme->mmtype == CC_LEAVE_REQ)
- cp_msg_cc_leave_cnf_send (ctx, &mme->peer);
- else
- cp_msg_cc_leave_rsp_send (ctx, &mme->peer);
- /* Get the station. */
- sta = cp_sta_mgr_sta_get_assoc (ctx, net, mme->peer.tei);
- if (sta)
- {
- cp_sta_mgr_release_station (ctx, cp_sta_get_tei (sta));
- cp_cco_action_cco_sta_leave_send_tei_map (ctx, sta);
- slab_release (sta);
- }
- }
-}
-
-void
-cp_cco_action_drv_mac_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- dbg_assert (cp_sta_own_data_get_cco_status (ctx));
-
- if (!cp_net_is_empty (ctx, cp_sta_mgr_get_our_avln (ctx))
- && (!cp_beacon_any_countdown_active (ctx)))
- {
- cp_sta_t *sta;
- cp_net_t *net;
-
- /* Clear the SET of cco selection. */
- cp_cco_action_cco_selection__clear (ctx);
- ctx->handover.reason = CP_HANDOVER_REASON_CCO_LEAVING;
-
- net = cp_sta_mgr_get_our_avln (ctx);
- for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
- sta;
- sta = cp_net_sta_get_next (ctx, net, sta))
- {
- if (cp_sta_get_authenticated (ctx, sta))
- cp_cco_action_cco_selection__mac_stop_sta_add (ctx, sta);
- }
-
- /* Trigger the event to start the handover CCo FSM. */
- cp_fsm_trigger_new_event (ctx, bare, CCO_HANDOVER_START);
- /* Trigger an event to change the Main FSM to go to the
- * CCO_LEAVING_HOIP state. */
- cp_fsm_trigger_new_event (ctx, bare, CCO_LEAVING_HANDOVER);
- }
- else if (cp_net_is_empty (ctx, cp_sta_mgr_get_our_avln (ctx))
- && (!cp_beacon_any_countdown_active (ctx)))
- cp_fsm_trigger_new_event (ctx, bare, cco__all_sta_leaved);
-}
-
-void
-cp_cco_action_drv_mac_stop_suspend (cp_t *ctx)
-{
- cp_beacon_cco_update_beacon_data (ctx);
- cp_cco_action_drv_mac_stop (ctx);
-}
-
-void
-cp_cco_action_drv_mac_stop_ended (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_cco_action_cco__assoc_stop (ctx);
- cp_fsm_trigger_new_event (ctx, bare, to_stop);
-}
-
-void
-cp_cco_action_ucco__to_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_cco_action_ucco_stop (ctx);
- cp_fsm_trigger_new_event (ctx, bare, to_stop);
-}
-
-void
-cp_cco_action_cco_selection__mac_stop_sta_add (cp_t *ctx, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (sta);
-
- slab_addref (sta);
- heap_node_init (&sta->cco_selection_node);
- heap_insert (&ctx->cco_action.selection_heap,
- &sta->cco_selection_node);
-}
-
-
-void
-cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
-{
- cp_sta_own_data_t *own;
- dbg_assert (ctx);
- dbg_assert (net);
- dbg_assert (sta);
-
- if ((net == cp_sta_mgr_get_our_avln (ctx))
- && (MAC_TEI_IS_STA (cp_sta_get_tei (sta)))
- && (cp_sta_get_authenticated (ctx, sta)))
- {
- own = cp_sta_mgr_get_sta_own_data (ctx);
- if (own->cco_prefered == false
- && sta->cco_cap > CP_CCO_LEVEL)
- {
- slab_addref (sta);
- heap_node_init (&sta->cco_selection_node);
- heap_insert (&ctx->cco_action.selection_heap,
- &sta->cco_selection_node);
- }
- }
-}
-
-void
-cp_cco_action_cco_selection__sta_remove (cp_t *ctx, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (sta);
-
- dbg_assert (!heap_empty (&ctx->cco_action.selection_heap));
-
- heap_remove (&ctx->cco_action.selection_heap, &sta->cco_selection_node);
- heap_node_init (&sta->cco_selection_node);
- slab_release (sta);
-}
-
-void
-cp_cco_action_cco_selection__clear (cp_t *ctx)
-{
- cp_sta_t *sta;
- heap_node_t *node;
-
- dbg_assert (ctx);
-
- /* Verify the set. */
- while (!heap_empty (&ctx->cco_action.selection_heap))
- {
- node = heap_get_root (&ctx->cco_action.selection_heap);
- dbg_assert (node);
-
- sta = PARENT_OF (cp_sta_t, cco_selection_node, node);
- dbg_assert (sta);
-
- /* Remove the node from the heap. */
- heap_remove (&ctx->cco_action.selection_heap, &sta->cco_selection_node);
- heap_node_init (&sta->cco_selection_node);
- slab_release (sta);
- }
-}
-
-cp_sta_t *
-cp_cco_action_cco_selection__selection (cp_t *ctx)
-{
- cp_sta_own_data_t *own;
- cp_sta_t *sta = NULL;
- heap_node_t *node;
- dbg_assert (ctx);
-
- own = cp_sta_mgr_get_sta_own_data (ctx);
-
- if ((!own->cco_prefered)
- && (!heap_empty (&ctx->cco_action.selection_heap)))
- {
- node = heap_get_root (&ctx->cco_action.selection_heap);
- dbg_assert (node);
-
- sta = PARENT_OF (cp_sta_t, cco_selection_node, node);
- dbg_assert (sta);
- slab_addref (sta);
- }
-
- return sta;
-}
-
-void
-cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
- /* Check parameters. */
- dbg_assert (ctx);
- dbg_assert (mme);
-
- /* Check received MME. */
- cp_msg_cc_assoc_req_t req;
- if (!cp_msg_cc_assoc_req_receive (ctx, mme, &req))
- {
- /* Error in the MME, do nothing. */
- }
- else
- {
- if (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NEW)
- {
- /* Request of association. */
- /* Peer is SC? */
- if (mme->peer.mac == ctx->sta_action.sc.peer.mac)
- {
- /* Ok, reply */
- cp_cco_action__assoc__join (ctx, mme, &req);
- cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (ctx, ctx->sta_action.sc.peer.mac);
- ctx->sta_action.sc.peer.tei = cp_sta_get_tei (sta);
- slab_release (sta);
- }
- else
- {
- /* Deny assoc request. */
- cp_msg_cc_assoc_cnf_t cnf;
- cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON;
- /* Get our net. */
- cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
- /* Set NID/SNID. */
- cnf.nid = cp_net_get_nid (ctx, net);
- cnf.snid = cp_net_get_snid (ctx, net);
- /* No TEI for the STA. */
- cnf.sta_tei = 0;
- /* Lease default value. */
- cnf.lease_time_min = CP_LEASE_ASSOC_MIN;
- /* Send reply. */
- cp_msg_cc_assoc_cnf_send (ctx, &mme->peer, &cnf);
- }
- }
- else if (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_RENEW)
- /* Renew is ok. */
- cp_cco_action__assoc__renew (ctx, mme, &req);
- else
- /* Should not occur. */
- dbg_assert (req.request_type == CP_MSG_CC_ASSOC_REQ_TYPE_NB);
- }
-}
-
-void
-cp_cco_action_handover__ended (cp_t *ctx)
-{
- cp_cco_action_cco_selection__clear (ctx);
- cp_cco_action_cco__assoc_stop (ctx);
-}
-
-/**
- * Last transaction ends try next STA.
- * \param ctx the module context.
- * \return The next station to start a transaction with.
- */
-static cp_sta_t*
-cp_cco_action_nek_next_sta (cp_t *ctx)
-{
- cp_sta_t *sta;
- cp_sta_t *sta_next;
- cp_net_t *net;
- dbg_assert (ctx);
-
- net = cp_sta_mgr_get_our_avln (ctx);
-
- if ((sta = cp_sta_mgr_sta_get_from_mac (ctx,
- ctx->cco_action.eks_sta_current_peer.mac)))
- {
- sta_next = cp_net_sta_get_next (ctx, net, sta);
-
- if (sta_next)
- {
- cp_sta_get_peer (sta_next, &ctx->cco_action.eks_sta_current_peer);
- return sta_next;
- }
- return NULL;
- }
-
- return NULL;
-}
-
-/**
- * Request the station for the NEK change.
- * \param ctx the module context.
- * \param sta the station to start the NEK exchange.
- */
-static void
-cp_cco_action_nek_change_start_transaction (cp_t *ctx, cp_sta_t *sta)
-
-{
- cp_msg_cm_set_key_req_t data;
- cp_fsm_event_t *event;
-
- dbg_assert (ctx);
- dbg_assert (sta);
-
- /* Get the station peer to send the MME. */
- cp_sta_get_peer (sta, &ctx->cco_action.eks_sta_current_peer);
-
- /* Initialise the protocol run. */
- cp_secu_protocol_run_new (&ctx->cco_action.eks_prun, 1,
- &ctx->rnd);
-
- /* Fill the data structure with key type == NONCE_ONLY. */
- memset (&data, 0, sizeof (cp_msg_cm_set_key_req_t));
- data.key_type = CP_MSG_KEY_NONCE_ONLY;
- data.cco_cap = CP_CCO_LEVEL;
- data.nid = cp_sta_own_data_get_nid (ctx);
-
- /* Send the MME. */
- cp_msg_cm_set_key_req_send (ctx,
- &ctx->cco_action.eks_sta_current_peer,
- CP_MME_PEKS_NONE,
- &ctx->cco_action.eks_prun,
- &data);
-
- /* Start the timeout timer. */
- event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_cco_nek_change__nek_timeout);
- cp_sta_core_gen_timed_event(ctx,
- &ctx->cco_action.eks_timer,
- event,
- CP_CCO_ACTION_EKS_TIMEOUT_MS);
-}
-
-void
-cp_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx)
-{
- cp_net_t *net;
- cp_sta_t *sta;
- dbg_assert (ctx);
- net = cp_sta_mgr_get_our_avln (ctx);
- sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_ASSOC);
- /* If the current STA is not authenticated, it is not necessary to send
- * the MME. */
- while (sta && !cp_sta_get_authenticated (ctx, sta))
- sta = cp_net_sta_get_next (ctx, net, sta);
- if (sta)
- {
- cp_cco_action_nek_change_start_transaction (ctx, sta);
- slab_release (sta);
- /* Change branch. */
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_IDLE, cco_nek_change__nek_provide, sta);
- }
- else
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_IDLE, cco_nek_change__nek_provide, nosta);
-}
-
-void
-cp_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx)
-{
- cp_sta_t *sta;
- dbg_assert (ctx);
-
- /* Stop the time out timer. */
- cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
-
- if ((sta = cp_cco_action_nek_next_sta (ctx)))
- {
- cp_cco_action_nek_change_start_transaction (ctx, sta);
- slab_release (sta);
-
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_WAIT_STA_CNF,
- cco_nek_change__nek_timeout, yes);
- }
- else
- {
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_WAIT_STA_CNF,
- cco_nek_change__nek_timeout, no);
- }
-}
-
-void
-cp_cco_action_cco__cco_nek_change__timeout (cp_t *ctx)
-{
- cp_sta_t *sta;
- dbg_assert (ctx);
-
- /* Stop the time out timer. */
- cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
-
- if ((sta = cp_cco_action_nek_next_sta (ctx)))
- {
- cp_cco_action_nek_change_start_transaction (ctx, sta);
- slab_release (sta);
-
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
- cco_nek_change__nek_timeout, yes);
- }
- else
- {
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
- cco_nek_change__nek_timeout, no);
- }
-}
-
-void
-cp_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
-{
- cp_msg_cm_set_key_cnf_t data;
- dbg_assert (ctx);
- dbg_assert (mme);
-
- /* Stop the time out timer. */
- cp_sta_core_stop_timed_or_cyclic_event (ctx, &ctx->cco_action.eks_timer);
-
- if ((cp_msg_cm_set_key_cnf_receive (ctx, mme, &data)
- && (cp_secu_protocol_check
- (&ctx->cco_action.eks_prun, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT)))
- && ((mme->prun.pid == 1) && (mme->prun.pmn == 2)))
- {
- uint i;
- cp_msg_cm_set_key_req_t data_req;
- cp_fsm_event_t *event;
-
- data_req.key_type = CP_MSG_KEY_NEK;
- data_req.cco_cap = CP_CCO_LEVEL;
- data_req.nid = cp_sta_own_data_get_nid (ctx);
- data_req.new_eks = CP_CCO_ACTION_EKS_NEXT
- (ctx->cco_action.eks_current);
- for (i = 0; i < COUNT (ctx->cco_action.nek_new.key); i++)
- data_req.new_key.key[i] = ctx->cco_action.nek_new.key[i];
-
-
- /* Prepare the EKS NEK exchange. */
- ctx->cco_action.eks_prun = mme->prun;
- cp_secu_protocol_next (&ctx->cco_action.eks_prun, &ctx->rnd,
- false /* not last*/);
-
- cp_msg_cm_set_key_req_send (ctx,
- &ctx->cco_action.eks_sta_current_peer,
- CP_MME_PEKS_NMK,
- &ctx->cco_action.eks_prun,
- &data_req);
-
- /* Start the timeout timer. */
- event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_cco_nek_change__nek_timeout);
- cp_sta_core_gen_timed_event(ctx,
- &ctx->cco_action.eks_timer,
- event,
- CP_CCO_ACTION_EKS_TIMEOUT_MS);
- }
- /* Last message or error, try the next station.
- * If it was an error the STA is responsible to request the key when it
- * see the EKS bentry in the central beacon. */
- else
- {
- cp_sta_t *sta = cp_sta_mgr_sta_get_from_mac (ctx, mme->peer.mac);
- cp_net_t *net = cp_sta_mgr_get_our_avln (ctx);
- sta = cp_net_sta_get_next (ctx, net, sta);
- /* If the current STA is not authenticated, it is not necessary to send
- * the MME. */
- while (sta && !cp_sta_get_authenticated (ctx, sta))
- sta = cp_net_sta_get_next (ctx, net, sta);
- if (sta)
- {
- cp_cco_action_nek_change_start_transaction (ctx, sta);
- slab_release (sta);
-
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
- CM_SET_KEY_CNF_PID1, ok_continue);
- }
- else
- {
- cp_fsm_branch (ctx, CCO_NEK_CHANGE_PROCESS_CM_SET_KEY_CNF,
- CM_SET_KEY_CNF_PID1, end);
- }
- }
-}
-
-void
-cp_cco_action_nek_change_prevent (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- /* If there is no new EKS then do not change it.
- * This disallow the stations to store a false nek in mac config. */
- if (cp_sta_own_data_get_cco_status (ctx))
- {
- cp_beacon_change_nek (ctx,
- CP_CCO_ACTION_EKS_NEXT(ctx->cco_action.eks_current),
- ctx->cco_action.nek_new,
- false /* central beacon change. */);
-
- /* Set the EKS_current to the new one. */
- ctx->cco_action.eks_current =
- CP_CCO_ACTION_EKS_NEXT(ctx->cco_action.eks_current);
- }
-}
-
-void
-cp_cco_action_cco__cc_discover_list_req (cp_t *ctx, cp_net_t *net,
- cp_sta_t *sta)
-{
- dbg_assert (ctx);
- cp_mme_peer_t peer;
- cp_sta_get_peer (sta, &peer);
- cp_msg_cc_discover_list_req_send (ctx, &peer);
-}
-
-void
-cp_cco_action_beacon_with_same_nid (
- cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
-{
- dbg_assert (beacon);
-
- /* If we have the highest mac address we do nothing. */
- if (beacon->bmis.mac_address.present)
- if (MAC_REVERSE (beacon->bmis.mac_address.mac_address) <
- MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx)))
- return;
-
- /* To merge the two avlns we shut our network by turning the cco into
- * an unassociated sta. */
- cp_fsm_post_new_event (ctx, bare, cco_leave_merge_avln);
-}
diff --git a/cesar/cp/cco/action/stub/src/cco_action.c b/cesar/cp/cco/action/stub/src/cco_action.c
index 8ddfa10213..9ea02134a2 100644
--- a/cesar/cp/cco/action/stub/src/cco_action.c
+++ b/cesar/cp/cco/action/stub/src/cco_action.c
@@ -8,7 +8,7 @@
/**
* \file src/cco_action.c
* \brief CCo functions stub.
- * \ingroup cp_cco_action
+ * \ingroup cp_cco_action_stub
*
* Stub function for the unit test of the other modules.
*/
@@ -16,281 +16,27 @@
#include "cp/cco/action/cco_action.h"
-/**
- * initialisation of CCo action module.
- * \param ctx the module context.
- *
- */
-void
-cp_cco_action_init (cp_t *ctx) __attribute__((weak));
-void
-cp_cco_action_init (cp_t *ctx)
-{
-}
-
-/**
- * Uninitialisation of CCo action module.
- * \param ctx the module context.
- *
- */
-void
-cp_cco_action_uninit (cp_t *ctx) __attribute__((weak));
-void
-cp_cco_action_uninit (cp_t *ctx)
-{
-}
-
-/**
- * Change the SNID.
- * \param ctx the module context.
- *
- * It shall request the SNIDs in use from the station manager to choose
- * one randomly in the available SNIDs
- */
void
-cp_cco_action_cco__cco_snid_conflict (cp_t *ctx) __attribute__((weak));
+cp_utest_cco_action_init (cp_t *ctx) __attribute__ ((weak));
void
-cp_cco_action_cco__cco_snid_conflict (cp_t *ctx)
-{
-}
-
-/**
- * perform garbage actions of CCo's responsibility.
- * \param ctx the module context.
- */
-void
-cp_cco_action_garbage (cp_t *ctx) __attribute__((weak));
-void
-cp_cco_action_garbage (cp_t *ctx)
-{
-}
-
-/**
- * generate a new NEK value.
- * \param ctx the module context.
- *
- * NEK shall be used no more than 1 hour, so must be changed after 1
- * hour for that purpose, NEK expiration date is checked at every occurrence
- * of the global garbage collector timer and if current NEK expiration
- * date reached, a new NEK value shall be generated by calling this function
- */
-void
-cp_cco_action_cco__cco_nek_change (cp_t *ctx) __attribute__((weak));
-
-void
-cp_cco_action_cco__cco_nek_change (cp_t *ctx)
-{
-}
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_cco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req) __attribute__((weak));
-void
-cp_cco_action_cco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req)
-{
-}
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req) __attribute__((weak));
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req)
-{
-}
-
-/**
- * manage association of a station.
- * \param ctx the module context.
- * \param assoc_req CM_ASSOC.REQ MME msg having being received
- */
-void
-cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req) __attribute__((weak));
-void
-cp_cco_action_sc_ucco__cc_assoc_req (cp_t *ctx,
- cp_mme_rx_t * assoc_req)
-{
-}
-
-
-/**
- * manage authentication of a station.
- * \param ctx the module context.
- * \param get_key_req CM_GET_KEY.REQ MME msg having being decrypted
- */
-void
-cp_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx,
- cp_mme_rx_t * get_key_req) __attribute__((weak));
-void
-cp_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx,
- cp_mme_rx_t * get_key_req)
-{
-}
-
-/**
- * Release a station.
- * \param ctx the CP context.
- * \param mme the MME received.
- */
-void
-cp_cco_action__cco__cc_leave_req (cp_t *ctx,
- cp_mme_rx_t *mme) __attribute__((weak));
-void
-cp_cco_action__cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
+cp_utest_cco_action_init (cp_t *ctx)
+{}
-/**
- * Start to act as a CCo coming from the unassociated state..
- * \param ctx the module context.
- *
- * This function shall:
- * - Change the station CCo status.
- * - Generate the NEK.
- * - Program the NEK change timer (to change in few minutes).
- * - Program the beacon timer to send a central beacon at the beginning of
- * the next beacon period.
- */
void
-cp_cco_action__assoc__cco_start (cp_t *ctx) __attribute__((weak));
+cp_utest_cco_action_uninit (cp_t *ctx) __attribute__ ((weak));
void
-cp_cco_action__assoc__cco_start (cp_t *ctx)
-{
-}
+cp_utest_cco_action_uninit (cp_t *ctx)
+{}
-/**
- * Stop acting as a CCo and become a unassociated station.
- * \param ctx the module context.
- *
- * This function shall:
- * - Change the station status.
- * - Reprogram the beacon timer to expire a few time after the beacon period
- * start date.
- * - Stop the NEK generation.
- * - Delete the AVLN.
- * - Change the station authenticated status to not authenticated.
- */
void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx) __attribute__((weak));
+cp_utest_cco_action_garbage (cp_t *ctx) __attribute__ ((weak));
void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx)
-{
-}
+cp_utest_cco_action_garbage (cp_t *ctx)
+{}
-/**
- * Release a TEI.
- * \param ctx the module context.
- * \param tei The TEI value to release.
- *
- */
void
cp_cco_action_tei_release (cp_t *ctx, u8 tei) __attribute__((weak));
void
cp_cco_action_tei_release (cp_t *ctx, u8 tei)
-{
-}
-
-void
-cp_cco_action_handover__discover_done (cp_t *ctx) __attribute__((weak));
-
-void
-cp_cco_action_handover__discover_done (cp_t *ctx) {}
-
-void
-cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
- cp_mme_rx_t *mme) __attribute__((weak));
-
-void
-cp_cco_action_handover__cc_handover_cnf_receive (cp_t *ctx,
- cp_mme_rx_t *mme) {}
-
-void
-cp_cco_action_handover__timeout (cp_t *ctx)__attribute__((weak));
-
-void
-cp_cco_action_handover__timeout (cp_t *ctx) {}
-
-void
-cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
- cp_mme_rx_t *mme)__attribute__((weak));
-
-void
-cp_cco_action_handover__cc_handover_info_rsp_receive (cp_t *ctx,
- cp_mme_rx_t *mme) {}
-
-void
-cp_cco_action_handover__hoip_countdown_expired (cp_t
- *ctx)__attribute__((weak));
-
-void
-cp_cco_action_handover__hoip_countdown_expired (cp_t *ctx) {}
-
-void
-cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
- __attribute__((weak));
-
-void
-cp_cco_action_cco_selection__sta_add (cp_t *ctx, cp_net_t *net, cp_sta_t *sta)
{}
-void
-cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
- __attribute__((weak));
-
-void
-cp_cco_action_sc__sc_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta) __attribute__((weak));
-
-void
-cp_cco_action_cco_sta_leave_send_tei_map (cp_t *ctx, cp_sta_t *sta) {}
-
-void
-cp_cco_action_drv_mac_stop (cp_t *ctx)__attribute__((weak));
-void
-cp_cco_action_drv_mac_stop_suspend (cp_t *ctx)__attribute__((weak));
-void
-cp_cco_action_drv_mac_stop_ended (cp_t *ctx)__attribute__((weak));
-void
-cp_cco_action_handover__ended (cp_t *ctx)__attribute__((weak));
-void
-cp_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx)__attribute__((weak));
-void
-cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx)__attribute__((weak));
-
-void
-cp_cco_action_drv_mac_stop (cp_t *ctx){}
-void
-cp_cco_action_drv_mac_stop_suspend (cp_t *ctx){}
-void
-cp_cco_action_drv_mac_stop_ended (cp_t *ctx){}
-void
-cp_cco_action_handover__ended (cp_t *ctx){}
-void
-cp_cco_action_handover__timeout_cc_handover_cnf (cp_t *ctx){}
-void
-cp_cco_action_handover__timeout_cc_handover_info_rsp (cp_t *ctx){}
-
-void
-cp_cco_action_beacon_with_same_nid (
- cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
- __attribute__ ((weak));
-void
-cp_cco_action_beacon_with_same_nid (
- cp_t *ctx, bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta) { }
-
diff --git a/cesar/cp/cco/action/test/Makefile b/cesar/cp/cco/action/test/Makefile
deleted file mode 100644
index 36c719e479..0000000000
--- a/cesar/cp/cco/action/test/Makefile
+++ /dev/null
@@ -1,47 +0,0 @@
-BASE = ../../../..
-
-ECOS = y
-
-INCLUDES = cp/cco/action/test/overide
-
-HOST_PROGRAMS= fsm_handover
-TARGET_PROGRAMS = action garbage status keys
-
-action_SOURCES = action-test.c core_stub.c \
- sar_stub.c pbproc_stub.c sta_action.c
-action_MODULES = lib cp/cco/action mac/common cp/sta/mgr \
- cp/av/cco/region/stub cp/av/cco/bw/stub \
- cp/fsm/stub cp/beacon/stub cl/stub\
- cp/secu cp/msg/stub bsu/stub cp/cco/region/stub \
- cp/cco/bw/stub
-
-garbage_SOURCES = garbage.c core_stub.c \
- sar_stub.c pbproc_stub.c sta_action.c
-garbage_MODULES = lib cp/cco/action mac/common cp/sta/mgr cp/fsm/stub \
- cp/av/cco/region/stub cp/av/cco/bw/stub \
- cp/beacon/stub cl/stub cp/secu cp/msg/stub bsu/stub \
- cp/cco/region/stub cp/cco/bw/stub
-
-status_SOURCES = status.c pbproc_stub.c sar_stub.c sta_action.c
-status_MODULES = lib cp/cco/action mac/common cp/sta/mgr \
- cp/av/cco/region/stub cp/av/cco/bw/stub \
- cp/fsm/stub cp/beacon/stub cp/sta/core/stub \
- cp/msg/stub cl/stub mac/sar/stub cp/secu/stub \
- cp/secu bsu/stub cp/cco/region/stub cp/cco/bw/stub
-
-keys_SOURCES = action_gen_nek.c pbproc_stub.c sar_stub.c \
- sta_action.c
-keys_MODULES = lib cp/cco/action mac/common cp/sta/mgr \
- cp/secu cp/av/cco/region/stub cp/av/cco/bw/stub \
- cp/fsm/stub cp/beacon/stub cp/sta/core/stub \
- cp/msg/stub cl/stub mac/sar/stub cl/stub \
- bsu/stub cp/cco/region/stub cp/cco/bw/stub
-
-fsm_handover_SOURCES= fsm_handover.c sta_action.c
-fsm_handover_MODULES= lib cp/cco/action mac/common cp/sta/mgr \
- cp/secu cp/av/cco/region/stub cp/av/cco/bw/stub \
- cp/fsm/stub cp/beacon/stub cp/sta/core/stub \
- cp/msg/stub cl/stub mac/sar/stub \
- bsu/stub cp/cco/region/stub cp/cco/bw/stub
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cco/action/test/utest/Makefile b/cesar/cp/cco/action/test/utest/Makefile
deleted file mode 100644
index df10d9cb8f..0000000000
--- a/cesar/cp/cco/action/test/utest/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-BASE = ../../../../..
-
-INCLUDES = cp/cco/action/test/utest cp/cco/action/test/utest/override
-
-HOST_PROGRAMS = test_cco_action
-test_cco_action_SOURCES = test_cco_action.c handover.c nek.c discover_list.c \
- assoc.c garbage.c msg_stub.c fsm_stub.c \
- cp_stub.c scenario_actions.c \
- dataplane_stub.c beacon_stub.c \
- sta_action.c secu.c bsu_stub.c
-test_cco_action_MODULES = lib lib/scenario cp/cco/action cp/sta/mgr \
- cp/fsm/stub mac/common cl/stub \
- cp/sta/core/stub cp/beacon/stub cp/msg/stub \
- cp/av/cco/region/stub bsu/stub cp/beacon/stub \
- cp/cco/region/stub cp/cco/bw/stub cp/av/cco/bw/stub
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/cco/region/Module b/cesar/cp/cco/region/Module
index c320911efa..138ad93f78 100644
--- a/cesar/cp/cco/region/Module
+++ b/cesar/cp/cco/region/Module
@@ -1 +1 @@
-SOURCES:=region.c
+SOURCES := region.c
diff --git a/cesar/cp/cl_interf/test/Makefile b/cesar/cp/cl_interf/test/Makefile
deleted file mode 100644
index 237af7bfc7..0000000000
--- a/cesar/cp/cl_interf/test/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-BASE = ../../..
-
-INCLUDES = cp/cl_interf/test/override
-
-HOST_PROGRAMS = test-cl-interf
-
-test-cl-interf_SOURCES = test-cl-interf.c test.c
-test-cl-interf_MODULES = lib cp/cl_interf cp/sta/mgr mac/common \
- cp/secu cp/fsm/stub cp/cco/action/stub \
- cp/sta/core/stub mac/sar/stub cl/stub \
- bsu/stub cp/msg/stub hle/tools hal/ipmbox/stub \
- bufmgr/stub cp/sta/core/stub
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/conn/test/Makefile b/cesar/cp/conn/test/Makefile
index 0a0cfe31b7..9b493854d1 100644
--- a/cesar/cp/conn/test/Makefile
+++ b/cesar/cp/conn/test/Makefile
@@ -5,13 +5,13 @@ INCLUDES = cp/conn/test/override/
HOST_PROGRAMS = conn_test conn_mgr_test
conn_test_SOURCES = conn_test.c msg_stub.c sar_stub.c
-conn_test_MODULES = lib cp/conn cp/sta/mgr cp/cco/bw mac/common cp/fsm/stub \
- cp/cco/action/stub cp/sta/core/stub cl/stub
+conn_test_MODULES = lib cp/conn cp/sta/mgr cp/cco/bw mac/common \
+ cp/av/fsm/stub cp/cco/action/stub cp/sta/core/stub cl/stub
conn_mgr_test_SOURCES = conn_mgr_test.c msg_stub.c \
- sar_stub.c
+ sar_stub.c
conn_mgr_test_MODULES = lib cp/conn cp/sta/mgr cp/cco/bw mac/common \
- cp/fsm/stub cp/cco/action/stub cp/sta/core/stub \
- cl/stub
+ cp/av/fsm/stub cp/cco/action/stub cp/sta/core/stub \
+ cl/stub
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/fsm/Config b/cesar/cp/fsm/Config
deleted file mode 100644
index 23ee136ab4..0000000000
--- a/cesar/cp/fsm/Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_CP_FSM_DEF = "cp/fsm/src/fsm/cp.fsm"
diff --git a/cesar/cp/fsm/Module b/cesar/cp/fsm/Module
index d93ecce9d8..1434a7388a 100644
--- a/cesar/cp/fsm/Module
+++ b/cesar/cp/fsm/Module
@@ -1,37 +1 @@
-SOURCES := tables.c fsm.c events.c
-
-ifndef $(MODULE_VAR)_ONCE
-$(MODULE_VAR)_ONCE := 1$(CONFIG_CP_FSM_DEF)
-
-cp_fsm_defs_h := $(OBJ_INC_DIR)/cp_fsm_defs.h
-cp_fsm_tables_h = $(OBJ_INC_DIR)/cp_fsm_tables.h
-CLEAN_FILES += $(cp_fsm_defs_h) $(cp_fsm_tables_h)
-
-COMPILE_DEPS += $(cp_fsm_defs_h)
-
-cp_fsm_deps = $(CONFIG_CP_FSM_DEF:"%"=%) \
- $(call src2src,cp.conf template_defs.h \
- template_tables.h,$(MODULE)/src/fsm)
-
-$(cp_fsm_defs_h) $(cp_fsm_tables_h): $(cp_fsm_deps) $(DFAGEN) \
- $(OBJ_INC_DIR_STAMP)
- python $(DFAGEN) -O $(OBJ_INC_DIR) \
- -o c -d $< -c $(filter %.conf,$^) -p cp_fsm
-
-CLEAN_FILES += $(OBJ_DIR)/cp_fsm.png $(OBJ_DIR)/cp_fsm.dot
-
-$(OBJ_DIR)/cp_fsm.png: $(OBJ_DIR)/cp_fsm.dot $(OBJ_DIR_STAMP)
- dot -Tpng -o $@ $<
-
-$(OBJ_DIR)/cp_fsm.dot: $(cp_fsm_deps) $(DFAGEN) $(OBJ_DIR_STAMP)
- python $(DFAGEN) -O $(OBJ_DIR) -o dot -d $< -p cp_fsm
-
-$(call src2obj,cp/fsm/src/tables.c,target): $(cp_fsm_tables_h)
-
-else
-# This module rules depend on a configuration item, it need work to be used in
-# several build type.
-ifneq ($($(MODULE_VAR)_ONCE),1$(CONFIG_CP_FSM_DEF))
-$(error Module not safe for multiple build types)
-endif
-endif
+SOURCES := fsm.c events.c
diff --git a/cesar/cp/fsm/stub/Module b/cesar/cp/fsm/stub/Module
deleted file mode 100644
index e335f2519b..0000000000
--- a/cesar/cp/fsm/stub/Module
+++ /dev/null
@@ -1,3 +0,0 @@
-SOURCES := fsm_stub.c
-MODULES := cp/fsm
-cp_fsm_MODULE_SOURCES := $(call default,cp_fsm_MODULE_SOURCES,)
diff --git a/cesar/cp/fsm/test/utest/Config b/cesar/cp/fsm/test/utest/Config
deleted file mode 100644
index 0c100ed2d2..0000000000
--- a/cesar/cp/fsm/test/utest/Config
+++ /dev/null
@@ -1,2 +0,0 @@
-CONFIG_DEBUG_FATAL_CATCH = y
-CONFIG_CP_FSM_DEF = "cp/fsm/test/utest/src/utest.fsm"
diff --git a/cesar/cp/msg/src/msg.c b/cesar/cp/msg/src/msg.c
index d39e8471d8..730db251e0 100644
--- a/cesar/cp/msg/src/msg.c
+++ b/cesar/cp/msg/src/msg.c
@@ -431,7 +431,7 @@ cp_msg_uninit (cp_t *ctx)
* one, if it is the case it will check if the TEI is broadcast, if not it
* will return false.
*/
-bool
+PRIVATE bool
cp_msg_dispatch__read_enc_header (cp_t *ctx, cp_mme_rx_t *mme)
{
/* If the MMe as been relayed the TEI shall be Broadcast one. */
@@ -788,7 +788,7 @@ cp_msg_mme_init_encrypted (cp_t *ctx, cp_mme_peer_t *peer,
* \param fmi_nb the fragment number.
* \param fmi_fmsn the transaction number.
*/
-void
+PRIVATE void
cp_msg_mme_write_relay_header (cp_t *ctx, bitstream_t *bs,
cp_mme_peer_t dpeer,
cp_mme_peer_t final_peer,
@@ -848,7 +848,7 @@ cp_msg_mme_write_relay_header (cp_t *ctx, bitstream_t *bs,
* \param bs the bitstream.
* \param msg the msg MME.
*/
-void
+PRIVATE void
cp_msg_mme_write_relay (cp_t *ctx, bitstream_t *bs, cp_mme_tx_t *msg)
{
dbg_assert (ctx);
diff --git a/cesar/cp/msg/src/msg_cm.c b/cesar/cp/msg/src/msg_cm.c
index d3ffba23a5..4658d7ef78 100644
--- a/cesar/cp/msg/src/msg_cm.c
+++ b/cesar/cp/msg/src/msg_cm.c
@@ -385,7 +385,7 @@ cp_msg_cm_get_key_req_get_pid (cp_t *ctx, cp_mme_rx_t *mme, u8 *pid)
* \param prun the protocol run context.
* \param data the structure to use to read or write the data.
*/
-void
+PRIVATE void
cp_msg_cm_get_key_req_access (bitstream_t *stream,
cp_secu_protocol_run_t *prun,
cp_msg_cm_get_key_req_t *data)
diff --git a/cesar/cp/msg/test/Config b/cesar/cp/msg/test/Config
deleted file mode 100644
index dbdade324f..0000000000
--- a/cesar/cp/msg/test/Config
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_DEBUG_FATAL_CATCH=y
diff --git a/cesar/cp/msg/test/Makefile b/cesar/cp/msg/test/Makefile
deleted file mode 100644
index f46fcdca1a..0000000000
--- a/cesar/cp/msg/test/Makefile
+++ /dev/null
@@ -1,66 +0,0 @@
-BASE = ../../..
-
-DEFS=-DNO_PRIVATE
-
-INCLUDES = cp/msg/test/overide/ cp/sta/core/stub/
-
-HOST_PROGRAMS = test-msg-read-header test-msg-cc test-msg-cm \
- test_drv_msg test_cc_discover_list test_frag_mme \
- relay test_vs_msg test_allowed_mme msg
-
-test-msg-read-header_SOURCES = test-msg-read-header.c \
- cp_cl_interface_stub.c misc_stub.c
-test-msg-read-header_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
- cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
- mac/sar/stub cl/stub bsu/stub bufmgr/stub
-
-test-msg-cc_SOURCES = msg_cc.c misc_stub.c
-test-msg-cc_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr cp/fsm/stub \
- cp/sta/core/stub cp/cco/action/stub mac/sar/stub \
- cl/stub bsu/stub bufmgr/stub
-
-test-msg-cm_SOURCES = msg_cm.c misc_stub.c
-test-msg-cm_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr cp/fsm/stub \
- cp/sta/core/stub cp/cco/action/stub mac/sar/stub \
- cl/stub bsu/stub bufmgr/stub
-
-test_frag_mme_SOURCES = mme_frag.c misc_stub.c
-test_frag_mme_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
- cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
- mac/sar/stub cl/stub bsu/stub bufmgr/stub
-
-test_drv_msg_SOURCES = msg_drv.c \
- cp_cl_interface_stub.c misc_stub.c
-test_drv_msg_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr cp/fsm/stub \
- cp/sta/core/stub cp/cco/action/stub mac/sar/stub \
- cl/stub bsu/stub bufmgr/stub
-
-test_cc_discover_list_SOURCES = cc_discover_list.c misc_stub.c
-test_cc_discover_list_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
- cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
- cl/stub bsu/stub mac/sar/stub bufmgr/stub
-
-relay_SOURCES = relay.c misc_stub.c
-relay_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
- cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
- cl/stub bsu/stub mac/sar/stub bufmgr/stub
-
-test_vs_msg_SOURCES = msg_vs.c misc_stub.c \
- mac_sar_interface_stub.c cp_cl_interface_vs_stub.c
-test_vs_msg_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
- cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
- cl/stub bsu/stub mac/sar/stub bufmgr/stub
-
-test_allowed_mme_SOURCES = test_msg_allowed_mme.c \
- cp_cl_interface_stub.c misc_stub.c
-test_allowed_mme_MODULES = lib cp/msg cp/sta/mgr cp/sta/core/stub \
- cp/fsm/stub cp/secu mac/common mac/sar/stub \
- cp/cco/action/stub cl/stub bsu/stub bufmgr/stub
-
-msg_SOURCES = msg.c cp_cl_interface_stub.c misc_stub.c
-msg_MODULES = lib cp/msg cp/sta/mgr \
- cp/sta/core/stub \
- cp/fsm/stub cp/secu mac/common mac/sar/stub \
- cp/cco/action/stub cl/stub bsu/stub bufmgr/stub
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/action/Module b/cesar/cp/sta/action/Module
index e7c989dd8c..c8c05fc886 100644
--- a/cesar/cp/sta/action/Module
+++ b/cesar/cp/sta/action/Module
@@ -1,2 +1 @@
-SOURCES := action.c assoc.c drv.c info.c key.c misc.c poweron.c bridge.c sc.c \
- handover.c vs.c
+SOURCES := action.c assoc.c drv.c misc.c poweron.c bridge.c vs.c
diff --git a/cesar/cp/sta/action/action.h b/cesar/cp/sta/action/action.h
index 4f602759f3..0ab84b4ae0 100644
--- a/cesar/cp/sta/action/action.h
+++ b/cesar/cp/sta/action/action.h
@@ -20,18 +20,16 @@
*
* This part includes top level functions.
*/
+#include "cp/inc/variant.h"
#include "cp/types.h"
#include "cp/mme.h"
#include "cp/sta/action/assoc.h"
#include "cp/sta/action/poweron.h"
-#include "cp/sta/action/info.h"
#include "cp/sta/action/key.h"
#include "cp/sta/action/misc.h"
#include "cp/sta/action/drv.h"
#include "cp/sta/action/bridge.h"
-#include "cp/sta/action/sc.h"
-#include "cp/sta/action/handover.h"
#include "cp/sta/action/vs.h"
BEGIN_DECLS
@@ -40,6 +38,8 @@ BEGIN_DECLS
* Initialise STA action.
* \param ctx control plane context
*/
+#define cp_sta_action_init \
+ CP_VARIANT_FUNCTION(sta_action_init)
void
cp_sta_action_init (cp_t *ctx);
diff --git a/cesar/cp/sta/action/assoc.h b/cesar/cp/sta/action/assoc.h
index 785343201d..6a5d3b239b 100644
--- a/cesar/cp/sta/action/assoc.h
+++ b/cesar/cp/sta/action/assoc.h
@@ -125,6 +125,7 @@
* request failed.
*/
#include "cp/sta/mgr/net.h"
+#include "cp/inc/variant.h"
BEGIN_DECLS
@@ -132,73 +133,20 @@ BEGIN_DECLS
* Initialise association part.
* \param ctx control plane context
*/
+#define cp_sta_action_assoc_init \
+ CP_VARIANT_FUNCTION(sta_action_assoc_init)
void
cp_sta_action_assoc_init (cp_t *ctx);
/**
- * Start a association procedure.
- * \param ctx control plane context
- * \param cco_net AVLN of the CCo to associate with
- * \param cco CCo to associate with
- *
- * Trigger TO_ASSOC event.
- *
- * Need:
- * - CCo to associate to (MAC, TEI, NID).
- * - our CCo cap and proxy network cap.
- */
-void
-cp_sta_action_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco);
-
-/**
- * Start an Simple Connect association procedure.
- * \param ctx control plane context
- * \param cco_net AVLN of the CCo to associate with
- * \param cco CCo to associate with
- * \param sc_peer the peer with which we are doing the SC procedure.
- *
- * Trigger TO_SC_ASSOC event.
- */
-void
-cp_sta_action_sc_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco);
-
-/**
- * Request to leave the current AVLN.
- * \param ctx control plane context
- *
- * Trigger a TO_LEAVE event.
- */
-void
-cp_sta_action_assoc_leave (cp_t *ctx);
-
-/**
- * Handle entering UNASSOCIATED.
- * \param ctx control plane context
- *
- * Trigger a LEFT event.
- */
-void
-cp_sta_action_assoc__unassociated__enter (cp_t *ctx);
-
-/**
- * Handle UNASSOCIATED => (TO_ASSOC or TO_SC_ASSOC) events.
- * \param ctx control plane context
- *
- * Send a CC_ASSOC.REQ to the CCo.
- * \note the transition is the same if we are in the SC procedure or not
- * because the CC_ASSOC.REQ is sent to the CCo (in the SC procedure, the peer
- * STA will act as the CCo).
- */
-void
-cp_sta_action_assoc__unassociated__to_assoc (cp_t *ctx);
-
-/**
* Handle entering WAIT_ASSOC_CONF, SC_WAIT_ASSOC_CONF, ASSOCIATED and
* SC_ASSOCIATED.
* \param ctx control plane context
*
* Start retry timer.
*/
+#define cp_sta_action_assoc__start_retry_timer \
+ CP_VARIANT_FUNCTION(sta_action_assoc__start_retry_timer)
void
cp_sta_action_assoc__start_retry_timer (cp_t *ctx);
@@ -212,305 +160,6 @@ cp_sta_action_assoc__start_retry_timer (cp_t *ctx);
void
cp_sta_action_assoc__stop_retry_timer (cp_t *ctx);
-/**
- * Common handle (WAIT_ASSOC_CONF or SC_WAIT_ASSOC_CONF) => CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme received MME handle
- * \param sc true if we are in simple connect procedure.
- *
- * If the CCo accepted our association and update association information.
- * If we are not in SC procedure, send the CM_GET_KEY.REQ and go to the
- * ASSOCIATED state. If we are in SC, do nothing and go to SC_ASSOCIATED.
- * If the CCo refused, go back to UNASSOCIATED state and update the CCo
- * information to remember the failure.
- *
- * Update:
- * - our TEI.
- * - our TEI lease time (update lease timer).
- * - our AVLN.
- * - our AVLN SNID.
- * - CCo failure info.
- */
-void
-cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (cp_t *ctx,
- cp_mme_rx_t *mme,
- bool sc);
-
-/**
- * Handle WAIT_ASSOC_CONF => CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme received MME handle
- */
-void
-cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle SC_WAIT_ASSOC_CONF => CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme received MME handle
- */
-void
-cp_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Common handle for {SC_,}WAIT_ASSOC_CONF => TIMEOUT.
- * \param ctx control plane context.
- * \param sc true if we are in simple connect procedure.
- *
- * If retry count is not zero, resend the CC_ASSOC.REQ.
- *
- * If retry count is zero, go back to UNASSOCIATED state.
- */
-void
-cp_sta_action_assoc__wait_assoc_cnf__timeout_common (cp_t *ctx, bool sc);
-
-/**
- * Handle WAIT_ASSOC_CONF => TIMEOUT.
- * \param ctx control plane context.
- */
-void
-cp_sta_action_assoc__wait_assoc_cnf__timeout (cp_t *ctx);
-
-/**
- * Handle SC_WAIT_ASSOC_CONF => TIMEOUT.
- * \param ctx control plane context.
- */
-void
-cp_sta_action_assoc__sc_wait_assoc_cnf__timeout (cp_t *ctx);
-
-/**
- * Common handle for ASSOCIATED or SC_NMK_EXCHANGED => CM_GET_KEY.CNF (PID=[0,3]).
- * \param ctx control plane context
- * \param mme received MME handle
- * \param sc true if we are in simple connect procedure.
- *
- * If this is a success, go to AUTHENTICATED state, trigger JOINED event and
- * update station status.
- *
- * If authentication has failed, remember this and go back to UNASSOCIATED
- * state.
- *
- * Update:
- * - authenticated status.
- * - NEK.
- * - CCo failure info.
- */
-
-void
-cp_sta_action_assoc__cm_get_key_cnf__common (cp_t *ctx, cp_mme_rx_t
- *mme, bool sc);
-
-/**
- * Handle SC_NMK_EXCHANGED => CM_GET_KYE.CNF (PID=0)
- * \param ctx control plane context.
- * \param mme received MME to handle.
- */
-void
-cp_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0 (cp_t *ctx,
- cp_mme_rx_t *
- mme);
-
-/**
- * Handle ASSOCIATED => CM_GET_KEY.CNF (PID=0).
- * \param ctx control plane context
- * \param mme received MME handle
- */
-void
-cp_sta_action_assoc__associated__cm_get_key_cnf_pid_0 (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle AUTHENTICATED => CM_GET_KEY.CNF (PID=1).
- * \param ctx control plane context
- * \param mme received MME handle
- */
-void
-cp_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1 (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle ASSOCIATED => TIMEOUT.
- * \param ctx control plane context
- *
- * Authentication failed, go back to UNASSOCIATED and update the CCo
- * information to remember the failure.
- *
- * Stop lease timer.
- */
-void
-cp_sta_action_assoc__associated__timeout (cp_t *ctx);
-
-/**
- * Handle ASSOCIATED => TO_LEAVE.
- * \param ctx control plane context
- *
- * Stop lease timer.
- */
-void
-cp_sta_action_assoc__associated__to_leave (cp_t *ctx);
-
-/**
- * Handle AUTHENTICATED => nek_request.
- * \param ctx control plane context.
- */
-void
-cp_sta_action_assoc__authenticated__nek_request (cp_t *ctx);
-
-/**
- * Handle SC_ASSOCIATED => CM_GET_KEY.REQ (PID=3).
- * \param ctx control plane context.
- * \param mme received MME to handle.
- */
-void
-cp_sta_action_assoc__sc_associated__cm_get_key_req_pid_3 (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle SC_TEK_EXCHANGED => CM_SET_KEY.REQ (PID=3).
- * \param ctx control plane context.
- * \param mme received MME to handle.
- */
-void
-cp_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3 (cp_t *ctx,
- cp_mme_rx_t *
- mme);
-
-/**
- * Handle leaving AUTHENTICATED.
- * \param ctx control plane context
- *
- * Stop lease timer.
- */
-void
-cp_sta_action_assoc__authenticated__leave (cp_t *ctx);
-
-/**
- * Handle AUTHENTICATED => RENEW.
- * \param ctx control plane context
- *
- * Time to renew our lease. Send a CC_ASSOC.REQ.
- */
-void
-cp_sta_action_assoc__authenticated__renew (cp_t *ctx);
-
-/**
- * Handle AUTHENTICATED => CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme received MME handle
- *
- * Update:
- * - our TEI lease time (update lease timer).
- */
-void
-cp_sta_action_assoc__authenticated__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle AUTHENTICATED => CM_SET_KEY.REQ (PID=1), NEK renewal.
- * \param ctx control plane context
- * \param mme received MME handle
- *
- * Sent periodically by the CCo to change the NEK.
- *
- * Update:
- * - NEK.
- */
-void
-cp_sta_action_assoc__authenticated__cm_set_key_req_pid_1 (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle AUTHENTICATED => TO_LEAVE.
- * \param ctx control plane context
- *
- * Send the CC_LEAVE.REQ message to the CCo. Set a timeout in three beacon
- * periods.
- */
-void
-cp_sta_action_assoc__authenticated__to_leave (cp_t *ctx);
-
-/**
- * Handle AUTHENTICATED => CC_LEAVE.IND.
- * \param ctx control plane context
- * \param mme received MME handle
- *
- * The CCo request us to leave the AVLN. Send a response and go to LEAVE_WAIT
- * event.
- */
-void
-cp_sta_action_assoc__authenticated__cc_leave_ind (cp_t *ctx,
- cp_mme_rx_t *mme);
-
-/**
- * Handle AUTHENTICATED => BEACON.
- * \param ctx control plane context
- * \param beacon received beacon
- * \param net STA net
- * \param sta STA emitting the beacon
- *
- * If the beacon is ours, reset the "beacon not received" counter.
- */
-void
-cp_sta_action_assoc__authenticated__beacon (cp_t *ctx,
- bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-/**
- * Handle AUTHENTICATED => BEACON NOT RECEIVED.
- * \param ctx control plane context
- *
- * Increment the "beacon not received" counter. If it reaches the limit,
- * this is a AVLN failure.
- */
-void
-cp_sta_action_assoc__authenticated__beacon_not_received (cp_t *ctx);
-
-/**
- * Handle LEAVING => CC_LEAVE.CNF.
- * \param ctx control plane context
- * \param mme received MME handle
- *
- * Leave the AVLN and cleanup data plane.
- */
-void
-cp_sta_action_assoc__leaving__cc_leave_cnf (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Handle LEAVING => TIMEOUT.
- * \param ctx control plane context
- *
- * Send a CC_LEAVE.REQ again.
- */
-void
-cp_sta_action_assoc__leaving__timeout (cp_t *ctx);
-
-/**
- * Handle entering LEAVE_WAIT.
- * \param ctx control plane context
- */
-void
-cp_sta_action_assoc__leave_wait__enter (cp_t *ctx);
-
-/**
- * Handle LEAVE_WAIT => TIMEOUT.
- * \param ctx control plane context
- *
- * Leave the AVLN and cleanup data plane.
- */
-void
-cp_sta_action_assoc__leave_wait__timeout (cp_t *ctx);
-
-/**
- * Enter in Unassociating state.
- * \param ctx the module context.
- *
- * Update the BSU to act as STA.
- */
-void
-cp_sta_action_unassoc__unassoc__enter (cp_t *ctx);
-
END_DECLS
#endif /* cp_sta_action_assoc_h */
diff --git a/cesar/cp/sta/action/drv.h b/cesar/cp/sta/action/drv.h
index 5191b6747b..829d2304dd 100644
--- a/cesar/cp/sta/action/drv.h
+++ b/cesar/cp/sta/action/drv.h
@@ -45,6 +45,7 @@
* The stop request is asynchronous as the station will first leave the AVLN
* before the confirmation is sent.
*/
+#include "cp/inc/variant.h"
BEGIN_DECLS
@@ -143,6 +144,8 @@ cp_sta_action_drv__stopped__drv_sta_set_avln_hfid_req (cp_t *ctx,
* \param ctx control plane context
* \param mme received MME handle
*/
+#define cp_sta_action_drv__stopped__drv_sta_set_tonemask_req \
+ CP_VARIANT_FUNCTION(sta_action_drv__stopped__drv_sta_set_tonemask_req)
void
cp_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
cp_mme_rx_t *mme);
@@ -192,44 +195,15 @@ cp_sta_action_drv__drv_sta_sc_common (cp_t *ctx, cp_mme_rx_t *mme,
bool allow_sc_join, bool *sc_join);
/**
- * Handle USTA => DRV_STA_SC.
- * \param ctx control plane context.
- * \param mme the MME to handle.
- */
-void
-cp_sta_action_drv__usta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Handle UCCO => DRV_STA_SC.
- * \param ctx control plane context.
- * \param mme the MME to handle.
- */
-void
-cp_sta_action_drv__ucco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Handle CCO => DRV_STA_SC.
- * \param ctx control plane context.
- * \param mme the MME to handle.
- */
-void
-cp_sta_action_drv__cco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Handle STA => DRV_STA_SC.
- * \param ctx control plane context.
- * \param mme the MME to handle.
- */
-void
-cp_sta_action_drv__sta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
* Common handler for DRV_STA_SET_KEY.
* \param ctx control plane context.
* \param mme the MME to handle.
*/
+#define cp_sta_action_drv__stopped__drv_sta_set_key_req \
+ CP_VARIANT_FUNCTION(sta_action_drv__stopped__drv_sta_set_key_req)
void
-cp_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx, cp_mme_rx_t *mme);
+cp_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx,
+ cp_mme_rx_t *mme);
/**
* Common handler for DRV_STA_SET_DAK.
@@ -263,16 +237,6 @@ void
cp_sta_action_drv__drv_sta_status_ind_send (cp_t *ctx);
/**
- * Handle many => DRV_STA_SC (failure).
- * \param ctx control plane context.
- * \param mme the MME received.
- *
- * Disable DRV_STA_SC, but reply to say it to the host.
- */
-void
-cp_sta_action_drv__many__drv_sta_sc__failure (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
* Common handler for DRV_STA_SET_CONFIG.REQ.
* \param ctx control plane context
* \param mme MME to handle
diff --git a/cesar/cp/sta/action/key.h b/cesar/cp/sta/action/key.h
index 4b06d023f4..5f004f85ed 100644
--- a/cesar/cp/sta/action/key.h
+++ b/cesar/cp/sta/action/key.h
@@ -19,6 +19,7 @@
* many unrelated protocol, theses functions will only handle generic
* verifications and will then forward the message to the right recipient.
*/
+#include "cp/inc/variant.h"
BEGIN_DECLS
@@ -43,6 +44,8 @@ BEGIN_DECLS
* - from HLE to STA:
* - set NMK (not handled)
*/
+#define cp_sta_action_process_cm_set_key_req \
+ CP_VARIANT_FUNCTION(sta_action_process_cm_set_key_req)
void
cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_rx_t *mme);
@@ -57,6 +60,8 @@ cp_sta_action_process_cm_set_key_req (cp_t *ctx, cp_mme_rx_t *mme);
*
* This message can be forwarded to the CCo module.
*/
+#define cp_sta_action_process_cm_set_key_cnf \
+ CP_VARIANT_FUNCTION(sta_action_process_cm_set_key_cnf)
void
cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_rx_t *mme);
@@ -81,6 +86,8 @@ cp_sta_action_process_cm_set_key_cnf (cp_t *ctx, cp_mme_rx_t *mme);
* - from HLE to STA:
* - get NMK (not handled)
*/
+#define cp_sta_action_process_cm_get_key_req \
+ CP_VARIANT_FUNCTION(sta_action_process_cm_get_key_req)
void
cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_rx_t *mme);
@@ -93,6 +100,8 @@ cp_sta_action_process_cm_get_key_req (cp_t *ctx, cp_mme_rx_t *mme);
* legitimate and that it correspond to a sent request, then trigger the
* corresponding event.
*/
+#define cp_sta_action_process_cm_get_key_cnf \
+ CP_VARIANT_FUNCTION(sta_action_process_cm_get_key_cnf)
void
cp_sta_action_process_cm_get_key_cnf (cp_t *ctx, cp_mme_rx_t *mme);
diff --git a/cesar/cp/sta/action/misc.h b/cesar/cp/sta/action/misc.h
index 928bf1843c..5398400be5 100644
--- a/cesar/cp/sta/action/misc.h
+++ b/cesar/cp/sta/action/misc.h
@@ -123,25 +123,6 @@ u8
cp_sta_action_get_average_ble (cp_t *ctx, cp_tei_t tei, bool tx,
bool fc_format);
-void
-cp_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme);
-
-/**
- * Join timeout expires or SC failed common function.
- * \param ctx the module context.
- * \param branch_no_sta_no_avln the branch to follow when no STA and no AVLN
- * is present.
- * \param branch_no_sta_avln the branch to follow when no STA is present but
- * an AVLN exists.
- * \param branch_sta the branch to follow when a STA is present.
- */
-void
-cp_sta_action_poweron__cco__join_timeout_sc_failed (
- cp_t *ctx,
- cp_fsm_branch_t branch_no_sta_no_avln,
- cp_fsm_branch_t branch_no_sta_avln,
- cp_fsm_branch_t branch_sta);
-
END_DECLS
#endif /* cp_sta_action_misc_h */
diff --git a/cesar/cp/sta/action/poweron.h b/cesar/cp/sta/action/poweron.h
index 6ded55f545..1f23183a90 100644
--- a/cesar/cp/sta/action/poweron.h
+++ b/cesar/cp/sta/action/poweron.h
@@ -27,6 +27,7 @@
*
* Related: 7.1.
*/
+#include "cp/inc/variant.h"
#include "cp/sta/mgr/net.h"
BEGIN_DECLS
@@ -53,6 +54,8 @@ cp_sta_action_poweron_stop (cp_t *ctx);
* Handle going back to IDLE.
* \param ctx control plane context
*/
+#define cp_sta_action_poweron__many__to_idle \
+ CP_VARIANT_FUNCTION(sta_action_poweron__many__to_idle)
void
cp_sta_action_poweron__many__to_idle (cp_t *ctx);
@@ -63,214 +66,11 @@ cp_sta_action_poweron__many__to_idle (cp_t *ctx);
* Initialise the data plane to receive beacons and CM_UNASSOCIATED_STA.IND
* messages.
*/
+#define cp_sta_action_poweron__idle__to_poweron \
+ CP_VARIANT_FUNCTION(sta_action_poweron__idle__to_poweron)
void
cp_sta_action_poweron__idle__to_poweron (cp_t *ctx);
-/**
- * Handle entering POWERON.
- * \param ctx control plane context
- *
- * Start the BTT and USTT timers.
- */
-void
-cp_sta_action_poweron__poweron__enter (cp_t *ctx);
-
-/**
- * Handle leaving POWERON.
- * \param ctx control plane context
- *
- * Stop BTT and USTT timers.
- */
-void
-cp_sta_action_poweron__poweron__leave (cp_t *ctx);
-
-/**
- * Handle POWERON => USTT TIMEOUT.
- * \param ctx control plane context
- *
- * If there is at least one AVLN in the discovered list, send a
- * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
- * (in the right range).
- */
-void
-cp_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx);
-
-/**
- * Handle POWERON => BTT TIMEOUT.
- * \param ctx control plane context
- *
- * No beacon has been received during the BTT timer. Look in the discovered
- * STA list to see if there is a NID match. If a NID match and the station
- * should become CCo, go to CCO state.
- *
- * In other cases, if there is at least one AVLN in the discovered list, go to
- * USTA state. If there is no AVLN discovered, go to UCCO state.
- */
-void
-cp_sta_action_poweron__poweron__btt_timeout (cp_t *ctx);
-
-/**
- * Handle POWERON => BEACON.
- * \param ctx control plane context
- * \param beacon received beacon
- * \param net STA net
- * \param sta STA emitting the beacon
- *
- * When a beacon is received, if NID matches, go to corresponding JOINING
- * states and start the association procedure. In the other case, select an
- * AVLN to track in the list of discovered AVLN and continue searching.
- */
-void
-cp_sta_action_poweron__poweron__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-/**
- * Handle POWERON_JOINING => LEFT.
- * \param ctx control plane context
- *
- * Select an AVLN to track and continue searching.
- */
-void
-cp_sta_action_poweron__poweron_joining__left (cp_t *ctx);
-
-/**
- * Handle POWERON_JOINING, USTA_JOINING => TO_STOP.
- * \param ctx control plane context
- */
-void
-cp_sta_action_poweron__joining__to_stop (cp_t *ctx);
-
-/**
- * Handle entering USTA.
- * \param ctx control plane context
- *
- * Start the USTT timer.
- */
-void
-cp_sta_action_poweron__usta__enter (cp_t *ctx);
-
-/**
- * Handle entering USTA_JOINING.
- * \param ctx control plane context
- */
-void
-cp_sta_action_poweron__usta_joining__enter (cp_t *ctx);
-
-/**
- * Handle leaving USTA.
- * \param ctx control plane context
- *
- * Stop the USTT timer.
- */
-void
-cp_sta_action_poweron__usta__leave (cp_t *ctx);
-
-/**
- * Handle USTA => USTT TIMEOUT.
- * \param ctx control plane context
- *
- * If there is at least one AVLN in the discovered list, send a
- * CM_UNASSOCIATED_STA.IND, then restart the USTT timer with a random value
- * (in the right range).
- */
-void
-cp_sta_action_poweron__usta__ustt_timeout (cp_t *ctx);
-
-/**
- * Handle USTA => BEACON.
- * \param ctx control plane context
- * \param beacon received beacon
- * \param net STA net
- * \param sta STA emitting the beacon
- *
- * When a beacon is received, if NID matches, go to corresponding JOINING
- * states and start the association procedure. In the other case, select an
- * AVLN to track in the list of discovered AVLN and continue searching.
- */
-void
-cp_sta_action_poweron__usta__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-/**
- * Handle USTA => USTA IND.
- * \param ctx control plane context
- * \param net STA net
- * \param sta STA emitting CM_UNASSOCIATED_STA.IND
- *
- * If the NID match and the station should become CCo go to CCO state.
- */
-void
-cp_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
- cp_sta_t *sta);
-
-/**
- * Handle USTA_JOINING => LEFT.
- * \param ctx control plane context
- *
- * Select an AVLN to track and continue searching.
- */
-void
-cp_sta_action_poweron__usta_joining__left (cp_t *ctx);
-
-/**
- * Handle UCCO => BEACON.
- * \param ctx control plane context
- * \param beacon received beacon
- * \param net STA net
- * \param sta STA emitting the beacon
- *
- * Disable discover beacon emission.
- */
-void
-cp_sta_action_poweron__ucco__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta);
-
-/**
- * Handle STA => TO_STOP.
- * \param ctx control plane context
- */
-void
-cp_sta_action_poweron__sta__to_stop (cp_t *ctx);
-
-/**
- * Handle entering CCO.
- * \param ctx control plane context
- *
- * Start join timer.
- */
-void
-cp_sta_action_poweron_cco__enter (cp_t *ctx);
-
-/**
- * Handle leaving CCO.
- * \param ctx control plane context
- *
- * Stop join timer.
- */
-void
-cp_sta_action_poweron_cco__leave (cp_t *ctx);
-
-/**
- * Handle CCO => JOIN TIMEOUT.
- * \param ctx control plane context
- *
- * If there is no associated STA, stop being a CCo. In this case, if there is
- * at least one discovered AVLN, go to USTA state. Else, go to UCCO state.
- */
-void
-cp_sta_action_poweron__cco__join_timeout (cp_t *ctx);
-
-void
-cp_sta_action_poweron__idle__enter (cp_t *ctx);
-
-/**
- * Initialise poweron part.
- * \param ctx control plane context
- */
-void
-cp_sta_action_poweron_init (cp_t *ctx);
-
-
END_DECLS
#endif /* cp_sta_action_poweron_h */
diff --git a/cesar/cp/sta/action/src/action.c b/cesar/cp/sta/action/src/action.c
index 7cb1c9a84a..545c58e7cc 100644
--- a/cesar/cp/sta/action/src/action.c
+++ b/cesar/cp/sta/action/src/action.c
@@ -15,29 +15,8 @@
#include "action.h"
#include "cp/inc/context.h" // cp_t
#include "cp/sta/action/bridge.h"
-#include "cp/av/cco/bw/bw.h"
#include "ce/tx/tx.h"
#include "cp/fsm/fsm.h"
-#include "cp/beacon/beacon.h"
-
-/** Delay after the one, the NET is considered worth than an other one.
- * This delay should be added to the last beacon reception date from the CCo
- * on the net. */
-#define CP_STA_ACTION_TRACK_EXPIRED_MS 400
-
-void
-cp_sta_action_init (cp_t *ctx)
-{
- cp_sta_action_assoc_init (ctx);
- /* Initialize the STA action bridge module. */
- cp_sta_action_bridge_init (ctx);
- /* Initialize the STA action misc module. */
- cp_sta_action_misc_init (ctx);
- /* Create the default allocation schedules. */
- cp_av_cco_bw_schedules_default (ctx);
- /* Initialize the STA action poweron module. */
- cp_sta_action_poweron_init (ctx);
-}
void
cp_sta_action_garbage (cp_t *ctx)
@@ -47,83 +26,3 @@ cp_sta_action_garbage (cp_t *ctx)
/* Update tone map list for CE in TX. */
ce_tx_update_tone_map (ctx);
}
-
-void
-cp_sta_action_beacon_match_and_join (cp_t *ctx,
- bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta, bool sc,
- cp_fsm_branch_t branch_match,
- cp_fsm_branch_t branch_no_match)
-{
- cp_sta_own_data_t *own_data = cp_sta_mgr_get_sta_own_data (ctx);
- cp_nid_t our_nid = cp_sta_own_data_get_nid (ctx);
- cp_nid_t its_nid = cp_net_get_nid (ctx, net);
- u8 its_snid = cp_net_get_snid (ctx, net);
- /* Does not support proxy networking for the moment, only handle CCo
- * beacon. */
- if (cp_sta_get_cco_status (sta))
- {
- cp_net_t *net_tracking =
- cp_sta_mgr_get_avln (ctx, cp_sta_own_data_get_snid (ctx),
- own_data->nid_track);
- /* Should we track this beacon? */
- if (!net_tracking /* Net tracking no more present. */
- || (its_nid == our_nid /* New net nid match our nid. */
- && !net->blacklisted /* New net is not blacklisted. */
- && (own_data->nid_track != our_nid /* Not our nid.*/
- || net_tracking->blacklisted
- || less_mod2p32 (
- net_tracking->beacon_recv_date
- + MAC_MS_TO_TCK (CP_STA_ACTION_TRACK_EXPIRED_MS),
- phy_date ()))
- )
- )
- {
- cp_sta_mgr_set_tracking (ctx, its_snid, its_nid);
- cp_beacon_process_tracked_avln (ctx, beacon, net);
- }
- /* The CCo has changed. */
- else if (net_tracking == net
- && !beacon->bmis.change_snid.present
- && cp_net_get_slot_id (ctx, net) == beacon->vf.slotid)
- {
- /* station manager stores MAC_BROADCAST if the mac address is
- * unknown, the tracking system store MAC_ZERO if it does not
- * track a CCo, so we need to adapt the station's MAC address to
- * the tracked one. */
- mac_t cco_mac = cp_sta_get_mac_address (sta) == MAC_BROADCAST ?
- MAC_ZERO : cp_sta_get_mac_address (sta);
- if (cco_mac != own_data->cco_mac_addr_track)
- {
- /* We can assume this CCo is the new one. */
- cp_net_set_cco (ctx, net, cp_sta_get_tei (sta));
- cp_beacon_process_tracked_avln (ctx, beacon, net);
- }
- }
- /* Should we associate? */
- if (its_nid == our_nid
- && its_snid == cp_sta_own_data_get_snid (ctx)
- && !net->blacklisted
- && cp_beacon_synchronised (ctx))
- {
- if (!sc)
- cp_sta_action_assoc_start (ctx, net, sta);
- else
- {
- /* Start assoc procedure. */
- cp_sta_action_sc_assoc_start (ctx, net, sta);
- /* Inform main FSM we have start SC association procedure. */
- cp_fsm_trigger_new_event (ctx, bare, sc_succeed);
- }
- cp_fsm_branch_ (ctx, branch_match);
- }
- else
- {
- cp_fsm_branch_ (ctx, branch_no_match);
- }
- }
- else
- {
- cp_fsm_branch_ (ctx, branch_no_match);
- }
-}
diff --git a/cesar/cp/sta/action/src/assoc.c b/cesar/cp/sta/action/src/assoc.c
index 97516b8e61..aff1658069 100644
--- a/cesar/cp/sta/action/src/assoc.c
+++ b/cesar/cp/sta/action/src/assoc.c
@@ -23,91 +23,6 @@
#include "cp/beacon/beacon.h"
#include "bsu/bsu.h"
-#define RETRY_TIMEOUT_MS 1000
-#define RENEW_MARGIN_MS (5 * 60 * 1000)
-#define LEAVING_TIMEOUT_MS (40 * 3)
-#define LEAVE_WAIT_TIMEOUT_MS 1000
-
-void
-cp_sta_action_assoc_init (cp_t *ctx)
-{
- dbg_assert (ctx);
-}
-
-void
-cp_sta_action_sc_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco)
-{
- /* Check parameters. */
- dbg_assert (ctx);
- dbg_assert (cco_net);
- /* cco can be NULL. */
-
- /* Check NID. */
- dbg_assert (cp_sta_own_data_get_nid (ctx)
- == cp_net_get_nid (ctx, cco_net));
-
- /* Do we know the CCo? */
- if (cco)
- /* Store CCo peer. */
- cp_sta_get_peer (cco, &ctx->sta_action.assoc.peer);
- else
- {
- /* Let's try to find the CCo from the net. */
- cp_sta_t *cco_from_net = cp_net_get_cco (ctx, cco_net);
- if (cco_from_net)
- {
- /* Get peer CCo. */
- cp_sta_get_peer (cco_from_net, &ctx->sta_action.assoc.peer);
- /* Release. */
- slab_release (cco_from_net);
- }
- else
- {
- /* We do not know the CCo, broadcast to all STA. */
- ctx->sta_action.assoc.peer = CP_MME_PEER (MAC_BROADCAST,
- MAC_TEI_UNASSOCIATED);
- }
- }
- ctx->sta_action.assoc.snid = cp_net_get_snid (ctx, cco_net);
- ctx->sta_action.assoc.retry = 3;
- /* Trigger to_sc_assoc event. */
- cp_fsm_trigger_new_event (ctx, bare, to_sc_assoc);
-}
-
-void
-cp_sta_action_assoc_start (cp_t *ctx, cp_net_t *cco_net, cp_sta_t *cco)
-{
- dbg_assert (ctx);
- dbg_assert (cco_net);
- dbg_assert (cco);
- /* Remember CCo to associate with. */
- dbg_assert (cp_sta_own_data_get_nid (ctx)
- == cp_net_get_nid (ctx, cco_net));
- cp_sta_get_peer (cco, &ctx->sta_action.assoc.peer);
- ctx->sta_action.assoc.snid = cp_net_get_snid (ctx, cco_net);
- ctx->sta_action.assoc.retry = 3;
- /* Trigger to_assoc event. */
- cp_fsm_trigger_new_event (ctx, bare, to_assoc);
-}
-
-void
-cp_sta_action_assoc_leave (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Trigger to_leave event. */
- cp_fsm_trigger_new_event (ctx, bare, to_leave);
-}
-
-void
-cp_sta_action_assoc__start_retry_timer (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
- RETRY_TIMEOUT_MS);
-}
-
void
cp_sta_action_assoc__stop_retry_timer (cp_t *ctx)
{
@@ -115,707 +30,3 @@ cp_sta_action_assoc__stop_retry_timer (cp_t *ctx)
cp_sta_core_stop_timed_or_cyclic_event (
ctx, &ctx->sta_action.assoc.timer);
}
-
-void
-cp_sta_action_assoc__unassociated__enter (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_own_data_set_authenticated_status (ctx, false);
- cp_sta_mgr_set_our_avln (ctx, NULL);
- cp_sta_own_data_set_tei (ctx, 0);
- cp_fsm_trigger_new_event (ctx, bare, left);
- /* Reset some parts. */
- cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (ctx);
- own->hybrid_mode = MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
-}
-
-void
-cp_sta_action_assoc__unassociated__to_assoc (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Send association request. */
- cp_msg_cc_assoc_req_t data = {
- CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
- cp_sta_own_data_get_nid (ctx),
- CP_CCO_LEVEL,
- CP_PCO_CAP
- };
- cp_msg_cc_assoc_req_send (ctx, &ctx->sta_action.assoc.peer, &data);
-}
-
-void
-cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (cp_t *ctx,
- cp_mme_rx_t *mme,
- bool sc)
-{
- cp_msg_cc_assoc_cnf_t cnf;
- dbg_assert (ctx);
- dbg_assert (mme);
- /* Check response. */
- if ((mme->peer.mac != ctx->sta_action.assoc.peer.mac
- && ctx->sta_action.assoc.peer.mac != MAC_BROADCAST)
- || !cp_msg_cc_assoc_cnf_receive (ctx, mme, &cnf)
- || cnf.nid != cp_sta_own_data_get_nid (ctx)
- || cnf.snid != ctx->sta_action.assoc.snid)
- {
- /* Unrelated message, drop. */
- if (!sc)
- cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, unrelated);
- else
- cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, unrelated);
- }
- else if (cnf.result != CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS)
- {
- /* Failure indication. */
- if (!sc)
- cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, nok);
- else
- cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, nok);
- }
- else
- {
- cp_net_t *our_net;
- /* Start lease timer, it can not expire before we go to authenticated
- * state because authentication timeout is shorter. */
- int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
- if (lease_time_ms > 0)
- {
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_renew);
- cp_sta_core_gen_timed_event (ctx,
- &ctx->sta_action.assoc.lease_timer,
- event, lease_time_ms);
- }
- /* Update state. */
- cp_sta_own_data_set_tei (ctx, cnf.sta_tei);
- our_net = cp_sta_mgr_add_avln (ctx, cnf.snid, cnf.nid);
- cp_sta_t *cco =
- cp_sta_mgr_sta_add (ctx, our_net, mme->peer.tei, mme->peer.mac);
- cp_net_set_cco (ctx, our_net, mme->peer.tei);
- slab_release (cco);
- ctx->sta_action.assoc.peer = mme->peer;
- ctx->sta_action.assoc.snid = cnf.snid;
- cp_sta_mgr_set_our_avln (ctx, our_net);
- /* Not in SC procedure. */
- if (!sc)
- {
- /* Send get key request. */
- cp_msg_cm_get_key_req_t get_key = {
- .relayed = false, .key_type = CP_MSG_KEY_NEK,
- .nid = cp_sta_own_data_get_nid (ctx) };
- cp_secu_protocol_run_new (&ctx->sta_action.assoc.prun, 0,
- &ctx->rnd);
- cp_msg_cm_get_key_req_send (ctx, &mme->peer, CP_MME_PEKS_NMK,
- &ctx->sta_action.assoc.prun, &get_key);
- /* Change state. */
- cp_fsm_branch (ctx, WAIT_ASSOC_CONF, CC_ASSOC_CNF, ok);
- }
- else
- {
- /* In SC procedure. */
- /* Ensure SC peer is correct, so let's copy it back (to handle TEI
- * change (UCCO to CCO) and/or MAC change (broadcast). */
- ctx->sta_action.sc.peer = mme->peer;
- /* Nothing to send. */
- /* Change state. */
- cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, CC_ASSOC_CNF, ok);
- }
- }
-}
-
-void
-cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (ctx, mme,
- false);
-}
-
-void
-cp_sta_action_assoc__sc_wait_assoc_cnf__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- cp_sta_action_assoc__wait_assoc_cnf__cc_assoc_cnf__common (ctx, mme,
- true);
-}
-
-void
-cp_sta_action_assoc__wait_assoc_cnf__timeout_common (cp_t *ctx, bool sc)
-{
- dbg_assert (ctx);
- ctx->sta_action.assoc.retry--;
- if (ctx->sta_action.assoc.retry)
- {
- /* Restart timer. */
- cp_sta_action_assoc__start_retry_timer (ctx);
- /* Resend association request. */
-
- cp_sta_action_assoc__unassociated__to_assoc (ctx);
- if (!sc)
- cp_fsm_branch (ctx, WAIT_ASSOC_CONF, assoc_timeout, retry);
- else
- cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, assoc_timeout, retry);
- }
- else
- {
- /* Give up. */
- if (!sc)
- cp_fsm_branch (ctx, WAIT_ASSOC_CONF, assoc_timeout, no_retry);
- else
- cp_fsm_branch (ctx, SC_WAIT_ASSOC_CONF, assoc_timeout, no_retry);
- /* Black list the net. */
- cp_sta_t *sta =
- cp_sta_mgr_sta_get_from_mac (
- ctx, ctx->sta_action.assoc.peer.mac);
- if (sta)
- {
- cp_net_t *net = cp_sta_get_net (sta);
- slab_release (sta);
- cp_net_blacklisted_status_set (ctx, net, true);
- }
- }
-}
-
-void
-cp_sta_action_assoc__wait_assoc_cnf__timeout (cp_t *ctx)
-{
- cp_sta_action_assoc__wait_assoc_cnf__timeout_common (ctx, false);
-}
-
-void
-cp_sta_action_assoc__sc_wait_assoc_cnf__timeout (cp_t *ctx)
-{
- cp_sta_action_assoc__wait_assoc_cnf__timeout_common (ctx, true);
-}
-
-void
-cp_sta_action_assoc__cm_get_key_cnf__common (cp_t *ctx, cp_mme_rx_t
- *mme, bool sc)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- cp_msg_cm_get_key_cnf_t cnf;
- /* Check response. */
- if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.assoc.peer)
- || !cp_msg_cm_get_key_cnf_receive (ctx, mme, &cnf)
- || (!cp_secu_protocol_check
- (&ctx->sta_action.assoc.prun, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_LAST))
- || cnf.nid != cp_sta_own_data_get_nid (ctx)
- || cnf.key_type != CP_MSG_KEY_NEK
- || (sc && mme->peks != CP_MME_PEKS_NMK))
- {
- /* Unrelated message, drop. */
- if (!sc)
- cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, unrelated);
- else
- cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, unrelated);
- }
- else if (cnf.result != CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED)
- {
- /* Failure indication. */
- if (!sc)
- cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, nok);
- else
- cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, nok);
- /* Black list the net. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_net_blacklisted_status_set (ctx, our_net, true);
- }
- else
- {
- /* Use the new key. */
- cp_sta_own_data_set_authenticated_status (ctx, true);
- cp_beacon_change_nek (ctx, cnf.eks, cnf.key, true);
- /* Signal joined state. */
- cp_fsm_trigger_new_event (ctx, bare, joined);
- /* Reset beacon loss counter. */
- ctx->sta_action.assoc.beacon_loss = 0;
- if (!sc)
- cp_fsm_branch (ctx, ASSOCIATED, CM_GET_KEY_CNF_PID0, ok);
- else
- cp_fsm_branch (ctx, SC_NMK_EXCHANGED, CM_GET_KEY_CNF_PID0, ok);
- }
-}
-
-void
-cp_sta_action_assoc__sc_nmk_exchanged__cm_get_key_cnf_pid_0 (cp_t *ctx,
- cp_mme_rx_t *
- mme)
-{
- cp_sta_action_assoc__cm_get_key_cnf__common (ctx, mme, true);
-}
-
-void
-cp_sta_action_assoc__authenticated__cm_get_key_cnf_pid_1 (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- cp_msg_cm_get_key_cnf_t cnf;
-
- /* Get our cco peer. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
-
- /* Check response. */
- if (cp_mme_peer_cmp (&mme->peer, &peer)
- && cp_msg_cm_get_key_cnf_receive (ctx, mme, &cnf)
- && (cp_secu_protocol_check
- (&ctx->sta_action.nek_prun, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_LAST))
- && cnf.nid == cp_sta_own_data_get_nid (ctx)
- && cnf.key_type == CP_MSG_KEY_NEK
- && mme->peks == CP_MME_PEKS_NMK
- && cnf.result == CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED)
- {
- /* Use the new key. */
- cp_beacon_change_nek (ctx, cnf.eks, cnf.key, false);
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__nek_request (cp_t *ctx)
-{
- cp_msg_cm_get_key_req_t get_key = {
- .relayed = false, .key_type = CP_MSG_KEY_NEK,
- .nid = cp_sta_own_data_get_nid (ctx) };
- cp_mme_peer_t cco_peer;
- cp_net_get_cco_peer (ctx, cp_sta_mgr_get_our_avln (ctx),
- &cco_peer);
- cp_secu_protocol_run_new (&ctx->sta_action.nek_prun,
- 1, &ctx->rnd);
-
- cp_msg_cm_get_key_req_send (ctx, &cco_peer,
- CP_MME_PEKS_NMK,
- &ctx->sta_action.nek_prun,
- &get_key);
-}
-
-void
-cp_sta_action_assoc__associated__cm_get_key_cnf_pid_0 (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- cp_sta_action_assoc__cm_get_key_cnf__common (ctx, mme, false);
-}
-
-void
-cp_sta_action_assoc__associated__timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Stop lease timer. */
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.assoc.lease_timer);
-}
-
-void
-cp_sta_action_assoc__associated__to_leave (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Stop lease timer. */
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.assoc.lease_timer);
-}
-
-void
-cp_sta_action_assoc__sc_associated__cm_get_key_req_pid_3 (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- /* Check parameters. */
- dbg_assert (ctx);
- dbg_assert (mme);
-
- cp_msg_cm_get_key_req_t req;
- /* Check response (note, the MME should be sent by the STA with which are
- * doing the SC (it can be different from the CCo); */
- if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.sc.peer)
- || !cp_msg_cm_get_key_req_receive (ctx, mme, &req)
- || (!cp_secu_protocol_check
- (NULL, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW))
- || (req.nid != cp_sta_own_data_get_nid (ctx))
- || (req.key_type != CP_MSG_KEY_HASH_KEY)
- || (mme->peks != CP_MME_PEKS_SPC_NOT_EMBEDDED)
- )
- {
- /* Unrelated message, drop it. */
- cp_fsm_branch (ctx, SC_ASSOCIATED, CM_GET_KEY_REQ_PID3, unrelated);
- }
- else
- {
- /* Message is valid, reply. */
- /* Copy security protocol run for authentication. */
- ctx->sta_action.assoc.prun = mme->prun;
- /* Prepare message. */
- cp_msg_cm_get_key_cnf_t cnf;
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- cnf.key_type = CP_MSG_KEY_HASH_KEY;
- cnf.nid = cp_sta_own_data_get_nid (ctx);
- cnf.eks = CP_MME_PEKS_TEK_MIN;
- /* Generate an hash key. */
- cp_secu_generate_hash (ctx, lib_rnd32 (&ctx->rnd), (u8 *) cnf.hash_key,
- CP_SECU_HASH_KEY_FOR_TEK_SIZE);
- /* Generate TEK with hash key from CM_HET_KEY REQ and CNF. */
- cp_secu_tek_gen (req.hash_key, cnf.hash_key,
- &ctx->sta_action.sc.tek);
- /* Send CM_GET_KEY.CNF. */
- cp_secu_protocol_next (&ctx->sta_action.assoc.prun, &ctx->rnd, false);
- cp_msg_cm_get_key_cnf_send (ctx, &ctx->sta_action.sc.peer,
- CP_MME_PEKS_SPC_NOT_EMBEDDED,
- &ctx->sta_action.assoc.prun,
- &cnf);
- /* Set TEK for encryption/decryption of cm_encrypted payload. */
- cp_sta_own_data_set_tek (ctx, ctx->sta_action.sc.tek);
- cp_fsm_branch (ctx, SC_ASSOCIATED, CM_GET_KEY_REQ_PID3, ok);
- }
-}
-
-void
-cp_sta_action_assoc__sc_tek_exchanged__cm_set_key_req_pid_3 (cp_t *ctx,
- cp_mme_rx_t
- *mme)
-{
- /* Check parameters. */
- dbg_assert (ctx);
- dbg_assert (mme);
-
- cp_msg_cm_set_key_req_t req;
- /* Check response (note, the MME should be sent by the STA with which are
- * doing the SC (it can be different from the CCo); */
- if (!cp_mme_peer_cmp (&mme->peer, &ctx->sta_action.sc.peer)
- || !cp_msg_cm_set_key_req_receive (ctx, mme, &req)
- || (!cp_secu_protocol_check
- (&ctx->sta_action.assoc.prun, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT))
- || (req.nid != cp_sta_own_data_get_nid (ctx))
- || (req.key_type != CP_MSG_KEY_NMK)
- )
- {
- /* Unrelated message, drop it. */
- cp_fsm_branch (ctx, SC_TEK_EXCHANGED, CM_SET_KEY_REQ_PID3, unrelated);
- }
- else
- {
- /* Message is valid. */
- /* Set NMK. */
- cp_sta_own_data_set_nmk (
- ctx,
- req.new_key,
- CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL);
- /* Copy security protocol run for authentication. */
- ctx->sta_action.assoc.prun = mme->prun;
- /* Prepare message for reply. */
- cp_msg_cm_set_key_cnf_t cnf;
- cnf.result = CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS;
- cnf.cco_cap = CP_CCO_LEVEL;
- /* Send CM_SET_KEY.CNF. */
- cp_secu_protocol_next (&ctx->sta_action.assoc.prun, &ctx->rnd, true);
- cp_msg_cm_set_key_cnf_send (ctx, &ctx->sta_action.sc.peer,
- CP_MME_PEKS_NMK,
- &ctx->sta_action.assoc.prun,
- &cnf);
- /* Start authentication. */
- cp_msg_cm_get_key_req_t get_key = {
- .relayed = false, .key_type = CP_MSG_KEY_NEK,
- .nid = cp_sta_own_data_get_nid (ctx) };
- cp_secu_protocol_run_new (&ctx->sta_action.assoc.prun, 0,
- &ctx->rnd);
- cp_msg_cm_get_key_req_send (ctx, &ctx->sta_action.assoc.peer,
- CP_MME_PEKS_NMK,
- &ctx->sta_action.assoc.prun, &get_key);
- cp_fsm_branch (ctx, SC_TEK_EXCHANGED, CM_SET_KEY_REQ_PID3, ok);
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__leave (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Stop lease timer. */
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.assoc.lease_timer);
-}
-
-void
-cp_sta_action_assoc__authenticated__renew (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Restart timer. */
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_renew);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.lease_timer,
- event, RENEW_MARGIN_MS / 2);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Send CC_ASSOC.REQ to renew lease. */
- cp_msg_cc_assoc_req_t req = {
- CP_MSG_CC_ASSOC_REQ_TYPE_RENEW,
- cp_sta_own_data_get_nid (ctx),
- CP_CCO_LEVEL, CP_PCO_CAP
- };
- cp_msg_cc_assoc_req_send (ctx, &peer, &req);
-}
-
-void
-cp_sta_action_assoc__authenticated__cc_assoc_cnf (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Check received message. */
- cp_msg_cc_assoc_cnf_t cnf;
- if (cp_mme_peer_cmp (&mme->peer, &peer)
- && cp_msg_cc_assoc_cnf_receive (ctx, mme, &cnf)
- && cnf.result == CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS
- && cnf.nid == cp_sta_own_data_get_nid (ctx))
- {
- /* Update lease. */
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.assoc.lease_timer);
- int lease_time_ms = cnf.lease_time_min * 60 * 1000 - RENEW_MARGIN_MS;
- if (lease_time_ms > 0)
- {
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_renew);
- cp_sta_core_gen_timed_event (ctx,
- &ctx->sta_action.assoc.lease_timer,
- event, lease_time_ms);
- }
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__cm_set_key_req_pid_1 (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Check received message. */
- cp_msg_cm_set_key_req_t req;
-
- if (cp_mme_peer_cmp (&mme->peer, &peer)
- && cp_msg_cm_set_key_req_receive (ctx, mme, &req)
- && req.nid == cp_sta_own_data_get_nid (ctx))
- {
- if ((req.key_type == CP_MSG_KEY_NEK)
- && (mme->peks == CP_MME_PEKS_NMK)
- && (cp_secu_protocol_check
- (&ctx->sta_action.nek_prun, &mme->prun,
- CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEXT)))
- {
- ctx->sta_action.nek_prun = mme->prun;
- /* Send response. */
- cp_msg_cm_set_key_cnf_t cnf = {
- CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
- CP_CCO_LEVEL };
- cp_secu_protocol_next (&ctx->sta_action.nek_prun, &ctx->rnd,
- true);
- cp_msg_cm_set_key_cnf_send (ctx, &peer, CP_MME_PEKS_NMK,
- &ctx->sta_action.nek_prun,
- &cnf);
- /* Update NEK. */
- cp_beacon_change_nek (ctx, req.new_eks, req.new_key, false);
- }
- else if ((req.key_type == CP_MSG_KEY_NONCE_ONLY)
- && (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED
- || mme->peks == CP_MME_PEKS_NONE)
- && (cp_secu_protocol_check
- (NULL, &mme->prun, CP_SECU_PROTOCOL_RUN_CHECK_RESULT_NEW)))
- {
- /* Send response. */
- cp_msg_cm_set_key_cnf_t cnf = {
- CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
- CP_CCO_LEVEL };
-
- ctx->sta_action.nek_prun = mme->prun;
- cp_secu_protocol_next (&ctx->sta_action.nek_prun, &ctx->rnd,
- false);
- ctx->sta_action.nek_prun.my_nonce = lib_rnd32 (&ctx->rnd);
- cp_msg_cm_set_key_cnf_send (ctx, &peer, mme->peks,
- &ctx->sta_action.nek_prun,
- &cnf);
- }
- }
- else
- {
- /* Send response. */
- cp_msg_cm_set_key_cnf_t cnf = {
- CP_MSG_CM_SET_KEY_CNF_RESULT_FAILURE,
- CP_CCO_LEVEL };
- cp_secu_protocol_run_t prun = mme->prun;
- prun.my_nonce = lib_rnd32 (&ctx->rnd);
- cp_secu_protocol_next (&prun, &ctx->rnd, true);
- cp_msg_cm_set_key_cnf_send (ctx, &peer, CP_MME_PEKS_NONE, &prun,
- &cnf);
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__to_leave (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- /* If we were the CCo and we cannot provide the CCo role to another
- * station (Handover failure because no station were authenticated in the
- * AVLN) we must not send any MME to the CCo. */
- cp_sta_t *cco = cp_net_get_cco (ctx, our_net);
- if (cco)
- {
- cp_mme_peer_t peer;
- cp_sta_get_peer (cco, &peer);
- /* Start timer. */
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
- LEAVING_TIMEOUT_MS);
- /* Send leave request. */
- cp_msg_cc_leave_req_send (ctx, &peer,
- CP_MSG_CC_LEAVE_REQ_REASON_USER_REQUEST);
- slab_release (cco);
- /* Branch to the LEAVING state. */
- cp_fsm_branch (ctx, AUTHENTICATED, to_leave, cco);
- }
- else
- {
- /* Branch to the UNASSOCIATED state. */
- cp_fsm_branch (ctx, AUTHENTICATED, to_leave, no_cco);
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__cc_leave_ind (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Check received message. */
- enum cp_msg_cc_leave_ind_reason_t reason;
- cp_nid_t nid;
- if (cp_mme_peer_cmp (&mme->peer, &peer)
- && cp_msg_cc_leave_ind_receive (ctx, mme, &reason, &nid)
- && nid == cp_sta_own_data_get_nid (ctx))
- {
- cp_msg_cc_leave_rsp_send (ctx, &mme->peer);
- cp_fsm_branch (ctx, AUTHENTICATED, CC_LEAVE_IND, ok);
- }
- else
- {
- cp_fsm_branch (ctx, AUTHENTICATED, CC_LEAVE_IND, nok);
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__beacon (cp_t *ctx,
- bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (beacon);
- dbg_assert (net);
- dbg_assert (sta);
- if (cp_net_get_nid (ctx, net) == cp_sta_own_data_get_nid (ctx)
- && cp_net_get_snid (ctx, net) == cp_sta_own_data_get_snid (ctx))
- {
- /* Only on central beacon, no support for proxy networking. */
- if (cp_sta_get_cco_status (sta))
- {
- ctx->sta_action.assoc.beacon_loss = 0;
- }
- }
-}
-
-void
-cp_sta_action_assoc__authenticated__beacon_not_received (cp_t *ctx)
-{
- dbg_assert (ctx);
- ctx->sta_action.assoc.beacon_loss++;
- if (ctx->sta_action.assoc.beacon_loss > CP_MAX_NO_BEACON)
- {
- cp_fsm_trigger_new_event (ctx, bare, avln_failure);
- cp_fsm_branch (ctx, AUTHENTICATED, BEACON_NOT_RECEIVED, avln_failure);
- }
- else
- cp_fsm_branch (ctx, AUTHENTICATED, BEACON_NOT_RECEIVED, else);
-}
-
-void
-cp_sta_action_assoc__leaving__cc_leave_cnf (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Check received message. */
- if (cp_mme_peer_cmp (&mme->peer, &peer))
- {
- /* Ignore bad MME (confirmation is sufficient, we do not expect any
- * parameter). */
- cp_msg_cc_leave_cnf_receive (ctx, mme);
- /* Stop timer. */
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.assoc.timer);
- cp_fsm_branch (ctx, LEAVING, CC_LEAVE_CNF, ok);
- }
- else
- {
- cp_fsm_branch (ctx, LEAVING, CC_LEAVE_CNF, unrelated);
- }
-}
-
-void
-cp_sta_action_assoc__leaving__timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Get our CCo. */
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- cp_mme_peer_t peer;
- cp_net_get_cco_peer (ctx, our_net, &peer);
- /* Send leave request again. */
- cp_msg_cc_leave_req_send (ctx, &peer,
- CP_MSG_CC_LEAVE_REQ_REASON_USER_REQUEST);
-}
-
-void
-cp_sta_action_assoc__leave_wait__enter (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Start timer. */
- cp_fsm_event_t *event = cp_fsm_event_bare_new (
- ctx, CP_FSM_EVENT_TYPE_assoc_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.assoc.timer, event,
- LEAVE_WAIT_TIMEOUT_MS);
-}
-
-void
-cp_sta_action_assoc__leave_wait__timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
-}
-
-void
-cp_sta_action_unassoc__unassoc__enter (cp_t *ctx)
-{
- dbg_assert (ctx);
- bsu_beacon_t beacon;
- /* Update the BSU. */
- cp_beacon_fill (ctx, &beacon);
- bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
-}
diff --git a/cesar/cp/sta/action/src/drv.c b/cesar/cp/sta/action/src/drv.c
index 58a0984931..ac110950e6 100644
--- a/cesar/cp/sta/action/src/drv.c
+++ b/cesar/cp/sta/action/src/drv.c
@@ -170,25 +170,6 @@ cp_sta_action_drv__stopped__drv_sta_set_avln_hfid_req (cp_t *ctx,
}
void
-cp_sta_action_drv__stopped__drv_sta_set_tonemask_req (cp_t *ctx,
- cp_mme_rx_t *mme)
-{
- u32 tonemask[PHY_TONEMASK_WORDS];
- bool ok = cp_msg_drv_sta_set_tonemask_req_receive (ctx, mme, tonemask);
- if (ok)
- {
- /* Commit to mac configuration and update tonemask informations. */
- memcpy (ctx->mac_config->tonemask_info.tonemask, tonemask,
- sizeof (tonemask));
- tonemask_update (&ctx->mac_config->tonemask_info);
- /* Tonemask will be programmed once the PBProc is activated. */
- }
- cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_TONEMASK_CNF,
- ok ? CP_MSG_DRV_RESULT_SUCCESS
- : CP_MSG_DRV_RESULT_FAILURE);
-}
-
-void
cp_sta_action_drv__stopped__drv_sta_mac_start_req (cp_t *ctx,
cp_mme_rx_t *mme)
{
@@ -251,147 +232,6 @@ cp_sta_action_drv__drv_sta_sc_common (cp_t *ctx, cp_mme_rx_t *mme,
}
void
-cp_sta_action_drv__usta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
-{
- bool sc_join;
-
- /* Decode driver MME. */
- cp_sta_action_drv__drv_sta_sc_common (ctx, mme, true, &sc_join);
- if (sc_join)
- {
- /* Start SC JOIN procedure. */
- cp_sta_action_sc__start_sc_join (ctx);
- }
- else
- {
- /* Start SC ADD procedure. */
- cp_sta_action_sc__start_sc_add (ctx);
- }
-}
-
-void
-cp_sta_action_drv__ucco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
-{
- bool sc_join;
-
- /* Decode driver MME. */
- cp_sta_action_drv__drv_sta_sc_common (ctx, mme, true, &sc_join);
- if (sc_join)
- {
- /* Start SC JOIN procedure. */
- cp_sta_action_sc__start_sc_join (ctx);
- }
- else
- {
- /* Start SC ADD procedure. */
- cp_sta_action_sc__start_sc_add (ctx);
- }
-}
-
-void
-cp_sta_action_drv__cco__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
-{
- bool sc_join;
-
- /* Decode driver MME. */
- cp_sta_action_drv__drv_sta_sc_common (ctx, mme, false, &sc_join);
- if (!sc_join)
- {
- /* Start SC ADD procedure. */
- cp_sta_action_sc__start_sc_add (ctx);
- cp_fsm_branch (ctx, CCO, DRV_STA_SC_REQ, sc_add);
- }
- else
- {
- /* SC JOIN disabled. */
- cp_fsm_branch (ctx, CCO, DRV_STA_SC_REQ, sc_join);
- }
-}
-
-void
-cp_sta_action_drv__sta__drv_sta_sc (cp_t *ctx, cp_mme_rx_t *mme)
-{
- bool sc_join;
-
- cp_sta_action_drv__drv_sta_sc_common (ctx, mme, false, &sc_join);
- if (!sc_join)
- {
- /* Start SC ADD procedure. */
- cp_sta_action_sc__start_sc_add (ctx);
- cp_fsm_branch (ctx, STA, DRV_STA_SC_REQ, sc_add);
- }
- else
- {
- /* SC JOIN disabled. */
- cp_fsm_branch (ctx, STA, DRV_STA_SC_REQ, sc_join);
- }
-}
-
-void
-cp_sta_action_drv__many__drv_sta_sc__failure (cp_t *ctx, cp_mme_rx_t *mme)
-{
- /* Check parameters. */
- dbg_assert (ctx);
- dbg_assert (mme);
-
- cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SC_CNF,
- CP_MSG_DRV_RESULT_FAILURE);
-}
-
-void
-cp_sta_action_drv__stopped__drv_sta_set_key_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
- cp_key_t nmk;
- enum cp_msg_drv_sta_set_key_type_t type;
- cp_nid_t nid;
- cp_security_level_t sl;
-
- dbg_assert (ctx);
- dbg_assert (mme);
-
- /* Try to decode the DRV MME. */
- if (cp_msg_drv_sta_set_key_req_receive (ctx, mme, &nmk, &type, &nid, &sl))
- {
- /* We need to have a NID; let's build it if we do not have one. */
- if (type == CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL)
- {
- /* Build NID from SL and NMK. */
- nid = cp_secu_nmk2nid (ctx, nmk, sl);
- }
-
- /* Set the NMK. */
- uint i;
- cp_key_t current_key = cp_sta_own_data_get_nmk (ctx);
-
- for (i = 0; i < COUNT(nmk.key) ;i++)
- if (nmk.key[i] != current_key.key[i])
- break;
-
- if ((i < COUNT(nmk.key)) || (nid != cp_sta_own_data_get_nid (ctx)))
- {
- /** save parameters as new ones. */
- ctx->sta_action.poweron.enter.need_set = true;
- ctx->sta_action.poweron.enter.nmk = nmk;
- ctx->sta_action.poweron.enter.type = type;
- ctx->sta_action.poweron.enter.nid = nid;
-
- /* Leave current avln to restart association. */
- cp_fsm_trigger_new_event (ctx, bare, to_stop);
- }
-
- /* Reply with success. */
- cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_KEY_CNF,
- CP_MSG_DRV_RESULT_SUCCESS);
- }
- else
- {
- /* Error in decoding, let's reply with an error. */
- cp_msg_drv_any_cnf_send (ctx, &mme->peer, DRV_STA_SET_KEY_CNF,
- CP_MSG_DRV_RESULT_FAILURE);
- }
-}
-
-void
cp_sta_action_drv__stopped__drv_sta_set_dak_req (cp_t *ctx, cp_mme_rx_t *mme)
{
cp_key_t dak;
diff --git a/cesar/cp/sta/action/src/misc.c b/cesar/cp/sta/action/src/misc.c
index 58595148b7..aa93219262 100644
--- a/cesar/cp/sta/action/src/misc.c
+++ b/cesar/cp/sta/action/src/misc.c
@@ -26,6 +26,7 @@
#include "mac/common/timings.h"
#include "cp/fsm/fsm.h"
#include "cp/cco/action/cco_action.h"
+#include "cp/sta/action/misc.h"
#include "build_info.h"
@@ -767,148 +768,3 @@ cp_sta_action_get_average_ble (cp_t *ctx, cp_tei_t tei, bool tx,
return average_ble;
}
-
-void
-cp_sta_action_process_cc_discover_list_req (cp_t *ctx, cp_mme_rx_t *rx_mme)
-{
- dbg_assert (ctx);
- dbg_assert (rx_mme);
-
- if (cp_msg_cc_discover_list_req_receive (ctx, rx_mme))
- {
- cp_mme_tx_t *tx_mme;
- cp_msg_cc_discover_list_ctx_t disc_ctx;
- cp_net_t *our_net = NULL;
-
- /* Check if our station is associated in a network. */
- if (cp_sta_own_data_get_tei (ctx) != MAC_TEI_UNASSOCIATED)
- {
- our_net = cp_sta_mgr_get_our_avln(ctx);
- }
-
- /* Prepare CC_DISCOVER_LIST.CNF */
- tx_mme = cp_msg_cc_discover_list_cnf_send_begin (ctx, &rx_mme->peer,
- cp_sta_mgr_get_num_discovered_stas (ctx),
- cp_sta_mgr_get_num_discovered_net (ctx),
- &disc_ctx);
-
- /* Send NumStation */
- cp_msg_cc_discover_list_cnf_send_stations_begin (ctx, tx_mme,
- &disc_ctx);
-
- /* Get stations informations for each existing network. */
- cp_net_t *net;
- for (net = cp_sta_mgr_get_first_avln (ctx); net;
- net = cp_sta_mgr_get_next_avln (ctx, net))
- {
- /* Collect info valid for all stations of this net. */
- cp_msg_cc_discover_list_sta_t list;
-
- list.snid = cp_net_get_snid (ctx, net);
- list.access = cp_net_get_access (ctx, net);
-
- /* For all kind of association states we seek stations. */
- cp_net_sta_status_t assoc;
-
- for (assoc = 0; assoc < CP_NET_STA_NB; assoc++)
- {
- /* Check association. */
- if ((assoc == CP_NET_STA_ASSOC) && (net == our_net))
- list.same_network = CC_DISCOVER_LIST_NET_SAME_NETWORK;
- else
- list.same_network = CC_DISCOVER_LIST_NET_DIFFERENT_NETWORK;
-
- cp_sta_t *cp_sta;
-
- for (cp_sta = cp_net_sta_get_first (ctx, net, assoc);
- cp_sta;
- cp_sta = cp_net_sta_get_next (ctx, net, cp_sta))
- {
- list.mac_addr = cp_sta_get_mac_address (cp_sta);
- list.tei = cp_sta_get_tei (cp_sta);
- list.cco_cap = cp_sta->cco_cap;
- list.proxy_cap = cp_sta->pco_cap;
- list.backup_cco_cap = cp_sta->backup_cco_cap;
- list.cco_status = cp_sta_get_cco_status (cp_sta);
- list.pco_status = cp_sta_get_pco_status (cp_sta);
- list.backup_cco_status = cp_sta->is_backup_cco;
- list.signal_level = 0x00;
-
- /** Compute average ble of the sta. */
- if (list.same_network == CC_DISCOVER_LIST_NET_SAME_NETWORK)
- list.average_ble =
- cp_sta_action_get_average_ble (ctx, list.tei, true,
- true);
- else
- list.average_ble = 0;
-
- cp_msg_cc_discover_list_cnf_send_station (ctx, tx_mme,
- &list);
- }
- }
- }
-
- /* Send NumNetwork */
- cp_msg_cc_discover_list_cnf_send_net_begin (ctx, tx_mme, &disc_ctx);
-
- /* For each present network but our network if we have one. */
- for (net = cp_sta_mgr_get_first_avln (ctx); net;
- net = cp_sta_mgr_get_next_avln (ctx, net))
- {
- if (our_net != net)
- {
- /* Collect info for all valid net */
- cp_msg_cc_discover_list_net_t data;
-
- data.nid = cp_net_get_nid (ctx, net);
- data.snid = cp_net_get_snid (ctx, net);
- data.access = cp_net_get_access (ctx, net);
- data.hm = net->hm;
- data.numslots = net->avln_num_slots;
-
- if (net->network_mode == MAC_NM_COORDINATED)
- /* Unsupported. */
- data.coordinated_status =
- CC_DISCOVER_LIST_COORD_COORDINATED_GROUP_UNKNOWN;
- else
- data.coordinated_status =
- CC_DISCOVER_LIST_COORD_NON_COORDINATED;
- data.offset = 0;
-
- cp_msg_cc_discover_list_cnf_send_net (ctx, tx_mme, &data);
- }
- }
-
- cp_msg_cc_discover_list_cnf_send_end (ctx, tx_mme);
- }
-}
-
-void
-cp_sta_action_poweron__cco__join_timeout_sc_failed (
- cp_t *ctx,
- cp_fsm_branch_t branch_no_sta_no_avln,
- cp_fsm_branch_t branch_no_sta_avln,
- cp_fsm_branch_t branch_sta)
-{
- dbg_assert (ctx);
- cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
- if (cp_net_is_empty (ctx, our_net))
- {
- if (cp_sta_mgr_net_list_is_empty (ctx))
- {
- cp_cco_action_cco__to_ucco (ctx);
- cp_fsm_branch_ (ctx, branch_no_sta_no_avln);
- }
- else
- {
- /* Leave CCo role. */
- cp_cco_action_cco__unassoc_stop (ctx);
- cp_fsm_branch_ (ctx, branch_no_sta_avln);
- }
- }
- else
- {
- /* Ok, stay CCo. */
- cp_fsm_branch_ (ctx, branch_sta);
- }
-}
diff --git a/cesar/cp/sta/action/src/poweron.c b/cesar/cp/sta/action/src/poweron.c
index 2384f64a0c..1e736f9032 100644
--- a/cesar/cp/sta/action/src/poweron.c
+++ b/cesar/cp/sta/action/src/poweron.c
@@ -19,65 +19,13 @@
#include "cp/sta/mgr/sta_mgr.h"
#include "cp/fsm/fsm.h"
#include "cp/beacon/beacon.h"
-#include "cp/beacon/discover.h"
#include "cp/cco/action/cco_action.h"
#include "bsu/bsu.h"
#include "lib/slab.h"
#include "cp/inc/context.h"
-#include "cp/sta/action/inc/action.h"
-
-#define ALL_STA_LEAVED_TIMEOUT_MS 1000
-
-void
-cp_sta_action_poweron_init (cp_t *ctx)
-{
- dbg_assert (ctx);
- ctx->sta_action.poweron.enter.need_set = false;
-}
-
-void
-cp_sta_action_poweron__idle__enter (cp_t *ctx)
-{
- if (ctx->sta_action.poweron.enter.need_set)
- {
- /* TODO: Changing the KEY should be handled by a new State in the
- * Started FSM see #2800 */
- cp_fsm_post_new_event (ctx, bare, to_poweron);
- }
-}
-
-/**
- * Start USTT timer.
- * \param ctx control plane context
- * \param ustt_ms USTT timer approximated value
- */
-static void
-cp_sta_action_poweron_ustt_start (cp_t *ctx, uint ustt_ms)
-{
- cp_fsm_event_t *event;
- uint ustt_timeout_ms = ustt_ms / 2
- + lib_rnd_uniform (&ctx->rnd, ustt_ms);
- event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_ustt_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.ustt_timer,
- event, ustt_timeout_ms);
-}
-
-/**
- * Common handling of POWERON and USTA => USTT TIMEOUT.
- * \param ctx control plane context
- * \param ustt_ms USTT timer approximated value
- */
-static void
-cp_sta_action_poweron_ustt_timeout (cp_t *ctx, uint ustt_ms)
-{
- /* Send an CM_UNASSOCIATED_STA.IND. */
- cp_msg_cm_unassociated_sta_ind_send (
- ctx, &CP_MME_PEER (MAC_BROADCAST, MAC_TEI_UNASSOCIATED),
- cp_sta_own_data_get_nid (ctx), CP_CCO_LEVEL);
- cp_sta_action_poweron_ustt_start (ctx, ustt_ms);
-}
+#include "action.h"
void
cp_sta_action_poweron_start (cp_t *ctx)
@@ -90,313 +38,3 @@ cp_sta_action_poweron_stop (cp_t *ctx)
{
cp_fsm_trigger_new_event (ctx, bare, to_stop);
}
-
-void
-cp_sta_action_poweron__many__to_idle (cp_t *ctx)
-{
- dbg_assert (ctx);
- /* Cleanup. */
- pbproc_activate (ctx->pbproc, false);
- sar_activate (ctx->sar, false);
- sar_cleanup (ctx->sar);
- bsu_activate (ctx->bsu, false);
- cp_beacon_deactivate (ctx);
- /* Signal station is stopped. */
- cp_fsm_trigger_new_event (ctx, bare, stopped);
-}
-
-void
-cp_sta_action_poweron__idle__to_poweron (cp_t *ctx)
-{
- cp_beacon_poweron_init (ctx);
- bsu_power_on (ctx->bsu, cp_sta_own_data_get_snid (ctx));
- /* Update beacon data program a timer is a wrong values beacon ACLF is
- * still not initialised.*/
- bsu_activate (ctx->bsu, true);
- cp_beacon_reconfigure_timer (ctx, false);
- sar_activate (ctx->sar, true);
- pbproc_activate (ctx->pbproc, true);
-}
-
-void
-cp_sta_action_poweron__poweron__enter (cp_t *ctx)
-{
- cp_fsm_event_t *event;
- /* BTT timer. */
- uint btt_timeout_min_ms, btt_timeout_max_ms, btt_timeout_ms;
- if (cp_sta_own_data_get_was_cco (ctx))
- {
- btt_timeout_min_ms = CP_CCO_BEACON_SCAN_MIN_MS;
- btt_timeout_max_ms = CP_CCO_BEACON_SCAN_MAX_MS;
- }
- else
- {
- btt_timeout_min_ms = CP_BEACON_SCAN_MIN_MS;
- btt_timeout_max_ms = CP_BEACON_SCAN_MAX_MS;
- }
- btt_timeout_ms = lib_rnd_uniform (
- &ctx->rnd, btt_timeout_max_ms - btt_timeout_min_ms + 1)
- + btt_timeout_min_ms;
- event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_btt_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.btt_timer,
- event, btt_timeout_ms);
- /* USTT timer. */
- cp_sta_action_poweron_ustt_start (ctx, CP_USTA_IND_INTERVAL_MS);
-
- if (ctx->sta_action.poweron.enter.need_set)
- {
- cp_sta_own_data_set_nid (ctx, ctx->sta_action.poweron.enter.nid);
- cp_sta_own_data_set_nmk (ctx, ctx->sta_action.poweron.enter.nmk,
- ctx->sta_action.poweron.enter.type);
-
- ctx->sta_action.poweron.enter.need_set = false;
- }
-
- bsu_beacon_t beacon;
- cp_beacon_fill (ctx, &beacon);
- /* Act as STA, for BSU corresponds to only hear the central beacon from
- * the CCo. */
- bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
-}
-
-void
-cp_sta_action_poweron__poweron__leave (cp_t *ctx)
-{
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.poweron.btt_timer);
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.poweron.ustt_timer);
-}
-
-void
-cp_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_action_poweron_ustt_timeout (ctx, CP_USTA_IND_INTERVAL_MS);
-}
-
-/**
- * Search for the first USTA with the mac address lesser than our own mac
- * address.
- * \param ctx the module context.
- * \param net the AVLN to search in.
- * \return true if a station with a bigger mac address than our own mac
- * address.
- */
-static bool
-cp_sta_action_btt_timeout_usta_with_mac_bigger (cp_t *ctx, cp_net_t *net)
-{
- cp_sta_t *sta;
- bool sta_found = false;
- mac_t rmac = MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx));
- for (sta = cp_net_sta_get_first (ctx, net, CP_NET_STA_UNASSOC);
- sta && !sta_found;
- sta = cp_net_sta_get_next (ctx, net, sta))
- {
- if (sta->cco_cap > CP_CCO_LEVEL
- || (sta->cco_cap == CP_CCO_LEVEL
- && MAC_REVERSE (cp_sta_get_mac_address (sta)) > rmac))
- sta_found = true;
- }
- return sta_found;
-}
-
-void
-cp_sta_action_poweron__poweron__btt_timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
- bool iam_cco_on_my_nid = false, iam_cco_on_other_nid = true;
- cp_nid_t nid = cp_sta_own_data_get_nid (ctx);
- cp_net_t *net;
- for (net = cp_sta_mgr_get_first_avln (ctx);
- net;
- net = cp_sta_mgr_get_next_avln (ctx, net))
- {
- /* Search for AVLN with our NID. */
- if (cp_net_get_nid (ctx, net) == nid)
- {
- iam_cco_on_my_nid = iam_cco_on_other_nid =
- !cp_sta_action_btt_timeout_usta_with_mac_bigger (
- ctx, net)
- && !net->num_associated_stas;
- }
- /* Search for AVLN with another NID. */
- else if (iam_cco_on_other_nid)
- {
- iam_cco_on_other_nid = !net->num_associated_stas;
- }
- }
- if (iam_cco_on_my_nid)
- {
- cp_cco_action_cco__unassoc_start (ctx);
- cp_fsm_branch (ctx, POWERON, btt_timeout, nid_match_cco);
- }
- else if (iam_cco_on_other_nid)
- {
- cp_cco_action_ucco_start (ctx);
- cp_fsm_branch (ctx, POWERON, btt_timeout, no_avln);
- }
- else
- cp_fsm_branch (ctx, POWERON, btt_timeout, avln);
-}
-
-void
-cp_sta_action_poweron__poweron__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (beacon);
- dbg_assert (net);
- dbg_assert (sta);
- cp_sta_action_beacon_match_and_join (
- ctx, beacon, net, sta, false /* not in SC */,
- CP_FSM_BRANCH (POWERON, BEACON, nid_match),
- CP_FSM_BRANCH (POWERON, BEACON, no_nid_match));
-}
-
-void
-cp_sta_action_poweron__poweron_joining__left (cp_t *ctx)
-{
-}
-
-void
-cp_sta_action_poweron__joining__to_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_action_assoc_leave (ctx);
-}
-
-static inline void
-cp_sta_action_poweron__usta_usta_joining__enter (cp_t *ctx)
-{
- bsu_beacon_t beacon;
- if (MAC_TEI_IS_STA (cp_sta_own_data_get_tei (ctx)))
- cp_cco_action_cco__unassoc_stop (ctx);
- cp_beacon_fill (ctx, &beacon);
- bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_STA);
-}
-
-void
-cp_sta_action_poweron__usta__enter (cp_t *ctx)
-{
- cp_sta_action_poweron__usta_usta_joining__enter (ctx);
- cp_sta_action_poweron_ustt_start (ctx, CP_DISCOVER_PERIOD_MAX_MS);
-}
-
-void
-cp_sta_action_poweron__usta_joining__enter (cp_t *ctx)
-{
- cp_sta_action_poweron__usta_usta_joining__enter (ctx);
-}
-
-void
-cp_sta_action_poweron__usta__leave (cp_t *ctx)
-{
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.poweron.ustt_timer);
-}
-
-void
-cp_sta_action_poweron__usta__ustt_timeout (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_action_poweron_ustt_timeout (ctx, CP_DISCOVER_PERIOD_MAX_MS);
-}
-
-void
-cp_sta_action_poweron__usta__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (beacon);
- dbg_assert (net);
- dbg_assert (sta);
- cp_sta_action_beacon_match_and_join (
- ctx, beacon, net, sta, false /* not in SC */,
- CP_FSM_BRANCH (USTA, BEACON, nid_match),
- CP_FSM_BRANCH (USTA, BEACON, no_nid_match));
-}
-
-void
-cp_sta_action_poweron__usta__usta_ind (cp_t *ctx, cp_net_t *net,
- cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (net);
- dbg_assert (sta);
- if (cp_net_get_nid (ctx, net) != cp_sta_own_data_get_nid (ctx))
- {
- cp_fsm_branch (ctx, USTA, usta_ind, else);
- }
- else
- {
- if (sta->cco_cap > CP_CCO_LEVEL
- || (sta->cco_cap == CP_CCO_LEVEL
- && (MAC_REVERSE (cp_sta_get_mac_address (sta))
- > MAC_REVERSE (cp_sta_own_data_get_mac_address (ctx)))))
- cp_fsm_branch (ctx, USTA, usta_ind, else);
- else
- {
- cp_cco_action_cco__unassoc_start (ctx);
- cp_fsm_branch (ctx, USTA, usta_ind, nid_match_cco);
- }
- }
-}
-
-void
-cp_sta_action_poweron__usta_joining__left (cp_t *ctx)
-{
-}
-
-void
-cp_sta_action_poweron__ucco__beacon (cp_t *ctx, bsu_beacon_t *beacon,
- cp_net_t *net, cp_sta_t *sta)
-{
- dbg_assert (ctx);
- dbg_assert (beacon);
- dbg_assert (net);
- dbg_assert (sta);
- /* Stop UCCo behavior. */
- cp_cco_action_ucco_stop (ctx);
- /* Handle incoming beacon. */
- cp_sta_action_beacon_match_and_join (
- ctx, beacon, net, sta, false /* not in SC */,
- CP_FSM_BRANCH (UCCO, BEACON, nid_match),
- CP_FSM_BRANCH (UCCO, BEACON, no_nid_match));
-}
-
-void
-cp_sta_action_poweron__sta__to_stop (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_action_assoc_leave (ctx);
-}
-
-void
-cp_sta_action_poweron_cco__enter (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_fsm_event_t *event;
- event = cp_fsm_event_bare_new (ctx, CP_FSM_EVENT_TYPE_join_timeout);
- cp_sta_core_gen_timed_event (ctx, &ctx->sta_action.poweron.join_timer,
- event, CP_DISCOVER_PERIOD_MAX_MS);
-}
-
-void
-cp_sta_action_poweron_cco__leave (cp_t *ctx)
-{
- dbg_assert (ctx);
- cp_sta_core_stop_timed_or_cyclic_event (
- ctx, &ctx->sta_action.poweron.join_timer);
-}
-
-void
-cp_sta_action_poweron__cco__join_timeout (cp_t *ctx)
-{
- cp_sta_action_poweron__cco__join_timeout_sc_failed (
- ctx,
- CP_FSM_BRANCH (CCO, join_timeout, no_sta_no_avln),
- CP_FSM_BRANCH (CCO, join_timeout, no_sta_avln),
- CP_FSM_BRANCH (CCO, join_timeout, sta)
- );
-}
diff --git a/cesar/cp/sta/action/test/utest/Config b/cesar/cp/sta/action/test/utest/Config
new file mode 100644
index 0000000000..8e2dffb304
--- /dev/null
+++ b/cesar/cp/sta/action/test/utest/Config
@@ -0,0 +1 @@
+CONFIG_CP_UTEST = y
diff --git a/cesar/cp/sta/action/test/utest/Makefile b/cesar/cp/sta/action/test/utest/Makefile
deleted file mode 100644
index 9efa946f33..0000000000
--- a/cesar/cp/sta/action/test/utest/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-BASE = ../../../../..
-
-INCLUDES = cp/sta/action/test/utest cp/sta/action/test/utest/override
-
-HOST_PROGRAMS = test_sta_action
-test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c info.c key.c \
- poweron.c misc.c bridge.c sc.c handover.c \
- msg_stub.c dataplane_stub.c fsm_stub.c \
- core_stub.c beacon_stub.c cp_stub.c \
- cco_stub.c scenario_actions.c sc_test.c vs.c ce_stub.c \
- mac_sar_interface_stub.c
-test_sta_action_MODULES = lib lib/scenario cp/sta/action cp/sta/mgr \
- cp/fsm/stub cp/secu mac/common cl/stub cl \
- cp/cco/action/stub cp/beacon/stub cp/msg/stub \
- ce/stub mac/sar/stub cp/av/cco/bw/stub bsu/stub \
- hal/ipmbox/stub
-cp_fsm_MODULE_SOURCES = tables.c
-
-# For bridging MME tests.
-cl_stub_MODULE_SOURCES = cl.c cl_mactotei.c brg_rx.c
-cl_MODULE_SOURCES = bridge_table.c data_rate.c
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/action/test/utest/src/cco_stub.c b/cesar/cp/sta/action/test/utest/src/cco_stub.c
deleted file mode 100644
index ca8b33982d..0000000000
--- a/cesar/cp/sta/action/test/utest/src/cco_stub.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/cco_stub.c
- * \brief CCo stub.
- * \ingroup test
- */
-#include "common/std.h"
-#include "cp/cco/action/cco_action.h"
-
-#include "cp/sta/mgr/sta_mgr.h"
-#include "lib/scenario/scenario.h"
-
-void
-cp_cco_action_handover__start (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_cco__snid_conflict (cp_t *ctx)
-{
- dbg_assert (ctx);
- scenario_event (cp_cco_action_cco__cco_snid_conflict);
-}
-
-void
-cp_cco_action_cco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
-}
-
-void
-cp_cco_action_ucco__cc_assoc_req (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
-}
-
-void
-cp_cco_action_cco__cm_get_key_req_pid0 (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
-}
-
-void
-cp_cco_action_cco__cc_leave_req (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_cco_action_cco__cco_nek_change (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_tei_release (cp_t *ctx, u8 tei)
-{
-}
-
-void
-cp_cco_action__drv_mac_stop (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_tei_in_use (cp_t *ctx, cp_tei_t tei)
-{
-}
-
-void
-cp_cco_action_cco__cco_nek_change__nek_provide (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_cco__cco_nek_change__nek_timeout__wait (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
-{
-}
-
-void
-cp_cco_action_cco__cco_nek_change__timeout (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_nek_change_prevent (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_cco_selection__clear (cp_t *ctx)
-{
-}
-
-void
-cp_cco_action_cco__cm_get_key_req_pid1 (cp_t *ctx, cp_mme_rx_t * assoc_req)
-{
-}
-
-void
-cp_cco_action_cco__cc_discover_list_req (
- cp_t *ctx, cp_net_t *net, cp_sta_t *sta) __attribute__ ((weak));
-
-void
-cp_cco_action_cco__cc_discover_list_req (
- cp_t *ctx, cp_net_t *net, cp_sta_t *sta) {}
-
-void
-cp_cco_action_ucco_start (cp_t *ctx)
-{
- scenario_event (cp_cco_action_ucco_start);
-}
-
-void
-cp_cco_action_ucco_stop (cp_t *ctx)
-{
- scenario_event (cp_cco_action_ucco_stop);
-}
-
-void
-cp_cco_action_ucco__to_cco (cp_t *ctx)
-{
- scenario_event (cp_cco_action_ucco__to_cco);
-}
-
-void
-cp_cco_action_ucco__to_stop (cp_t *ctx)
-{
- scenario_event (cp_cco_action_ucco__to_stop);
-}
-
-void
-cp_cco_action_cco__to_ucco (cp_t *ctx)
-{
- scenario_event (cp_cco_action_cco__to_ucco);
-}
-
-void
-cp_cco_action_cco__unassoc_start (cp_t *ctx)
-{
- scenario_event (cp_cco_action_cco__unassoc_start);
-}
-
-void
-cp_cco_action_cco__unassoc_stop (cp_t *ctx)
-{
- scenario_event (cp_cco_action_cco__unassoc_stop);
-}
-
-void
-cp_cco_action_cco__assoc_start (cp_t *ctx)
-{
- scenario_event (cp_cco_action_cco__assoc_start);
-}
-
-void
-cp_cco_action_cco__assoc_stop (cp_t *ctx)
-{
- scenario_event (cp_cco_action_cco__assoc_stop);
-}
diff --git a/cesar/cp/sta/core/src/core.c b/cesar/cp/sta/core/src/core.c
index ab33992817..cc66f39234 100644
--- a/cesar/cp/sta/core/src/core.c
+++ b/cesar/cp/sta/core/src/core.c
@@ -53,6 +53,7 @@
#include "cp/cco/action/cco_action.h"
#include "cp/sta/mgr/sta_mgr.h"
#include "ce/rx/cp/cp.h"
+#include "cp/beacon/beacon.h"
#include "cp/sta/core/inc/core.h"
diff --git a/cesar/cp/sta/core/test/Config b/cesar/cp/sta/core/test/Config
new file mode 100644
index 0000000000..285d42d151
--- /dev/null
+++ b/cesar/cp/sta/core/test/Config
@@ -0,0 +1,2 @@
+CONFIG_CP_AV = n
+CONFIG_CP_EOC = n
diff --git a/cesar/cp/sta/core/test/Makefile.mk b/cesar/cp/sta/core/test/Makefile.mk
index 379a472919..1ea0298290 100644
--- a/cesar/cp/sta/core/test/Makefile.mk
+++ b/cesar/cp/sta/core/test/Makefile.mk
@@ -8,23 +8,28 @@ INCLUDES = cp/sta/core/test/override
TARGET_PROGRAMS = core_events core core_thread core_timer
core_events_SOURCES = core_events.c cp_cl_interf_stub.c action_stub.c \
- sta_mgr_stub.c pwl_stub.c beacon_stub.c
-core_events_MODULES = lib cp/sta/core cp/fsm/stub cp/cco/action/stub \
- ce/rx/cp/stub \
- $(SPARC_MODULES)
+ sta_mgr_stub.c pwl_stub.c
+core_events_MODULES = lib cp/sta/core cp/av/fsm/stub cp/cco/action/stub \
+ ce/rx/cp/stub cp/beacon/stub \
+ $(SPARC_MODULES)
+core_events_CONFIG_MODULES = cp
core_SOURCES = core.c cp_cl_interf_stub.c action_stub.c\
- sta_mgr_stub.c pwl_stub.c beacon_stub.c
-core_MODULES = lib cp/sta/core cp/fsm/stub cp/cco/action/stub \
- ce/rx/cp/stub \
- $(SPARC_MODULES)
+ sta_mgr_stub.c pwl_stub.c
+core_MODULES = lib cp/sta/core cp/av/fsm/stub cp/cco/action/stub \
+ ce/rx/cp/stub cp/beacon/stub \
+ $(SPARC_MODULES)
+core_CONFIG_MODULES = cp
core_thread_SOURCES = core_thread.c
-core_thread_MODULES = lib cp/sta/core cp/fsm/stub ce/rx/cp/stub \
- $(SPARC_MODULES)
-
-core_timer_SOURCES = core_timer.c
-core_timer_MODULES = lib cp/sta/core cp/fsm/stub ce/rx/cp/stub \
- $(SPARC_MODULES)
+core_thread_MODULES = lib cp/sta/core cp/av/fsm/stub ce/rx/cp/stub \
+ cp/cco/action/stub \
+ $(SPARC_MODULES)
+
+core_timer_SOURCES = core_timer.c sta_mgr_stub.c
+core_timer_MODULES = lib cp/sta/core cp/av/fsm/stub ce/rx/cp/stub \
+ cp/cco/action/stub \
+ $(SPARC_MODULES)
+core_timer_CONFIG_MODULES = cp
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/sta/core/test/src/beacon_stub.c b/cesar/cp/sta/core/test/src/beacon_stub.c
deleted file mode 100644
index d91490f6c4..0000000000
--- a/cesar/cp/sta/core/test/src/beacon_stub.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/beacon_stub.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-
-#include "cp/cp.h"
-
-void
-cp_beacon_get_and_process_beacon(cp_t *ctx)
-{
-}
diff --git a/cesar/cp/sta/core/test/src/core_thread.c b/cesar/cp/sta/core/test/src/core_thread.c
index 7538dace53..8910257a2f 100644
--- a/cesar/cp/sta/core/test/src/core_thread.c
+++ b/cesar/cp/sta/core/test/src/core_thread.c
@@ -212,7 +212,7 @@ cp_cco_action_garbage(cp_t *ctx)
}
void
-cp_sta_mgr_garbage(cp_t *ctx)
+cp_utest_sta_mgr_garbage(cp_t *ctx)
{
test_sta_mgr_garbage = true;
}
@@ -240,4 +240,3 @@ cp_sta_own_data_get_cco_status (cp_t *ctx)
{
return false;
}
-
diff --git a/cesar/cp/sta/core/test/src/core_timer.c b/cesar/cp/sta/core/test/src/core_timer.c
index bfb659c1d5..5f4808f01b 100644
--- a/cesar/cp/sta/core/test/src/core_timer.c
+++ b/cesar/cp/sta/core/test/src/core_timer.c
@@ -134,10 +134,3 @@ void
cp_beacon_get_and_process_beacon(cp_t *ctx)
{
}
-
-bool
-cp_sta_own_data_get_cco_status (cp_t *ctx)
-{
- return false;
-}
-
diff --git a/cesar/cp/sta/core/test/src/sta_mgr_stub.c b/cesar/cp/sta/core/test/src/sta_mgr_stub.c
index 8a27056ab4..2ff1efbf80 100644
--- a/cesar/cp/sta/core/test/src/sta_mgr_stub.c
+++ b/cesar/cp/sta/core/test/src/sta_mgr_stub.c
@@ -22,7 +22,7 @@
* \param ctx the module context.
*/
void
-cp_sta_mgr_garbage (cp_t *ctx)
+cp_utest_sta_mgr_garbage (cp_t *ctx)
{
}
diff --git a/cesar/cp/sta/mgr/inc/net.h b/cesar/cp/sta/mgr/inc/net.h
index ed3690b913..92f98f05d6 100644
--- a/cesar/cp/sta/mgr/inc/net.h
+++ b/cesar/cp/sta/mgr/inc/net.h
@@ -117,6 +117,19 @@ BEGIN_DECLS
cp_sta_t *
cp_net_release_station (cp_t *ctx, cp_net_t *net, cp_tei_t tei);
+/**
+ * Garbage function for the unassociated station list and the associated
+ * station list.
+ *
+ * \param ctx the module context.
+ * \param net the network.
+ * \param date_ms the current date in milliseconds.
+ * \param assoc the station list to expire.
+ */
+void
+cp_net_garbage_station_list (cp_t *ctx, cp_net_t *net, u32 date_ms,
+ cp_net_sta_status_t assoc);
+
END_DECLS
#endif /* cp_sta_mgr_inc_net */
diff --git a/cesar/cp/sta/mgr/inc/sta_mgr.h b/cesar/cp/sta/mgr/inc/sta_mgr.h
index 7ea53f9a82..2b42f9392e 100644
--- a/cesar/cp/sta/mgr/inc/sta_mgr.h
+++ b/cesar/cp/sta/mgr/inc/sta_mgr.h
@@ -49,5 +49,20 @@ struct cp_sta_mgr_t
slab_cache_t sta_slab_cache;
};
+BEGIN_DECLS
+
+/**
+ * Add a station to the station manager.
+ * \param ctx the CP context.
+ * \param net the network within the station exists.
+ * \param tei the station's TEI.
+ * \param mac_address the station's mac address.
+ * \return the newly created station.
+ */
+cp_sta_t*
+cp_sta_mgr_sta_add_realy (cp_t *ctx, cp_net_t *net, cp_tei_t tei,
+ mac_t mac_address);
+
+END_DECLS
#endif /* cp_sta_mgr_inc_context_h */
diff --git a/cesar/cp/sta/mgr/src/net.c b/cesar/cp/sta/mgr/src/net.c
index 350acd76d6..ffc9d18337 100644
--- a/cesar/cp/sta/mgr/src/net.c
+++ b/cesar/cp/sta/mgr/src/net.c
@@ -85,15 +85,6 @@ cp_net_station_unassoc_less (set_node_t *left, set_node_t *right)
return false;
}
-/**
- * Garbage function for the unassociated station list and the associated
- * station list.
- *
- * \param ctx the module context.
- * \param net the network.
- * \param date_ms the current date in milliseconds.
- * \param assoc the station list to expire.
- */
void
cp_net_garbage_station_list (cp_t *ctx, cp_net_t *net, u32 date_ms,
cp_net_sta_status_t assoc)
diff --git a/cesar/cp/sta/mgr/src/sta_mgr.c b/cesar/cp/sta/mgr/src/sta_mgr.c
index 4bddfc0d8d..50836c8731 100644
--- a/cesar/cp/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/src/sta_mgr.c
@@ -31,13 +31,6 @@
#include "cp/sta/mgr/inc/sta_mgr.h"
#include "cp/sta/mgr/inc/sta_own_data.h"
-/**
- * Elects a station in our AVLN to be the acknowledge station for all the
- * station to which the packet is send.
- * \param ctx the module context.
- *
- * This function choose the station randomly on the network.
- */
void
cp_sta_mgr_elects_sta_partial_ack (cp_t *ctx)
{
@@ -67,12 +60,7 @@ cp_sta_mgr_elects_sta_partial_ack (cp_t *ctx)
ctx->mac_config->partial_ack_tei_default = pack;
}
-/**
- * Compare two station with the mac address.
- * \param left the left station.
- * \param right the right station.
- */
-static bool
+bool
cp_sta_mgr_sta_mac_address_less (set_node_t *left, set_node_t *right)
{
cp_sta_private_t *sta_left;
@@ -94,15 +82,7 @@ cp_sta_mgr_sta_mac_address_less (set_node_t *left, set_node_t *right)
return false;
}
-/**
- * Get the first station from the release station list.
- * \param ctx the CP context.
- * \return the first station of the list.
- *
- * \warn It does not add a reference on the list, so a slab_release on the
- * station will free the station data, without removing it from the dataplane.
- */
-static cp_sta_t *
+cp_sta_t *
cp_sta_mgr_release_sta_get_first (cp_t *ctx)
{
cp_sta_t *sta = NULL;
@@ -119,15 +99,7 @@ cp_sta_mgr_release_sta_get_first (cp_t *ctx)
return sta;
}
-/**
- * Add a station to the station manager.
- * \param ctx the CP context.
- * \param net the network within the station exists.
- * \param tei the station's TEI.
- * \param mac_address the station's mac address.
- * \return the newly created station.
- */
-static cp_sta_t*
+cp_sta_t*
cp_sta_mgr_sta_add_realy (cp_t *ctx, cp_net_t *net, cp_tei_t tei,
mac_t mac_address)
{
@@ -191,76 +163,6 @@ cp_sta_mgr_sta_add_realy (cp_t *ctx, cp_net_t *net, cp_tei_t tei,
return &sta->public_data;
}
-static void
-cp_sta_mgr_sta_remove_common (cp_t *ctx, cp_sta_t * station)
-{
- set_t *set;
- cp_sta_private_t *sta = (cp_sta_private_t *) station;
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (sta);
- dbg_assert (sta->net);
-
- net = sta->net;
-
- // If the station is CCo, modify the net CCo pointer to NULL.
- if (cp_sta_get_cco_status(station))
- net->cco = NULL;
-
- // If the station is PCo to communicate with the CCo, modify the
- // pointer in the net.
- if (net->pco == station)
- net->pco = NULL;
-
- set = (cp_sta_get_tei (&sta->public_data)) ?
- &sta->net->associated_stas : &sta->net->unassociated_stas;
- /* Remove the station from its net. */
- set_remove (set, &sta->public_data.node_net);
-
- /* Remove the station from the station manager. If the mac address of the
- * station is broadcast, the station is not in the set. */
- if (sta->mac_address != MAC_BROADCAST)
- set_remove (&ctx->sta_mgr.stas, &sta->public_data.node_sta_mgr);
-
- /* decrease the visible counter. */
- if (sta->visible)
- sta->net->num_visible_stas --;
-
- /* decrease the number of stations. */
- sta->net->num_stas --;
-
- if (MAC_TEI_IS_STA (cp_sta_get_tei (&sta->public_data)))
- sta->net->num_associated_stas--;
- if (net == ctx->sta_mgr.our_avln && sta->net->num_associated_stas == 0)
- cp_fsm_post_new_event (ctx, bare, sta_status_changed);
-
- cp_sta_mgr_elects_sta_partial_ack (ctx);
-}
-
-void
-cp_sta_mgr_init (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- memset (&ctx->sta_mgr, 0, sizeof (cp_sta_mgr_t));
-
- // Initialise the station own data.
- cp_sta_own_data_init (ctx);
-
- // Initialise the list of releasing stations.
- list_init (&ctx->sta_mgr.release_sta_list);
-
- // Initialise the slab cache.
- slab_cache_init (&ctx->sta_mgr.sta_slab_cache,
- "Station cache",
- sizeof (cp_sta_private_t),
- (slab_object_destructor_t) cp_sta_uninit);
-
- // Initialise the set of station sorted by mac addresses.
- set_init (&ctx->sta_mgr.stas, cp_sta_mgr_sta_mac_address_less);
-}
-
void
cp_sta_mgr_uninit (cp_t *ctx)
{
@@ -417,47 +319,6 @@ cp_sta_mgr_get_present_snids (cp_t *ctx)
return snidflags;
}
-void
-cp_sta_mgr_garbage (cp_t *ctx)
-{
- cp_sta_t *sta;
- cp_net_t *net;
- dbg_assert (ctx);
- u32 now = cp_sta_core_get_date_ms (ctx);
- for (net = cp_sta_mgr_get_first_avln (ctx);
- net;
- net = cp_sta_mgr_get_next_avln (ctx, net))
- {
- if (net != ctx->sta_mgr.our_avln)
- cp_net_garbage_stations (ctx, net, now);
- if (net->blacklisted
- && less_mod2p32 ( net->blacklisted_reset_date, phy_date ()))
- net->blacklisted = false;
- }
- /* Release the release stations if possible. */
- while ((sta = cp_sta_mgr_release_sta_get_first (ctx))
- && (less_mod2p32 (sta->tei_lease_date_ms, now)))
- {
- /* remove the station from the list. */
- list_remove (&ctx->sta_mgr.release_sta_list,
- &sta->release_node);
-
- sar_sta_remove (ctx->sar, cp_sta_get_tei (sta));
-
- if (cp_sta_own_data_get_cco_status (ctx))
- {
- /* Request the CCo to release the TEI. */
- cp_cco_action_tei_release (ctx, cp_sta_get_tei (sta));
- }
- slab_release (sta);
- }
- cp_sta_mgr_elects_sta_partial_ack (ctx);
- if (cp_sta_mgr_net_list_is_empty (ctx))
- cp_fsm_trigger_new_event (ctx, bare, net_list_empty);
- /* Recommit to dataplane. */
- cp_sta_mgr_commit_to_dataplane (ctx);
-}
-
cp_sta_own_data_t *
cp_sta_mgr_get_sta_own_data (cp_t *ctx)
{
@@ -601,159 +462,6 @@ cp_sta_mgr_set_our_avln (cp_t *ctx, cp_net_t *net)
}
void
-cp_sta_mgr_release_station (cp_t *ctx, cp_tei_t tei)
-{
- cp_sta_t *sta;
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (tei);
- dbg_assert (cp_sta_own_data_get_cco_status (ctx));
-
- net = cp_sta_mgr_get_our_avln (ctx);
- sta = cp_sta_mgr_sta_get_assoc (ctx, net, tei);
- dbg_assert (sta);
-
- list_init_node (&sta->release_node);
- list_push (&ctx->sta_mgr.release_sta_list, &sta->release_node);
-
- /* Set the station tei_lease_ms to 5 min as indicated in the HPAV
- * specification. */
- sta->tei_lease_date_ms = CP_STA_MGR_STATION_RELEASE_MS +
- cp_sta_core_get_date_ms (ctx);
-
- /* Remove the station. */
- cp_sta_mgr_sta_remove_common (ctx, sta);
- /* Remove the reference provided. */
- slab_release (sta);
-
- /* Check if our net is empty, if it is post an FSM event
- * cco__all_sta_leaved */
- if (cp_sta_own_data_get_tei (ctx)
- && net == cp_sta_mgr_get_our_avln (ctx)
- && cp_net_is_empty (ctx, net))
- cp_fsm_trigger_new_event (ctx, bare, cco__all_sta_leaved);
-}
-
-cp_sta_t *
-cp_sta_mgr_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei, mac_t mac_address)
-{
- cp_sta_t *sta = NULL;
- cp_sta_t *sta_from_tei = NULL;
- dbg_assert (ctx);
- dbg_assert (net);
- dbg_assert ((tei && mac_address == MAC_BROADCAST)
- || (mac_address & ~MAC_BROADCAST) == 0);
- /* Try to get the station by the TEI. */
- if (tei)
- sta_from_tei = cp_sta_mgr_sta_get_assoc (ctx, net, tei);
- /* Try to get the station by the mac address. */
- if (MAC_IS_VALID(mac_address))
- sta = cp_sta_mgr_sta_get_from_mac (ctx, mac_address);
-
- /* Does the two station match ? */
- if (sta && sta_from_tei)
- {
- if (sta != sta_from_tei)
- /* remove the station got using the TEI. */
- cp_sta_mgr_sta_remove_assoc (ctx, net, tei);
- slab_release (sta_from_tei);
- }
- else if (!sta)
- sta = sta_from_tei;
-
- if (!sta)
- {
- sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
- }
- else
- {
- cp_tei_t sta_tei = cp_sta_get_tei (sta);
- mac_t sta_mac = cp_sta_get_mac_address (sta);
- cp_net_t *sta_net = cp_sta_get_net (sta);
- /* Last case. The network change. */
- if (sta_net != net)
- {
- cp_sta_mgr_sta_remove (ctx, sta);
- slab_release (sta);
- sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
- }
- /* Second case,
- * - station's TEI == TEI and != MAC_TEI_UNASSOCIATED.
- * - station's Mac address was broadcast. */
- else if ((sta_tei == tei)
- && (tei != MAC_TEI_UNASSOCIATED)
- && (sta_mac != mac_address)
- && (sta_mac == MAC_BROADCAST))
- {
- /* Add the station mgr node to the set. */
- cp_sta_private_t *p = PARENT_OF (cp_sta_private_t, public_data,
- sta);
- p->mac_address = mac_address;
- set_insert (&ctx->sta_mgr.stas, &sta->node_sta_mgr);
- }
- /* First case only the TEI change from the previous state. */
- else if ((sta_tei == MAC_TEI_UNASSOCIATED
- && tei != MAC_TEI_UNASSOCIATED
- && sta_mac == mac_address)
- /* Third case, only the station's TEI change. */
- || (sta_tei != tei
- && tei != MAC_TEI_UNASSOCIATED
- && sta_mac == mac_address
- && mac_address != MAC_BROADCAST)
- /* Fourth case, only the station's TEI change from a
- * associated tei to the unassociated TEI.. */
- || (sta_tei != tei
- && tei == MAC_TEI_UNASSOCIATED
- && sta_mac == mac_address
- && mac_address != MAC_BROADCAST)
- /* Fifth case, Same TEI only the mac address change from A
- * to B without being null or broadcast. */
- || (sta_tei == tei
- && sta_mac != mac_address
- && MAC_IS_VALID (sta_mac)
- && MAC_IS_VALID (mac_address))
- )
- {
- /* Remove the station. */
- cp_sta_mgr_sta_remove (ctx, sta);
- slab_release (sta);
- /* Add the station with the new TEI. */
- sta = cp_sta_mgr_sta_add_realy (ctx, net, tei, mac_address);
- }
- }
- /* Update the last seen value. */
- if (ctx->sta_mgr.sta_own_data.is_cco
- && cp_sta_get_net (sta) == ctx->sta_mgr.our_avln)
- sta->expired_date_ms = cp_sta_core_get_date_ms (ctx)
- + HPAV_STA_PRESENCE_TIMEOUT_INSIDE_AVLN_MS;
- else
- sta->expired_date_ms = cp_sta_core_get_date_ms (ctx)
- + HPAV_DISCOVERED_LIST_EXPIRE_TIME_MS;
- return sta;
-}
-
-void
-cp_sta_mgr_sta_remove (cp_t *ctx, cp_sta_t * station)
-{
- cp_sta_private_t *sta = (cp_sta_private_t *) station;
-
- dbg_assert (ctx);
- dbg_assert (sta);
-
- if ((sta->net == ctx->sta_mgr.our_avln)
- && (MAC_TEI_IS_STA (sta->tei)))
- {
- sar_sta_remove (ctx->sar, sta->tei);
- }
-
- cp_sta_mgr_sta_remove_common (ctx, station);
-
- /* Release the station. */
- slab_release (sta);
-}
-
-void
cp_sta_mgr_sta_remove_from_mac (cp_t *ctx, mac_t mac_addr)
{
cp_sta_t *sta;
@@ -847,77 +555,6 @@ cp_sta_mgr_sta_get_from_mac (cp_t *ctx, mac_t mac_addr)
}
void
-cp_sta_mgr_commit_to_dataplane (cp_t *ctx)
-{
- cp_sta_t *sta;
- cl_mactotei_blk_t *mactotei;
-
- dbg_assert (ctx);
- dbg_assert (ctx->cl);
-
- // If the net does not correspond to the AVLN, do not commit.
- if (!ctx->sta_mgr.our_avln)
- return;
-
- // Get the first station from the set.
- if (set_empty (&ctx->sta_mgr.our_avln->associated_stas))
- {
- cl_mactotei_release_table (ctx->cl);
- }
- else
- {
- // There is at least a station in the network list.
- mactotei = cl_mactotei_new ();
- uint i;
-
- for (sta = cp_net_sta_get_first (
- ctx, ctx->sta_mgr.our_avln, CP_NET_STA_ASSOC);
- sta;
- sta = cp_net_sta_get_next (ctx, ctx->sta_mgr.our_avln, sta))
- {
- cp_sta_private_t *sta_private =
- PARENT_OF (cp_sta_private_t, public_data, sta);
- // Copy all the bridge table from the previous list.
- cl_mactotei_copy_tei_and_tag (ctx->cl, mactotei, sta_private->tei,
- sta_private->tei);
- // Add the current station.
- cl_mactotei_addr_add (mactotei, sta_private->mac_address,
- sta_private->tei, MAC_TEI_UNASSOCIATED);
- }
- /* Get the bridge RX table of the CL. */
- cl_brg_rx_t *brg_rx_table = cl_brg_rx_get (ctx->cl);
- if (brg_rx_table)
- {
- /* Add bridged Mac addresses to the mac to tei.
- * If the bridged MAC address is already present in the mac2tei,
- * the extra_info will be updated using the bridged tei. */
- for (i = 0; i < brg_rx_table->nb_entry; i++)
- {
- sta = cp_sta_mgr_sta_get_assoc (
- ctx, ctx->sta_mgr.our_avln,
- brg_rx_table->entry[i].tei);
- if (sta)
- {
- cl_mactotei_addr_add (
- mactotei, brg_rx_table->entry[i].mac,
- brg_rx_table->entry[i].tei,
- brg_rx_table->entry[i].tei);
- slab_release (sta);
- }
- }
- blk_release (brg_rx_table);
- }
-
- // Copy all the groups list table from the previous list.
- cl_mactotei_copy_tei (ctx->cl, mactotei, MAC_TEI_BCAST);
-
- // Request the CL to use the table.
- cl_mactotei_use_table (ctx->cl, mactotei);
- cl_update_igmp_groups (ctx->cl);
- }
-}
-
-void
cp_sta_mgr__assoc__timeout (cp_t *ctx, uint time_ms)
{
cp_sta_t *sta;
@@ -940,24 +577,3 @@ cp_sta_mgr__assoc__timeout (cp_t *ctx, uint time_ms)
}
}
}
-
-void
-cp_sta_mgr_set_tracking (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
-{
- dbg_assert (ctx);
- dbg_assert (HPAV_NID_IS_VALID (nid));
-#if CONFIG_DEBUG
- bool found = false;
- cp_net_t *net;
- for (net = cp_sta_mgr_get_first_avln (ctx);
- net;
- net = cp_sta_mgr_get_next_avln (ctx, net))
- {
- if (cp_net_get_snid (ctx, net) == snid
- && cp_net_get_nid (ctx, net) == nid)
- found = true;
- }
- dbg_assert (found);
-#endif
- ctx->sta_mgr.sta_own_data.snid = snid;
-}
diff --git a/cesar/cp/sta/mgr/src/sta_own_data.c b/cesar/cp/sta/mgr/src/sta_own_data.c
index 3a4ce879b1..abed0aaf5b 100644
--- a/cesar/cp/sta/mgr/src/sta_own_data.c
+++ b/cesar/cp/sta/mgr/src/sta_own_data.c
@@ -29,24 +29,6 @@
#include "cp/sta/mgr/inc/sta_own_data.h"
/**
- * Initialise the station own data to default values.
- * \param ctx the module context.
- */
-void
-cp_sta_own_data_init (cp_t *ctx)
-{
- dbg_assert (ctx);
- memset (&ctx->sta_mgr.sta_own_data, 0,
- sizeof (cp_sta_own_data_private_t));
- /* Store the hybrid mode. */
- ctx->sta_mgr.sta_own_data.public.hybrid_mode =
- MAC_COEXISTENCE_HYBRID_DELIMITERS_MODE;
- /* Get an snid. */
- ctx->sta_mgr.sta_own_data.snid =
- lib_rnd_uniform (&ctx->rnd, HPAV_SNID_NB);
-}
-
-/**
* Uninitialise the station own data to default values.
* \param ctx the module context.
*/
@@ -155,46 +137,6 @@ cp_sta_own_data_get_npw (cp_t *ctx)
return ctx->sta_mgr.sta_own_data.npw;
}
-bool
-cp_sta_own_data_set_nmk (cp_t *ctx, const cp_key_t nmk,
- cp_msg_drv_sta_set_key_type_t type)
-{
- dbg_assert (ctx);
- dbg_assert (type < CP_MSG_DRV_STA_SET_KEY_TYPE_NB);
-
- uint i;
- cp_key_t current_key = cp_sta_own_data_get_nmk (ctx);
-
- for (i = 0; i < COUNT(nmk.key) ;i++)
- if (nmk.key[i] != current_key.key[i])
- break;
-
- if (i < COUNT(nmk.key))
- {
- ctx->sta_mgr.sta_own_data.nmk = nmk;
-
- /* Report new computed values to HLE. */
- cp_mme_peer_t peer = CP_MME_PEER (cp_sta_own_data_get_mac_address (ctx),
- MAC_TEI_FOREIGN);
- cp_nid_t nid = 0;
- cp_security_level_t sl = 0;
-
- if (type == CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID)
- nid = cp_sta_own_data_get_nid (ctx);
- else
- sl = cp_sta_own_data_get_security_level (ctx);
-
- cp_msg_drv_sta_set_key_ind_send (ctx, &peer,
- nmk,
- type,
- nid,
- sl);
- return true;
- }
-
- return false;
-}
-
/**
* Get the NMK of the AVLN.
* \param ctx the module context.
diff --git a/cesar/cp/sta/mgr/sta_mgr.h b/cesar/cp/sta/mgr/sta_mgr.h
index d624630c9d..6fe5207c1c 100644
--- a/cesar/cp/sta/mgr/sta_mgr.h
+++ b/cesar/cp/sta/mgr/sta_mgr.h
@@ -14,6 +14,7 @@
*
* Station and AVLN manager.
*/
+#include "cp/inc/variant.h"
#include "cp/sta/mgr/net.h"
#include "cp/sta/mgr/sta_own_data.h"
@@ -23,6 +24,35 @@ typedef struct cp_sta_mgr_t cp_sta_mgr_t;
BEGIN_DECLS
/**
+ * Elects a station in our AVLN to be the acknowledge station for all the
+ * station to which the packet is send.
+ * \param ctx the module context.
+ *
+ * This function choose the station randomly on the network.
+ */
+void
+cp_sta_mgr_elects_sta_partial_ack (cp_t *ctx);
+
+/**
+ * Get the first station from the release station list.
+ * \param ctx the CP context.
+ * \return the first station of the list.
+ *
+ * \warn It does not add a reference on the list, so a slab_release on the
+ * station will free the station data, without removing it from the dataplane.
+ */
+cp_sta_t *
+cp_sta_mgr_release_sta_get_first (cp_t *ctx);
+
+/**
+ * Compare two station with the mac address.
+ * \param left the left station.
+ * \param right the right station.
+ */
+bool
+cp_sta_mgr_sta_mac_address_less (set_node_t *left, set_node_t *right);
+
+/**
* Add a AVLN to the manager list.
* \param ctx the module context.
* \param snid The AVLN's SNID to add.
@@ -72,6 +102,8 @@ cp_sta_mgr_get_next_avln (cp_t *ctx, cp_net_t *prev);
* Initialise the sta manager.
* \param ctx the module context.
*/
+#define cp_sta_mgr_init \
+ CP_VARIANT_FUNCTION(sta_mgr_init)
void
cp_sta_mgr_init (cp_t *ctx);
@@ -98,6 +130,8 @@ cp_sta_mgr_get_present_snids (cp_t *ctx);
* \param ctx the module context.
*
*/
+#define cp_sta_mgr_garbage \
+ CP_VARIANT_FUNCTION(sta_mgr_garbage)
void
cp_sta_mgr_garbage (cp_t *ctx);
@@ -166,6 +200,8 @@ cp_sta_mgr_set_our_avln (cp_t *ctx, cp_net_t *net);
*
* This function verifies if the own station is CCo, if its not, it asserts.
*/
+#define cp_sta_mgr_release_station \
+ CP_VARIANT_FUNCTION(sta_mgr_release_station)
void
cp_sta_mgr_release_station (cp_t *ctx, cp_tei_t tei);
@@ -177,6 +213,8 @@ cp_sta_mgr_release_station (cp_t *ctx, cp_tei_t tei);
* \param mac_address Station's mac address.
* \return A reference on the station just created.
*/
+#define cp_sta_mgr_sta_add \
+ CP_VARIANT_FUNCTION(sta_mgr_sta_add)
cp_sta_t *
cp_sta_mgr_sta_add (cp_t *ctx, cp_net_t *net, cp_tei_t tei,
mac_t mac_address);
@@ -208,6 +246,8 @@ cp_sta_mgr_sta_remove_from_mac (cp_t *ctx, mac_t mac_addr);
*
* The user shall release the reference
*/
+#define cp_sta_mgr_sta_remove \
+ CP_VARIANT_FUNCTION(sta_mgr_sta_remove)
void
cp_sta_mgr_sta_remove (cp_t *ctx, cp_sta_t * sta);
@@ -250,6 +290,8 @@ cp_sta_mgr_sta_get_from_mac (cp_t *ctx, mac_t mac_addr);
* to remove stations it only have the possibility to remove the station
* by excluding it from the copy to the new one.
*/
+#define cp_sta_mgr_commit_to_dataplane \
+ CP_VARIANT_FUNCTION(sta_mgr_commit_to_dataplane)
void
cp_sta_mgr_commit_to_dataplane (cp_t *ctx);
@@ -263,18 +305,6 @@ cp_sta_mgr_commit_to_dataplane (cp_t *ctx);
void
cp_sta_mgr__assoc__timeout (cp_t *ctx, uint time_ms);
-/**
- * Set the SNID of the station to track the correct AVLN.
- * \param ctx the module context.
- * \param snid the station SNID.
- * \param nid the network identifier to track.
- *
- * Be careful, this function does not modify our AVLN snid to do some use
- * cp_sta_own_data_set_snid.
- */
-void
-cp_sta_mgr_set_tracking (cp_t *ctx, cp_snid_t snid, cp_nid_t nid);
-
END_DECLS
#endif /* cp_sta_mgr_h */
diff --git a/cesar/cp/sta/mgr/sta_own_data.h b/cesar/cp/sta/mgr/sta_own_data.h
index 871e6853d5..072e306fd2 100644
--- a/cesar/cp/sta/mgr/sta_own_data.h
+++ b/cesar/cp/sta/mgr/sta_own_data.h
@@ -14,6 +14,7 @@
*
*/
+#include "cp/inc/variant.h"
#include "cp/defs.h"
#include "cp/cp.h"
@@ -82,6 +83,8 @@ BEGIN_DECLS
* Initialise the station own data to default values.
* \param ctx the module context.
*/
+#define cp_sta_own_data_init \
+ CP_VARIANT_FUNCTION(sta_own_data_init)
void
cp_sta_own_data_init (cp_t *ctx);
@@ -153,6 +156,8 @@ cp_sta_own_data_get_npw (cp_t *ctx);
* \param type type of data the nmk is modify after.
* \return true if the nmk was changed.
*/
+#define cp_sta_own_data_set_nmk \
+ CP_VARIANT_FUNCTION(sta_own_data_set_nmk)
bool
cp_sta_own_data_set_nmk (cp_t *ctx, const cp_key_t nmk,
cp_msg_drv_sta_set_key_type_t type);
diff --git a/cesar/cp/sta/mgr/test/Makefile b/cesar/cp/sta/mgr/test/Makefile
deleted file mode 100644
index 33aac4cf7f..0000000000
--- a/cesar/cp/sta/mgr/test/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-BASE = ../../../..
-
-INCLUDES = cp/sta/mgr/test/overide
-
-HOST_PROGRAMS = test_sta_mgr
-test_sta_mgr_SOURCES = core_stub.c net_test.c sar_stub.c sta_mgr.c \
- sta-test.c station_test.c test_sta_mgr.c
-test_sta_mgr_MODULES = lib cp/sta/mgr mac/common cp/fsm/stub \
- cp/cco/action/stub bsu/stub cp/msg/stub \
- cl cl/stub hal/ipmbox/stub
-
-cl_MODULE_SOURCES = cl_mactotei.c brg_rx.c
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/projects/plc/Makefile b/cesar/projects/plc/Makefile
index 26a0dfb050..8296299a9f 100644
--- a/cesar/projects/plc/Makefile
+++ b/cesar/projects/plc/Makefile
@@ -7,8 +7,8 @@ TARGET_OPTIMIZE = -Os
TARGET_PROGRAMS = plc
plc_SOURCES = plc.c
-plc_MODULES = lib hal mac cl interface cp cp/av ce station bsu hle/tools \
- bufmgr
+plc_MODULES = lib hal mac cl interface cp/av ce station bsu hle/tools \
+ bufmgr
# Add support for Fcalls.
plc_MODULES += host ce/fcall
diff --git a/cesar/test_general/station/compliance/board-Config b/cesar/test_general/station/compliance/board-Config
index 58b80b5f6e..b02c6114af 100644
--- a/cesar/test_general/station/compliance/board-Config
+++ b/cesar/test_general/station/compliance/board-Config
@@ -1,3 +1,4 @@
+CONFIG_CP_AV = y
CONFIG_GPIO_LED_TRAFFIC = y
CONFIG_GPIO_LED_PBPROC_ALIVE = y
CONFIG_GPIO_LED_PBPROC_ALIVE_GPIO = 12
diff --git a/cesar/test_general/station/compliance/simu-Config b/cesar/test_general/station/compliance/simu-Config
index dc2b3fd1bf..95fc3b5ed8 100644
--- a/cesar/test_general/station/compliance/simu-Config
+++ b/cesar/test_general/station/compliance/simu-Config
@@ -1 +1,2 @@
+CONFIG_CP_AV = y
CONFIG_TRACE=y
diff --git a/cesar/test_general/station/fcall/src/beacon.c b/cesar/test_general/station/fcall/src/beacon.c
index 2b982fc0ff..50a941c113 100644
--- a/cesar/test_general/station/fcall/src/beacon.c
+++ b/cesar/test_general/station/fcall/src/beacon.c
@@ -16,11 +16,15 @@
#include "station/station.h"
#include "host/fcall/fcall.h"
#include "mac/ca/inc/context.h"
+#include "cp/av/beacon/beacon.h"
#include "cp/fsm/fsm.h"
#include <string.h>
#include <stdio.h>
+void
+cp_av_beacon_change_hm (cp_t *ctx, uint hybrid_mode);
+
int
fc_cco_change_snid (fcall_ctx_t *fcall, fcall_param_t **param,
sci_msg_t **msg, void *data)
@@ -54,7 +58,7 @@ fc_cco_change_hm (fcall_ctx_t *fcall, fcall_param_t **param,
fcall_param_reset (*param);
/* Request the beacon module to change the snid, */
- cp_beacon_change_hm (cesar->cp, hm);
+ cp_av_beacon_change_hm (cesar->cp, hm);
return true;
}
diff --git a/cesar/test_general/station/fcall/src/cc_leave.c b/cesar/test_general/station/fcall/src/cc_leave.c
index d46d3a3596..de90b9bd8c 100644
--- a/cesar/test_general/station/fcall/src/cc_leave.c
+++ b/cesar/test_general/station/fcall/src/cc_leave.c
@@ -20,6 +20,7 @@
#include "cp/sta/mgr/inc/sta_own_data.h"
#include "cp/sta/action/action.h"
+#include "cp/av/sta/action/assoc.h"
#include "station/station.h"
#include "host/fcall/fcall.h"
@@ -39,7 +40,7 @@ fc_cc_leave_req (fcall_ctx_t *fcall, fcall_param_t **param,
cesar = data;
- cp_sta_action_assoc_leave (cesar->cp);
+ cp_av_sta_action_assoc_leave (cesar->cp);
fcall_param_reset (*param);
diff --git a/cesar/test_general/station/maximus/Config b/cesar/test_general/station/maximus/Config
new file mode 100644
index 0000000000..3ebfb2f0b9
--- /dev/null
+++ b/cesar/test_general/station/maximus/Config
@@ -0,0 +1 @@
+CONFIG_CP_AV = y
diff --git a/cesar/test_general/station/scenario/Makefile b/cesar/test_general/station/scenario/Makefile
deleted file mode 100644
index 6f6c96cf8d..0000000000
--- a/cesar/test_general/station/scenario/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-BASE = ../../..
-ECOS = y
-
-TARGET_PROGRAMS= test_scenario
-
-test_scenario_SOURCES =
-test_scenario_MODULES = lib mac cl interface cp hal station \
- host cp/av bsu hal/ipmbox/maximus \
- bufmgr \
- test_general/station/fcall \
- test_general/station/common ce/stub
-
-include $(BASE)/common/make/top.mk
-
-testbook: py/sc01_assoc_auth.py py/sc02_stas_communication.py \
- py/sc03_two_avln_coexisting.py py/sc04_cc_whoru.py \
- py/sc05_cc_leave.py py/sc06_discover_procedure.py \
- py/sc07_bridge.py py/sc08_bentry_change.py \
- py/sc09_simple_connect.py py/sc10_short_messages.py \
- py/sc11_cm_nw_info.py py/sc12_change_nmk.py \
- py/sc13_data_rate.py py/sc14_igmp.py
- python testbook.py $^ > $@.rst
-
-CLEAN_FILES += testbook.rst
-
-all: maximus
-
-maximus:
- $(MAKE) -C $(BASE)/maximus/python
-
-$(call src2obj,src/region_stub.c,target): $(BASE)/cp/fsm/fsm.h
diff --git a/cesar/test_general/station/scenario/av/Config b/cesar/test_general/station/scenario/av/Config
new file mode 100644
index 0000000000..3ebfb2f0b9
--- /dev/null
+++ b/cesar/test_general/station/scenario/av/Config
@@ -0,0 +1 @@
+CONFIG_CP_AV = y
diff --git a/cesar/test_general/station/scenario/av/Makefile b/cesar/test_general/station/scenario/av/Makefile
new file mode 100644
index 0000000000..6dfeb65f78
--- /dev/null
+++ b/cesar/test_general/station/scenario/av/Makefile
@@ -0,0 +1,31 @@
+BASE = ../../../..
+ECOS = y
+
+TARGET_PROGRAMS= test_scenario
+
+test_scenario_SOURCES =
+test_scenario_MODULES = lib mac cl interface cp hal station \
+ host cp/av bsu hal/ipmbox/maximus \
+ bufmgr \
+ test_general/station/fcall \
+ test_general/station/common ce/stub
+
+include $(BASE)/common/make/top.mk
+
+testbook: py/sc01_assoc_auth.py py/sc02_stas_communication.py \
+ py/sc03_two_avln_coexisting.py py/sc04_cc_whoru.py \
+ py/sc05_cc_leave.py py/sc06_discover_procedure.py \
+ py/sc07_bridge.py py/sc08_bentry_change.py \
+ py/sc09_simple_connect.py py/sc10_short_messages.py \
+ py/sc11_cm_nw_info.py py/sc12_change_nmk.py \
+ py/sc13_data_rate.py py/sc14_igmp.py
+ python testbook.py $^ > $@.rst
+
+CLEAN_FILES += testbook.rst
+
+all: maximus
+
+maximus:
+ $(MAKE) -C $(BASE)/maximus/python
+
+$(call src2obj,src/region_stub.c,target): $(BASE)/cp/fsm/fsm.h
diff --git a/cesar/test_general/station/scenario/ecos.ecc.sh b/cesar/test_general/station/scenario/av/ecos.ecc.sh
index e0278271fe..e0278271fe 100644
--- a/cesar/test_general/station/scenario/ecos.ecc.sh
+++ b/cesar/test_general/station/scenario/av/ecos.ecc.sh
diff --git a/cesar/test_general/station/scenario/lib/association_protocol.py b/cesar/test_general/station/scenario/av/lib/association_protocol.py
index fe36635c03..fe36635c03 100644
--- a/cesar/test_general/station/scenario/lib/association_protocol.py
+++ b/cesar/test_general/station/scenario/av/lib/association_protocol.py
diff --git a/cesar/test_general/station/scenario/lib/handover_protocol.py b/cesar/test_general/station/scenario/av/lib/handover_protocol.py
index df4795000a..df4795000a 100644
--- a/cesar/test_general/station/scenario/lib/handover_protocol.py
+++ b/cesar/test_general/station/scenario/av/lib/handover_protocol.py
diff --git a/cesar/test_general/station/scenario/py/sc01_assoc_auth.py b/cesar/test_general/station/scenario/av/py/sc01_assoc_auth.py
index ba32efd9a9..ba32efd9a9 100644
--- a/cesar/test_general/station/scenario/py/sc01_assoc_auth.py
+++ b/cesar/test_general/station/scenario/av/py/sc01_assoc_auth.py
diff --git a/cesar/test_general/station/scenario/py/sc02_stas_communication.py b/cesar/test_general/station/scenario/av/py/sc02_stas_communication.py
index 668b614e87..668b614e87 100644
--- a/cesar/test_general/station/scenario/py/sc02_stas_communication.py
+++ b/cesar/test_general/station/scenario/av/py/sc02_stas_communication.py
diff --git a/cesar/test_general/station/scenario/py/sc03_two_avln_coexisting.py b/cesar/test_general/station/scenario/av/py/sc03_two_avln_coexisting.py
index 488e476760..488e476760 100644
--- a/cesar/test_general/station/scenario/py/sc03_two_avln_coexisting.py
+++ b/cesar/test_general/station/scenario/av/py/sc03_two_avln_coexisting.py
diff --git a/cesar/test_general/station/scenario/py/sc04_cc_whoru.py b/cesar/test_general/station/scenario/av/py/sc04_cc_whoru.py
index a1144944de..a1144944de 100644
--- a/cesar/test_general/station/scenario/py/sc04_cc_whoru.py
+++ b/cesar/test_general/station/scenario/av/py/sc04_cc_whoru.py
diff --git a/cesar/test_general/station/scenario/py/sc05_cc_leave.py b/cesar/test_general/station/scenario/av/py/sc05_cc_leave.py
index f47d2bcfa3..f47d2bcfa3 100644
--- a/cesar/test_general/station/scenario/py/sc05_cc_leave.py
+++ b/cesar/test_general/station/scenario/av/py/sc05_cc_leave.py
diff --git a/cesar/test_general/station/scenario/py/sc06_discover_procedure.py b/cesar/test_general/station/scenario/av/py/sc06_discover_procedure.py
index c294599039..c294599039 100644
--- a/cesar/test_general/station/scenario/py/sc06_discover_procedure.py
+++ b/cesar/test_general/station/scenario/av/py/sc06_discover_procedure.py
diff --git a/cesar/test_general/station/scenario/py/sc07_bridge.py b/cesar/test_general/station/scenario/av/py/sc07_bridge.py
index 95ae3c6085..95ae3c6085 100644
--- a/cesar/test_general/station/scenario/py/sc07_bridge.py
+++ b/cesar/test_general/station/scenario/av/py/sc07_bridge.py
diff --git a/cesar/test_general/station/scenario/py/sc08_bentry_change.py b/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py
index c32acc3d78..c32acc3d78 100644
--- a/cesar/test_general/station/scenario/py/sc08_bentry_change.py
+++ b/cesar/test_general/station/scenario/av/py/sc08_bentry_change.py
diff --git a/cesar/test_general/station/scenario/py/sc09_simple_connect.py b/cesar/test_general/station/scenario/av/py/sc09_simple_connect.py
index f02e87a197..f02e87a197 100644
--- a/cesar/test_general/station/scenario/py/sc09_simple_connect.py
+++ b/cesar/test_general/station/scenario/av/py/sc09_simple_connect.py
diff --git a/cesar/test_general/station/scenario/py/sc10_short_messages.py b/cesar/test_general/station/scenario/av/py/sc10_short_messages.py
index b931fd0365..b931fd0365 100644
--- a/cesar/test_general/station/scenario/py/sc10_short_messages.py
+++ b/cesar/test_general/station/scenario/av/py/sc10_short_messages.py
diff --git a/cesar/test_general/station/scenario/py/sc11_cm_nw_info.py b/cesar/test_general/station/scenario/av/py/sc11_cm_nw_info.py
index 7d407d84b1..7d407d84b1 100644
--- a/cesar/test_general/station/scenario/py/sc11_cm_nw_info.py
+++ b/cesar/test_general/station/scenario/av/py/sc11_cm_nw_info.py
diff --git a/cesar/test_general/station/scenario/py/sc12_change_nmk.py b/cesar/test_general/station/scenario/av/py/sc12_change_nmk.py
index 636eb73629..67a54b0a14 100644
--- a/cesar/test_general/station/scenario/py/sc12_change_nmk.py
+++ b/cesar/test_general/station/scenario/av/py/sc12_change_nmk.py
@@ -131,7 +131,7 @@ class TestNMK (unittest.TestCase):
# We can test some communication.
avln = self.csi.avln_get (0)
packets = prepare_packets (avln, self.avlns[0].cco, self.avlns[0].stas)
- result = send_check_datas (self.csi, avln, packets)
+ result = send_check_datas (self.csi, avln, packets)
self.failUnless (result)
def t3StaStep2 (self):
diff --git a/cesar/test_general/station/scenario/py/sc14_igmp.py b/cesar/test_general/station/scenario/av/py/sc14_igmp.py
index cafde5a852..7210a37c3a 100644
--- a/cesar/test_general/station/scenario/py/sc14_igmp.py
+++ b/cesar/test_general/station/scenario/av/py/sc14_igmp.py
@@ -30,7 +30,7 @@ class TestIGMP (unittest.TestCase):
rsp = sendnrecv_mme (self.csi.get_maximus (), sta, mme)
self.failUnless (rsp)
drv_mcast_set_list_cnf = Ether (rsp[0].get ())
- self.failUnless (drv_mcast_set_list_cnf.result == 0)
+ self.failUnless (drv_mcast_set_list_cnf.result == 0)
# Get the Mac 2 TEI table.
mac2tei = Ether (dst = sta_mac, src = MAC_DEFAULT)\
/ scammer.MME () / scammer.VS_GET_MACTOTEI_REQ ()
diff --git a/cesar/test_general/station/scenario/py/scenario_init.py b/cesar/test_general/station/scenario/av/py/scenario_init.py
index 40c333b58f..aeedf89c8c 100644
--- a/cesar/test_general/station/scenario/py/scenario_init.py
+++ b/cesar/test_general/station/scenario/av/py/scenario_init.py
@@ -7,11 +7,11 @@
import os
import sys
import unittest
-sys.path.append ('../../../maximus/python/tools/csi/')
-sys.path.append ('../../../maximus/python/')
-sys.path.append ('../../../maximus/python/obj')
-sys.path.append ('../../../maximus/python/lib/cesar')
-sys.path.append ('../../../../common/lib')
+sys.path.append ('../../../../maximus/python/tools/csi/')
+sys.path.append ('../../../../maximus/python/')
+sys.path.append ('../../../../maximus/python/obj')
+sys.path.append ('../../../../maximus/python/lib/cesar')
+sys.path.append ('../../../../../common/lib')
sys.path.append ('lib')
from csicore import *
from maximus.mme.mme import MME
diff --git a/cesar/test_general/station/scenario/py/testtemplate.py b/cesar/test_general/station/scenario/av/py/testtemplate.py
index 664cbd4da4..664cbd4da4 100644
--- a/cesar/test_general/station/scenario/py/testtemplate.py
+++ b/cesar/test_general/station/scenario/av/py/testtemplate.py
diff --git a/cesar/test_general/station/scenario/testbook.py b/cesar/test_general/station/scenario/av/testbook.py
index 5003948800..5003948800 100644
--- a/cesar/test_general/station/scenario/testbook.py
+++ b/cesar/test_general/station/scenario/av/testbook.py
diff --git a/cesar/test_general/station/tonemap/host-Config b/cesar/test_general/station/tonemap/host-Config
index e1d5503357..e40266de58 100644
--- a/cesar/test_general/station/tonemap/host-Config
+++ b/cesar/test_general/station/tonemap/host-Config
@@ -1,2 +1,3 @@
CONFIG_TRACE = y
CONFIG_BLK_NB = 2048
+CONFIG_CP_AV = y
diff --git a/cesar/test_general/station/tonemap/sparc-Config b/cesar/test_general/station/tonemap/sparc-Config
index 4ae8b9e9fa..a0f625772b 100644
--- a/cesar/test_general/station/tonemap/sparc-Config
+++ b/cesar/test_general/station/tonemap/sparc-Config
@@ -3,3 +3,4 @@ CONFIG_TRACE = y
CONFIG_DEBUG_CLAIM = n
CONFIG_LEON_FATAL_BUTTON = y
CONFIG_GPIO_LED_TRAFFIC = y
+CONFIG_CP_AV = y
diff --git a/common/tests/tests b/common/tests/tests
index d93b72c609..1503ac209c 100644
--- a/common/tests/tests
+++ b/common/tests/tests
@@ -363,35 +363,40 @@ cesar/cp/test/mme:
make: make COV=y host.all
cov test_mme: ./obj/test_mme
-cesar/cp/fsm/test/utest:
+cesar/cp/av/fsm/test/utest:
make: make COV=y
cov test_fsm: ./obj/test_fsm
-cesar/cp/sta/action/test/utest:
+cesar/cp/av/sta/action/test/utest:
make: make COV=y
cov test_sta_action: ./obj/test_sta_action
-cesar/cp/sta/mgr/test:
+cesar/cp/av/sta/mgr/test/utest:
make
test_sta_mgr: obj/test_sta_mgr
-cesar/cp/cco/action/test:
+cesar/cp/av/cco/action/test/utest2:
make
action: ./obj/action.elf
garbage: ./obj/garbage.elf
status: ./obj/status.elf
keys: ./obj/keys.elf
-cesar/cp/cco/action/test/utest:
+cesar/cp/av/cco/action/test/utest:
make
action: ./obj/test_cco_action
-cesar/cp/beacon/test:
+cesar/cp/av/beacon/test/utest:
make
beacon: ./obj/beacon.elf
-discover: ./obj/discover_process.elf
+test_beacon: ./obj/test_beacon.elf
+discover: ./obj/test_discover_process.elf
-cesar/cp/msg/test:
+cesar/cp/av/beacon/test/utest2:
+make
+beacon_bis: ./obj/beacon_scenario
+
+cesar/cp/av/msg/test/utest:
make: make COV=y
read-header: ./obj/test-msg-read-header
cc-msg: ./obj/test-msg-cc
@@ -412,7 +417,7 @@ prun: ./obj/test_prun
nmk: ./obj/test_nmk
hash: ./obj/test_hash
-cesar/cp/cl_interf/test:
+cesar/cp/av/cl_interf/test/utest:
make
cl_interf: ./obj/test-cl-interf
@@ -423,7 +428,7 @@ core_event: ./obj/simu/core_events.elf
core_thread: ./obj/simu/core_thread.elf
core_timer: ./obj/simu/core_timer.elf
-cesar/test_general/station/scenario:
+cesar/test_general/station/scenario/av:
make
sc01_assoc_auth: python py/sc01_assoc_auth.py -d false -t 25000000000
sc02_stas_communication: python py/sc02_stas_communication.py -d false -t 25000000000