summaryrefslogtreecommitdiff
path: root/cesar/cp/beacon/test/cco
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/beacon/test/cco')
-rw-r--r--cesar/cp/beacon/test/cco/Makefile25
-rw-r--r--cesar/cp/beacon/test/cco/ecos.ecc.sh5
-rw-r--r--cesar/cp/beacon/test/cco/inc/phy_stub.h28
-rw-r--r--cesar/cp/beacon/test/cco/src/ca_stub.c57
-rw-r--r--cesar/cp/beacon/test/cco/src/cco.c231
-rw-r--r--cesar/cp/beacon/test/cco/src/cl_stub.c63
-rw-r--r--cesar/cp/beacon/test/cco/src/hle_stub.c44
-rw-r--r--cesar/cp/beacon/test/cco/src/ipmbox_stub.c22
-rw-r--r--cesar/cp/beacon/test/cco/src/phy_stub.c38
-rw-r--r--cesar/cp/beacon/test/cco/src/sar_stub.c37
-rw-r--r--cesar/cp/beacon/test/cco/src/ucco.c229
11 files changed, 779 insertions, 0 deletions
diff --git a/cesar/cp/beacon/test/cco/Makefile b/cesar/cp/beacon/test/cco/Makefile
new file mode 100644
index 0000000000..f740421477
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/Makefile
@@ -0,0 +1,25 @@
+BASE = ../../../..
+
+ECOS=y
+
+INCLUDES = cp/beacon/test/overide
+
+TARGET_PROGRAMS = ucco cco
+
+ucco_SOURCES = ucco.c phy_stub.c ca_stub.c cl_stub.c sar_stub.c ipmbox_stub.c \
+ hle_stub.c
+ucco_MODULES = lib mac/common cp/beacon hal/timer hal/leon/unit-test \
+ interface interface/sniffer \
+ cp/beacon/test/overide/cp/station \
+ cp/beacon/test/overide/cp/cco
+
+cco_SOURCES = cco.c phy_stub.c ca_stub.c cl_stub.c sar_stub.c ipmbox_stub.c \
+ hle_stub.c
+cco_MODULES = lib mac/common cp/beacon hal/timer hal/leon/unit-test \
+ interface interface/sniffer \
+ cp/beacon/test/overide/cp/station \
+ cp/beacon/test/overide/cp/cco
+
+cp_beacon_MODULE_SOURCES = beacons.c bentry.c
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/cp/beacon/test/cco/ecos.ecc.sh b/cesar/cp/beacon/test/cco/ecos.ecc.sh
new file mode 100644
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/cp/beacon/test/cco/inc/phy_stub.h b/cesar/cp/beacon/test/cco/inc/phy_stub.h
new file mode 100644
index 0000000000..bb39c132d3
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/inc/phy_stub.h
@@ -0,0 +1,28 @@
+#ifndef cp_beacon_test_central_beacon_phy_stub_h
+#define cp_beacon_test_central_beacon_phy_stub_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/phy_stub.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+
+struct phy_test_t
+{
+ uint freq_test;
+ uint ntb;
+ uint date_ntb;
+};
+typedef struct phy_test_t phy_test_t;
+
+
+#endif /* cp_beacon_test_central_beacon_phy_stub_h */
diff --git a/cesar/cp/beacon/test/cco/src/ca_stub.c b/cesar/cp/beacon/test/cco/src/ca_stub.c
new file mode 100644
index 0000000000..9ec7775696
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/ca_stub.c
@@ -0,0 +1,57 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/src/ca_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "mac/ca/ca.h"
+
+static ca_schedule_t sched;
+
+ca_schedule_t *
+ca_alloc_get_schedule (ca_t *ctx, uint index)
+{
+ return &sched;
+}
+
+void
+ca_alloc_update_beacon_periods (ca_t *ctx,
+ ca_beacon_period_t *beacon_periods,
+ uint beacon_periods_nb)
+{
+}
+
+
+bool
+ca_mfs_remove (ca_t *ctx, mfs_tx_t *mfs)
+{
+ return true;
+}
+
+void
+ca_mfs_add (ca_t *ctx, mfs_tx_t *mfs)
+{
+ dbg_assert (ctx);
+ dbg_assert (mfs);
+}
+
+
+void
+ca_mfs_update (ca_t *ctx, mfs_tx_t *mfs)
+{
+}
+
+void
+ca_mfs_hold (ca_t *ctx, mfs_tx_t *mfs)
+{
+}
diff --git a/cesar/cp/beacon/test/cco/src/cco.c b/cesar/cp/beacon/test/cco/src/cco.c
new file mode 100644
index 0000000000..5c7c47afa3
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/cco.c
@@ -0,0 +1,231 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/ucco/src/cco.c
+ * \brief Test the schedule procedure with the leon timer.
+ * \ingroup cp/beacon
+ *
+ */
+#include "common/std.h"
+
+#include "hal/timer/timer.h"
+
+#include "cp/station/station.h"
+#include "cp/cco/cco.h"
+#include "cp/secu/secu.h"
+#include "cp/beacon/beacons.h"
+
+#include "hal/phy/phy.h"
+
+#include "cl/cl.h"
+
+#include "mac/common/ntb.h"
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+
+#include "lib/test.h"
+#include "lib/read_word.h"
+#include "lib/bitstream.h"
+
+#include <stdio.h>
+
+#include "cp/beacon/inc/beacons_ctx.h"
+
+
+cp_beacon_t *cp_beacon;
+test_t test;
+uint count_beacon;
+
+void
+cp_beacon_expired (void *user_data)
+{
+
+}
+
+void
+test_emetting_discover_beacons(void)
+{
+ uint i;
+ count_beacon = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ // Create the default schedules for the CA.
+ cp_beacon_cco_send_central_beacon (cp_beacon);
+ }
+}
+
+int
+cyg_user_start (void)
+{
+ phy_t *phy;
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_config_t *mac_config;
+ mac_store_t *mac_store;
+ hal_timer_t *timer;
+ cp_sta_t *sta;
+ cp_secu_t *secu;
+ cp_cco_t *cco;
+ cl_t *cl;
+ interface_t *interface;
+ hle_t *hle;
+
+ test_init (test, 0, NULL);
+
+ cl = blk_alloc ();
+ phy = blk_alloc ();
+ ca = blk_alloc ();
+ mac_config = blk_alloc ();
+ pbproc = blk_alloc ();
+ secu = blk_alloc ();
+ cco = blk_alloc ();
+ hle = blk_alloc ();
+
+ mac_ntb_init (phy, mac_config);
+ timer = hal_timer_init (phy);
+ mac_store = mac_store_init ();
+
+ // Configure the STA to be CCo.
+ cp_cco_set_cco_status (cco, true);
+ // Add the mac_config to the sta.
+ sta = cp_station_init (mac_store, cl, pbproc, mac_config);
+ mac_config->sta_mac_address = 0x123456789abcull;
+
+ interface = interface_init (hle , cl, (sar_t *) cl, mac_config);
+
+ cp_beacon = cp_beacon_init(interface, phy, sta, secu, ca, pbproc, mac_store, cco, timer, NULL,
+ cp_beacon_expired);
+ cp_beacon_acl_frequency_detection (cp_beacon);
+ cp_beacon_acl_frequency_detection (cp_beacon);
+
+ test_emetting_discover_beacons ();
+
+ cp_beacon_uninit (cp_beacon);
+ hal_timer_uninit(timer);
+ mac_ntb_uninit ();
+ cp_station_uninit (sta);
+ mac_store_uninit (mac_store);
+
+ blk_release (cco);
+ blk_release (secu);
+ blk_release (pbproc);
+ blk_release (mac_config);
+ blk_release (ca);
+ blk_release (phy);
+ blk_release (cl);
+ blk_release (hle);
+
+
+ blk_print_memory ();
+
+ test_case_begin (test, "Memory");
+ test_begin (test, "Memory")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+/**
+ * Prepare a beacon for transmission.
+ * \param ctx pbproc context
+ * \param mfs corresponding special MFS
+ * \param pb beacon payload
+ * \param params extra parameters for beacon transmission
+ *
+ * There can only be one beacon prepared in advance (for a given MFS).
+ *
+ * This will cancel the preceding prepared beacon if it was not sent.
+ *
+ * PB reference is transfered to PB Processing. Extra parameters are copied.
+ */
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params)
+{
+ cp_beacon_work_beacon_t beacon_work;
+ cp_beacon_desc_t *beacon;
+ bitstream_t bitstream;
+ cp_bentry_sai_t sai;
+
+ uint res;
+
+ dbg_assert (pb);
+
+ beacon = (cp_beacon_desc_t *) pb;
+
+ bitstream_init (&bitstream, beacon->payload->beacon_mpdu_payload, 32,
+ BITSTREAM_READ);
+ bitstream_access (&bitstream, &beacon_work.nid_lsb, 22);
+ bitstream_access (&bitstream, &beacon_work.hm, 2);
+ bitstream_access (&bitstream, &beacon_work.stei, 8);
+ bitstream_finalise (&bitstream);
+
+ bitstream_init (&bitstream, beacon->payload->beacon_mpdu_payload + 4, 32,
+ BITSTREAM_READ);
+ bitstream_access (&bitstream, &beacon_work.bt, 3);
+ beacon_work.bt = CP_BEACON_WORK_MASK_BT (beacon_work.bt);
+
+ bitstream_access (&bitstream, &beacon_work.ncnr, 1);
+ bitstream_access (&bitstream, &beacon_work.npsm, 1);
+ bitstream_access (&bitstream, &beacon_work.num_slots, 3);
+ beacon_work.num_slots =
+ CP_BEACON_WORK_MASK_NUM_SLOTS(beacon_work.num_slots);
+
+ bitstream_access (&bitstream, &beacon_work.slot_usage, 8);
+ bitstream_access (&bitstream, &beacon_work.slot_id, 3);
+ beacon_work.slot_id = CP_BEACON_WORK_MASK_SLOT_ID(beacon_work.slot_id);
+
+ bitstream_access (&bitstream, &beacon_work.aclss, 3);
+ beacon_work.aclss = CP_BEACON_WORK_MASK_ACLSS(beacon_work.aclss);
+
+ bitstream_access (&bitstream, &beacon_work.hoip, 1);
+ bitstream_access (&bitstream, &beacon_work.rtsbf, 1);
+ bitstream_access (&bitstream, &beacon_work.nm, 2);
+ beacon_work.nm = CP_BEACON_WORK_MASK_NM(beacon_work.nm);
+
+ bitstream_access (&bitstream, &beacon_work.cco_cap, 2);
+ beacon_work.cco_cap = CP_BEACON_WORK_MASK_CCO_CAP(beacon_work.cco_cap);
+ bitstream_finalise (&bitstream);
+
+ res = read_u32_from_word (&beacon->payload->bmis[22]);
+ sai.stpf = res & true;
+ res = res >> 1;
+ sai.glid = res & 0x7f;
+ res = res >> 7;
+ sai.st = res & 0xFFF;
+ res = res >> 12;
+ sai.et = res & 0xFFF;
+
+ test_case_begin (test, "Verify the beacon");
+
+ test_begin (test, "Verifying the beacon")
+ {
+ test_fail_if (beacon_work.bt != CP_BEACON_CENTRAL_BEACON,
+ "Wrong beacon type");
+ test_fail_if (sai.stpf != true, "Wrong SAI type");
+ test_fail_if (sai.glid != 0x7F, "Wrong GLID");
+ test_fail_if (sai.st != 0, "Wrong start time");
+ test_fail_if (sai.et != 3906, "Wrong end time");
+ }
+ test_end;
+
+ blk_release_desc ((blk_t *) pb);
+}
+
+void
+pbproc_activate (pbproc_t *ctx, bool flag)
+{
+ dbg_assert (ctx);
+}
+
diff --git a/cesar/cp/beacon/test/cco/src/cl_stub.c b/cesar/cp/beacon/test/cco/src/cl_stub.c
new file mode 100644
index 0000000000..8a6ec73d79
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/cl_stub.c
@@ -0,0 +1,63 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cl_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "common/defs/ethernet.h"
+#include "lib/read_word.h"
+
+#include "cl/cl.h"
+#include "mac/sar/sar.h"
+#include "mac/pbproc/pbproc.h"
+
+#include "cl/inc/context.h"
+#include "cl/inc/cl.h"
+#include "cl/inc/trace.h"
+#include "cl/inc/cl_mactotei.h"
+
+#include "mac/common/ntb.h"
+
+static cl_t cl_global;
+
+cl_t *
+cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config)
+{
+ return &cl_global;
+}
+
+void
+cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t* mme_recv)
+{
+}
+
+
+void
+cl_mme_send_as_mme (cl_t *ctx, u8 *buffer, uint length, mfs_tx_t *mfs)
+{
+}
+
+void
+cl_mme_send_as_data (cl_t *ctx, u8 *buffer, uint length)
+{
+}
+
+void cl_mme_init_buffer_add_cb (cl_t *cl, cl_mme_buffer_add_cb_t cb,
+ void *user_data)
+{
+}
+
+void cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void
+*user_data)
+{
+}
diff --git a/cesar/cp/beacon/test/cco/src/hle_stub.c b/cesar/cp/beacon/test/cco/src/hle_stub.c
new file mode 100644
index 0000000000..76add71ff4
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/hle_stub.c
@@ -0,0 +1,44 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/hle_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+
+#include "hle/hle.h"
+
+/**
+ * Initialise the interface to add an Interface buffer.
+ *
+ * \param ctx the hle context.
+ * \param cb the function to call on interface buffer reception.
+ * \param user_data the user_data to provide on function call.
+ */
+void
+hle_init_interface_buffer_add_cb (hle_t *ctx, hle_interface_buffer_add_cb_t
+ cb, void *user_data)
+{
+}
+
+/**
+ * Send a packet to the ipmbox.
+ *
+ * \param ctx the hle context.
+ * \param msg the message address to post the message in the ipmbox.
+ * \param length the length of the message in words.
+ */
+void
+hle_ipmbox_send (hle_t *ctx, u32 *msg, uint length)
+{
+}
+
diff --git a/cesar/cp/beacon/test/cco/src/ipmbox_stub.c b/cesar/cp/beacon/test/cco/src/ipmbox_stub.c
new file mode 100644
index 0000000000..4c14998b0d
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/ipmbox_stub.c
@@ -0,0 +1,22 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/ipmbox_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "hal/hle/ipmbox.h"
+
+
+void ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length)
+{
+}
+
diff --git a/cesar/cp/beacon/test/cco/src/phy_stub.c b/cesar/cp/beacon/test/cco/src/phy_stub.c
new file mode 100644
index 0000000000..e05b2805a2
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/phy_stub.c
@@ -0,0 +1,38 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/central_beacon/src/phy_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "hal/phy/phy.h"
+
+#include "cp/beacon/test/cco/inc/phy_stub.h"
+
+u32
+phy_date (phy_t *ctx)
+{
+ phy_test_t *phy;
+ dbg_assert(ctx);
+
+ phy = (phy_test_t *) ctx;
+ phy->ntb += phy->date_ntb + 10;
+
+ return phy->ntb;
+}
+
+u32
+phy_clock_get_zero_cross_captured_date (phy_t *ctx)
+{
+ return 0;
+}
+
diff --git a/cesar/cp/beacon/test/cco/src/sar_stub.c b/cesar/cp/beacon/test/cco/src/sar_stub.c
new file mode 100644
index 0000000000..a9f89c5132
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/sar_stub.c
@@ -0,0 +1,37 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/sar_stub.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "mac/sar/sar.h"
+#include "mac/sar/inc/sar_context.h"
+
+static sar_t sar_global;
+
+sar_t *
+sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca)
+{
+ return &sar_global;
+}
+
+void
+sar_beacon_send (sar_t *ctx, pb_beacon_t *beacon, mfs_tx_t *beacon_mfs, void *bto_bpsto)
+{
+ blk_release_desc ((blk_t *)beacon);
+}
+
+
+void sar_init_beacon_cb (sar_t *sar, void *user_data, sar_beacon_cb_t uf)
+{
+}
diff --git a/cesar/cp/beacon/test/cco/src/ucco.c b/cesar/cp/beacon/test/cco/src/ucco.c
new file mode 100644
index 0000000000..be47fa31dd
--- /dev/null
+++ b/cesar/cp/beacon/test/cco/src/ucco.c
@@ -0,0 +1,229 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/beacon/test/ucco/src/ucco.c
+ * \brief Test the schedule procedure with the leon timer.
+ * \ingroup cp/beacon
+ *
+ */
+#include "common/std.h"
+
+#include "hal/timer/timer.h"
+
+#include "cp/station/station.h"
+#include "cp/cco/cco.h"
+#include "cp/secu/secu.h"
+#include "cp/beacon/beacons.h"
+
+#include "hal/phy/phy.h"
+
+#include "cl/cl.h"
+
+#include "mac/common/ntb.h"
+#include "mac/common/config.h"
+#include "mac/common/store.h"
+
+#include "lib/test.h"
+#include "lib/read_word.h"
+#include "lib/bitstream.h"
+
+#include <stdio.h>
+
+#include "cp/beacon/inc/beacons_ctx.h"
+
+cp_beacon_t *cp_beacon;
+test_t test;
+uint count_beacon;
+
+void
+cp_beacon_expired (void *user_data)
+{
+
+}
+
+void
+test_emetting_discover_beacons(void)
+{
+ uint i;
+ count_beacon = 0;
+
+ for (i = 0; i < 10; i++)
+ {
+ // Create the default schedules for the CA.
+ cp_beacon_cco_send_discover_beacon (cp_beacon);
+ }
+}
+
+int
+cyg_user_start (void)
+{
+ phy_t *phy;
+ ca_t *ca;
+ pbproc_t *pbproc;
+ mac_config_t *mac_config;
+ mac_store_t *mac_store;
+ hal_timer_t *timer;
+ cp_sta_t *sta;
+ cp_secu_t *secu;
+ cp_cco_t *cco;
+ cl_t *cl;
+ interface_t *interface;
+ hle_t *hle;
+
+ test_init (test, 0, NULL);
+
+ cl = blk_alloc ();
+ phy = blk_alloc ();
+ ca = blk_alloc ();
+ mac_config = blk_alloc ();
+ pbproc = blk_alloc ();
+ secu = blk_alloc ();
+ cco = blk_alloc ();
+ hle = blk_alloc ();
+
+ mac_ntb_init (phy, mac_config);
+ timer = hal_timer_init (phy);
+ mac_store = mac_store_init ();
+
+ // Configure the STA to be CCo.
+ cp_cco_set_cco_status (cco, true);
+ // Add the mac_config to the sta.
+ sta = cp_station_init (mac_store, cl, pbproc, mac_config);
+
+ interface = interface_init (hle, cl, (sar_t *)cl , mac_config);
+
+ cp_beacon = cp_beacon_init(interface, phy, sta, secu, ca, pbproc, mac_store, cco, timer, NULL,
+ cp_beacon_expired);
+ cp_beacon_acl_frequency_detection (cp_beacon);
+ cp_beacon_acl_frequency_detection (cp_beacon);
+
+ test_emetting_discover_beacons ();
+
+ cp_beacon_uninit (cp_beacon);
+ hal_timer_uninit(timer);
+ mac_ntb_uninit ();
+ cp_station_uninit (sta);
+ mac_store_uninit (mac_store);
+
+ blk_release (cco);
+ blk_release (secu);
+ blk_release (pbproc);
+ blk_release (mac_config);
+ blk_release (ca);
+ blk_release (phy);
+ blk_release (cl);
+ blk_release (hle);
+
+
+ blk_print_memory ();
+
+ test_case_begin (test, "Memory");
+ test_begin (test, "Memory")
+ {
+ test_fail_if (blk_check_memory () != true, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
+/**
+ * Prepare a beacon for transmission.
+ * \param ctx pbproc context
+ * \param mfs corresponding special MFS
+ * \param pb beacon payload
+ * \param params extra parameters for beacon transmission
+ *
+ * There can only be one beacon prepared in advance (for a given MFS).
+ *
+ * This will cancel the preceding prepared beacon if it was not sent.
+ *
+ * PB reference is transfered to PB Processing. Extra parameters are copied.
+ */
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params)
+{
+ cp_beacon_work_beacon_t beacon_work;
+ cp_beacon_desc_t *beacon;
+ bitstream_t bitstream;
+ cp_bentry_sai_t sai;
+
+ uint res;
+
+ dbg_assert (pb);
+
+ beacon = (cp_beacon_desc_t *) pb;
+
+ bitstream_init (&bitstream, beacon->payload->beacon_mpdu_payload, 32,
+ BITSTREAM_READ);
+ bitstream_access (&bitstream, &beacon_work.nid_lsb, 22);
+ bitstream_access (&bitstream, &beacon_work.hm, 2);
+ bitstream_access (&bitstream, &beacon_work.stei, 8);
+ bitstream_finalise (&bitstream);
+
+ bitstream_init (&bitstream, beacon->payload->beacon_mpdu_payload + 4, 32,
+ BITSTREAM_READ);
+ bitstream_access (&bitstream, &beacon_work.bt, 3);
+ beacon_work.bt = CP_BEACON_WORK_MASK_BT (beacon_work.bt);
+
+ bitstream_access (&bitstream, &beacon_work.ncnr, 1);
+ bitstream_access (&bitstream, &beacon_work.npsm, 1);
+ bitstream_access (&bitstream, &beacon_work.num_slots, 3);
+ beacon_work.num_slots =
+ CP_BEACON_WORK_MASK_NUM_SLOTS(beacon_work.num_slots);
+
+ bitstream_access (&bitstream, &beacon_work.slot_usage, 8);
+ bitstream_access (&bitstream, &beacon_work.slot_id, 3);
+ beacon_work.slot_id = CP_BEACON_WORK_MASK_SLOT_ID(beacon_work.slot_id);
+
+ bitstream_access (&bitstream, &beacon_work.aclss, 3);
+ beacon_work.aclss = CP_BEACON_WORK_MASK_ACLSS(beacon_work.aclss);
+
+ bitstream_access (&bitstream, &beacon_work.hoip, 1);
+ bitstream_access (&bitstream, &beacon_work.rtsbf, 1);
+ bitstream_access (&bitstream, &beacon_work.nm, 2);
+ beacon_work.nm = CP_BEACON_WORK_MASK_NM(beacon_work.nm);
+
+ bitstream_access (&bitstream, &beacon_work.cco_cap, 2);
+ beacon_work.cco_cap = CP_BEACON_WORK_MASK_CCO_CAP(beacon_work.cco_cap);
+ bitstream_finalise (&bitstream);
+
+ res = read_u32_from_word (&beacon->payload->bmis[21]);
+ sai.stpf = res & true;
+ res = res >> 1;
+ sai.glid = res & 0x7f;
+ res = res >> 7;
+ sai.st = res & 0xFFF;
+ res = res >> 12;
+ sai.et = res & 0xFFF;
+
+ test_case_begin (test, "Verify the beacon");
+
+ test_begin (test, "Verifying the beacon")
+ {
+ test_fail_if (beacon_work.bt != CP_BEACON_DISCOVER_BEACON,
+ "Wrong beacon type");
+ test_fail_if (sai.stpf != true, "Wrong SAI type");
+ test_fail_if (sai.glid != 0x7F, "Wrong GLID");
+ test_fail_if (sai.st != 0, "Wrong start time");
+ test_fail_if (sai.et != 4095, "Wrong end time");
+ }
+ test_end;
+
+ blk_release_desc ((blk_t *) pb);
+}
+
+void
+pbproc_activate (pbproc_t *ctx, bool flag)
+{
+ dbg_assert (ctx);
+}
+