summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
Diffstat (limited to 'cesar')
-rw-r--r--cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c28
-rw-r--r--cesar/cp/beacon/src/beacon.c13
2 files changed, 39 insertions, 2 deletions
diff --git a/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c b/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c
index 64877656a7..35150de3e0 100644
--- a/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c
+++ b/cesar/cp/av/beacon/test/utest2/src/beacon_scenario.c
@@ -125,6 +125,7 @@ beacon_nek_request_test_case (test_t test)
* we check a nek_request event is sent. */
beacon = (bsu_beacon_t *) blk_alloc ();
beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = 3;
beacon->bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
beacon->bmis.eks.new_eks = ref_eks_next + 1;
beacon->vf.stei = 1;
@@ -147,10 +148,35 @@ beacon_nek_request_test_case (test_t test)
}
test_end;
+ /** Check that a nek_request is only posted once. */
+ beacon = (bsu_beacon_t *) blk_alloc ();
+ beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = 2;
+ beacon->bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
+ beacon->bmis.eks.new_eks = ref_eks_next + 1;
+ beacon->vf.stei = 1;
+ beacon->vf.nid = 1;
+ beacon->params.rx_parameters.snid = 1;
+ beacon->bmis.mac_address.present = false;
+ beacon->params.direction = BSU_BEACON_DIRECTION_FROM_PLC;
+ cp_beacon_receive (&cp, beacon);
+ test_begin (test, "different eks:nek_request only once")
+ {
+ scenario_entry_t entries[] =
+ {
+ SCENARIO_ACTION (get_and_process_beacon),
+ SCENARIO_END
+ };
+ scenario_run (test, entries, &globals);
+ }
+ test_end;
+
/** Test with matching eks
* we check that no event is sent. */
+ cp.beacon.eks.kccd = 5;
beacon = (bsu_beacon_t *) blk_alloc ();
beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = 4;
beacon->bmis.eks.kbc = BSU_BEACON_EKS_KBC_NEK;
beacon->bmis.eks.new_eks = ref_eks_next;
beacon->vf.stei = 1;
@@ -175,6 +201,7 @@ beacon_nek_request_test_case (test_t test)
* we check that no event is sent. */
beacon = (bsu_beacon_t *) blk_alloc ();
beacon->bmis.eks.present = true;
+ beacon->bmis.eks.kccd = 4;
beacon->bmis.eks.kbc = BSU_BEACON_EKS_KBC_NMK;
beacon->bmis.eks.new_eks = ref_eks_next + 1;
beacon->vf.stei = 1;
@@ -198,6 +225,7 @@ beacon_nek_request_test_case (test_t test)
/* Test with everything ok, but the local next eks is invalid
* we check that a nek_request event is sent. */
mac_config.nek_mgr.next_nek = NULL;
+ cp.beacon.eks.kccd = 0;
beacon = (bsu_beacon_t *) blk_alloc ();
beacon->bmis.eks.present = true;
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index 086253b8e1..1ecf0b015d 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -576,8 +576,17 @@ cp_beacon_process_bmi_eks (cp_t *ctx, const bsu_beacon_t *beacon)
|| (ctx->mac_config->nek_mgr.next_nek->eks
!= beacon->bmis.eks.new_eks))
{
- /* We don't have the new NEK. We need to ask for it. */
- cp_fsm_post_new_event (ctx, bare, nek_request);
+ /* We don't have the new NEK. We need to ask for it.
+ * But we don't want to ask many times. After all, this already
+ * is a fall-back mechanism in case we missed the CM_SET_KEY_REQ
+ * MME sent by the CCo before the start of a NEK change. It
+ * doesn't seem useful to insist that much. So, only ask once.
+ *
+ * If ctx->beacon.eks.kccd != 0, it means we are already aware
+ * of the countdown. So we already asked for the new missing
+ * NEK. */
+ if (ctx->beacon.eks.kccd == 0)
+ cp_fsm_post_new_event (ctx, bare, nek_request);
}
}