summaryrefslogtreecommitdiff
path: root/hle/test/overide
diff options
context:
space:
mode:
Diffstat (limited to 'hle/test/overide')
-rw-r--r--hle/test/overide/cl/Module1
-rw-r--r--hle/test/overide/cl/cl.h173
-rw-r--r--hle/test/overide/cl/inc/cl.h83
-rw-r--r--hle/test/overide/cl/src/cl.c209
-rw-r--r--hle/test/overide/hal/hle/Module1
-rw-r--r--hle/test/overide/hal/hle/ipmbox.h32
-rw-r--r--hle/test/overide/hal/hle/src/ipmbox.c32
7 files changed, 531 insertions, 0 deletions
diff --git a/hle/test/overide/cl/Module b/hle/test/overide/cl/Module
new file mode 100644
index 0000000000..b0caf505d6
--- /dev/null
+++ b/hle/test/overide/cl/Module
@@ -0,0 +1 @@
+SOURCES := cl.c \ No newline at end of file
diff --git a/hle/test/overide/cl/cl.h b/hle/test/overide/cl/cl.h
new file mode 100644
index 0000000000..525eb3936d
--- /dev/null
+++ b/hle/test/overide/cl/cl.h
@@ -0,0 +1,173 @@
+#ifndef test_overide_cl_cl_h
+#define test_overide_cl_cl_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/overide/cl/cl.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+typedef struct cl_t cl_t;
+typedef uint cl_mme_recv_t;
+
+// for the tests;
+typedef uint mac_store_t;
+typedef uint sar_t;
+
+/**
+ * Callback to provide a received data to the upper layer comming from the SAR.
+ *
+ * \param user the user data
+ * \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);
+
+/**
+ * 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_send_done_cb_t) (void *user, u8 *buffer);
+
+/**
+ * Call back to use when the CL needs to send a MME to the upper layer.
+ *
+ * \param ul_data the upper layer data provided on the registration.
+ * \param buffer the buffer containig the MME.
+ * \param length the length of the MME
+ */
+typedef void (*cl_mme_send_ul_cb_t) (void *ul_data, u8 *buffer, uint length);
+
+/**
+ * Call back to use once a MME had been sent to the HLE or to the SAR.
+ *
+ * \param user the user data
+ */
+typedef void (*cl_mme_send_done_cb_t) (void *user, u8* buffer);
+
+/**
+ * Callback definition used by the CL when the CP had processed the MME
+ * in the buffer. This will return the buffer to the upper layer.
+ *
+ * \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);
+
+
+/**
+ * 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);
+
+/**
+ * Initialize the callback to receive the data from the PLC to the upper layer.
+ *
+ * \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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * 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);
+
+/**
+ * Uninit the Convergence layer context.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_uninit (cl_t *ctx);
+
+#endif /* test_overide_cl_cl_h */
diff --git a/hle/test/overide/cl/inc/cl.h b/hle/test/overide/cl/inc/cl.h
new file mode 100644
index 0000000000..07cf11ab72
--- /dev/null
+++ b/hle/test/overide/cl/inc/cl.h
@@ -0,0 +1,83 @@
+#ifndef overide_cl_inc_cl_h
+#define overide_cl_inc_cl_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cl/inc/cl.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+/** data tx structure. */
+struct cl_data_tx_t
+{
+ /** the callback function to use once the data hab been sent. */
+ cl_data_send_done_cb_t cb;
+ /** user data to provide with the callback. */
+ void *user;
+};
+typedef struct cl_data_tx_t cl_data_tx_t;
+
+/** data tx structure. */
+struct cl_data_rx_t
+{
+ /** callback to call the upperlayer once the CL receives a data. */
+ cl_data_recv_cb_t cb;
+ /** user value to provide with the function callback. */
+ void *user;
+};
+typedef struct cl_data_rx_t cl_data_rx_t;
+
+/** MME tx structure to the upper layer*/
+struct cl_mme_tx_t
+{
+ /** function to call when a mme is for the driver */
+ cl_data_recv_cb_t cb;
+ /** user data */
+ void *user;
+ /** mme buffer address */
+ u8 *mme_buffer;
+};
+typedef struct cl_mme_tx_t cl_mme_tx_t;
+
+/** cl mme context */
+struct cl_mme_t
+{
+ /** The Call back to inform the upper layer when a MME has been processed
+ * */
+ cl_mme_ul_recv_done_cb_t ul_mme_recv_done;
+ void *ul_mme_recv_done_user_data;
+
+ /** The callback to use once the MME had been sent. */
+ cl_mme_send_done_cb_t mme_send_done_cb;
+ /** The user data to provide with the bellow callback. */
+ void *mme_send_done_user_data;
+
+ /** Data corresponding to the mme_recv message send to the CP. */
+ cl_mme_recv_t mme_recv;
+};
+typedef struct cl_mme_t cl_mme_t;
+
+struct cl_t
+{
+ /** send data context. */
+ cl_data_tx_t data_tx;
+
+ /** recevie data context. */
+ cl_data_rx_t data_rx;
+
+ /** When a MME is send as data to the local tei */
+ cl_mme_tx_t mme_ul_send;
+
+ /** MME module to use to send or receive the MME to the CP. */
+ cl_mme_t mme;
+};
+
+#endif /* overide_cl_inc_cl_h */
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)
+{
+
+}
diff --git a/hle/test/overide/hal/hle/Module b/hle/test/overide/hal/hle/Module
new file mode 100644
index 0000000000..2a248a2de2
--- /dev/null
+++ b/hle/test/overide/hal/hle/Module
@@ -0,0 +1 @@
+SOURCES := ipmbox.c \ No newline at end of file
diff --git a/hle/test/overide/hal/hle/ipmbox.h b/hle/test/overide/hal/hle/ipmbox.h
new file mode 100644
index 0000000000..ed1f416927
--- /dev/null
+++ b/hle/test/overide/hal/hle/ipmbox.h
@@ -0,0 +1,32 @@
+#ifndef IPMBOX_H_
+#define IPMBOX_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ipmbox.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+typedef uint ipmbox_t;
+
+typedef bool (*ipmbox_rx_cb_t) (u32 *msg_buffer, uint length, void *user_data);
+
+typedef bool (*ipmbox_tx_cb_t)(u32 *msg_buffer, uint length, void *user_data);
+
+typedef bool (*ipmbox_deferred_cb_t)(u32 *buffer, uint length, void *user_data);
+
+ipmbox_t *ipmbox_init(void *user_data, ipmbox_rx_cb_t rx_cb, ipmbox_tx_cb_t
+ tx_cb, ipmbox_deferred_cb_t deferred_cb);
+
+void ipmbox_tx (ipmbox_t *ctx, u32 *msg_buffer, uint length);
+
+#endif /*IPMBOX_H_*/
diff --git a/hle/test/overide/hal/hle/src/ipmbox.c b/hle/test/overide/hal/hle/src/ipmbox.c
new file mode 100644
index 0000000000..a287b0f803
--- /dev/null
+++ b/hle/test/overide/hal/hle/src/ipmbox.c
@@ -0,0 +1,32 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/hle_recv.c
+ * \brief unit test to test the hle when it sends a data to the CL.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+
+#include "hal/hle/ipmbox.h"
+
+static ipmbox_t ipmbox_global;
+
+ipmbox_t *ipmbox_init (void *user_data, ipmbox_rx_cb_t rx_cb,
+ ipmbox_tx_cb_t tx_cb, ipmbox_deferred_cb_t deferred_cb)
+{
+ return &ipmbox_global;
+}
+
+void ipmbox_tx (ipmbox_t *ctx, u32 *msg_buffer, uint length)
+{
+ dbg_assert (ctx);
+ dbg_assert (msg_buffer);
+}