summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-04-14 14:46:57 +0000
committerlaranjeiro2008-04-14 14:46:57 +0000
commit600a0c5e7b5e21c78b61d623d62ca4be068de1f5 (patch)
tree2f64c77cb55504e3ea37270eec8784b1633e8da0
parent37ce0b77cf6af8f4d2969a99af96eb319f5d905b (diff)
Interface :
* Updated the interface to received the MME to configure the interface module or submodules instead of giving it to the CP. * Added a thread to use the interface and a mailbox to synchronize the thread, it will be blocked on the mailbox read. * Tested. * Documentation updated. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1822 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/interface/defs-mmtype.h27
-rw-r--r--cesar/interface/doc/interface.odtbin231304 -> 233776 bytes
-rw-r--r--cesar/interface/inc/context.h16
-rw-r--r--cesar/interface/inc/interface.h24
-rw-r--r--cesar/interface/inc/mme_process.h63
-rw-r--r--cesar/interface/interface.h12
-rw-r--r--cesar/interface/sniffer/doc/sniffer.odtbin272050 -> 230559 bytes
-rw-r--r--cesar/interface/sniffer/sniffer.h8
-rw-r--r--cesar/interface/sniffer/src/sniffer.c42
-rw-r--r--cesar/interface/sniffer/test/src/test-sniffer.c51
-rw-r--r--cesar/interface/src/interface.c149
-rw-r--r--cesar/interface/test/src/test-interface.c130
12 files changed, 411 insertions, 111 deletions
diff --git a/cesar/interface/defs-mmtype.h b/cesar/interface/defs-mmtype.h
new file mode 100644
index 0000000000..5cdf94912d
--- /dev/null
+++ b/cesar/interface/defs-mmtype.h
@@ -0,0 +1,27 @@
+#ifndef interface_defs_mmtype_h
+#define interface_defs_mmtype_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file interface/defs-mmtype.h
+ * \brief The MMType of the Interface's MME.
+ * \ingroup interface
+ *
+ */
+
+#define DRV_INTERFACE_CONFIG 0xA030
+#define DRV_INTERFACE_DATA 0xA034
+
+enum interface_mmtype_t
+{
+ DRV_INTERFACE_CONFIG_REQ = DRV_INTERFACE_CONFIG,
+ DRV_INTERFACE_CONFIG_CNF = DRV_INTERFACE_CONFIG + 1,
+ DRV_INTERFACE_DATA_IND = DRV_INTERFACE_DATA + 2
+};
+
+#endif /* interface_defs_mmtype_h */
diff --git a/cesar/interface/doc/interface.odt b/cesar/interface/doc/interface.odt
index 5c079c664f..c4586272b3 100644
--- a/cesar/interface/doc/interface.odt
+++ b/cesar/interface/doc/interface.odt
Binary files differ
diff --git a/cesar/interface/inc/context.h b/cesar/interface/inc/context.h
index 27d1eab5b0..5bc1da86ae 100644
--- a/cesar/interface/inc/context.h
+++ b/cesar/interface/inc/context.h
@@ -22,6 +22,10 @@
/** module includes. */
#include "interface/sniffer/sniffer.h"
+
+#define INTERFACE_THREAD_STACK CYGNUM_HAL_STACK_SIZE_TYPICAL
+#define INTERFACE_THREAD_PRIORITY 9
+
struct interface_t
{
/** cl context. */
@@ -52,6 +56,18 @@ struct interface_t
circular_buffer_t buffers;
cyg_mutex_t buffer_mutex;
+
+ /** Thread. */
+ cyg_thread thread;
+ /** Thread handle. */
+ cyg_handle_t thread_handle;
+ /** Thread stack. */
+ u8 thread_stack [INTERFACE_THREAD_STACK];
+
+ /** Mailbox. */
+ cyg_mbox mailbox;
+ /** Mailbox handle. */
+ cyg_handle_t mbox_handle;
};
#endif /* interface_inc_context_h */
diff --git a/cesar/interface/inc/interface.h b/cesar/interface/inc/interface.h
index aec0877ff4..c13126b479 100644
--- a/cesar/interface/inc/interface.h
+++ b/cesar/interface/inc/interface.h
@@ -15,6 +15,9 @@
*/
#include "interface/interface.h"
+#include "interface/defs-mmtype.h"
+
+#include "lib/read_word.h"
/**
* The buffer shall be provided to the CP.
@@ -32,6 +35,17 @@ interface_buffer_add (interface_t *ctx, u8 *buffer);
void
interface_buffer_work_add (interface_t *ctx, u8 *buffer);
+/**
+ * Receive a data from the HLE.
+ * \param ctx the interface context.
+ * \param buffer the Message received.
+ *
+ * This will be use by the Fcall module in the interface. It can be use by
+ * anything in the future.
+ */
+void
+interface_hle_recv (interface_t *ctx, u8 *buffer);
+
/**
* Get a buffer from the list.
* \param ctx the interface context.
@@ -40,4 +54,14 @@ interface_buffer_work_add (interface_t *ctx, u8 *buffer);
u8*
interface_buffer_work_get (interface_t *ctx);
+/**
+ * Interface process, function used by the interface thread to process
+ * received MMEs.
+ *
+ * \param data the address of the interface context.
+ */
+void
+interface_process (cyg_addrword_t data);
+
+
#endif /* interface_inc_interface_h */
diff --git a/cesar/interface/inc/mme_process.h b/cesar/interface/inc/mme_process.h
new file mode 100644
index 0000000000..2e208d8683
--- /dev/null
+++ b/cesar/interface/inc/mme_process.h
@@ -0,0 +1,63 @@
+#ifndef interface_inc_mme_process_h
+#define interface_inc_mme_process_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file interface/inc/mme_process.h
+ * \brief Function to read or get the informations.
+ * \ingroup interface
+ *
+ */
+
+/**
+ * Interface read the MMtype of the MME.
+ *
+ * \param buffer the buffer to get the MMtype.
+ * \return the MME type.
+ */
+extern inline uint
+interface_mmtype_get (u8 *buffer)
+{
+ dbg_assert (buffer);
+ return read_u16_from_word (buffer + 0xF);
+}
+
+/**
+ * Get the sub module information.
+ * \param buffer the buffer containing the MME.
+ * \return the submodule id in the interface.
+ *
+ * - 0 for interface module.
+ * - 1 for sniffer module.
+ * - 2 for fcall module.
+ */
+extern inline uint
+interface_moduleid_get (u8 *buffer)
+{
+ dbg_assert (buffer);
+ return read_u8_from_word (buffer + 0x13);
+}
+
+/**
+ * Send the configuration part to the Sniffer sub module and create the
+ * response of the configuration.
+ * \param ctx the interface context.
+ * \param buffer the MME buffer containing the data and use to response.
+ *
+ * Provide the configuration byte to the sniffer sub module and reuse the
+ * buffer to create the confirm MME by replace the MMType and the payload by
+ * the ACK value.
+ * For that this will call the interface_sniffer_status which returns the
+ * corresponding value of the sniffer configuration as the same format as the
+ * one present in the MME. If the two data are equals then the ACK is
+ * positive, in the other case it will be equal to 0.
+ */
+void
+interface_sniffer_configure_and_respond (interface_t *ctx, u8 *buffer);
+
+#endif /* interface_inc_mme_process_h */
diff --git a/cesar/interface/interface.h b/cesar/interface/interface.h
index e9e995dfbc..2ec5d0b65e 100644
--- a/cesar/interface/interface.h
+++ b/cesar/interface/interface.h
@@ -38,8 +38,8 @@ typedef struct interface_t interface_t;
* crypted.
*/
typedef void
-(*interface_mme_recv_cb_t) (void *user_data, mfs_rx_t *mfs, u8 *buffer, uint length,
- void *mme_recv, bool encryption);
+(*interface_mme_recv_cb_t) (void *user_data, mfs_rx_t *mfs, u8 *buffer,
+ uint length, void *mme_recv, bool encryption);
/**
* Function to call when the interface receives a empty buffer.
@@ -90,14 +90,6 @@ interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
interface_beacon_add_cb_t beacon_add_cb, void *user_data);
-/**
- * Configure the interface.
- * \param ctx the interface context.
- * \param data the data to configure the module of sub module.
- */
-void
-interface_configure (interface_t *ctx, u8 *data);
-
/** Receives an MME from the PWL or the HLE.
* \param ctx the interface context
* \param mfs the mfs from the one the MF comes if it comes from the PWL.
diff --git a/cesar/interface/sniffer/doc/sniffer.odt b/cesar/interface/sniffer/doc/sniffer.odt
index 1c914f0f13..6b457d5d05 100644
--- a/cesar/interface/sniffer/doc/sniffer.odt
+++ b/cesar/interface/sniffer/doc/sniffer.odt
Binary files differ
diff --git a/cesar/interface/sniffer/sniffer.h b/cesar/interface/sniffer/sniffer.h
index d1fb0be2ba..6f21e2dfd8 100644
--- a/cesar/interface/sniffer/sniffer.h
+++ b/cesar/interface/sniffer/sniffer.h
@@ -199,4 +199,12 @@ interface_sniffer_beacon_status_rx (interface_sniffer_t *ctx)
return interface_sniffer_beacon_status (ctx, false);
}
+/** Return the status as the same format as received in the configuration
+ * status.
+ * \param ctx the interface sniffer context.
+ * \return the status.
+ */
+uint
+interface_sniffer_status (interface_sniffer_t *ctx);
+
#endif /* interface_sniffer_sniffer_h */
diff --git a/cesar/interface/sniffer/src/sniffer.c b/cesar/interface/sniffer/src/sniffer.c
index 057281a0bc..d258011e87 100644
--- a/cesar/interface/sniffer/src/sniffer.c
+++ b/cesar/interface/sniffer/src/sniffer.c
@@ -82,7 +82,7 @@ void
interface_sniffer_copy_mme (interface_sniffer_t *ctx, u8 *mme, uint length,
u8 *buffer, bool tx, bool encrypted)
{
- uint word[3];
+ uint word[2];
dbg_assert (ctx);
dbg_assert (mme);
@@ -94,19 +94,15 @@ interface_sniffer_copy_mme (interface_sniffer_t *ctx, u8 *mme, uint length,
bitstream_memcpy (buffer, mme, length);
word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_INTERFACE),
- (MSG_LENGTH, 2),
+ (MSG_LENGTH, 1),
(PARAM_INTERFACE_TYPE, INTERFACE_MODULE_SNIFFER),
(PARAM_INTERFACE_LENGTH, length));
- word[1] = BF_FILL (IPMBOX_REG, (PARAM_MODULE_WAY, !tx),
- (PARAM_MODULE_ENC, encrypted),
- (PARAM_MODULE_TYPE, SNIFFER_MME));
-
- word[2] = (uint)buffer;
+ word[1] = (uint)buffer;
/** Request the interface to send the message to the linux driver. */
- (*ctx->send_func) (ctx->send_user_data, word, 3);
+ (*ctx->send_func) (ctx->send_user_data, word, 2);
}
/** Copy a beacon to the buffer and request the interface to send the copied beacon.
@@ -125,7 +121,7 @@ interface_sniffer_copy_beacon (interface_sniffer_t *ctx, pb_beacon_t *beacon,
bitstream_t bitstream;
uint data;
uint length;
- uint word[3];
+ uint word[2];
dbg_assert (ctx);
dbg_assert (buffer);
@@ -174,19 +170,15 @@ interface_sniffer_copy_beacon (interface_sniffer_t *ctx, pb_beacon_t *beacon,
word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_INTERFACE),
- (MSG_LENGTH, 2),
+ (MSG_LENGTH, 1),
(PARAM_INTERFACE_TYPE, INTERFACE_MODULE_SNIFFER),
(PARAM_INTERFACE_LENGTH, length));
- word[1] = BF_FILL (IPMBOX_REG, (PARAM_MODULE_WAY, !tx),
- (PARAM_MODULE_ENC, 0),
- (PARAM_MODULE_TYPE, SNIFFER_BEACON));
-
- word[2] = (uint)buffer;
+ word[1] = (uint)buffer;
/** Request the interface to send the message to the linux driver. */
- (*ctx->send_func) (ctx->send_user_data, word, 3);
+ (*ctx->send_func) (ctx->send_user_data, word, 2);
}
@@ -222,3 +214,21 @@ interface_sniffer_beacon_status (interface_sniffer_t *ctx, bool tx)
return ctx->sniff_beacon_rx;
}
+/** Return the status as the same format as received in the configuration
+ * status.
+ * \param ctx the interface sniffer context.
+ * \return the status.
+ */
+uint
+interface_sniffer_status (interface_sniffer_t *ctx)
+{
+ uint res;
+ dbg_assert (ctx);
+
+ res = BF_FILL (SNIFFER_REG, (SNIFF_MME_TX, ctx->sniff_mme_tx),
+ (SNIFF_MME_RX, ctx->sniff_mme_rx),
+ (SNIFF_BEACON_TX, ctx->sniff_beacon_tx),
+ (SNIFF_BEACON_RX, ctx->sniff_beacon_rx));
+
+ return res;
+}
diff --git a/cesar/interface/sniffer/test/src/test-sniffer.c b/cesar/interface/sniffer/test/src/test-sniffer.c
index 723e232885..a3b6c5a70a 100644
--- a/cesar/interface/sniffer/test/src/test-sniffer.c
+++ b/cesar/interface/sniffer/test/src/test-sniffer.c
@@ -42,11 +42,8 @@ main (void)
/** Data to process the ipmbox message. */
uint type;
- uint data_tx;
uint data_length;
uint data_type;
- uint data_ekc;
- uint sniffer_type;
u8 *msg;
uint msg_len;
bitstream_t bitstream;
@@ -151,20 +148,12 @@ main (void)
bitstream_access (&bitstream, &data_length, 11);
bitstream_finalise (&bitstream);
- bitstream_init (&bitstream, ipmbox_msg + 1, sizeof (uint), BITSTREAM_READ);
- bitstream_access (&bitstream, &data_tx, 1);
- bitstream_access (&bitstream, &data_ekc, 1);
- bitstream_access (&bitstream, &sniffer_type, 3);
- bitstream_finalise (&bitstream);
-
- msg = (u8 *) ipmbox_msg[2];
+ msg = (u8 *) ipmbox_msg[1];
test_begin (test, "Verify message posted in the IPMBOX")
{
test_fail_if (type != HLE_MSG_TYPE_INTERFACE, "Error on message type");
- test_fail_if (msg_len != 2, "Error on message length");
- test_fail_if (data_ekc != false, "Error on message encryption");
- test_fail_if (data_tx != false, "Error on message way");
+ test_fail_if (msg_len != 1, "Error on message length");
test_fail_if (data_type != 1, "Error on message data type");
test_fail_if (data_length != 1500, "Error on message data length");
@@ -184,20 +173,12 @@ main (void)
bitstream_access (&bitstream, &data_length, 11);
bitstream_finalise (&bitstream);
- bitstream_init (&bitstream, ipmbox_msg + 1, sizeof (uint), BITSTREAM_READ);
- bitstream_access (&bitstream, &data_tx, 1);
- bitstream_access (&bitstream, &data_ekc, 1);
- bitstream_access (&bitstream, &sniffer_type, 3);
- bitstream_finalise (&bitstream);
-
- msg = (u8 *) ipmbox_msg[2];
+ msg = (u8 *) ipmbox_msg[1];
test_begin (test, "Verify message posted in the IPMBOX")
{
test_fail_if (type != HLE_MSG_TYPE_INTERFACE, "Error on message type");
- test_fail_if (msg_len != 2, "Error on message length");
- test_fail_if (data_ekc != true, "Error on message encryption");
- test_fail_if (data_tx != true, "Error on message way");
+ test_fail_if (msg_len != 1, "Error on message length");
test_fail_if (data_type != 1, "Error on message data type");
test_fail_if (data_length != 1500, "Error on message data length");
@@ -225,13 +206,7 @@ main (void)
bitstream_access (&bitstream, &data_length, 11);
bitstream_finalise (&bitstream);
- bitstream_init (&bitstream, ipmbox_msg + 1, sizeof (uint), BITSTREAM_READ);
- bitstream_access (&bitstream, &data_tx, 1);
- bitstream_access (&bitstream, &data_ekc, 1);
- bitstream_access (&bitstream, &sniffer_type, 3);
- bitstream_finalise (&bitstream);
-
- msg = (u8*)ipmbox_msg[2];
+ msg = (u8*)ipmbox_msg[1];
bitstream_init (&bitstream, msg, 23, BITSTREAM_READ);
bitstream_access (&bitstream, &oda, 48);
@@ -261,10 +236,7 @@ main (void)
test_begin (test, "verify beacon data")
{
test_fail_if (type != HLE_MSG_TYPE_INTERFACE, "Error on message type");
- test_fail_if (msg_len != 2, "Error on message length");
- test_fail_if (data_tx != false, "Error on message way");
- test_fail_if (data_ekc != false, "Error on message encryption");
- test_fail_if (sniffer_type != SNIFFER_BEACON, "Error on message data type");
+ test_fail_if (msg_len != 1, "Error on message length");
test_fail_if (data_length != 160 , "Error on message data length");
for (i = 0; i < 132; i++)
@@ -284,19 +256,10 @@ main (void)
bitstream_access (&bitstream, &data_length, 11);
bitstream_finalise (&bitstream);
- bitstream_init (&bitstream, ipmbox_msg + 1, sizeof (uint), BITSTREAM_READ);
- bitstream_access (&bitstream, &data_tx, 1);
- bitstream_access (&bitstream, &data_ekc, 1);
- bitstream_access (&bitstream, &sniffer_type, 3);
- bitstream_finalise (&bitstream);
-
test_begin (test, "verify beacon data")
{
test_fail_if (type != HLE_MSG_TYPE_INTERFACE, "Error on message type");
- test_fail_if (msg_len != 2, "Error on message length");
- test_fail_if (data_tx != true, "Error on message way");
- test_fail_if (data_ekc != false, "Error on message encryption");
- test_fail_if (sniffer_type != SNIFFER_BEACON, "Error on message data type");
+ test_fail_if (msg_len != 1, "Error on message length");
test_fail_if (data_length != 160 , "Error on message data length");
for (i = 0; i < 132; i++)
diff --git a/cesar/interface/src/interface.c b/cesar/interface/src/interface.c
index b24821241d..7e173bf3d1 100644
--- a/cesar/interface/src/interface.c
+++ b/cesar/interface/src/interface.c
@@ -22,6 +22,7 @@
#include "interface/inc/interface.h"
#include "interface/inc/context.h"
+#include "interface/inc/mme_process.h"
static interface_t interface_global;
@@ -58,17 +59,32 @@ interface_init (hle_t *hle, cl_t *cl, sar_t *sar, mac_config_t
cyg_mutex_init (&interface_global.buffer_mutex);
// Integrate the HLE.
- hle_init_interface_buffer_add_cb (hle,
+ hle_init_interface_cb (hle,
(hle_interface_buffer_add_cb_t) interface_buffer_work_add,
+ (hle_interface_mme_recv_cb_t) interface_hle_recv,
&interface_global);
// Integrate the CL.
- cl_mme_init_buffer_add_cb (cl,(cl_mme_buffer_add_cb_t) interface_buffer_add, &interface_global);
+ cl_mme_init_buffer_add_cb (cl,(cl_mme_buffer_add_cb_t) interface_buffer_add,
+ &interface_global);
cl_mme_recv_init (cl,(cl_mme_recv_cb_t) interface_mme_recv, &interface_global);
// Integrate the SAR.
sar_init_beacon_cb (sar, &interface_global, (sar_beacon_cb_t) interface_beacon_add);
+ // Create the mailbox.
+ cyg_mbox_create(&interface_global.mbox_handle, &interface_global.mailbox);
+
+ // Create the interface thread.
+ cyg_thread_create(INTERFACE_THREAD_PRIORITY, &interface_process,
+ (cyg_addrword_t) &interface_global,
+ "INTERFACE",
+ interface_global.thread_stack,
+ INTERFACE_THREAD_STACK,
+ &interface_global.thread_handle,
+ &interface_global.thread);
+ cyg_thread_resume (interface_global.thread_handle);
+
return &interface_global;
}
@@ -82,6 +98,7 @@ interface_uninit (interface_t *ctx)
dbg_assert (ctx);
dbg_assert (ctx->sniffer);
+ cyg_thread_suspend (ctx->thread_handle);
interface_sniffer_uninit (ctx->sniffer);
}
@@ -110,29 +127,6 @@ interface_callback_init (interface_t *ctx, interface_mme_recv_cb_t mme_recv_cb,
}
-/**
- * Configure the interface.
- * \param ctx the interface context.
- * \param data the data to configure the module of sub module.
- */
-void
-interface_configure (interface_t *ctx, u8 *data)
-{
- dbg_assert (ctx);
- dbg_assert (data);
-
- switch (read_u8_from_word(data))
- {
- case INTERFACE_MODULE_SNIFFER:
- /** The length contained in the second octet shall be equal to 1. */
- dbg_assert (read_u8_from_word(data + 1) == 1);
- interface_sniffer_configure (ctx->sniffer, read_u8_from_word (data + 2));
- break;
- default :
- break;
- }
-}
-
/** Receives an MME from the PWL or the HLE.
* \param ctx the interface context
* \param mfs the mfs from the one the MF comes if it comes from the PWL.
@@ -356,3 +350,108 @@ interface_buffer_work_get (interface_t *ctx)
return buffer;
}
+/**
+ * Receive a data from the HLE.
+ * \param ctx the interface context.
+ * \param buffer the Message received.
+ *
+ * This will be use by the Fcall module in the interface. It can be use by
+ * anything in the future.
+ */
+void
+interface_hle_recv (interface_t *ctx, u8 *buffer)
+{
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ cyg_mbox_put (ctx->mbox_handle, buffer);
+}
+
+/**
+ * Interface process, function used by the interface thread to process
+ * received MMEs.
+ *
+ * \param data the address of the interface context.
+ */
+void
+interface_process (cyg_addrword_t data)
+{
+ interface_t *ctx;
+ u8 *buffer;
+ dbg_assert (data);
+
+ ctx = (interface_t *) data;
+
+ while (true)
+ {
+ if ((buffer = (u8 *) cyg_mbox_get(ctx->mbox_handle)))
+ {
+ switch (interface_mmtype_get (buffer))
+ {
+ case DRV_INTERFACE_CONFIG_REQ:
+ switch (interface_moduleid_get (buffer))
+ {
+ // Configure the interface sniffer sub module.
+ case INTERFACE_MODULE_SNIFFER:
+ interface_sniffer_configure_and_respond (ctx, buffer);
+ break;
+ }
+ }
+ }
+ }
+}
+
+/**
+ * Send the configuration part to the Sniffer sub module and create the
+ * response of the configuration.
+ * \param ctx the interface context.
+ * \param buffer the MME buffer containing the data and use to response.
+ *
+ * Provide the configuration byte to the sniffer sub module and reuse the
+ * buffer to create the confirm MME by replace the MMType and the payload by
+ * the ACK value.
+ * For that this will call the interface_sniffer_status which returns the
+ * corresponding value of the sniffer configuration as the same format as the
+ * one present in the MME. If the two data are equals then the ACK is
+ * positive, in the other case it will be equal to 0.
+ */
+void
+interface_sniffer_configure_and_respond (interface_t *ctx, u8 *buffer)
+{
+ bitstream_t bitstream;
+ uint mmtype;
+ uint sack;
+ uint word[2];
+
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ interface_sniffer_configure (ctx->sniffer, read_u8_from_word (buffer + 0x15));
+
+ // Writing the answer.
+
+ mmtype = DRV_INTERFACE_CONFIG_CNF;
+ //Modify directly the MMTYPE.
+ bitstream_init (&bitstream, buffer + 0xF, 2, BITSTREAM_WRITE);
+ bitstream_access (&bitstream, &mmtype, 16);
+ bitstream_finalise (&bitstream);
+
+ // Add the SACK.
+ bitstream_init (&bitstream, buffer + 0x14, 1, BITSTREAM_WRITE);
+ if (read_u8_from_word (buffer + 0x15) == interface_sniffer_status(ctx->sniffer))
+ {
+ sack = true;
+ bitstream_access ( &bitstream, &sack, 8);
+ }
+ bitstream_finalise ( &bitstream);
+
+ word[0] = BF_FILL (IPMBOX_REG, (MSG_TYPE, HLE_MSG_TYPE_INTERFACE),
+ (MSG_LENGTH, 1),
+ (PARAM_INTERFACE_TYPE, INTERFACE_MODULE_SNIFFER),
+ (PARAM_INTERFACE_LENGTH, 60));
+
+ word[1] = (uint)buffer;
+
+ interface_hle_send (ctx, word, 2);
+}
+
diff --git a/cesar/interface/test/src/test-interface.c b/cesar/interface/test/src/test-interface.c
index aacdafce92..74a1e910da 100644
--- a/cesar/interface/test/src/test-interface.c
+++ b/cesar/interface/test/src/test-interface.c
@@ -54,14 +54,42 @@ void ipmbox_tx (ipmbox_t *ctx, u32 *first_msg, uint length);
void
test_configure_sniffer (test_t test)
{
- u8 buffer[3];
- test_case_begin (test, "Configure the sniffer");
+ bitstream_t bitstream;
+ u8 buffer[60];
+ mac_t oda;
+ uint mtype;
+ uint data;
+
- buffer[0] = INTERFACE_MODULE_SNIFFER;
- buffer[1] = 1;
+ test_case_begin (test, "Configure the sniffer");
- buffer[2] = 0x1;
- interface_configure (interface, buffer);
+ oda = 0x123456789ABCull;
+ mtype = HPAV_MTYPE_MME;
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &mtype, 16);
+ // MMV equal 1.
+ data = 0x1;
+ bitstream_access ( &bitstream, &data, 8);
+ // MMtype = 0xA030
+ data = 0xA030;
+ bitstream_access ( &bitstream, &data, 16);
+ // FMI = 0
+ data = 0;
+ bitstream_access ( &bitstream, &data, 16);
+ // Module
+ data = INTERFACE_MODULE_SNIFFER;
+ bitstream_access ( &bitstream, &data, 8);
+ // length in bytes = 1
+ data = 1;
+ bitstream_access ( &bitstream, &data, 8);
+ // Activate the MME tx sniffer
+ data = 0x1;
+ bitstream_access ( &bitstream, &data, 8);
+ bitstream_finalise ( &bitstream );
+
+ interface_hle_recv (interface, buffer);
test_begin (test, "Activate the mme tx")
{
test_fail_if (interface_sniffer_mme_status_tx (interface->sniffer) !=
@@ -69,9 +97,32 @@ test_configure_sniffer (test_t test)
}
test_end;
- buffer[2] = 0x3;
- interface_configure (interface, buffer);
- test_begin (test, "Anactivate the mme tx/rx")
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &mtype, 16);
+ // MMV equal 1.
+ data = 0x1;
+ bitstream_access ( &bitstream, &data, 8);
+ // MMtype = 0xA030
+ data = 0xA030;
+ bitstream_access ( &bitstream, &data, 16);
+ // FMI = 0
+ data = 0;
+ bitstream_access ( &bitstream, &data, 16);
+ // Module
+ data = INTERFACE_MODULE_SNIFFER;
+ bitstream_access ( &bitstream, &data, 8);
+ // length in bytes = 1
+ data = 1;
+ bitstream_access ( &bitstream, &data, 8);
+ // Activate the MME tx sniffer
+ data = 0x3;
+ bitstream_access ( &bitstream, &data, 8);
+ bitstream_finalise ( &bitstream );
+
+ interface_hle_recv (interface, buffer);
+ test_begin (test, "Unactivate the mme tx/rx")
{
test_fail_if (interface_sniffer_mme_status_tx (interface->sniffer) !=
true, "Error sniffer mme TX shall be active");
@@ -80,8 +131,31 @@ test_configure_sniffer (test_t test)
}
test_end;
- buffer[2] = 0x7;
- interface_configure (interface, buffer);
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &mtype, 16);
+ // MMV equal 1.
+ data = 0x1;
+ bitstream_access ( &bitstream, &data, 8);
+ // MMtype = 0xA030
+ data = 0xA030;
+ bitstream_access ( &bitstream, &data, 16);
+ // FMI = 0
+ data = 0;
+ bitstream_access ( &bitstream, &data, 16);
+ // Module
+ data = INTERFACE_MODULE_SNIFFER;
+ bitstream_access ( &bitstream, &data, 8);
+ // length in bytes = 1
+ data = 1;
+ bitstream_access ( &bitstream, &data, 8);
+ // Activate the MME tx sniffer
+ data = 0x7;
+ bitstream_access ( &bitstream, &data, 8);
+ bitstream_finalise ( &bitstream );
+
+ interface_hle_recv (interface, buffer);
test_begin (test, "Anactivate the mme tx/rx, beacon Tx")
{
test_fail_if (interface_sniffer_mme_status_tx (interface->sniffer) !=
@@ -93,8 +167,31 @@ test_configure_sniffer (test_t test)
}
test_end;
- buffer[2] = 0xF;
- interface_configure (interface, buffer);
+ bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &oda, 48);
+ bitstream_access ( &bitstream, &mtype, 16);
+ // MMV equal 1.
+ data = 0x1;
+ bitstream_access ( &bitstream, &data, 8);
+ // MMtype = 0xA030
+ data = 0xA030;
+ bitstream_access ( &bitstream, &data, 16);
+ // FMI = 0
+ data = 0;
+ bitstream_access ( &bitstream, &data, 16);
+ // Module
+ data = INTERFACE_MODULE_SNIFFER;
+ bitstream_access ( &bitstream, &data, 8);
+ // length in bytes = 1
+ data = 1;
+ bitstream_access ( &bitstream, &data, 8);
+ // Activate the MME tx sniffer
+ data = 0xF;
+ bitstream_access ( &bitstream, &data, 8);
+ bitstream_finalise ( &bitstream );
+
+ interface_hle_recv (interface, buffer);
test_begin (test, "Sniffer conf")
{
test_fail_if (interface_sniffer_beacon_status_rx (interface->sniffer)
@@ -301,12 +398,13 @@ main (void)
* Initialise the interface to add an Interface buffer.
*
* \param ctx the hle context.
- * \param cb the function to call on interface buffer reception.
+ * \param buffer_cb the function to call on interface buffer reception.
+ * \param mme_cb the function to call on interface mme.
* \param user_data the user_data to provide on function call.
*/
void
-hle_init_interface_buffer_add_cb (hle_t *ctx, hle_interface_buffer_add_cb_t
- cb, void *user_data)
+hle_init_interface_cb (hle_t *ctx, hle_interface_buffer_add_cb_t buffer_cb,
+ hle_interface_mme_recv_cb_t mme_cb, void *user_data)
{
}