summaryrefslogtreecommitdiff
path: root/cesar/cp2
diff options
context:
space:
mode:
authorschodet2008-07-28 13:10:29 +0000
committerschodet2008-07-28 13:10:29 +0000
commit9ea9051383245eaa802a594021e888db161f7db9 (patch)
treea357aad071e1b9753a031a82ed048d9b8f9cd1a7 /cesar/cp2
parentcd5e703ffe18c0440ecd196949419d75d1672381 (diff)
* cp2/sta/action:
- added first poweron test. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2675 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2')
-rw-r--r--cesar/cp2/defs.h3
-rw-r--r--cesar/cp2/sta/action/src/poweron.c23
-rw-r--r--cesar/cp2/sta/action/test/utest/Makefile3
-rw-r--r--cesar/cp2/sta/action/test/utest/src/poweron.c71
-rw-r--r--cesar/cp2/sta/action/test/utest/src/test_sta_action.c4
5 files changed, 103 insertions, 1 deletions
diff --git a/cesar/cp2/defs.h b/cesar/cp2/defs.h
index ae068e2b84..83ffc66fca 100644
--- a/cesar/cp2/defs.h
+++ b/cesar/cp2/defs.h
@@ -47,6 +47,9 @@
/** Expiration delay for the networks. */
#define CP_NET_EXPIRATION_DELAY_S 70
+/** Unassociated STA Advertisement Interval. */
+#define CP_USAI_S 1
+
/** Discover period in seconds. */
#define CP_DISCOVER_PERIOD_MAX_S 10
diff --git a/cesar/cp2/sta/action/src/poweron.c b/cesar/cp2/sta/action/src/poweron.c
index 90b5d3d339..d8207cfd2d 100644
--- a/cesar/cp2/sta/action/src/poweron.c
+++ b/cesar/cp2/sta/action/src/poweron.c
@@ -14,6 +14,27 @@
#include "action.h"
+#include "cp2/msg/msg.h"
+#include "cp2/sta/mgr/sta_mgr.h"
+
+/**
+ * Common handling of POWERON and USTA => USTT TIMEOUT.
+ * \param ctx control plane context
+ * \param ustt_ms USTT timer maximum value
+ */
+static void
+cp_sta_action_poweron_ustt_timeout (cp_t *ctx, uint ustt_ms)
+{
+ if (!cp_sta_mgr_net_list_is_empty (ctx))
+ {
+ /* Send an CM_UNASSOCIATED_STA.IND. */
+ cp_net_t *our_net = cp_sta_mgr_get_our_avln (ctx);
+ cp_msg_cm_unassociated_sta_ind_send (ctx, &CP_MME_PEER (MAC_BROADCAST),
+ cp_net_get_nid (ctx, our_net),
+ CP_CCO_LEVEL);
+ }
+}
+
void
cp_sta_action_poweron_start (cp_t *ctx)
{
@@ -22,6 +43,7 @@ cp_sta_action_poweron_start (cp_t *ctx)
void
cp_sta_action_poweron__poweron__ustt_timeout (cp_t *ctx)
{
+ cp_sta_action_poweron_ustt_timeout (ctx, CP_USAI_S * 1000);
}
void
@@ -43,6 +65,7 @@ cp_sta_action_poweron__poweron_joining__unassociated (cp_t *ctx)
void
cp_sta_action_poweron__usta__ustt_timeout (cp_t *ctx)
{
+ cp_sta_action_poweron_ustt_timeout (ctx, CP_DISCOVER_PERIOD_MAX_S * 1000);
}
void
diff --git a/cesar/cp2/sta/action/test/utest/Makefile b/cesar/cp2/sta/action/test/utest/Makefile
index 0946cf9cc4..3f9ee944ed 100644
--- a/cesar/cp2/sta/action/test/utest/Makefile
+++ b/cesar/cp2/sta/action/test/utest/Makefile
@@ -4,6 +4,7 @@ INCLUDES = cp2/sta/action/test/utest cp2/sta/action/test/utest/override
HOST_PROGRAMS = test_sta_action
test_sta_action_SOURCES = test_sta_action.c assoc.c drv.c info.c \
+ poweron.c \
msg_stub.c dataplane_stub.c fsm_stub.c \
scenario_actions.c
test_sta_action_MODULES = lib lib/scenario cp2/sta/action cp2/sta/mgr \
@@ -12,5 +13,5 @@ cp2_fsm_MODULE_SOURCES = tables.c
include $(BASE)/common/make/top.mk
+$(call src2obj,src/assoc.c,host): $(BASE)/cp2/fsm/fsm.h
$(call src2obj,src/fsm_stub.c,host): $(BASE)/cp2/fsm/fsm.h
-$(call src2obj,src/fsm_stub.c,target): $(BASE)/cp2/fsm/fsm.h
diff --git a/cesar/cp2/sta/action/test/utest/src/poweron.c b/cesar/cp2/sta/action/test/utest/src/poweron.c
new file mode 100644
index 0000000000..3de55d978d
--- /dev/null
+++ b/cesar/cp2/sta/action/test/utest/src/poweron.c
@@ -0,0 +1,71 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/poweron.c
+ * \brief Test sta/action/poweron.
+ * \ingroup test
+ */
+#include "common/std.h"
+
+#include "lib/scenario/scenario.h"
+
+#include "inc/test_sta_action.h"
+
+void
+poweron_test_cases (test_t t)
+{
+ test_sta_action_t ctx;
+ test_sta_action_init (&ctx);
+ scenario_globals_t globals = {
+ .cp = &ctx.cp,
+ };
+ cp_nid_t nid = 0x111111111111ull;
+ cp_sta_mgr_update_our_avln_nid (&ctx.cp, nid);
+ test_case_begin (t, "poweron-usta");
+ test_begin (t, "ustt")
+ {
+ /* Without any other AVLN. */
+ scenario_entry_t entries_wo[] = {
+ /* POWERON. */
+ SCENARIO_ACTION (poweron__poweron__ustt_timeout),
+ /* USTA. */
+ SCENARIO_ACTION (poweron__usta__ustt_timeout),
+ SCENARIO_END
+ };
+ scenario_run (t, entries_wo, &globals);
+ /* With other AVLN. */
+ cp_sta_mgr_add_avln (&ctx.cp, 1, 0x111111111111ull);
+ scenario_entry_t entries_w[] = {
+ /* POWERON. */
+ SCENARIO_ACTION (poweron__poweron__ustt_timeout),
+ SCENARIO_EVENT (cp_msg_cm_unassociated_sta_ind_send,
+ .peer = CP_MME_PEER (MAC_BROADCAST), .nid = nid,
+ .cco_cap = CP_CCO_LEVEL),
+ /* USTA. */
+ SCENARIO_ACTION (poweron__usta__ustt_timeout),
+ SCENARIO_EVENT (cp_msg_cm_unassociated_sta_ind_send,
+ .peer = CP_MME_PEER (MAC_BROADCAST), .nid = nid,
+ .cco_cap = CP_CCO_LEVEL),
+ SCENARIO_END
+ };
+ scenario_run (t, entries_w, &globals);
+ } test_end;
+}
+
+void
+poweron_test_suite (test_t t)
+{
+ test_suite_begin (t, "poweron");
+ poweron_test_cases (t);
+ test_case_begin (t, "memory");
+ test_begin (t, "memory")
+ {
+ test_fail_unless (blk_check_memory ());
+ } test_end;
+}
+
diff --git a/cesar/cp2/sta/action/test/utest/src/test_sta_action.c b/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
index 0a8c957742..1f68f9e648 100644
--- a/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
+++ b/cesar/cp2/sta/action/test/utest/src/test_sta_action.c
@@ -26,6 +26,9 @@ void
info_test_suite (test_t t);
void
+poweron_test_suite (test_t t);
+
+void
test_sta_action_init (test_sta_action_t *ctx)
{
ctx->cp.mac_config = &ctx->mac_config;
@@ -47,6 +50,7 @@ main (int argc, char **argv)
assoc_test_suite (t);
drv_test_suite (t);
info_test_suite (t);
+ poweron_test_suite (t);
test_result (t);
return test_nb_failed (t) == 0 ? 0 : 1;
}