summaryrefslogtreecommitdiff
path: root/hle/test/overide/cl/src/cl.c
diff options
context:
space:
mode:
Diffstat (limited to 'hle/test/overide/cl/src/cl.c')
-rw-r--r--hle/test/overide/cl/src/cl.c209
1 files changed, 209 insertions, 0 deletions
diff --git a/hle/test/overide/cl/src/cl.c b/hle/test/overide/cl/src/cl.c
new file mode 100644
index 0000000000..e0cfdee329
--- /dev/null
+++ b/hle/test/overide/cl/src/cl.c
@@ -0,0 +1,209 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cl.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <stdlib.h>
+
+#include "cl/cl.h"
+#include "cl/inc/cl.h"
+
+static cl_t cl_global;
+
+/**
+ * Init the Convergence Layer and return a pointer on the CL context.
+ *
+ * \param mac_store the mac store.
+ * \param sar the sar context.
+ * \return the convergence layer context.
+ */
+cl_t *cl_init (mac_store_t *mac_store, sar_t *sar)
+{
+ return &cl_global;
+}
+
+/**
+ * Initialize the callback to receive the data from the PLC.
+ *
+ * \param cl the CL context
+ * \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)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+
+ cl->data_rx.cb = cb;
+ cl->data_rx.user = user;
+}
+
+/**
+ * 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_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+
+ cl->data_tx.cb = cb;
+ cl->data_tx.user = user;
+}
+
+/**
+ * Initialize the CL to send MMEs to the Upper layer considered as data.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \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_send_ul_cb_t cb, void *user)
+{
+ dbg_assert (ctx);
+ dbg_assert (cb);
+
+ ctx->mme_ul_send.cb = cb;
+ ctx->mme_ul_send.user = user;
+ ctx->mme_ul_send.mme_buffer = NULL;
+}
+
+/**
+ * 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
+ */
+void cl_data_send (cl_t *cl, u8 *buffer, uint length)
+{
+ dbg_assert (cl);
+
+ cl_data_send_done (cl, buffer);
+}
+
+/**
+ * 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_send_done (void *ctx, u8 *buffer)
+{
+ cl_t *cl;
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ cl = (cl_t *) ctx;
+
+ /* Compare the buffer address with the MME buffer address. */
+ if (cl->mme_ul_send.mme_buffer == buffer)
+ {
+ dbg_assert (cl->mme.mme_send_done_cb);
+ (*cl->mme.mme_send_done_cb) (cl->mme.mme_send_done_user_data, buffer);
+ cl->mme_ul_send.mme_buffer = NULL;
+ }
+ else
+ {
+ dbg_assert (cl->data_tx.cb);
+ (*cl->data_tx.cb) (cl->data_tx.user, buffer);
+ }
+}
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_data (cl_t *cl, u8 *buffer)
+{
+ dbg_assert (cl);
+ dbg_assert (buffer);
+
+ free (buffer);
+
+ return true;
+}
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_mme (cl_t *cl, u8 *buffer)
+{
+ dbg_assert (cl);
+ dbg_assert (buffer);
+
+ free (buffer);
+
+ return true;
+}
+
+/**
+ * Receives an MME from the Upper layer.
+ * It will provide this MME to the Control Plane to be processed.
+ *
+ * \param ctx the cl context
+ * \param buffer the MME buffer
+ * \param length the MME length
+ */
+void cl_mme_ul_recv (cl_t *ctx, u8 *buffer, uint length)
+{
+ dbg_assert (ctx->mme.ul_mme_recv_done);
+
+ (*ctx->mme.ul_mme_recv_done) (ctx->mme.ul_mme_recv_done_user_data,
+ buffer);
+}
+
+/**
+ * Initialize the CL to call the Upper layer once the CP ends processing the
+ * MME.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \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_recv_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
+ void *user)
+{
+ dbg_assert (ctx);
+ dbg_assert (cb);
+
+ ctx->mme.ul_mme_recv_done = cb;
+ ctx->mme.ul_mme_recv_done_user_data = user;
+}
+
+
+/**
+ * Uninit the Convergence layer context.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_uninit (cl_t *ctx)
+{
+
+}