summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cp/beacon/test/overide/test/Makefile30
-rw-r--r--cp/beacon/test/overide/test/ecos.ecc.sh5
-rw-r--r--cp/beacon/test/overide/test/inc/test_interf.h29
-rw-r--r--cp/beacon/test/overide/test/inc/test_msg.h27
-rw-r--r--cp/beacon/test/overide/test/inc/test_secu.h24
-rw-r--r--cp/beacon/test/overide/test/inc/test_station.h26
-rw-r--r--cp/beacon/test/overide/test/src/test_cp.c89
-rw-r--r--cp/beacon/test/overide/test/src/test_interf.c342
-rw-r--r--cp/beacon/test/overide/test/src/test_msg.c159
-rw-r--r--cp/beacon/test/overide/test/src/test_secu.c475
-rw-r--r--cp/beacon/test/overide/test/src/test_station.c393
11 files changed, 0 insertions, 1599 deletions
diff --git a/cp/beacon/test/overide/test/Makefile b/cp/beacon/test/overide/test/Makefile
deleted file mode 100644
index 644e4ad413..0000000000
--- a/cp/beacon/test/overide/test/Makefile
+++ /dev/null
@@ -1,30 +0,0 @@
-BASE = ../../
-
-ECOS = y
-
-#INCLUDES = test_general/station/overide/
-
-TARGET_PROGRAMS = UnitTestCP
-UnitTestCP_SOURCES = test_interf.c test_cp.c test_msg.c test_station.c test_secu.c
-UnitTestCP_MODULES = lib \
- lib/visual_state_api \
- cp/interf \
- cp/msg \
- cp/station \
- cp/secu \
- cp/vstate_fsm \
- cp/beacon \
- cl \
- mac/sar \
- mac/common \
- mac/pbproc \
- mac/sar/bridgedma \
- test_general/station/overide/cp/cco \
- test_general/station/overide/cp/secu \
-
-
-
-
-mac_pbproc_MODULE_SOURCES = mfs.c
-
-include $(BASE)/common/make/top.mk
diff --git a/cp/beacon/test/overide/test/ecos.ecc.sh b/cp/beacon/test/overide/test/ecos.ecc.sh
deleted file mode 100644
index 8253d98c9a..0000000000
--- a/cp/beacon/test/overide/test/ecos.ecc.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-config=${1:-ecos-gen.ecc}
-ecosconfig --config=$config new linux default
-cat >> $config <<EOF
-EOF
-ecosconfig --config=$config check
diff --git a/cp/beacon/test/overide/test/inc/test_interf.h b/cp/beacon/test/overide/test/inc/test_interf.h
deleted file mode 100644
index d351ca5769..0000000000
--- a/cp/beacon/test/overide/test/inc/test_interf.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_interf.h
- * \brief Unit test for module interf
- * \ingroup cp_test
- */
-
-#ifndef interf__test__h
-#define interf__test__h
-
-#include <stdio.h>
-#include <string.h>
-
-#include "cp/cp_types.h"
-#include "cp/interf/interf.h"
-#include "cp/interf/inc/interf_private.h"
-#include "cp/msg/msg.h"
-
-
-int interf_test (void);
-
-#endif
-
diff --git a/cp/beacon/test/overide/test/inc/test_msg.h b/cp/beacon/test/overide/test/inc/test_msg.h
deleted file mode 100644
index 37f1087db6..0000000000
--- a/cp/beacon/test/overide/test/inc/test_msg.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_msg.h
- * \brief Unit tests for module MSG.
- * \ingroup cp_test
- */
-
-#ifndef messages__test__h
-#define messages__test__h
-
-#include <stdio.h>
-#include <string.h>
-
-#include "cp/msg/msg.h"
-#include "cp/cp_types.h"
-
-
-int msg_test (void);
-
-#endif
-
diff --git a/cp/beacon/test/overide/test/inc/test_secu.h b/cp/beacon/test/overide/test/inc/test_secu.h
deleted file mode 100644
index f36ae5502a..0000000000
--- a/cp/beacon/test/overide/test/inc/test_secu.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_secu.h
- * \brief Unit tests for module secu.
- * \ingroup cp_test
- */
-
-#ifndef secu__test__h
-#define secu__test__h
-
-#include <stdio.h>
-#include <string.h>
-
-#include "cp/secu/secu.h"
-
-int secu_test (void);
-
-#endif
diff --git a/cp/beacon/test/overide/test/inc/test_station.h b/cp/beacon/test/overide/test/inc/test_station.h
deleted file mode 100644
index 6e9997f9a0..0000000000
--- a/cp/beacon/test/overide/test/inc/test_station.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_station.h
- * \brief Unit tests for module station.
- * \ingroup cp_test
- */
-#ifndef TEST_STATION_H_
-#define TEST_STATION_H_
-
-#include "cp/station/station.h"
-#include "cp/station/inc/station_event_handler.h"
-#include "cp/msg/msg.h"
-
-#include <cyg/hal/hal_arch.h>
-
-
-int station_test (void);
-
-
-#endif /*TEST_STATION_H_*/
diff --git a/cp/beacon/test/overide/test/src/test_cp.c b/cp/beacon/test/overide/test/src/test_cp.c
deleted file mode 100644
index 920edbe985..0000000000
--- a/cp/beacon/test/overide/test/src/test_cp.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_cp.c
- * \brief main entry to launch all cp unit tests
- * \ingroup cp_test
- *
- */
-
-#include <cyg/hal/hal_arch.h>
-#include <cyg/kernel/kapi.h>
-
-#include "common/std.h"
-
-#include "cp/test/inc/test_secu.h"
-#include "cp/test/inc/test_msg.h"
-#include "cp/test/inc/test_interf.h"
-#include "cp/test/inc/test_station.h"
-#include "cp/beacon/inc/beacon_types.h"
-#include "lib/trace.h"
-
-
-/////////////////
-
-mac_store_t *mac_store;
-mac_config_t *mac_config;
-pbproc_t *pbproc;
-sar_t *sar;
-cl_t *cl;
-ca_t *ca;
-sec_t sec_m;
-
-
-#define STA_THREAD_PRIORITY 30
-/*
-static unsigned char station_thread_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
-static cyg_handle_t station_thread_handle;
-static cyg_thread station_thread;
-*/
-
-/*
- * this will init the cp module, and launch the cp thread
- */
-int cp_init(mac_store_t *mac_store_ctx, cl_t *interf_cl_ctx)
-{
- /*
- beacon_init();
- interf_init ();
- msg_init();
- secu_init(&sec_m);
- cp_station_init(mac_store_ctx, interf_cl_ctx);
- // creation of the CP thread
- cyg_thread_create(
- STA_THREAD_PRIORITY,
- &station_wait_event,
- 0,
- "CP",
- station_thread_stack,
- sizeof(station_thread_stack),
- &station_thread_handle,
- &station_thread
- );
- cyg_thread_resume(station_thread_handle);
- */
- return 0;
-}
-
-/////////////////
-int main ( int argc, char * argv[] )
-{
- int return_value = 0;
-
- return_value += secu_test();
- return_value += msg_test ();
- return_value += interf_test ();
- return_value += station_test ();
-
- if(return_value == 0) printf ("test complete successfully.\n");
- else printf ("test complete with some failures.\n");
- // and stop the ecos thread
- HAL_PLATFORM_EXIT(0);
-
- return return_value;
-}
diff --git a/cp/beacon/test/overide/test/src/test_interf.c b/cp/beacon/test/overide/test/src/test_interf.c
deleted file mode 100644
index d0b28e107a..0000000000
--- a/cp/beacon/test/overide/test/src/test_interf.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_interf.c
- * \brief unit tests for interf module
- * \ingroup cp_test
- */
-
-#include "common/std.h"
-#include "cp/test/inc/test_interf.h"
-
-/*
- * Test de void interf_init(void);
- */
-int interf_init_test (void)
-{
- return interf_init ();
-}
-
-/*
- * Test de interf_received_frag_test
- */
-int interf_received_frag_test (void)
-{
- interf_buffer_t buf_test[5];
- msg_mme_t *msg;
- int i;
-
- interf_init ();
- // init the buf
- bzero (buf_test, sizeof(buf_test));
- // Test add of a 5 fragments message
- for(i=0; i<5; i++)
- {
- msg = &buf_test[i].msg;
- msg_set_mme_const_values(msg);
- bzero(msg->osa, 6);
- msg->fmi.nf_mi = 4; // Number of fragments for message
- msg->fmi.fn_mi = i; // fragment number
- msg->fmi.fmsn = 32;
- msg->mm_type = TEST_MSG_NUM;
- if(i != msg->fmi.nf_mi)
- {
- if(interf_received_frag(msg) != NULL) return 1;
- }
- else if(interf_received_frag(msg) == NULL) return 2;
- }
- // check that BufTest structure is updated correctly
- for(i=0; i < 3; i++)
- {
- if(buf_test[i].next_msg != &buf_test[i+1].msg ) return 3;
- }
- // Test filling the receiving struct
- interf_init();
- for(i=0 ; i < INTERF_MAX_FRAG_MSG_SIM ; i++)
- {
- msg = &buf_test[i].msg;
- bzero(msg->osa, 6);
- msg->fmi.nf_mi = 4; // Number of fragments for message
- msg->fmi.fn_mi = i; // fragment number
- msg->fmi.fmsn = i;
- if(interf_received_frag(msg) != NULL) return 4;
- }
- // and then test adding others fragments
- for(i=1 ; i<5 ; i++)
- {
- msg = &buf_test[i].msg;
- bzero(msg->osa, 6);
- msg->fmi.nf_mi = 4; // Number of fragments for message
- msg->fmi.fn_mi = i; // fragment number
- msg->fmi.fmsn = 0;
- if(i != msg->fmi.nf_mi)
- {
- if(interf_received_frag(msg) != NULL) return 5;
- }
- else if(interf_received_frag(msg) == NULL) return 6;
- }
- return 0;
-}
-
-/*
- * Test de void interf_send(msg_mme_t *msg)
- *
- */
-int interf_send_test (void)
-{
- interf_buffer_t buffer;
- msg_mme_t *msg;
- msg_param_t msg_param;
-
- msg = &buffer.msg;
- msg_param.mnbf = 1;
- msg_set_mme_const_values (msg);
- interf_send (msg, 80, msg_param, 0xFF);
- return 0;
-}
-
-/*
- * Test de void interf_received(void)
- *
- */
-int interf_received_test (void)
-{
- interf_buffer_t buf_test;
- msg_mme_t *msg;
-
- msg = &buf_test.msg;
- msg_set_mme_const_values (msg);
- msg->mm_type = TEST_MSG_NUM;
-
- interf_init();
-
- interf_receive(0, 0, (u8*) msg, 0, 0);
-
- interf_received ();
- return 0;
-}
-
-
-/*
- * test de void interf_release_buf(msg_mme_t *msg)
- * et des fonctions attachées
- */
-#define MY_CONST_ 9 // doit etre inférieure a la taille d'une mailbox
-int interf_release_buf_test (void)
-{
- interf_buffer_t buf[MY_CONST_];
- msg_mme_t *msg[MY_CONST_];
- int i;
-
- // init all the interf module
- interf_init ();
- bzero (&buf, sizeof(buf));
-
- // init the messages for test
- for(i=0 ; i<MY_CONST_ ; i++)
- {
- msg[i] = &buf[i].msg;
- 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
- }
-
- // empile les message dans la fifo
- for(i=0 ; i<MY_CONST_ ; i++)
- {
- interf_release_buf(msg[i]);
- }
- // et hop on vide !
- interf_buf_to_release();
-
- return 0;
-}
-
-/*
- * test de la fonction de purge
- */
-int interf_msg_purge_test (void)
-{
- interf_buffer_t buf_test;
- msg_mme_t *msg;
-
- // init all the interf module
- interf_init ();
- bzero (&buf_test, sizeof(buf_test));
-
- // create a fragment of message
- msg = &buf_test.msg;
- msg_set_mme_const_values(msg);
- bzero(msg->osa, 6);
- msg->fmi.nf_mi = 4; // Number of fragments for message
- msg->fmi.fn_mi = 1; // fragment number
- msg->fmi.fmsn = 32;
- // add this fragment in the fifo
- //interf_receive(msg);
- interf_receive(0, 0, (u8*) msg, 0, 0);
-
- interf_received();
- cyg_thread_delay( (FragMMI_ReassemblyTimeOut_sec + 1) * 100);
- interf_msg_purge();
- return 0;
-}
-
-/*
- * Test de l'ensemble du module
- *
- */
-#define NB_MSG_TEST 9
-
-int interf_module_test (void)
-{
-/*
- interf_buffer_t buf[NB_MSG_TEST];
- msg_mme_t *msg[NB_MSG_TEST], *test;
- int i;
-
- for (i=0 ; i<NB_MSG_TEST ; i++)
- {
- msg[i] = &buf[i].msg;
- }
-
- // init all the interf module
- interf_init ();
- bzero (&buf, sizeof(buf));
-
- // init the messages for test
- for(i=0 ; i<NB_MSG_TEST ; i++)
- {
- bzero(msg[i]->osa, sizeof(msg[i]->osa));
- msg_set_mme_const_values(msg[i]);
- msg[i]->mm_type = TEST_MSG_NUM;
- }
- // create a test message
- msg[1]->mm_type = TEST_MSG_NUM;
-
- // create a 3 parts fragmented message
-
- msg[2]->mm_type = TEST_MSG_NUM;
- msg[2]->fmi.nf_mi = 2;
- msg[2]->fmi.fn_mi = 0;
- msg[2]->fmi.fmsn = 45;
-
- msg[4]->mm_type = TEST_MSG_NUM;
- msg[4]->fmi.nf_mi = 2;
- msg[4]->fmi.fn_mi = 1;
- msg[4]->fmi.fmsn = 45;
-
- msg[7]->mm_type = TEST_MSG_NUM;
- msg[7]->fmi.nf_mi = 2;
- msg[7]->fmi.fn_mi = 2;
- msg[7]->fmi.fmsn = 45;
-
- // receive the message at the STA
- for(i=0 ; i<NB_MSG_TEST ; i++)
- {
- interf_receive(msg[i]);
- }
-
- // simulate the sta event,
- interf_received();
-
- // 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 1;
-
- // the previous msg should be the first part of frag msg
- test = interf_msg_get_previous(MSG_STA);
- 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 3;
- test = interf_msg_get_previous(MSG_STA);
- if(test != msg[5]) return 4;
- test = interf_msg_get_previous(MSG_STA);
- if(test != msg[3]) return 5;
- test = interf_msg_get_previous(MSG_STA);
- if(test != msg[1]) return 6;
- test = interf_msg_get_previous(MSG_STA);
- 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 8;
- // test it once again to discover an assert ...
- test = interf_msg_get_previous(MSG_STA);
- 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 10;
-
- // remove one before it, and ask again
- 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 12;
-
- // and we ask for the others parts of the message
- test = interf_msg_get_next_part(test);
- if(test != msg[4]) return 13;
-
- test = interf_msg_get_next_part(test);
- if(test != msg[7]) return 14;
-
- // there is no more part
- test = interf_msg_get_next_part(test);
- 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 16;
- // we ask for previous message of this type
- test = interf_msg_get_previous_of_type(MSG_STA, 9);
- if(test != msg[1]) return 17;
-*/
- return 0;
-}
-
-struct interf_test_t
-{
- int(*func) (void);
- char func_name[30];
-};
-
-int interf_test (void)
-{
- bool verbose = 0;
- unsigned int i;
- int res, return_value = 0;
- struct interf_test_t my_test[]=
- {
- { interf_init_test, "interf_init" },
- { interf_received_frag_test, "interf_received_frag" },
- { interf_received_test, "inter_received"},
- { interf_send_test, "interf_send" },
- { interf_received_test, "interf_received" },
- { interf_release_buf_test, "interf_release_buf" },
- { interf_msg_purge_test, "interf_msg_purge" }
- //{ interf_module_test, "interf : module" }
- };
-
- printf ("test du module interf\n");
- for (i=0 ; i<COUNT(my_test) ; i++)
- {
- res = my_test[i].func ();
- if(verbose || (res != 0))
- {
- printf (" %-50s", my_test[i].func_name);
- if (res == 0) printf ("OK\n");
- else printf ("FAILED : %i\n", res);
- }
- if(res != 0) return_value++;
- }
- if (i != COUNT(my_test)) return 1;
- return return_value;
-}
diff --git a/cp/beacon/test/overide/test/src/test_msg.c b/cp/beacon/test/overide/test/src/test_msg.c
deleted file mode 100644
index a392b1e901..0000000000
--- a/cp/beacon/test/overide/test/src/test_msg.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_msg.c
- * \brief unit tests for msg module
- * \ingroup cp_test
- */
-
-#include "common/std.h"
-#include "cp/test/inc/test_msg.h"
-#include "cp/secu/inc/secu_aes.h"
-
-/*
- * test de void msg_init(void)
- */
-int msg_init_test (void)
-{
- msg_init();
- return 0;
-}
-
-/*
- * test de void msg_xxx_mme_const_values
- */
-int msg_set_mme_const_values_test (void)
-{
- msg_mme_t msg;
- msg_set_mme_const_values (&msg);
- 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 0;
-}
-
-/*
- * test cm_encrypted payload
- */
-int
-int_test_enc(void)
-{
- //char msg_orig[] = "\x00\x31\x32\x33\x34\x35\x00\x46\x47\x48\x49\x50\x88\xe1\x01\x08\x60\x00\x00\x01\x00\x11\x22\x33\x44\x33\x22\x11\x02\x2d\x37\x03\x02\x02\x6b\xcb\xa5\x35\x4e\x18\x01\xb5\x93\x19\xd7\xe8\x15\x7b\xa0\x01\xb0\x18\x66\x9c\xce\xe3\x0d";
- unsigned char msg[] = "\x00\x31\x32\x33\x34\x35\x00\x46\x47\x48\x49\x50\x88\xe1\x01\x06\x60\x00\x00\x00\x05\x02\x2d\x37\x03\xfe\xdc\xba\x98\x76\x54\x32\x10\xfe\xdc\xba\x98\x76\x54\x32\x10\x39\x00\x24\x68\xac\xe0\x35\x00\x31\x32\x33\x34\x35\x00\x46\x47\x48\x49\x50\x88\xe1\x01\x08\x60\x00\x00\x01\x00\x11\x22\x33\x44\x33\x22\x11\x02\x2d\x37\x03\x02\x02\x6b\xcb\xa5\x35\x4e\x18\x01\xb5\x93\x19\xd7\xe8\x15\x7b\xa0\x01\xb0\x18\x66\x9c\xce\xe3\x0d\xf1\x66\x28\x20\x02\x2d\x37\x03\xac\xbc\xd2\x11\x4d\xae\x15\x77\xc6\x05";
- unsigned char iv[] = "\xfe\xdc\xba\x98\x76\x54\x32\x10\xfe\xdc\xba\x98\x76\x54\x32\x10";
- unsigned char key[] = "\xEE\x7F\x57\x88\xE2\xA0\x21\xC9\x99\x46\x9A\xC5\x2A\xF3\x0A\x06";
- unsigned char res[] = "\xa9\xa8\x87\xca\x49\x53\x09\x31\xbb\x73\x60\xad\x22\xb2\x84\x61\x9e\xaf\xb1\x07\x8a";
- unsigned char enc[1518];
- aes_context ctx;
- int i;
-
- aes_set_key(&ctx, key, sizeof(aes_key_t)*8);
- aes_cbc_encrypt (&ctx, iv, &msg[43], enc, 0x50);
- i = memcmp(enc, res, COUNT(res)-1);
- if(i)return 1;
- return 0;
-}
-
-int
-msg_cm_encrypted_payload_ind_send_test(void)
-{
- msg_mme_t msg;
- cm_set_key_req_t *cm_set_key_req;
- msg_param_t msg_param;
- tei_t tei = 1;
- int i;
-
- i = int_test_enc();
- if(i) return i;
-
- // create the message cm_set_key.REQ such as in table 13-144
- memcpy(&msg.oda, "\x00\x31\x32\x33\x34\x35", 6);
- memcpy(&msg.osa, "\x00\x46\x47\x48\x49\x50", 6);
- msg_set_mme_const_values((msg_mme_t *)&msg);
- msg.mm_type = CM_SET_KEY_REQ;
- msg.fmi.fmsn = 0;
- msg.fmi.fn_mi = 0;
- msg.fmi.nf_mi = 0;
- cm_set_key_req = (cm_set_key_req_t *) msg.mm_entry;
- cm_set_key_req->key_type = 1;
- cm_set_key_req->my_nonce = 0x33221100;
- cm_set_key_req->your_nonce = 0x11223344;
- cm_set_key_req->pid = 2;
- cm_set_key_req->prn = 0x372D;
- cm_set_key_req->pmn = 3;
- cm_set_key_req->cco_capa = 2;
- memcpy(cm_set_key_req->nid, "\x02\x6B\xCB\xA5\x35\x4E\x18", 7);
- cm_set_key_req->new_eks = 1;
- memcpy(cm_set_key_req->new_key, "\xB5\x93\x19\xD7\xE8\x15\x7B\xA0\x01\xB0\x18\x66\x9C\xCE\xE3\x0D", 16);
-
- msg_param.peks = PEKS_DESTINATION_STA_DAK;
- secu_set_sta_s_dak(tei, "\xEE\x7F\x57\x88\xE2\xA0\x21\xC9\x99\x46\x9A\xC5\x2A\xF3\x0A\x06");
- cp_station_set_mac_address(NULL, "\x00\x46\x47\x48\x49\x50");
-
- msg_cm_encrypted_payload_ind_send(
- (msg_mme_t *)&msg,
- msg_param,
- tei,
- false,
- 2,
- sizeof(cm_set_key_req_t) + MSG_MME_HEADER_SIZE
- );
- return 0;
-}
-
-struct msg_test_t
-{
- int(*func) (void);
- char func_name[30];
-};
-
-int msg_test (void)
-{
- bool verbose = false;
- unsigned int i;
- int res, return_value = 0;
- struct msg_test_t my_test[]=
- {
- { msg_init_test, "msg_init"},
- { msg_set_mme_const_values_test, "msg_xxx_mme_const_values" },
- { msg_get_number_test, "msg_get_number"},
- { msg_cm_encrypted_payload_ind_send_test, "cm_encrypted_payload_ind"}
- };
-
- printf ("test du module msg\n");
- for (i=0 ; i<COUNT (my_test) ; i++)
- {
- res = my_test[i].func ();
- if(verbose || (res != 0))
- {
- printf (" %-50s", my_test[i].func_name);
- if (res == 0) printf ("OK\n");
- else printf ("FAILED : %i\n", res);
- }
- if(res != 0) return_value++;
- }
- if (i != COUNT(my_test)) return 1;
- return return_value;
-}
diff --git a/cp/beacon/test/overide/test/src/test_secu.c b/cp/beacon/test/overide/test/src/test_secu.c
deleted file mode 100644
index 4d2b8ca99b..0000000000
--- a/cp/beacon/test/overide/test/src/test_secu.c
+++ /dev/null
@@ -1,475 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_secu.c
- * \brief unit tests for secu module
- * \ingroup cp_test
- */
-
-#include "common/std.h"
-#include "cp/test/inc/test_secu.h"
-
-/*
- * Test de la fonction sha2
- */
-
-/*
- * FIPS-180-2 test vectors
- */
-
-//static const char sha2_test_str[3][57] =
-static char sha2_test_str[3][57] =
- {
- { "abc" },
- { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" },
- { "" }
- };
-
-static const unsigned char sha2_test_sum[6][32] = {
-/*
- * SHA-224 test vectors
- */
-{ 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22, 0x86, 0x42, 0xA4, 0x77,
- 0xBD, 0xA2, 0x55, 0xB3, 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3,
- 0xF7, 0xE3, 0x6C, 0x9D, 0xA7 }, { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27,
- 0x76, 0xCC, 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50, 0xB0,
- 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19, 0x52, 0x52, 0x25, 0x25 }, {
- 0x20, 0x79, 0x46, 0x55, 0x98, 0x0C, 0x91, 0xD8, 0xBB, 0xB4, 0xC1,
- 0xEA, 0x97, 0x61, 0x8A, 0x4B, 0xF0, 0x3F, 0x42, 0x58, 0x19, 0x48,
- 0xB2, 0xEE, 0x4E, 0xE7, 0xAD, 0x67 },
-
-/*
- * SHA-256 test vectors
- */
-{ 0xBA, 0x78, 0x16, 0xBF, 0x8F, 0x01, 0xCF, 0xEA, 0x41, 0x41, 0x40, 0xDE,
- 0x5D, 0xAE, 0x22, 0x23, 0xB0, 0x03, 0x61, 0xA3, 0x96, 0x17, 0x7A,
- 0x9C, 0xB4, 0x10, 0xFF, 0x61, 0xF2, 0x00, 0x15, 0xAD }, { 0x24, 0x8D,
- 0x6A, 0x61, 0xD2, 0x06, 0x38, 0xB8, 0xE5, 0xC0, 0x26, 0x93, 0x0C,
- 0x3E, 0x60, 0x39, 0xA3, 0x3C, 0xE4, 0x59, 0x64, 0xFF, 0x21, 0x67,
- 0xF6, 0xEC, 0xED, 0xD4, 0x19, 0xDB, 0x06, 0xC1 }, { 0xCD, 0xC7, 0x6E,
- 0x5C, 0x99, 0x14, 0xFB, 0x92, 0x81, 0xA1, 0xC7, 0xE2, 0x84, 0xD7,
- 0x3E, 0x67, 0xF1, 0x80, 0x9A, 0x48, 0xA4, 0x97, 0x20, 0x0E, 0x04,
- 0x6D, 0x39, 0xCC, 0xC7, 0x11, 0x2C, 0xD0 } };
-
-/*
- * Checkup routine
- */
-int sha2_self_test (void)
-{
- //int verbose = 0;
- int i, j, k;
- unsigned char buf[1000];
- unsigned char sha2sum[32];
- sha2_context ctx;
-
- memset (buf, 'a', 1000);
-
- for (i = 0; i < 6; i++)
- {
- j = i % 3;
- k = i < 3;
-
- sha2_starts ( &ctx, k );
- if (j < 2)
- sha2_update ( &ctx, (unsigned char *)sha2_test_str[j],
- strlen (sha2_test_str[j]) );
- else
- {
- for (j = 0; j < 1000; j++)
- sha2_update ( &ctx, buf, 1000);
- }
- sha2_finish ( &ctx, sha2sum );
- if (memcmp (sha2sum, sha2_test_sum[i], 32 - k * 4) != 0)
- {
- return ( 1 );
- }
- }
- return ( 0 );
-}
-
-int sha2_self_test_wikipedia (void)
-// these test vector were found on wikipedia
-{
- unsigned int i;
- int j, errcount = 0;
- unsigned char output[SHA256_OUTPUT_SIZE];
- unsigned char samples[3][44] = { {
- "The quick brown fox jumps over the lazy dog" }, {
- "The quick brown fox jumps over the lazy cog" }, { "" } };
- unsigned char samplesres[3][SHA256_OUTPUT_SIZE] = { { 0xd7, 0xa8, 0xfb,
- 0xb3, 0x07, 0xd7, 0x80, 0x94, 0x69, 0xca, 0x9a, 0xbc, 0xb0, 0x08,
- 0x2e, 0x4f, 0x8d, 0x56, 0x51, 0xe4, 0x6d, 0x3c, 0xdb, 0x76, 0x2d,
- 0x02, 0xd0, 0xbf, 0x37, 0xc9, 0xe5, 0x92 }, { 0xe4, 0xc4, 0xd8,
- 0xf3, 0xbf, 0x76, 0xb6, 0x92, 0xde, 0x79, 0x1a, 0x17, 0x3e, 0x05,
- 0x32, 0x11, 0x50, 0xf7, 0xa3, 0x45, 0xb4, 0x64, 0x84, 0xfe, 0x42,
- 0x7f, 0x6a, 0xcc, 0x7e, 0xcc, 0x81, 0xbe }, { 0xe3, 0xb0, 0xc4,
- 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f,
- 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4,
- 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 } };
-
- for (i=0; i<COUNT (samples) ; i++)
- {
- if (i!=2)
- sha2 (samples[i], 43, output, 0);
- else
- sha2 (samples[i], 0, output, 0);
- for (j=0; j<32; j++)
- {
- if (output[j] != samplesres[i][j])
- errcount++;
- }
- }
- return (errcount);
-}
-
-/*
- * Test of secu_check_password_validity
- */
-struct pwd_test_t
-{
- pwd_type_t pwd_type;
- unsigned char password[MAX_PWD_SIZE + 1];
- unsigned int exp_result;
-};
-
-int secu_check_password_validity_test (void)
-{
- struct pwd_test_t pwd_test[]=
- {
- { 0x32, "abcd efgh ijkl mnop", Failure }, // type de mot de passe incorrect
- { PWD_DPW, "abcd efgh ijkl m", Success }, // le plus petit mot de passe DPW
- { PWD_NPW, "abcd efg", Success }, // le plus petit mot de passe NPW
- { PWD_DPW, "abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd abcd", Success }, // le plus grand mot de passe
- { PWD_DPW, "abcd efgh ijkl ", PWD_WrongSize }, // mot de passe DPW trop petit
- { PWD_NPW, "abcd ef", PWD_WrongSize }, // mot de passe NPW trop petit
- { PWD_DPW, "abcd efgh ijkl m\x1F", PWD_ForbidenChar }, // mot de passe avec caractère incorrect
- { PWD_DPW, "abcd efgh ijkl m\x80", PWD_ForbidenChar } // mot de passe avec caractère incorrect
- };
- unsigned int i;
- for (i=0 ; i<COUNT (pwd_test) ; i++)
- {
- if (secu_check_password_validity (pwd_test[i].pwd_type, pwd_test[i].password)
- != pwd_test[i].exp_result)
- return Failure;
- }
- return 0;
-}
-
-/*
- * Test secu_pbkdf1
- */
-struct pbkdf1_test_t
-{
- u8 password[MAX_PWD_SIZE + 1];
- u8 salt[SALT_SIZE];
- int it_count;
- u8 exp_output_key[OUTPUT_KEY_SIZE];
-};
-
-int
-secu_pbkdf1_test (void)
-{
- unsigned int i;
- u8 output_key[OUTPUT_KEY_SIZE];
- struct pbkdf1_test_t pbkdf1_test[]=
- {
- { "hello world how are you?",
- { 0x58, 0x56, 0x52, 0xf6, 0x9c, 0x04, 0xb5, 0x72 },
- 999,
- { 0x84, 0x33, 0x45, 0x96, 0xab, 0xe5, 0x1e, 0x60, 0x7e, 0x63, 0x8f, 0x4b, 0x2d, 0x8c, 0x51, 0x68 }
- } //
- };
- for(i=0 ; i<COUNT(pbkdf1_test) ; i++)
- {
- secu_pbkdf1(pbkdf1_test[i].password, pbkdf1_test[i].salt, pbkdf1_test[i].it_count, output_key);
- if(memcmp( output_key, pbkdf1_test[i].exp_output_key, OUTPUT_KEY_SIZE)) return Failure;
- }
- return 0;
-}
-
-/*
- * Test des fonctions AES
- */
-
-/*
- * AES-ECB test vectors (source: NIST, rijndael-vals.zip)
- */
-
-/*
- * Checkup routine
- */
-int aes_self_test (void)
-{
- //int verbose = 0;
- int i, j, u, v;
- aes_context ctx;
- unsigned char buf[32];
-
- uint8 aes_enc_test[3][16] = { { 0xC3, 0x4C, 0x05, 0x2C, 0xC0, 0xDA, 0x8D,
- 0x73, 0x45, 0x1A, 0xFE, 0x5F, 0x03, 0xBE, 0x29, 0x7F }, { 0xF3,
- 0xF6, 0x75, 0x2A, 0xE8, 0xD7, 0x83, 0x11, 0x38, 0xF0, 0x41, 0x56,
- 0x06, 0x31, 0xB1, 0x14 }, { 0x8B, 0x79, 0xEE, 0xCC, 0x93, 0xA0,
- 0xEE, 0x5D, 0xFF, 0x30, 0xB4, 0xEA, 0x21, 0x63, 0x6D, 0xA4 } };
-
- uint8 aes_dec_test[3][16] = { { 0x44, 0x41, 0x6A, 0xC2, 0xD1, 0xF5, 0x3C,
- 0x58, 0x33, 0x03, 0x91, 0x7E, 0x6B, 0xE9, 0xEB, 0xE0 }, { 0x48,
- 0xE3, 0x1E, 0x9E, 0x25, 0x67, 0x18, 0xF2, 0x92, 0x29, 0x31, 0x9C,
- 0x19, 0xF1, 0x5B, 0xA4 }, { 0x05, 0x8C, 0xCF, 0xFD, 0xBB, 0xCB,
- 0x38, 0x2D, 0x1F, 0x6F, 0x56, 0x58, 0x5D, 0x8A, 0x4A, 0xDE } };
-
- for (i = 0; i < 6; i++)
- {
- u = i >> 1;
- v = i & 1;
-
- memset (buf, 0, 32);
- aes_set_key ( &ctx, buf, 128 + u * 64);
- for (j = 0; j < 10000; j++)
- {
- if (v == 0)
- aes_encrypt ( &ctx, buf, buf );
- if (v == 1)
- aes_decrypt ( &ctx, buf, buf );
- }
- if ( (v == 0&& memcmp (buf, aes_enc_test[u], 16) != 0) ||(v == 1
- && memcmp (buf, aes_dec_test[u], 16) != 0))
- {
- return ( 1 );
- }
- }
- return ( 0 );
-}
-/*
- * test of aes function, with test vectors provided by NIS
- */
-#define AES_TEXT_SIZE 112
-struct T_aes_test
-{
- unsigned char Key[AES_KEY_SIZE];
- unsigned char IV[16];
- unsigned char PlainText[AES_TEXT_SIZE];
- int len;
- unsigned char CypherText[AES_TEXT_SIZE];
-};
-
-int aes_avs_test (void)
-{
- aes_context ctx;
- unsigned char AESOutput[AES_TEXT_SIZE];
- unsigned char tmp[AES_TEXT_SIZE];
- unsigned int i;
- struct T_aes_test aes_test[]=
- {
- { // élément de test http://www.faqs.org/rfcs/rfc3602.html case #1
- { 0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b, 0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06 },
- { 0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30, 0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41 },
- { "Single block msg" },
- 16,
- {0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8, 0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a }
- },
- { // élément de test http://www.faqs.org/rfcs/rfc3602.html case #4
- { 0x56, 0xe4, 0x7a, 0x38, 0xc5, 0x59, 0x89, 0x74, 0xbc, 0x46, 0x90, 0x3d, 0xba, 0x29, 0x03, 0x49 },
- { 0x8c, 0xe8, 0x2e, 0xef, 0xbe, 0xa0, 0xda, 0x3c, 0x44, 0x69, 0x9e, 0xd7, 0xdb, 0x51, 0xb7, 0xd9 },
- { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
- 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf },
- 64,
- { 0xc3, 0x0e, 0x32, 0xff, 0xed, 0xc0, 0x77, 0x4e, 0x6a, 0xff, 0x6a, 0xf0, 0x86, 0x9f, 0x71, 0xaa,
- 0x0f, 0x3a, 0xf0, 0x7a, 0x9a, 0x31, 0xa9, 0xc6, 0x84, 0xdb, 0x20, 0x7e, 0xb0, 0xef, 0x8e, 0x4e,
- 0x35, 0x90, 0x7a, 0xa6, 0x32, 0xc3, 0xff, 0xdf, 0x86, 0x8b, 0xb7, 0xb2, 0x9d, 0x3d, 0x46, 0xad,
- 0x83, 0xce, 0x9f, 0x9a, 0x10, 0x2e, 0xe9, 0x9d, 0x49, 0xa5, 0x3e, 0x87, 0xf4, 0xc3, 0xda, 0x55 }
- }
-
- };
- // teste une valeur de clé incorrecte
- aes_set_key ( &ctx, aes_test[0].Key, 1);
-
- // vérifie le fonctionnement de l'encryptage/décryptage AES
- // sans le mode CBC
- aes_set_key ( &ctx, aes_test[0].Key, AES_KEY_SIZE*8);
- aes_encrypt ( &ctx, aes_test[0].PlainText, AESOutput);
- memset(tmp, 0, sizeof(tmp));
- aes_decrypt ( &ctx, AESOutput, tmp);
- if (memcmp (tmp, aes_test[0].PlainText, aes_test[0].len) != 0)
- {
- return 1;
- }
-
- // test du mode CBC
- for (i=0; i<COUNT (aes_test) ; i++)
- {
- aes_set_key ( &ctx, aes_test[i].Key, AES_KEY_SIZE*8);
- memcpy(tmp, aes_test[i].IV, sizeof(aes_test[i].IV));
- aes_cbc_encrypt (&ctx, tmp, aes_test[i].PlainText, AESOutput, aes_test[i].len);
- if (memcmp (aes_test[i].CypherText, AESOutput, aes_test[i].len) != 0)
- {
- return 3;
- }
-
- aes_set_key ( &ctx, aes_test[i].Key, AES_KEY_SIZE*8);
- memset(tmp, 0, sizeof(tmp));
- aes_cbc_decrypt (&ctx, aes_test[i].IV, aes_test[i].CypherText, tmp, aes_test[i].len);
- if (memcmp (aes_test[i].PlainText, tmp, aes_test[i].len) != 0)
- {
- return 4;
- }
- }
- return 0;
-}
-
-/*
- * test de void SECU_Init(T_SEC *p_sec)
- */
-int secu_init_test (void)
-{
- sec_t sec;
-
- secu_init (&sec);
-
- return 0;
-}
-/*
- * test de E_SecuErrCode SECU_Hash(E_PWDType PWDType, u8 in[], u8 out[])
- */
-int secu_hash_test (void)
-{
- u8 out[AES_KEY_SIZE];
- u8 pwd[] = "Hello world! what's up ?";
- return secu_hash (PWD_DPW, pwd , out);
-}
-
-/*
- * test de E_SecuErrCode SECU_GenAESKey(u8 Key[])
- */
-int secu_gen_aes_key_test (void)
-{
- u8 key[AES_KEY_SIZE];
- E_ErrCode r;
- unsigned int i;
- u8 ExpRes[] = { 0x18, 0x72, 0xce, 0x0, 0x56, 0xcb, 0xf2, 0xdf, 0x33,
- 0x5a, 0x6, 0x9c, 0x6b, 0x41, 0x2d, 0x26 };
-
- r = secu_gen_aes_key (key);
- if (r != 0)
- return r;
- for (i=0; i<COUNT (ExpRes) ; i++)
- if (key[i] != ExpRes[i])
- return Failure;
- return 0;
-}
-
-/*
- * test de E_SecuErrCode SECU_GenNonce(T_SEC *p_sec)
- */
-int secu_gen_nonce_test (void)
-{
- tei_t tei = 1;
- sec_t sec;
- protocol_run_t p_run;
-
- secu_init (&sec);
- secu_gen_nonce (tei);
- p_run.pid = 0;
- p_run.nonce = 0xce7218; // résultat obtenu avec la clé par défaut de SECU_GenAESKey()
- if (secu_check_protocol_run_param(tei, p_run) != NONCE_INCORRECT)
- return 0;
- else
- return 1;
-}
-
-/*
- * test des protocol-run
- */
-int secu_protocol_run_test (void)
-{
- sec_t STA_sec;
- protocol_run_t Msg;
- cp_pid_t PID = PROV_STA_WITH_NMK_U_UKE;
- tei_t tei_cco = 1, tei_sta = 2;
-
- secu_init (&STA_sec);
-
- // cco start a new protocol-run
- secu_start_new_protocol_run (tei_cco, PID, &Msg);
- // check that parameters are correctly set
- if (Msg.pid != PROV_STA_WITH_NMK_U_UKE)
- return 2;
- // le CCO demande les paramètres du pr en cours
- if (secu_gen_protocol_run_param (tei_cco, false, &Msg) != 0)
- return 3;
- // la STA reçoit le premier message du pr
- if (secu_check_protocol_run_param (tei_sta, Msg) != 0)
- return 4;
- // la STA génère un nouveau message
- if (secu_gen_protocol_run_param (tei_sta, false, &Msg) != 0)
- return 5;
- // et le renvoie au CCO
- if (secu_check_protocol_run_param (tei_cco, Msg) != 0)
- return 6;
- // le CCO refait un message
- if (secu_gen_protocol_run_param (tei_cco, false, &Msg) != 0)
- return 7;
- // et le renvoie à la STA
- if (secu_check_protocol_run_param (tei_sta, Msg) != 0)
- return 8;
- // la STA génère le dernier message du protocol run
- if (secu_gen_protocol_run_param (tei_sta, true, &Msg) != 0)
- return 9;
- // et le renvoie au CCO
- if (secu_check_protocol_run_param (tei_cco, Msg) != 0)
- return 10;
- // le CCO ne peut plus renvoyer de messages
- if (secu_gen_protocol_run_param (tei_cco, false, &Msg)
- != PRN_NotInitialised)
- return 11;
-
- return 0;
-}
-
-struct T_SecuTest
-{
- int(*func) (void);
- char FuncName[30];
-};
-
-int secu_test (void)
-{
- bool verbose = false;
- unsigned int i;
- int res, return_value = 0;
- struct T_SecuTest SecuTest[]=
- {
- { sha2_self_test, "sha2 (1)" },
- { sha2_self_test_wikipedia, "sha2 (2)" },
- { secu_check_password_validity_test, "check_password_validity" },
- { secu_pbkdf1_test, "pbkdf1" },
- { aes_self_test, "aes (1)" },
- { aes_avs_test, "aes (2)" },
- { secu_init_test, "secu_init" },
- { secu_hash_test, "secu_hash" },
- { secu_gen_aes_key_test, "secu_gen_aes_key" },
- { secu_gen_nonce_test, "secu_gen_nonce" },
- { secu_protocol_run_test, "secu_protocol_run" }
- };
-
- printf ("test du module secu\n");
- for (i=0; i<COUNT (SecuTest) ; i++)
- {
- res = SecuTest[i].func ();
- if(verbose || (res != 0))
- {
- printf (" %-50s", SecuTest[i].FuncName);
- if (res == 0) printf ("OK\n");
- else printf ("FAILED : %i\n", res);
- }
- if(res != 0) return_value++;
- }
- if (i != COUNT(SecuTest)) return 1;
- return return_value;
-}
diff --git a/cp/beacon/test/overide/test/src/test_station.c b/cp/beacon/test/overide/test/src/test_station.c
deleted file mode 100644
index 17926a97a3..0000000000
--- a/cp/beacon/test/overide/test/src/test_station.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2007 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp/test/test_station.c
- * \brief unit tests for station module
- * \ingroup cp_test
- */
-
-#include "common/std.h"
-#include "cp/test/inc/test_station.h"
-#include "mac/pbproc/pbproc.h"
-#include "hal/phy/phy.h"
-
-
-#define STA_THREAD_PRIORITY 30
-
-
-static unsigned char station_thread_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
-static cyg_handle_t station_thread_handle;
-static cyg_thread station_thread;
-static sec_t sec_m;
-
-
-/*
- * void station_gen_timed_event(cyg_flag_t *cyg_flag, station_flag_t station_flag, uint event_delay_ms)
- */
-int station_gen_timed_event_test(void)
-{
- // we create a local event for the test
- cyg_flag_t local_flag;
- cyg_flag_value_t flag_value = 4, flag_return = 0;
- cyg_tick_count_t cyg_tick_count, cur_time, event_wait_tick;
- uint event_wait_ms = 200;
-
- event_wait_tick = interf_ms_to_cyg_tick(event_wait_ms);
- // init the local event
- cyg_flag_init(&local_flag);
- // generate the timed event
- cp_station_gen_timed_event(&local_flag, flag_value>>1, 0, event_wait_ms/2);
- cp_station_gen_timed_event(&local_flag, flag_value, 0, event_wait_ms);
- cp_station_gen_timed_event(&local_flag, flag_value<<1, 0, event_wait_ms/2);
- // and now wait for the event...
- cur_time = cyg_current_time();
- //printf("cur_time = %i\n", cur_time);
- cyg_flag_timed_wait (&local_flag, flag_value, CYG_FLAG_WAITMODE_OR, event_wait_ms*2);
- if(cyg_current_time() != (cur_time + event_wait_tick) ) return 1;
- //cur_time = cyg_current_time();
- //printf("cur_time 2 = %i\n", cur_time);
- // test if we can delete an event
- // delete the previous events
- cp_station_stop_timed_event(&local_flag, flag_value>>1);
- cp_station_stop_timed_event(&local_flag, flag_value);
- cp_station_stop_timed_event(&local_flag, flag_value<<1);
- // generated another timed event
- cp_station_gen_timed_event(&local_flag, flag_value, 0, event_wait_ms);
- // and another one which arrive later
- cp_station_gen_timed_event(&local_flag, flag_value>>1, 0, 2*event_wait_ms);
- // delete the first one
- cp_station_stop_timed_event(&local_flag, flag_value);
- // wait for it...
- cyg_tick_count = cyg_current_time();
- cyg_tick_count += (event_wait_ms * 3);
- //printf("wait at %i\n", (int)cyg_current_time());
- flag_return = cyg_flag_timed_wait(&local_flag, 0xFFFFFFFF, CYG_FLAG_WAITMODE_OR, cyg_tick_count);
- //printf("got event %i at %i\n", (int)flag_return, cyg_current_time());
- // if we had an event, it's a failure
- if(flag_return != (flag_value>>1)) return 2;
- //
- // check if we can re-arm the timer
- //
- // delete any previous timer
- // delete the previous events
- cp_station_stop_timed_event(&local_flag, flag_value>>1);
- cp_station_stop_timed_event(&local_flag, flag_value);
- cp_station_stop_timed_event(&local_flag, flag_value<<1);
- // set a first timer in 200 ms
- cur_time = cyg_current_time();
- //printf("cur_time1 = %i\n",cur_time);
- cp_station_gen_timed_event(&local_flag, flag_value, 0, 200);
- // wait 100 ms
- cyg_thread_delay (interf_ms_to_cyg_tick (100));
- // re-set the timer in 200 ms
- // note that we should kill the first timer and reset it.
- cp_station_stop_timed_event(&local_flag, flag_value);
- cp_station_gen_timed_event(&local_flag, flag_value, 0, 200);
- // wait for the timer to expires
- cyg_tick_count = cyg_current_time();
- cyg_tick_count += (600);
- flag_return = cyg_flag_timed_wait(&local_flag, 0xFFFFFFFF, CYG_FLAG_WAITMODE_OR, cyg_tick_count);
- if(flag_return != (flag_value)) return 3;
- // here, we should have wait at least event_wait_ms + event_wait_ms/2
- if(cur_time + (event_wait_ms + event_wait_ms/2)/10 != cyg_current_time()) return 4;
- //cur_time = cyg_current_time();
- //printf("cyg_current2 = %i\n", cur_time);
-
-// cyg_thread_delay (interf_ms_to_cyg_tick (1000));
- return 0;
-}
-
-
-/*
- * test de l'envoie d'un message unassociated_sta et de sa reception...
- */
-int station_unassociated_sta_test(void)
-{
- msg_mme_t *msg;
- cm_unassociated_sta_t *cm_unassociated_sta;
-
- msg = interf_give_buf();
- msg->mm_type = CM_UNASSOCIATED_STA_IND;
- msg->osa[3] = 3;
- cm_unassociated_sta = (cm_unassociated_sta_t *) msg->mm_entry;
- cm_unassociated_sta->cco_capability = 0;
- cm_unassociated_sta->nid = 0;
-
- interf_receive(0, 0, (u8 *)msg, 0, 0);
- cyg_thread_delay (interf_ms_to_cyg_tick (100));
- return 0;
-}
-
-/*
- * test du event handler
- */
-int station_event_handler_test(void)
-{
- event_t event;
- int i;
-
- // test init function
- cp_station_initialize_handler();
- // test add and get function
- if(cp_station_get_event(&event) != EV_QUEUE_EMPTY) return 1;
- if(cp_station_add_event(0, NULL) != EV_OK) return 2;
- if(cp_station_get_event(&event) != EV_OK) return 3;
- if(cp_station_get_event(&event) != EV_QUEUE_EMPTY) return 4;
- // try to fill the queue
- for(i = 0 ; i < 2*INTERF_NB_BUFFER/3 ; i++)
- if(cp_station_add_event(0, NULL) != EV_OK) return 5;
- for(i = 0 ; i < INTERF_NB_BUFFER/3 ; i++)
- if(cp_station_get_event(&event) != EV_OK) return 6;
- for(i = 0 ; i < 2*INTERF_NB_BUFFER/3+1 ; i++)
- if(cp_station_add_event(0, NULL) != EV_OK) return 7;
- for(i = 0 ; i < INTERF_NB_BUFFER+1 ; i++)
- if(cp_station_get_event(&event) != EV_OK) return 8;
- if(cp_station_get_event(&event) != EV_QUEUE_EMPTY) return 9;
-
- return 0;
-}
-
-/*
- * test de cp_station_process_usta
- */
-int station_process_usta_test(void)
-{
- mac_address_t mac_address;
- u8 cco_capa;
- nid_t nid;
- process_usta_result_t process_usta_result;
-
- // init the test vectors
- bzero(mac_address, sizeof(mac_address_t));
- cco_capa = 0;
- nid = 0;
- // init the station with it default parameters
- cp_station_data_init(NULL, NULL, NULL);
- // first, test with a different nid
- nid = 3;
- process_usta_result = cp_station_process_usta(mac_address, cco_capa, nid);
- if(process_usta_result != CHECK_EXISTING_OTHER_AVLN) return 1;
- // test with same nid and same cco_capability, but higher mac adress
- mac_address[3] = 5;
- cco_capa = 0;
- nid = 0;
- process_usta_result = cp_station_process_usta(mac_address, cco_capa, nid);
- if(process_usta_result != USTA_MATCHING_NID) return 2;
- // now, test the recording functions
- bzero(mac_address, sizeof(mac_address_t));
- cco_capa = 0;
- nid = 3;
- cp_station_add_usta(mac_address, cco_capa, nid);
- process_usta_result = cp_station_process_recorded_usta();
- if(process_usta_result != CHECK_EXISTING_OTHER_AVLN) return 3;
- mac_address[3] = 5;
- cco_capa = 0;
- nid = 0;
- cp_station_add_usta(mac_address, cco_capa, nid);
- process_usta_result = cp_station_process_recorded_usta();
- if(process_usta_result != USTA_MATCHING_NID) return 4;
-
- return 0;
-}
-
-/*
- * test sur les stations associées
- */
-int associated_sta_test(void)
-{
- station_t sta;
- tei_t tei;
- char s[] = "GHIJKL";
-
- // init the station with it default parameters
- cp_station_data_init(NULL, NULL, NULL);
- // test retreiving a sta
- tei = cp_station_get_associate_info(&sta, true, 0);
- if(tei != 0) return 1;
- // add a new created station
- sta.cco_capa = true;
- memcpy(sta.mac_address, "ABCEDF", sizeof(mac_address_t));
- sta.proxy_net_capa = 0;
- sta.station_status = STATION_UNASSOCIATED;
- tei = cp_station_associate_new(sta);
- if(tei != 1) return 2;
- // add a new created station
- sta.cco_capa = true;
- memcpy(sta.mac_address, "GHIJKL", sizeof(mac_address_t));
- sta.proxy_net_capa = 0;
- sta.station_status = STATION_UNASSOCIATED;
- tei = cp_station_associate_new(sta);
- if(tei != 2) return 3;
- // try to retreive the first station added
- tei = cp_station_get_associate_info(&sta, true, 0);
- if(tei != 2) return 4;
- memcpy(s, "ABCEDF", sizeof(mac_address_t));
- if(memcmp(sta.mac_address, s, 6)) return 5;
- // try to retreive the second station added
- tei = cp_station_get_associate_info(&sta, false, tei);
- if(tei != 0) return 6;
- memcpy(s, "GHIJKL", sizeof(mac_address_t));
- if( memcmp(sta.mac_address, s, 6)) return 7;
-
- // test tei renewal
- memcpy(sta.mac_address, "GHIJKL", sizeof(mac_address_t));
- if(cp_station_renew(sta) != 2) return 8;
-
-
- return 0;
-}
-
-int
-process_cc_assoc_req_test(void)
-{
- station_t sta;
- tei_t tei;
- msg_mme_t *msg;
- cc_assoc_req_t *cc_assoc_req;
- msg_param_t msg_param;
- u8 buf[1518];
-
- // init the station with it default parameters
- cp_station_data_init(NULL, NULL, NULL);
- // associate 2 sta for test purpose
- sta.cco_capa = true;
- memcpy(sta.mac_address, "ABCEDF", sizeof(mac_address_t));
- sta.proxy_net_capa = 0;
- sta.station_status = STATION_UNASSOCIATED;
- tei = cp_station_associate_new(sta);
- if(tei != 1) return 1;
- // add a new created station
- sta.cco_capa = true;
- memcpy(sta.mac_address, "GHIJKL", sizeof(mac_address_t));
- sta.proxy_net_capa = 0;
- sta.station_status = STATION_UNASSOCIATED;
- tei = cp_station_associate_new(sta);
- if(tei != 2) return 2;
- // simulate the reception of a cc_assoc_req
- // 1) construct the message
- msg = msg_sending_common_part((msg_mme_t *)buf, "IJKLMN", &msg_param);
- msg->mm_type = CC_ASSOC_REQ;
- memcpy(&msg->osa, "HELLO!", 6);
- // set the message values ( 11.2.28 )
- cc_assoc_req = (cc_assoc_req_t *) & msg->mm_entry;
- cc_assoc_req->cco_capability = cp_station_get_cco_capa();
- cc_assoc_req->nid = cp_station_get_nid();
- cc_assoc_req->proxy_networking_capability = 0;
- cc_assoc_req->req_type = 0;
- // 2) simulate it reception
- process_cc_assoc_req(msg);
-
- return 0;
-}
-
-/*
- * running the thread used for testing
- */
-int station_run_testing_thread(void)
-{
- /*
- int_station_t int_sta_global;
- phy_t *phy_ctx;
- ca_t *ca_ctx;
-
- // do the station init procedure
- int_sta_global.mac_store = mac_store_init ();
-
- int_sta_global.mac_config = blk_alloc ();
- int_sta_global.mac_config->rts_broadcast = false;
- int_sta_global.mac_config->fc_symbols_nb = 1;
- int_sta_global.mac_config->ntb_offset_tck = 0;
- tonemask_default ((u8*) &int_sta_global.mac_config->tonemask_info);
- tonemask_update (&int_sta_global.mac_config->tonemask_info);
-
-// int_sta_global.pbproc = pbproc_init (int_sta_global.mac_config, int_sta_global.mac_store);
-
-
-// int_sta_global.sar = sar_init (int_sta_global.mac_store,
-// int_sta_global.pbproc, pbproc_get_ca (int_sta_global.pbproc));
-
-// int_sta_global.cl
-// = cl_init (int_sta_global.mac_store, int_sta_global.sar);
-
-// phy_ctx = phy_init (NULL, NULL, NULL, NULL, NULL, NULL, NULL);
-// ca_ctx = ca_init (phy_ctx, int_sta_global.mac_config, int_sta_global.mac_store);
-
-
- // do the CP init procedure
- interf_init ();
- msg_init();
- secu_init(&sec_m);
- cp_station_init(int_sta_global.mac_store, int_sta_global.cl, int_sta_global.pbproc, NULL);
- beacon_init();
-
- cyg_thread_resume(station_thread_handle);
- // wait for the thread to start and init
- cyg_thread_delay(10);
-
- */
- return 0;
-}
-
-struct station_test_t
-{
- int(*func) (void);
- char func_name[30];
-};
-
-
-int station_test (void)
-{
- bool verbose = 1;
- unsigned int i;
- int res, return_value = 0;
- struct station_test_t my_test[]=
- {
- {station_event_handler_test, "station_event_handler"},
- {station_process_usta_test, "station_process_usta"},
- {associated_sta_test, "associated_sta"},
- { process_cc_assoc_req_test, "process_cc_assoc_req"},
-
- {station_run_testing_thread, "sta thread launched"},
- // from now, it is possible to test function that request the thread
- // {station_gen_timed_event_test, "station_gen_timed_event"},
- //{station_unassociated_sta_test, "station_unassociated_sta"}
- };
-
- printf ("test du module station\n");
-
- // for the test, we create a thread STA
- cyg_thread_create(
- STA_THREAD_PRIORITY,
- &cp_station_wait_event,
- 0,
- "STA",
- station_thread_stack,
- sizeof(station_thread_stack),
- &station_thread_handle,
- &station_thread
- );
- // and now do the unit tests
- for (i=0 ; i<COUNT (my_test) ; i++)
- {
- res = my_test[i].func ();
- if(verbose || (res != 0))
- {
- printf (" %-50s", my_test[i].func_name);
- if (res == 0) printf ("OK\n");
- else printf ("FAILED : %i\n", res);
- }
- if(res != 0) return_value++;
- }
- // end of the test, we destroy the STA thread
- cyg_thread_delay(2000);
- cyg_thread_kill(station_thread_handle);
-
- if (i != COUNT(my_test)) return 1;
- return return_value;
-}
-