summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/cp/sta/action/bridge.h8
-rw-r--r--cesar/cp/sta/action/inc/context.h13
-rw-r--r--cesar/cp/sta/action/src/action.c4
-rw-r--r--cesar/cp/sta/action/src/assoc.c3
-rw-r--r--cesar/cp/sta/action/src/bridge.c60
5 files changed, 85 insertions, 3 deletions
diff --git a/cesar/cp/sta/action/bridge.h b/cesar/cp/sta/action/bridge.h
index d694c475c5..305410d77c 100644
--- a/cesar/cp/sta/action/bridge.h
+++ b/cesar/cp/sta/action/bridge.h
@@ -37,7 +37,13 @@ cp_sta_action_process_cm_brg_info_cnf (cp_t *ctx, cp_mme_rx_t *mme);
void
cp_sta_action_process_cm_brg_info_req (cp_t *ctx, cp_mme_rx_t *mme);
-END_DECLS
+/**
+ * Update bridge table and send CM_BRG_INFO.CNF if needed.
+ * \param ctx the control plain context.
+ */
+void
+cp_sta_action_update_bridge_table (cp_t *ctx);
+END_DECLS
#endif /* cp_sta_action_bridge_h */
diff --git a/cesar/cp/sta/action/inc/context.h b/cesar/cp/sta/action/inc/context.h
index 6c4e27dc66..03038cdcc2 100644
--- a/cesar/cp/sta/action/inc/context.h
+++ b/cesar/cp/sta/action/inc/context.h
@@ -46,6 +46,17 @@ struct cp_sta_action_poweron_t
cp_sta_core_timed_event_def_t join_timer;
};
+/** STA action/bridge sub-context. */
+struct cp_sta_action_bridge_t
+{
+ /** Minimum time to wait before sending a new bridge table after an
+ * update. */
+ uint min_time_send_new_s;
+ /** Time to wait before sending the bridge table when there is no
+ * update. */
+ uint wait_time_without_update_s;
+};
+
/** STA action context */
struct cp_sta_action_t
{
@@ -55,6 +66,8 @@ struct cp_sta_action_t
struct cp_sta_action_assoc_t assoc;
/** Power-on part. */
struct cp_sta_action_poweron_t poweron;
+ /** Bridge part. */
+ struct cp_sta_action_bridge_t bridge;
};
typedef struct cp_sta_action_t cp_sta_action_t;
diff --git a/cesar/cp/sta/action/src/action.c b/cesar/cp/sta/action/src/action.c
index ffae141a38..21b733629d 100644
--- a/cesar/cp/sta/action/src/action.c
+++ b/cesar/cp/sta/action/src/action.c
@@ -13,8 +13,8 @@
#include "common/std.h"
#include "action.h"
-#include "cl/bridge_table.h" // bridge_table_update
#include "cp/inc/context.h" // cp_t
+#include "cp/sta/action/bridge.h" // cp_sta_action_update_bridge_table
void
cp_sta_action_init (cp_t *ctx)
@@ -26,6 +26,6 @@ void
cp_sta_action_garbage (cp_t *ctx)
{
/* Update local bridge table. */
- bridge_table_update (ctx->cl);
+ cp_sta_action_update_bridge_table (ctx);
}
diff --git a/cesar/cp/sta/action/src/assoc.c b/cesar/cp/sta/action/src/assoc.c
index 702db26cc4..0005f79e2d 100644
--- a/cesar/cp/sta/action/src/assoc.c
+++ b/cesar/cp/sta/action/src/assoc.c
@@ -30,6 +30,9 @@ cp_sta_action_assoc_init (cp_t *ctx)
{
dbg_assert (ctx);
ctx->sta_action.assoc.cco_net = NULL;
+ /* Bridge table default expiration values. */
+ ctx->sta_action.bridge.min_time_send_new_s = 5;
+ ctx->sta_action.bridge.wait_time_without_update_s = 90;
}
void
diff --git a/cesar/cp/sta/action/src/bridge.c b/cesar/cp/sta/action/src/bridge.c
index f8e5ecdbfa..c2bd82fd84 100644
--- a/cesar/cp/sta/action/src/bridge.c
+++ b/cesar/cp/sta/action/src/bridge.c
@@ -17,9 +17,13 @@
#include "cp/mme.h" // cp_mme_rx_t
#include "cp/msg/msg.h" // to include cp/msg/inc/msg_cm.h
#include "cp/msg/inc/msg_cm.h" // cp_msg_cm_brg_info_cnf_receive_*
+#include "cp/sta/mgr/sta_mgr.h" // cp_sta_mgr_get_our_avln
+#include "cp/sta/mgr/sta.h" // cp_sta_get_peer
+#include "cp/sta/mgr/net.h" // cp_net_sta_get_*
#include "cl/cl_mactotei.h" // cl_mactotei_*
#include "cp/inc/context.h" // cp_t
#include "cl/bridge_table.h" // bridge_table_*
+#include "lib/utils.h" // less_mod2p32
#include "cp/sta/action/bridge.h"
/**
@@ -127,3 +131,59 @@ cp_sta_action_process_cm_brg_info_req (cp_t *ctx, cp_mme_rx_t *mme)
cp_sta_action_send_cm_brg_info_cnf (ctx, &mme->peer);
}
}
+
+void
+cp_sta_action_update_bridge_table (cp_t *ctx)
+{
+ /* Check parameter. */
+ dbg_assert (ctx);
+
+ /* Cycle count. */
+ static u32 cycle_count = 0;
+ /* Last cycle where the bridge table was sent with a CM_BRG_INFO.CNF. */
+ static u32 last_emission_cycle = 0;
+ /* Flag to know if the bridge table has been updated (modified) and need
+ * to be sent. */
+ static bool new_table_to_send = false;
+
+ /* Update cycle count. */
+ cycle_count++;
+
+ /* Update bridge table. */
+ new_table_to_send = bridge_table_update (ctx->cl);
+
+ /* Send the bridge table with a CM_BRG_INFO.CNF if the table is not empty
+ * and last emission is more than wait_time_without_update_s or a new
+ * table has not been sent yet (we must wait at least
+ * min_time_send_new_s). */
+ if ((bridge_table_size (ctx->cl) > 0)
+ && (
+ (lesseq_mod2p32
+ (cycle_count + ctx->sta_action.bridge.wait_time_without_update_s,
+ last_emission_cycle))
+ ||
+ (new_table_to_send
+ && lesseq_mod2p32
+ (cycle_count + ctx->sta_action.bridge.min_time_send_new_s,
+ last_emission_cycle))
+ ))
+ {
+ /* Sent the local bridge table. */
+ /* Get our AVLN. */
+ cp_net_t *our_avln = cp_sta_mgr_get_our_avln (ctx);
+ /* Go through all STA of the AVLN. */
+ cp_sta_t *sta;
+ cp_mme_peer_t peer;
+ for (sta = cp_net_sta_get_first (ctx, our_avln, CP_NET_STA_ASSOC);
+ sta; sta = cp_net_sta_get_next (ctx, our_avln, sta))
+ {
+ /* Construct peer. */
+ cp_sta_get_peer (sta, &peer);
+ cp_sta_action_send_cm_brg_info_cnf (ctx, &peer);
+ }
+ /* Update last emission cycle. */
+ last_emission_cycle = cycle_count;
+ /* Reset flag for new table to send. */
+ new_table_to_send = false;
+ }
+}