summaryrefslogtreecommitdiff
path: root/cesar/cp2/cl_interf/cl_interf.h
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp2/cl_interf/cl_interf.h')
-rw-r--r--cesar/cp2/cl_interf/cl_interf.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/cesar/cp2/cl_interf/cl_interf.h b/cesar/cp2/cl_interf/cl_interf.h
new file mode 100644
index 0000000000..6f51494e99
--- /dev/null
+++ b/cesar/cp2/cl_interf/cl_interf.h
@@ -0,0 +1,126 @@
+#ifndef cl_interf__h__
+#define cl_interf__h__
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file Cesare/cp/cl_interf/cl_interf.h
+ * \brief mme interface between CP and DP
+ * \ingroup cp/cl_interf
+ *
+ * This module will :
+ * - get the mme from CL
+ * - if necessary, reassemble it
+ * - manage the Tx buffer
+ * - send mme to the CL
+ */
+
+#include "inc/cl_interf_defs.h"
+
+
+
+BEGIN_DECLS
+
+/**
+ * initialisation of cp_cl_interf module.
+ *
+ * \param ctx the cp context
+ *
+ * register callbacks in DP/CL module,
+ * clear buffers etc.
+ *
+ */
+void
+cp_cl_interf_init(cp_t *ctx);
+
+/**
+ * callback for Rx MME.
+ *
+ * \param ctx the cp context
+ * \param payload the mme itself
+ * \param payload_size size of the payload
+ * \param mfs the receiving mfs
+ * \param hardware_encrypted set to true if the mme was hardwarely encrypted
+ *
+ * !!! this function is executed in the CL context !!!
+ * 1) push the message in the MMEs fifo
+ * 2) set the flag to unlock the station core
+ */
+void
+cp_cl_interf_rx_mme(cp_t *ctx, char *payload, int payload_size, mfs_t * mfs, bool hardware_encrypted);
+
+/**
+ * return the last received and completed mme.
+ *
+ * \param ctx the cp context
+ * \return mme_rx_t the mme context (for unit test purpose only)
+ *
+ * 1) get the last MME from the MMEs fifo
+ * 2) read the MME's header and store it in a newly allocated MME Tx context
+ * 3) check the ODA, and the MME constants
+ * 4) if it is a fragment from a bigger MME
+ * - update the MME context
+ * - copy the payload in 512 byte blocs
+ * 5) if the message is completed, call the msg_dispatch function
+ */
+mme_rx_t *
+cp_cl_interf_give_last_mme(cp_t *ctx);
+
+
+/**
+ * return the Tx MME buffer.
+ *
+ * \param ctx the cp context
+ * \return mme_rx_t the mme context
+ *
+ * !!! This function must be thread-safe !!!
+ * If the Tx buffer is available, return it.
+ * else, wait for it.
+ * It can be called either from CP or CE thread, and the Tx buffer is given
+ * from the CL environnement.
+ */
+mme_tx_t *
+cp_cl_interf_give_tx_buffer(cp_t *ctx);
+
+/**
+ * will send the MME buffer to the DP.
+ *
+ * \param ctx the cp context
+ * \param mme the mme to send and it context
+ *
+ * Must retreive the MFS and send the message through this MFS.
+ * if necessary, will pad the message to the minimum MME size
+ */
+void
+cp_cl_interf_mme_send(cp_t *ctx, mme_tx_t *mme);
+
+/**
+ * callback used by the CL to give back the Tx buffer.
+ *
+ * \param ctx the cp context
+ * \param buffer the buffer
+ *
+ * * !!! this function is executed in the CL context
+ */
+void
+cp_cl_interf_receive_tx_buffer(cp_t *ctx, char * buffer);
+
+/**
+ * this function will remove expired block of fragmented mme.
+ *
+ * \param ctx the cp context
+ *
+ * it is called periodicly, and will check all the currently stored MME
+ * fragments. If necessary, release it.
+ */
+void
+cp_cl_interf_garbage_collector(cp_t *ctx);
+
+
+END_DECLS
+
+#endif \ No newline at end of file