summaryrefslogtreecommitdiff
path: root/cesar/bsu
diff options
context:
space:
mode:
authorNélio Laranjeiro2010-12-03 09:11:06 +0100
committerNélio Laranjeiro2011-01-11 15:39:43 +0100
commitc6a459052635a62ebf4745a75d72dd091a57068c (patch)
tree2178782237d3086921d9458dfdd9cbaac51a1c10 /cesar/bsu
parent224594457d46d928d94ee26990a510db3e301f9e (diff)
cesar/{cp, bsu, interface}: provide a decoded beacon to CP, closes #2127
Diffstat (limited to 'cesar/bsu')
-rw-r--r--cesar/bsu/beacon/beacon.h125
-rw-r--r--cesar/bsu/beacon/inc/misc.h2
-rw-r--r--cesar/bsu/beacon/src/beacon.c188
-rw-r--r--cesar/bsu/bsu.h26
-rw-r--r--cesar/bsu/inc/interface.h12
-rw-r--r--cesar/bsu/inc/trace.h2
-rw-r--r--cesar/bsu/src/bsu.c45
-rw-r--r--cesar/bsu/src/interface.c40
-rw-r--r--cesar/bsu/src/trace.c2
-rw-r--r--cesar/bsu/test/utest/src/bsu.c1
-rw-r--r--cesar/bsu/test/utest/src/bsut.c20
-rw-r--r--cesar/bsu/test/utest/src/interface.c30
-rw-r--r--cesar/bsu/test/utest/src/sar.c1
-rw-r--r--cesar/bsu/test/utest/src/schedules.c14
-rw-r--r--cesar/bsu/test/utest/src/tests.c7
-rw-r--r--cesar/bsu/test/utest/tests.h4
16 files changed, 276 insertions, 243 deletions
diff --git a/cesar/bsu/beacon/beacon.h b/cesar/bsu/beacon/beacon.h
index e522fbcf85..68d931d15b 100644
--- a/cesar/bsu/beacon/beacon.h
+++ b/cesar/bsu/beacon/beacon.h
@@ -14,6 +14,7 @@
*
* Functions to read and write beacons.
*/
+#include "lib/bitstream.h"
#include "bsu/beacon/defs.h"
#include "bsu/beacon/inc/region.h"
#include "bsu/beacon/inc/schedule.h"
@@ -24,6 +25,28 @@
/** Number of schedules information kept from the beacon. */
#define BSU_BEACON_SCHEDULES_MAX 3
+enum bsu_beacon_direction_t
+{
+ BSU_BEACON_DIRECTION_TO_PLC,
+ BSU_BEACON_DIRECTION_FROM_PLC,
+ BSU_BEACON_DIRECTION_NB
+};
+typedef enum bsu_beacon_direction_t bsu_beacon_direction_t;
+
+/** BSU computed parameters. */
+struct bsu_beacon_params_t
+{
+ /** Pbproc RX parameters. */
+ pbproc_rx_beacon_params_t rx_parameters;
+ /** Direction */
+ bsu_beacon_direction_t direction;
+ /** Frequency error. */
+ s32 frequency_error;
+ /** Tick offset, difference between the NTB and PHY Date clock. */
+ u32 ntb_offset_tck;
+};
+typedef struct bsu_beacon_params_t bsu_beacon_params_t;
+
enum bsu_beacon_type_t
{
BSU_BEACON_TYPE_CENTRAL,
@@ -49,39 +72,32 @@ struct bsu_beacon_variant_fields_t
{
/** Network Identifier. */
u64 nid;
- BITFIELDS_WORD
- (
- /** Hybrid mode. */
- u32 hm:8;,
- /** Non-Coordinating Networks Reported. */
- u32 ncnr:8;,
- /** Network Power Saving Mode. */
- u32 npsm:8;,
- /** Number of beacon slots. */
- u32 numslots:8;
- );
- BITFIELDS_WORD
- (
- /** Beacon slot usage. */
- u32 slotusage:8;,
- /** Slot identifier. */
- u32 slotid:8;,
- /** AC Line Synchronization Status. */
- u32 aclsss:8;,
- /** Handover in Progress. */
- u32 hoip:8;
- );
- BITFIELDS_WORD
- (
- /** RTS Broadcast Flag. */
- u32 rtsbf:8;,
- /** Network Mode. */
- u32 nm:8;,
- /** CCo Capability. */
- u32 ccocap:8;,
- /** Reserved. */
- u32 rsvd:8;
- );
+ /** Hybrid mode. */
+ u8 hm;
+ /** Source TEI. */
+ u8 stei;
+ /** Beacon type. */
+ bsu_beacon_type_t bt;
+ /** Non-Coordinating Networks Reported. */
+ bool ncnr;
+ /** Network Power Saving Mode. */
+ bool npsm;
+ /** Number of beacon slots. */
+ u8 numslots;
+ /** Beacon slot usage. */
+ u8 slotusage;
+ /** Slot identifier. */
+ u8 slotid;
+ /** AC Line Synchronization Status. */
+ u8 aclsss;
+ /** Handover in Progress. */
+ bool hoip;
+ /** RTS Broadcast Flag. */
+ bool rtsbf;
+ /** Network Mode. */
+ bsu_beacon_nm_t nm;
+ /** CCo Capability. */
+ u8 ccocap;
};
typedef struct bsu_beacon_variant_fields_t bsu_beacon_variant_fields_t;
@@ -124,12 +140,16 @@ typedef struct bsu_beacon_bmi_t bsu_beacon_bmi_t;
/** beacon description structure. */
struct bsu_beacon_t
{
+ /** Next pointer, usefull to chain beacons in a list if necessary.*/
+ struct bsu_beacon_t *next;
/** Data are valid for the beacon period starting at this date. */
u32 beacon_period_start_date;
/** Variant fields. */
bsu_beacon_variant_fields_t vf;
/** Beacon Management Information. */
bsu_beacon_bmi_t bmis;
+ /** Parameters received with the beacon in the frame control. */
+ bsu_beacon_params_t params;
};
typedef struct bsu_beacon_t bsu_beacon_t;
@@ -156,6 +176,39 @@ typedef struct bsu_beacon_schedules_t bsu_beacon_schedules_t;
BEGIN_DECLS
/**
+ * When the bitstream is initialised it will fill the phy beacon with the
+ * bitstream.
+ * \param beacon the bsu_beacon containing the data.
+ * \param stream the bitstream to use.
+ * \param data the start address where the beacon is written down.
+ * \return the offset to store the BSPTO when network mode is CSMA_ONLY.
+ *
+ * phy_beacon is necessary to store a part of the NID in the phy_beacon
+ * header.
+ * \warn client is responsible for initialising and finalising the bitstream.
+ * The NID is not embedded with this function, client is responsible to store
+ * it with the bitstream.
+ */
+uint
+bsu_beacon_write_bitstream_initialised_no_nid (
+ bsu_beacon_t *beacon, bitstream_t *stream, u8 *data);
+
+/**
+ * When the bitstream is initialised it will fill the phy beacon with the
+ * bitstream.
+ * \param beacon the bsu_beacon containing the data.
+ * \param stream the bitstream to use.
+ * \param pbbeacon the physical beacon to write in.
+ * \return the offset to store the BSPTO when network mode is CSMA_ONLY.
+ *
+ * phy_beacon is necessary to store a part of the NID in the phy_beacon
+ * header.
+ */
+uint
+bsu_beacon_write_bitstream_initialised (
+ bsu_beacon_t *beacon, bitstream_t *stream, pb_beacon_t *pbbeacon);
+
+/**
* Write a beacon to be sent on the medium
* \param beacon the beacon containing the data to store.
* \param type the beacon type to send.
@@ -172,14 +225,10 @@ bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
* Read the whole beacon and store the data into the beacon structure.
* \param pbbeacon the beacon received from the medium.
* \param beacon the structure to store the data.
- * \param type the beacon type.
- * \param tei the Source TEI present in the beacon.
- * \param mac_address the Source MAC Address if present in beacon.
* \return true on success false otherwise.
*/
bool
-bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
- bsu_beacon_type_t *type, u8 *tei, mac_t *mac_address);
+bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon);
/**
* Decrease the countdown values of the beacon.
diff --git a/cesar/bsu/beacon/inc/misc.h b/cesar/bsu/beacon/inc/misc.h
index 7d8ccbd2dc..c7994cfec1 100644
--- a/cesar/bsu/beacon/inc/misc.h
+++ b/cesar/bsu/beacon/inc/misc.h
@@ -192,6 +192,8 @@ struct bsu_beacon_bmi_mac_address_t
{
/** Present. */
u32 present;
+ /** Peer mac address. */
+ mac_t mac_address;
};
typedef struct bsu_beacon_bmi_mac_address_t bsu_beacon_bmi_mac_address_t;
diff --git a/cesar/bsu/beacon/src/beacon.c b/cesar/bsu/beacon/src/beacon.c
index bb22d960d5..b794543120 100644
--- a/cesar/bsu/beacon/src/beacon.c
+++ b/cesar/bsu/beacon/src/beacon.c
@@ -42,6 +42,8 @@ bsu_beacon_reset (bsu_beacon_t *beacon)
beacon->beacon_period_start_date = 0;
beacon->vf.nid = 0;
beacon->vf.hm = 0;
+ beacon->vf.stei = MAC_TEI_UNASSOCIATED;
+ beacon->vf.bt = BSU_BEACON_TYPE_NB;
beacon->vf.ncnr = 0;
beacon->vf.npsm = 0;
beacon->vf.numslots = 0;
@@ -52,7 +54,6 @@ bsu_beacon_reset (bsu_beacon_t *beacon)
beacon->vf.rtsbf = 0;
beacon->vf.nm = 0;
beacon->vf.ccocap = 0;
- beacon->vf.rsvd = 0;
beacon->bmis.nbe = 0;
beacon->bmis.region.nb = 0;
beacon->bmis.ps.nb = 0;
@@ -80,27 +81,19 @@ bsu_beacon_read_nid (pb_beacon_t *beacon, bitstream_t *stream)
return ((u64) bitstream_read (stream, 22)) << 32
| beacon->first_data_word;
}
-
/**
* Write the beacon variant fields.
* \param phy_beacon the beacon bloc.
* \param stream the bitstream context.
- * \param mac_config the mac config object.
* \param beacon the data to use to write the beacon.
- * \param type the beacon type.
*/
static void
-bsu_beacon_write_variant_fields (pb_beacon_t *phy_beacon,
- bitstream_t *stream,
- mac_config_t *mac_config,
- bsu_beacon_t *beacon,
- bsu_beacon_type_t type)
+bsu_beacon_write_variant_fields_without_nid (
+ bitstream_t *stream, bsu_beacon_t *beacon)
{
- phy_beacon->first_data_word = beacon->vf.nid;
- bitstream_write (stream, beacon->vf.nid >> 32, 22);
bitstream_write (stream, beacon->vf.hm, 2);
- bitstream_write (stream, mac_config->tei, 8);
- bitstream_write (stream, type, 3);
+ bitstream_write (stream, beacon->vf.stei, 8);
+ bitstream_write (stream, beacon->vf.bt, 3);
bitstream_write (stream, beacon->vf.ncnr, 1);
bitstream_write (stream, beacon->vf.npsm, 1);
bitstream_write (stream, beacon->vf.numslots, 3);
@@ -115,6 +108,21 @@ bsu_beacon_write_variant_fields (pb_beacon_t *phy_beacon,
}
/**
+ * Write the beacon variant fields.
+ * \param phy_beacon the beacon bloc.
+ * \param stream the bitstream context.
+ * \param beacon the data to use to write the beacon.
+ */
+static void
+bsu_beacon_write_variant_fields (
+ pb_beacon_t *phy_beacon, bitstream_t *stream, bsu_beacon_t *beacon)
+{
+ phy_beacon->first_data_word = beacon->vf.nid;
+ bitstream_write (stream, beacon->vf.nid >> 32, 22);
+ bsu_beacon_write_variant_fields_without_nid (stream, beacon);
+}
+
+/**
* Write the regions entries in the beacon.
* \param stream the bitstream context.
* \param region the region bentry.
@@ -265,7 +273,7 @@ bsu_beacon_write_bmi_discover (bitstream_t *stream,
bsu_beacon_bmi_discover_t *discover,
bsu_beacon_type_t type)
{
- if (discover->present && type == BSU_BEACON_TYPE_CENTRAL)
+ if (discover->present)
{
bitstream_write (stream, BSU_BEACON_ENTRY_HEADER_DISCOVER, 8);
bitstream_write (stream, BSU_BEACON_ENTRY_SIZE_DISCOVER, 8);
@@ -459,43 +467,38 @@ bsu_beacon_write_bmi_change_snid (bitstream_t *stream,
/**
* Write the Mac address beacon entry.
* \param stream the bitstream context.
- * \param mac_config the mac config object.
* \param mac the beacon entry to store in the beacon.
*/
static void
bsu_beacon_write_bmi_mac_address (bitstream_t *stream,
- mac_config_t *mac_config,
bsu_beacon_bmi_mac_address_t *mac)
{
if (mac->present)
{
bitstream_write (stream, BSU_BEACON_ENTRY_HEADER_MAC_ADDRESS, 8);
bitstream_write (stream, BSU_BEACON_ENTRY_SIZE_MAC_ADDRESS, 8);
- bitstream_write_large (stream, mac_config->sta_mac_address, 48);
+ bitstream_write_large (stream, mac->mac_address, 48);
}
}
/**
* Compute the number of beacon entries are present in the beacon.
* \param beacon the beacon data to store in the beacon.
- * \param type the beacon type.
- * \param mac_config the MAC configuration structure to get the TEI.
* \return the number of Beacon entries present in the beacon.
*/
static inline uint
-bsu_beacon_write_nbe_nb (bsu_beacon_t *beacon, bsu_beacon_type_t type,
- mac_config_t *mac_config)
+bsu_beacon_write_nbe_nb (bsu_beacon_t *beacon)
{
uint nbe = 1;
dbg_assert (beacon->bmis.region.nb);
- dbg_assert ((type == BSU_BEACON_TYPE_DISCOVER &&
+ dbg_assert ((beacon->vf.bt == BSU_BEACON_TYPE_DISCOVER &&
beacon->bmis.discover_info.present)
- || type != BSU_BEACON_TYPE_DISCOVER);
- dbg_assert ((type == BSU_BEACON_TYPE_CENTRAL
- && ((mac_config->tei == beacon->bmis.discover.tei
+ || beacon->vf.bt != BSU_BEACON_TYPE_DISCOVER);
+ dbg_assert ((beacon->vf.bt == BSU_BEACON_TYPE_CENTRAL
+ && ((beacon->vf.stei == beacon->bmis.discover.tei
&& beacon->bmis.discover_info.present)
- || mac_config->tei != beacon->bmis.discover.tei))
- || type != BSU_BEACON_TYPE_CENTRAL);
+ || beacon->vf.stei != beacon->bmis.discover.tei))
+ || beacon->vf.bt != BSU_BEACON_TYPE_CENTRAL);
dbg_assert ((beacon->vf.nm == BSU_BEACON_NM_CSMA_ONLY &&
beacon->bmis.bpsto.present)
|| (beacon->vf.nm != BSU_BEACON_NM_CSMA_ONLY &&
@@ -503,7 +506,7 @@ bsu_beacon_write_nbe_nb (bsu_beacon_t *beacon, bsu_beacon_type_t type,
if (beacon->bmis.ps.nb)
nbe += beacon->bmis.ps.nb;
nbe += beacon->bmis.nps.ns ? 1 : 0;
- if (beacon->bmis.discover.present && type == BSU_BEACON_TYPE_CENTRAL)
+ if (beacon->bmis.discover.present)
nbe++;
if (beacon->bmis.bpsto.present)
nbe++;
@@ -528,6 +531,64 @@ bsu_beacon_write_nbe_nb (bsu_beacon_t *beacon, bsu_beacon_type_t type,
return nbe;
}
+/**
+ * Write the NBE and the beacon entries using the bitstream library.
+ * \param beacon the bsu beacon containing the data.
+ * \param stream the bitstream (initialized) to store data.
+ * \param data the address of the begining of the data in the pb beacon.
+ * \return the btpsto offset.
+ */
+static uint
+bsu_beacon_write_beacon_entries (bsu_beacon_t *beacon, bitstream_t *stream,
+ u8 *data)
+{
+ uint offset;
+ uint nbe = bsu_beacon_write_nbe_nb (beacon);
+ dbg_assert (nbe);
+ bitstream_write (stream, nbe, 8);
+ bsu_beacon_write_bmi_non_persistent (stream, &beacon->bmis.nps,
+ data);
+ bsu_beacon_write_bmi_persistent (stream, &beacon->bmis.ps,
+ data);
+ bsu_beacon_write_bmi_region (stream, &beacon->bmis.region);
+ bsu_beacon_write_bmi_mac_address (
+ stream, &beacon->bmis.mac_address_present);
+ bsu_beacon_write_bmi_discover (
+ stream, &beacon->bmis.discover, beacon->vf.bt);
+ bsu_beacon_write_bmi_discover_info (stream,
+ &beacon->bmis.discover_info);
+ offset = bsu_beacon_write_bmi_bpsto (stream,
+ &beacon->bmis.bpsto);
+ bsu_beacon_write_bmi_eks (stream, &beacon->bmis.eks);
+ bsu_beacon_write_bmi_handover (stream, &beacon->bmis.handover);
+ bsu_beacon_write_bmi_relocation (stream,
+ &beacon->bmis.relocation);
+ bsu_beacon_write_bmi_aclsc (stream, &beacon->bmis.aclsc);
+ bsu_beacon_write_bmi_change_num_slot (stream,
+ &beacon->bmis.cns);
+ bsu_beacon_write_bmi_change_hm (stream,
+ &beacon->bmis.change_hm);
+ bsu_beacon_write_bmi_change_snid (stream,
+ &beacon->bmis.change_snid);
+ return offset;
+}
+
+uint
+bsu_beacon_write_bitstream_initialised_no_nid (
+ bsu_beacon_t *beacon, bitstream_t *stream, u8 *data)
+{
+ bsu_beacon_write_variant_fields_without_nid (stream, beacon);
+ return bsu_beacon_write_beacon_entries (beacon, stream, data);
+}
+
+uint
+bsu_beacon_write_bitstream_initialised (
+ bsu_beacon_t *beacon, bitstream_t *stream, pb_beacon_t *pbbeacon)
+{
+ bsu_beacon_write_variant_fields (pbbeacon, stream, beacon);
+ return bsu_beacon_write_beacon_entries (beacon, stream, pbbeacon->data);
+}
+
pb_beacon_t*
bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
mac_config_t *mac_config, pbproc_tx_beacon_params_t *params)
@@ -539,37 +600,13 @@ bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
dbg_assert (type < BSU_BEACON_TYPE_NB);
dbg_assert (mac_config);
dbg_assert (params);
+ beacon->vf.bt = type;
+ beacon->vf.stei = mac_config->tei;
/* Allocate the beacon. */
pbbeacon = (pb_beacon_t *) blk_alloc_desc ();
bitstream_write_init (&stream, pbbeacon->data, BSU_BEACON_SIZE);
- bsu_beacon_write_variant_fields (
- pbbeacon, &stream, mac_config, beacon, type);
- uint nbe = bsu_beacon_write_nbe_nb (beacon, type, mac_config);
- dbg_assert (nbe);
- bitstream_write (&stream, nbe, 8);
- bsu_beacon_write_bmi_non_persistent (&stream, &beacon->bmis.nps,
- pbbeacon->data);
- bsu_beacon_write_bmi_persistent (&stream, &beacon->bmis.ps,
- pbbeacon->data);
- bsu_beacon_write_bmi_region (&stream, &beacon->bmis.region);
- bsu_beacon_write_bmi_mac_address (&stream, mac_config,
- &beacon->bmis.mac_address_present);
- bsu_beacon_write_bmi_discover (&stream, &beacon->bmis.discover, type);
- bsu_beacon_write_bmi_discover_info (&stream,
- &beacon->bmis.discover_info);
- offset = bsu_beacon_write_bmi_bpsto (&stream,
- &beacon->bmis.bpsto);
- bsu_beacon_write_bmi_eks (&stream, &beacon->bmis.eks);
- bsu_beacon_write_bmi_handover (&stream, &beacon->bmis.handover);
- bsu_beacon_write_bmi_relocation (&stream,
- &beacon->bmis.relocation);
- bsu_beacon_write_bmi_aclsc (&stream, &beacon->bmis.aclsc);
- bsu_beacon_write_bmi_change_num_slot (&stream,
- &beacon->bmis.cns);
- bsu_beacon_write_bmi_change_hm (&stream,
- &beacon->bmis.change_hm);
- bsu_beacon_write_bmi_change_snid (&stream,
- &beacon->bmis.change_snid);
+ offset =
+ bsu_beacon_write_bitstream_initialised (beacon, &stream, pbbeacon);
bitstream_finalise (&stream);
if (beacon->bmis.bpsto.present)
params->bpsto = pbbeacon->data + offset;
@@ -583,21 +620,18 @@ bsu_beacon_write (bsu_beacon_t *beacon, bsu_beacon_type_t type,
* \param phy_beacon the beacon received from the medium.
* \param stream the bitstream context.
* \param mac_config the mac config object.
- * \param beacon the data to use to write the beacon.
- * \param type the beacon type.
* \param tei the variable to store the TEI.
* \return true on success, false otherwise.
*/
static bool
bsu_beacon_read_variant_fields (pb_beacon_t *phy_beacon,
bitstream_t *stream,
- bsu_beacon_t *beacon,
- bsu_beacon_type_t *type, u8 *tei)
+ bsu_beacon_t *beacon)
{
beacon->vf.nid = bsu_beacon_read_nid (phy_beacon, stream);
beacon->vf.hm = bitstream_read (stream, 2);
- *tei = bitstream_read (stream, 8);
- *type = bitstream_read (stream, 3);
+ beacon->vf.stei = bitstream_read (stream, 8);
+ beacon->vf.bt = bitstream_read (stream, 3);
beacon->vf.ncnr = bitstream_read (stream, 1);
beacon->vf.npsm = bitstream_read (stream, 1);
beacon->vf.numslots = bitstream_read (stream, 3);
@@ -609,7 +643,7 @@ bsu_beacon_read_variant_fields (pb_beacon_t *phy_beacon,
beacon->vf.nm = bitstream_read (stream, 2);
beacon->vf.ccocap = bitstream_read (stream, 2);
bitstream_skip (stream, 4);
- if ((*type < BSU_BEACON_TYPE_NB)
+ if ((beacon->vf.bt < BSU_BEACON_TYPE_NB)
&& (beacon->vf.nm < BSU_BEACON_NM_NB)
&& HPAV_NID_IS_VALID (beacon->vf.nid))
return true;
@@ -726,14 +760,14 @@ bsu_beacon_read_bmi_region (bitstream_t *bitstream,
/**
* Read the beacon mac address entry.
* \param bitstream the bitstream context.
- * \param mac_address to store data,
- * \return true on success, false otherwise.
+ * \param mac_address beacon entry,
*/
-static bool
-bsu_beacon_read_bmi_mac_address (bitstream_t *bitstream, mac_t *mac_address)
+static void
+bsu_beacon_read_bmi_mac_address (
+ bitstream_t *bitstream, bsu_beacon_bmi_mac_address_t *mac_address)
{
- *mac_address = bitstream_read_large (bitstream, 48);
- return MAC_IS_VALID (*mac_address);
+ mac_address->mac_address = bitstream_read_large (bitstream, 48);
+ mac_address->present = MAC_IS_VALID (mac_address->mac_address);
}
/**
@@ -871,8 +905,7 @@ bsu_beacon_read_bmi_change_num_slot (bitstream_t *stream,
}
bool
-bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
- bsu_beacon_type_t *type, u8 *tei, mac_t *mac_address)
+bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon)
{
bitstream_t stream;
int nb_persistent = 0;
@@ -887,8 +920,7 @@ bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
/* Initialise the data needed for the job. */
bsu_beacon_reset (beacon);
bitstream_read_init (&stream, pbbeacon->data, BSU_BEACON_SIZE);
- ok = bsu_beacon_read_variant_fields (
- pbbeacon, &stream, beacon, type, tei);
+ ok = bsu_beacon_read_variant_fields (pbbeacon, &stream, beacon);
beacon->bmis.nbe = bitstream_read (&stream, 8);
// Processing beacon entries.
for (nbe = 0; ok && nbe < beacon->bmis.nbe; nbe++)
@@ -911,8 +943,8 @@ bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
&stream, &beacon->bmis.ps.ps[nb_persistent++]);
break;
case BSU_BEACON_ENTRY_HEADER_MAC_ADDRESS:
- ok = bsu_beacon_read_bmi_mac_address (&stream, mac_address);
- beacon->bmis.mac_address_present.present = ok;
+ bsu_beacon_read_bmi_mac_address (
+ &stream, &beacon->bmis.mac_address_present);
break;
case BSU_BEACON_ENTRY_HEADER_DISCOVER:
bsu_beacon_read_bmi_discover (
@@ -965,7 +997,7 @@ bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
/* If the beacon seams still ok check if the mandatory fields are
* present. */
if (ok
- && !((*type == BSU_BEACON_TYPE_CENTRAL)
+ && !((beacon->vf.bt == BSU_BEACON_TYPE_CENTRAL)
&& (beacon->bmis.region.nb != 0)
&& (beacon->bmis.nps.ns != 0 || beacon->bmis.ps.nb != 0)
&& (((beacon->vf.nm == BSU_BEACON_NM_CSMA_ONLY)
@@ -974,12 +1006,12 @@ bsu_beacon_read (pb_beacon_t *pbbeacon, bsu_beacon_t *beacon,
&& (((beacon->vf.hoip == true)
&& (beacon->bmis.handover.present == true))
|| (beacon->vf.hoip == false)))
- && !((*type == BSU_BEACON_TYPE_DISCOVER)
+ && !((beacon->vf.bt == BSU_BEACON_TYPE_DISCOVER)
&& (beacon->bmis.region.nb != 0)
&& (beacon->bmis.mac_address_present.present == true)
&& (beacon->bmis.discover_info.present == true)
&& (beacon->bmis.bpsto.present == true))
- && !((*type == BSU_BEACON_TYPE_PROXY)
+ && !((beacon->vf.bt == BSU_BEACON_TYPE_PROXY)
&& (beacon->bmis.bpsto.present == true)))
ok = false;
return ok;
diff --git a/cesar/bsu/bsu.h b/cesar/bsu/bsu.h
index 19d50eb06b..2b4649e8ea 100644
--- a/cesar/bsu/bsu.h
+++ b/cesar/bsu/bsu.h
@@ -35,38 +35,14 @@ enum bsu_update_sta_type_t
};
typedef enum bsu_update_sta_type_t bsu_update_sta_type_t;
-enum bsu_beacon_direction_t
-{
- BSU_BEACON_DIRECTION_TO_PLC,
- BSU_BEACON_DIRECTION_FROM_PLC,
- BSU_BEACON_DIRECTION_NB
-};
-typedef enum bsu_beacon_direction_t bsu_beacon_direction_t;
-
-/** BSU computed parameters. */
-struct bsu_params_t
-{
- /** Pbproc RX parameters. */
- pbproc_rx_beacon_params_t rx_parameters;
- /** Direction */
- bsu_beacon_direction_t direction;
- /** Frequency error. */
- s32 frequency_error;
- /** Tick offset, difference between the NTB and PHY Date clock. */
- u32 ntb_offset_tck;
-};
-typedef struct bsu_params_t bsu_params_t;
-
/** Function to call on beacon reception or beacon sending.
* \param ctx upper layer context.
* \param beacon the beacon sent or received.
- * \param bparams the BSU computed data.
* \warn the upper layer is responsible for releasing the reference on the
* beacon.
*/
typedef void
-(*bsu_beacon_processed_t) (void *ctx, pb_beacon_t *beacon,
- bsu_params_t *bparams);
+(*bsu_beacon_processed_t) (void *ctx, bsu_beacon_t *beacon);
BEGIN_DECLS
diff --git a/cesar/bsu/inc/interface.h b/cesar/bsu/inc/interface.h
index 1f5af18ee0..9d49f19d94 100644
--- a/cesar/bsu/inc/interface.h
+++ b/cesar/bsu/inc/interface.h
@@ -16,6 +16,18 @@
BEGIN_DECLS
/**
+ * Send a copy of the beacon to the upper layer.
+ * \param ctx the module context.
+ * \param beacon the beacon structure to fill.
+ * \param direction the reception or transmission.
+ * \param avln structure to get the beacon.
+ */
+void
+bsu_beacon_send_upper_layer (
+ bsu_t *ctx, bsu_beacon_direction_t direction,
+ bsu_beacon_t *beacon, bsu_avln_t *avln);
+
+/**
* Send a beacon over the medium.
* \param ctx the bsu context.
* \param beacon_type the beacon type to send.
diff --git a/cesar/bsu/inc/trace.h b/cesar/bsu/inc/trace.h
index 0ebe6daccc..a51c66fefc 100644
--- a/cesar/bsu/inc/trace.h
+++ b/cesar/bsu/inc/trace.h
@@ -25,7 +25,7 @@ enum
{
BSU_TRACE_BEACON_PROCESS,
BSU_TRACE_BEACON_DATA,
- BSU_TRACE_BEACON_CRC_ERROR,
+ BSU_TRACE_BEACON_ERROR,
BSU_TRACE_BEACON_SEND,
BSU_TRACE_SCHEDULES,
};
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 65579ca184..cded996ce7 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -580,6 +580,8 @@ bsu_beacon_send_prepare (bsu_t *ctx, bsu_beacon_type_t type,
bitstream_direct_write (&ctx->discover_info.info_data, 0, 0, 1);
/* Send the beacon. */
bsu_beacon_send (ctx, type, beacon, &params);
+ bsu_beacon_send_upper_layer (
+ ctx, BSU_BEACON_DIRECTION_TO_PLC, bsu_beacon, ctx->sta_avln);
}
/**
@@ -754,12 +756,10 @@ bsu_uninit (bsu_t *ctx)
* \param ctx the module context.
* \param beacon the beacon unpacked.
* \param params the RX parameters.
- * \param tei the source TEI.
*/
static inline bsu_avln_t*
bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
- pbproc_rx_beacon_params_t *params,
- u8 tei)
+ pbproc_rx_beacon_params_t *params)
{
u32 i, bts_date, bpsd0;
/* Inform PBProc we received the central beacon. */
@@ -767,6 +767,7 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
ctx->pbproc, params->preamble_date
+ bsu_aclf_beacon_period_tck (ctx->aclf));
ctx->sta_avln->beacon = *beacon;
+ ctx->sta_avln->beacon.params.rx_parameters = *params;
/* NTB synchronisation. */
bsu_ntb_clk_sync (&ctx->sta_avln->sync, ctx->phy,
params->bts, params->preamble_sysdate,
@@ -788,9 +789,10 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
/* Create the CA schedules. */
bsu_ca_schedules__beacon_reception (ctx, ctx->sta_avln);
}
- BSU_TRACE (BEACON_PROCESS, phy_date (), params->snid, tei,
- ctx->sta_avln->sync.ntb_offset_tck,
- FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT));
+ BSU_TRACE (
+ BEACON_PROCESS, phy_date (), params->snid, beacon->vf.stei,
+ ctx->sta_avln->sync.ntb_offset_tck,
+ FIXED (ctx->sta_avln->sync.fe, BSU_NTB_FIXED_POINT));
BSU_TRACE (BEACON_DATA, params->bts, params->bto[0],
params->bto[1], params->bto[2]);
/* A discover beacon had been requested ? */
@@ -807,12 +809,10 @@ bsu_beacon_process__avln_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
* \param ctx the module context.
* \param beacon the beacon unpacked.
* \param params the RX parameters.
- * \param tei the source TEI.
*/
static inline bsu_avln_t*
bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
- pbproc_rx_beacon_params_t *params,
- u8 tei)
+ pbproc_rx_beacon_params_t *params)
{
bool added;
bsu_avln_t *avln = bsu_avln_add (
@@ -828,13 +828,14 @@ bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
for (i = 0; i < HPAV_BEACON_BTO_NB; i++)
avln->bto[i] = params->bto[i];
avln->beacon = *beacon;
+ avln->beacon.params.rx_parameters = *params;
/* NTB synchronisation. */
bsu_ntb_clk_sync (&avln->sync, ctx->phy,
params->bts, params->preamble_sysdate,
params->preamble_date);
avln->beacon.beacon_period_start_date = params->bts -
avln->sync.ntb_offset_tck;
- BSU_TRACE (BEACON_PROCESS, phy_date (), params->snid, tei,
+ BSU_TRACE (BEACON_PROCESS, phy_date (), params->snid, beacon->vf.stei,
avln ? avln->sync.ntb_offset_tck : 0,
avln ? FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT): 0);
BSU_TRACE (BEACON_DATA, params->bts, params->bto[0],
@@ -848,40 +849,32 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
pbproc_rx_beacon_params_t *params)
{
bsu_avln_t *avln = NULL;
- u8 tei;
- bsu_beacon_type_t bt;
bsu_beacon_t bsu_beacon;
- mac_t mac_address;
- bool valid;
dbg_assert (ctx);
dbg_assert (beacon);
dbg_assert (params);
/* Check the CRC. */
- valid = !((pb_t *) beacon)->phy_pb.pb_rx.pb_measurement.crc_error
- && bsu_beacon_read (
- beacon, &bsu_beacon, &bt, &tei, &mac_address);
- if (valid)
+ if (bsu_beacon_read (beacon, &bsu_beacon))
{
- ctx->beacon_nb_recv[bt]++;
- if (bt == BSU_BEACON_TYPE_CENTRAL)
+ ctx->beacon_nb_recv[bsu_beacon.vf.bt]++;
+ if (bsu_beacon.vf.bt == BSU_BEACON_TYPE_CENTRAL)
{
/* It the beacon from our AVLN ? */
if (ctx->is_sta == BSU_UPDATE_STA_TYPE_STA
&& ctx->nid_track == bsu_beacon.vf.nid
&& ctx->snid_track == params->snid
- && ctx->tei_track == tei)
+ && ctx->tei_track == bsu_beacon.vf.stei)
avln = bsu_beacon_process__avln_tracked (
- ctx, &bsu_beacon, params, tei);
+ ctx, &bsu_beacon, params);
/* Other AVLN. */
else
avln = bsu_beacon_process__avln_not_tracked (
- ctx, &bsu_beacon, params, tei);
+ ctx, &bsu_beacon, params);
}
}
- if (!valid)
+ else
{
- blk_release_desc ((blk_t*) beacon);
- BSU_TRACE (BEACON_CRC_ERROR, phy_date ());
+ BSU_TRACE (BEACON_ERROR, phy_date ());
return NULL;
}
return avln;
diff --git a/cesar/bsu/src/interface.c b/cesar/bsu/src/interface.c
index 2464f1c857..99c3ce4678 100644
--- a/cesar/bsu/src/interface.c
+++ b/cesar/bsu/src/interface.c
@@ -20,24 +20,18 @@
#include "bsu/inc/bsu.h"
#include "bsu/inc/context.h"
-/**
- * Store the BSU params in the beacon.
- * \param ctx the module context.
- * \param beacon the beacon.
- * \param direction the reception or transmission.
- * \param avln the avln synchronisation data.
- */
-static inline bsu_params_t*
-bsu_params_store (bsu_t *ctx, pb_beacon_t *beacon,
- bsu_beacon_direction_t direction,
- bsu_avln_t *avln)
+void
+bsu_beacon_send_upper_layer (
+ bsu_t *ctx, bsu_beacon_direction_t direction,
+ bsu_beacon_t *beacon, bsu_avln_t *avln)
{
- bsu_params_t *bsu_params =
- (bsu_params_t *) (beacon->data + BSU_BEACON_SIZE);
- bsu_params->direction = direction;
- bsu_params->frequency_error = FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT);
- bsu_params->ntb_offset_tck = avln->sync.ntb_offset_tck;
- return bsu_params;
+ bsu_beacon_t *bsu_beacon = blk_alloc ();
+ *bsu_beacon = avln->beacon;
+ bsu_beacon->params.direction = direction;
+ bsu_beacon->params.frequency_error =
+ FIXED (avln->sync.fe, BSU_NTB_FIXED_POINT);
+ bsu_beacon->params.ntb_offset_tck = avln->sync.ntb_offset_tck;
+ (*ctx->ul_cb) (ctx->ul_data, bsu_beacon);
}
/**
@@ -102,13 +96,8 @@ bsu_beacon_send (bsu_t *ctx, bsu_beacon_type_t beacon_type,
if (beacon_type == BSU_BEACON_TYPE_CENTRAL)
ca_mfs_hold (ctx->ca, mfs);
mfs->cfp = ctx->sta_avln->beacon.vf.hm == MAC_COEXISTENCE_AV_ONLY_MODE;
- blk_addref_desc ((blk_t*) beacon);
/* Provide the beacon to the SAR. */
sar_beacon_send (ctx->sar, beacon, mfs, bto_bpsto);
- /* Send the beacon to the upper layer. */
- bsu_params_t * bsu_params = bsu_params_store (
- ctx, beacon, BSU_BEACON_DIRECTION_TO_PLC, ctx->sta_avln);
- (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
BSU_TRACE (BEACON_SEND, phy_date (), beacon_type);
}
@@ -126,9 +115,8 @@ bsu_beacon_recv (bsu_t *ctx, pb_beacon_t *beacon,
bsu_avln_t *avln = bsu_beacon_process (ctx, beacon, params);
if (avln)
{
- /* Send it to the upper layer. */
- bsu_params_t * bsu_params = bsu_params_store (
- ctx, beacon, BSU_BEACON_DIRECTION_FROM_PLC, avln);
- (*ctx->ul_cb) (ctx->ul_data, beacon, bsu_params);
+ bsu_beacon_send_upper_layer (
+ ctx, BSU_BEACON_DIRECTION_FROM_PLC, &avln->beacon, avln);
}
+ blk_release_desc ((blk_t*) beacon);
}
diff --git a/cesar/bsu/src/trace.c b/cesar/bsu/src/trace.c
index 842397071b..fbdc88a440 100644
--- a/cesar/bsu/src/trace.c
+++ b/cesar/bsu/src/trace.c
@@ -25,7 +25,7 @@ bsu_trace_init (bsu_t *ctx)
TIMESTAMP),
TRACE_EVENT (BSU_TRACE_BEACON_DATA, "bts %x bto %x %x %x"),
- TRACE_EVENT (BSU_TRACE_BEACON_CRC_ERROR, "Beacon crc error",
+ TRACE_EVENT (BSU_TRACE_BEACON_ERROR, "Beacon received has errors",
TIMESTAMP),
TRACE_EVENT (BSU_TRACE_BEACON_SEND, "Beacon send type %d", TIMESTAMP),
TRACE_EVENT (BSU_TRACE_SCHEDULES, "b0 date=%x b1 date=%x b2 date=%x"),
diff --git a/cesar/bsu/test/utest/src/bsu.c b/cesar/bsu/test/utest/src/bsu.c
index 0a8f78e0ab..af2762b5ab 100644
--- a/cesar/bsu/test/utest/src/bsu.c
+++ b/cesar/bsu/test/utest/src/bsu.c
@@ -39,4 +39,3 @@ main (int argc, char **argv)
test_result (test);
return test_nb_failed (test) == 0 ? 0 : 1;
}
-
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index 948c1d699d..57bcd23009 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -61,6 +61,7 @@ test_case_bsu_process (test_t test)
&bpneighbour_tx);
bneighbour->phy_pb.pb_rx.pb_measurement.crc_error = true;
bsu_beacon_process (t.bsu, bneighbour, &bpneighbour_rx);
+ blk_release_desc ((blk_t*) bneighbour);
/* Central beacon processed ? */
test_fail_unless (t.bsu->avlns[0].snid == 0);
test_fail_unless (t.bsu->avlns[0].beacon.vf.nid == 0);
@@ -107,6 +108,7 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.bsu->sta_avln->beacon.vf.nid == t.bsu->nid_track);
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 2);
+ blk_release_desc ((blk_t*) b);
/* NTB called ? */
test_fail_unless (t.bsu->sta_avln->sync.init == false);
bp_rx.snid = 0x4;
@@ -155,10 +157,10 @@ test_case_bsu_process (test_t test)
test_fail_unless (t.bsu->beacon_nb_recv [BSU_BEACON_TYPE_CENTRAL]
== 5);
/* Upper layer receives it ? */
- test_fail_unless (t.ul.beacon == t.sar.beacon);
+ test_fail_unless (t.ul.beacon);
test_fail_unless (t.ul.beacon->next);
- blk_release_desc ((blk_t*) t.ul.beacon->next);
- blk_release_desc ((blk_t*) t.ul.beacon);
+ blk_release ((blk_t*) t.ul.beacon->next);
+ blk_release ((blk_t*) t.ul.beacon);
}
test_end;
test_begin (test, "Discover beacon: associated do not track discover")
@@ -213,6 +215,7 @@ test_case_bsu_process (test_t test)
test_fail_unless (avln == NULL);
avln = bsu_avln_get (t.bsu, 0x3, 0x4);
test_fail_unless (avln == NULL);
+ blk_release_desc ((blk_t*) beacon);
/* Our AVLN. */
beacon = (pb_beacon_t*) blk_alloc_desc ();
memset (beacon->data, 0, BLK_SIZE);
@@ -226,6 +229,7 @@ test_case_bsu_process (test_t test)
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
avln = bsu_beacon_process (t.bsu, beacon, &bp_rx);
test_fail_unless (avln == NULL);
+ blk_release_desc ((blk_t*) beacon);
}
test_end;
bsu_test_uninit (&t);
@@ -411,10 +415,9 @@ test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
cmp_avln.beacon.vf.nm = BSU_BEACON_NM_UNCOORDINATED;
bsu_timer_event_process (t->bsu);
test_fail_unless (t->ul.beacon != INVALID_PTR);
- test_fail_unless (t->ul.bparams != INVALID_PTR);
test_fail_unless (t->ul.beacon->next == NULL);
/* Release the reference handled by the CP. */
- blk_release_desc ((blk_t*) t->ul.beacon);
+ blk_release (t->ul.beacon);
mfs = mac_store_mfs_get (t->mac_store, true, true, false,
lid, MAC_TEI_BCAST);
mfs->tx.head = NULL;
@@ -431,8 +434,7 @@ test_case_bsu_timer_event_cco_ucco (test_t test, bsu_test_t *t,
bsu_avln_schedules_decrease_countdown (t->bsu, &cmp_avln);
bsu_timer_event_process (t->bsu);
test_fail_unless (t->ul.beacon != INVALID_PTR);
- test_fail_unless (t->ul.bparams != INVALID_PTR);
- blk_release_desc ((blk_t*) t->ul.beacon);
+ blk_release (t->ul.beacon);
for (j = 0; j < cmp_avln.beacon.bmis.ps.nb; j++)
{
test_fail_unless (cmp_avln.beacon.bmis.ps.ps[j].pscd
@@ -519,8 +521,8 @@ test_case_bsu_timer_event (test_t test)
bsu_timer_event_process (t.bsu);
test_fail_unless (t.ul.beacon);
test_fail_unless (t.ul.beacon->next);
- blk_release_desc ((blk_t*) t.ul.beacon->next);
- blk_release_desc ((blk_t*) t.ul.beacon);
+ blk_release (t.ul.beacon->next);
+ blk_release (t.ul.beacon);
mfs = mac_store_mfs_get (t.mac_store, true, true, false,
MAC_LID_SPC_CENTRAL, MAC_TEI_BCAST);
test_fail_unless (mfs != NULL);
diff --git a/cesar/bsu/test/utest/src/interface.c b/cesar/bsu/test/utest/src/interface.c
index f9d07fe40e..b39aed9da5 100644
--- a/cesar/bsu/test/utest/src/interface.c
+++ b/cesar/bsu/test/utest/src/interface.c
@@ -59,22 +59,10 @@ test_case_bsu_interface_tx (test_t t, bsu_beacon_type_t type)
test.bsu->avlns[0].sync.fe = 0.34;
test.bsu->sta_avln = &test.bsu->avlns[0];
bsu_beacon_send (test.bsu, type, beacon, &params);
- test_fail_unless (test.sar.beacon == beacon);
- test_fail_unless (test.sar.mfs->beacon == true);
if (type == BSU_BEACON_TYPE_CENTRAL)
test_fail_unless (test.sar.mfs->cap == 0x3);
else
test_fail_unless (test.sar.mfs->cap == 0x2);
- test_fail_unless (test.ul.beacon == beacon);
- test_fail_unless (test.ul.bparams->direction
- == BSU_BEACON_DIRECTION_TO_PLC);
- test_fail_unless (test.ul.bparams->frequency_error
- == FIXED(test.bsu->avlns[0].sync.fe,
- BSU_NTB_FIXED_POINT));
- test_fail_unless (test.ul.bparams->ntb_offset_tck
- == test.bsu->avlns[0].sync.ntb_offset_tck);
- /* Free the beacon. */
- blk_release_desc ((blk_t*) beacon);
/* Remove the MFS from the store. */
mac_store_mfs_remove (test.mac_store,
PARENT_OF (mfs_t, tx, test.sar.mfs));
@@ -107,22 +95,26 @@ test_case_bsu_interface_rx (test_t t)
beacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
rx_params.snid = 0x1;
bsu_beacon_recv (test.bsu, beacon, &rx_params);
- test_fail_unless (test.ul.beacon == beacon);
- test_fail_unless (test.ul.bparams->direction
+ test_fail_unless (test.ul.beacon != INVALID_PTR);
+ test_fail_unless (test.ul.beacon->params.direction
== BSU_BEACON_DIRECTION_FROM_PLC);
bsu_avln_t *avln = bsu_avln_get (test.bsu, bbeacon.vf.nid,
rx_params.snid);
test_fail_unless (avln != NULL);
- test_fail_unless (test.ul.bparams->frequency_error
+ test_fail_unless (test.ul.beacon->params.frequency_error
== FIXED(avln->sync.fe,
BSU_NTB_FIXED_POINT));
- test_fail_unless (test.ul.bparams->ntb_offset_tck
+ test_fail_unless (test.ul.beacon->params.ntb_offset_tck
== avln->sync.ntb_offset_tck);
- memset (&test.ul, 0, sizeof (bsu_test_ul_t));
+ blk_release (test.ul.beacon);
+ bsu_test_upper_layer_beacon_received_init (&test);
+ beacon = bsu_beacon_write (&bbeacon,
+ BSU_BEACON_TYPE_CENTRAL,
+ &test.mac_config,
+ &tx_params);
beacon->phy_pb.pb_rx.pb_measurement.crc_error = true;
bsu_beacon_recv (test.bsu, beacon, &rx_params);
- test_fail_unless (test.ul.beacon == NULL);
- test_fail_unless (test.ul.bparams == NULL);
+ test_fail_unless (test.ul.beacon == INVALID_PTR);
bsu_test_uninit (&test);
}
test_end;
diff --git a/cesar/bsu/test/utest/src/sar.c b/cesar/bsu/test/utest/src/sar.c
index ed46c08b58..ab6988d161 100644
--- a/cesar/bsu/test/utest/src/sar.c
+++ b/cesar/bsu/test/utest/src/sar.c
@@ -23,7 +23,6 @@ sar_beacon_send (sar_t *sar, pb_beacon_t *beacon, mfs_tx_t *beacon_mfs,
ctx->sar.beacon = beacon;
ctx->sar.mfs = beacon_mfs;
ctx->sar.bto_bpsto = bto_bpsto;
- /* release the beacon. */
blk_release_desc ((blk_t*) beacon);
}
diff --git a/cesar/bsu/test/utest/src/schedules.c b/cesar/bsu/test/utest/src/schedules.c
index a4beaa8d22..5aaa217f20 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -164,10 +164,8 @@ test_case_bsu_schedules_countdowns (test_t t)
bparamsrx.snid = 0;
pbbeacon->phy_pb.pb_rx.pb_measurement.crc_error = false;
bsu_beacon_recv (ctx.bsu, pbbeacon, &bparamsrx);
- /* Clear memory. */
- blk_release_desc ((blk_t*) pbbeacon);
- ctx.ul.beacon = INVALID_PTR;
- ctx.ul.bparams = NULL;
+ blk_release (ctx.ul.beacon);
+ bsu_test_upper_layer_beacon_received_init (&ctx);
/* Continue the test. */
bsu_track_avln (beacon.vf.nid, 0x0, ctx.mac_config.tei);
ctx.bsu->track_new = false;
@@ -206,6 +204,8 @@ test_case_bsu_schedules_countdowns (test_t t)
/* On beacon reception only schedules are read and CA is
* programmed with the current data. */
bsu_beacon_recv (ctx.bsu, b, &bparamsrx);
+ blk_release (ctx.ul.beacon);
+ bsu_test_upper_layer_beacon_received_init (&ctx);
}
/* On timer event the snid change, NEK and hybrid mode are changed
* in the lower layers. */
@@ -227,12 +227,6 @@ test_case_bsu_schedules_countdowns (test_t t)
}
cas[0] = cas[1];
cas[1] = cas[2];
- if (i != 1)
- {
- /* Release beacon. */
- blk_release_desc ((blk_t*) ctx.ul.beacon);
- ctx.ul.beacon = INVALID_PTR;
- }
beacon.bmis.change_snid.snidccd --;
beacon.bmis.change_snid.present =
beacon.bmis.change_snid.snidccd != 0;
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index deb64ad81c..58011eb76c 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -27,8 +27,7 @@ bsu_trace_buffer_dbg_dump_callback (void *user, const char *text,
static void
-bsu_test_upper_layer_beacon_received (void *ctx, pb_beacon_t *beacon,
- bsu_params_t *bparams)
+bsu_test_upper_layer_beacon_received (void *ctx, bsu_beacon_t *beacon)
{
bsu_test_t *test = (bsu_test_t*) ctx;
dbg_assert (ctx);
@@ -37,7 +36,6 @@ bsu_test_upper_layer_beacon_received (void *ctx, pb_beacon_t *beacon,
test->ul.beacon = beacon;
else
test->ul.beacon->next = beacon;
- test->ul.bparams = bparams;
}
void
@@ -45,7 +43,6 @@ bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx)
{
dbg_assert (ctx);
ctx->ul.beacon = INVALID_PTR;
- ctx->ul.bparams = INVALID_PTR;
}
void
@@ -147,7 +144,6 @@ bsu_test_create_beacon (bsu_test_t *ctx, bsu_beacon_t *beacon)
beacon->vf.rtsbf = false;
beacon->vf.nm = BSU_BEACON_NM_CSMA_ONLY;
beacon->vf.ccocap = 0;
- beacon->vf.rsvd = 0;
/* Regions. */
beacon->bmis.region.nb = 2;
beacon->bmis.region.region[0].rt = BSU_BEACON_REGION_BEACON;
@@ -199,6 +195,7 @@ bsu_test_create_beacon (bsu_test_t *ctx, bsu_beacon_t *beacon)
beacon->bmis.change_snid.new_snid = 0xf;
/* Mac address. */
beacon->bmis.mac_address_present.present = true;
+ beacon->bmis.mac_address_present.mac_address = 0x123456789abcull;
/* Number of beacon entries. */
beacon->bmis.nbe = 14;
}
diff --git a/cesar/bsu/test/utest/tests.h b/cesar/bsu/test/utest/tests.h
index ff59576c09..aa5c9be8b0 100644
--- a/cesar/bsu/test/utest/tests.h
+++ b/cesar/bsu/test/utest/tests.h
@@ -51,9 +51,7 @@ typedef struct bsu_test_sar_t bsu_test_sar_t;
struct bsu_test_ul_t
{
/** Beacon sent. */
- pb_beacon_t *beacon;
- /** BSU beacon params. */
- bsu_params_t *bparams;
+ bsu_beacon_t *beacon;
};
typedef struct bsu_test_ul_t bsu_test_ul_t;