summaryrefslogtreecommitdiff
path: root/cesar/cp/interf/src/interf.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp/interf/src/interf.c')
-rw-r--r--cesar/cp/interf/src/interf.c639
1 files changed, 639 insertions, 0 deletions
diff --git a/cesar/cp/interf/src/interf.c b/cesar/cp/interf/src/interf.c
new file mode 100644
index 0000000000..b07380b98f
--- /dev/null
+++ b/cesar/cp/interf/src/interf.c
@@ -0,0 +1,639 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/interf/interf.c
+ * \brief Interfaces between CP and CL
+ * \ingroup cp_interf
+ */
+
+#include "common/std.h"
+
+#include "cp/beacon/inc/bentry.h"
+#include "cp/beacon/inc/beacons_ctx.h"
+#include "cp/beacon/forward.h"
+#include "cp/beacon/inc/beacons_work.h"
+
+#include "cp/interf/interf.h"
+#include "cp/interf/inc/interf_private.h"
+
+/*
+ * locale Variables
+ */
+
+static interf_buffer_t pool[INTERF_NB_BUFFER];
+static interf_frag_msg_t frag_msg[INTERF_MAX_FRAG_MSG_SIM];
+static uint nb_local_buf_available;
+static cyg_mutex_t local_ressource_lock;
+static cyg_cond_t local_ressource_wait;
+// mbox for incomming msg
+static cyg_handle_t incoming_mbox_handle;
+static cyg_mbox incoming_mbox;
+// mbox for buf to release
+static cyg_handle_t buf_rel_mbox_handle;
+static cyg_mbox buf_rel_mbox;
+// delay in ticks for the frag MMI timeout
+static cyg_tick_count_t frag_MMI_time_out_delay;
+
+#if 1
+
+extern cp_sta_t cp_sta_global;
+
+int mme_buffer_count = 0;
+int mme_buffer_first = 0;
+int mme_buffer_last = -1;
+u8 * mme_tx_buffer[MME_BUFFER_MAXCOUNT];
+
+#define NEW_INTERFACE_WITH_DATA_PLANE
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv);
+#else
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv, bool encryption);
+void
+cp_beacon_recv(void *user_data, pb_beacon_t *beacon);
+#endif
+
+void cp_mme_get (void *user, u8 *buffer);
+
+#else
+
+/* External functions */
+
+extern void cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length,
+ cl_mme_recv_t *mme_recv);
+
+extern void cp_mme_get (void *user, u8 *buffer);
+
+#endif
+
+/***************************************************************/
+/***************************************************************/
+/***************************************************************/
+/* "Private" functions */
+/***************************************************************/
+/***************************************************************/
+/***************************************************************/
+
+msg_mme_t *
+interf_received_frag (msg_mme_t *msg)
+{
+ int i, j, checksum;
+ msg_mme_t *first_frag;
+ interf_buffer_t *buffer = NULL;
+
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+
+ // check if some old messages must be removed
+ // this can be done anywhere, but i think here is a good place.
+ interf_msg_purge ();
+ // now, process the received fragment
+ // check if previous fragment has been received
+ for (i=0; i < INTERF_MAX_FRAG_MSG_SIM ; i++)
+ {
+ if ( (frag_msg[i].fmsn == msg->fmi.fmsn)
+ && (memcmp (frag_msg[i].osa,msg->osa, sizeof(msg->osa))==0)
+ )
+ {
+ // we find previous fragment, so stop searching
+ break;
+ }
+ }
+ if(i == INTERF_MAX_FRAG_MSG_SIM)
+ {
+ // we did not found any previous fragment
+ // so look for first empty slot
+ for(i=0 ; i < INTERF_MAX_FRAG_MSG_SIM ; i++)
+ {
+ if( ! frag_msg[i].frag_counter)
+ {
+ // we found an empty slot
+ frag_msg[i].fmsn = msg->fmi.fmsn;
+ memcpy(frag_msg[i].osa, msg->osa, sizeof(msg->osa));
+ break;
+ }
+ }
+ }
+ if(i == INTERF_MAX_FRAG_MSG_SIM)
+ {
+ // obviously, there is no more space...
+ dbg_assert_print(0, "interf.c : frag_msg array is full, loose fragment");
+ // and so, we loose the message
+ interf_release_buf(msg);
+ return NULL;
+ }
+ frag_msg[i].date_cyg_tick = cyg_current_time();
+ // message are ordered in our structure
+ frag_msg[i].msg[msg->fmi.fn_mi] = msg;
+ frag_msg[i].frag_counter ++;
+ // check if message is complete and return
+ if( frag_msg[i].frag_counter == (msg->fmi.nf_mi + 1) )
+ {
+ // message is supposed to be completed
+ // check if all fragment are coherent
+ checksum = 0;
+ for(j=0 ; j<frag_msg[i].frag_counter ; j++)
+ checksum += frag_msg[i].msg[j]->fmi.fn_mi;
+ if(checksum != (frag_msg[i].frag_counter * msg->fmi.nf_mi / 2))
+ {
+ // the message fragment are not coherent (and they will be purged later)
+ dbg_assert_print(0, "interf.c : MME fragments incoherents\n");
+ return NULL;
+ }
+ // update the buffer structure
+ first_frag = frag_msg[i].msg[0];
+ for(j=0; j<frag_msg[i].frag_counter; j++)
+ {
+ buffer = PARENT_OF(interf_buffer_t, msg, frag_msg[i].msg[j]);
+ dbg_assert(buffer);
+ buffer->next_msg = frag_msg[i].msg[j+1];
+ }
+ // the last fragment has no NextPart
+ dbg_assert(buffer);
+ buffer->next_msg = NULL;
+ // reset the current slot
+ bzero(&frag_msg[i], sizeof(interf_frag_msg_t));
+ // and return ptr to first part of MME
+ return first_frag;
+ }
+ return NULL;
+}
+
+void
+interf_buf_to_release (void)
+{
+ interf_buffer_t *buf;
+ msg_mme_t *msg, *next_msg;
+
+ // as we have buffer to release in the mailbox
+ while ( (msg = cyg_mbox_tryget (buf_rel_mbox_handle)) != NULL )
+ {
+ #if DEBUG
+ int i;
+ dbg_assert( ! msg_check_wrong_mme_const_values(msg));
+ // check that the message to release is not the last part
+ // of a fragmented message (which would cause a severe
+ // memory leak)
+ for(i=0; i<INTERF_NB_BUFFER; i++)
+ {
+ dbg_assert(pool[i].next_msg != msg);
+ }
+ #endif
+ do
+ {
+ buf = PARENT_OF (interf_buffer_t, msg, msg);
+ buf->size = 0;
+ next_msg = buf->next_msg;
+ buf->next_msg = NULL;
+ } while (next_msg);
+ }
+}
+
+/***************************************************************/
+/***************************************************************/
+/***************************************************************/
+/* "Public" functions */
+/***************************************************************/
+/***************************************************************/
+/***************************************************************/
+
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+E_ErrCode
+interf_init (cl_t *interf_cl_ctx)
+#else
+E_ErrCode
+interf_init (cl_t *interf_cl_ctx)
+#endif
+{
+ unsigned int i;
+ #if DEBUG
+ // check parameters
+ if (sizeof(pool[0].msg) != ETH_PACKET_MAX_SIZE )
+ {
+ printf("%u %s() : wrong mmentry size : %lu octets instead of %i\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg), ETH_PACKET_MAX_SIZE);
+ printf("%u %s() : osa : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.osa));
+ printf("%u %s() : oda : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.oda));
+ //printf("%u %s() : v_lan_tag : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.v_lan_tag));
+ printf("%u %s() : m_type : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.m_type));
+ printf("%u %s() : mmv : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mmv));
+ printf("%u %s() : mm_type : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mm_type));
+ printf("%u %s() : fmi : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.fmi));
+ printf("%u %s() : mm_entry : %lu\n",cyg_hal_sys_getpid(),__FUNCTION__, sizeof(pool[0].msg.mm_entry));
+ }
+ #endif
+
+ // calculate the frag MMI timeout delay
+ frag_MMI_time_out_delay = FragMMI_ReassemblyTimeOut_sec;
+ // convert it from s to ms
+ frag_MMI_time_out_delay *= 1000;
+ // and then convert it to system ticks
+ frag_MMI_time_out_delay = interf_ms_to_cyg_tick (frag_MMI_time_out_delay);
+ // init msg const values
+ bzero (pool, sizeof(pool));
+ for(i=0 ; i<COUNT(pool) ; i++)
+ {
+ msg_set_mme_const_values(&pool[i].msg);
+ }
+ // Init FragMsg
+ bzero(frag_msg, sizeof(frag_msg));
+ // init of local ressources
+ nb_local_buf_available = 0;
+ cyg_mutex_init( & local_ressource_lock);
+ cyg_cond_init( & local_ressource_wait, & local_ressource_lock);
+ // Init callback and transmit buffer's pool
+ // init of mailboxes
+ cyg_mbox_create( & incoming_mbox_handle, & incoming_mbox);
+ cyg_mbox_create( & buf_rel_mbox_handle, & buf_rel_mbox);
+#if 0
+ // init CL layer
+ interf_cl_layer_init();
+#else
+ printf("%u %s() : Configure the CP-DP interface...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+# ifdef NEW_INTERFACE_WITH_DATA_PLANE
+ /* Configure the interface module between Control-Plane and Data-Plane */
+ interface_callback_init (cp_sta_global.interface, cp_mme_recv, cp_mme_get, cp_beacon_recv, NULL);
+# else
+ /* Configure the CP-CL interface */
+ cl_mme_recv_init (interf_cl_ctx, cp_mme_recv, NULL);
+ cl_mme_init_buffer_add_cb (interf_cl_ctx, cp_mme_get, NULL);
+# endif
+ printf("%u %s() : CP-CL interface configuration done.\n",cyg_hal_sys_getpid(),__FUNCTION__);
+#endif
+ // TODO : give one buffer to the CL
+ return Success;
+}
+
+msg_ctx_t my_msg_ctx;
+//void
+//interf_receive (const msg_mme_t *msg)
+void
+interf_receive (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv)
+{
+ uint i, j;
+ msg_mme_t *msg = (msg_mme_t *) buffer;
+ msg_ctx_t *msg_ctx = &my_msg_ctx;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+
+ //msg_ctx = blk_alloc();
+ msg_ctx->user = user;
+ msg_ctx->mfs = mfs;
+ msg_ctx->buffer = buffer;
+ msg_ctx->length = length;
+ //msg_ctx->mme_recv = mme_recv;
+ msg_ctx->cl_mme_data = (void*)mme_recv;
+
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : RECEIVING AN MME (len = %u bytes)...\n",cyg_hal_sys_getpid(),
+ /*cp_sta_global.mac_config->tei*/0,
+ length);
+ printf ("%u /* buffer = 0x%08lX ; msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)buffer,(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ if (length > 0)
+ {
+ j = 0;
+ printf("%u /* ",cyg_hal_sys_getpid());
+ for (i = 0; i < (length / 16); i++)
+ {
+ for (j = 0; j < 16; j++) printf ("%02x.",buffer[(i*16)+j]);
+ printf("\n");
+ printf("%u /* ",cyg_hal_sys_getpid());
+ }
+ for (i = 0; i < (length % 16); i++)
+ {
+ printf ("%02x.",buffer[(j*16)+i]);
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("%u /*\n",cyg_hal_sys_getpid());
+ }
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+
+ printf ("%u /* AVANT cyg_mbox_put() : msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+
+ #if DEBUG
+ printf("%u /* ON PASSE dans le cas DEBUG...*/\n",cyg_hal_sys_getpid());
+ //dbg_assert(cyg_mbox_tryput(incoming_mbox_handle, (void *) msg));
+ dbg_assert(cyg_mbox_tryput(incoming_mbox_handle, (void *) msg_ctx));
+ #else
+ //cyg_mbox_put (incoming_mbox_handle, msg);
+ printf ("%u /* AVANT cyg_mbox_put() : msg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ cyg_mbox_put (incoming_mbox_handle, msg_ctx);
+ #endif
+ // set the event flag for the station
+ printf ("%u /* AVANT cyg_flag_setbits() : @station_flag=0x%08lx ; station_flag=0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)&station_flag,(unsigned long)*((u32*)&station_flag));
+ cyg_flag_setbits (&station_flag, STATION_FLAG_MSG_RCV);
+ printf ("%u /* APRES cyg_flag_setbits() : @station_flag=0x%08lx ; station_flag=0x%08lX\n",cyg_hal_sys_getpid(),(unsigned long)&station_flag,(unsigned long)*((u32*)&station_flag));
+}
+
+void
+interf_received (void)
+{
+ msg_ctx_t * msg_ctx;
+ msg_mme_t * msg;
+ msg_mme_b_t * msg_b;
+
+ printf ("%u %s() : AVANT while(cyg_mbox_tryget)...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ // as we have msg in the mailbox
+ while ( (msg_ctx = cyg_mbox_tryget (incoming_mbox_handle)) != NULL )
+ {
+ //printf ("%u %s() : DANS while(cyg_mbox_tryget)...",cyg_hal_sys_getpid(),__FUNCTION__);
+ //printf ("\t\tmsg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ printf ("%u %s() : DANS while(cyg_mbox_tryget)...\t\tmsg_ctx = 0x%08lX ; msg_ctx->buffer = 0x%08lX\n",cyg_hal_sys_getpid(),__FUNCTION__,(unsigned long)msg_ctx,(unsigned long)msg_ctx->buffer);
+ // check that the message is really an mme
+ //{int k; for (k=0;k<60;k++)printf("%02x.",msg_ctx->buffer[k]);printf("\n");}
+ if(msg_check_wrong_mme_const_values (msg_ctx->buffer))
+ {
+ // in debug we should ask why we received a wrong message...
+ dbg_assert(0);
+ // discard it and process the next msg
+ interf_release_buf(msg_ctx->buffer);
+ continue;
+ }
+ msg = (msg_mme_t *)msg_ctx->buffer;
+ // TODO : vérifier que l'ODA est bien celle de la station
+ // check if message is complete
+ printf("%u test msg->fmi.nf_mi != 0 ?\n",cyg_hal_sys_getpid());
+ msg_b = (msg_mme_b_t *)msg;
+ if (
+ ((msg->m_type == MSG_MTYPE_IEEE_ETHERTYPE) && (msg->fmi.nf_mi != 0))
+ ||
+ ((msg_b->m_type == MSG_MTYPE_IEEE_ETHERTYPE) && (msg_b->fmi.nf_mi != 0))
+ )
+ {
+ msg = interf_received_frag (msg);
+ // if message not complete, process the next one
+ if ( ! msg) continue;
+ }
+ // the message is complete, so we process it
+ msg_dispatch(msg_ctx);
+ }
+ printf ("%u %s() : APRES while(cyg_mbox_tryget)... => (achieved op.)\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ // give another buffer to the CL
+ // TODO : give one buffer to the CL
+}
+
+void
+interf_send (
+ const msg_mme_t *msg,
+ const uint msg_size,
+ const msg_param_t msg_param,
+ const tei_t tei
+ )
+{
+ uint size;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+ dbg_assert (msg_size <= ETH_PACKET_MAX_SIZE);
+
+ // check if padding is requested (and if yes, do so)
+ if (msg_size < ETH_PACKET_MIN_SIZE) size = ETH_PACKET_MIN_SIZE;
+ else size = msg_size;
+ // and send the param...
+ interf_cl_layer_send_buf(msg, size, msg_param, tei);
+
+}
+
+msg_mme_t *
+interf_msg_get_next_part (const msg_mme_t *msg)
+{
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+
+ return PARENT_OF(interf_buffer_t, msg, msg)->next_msg;
+}
+
+void
+interf_release_buf (void *msg)
+{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+
+ #if DEBUG
+ dbg_assert(cyg_mbox_tryput(buf_rel_mbox_handle, msg));
+ #else
+ // !!! WARNING : in some case we can wait here forever !!!
+ // TODO think about it...
+ cyg_mbox_put (buf_rel_mbox_handle, msg);
+ #endif
+ // set the flag
+ cyg_flag_setbits (&station_flag, STATION_FLAG_BUF_REL);
+}
+
+msg_mme_t *
+interf_give_buf (void)
+{
+ msg_mme_t *msg;
+ uint i;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ for (i=0 ; i < sizeof(pool) ; i++)
+ {
+ if (pool[i].size == 0)
+ break;
+ }
+ dbg_assert (i != sizeof(pool));
+ // lock the availble buffer and return it
+ pool[i].size = 1;
+ msg = &pool[i].msg;
+ // and return the buffer
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+ return msg;
+}
+
+void
+interf_msg_purge (void)
+{
+ int i, j;
+ cyg_tick_count_t time_out_date;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ dbg_assert (frag_MMI_time_out_delay >= 1);
+ // calculate the date before which messages has expired
+ time_out_date = cyg_current_time ();
+ if (time_out_date < frag_MMI_time_out_delay)
+ return;
+ time_out_date -= frag_MMI_time_out_delay;
+ // check if some messages has expired
+ for (i=0; i<INTERF_MAX_FRAG_MSG_SIM ; i++)
+ {
+ if ( (frag_msg[i].date_cyg_tick != 0)&& (frag_msg[i].date_cyg_tick
+ < time_out_date))
+ {
+ // the message has expired, so remove it parts
+ for (j=0; j<INTERF_MAX_FRAG_PER_MSG ; j++)
+ {
+ if (frag_msg[i].msg[j])
+ interf_release_buf (frag_msg[i].msg[j]);
+ }
+ // and reset it slot in the waiting file
+ bzero ( &frag_msg[i], sizeof(frag_msg[i]));
+ }
+ }
+}
+
+cyg_tick_count_t
+interf_ms_to_cyg_tick (const uint ms)
+{
+ cyg_resolution_t resolution;
+ cyg_tick_count_t return_value;
+
+ return_value = ms;
+ // convert it from ms to ns
+ return_value *= 1000000;
+ // and then convert it to system ticks
+ resolution = cyg_clock_get_resolution (cyg_real_time_clock ());
+ return_value *= resolution.divisor;
+ return_value /= resolution.dividend;
+ return return_value;
+}
+
+/*************/
+
+#if 1
+
+/**
+ * \brief Get a buffer from HLE (such a buffer is used to send MME to HLE or over PWL).
+ *
+ * \param user pointer to user context
+ * \param buffer buffer pointer
+ */
+void cp_mme_get (void *user, u8 *buffer)
+{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : OBTAINING AN MME BUFFER...\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u ### AVANT maj mme_buffer_count (first = %d ; last = %d ; count = %d) ###\n",cyg_hal_sys_getpid(),
+ mme_buffer_first, mme_buffer_last, mme_buffer_count);
+ if (mme_buffer_count < MME_BUFFER_MAXCOUNT)
+ {
+ mme_buffer_last = (mme_buffer_last + 1) % MME_BUFFER_MAXCOUNT;
+ mme_tx_buffer[mme_buffer_last] = buffer;
+ mme_buffer_count++;
+ if (mme_buffer_count == MME_BUFFER_MAXCOUNT)
+ {
+ printf ("%u /* STA : %d OK, BUT CP WILL NOT ACCEPT\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u /* ANOTHER MME BUFFER.\n",cyg_hal_sys_getpid());
+ printf ("%u /* (MME_BUFFER_MAXCOUNT reached)\n",cyg_hal_sys_getpid());
+ }
+ }
+ else
+ {
+ printf ("%u /* STA : %d WARNING, CP CANNOT ACCEPT\n",cyg_hal_sys_getpid(),
+ cp_sta_global.mac_config->tei);
+ printf ("%u /* ANOTHER MME BUFFER !\n",cyg_hal_sys_getpid());
+ printf ("%u /* (MME_BUFFER_MAXCOUNT reached)\n",cyg_hal_sys_getpid());
+ }
+ printf ("%u ### APRES maj mme_buffer_count (first = %d ; last = %d ; count = %d) ###\n",cyg_hal_sys_getpid(),
+ mme_buffer_first, mme_buffer_last, mme_buffer_count);
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+}
+
+/**
+ * \brief Receive an MME message from CL.
+ *
+ * \param user a specific user context
+ * \param mfs the mfs used
+ * \param buffer the buffer containing the message being received
+ * \param length the length of message being received
+ * \param mme_recv
+ * \return status of memory blocks check
+ */
+#ifndef NEW_INTERFACE_WITH_DATA_PLANE
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv)
+#else
+void
+cp_mme_recv (void *user, mfs_rx_t *mfs, u8 *buffer, uint length, cl_mme_recv_t *mme_recv, bool encryption)
+#endif
+{
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ interf_receive (user, mfs, buffer, length, mme_recv);
+}
+
+#if 0
+/** Beacon PB descriptor. */
+union pb_beacon_t
+{
+ /** Common block descriptor. */
+ blk_t blk;
+ /** Hardware descriptor. */
+ phy_pb_t phy_pb;
+ struct
+ {
+ /** Pointer to next descriptor. */
+ union pb_t *next;
+ /** Pointer to data. */
+ u8 *data;
+ /** First four bytes of the beacon payload. */
+ u32 first_data_word;
+ };
+};
+typedef union pb_beacon_t pb_beacon_t;
+#endif
+
+/**
+ * \brief Receive a beacon.
+ *
+ * \param user a specific user context
+ * \param beacon the received beacon buffer reference
+ *
+ */
+void
+cp_beacon_recv(void *user_data, pb_beacon_t *beacon)
+{
+#define BEACON_DATA_MAXSIZE 132
+ uint i, j;
+ u8 *buffer;
+
+ printf ("%u %s()...\n",cyg_hal_sys_getpid(),__FUNCTION__);
+ dbg_assert (beacon);
+
+
+ // TODO : to be removed (Hexdump of beacon is for debug purpose only)
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+ printf ("%u /* STA : %d CP : RECEIVING A BEACON...\n",cyg_hal_sys_getpid(),
+ /*cp_sta_global.mac_config->tei*/0);
+ printf ("%u /* @beacon_descriptor = 0x%08lx\n",cyg_hal_sys_getpid(),
+ (unsigned long)beacon);
+ {
+ j = 0;
+ printf("%u /* ",cyg_hal_sys_getpid());
+ buffer = (u8 *)&(beacon->first_data_word);
+ for (i = 0; i < (BEACON_DATA_MAXSIZE / 16); i++)
+ {
+ for (j = 0; j < 16; j++)
+ {
+ if (((j*16)+i) == 4) buffer = beacon->data;
+ printf ("%02x.",buffer[(i*16)+j]);
+ }
+ printf("\n");
+ printf("%u /* ",cyg_hal_sys_getpid());
+ }
+ for (i = 0; i < (BEACON_DATA_MAXSIZE % 16); i++)
+ {
+ printf ("%02x.",buffer[(j*16)+i]);
+ }
+ printf("\n");
+ }
+ printf ("%u /***************************************************/\n",cyg_hal_sys_getpid());
+
+
+ // TODO : generate beacon receive event for Control-Plane FSM
+ // and use this beacon
+
+}
+
+#endif