From 788ef9b8c3584b453f22faf088a028335317f4a9 Mon Sep 17 00:00:00 2001 From: Yacine Belkadi Date: Wed, 3 Apr 2013 11:42:05 +0200 Subject: cesar/cp/beacon: add cp_beacon_process_bmi_eks() To prepare for next commits, move the code processing the key change bentry into a new function cp_beacon_process_bmi_eks(). --- cesar/cp/beacon/src/beacon.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'cesar/cp/beacon/src') diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c index afdf81d046..f509711638 100644 --- a/cesar/cp/beacon/src/beacon.c +++ b/cesar/cp/beacon/src/beacon.c @@ -576,6 +576,34 @@ cp_beacon_poweron_init (cp_t *ctx) GPIO_TOGGLE (LED_BEACON_TX_RX); } +/** + * Process the key change part of the beacon. + * \param ctx cp context. + * \param beacon The beacon to process. + */ +static void +cp_beacon_process_bmi_eks (cp_t *ctx, const bsu_beacon_t *beacon) +{ + /* This only runs on a Sta. The CCo, being the origin of the change, doesn't + * need to process a beacon to know about it and react. */ + dbg_assert (!cp_sta_own_data_get_cco_status (ctx)); + + if (beacon->bmis.eks.present) + { + if ((beacon->bmis.eks.kbc == BSU_BEACON_EKS_KBC_NEK) + && (ctx->mac_config->nek[bsu_nek_index_next (ctx->bsu)].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); + } + + ctx->beacon.eks.kccd = beacon->bmis.eks.kccd; + ctx->beacon.eks.kbc = beacon->bmis.eks.kbc; + ctx->beacon.eks.new_eks = beacon->bmis.eks.new_eks; + } +} + /** * Process the first beacon in the received list. * \param ctx the control plane context. @@ -663,21 +691,9 @@ cp_beacon_process_beacon_central ( beacon->bmis.handover.hcd; ctx->beacon.hoip.cco = beacon->bmis.handover.tei; } - if (beacon->bmis.eks.present) - { - if ((beacon->bmis.eks.kbc == BSU_BEACON_EKS_KBC_NEK) && - (ctx->mac_config->nek[bsu_nek_index_next (ctx->bsu)].eks != - beacon->bmis.eks.new_eks)) - { - /* POST the FSM event. */ - cp_fsm_post_new_event (ctx, bare, nek_request); - } - ctx->beacon.eks.kccd = beacon->bmis.eks.kccd; - ctx->beacon.eks.kbc = beacon->bmis.eks.kbc; - ctx->beacon.eks.new_eks = - beacon->bmis.eks.new_eks; - } + cp_beacon_process_bmi_eks (ctx, beacon); + /** Update the schedules. */ cp_beacon_sta_compute_schedules (ctx, beacon); if (CONFIG_CP_AV) -- cgit v1.2.3