summaryrefslogtreecommitdiff
path: root/cp
diff options
context:
space:
mode:
authorGuillaume2007-09-11 08:51:56 +0000
committerGuillaume2007-09-11 08:51:56 +0000
commite212ed516dcbcf390807a2cbe413f18220ca8b50 (patch)
tree4795b4d69d84c0b8c41a1d79e49723dc212bf9c3 /cp
parentfece8b856111c67a1c571208fa503afc9d835917 (diff)
work in progress...
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@693 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cp')
-rw-r--r--cp/interf/inc/interf_types.h9
-rw-r--r--cp/interf/src/interf.c25
-rw-r--r--cp/msg/inc/msg_cm.h4
-rw-r--r--cp/msg/inc/msg_const.h30
-rw-r--r--cp/msg/msg.h17
-rw-r--r--cp/msg/src/msg.c126
-rw-r--r--cp/msg/src/msg_cm.c13
-rw-r--r--cp/station/inc/station_types.h12
-rw-r--r--cp/station/src/station_events.c11
-rw-r--r--cp/station/src/station_fsm.c20
-rw-r--r--cp/test/inc/test_interf.h2
-rw-r--r--cp/test/inc/test_msg.h2
-rw-r--r--cp/test/inc/test_secu.h2
-rw-r--r--cp/test/inc/test_station.h2
-rw-r--r--cp/test/src/test_cp.c12
-rw-r--r--cp/test/src/test_interf.c50
-rw-r--r--cp/test/src/test_msg.c62
-rw-r--r--cp/test/src/test_secu.c6
-rw-r--r--cp/test/src/test_station.c28
19 files changed, 269 insertions, 164 deletions
diff --git a/cp/interf/inc/interf_types.h b/cp/interf/inc/interf_types.h
index 2476ac982b..ea31f45a74 100644
--- a/cp/interf/inc/interf_types.h
+++ b/cp/interf/inc/interf_types.h
@@ -32,6 +32,12 @@
#define INTERF_MAX_FRAG_MSG_SIM 4
/*
+ * This directive is used to check some buffer overflow within the pool
+ * array.
+ */
+#define CHECK_BUFFER_OVERFLOW 1
+#define BUFFER_SIGNATURE 0xABCDABCD
+/*
* check constant coherency
*/
#if (INTERF_NB_BUFFER < MAX_STA_NB)
@@ -59,6 +65,9 @@ typedef struct interf_buffer_t
interf_id_t id;
uint size;
msg_mme_t msg;
+ #if CHECK_BUFFER_OVERFLOW
+ uint signature;
+ #endif
msg_mme_t *next_msg;
} interf_buffer_t;
diff --git a/cp/interf/src/interf.c b/cp/interf/src/interf.c
index 0cbdf42ba6..e9214ed1d5 100644
--- a/cp/interf/src/interf.c
+++ b/cp/interf/src/interf.c
@@ -157,6 +157,9 @@ cyg_mutex_lock ( &cco_fifo_lock);
{
fifo[dest].msg[fifo[dest].start] = msg;
fifo[dest].start ++;
+ // and then, set corresponding flags
+ if(dest == MSG_STA) cyg_flag_setbits (&station_flag, STATION_FLAG_MSG_RCV_STA);
+ // TODO else the same for CCO
}
// if necessary, release the CCO mutex
@@ -359,7 +362,15 @@ interf_received (void)
// as we have msg in the mailbox
while ( (msg = cyg_mbox_tryget (incoming_mbox_handle)) != NULL )
{
- dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+ // check that the message is really an mme
+ if(msg_check_wrong_mme_const_values (msg))
+ {
+ // in debug we shold ask why we received a wrong message...
+ dbg_assert(0);
+ // discard it and process the next msg
+ interf_release_buf(msg);
+ continue;
+ }
// TODO : vérifier que l'ODA est bien celle de la station
// check if message is complete
if (msg->fmi.nf_mi == 0)
@@ -379,8 +390,16 @@ interf_received (void)
msg_RSP_or_CNF = msg->mm_type & 0x1;
// check if message is for CCO or STA and add it in corresponding fifo
msg_nb = msg_get_number (msg);
- interf_msg_add (msg_list[msg_nb].msg_dest, msg);
- // TODO : set corresponding flags
+ if(msg_nb != MSG_UNKNOW)
+ {
+ // this is a known message
+ interf_msg_add (msg_list[msg_nb].msg_dest, msg);
+ }
+ else
+ {
+ // this is an unknown message, so we discard it
+ interf_release_buf(msg);
+ }
}
}
diff --git a/cp/msg/inc/msg_cm.h b/cp/msg/inc/msg_cm.h
index 5f25425693..c6de1fa270 100644
--- a/cp/msg/inc/msg_cm.h
+++ b/cp/msg/inc/msg_cm.h
@@ -26,8 +26,8 @@ typedef struct unassociated_sta_t // 11.5.1
} __attribute__ ((packed)) unassociated_sta_t;
-void
-msg_cm_unassociated_sta_ind_send(interf_id_t interf_id, mac_adresse_t oda);
+void msg_cm_unassociated_sta_ind_send(interf_id_t interf_id, mac_adresse_t oda);
+void msg_cm_unassociated_sta_ind_rcv(msg_mme_t *msg);
diff --git a/cp/msg/inc/msg_const.h b/cp/msg/inc/msg_const.h
index 5cfb180946..2ada9fb06f 100644
--- a/cp/msg/inc/msg_const.h
+++ b/cp/msg/inc/msg_const.h
@@ -23,20 +23,10 @@
#define MSG_VLAN_TAG 0 // TBD
#define MSG_MTYPE 0xE188 // 11.1
#define MSG_MME_HEADER_SIZE 23
+#define MSG_MM_VERSION 0x01 // 11.1.5
/*
- * Familles et numéros de message
+ * other constants
*/
-#define MSG_CC_START 0x0000
-#define MSG_CC_STOP 0x005B
-
-#define MSG_CP_START 0x2000
-#define MSG_CP_STOP 0x200B
-
-#define MSG_NN_START 0x4000
-#define MSG_NN_STOP 0x4013
-
-#define MSG_CM_START 0x6000
-#define MSG_CM_STOP 0x604F
#define MSG_UNKNOW 0xFFFF
@@ -65,8 +55,8 @@ typedef enum mm_type_t
CC_LINK_INFO_RSP = 0x000B,
CC_HANDOVER_REQ = 0x000C,
CC_HANDOVER_CNF = 0x000D,
- CC_HANDOVER_INFO_IND = 0x0010,
- CC_HANDOVER_INFO_RSP = 0x0011,
+ CC_HANDOVER_INFO_IND = 0x0012,
+ CC_HANDOVER_INFO_RSP = 0x0013,
CC_DISCOVER_LIST_REQ = 0x0014,
CC_DISCOVER_LIST_CNF = 0x0015,
CC_DISCOVER_LIST_IND = 0x0016,
@@ -108,7 +98,7 @@ typedef enum mm_type_t
CC_DCPPC_RSP = 0x0053,
CC_HP1_DET_REQ = 0x0054,
CC_HP1_DET_CNF = 0x0055,
- CC_BLE_UPDATE_IND = 0x0058,
+ CC_BLE_UPDATE_IND = 0x005A,
CP_PROXY_APPOINT_REQ = 0x2000,
CP_PROXY_APPOINT_CNF = 0x2001,
@@ -125,9 +115,9 @@ typedef enum mm_type_t
NN_ADD_ALLOC_IND = 0x400A,
NN_REL_ALLOC_REQ = 0x400C,
NN_REL_ALLOC_CNF = 0x400D,
- NN_REL_NET_IND = 0x4013,
+ NN_REL_NET_IND = 0x4012,
- CM_UNASSOCIATED_STA_IND = 0x6003,
+ CM_UNASSOCIATED_STA_IND = 0x6002,
CM_ENCRYPTED_PAYLOAD_IND = 0x6006,
CM_ENCRYPTED_PAYLOAD_RSP = 0x6007,
CM_SET_KEY_REQ = 0x6008,
@@ -137,7 +127,7 @@ typedef enum mm_type_t
CM_SC_JOIN_REQ = 0x6010,
CM_SC_JOIN_CNF = 0x6011,
CM_CHAN_EST_IND = 0x6016,
- CM_TM_UPDATE_IND = 0x6020,
+ CM_TM_UPDATE_IND = 0x601A,
CM_AMP_MAP_REQ = 0x601C,
CM_AMP_MAP_CNF = 0x601D,
CM_BRG_INFO_REQ = 0x6020,
@@ -189,9 +179,9 @@ typedef struct msg_mme_t // Table 11-178
typedef struct msg_list_mme_t
{
- u8 msg_mame[30]; // Message Name
+ mm_type_t mm_type; // Message type
msg_mme_dest_t msg_dest; // prefered destination (default if STA)
- int (*msg_func) (msg_mme_t msg[]); // Function processing the message
+ void (*msg_func) (msg_mme_t *msg); // Function processing the message
} msg_list_mme_t;
diff --git a/cp/msg/msg.h b/cp/msg/msg.h
index f2ed56eb1e..def3def449 100644
--- a/cp/msg/msg.h
+++ b/cp/msg/msg.h
@@ -24,7 +24,14 @@
/*
* Global variables
*/
-extern msg_list_mme_t msg_list[];
+extern const msg_list_mme_t msg_list[];
+
+
+/**
+ * \brief init the msg module
+ */
+void msg_init(void);
+
/**
* \brief Give the message number in our local reference.
@@ -35,12 +42,12 @@ u16
msg_get_number (msg_mme_t *msg);
/**
- * \brief
- * \param Msg : pointer to the message
+ * \brief this function is called in STA or CCO thread when a message is
+ * present in the corresponding fifo.
* \return NULL or ptr to the function
*/
-void *
-msg_dispatch (msg_mme_t *msg);
+void
+msg_dispatch (void);
/**
* \brief set the const values of mme (ie mtype)
diff --git a/cp/msg/src/msg.c b/cp/msg/src/msg.c
index 75f5c63924..2efcd177b9 100644
--- a/cp/msg/src/msg.c
+++ b/cp/msg/src/msg.c
@@ -14,88 +14,108 @@
#include "common/std.h"
#include "cp/msg/msg.h"
-msg_list_mme_t msg_list[] =
+/*
+ * this array describe messages, their prefered destination and the function
+ * which process it.
+ * the array must be ordered on the first field of each line.
+ */
+const msg_list_mme_t msg_list[] =
{
- { "CC_CCO_APPOINT.REQ", MSG_STA, NULL },
- { "CC_CCO_APPOINT.CNF", MSG_STA, NULL },
- { "CC_CCO_APPOINT.", MSG_STA, NULL },
- { "CC_CCO_APPOINT.", MSG_STA, NULL },
-
- { "CC_BACKUP_APPOINT.REQ", MSG_STA, NULL },
- { "CC_BACKUP_APPOINT.CNF", MSG_CCO, NULL },
- { "CC_BACKUP_APPOINT.", MSG_STA, NULL },
- { "CC_BACKUP_APPOINT.", MSG_STA, NULL },
-
- { "CC_LINK_INFO.REQ", MSG_CCO, NULL },
- { "CC_LINK_INFO.CNF", MSG_STA, NULL },
- { "CC_LINK_INFO.IND", MSG_STA, NULL }, // le msg est STA car le destinataire n'a pas encore changé
- { "CC_LINK_INFO.RSP", MSG_CCO, NULL },
-
- { "CC_HANDOVER.REQ", MSG_STA, NULL },
- { "CC_HANDOVER.CNF", MSG_CCO, NULL },
- { "CC_HANDOVER.", MSG_STA, NULL },
- { "CC_HANDOVER.", MSG_STA, NULL },
-
- { "CC_HANDOVER_INFO.", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.IND", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.RSP", MSG_CCO, NULL }
+ { CC_CCO_APPOINT_REQ, MSG_STA, NULL },
+ { CC_CCO_APPOINT_CNF, MSG_STA, NULL },
+ { CC_BACKUP_APPOINT_REQ, MSG_STA, NULL },
+ { CC_BACKUP_APPOINT_CNF, MSG_CCO, NULL },
+ { CC_LINK_INFO_REQ, MSG_CCO, NULL },
+ { CC_LINK_INFO_CNF, MSG_STA, NULL },
+ { CC_LINK_INFO_IND, MSG_STA, NULL },
+ { CC_LINK_INFO_RSP, MSG_CCO, NULL },
+ { CC_HANDOVER_REQ, MSG_STA, NULL },
+ { CC_HANDOVER_CNF, MSG_CCO, NULL },
+ { CC_HANDOVER_INFO_IND, MSG_STA, NULL },
+ { CC_HANDOVER_INFO_RSP, MSG_STA, NULL },
+ // TBC ...
+ { CM_UNASSOCIATED_STA_IND, MSG_STA, msg_cm_unassociated_sta_ind_rcv}
+ // TBC ...
};
+void msg_init(void)
+// it is not really useful to call this function from anywhere but a unit test.
+{
+ uint i;
+ for(i=1 ; i<COUNT(msg_list) ; i++)
+ dbg_assert(msg_list[i].mm_type > msg_list[i-1].mm_type);
+}
+
u16
msg_get_number (msg_mme_t *msg)
{
- msg_mme_t * mme;
u16 mme_num;
-
+
dbg_assert ( !msg_check_wrong_mme_const_values (msg));
-
- mme = msg;
- mme_num = mme->mm_type;
-
- if (mme->mm_type >= MSG_CM_START ) mme_num -= (MSG_CM_START - (MSG_NN_STOP + 1));
- if (mme->mm_type >= MSG_NN_START ) mme_num -= (MSG_NN_START - (MSG_CP_STOP + 1));
- if (mme->mm_type >= MSG_CP_START ) mme_num -= (MSG_CP_START - (MSG_CC_STOP + 1));
-
- if (mme_num >= COUNT (msg_list))
- {
- dbg_assert (0);
- return MSG_UNKNOW;
- }
+ //TODO this is maybe not very efficient, to check with more messages ...
+ DICHOTOMY_SEARCH(0, COUNT(msg_list), mme_num, msg->mm_type <= msg_list[mme_num].mm_type);
+ //printf("requested msg : %i, index found : %i\n", msg->mm_type, mme_num);
+ if(msg->mm_type != msg_list[mme_num].mm_type) return MSG_UNKNOW;
return mme_num;
}
-void *
-msg_dispatch (msg_mme_t *msg)
+void
+msg_dispatch (void)
{
u16 mme_num;
+ msg_mme_t *msg;
- dbg_assert ( !msg_check_wrong_mme_const_values (msg));
-
- mme_num = msg_get_number (msg);
- if ( (mme_num == MSG_UNKNOW) || (msg_list[mme_num].msg_func == NULL))
+ // process all the messages in the fifo
+ // TODO, in the next line, replace MSG_STA
+ msg = interf_msg_get_last(MSG_STA);
+ while(msg)
{
- // unknown or not implemented message
- return NULL;
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+ mme_num = msg_get_number (msg);
+ if (mme_num != MSG_UNKNOW)
+ {
+ dbg_assert(msg_list[mme_num].msg_func);
+ // process the message
+ msg_list[mme_num].msg_func (msg);
+ }
+ // release the message's buffer(s)
+ interf_release_buf(msg);
+ // and look for the next message
+ // TODO, in the next line, replace MSG_STA
+ msg = interf_msg_get_previous(MSG_STA);
}
- msg_list[mme_num].msg_func (msg);
- return msg_list[mme_num].msg_func;
}
void
msg_set_mme_const_values (msg_mme_t *msg)
{
dbg_assert (msg);
-
+ #if CHECK_BUFFER_OVERFLOW
+ interf_buffer_t *buffer = NULL;
+ #endif
+
msg->m_type = MSG_MTYPE; // 11.1.4
- msg->mmv = 0x01; // 11.1.5
+ msg->mmv = MSG_MM_VERSION;
+ #if CHECK_BUFFER_OVERFLOW
+ buffer = PARENT_OF(interf_buffer_t, msg, msg);
+ buffer->signature = BUFFER_SIGNATURE;
+ #endif
}
bool
msg_check_wrong_mme_const_values (msg_mme_t *msg)
{
+ #if CHECK_BUFFER_OVERFLOW
+ interf_buffer_t *buffer = NULL;
+ #endif
+
dbg_assert (msg);
+ #if CHECK_BUFFER_OVERFLOW
+ buffer = PARENT_OF(interf_buffer_t, msg, msg);
+ dbg_assert(buffer->signature == BUFFER_SIGNATURE);
+ #endif
+
return (msg->m_type != MSG_MTYPE);
}
@@ -106,7 +126,7 @@ msg_send(msg_mme_t *msg, uint msg_size, interf_id_t interf_id)
dbg_assert(msg_size <= SAR_MSDU_PAYLOAD_MAX_SIZE);
dbg_assert(interf_id < INTERF_MAX);
// set the values common to all MME
- // TODO set the ODA
+ // TODO set the OSA
// and then, send the message
interf_send (msg, msg_size, interf_id);
}
diff --git a/cp/msg/src/msg_cm.c b/cp/msg/src/msg_cm.c
index 7e3aa303ad..3191b6fdb1 100644
--- a/cp/msg/src/msg_cm.c
+++ b/cp/msg/src/msg_cm.c
@@ -46,3 +46,16 @@ msg_cm_unassociated_sta_ind_send(interf_id_t interf_id, mac_adresse_t oda)
STA_TRACE(" send cm_unassociated_sta\n");
msg_send(msg, sizeof(unassociated_sta_t) + MSG_MME_HEADER_SIZE, interf_id);
}
+
+void
+msg_cm_unassociated_sta_ind_rcv(msg_mme_t *msg)
+// 11.5.1
+{
+ unassociated_sta_t *unassociated_sta;
+
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+
+ unassociated_sta = (unassociated_sta_t *) & msg->mm_entry;
+ // TODO add the station which send the message to the discovered STA list...
+ //printf("hello world !\n");
+}
diff --git a/cp/station/inc/station_types.h b/cp/station/inc/station_types.h
index 9081cc1b6c..c6aa66c7db 100644
--- a/cp/station/inc/station_types.h
+++ b/cp/station/inc/station_types.h
@@ -38,7 +38,7 @@
*/
typedef enum station_flag_t
{
- STATION_FLAG_MSG_RCV = 0x1, // the sta has received a mme
+ STATION_FLAG_MSG_RCV = 0x1, // the sta has received a mme (for sta or cco)
STATION_FLAG_PERIODIC_UNASSO = 0x2, // send a cm_unassociated_sta message
STATION_FLAG_PERIODIC_BEACON = 0x4, // send a periodic beacon
STATION_FLAG_BEACON_MISSED = 0x8, // the last beacon was missed
@@ -46,7 +46,8 @@ typedef enum station_flag_t
STATION_FLAG_BBT = 0x20, // the timer bbt has expired
STATION_FLAG_USTT = 0x40, // the timer ustt has expired
STATION_FLAG_TEI_LEASE = 0x80, // the tei of the sta has expired
- STATION_FLAG_BUF_REL = 0x100 // some buffer can be released
+ STATION_FLAG_BUF_REL = 0x100,// some buffer can be released
+ STATION_FLAG_MSG_RCV_STA = 0x200,// a msg was received for the sta
// TBC
} station_flag_t;
@@ -60,6 +61,13 @@ typedef enum station_status_t
AUTHEN_STA
} station_status_t;
+typedef enum station_secu_state_t
+{
+ SECU_NONE,
+ SECU_ADD,
+ SECU_JOIN
+} station_secu_state_t;
+
typedef struct station_event_t
{
cyg_flag_value_t flag_value;
diff --git a/cp/station/src/station_events.c b/cp/station/src/station_events.c
index 24a4679839..b490a4ab01 100644
--- a/cp/station/src/station_events.c
+++ b/cp/station/src/station_events.c
@@ -35,10 +35,9 @@ station_launch_ustt(void)
void
station_ustt_expires(void)
-{
-
+{
// see Figure 7-76
- bool avln_detected = true;
+ bool avln_detected = false;
//STA_TRACE("ustt expires\n");
// check if some AVLN are detected
@@ -55,7 +54,7 @@ station_ustt_expires(void)
if( unassoc_sta_mme_periodic_sending)
station_stop_cm_unassoc_sta_mme_periodicaly();
}
- // check if we launch again the ustt timer Fig 7-76 or Fig 7-77
+ // check if we launch again the ustt timer (Fig 7-76 or Fig 7-77)
if( (station_status == POWER_ON) || (station_status == UNASSO_STA) )
{
station_launch_ustt();
@@ -80,7 +79,8 @@ station_send_cm_unassoc_sta_mme_periodicaly(void)
next_event_date_ms += offset_ms;
offset_ms = MaxDiscoverPeriod_ms - tmp;
dbg_assert(next_event_date_ms);
- dbg_assert(next_event_date_ms < (2 * MaxDiscoverPeriod_ms));
+ dbg_assert(next_event_date_ms < (2 * MaxDiscoverPeriod_ms));
+ dbg_assert(offset_ms < MaxDiscoverPeriod_ms);
station_gen_timed_event(&station_flag, STATION_FLAG_PERIODIC_UNASSO, next_event_date_ms);
// send the message
msg_cm_unassociated_sta_ind_send(INTERF_SAR, BROADCAST_MAC_AD);
@@ -91,5 +91,6 @@ station_stop_cm_unassoc_sta_mme_periodicaly(void)
{
// reset the flag
unassoc_sta_mme_periodic_sending = false;
+ // and reset the event
station_stop_timed_event(&station_flag, STATION_FLAG_PERIODIC_UNASSO);
}
diff --git a/cp/station/src/station_fsm.c b/cp/station/src/station_fsm.c
index 0f9757c46e..e015a88163 100644
--- a/cp/station/src/station_fsm.c
+++ b/cp/station/src/station_fsm.c
@@ -35,11 +35,12 @@ const station_event_t station_event[] =
{ STATION_FLAG_MSG_RCV, interf_received },
{ STATION_FLAG_BUF_REL, interf_buf_to_release },
{ STATION_FLAG_USTT, station_ustt_expires},
- { STATION_FLAG_PERIODIC_UNASSO, station_send_cm_unassoc_sta_mme_periodicaly }
+ { STATION_FLAG_PERIODIC_UNASSO, station_send_cm_unassoc_sta_mme_periodicaly },
+ { STATION_FLAG_MSG_RCV_STA, msg_dispatch}
};
static alarm_def_t alarm_def[ALARM_NB];
static cyg_mutex_t alarm_lock;
-
+static station_secu_state_t station_secu_state;
/*
* functions of station module
*/
@@ -49,8 +50,7 @@ station_init (void)
{
uint i;
- // TODO init station_seed
- // init the station module
+ // 1) init the station module
// init the event
cyg_flag_init (&station_flag);
// init the alarm
@@ -58,15 +58,18 @@ station_init (void)
alarm_def[i].alarm_used = false;
cyg_mutex_init( & alarm_lock);
unassoc_sta_mme_periodic_sending = false;
+ // init the security state of the station
+ station_secu_state = SECU_NONE;
+ // TODO init station_seed
- // init the others modules
+ // 2) init the others modules
interf_init ();
// TODO init the others modules
// wait 60 ms for some zero cross
-#if DEBUG == 0
+ #if DEBUG == 0
cyg_thread_delay (interf_ms_to_cyg_tick (60));
-#endif
+ #endif
// now that everything is initialised, do the AVLN discovery
station_power_on_net_disco();
}
@@ -75,6 +78,7 @@ station_init (void)
void
station_power_on_net_disco (void)
+// 7.1
{
bool sta_was_cco = false;
uint min_bbt, max_bbt, bbt;
@@ -104,7 +108,7 @@ station_power_on_net_disco (void)
// set the BBT timer
//printf("bbt = %i ms\n", bbt);
station_gen_timed_event(&station_flag, STATION_FLAG_BBT, bbt);
- // calculate USTT timer
+ // set ustt timer
station_launch_ustt();
station_wait_event ();
diff --git a/cp/test/inc/test_interf.h b/cp/test/inc/test_interf.h
index 7ffdca8378..400d616c1b 100644
--- a/cp/test/inc/test_interf.h
+++ b/cp/test/inc/test_interf.h
@@ -21,7 +21,7 @@
#include "cp/interf/interf.h"
#include "cp/interf/inc/interf_private.h"
-void interf_test (void);
+int interf_test (void);
#endif
diff --git a/cp/test/inc/test_msg.h b/cp/test/inc/test_msg.h
index f4ce28aa22..c3e8aa0030 100644
--- a/cp/test/inc/test_msg.h
+++ b/cp/test/inc/test_msg.h
@@ -20,7 +20,7 @@
#include "cp/msg/msg.h"
#include "cp/cp_types.h"
-void msg_test (void);
+int msg_test (void);
#endif
diff --git a/cp/test/inc/test_secu.h b/cp/test/inc/test_secu.h
index 3e46cc7182..b2ef02e7f9 100644
--- a/cp/test/inc/test_secu.h
+++ b/cp/test/inc/test_secu.h
@@ -19,6 +19,6 @@
#include "cp/secu/secu.h"
-void SECU_Test (void);
+int SECU_Test (void);
#endif
diff --git a/cp/test/inc/test_station.h b/cp/test/inc/test_station.h
index 789fa54c58..7056662983 100644
--- a/cp/test/inc/test_station.h
+++ b/cp/test/inc/test_station.h
@@ -16,7 +16,7 @@
#include "cp/station/station.h"
-void station_test (void);
+int station_test (void);
#endif /*TEST_STATION_H_*/
diff --git a/cp/test/src/test_cp.c b/cp/test/src/test_cp.c
index f463238aec..22e22dbd02 100644
--- a/cp/test/src/test_cp.c
+++ b/cp/test/src/test_cp.c
@@ -25,13 +25,15 @@
int main (void)
{
+ int return_value = 0;
// SECU_Test();
- msg_test ();
- interf_test ();
- station_test ();
+ return_value += msg_test ();
+ return_value += interf_test ();
+ return_value += station_test ();
- printf ("test complete.\n");
+ if(return_value == Success) printf ("test complete successfully.\n");
+ else printf ("test complete with some failures.\n");
// and stop the ecos thread
HAL_PLATFORM_EXIT(0);
- return 0;
+ return return_value;
}
diff --git a/cp/test/src/test_interf.c b/cp/test/src/test_interf.c
index 1ecd7fbc8b..78b648560b 100644
--- a/cp/test/src/test_interf.c
+++ b/cp/test/src/test_interf.c
@@ -247,24 +247,24 @@ int interf_module_test (void)
{
bzero(msg[i]->osa, sizeof(msg[i]->osa));
msg_set_mme_const_values(msg[i]);
- msg[i]->mm_type = 4; // cc_backup_appoint.req message,to STA
+ msg[i]->mm_type = CC_BACKUP_APPOINT_REQ; // messageto STA
}
// create a message of type 9
- msg[1]->mm_type = 9; // cc_link_info.cnf, to STA
+ msg[1]->mm_type = CC_LINK_INFO_CNF; // to STA
// create a 3 parts fragmented message
- msg[2]->mm_type = 9; // cc_link_info.cnf, to STA
+ msg[2]->mm_type = CC_LINK_INFO_CNF; // cc_link_info.cnf, to STA
msg[2]->fmi.nf_mi = 2;
msg[2]->fmi.fn_mi = 0;
msg[2]->fmi.fmsn = 45;
- msg[4]->mm_type = 9; // cc_link_info.cnf, to STA
+ msg[4]->mm_type = CC_LINK_INFO_CNF; // cc_link_info.cnf, to STA
msg[4]->fmi.nf_mi = 2;
msg[4]->fmi.fn_mi = 1;
msg[4]->fmi.fmsn = 45;
- msg[7]->mm_type = 9; // cc_link_info.cnf, to STA
+ msg[7]->mm_type = CC_LINK_INFO_CNF; // cc_link_info.cnf, to STA
msg[7]->fmi.nf_mi = 2;
msg[7]->fmi.fn_mi = 2;
msg[7]->fmi.fmsn = 45;
@@ -281,57 +281,57 @@ int interf_module_test (void)
// the msg should now be in the STA fifo, so ask for it
test = interf_msg_get_last(MSG_STA);
// check that we have the same msg
- if(test != msg[8]) return Failure;
+ if(test != msg[8]) return 1;
// the previous msg should be the first part of frag msg
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[2]) return Failure;
+ if(test != msg[2]) return 2;
// then we should have the other complete msg
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[6]) return Failure;
+ if(test != msg[6]) return 3;
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[5]) return Failure;
+ if(test != msg[5]) return 4;
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[3]) return Failure;
+ if(test != msg[3]) return 5;
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[1]) return Failure;
+ if(test != msg[1]) return 6;
test = interf_msg_get_previous(MSG_STA);
- if(test != msg[0]) return Failure;
+ if(test != msg[0]) return 7;
// and here, we are at the end of the fifo
test = interf_msg_get_previous(MSG_STA);
- if(test != NULL) return Failure;
+ if(test != NULL) return 8;
// test it once again to discover an assert ...
test = interf_msg_get_previous(MSG_STA);
- if(test != NULL) return Failure;
+ if(test != NULL) return 9;
// then we try to get a message from it type
test = interf_msg_get_last_of_type(MSG_STA, 9);
- if(test != msg[2]) return Failure;
+ if(test != msg[2]) return 10;
// remove one before it, and ask again
- if( ! interf_msg_remove(MSG_STA, msg[3])) return Failure;
+ if( ! interf_msg_remove(MSG_STA, msg[3])) return 11;
test = interf_msg_get_last_of_type(MSG_STA, 9);
- if(test != msg[2]) return Failure;
+ if(test != msg[2]) return 12;
// and we ask for the others parts of the message
test = interf_msg_get_next_part(test);
- if(test != msg[4]) return Failure;
+ if(test != msg[4]) return 13;
test = interf_msg_get_next_part(test);
- if(test != msg[7]) return Failure;
+ if(test != msg[7]) return 14;
// there is no more part
test = interf_msg_get_next_part(test);
- if(test != NULL) return Failure;
+ if(test != NULL) return 15;
// then we try (again) to get a message from it type
test = interf_msg_get_last_of_type(MSG_STA, 9);
- if(test != msg[2]) return Failure;
+ if(test != msg[2]) return 16;
// we ask for previous message of this type
test = interf_msg_get_previous_of_type(MSG_STA, 9);
- if(test != msg[1]) return Failure;
+ if(test != msg[1]) return 17;
return Success;
}
@@ -342,11 +342,11 @@ struct interf_test_t
char func_name[30];
};
-void interf_test (void)
+int interf_test (void)
{
bool verbose = false;
unsigned int i;
- int res;
+ int res, return_value = 0;
struct interf_test_t my_test[]=
{
{ interf_init_test, "interf_init" },
@@ -370,5 +370,7 @@ void interf_test (void)
if (res == Success) printf ("OK\n");
else printf ("FAILED : %i\n", res);
}
+ if(res != Success) return_value++;
}
+ return return_value;
}
diff --git a/cp/test/src/test_msg.c b/cp/test/src/test_msg.c
index b3a0205298..81f9b04886 100644
--- a/cp/test/src/test_msg.c
+++ b/cp/test/src/test_msg.c
@@ -14,30 +14,13 @@
#include "common/std.h"
#include "cp/test/inc/test_msg.h"
+
/*
- * test de void MSG_Dispatch(u8 Msg[])
+ * test de void msg_init(void)
*/
-typedef struct msg_dispatch_test_t
-{
- msg_mme_t sample; // message à tester
- int ( * expected_func) (u8 msg[]); // numéro de message attendu
-} msg_dispatch_test_t;
-
-int msg_dispatch_test (void)
+int msg_init_test (void)
{
- /*
- unsigned int i;
- msg_dispatch_test_t sample[]=
- {
- {"ODAODAOSAOSAVLANMT1\x08\x00MFM", NULL}, // 0x08 CC_LINK_INFO.REQ
- {"ODAODAOSAOSAVLANMT1\x00\x60MFM", NULL} // 0x6000
- };
-
- for(i=0 ; i < COUNT(sample) ; i++)
- {
- if(msg_dispatch(& sample[i].sample) != sample[i].expected_func) return Failure;
- }
- */
+ msg_init();
return Success;
}
@@ -51,24 +34,48 @@ int msg_set_mme_const_values_test (void)
return msg_check_wrong_mme_const_values (&msg);
}
+
+/*
+ * u16 msg_get_number (msg_mme_t *msg)
+ */
+
+int msg_get_number_test(void)
+{
+ msg_mme_t msg;
+ msg_set_mme_const_values(& msg);
+ msg.mm_type = 0;
+ if(msg_get_number(&msg) != 0) return 1;
+ msg.mm_type = 63;
+ if(msg_get_number(&msg) != MSG_UNKNOW) return 2;
+ msg.mm_type = 0xE;
+ if(msg_get_number(&msg) != MSG_UNKNOW) return 3;
+ msg.mm_type = 0xD;
+ if(msg_get_number(&msg) != 9) return 4;
+ return Success;
+}
+
+
+
+
struct msg_test_t
{
int(*func) (void);
char func_name[30];
};
-void msg_test (void)
+int msg_test (void)
{
bool verbose = false;
unsigned int i;
- int res;
+ int res, return_value = 0;
struct msg_test_t my_test[]=
{
- { msg_dispatch_test, "msg_dispatch" },
- { msg_set_mme_const_values_test, "msg_xx_mme_const_values" }
+ { msg_init_test, "msg_init"},
+ { msg_set_mme_const_values_test, "msg_xxx_mme_const_values" },
+ { msg_get_number_test, "msg_get_number"}
};
- printf ("test du module MSG\n");
+ printf ("test du module msg\n");
for (i=0 ; i<COUNT (my_test) ; i++)
{
res = my_test[i].func ();
@@ -78,6 +85,7 @@ void msg_test (void)
if (res == Success) printf ("OK\n");
else printf ("FAILED : %i\n", res);
}
+ if(res != Success) return_value++;
}
-
+ return return_value;
}
diff --git a/cp/test/src/test_secu.c b/cp/test/src/test_secu.c
index 76eebb67df..318e1d0203 100644
--- a/cp/test/src/test_secu.c
+++ b/cp/test/src/test_secu.c
@@ -440,10 +440,10 @@ struct T_SecuTest
char FuncName[30];
};
-void SECU_Test (void)
+int SECU_Test (void)
{
unsigned int i;
- int res;
+ int res, return_value = 0;
struct T_SecuTest SecuTest[]=
{
{ sha2_self_test, "sha2 (1)" },
@@ -466,5 +466,7 @@ void SECU_Test (void)
printf (" %-50s", SecuTest[i].FuncName);
if (res == Success) printf ("OK\n");
else printf ("FAILED : %i\n", res);
+ if(res != Success) return_value++;
}
+ return return_value;
}
diff --git a/cp/test/src/test_station.c b/cp/test/src/test_station.c
index bd8b0bddc8..a4b4486d73 100644
--- a/cp/test/src/test_station.c
+++ b/cp/test/src/test_station.c
@@ -65,8 +65,25 @@ int station_gen_timed_event_test(void)
// if we had an event, it's a failure
if(flag_return != (flag_value>>1)) return 2;
- cyg_thread_delay (interf_ms_to_cyg_tick (10000));
+ cyg_thread_delay (interf_ms_to_cyg_tick (1000));
+ return Success;
+}
+
+
+/*
+ * test de l'envoie d'un message unassociated_sta et de sa reception...
+ */
+int station_unassociated_sta_test(void)
+{
+ msg_mme_t *msg;
+// unassociated_sta_t *unassociated_sta;
+
+ msg = interf_give_buf();
+ msg->mm_type = CM_UNASSOCIATED_STA_IND;
+ //unassociated_sta = (unassociated_sta_t *) & msg->mm_entry;
+ interf_receive(msg);
+ cyg_thread_delay (interf_ms_to_cyg_tick (100));
return Success;
}
@@ -83,14 +100,15 @@ station_thread_launch(cyg_addrword_t data)
station_init();
}
-void station_test (void)
+int station_test (void)
{
bool verbose = true;
unsigned int i;
- int res;
+ int res, return_value = 0;
struct station_test_t my_test[]=
{
- {station_gen_timed_event_test, "station_gen_timed_event"}
+ {station_gen_timed_event_test, "station_gen_timed_event"},
+ {station_unassociated_sta_test, "station_unassociated_sta"}
};
printf ("test du module station\n");
@@ -118,8 +136,10 @@ void station_test (void)
if (res == Success) printf ("OK\n");
else printf ("FAILED : %i\n", res);
}
+ if(res != Success) return_value++;
}
// end of the test, we destroy the STA thread
cyg_thread_kill(station_thread_handle);
+ return return_value;
}