summaryrefslogtreecommitdiff
path: root/cesar/test_general/station
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/test_general/station
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/test_general/station')
-rw-r--r--cesar/test_general/station/Module1
-rw-r--r--cesar/test_general/station/inc/int_context.h97
-rw-r--r--cesar/test_general/station/int_station.h117
-rw-r--r--cesar/test_general/station/int_station_fc.h154
-rw-r--r--cesar/test_general/station/overide/cp/cco/Module1
-rw-r--r--cesar/test_general/station/overide/cp/cco/cco.h123
-rw-r--r--cesar/test_general/station/overide/cp/cco/inc/context.h46
-rw-r--r--cesar/test_general/station/overide/cp/cco/src/cco.c281
-rw-r--r--cesar/test_general/station/overide/cp/secu/Module1
-rw-r--r--cesar/test_general/station/overide/cp/secu/inc/context.h24
-rw-r--r--cesar/test_general/station/overide/cp/secu/secu.h58
-rw-r--r--cesar/test_general/station/overide/cp/secu/src/secu.c74
-rw-r--r--cesar/test_general/station/overide/cp/station/Module1
-rw-r--r--cesar/test_general/station/overide/cp/station/inc/context.h39
-rw-r--r--cesar/test_general/station/overide/cp/station/src/station.c243
-rw-r--r--cesar/test_general/station/overide/cp/station/station.h183
-rw-r--r--cesar/test_general/station/src/int_station.c736
17 files changed, 2179 insertions, 0 deletions
diff --git a/cesar/test_general/station/Module b/cesar/test_general/station/Module
new file mode 100644
index 0000000000..c6741e6429
--- /dev/null
+++ b/cesar/test_general/station/Module
@@ -0,0 +1 @@
+SOURCES:= int_station.c
diff --git a/cesar/test_general/station/inc/int_context.h b/cesar/test_general/station/inc/int_context.h
new file mode 100644
index 0000000000..a5e133063b
--- /dev/null
+++ b/cesar/test_general/station/inc/int_context.h
@@ -0,0 +1,97 @@
+#ifndef INT_CONTEXT_H_
+#define INT_CONTEXT_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file int_context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include <cyg/hal/hal_arch.h>
+#include <cyg/kernel/kapi.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "lib/trace.h"
+
+#include "mac/common/timings.h"
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/sar/sar.h"
+
+#include "cl/cl.h"
+#include "hle/hle.h"
+
+#include "cp/beacon/beacons.h"
+#include "cp/secu/inc/secu_types.h"
+#include "cp/station/station.h"
+#include "cp/cco/cco.h"
+
+#include "hal/timer/timer.h"
+#include "interface/interface.h"
+
+
+u8 sched_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+u8 sar_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+struct tei_node_t
+{
+ list_node_t node;
+ uint tei;
+};
+typedef struct tei_node_t tei_node_t;
+
+struct cp_t
+{
+ u8 *mme_tx_buffer;
+ cp_cco_t *cco;
+ cp_sta_t *sta;
+ cp_secu_t *secu;
+ cp_beacon_t *beacon;
+};
+typedef struct cp_t cp_t;
+
+struct int_station_t
+{
+ mac_config_t *mac_config;
+ mac_store_t *mac_store;
+ pbproc_t *pbproc;
+ sar_t *sar;
+ cl_t *cl;
+ hle_t *hle;
+ cp_t cp;
+ hal_timer_t *timer;
+ interface_t *interface;
+
+
+ /** indicate if the pbproc is activate */
+ bool pbproc_activate;
+
+ /** Used to memorize the list of TEI inserted in the mac_Store to remove it
+ * in the future.
+ */
+ list_t tei_list;
+
+ /** pbproc data */
+ uint sched_index;
+
+ cyg_handle_t sched_handle;
+ cyg_thread sched_thread;
+
+ /** sar data*/
+ cyg_handle_t sar_handle;
+ cyg_thread sar_thread;
+};
+typedef struct int_station_t int_station_t;
+
+#endif /*INT_CONTEXT_H_*/
diff --git a/cesar/test_general/station/int_station.h b/cesar/test_general/station/int_station.h
new file mode 100644
index 0000000000..ba545675e3
--- /dev/null
+++ b/cesar/test_general/station/int_station.h
@@ -0,0 +1,117 @@
+#ifndef TEST_GENERAL_STATION_H_
+#define TEST_GENERAL_STATION_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file station/inc/station.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * Contains all the functions calls to initialize for maximus test.
+ */
+
+#include "test_general/station/inc/int_context.h"
+
+typedef struct int_station_t int_station;
+
+/**
+ * Init the station and returns the result of the memory test
+ *
+ * \return ctx the int_station context.
+ */
+int_station_t *int_station_init (void);
+
+/**
+ * Uninit the station and returns the result of the memory test
+ *
+ * \param ctx the station context.
+ */
+void int_station_uninit (int_station_t *ctx);
+
+/**
+ * Provides the Tei of the STA and the SNID
+ *
+ * \param ctx the station context
+ * \param tei the tei of the station
+ * \param snid the snid of the AVLN
+ * \param beacon_period_auto generation automatic of the beacon period for
+ * the CA scheduling
+ * \param cco boolean informing if the sta is cco or not
+ * \param authenticated boolean informing if the sta is authenticated or
+ * not.
+ */
+void int_station_config (int_station_t *ctx, uint tei, uint snid,
+ bool beacon_period_auto, bool cco, bool authenticated, mac_t
+ mac_address);
+
+/**
+ * Provides the TEI of all the station in the AVLN.
+ *
+ * \param ctx the station context.
+ * \param tei the tei list of the stations
+ * \param macs the list of mac address of the STAs.
+ * \param qte the quantity of TEIs in the list.
+ */
+void int_station_discover (int_station_t *ctx, uint *tei, mac_t *macs,
+ uint qte);
+
+/**
+ * Add a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void int_station_link_add (int_station_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei);
+
+/**
+ * Remove a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void int_station_link_remove (int_station_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei);
+
+/**
+ * Thread entry finction
+ *
+ * \param int_sta the sta context.
+ */
+void pbproc_sched (cyg_addrword_t int_sta);
+
+/**
+ * Create a schedule for the Channel Access (beacon period) in CSMA only mode.
+ * Shall always be used to send or receive data.
+ *
+ * \param int_sta the pbproc context
+ * \param beacon_period_nb the quantity of beacon periods for the test.
+ */
+void
+create_schedule_csma_only (int_station_t *int_sta,
+ uint beacon_period_nb);
+
+/**
+ * Cp beacon call back when the leon timer expires.
+ * It shall call the add event function of the Visual state FSM.
+ *
+ * \param user_data the user_data provided on the cp_beacon_init function.
+ */
+void
+cp_beacon_timer_expires (void *user_data);
+
+#endif /*TEST_GENERAL_STATION_H_*/
diff --git a/cesar/test_general/station/int_station_fc.h b/cesar/test_general/station/int_station_fc.h
new file mode 100644
index 0000000000..c170f8ffbd
--- /dev/null
+++ b/cesar/test_general/station/int_station_fc.h
@@ -0,0 +1,154 @@
+#ifndef INT_STATION_FC_H_
+#define INT_STATION_FC_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file int_station_fc.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "host/station.h"
+
+/**
+ * Initialize the configuration of the STA.
+ * The parameters we must provide are the TEI of the STA, the SNID and the
+ * boolean to indicate the auto generation of the beacon periods.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_init_config (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * Provide to the STA using the parameters of the function call the station
+ * use for the test. Each STA shall known the TEI of the others present in the
+ * AVLN.
+ *
+ * The function call parameters must be
+ * - qte the quantity of TEIs present in the paramters. One for each STA
+ * without this one.
+ * - tei The list of TEIs.
+ * - mac the list of mac address.
+ *
+ * This will be use to add the STA's to the mac store, the STA will keep a
+ * list of theses TEI to remove the STA during the uninit procedure.
+ *
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_discover (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * Add a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_add (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * Remove a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_remove (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * Request the pbproc to print its trace buffer.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_pbproc_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * Request the cp_beacon to print its trace buffer.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_cp_beacon_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * print the sar traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_sar_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+
+/**
+ * print the cl traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_cl_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+/**
+ * print the hle traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_hle_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data);
+
+
+#endif /*INT_STATION_FC_H_*/
diff --git a/cesar/test_general/station/overide/cp/cco/Module b/cesar/test_general/station/overide/cp/cco/Module
new file mode 100644
index 0000000000..89eab437be
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/cco/Module
@@ -0,0 +1 @@
+SOURCES:=cco.c
diff --git a/cesar/test_general/station/overide/cp/cco/cco.h b/cesar/test_general/station/overide/cp/cco/cco.h
new file mode 100644
index 0000000000..0dcda62b01
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/cco/cco.h
@@ -0,0 +1,123 @@
+#ifndef cp_beacon_test_central_beacon_overide_cp_cco_cco_h
+#define cp_beacon_test_central_beacon_overide_cp_cco_cco_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/cco/cco.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+/** Foward declaration */
+typedef struct cp_cco_t cp_cco_t;
+
+cp_cco_t *
+cp_cco_init (void);
+
+void
+cp_cco_uninit (cp_cco_t *ctx);
+
+uint
+cp_cco_get_dt_av(cp_cco_t *ctx);
+
+void
+cp_coo_set_dt_av (cp_cco_t *ctx, uint dt_av);
+
+bool
+cp_cco_get_access(cp_cco_t *ctx);
+
+void
+cp_cco_set_access(cp_cco_t *ctx, bool access);
+
+bool
+cp_cco_get_ncnr (cp_cco_t *ctx);
+
+void
+cp_cco_set_ncnr (cp_cco_t *ctx, bool ncnr);
+
+bool
+cp_cco_get_npsm (cp_cco_t *ctx);
+
+void
+cp_cco_set_npsm (cp_cco_t *ctx, bool npsm);
+
+u8
+cp_cco_get_numslots (cp_cco_t *ctx);
+
+void
+cp_cco_set_numslots (cp_cco_t *ctx, u8 num_slots);
+
+u8
+cp_cco_get_slotusage (cp_cco_t *ctx);
+
+void
+cp_cco_set_slotusage (cp_cco_t *ctx, u8 slotusage);
+
+u8
+cp_cco_get_slot_id (cp_cco_t *ctx);
+
+void
+cp_cco_set_slot_id (cp_cco_t *ctx, u8 slot_id);
+
+u8
+cp_cco_get_aclss (cp_cco_t *ctx);
+
+void
+cp_cco_set_aclss (cp_cco_t *ctx, u8 aclss);
+
+u8
+cp_cco_get_nm (cp_cco_t *ctx);
+
+void
+cp_cco_set_nm (cp_cco_t *ctx, u8 nm);
+
+u8
+cp_cco_get_cco_cap (cp_cco_t *ctx);
+
+void
+cp_cco_set_cco_cap (cp_cco_t *ctx, u8 cco_cap);
+
+bool
+cp_cco_get_proxy_cap (cp_cco_t *ctx);
+
+void
+cp_cco_set_proxy_cap (cp_cco_t *ctx, bool proxy_cap);
+
+bool
+cp_cco_get_backup_cap (cp_cco_t *ctx);
+
+void
+cp_cco_set_backup_cap (cp_cco_t *ctx, bool backup_cap);
+
+bool
+cp_cco_get_cco_status (cp_cco_t *ctx);
+
+void
+cp_cco_set_cco_status (cp_cco_t *ctx, bool cco_status);
+
+bool
+cp_cco_get_pco_status(cp_cco_t *ctx);
+
+void
+cp_cco_set_pco_status(cp_cco_t *ctx, bool pco_status);
+
+bool
+cp_cco_get_backup_cco_status(cp_cco_t *ctx);
+
+void
+cp_cco_set_backup_cco_status(cp_cco_t *ctx, bool backup_cco_status);
+
+bool
+cp_cco_get_user_appointed_cco_status(cp_cco_t *ctx);
+
+void
+cp_cco_set_user_appointed_cco_status(cp_cco_t *ctx, bool ua_cco_status);
+
+#endif /* cp_beacon_test_central_beacon_overide_cp_cco_cco_h */
diff --git a/cesar/test_general/station/overide/cp/cco/inc/context.h b/cesar/test_general/station/overide/cp/cco/inc/context.h
new file mode 100644
index 0000000000..a503f02382
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/cco/inc/context.h
@@ -0,0 +1,46 @@
+#ifndef cp_beacon_test_central_beacon_overide_cp_cco_inc_context_h
+#define cp_beacon_test_central_beacon_overide_cp_cco_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/cco/inc/context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+struct cp_cco_t
+{
+ BITFIELDS_WORD
+ (
+ uint dt_av:3;,
+ uint access:1;,
+ uint ncnr:1;,
+ uint npsm:1;,
+ uint num_slots:3;,
+ uint slot_usage:8;,
+ uint slotid:3;,
+ uint aclss:3;,
+ uint nm:2;,
+ uint cco_cap:2;,
+ uint proxy_cap:1;,
+ uint backup_cap:1;,
+ uint cco_status:1;,
+ uint pco_status:1;,
+ uint backup_cco:1;
+ );
+ BITFIELDS_WORD
+ (
+ uint nr:6;,
+ uint user_appointed_cco_status:1;,
+ uint rsvd:25;
+ );
+};
+
+#endif /* cp_beacon_test_central_beacon_overide_cp_cco_inc_context_h */
diff --git a/cesar/test_general/station/overide/cp/cco/src/cco.c b/cesar/test_general/station/overide/cp/cco/src/cco.c
new file mode 100644
index 0000000000..c793828138
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/cco/src/cco.c
@@ -0,0 +1,281 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/cco/src/cco.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "cp/cco/cco.h"
+#include "cp/cco/inc/context.h"
+
+static cp_cco_t cco;
+
+cp_cco_t *
+cp_cco_init (void)
+{
+ cco.dt_av = 0x0;
+ cco.access = 0x0;
+ cco.ncnr = 0x0;
+ cco.npsm = 0x0;
+ cco.num_slots = 0x1;
+ cco.slot_usage = 0x1;
+ cco.slotid = 0x0;
+ cco.aclss = 0x1;
+ cco.nm = 0x2;
+ cco.cco_cap = 0x0;
+ cco.proxy_cap = 0;
+ cco.backup_cap = 0;
+ cco.cco_status = 0;
+ cco.pco_status = 0;
+ cco.backup_cco = 0;
+ cco.nr = 0;
+ cco.user_appointed_cco_status = 0;
+ cco.rsvd = 0;
+
+ return &cco;
+}
+
+void
+cp_cco_uninit (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+uint
+cp_cco_get_dt_av(cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->dt_av;
+}
+
+void
+cp_coo_set_dt_av (cp_cco_t *ctx, uint dt_av)
+{
+ dbg_assert (ctx);
+ ctx->dt_av = dt_av;
+}
+
+bool
+cp_cco_get_access(cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->access;
+}
+
+void
+cp_cco_set_access(cp_cco_t *ctx, bool access)
+{
+ dbg_assert (ctx);
+
+ ctx->access = access;
+}
+
+bool
+cp_cco_get_ncnr (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->ncnr;
+}
+
+void
+cp_cco_set_ncnr (cp_cco_t *ctx, bool ncnr)
+{
+ dbg_assert (ctx);
+ ctx->ncnr = ncnr;
+}
+
+bool
+cp_cco_get_npsm (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->npsm;
+}
+
+void
+cp_cco_set_npsm (cp_cco_t *ctx, bool npsm)
+{
+ dbg_assert (ctx);
+ ctx->npsm = npsm;
+}
+
+u8
+cp_cco_get_numslots (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->num_slots;
+}
+
+void
+cp_cco_set_numslots (cp_cco_t *ctx, u8 num_slots)
+{
+ dbg_assert (ctx);
+ ctx->num_slots = num_slots;
+}
+
+u8
+cp_cco_get_slotusage (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->slot_usage;
+}
+
+void
+cp_cco_set_slotusage (cp_cco_t *ctx, u8 slotusage)
+{
+ dbg_assert (ctx);
+ ctx->slot_usage = slotusage;
+}
+
+u8
+cp_cco_get_slot_id (cp_cco_t *cco)
+{
+ dbg_assert (cco);
+ return cco->slotid;
+}
+
+void
+cp_cco_set_slot_id (cp_cco_t *ctx, u8 slot_id)
+{
+ dbg_assert (ctx);
+ ctx->slotid = slot_id;
+}
+
+u8
+cp_cco_get_aclss (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->aclss;
+}
+
+void
+cp_cco_set_aclss (cp_cco_t *ctx, u8 aclss)
+{
+ dbg_assert (ctx);
+ ctx->aclss = aclss;
+}
+
+u8
+cp_cco_get_nm (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->nm;
+}
+
+void
+cp_cco_set_nm (cp_cco_t *ctx, u8 nm)
+{
+ dbg_assert (ctx);
+ ctx->nm = nm;
+}
+
+u8
+cp_cco_get_cco_cap (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->cco_cap;
+}
+
+void
+cp_cco_set_cco_cap (cp_cco_t *ctx, u8 cco_cap)
+{
+ dbg_assert (ctx);
+ ctx->cco_cap = cco_cap;
+}
+
+bool
+cp_cco_get_proxy_cap (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->proxy_cap;
+}
+
+void
+cp_cco_set_proxy_cap (cp_cco_t *ctx, bool proxy_cap)
+{
+ dbg_assert (ctx);
+ ctx->proxy_cap = proxy_cap;
+}
+
+bool
+cp_cco_get_backup_cap (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->backup_cap;
+}
+
+void
+cp_cco_set_backup_cap (cp_cco_t *ctx, bool backup_cap)
+{
+ dbg_assert (ctx);
+ ctx->backup_cap = backup_cap;
+}
+
+bool
+cp_cco_get_cco_status (cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->cco_status;
+}
+
+void
+cp_cco_set_cco_status (cp_cco_t *ctx, bool cco_status)
+{
+ dbg_assert (ctx);
+ ctx->cco_status = cco_status;
+}
+
+bool
+cp_cco_get_pco_status(cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->pco_status;
+}
+
+void
+cp_cco_set_pco_status(cp_cco_t *ctx, bool pco_status)
+{
+ dbg_assert(ctx);
+ ctx->pco_status = pco_status;
+}
+
+bool
+cp_cco_get_backup_cco_status(cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->backup_cco;
+}
+
+void
+cp_cco_set_backup_cco_status(cp_cco_t *ctx, bool backup_cco_status)
+{
+ dbg_assert (ctx);
+ ctx->backup_cco = backup_cco_status;
+}
+
+bool
+cp_cco_get_user_appointed_cco_status(cp_cco_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->user_appointed_cco_status;
+}
+
+void
+cp_cco_set_user_appointed_cco_status(cp_cco_t *ctx, bool ua_cco_status)
+{
+ dbg_assert (ctx);
+ ctx->user_appointed_cco_status = ua_cco_status;
+}
+
diff --git a/cesar/test_general/station/overide/cp/secu/Module b/cesar/test_general/station/overide/cp/secu/Module
new file mode 100644
index 0000000000..9087aae87c
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/secu/Module
@@ -0,0 +1 @@
+SOURCES:=secu.c
diff --git a/cesar/test_general/station/overide/cp/secu/inc/context.h b/cesar/test_general/station/overide/cp/secu/inc/context.h
new file mode 100644
index 0000000000..f7772ad9bc
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/secu/inc/context.h
@@ -0,0 +1,24 @@
+#ifndef cp_beacon_test_central_beacon_overide_cp_secu_inc_context_h
+#define cp_beacon_test_central_beacon_overide_cp_secu_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/secu/inc/context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+struct cp_secu_t
+{
+ bool kbc;
+ u8 eks;
+};
+
+#endif /* cp_beacon_test_central_beacon_overide_cp_secu_inc_context_h */
diff --git a/cesar/test_general/station/overide/cp/secu/secu.h b/cesar/test_general/station/overide/cp/secu/secu.h
new file mode 100644
index 0000000000..c571679059
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/secu/secu.h
@@ -0,0 +1,58 @@
+#ifndef cp_beacon_test_central_beacon_overide_cp_secu_secu_h
+#define cp_beacon_test_central_beacon_overide_cp_secu_secu_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/secu/secu.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "cp/secu/secu.h"
+
+typedef struct cp_secu_t cp_secu_t;
+
+/**
+ * Initialize the security layer
+ *
+ * \return the security context.
+ */
+cp_secu_t *
+cp_secu_init (void);
+
+/**
+ * Uninitialize the seucurity layer
+ *
+ * \param ctx the security context.
+ */
+void
+cp_secu_uninit (cp_secu_t *ctx);
+
+/**
+ * Get Key being change
+ * 0 for a frame level encyption key NEK.
+ * 1 for a payload encryption key.
+ *
+ * \param ctx the security context.
+ * \return the boolean value
+ */
+bool
+cp_secu_get_kbc (cp_secu_t *ctx);
+
+/**
+ * Get the new EKS for the next beacon period.
+ *
+ * \param ctx the security context
+ * \return the eks value.
+ */
+u8
+cp_secu_get_eks (cp_secu_t *ctx);
+
+#endif /* cp_beacon_test_central_beacon_overide_cp_secu_secu_h */
diff --git a/cesar/test_general/station/overide/cp/secu/src/secu.c b/cesar/test_general/station/overide/cp/secu/src/secu.c
new file mode 100644
index 0000000000..b2fa99d671
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/secu/src/secu.c
@@ -0,0 +1,74 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/overide/cp/secu/src/secu.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "cp/secu/secu.h"
+#include "cp/secu/inc/context.h"
+
+// static declaration
+static cp_secu_t secu_global;
+
+/**
+ * Initialize the security layer
+ *
+ * \return the security context.
+ */
+cp_secu_t *
+cp_secu_init (void)
+{
+ return &secu_global;
+}
+
+/**
+ * Uninitialize the seucurity layer
+ *
+ * \param ctx the security context.
+ */
+void
+cp_secu_uninit (cp_secu_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+/**
+ * Get Key being change
+ * 0 for a frame level encyption key NEK.
+ * 1 for a payload encryption key.
+ *
+ * \param ctx the security context.
+ * \return the boolean value
+ */
+bool
+cp_secu_get_kbc (cp_secu_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->kbc;
+}
+
+/**
+ * Get the new EKS for the next beacon period.
+ *
+ * \param ctx the security context
+ * \return the eks value.
+ */
+u8
+cp_secu_get_eks (cp_secu_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->eks;
+}
+
diff --git a/cesar/test_general/station/overide/cp/station/Module b/cesar/test_general/station/overide/cp/station/Module
new file mode 100644
index 0000000000..360ddd8c71
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/station/Module
@@ -0,0 +1 @@
+SOURCES=station.c
diff --git a/cesar/test_general/station/overide/cp/station/inc/context.h b/cesar/test_general/station/overide/cp/station/inc/context.h
new file mode 100644
index 0000000000..98516ef28e
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/station/inc/context.h
@@ -0,0 +1,39 @@
+#ifndef overide_cp_station_inc_context_h
+#define overide_cp_station_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp/station/inc/context.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+#include "mac/pbproc/pbproc.h"
+#include "cl/cl.h"
+
+#include "cp/beacon/inc/bentry.h"
+
+struct cp_sta_t
+{
+ mac_config_t *mac_config;
+ mac_store_t *mac_store;
+ pbproc_t *pbproc;
+ cl_t *cl;
+
+ u64 nid;
+ bool hoip;
+ u8 numDisSta;
+ u8 numDisNet;
+ bool authentication;
+};
+
+#endif /* overide_cp_station_inc_context_h */
diff --git a/cesar/test_general/station/overide/cp/station/src/station.c b/cesar/test_general/station/overide/cp/station/src/station.c
new file mode 100644
index 0000000000..ef8e17ea23
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/station/src/station.c
@@ -0,0 +1,243 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp/station/src/station.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <string.h>
+
+#include "cp/station/station.h"
+
+#include "mac/common/store.h"
+#include "mac/common/config.h"
+#include "mac/pbproc/pbproc.h"
+#include "cl/cl.h"
+
+#include "cp/station/inc/context.h"
+
+static cp_sta_t sta_global;
+
+/**
+ * Station init.
+ *
+ * \param mac_store_ctx mac_store context
+ * \param interf_cl_ctx cl context
+ * \param pbproc_ctx pbproc context.
+ * \param mac_config the mac_config context.
+ * \return sta context.
+ */
+cp_sta_t *
+cp_station_init (mac_store_t *mac_store_ctx, cl_t *interf_cl_ctx,
+ pbproc_t *pbproc_ctx, mac_config_t *mac_config)
+{
+ dbg_assert (pbproc_ctx);
+ dbg_assert (mac_config);
+ dbg_assert (interf_cl_ctx);
+ dbg_assert (mac_store_ctx);
+
+ sta_global.pbproc = pbproc_ctx;
+ sta_global.mac_store = mac_store_ctx;
+ sta_global.mac_config = mac_config;
+ sta_global.cl = interf_cl_ctx;
+
+ return &sta_global;
+}
+
+/**
+ * Station init.
+ *
+ * \param ctx sta context.
+ */
+void
+cp_station_uninit (cp_sta_t *ctx)
+{
+ dbg_assert (ctx);
+}
+
+/**
+ *
+ * Station get NID
+ *
+ * \param ctx the station context.
+ * \return the nid of the AVLN
+ */
+u64
+cp_station_get_nid (cp_sta_t *ctx)
+{
+ dbg_assert (ctx);
+ return ctx->nid;
+}
+
+/**
+ * Station set nid
+ *
+ * \param ctx the station context
+ * \param nid the nid
+ */
+void
+cp_station_set_nid (cp_sta_t *ctx, u64 nid)
+{
+ dbg_assert (ctx);
+ ctx->nid = nid;
+}
+
+/**
+ * Station get mac address return the mac address of the station
+ *
+ * \param sta the station context.
+ * \param mac_address_addr the buffer address to store the mac address.
+ */
+void
+cp_station_get_mac_address (cp_sta_t *sta, u8 *addr)
+{
+ dbg_assert (sta);
+ dbg_assert (addr);
+
+ memcpy (addr, &sta->mac_config->sta_mac_address, 6 * sizeof(u8));
+}
+
+/**
+ * Station get TEI
+ *
+ * \param ctx the station context.
+ */
+u8
+cp_station_get_tei (cp_sta_t *ctx)
+{
+ dbg_assert (ctx);
+
+ return ctx->mac_config->tei;
+}
+
+/**
+ * Get the number of distant STAs
+ *
+ * \param sta the station context
+ * \retun the number of distante stations
+ */
+u8
+cp_station_get_num_dis_sta(cp_sta_t *sta)
+{
+ dbg_assert (sta);
+
+ return sta->numDisSta;
+}
+
+/**
+ * Get number of distant networks.
+ *
+ * \param sta the sta context.
+ * \return the number of distant networks.
+ */
+u8
+cp_station_get_num_dis_net(cp_sta_t *sta)
+{
+ dbg_assert (sta);
+
+ return sta->numDisNet;
+}
+
+/**
+ * Return the authentication status of the station
+ *
+ * \param sta the station context.
+ * \return the status.
+ */
+bool
+cp_station_is_authenticated(cp_sta_t *sta)
+{
+ dbg_assert (sta);
+
+ return sta->authentication;
+}
+
+/**
+ * Set the authenticated flag to one
+ *
+ * \param sta the station context
+ * \param auth boolean informing if the sta is authenticated or not
+ */
+void
+cp_station_set_authenticated (cp_sta_t *sta, bool auth)
+{
+ dbg_assert (sta);
+
+ sta->authentication = true;
+}
+
+/**
+ * Get the Handover in progress status.
+ *
+ * \param sta the station context
+ * \return the handover progress status.
+ */
+bool
+cp_station_get_hoip (cp_sta_t *sta)
+{
+ dbg_assert (sta);
+ return sta->hoip;
+}
+
+/**
+ * Set the Handover in progress status.
+ *
+ * \param sta context.
+ * \param hoip handover in progress.
+ */
+void
+cp_station_set_hoip(cp_sta_t *sta, uint hoip)
+{
+ dbg_assert (sta);
+
+ sta->hoip = hoip;
+}
+
+/**
+ * Station set mac address return the mac address of the station
+ *
+ * \param sta the station context.
+ * \param mac the mac address.
+ */
+void
+cp_station_set_mac_address (cp_sta_t *sta, mac_t mac)
+{
+ dbg_assert (sta);
+ sta->mac_config->sta_mac_address = mac;
+}
+
+/**
+ * get the rstbf flag
+ *
+ * \param sta the sta context.
+ */
+bool
+cp_station_get_rtsbf(cp_sta_t *sta)
+{
+ dbg_assert (sta);
+
+ return sta->mac_config->rts_broadcast;
+}
+
+/**
+ * Set the sta rtsbf
+ *
+ * \param sta the station context
+ * \param rstbf the flag
+ */
+void
+cp_station_set_rtsbf (cp_sta_t *sta, bool rtsbf)
+{
+ dbg_assert (sta);
+ sta->mac_config->rts_broadcast = true;
+}
+
diff --git a/cesar/test_general/station/overide/cp/station/station.h b/cesar/test_general/station/overide/cp/station/station.h
new file mode 100644
index 0000000000..b5700b165b
--- /dev/null
+++ b/cesar/test_general/station/overide/cp/station/station.h
@@ -0,0 +1,183 @@
+#ifndef overide_cp_station_station_h
+#define overide_cp_station_station_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp/station/station.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "hal/phy/phy.h"
+#include "cp/station/station.h"
+
+#include "mac/common/store.h"
+#include "mac/common/config.h"
+#include "mac/pbproc/pbproc.h"
+#include "cl/cl.h"
+
+
+/** forward declaration. */
+typedef struct cp_sta_t cp_sta_t;
+
+/**
+ * Station init.
+ *
+ * \param mac_store_ctx mac_store context
+ * \param interf_cl_ctx cl context
+ * \param pbproc_ctx pbproc context.
+ * \param mac_config the mac_config context.
+ * \return sta context.
+ */
+cp_sta_t *
+cp_station_init (mac_store_t *mac_store_ctx, cl_t *interf_cl_ctx, pbproc_t *pbproc_ctx, mac_config_t *mac_config);
+
+/**
+ * Station init.
+ *
+ * \param ctx sta context.
+ */
+void
+cp_station_uninit (cp_sta_t *ctx);
+
+/**
+ * Station get NID
+ *
+ * \param ctx the station context.
+ * \return the nid of the AVLN
+ */
+u64
+cp_station_get_nid (cp_sta_t *ctx);
+
+/**
+ * Station set nid
+ *
+ * \param ctx the station context
+ * \param nid the nid
+ */
+void
+cp_station_set_nid (cp_sta_t *ctx, u64 nid);
+
+/**
+ * Station get TEI
+ *
+ * \param ctx the station context.
+ */
+u8
+cp_station_get_tei (cp_sta_t *ctx);
+
+/**
+ * Station get mac address return the mac address of the station
+ *
+ * \param sta the station context.
+ * \param mac_address_addr the buffer address to store the mac address.
+ */
+void
+cp_station_get_mac_address (cp_sta_t *sta, u8 *addr);
+
+/**
+ * Get the number of distant STAs
+ *
+ * \param sta the station context
+ * \retun the number of distante stations
+ */
+u8
+cp_station_get_num_dis_sta(cp_sta_t *sta);
+
+/**
+ * Get number of distant networks.
+ *
+ * \param sta the sta context.
+ * \return the number of distant networks.
+ */
+u8
+cp_station_get_num_dis_net(cp_sta_t *sta);
+
+/**
+ * Return the authentication status of the station
+ *
+ * \param sta the station context.
+ * \return the status.
+ */
+bool
+cp_station_is_authenticated(cp_sta_t *sta);
+
+/**
+ * Set the authenticated flag to one
+ *
+ * \param sta the station context
+ * \param auth boolean informing if the sta is authenticated or not
+ */
+void
+cp_station_set_authenticated (cp_sta_t *sta, bool auth);
+
+/**
+ * Set the authenticated flag to one
+ *
+ * \param sta the station context
+ * \param auth boolean informing if the sta is authenticated or not
+ */
+void
+cp_station_set_authenticated (cp_sta_t *sta, bool auth);
+
+/**
+ * get the rstbf flag
+ *
+ * \param sta the sta context.
+ */
+bool
+cp_station_get_rtsbf(cp_sta_t *sta);
+
+/**
+ * Set the sta rtsbf
+ *
+ * \param sta the station context
+ * \param rstbf the flag
+ */
+void
+cp_station_set_rtsbf (cp_sta_t *sta, bool rtsbf);
+
+/**
+ * Set the CCo tei.
+ *
+ * \param sta the sta context.
+ * \param stei the cco tei.
+ */
+void
+cp_station_set_cco_tei(cp_sta_t *sta, uint stei);
+
+/**
+ * Get the Handover in progress status.
+ *
+ * \param sta the station context
+ * \return the handover progress status.
+ */
+bool
+cp_station_get_hoip (cp_sta_t *sta);
+
+/**
+ * Set the Handover in progress status.
+ *
+ * \param sta context.
+ * \param hoip handover in progress.
+ */
+void
+cp_station_set_hoip(cp_sta_t *sta, uint hoip);
+
+/**
+ * Station set mac address return the mac address of the station
+ *
+ * \param sta the station context.
+ * \param mac the mac address.
+ */
+void
+cp_station_set_mac_address (cp_sta_t *sta, mac_t addr);
+
+#endif /* overide_cp_station_station_h */
diff --git a/cesar/test_general/station/src/int_station.c b/cesar/test_general/station/src/int_station.c
new file mode 100644
index 0000000000..dc937cbbee
--- /dev/null
+++ b/cesar/test_general/station/src/int_station.c
@@ -0,0 +1,736 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file int_station.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "host/station.h"
+
+#include "lib/blk.h"
+#include "lib/read_word.h"
+#include "lib/trace.h"
+#include "cl/cl_mactotei.h"
+
+#include "test_general/station/int_station.h"
+#include "test_general/station/int_station_fc.h"
+
+#include "test_general/station/inc/int_context.h"
+
+#include "mac/sar/inc/trace.h"
+#include "cl/inc/trace.h"
+#include "hle/inc/trace.h"
+#include "cp/beacon/inc/trace.h"
+#include "cp/station/station.h"
+
+#include "mac/common/ntb.h"
+#include "mac/pbproc/inc/context.h"
+
+#include "hal/timer/timer.h"
+
+int_station_t int_sta_global;
+
+/**
+ * Cp beacon call back when the leon timer expires.
+ * It shall call the add event function of the Visual state FSM.
+ *
+ * \param user_data the user_data provided on the cp_beacon_init function.
+ */
+void
+cp_beacon_timer_expires (void *user_data) __attribute__((weak));
+
+
+/**
+ * Init the station and returns the result of the memory test
+ *
+ * \return ctx the int_station context.
+ */
+int_station_t *int_station_init (void)
+{
+ my_station.pipe_log_fd = 1;
+
+ trace_init ();
+
+ int_sta_global.mac_store = mac_store_init ();
+ int_sta_global.pbproc_activate = false;
+
+ int_sta_global.mac_config = blk_alloc ();
+ int_sta_global.mac_config->rts_broadcast = false;
+ int_sta_global.mac_config->fc_symbols_nb = 1;
+ int_sta_global.mac_config->ntb_offset_tck = 0;
+ tonemask_default ((u8*) &int_sta_global.mac_config->tonemask_info);
+ tonemask_update (&int_sta_global.mac_config->tonemask_info);
+
+ int_sta_global.pbproc = pbproc_init (int_sta_global.mac_config,
+ int_sta_global.mac_store);
+
+ // Initialise the hal_timer
+ int_sta_global.timer =
+ hal_timer_init(pbproc_get_phy(int_sta_global.pbproc));
+
+ mac_ntb_init (pbproc_get_phy(int_sta_global.pbproc),
+ int_sta_global.mac_config);
+
+ int_sta_global.sar = sar_init (int_sta_global.mac_store,
+ int_sta_global.pbproc, pbproc_get_ca (int_sta_global.pbproc));
+
+ int_sta_global.cl
+ = cl_init (int_sta_global.mac_store, int_sta_global.sar,
+ int_sta_global.mac_config);
+
+ int_sta_global.hle = hle_init (int_sta_global.cl);
+
+ int_sta_global.interface = interface_init (int_sta_global.hle,
+ int_sta_global.cl,
+ int_sta_global.sar,
+ int_sta_global.mac_config);
+
+ int_sta_global.cp.sta = cp_station_init (int_sta_global.mac_store,
+ int_sta_global.cl,
+ int_sta_global.pbproc,
+ int_sta_global.mac_config);
+
+ int_sta_global.cp.secu = cp_secu_init ();
+ int_sta_global.cp.cco = cp_cco_init ();
+
+ int_sta_global.cp.beacon = cp_beacon_init(int_sta_global.interface,
+ pbproc_get_phy(int_sta_global.pbproc),
+ int_sta_global.cp.sta, int_sta_global.cp.secu,
+ pbproc_get_ca (int_sta_global.pbproc),
+ int_sta_global.pbproc, int_sta_global.mac_store,
+ int_sta_global.cp.cco,
+ int_sta_global.timer, NULL,
+ cp_beacon_timer_expires);
+
+ list_init (&int_sta_global.tei_list);
+
+ int_sta_global.mac_config->sta_mac_address = 0x123456789abcull;
+ int_sta_global.mac_config->authenticated = true;
+
+ /* Activate the hle. */
+ hle_activate (int_sta_global.hle, true);
+
+ return &int_sta_global;
+}
+
+/**
+ * Uninit the station and returns the result of the memory test
+ *
+ * \param ctx the station context.
+ */
+void int_station_uninit (int_station_t *ctx)
+{
+ tei_node_t *tei_node;
+ uint now;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_config);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->pbproc);
+ dbg_assert (ctx->sar);
+ dbg_assert (ctx->cl);
+ dbg_assert (ctx->hle);
+
+ dbg_assert (ctx->cp.secu);
+ dbg_assert (ctx->cp.cco);
+ dbg_assert (ctx->cp.sta);
+ dbg_assert (ctx->cp.beacon);
+
+ dbg_assert (ctx->timer);
+
+ pbproc_activate (ctx->pbproc, false);
+
+ now = mac_ntb();
+ pbproc_uninit (ctx->pbproc);
+ sar_uninit (ctx->sar);
+ cl_uninit (ctx->cl);
+ hle_uninit (ctx->hle);
+
+ cp_secu_uninit (ctx->cp.secu);
+ cp_station_uninit (ctx->cp.sta);
+ cp_cco_uninit (ctx->cp.cco);
+ cp_beacon_uninit(ctx->cp.beacon);
+
+ blk_release (ctx->mac_config);
+
+ while (!list_empty (&ctx->tei_list))
+ {
+ tei_node = PARENT_OF (tei_node_t, node, list_pop (&ctx->tei_list));
+ mac_store_sta_remove (ctx->mac_store, tei_node->tei);
+
+ blk_release (tei_node);
+ }
+
+ mac_store_uninit (ctx->mac_store);
+ hal_timer_uninit (ctx->timer);
+ trace_uninit();
+
+ blk_print_memory ();
+}
+
+/**
+ * Provides the Tei of the STA and the SNID
+ *
+ * \param ctx the station context
+ * \param tei the tei of the station
+ * \param snid the snid of the AVLN
+ * \param beacon_period_auto generation automatic of the beacon period for
+ * the CA scheduling
+ * \param cco boolean informing if the sta is cco or not
+ * \param authenticated boolean informing if the sta is authenticated or
+ * not.
+ */
+void int_station_config (int_station_t *ctx, uint tei, uint snid,
+ bool beacon_period_auto, bool cco, bool authenticated, mac_t mac_addr)
+{
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_config);
+ dbg_assert (ctx->cp.cco);
+ dbg_assert (ctx->cp.sta);
+
+ ctx->mac_config->snid = snid;
+ ctx->mac_config->tei = tei;
+
+ if (mac_addr == 0)
+ {
+ ctx->mac_config->sta_mac_address = 0x123456789abcull;
+ }
+ else
+ ctx->mac_config->sta_mac_address = mac_addr;
+
+ if (beacon_period_auto)
+ {
+ // Create the Thread for the pbproc.
+ cyg_thread_create (9, &pbproc_sched, (cyg_addrword_t) ctx, "Sched",
+ sched_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &ctx->sched_handle, &ctx->sched_thread);
+ cyg_thread_resume (ctx->sched_handle);
+
+ printf ("[STATION] PBproc Activated\n");
+ }
+
+ if (cco)
+ {
+ cp_cco_set_cco_status (ctx->cp.cco, cco);
+ cp_station_set_authenticated (ctx->cp.sta, authenticated);
+ }
+
+ if (authenticated)
+ {
+ cp_station_set_authenticated (ctx->cp.sta, authenticated);
+ }
+}
+
+/**
+ * Provides the TEI of all the station in the AVLN.
+ *
+ * \param ctx the station context.
+ * \param tei the tei list of the stations
+ * \param macs the list of mac address of the STAs.
+ * \param qte the quantity of TEIs in the list.
+ */
+void int_station_discover (int_station_t *ctx, uint *tei, mac_t *macs,
+ uint qte)
+{
+ tei_node_t *node;
+ uint i;
+
+ for (i = 0; i < qte; i++)
+ {
+ if (tei[i] != 0)
+ {
+ node = blk_alloc ();
+ list_init_node (&node->node);
+ node->tei = tei[i];
+ list_push (&ctx->tei_list, &node->node);
+
+ mac_store_sta_add (ctx->mac_store, tei[i]);
+ }
+ }
+
+ if (macs != NULL)
+ {
+ dbg_assert (ctx->cl);
+
+ cl_mactotei_blk_t *table;
+ table = cl_mactotei_new ();
+
+ for (i = 0; i < qte; i++)
+ {
+ cl_mactotei_addr_add (table, macs[i], tei[i], tei[i]);
+ }
+
+ cl_mactotei_use_table (ctx->cl, table);
+ }
+}
+
+/**
+ * Add a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void int_station_link_add (int_station_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei)
+{
+ bool added;
+ mfs_t *mfs;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->sar);
+
+ mfs = mac_store_mfs_add (ctx->mac_store, type, bcast, mme, lid, tei,
+ &added);
+ dbg_assert (added);
+
+ // add the link to the sar.
+ sar_mfs_add (ctx->sar, mfs);
+
+ blk_release (mfs);
+}
+
+/**
+ * Remove a link to the STAtion i.e. will create a MFS
+ *
+ * \param ctx the station context.
+ * \param type TX or RX link, it is a short 1 for TX 0 for RX.
+ * \param bcast short indicating if the link is a broadcast link
+ * \param mme short indicating if the link will be use to transmit MMEs
+ * \param lid short indicating if it is a link identitier.
+ * \param tei short the destination station.
+ */
+void int_station_link_remove (int_station_t *ctx, uint type, uint bcast,
+ uint mme, uint lid, uint tei)
+{
+ mfs_t *mfs;
+ pb_t *pb;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->mac_store);
+ dbg_assert (ctx->sar);
+
+ mfs = mac_store_mfs_get (ctx->mac_store, type, bcast, mme, lid, tei);
+
+ if (mfs != NULL)
+ {
+ while (type && mfs->tx.head)
+ {
+ pb = mfs->tx.head;
+ mfs->tx.head = mfs->tx.head->next;
+ blk_release_desc ((blk_t *) pb);
+ }
+
+ while (!type && mfs->rx.head)
+ {
+ pb = mfs->rx.head;
+ mfs->rx.head = mfs->rx.head->next;
+ blk_release_desc ((blk_t *) pb);
+ }
+
+ // remove the MFS from the sar
+ sar_mfs_remove (ctx->sar, mfs);
+
+ blk_release (mfs);
+ }
+}
+
+/**
+ * Thread entry finction
+ *
+ * \param int_sta the sta context.
+ */
+void pbproc_sched (cyg_addrword_t int_sta)
+{
+ while (true)
+ {
+ create_schedule_csma_only ((int_station_t *) int_sta, 14);
+ ((int_station_t *) int_sta)->sched_index ++;
+
+ //create the second schedule.
+ create_schedule_csma_only ((int_station_t *) int_sta, 14);
+ ((int_station_t *) int_sta)->sched_index ++;
+
+ //create the third schedule.
+ create_schedule_csma_only ((int_station_t *) int_sta, 14);
+ ((int_station_t *) int_sta)->sched_index ++;
+
+ cyg_thread_delay (500);
+ }
+}
+
+/**
+ * Create a schedule for the Channel Access (beacon period) in CSMA only mode.
+ * Shall always be used to send or receive data.
+ *
+ * \param int_sta the pbproc context
+ * \param beacon_period_nb the quantity of beacon periods for the test.
+ */
+void create_schedule_csma_only (int_station_t *int_sta, uint beacon_period_nb)
+{
+ pbproc_t *pbproc;
+
+ dbg_assert (int_sta);
+
+ pbproc = int_sta->pbproc;
+ ca_beacon_period_t beacons_periods[beacon_period_nb];
+ uint i;
+
+ dbg_assert (pbproc);
+ dbg_assert (beacon_period_nb < CA_BEACON_PERIOD_NB);
+
+ /* Get and fill the schedule */
+ ca_schedule_t *sched = ca_alloc_get_schedule (pbproc_get_ca (pbproc),
+ int_sta->sched_index);
+
+ sched->coexistence_mode = MAC_COEXISTENCE_SHARED_CSMA_HYBRID_MODE;
+ sched->nek_switch = 0; //TODO
+ sched->allocations_nb = 1;
+ sched->allocations[0].end_offset_tck = 10000000;
+ sched->allocations[0].glid = 0xff;
+
+ /* Create a schedule for 14 beacon period */
+ for (i = 0; i < beacon_period_nb; i++)
+ {
+ beacons_periods[i].start_date = 1000000 * i
+ + my_station.current_tick_tck;
+ beacons_periods[i].schedule_index = int_sta->sched_index;
+ }
+
+ /* Use the new schedule */
+ ca_alloc_update_beacon_periods (pbproc_get_ca (pbproc), beacons_periods,
+ beacon_period_nb);
+
+ /* Activate the pbproc */
+ if (!int_sta->pbproc_activate)
+ {
+ pbproc_activate (pbproc, true);
+ int_sta->pbproc_activate = true;
+ }
+
+ int_sta->sched_index++;
+}
+
+/**
+ * Cp beacon call back when the leon timer expires.
+ * It shall call the add event function of the Visual state FSM.
+ *
+ * \param user_data the user_data provided on the cp_beacon_init function.
+ */
+void
+cp_beacon_timer_expires (void *user_data)
+{
+}
+
+
+//----------------------------------------------------------------------------
+
+/**
+ * Initialize the configuration of the STA.
+ * The parameters we must provide are the TEI of the STA, the SNID and the
+ * boolean to indicate the auto generation of the beacon periods.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_init_config (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint tei;
+ uint snid;
+ uint beacon_period_auto;
+ uint cco;
+ uint auth;
+ mac_t mac;
+
+ tei = 0;
+ snid = 0;
+ beacon_period_auto = 0;
+ auth = 0;
+ cco = 0;
+
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+ fcall_param_bind_short (*param, *msg, "snid", &snid);
+ fcall_param_bind_short (*param, *msg, "auto_sched", &beacon_period_auto);
+ fcall_param_bind_short (*param, *msg, "cco", &cco);
+ fcall_param_bind_short (*param, *msg, "authenticated", &auth);
+
+ int_station_config (&int_sta_global, tei, snid, beacon_period_auto, cco,
+ auth, mac);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Provide to the STA using the parameters of the function call the station
+ * use for the test. Each STA shall known the TEI of the others present in the
+ * AVLN.
+ *
+ * The function call parameters must be
+ * - qte the quantity of TEIs present in the paramters. One for each STA
+ * without this one.
+ * - tei The list of TEIs.
+ * - mac the list of mac address.
+ *
+ * This will be use to add the STA's to the mac store, the STA will keep a
+ * list of theses TEI to remove the STA during the uninit procedure.
+ *
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_discover (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint tei[256];
+ mac_t macs[256];
+ uint qte;
+ char val [2];
+ char id[5];
+ uint count;
+ uint error;
+
+ qte = 0;
+ fcall_param_bind_short (*param, *msg, "qte", &qte);
+
+ count = 0;
+ error = 0;
+ for (count = 0; count < qte; count ++)
+ {
+ tei[count] = 0;
+ macs[count] = 0;
+ sprintf (val, "%d", count);
+ strcpy (id, "tei");
+ strcat (id, val);
+ fcall_param_bind_short (*param, *msg, id, &tei[count]);
+ strcpy (id, "mac");
+ strcat (id, val);
+ fcall_param_bind (*param, *msg, id, sizeof(mac_t), &macs[count]);
+ }
+
+ int_station_discover (&int_sta_global, tei, macs, qte);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Add a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_add (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint type;
+ uint bcast;
+ uint mme;
+ uint lid;
+ uint tei;
+
+ type = 0;
+ bcast = 0;
+ mme = 0;
+ lid = 0;
+ tei = 0;
+
+ fcall_param_bind_short (*param, *msg, "type", &type);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+ fcall_param_bind_short (*param, *msg, "mme", &mme);
+ fcall_param_bind_short (*param, *msg, "lid", &lid);
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+
+ if (type)
+ printf (
+ "[STATION : %d] TX link added, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ int_sta_global.mac_config->tei, bcast, mme, lid, tei);
+ else
+ printf (
+ "[STATION : %d] RX link added, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ int_sta_global.mac_config->tei, bcast, mme, lid, tei);
+
+ int_station_link_add (&int_sta_global, type, bcast, mme, lid, tei);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * Remove a link to the Station in order to receive or transmit data.
+ *
+ * - type TX or RX link, it is a short 1 for TX 0 for RX.
+ * - bcast short indicating if the link is a broadcast link
+ * - mme short indicating if the link will be use to transmit MMEs
+ * - lid short indicating if it is a link identitier.
+ * - tei short the destination station.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_station_link_remove (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ uint type;
+ uint bcast;
+ uint mme;
+ uint lid;
+ uint tei;
+
+ type = 0;
+ bcast = 0;
+ mme = 0;
+ lid = 0;
+ tei = 0;
+
+ fcall_param_bind_short (*param, *msg, "type", &type);
+ fcall_param_bind_short (*param, *msg, "bcast", &bcast);
+ fcall_param_bind_short (*param, *msg, "mme", &mme);
+ fcall_param_bind_short (*param, *msg, "lid", &lid);
+ fcall_param_bind_short (*param, *msg, "tei", &tei);
+
+ if (type)
+ printf (
+ "[STATION : %d] TX link removed, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ int_sta_global.mac_config->tei, bcast, mme, lid, tei);
+ else
+ printf (
+ "[STATION : %d] RX link removed, bcast : %d, mme : %d, lid : %d, tei : %d\n",
+ int_sta_global.mac_config->tei, bcast, mme, lid, tei);
+
+ int_station_link_remove (&int_sta_global, type, bcast, mme, lid, tei);
+
+ fcall_param_reset (*param);
+
+ return true;
+}
+
+/**
+ * print the sar traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_sar_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+ sar_trace_print (int_sta_global.sar);
+
+ return true;
+}
+
+/**
+ * print the cl traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_cl_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+ cl_trace_print (int_sta_global.cl);
+
+ return true;
+}
+
+/**
+ * print the hle traces for the tests.
+ * if the trace_config == y the traces are printed to the stdio.
+ * otherwise nothing is printed.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_hle_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+ hle_trace_print (int_sta_global.hle);
+
+ return true;
+}
+
+/**
+ * Send a central beacon over the PWL.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_pbproc_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+#if CONFIG_TRACE
+ trace_buffer_dbg_dump (&int_sta_global.pbproc->trace);
+#endif
+
+ return true;
+}
+
+
+/**
+ * Request the cp_beacon to print its trace buffer.
+ *
+ * \param fcall the fcall context.
+ * \param param the fcall param
+ * \param msg the message
+ * \param data anything
+ */
+int fc_cp_beacon_print_trace (fcall_ctx_t *fcall, fcall_param_t **param,
+ sci_msg_t **msg, void *data)
+{
+ fcall_param_reset (*param);
+
+ cp_beacon_trace_print (int_sta_global.cp.beacon);
+
+ return true;
+}
+