summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-02-08 17:49:20 +0100
committerNélio Laranjeiro2011-02-18 17:23:41 +0100
commit2d33ff1894ffcd08101906487225b08a98322ab1 (patch)
tree6da5d25231b1a7c9cf38582a9510da091b2483a0
parent1ae60d57b5adde2aa916b10bf3970ef61eb92b04 (diff)
cesar/{cp, bsu}: add CCo's mac address to track on it too, refs #2235
BSU will track on CCo's mac address if the CCo provides it in the central beacon. If the CCo does not provide it, MAC_ZERO should be used to inform BSU to not filter on this field.
-rw-r--r--cesar/bsu/bsu.h6
-rw-r--r--cesar/bsu/inc/context.h5
-rw-r--r--cesar/bsu/src/bsu.c110
-rw-r--r--cesar/bsu/stub/src/bsu.c8
-rw-r--r--cesar/bsu/test/utest/src/bsut.c26
-rw-r--r--cesar/bsu/test/utest/src/interface.c8
-rw-r--r--cesar/bsu/test/utest/src/schedules.c128
-rw-r--r--cesar/bsu/test/utest/src/tests.c14
-rw-r--r--cesar/bsu/test/utest/tests.h5
-rw-r--r--cesar/cp/beacon/src/beacon.c4
-rw-r--r--cesar/cp/sta/mgr/src/sta_mgr.c15
11 files changed, 241 insertions, 88 deletions
diff --git a/cesar/bsu/bsu.h b/cesar/bsu/bsu.h
index eaaab8a4b7..013f44de84 100644
--- a/cesar/bsu/bsu.h
+++ b/cesar/bsu/bsu.h
@@ -91,9 +91,10 @@ bsu_update (bsu_beacon_t *beacon, bsu_update_sta_type_t sta);
* \param nid the NID to track.
* \param snid the SNID to track.
* \param tei the TEI to track.
+ * \param mac the CCo's mac address if present, MAC_ZERO otherwise.
*/
void
-bsu_track_avln (u64 nid, u16 snid, u8 tei);
+bsu_track_avln (u64 nid, u16 snid, u8 tei, mac_t mac);
/**
* Un-track an AVLN.
@@ -149,11 +150,12 @@ bsu_update_nid (u64 nid);
* Remove an AVLN.
* \param nid the NID of the AVLN.
* \param snid the SNID of the AVLN.
+ * \param mac the CCo's mac address.
*
* The AVLNs are static object do not release it.
*/
void
-bsu_avln_remove (u64 nid, u8 snid);
+bsu_avln_remove (u64 nid, u8 snid, mac_t mac);
END_DECLS
diff --git a/cesar/bsu/inc/context.h b/cesar/bsu/inc/context.h
index 7a0000c9ce..84edc094e5 100644
--- a/cesar/bsu/inc/context.h
+++ b/cesar/bsu/inc/context.h
@@ -57,6 +57,8 @@ struct bsu_avln_t
s16 bto [HPAV_BEACON_BTO_NB];
/** SNID. */
u8 snid;
+ /** CCo's Mac address. */
+ mac_t cco_mac_address;
};
struct bsu_t
@@ -93,6 +95,9 @@ struct bsu_t
u8 snid_track;
/** TEI to track. */
u8 tei_track;
+ /** Mac address of the CCo the station tracks.
+ * Zero if the CCo does not provide the mac address in the central beacon. */
+ mac_t cco_mac_address_track;
/** Track a new AVLN. */
bool track_new;
/** CA schedule index. */
diff --git a/cesar/bsu/src/bsu.c b/cesar/bsu/src/bsu.c
index 127447c336..1190b4afb5 100644
--- a/cesar/bsu/src/bsu.c
+++ b/cesar/bsu/src/bsu.c
@@ -102,21 +102,59 @@ bsu_reprogram_timer (bsu_t *ctx, u32 date)
}
/**
+ * Set tracking data.
+ * \param ctx the module context.
+ * \param avln the new AVLN to track.
+ *
+ * \warn providing a NULL AVLN will be considered as untracked.
+ */
+static void
+bsu_track_avln_identify (bsu_t *ctx, bsu_avln_t *avln)
+{
+ bsu_clear_mfs_beacons (ctx);
+ if (avln)
+ {
+ ctx->nid_track = avln->beacon.vf.nid;
+ ctx->snid_track = avln->snid;
+ ctx->tei_track = avln->beacon.vf.stei;
+ ctx->cco_mac_address_track = avln->cco_mac_address;
+ ctx->sta_avln = avln;
+ }
+ else
+ {
+ ctx->nid_track = 0;
+ ctx->snid_track = 0;
+ ctx->tei_track = MAC_TEI_UNASSOCIATED;
+ ctx->cco_mac_address_track = MAC_ZERO;
+ bsu_avln_t *old_avln = ctx->sta_avln;
+ ctx->sta_avln = &ctx->poweron;
+ dbg_assert (!ctx->poweron.sync.init);
+ dbg_assert (ctx->poweron.sync.fe == 0.0);
+ /* When the CCo starts it must keep the ntb offset tck of the network.
+ */
+ ctx->poweron.sync.ntb_offset_tck = old_avln->sync.ntb_offset_tck;
+ }
+ ctx->track_new = true;
+}
+
+/**
* Get the associated AVLN.
* \param ctx the module context.
* \param nid the NID of the AVLN.
* \param snid the SNID of the AVLN.
+ * \param mac the CCo's mac address.
* \return the AVLN object.
*
* The AVLNs are static object do not release it.
*/
-inline bsu_avln_t*
-bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid)
+bsu_avln_t*
+bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid, mac_t mac)
{
uint i;
for (i = 0; i < ctx->avlns_nb; i++)
if (ctx->avlns[i].beacon.vf.nid == nid
- && ctx->avlns[i].snid == snid)
+ && ctx->avlns[i].snid == snid
+ && ctx->avlns[i].cco_mac_address == mac)
return &ctx->avlns[i];
return NULL;
}
@@ -126,22 +164,24 @@ bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid)
* \param ctx the module context.
* \param nid the NID of the AVLN.
* \param snid the SNID of the AVLN.
+ * \param mac the CCo's mac address.
* \param added set true if newly added.
* \return the AVLN object.
*
* The AVLNs are static object do not release it.
*/
inline bsu_avln_t*
-bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, bool *added)
+bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, mac_t mac, bool *added)
{
*added = false;
- bsu_avln_t* avln = bsu_avln_get (ctx, nid, snid);
+ bsu_avln_t* avln = bsu_avln_get (ctx, nid, snid, mac);
if (!avln && ctx->avlns_nb < BSU_FOREIGN_AVLNS_NB)
{
avln = &ctx->avlns[ctx->avlns_nb];
bsu_ntb_init (&avln->sync);
avln->beacon.vf.nid = nid;
avln->snid = snid;
+ avln->cco_mac_address = mac;
avln->beacon.beacon_period_start_date = phy_date ();
ctx->avlns_nb++;
*added = true;
@@ -150,7 +190,7 @@ bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, bool *added)
}
void
-bsu_avln_remove (u64 nid, u8 snid)
+bsu_avln_remove (u64 nid, u8 snid, mac_t mac)
{
bsu_t *ctx = &bsu_global;
bsu_avln_t *to_remove = NULL;
@@ -158,7 +198,8 @@ bsu_avln_remove (u64 nid, u8 snid)
for (i = 0; i < ctx->avlns_nb; i++)
{
if (ctx->avlns[i].beacon.vf.nid == nid
- && ctx->avlns[i].snid == snid)
+ && ctx->avlns[i].snid == snid
+ && ctx->avlns[i].cco_mac_address == mac)
{
to_remove = &ctx->avlns[i];
pos = i;
@@ -168,12 +209,7 @@ bsu_avln_remove (u64 nid, u8 snid)
if (to_remove)
{
if (to_remove == ctx->sta_avln)
- {
- ctx->sta_avln = &ctx->poweron;
- ctx->nid_track = 0;
- ctx->snid_track = 0;
- ctx->tei_track = 0;
- }
+ bsu_track_avln_identify (ctx, NULL);
for (i = pos; i < ctx->avlns_nb - 1; i++)
ctx->avlns[i] = ctx->avlns[i+1];
ctx->avlns_nb--;
@@ -892,7 +928,10 @@ bsu_beacon_process__avln_not_tracked (bsu_t *ctx, bsu_beacon_t *beacon,
{
bool added;
bsu_avln_t *avln = bsu_avln_add (
- ctx, beacon->vf.nid, params->snid, &added);
+ ctx, beacon->vf.nid, params->snid,
+ beacon->bmis.mac_address.present ?
+ beacon->bmis.mac_address.mac_address : MAC_ZERO,
+ &added);
u32 bpsd, i;
bsu_aclf_beacon_period_start_date (ctx->aclf, &bpsd, 1);
/* Other AVLN. */
@@ -937,11 +976,14 @@ bsu_beacon_process (bsu_t *ctx, pb_beacon_t *beacon,
bsu_ca_schedules_nm_csma_only (ctx, bsu_beacon);
if (bsu_beacon->vf.bt == BSU_BEACON_TYPE_CENTRAL)
{
+ mac_t cco_mac = bsu_beacon->bmis.mac_address.present ?
+ bsu_beacon->bmis.mac_address.mac_address: MAC_ZERO;
/* 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 == bsu_beacon->vf.stei)
+ && ctx->tei_track == bsu_beacon->vf.stei
+ && ctx->cco_mac_address_track == cco_mac)
avln = bsu_beacon_process__avln_tracked (
ctx, bsu_beacon, params);
/* Other AVLN. */
@@ -1094,42 +1136,8 @@ bsu_update (bsu_beacon_t *beacon, bsu_update_sta_type_t is_sta)
arch_dsr_unlock ();
}
-/**
- * Set tracking data.
- * \param ctx the module context.
- * \param avln the new AVLN to track.
- *
- * \warn providing a NULL AVLN will be considered as untracked.
- */
-static void
-bsu_track_avln_identify (bsu_t *ctx, bsu_avln_t *avln)
-{
- bsu_clear_mfs_beacons (ctx);
- if (avln)
- {
- ctx->nid_track = avln->beacon.vf.nid;
- ctx->snid_track = avln->snid;
- ctx->tei_track = avln->beacon.vf.stei;
- ctx->sta_avln = avln;
- }
- else
- {
- ctx->nid_track = 0;
- ctx->snid_track = 0;
- ctx->tei_track = MAC_TEI_UNASSOCIATED;
- bsu_avln_t *old_avln = ctx->sta_avln;
- ctx->sta_avln = &ctx->poweron;
- dbg_assert (!ctx->poweron.sync.init);
- dbg_assert (ctx->poweron.sync.fe == 0.0);
- /* When the CCo starts it must keep the ntb offset tck of the network.
- */
- ctx->poweron.sync.ntb_offset_tck = old_avln->sync.ntb_offset_tck;
- }
- ctx->track_new = true;
-}
-
void
-bsu_track_avln (u64 nid, u16 snid, u8 tei)
+bsu_track_avln (u64 nid, u16 snid, u8 tei, mac_t mac)
{
bool added;
bsu_t *ctx = &bsu_global;
@@ -1137,7 +1145,7 @@ bsu_track_avln (u64 nid, u16 snid, u8 tei)
arch_dsr_lock ();
/* Station acts as STA now. */
ctx->is_sta = BSU_UPDATE_STA_TYPE_STA;
- avln = bsu_avln_add (ctx, nid, snid, &added);
+ avln = bsu_avln_add (ctx, nid, snid, mac, &added);
dbg_check (avln);
bsu_track_avln_identify (ctx, avln);
arch_dsr_unlock ();
diff --git a/cesar/bsu/stub/src/bsu.c b/cesar/bsu/stub/src/bsu.c
index ae8f8de630..1791a972b0 100644
--- a/cesar/bsu/stub/src/bsu.c
+++ b/cesar/bsu/stub/src/bsu.c
@@ -32,9 +32,9 @@ bsu_nek_index_next (void)
}
void
-bsu_track_avln (u64 nid, u16 snid, u8 tei)__attribute__ ((weak));
+bsu_track_avln (u64 nid, u16 snid, u8 tei, mac_t mac)__attribute__ ((weak));
-void bsu_track_avln (u64 nid, u16 snid, u8 tei) { }
+void bsu_track_avln (u64 nid, u16 snid, u8 tei, mac_t mac) { }
void
bsu_untrack_avln (void)__attribute__ ((weak));
@@ -68,7 +68,7 @@ void
bsu_update_nid (u64 nid) {}
void
-bsu_avln_remove (u64 nid, u8 snid) __attribute__ ((weak));
+bsu_avln_remove (u64 nid, u8 snid, mac_t mac) __attribute__ ((weak));
void
-bsu_avln_remove (u64 nid, u8 snid) {}
+bsu_avln_remove (u64 nid, u8 snid, mac_t mac) {}
diff --git a/cesar/bsu/test/utest/src/bsut.c b/cesar/bsu/test/utest/src/bsut.c
index f6e3c169bc..8baa2665ac 100644
--- a/cesar/bsu/test/utest/src/bsut.c
+++ b/cesar/bsu/test/utest/src/bsut.c
@@ -30,9 +30,6 @@ bsu_avln_schedules_decrease_countdown (bsu_t *ctx, bsu_avln_t *avln);
void
bsu_update__persistent_schedules (bsu_t *ctx, bsu_beacon_t *beacon);
-bsu_avln_t*
-bsu_avln_get (bsu_t *ctx, u64 nid, u16 snid);
-
void
test_case_bsu_process (test_t test)
{
@@ -105,7 +102,8 @@ test_case_bsu_process (test_t test)
blk_release (bprocessed);
/* Our AVLN. */
bsu_track_avln (
- beacon_neighbour.vf.nid, 0x4, beacon_neighbour.vf.stei);
+ beacon_neighbour.vf.nid, 0x4, beacon_neighbour.vf.stei,
+ beacon_neighbour.bmis.mac_address.mac_address);
t.bsu->sta_avln->sync.init = false;
bsu_test_create_beacon (&t, &beacon);
b = bsu_beacon_write (&beacon, BSU_BEACON_TYPE_CENTRAL,
@@ -158,7 +156,8 @@ test_case_bsu_process (test_t test)
bsu_beacon_t *bbeacon = bsu_beacon_process (t.bsu, b, &brx);
blk_release (bbeacon);
/* Change MAC config TEI for the test. */
- bsu_track_avln (beacon.vf.nid, brx.snid, t.mac_config.tei);
+ bsu_track_avln (beacon.vf.nid, brx.snid, t.mac_config.tei,
+ beacon.bmis.mac_address.mac_address);
t.mac_config.tei = beacon.bmis.discover.tei;
memset (&t.sar, 0, sizeof (bsu_test_sar_t));
bsu_test_upper_layer_beacon_received_init (&t);
@@ -186,6 +185,7 @@ test_case_bsu_process (test_t test)
t.mac_config.tei = 254;
bsu_update_sta_type_t type [] = { BSU_UPDATE_STA_TYPE_STA,
BSU_UPDATE_STA_TYPE_CCO };
+ bsu_ntb_init (&t.bsu->poweron.sync);
for (i = 0; i < COUNT (type); i++)
{
bsu_update (&beacon, type[i]);
@@ -200,7 +200,9 @@ test_case_bsu_process (test_t test)
t.bsu->sta_avln->beacon.beacon_period_start_date =
phy_date () - BSU_ACLF_BP_50HZ_TCK - 1000;
bsu_beacon_t *bprocessed = bsu_beacon_process (t.bsu, b, &brx);
- bsu_avln_t *avln = bsu_avln_get (t.bsu, beacon.vf.nid, brx.snid);
+ bsu_avln_t *avln = bsu_avln_get (
+ t.bsu, beacon.vf.nid, brx.snid,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (bprocessed);
test_fail_unless (avln == NULL);
blk_release_desc ((blk_t*) b);
@@ -210,14 +212,18 @@ test_case_bsu_process (test_t test)
b->phy_pb.pb_rx.pb_measurement.crc_error = false;
bprocessed = bsu_beacon_process (t.bsu, b, &brx);
test_fail_unless (bprocessed);
- avln = bsu_avln_get (t.bsu, beacon.vf.nid, brx.snid);
+ avln = bsu_avln_get (
+ t.bsu, beacon.vf.nid, brx.snid,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (avln != NULL);
test_fail_unless (avln != t.bsu->sta_avln);
blk_release_desc ((blk_t*) b);
blk_release (bprocessed);
- bsu_track_avln (beacon.vf.nid, brx.snid, 1);
+ bsu_track_avln (beacon.vf.nid, brx.snid, 1,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (avln == t.bsu->sta_avln);
- bsu_avln_remove (beacon.vf.nid, brx.snid);
+ bsu_avln_remove (beacon.vf.nid, brx.snid,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (&t.bsu->poweron == t.bsu->sta_avln);
}
}
@@ -234,7 +240,7 @@ test_case_bsu_process (test_t test)
/* Neighbour AVLN. */
bsu_beacon_t *bbeacon = bsu_beacon_process (t.bsu, beacon, &bp_rx);
test_fail_unless (bbeacon == NULL);
- bsu_avln_t *avln = bsu_avln_get (t.bsu, 0x3, 0x4);
+ bsu_avln_t *avln = bsu_avln_get (t.bsu, 0x3, 0x4, MAC_ZERO);
test_fail_unless (avln == NULL);
blk_release_desc (&beacon->blk);
/* Our AVLN. */
diff --git a/cesar/bsu/test/utest/src/interface.c b/cesar/bsu/test/utest/src/interface.c
index b39aed9da5..b7b34d2353 100644
--- a/cesar/bsu/test/utest/src/interface.c
+++ b/cesar/bsu/test/utest/src/interface.c
@@ -19,9 +19,6 @@
#include "bsu/inc/interface.h"
#include "bsu/inc/context.h"
-bsu_avln_t*
-bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid);
-
void
test_case_bsu_interface_tx (test_t t, bsu_beacon_type_t type)
{
@@ -98,8 +95,9 @@ test_case_bsu_interface_rx (test_t t)
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);
+ bsu_avln_t *avln = bsu_avln_get (
+ test.bsu, bbeacon.vf.nid, rx_params.snid,
+ bbeacon.bmis.mac_address.mac_address);
test_fail_unless (avln != NULL);
test_fail_unless (test.ul.beacon->params.frequency_error
== FIXED(avln->sync.fe,
diff --git a/cesar/bsu/test/utest/src/schedules.c b/cesar/bsu/test/utest/src/schedules.c
index 3436936b25..275e3ec229 100644
--- a/cesar/bsu/test/utest/src/schedules.c
+++ b/cesar/bsu/test/utest/src/schedules.c
@@ -21,7 +21,7 @@
#include <string.h>
bsu_avln_t*
-bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid);
+bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid, mac_t mac);
void
bsu_schedules_merge (bsu_t *ctx, bsu_beacon_t *beacon,
@@ -34,7 +34,7 @@ void
bsu_timer_event_process (void *ud);
bsu_avln_t*
-bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, bool *added);
+bsu_avln_add (bsu_t *ctx, u64 nid, u8 snid, mac_t mac, bool *added);
void
test_case_ca_schedules (test_t test)
@@ -173,7 +173,8 @@ test_case_bsu_schedules_countdowns (test_t t)
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);
+ bsu_track_avln (beacon.vf.nid, 0x0, ctx.mac_config.tei,
+ beacon.bmis.mac_address.mac_address);
ctx.bsu->track_new = false;
ctx.phy->use_phy_clock = false;
u32 now = phy_date ();
@@ -300,7 +301,8 @@ test_case_ca_schedules_intellon (test_t test)
bprocessed = bsu_beacon_process (t.bsu, pbbeacon, &brx);
blk_release (bprocessed);
/* Control plane request to track this AVLN. */
- bsu_track_avln (beacon.vf.nid, brx.snid, 0);
+ bsu_track_avln (beacon.vf.nid, brx.snid, 0,
+ beacon.bmis.mac_address.mac_address);
t.bsu->track_new = false;
t.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
/* BSU receives the next beacon. */
@@ -399,7 +401,8 @@ test_case_track_new_beacon (test_t t, bsu_test_t *ctx, bsu_beacon_t *beacon)
blk_release_desc (&pbbeacon->blk);
/* Modify the ntb_offset_tck to have a real case. */
bsu_avln_t *avln = bsu_avln_get (ctx->bsu, bbeacon->vf.nid,
- bbeacon->params.rx_parameters.snid);
+ bbeacon->params.rx_parameters.snid,
+ beacon->bmis.mac_address.mac_address);
blk_release (bbeacon);
avln->sync.ntb_offset_tck = 0;
avln->beacon.beacon_period_start_date = params_rx.bts;
@@ -424,7 +427,8 @@ test_case_track_new (test_t t)
ctx.bsu->activate = true;
ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
bsu_avln_t *avln = test_case_track_new_beacon (t, &ctx, &beacon);
- bsu_track_avln (beacon.vf.nid, 0x1, 0x1);
+ bsu_track_avln (beacon.vf.nid, 0x1, 0x1,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (ctx.bsu->track_new);
test_fail_unless (ctx.bsu->nid_track == beacon.vf.nid);
test_fail_unless (ctx.bsu->snid_track == 0x1);
@@ -468,7 +472,8 @@ test_case_track_new (test_t t)
ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
bsu_avln_t *avln = test_case_track_new_beacon (t, &ctx, &beacon);
bsu_timer_event_process (ctx.bsu);
- bsu_track_avln (beacon.vf.nid, 0x1, 0x1);
+ bsu_track_avln (beacon.vf.nid, 0x1, 0x1,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (ctx.bsu->track_new);
test_fail_unless (ctx.bsu->nid_track == beacon.vf.nid);
test_fail_unless (ctx.bsu->snid_track == 0x1);
@@ -511,7 +516,8 @@ test_case_track_new (test_t t)
ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
bsu_avln_t *avln = test_case_track_new_beacon (t, &ctx, &beacon);
bsu_timer_event_process (ctx.bsu);
- bsu_track_avln (beacon.vf.nid, 0x1, 0x1);
+ bsu_track_avln (beacon.vf.nid, 0x1, 0x1,
+ beacon.bmis.mac_address.mac_address);
test_fail_unless (ctx.bsu->track_new);
bsu_timer_event_process (ctx.bsu);
test_fail_unless (ctx.bsu->track_new == false);
@@ -547,7 +553,7 @@ test_case_track_new (test_t t)
ctx.bsu->poweron.sync.fe = 0.0;
/* Create the previous AVLN. */
bool added;
- bsu_avln_t *avln = bsu_avln_add (ctx.bsu, 1, 1, &added);
+ bsu_avln_t *avln = bsu_avln_add (ctx.bsu, 1, 1, MAC_ZERO, &added);
test_fail_unless (added);
/* Change synchronisation information for the test. */
avln->sync.ntb_offset_tck = 439;
@@ -582,6 +588,110 @@ test_case_track_new (test_t t)
bsu_test_uninit (&ctx);
}
test_end;
+ test_begin (t, "Receive a beacon from the same network but different CCo")
+ {
+ mac_t mac_track = 0x0013d7000001ull;
+ bsu_test_init (&ctx);
+ ctx.bsu->aclf->beacon_period_tck = BSU_ACLF_BP_50HZ_TCK;
+ for (i = 0; i < COUNT (ctx.bsu->aclf->bpsd); i++)
+ ctx.bsu->aclf->bpsd[i] = i * ctx.bsu->aclf->beacon_period_tck;
+ ctx.bsu->activate = true;
+ ctx.bsu->is_sta = BSU_UPDATE_STA_TYPE_STA;
+ ctx.bsu->poweron.sync.ntb_offset_tck = 0;
+ ctx.bsu->poweron.sync.fe = 0.0;
+ /* Create the previous AVLN. */
+ bsu_track_avln (1, 1, 1, mac_track);
+ /* Create a central beacon of the same NID, SNID but from a different
+ * CCo. */
+ bsu_beacon_t beacon;
+ bsu_test_create_beacon (&ctx, &beacon);
+ beacon.vf.nid = 1;
+ pbproc_tx_beacon_params_t tx_params;
+ pb_beacon_t *pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &tx_params);
+ pbproc_rx_beacon_params_t rx_params;
+ memset (&rx_params, 0, sizeof (pbproc_rx_beacon_params_t));
+ rx_params.snid = 1;
+ /* Process the beacon. */
+ bsu_beacon_t* beacon_processed =
+ bsu_beacon_process (ctx.bsu, pbbeacon, &rx_params);
+ test_fail_unless (beacon_processed);
+ blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (beacon_processed);
+ /* Check another AVLN has been created. */
+ bsu_avln_t *avln = bsu_avln_get (
+ ctx.bsu, 1, 1, beacon.bmis.mac_address.mac_address);
+ test_fail_unless (avln != ctx.bsu->sta_avln);
+ /* Beacon from our CCo */
+ bsu_test_create_beacon (&ctx, &beacon);
+ beacon.vf.nid = 1;
+ beacon.bmis.mac_address.mac_address = mac_track;
+ pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &tx_params);
+ /* Process the beacon. */
+ bsu_test_reset_phy (ctx.phy);
+ beacon_processed =
+ bsu_beacon_process (ctx.bsu, pbbeacon, &rx_params);
+ test_fail_unless (beacon_processed);
+ /* Get the AVLN. */
+ avln = bsu_avln_get (
+ ctx.bsu, 1, 1, beacon.bmis.mac_address.mac_address);
+ test_fail_unless (avln == ctx.bsu->sta_avln);
+ blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (beacon_processed);
+ /* Beacon from CCo without mac address. */
+ bsu_test_create_beacon (&ctx, &beacon);
+ beacon.vf.nid = 1;
+ beacon.bmis.mac_address.present = false;
+ pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &tx_params);
+ /* Process the beacon. */
+ bsu_test_reset_phy (ctx.phy);
+ beacon_processed =
+ bsu_beacon_process (ctx.bsu, pbbeacon, &rx_params);
+ test_fail_unless (beacon_processed);
+ avln = bsu_avln_get (ctx.bsu, 1, 1, MAC_ZERO);
+ test_fail_unless (avln != ctx.bsu->sta_avln);
+ blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (beacon_processed);
+ /* Process the beacon without mac address tracking. */
+ ctx.bsu->cco_mac_address_track = 0;
+ /* remove the AVLN create just above. */
+ bsu_avln_remove (1, 1, MAC_ZERO);
+ bsu_test_reset_phy (ctx.phy);
+ pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &tx_params);
+ beacon_processed =
+ bsu_beacon_process (ctx.bsu, pbbeacon, &rx_params);
+ test_fail_unless (beacon_processed);
+ avln = bsu_avln_get (ctx.bsu, 1, 1, MAC_ZERO);
+ /* Our AVLN has been used because the mac address tracked is none, in
+ * this case the station process the central beacon even it is from
+ * another network. */
+ test_fail_unless (!avln);
+ blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (beacon_processed);
+ /* Same case but now the central beacon have a mac address */
+ bsu_test_reset_phy (ctx.phy);
+ beacon.bmis.mac_address.present = true;
+ beacon.bmis.mac_address.mac_address = mac_track;
+ pbbeacon = bsu_beacon_write (
+ &beacon, BSU_BEACON_TYPE_CENTRAL, &ctx.mac_config, &tx_params);
+ beacon_processed =
+ bsu_beacon_process (ctx.bsu, pbbeacon, &rx_params);
+ test_fail_unless (beacon_processed);
+ /* Our AVLN has been used because the mac address tracked is none, in
+ * this case the station process the central beacon even it is from
+ * another network. */
+ avln = bsu_avln_get (ctx.bsu, 1, 1, MAC_ZERO);
+ test_fail_unless (!avln);
+ avln = bsu_avln_get (ctx.bsu, 1, 1, mac_track);
+ test_fail_unless (avln == ctx.bsu->sta_avln);
+ blk_release_desc ((blk_t*) pbbeacon);
+ blk_release (beacon_processed);
+ bsu_test_uninit (&ctx);
+ }
+ test_end;
}
void
diff --git a/cesar/bsu/test/utest/src/tests.c b/cesar/bsu/test/utest/src/tests.c
index 00e95f7c2f..98f6d2b472 100644
--- a/cesar/bsu/test/utest/src/tests.c
+++ b/cesar/bsu/test/utest/src/tests.c
@@ -48,15 +48,21 @@ bsu_test_upper_layer_beacon_received_init (bsu_test_t *ctx)
}
void
+bsu_test_reset_phy (bsu_aclf_test_phy_t *ctx)
+{
+ ctx->frequency_hz = 50.0;
+ ctx->phy_date = 0;
+ ctx->zero_crossing_date = 0;
+ ctx->use_phy_clock = true;
+}
+
+void
bsu_test_init (bsu_test_t *ctx)
{
dbg_assert (ctx);
trace_init ();
lib_stats_init ();
- phy_test_global.frequency_hz = 50.0;
- phy_test_global.phy_date = 0;
- phy_test_global.zero_crossing_date = 0;
- phy_test_global.use_phy_clock = true;
+ bsu_test_reset_phy (&phy_test_global);
ctx->phy = &phy_test_global;
ctx->mac_config.tei = 0x0;
ctx->mac_config.sta_mac_address = 0x123456789abcull;
diff --git a/cesar/bsu/test/utest/tests.h b/cesar/bsu/test/utest/tests.h
index 4ec96ff30d..285b849392 100644
--- a/cesar/bsu/test/utest/tests.h
+++ b/cesar/bsu/test/utest/tests.h
@@ -157,6 +157,11 @@ bsu_test_avln_create (bsu_test_t *ctx, bsu_avln_t *avln);
void
phy_clock (bsu_aclf_test_phy_t *ctx, u32 ticks);
+void
+bsu_test_reset_phy (bsu_aclf_test_phy_t *ctx);
+
+bsu_avln_t*
+bsu_avln_get (bsu_t *ctx, u64 nid, u8 snid, mac_t mac);
END_DECLS
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index f81f65a7c6..7ee0e6cfaf 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -772,7 +772,9 @@ cp_beacon_process_tracked_avln (cp_t *ctx, bsu_beacon_t *beacon,
cp_beacon_fill_discover_info (ctx, &discover);
bsu_update_discover_info (&discover);
bsu_track_avln (beacon->vf.nid, beacon->params.rx_parameters.snid,
- beacon->vf.stei);
+ beacon->vf.stei,
+ beacon->bmis.mac_address.present ?
+ beacon->bmis.mac_address.mac_address : MAC_ZERO);
// Program the timer.
cp_beacon_reconfigure_timer (ctx, false);
}
diff --git a/cesar/cp/sta/mgr/src/sta_mgr.c b/cesar/cp/sta/mgr/src/sta_mgr.c
index eae0a1003a..480396a7a5 100644
--- a/cesar/cp/sta/mgr/src/sta_mgr.c
+++ b/cesar/cp/sta/mgr/src/sta_mgr.c
@@ -313,9 +313,20 @@ cp_sta_mgr_remove_avln (cp_t *ctx, cp_snid_t snid, cp_nid_t nid)
/* Is it our net ? */
if (ctx->sta_mgr.our_avln == net)
cp_sta_mgr_set_our_avln (ctx, NULL);
+ /* Get the CCo to inform the BSU. */
+ mac_t cco_mac = MAC_ZERO;
+ cp_sta_t *cco = cp_net_get_cco (ctx, net);
+ if (cco)
+ {
+ cco_mac = cp_sta_get_mac_address (cco);
+ /* Mac address can be broadcast. */
+ if (cco_mac == MAC_BROADCAST)
+ cco_mac = MAC_ZERO;
+ slab_release (cco);
+ }
+ /* Inform BSU. */
+ bsu_avln_remove (nid, snid, cco_mac);
cp_net_uninit (ctx, net);
- /* Inform the BSU. */
- bsu_avln_remove (nid, snid);
}
}