summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/beacon')
-rw-r--r--cesar/cp/beacon/src/beacon.c15
-rw-r--r--cesar/cp/beacon/test/Makefile-scenario15
-rw-r--r--cesar/cp/beacon/test/inc/scenario_defs.h57
-rw-r--r--cesar/cp/beacon/test/override-scenario/cp/inc/context.h53
-rw-r--r--cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h57
-rw-r--r--cesar/cp/beacon/test/src/beacon.c16
-rw-r--r--cesar/cp/beacon/test/src/beacon_scenario.c136
-rw-r--r--cesar/cp/beacon/test/src/bsu_beacon_stub.c69
-rw-r--r--cesar/cp/beacon/test/src/bsu_stub_scenario.c64
-rw-r--r--cesar/cp/beacon/test/src/fsm_stub.c42
-rw-r--r--cesar/cp/beacon/test/src/scenario_actions.c25
-rw-r--r--cesar/cp/beacon/test/src/sta_mgr_stub.c193
12 files changed, 741 insertions, 1 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 13a09b6b4b..59281a4cdb 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -426,7 +426,6 @@ cp_beacon_countdowns (cp_t *ctx)
{
dbg_assert (ctx);
- // TODO DM: is this test really usefull?
if (less_mod2p32 (ctx->beacon.countdown_limit_date, phy_date ()))
{
u32 intervals;
@@ -514,6 +513,12 @@ cp_beacon_countdowns (cp_t *ctx)
ctx->beacon.eks.kccd = 0;
else
ctx->beacon.eks.kccd -= intervals;
+
+ if (!ctx->beacon.eks.kccd &&
+ (ctx->beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK))
+ {
+ ctx->mac_config->nek[bsu_nek_index_next ()].eks = MAC_EKS_CLEAR;
+ }
}
}
}
@@ -672,6 +677,14 @@ cp_beacon_process_beacon_central (
}
if (beacon->bmis.eks.present)
{
+ if ((beacon->bmis.eks.kbc == BSU_BEACON_EKS_KBC_NEK) &&
+ (ctx->mac_config->nek[bsu_nek_index_next ()].eks !=
+ beacon->bmis.eks.new_eks))
+ {
+ /* POST the FSM event. */
+ cp_fsm_post_new_event (ctx, bare, nek_request);
+ }
+
ctx->beacon.eks.kccd = beacon->bmis.eks.kccd;
ctx->beacon.eks.kbc = beacon->bmis.eks.kbc;
ctx->beacon.eks.new_eks =
diff --git a/cesar/cp/beacon/test/Makefile-scenario b/cesar/cp/beacon/test/Makefile-scenario
new file mode 100644
index 0000000000..58851efaaf
--- /dev/null
+++ b/cesar/cp/beacon/test/Makefile-scenario
@@ -0,0 +1,15 @@
+BASE = ../../..
+
+INCLUDES = cp/beacon/test/override-scenario cp/beacon/test
+
+HOST_PROGRAMS = beacon_fsm
+
+beacon_fsm_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_fsm_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
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/inc/scenario_defs.h b/cesar/cp/beacon/test/inc/scenario_defs.h
new file mode 100644
index 0000000000..ca29563729
--- /dev/null
+++ b/cesar/cp/beacon/test/inc/scenario_defs.h
@@ -0,0 +1,57 @@
+#ifndef inc_scenario_defs_h
+#define inc_scenario_defs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file inc/scenario_defs.h
+ * \brief Scenario definitions.
+ * \ingroup test
+ */
+
+#include "cp/fsm/fsm.h"
+
+/* Scenario globals. */
+#define SCENARIO_DEFS_GLOBALS \
+ cp_t *cp;
+
+#define SCENARIO_DEFS_ACTIONS \
+ nek_request, \
+ get_and_process_beacon
+
+/* Actions without parameter. */
+#define __0(action) \
+typedef scenario_empty_t scenario_action_ ## action ## _t; \
+void \
+scenario_action_ ## action ## _cb ( \
+ scenario_globals_t *globals, scenario_params_t *params);
+
+__0 (nek_request)
+__0 (get_and_process_beacon)
+
+#undef __0
+
+/* Scenario events. */
+/* Scenario events. */
+#define SCENARIO_DEFS_EVENTS \
+ cp_fsm_event_bare_new
+
+/* Any event. */
+#define __p_(param) param;
+
+#define __e(event, param...) \
+typedef struct \
+{ \
+ PREPROC_FOR_EACH (__p_, ## param) \
+} scenario_event_ ## event ## _t;
+
+__e (cp_fsm_event_bare_new, cp_fsm_event_type_t type)
+
+#undef __p_
+#undef __e
+
+#endif /* inc_scenario_defs_h */
diff --git a/cesar/cp/beacon/test/override-scenario/cp/inc/context.h b/cesar/cp/beacon/test/override-scenario/cp/inc/context.h
new file mode 100644
index 0000000000..1a3636145e
--- /dev/null
+++ b/cesar/cp/beacon/test/override-scenario/cp/inc/context.h
@@ -0,0 +1,53 @@
+#ifndef overide_cp_inc_context_h
+#define overide_cp_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp/inc/context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "cp/cco/region/region.h"
+#include "cp/cco/region/inc/context.h"
+#include "cp/cco/bw/bw.h"
+#include "cp/cco/bw/inc/context.h"
+#include "interface/interface.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/sta/mgr/inc/sta_mgr.h"
+
+#include "cp/types.h"
+#include "cp/cco/action/inc/cco_action.h"
+#include "cp/sta/action/inc/context.h"
+#include "cp/beacon/inc/beacon.h"
+#include "cl/cl.h"
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+#include "mac/sar/sar.h"
+#include "mac/pbproc/pbproc.h"
+#include "lib/rnd.h"
+#include "lib/trace.h"
+
+struct cp_t
+{
+ cp_beacon_t beacon;
+ mac_store_t *mac_store;
+ cp_cco_bw_t bw;
+ cp_cco_region_t region;
+ cp_sta_mgr_t sta_mgr;
+
+ hal_timer_t *hal_timer;
+ interface_t *interface;
+
+ mac_config_t *mac_config;
+ bsu_aclf_t *bsu_aclf;
+ pbproc_t *pbproc;
+};
+
+#endif /* overide_cp_inc_context_h */
diff --git a/cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h b/cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h
new file mode 100644
index 0000000000..9698b44e93
--- /dev/null
+++ b/cesar/cp/beacon/test/override-scenario/cp/sta/core/defs.h
@@ -0,0 +1,57 @@
+#ifndef cp_sta_core_defs_h
+#define cp_sta_core_defs_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/sta/core/defs.h
+ * \brief Sta core defs.
+ * \ingroup cp/sta/core
+ *
+ */
+#include "cp/fsm/forward.h"
+
+/** Forward declaration. */
+typedef struct cp_sta_core_t cp_sta_core_t;
+
+/*
+ * the sta core event flags
+ * these are some flags, so take care to give a value with all bits set to 0 but one.
+ */
+enum cp_sta_core_event_flag_t
+{
+ CP_STA_CORE_EVENT_FLAG_RECV_BEACON = 0x1,
+ CP_STA_CORE_EVENT_FLAG_RECV_MME = 0x2,
+ CP_STA_CORE_EVENT_FLAG_FSM = 0x4,
+ CP_STA_CORE_EVENT_FLAG_GARBAGE = 0x8,
+ CP_STA_CORE_EVENT_FLAG_TERMINATE = 0x10
+};
+typedef enum cp_sta_core_event_flag_t cp_sta_core_event_flag_t;
+
+/** Definition of alarm info structure
+ * (applications should not use it directly but use "alias" defined just below) */
+struct cp_sta_core_timed_event_def_t
+{
+ /* eCos alarm. */
+ uint alarm;
+ /* eCos alarm handle. */
+ uint alarm_handle;
+ /* the sta core event flag to set
+ * (auto or user-specified when creating/launching timer alarm). */
+ cp_sta_core_event_flag_t event_flag;
+ /* FSM event specified when creating/launching timer alarm
+ * (set if the previous flag is CP_STA_CORE_EVENT_FLAG_FSM). */
+ cp_fsm_event_t *fsm_event;
+ /* flag indicating a periodic alarm (if set to true)
+ * or one-shot alarm (if set to false). */
+ bool cyclic_alarm;
+ /* pointer to CP context. */
+ cp_t *cp_ctx;
+};
+typedef struct cp_sta_core_timed_event_def_t cp_sta_core_timed_event_def_t;
+
+#endif /* cp_sta_core_defs_h */
diff --git a/cesar/cp/beacon/test/src/beacon.c b/cesar/cp/beacon/test/src/beacon.c
index c72f02670b..b65c45c170 100644
--- a/cesar/cp/beacon/test/src/beacon.c
+++ b/cesar/cp/beacon/test/src/beacon.c
@@ -1148,6 +1148,10 @@ test_case_beacon_eks_change_sta (test_t test)
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;
+ mac_config.nek[bsu_nek_index_current ()].eks = ref_eks_current;
+ mac_config.nek[bsu_nek_index_next ()].eks = ref_eks_next;
/** Check default values. */
test_fail_unless (cp.beacon.eks.kccd == 0);
test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
@@ -1158,6 +1162,10 @@ test_case_beacon_eks_change_sta (test_t test)
test_fail_unless (cp.beacon.eks.kccd == 2);
test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (mac_config.nek[bsu_nek_index_current ()].eks ==
+ ref_eks_current);
+ test_fail_unless (mac_config.nek[bsu_nek_index_next ()].eks ==
+ ref_eks_next);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.eks.kccd = 1;
@@ -1169,6 +1177,10 @@ test_case_beacon_eks_change_sta (test_t test)
test_fail_unless (cp.beacon.eks.kccd == 1);
test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (mac_config.nek[bsu_nek_index_current ()].eks ==
+ ref_eks_current);
+ test_fail_unless (mac_config.nek[bsu_nek_index_next ()].eks ==
+ ref_eks_next);
/* Create the beacon. */
beacon = test_new_beacon ();
beacon->bmis.eks.present = false;
@@ -1181,6 +1193,10 @@ test_case_beacon_eks_change_sta (test_t test)
test_fail_unless (cp.beacon.eks.kccd == 0);
test_fail_unless (cp.beacon.eks.kbc == BSU_BEACON_EKS_KBC_NEK);
test_fail_unless (cp.beacon.eks.new_eks == MAC_EKS_MIN + 1);
+ test_fail_unless (mac_config.nek[bsu_nek_index_current ()].eks ==
+ ref_eks_current);
+ test_fail_unless (mac_config.nek[bsu_nek_index_next ()].eks ==
+ MAC_EKS_CLEAR);
cp_beacon_uninit (&cp);
cp_sta_mgr_uninit (&cp);
dbg_check (mac_store_sta_remove (cp.mac_store, 1));
diff --git a/cesar/cp/beacon/test/src/beacon_scenario.c b/cesar/cp/beacon/test/src/beacon_scenario.c
new file mode 100644
index 0000000000..dce602da64
--- /dev/null
+++ b/cesar/cp/beacon/test/src/beacon_scenario.c
@@ -0,0 +1,136 @@
+/*
+ * beacon_fsm.c
+ *
+ * Created on: 8 mars 2011
+ * Author: mercadie
+ */
+
+
+#include "common/std.h"
+#include "lib/slist.h"
+#include "lib/scenario/scenario.h"
+#include "lib/test.h"
+#include "cp/inc/context.h"
+
+bsu_beacon_t beacon_data;
+
+void
+cp_beacon_receive (cp_t *ctx, pb_beacon_t *beacon, bsu_params_t *params);
+
+void
+beacon_test_case (test_t test)
+{
+ cp_t cp;
+ scenario_globals_t globals = { .cp = &cp, };
+
+ /** Init the context. */
+ memset (&cp, 0, sizeof (cp_t));
+ mac_config_t mac_config;
+ memset (&mac_config, 0, sizeof (mac_config_t));
+ cp.mac_config = &mac_config;
+ cp_sta_mgr_init (&cp);
+
+ mac_eks_t ref_eks_current = MAC_EKS_MIN + 2;
+ mac_eks_t ref_eks_next = MAC_EKS_MIN + 3;
+
+ mac_config.nek[bsu_nek_index_current ()].eks = ref_eks_current;
+ mac_config.nek[bsu_nek_index_next ()].eks = ref_eks_next;
+
+ cp_snid_t our_snid = 1;
+ pb_beacon_t *beacon = (pb_beacon_t *) blk_alloc_desc ();
+ bsu_params_t *bsu_params =
+ &((cp_beacon_payload_t*)beacon->data)->bsu_params;
+ bsu_params->rx_parameters.snid = our_snid;
+
+ test_case_begin (test, "get_and_process_beacon");
+
+ /** Test with eks from the beacon different than the local next eks
+ * we check a nek_request event is sent. */
+ slist_push_back (cp.beacon.list., beacon, bare);
+ beacon_data.bmis.eks.present = true;
+ beacon_data.bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ beacon_data.bmis.eks.new_eks = ref_eks_next + 1;
+
+ test_begin (test, "different eks")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (get_and_process_beacon),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_nek_request),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ }
+ test_end;
+
+ /** Test with matching eks
+ * we check that no event is sent. */
+ slist_push_back (cp.beacon.list., beacon, bare);
+ beacon_data.bmis.eks.present = true;
+ beacon_data.bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ beacon_data.bmis.eks.new_eks = ref_eks_next;
+
+ test_begin (test, "same eks")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (get_and_process_beacon),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ }
+ test_end;
+
+ /* Test with different eks but the it's not a NEK key type
+ * we check that no event is sent. */
+ slist_push_back (cp.beacon.list., beacon, bare);
+ beacon_data.bmis.eks.present = true;
+ beacon_data.bmis.eks.kbc = BSU_BEACON_EKS_KBC_NMK;
+ beacon_data.bmis.eks.new_eks = ref_eks_next + 1;
+
+ test_begin (test, "different eks but not the NEK")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (get_and_process_beacon),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ }
+ test_end;
+
+ /* Test with everything ok, but the local next eks is invalid
+ * we check that a nek_request event is sent. */
+ slist_push_back (cp.beacon.list., beacon, bare);
+ beacon_data.bmis.eks.present = true;
+ beacon_data.bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ beacon_data.bmis.eks.new_eks = ref_eks_next;
+ mac_config.nek[bsu_nek_index_next ()].eks = MAC_EKS_CLEAR;
+
+ test_begin (test, "next eks is invalid")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (get_and_process_beacon),
+ SCENARIO_EVENT (cp_fsm_event_bare_new,
+ .type = CP_FSM_EVENT_TYPE_nek_request),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ }
+ test_end;
+
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t t;
+ test_init (t, argc, argv);
+
+ beacon_test_case (t);
+
+ test_result (t);
+ return test_nb_failed (t) == 0 ? 0 : 1;
+}
diff --git a/cesar/cp/beacon/test/src/bsu_beacon_stub.c b/cesar/cp/beacon/test/src/bsu_beacon_stub.c
new file mode 100644
index 0000000000..2a45ab534b
--- /dev/null
+++ b/cesar/cp/beacon/test/src/bsu_beacon_stub.c
@@ -0,0 +1,69 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/beacon/stub/src/beacon.c
+ * \brief BSU bsu_beacon STUB functions.
+ * \ingroup bsu
+ *
+ * Functions to read and write bsu_beacons.
+ */
+#include "common/std.h"
+#include "common/defs/homeplugAV.h"
+#include "lib/bitstream.h"
+#include "bsu/beacon/beacon.h"
+#include "cp/defs.h"
+
+
+pb_beacon_t pbbeacon;
+extern bsu_beacon_t beacon_data;
+
+pb_beacon_t*
+bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
+ mac_config_t *mac_config, pbproc_tx_beacon_params_t *params)
+{
+ return &pbbeacon;
+}
+
+
+/**
+ * Read the beacon entry header and length.
+ * \param stream the bitstream context.
+ * \param header the pointer to store the header.
+ * \param length the pointer to store the length.
+ * \return true on success, false otherwise.
+ */
+bool
+bsu_beacon_read_bmi_header (bitstream_t *bitstream, uint *header,
+ uint *length)
+{
+ *header = bitstream_read (bitstream, 8);
+ *length = bitstream_read (bitstream, 8);
+ if (BSU_BEACON_ENTRY_IS_BENTRY (*header))
+ return true;
+ return false;
+}
+
+bool
+bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
+ bsu_beacon_type_t *type, u8 *tei, mac_t *mac_address)
+{
+ *type = BSU_BEACON_TYPE_CENTRAL;
+ beacon->vf.nid = 1;
+ *tei = 1;
+ *mac_address = 0x123456789ABCull;
+ beacon->bmis.eks.present = beacon_data.bmis.eks.present;
+ beacon->bmis.eks.kbc = beacon_data.bmis.eks.kbc;
+ beacon->bmis.eks.new_eks = beacon_data.bmis.eks.new_eks;
+
+ return true;
+}
+
+void
+bsu_beacon_countdown (bsu_beacon_t *beacon)
+{
+}
diff --git a/cesar/cp/beacon/test/src/bsu_stub_scenario.c b/cesar/cp/beacon/test/src/bsu_stub_scenario.c
new file mode 100644
index 0000000000..081dbd6fbe
--- /dev/null
+++ b/cesar/cp/beacon/test/src/bsu_stub_scenario.c
@@ -0,0 +1,64 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/bsu_stub.c
+ */
+#include "common/std.h"
+#include "bsu/beacon/beacon.h"
+#include "bsu/aclf/aclf.h"
+
+void
+bsu_update (bsu_beacon_t *beacon, bool sta)
+{
+}
+
+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_60HZ_TCK;
+}
+
+u32
+bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx)
+{
+ return MAC_TCK_TO_ATU (BSU_ACLF_BP_60HZ_TCK);
+}
+
+
+void
+bsu_track_avln (u64 nid, u16 snid, u8 tei, mac_coexistence_mode_t hm)
+{
+}
+
+void
+bsu_update_discover_info (bsu_beacon_bmi_discover_info_t *discover)
+{
+}
+
+void
+bsu_update_nid (u64 nid)
+{
+}
+
diff --git a/cesar/cp/beacon/test/src/fsm_stub.c b/cesar/cp/beacon/test/src/fsm_stub.c
new file mode 100644
index 0000000000..2c0883dc97
--- /dev/null
+++ b/cesar/cp/beacon/test/src/fsm_stub.c
@@ -0,0 +1,42 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/fsm_stub.c
+ * \brief FSM stub.
+ * \ingroup test
+ */
+#include "common/std.h"
+#include "cp/fsm/fsm.h"
+
+#include "lib/scenario/scenario.h"
+
+cp_fsm_event_t *
+cp_fsm_event_bare_new (cp_t *ctx, cp_fsm_event_type_t type)
+{
+ dbg_assert (ctx);
+ switch (type)
+ {
+ case CP_FSM_EVENT_TYPE_snid_conflict:
+ case CP_FSM_EVENT_TYPE_net_list_empty:
+ case CP_FSM_EVENT_TYPE_ustt_timeout:
+ case CP_FSM_EVENT_TYPE_btt_timeout:
+ case CP_FSM_EVENT_TYPE_join_timeout:
+ case CP_FSM_EVENT_TYPE_assoc_timeout:
+ case CP_FSM_EVENT_TYPE_renew:
+ case CP_FSM_EVENT_TYPE_sta_status_changed:
+ case CP_FSM_EVENT_TYPE_all_sta_leaved:
+ case CP_FSM_EVENT_TYPE_become_cco:
+ /* Ignore. */
+ return INVALID_PTR;
+ default:
+ ;
+ }
+ scenario_event (cp_fsm_event_bare_new, param);
+ test_fail_unless (type == param->type);
+ return INVALID_PTR;
+}
diff --git a/cesar/cp/beacon/test/src/scenario_actions.c b/cesar/cp/beacon/test/src/scenario_actions.c
new file mode 100644
index 0000000000..1e71f46112
--- /dev/null
+++ b/cesar/cp/beacon/test/src/scenario_actions.c
@@ -0,0 +1,25 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/scenario_actions.c
+ * \brief Scenario actions.
+ * \ingroup test
+ */
+#include "common/std.h"
+#include "cp/beacon/beacon.h"
+#include "lib/scenario/scenario.h"
+
+#define __0(ACTION) \
+void \
+scenario_action_ ## ACTION ## _cb (scenario_globals_t *globals, \
+ scenario_params_t *params) \
+{ \
+ cp_beacon_ ## ACTION (globals->cp); \
+}
+
+__0 (get_and_process_beacon)
diff --git a/cesar/cp/beacon/test/src/sta_mgr_stub.c b/cesar/cp/beacon/test/src/sta_mgr_stub.c
new file mode 100644
index 0000000000..dc4b05e16e
--- /dev/null
+++ b/cesar/cp/beacon/test/src/sta_mgr_stub.c
@@ -0,0 +1,193 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/src/sta_mgr_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp/sta/mgr/sta_own_data.h"
+#include "cp/sta/mgr/net.h"
+#include "cp/sta/mgr/inc/net.h"
+#include "cp/sta/mgr/inc/sta.h"
+#include "cp/sta/mgr/inc/sta_mgr.h"
+#include "cp/sta/mgr/sta_mgr.h"
+#include "cp/inc/context.h"
+
+cp_sta_own_data_t own_data;
+cp_net_t our_avln;
+
+void
+cp_sta_mgr_init (cp_t *ctx)
+{
+ dbg_assert (ctx);
+
+ own_data.nid_track = 1;
+ own_data.tei_track = 1;
+
+ memset (&ctx->sta_mgr, 0, sizeof (cp_sta_mgr_t));
+
+
+ // Initialise the slab cache.
+ slab_cache_init (&ctx->sta_mgr.sta_slab_cache,
+ "Station cache",
+ sizeof (cp_sta_private_t),
+ (slab_object_destructor_t) NULL);
+}
+
+
+cp_sta_own_data_t *
+cp_sta_mgr_get_sta_own_data (cp_t *ctx)
+{
+ return &own_data;
+}
+
+bool
+cp_sta_own_data_get_cco_status (cp_t *ctx)
+{
+ return false;
+}
+
+bool
+cp_sta_own_data_get_pco_status (cp_t *ctx)
+{
+ return false;
+}
+
+u8
+cp_sta_mgr_get_num_discovered_stas (cp_t *ctx)
+{
+ return 0;
+}
+
+u8
+cp_sta_mgr_get_num_discovered_net (cp_t *ctx)
+{
+ return 0;
+}
+
+bool
+cp_sta_own_data_get_authenticated_status (cp_t *ctx)
+{
+ return true;
+}
+
+cp_tei_t
+cp_sta_own_data_get_tei (cp_t *ctx)
+{
+ return 2;
+}
+
+cp_net_t *
+cp_sta_mgr_get_our_avln (cp_t *ctx)
+{
+ return &our_avln;
+}
+
+cp_nid_t
+cp_sta_own_data_get_nid (cp_t *ctx)
+{
+ return 1;
+}
+
+u8
+cp_sta_mgr_get_slot_usage (cp_t *ctx)
+{
+ return 1;
+}
+
+u8
+cp_net_get_slot_id (cp_t *ctx, cp_net_t *net)
+{
+ return 0;
+}
+
+cp_net_network_mode_t
+cp_net_get_nm (cp_t *ctx, cp_net_t *net)
+{
+ return CP_NET_NM_UNCOORDINATED;
+}
+
+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_private_t *sta;
+
+ sta = (cp_sta_private_t *) slab_alloc (&ctx->sta_mgr.sta_slab_cache);
+ memset (sta, 0, sizeof (cp_sta_private_t));
+
+ // Add a reference on the station.
+ slab_addref (sta);
+
+ return &sta->public_data;
+}
+
+void
+cp_net_set_cco (cp_t *ctx, cp_net_t *net, cp_tei_t tei){}
+
+void
+cp_net_set_pco (cp_t *ctx, cp_net_t *net, cp_tei_t tei){}
+
+void
+cp_sta_set_authenticated_ (
+ cp_t *ctx, cp_sta_t *sta, bool auth __FL){}
+
+void
+cp_sta_own_data_set_snid (cp_t *ctx, cp_snid_t snid){}
+
+cp_sta_t *
+cp_sta_mgr_sta_get_assoc (cp_t *ctx, cp_net_t *net, cp_tei_t tei)
+{
+ return NULL;
+}
+
+cp_net_t *
+cp_sta_mgr_add_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
+{
+ return &our_avln;
+}
+
+void
+cp_net_set_access (cp_t *ctx, cp_net_t *net, hpav_access_t access){}
+
+void
+cp_net_set_slot_id_and_usage (cp_t *ctx, cp_net_t *net,
+ u8 slot_id, u8 slot_usage){}
+
+cp_snid_t
+cp_sta_own_data_get_snid (cp_t *ctx)
+{
+ return 1;
+}
+
+u8
+cp_net_get_num_stas (cp_t *ctx, cp_net_t *net)
+{
+ dbg_assert (net);
+ return net->num_stas;
+}
+
+cp_sta_t *
+cp_net_sta_get_first (cp_t *ctx, cp_net_t *net, cp_net_sta_status_t assoc)
+{
+ return NULL;
+}
+
+cp_tei_t
+cp_sta_get_tei (cp_sta_t *ctx)
+{
+ return 0;
+}
+
+cp_sta_t *
+cp_net_sta_get_next (cp_t *ctx, cp_net_t *net, cp_sta_t *prev_sta)
+{
+ return NULL;
+}