summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-04-13 16:04:02 +0200
committerNélio Laranjeiro2011-04-18 14:31:57 +0200
commit1f1861d5bda83c7f6d1f4656f6c9d16fb81ed507 (patch)
treebfacc902536d9a3b3e1b9d1152c66657a983ae93 /cesar/cp
parent949e9720fb4a09999538661cef19fc56bb776873 (diff)
cesar/cp/cco/action: take a new snid before starting CCo, closes #2457
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/cco/action/src/cco_action.c4
-rw-r--r--cesar/cp/cco/action/test/src/action-test.c18
-rw-r--r--cesar/cp/cco/action/test/utest/Makefile2
-rw-r--r--cesar/cp/cco/action/test/utest/inc/scenario_defs.h6
-rw-r--r--cesar/cp/cco/action/test/utest/src/assoc.c5
-rw-r--r--cesar/cp/cco/action/test/utest/src/bsu_stub.c24
6 files changed, 47 insertions, 12 deletions
diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c
index f1452f95f1..3e8dc92a67 100644
--- a/cesar/cp/cco/action/src/cco_action.c
+++ b/cesar/cp/cco/action/src/cco_action.c
@@ -385,6 +385,10 @@ 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 (snid);
cp_cco_action_start (ctx);
cp_fsm_trigger_new_event (ctx, bare, assoc_become_cco);
}
diff --git a/cesar/cp/cco/action/test/src/action-test.c b/cesar/cp/cco/action/test/src/action-test.c
index 3d5e531b91..8f46dde156 100644
--- a/cesar/cp/cco/action/test/src/action-test.c
+++ b/cesar/cp/cco/action/test/src/action-test.c
@@ -306,17 +306,15 @@ test_case_cco_action_start (test_t test)
slab_release (sta);
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);
- net = cp_sta_mgr_get_our_avln (&cp);
- test_fail_unless (cp_sta_mgr_net_list_is_empty (&cp));
- test_fail_unless (cp_sta_own_data_get_tei (&cp));
-
- test_fail_if (cp_sta_own_data_get_cco_status (&cp) != true);
- test_fail_if (cp_sta_own_data_get_tei (&cp) == 0x0);
- test_fail_if (cp_net_get_nid (&cp, net)
- != cp_sta_own_data_get_nid (&cp));
- test_fail_if (cp_net_get_snid (&cp, net)
- != cp_sta_own_data_get_snid (&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));
+ test_fail_unless (cp_net_get_snid (&cp, net)
+ != cp_sta_own_data_get_snid (&cp));
+ test_fail_unless (cp_sta_own_data_get_cco_status (&cp));
+ test_fail_unless (MAC_TEI_IS_STA (cp_sta_own_data_get_tei (&cp)));
test_fail_if (cp.mac_config->nek[0].nek_enc[0] == 0);
}
test_end;
diff --git a/cesar/cp/cco/action/test/utest/Makefile b/cesar/cp/cco/action/test/utest/Makefile
index e561a4f2fb..3b9d9b1b86 100644
--- a/cesar/cp/cco/action/test/utest/Makefile
+++ b/cesar/cp/cco/action/test/utest/Makefile
@@ -7,7 +7,7 @@ test_cco_action_SOURCES = test_cco_action.c handover.c nek.c discover_list.c \
assoc.c msg_stub.c fsm_stub.c \
cp_stub.c scenario_actions.c \
dataplane_stub.c beacon_stub.c \
- sta_action.c secu.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 \
diff --git a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h b/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
index 415a2b4b26..f9003b1520 100644
--- a/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
+++ b/cesar/cp/cco/action/test/utest/inc/scenario_defs.h
@@ -153,7 +153,9 @@ __0 (cco__assoc_stop)
cp_msg_cm_set_key_req_send, \
cp_msg_cm_set_key_cnf_receive, \
cp_msg_cm_get_key_req_receive, \
- cp_msg_cm_get_key_cnf_send
+ cp_msg_cm_get_key_cnf_send, \
+ \
+ bsu_power_on
/* MME send event. */
#define __ms(event, param...) \
@@ -274,6 +276,8 @@ __e (cp_beacon_process_untracked_avln)
__e (cp_sta_action_assoc__authenticated__renew)
+__e (bsu_power_on, u8 snid)
+
#undef __e
#undef __p_
diff --git a/cesar/cp/cco/action/test/utest/src/assoc.c b/cesar/cp/cco/action/test/utest/src/assoc.c
index 08dff2dbbb..3ad02d7f98 100644
--- a/cesar/cp/cco/action/test/utest/src/assoc.c
+++ b/cesar/cp/cco/action/test/utest/src/assoc.c
@@ -213,8 +213,10 @@ assoc_test_case_cco (test_t t)
cp_sta_own_data_set_cco_status (&ctx.cp, false);
cp_sta_mgr_set_our_avln (&ctx.cp, NULL);
cp_sta_own_data_set_tei (&ctx.cp, MAC_TEI_UNASSOCIATED);
+ cp_sta_mgr_add_avln (&ctx.cp, 0, 1);
scenario_entry_t usta_to_cco_start [] = {
SCENARIO_ACTION (cco__unassoc_start),
+ SCENARIO_EVENT (bsu_power_on, .snid = 14),
SCENARIO_EVENT (cp_fsm_event_bare_new,
.type = CP_FSM_EVENT_TYPE_cco__nek_change),
SCENARIO_EVENT (cp_beacon_process_untracked_avln),
@@ -223,9 +225,12 @@ assoc_test_case_cco (test_t t)
.type = CP_FSM_EVENT_TYPE_assoc_become_cco),
SCENARIO_END
};
+ cp_snid_t old_snid = cp_sta_own_data_get_snid (&ctx.cp);
scenario_run (t, usta_to_cco_start, &globals);
+ cp_sta_mgr_remove_avln (&ctx.cp, 0, 1);
test_fail_unless (cp_sta_own_data_get_cco_status (&ctx.cp));
test_fail_unless (MAC_TEI_IS_STA (cp_sta_own_data_get_tei (&ctx.cp)));
+ test_fail_unless (old_snid != cp_sta_own_data_get_snid (&ctx.cp));
/* STA to CCo start. */
cp_sta_own_data_set_cco_status (&ctx.cp, false);
scenario_entry_t sta_to_cco [] = {
diff --git a/cesar/cp/cco/action/test/utest/src/bsu_stub.c b/cesar/cp/cco/action/test/utest/src/bsu_stub.c
new file mode 100644
index 0000000000..ebb89e8e87
--- /dev/null
+++ b/cesar/cp/cco/action/test/utest/src/bsu_stub.c
@@ -0,0 +1,24 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/bsu_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "bsu/bsu.h"
+#include "lib/scenario/scenario.h"
+
+void
+bsu_power_on (u8 snid)
+{
+ scenario_event (bsu_power_on, param);
+ test_fail_unless (snid == param->snid);
+}