summaryrefslogtreecommitdiff
path: root/cesar/cl/cl.h
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/cl/cl.h
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cl/cl.h')
-rw-r--r--cesar/cl/cl.h321
1 files changed, 321 insertions, 0 deletions
diff --git a/cesar/cl/cl.h b/cesar/cl/cl.h
new file mode 100644
index 0000000000..e6b1dc9912
--- /dev/null
+++ b/cesar/cl/cl.h
@@ -0,0 +1,321 @@
+#ifndef CL_CL_H_
+#define CL_CL_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cl/cl.h
+ * \brief Public functions
+ * \ingroup cl
+ *
+ */
+
+#include "mac/common/mfs.h"
+#include "mac/common/store.h"
+#include "lib/utils.h"
+#include "mac/sar/sar.h"
+
+/** forward declaration. */
+typedef struct cl_t cl_t;
+typedef struct cl_mme_recv_t cl_mme_recv_t;
+
+/**
+ * Callback use to inform the upper layer when a data had 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);
+
+/**
+ * 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);
+
+/**
+ * Provides a MME buffer to the CP.
+ *
+ * \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);
+
+/**
+ * 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_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.
+ *
+ * \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);
+
+/**
+ * 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);
+
+/**
+ * Use this callback to provide a received MME to the CP.
+ *
+ * \param user user daya
+ * \param mfs the mfs used for the reassembly if MME received from the SAR.
+ * \param buffer the buffer containing the MME.
+ * \param length the MME length
+ * \param mme_recv private data for the cl_mme.
+ * \param encryption inform if the MF has been crypted or not when it
+ * arrives from the PWL.
+ */
+typedef void (*cl_mme_recv_cb_t) (void *user, mfs_rx_t *mfs, u8 *buffer,
+ uint length, cl_mme_recv_t *mme_recv, bool encryption);
+
+/**
+ * Init the Convergence Layer and return a pointer on the CL context.
+ *
+ * \param mac_store the mac store.
+ * \param sar the sar context.
+ * \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);
+
+/**
+ * Uninit the Convergence layer context.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_uninit (cl_t *ctx);
+
+/**
+ * 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_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
+ void *user);
+
+/**
+ * Init the function call when an MME is recived from the SAR or the HLE.
+ * The CP registers its callback to allow the CL to call it each time a MME
+ * is receved from the PLC or the HLE.
+ *
+ * \param ctx the CL ctx
+ * \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);
+
+/**
+ * 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_ul_send_done_cb_t cb, void *user);
+
+
+/**
+ * Initialize the CP call back to get a buffer.
+ *
+ * \param cl the cl context
+ * \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);
+
+/**
+ * Send an MME from the CP to the PLC via the SAR MME way.
+ *
+ * \param ctx the CL context
+ * \param buffer the buffer containing the MME
+ * \param length the length of the MME
+ * \param mfs the MFS use for the SAR if the MME should be send over the PLC
+ */
+void cl_mme_send_as_mme (cl_t *ctx, u8 *buffer, uint length, mfs_tx_t *mfs);
+
+/**
+ * Send an MME as a data packet from the CP to the PLC or to the upper layer.
+ *
+ * \param ctx the CL context
+ * \param buffer the buffer containing the MME
+ * \param length the length of the MME
+ */
+void cl_mme_send_as_data (cl_t *ctx, u8 *buffer, uint length);
+
+/**
+ * Send a MME from the CP to the Upper layer or to the PWL.
+ *
+ * \param ctx the cl context.
+ * \param buffer the buffer containing the data to send.
+ * \param length the length of the MME.
+ * \param mfs the mfs to use if necessary.
+ */
+extern inline void
+cl_mme_send (cl_t *ctx, u8 *buffer, uint length, mfs_tx_t *mfs)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ if (mfs)
+ cl_mme_send_as_mme (ctx, buffer, length, mfs);
+ else
+ cl_mme_send_as_data (ctx, buffer, length);
+}
+
+/**
+ * Callback called by the sar when a MME as been sent over the PWL.
+ *
+ * \param ctx the cl context.
+ * \param buffer the buffer used.
+ */
+void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer);
+
+/**
+ * Receives an MME from the SAR or the upper layer.
+ * This function is called each time the SAR or the HLE has an MME to send to
+ * the CP. It is used by the inline function.
+ * When the MFS is NULL the MME received comes from the HLE. Otherwise the MME
+ * comes from the SAR.
+ *
+ * \param ctx the cl context
+ * \param buffer the MME buffer
+ * \param length the MME length
+ * \param mfs the MFS used in 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, mfs_rx_t *mfs, bool
+ encryption);
+
+/**
+ * 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
+ */
+extern inline void cl_mme_ul_send (cl_t *ctx, u8 *buffer, uint length)
+{
+ cl_mme_recv (ctx, buffer, length, NULL, false);
+}
+
+/**
+ * Receives an MME from the SAR.
+ * 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
+ * \param mfs the MFS used by to receive the MME.
+ * \param encryption boolean informing if the MF was crypted or not.
+ */
+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, mfs, encryption);
+}
+
+/**
+ * The CP inform the CL that the buffer contaning previously a receved MME can
+ * be use again to store another MME if necessary.
+ *
+ * \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);
+
+/**
+ * Initialize the callback to inform the upper layer when a data had been sent
+ * over the PWL.
+ *
+ * \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);
+
+/**
+ * The SAR inform the CL that the data previously provided had been sent over
+ * the PWL.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the MME
+ */
+void cl_data_send_done (cl_t *ctx, u8 *buffer);
+
+/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PWL.
+ *
+ * \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);
+
+/**
+ * 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);
+
+/**
+ * Called by the SAR each time it has a data to provide to the CL.
+ *
+ * \param ctx the CL context
+ * \param buffer the buffer containing the data to send to the Upper layer.
+ * \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);
+
+
+/**
+ * Provides a buffer to the CP.
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ */
+void cl_mme_buffer_add (cl_t *cl, u8 *buffer);
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ */
+void cl_data_buffer_add (cl_t *cl, u8 *buffer);
+
+#endif /* CL_CL_H_ */