summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Cecaric2010-05-31 13:48:42 +0200
committerAleksandar Cecaric2010-05-31 13:48:42 +0200
commitf74fcb298391de7d28ca807a4291d53ba5440932 (patch)
tree8f1b49ae157c0debee858310f5763ed6af7b4871
parentf21df12c4d5b19c894d362f67e5ec02565175031 (diff)
cesar/cl[eoc] : make copy of valid MAC addresses before sending cm_brg_info_cnf, closes #1202
While counted, MAC adresses of valid routing entries are also stored to be fed later to cm_brg_info_cnf message
-rw-r--r--cesar/cl/cl.h9
-rw-r--r--cesar/cl/cl_eoc_mactotei.h12
-rw-r--r--cesar/cl/src/bridge_table.c5
-rw-r--r--cesar/cl/src/cl_eoc_mactotei.c30
-rw-r--r--cesar/cl/test/utest_eoc/src/test_mactotei.c3
5 files changed, 25 insertions, 34 deletions
diff --git a/cesar/cl/cl.h b/cesar/cl/cl.h
index 43b578ff17..aa8b870836 100644
--- a/cesar/cl/cl.h
+++ b/cesar/cl/cl.h
@@ -320,15 +320,6 @@ cl_mme_buffer_add (cl_t *cl, u8 *buffer);
void
cl_data_buffer_add (cl_t *cl, u8 *buffer);
-#if CONFIG_CL_EOC_ROUTE
-/** Return mac addresses of valid entries in mactotei table
- * \param ctx CL context
- * \param next_node next node in ageing list to be read
- */
-mac_t
-cl_eoc_mactotei_get_mac (cl_t *ctx, list_node_t **next_node);
-#endif
-
END_DECLS
#endif /* CL_CL_H_ */
diff --git a/cesar/cl/cl_eoc_mactotei.h b/cesar/cl/cl_eoc_mactotei.h
index c6127e0402..069df23f6c 100644
--- a/cesar/cl/cl_eoc_mactotei.h
+++ b/cesar/cl/cl_eoc_mactotei.h
@@ -66,6 +66,8 @@ struct cl_eoc_mactotei_table_t
uint num_of_entries;
/** STA's local time for entries expiration */
uint time_count;
+ /** Snapshot list of valid mac addresses in MAC to TEI table.*/
+ mac_t mac_snapshot[MACTOTEI_NB_ENTRIES];
};
typedef struct cl_eoc_mactotei_table_t cl_eoc_mactotei_table_t;
@@ -120,12 +122,20 @@ cl_eoc_time_update (cl_t *ctx);
uint
cl_eoc_get_time (cl_t *ctx);
-/** Return number of valid entries in mactotei table
+/** Return number of valid entries in mactotei table and store MAC adresses of
+ * valid entries
* \param ctx CL context
*/
uint
cl_eoc_mactotei_entry_count (cl_t *ctx);
+/** Return mac addresses of valid entries in mactotei table
+ * \param ctx CL context
+ * \param next_mac next element in mac snapshot list to be read
+ */
+mac_t
+cl_eoc_mactotei_get_mac (cl_t *ctx, uint next_mac);
+
END_DECLS
#endif /*CL_EOC_MACTOTEI_H_*/
diff --git a/cesar/cl/src/bridge_table.c b/cesar/cl/src/bridge_table.c
index 30742df960..94d96f0cc2 100644
--- a/cesar/cl/src/bridge_table.c
+++ b/cesar/cl/src/bridge_table.c
@@ -206,7 +206,10 @@ bridge_table_get_entry (cl_t *ctx, uint position)
{
/* Check parameters. */
dbg_assert (ctx);
+#if !CONFIG_CL_EOC_ROUTE
dbg_assert (position < bridge_table_size (ctx));
-
return mac_lookup_get_mac (ctx->bridge_table.table, position);
+#else
+ return cl_eoc_mactotei_get_mac (ctx, position);
+#endif
}
diff --git a/cesar/cl/src/cl_eoc_mactotei.c b/cesar/cl/src/cl_eoc_mactotei.c
index 24a86b4f2e..acad1d57dc 100644
--- a/cesar/cl/src/cl_eoc_mactotei.c
+++ b/cesar/cl/src/cl_eoc_mactotei.c
@@ -235,7 +235,8 @@ cl_eoc_mactotei_set_entry_duration (cl_t * ctx, uint max_dur_sec)
ctx->cl_eoc_mactotei_table.max_duration = max_dur_sec;
}
-/** Return number of valid entries in mactotei table
+/** Return number of valid entries in mactotei table and store MAC adresses of
+ * valid entries
* \param ctx CL context
*/
uint
@@ -253,7 +254,11 @@ cl_eoc_mactotei_entry_count (cl_t *ctx)
entry = PARENT_OF (cl_eoc_mactotei_entry_t, l_age, list_node);
if (entry && !cl_eoc_is_obsolete (ctx, entry, cl_eoc_get_time (ctx)) &&
entry->mac_addr)
+ {
+ ctx->cl_eoc_mactotei_table.mac_snapshot[valid_entries_nb] =
+ entry->mac_addr;
valid_entries_nb++;
+ }
else
break;
list_node = list_prev (list_node);
@@ -265,27 +270,10 @@ cl_eoc_mactotei_entry_count (cl_t *ctx)
/** Return mac addresses of valid entries in mactotei table
* \param ctx CL context
- * \param next_node next node in ageing list to be read
+ * \param next_mac next element in mac snapshot list to be read
*/
mac_t
-cl_eoc_mactotei_get_mac (cl_t *ctx, list_node_t **next_node)
+cl_eoc_mactotei_get_mac (cl_t *ctx, uint next_mac)
{
- cl_eoc_mactotei_entry_t *entry = NULL;
- list_node_t *list_node = NULL;
-
- arch_dsr_lock ();
- if (*next_node == NULL)
- list_node = list_rbegin (&ctx->cl_eoc_mactotei_table.ageing_list);
- else
- {
- list_node = list_prev (*next_node);
- if(list_node == &ctx->cl_eoc_mactotei_table.ageing_list.nil)
- list_node = NULL;
- }
- if (list_node)
- entry = PARENT_OF (cl_eoc_mactotei_entry_t, l_age, list_node);
- *next_node = list_node;
- arch_dsr_unlock ();
-
- return entry->mac_addr;
+ return ctx->cl_eoc_mactotei_table.mac_snapshot[next_mac];
}
diff --git a/cesar/cl/test/utest_eoc/src/test_mactotei.c b/cesar/cl/test/utest_eoc/src/test_mactotei.c
index b8378c5b99..a18370a09a 100644
--- a/cesar/cl/test/utest_eoc/src/test_mactotei.c
+++ b/cesar/cl/test/utest_eoc/src/test_mactotei.c
@@ -143,7 +143,6 @@ test_entries (test_t test)
{
uint nb_entry;
mac_t mac, mac_ref;
- list_node_t *list_node = NULL;
cl_eoc_mactotei_init (&cl);
cl.mac_config->tei = 1;
ok = cl_eoc_mactotei_entry_insert (&cl, 0x0000112233445566ull, 4);
@@ -171,7 +170,7 @@ test_entries (test_t test)
mac_ref = 0x0000112233445515ull;
for (i = 0; i < nb_entry; i++)
{
- mac = cl_eoc_mactotei_get_mac (&cl, &list_node);
+ mac = cl_eoc_mactotei_get_mac (&cl, i);
test_fail_unless (mac == mac_ref - i);
}
}