summaryrefslogtreecommitdiff
path: root/cesar/cl
diff options
context:
space:
mode:
authorlaranjeiro2008-10-27 14:05:55 +0000
committerlaranjeiro2008-10-27 14:05:55 +0000
commit9d1c34f849c028e03e9c0a640aa10e156caf478b (patch)
treea17644352f93f634be8642eb4cda4db48fc7c16c /cesar/cl
parent2e5e0a0b7d49deebc21bf1185eec58e5fb5f9793 (diff)
cl: Added the MFS on the rx callback function done by the SAR.
- Update the unit test cl_mme_send to verify all the cases to send a MME. - Update the tests scripts. - Update the Makefile. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@3371 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl')
-rw-r--r--cesar/cl/cl.h94
-rw-r--r--cesar/cl/inc/trace.h1
-rw-r--r--cesar/cl/src/cl.c62
-rw-r--r--cesar/cl/src/trace.c1
-rw-r--r--cesar/cl/test/Makefile17
-rw-r--r--cesar/cl/test/overide/mac/sar/sar.h38
-rw-r--r--cesar/cl/test/src/cl_mme_recv.c4
-rw-r--r--cesar/cl/test/src/cl_mme_send_as_data.c358
8 files changed, 399 insertions, 176 deletions
diff --git a/cesar/cl/cl.h b/cesar/cl/cl.h
index 7a32c5b7ef..33b74a04fd 100644
--- a/cesar/cl/cl.h
+++ b/cesar/cl/cl.h
@@ -32,7 +32,8 @@ typedef struct cl_send_t cl_send_t;
* \param user the user data
* \param buffer the buffer use to send the data over the PLC.
*/
-typedef void (*cl_data_send_done_cb_t) (void *user, u8 *buffer);
+typedef void
+(*cl_data_send_done_cb_t) (void *user, u8 *buffer);
/**
* Callback to provide a received data to the upper layer coming from the SAR.
@@ -41,7 +42,8 @@ typedef void (*cl_data_send_done_cb_t) (void *user, u8 *buffer);
* \param buffer the buffer containing the data
* \param length the data length in the buffer.
*/
-typedef void (*cl_data_recv_cb_t) (void *user, u8 *buffer, uint length);
+typedef void
+(*cl_data_recv_cb_t) (void *user, u8 *buffer, uint length);
/**
* Provides a MME buffer to the CP.
@@ -49,7 +51,8 @@ typedef void (*cl_data_recv_cb_t) (void *user, u8 *buffer, uint length);
* \param user_data the layer data.
* \param buffer the buffer to provide.
*/
-typedef void (*cl_mme_buffer_add_cb_t) (void *user_data, u8 *buffer);
+typedef void
+(*cl_mme_buffer_add_cb_t) (void *user_data, u8 *buffer);
/**
* Call back to use when the CL needs to send a MME to the upper layer.
@@ -58,7 +61,8 @@ typedef void (*cl_mme_buffer_add_cb_t) (void *user_data, u8 *buffer);
* \param buffer the buffer containing the MME.
* \param length the length of the MME
*/
-typedef void (*cl_mme_ul_send_done_cb_t) (void *ul_data, u8 *buffer, uint length);
+typedef void
+(*cl_mme_ul_send_done_cb_t) (void *ul_data, u8 *buffer, uint length);
/**
* Call back to use once the CP had used the buffer containing a received MME.
@@ -66,7 +70,8 @@ typedef void (*cl_mme_ul_send_done_cb_t) (void *ul_data, u8 *buffer, uint length
* \param ctx the CL context
* \param mme_recv user data
*/
-typedef void (*cl_mme_recv_done_cb_t) (void *ctx, cl_mme_recv_t *mme_recv);
+typedef void
+(*cl_mme_recv_done_cb_t) (void *ctx, cl_mme_recv_t *mme_recv);
/**
* Callback definition used by the CL when the CP had processed the MME
@@ -75,7 +80,8 @@ typedef void (*cl_mme_recv_done_cb_t) (void *ctx, cl_mme_recv_t *mme_recv);
* \param user_data the upper layer user data
* \param buffer the buffer containing the MME.
*/
-typedef void (*cl_mme_ul_recv_done_cb_t) (void *user_data, u8 *buffer);
+typedef void
+(*cl_mme_ul_recv_done_cb_t) (void *user_data, u8 *buffer);
/**
* Use this callback to provide a received MME to the CP.
@@ -88,8 +94,9 @@ typedef void (*cl_mme_ul_recv_done_cb_t) (void *user_data, u8 *buffer);
* \param encryption inform if the MF has been encrypted or not when it
* arrives from the PWL.
*/
-typedef void (*cl_mme_recv_cb_t) (void *user, uint tei, u8 *buffer,
- uint length, cl_mme_recv_t *mme_recv, bool encryption);
+typedef void
+(*cl_mme_recv_cb_t) (void *user, uint tei, u8 *buffer,
+ uint length, cl_mme_recv_t *mme_recv, bool encryption);
/**
* Init the Convergence Layer and return a pointer on the CL context.
@@ -99,14 +106,16 @@ typedef void (*cl_mme_recv_cb_t) (void *user, uint tei, u8 *buffer,
* \param mac_config the mac config.
* \return the convergence layer context.
*/
-cl_t *cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config);
+cl_t *
+cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config);
/**
* Uninit the Convergence layer context.
*
* \param ctx the convergence layer context
*/
-void cl_uninit (cl_t *ctx);
+void
+cl_uninit (cl_t *ctx);
/**
* Initialize the CL to call the Upper layer once the CP ends processing the
@@ -117,8 +126,9 @@ void cl_uninit (cl_t *ctx);
* \param cb the upper layer callback to use to send an MME.
* \param user the user data to provide with the callback
*/
-void cl_mme_ul_init_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
- void *user);
+void
+cl_mme_ul_init_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
+ void *user);
/**
* Init the function call when an MME is received from the SAR or the HLE.
@@ -129,7 +139,8 @@ void cl_mme_ul_init_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
* \param mme_recv_cb
* \param user the user data
*/
-void cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void *user);
+void
+cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void *user);
/**
* Initialize the CL to send MMEs to the Upper layer considered as data.
@@ -139,7 +150,8 @@ void cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void *user);
* \param cb the upper layer callback to use to send an MME.
* \param user the user data to provide with the callback
*/
-void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_ul_send_done_cb_t cb, void *user);
+void
+cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_ul_send_done_cb_t cb, void *user);
/**
@@ -149,8 +161,9 @@ void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_ul_send_done_cb_t cb, void *user)
* \param cb the call back function
* \param user_data the user data.
*/
-void cl_mme_init_buffer_add_cb (cl_t *cl, cl_mme_buffer_add_cb_t cb,
- void *user_data);
+void
+cl_mme_init_buffer_add_cb (cl_t *cl, cl_mme_buffer_add_cb_t cb,
+ void *user_data);
/**
* Send a MME from the CP to the Upper layer or to the PWL.
@@ -176,7 +189,8 @@ cl_mme_send (cl_t *ctx, u8 *buffer, uint length, uint tei);
* \param buffer the buffer used.
* \param cl_data the data provided to the SAR on the send.
*/
-void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
+void
+cl_mme_sar_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
/**
* Receives an MME from the SAR or the upper layer.
@@ -188,12 +202,13 @@ void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
* \param ctx the cl context
* \param buffer the MME buffer
* \param length the MME length
- * \param tei the station's source TEI.
+ * \param mfs the MFS used by the reassembly process.
* \param encryption if the mac frame comes from the SAR if returns the
* state of the encryption.
*/
-void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, uint tei, bool
- encryption);
+void
+cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs,
+ bool encryption);
/**
* Receives an MME from the Upper layer.
@@ -203,9 +218,10 @@ void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, uint tei, bool
* \param buffer the MME buffer
* \param length the MME length
*/
-extern inline void cl_mme_ul_send (cl_t *ctx, u8 *buffer, uint length)
+extern inline void
+cl_mme_ul_send (cl_t *ctx, u8 *buffer, uint length)
{
- cl_mme_recv (ctx, buffer, length, MAC_TEI_FOREIGN, false);
+ cl_mme_recv (ctx, buffer, length, NULL, false);
}
/**
@@ -215,13 +231,14 @@ extern inline void cl_mme_ul_send (cl_t *ctx, u8 *buffer, uint length)
* \param ctx the cl context
* \param buffer the MME buffer
* \param length the MME length
- * \param tei the station's source TEI.
+ * \param mfs the MFS used by the reassembly process.
* \param encryption boolean informing if the MF was encrypted or not.
*/
-extern inline void cl_mme_sar_recv (cl_t *ctx, u8 *buffer, uint length,
- uint tei, bool encryption)
+extern inline void
+cl_mme_sar_recv (cl_t *ctx, u8 *buffer, uint length,
+ mfs_rx_t *mfs, bool encryption)
{
- cl_mme_recv (ctx, buffer, length, tei, encryption);
+ cl_mme_recv (ctx, buffer, length, mfs, encryption);
}
/**
@@ -231,7 +248,8 @@ extern inline void cl_mme_sar_recv (cl_t *ctx, u8 *buffer, uint length,
* \param ctx the CL context
* \param mme_recv the data provided on the previous callback.
*/
-void cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv);
+void
+cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv);
/**
* Initialize the callback to inform the upper layer when a data had been sent
@@ -241,7 +259,8 @@ void cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv);
* \param cb the callback to call once the data had been sent
* \param user the user data to provide with the callback call
*/
-void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user);
+void
+cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user);
/**
* The SAR inform the CL that the data previously provided had been sent over
@@ -251,7 +270,8 @@ void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user);
* \param buffer the buffer containing the MME
* \param cl_data the data provided to the SAR on the msdu add.
*/
-void cl_data_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
+void
+cl_data_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
/**
* Send a data from the upper layer to the SAR, this data should be sent over
@@ -261,7 +281,8 @@ void cl_data_send_done (cl_t *ctx, u8 *buffer, void *cl_data);
* \param buffer the buffer containing the data to send
* \param length the data length
*/
-void cl_data_send (cl_t *cl, u8 *buffer, uint length);
+void
+cl_data_send (cl_t *cl, u8 *buffer, uint length);
/**
* Initialize the callback to receive the data from the PLC to the upper layer.
@@ -270,7 +291,8 @@ void cl_data_send (cl_t *cl, u8 *buffer, uint length);
* \param cb the function callback to call
* \param user the user data to provide on the callback.
*/
-void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user);
+void
+cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user);
/**
* Called by the SAR each time it has a data to provide to the CL.
@@ -280,8 +302,8 @@ void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user);
* \param length the data length in the buffer
* \param mfs the mfs used to receive the data.
*/
-void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs);
-
+void
+cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs);
/**
* Provides a buffer to the CP.
@@ -289,7 +311,8 @@ void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs);
* \param cl the CL context
* \param buffer the buffer to reassembly some data
*/
-void cl_mme_buffer_add (cl_t *cl, u8 *buffer);
+void
+cl_mme_buffer_add (cl_t *cl, u8 *buffer);
/**
* Provides a buffer to the SAR to reassembly data
@@ -297,6 +320,7 @@ void cl_mme_buffer_add (cl_t *cl, u8 *buffer);
* \param cl the CL context
* \param buffer the buffer to reassembly some data
*/
-void cl_data_buffer_add (cl_t *cl, u8 *buffer);
+void
+cl_data_buffer_add (cl_t *cl, u8 *buffer);
#endif /* CL_CL_H_ */
diff --git a/cesar/cl/inc/trace.h b/cesar/cl/inc/trace.h
index 6671dbe09e..383e5f5846 100644
--- a/cesar/cl/inc/trace.h
+++ b/cesar/cl/inc/trace.h
@@ -30,6 +30,7 @@ enum
CL_TRACE_MME_SEND_AS_DATA,
CL_TRACE_MME_SEND_TO_DRIVER,
CL_TRACE_MME_SEND_DONE,
+ CL_TRACE_MME_SEND_DROP,
CL_TRACE_MME_BUFFER_ADD,
CL_TRACE_MME_RECV,
CL_TRACE_MME_RECV_DONE,
diff --git a/cesar/cl/src/cl.c b/cesar/cl/src/cl.c
index cb4667d711..3891a0d424 100644
--- a/cesar/cl/src/cl.c
+++ b/cesar/cl/src/cl.c
@@ -424,12 +424,41 @@ cl_mme_send (cl_t *ctx, u8 *buffer, uint length, uint tei)
blk_release (mfs);
}
- else
+ else if (read_u48_from_word (buffer) == ctx->mac_config->sta_mac_address)
{
CL_TRACE (MME_SEND_TO_DRIVER, mac_ntb(), length, buffer);
dbg_assert (ctx->mme_ul_send.cb);
(*ctx->mme_ul_send.cb) (ctx->mme_ul_send.user, buffer, length);
}
+ else
+ {
+ uint tei;
+ mac_t mac;
+ cl_send_t *cl_data;
+
+ if (!ctx->mac_config->authenticated)
+ {
+ cl_mme_buffer_add (ctx, buffer);
+ CL_TRACE (MME_SEND_DROP, mac_ntb(), ctx->mac_config->authenticated, buffer,
+ length);
+ }
+ else
+ {
+ mac = read_u48_from_word (buffer);
+ /* Get the TEI from the mactotei table. */
+ tei = cl_mactotei_table_find_tei_from_mac (ctx, mac & MAC_BROADCAST);
+
+ dbg_assert (tei != ctx->mac_config->tei);
+ // if the TEI is not found the packet is send as broadcast.
+
+ cl_data = cl_send_init (ctx, buffer, true /* MME. */);
+ cl_data_send_with_tei (ctx, buffer, length,
+ tei == MAC_TEI_UNASSOCIATED ? MAC_TEI_BCAST: tei,
+ cl_data);
+
+ CL_TRACE (MME_SEND_AS_DATA, mac_ntb(), length, buffer, tei);
+ }
+ }
}
/**
@@ -461,11 +490,11 @@ void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer, void *cl_data)
* \param ctx the cl context
* \param buffer the MME buffer
* \param length the MME length
- * \param tei the station's source TEI.
+ * \param mfs the MFS used by the reassembly process.
* \param encryption if the mac frame comes from the SAR if returns the
* state of the encryption.
*/
-void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, uint tei, bool
+void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs, bool
encryption)
{
dbg_assert (ctx);
@@ -478,13 +507,14 @@ void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, uint tei, bool
CL_TRACE (MME_RECV, mac_ntb(), length, buffer, ctx->mme.mme_recv.sar);
- if (tei != MAC_TEI_FOREIGN)
+ if (mfs)
ctx->mme.mme_recv.sar = true;
else
ctx->mme.mme_recv.sar = false;
- (*ctx->mme.mme_recv_cb) (ctx->mme.mme_recv_user_data, tei, buffer, length,
- &ctx->mme.mme_recv, encryption);
+ (*ctx->mme.mme_recv_cb) (ctx->mme.mme_recv_user_data,
+ mfs ? mfs->common.tei : MAC_TEI_FOREIGN,
+ buffer, length, &ctx->mme.mme_recv, encryption);
}
/**
@@ -572,8 +602,10 @@ void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user)
* \param ctx the CL context.
* \param buffer the buffer containing the data to send
* \param length the data length
+ * \param mme the boolean indicating if the buffer contains a MME or a data.
*/
-void cl_data_send (cl_t *ctx, u8 *buffer, uint length)
+static inline
+void cl_data_mme_send (cl_t *ctx, u8 *buffer, uint length, bool mme)
{
uint tei;
mac_t mac;
@@ -599,13 +631,27 @@ void cl_data_send (cl_t *ctx, u8 *buffer, uint length)
dbg_assert (tei != ctx->mac_config->tei);
// if the TEI is not found the packet is send as broadcast.
- cl_data = cl_send_init (ctx, buffer, false /* data. */);
+ cl_data = cl_send_init (ctx, buffer, mme);
cl_data_send_with_tei (ctx, buffer, length,
tei == MAC_TEI_UNASSOCIATED ? MAC_TEI_BCAST: tei,
cl_data);
}
/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PLC.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the data to send
+ * \param length the data length
+ */
+void
+cl_data_send (cl_t *ctx, u8 *buffer, uint length)
+{
+ cl_data_mme_send (ctx, buffer, length, false /* Data */);
+}
+
+/**
* Send a data once the TEI has been find.
*
* \param ctx the cl context.
diff --git a/cesar/cl/src/trace.c b/cesar/cl/src/trace.c
index e39e5a7d36..b368778745 100644
--- a/cesar/cl/src/trace.c
+++ b/cesar/cl/src/trace.c
@@ -35,6 +35,7 @@ cl_trace_init (cl_t *ctx)
TRACE_EVENT (CL_TRACE_MME_SEND_AS_DATA, "CL_MME_SEND_AS_DATA length : %d, buffer @ : %x", TIMESTAMP),
TRACE_EVENT (CL_TRACE_MME_SEND_TO_DRIVER, "CL_MME_SEND_TO_DRIVER length : %d, buffer @ : %x", TIMESTAMP),
TRACE_EVENT (CL_TRACE_MME_SEND_DONE, "CL_MME_SEND_DONE buffer : %d", TIMESTAMP),
+ TRACE_EVENT (CL_TRACE_MME_SEND_DROP, "CL_MME_SEND_DROP authenticated : %d, buffer @ : %x, length : %d", TIMESTAMP),
TRACE_EVENT (CL_TRACE_MME_BUFFER_ADD, "CL_MME_BUFFER_ADD buffer @ : %x", TIMESTAMP),
TRACE_EVENT (CL_TRACE_MME_RECV, "CL_MME_RECV length : %d, buffer @ : %x, from sar : %d", TIMESTAMP),
TRACE_EVENT (CL_TRACE_MME_RECV_DONE, "CL_MME_RECV_DONE buffer @ : %x, from sar : %d", TIMESTAMP),
diff --git a/cesar/cl/test/Makefile b/cesar/cl/test/Makefile
index cf15834875..eebd81dd16 100644
--- a/cesar/cl/test/Makefile
+++ b/cesar/cl/test/Makefile
@@ -3,8 +3,7 @@ BASE = ../..
INCLUDES = cl/test/overide
HOST_PROGRAMS = cl_mactotei_api cl_mactotei_heapsort cl_mactotei_find \
- cl_recv_data cl_send_data cl_mme_send_as_mme cl_mme_send_as_data \
- cl_mme_recv
+ cl_recv_data cl_send_data cl_send_mme cl_recv_mme
cl_mactotei_api_SOURCES = cl_mactotei_api.c phy_stub.c
cl_mactotei_api_MODULES = lib cl cl/test/overide/mac/sar mac/common \
@@ -24,16 +23,12 @@ cl_recv_data_MODULES = lib cl cl/test/overide/mac/sar mac/common mac/sar/test
cl_send_data_SOURCES = cl_send_data.c phy_stub.c
cl_send_data_MODULES = lib cl cl/test/overide/mac/sar mac/common mac/sar/test
-cl_mme_send_as_mme_SOURCES = cl_mme_send_as_mme.c phy_stub.c
-cl_mme_send_as_mme_MODULES = lib cl cl/test/overide/mac/sar mac/common \
- mac/sar/test
+cl_send_mme_SOURCES = cl_mme_send_as_mme.c phy_stub.c
+cl_send_mme_MODULES = lib cl cl/test/overide/mac/sar mac/common \
+ mac/sar/test
-cl_mme_send_as_data_SOURCES = cl_mme_send_as_data.c phy_stub.c
-cl_mme_send_as_data_MODULES = lib cl cl/test/overide/mac/sar mac/common \
- mac/sar/test
-
-cl_mme_recv_SOURCES = cl_mme_recv.c phy_stub.c
-cl_mme_recv_MODULES = lib cl cl/test/overide/mac/sar mac/common \
+cl_recv_mme_SOURCES = cl_mme_recv.c phy_stub.c
+cl_recv_mme_MODULES = lib cl cl/test/overide/mac/sar mac/common \
mac/sar/test
include $(BASE)/common/make/top.mk
diff --git a/cesar/cl/test/overide/mac/sar/sar.h b/cesar/cl/test/overide/mac/sar/sar.h
index bad2a206cd..ffcae25c2f 100644
--- a/cesar/cl/test/overide/mac/sar/sar.h
+++ b/cesar/cl/test/overide/mac/sar/sar.h
@@ -12,7 +12,7 @@
* \file sar.h
* \brief The SAR overwrite.
* \ingroup cl/test/inc/sar.h
- *
+ *
*/
#include "mac/common/mfs.h"
@@ -20,14 +20,14 @@
#include "mac/pbproc/pbproc.h"
/**
- * Segmentation job done for the segmentation module, it send a data to inform
+ * Segmentation job done for the segmentation module, it send a data to inform
* the upper layer that a job had been processed.
- *
+ *
* \param user upper layer context
* \param buffer the buffer which is no more used.
* \param length the length of the buffer.
* \param mfs the mfs correponding to the payload in the buffer.
- *
+ *
* The MFS reference is given to the CL it do not make a addref on it.
*/
typedef void (*sar_segmentation_done_cb_t) (void *user, u8* buffer,
@@ -35,12 +35,12 @@ typedef void (*sar_segmentation_done_cb_t) (void *user, u8* buffer,
/**
* Inform the upper layer that the buffer given in parameter is not used anymore.
- *
+ *
* \param user upper layer context pointer
* \param buffer the buffer which is no more used.
- * \param length the length of the buffer.
+ * \param length the length of the buffer.
* \param mfs the mfs correponding to the payload in the buffer.
- *
+ *
* The MFS reference is given to the CL it do not make a addref on it.
*/
typedef void (*sar_reassembly_done_cb_t) (void *user, u8* buffer,
@@ -73,7 +73,7 @@ void sar_uninit (sar_t *ctx);
/**
* Add the mac store to the SAR.
- *
+ *
* \param ctx the sar context
* \param mac_store the mac store ctx.
*/
@@ -84,9 +84,9 @@ bool sar_msdu_add (sar_t *sar_ctx, u8* buffer, u16 length,
/**
* Used by the upper layers to send or received messages.
- *
+ *
* \param ctx the sar context
- * \param sar_seg_done used by the segmentation to inform the upper layer the
+ * \param sar_seg_done used by the segmentation to inform the upper layer the
* buffer is not used anymore.
*/
void sar_init_segmentation_mme_cb (sar_t *ctx,
@@ -95,7 +95,7 @@ void sar_init_segmentation_mme_cb (sar_t *ctx,
/**
* Add the upper data layer context to the SAR. It allows the sar to use
* the context in the callbacks to this layer.
- *
+ *
* \param ctx the sar context
* \param user the upper layer msg context.
*/
@@ -103,7 +103,7 @@ void sar_init_mme_context (sar_t *ctx, void *user);
/**
* Initialise the callback pointer and return the contexte to the Upper layers
- *
+ *
* \param ctx the sar context
* \param sar_rea_done inform the upper layers that the buffer is filled.
* \param data a boolean to indicate if it is a data stream or not.
@@ -114,7 +114,7 @@ void sar_init_reassembly_ul (sar_t *ctx,
/**
* Initialise the callback pointer and return the contexte to the Control Plane
* to manage MME data
- *
+ *
* \param ctx the sar context
* \param sar_rea_done the function to call when the bridge DMA ends a job.
*/
@@ -127,7 +127,7 @@ extern inline void sar_init_reassembly_mme_cb (sar_t *ctx,
/**
* Add the upper data layer context to the SAR. It allows the sar to use
* the context in the callbacks to this layer.
- *
+ *
* \param ctx the sar context
* \param user the upper layer data context.
*/
@@ -135,18 +135,18 @@ void sar_init_data_context (sar_t *ctx, void *user);
/**
* Used by the upper layers to send or received data.
- *
- * \param ctx the sar context
- * \param sar_seg_done used by the segmentation to inform the upper layer the
+ *
+ * \param ctx the sar context
+ * \param sar_seg_done used by the segmentation to inform the upper layer the
* buffer is not used anymore.
*/
void sar_init_segmentation_data_cb (sar_t *ctx,
sar_segmentation_done_cb_t sar_seg_done);
/**
- * Initialise the callback pointer and return the contexte to the Convergence
+ * Initialise the callback pointer and return the contexte to the Convergence
* layer to manage data
- *
+ *
* \param ctx the sar context
* \param sar_rea_done the function to call when the bridge DMA ends a job.
*/
diff --git a/cesar/cl/test/src/cl_mme_recv.c b/cesar/cl/test/src/cl_mme_recv.c
index 8001266ca3..414c3b08d8 100644
--- a/cesar/cl/test/src/cl_mme_recv.c
+++ b/cesar/cl/test/src/cl_mme_recv.c
@@ -53,6 +53,7 @@ int main (void)
pbproc_t *pbproc;
mac_config_t *mac_config;
phy_t *phy;
+ mfs_rx_t mfs;
u8 buffer[2048];
test_init (test, 0, NULL);
@@ -70,8 +71,9 @@ int main (void)
cl_mme_recv_init (cl, cl_send_mme_to_cp, NULL);
// send a data to the CP
+ mfs_rx_init (&mfs, false, true, MAC_LID_NONE, 1);
test_mme_send_done_to_cp = false;
- cl_mme_sar_recv (cl, buffer, 1204, 1, false);
+ cl_mme_sar_recv (cl, buffer, 1204, &mfs, false);
test_begin(test, "Send done to CP from SAR")
{
diff --git a/cesar/cl/test/src/cl_mme_send_as_data.c b/cesar/cl/test/src/cl_mme_send_as_data.c
index b6c128bf58..de602ae350 100644
--- a/cesar/cl/test/src/cl_mme_send_as_data.c
+++ b/cesar/cl/test/src/cl_mme_send_as_data.c
@@ -9,13 +9,14 @@
* \file cl/test/src/cl_mme_semd_as_mme.c
* \brief Test to send mme over the PLC.
* \ingroup cl
- *
+ *
*/
#include "common/std.h"
#include "lib/test.h"
#include "lib/trace.h"
#include "lib/read_word.h"
+#include "lib/bitstream.h"
#include "cl/cl_mactotei.h"
#include "cl/cl.h"
@@ -28,6 +29,9 @@
#include "hal/phy/phy.h"
#include "cl/inc/trace.h"
+#include "cl/inc/context.h"
+
+#include "string.h"
unsigned int packet[]__attribute__((aligned(2048))) =
{ 0x001111B6, 0x1E520002, 0x00000000, 0x00000000,
@@ -41,148 +45,297 @@ unsigned int packet_len = 106;
bool test_seg_mme;
bool test_ul_mme_recv;
-bool test_add_buffer;
+bool test_buffer_add;
+void
+cl_send_release (void *object)
+{
+ test_seg_mme = true;
+}
-void test_mme_cp_add_buffer (void *user, u8 *buffer)
+void
+test_mme_buffer_add (void *cl, u8 *buffer)
{
- test_add_buffer = true;
+ test_buffer_add = true;
}
void test_mme_ul_reception_done (void *user, u8* buffer, uint length)
{
test_ul_mme_recv = true;
-
- cl_mme_buffer_add(user, buffer);
+}
+
+void
+test_mme_seg_done (void *user, u8 *buffer, void *cl_data)
+{
+ cl_send_t *data = cl_data;
+
+ slab_release (data);
}
void cl_test_send_mme_as_data_to_sar (test_t test)
{
- u8 *buffer;
-
- cl_t *cl;
- mac_store_t *mac_store;
- sar_t *sar;
- pbproc_t *pbproc;
- mac_config_t *mac_config;
- bool added;
+ u8 buffer[256];
+ mac_config_t mac_config;
+ cl_t cl;
+ mac_t mac_dest;
+ sar_t sar;
+ uint tei_dest;
cl_mactotei_blk_t *table;
- mfs_tx_t *mfs;
- phy_t *phy;
- mac_t mac;
- mac_store = mac_store_init ();
- mac_config = blk_alloc ();
- phy = blk_alloc ();
- mac_ntb_init(phy, mac_config);
- pbproc = pbproc_init (mac_config, mac_store);
- sar = sar_init (mac_store, pbproc, NULL);
+ test_case_begin (test, "Sending a MME by the data channel");
+
+ test_begin (test, "sending, Unicast with TEI.")
+ {
+ mfs_tx_t *mfs;
+ mac_dest = 0x23456789ABCDull;
+ tei_dest = 1;
+
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
+
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
+
+ /* Configure the CL. */
+ cl.mac_config = &mac_config;
+ /* Use to pass the asserts in the CL. */
+ cl.sar = &sar;
+ cl.mac_store = mac_store_init ();
+ slab_cache_init (&cl.slab_buffer_handler,
+ "CL cache", sizeof (cl_send_t),
+ cl_send_release);
+
+ /* configure the sar. */
+ sar.sar_msg_segmentation_done = test_mme_seg_done;
+ sar.ul_msg_ctx = &cl;
+
+ /* Create the table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, mac_dest, tei_dest, 0);
+ cl_mactotei_use_table (&cl, table);
+
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0, mac_dest, 48);
+
+ test_seg_mme = false;
+ cl_mme_send (&cl, buffer, 60, tei_dest);
+
+ test_fail_if (test_seg_mme == false);
+
+ cl_mactotei_release_table (&cl);
+
+ mfs = mac_store_mfs_get_tx (cl.mac_store, false, true, MAC_LID_NONE,
+ tei_dest);
+ mac_store_mfs_remove (cl.mac_store, (mfs_t *)mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (cl.mac_store, tei_dest));
+ mac_store_uninit (cl.mac_store);
+ slab_cache_uninit (&cl.slab_buffer_handler);
+ }
+ test_end;
- mac_config->tei = 10;
- cl = cl_init (mac_store, sar, mac_config);
- cl_mme_init_buffer_add_cb(cl, test_mme_cp_add_buffer, cl);
+ test_begin (test, "sending, Unicast without TEI.")
+ {
+ mfs_tx_t *mfs;
+ uint phy;
+ mac_dest = 0x23456789ABCDull;
+ tei_dest = 1;
+
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
+
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
+ mac_config.authenticated = true;
+
+ /* configure the mac ntb. */
+ mac_ntb_init ((phy_t *) &phy, &mac_config);
+
+ /* Configure the CL. */
+ cl.mac_config = &mac_config;
+ /* Use to pass the asserts in the CL. */
+ cl.sar = &sar;
+ cl.mac_store = mac_store_init ();
+ slab_cache_init (&cl.slab_buffer_handler,
+ "CL cache", sizeof (cl_send_t),
+ cl_send_release);
+
+ /* configure the sar. */
+ sar.sar_data_segmentation_done = test_mme_seg_done;
+ sar.ul_msg_ctx = &cl;
+
+ /* Create the table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, mac_dest, tei_dest, 0);
+ cl_mactotei_use_table (&cl, table);
+
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0, mac_dest, 48);
+
+ test_seg_mme = false;
+ cl_mme_send (&cl, buffer, 60, MAC_TEI_FOREIGN);
+
+ test_fail_if (test_seg_mme == false);
+
+ cl_mactotei_release_table (&cl);
+
+ mfs = mac_store_mfs_get_tx (cl.mac_store, false, false, 1, tei_dest);
+ mac_store_mfs_remove (cl.mac_store, (mfs_t *)mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (cl.mac_store, tei_dest));
+ mac_store_uninit (cl.mac_store);
+ slab_cache_uninit (&cl.slab_buffer_handler);
+ }
+ test_end;
- sar_init_segmentation_data_cb (sar, (sar_segmentation_done_cb_t) cl_data_send_done);
- sar_init_mme_context (sar, cl);
+ test_begin (test, "sending, Broadcast with TEI.")
+ {
+ mfs_tx_t *mfs;
+ mac_dest = MAC_BROADCAST;
+ tei_dest = MAC_TEI_BCAST;
+
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
+
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
+
+ /* Configure the CL. */
+ cl.mac_config = &mac_config;
+ /* Use to pass the asserts in the CL. */
+ cl.sar = &sar;
+ cl.mac_store = mac_store_init ();
+ slab_cache_init (&cl.slab_buffer_handler,
+ "CL cache", sizeof (cl_send_t),
+ cl_send_release);
+
+ /* configure the sar. */
+ sar.sar_msg_segmentation_done = test_mme_seg_done;
+ sar.ul_msg_ctx = &cl;
+
+ /* Create the table. */
+ table = cl_mactotei_new ();
+ cl_mactotei_addr_add (table, mac_dest, tei_dest, 0);
+ cl_mactotei_use_table (&cl, table);
+
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0, mac_dest, 48);
+
+ /* Add a station to the mac store. */
+ mac_store_sta_add (cl.mac_store, 2);
+
+ test_seg_mme = false;
+ cl_mme_send (&cl, buffer, 60, tei_dest);
+
+ test_fail_if (test_seg_mme == false);
+
+ cl_mactotei_release_table (&cl);
+
+ mfs = mac_store_mfs_get_tx (cl.mac_store, false, true, MAC_LID_NONE,
+ 2);
+ mac_store_mfs_remove (cl.mac_store, (mfs_t *)mfs);
+ blk_release (mfs);
+ dbg_check (mac_store_sta_remove (cl.mac_store, 2));
+ mac_store_uninit (cl.mac_store);
+ slab_cache_uninit (&cl.slab_buffer_handler);
+ }
+ test_end;
- /* create the mfs for the test. */
- mfs = mac_store_mfs_add_tx (mac_store, false, false, 1, 0x2, &added);
- dbg_assert (added);
+ test_begin (test, "sending, Unassociated with TEI.")
+ {
+ mac_dest = MAC_BROADCAST;
+ tei_dest = MAC_TEI_UNASSOCIATED;
- /* create the mactotei table */
- table = cl_mactotei_new ();
- mac = read_u32_from_word((u8*)packet) | ((u64)read_u16_from_word((u8*)packet + 4) << 32);
- cl_mactotei_addr_add (table,mac, 2, 2);
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
- cl_mactotei_use_table (cl, table);
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
- test_seg_mme = false;
- test_add_buffer = false;
- buffer = (u8 *) packet;
- cl_mme_send (cl, buffer, packet_len, MAC_TEI_FOREIGN);
+ /* Configure the CL. */
+ cl.mac_config = &mac_config;
+ /* Use to pass the asserts in the CL. */
+ cl.sar = &sar;
+ slab_cache_init (&cl.slab_buffer_handler,
+ "CL cache", sizeof (cl_send_t),
+ cl_send_release);
- test_begin (test, "add buffer")
- {
- test_fail_if (test_add_buffer == false, "no buffer added");
+ /* configure the sar. */
+ sar.sar_msg_segmentation_done = test_mme_seg_done;
+ sar.ul_msg_ctx = &cl;
+
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0, mac_dest, 48);
+
+ test_seg_mme = false;
+ cl_mme_send (&cl, buffer, 60, tei_dest);
+
+ test_fail_if (test_seg_mme == false);
+
+ slab_cache_uninit (&cl.slab_buffer_handler);
}
test_end;
- mac_store_mfs_remove (mac_store, (mfs_t *) mfs);
- blk_release (mfs);
- // release the associate STA.
- bool done = mac_store_sta_remove (mac_store, 0x2);
- dbg_check (done);
- mac_store_uninit (mac_store);
+ test_begin (test, "sending, Foreign TEI no authenticated.")
+ {
+ mac_dest = MAC_BROADCAST;
+ tei_dest = MAC_TEI_FOREIGN;
+
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
- pbproc_uninit (pbproc);
- blk_release (mac_config);
- blk_release (phy);
- sar_uninit (sar);
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
- cl_trace_print (cl);
- cl_uninit (cl);
+ /* Configure the CL. */
+ cl.mac_config = &mac_config;
+ cl.sar = &sar;
+ cl.mme.mme_buffer_add_cb = test_mme_buffer_add;
- test_begin (test, "Memory test")
- {
- test_fail_if (blk_check_memory() == false, "Memory not freed");
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0, mac_dest, 48);
+
+ test_buffer_add = false;
+ cl_mme_send (&cl, buffer, 60, tei_dest);
+
+ test_fail_if (test_buffer_add == false);
}
test_end;
}
void cl_test_send_mme_as_data_to_hle (test_t test)
{
- u8 *buffer;
-
- cl_t *cl;
- mac_store_t *mac_store;
- sar_t *sar;
- pbproc_t *pbproc;
- mac_config_t *mac_config;
- cl_mactotei_blk_t *table;
-
- mac_store = mac_store_init ();
- mac_config = blk_alloc ();
- pbproc = pbproc_init (mac_config, mac_store);
- sar = sar_init (mac_store, pbproc, NULL);
-
- mac_config->tei = 10;
- cl = cl_init (mac_store, sar, mac_config);
- cl_mme_init_ul_as_data(cl,test_mme_ul_reception_done , cl);
- cl_mme_init_buffer_add_cb(cl, test_mme_cp_add_buffer, cl);
+ u8 buffer[256];
+ mac_config_t mac_config;
+ cl_t cl;
+ uint sar;
- sar_init_segmentation_data_cb (sar, (sar_segmentation_done_cb_t) cl_data_send_done);
- sar_init_mme_context (sar, cl);
+ test_case_begin (test, "Sending a MME by the data channel");
- /* create the mactotei table */
- table = cl_mactotei_new ();
- cl_mactotei_addr_add (table, 0x001111B60002ull, 10, 10);
+ test_begin (test, "sending, send to upper layer.")
+ {
+ memset (&cl, 0, sizeof (cl_t));
+ memset (&mac_config, 0, sizeof (mac_config_t));
- cl_mactotei_use_table (cl, table);
- test_ul_mme_recv = false;
- test_add_buffer = false;
- buffer = (u8 *) packet;
- cl_mme_send (cl, buffer, packet_len, MAC_TEI_FOREIGN);
+ cl.mac_config = &mac_config;
+ /* Use to pass the asserts in the CL. */
+ cl.sar = (sar_t *) &sar;
- test_begin (test, "Send mme test")
- {
- test_fail_if (test_ul_mme_recv == false, "not send");
- test_fail_if (test_add_buffer == false, "no buffer added");
- }
- test_end;
+ /* Configuring the mac config. */
+ mac_config.sta_mac_address = 0x123456789ABCull;
- mac_store_uninit (mac_store);
+ /* Configure the Call back. */
+ cl.mme_ul_send.cb = test_mme_ul_reception_done;
- pbproc_uninit (pbproc);
- blk_release (mac_config);
- sar_uninit (sar);
+ /* Add the station mac address to the buffer. */
+ bitstream_direct_write_large (buffer, 0,
+ mac_config.sta_mac_address, 48);
- cl_trace_print (cl);
- cl_uninit (cl);
+ test_ul_mme_recv = false;
+ cl_mme_send (&cl, buffer, 60, MAC_TEI_FOREIGN);
- test_begin (test, "Memory test")
- {
- test_fail_if (blk_check_memory() == false, "Memory not freed");
+ test_fail_if (test_ul_mme_recv == false);
}
test_end;
}
@@ -190,7 +343,7 @@ void cl_test_send_mme_as_data_to_hle (test_t test)
int main (void)
{
test_t test;
-
+
test_init (test, 0, NULL);
trace_init ();
@@ -200,3 +353,4 @@ int main (void)
test_result (test);
return test_nb_failed (test) == 0 ? 0 : 1;
}
+