summaryrefslogtreecommitdiff
path: root/cesar/cl
diff options
context:
space:
mode:
authordufour2009-10-16 10:29:11 +0000
committerdufour2009-10-16 10:29:11 +0000
commit1d3328ca1ee80a7fca3bdeca2b14a5ed9cade084 (patch)
treef13e92ae741aa0b7811a6f6bade637a7dff7cde2 /cesar/cl
parentb50f2e6fe9d4ae035500681be1b3f7dbf8f65a3d (diff)
cesar/{cl,cp}: add support for bridged data learnt from traffic.
To be compatible with some other vendors, we need to support the bridged traffic we learn (and not only the one from the bridge info MME). This commit add a temporary table which will contain the bridge entries we just have learnt. Regularly, the temporary table is committed into the MAC to TEI table. There is no management for expiration of entries. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@6148 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl')
-rw-r--r--cesar/cl/cl_mactotei.h36
-rw-r--r--cesar/cl/inc/context.h11
-rw-r--r--cesar/cl/inc/trace.h1
-rw-r--r--cesar/cl/src/cl.c15
-rw-r--r--cesar/cl/src/cl_mactotei.c58
-rw-r--r--cesar/cl/src/trace.c4
-rw-r--r--cesar/cl/stub/src/cl_mactotei.c16
7 files changed, 139 insertions, 2 deletions
diff --git a/cesar/cl/cl_mactotei.h b/cesar/cl/cl_mactotei.h
index 6c043e6cf0..20a4e999f4 100644
--- a/cesar/cl/cl_mactotei.h
+++ b/cesar/cl/cl_mactotei.h
@@ -43,6 +43,22 @@ typedef struct mac_lookup_table_t cl_mactotei_table_t;
*/
typedef struct mac_lookup_block_header_t cl_mactotei_blk_t;
+/**
+ * A MAC address with a TEI.
+ */
+struct cl_mactotei_entry_t
+{
+ /**
+ * A MAC address.
+ */
+ mac_t mac;
+ /**
+ * A TEI.
+ */
+ uint tei;
+};
+typedef struct cl_mactotei_entry_t cl_mactotei_entry_t;
+
BEGIN_DECLS
/**
@@ -132,6 +148,26 @@ cl_mactotei_copy_except_tag (cl_t *ctx, cl_mactotei_blk_t *table, uint tag);
void
cl_mactotei_cancel (cl_mactotei_blk_t *table);
+/**
+ * Add a temporary entry to the bridge table (if not already existing).
+ * \param cl the CL context.
+ * \param tei the TEI.
+ * \param mac the source MAC address.
+ */
+void
+cl_mactotei_bridge_add (cl_t *ctx, uint tei, mac_t mac);
+
+/**
+ * Update MAC to TEI table with temporary bridged entries.
+ * \param cl the CL context.
+ * \param tag the tag of the bridge entries.
+ *
+ * This function must be called every one second by the CP to update the MAC
+ * to TEI table with the temporary bridged entries.
+ */
+void
+cl_mactotei_bridge_update (cl_t *ctx, uint tag);
+
END_DECLS
#endif /*CL_MACTOTEI_H_*/
diff --git a/cesar/cl/inc/context.h b/cesar/cl/inc/context.h
index 58e2b80038..eed5cadb62 100644
--- a/cesar/cl/inc/context.h
+++ b/cesar/cl/inc/context.h
@@ -100,6 +100,17 @@ struct cl_t
/** mactotei table to send data over the PLC. */
cl_mactotei_table_t *mactotei;
+ /**
+ * Temporary table to store bridged entries learnt (not the one coming
+ * from the bridge info MME).
+ */
+ cl_mactotei_entry_t mactotei_bridge[BRIDGE_TABLE_MAX_TMP_ENTRY];
+
+ /**
+ * Size of the MAC to TEI bridge temporary table.
+ */
+ uint mactotei_bridge_entry_count;
+
/** send data context. */
cl_data_tx_t data_tx;
diff --git a/cesar/cl/inc/trace.h b/cesar/cl/inc/trace.h
index 383e5f5846..26b0c20273 100644
--- a/cesar/cl/inc/trace.h
+++ b/cesar/cl/inc/trace.h
@@ -44,6 +44,7 @@ enum
CL_TRACE_DATA_SEND_DONE,
CL_TRACE_DATA_RECV,
CL_TRACE_DATA_BUFFER_ADD,
+ CL_TRACE_BRIDGE_DETECTED,
};
BEGIN_DECLS
diff --git a/cesar/cl/src/cl.c b/cesar/cl/src/cl.c
index aba96d6054..8b060bd375 100644
--- a/cesar/cl/src/cl.c
+++ b/cesar/cl/src/cl.c
@@ -329,6 +329,15 @@ cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config)
/* Initialize the local bridge table module. */
bridge_table_init (ctx);
+ /* Initialize the MAC to TEI bridge temporary table. */
+ uint i;
+ for (i = 0; i < BRIDGE_TABLE_MAX_TMP_ENTRY; i++)
+ {
+ ctx->mactotei_bridge[i].mac = MAC_ZERO;
+ ctx->mactotei_bridge[i].tei = MAC_TEI_UNASSOCIATED;
+ }
+ ctx->mactotei_bridge_entry_count = 0;
+
CL_TRACE (INIT, mac_ntb());
return &cl_global;
@@ -852,10 +861,11 @@ void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
dbg_assert (ctx->data_rx.cb);
+ /* Get source MAC address. */
+ mac_t src = bitstream_direct_read_large (buffer, 48, 48);
if (CONFIG_TRACE)
{
mac_t dest = bitstream_direct_read_large (buffer, 0, 48);
- mac_t src = bitstream_direct_read_large (buffer, 48, 48);
CL_TRACE (DATA_RECV, mac_ntb(), buffer, TRACE_U64(dest),
TRACE_U64(src), length);
}
@@ -874,6 +884,9 @@ void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
data_rate_update_info(&(sta->rx_data_rate), length);
blk_release (sta);
}
+
+ /* Update temporary bridge table. */
+ cl_mactotei_bridge_add (ctx, tei, src);
}
/* Debug info. */
diff --git a/cesar/cl/src/cl_mactotei.c b/cesar/cl/src/cl_mactotei.c
index 53b040f89f..ed85d9977c 100644
--- a/cesar/cl/src/cl_mactotei.c
+++ b/cesar/cl/src/cl_mactotei.c
@@ -145,3 +145,61 @@ cl_mactotei_cancel (cl_mactotei_blk_t *table)
/* Release table from memory. */
mac_lookup_table_delete (table);
}
+
+void
+cl_mactotei_bridge_add (cl_t *ctx, uint tei, mac_t mac)
+{
+ /* Check parameters. */
+ dbg_assert (ctx);
+ dbg_assert (MAC_TEI_IS_STA (tei));
+ dbg_assert (MAC_IS_VALID (mac));
+
+ /* Check if entry exist in the MAC to TEI table. */
+ if (cl_mactotei_table_find_tei_from_mac (ctx, mac)
+ == MAC_TEI_UNASSOCIATED)
+ {
+ /* Check if entry is already in temporary table. */
+ uint i = 0;
+ bool exist = false;
+ do
+ {
+ if (ctx->mactotei_bridge[i].mac == mac)
+ exist = true;
+ } while ((i < ctx->mactotei_bridge_entry_count) && (exist == false));
+ /* If not in temporary. */
+ if (!exist
+ && ctx->mactotei_bridge_entry_count < BRIDGE_TABLE_MAX_TMP_ENTRY)
+ {
+ CL_TRACE (BRIDGE_DETECTED, TRACE_U64 (mac), tei);
+ /* Add it to temporary. */
+ ctx->mactotei_bridge[ctx->mactotei_bridge_entry_count].mac = mac;
+ ctx->mactotei_bridge[ctx->mactotei_bridge_entry_count].tei = tei;
+ ctx->mactotei_bridge_entry_count++;
+ }
+ }
+}
+
+void
+cl_mactotei_bridge_update (cl_t *ctx, uint tag)
+{
+ /* Check parameter. */
+ dbg_assert (ctx);
+
+ /* If something to do. */
+ if (ctx->mactotei_bridge_entry_count)
+ {
+ uint i;
+ /* Create a new MAC to TEI table. */
+ cl_mactotei_blk_t *new_table = cl_mactotei_new ();
+ /* Copy all the current entries. */
+ mac_lookup_table_copy (ctx->mactotei, new_table, 0, 0);
+ /* Add new entries. */
+ for (i = 0; i < ctx->mactotei_bridge_entry_count; i++)
+ cl_mactotei_addr_add (new_table,
+ ctx->mactotei_bridge[i].mac,
+ ctx->mactotei_bridge[i].tei,
+ tag);
+ /* Reset temporary table. */
+ ctx->mactotei_bridge_entry_count = 0;
+ }
+}
diff --git a/cesar/cl/src/trace.c b/cesar/cl/src/trace.c
index 51ce19c966..60091bd28e 100644
--- a/cesar/cl/src/trace.c
+++ b/cesar/cl/src/trace.c
@@ -48,7 +48,9 @@ cl_trace_init (cl_t *ctx)
TRACE_EVENT (CL_TRACE_DATA_SEND_DROP, "CL_DATA_SEND_DROP authenticated : %d, buffer @ : %x, length : %d", TIMESTAMP),
TRACE_EVENT (CL_TRACE_DATA_SEND_DONE, "CL_DATA_SEND_DONE buffer @ : %x", TIMESTAMP),
TRACE_EVENT (CL_TRACE_DATA_RECV, "CL_DATA_RECV buffer @ : %x, destination : %m, source : %m, length : %d", TIMESTAMP),
- TRACE_EVENT (CL_TRACE_DATA_BUFFER_ADD, "CL_DATA_BUFFER_ADD buffer @ : %x", TIMESTAMP)
+ TRACE_EVENT (CL_TRACE_DATA_BUFFER_ADD, "CL_DATA_BUFFER_ADD buffer @ : %x", TIMESTAMP),
+ TRACE_EVENT (CL_TRACE_BRIDGE_DETECTED, "Bridge detected for MAC %m by"
+ " TEI %d"),
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));
diff --git a/cesar/cl/stub/src/cl_mactotei.c b/cesar/cl/stub/src/cl_mactotei.c
index 135d33430e..3941d18eaa 100644
--- a/cesar/cl/stub/src/cl_mactotei.c
+++ b/cesar/cl/stub/src/cl_mactotei.c
@@ -86,3 +86,19 @@ void
cl_mactotei_cancel (cl_mactotei_blk_t *table)
{
}
+
+void
+cl_mactotei_bridge_add (cl_t *ctx, uint tei, mac_t mac) __attribute__((weak));
+
+void
+cl_mactotei_bridge_add (cl_t *ctx, uint tei, mac_t mac)
+{
+}
+
+void
+cl_mactotei_bridge_update (cl_t *ctx, uint tag) __attribute__((weak));
+
+void
+cl_mactotei_bridge_update (cl_t *ctx, uint tag)
+{
+}