summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNélio Laranjeiro2011-09-02 10:42:57 +0200
committerNélio Laranjeiro2011-09-22 16:45:18 +0200
commit24b34d140745034d6b9042d4f7a312d6b3b7fdaf (patch)
treec5e960ff6ef20bbe4c4d9c3b2660bff4a414ca8a /cesar/cp
parent6e33cc85bb50c017ea1cad9281be354de534f9ca (diff)
cesar/cp/beacon: do not send a beacon when hoip is ended, closes #2707
When the FSM calls the update function of the cp/beacon which create the bsu_beacon_t object to provide it to the BSU, the handover in progress countdown should be checked, if it is equal to one, the bsu_update function should not be called because on the next beacon period (cp/beacon is awaken few ms before the end of the beacon period when the station acts as CCo) it will be a simple station. The FSM will just after change the station status from CCo to Authenticated.
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/beacon/src/beacon.c8
-rw-r--r--cesar/cp/beacon/test/src/beacon.c29
-rw-r--r--cesar/cp/beacon/test/src/bsu_stub.c2
3 files changed, 38 insertions, 1 deletions
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 1ca8b03c64..a653409c7b 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -602,8 +602,14 @@ cp_beacon_cco_update_beacon_data (cp_t *ctx)
{
bsu_beacon_t beacon;
dbg_assert (ctx);
+ /* Be aware that an handover can be in progress. If the it is the case and
+ * the current countdown is 1, then after the cp_beacon_update_beacon_data
+ * function, the handover is ended. The emission of the beacon MUST be
+ * aborted. */
+ bool hoip_ended = ctx->beacon.hoip.hoipcd == 1;
cp_beacon_update_beacon_data (ctx, &beacon, true);
- bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_CCO);
+ if (!hoip_ended)
+ bsu_update (ctx->bsu, &beacon, BSU_UPDATE_STA_TYPE_CCO);
}
void
diff --git a/cesar/cp/beacon/test/src/beacon.c b/cesar/cp/beacon/test/src/beacon.c
index 0e4b83c116..d096b4ad09 100644
--- a/cesar/cp/beacon/test/src/beacon.c
+++ b/cesar/cp/beacon/test/src/beacon.c
@@ -43,6 +43,7 @@ struct test_beacon_t
sar_t sar;
bsu_aclf_t aclf;
uint ca;
+ bool bsu_updated;
};
typedef struct test_beacon_t test_beacon_t;
@@ -55,6 +56,7 @@ test_beacon_init (test_beacon_t *ctx)
ctx->cp.sar = &ctx->sar;
ctx->cp.cl = &ctx->cl;
ctx->cp.bsu_aclf = &ctx->aclf;
+ ctx->cp.bsu = (bsu_t *) &ctx->bsu_updated;
*((bsu_aclf_frequency_t*) &ctx->aclf.frequency) = BSU_ACLF_FREQ_50HZ;
*((bsu_aclf_bp_t*) &ctx->aclf.beacon_period_theo_tck) =
BSU_ACLF_BP_50HZ_TCK;
@@ -1335,6 +1337,32 @@ test_suite_beacon_spoc_update (test_t test)
test_beacon_uninit (&ctx);
}
+void
+test_suite_beacon_hoip_ended (test_t t)
+{
+ test_suite_begin (t, "Handover ended, avoid to send the last beacon");
+ test_case_begin (t, "Handover in progress");
+ test_beacon_t ctx;
+ test_beacon_init (&ctx);
+ test_begin (t, "Handover not ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 2;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (ctx.bsu_updated);
+ }
+ test_end;
+ test_begin (t, "Handover Ended")
+ {
+ ctx.bsu_updated = false;
+ ctx.cp.beacon.hoip.hoipcd = 1;
+ cp_beacon_cco_update_beacon_data (&ctx.cp);
+ test_fail_unless (!ctx.bsu_updated);
+ }
+ test_end;
+ test_beacon_uninit (&ctx);
+}
+
int
main (void)
{
@@ -1350,6 +1378,7 @@ main (void)
test_suite_beacon_mac_address_bentry (test);
test_suite_beacon_no_net (test);
test_suite_beacon_spoc_update (test);
+ test_suite_beacon_hoip_ended (test);
test_case_begin (test, "Memory allocation");
test_begin (test, "memory leaks")
diff --git a/cesar/cp/beacon/test/src/bsu_stub.c b/cesar/cp/beacon/test/src/bsu_stub.c
index 8d2753a8e9..fc1f92d0c1 100644
--- a/cesar/cp/beacon/test/src/bsu_stub.c
+++ b/cesar/cp/beacon/test/src/bsu_stub.c
@@ -46,6 +46,8 @@ bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx)
void
bsu_update (bsu_t *ctx, bsu_beacon_t *beacon, bsu_update_sta_type_t sta)
{
+ bool *updated = (bool*) ctx;
+ *updated = true;
}
void