summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cl/cl.h37
-rw-r--r--cl/cl_mactotei.h30
-rw-r--r--cl/inc/cl.h32
-rw-r--r--cl/inc/cl_mactotei.h30
-rw-r--r--cl/inc/context.h17
-rw-r--r--cl/src/cl.c133
-rw-r--r--cl/test/cl_mactotei/Makefile8
-rw-r--r--cl/test/cl_mactotei/src/cl_mactotei_api.c2
-rw-r--r--cl/test/cl_mactotei/src/cl_mactotei_find.c4
-rw-r--r--cl/test/cl_mactotei/src/cl_mactotei_heapsort.c2
-rw-r--r--cl/test/mme_part/Makefile4
-rw-r--r--cl/test/mme_part/src/test_mme_interface.c11
-rw-r--r--cl/test/overide/mac/sar/sar.h36
-rw-r--r--cl/test/overide/mac/sar/src/sar.c59
14 files changed, 342 insertions, 63 deletions
diff --git a/cl/cl.h b/cl/cl.h
index bc96453b43..0409bba3c8 100644
--- a/cl/cl.h
+++ b/cl/cl.h
@@ -16,21 +16,33 @@
*/
#include "mac/common/mfs.h"
+#include "mac/common/store.h"
#include "cl/cl_mme_callback.h"
#include "cl/cl_mactotei.h"
#include "lib/utils.h"
+/** forward declaration. */
typedef struct cl_t cl_t;
/**
+ * Callback use to inform the upper layer when a data hab been sent over the
+ * PLC.
+ *
+ * \param user the user data
+ * \param buffer the buffer use to send the data over the PLC.
+ */
+typedef void (*cl_data_sent_cb_t) (void *user, u8 *buffer);
+
+/**
* Init the Convergence Layer and return a pointer on the CL context.
*
* \msc
* OL,CL,SAR,rnd,CL_MME;
*
- * OL->CL [label = "cl_init ()"];
+ * OL->CL [label = "cl_init (mac_store)"];
* CL->SAR [label = "sar_init ()"];
* CL<<SAR [label = "sar_t *ctx"];
+ * CL->SAR [label = "sar_init_mac_store (sar, mac_store)"];
* CL->SAR [label = "sar_init_mme_context(sar_ctx, cl_ctx)"];
* CL->SAR [label = "sar_init_segmentation_mme_cb (sar, cl_mme_sent_intern)"];
* CL->SAR [label = "sar_init_reassembly_mme_cb (sar, cl_mme_recv)"];
@@ -42,7 +54,7 @@ typedef struct cl_t cl_t;
*
* \return the convergence layer context.
*/
-cl_t *cl_init (void);
+cl_t *cl_init (mac_store_t *mac_store);
/**
* Uninit the Convergence layer context.
@@ -269,13 +281,24 @@ void cl_mactotei_use_table (cl_t *cl, cl_mactotei_blk_t *table);
void cl_mactotei_release_table (cl_t *cl);
/**
- * Find a mac address in the table using a dichotomy search
+ * Initialize the callback to inform the upper layer when a data had been sent
+ * over the PLC.
*
- * \param cl the convergence layer context.
- * \return the tei corresponding to the mac address if known otherwise it
- * returns 0xff a broadcast tei (see HPAV section 5.3.1.2)
+ * \param cl the CL context
+ * \param cb the callback to call once the data had been sent
+ * \param user the user data to provide with the callback call
*/
-uint cl_mactotei_table_find_tei_from_mac (cl_t *cl, mac_t mac);
+void cl_data_sent_init (cl_t *cl, cl_data_sent_cb_t cb, void *user);
+/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PLC.
+ *
+ * \param cl the CL context.
+ * \param buffer the buffer containing the data to send
+ * \param length the data length
+ * \param u32 ats_ntb the ats of the data
+ */
+void cl_data_send (cl_t *cl, u8 *buffer, uint length, u32 ats_ntb);
#endif /* CL_CL_H_ */
diff --git a/cl/cl_mactotei.h b/cl/cl_mactotei.h
index bd6f2ca030..83f8da20d6 100644
--- a/cl/cl_mactotei.h
+++ b/cl/cl_mactotei.h
@@ -19,4 +19,34 @@ typedef struct cl_mactotei_table_t cl_mactotei_table_t;
typedef struct cl_mactotei_blk_t cl_mactotei_blk_t;
typedef struct cl_mactotei_t cl_mactotei_t;
+/**
+ * Create a new table to be filled by the CP.
+ *
+ * \return a pointer to the new block to be fill with the mac to tei table
+ * data
+ */
+cl_mactotei_blk_t *cl_mactotei_new (void);
+
+/**
+ * Request the CL to copy all the data without the coresponding one provide in
+ * this function paramater.
+ *
+ * \param table_old the table actually use by the CL
+ * \param table the mactotei new table to fill
+ * \param tag the tag to exclude from the copy
+ */
+void cl_mactotei_copy (cl_mactotei_table_t *table_old,
+ cl_mactotei_blk_t *table, u8 tag);
+
+/**
+ * Add a new tupple of data to the table.
+ *
+ * \param table the table pointer to add a new mac to tei correspondance.
+ * \param mac_addr the mac addr to add
+ * \param tei the tei corresponding to the STA.
+ * \param tag the CP tag provide to indentifier a network.
+ */
+void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
+ uint tei, uint tag);
+
#endif /*CL_MACTOTEI_H_*/
diff --git a/cl/inc/cl.h b/cl/inc/cl.h
index dd4841b58c..1f1fb9405f 100644
--- a/cl/inc/cl.h
+++ b/cl/inc/cl.h
@@ -13,7 +13,7 @@
* \brief private function for the CL
* \ingroup cl/inc
*
- */
+ */
#include "cl/cl_mactotei.h"
@@ -25,4 +25,34 @@
*/
void cl_mactotei_switch_table (cl_t *cl, cl_mactotei_table_t *table);
+/**
+ * Find a mac address in the table using a dichotomy search
+ *
+ * \param cl the convergence layer context.
+ * \return the tei corresponding to the mac address if known otherwise it
+ * returns 0xff a broadcast tei (see HPAV section 5.3.1.2)
+ */
+uint cl_mactotei_table_find_tei_from_mac (cl_t *cl, mac_t mac);
+
+/**
+ * Search for the lid in the classifier
+ *
+ * \param cl CL context
+ * \param bcast put true if the link is a bcast one, false otherwise.
+ * \param tei the tei found previously by the mactotei table.
+ * \param acs put true if the link should be process by the acs
+ * \param drop put true if the data should be drop.
+ */
+uint cl_classifer_get_lid (cl_t *cl, uint tei, bool *bcast, bool *acs,
+ bool *drop);
+
+/**
+ * The SAR inform the CL that the data previously provided had been sent over
+ * the PLC.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the MME
+ */
+void cl_data_sent (void *ctx, u8 *buffer);
+
#endif /*CL_INC_CL_H_*/
diff --git a/cl/inc/cl_mactotei.h b/cl/inc/cl_mactotei.h
index 9d884d2241..67c5a139a9 100644
--- a/cl/inc/cl_mactotei.h
+++ b/cl/inc/cl_mactotei.h
@@ -65,36 +65,6 @@ struct cl_mactotei_table_t
};
/**
- * Create a new table to be filled by the CP.
- *
- * \return a pointer to the new block to be fill with the mac to tei table
- * data
- */
-cl_mactotei_blk_t *cl_mactotei_new (void);
-
-/**
- * Request the CL to copy all the data without the coresponding one provide in
- * this function paramater.
- *
- * \param table_old the table actually use by the CL
- * \param table the mactotei new table to fill
- * \param tag the tag to exclude from the copy
- */
-void cl_mactotei_copy (cl_mactotei_table_t *table_old,
- cl_mactotei_blk_t *table, u8 tag);
-
-/**
- * Add a new tupple of data to the table.
- *
- * \param table the table pointer to add a new mac to tei correspondance.
- * \param mac_addr the mac addr to add
- * \param tei the tei corresponding to the STA.
- * \param tag the CP tag provide to indentifier a network.
- */
-void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
- uint tei, uint tag);
-
-/**
* Genrate the table which will be use by the CL.
*
* \param table the new table to use.
diff --git a/cl/inc/context.h b/cl/inc/context.h
index 5b88d2ad22..cc1d7a6b7d 100644
--- a/cl/inc/context.h
+++ b/cl/inc/context.h
@@ -17,15 +17,29 @@
#include "lib/rnd.h"
#include "mac/common/mfs.h"
+#include "mac/common/store.h"
#include "mac/sar/sar.h"
#include "cl/inc/mme.h"
#include "cl/inc/cl_mactotei.h"
+/** data tx structure. */
+struct cl_data_tx_t
+{
+ /** the callback function to use once the data hab been sent. */
+ cl_data_sent_cb_t cb;
+ /** user data to provide with the callback. */
+ void *user;
+};
+typedef struct cl_data_tx_t cl_data_tx_t;
+
struct cl_t
{
/** The sar context use to send the MME or data. */
sar_t *sar;
+
+ /** Mac store reference. */
+ mac_store_t *mac_store;
/** randome value generator to generate the confounder for the MME. */
lib_rnd_t random_generator;
@@ -35,6 +49,9 @@ struct cl_t
/** mactotei table to send data over the PLC. */
cl_mactotei_table_t *mactotei;
+
+ /** send data context. */
+ cl_data_tx_t data_tx;
};
#endif /* CL_INC_CONTEXT_H_ */
diff --git a/cl/src/cl.c b/cl/src/cl.c
index d1ce3d5928..87d460a07b 100644
--- a/cl/src/cl.c
+++ b/cl/src/cl.c
@@ -29,9 +29,10 @@ static struct cl_t cl_global;
* \msc
* OL,CL,SAR,rnd,CL_MME;
*
- * OL->CL [label = "cl_init ()"];
+ * OL->CL [label = "cl_init (mac_store)"];
* CL->SAR [label = "sar_init ()"];
* CL<<SAR [label = "sar_t *ctx"];
+ * CL->SAR [label = "sar_init_mac_store (sar, mac_store)"];
* CL->SAR [label = "sar_init_mme_context(sar_ctx, cl_ctx)"];
* CL->SAR [label = "sar_init_segmentation_mme_cb (sar, cl_mme_sent_intern)"];
* CL->SAR [label = "sar_init_reassembly_mme_cb (sar, cl_mme_recv)"];
@@ -43,14 +44,23 @@ static struct cl_t cl_global;
*
* \return the convergence layer context.
*/
-cl_t *cl_init (void)
+cl_t *cl_init (mac_store_t *mac_store)
{
+ cl_global.mac_store = mac_store;
+
/* Initialize the SAR */
cl_global.sar = sar_init ();
+ sar_init_mac_store (cl_global.sar, mac_store);
+
+ // MME part
sar_init_mme_context (cl_global.sar, &cl_global);
sar_init_segmentation_mme_cb (cl_global.sar, cl_mme_sent);
sar_init_reassembly_mme_cb (cl_global.sar, cl_mme_recv);
+ // Data TX part
+ sar_init_data_context (cl_global.sar, &cl_global);
+ sar_init_segmentation_data_cb (cl_global.sar, cl_data_sent);
+
/* Initialize the random generator */
lib_rnd_init (&cl_global.random_generator, 12345678);
@@ -270,8 +280,8 @@ void cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv)
* \param table the mactotei new table to fill
* \param tag the tag to exclude from the copy
*/
-void cl_mactotei_copy_table_excluding_tag (cl_t *cl, cl_mactotei_blk_t *table,
- u8 tag)
+void cl_mactotei_copy_table_excluding_tag (cl_t *cl,
+ cl_mactotei_blk_t *table, u8 tag)
{
dbg_assert (cl);
dbg_assert (cl->mactotei);
@@ -337,8 +347,8 @@ void cl_mactotei_release_table (cl_t *cl)
{
dbg_assert (cl);
dbg_assert (cl->mactotei);
-
- cl_mactotei_release_table_intern(cl->mactotei);
+
+ cl_mactotei_release_table_intern (cl->mactotei);
cl->mactotei = NULL;
}
@@ -353,17 +363,17 @@ uint cl_mactotei_table_find_tei_from_mac (cl_t *cl, mac_t mac)
{
uint index;
cl_mactotei_t mactotei;
-
+
dbg_assert (cl);
dbg_assert (cl->mactotei);
DICHOTOMY_SEARCH (0, cl->mactotei->nb_total, index, mac
<= cl_mactotei_table_get_mac_at (cl->mactotei, index));
-
+
if (index < cl->mactotei->nb_total)
{
mactotei = cl_mactotei_table_get_mactotei_at (cl->mactotei, index);
-
+
if (mactotei.mac != mac)
{
return 0xff;
@@ -373,6 +383,109 @@ uint cl_mactotei_table_find_tei_from_mac (cl_t *cl, mac_t mac)
return mactotei.tei;
}
}
-
+
return 0xff;
}
+
+/**
+ * Search for the lid in the classifier
+ *
+ * \param cl CL context
+ * \param bcast put true if the link is a bcast one, false otherwise.
+ * \param tei the tei found previously by the mactotei table.
+ * \param acs put true if the link should be process by the acs
+ * \param drop put true if the data should be drop.
+ */
+uint cl_classifer_get_lid (cl_t *cl, uint tei, bool *bcast, bool *acs,
+ bool *drop)
+{
+ if (tei == 0xff)
+ {
+ *bcast = true;
+ }
+ else
+ {
+ bcast = false;
+ }
+
+ *acs = false;
+ *drop = false;
+
+ return 1;
+}
+
+/**
+ * Initialize the callback to inform the upper layer when a data had been sent
+ * over the PLC.
+ *
+ * \param cl the CL context
+ * \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_sent_init (cl_t *cl, cl_data_sent_cb_t cb, void *user)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+
+ cl->data_tx.cb = cb;
+ cl->data_tx.user = user;
+}
+
+/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PLC.
+ *
+ * \param cl the CL context.
+ * \param buffer the buffer containing the data to send
+ * \param length the data length
+ * \param u32 ats_ntb the ats of the data
+ */
+void cl_data_send (cl_t *cl, u8 *buffer, uint length, u32 ats_ntb)
+{
+ uint tei;
+ uint lid;
+ bool bcast;
+ bool acs;
+ bool drop;
+
+ mfs_tx_t *mfs;
+
+ dbg_assert (cl);
+ dbg_assert (buffer);
+ dbg_assert (length >= 64 && length <= 1518);
+ dbg_assert (ats_ntb);
+ dbg_assert (cl->mactotei);
+ dbg_assert (cl->sar);
+ dbg_assert (cl->mac_store);
+
+ /* Get the TEI from the mactotei table. */
+ tei = cl_mactotei_table_find_tei_from_mac (cl, *((mac_t *)buffer) & 0x0000FFFFFFFFFFFFull);
+
+ /* Get some data from the classifier. */
+ lid = cl_classifer_get_lid (cl, tei, &bcast, &acs, &drop);
+
+ /* try to get the mfs from the store. */
+ mfs = mac_store_mfs_get_tx (cl->mac_store, bcast, false, lid, tei);
+
+ if (!drop && !acs && mfs)
+ {
+ sar_msdu_add (cl->sar, buffer, length, ats_ntb, mfs);
+ }
+}
+
+/**
+ * The SAR inform the CL that the data previously provided had been sent over
+ * the PLC.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the MME
+ */
+void cl_data_sent (void *ctx, u8 *buffer)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ dbg_assert (((cl_t *)ctx)->data_tx.cb);
+
+ (*((cl_t *)ctx)->data_tx.cb) (((cl_t *)ctx)->data_tx.user, buffer);
+}
diff --git a/cl/test/cl_mactotei/Makefile b/cl/test/cl_mactotei/Makefile
index be7c6b04e3..fa3ab0e032 100644
--- a/cl/test/cl_mactotei/Makefile
+++ b/cl/test/cl_mactotei/Makefile
@@ -1,16 +1,18 @@
BASE = ../../..
+COV = y
+
INCLUDES = cl/test/overide/
HOST_PROGRAMS = cl_mactotei_api cl_mactotei_heapsort cl_mactotei_find
cl_mactotei_api_SOURCES = cl_mactotei_api.c
-cl_mactotei_api_MODULES = lib cl cl/test/overide/mac/sar
+cl_mactotei_api_MODULES = lib cl cl/test/overide/mac/sar mac/common
cl_mactotei_heapsort_SOURCES = cl_mactotei_heapsort.c
-cl_mactotei_heapsort_MODULES = lib cl cl/test/overide/mac/sar
+cl_mactotei_heapsort_MODULES = lib cl cl/test/overide/mac/sar mac/common
cl_mactotei_find_SOURCES = cl_mactotei_find.c
-cl_mactotei_find_MODULES = lib cl cl/test/overide/mac/sar
+cl_mactotei_find_MODULES = lib cl cl/test/overide/mac/sar mac/common
include $(BASE)/common/make/top.mk
diff --git a/cl/test/cl_mactotei/src/cl_mactotei_api.c b/cl/test/cl_mactotei/src/cl_mactotei_api.c
index e21a1d3cdc..264aa5be1c 100644
--- a/cl/test/cl_mactotei/src/cl_mactotei_api.c
+++ b/cl/test/cl_mactotei/src/cl_mactotei_api.c
@@ -30,7 +30,7 @@ int main (void)
test_init (test, 0, NULL);
- cl = cl_init ();
+ cl = cl_init (mac_store_init());
test_case_begin (test, "Init mactotei table");
diff --git a/cl/test/cl_mactotei/src/cl_mactotei_find.c b/cl/test/cl_mactotei/src/cl_mactotei_find.c
index 78b820cfe9..ab28abe57b 100644
--- a/cl/test/cl_mactotei/src/cl_mactotei_find.c
+++ b/cl/test/cl_mactotei/src/cl_mactotei_find.c
@@ -19,6 +19,7 @@
#include "cl/cl.h"
#include "cl/inc/cl_mactotei.h"
+#include "cl/inc/cl.h"
#include "cl/inc/context.h"
#include <stdio.h>
@@ -31,7 +32,7 @@ int main (void)
uint count;
test_init (test, 0, NULL);
- cl = cl_init ();
+ cl = cl_init (mac_store_init());
table = cl_mactotei_new ();
for (count = 0; count < 120; count ++)
@@ -49,6 +50,7 @@ int main (void)
}
}
test_end;
+ cl_mactotei_table_find_tei_from_mac(cl, count * 2);
test_begin (test, "Search for a mac @ which does not exists")
{
diff --git a/cl/test/cl_mactotei/src/cl_mactotei_heapsort.c b/cl/test/cl_mactotei/src/cl_mactotei_heapsort.c
index 7f1ca05a53..00e2f2cc31 100644
--- a/cl/test/cl_mactotei/src/cl_mactotei_heapsort.c
+++ b/cl/test/cl_mactotei/src/cl_mactotei_heapsort.c
@@ -36,7 +36,7 @@ int main (void)
lib_rnd_init (&rnd1, 12345678);
lib_rnd_init (&rnd2, 23456789);
- cl = cl_init ();
+ cl = cl_init (mac_store_init());
table = cl_mactotei_new ();
diff --git a/cl/test/mme_part/Makefile b/cl/test/mme_part/Makefile
index 4fc7d1f447..d414a06c7e 100644
--- a/cl/test/mme_part/Makefile
+++ b/cl/test/mme_part/Makefile
@@ -6,6 +6,6 @@ INCLUDES = cl/test/overide/
HOST_PROGRAMS = mme_interface
mme_interface_SOURCES = test_mme_interface.c
-mme_interface_MODULES = lib cl cl/test/overide/mac/sar
-
+mme_interface_MODULES = lib cl cl/test/overide/mac/sar mac/common
+
include $(BASE)/common/make/top.mk
diff --git a/cl/test/mme_part/src/test_mme_interface.c b/cl/test/mme_part/src/test_mme_interface.c
index 5f906b25ee..95c9175da9 100644
--- a/cl/test/mme_part/src/test_mme_interface.c
+++ b/cl/test/mme_part/src/test_mme_interface.c
@@ -52,13 +52,16 @@ int main (void)
u8 buffer;
mfs_tx_t *mfs_tx;
mfs_rx_t *mfs_rx;
+ mac_store_t *mac_store;
test_t test;
test_init (test, 0, NULL);
- ctx = cl_init ();
+ mac_store = mac_store_init();
+ ctx = cl_init (mac_store);
mfs_tx = (mfs_tx_t *) blk_alloc ();
+ mfs_tx->common.mme = true;
bool_send_done = false;
cl_mme_send (ctx, &buffer, 70, mfs_tx, cl_mme_send_done, NULL);
@@ -72,7 +75,7 @@ int main (void)
blk_release (mfs_tx);
// second test
- ctx = cl_init ();
+ ctx = cl_init (mac_store);
test_case_begin (test, "cl mme send to HLE");
bool_ul_send_mme = false;
@@ -88,7 +91,7 @@ int main (void)
cl_uninit (ctx);
// third test
- ctx = cl_init ();
+ ctx = cl_init (mac_store);
cl_mme_recv_init (ctx, cp_mme_received, NULL);
test_case_begin (test, "cl mme received");
@@ -104,7 +107,7 @@ int main (void)
cl_uninit (ctx);
//fourth test
- ctx = cl_init ();
+ ctx = cl_init (mac_store);
test_case_begin (test, "cl mme received");
/* The HLE call the cl_mme_recv function. */
diff --git a/cl/test/overide/mac/sar/sar.h b/cl/test/overide/mac/sar/sar.h
index b55897b018..a97964be56 100644
--- a/cl/test/overide/mac/sar/sar.h
+++ b/cl/test/overide/mac/sar/sar.h
@@ -16,6 +16,7 @@
*/
#include "mac/common/mfs.h"
+#include "mac/common/store.h"
/**
* Segmentation job done for the segmentation module, it send a data to inform
@@ -45,6 +46,12 @@ typedef void (*sar_reassembly_done_cb_t) (void *user, u8* buffer,
uint length, mfs_rx_t *mfs);
+struct sar_expiration_t
+{
+ mac_store_t *mfs_store;
+};
+typedef struct sar_expiration_t sar_expiration_t;
+
struct sar_t
{
void *ul_data_ctx;
@@ -54,6 +61,8 @@ struct sar_t
sar_segmentation_done_cb_t sar_data_segmentation_done;
sar_reassembly_done_cb_t sar_rea_mme_done;
+
+ sar_expiration_t expiration;
};
typedef struct sar_t sar_t;
@@ -63,6 +72,14 @@ sar_init (void);
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.
+ */
+void sar_init_mac_store (sar_t *ctx, mac_store_t *mac_store);
+
bool
sar_msdu_add(sar_t *sar_ctx, u8* buffer, u16 length,
u32 ats_confounder, mfs_tx_t *mfs);
@@ -109,4 +126,23 @@ extern inline void sar_init_reassembly_mme_cb (
sar_init_reassembly_ul (ctx, sar_rea_done, false);
}
+/**
+ * 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.
+ */
+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
+ * buffer is not used anymore.
+ */
+void sar_init_segmentation_data_cb (sar_t *ctx,
+ sar_segmentation_done_cb_t sar_seg_done);
+
#endif /*SAR_H_*/
diff --git a/cl/test/overide/mac/sar/src/sar.c b/cl/test/overide/mac/sar/src/sar.c
index d270ac7ed4..bdd13823ba 100644
--- a/cl/test/overide/mac/sar/src/sar.c
+++ b/cl/test/overide/mac/sar/src/sar.c
@@ -37,9 +37,17 @@ bool sar_msdu_add (sar_t *sar_ctx, u8* buffer, u16 length,
{
dbg_assert (sar_ctx);
dbg_assert (mfs);
- dbg_assert (sar_ctx->sar_msg_segmentation_done);
- (*sar_ctx->sar_msg_segmentation_done) (sar_ctx->ul_msg_ctx, buffer);
+ if (mfs->common.mme)
+ {
+ dbg_assert (sar_ctx->sar_msg_segmentation_done);
+ (*sar_ctx->sar_msg_segmentation_done) (sar_ctx->ul_msg_ctx, buffer);
+ }
+ else
+ {
+ dbg_assert (sar_ctx->sar_data_segmentation_done);
+ (*sar_ctx->sar_data_segmentation_done) (sar_ctx->ul_msg_ctx, buffer);
+ }
return true;
}
@@ -83,7 +91,52 @@ void sar_init_reassembly_ul (sar_t *ctx,
sar_reassembly_done_cb_t sar_rea_done, bool data)
{
dbg_assert (ctx);
-
+
if (!data)
ctx->sar_rea_mme_done = sar_rea_done;
}
+
+/**
+ * Add the mac store to the SAR.
+ *
+ * \param ctx the sar context
+ * \param mac_store the mac store ctx.
+ */
+void sar_init_mac_store (sar_t *ctx, mac_store_t *mac_store)
+{
+ dbg_assert (ctx);
+ dbg_assert (mac_store);
+
+ // init the mac store ctx in the sar.
+ ctx->expiration.mfs_store = mac_store;
+}
+
+/**
+ * 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.
+ */
+void sar_init_data_context (sar_t *ctx, void *user)
+{
+ dbg_assert (ctx);
+
+ ctx->ul_data_ctx = 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
+ * buffer is not used anymore.
+ */
+void sar_init_segmentation_data_cb (sar_t *ctx,
+ sar_segmentation_done_cb_t sar_seg_done)
+{
+ dbg_assert (ctx);
+ dbg_assert (ctx->ul_data_ctx);
+
+ ctx->sar_data_segmentation_done = sar_seg_done;
+}