summaryrefslogtreecommitdiff
path: root/cesar/cp2/msg
diff options
context:
space:
mode:
authorlaranjeiro2008-06-26 13:31:57 +0000
committerlaranjeiro2008-06-26 13:31:57 +0000
commitaa74a95125bc8b76b33c695ba28ff5bd095e96a6 (patch)
treed7da3f4b5c4748a4e65e95691724beab3ef12318 /cesar/cp2/msg
parentdd785241d5ee7bed275469a270980870d07c450c (diff)
cp2/msg : Replace the station manager stub by the real station manager for MME tests.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2449 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/msg')
-rw-r--r--cesar/cp2/msg/Module2
-rw-r--r--cesar/cp2/msg/test/Makefile8
-rw-r--r--cesar/cp2/msg/test/overide/cp2/inc/context.h11
-rw-r--r--cesar/cp2/msg/test/overide/cp2/sta/core/core.h18
-rw-r--r--cesar/cp2/msg/test/src/cl_stub.c118
-rw-r--r--cesar/cp2/msg/test/src/test-msg.c19
6 files changed, 169 insertions, 7 deletions
diff --git a/cesar/cp2/msg/Module b/cesar/cp2/msg/Module
index 9bf31e7f0f..260322723c 100644
--- a/cesar/cp2/msg/Module
+++ b/cesar/cp2/msg/Module
@@ -1 +1 @@
-SOURCES := msg.c mme.c
+SOURCES := msg.c mme.c msg_cc.c
diff --git a/cesar/cp2/msg/test/Makefile b/cesar/cp2/msg/test/Makefile
index a988bcc43f..f4f4f1e32f 100644
--- a/cesar/cp2/msg/test/Makefile
+++ b/cesar/cp2/msg/test/Makefile
@@ -5,11 +5,11 @@ INCLUDES = cp2/msg/test/overide/
HOST_PROGRAMS = test-msg-read-header test-msg
test-msg-read-header_SOURCES = test-msg-read-header.c interface_stub.c \
- cp_cl_interface_stub.c sta_mgr_stub.c
-test-msg-read-header_MODULES = lib cp2/msg cp2/secu
+ cp_cl_interface_stub.c cl_stub.c
+test-msg-read-header_MODULES = lib cp2/msg cp2/secu cp2/sta/mgr
test-msg_SOURCES = test-msg.c interface_stub.c cp_cl_interface_stub.c \
- sta_mgr_stub.c
-test-msg_MODULES = lib cp2/msg cp2/secu
+ cl_stub.c
+test-msg_MODULES = lib cp2/msg cp2/secu cp2/sta/mgr
include $(BASE)/common/make/top.mk
diff --git a/cesar/cp2/msg/test/overide/cp2/inc/context.h b/cesar/cp2/msg/test/overide/cp2/inc/context.h
index 8eec030349..526c7efd34 100644
--- a/cesar/cp2/msg/test/overide/cp2/inc/context.h
+++ b/cesar/cp2/msg/test/overide/cp2/inc/context.h
@@ -19,6 +19,11 @@
#include "cp2/msg/inc/context.h"
#include "cl/cl.h"
+#include "cp2/sta/mgr/sta_mgr.h"
+#include "cp2/sta/mgr/inc/sta_mgr.h"
+
+#include "mac/common/config.h"
+
struct cp_t
{
/** MSG context. */
@@ -27,11 +32,17 @@ struct cp_t
/** Interface context. */
interface_t *interface;
+ /** Station Manager. */
+ cp_sta_mgr_t sta_mgr;
+
/** Convergence layer context. */
cl_t *cl;
/** Random generator. */
lib_rnd_t rnd;
+
+ /** Mac config. */
+ mac_config_t *mac_config;
};
#endif /* overide_cp2_inc_context_h */
diff --git a/cesar/cp2/msg/test/overide/cp2/sta/core/core.h b/cesar/cp2/msg/test/overide/cp2/sta/core/core.h
new file mode 100644
index 0000000000..e1448e37e8
--- /dev/null
+++ b/cesar/cp2/msg/test/overide/cp2/sta/core/core.h
@@ -0,0 +1,18 @@
+#ifndef overide_cp2_sta_core_core_h
+#define overide_cp2_sta_core_core_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cp2/sta/core/core.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#endif /* overide_cp2_sta_core_core_h */
diff --git a/cesar/cp2/msg/test/src/cl_stub.c b/cesar/cp2/msg/test/src/cl_stub.c
new file mode 100644
index 0000000000..6c24a2ba02
--- /dev/null
+++ b/cesar/cp2/msg/test/src/cl_stub.c
@@ -0,0 +1,118 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cl/cl_mactotei.h
+ * \brief mac to tei table interface between the CL and the CP
+ * \ingroup cl
+ *
+ */
+#include "common/std.h"
+#include "cl/cl_mactotei.h"
+
+#include "lib/bitstream.h"
+
+/**
+ * Create a new table to be filled by the CP.
+ *
+ * \return a pointer to the new block to be fill with the mac to tei table
+ * data
+ */
+cl_mactotei_blk_t *
+cl_mactotei_new (void)
+{
+ u8 *my_data;
+
+ my_data = blk_alloc ();
+ my_data[0] = 0;
+ return (cl_mactotei_blk_t *) my_data;
+}
+
+/**
+ * Add a new tupple of data to the table.
+ *
+ * \param table the table pointer to add a new mac to tei correspondance.
+ * \param mac_addr the mac addr to add
+ * \param tei the tei corresponding to the STA.
+ * \param tag the CP tag provide to indentifier a network.
+ */
+void cl_mactotei_addr_add (cl_mactotei_blk_t *table, mac_t mac_addr,
+ uint tei, uint tag)
+{
+ bitstream_t bitstream;
+ u8 *data;
+ uint pos;
+
+ dbg_assert (table);
+ dbg_assert (tei);
+
+ data = (u8 *) table;
+ pos = 8 * data[0] + 1;
+
+ bitstream_init (&bitstream, &data[pos],
+ 8, BITSTREAM_WRITE);
+ bitstream_access (&bitstream, &tag, 8);
+ bitstream_access (&bitstream, &tei, 8);
+ bitstream_access (&bitstream, &mac_addr, 48);
+ bitstream_finalise (&bitstream);
+
+ data[0] ++;
+}
+
+/**
+ * Request the CL to copy all the data corresponding to the tag.
+ *
+ * \param ctx the cl context.
+ * \param table the mactotei new table to fill
+ * \param tag the tag to copy
+ */
+void
+cl_mactotei_copy_tag (cl_t *ctx,
+ cl_mactotei_blk_t *table, u8 tag)
+{
+}
+
+/**
+ * Request the CL to copy all the data corresponding to the tag and the tei.
+ *
+ * \param ctx the cl context.
+ * \param table the mactotei new table to fill
+ * \param tei the tei to copy.
+ * \param tag the tag to copy
+ */
+void
+cl_mactotei_copy_tei_and_tag (cl_t *ctx,
+ cl_mactotei_blk_t *table, u8 tei, u8 tag)
+{
+}
+
+/**
+ * Request the CL to use the new table and remove the old one.
+ *
+ * \param ctx the CL context
+ * \param table the new table to use.
+ */
+void
+cl_mactotei_use_table (cl_t *ctx, cl_mactotei_blk_t *table)
+{
+ dbg_assert (ctx);
+ dbg_assert (table);
+
+ bitstream_memcpy ((u8 *) ctx, (u8 *)table, 512) ;
+
+ blk_release (table);
+}
+
+/**
+ * Release the complete table from the memory.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_mactotei_release_table (cl_t *ctx)
+{
+}
+
diff --git a/cesar/cp2/msg/test/src/test-msg.c b/cesar/cp2/msg/test/src/test-msg.c
index 48b7786ae4..bdf237f7f6 100644
--- a/cesar/cp2/msg/test/src/test-msg.c
+++ b/cesar/cp2/msg/test/src/test-msg.c
@@ -73,8 +73,10 @@ test_case_msg_mme_tx_init (test_t test)
bitstream_t bitstream;
u64 data;
cp_sta_own_data_t *sta;
+ mac_config_t mac_config;
cp_msg_init (&cp);
+ cp.mac_config = &mac_config;
sta = cp_sta_mgr_get_sta_own_data (&cp);
cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
@@ -132,9 +134,12 @@ test_case_msg_mme_tx_init_enc (test_t test)
bitstream_t bitstream;
cp_sta_own_data_t *sta;
u64 data;
+ mac_config_t mac_config;
cp_msg_init (&cp);
+ cp.mac_config = &mac_config;
sta = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_tei (sta, 0xA, &cp);
cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
sta->is_cco = false;
sta->pco_status = false;
@@ -246,6 +251,7 @@ test_case_msg_mme_tx_without_vlan_tag (test_t test)
mac_t mac;
bitstream_t bitstream;
cp_key_t key;
+ mac_config_t mac_config;
lib_rnd_init (&cp.rnd, 0x12345678);
peer.mac = 0x23456789ABCDull;
@@ -258,6 +264,7 @@ test_case_msg_mme_tx_without_vlan_tag (test_t test)
uint enc_length;
cp_msg_init (&cp);
+ cp.mac_config = &mac_config;
sta = cp_sta_mgr_get_sta_own_data (&cp);
cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
@@ -401,6 +408,7 @@ test_case_msg_mme_tx_with_vlan_tag (test_t test)
mac_t mac;
bitstream_t bitstream;
cp_key_t key;
+ mac_config_t mac_config;
lib_rnd_init (&cp.rnd, 0x12345678);
peer.mac = 0x23456789ABCDull;
@@ -413,6 +421,7 @@ test_case_msg_mme_tx_with_vlan_tag (test_t test)
uint enc_length;
cp_msg_init (&cp);
+ cp.mac_config = &mac_config;
sta = cp_sta_mgr_get_sta_own_data (&cp);
cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
@@ -561,8 +570,11 @@ test_case_msg_not_enc (test_t test)
bitstream_t bitstream;
u64 data;
u8 *buffer;
+ cp_sta_own_data_t *own;
+ mac_config_t mac_config;
cp_msg_init (&cp);
+ cp.mac_config = &mac_config;
test_case_begin (test, "Send a MME not encrypted");
@@ -571,6 +583,9 @@ test_case_msg_not_enc (test_t test)
peer.tei = 0xA;
peer.all_sta = false;
+ own = cp_sta_mgr_get_sta_own_data (&cp);
+ cp_sta_own_data_set_mac_address (own, 0x123456789ABCull, &cp);
+
mme = cp_msg_mme_init (&cp, &peer, 0xb0);
slab_addref (mme);
buffer = mme->p_mme;
@@ -585,11 +600,11 @@ test_case_msg_not_enc (test_t test)
test_fail_if (mme->peer.all_sta != peer.all_sta, "Wrong STA Flag");
bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != peer.mac, "Wrong destination mac address");
+ test_fail_if (data != peer.mac, "Wrong Destination mac address");
bitstream_access (&bitstream, &data, 48);
test_fail_if (data != 0x123456789ABCull,
- "Wrong destination mac address");
+ "Wrong Source mac address");
bitstream_access (&bitstream, &data, 32);
test_fail_if (data != peer.vlan_tag, "Wrong VLAN TAG");