summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNélio Laranjeiro2012-07-04 17:20:41 +0200
committerNélio Laranjeiro2012-07-23 16:25:19 +0200
commit1b879b581e7ea2e474490e5914c2281816f18591 (patch)
tree9570d7d8b24805a4274a178924f25008dad2222f /cesar/cp
parent09894047b2f8623a11688c6dc64d97ed53ea8533 (diff)
cesar/cp/eoc/sta/action: add detection, assoc, auth scenario test, closes #3239
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/Makefile17
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h57
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/assoc.c384
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/beacon_stub.c18
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/cp_stub.c6
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/drv.c11
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/msg_stub.c27
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/scenario_actions.c15
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/secu.c52
-rw-r--r--cesar/cp/eoc/sta/action/test/utest_eoc/src/test_sta_action.c4
-rw-r--r--cesar/cp/secu/stub/src/secu.c4
11 files changed, 565 insertions, 30 deletions
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/Makefile b/cesar/cp/eoc/sta/action/test/utest_eoc/Makefile
index f6b7e900c7..99a54f4527 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/Makefile
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/Makefile
@@ -5,16 +5,17 @@ INCLUDES = cp/eoc/sta/action/test/utest_eoc \
HOST_PROGRAMS = test_sta_action
test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c \
- msg_stub.c dataplane_stub.c fsm_stub.c \
- core_stub.c beacon_stub.c cp_stub.c \
- scenario_actions.c ce_stub.c \
- mac_sar_interface_stub.c
+ msg_stub.c dataplane_stub.c fsm_stub.c \
+ core_stub.c beacon_stub.c cp_stub.c \
+ scenario_actions.c ce_stub.c \
+ mac_sar_interface_stub.c secu.c
test_sta_action_MODULES = lib lib/scenario cp/eoc/sta/action cp/eoc/sta/mgr \
- cp/eoc/fsm/stub cp/secu mac/common cl/stub \
- cp/eoc/cco/action/stub cp/eoc/beacon/stub cp/msg/stub \
- ce/stub mac/sar/stub cp/eoc/cco/bw/stub bsu/stub \
- hal/ipmbox/stub bufmgr/stub
+ cp/eoc/fsm/stub mac/common cl/stub cp/secu/stub \
+ cp/eoc/cco/action/stub cp/eoc/beacon/stub \
+ cp/msg/stub ce/stub mac/sar/stub \
+ cp/eoc/cco/bw/stub bsu/stub hal/ipmbox/stub \
+ bufmgr/stub
test_sta_action_CONFIG_MODULES = cp cp/eoc cp/eoc/msg mac/sar mac/pbproc cl
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h b/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h
index 4822cd6fd5..01ebf57b1f 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/inc/scenario_defs.h
@@ -50,7 +50,19 @@
drv__stopping__stopped, \
drv__drv_sta_get_key_req, \
drv__drv_sta_status_req, \
- drv__drv_sta_set_config_req
+ drv__drv_sta_set_config_req, \
+ \
+ detect__beacon_received, \
+ assoc__detecting_no_beacons, \
+ assoc__detecting_detected, \
+ assoc__associating_cnf, \
+ assoc__associating_timeout, \
+ assoc__associating_no_beacons, \
+ assoc__associated_key_cnf, \
+ assoc__associated_no_beacons, \
+ assoc__associated_timeout, \
+ assoc__associated_leave, \
+ auth__authenticated_key_cnf
/* Actions without parameter. */
#define __0(action) \
@@ -102,11 +114,25 @@ __m (drv__drv_sta_get_key_req)
__m (drv__drv_sta_status_req)
__m (drv__drv_sta_set_config_req)
+__n (detect__beacon_received,
+ bsu_beacon_t *beacon, cp_net_t *net, cp_sta_t *sta)
+__0 (assoc__detecting_no_beacons)
+__0 (assoc__detecting_detected)
+__m (assoc__associating_cnf)
+__0 (assoc__associating_timeout)
+__0 (assoc__associating_no_beacons)
+__m (assoc__associated_key_cnf)
+__0 (assoc__associated_no_beacons)
+__0 (assoc__associated_timeout)
+__m (assoc__associated_leave)
+__m (auth__authenticated_key_cnf)
+
#undef __0
#undef __n
#undef __n_
#undef __m
#undef __m_
+#undef __m
/* Scenario events. */
#define SCENARIO_DEFS_EVENTS \
@@ -135,6 +161,14 @@ __m (drv__drv_sta_set_config_req)
cp_msg_drv_sta_status_ind_send, \
cp_msg_drv_sta_set_config_req_receive, \
\
+ cp_msg_cc_assoc_req_send, \
+ cp_msg_cc_assoc_cnf_receive, \
+ cp_msg_cc_leave_ind_receive, \
+ cp_msg_cc_leave_rsp_send, \
+ \
+ cp_msg_cm_get_key_req_send, \
+ cp_msg_cm_get_key_cnf_receive, \
+ \
cp_msg_vs_eoc_cco_get_info_req_receive, \
cp_msg_vs_eoc_cco_get_info_cnf_send, \
cp_msg_vs_eoc_cco_diagnostic_info_req_receive, \
@@ -153,10 +187,14 @@ __m (drv__drv_sta_set_config_req)
\
cp_beacon_create_default_schedules, \
cp_beacon_process_tracked_avln, \
+ cp_beacon_process_untracked_avln, \
cp_beacon_reconfigure_timer, \
cp_beacon_change_nek, \
cp_beacon_deactivate, \
cp_beacon_synchronised, \
+ cp_eoc_beacon_nek_index_adjust, \
+ \
+ cp_eoc_cco_bw_sta_allocations, \
\
sar_activate, \
sar_cleanup, \
@@ -265,6 +303,19 @@ __ms (cp_msg_drv_sta_status_ind_send,
bsu_aclf_frequency_t pwl_sync_frequency)
__mr (cp_msg_drv_sta_set_config_req_receive,
char *config)
+__ms (cp_msg_cc_assoc_req_send, enum cp_msg_cc_assoc_req_type_t request_type,
+ cp_nid_t nid, u8 cco_cap, u8 proxy_cap)
+__mr (cp_msg_cc_assoc_cnf_receive, enum cp_msg_cc_assoc_cnf_result_t result,
+ cp_nid_t nid, cp_snid_t snid, cp_tei_t sta_tei, u16 lease_time_min)
+__mr (cp_msg_cc_leave_ind_receive, enum cp_msg_cc_leave_ind_reason_t reason,
+ cp_nid_t nid)
+__ms (cp_msg_cc_leave_rsp_send)
+__msk (cp_msg_cm_get_key_req_send, bool relayed,
+ enum cp_msg_key_type_t key_type, cp_nid_t nid, u32 *hash_key)
+__mrk (cp_msg_cm_get_key_cnf_receive,
+ enum cp_msg_cm_get_key_cnf_result_t result,
+ enum cp_msg_key_type_t key_type, cp_nid_t nid, u8 eks, u32 *hash_key,
+ cp_key_t *key)
__mr (cp_msg_vs_eoc_cco_get_info_req_receive,
u8 internal_eoc_index, u8 control)
__ms (cp_msg_vs_eoc_cco_get_info_cnf_send,
@@ -324,10 +375,14 @@ __e (cp_sta_core_stop_timed_or_cyclic_event)
__e (cp_beacon_create_default_schedules)
__e (cp_beacon_process_tracked_avln, bsu_beacon_t *beacon, cp_net_t *net)
+__e (cp_beacon_process_untracked_avln)
__e (cp_beacon_reconfigure_timer)
__e (cp_beacon_change_nek, u8 eks, cp_key_t *nek, bool now)
__e (cp_beacon_deactivate)
__er (cp_beacon_synchronised)
+__e (cp_eoc_beacon_nek_index_adjust, uint eks)
+
+__e (cp_eoc_cco_bw_sta_allocations)
__e (sar_activate, bool flag)
__e (sar_cleanup)
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/assoc.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/assoc.c
index d3c961cf4c..2b4454a54b 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/assoc.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/assoc.c
@@ -22,8 +22,7 @@
void
assoc_create_master (test_t t, test_sta_action_t *ctx, cp_snid_t snid,
cp_nid_t nid, cp_tei_t master_tei, mac_t master_mac,
- cp_net_t **master_net, cp_sta_t **master,
- scenario_entry_t *assoc_entry)
+ cp_net_t **master_net, cp_sta_t **master)
{
/* Clean current state. */
if (*master)
@@ -55,10 +54,6 @@ assoc_test_case_basic (test_t t)
test_case_begin (t, "Associate with a Master");
test_begin (t, "Started up.")
{
- scenario_entry_t entries[] = {
- SCENARIO_END
- };
- scenario_run (t, entries, &globals);
test_fail_unless (ctx.cp.mac_config->authenticated == false);
test_fail_unless (ctx.cp.sta_mgr.sta_own_data.tei
== MAC_TEI_UNASSOCIATED);
@@ -69,13 +64,382 @@ assoc_test_case_basic (test_t t)
}
test_end;
+ test_begin (t, "No beacons")
+ {
+ scenario_entry_t entries[] = {
+ SCENARIO_ACTION (assoc__detecting_no_beacons),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ }
+ test_end;
+
/* Create a Master to associate with. */
const cp_snid_t snid = 0;
const cp_nid_t nid = 0xf11111111111ull;
- const cp_tei_t cco_tei = 1, sta_tei = 2;
- const mac_t cco_mac = 0x111111111111ull;
- cp_net_t *cco_net;
- cp_sta_t *cco = NULL;
+ const cp_tei_t master_tei = 1, sta_tei = 3;
+ const mac_t master_mac = 0x111111111111ull;
+ cp_net_t *master_net;
+ cp_sta_t *master = NULL;
+
+ /* Create a second master, as on EoC clients barely change the NPW (i.e.
+ * the nid is a hash of the NMK which is hashed from the NPW) the second
+ * master has the same NID. */
+ const cp_tei_t master2_tei = 1;
+ const mac_t master2_mac = 0x222222222222ull;
+ cp_sta_t *master2 = NULL;
+
+ assoc_create_master (t, &ctx, snid, nid, master2_tei, master2_mac,
+ &master_net, &master2);
+
+ /* Create and set Master as the real master of the net. */
+ assoc_create_master (t, &ctx, snid, nid, master_tei, master_mac,
+ &master_net, &master);
+
+ bsu_beacon_t beacon_master;
+ test_sta_action_beacon_create (&beacon_master, nid, snid,
+ master_tei, master_mac);
+ bsu_beacon_t beacon_master2;
+ test_sta_action_beacon_create (&beacon_master2, nid, snid,
+ master2_tei, master2_mac);
+
+ ctx.cp.sta_action.assoc.init_count = 2;
+ test_begin (t, "Receive a beacon from the master, synchronisation")
+ {
+ /* In state DETECTING_BEACON */
+ scenario_entry_t entries[] = {
+ SCENARIO_ACTION (detect__beacon_received,
+ .beacon = &beacon_master,
+ .net = master_net,
+ .sta = master),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = false),
+ SCENARIO_EVENT (cp_beacon_process_tracked_avln,
+ .beacon = &beacon_master,
+ .net = master_net),
+ /* Synchronisation still wrong. */
+ SCENARIO_ACTION (detect__beacon_received,
+ .beacon = &beacon_master,
+ .net = master_net,
+ .sta = master),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = false),
+ /* Synchronisation is okay. */
+ SCENARIO_ACTION (detect__beacon_received,
+ .beacon = &beacon_master,
+ .net = master_net,
+ .sta = master),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = true),
+ /* Synchronisation is okay, start association */
+ SCENARIO_ACTION (detect__beacon_received,
+ .beacon = &beacon_master,
+ .net = master_net,
+ .sta = master),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = true),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_nd_beacon),
+ /* Synchronisation is okay, should NOT associate */
+ SCENARIO_ACTION (detect__beacon_received,
+ .beacon = &beacon_master2,
+ .net = master_net,
+ .sta = master2),
+ SCENARIO_EVENT (cp_beacon_synchronised, .ok = true),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (&ctx.cp);
+ test_fail_unless (own->tei_track == master_tei);
+ test_fail_unless (own->cco_mac_addr_track = master_mac);
+ test_fail_unless (own->nid_track = nid);
+ }
+ test_end;
+
+ cp_mme_peer_t master_peer, master2_peer;
+ cp_sta_get_peer (master, &master_peer);
+ cp_sta_get_peer (master2, &master2_peer);
+
+ test_begin (t, "Associate with the master")
+ {
+ ctx.cp.sta_action.assoc.retry = 2;
+ scenario_entry_t entries[] = {
+ /* In state DETECTING_BEACON with event nd_beacon */
+ SCENARIO_ACTION (assoc__detecting_detected),
+ SCENARIO_EVENT (cp_msg_cc_assoc_req_send,
+ .peer = master_peer,
+ .request_type = CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
+ .nid = nid,
+ .cco_cap = CP_CCO_LEVEL,
+ .proxy_cap = CP_PCO_CAP),
+ /* Master2 answers. */
+ SCENARIO_ACTION (assoc__associating_cnf, .peer = master2_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 15),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, CC_ASSOC_CNF, unrelated)),
+ /* Master answers. */
+ SCENARIO_ACTION (assoc__associating_cnf, .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 15),
+ SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
+ .peer = master_peer, .peks = CP_MME_PEKS_DAK,
+ .pid = 0, .pmn = 1, .relayed = false,
+ .key_type = CP_MSG_KEY_NEK, .nid = nid),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, CC_ASSOC_CNF, success)),
+ /* Master answers White list ALL */
+ SCENARIO_ACTION (assoc__associating_cnf, .peer = master_peer),
+ SCENARIO_EVENT (
+ cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS_WL_ACCEPT_ALL,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 15),
+ SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
+ .peer = master_peer, .peks = CP_MME_PEKS_DAK,
+ .pid = 0, .pmn = 1, .relayed = false,
+ .key_type = CP_MSG_KEY_NEK, .nid = nid),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, CC_ASSOC_CNF, success)),
+ /* Master answers with an error in the mme */
+ SCENARIO_ACTION (assoc__associating_cnf, .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = false,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = nid, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 15),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, CC_ASSOC_CNF, unsuccess)),
+ /* Wrong NID. */
+ SCENARIO_ACTION (assoc__associating_cnf, .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cc_assoc_cnf_receive, .ok = true,
+ .result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
+ .nid = 0, .snid = snid, .sta_tei = sta_tei,
+ .lease_time_min = 15),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, CC_ASSOC_CNF, unsuccess)),
+ /* Associating receiving a timeout retry */
+ SCENARIO_ACTION (assoc__associating_timeout),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, timeout_associating, retry)),
+ /* Associating receiving a timeout no retry */
+ SCENARIO_ACTION (assoc__associating_timeout),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATING, timeout_associating, no_retry)),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ /* ASSOCIATING receives a no_beacons event. */
+ SCENARIO_ACTION (assoc__associating_no_beacons),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ }
+ test_end;
+
+ cp_key_t nek = {.key = {0, 0, 0, 0 }};
+ test_begin (t, "Authenticate with the master")
+ {
+ ctx.cp.sta_action.assoc.prun.pid = 0;
+ ctx.cp.sta_action.assoc.prun.pmn = 0;
+ scenario_entry_t entries[] = {
+ /* Receive the get key conf from the master 2. */
+ SCENARIO_ACTION (assoc__associated_key_cnf, .peer = master2_peer),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATED, CM_GET_KEY_CNF, unrelated)),
+ /* Receive the get key conf from the master MME is wrong. */
+ SCENARIO_ACTION (assoc__associated_key_cnf, .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = false,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
+ .key_type = CP_MSG_KEY_NEK,
+ .nid = nid),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATED, CM_GET_KEY_CNF, unrelated)),
+ /* Receive the get key conf from the master MME key refuse. */
+ SCENARIO_ACTION (assoc__associated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 0x2,
+ .new_prn = true,
+ .new_my_nonce = false,
+ .new_your_nonce = false,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED,
+ .key_type = CP_MSG_KEY_NEK,
+ .nid = nid),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATED, CM_GET_KEY_CNF, not_granted)),
+ /* Receive the get key conf from the master MME key granted, wrong
+ * NID. */
+ SCENARIO_ACTION (assoc__associated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .new_prn = true,
+ .pid = 0,
+ .pmn = 0x2,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
+ .key_type = CP_MSG_KEY_NEK),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATED, CM_GET_KEY_CNF, unrelated)),
+ /* Receive the get key conf from the master MME key granted.
+ * Wrong Key type. */
+ SCENARIO_ACTION (assoc__associated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .new_prn = true,
+ .pid = 0,
+ .pmn = 0x2,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
+ .key_type = CP_MSG_KEY_TEK,
+ .nid = nid),
+ /* Receive the get key conf from the master MME key granted. */
+ SCENARIO_ACTION (assoc__associated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 0,
+ .new_prn = false,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
+ .key_type = CP_MSG_KEY_NEK,
+ .nid = nid,
+ .eks = 0,
+ .key = &nek),
+ SCENARIO_EVENT (cp_eoc_beacon_nek_index_adjust, .eks = 0),
+ SCENARIO_EVENT (cp_beacon_change_nek, .eks = 0,
+ .nek = &nek,
+ .now = true),
+ SCENARIO_EVENT (cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (
+ ASSOCIATED, CM_GET_KEY_CNF, all_keys_granted)),
+ SCENARIO_EVENT (cp_msg_cm_get_key_req_send,
+ .peer = master_peer,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 1,
+ .relayed = false,
+ .key_type = CP_MSG_KEY_TEK,
+ .nid = nid),
+ /* ASSOCIATED no beacons. */
+ SCENARIO_ACTION (assoc__associated_no_beacons),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ /* ASSOCIATED timeout associating. */
+ SCENARIO_ACTION (assoc__associated_timeout),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ /* ASSOCIATED receives a CC_LEAVE_IND. Wrong MME. */
+ SCENARIO_ACTION (assoc__associated_leave, .peer = master_peer),
+ SCENARIO_EVENT (
+ cp_msg_cc_leave_ind_receive,
+ .ok = false,
+ .reason = CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
+ .nid = nid),
+ SCENARIO_EVENT (
+ cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (ASSOCIATED, CC_LEAVE_IND, nok)),
+ /* ASSOCIATED receives a CC_LEAVE_IND. Wrong NID */
+ SCENARIO_ACTION (assoc__associated_leave, .peer = master_peer),
+ SCENARIO_EVENT (
+ cp_msg_cc_leave_ind_receive,
+ .ok = true,
+ .reason = CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
+ .nid = 0),
+ SCENARIO_EVENT (
+ cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (ASSOCIATED, CC_LEAVE_IND, nok)),
+ /* ASSOCIATED receives a CC_LEAVE_IND. */
+ SCENARIO_ACTION (assoc__associated_leave, .peer = master_peer),
+ SCENARIO_EVENT (
+ cp_msg_cc_leave_ind_receive,
+ .ok = true,
+ .reason = CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
+ .nid = nid),
+ SCENARIO_EVENT (cp_msg_cc_leave_rsp_send, .peer = master_peer),
+ SCENARIO_EVENT (
+ cp_fsm_branch,
+ .branch = CP_FSM_BRANCH (ASSOCIATED, CC_LEAVE_IND, ok)),
+ SCENARIO_EVENT (cp_beacon_process_untracked_avln),
+ SCENARIO_EVENT (cp_eoc_cco_bw_sta_allocations),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ }
+ test_end;
+
+ test_begin (t, "Authenticate with the master")
+ {
+ cp_sta_mgr_set_our_avln (&ctx.cp, master_net);
+ scenario_entry_t entries[] = {
+ /* Receives the cm_get_key_cnf from Master2. Fails. */
+ SCENARIO_ACTION (auth__authenticated_key_cnf,
+ .peer = master2_peer),
+ /* Receives the cm_get_key_cnf from Master. Wrong MME. */
+ SCENARIO_ACTION (auth__authenticated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true),
+ /* Receives the cm_get_key_cnf from Master. Wrong key. */
+ SCENARIO_ACTION (auth__authenticated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 0x2,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED,
+ .key_type = CP_MSG_KEY_NEK,
+ .nid = nid),
+ /* Receives the cm_get_key_cnf from Master. Refused. */
+ SCENARIO_ACTION (auth__authenticated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 0x2,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED,
+ .key_type = CP_MSG_KEY_TEK,
+ .nid = nid),
+ /* Receives the cm_get_key_cnf from Master. Granted. */
+ SCENARIO_ACTION (auth__authenticated_key_cnf,
+ .peer = master_peer),
+ SCENARIO_EVENT (cp_msg_cm_get_key_cnf_receive,
+ .ok = true,
+ .peks = CP_MME_PEKS_DAK,
+ .pid = 0,
+ .pmn = 0x2,
+ .result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
+ .key_type = CP_MSG_KEY_TEK,
+ .nid = nid),
+ SCENARIO_END
+ };
+ scenario_run (t, entries, &globals);
+ }
+ test_end;
+
test_sta_action_uninit (&ctx);
}
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/beacon_stub.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/beacon_stub.c
index 5593dc7f24..8bdcd88740 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/beacon_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/beacon_stub.c
@@ -43,6 +43,16 @@ cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
}
void
+cp_beacon_process_untracked_avln (cp_t *ctx)
+{
+ cp_sta_own_data_t *own = cp_sta_mgr_get_sta_own_data (ctx);
+ own->nid_track = 0;
+ own->tei_track = 0;
+ own->cco_mac_addr_track = MAC_ZERO;
+ scenario_event (cp_beacon_process_untracked_avln);
+}
+
+void
cp_beacon_beacon_not_received (cp_t *ctx)
{
dbg_assert (ctx);
@@ -66,6 +76,14 @@ cp_beacon_change_nek (cp_t *ctx, uint eks, cp_key_t nek, bool now)
}
void
+cp_eoc_beacon_nek_index_adjust (cp_t *ctx, uint eks)
+{
+ dbg_assert (ctx);
+ scenario_event (cp_eoc_beacon_nek_index_adjust, param);
+ test_fail_unless (eks == param->eks);
+}
+
+void
cp_beacon_deactivate (cp_t *ctx)
{
dbg_assert (ctx);
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/cp_stub.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/cp_stub.c
index 5309cd66bb..b9d5f3c7f3 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/cp_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/cp_stub.c
@@ -11,6 +11,7 @@
* \ingroup test
*/
#include "common/std.h"
+#include "lib/scenario/scenario.h"
#include "cp/cp.h"
void
@@ -27,3 +28,8 @@ cp_sta_core_get_date_ms (cp_t *ctx)
return 0;
}
+void
+cp_eoc_cco_bw_sta_allocations (cp_t *ctx)
+{
+ scenario_event (cp_eoc_cco_bw_sta_allocations);
+}
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/drv.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/drv.c
index 97636daaf9..e51a17e2cd 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/drv.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/drv.c
@@ -115,7 +115,6 @@ drv_basic_test_case (test_t t)
u8 my_param_u8 = 0;
u64 my_param_u64 = 0;
char config[] = "my_param_u8:42 my_param_u64:0x4242424242";
- lib_stats_init ();
lib_stats_set_stat_value_notype ("my_param_u8", &my_param_u8,
LIB_STATS_ACCESS_WRITE_ONLY,
LIB_STATS_USER);
@@ -229,6 +228,7 @@ drv_basic_test_case (test_t t)
SCENARIO_EVENT (cp_msg_drv_sta_set_tonemask_req_receive,
.ok = true,
.tonemask = tonemask),
+ SCENARIO_EVENT (pbproc_parameters_adjust, .adjust = false),
SCENARIO_EVENT (cp_msg_drv_any_cnf_send,
.peer = peer,
.mmtype = DRV_STA_SET_TONEMASK_CNF,
@@ -257,15 +257,11 @@ drv_basic_test_case (test_t t)
cp_key_t nmk_old = { { 0x0, 0x0, 0x0, 0x0} };
- cp_key_t nmk = { { 0x11112222, 0x33334444, 0x55556666, 0x77778888 } };
ctx.cp.sta_mgr.sta_own_data.nmk = nmk_old;
cp_nid_t old_nid = 0x1;
cp_sta_own_data_set_nid (&ctx.cp, old_nid);
cp_sta_own_data_set_security_level (&ctx.cp, 0x0);
- lib_stats_uninit ();
- test_fail_if (my_param_u8 != 42);
- test_fail_if (my_param_u64 != 0x4242424242ull);
enum cp_msg_drv_sta_set_key_type_t type =
CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_NID;
@@ -273,6 +269,7 @@ drv_basic_test_case (test_t t)
nid = ((u64) sl) << (HPAV_NID_SIZE_BITS - 2) | 0x123456789abcdull;
cp_sta_own_data_set_nid (&ctx.cp, nid);
+ cp_key_t nmk = { { 0x11112222, 0x33334444, 0x55556666, 0x77778889 } };
type = CP_MSG_DRV_STA_SET_KEY_TYPE_CHANGE_SECURITY_LEVEL;
scenario_entry_t entries3[] = {
@@ -285,8 +282,6 @@ drv_basic_test_case (test_t t)
.type = type,
.nid = nid,
.sl = sl),
- SCENARIO_EVENT (cp_fsm_event_bare_new,
- .type = CP_FSM_EVENT_TYPE_to_stop),
SCENARIO_EVENT (cp_msg_drv_any_cnf_send,
.peer = peer,
.mmtype = DRV_STA_SET_KEY_CNF,
@@ -308,7 +303,7 @@ drv_basic_test_case (test_t t)
scenario_run (t, entries3, &globals);
nid = cp_secu_nmk2nid (&ctx.cp, nmk, sl);
- test_fail_unless ((cp_sta_own_data_get_nid (&ctx.cp)) == old_nid);
+ test_fail_unless ((cp_sta_own_data_get_nid (&ctx.cp)) == nid);
/* SET DAK. */
cp_key_t dak = {{ 0x11111111, 0x22222222, 0x33333333, 0x44444444}};
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/msg_stub.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/msg_stub.c
index b5dcf4f129..a5ea611e86 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/msg_stub.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/msg_stub.c
@@ -341,6 +341,33 @@ __msd (cp_msg_drv_sta_status_ind_send, cp_msg_drv_sta_status_t,
(bsu_aclf_frequency_t, pwl_sync_frequency, assign))
__mr (cp_msg_drv_sta_set_config_req_receive,
(char *, config, string))
+__msd (cp_msg_cc_assoc_req_send, cp_msg_cc_assoc_req_t,
+ (enum cp_msg_cc_assoc_req_type_t, request_type, assign),
+ (cp_nid_t, nid, assign),
+ (u8, cco_cap, assign),
+ (u8, proxy_cap, assign))
+__mrd (cp_msg_cc_assoc_cnf_receive, cp_msg_cc_assoc_cnf_t,
+ (enum cp_msg_cc_assoc_cnf_result_t *, result, assign),
+ (cp_nid_t, nid, assign),
+ (cp_snid_t, snid, assign),
+ (cp_tei_t, sta_tei, assign),
+ (u16, lease_time_min, assign))
+__mr (cp_msg_cc_leave_ind_receive,
+ (enum cp_msg_cc_leave_ind_reason_t, reason, assign),
+ (cp_nid_t, nid, assign))
+__ms (cp_msg_cc_leave_rsp_send)
+__msk (cp_msg_cm_get_key_req_send, cp_msg_cm_get_key_req_t,
+ (bool, relayed, assign),
+ (enum cp_msg_key_type_t, key_type, assign),
+ (cp_nid_t, nid, assign),
+ (u32 *, hash_key, hash_key))
+__mrk (cp_msg_cm_get_key_cnf_receive, cp_msg_cm_get_key_cnf_t,
+ (enum cp_msg_cm_get_key_cnf_result_t, result, assign),
+ (enum cp_msg_key_type_t, key_type, assign),
+ (cp_nid_t, nid, assign),
+ (u8, eks, assign),
+ (u32 *, hash_key, hash_key),
+ (cp_key_t, key, assign_deref))
__mr (cp_msg_vs_eoc_cco_get_info_req_receive,
(u8, internal_eoc_index, assign),
(u8, control, assign))
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/scenario_actions.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/scenario_actions.c
index 36db73a4b6..94e2d9ced6 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/scenario_actions.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/scenario_actions.c
@@ -154,3 +154,18 @@ __0 (drv__stopping__stopped)
__m (drv__drv_sta_get_key_req)
__m (drv__drv_sta_status_req)
__m (drv__drv_sta_set_config_req)
+
+__n_eoc (detect__beacon_received,
+ (bsu_beacon_t *, beacon),
+ (cp_net_t *, net),
+ (cp_sta_t *, sta))
+__0_eoc (assoc__detecting_no_beacons)
+__0_eoc (assoc__detecting_detected)
+__m_eoc (assoc__associating_cnf)
+__0_eoc (assoc__associating_timeout)
+__0_eoc (assoc__associating_no_beacons)
+__m_eoc (assoc__associated_key_cnf)
+__0_eoc (assoc__associated_no_beacons)
+__0_eoc (assoc__associated_timeout)
+__m_eoc (assoc__associated_leave)
+__m_eoc (auth__authenticated_key_cnf)
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/secu.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/secu.c
new file mode 100644
index 0000000000..d053072477
--- /dev/null
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/secu.c
@@ -0,0 +1,52 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/secu.c
+ * \brief Secu stubs.
+ * \ingroup cp_eoc_sta_action
+ */
+#include "common/std.h"
+#include "cp/secu/secu.h"
+
+void
+cp_secu_protocol_run_new (cp_secu_protocol_run_t *prun, u8 pid,
+ lib_rnd_t *rnd)
+{
+ memset (prun, 0, sizeof (cp_secu_protocol_run_t));
+ prun->pmn = 1;
+ prun->pid = pid;
+ prun->prn = lib_rnd32 (rnd);
+ prun->my_nonce = lib_rnd32 (rnd);
+}
+
+void
+cp_secu_protocol_next (cp_secu_protocol_run_t *prun, lib_rnd_t *rnd,
+ bool last)
+{
+ dbg_assert (prun);
+ dbg_assert (rnd);
+ if (prun->pmn == 1)
+ prun->my_nonce = lib_rnd32 (rnd);
+ if (last)
+ prun->pmn = 0xff;
+ else
+ {
+ dbg_assert (prun->pmn != 0xff);
+ prun->pmn++;
+ }
+}
+
+bool
+cp_secu_protocol_check (const cp_secu_protocol_run_t *prun,
+ const cp_secu_protocol_run_t *prun_recv,
+ const cp_secu_protocol_run_check_result_t expected_result)
+{
+ dbg_assert (prun_recv);
+ return true;
+}
+
diff --git a/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_sta_action.c b/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_sta_action.c
index 2bc846b0bb..3481cb0e37 100644
--- a/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_sta_action.c
+++ b/cesar/cp/eoc/sta/action/test/utest_eoc/src/test_sta_action.c
@@ -113,8 +113,8 @@ main (int argc, char **argv)
test_init (t, argc, argv);
trace_init ();
lib_stats_init ();
-// drv_test_suite (t);
-// assoc_test_suite (t);
+ drv_test_suite (t);
+ assoc_test_suite (t);
lib_stats_uninit ();
trace_uninit ();
test_result (t);
diff --git a/cesar/cp/secu/stub/src/secu.c b/cesar/cp/secu/stub/src/secu.c
index 4c16740551..24a8e59b5c 100644
--- a/cesar/cp/secu/stub/src/secu.c
+++ b/cesar/cp/secu/stub/src/secu.c
@@ -58,7 +58,9 @@ cp_secu_generate_key (cp_t *ctx, uint num, uint nb_iteration, cp_key_t *output)
cp_nid_t
cp_secu_nmk2nid(cp_t *ctx, cp_key_t nmk, u8 security_level)
{
- return 1;
+ cp_nid_t nid = 1;
+ nid |= ((u64) security_level << 52);
+ return nid;
}
void