summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-01-17 16:53:31 +0000
committerlaranjeiro2008-01-17 16:53:31 +0000
commitf073d36e9f9bc31b2cbf4bce757d7a6166ce6def (patch)
tree151c47ec47dcd32cc840089ea3ad17d97f21d2b2
parent293b87f8599d100e84394e4515854dfcb0ba7e49 (diff)
Modified the CP to generate central beacon or discover beacons when it is respectively a CCo or a UCCo.
Update the traces to follow exactly what is happening. Update the test. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1287 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cp/beacon/beacons.h34
-rw-r--r--cp/beacon/inc/beacons.h53
-rw-r--r--cp/beacon/inc/beacons_ctx.h10
-rw-r--r--cp/beacon/inc/bentry.h11
-rw-r--r--cp/beacon/inc/trace.h5
-rw-r--r--cp/beacon/src/beacons.c269
-rw-r--r--cp/beacon/src/bentry.c31
-rw-r--r--cp/beacon/src/trace.c5
-rw-r--r--cp/beacon/test/central_beacon/Makefile2
-rw-r--r--cp/beacon/test/central_beacon/overide/cp/station/src/station.c15
-rw-r--r--cp/beacon/test/central_beacon/src/central_beacon.c2
-rw-r--r--cp/beacon/test/central_beacon/src/generate_cb.c5
12 files changed, 332 insertions, 110 deletions
diff --git a/cp/beacon/beacons.h b/cp/beacon/beacons.h
index 04a066a960..f2390ec51c 100644
--- a/cp/beacon/beacons.h
+++ b/cp/beacon/beacons.h
@@ -86,22 +86,38 @@ void
cp_beacon_estimate_bts_bto_bp (cp_beacon_t *ctx, cp_beacon_common_t *common);
/**
- * Generate the central beacon.
+ * Send a beacon when the STA is acting as a CCo.
*
- * \param ctx the beacon context.
- * \param beacon the central beacon to fill.
+ * \param ctx the beacon module context
+ * \param central boolean informing if it is a central beacon or a discover
+ * beacon.
*/
void
-cp_beacon_central_beacon_generate (cp_beacon_t *ctx, cp_beacon_desc_t *beacon);
+cp_beacon_cco_send_beacon (cp_beacon_t *ctx, bool central);
/**
- * Send the beacon over the PWL.
+ * Generate the central beacon when the STA acts as a CCo.
*
- * \param ctx the cp beacon context
- * \param beacon the beacon to send
+ * \param ctx the beacon context.
*/
-void
-cp_beacon_send_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon);
+extern inline void
+cp_beacon_cco_send_central_beacon (cp_beacon_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_beacon_cco_send_beacon (ctx, true);
+}
+
+/**
+ * Generate the discover beacon when the STA acts as a UCCo.
+ *
+ * \param ctx the beacon context.
+ */
+extern inline void
+cp_beacon_cco_send_discover_beacon (cp_beacon_t *ctx)
+{
+ dbg_assert (ctx);
+ cp_beacon_cco_send_beacon (ctx, false);
+}
/**
* Process the received beacon.
diff --git a/cp/beacon/inc/beacons.h b/cp/beacon/inc/beacons.h
index 540a70e37c..451be608dc 100644
--- a/cp/beacon/inc/beacons.h
+++ b/cp/beacon/inc/beacons.h
@@ -17,6 +17,25 @@
#include "cp/beacon/beacons.h"
/**
+ * Initialize the sub module for the discover, central and proxy beacons.
+ * The beacon_ctx corresponds to the each part contained in the ctx.
+ *
+ * \param ctx the becon module context.
+ * \param beacon_ctx the central, discover or proxy context.
+ */
+void
+cp_beacon_init_beacons (cp_beacon_t *ctx, cp_beacon_common_t *beacon_ctx);
+
+/**
+ * Uninit the sub beacon modules.
+ *
+ * \param ctx the beacon module context
+ * \param beacon_ctx the beacon context to uninit.
+ */
+void
+cp_beacon_uninit_beacons (cp_beacon_t *ctx, cp_beacon_common_t *beacon_ctx);
+
+/**
* Compute the beacon period using the beacon period thereotic calculated
* during the pw frequency detection.
*
@@ -25,6 +44,40 @@
uint
cp_beacon_pwl_period (cp_beacon_t *ctx);
+/**
+ * Fill the payload of the beacon when the STA is accting as CCo or UCCo.
+ * Can be use for
+ * - the Central beacon when acting as a CCo
+ * - the discover beacon when acting as a UCCo.
+ *
+ *
+ * \param ctx the beacon module context
+ * \param beacon the beacon to fill.
+ */
+void
+cp_beacon_xcco_fill_common_part (cp_beacon_t *ctx, cp_beacon_desc_t *beacon);
+
+/**
+ * Generate the beacon.
+ *
+ * \param ctx the beacon context.
+ * \parma common the beacon central or discover context.
+ * \param beacon the central beacon to fill
+ */
+void
+cp_beacon_cco_beacon_generate (cp_beacon_t *ctx, cp_beacon_common_t *common,
+ cp_beacon_desc_t *beacon);
+
+
+/**
+ * Send the beacon over the PWL.
+ *
+ * \param ctx the cp beacon context
+ * \param beacon the beacon to send
+ */
+void
+cp_beacon_send_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon);
+
/**
* Process a the central beacon received.
diff --git a/cp/beacon/inc/beacons_ctx.h b/cp/beacon/inc/beacons_ctx.h
index 6e55a92fb4..2527a685ff 100644
--- a/cp/beacon/inc/beacons_ctx.h
+++ b/cp/beacon/inc/beacons_ctx.h
@@ -121,6 +121,10 @@ struct cp_beacon_common_t
uint bp_tau[4];
/** last beacon period computed. */
uint per_ntb;
+ /** Last central beacon received. */
+ cp_beacon_desc_t *last_beacon;
+ /** MFS use to send the beacons */
+ mfs_tx_t *mfs;
};
struct cp_beacon_t
@@ -151,18 +155,12 @@ struct cp_beacon_t
/** Central beacon data. */
cp_beacon_common_t cbeacon;
- /** Last central beacon received. */
- cp_beacon_desc_t *last_central_beacon;
- mfs_tx_t *mfs_central_beacon;
/** Proxy beacon data. */
//cp_proxy_beaocn_t pbeacon;
/** Discover beacon data. */
cp_beacon_common_t dbeacon;
- /** Last discover beacon sent. */
- cp_beacon_desc_t *last_discover_beacon;
- mfs_tx_t *mfs_discover_beacon;
/** bentries data. */
cp_bentries_data_t bentries_data;
diff --git a/cp/beacon/inc/bentry.h b/cp/beacon/inc/bentry.h
index bfdd370e7d..a09cc28a28 100644
--- a/cp/beacon/inc/bentry.h
+++ b/cp/beacon/inc/bentry.h
@@ -180,14 +180,18 @@ void
cp_bentry_header_fill (u8 *bentry_header_addr, uint type, uint length);
/**
- * Create the non persistente schedule bentry for the beacon period.
+ * Create the non perisistent schedule bentry for the beacon period.
*
* \param ctx the cp_beacon_context.
* \param bentry_addr the address to store the data in the beacon payload.
+ * \param sched the ca schedule to fill the next schedule.
+ * \param central if it is a central beacon.
* \return the next address to store the next bentry.
*/
u8 *
-cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr);
+cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr,
+ cp_beacon_desc_alloc_t *sched, bool central);
+
/**
* Create the schedule bentry for the beacon period.
@@ -195,11 +199,12 @@ cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr);
* \param ctx the cp_beacon_context.
* \param bentry_addr the address to store the data in the beacon payload.
* \param sched the ca schedule to fill the next schedule.
+ * \param central if it is a central beacon.
* \return the next address to store the next bentry.
*/
u8 *
cp_bentry_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr,
- cp_beacon_desc_alloc_t *sched);
+ cp_beacon_desc_alloc_t *sched, bool central);
/**
* Create the regions for the beacons.
diff --git a/cp/beacon/inc/trace.h b/cp/beacon/inc/trace.h
index 14fa3d273e..34715caaf2 100644
--- a/cp/beacon/inc/trace.h
+++ b/cp/beacon/inc/trace.h
@@ -30,13 +30,12 @@ enum
{
CP_BEACON_ID (INIT, 1, 1),
CP_BEACON_ID (UNINIT, 2, 1),
- CP_BEACON_ID (FREQ, 3, 2),
+ CP_BEACON_ID (FREQ, 3, 4),
CP_BEACON_ID (ESTIMATION, 4, 4),
CP_BEACON_ID (DEFAULT_SCHED, 5, 1),
CP_BEACON_ID (PWL_PER, 6, 4),
CP_BEACON_ID (CENTRAL_BEACON_PROCESS, 7, 1),
- CP_BEACON_ID (CENTRAL_BEACON_GENE, 8, 1),
- CP_BEACON_ID (SEND_BEACON, 9, 2),
+ CP_BEACON_ID (SEND_BEACON, 8, 3),
};
BEGIN_DECLS
diff --git a/cp/beacon/src/beacons.c b/cp/beacon/src/beacons.c
index 0abd127089..186353f196 100644
--- a/cp/beacon/src/beacons.c
+++ b/cp/beacon/src/beacons.c
@@ -14,6 +14,9 @@
*/
#include "common/std.h"
+// TODO REMOVE IT
+#include <stdio.h>
+
#include "cp/beacon/beacons.h"
#include "hal/phy/phy.h"
@@ -44,7 +47,6 @@ cp_beacon_t *
cp_beacon_init(phy_t *phy, cp_sta_t *sta, cp_secu_t *secu, ca_t *ca,
pbproc_t *pbproc, mac_store_t *mac_store, cp_cco_t *cco)
{
- uint i;
cp_beacon_t *ctx;
dbg_assert(phy);
@@ -70,25 +72,18 @@ cp_beacon_init(phy_t *phy, cp_sta_t *sta, cp_secu_t *secu, ca_t *ca,
CP_BEACON_TRACE (INIT, mac_ntb());
// init all the context.
- ctx->last_central_beacon = NULL;
- ctx->mfs_discover_beacon = NULL;
- ctx->mfs_central_beacon = NULL;
ctx->schedule_index = 0;
ctx->hm = 0x0;
- // initialize the central beacon data.
- ctx->cbeacon.beacon_nb = 0;
- for (i = 0; i < 4; i++)
- {
- ctx->cbeacon.btse_ntb[i] = 0;
- ctx->cbeacon.bto_bpsto.bto[i] = 0;
- ctx->cbeacon.bp_tau[i] = 0;
- }
-
// verify the AC line frequence.
ctx->pwl.date_ntb[0] = 0;
ctx->pwl.date_ntb[1] = 0;
+ // init cbeacon
+ cp_beacon_init_beacons (ctx, &ctx->cbeacon);
+ // init dbeacon
+ cp_beacon_init_beacons (ctx, &ctx->dbeacon);
+
return ctx;
}
@@ -102,45 +97,78 @@ cp_beacon_uninit(cp_beacon_t *ctx)
{
dbg_assert(ctx);
- if (ctx->last_central_beacon != NULL)
- {
- blk_release_desc ((blk_t *) ctx->last_central_beacon);
- }
+ cp_beacon_uninit_beacons (ctx, &ctx->cbeacon);
+ cp_beacon_uninit_beacons (ctx, &ctx->dbeacon);
+
+ CP_BEACON_TRACE (UNINIT, mac_ntb());
+ cp_beacon_trace_uninit(ctx);
+}
- if (ctx->last_discover_beacon != NULL)
+/**
+ * Initialize the sub module for the discover, central and proxy beacons.
+ * The beacon_ctx corresponds to the each part contained in the ctx.
+ *
+ * \param ctx the becon module context.
+ * \param beacon_ctx the central, discover or proxy context.
+ */
+void
+cp_beacon_init_beacons (cp_beacon_t *ctx, cp_beacon_common_t *beacon_ctx)
+{
+ uint i;
+
+ dbg_assert (ctx);
+ dbg_assert (beacon_ctx);
+
+ beacon_ctx->mfs = NULL;
+ beacon_ctx->bto_bpsto.bpsto = 0;
+ beacon_ctx->beacon_nb = 0;
+ beacon_ctx->per_ntb = 0;
+ beacon_ctx->last_beacon = NULL;
+ beacon_ctx->mfs = NULL;
+
+ // initialize the central beacon data.
+ ctx->cbeacon.beacon_nb = 0;
+ for (i = 0; i < 4; i++)
{
- blk_release_desc ((blk_t *) ctx->last_discover_beacon);
+ beacon_ctx->btse_ntb[i] = 0;
+ beacon_ctx->bto_bpsto.bto[i] = 0;
+ beacon_ctx->bp_tau[i] = 0;
}
+}
- if (ctx->mfs_central_beacon)
- {
- dbg_assert (ctx->mac_store);
- mac_store_mfs_remove (ctx->mac_store, (mfs_t *)
- ctx->mfs_central_beacon);
+/**
+ * Uninit the sub beacon modules.
+ *
+ * \param ctx the beacon module context
+ * \param beacon_ctx the beacon context to uninit.
+ */
+void
+cp_beacon_uninit_beacons (cp_beacon_t *ctx, cp_beacon_common_t *beacon_ctx)
+{
+ dbg_assert (ctx);
+ dbg_assert (beacon_ctx);
- // Remove the MFS from the CA
- ca_mfs_remove (ctx->ca, ctx->mfs_central_beacon);
- // Release the mfs.
- blk_release (ctx->mfs_central_beacon);
+ if (beacon_ctx->last_beacon != NULL)
+ {
+ blk_release_desc ((blk_t *) beacon_ctx->last_beacon);
}
- if (ctx->mfs_discover_beacon)
+
+ if (beacon_ctx->mfs)
{
dbg_assert (ctx->mac_store);
mac_store_mfs_remove (ctx->mac_store, (mfs_t *)
- ctx->mfs_discover_beacon);
+ beacon_ctx->mfs);
// Remove the MFS from the CA
- ca_mfs_remove (ctx->ca, ctx->mfs_discover_beacon);
+ ca_mfs_remove (ctx->ca, beacon_ctx->mfs);
// Release the mfs.
- blk_release (ctx->mfs_discover_beacon);
+ blk_release (beacon_ctx->mfs);
}
-
- CP_BEACON_TRACE (UNINIT, mac_ntb());
- cp_beacon_trace_uninit(ctx);
}
+
/**
* Create the default schedule for the CA when the station is set as an
* Unauthenticated station.
@@ -220,7 +248,8 @@ cp_beacon_acl_frequency_detection (cp_beacon_t *ctx)
ctx->pwl.pwzc_ntb = 250000;
}
- CP_BEACON_TRACE (FREQ, mac_ntb(), ctx->pwl.bp_ntb);
+ CP_BEACON_TRACE (FREQ, mac_ntb(), ctx->pwl.bp_ntb, ctx->pwl.date_ntb[1],
+ ctx->pwl.date_ntb[0]);
}
/**
@@ -440,16 +469,16 @@ cp_beacon_process_central_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
}
// Store the beacon in the cp_beacon context.
- if (ctx->last_central_beacon != NULL)
+ if (ctx->cbeacon.last_beacon != NULL)
{
- blk_release_desc ((blk_t *) ctx->last_central_beacon);
+ blk_release_desc ((blk_t *) ctx->cbeacon.last_beacon);
nb_beacon_period = 3;
}
else
{
nb_beacon_period = 4;
}
- ctx->last_central_beacon = beacon;
+ ctx->cbeacon.last_beacon = beacon;
// ADD the schedule to the CA.
for (i = 0; i < nb_beacon_period; i++)
@@ -482,7 +511,7 @@ cp_beacon_process_central_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
void
cp_beacon_process_discover_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
{
- dbg_assert (false);
+ printf ("WARN : cp_beacon_process_discover_beacon is not implemented yet\n");
}
/**
@@ -498,34 +527,60 @@ cp_beacon_process_proxy_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
}
/**
- * Generate the central beacon.
+ * Send a beacon when the STA is acting as a CCo.
*
- * \param ctx the beacon context.
- * \param beacon the central beacon to fill
+ * \param ctx the beacon module context
+ * \param central boolean informing if it is a central beacon
*/
void
-cp_beacon_central_beacon_generate (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
+cp_beacon_cco_send_beacon (cp_beacon_t *ctx, bool central)
{
- u64 nid;
- u8 *bentry;
- cp_beacon_desc_alloc_t sched;
- ca_beacon_period_t beacon_period[4];
- uint i;
+ cp_beacon_desc_t *beacon;
+ cp_beacon_common_t *common;
dbg_assert (ctx);
- dbg_assert (ctx->sta);
- dbg_assert (ctx->cco);
- dbg_assert (beacon);
+ dbg_assert (cp_cco_get_cco_status(ctx->cco));
- cp_beacon_estimate_bts_bto_bp (ctx, &ctx->cbeacon);
+ beacon = (cp_beacon_desc_t *) blk_alloc_desc();
- // Store the coexistence mode
- sched.next_alloc = 0;
- sched.ca_sched = ca_alloc_get_schedule (ctx->ca, ctx->schedule_index);
- sched.ca_sched->coexistence_mode = ctx->hm;
+ // To keep the beacon in memroy for a future use
+ blk_addref_desc ((blk_t *) beacon);
+
+ if (central)
+ {
+ common = &ctx->cbeacon;
+ beacon->payload->bt = CP_BEACON_CENTRAL_BEACON;
+ }
+ else
+ {
+ common = &ctx->dbeacon;
+ beacon->payload->bt = CP_BEACON_DISCOVER_BEACON;
+ }
- beacon->payload->fc.bts = ctx->cbeacon.btse_ntb[0];
- *beacon->payload->fc.bto = *ctx->cbeacon.bto_bpsto.bto;
+ cp_beacon_cco_beacon_generate (ctx, common, beacon);
+ cp_beacon_send_beacon (ctx, beacon);
+}
+
+/**
+ * Fill the payload of the beacon when the STA is accting as CCo or UCCo.
+ * Can be use for
+ * - the Central beacon when acting as a CCo
+ * - the discover beacon when acting as a UCCo.
+ *
+ *
+ * \param ctx the beacon module context
+ * \param beacon the beacon to fill.
+ */
+void
+cp_beacon_xcco_fill_common_part (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
+{
+ u64 nid;
+
+ dbg_assert (ctx);
+ dbg_assert (ctx->sta);
+ dbg_assert (ctx->cco);
+ dbg_assert (beacon);
+ dbg_assert (beacon->payload->bt < 3);
// Beacon payload
nid = cp_station_get_nid (ctx->sta);
@@ -534,7 +589,6 @@ cp_beacon_central_beacon_generate (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
beacon->payload->hm = ctx->hm;
beacon->payload->stei = cp_station_get_tei (ctx->sta);
- beacon->payload->bt = CP_BEACON_CENTRAL_BEACON;
beacon->payload->ncnr = cp_cco_get_ncnr (ctx->cco);
beacon->payload->npsm = cp_cco_get_npsm (ctx->cco);
beacon->payload->num_slots = cp_cco_get_numslots (ctx->cco);
@@ -545,20 +599,62 @@ cp_beacon_central_beacon_generate (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
beacon->payload->rtsbf = cp_station_get_rtsbf (ctx->sta);
beacon->payload->nm = cp_cco_get_nm (ctx->cco);
beacon->payload->cco_cap = cp_cco_get_cco_cap (ctx->cco);
- beacon->payload->bmi_nbe = 0x4;
+}
+
+/**
+ * Generate the beacon.
+ *
+ * \param ctx the beacon context.
+ * \parma common the beacon central or discover context.
+ * \param beacon the central beacon to fill
+ */
+void
+cp_beacon_cco_beacon_generate (cp_beacon_t *ctx, cp_beacon_common_t *common,
+ cp_beacon_desc_t *beacon)
+{
+ u8 *bentry;
+ cp_beacon_desc_alloc_t sched;
+ ca_beacon_period_t beacon_period[4];
+ uint i;
+ dbg_assert (ctx);
+ dbg_assert (ctx->sta);
+ dbg_assert (ctx->cco);
+ dbg_assert (common);
+ dbg_assert (beacon);
+ dbg_assert (beacon->payload->bt < 0x3);
+
+ cp_beacon_estimate_bts_bto_bp (ctx, common);
+
+ // Store the coexistence mode
+ sched.next_alloc = 0;
+ sched.ca_sched = ca_alloc_get_schedule (ctx->ca, ctx->schedule_index);
+ sched.ca_sched->coexistence_mode = ctx->hm;
+
+ beacon->payload->fc.bts = common->btse_ntb[0];
+ *beacon->payload->fc.bto = *common->bto_bpsto.bto;
+
+ // Beacon payload
+ cp_beacon_xcco_fill_common_part (ctx, beacon);
// Bentries.
- bentry = cp_bentry_bpsto (ctx, &ctx->cbeacon, beacon->payload->bmis);
+ bentry = cp_bentry_bpsto (ctx, common, beacon->payload->bmis);
bentry = cp_bentry_mac_address (ctx, bentry);
- bentry = cp_bentry_persistent_schedule (ctx, bentry, &sched);
+ bentry = cp_bentry_persistent_schedule (ctx, bentry, &sched,
+ !beacon->payload->bt);
bentry = cp_bentry_regions (ctx, bentry);
+ if (beacon->payload->bt == CP_BEACON_DISCOVER_BEACON)
+ {
+ bentry = cp_bentry_discover_info (ctx, bentry);
+ }
+
+
// ADD the schedule to the CA.
for (i = 0; i < 4; i++)
{
- beacon_period[i].start_date = ctx->cbeacon.per_ntb * i + beacon->payload->fc.bts
- + beacon->payload->fc.bto[i];
+ beacon_period[i].start_date = common->per_ntb * i
+ + MAC_NTB_TO_DATE(beacon->payload->fc.bts) + beacon->payload->fc.bto[i];
beacon_period[i].schedule_index = ctx->schedule_index;
}
ca_alloc_update_beacon_periods (ctx->ca, beacon_period, 4);
@@ -570,12 +666,11 @@ cp_beacon_central_beacon_generate (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
ctx->pbproc_activated = true;
pbproc_activate (ctx->pbproc, true);
}
-
- CP_BEACON_TRACE (CENTRAL_BEACON_GENE, mac_ntb());
}
/**
* Send the beacon over the PWL.
+ * TODO Implement the proxy beacon part
*
* \param ctx the cp beacon context
* \param beacon the beacon to send
@@ -585,34 +680,58 @@ cp_beacon_send_beacon (cp_beacon_t *ctx, cp_beacon_desc_t *beacon)
{
mfs_tx_t *mfs_beacon;
bool added;
+ uint bt;
+ cp_beacon_common_t *common;
dbg_assert (ctx);
dbg_assert (beacon);
+ bt = beacon->payload->bt;
+
/* Create the MFS
* see http://pessac/cesar/trac/wiki/SoftMacBeacons#BeaconMFS
* for more details.
*/
dbg_assert (ctx->mac_store);
- mfs_beacon = mac_store_mfs_add_tx (ctx->mac_store, true, false, MAC_LID_SPC_CENTRAL, 0xff, &added);
+ switch (bt)
+ {
+ case CP_BEACON_CENTRAL_BEACON:
+ mfs_beacon = mac_store_mfs_add_tx (ctx->mac_store, true, false,
+ MAC_LID_SPC_CENTRAL, 0xff, &added);
+ ctx->cbeacon.mfs = mfs_beacon;
+ mfs_beacon->cap = 0x3;
+ common = &ctx->cbeacon;
+ break;
+ case CP_BEACON_DISCOVER_BEACON:
+ mfs_beacon = mac_store_mfs_add_tx (ctx->mac_store, true, false,
+ MAC_LID_DISCOVER, 0xff, &added);
+ ctx->dbeacon.mfs = mfs_beacon;
+ mfs_beacon->cap = 0x2;
+ common = &ctx->dbeacon;
+ break;
+ default:
+ dbg_assert (false);
+ }
+
+ dbg_assert (mfs_beacon);
if (added)
{
- ctx->mfs_central_beacon = mfs_beacon;
- mfs_beacon->common.ats = false;
- mfs_beacon->cap = 0x2;
mfs_beacon->beacon = true;
+ mfs_beacon->common.ats = false;
// Add the mfs to the CA
ca_mfs_add (ctx->ca, mfs_beacon);
}
dbg_assert (ctx->pbproc);
- pbproc_mfs_beacon_prepare (ctx->pbproc, mfs_beacon, ctx->cbeacon.btse_ntb[0],
- (pb_beacon_t *) beacon, &ctx->cbeacon.bto_bpsto);
+ dbg_assert (common);
+ pbproc_mfs_beacon_prepare (ctx->pbproc, mfs_beacon, MAC_NTB_TO_DATE(common->btse_ntb[0]),
+ (pb_beacon_t *) beacon, &common->bto_bpsto);
- ca_mfs_update (ctx->ca, ctx->mfs_central_beacon);
+ ca_mfs_update (ctx->ca, mfs_beacon);
- CP_BEACON_TRACE (SEND_BEACON, mac_ntb(), ctx->cbeacon.btse_ntb[0]);
+ CP_BEACON_TRACE (SEND_BEACON, mac_ntb(), common->btse_ntb[0],
+ beacon->payload->bt);
}
diff --git a/cp/beacon/src/bentry.c b/cp/beacon/src/bentry.c
index 1ced8b2d6a..ad9a2f1e65 100644
--- a/cp/beacon/src/bentry.c
+++ b/cp/beacon/src/bentry.c
@@ -12,13 +12,12 @@
*
*/
#include "common/std.h"
-
-// TODO remove this include.
-#include <stdio.h>
+#include "stdio.h"
#include "mac/common/timings.h"
#include "lib/read_word.h"
+#include "lib/blk.h"
#include "cp/station/station.h"
#include "cp/secu/secu.h"
@@ -27,14 +26,17 @@
#include "cp/beacon/inc/beacons_ctx.h"
/**
- * Create the non persistente schedule bentry for the beacon period.
+ * Create the non perisistent schedule bentry for the beacon period.
*
* \param ctx the cp_beacon_context.
* \param bentry_addr the address to store the data in the beacon payload.
+ * \param sched the ca schedule to fill the next schedule.
+ * \param central if it is a central beacon.
* \return the next address to store the next bentry.
*/
u8 *
-cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr)
+cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr,
+ cp_beacon_desc_alloc_t *sched, bool central)
{
// TODO Fill correctly this function. For this moment it will not be use.
@@ -48,11 +50,12 @@ cp_bentry_non_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr)
* \param ctx the cp_beacon_context.
* \param bentry_addr the address to store the data in the beacon payload.
* \param sched the ca schedule to fill the next schedule.
+ * \param central if it is a central beacon.
* \return the next address to store the next bentry.
*/
u8 *
cp_bentry_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr,
- cp_beacon_desc_alloc_t *sched)
+ cp_beacon_desc_alloc_t *sched, bool central)
{
cp_bentry_persistent_schedule_struct_t *bentry;
cp_bentry_sai_stpf_t *sai;
@@ -79,7 +82,11 @@ cp_bentry_persistent_schedule(cp_beacon_t *ctx, u8 *bentry_addr,
sai->stpf = true;
sai->glid = 0xFF;
sai->st = 0x0;
- sai->et = ctx->cbeacon.bp_tau[0];
+
+ if (central)
+ sai->et = ctx->cbeacon.bp_tau[0];
+ else
+ sai->et = ctx->dbeacon.bp_tau[0];
sched->ca_sched->allocations_nb = 1;
sched->ca_sched->allocations[0].end_offset_tck = MAC_ATU_TO_TCK (sai->et);
@@ -438,6 +445,14 @@ cp_bentry_discover_process (cp_beacon_t *ctx, u8 *bentry, cp_beacon_desc_t
//Generate the discover beacon and provide it to the CA.
beacon = (cp_beacon_desc_t *) blk_alloc_desc();
+
+ // Store the discover beacon in the discover context.
+ if (ctx->dbeacon.last_beacon)
+ {
+ blk_release_desc ((blk_t *) ctx->dbeacon.last_beacon);
+ }
+ blk_addref_desc ((blk_t *) beacon);
+ ctx->dbeacon.last_beacon = beacon;
// Copy 96 bytes from the central beacon.
beacon->nid_msb = central_beacon->nid_msb;
@@ -474,7 +489,7 @@ cp_bentry_discover_process (cp_beacon_t *ctx, u8 *bentry, cp_beacon_desc_t
if (added)
{
- ctx->mfs_discover_beacon = mfs_beacon;
+ ctx->dbeacon.mfs = mfs_beacon;
mfs_beacon->common.ats = false;
mfs_beacon->cap = 0x2;
mfs_beacon->beacon = true;
diff --git a/cp/beacon/src/trace.c b/cp/beacon/src/trace.c
index 6af0354351..a78be0601e 100644
--- a/cp/beacon/src/trace.c
+++ b/cp/beacon/src/trace.c
@@ -37,13 +37,12 @@ cp_beacon_trace_init (cp_beacon_t *ctx)
{
TRACE_EVENT (CP_BEACON_TRACE_INIT, "[%x] CP_BEACON_INIT"),
TRACE_EVENT (CP_BEACON_TRACE_UNINIT, "[%x] CP_BEACON_UNINIT"),
- TRACE_EVENT (CP_BEACON_TRACE_FREQ, "[%x] CP_BEACON_FREQ detected : %d ntb"),
+ TRACE_EVENT (CP_BEACON_TRACE_FREQ, "[%x] CP_BEACON_FREQ detected : %d ntb, first zero cross : %d, second zero cross : %d"),
TRACE_EVENT (CP_BEACON_TRACE_ESTIMATION, "[%x] CP_BEACON_ESTIMATION btse : %d\t per : %d\t bto : %d"),
TRACE_EVENT (CP_BEACON_TRACE_DEFAULT_SCHED, "[%x] CP_BEACON_DEFAULT_SCHED"),
TRACE_EVENT (CP_BEACON_TRACE_PWL_PER, "[%x] CP_BEACON_PWL_PER, old zero cross : %x, last zero cross : %x, per ntb : %x"),
TRACE_EVENT (CP_BEACON_TRACE_CENTRAL_BEACON_PROCESS, "[%x] CP_BEACON_CENTRAL_BEACON_PROCESS"),
- TRACE_EVENT (CP_BEACON_TRACE_CENTRAL_BEACON_GENE, "[%x] CP_BEACON_CENTRAL_BEACON_GENERATION"),
- TRACE_EVENT (CP_BEACON_TRACE_SEND_BEACON, "[%x] CP_BEACON_SEND_BEACON send at %x"),
+ TRACE_EVENT (CP_BEACON_TRACE_SEND_BEACON, "[%x] CP_BEACON_SEND_BEACON send at %d, BT : %x"),
};
trace_namespace_init (&ctx->trace_namespace);
diff --git a/cp/beacon/test/central_beacon/Makefile b/cp/beacon/test/central_beacon/Makefile
index 1eb4a3d331..c4737b3249 100644
--- a/cp/beacon/test/central_beacon/Makefile
+++ b/cp/beacon/test/central_beacon/Makefile
@@ -36,6 +36,6 @@ usta_MODULES = lib mac/common cp/beacon \
cp/beacon/test/central_beacon/overide/cp/secu \
cp/beacon/test/central_beacon/overide/cp/cco
-cp_beacon_MODULE_SOURCES = beacons.c bentry.c
+cp_beacon_MODULE_SOURCES = beacons.c bentry.c
include $(BASE)/common/make/top.mk
diff --git a/cp/beacon/test/central_beacon/overide/cp/station/src/station.c b/cp/beacon/test/central_beacon/overide/cp/station/src/station.c
index 395616aa65..793d695f8e 100644
--- a/cp/beacon/test/central_beacon/overide/cp/station/src/station.c
+++ b/cp/beacon/test/central_beacon/overide/cp/station/src/station.c
@@ -161,6 +161,21 @@ cp_station_is_authenticated(cp_sta_t *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.
*
diff --git a/cp/beacon/test/central_beacon/src/central_beacon.c b/cp/beacon/test/central_beacon/src/central_beacon.c
index 41bfc07361..cd95bebc2f 100644
--- a/cp/beacon/test/central_beacon/src/central_beacon.c
+++ b/cp/beacon/test/central_beacon/src/central_beacon.c
@@ -423,7 +423,7 @@ test_beacon_process (void)
*/
// Launch the same beacon but simulating that the sta which receives it
// has been designated by the CCo to send a discover beacon.
- cp_beacon->last_central_beacon = NULL;
+ cp_beacon->cbeacon.last_beacon = NULL;
sta->mac_config->tei = 0xA;
cp_beacon_process (cp_beacon, beacon);
diff --git a/cp/beacon/test/central_beacon/src/generate_cb.c b/cp/beacon/test/central_beacon/src/generate_cb.c
index ccaf7f8cb1..28f9e4443f 100644
--- a/cp/beacon/test/central_beacon/src/generate_cb.c
+++ b/cp/beacon/test/central_beacon/src/generate_cb.c
@@ -33,6 +33,8 @@
#include "cp/beacon/inc/beacons_ctx.h"
#include "cp/beacon/test/central_beacon/inc/phy_stub.h"
+#include "cp/beacon/inc/beacons.h"
+
int
main (void)
{
@@ -87,7 +89,8 @@ main (void)
cp_station_set_mac_address (sta, 0x123456789ABC);
beacon = (cp_beacon_desc_t *) blk_alloc_desc ();
- cp_beacon_central_beacon_generate (cp_beacon, beacon);
+ beacon->payload->bt = CP_BEACON_CENTRAL_BEACON;
+ cp_beacon_cco_beacon_generate (cp_beacon, &cp_beacon->cbeacon, beacon);
test_case_begin (test, "Verification");
test_begin (test, "Frame Control")