summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/fsm/src/fsm/cp.fsm2
-rw-r--r--cesar/cp/mme.h3
-rw-r--r--cesar/cp/msg/inc/msg_vs.h41
-rw-r--r--cesar/cp/msg/inc/vs_get_mactotei.h22
-rw-r--r--cesar/cp/msg/src/msg.c2
-rw-r--r--cesar/cp/msg/src/msg_vs.c40
-rw-r--r--cesar/cp/msg/stub/src/msg_vs.c40
-rw-r--r--cesar/cp/msg/test/Makefile5
-rw-r--r--cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c41
-rw-r--r--cesar/cp/msg/test/src/msg_vs.c107
-rw-r--r--cesar/cp/sta/action/src/vs.c29
-rw-r--r--cesar/cp/sta/action/vs.h8
12 files changed, 336 insertions, 4 deletions
diff --git a/cesar/cp/fsm/src/fsm/cp.fsm b/cesar/cp/fsm/src/fsm/cp.fsm
index 5b7a420970..7f75e68573 100644
--- a/cesar/cp/fsm/src/fsm/cp.fsm
+++ b/cesar/cp/fsm/src/fsm/cp.fsm
@@ -132,6 +132,7 @@ Events:
VS_GET_STATS_REQ
VS_GET_CE_STATS_REQ
VS_GET_PB_STATS_REQ
+ VS_GET_MACTOTEI_REQ
IMAC_GET_DISCOVER_LIST_REQ
to_poweron
@@ -395,6 +396,7 @@ STARTED:
VS_GET_STATS_REQ -> . [cp_sta_action_vs__started__vs_get_stats_req]
VS_GET_CE_STATS_REQ -> . [cp_sta_action_vs__started__vs_get_ce_stats_req]
VS_GET_PB_STATS_REQ -> . [cp_sta_action_vs__started__vs_get_pb_stats_req]
+ VS_GET_MACTOTEI_REQ -> . [cp_sta_action_vs__started__vs_get_mactotei_req]
CM_NW_INFO_REQ -> . [cp_sta_action_process_cm_nw_info_req]
sta_status_changed -> . [cp_sta_action_drv__drv_sta_status_ind_send]
CM_NW_STATS_REQ -> . [cp_sta_action_process_cm_nw_stats_req]
diff --git a/cesar/cp/mme.h b/cesar/cp/mme.h
index 4f15c5ab0b..5db831e6f4 100644
--- a/cesar/cp/mme.h
+++ b/cesar/cp/mme.h
@@ -133,6 +133,7 @@
#define VS_GET_STATS 0xA048
#define VS_GET_CE_STATS 0xA074
#define VS_GET_PB_STATS 0xA0D8
+#define VS_GET_MACTOTEI 0xA0DC
#define IMAC_GET_DISCOVER_LIST 0xA800
#define VS_MIN 0xA000
#define VS_MAX (DRV_MIN - 1)
@@ -318,6 +319,8 @@ enum cp_mmtype_t
VS_GET_CE_STATS_CNF = VS_GET_CE_STATS + CP_MME_CNF,
VS_GET_PB_STATS_REQ = VS_GET_PB_STATS + CP_MME_REQ,
VS_GET_PB_STATS_CNF = VS_GET_PB_STATS + CP_MME_CNF,
+ VS_GET_MACTOTEI_REQ = VS_GET_MACTOTEI + CP_MME_REQ,
+ VS_GET_MACTOTEI_CNF = VS_GET_MACTOTEI + CP_MME_CNF,
IMAC_GET_DISCOVER_LIST_REQ = IMAC_GET_DISCOVER_LIST + CP_MME_REQ,
IMAC_GET_DISCOVER_LIST_CNF = IMAC_GET_DISCOVER_LIST + CP_MME_CNF,
};
diff --git a/cesar/cp/msg/inc/msg_vs.h b/cesar/cp/msg/inc/msg_vs.h
index 0ebae22bd6..65a8fc25eb 100644
--- a/cesar/cp/msg/inc/msg_vs.h
+++ b/cesar/cp/msg/inc/msg_vs.h
@@ -22,6 +22,7 @@
#include "cp/msg/inc/imac_get_discover_list.h"
#include "cp/msg/inc/vs_get_snr.h"
#include "cp/msg/inc/vs_get_ce_stats.h"
+#include "cp/msg/inc/vs_get_mactotei.h"
#include "mac/common/tonemap.h"
#include "lib/stats.h"
@@ -277,6 +278,46 @@ void
cp_msg_vs_get_pb_stats_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme);
/**
+ * Receive a VS_GET_MACTOTEI.REQ.
+ * \param ctx the control plane context.
+ * \param mme the MME handle.
+ * \return true on success.
+ */
+bool
+cp_msg_vs_get_mactotei_req_receive (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
+ * Start sending of a VS_GET_MACTOTEI.CNF.
+ * \param ctx the control plane context.
+ * \param peer the peer info.
+ * \param nb_entry Number of entry in the mactotei table.
+ * \return the message context.
+ */
+cp_mme_tx_t *
+cp_msg_vs_get_mactotei_cnf_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
+ uint nb_entry);
+
+/**
+ * Send one entry of mactotei in the VS_GET_MACTOTEI.CNF
+ * \param ctx the control plane context.
+ * \param mme the MME handle.
+ * \param mac mac address found in the mactotei table of one entry.
+ * \param tei tei found in the mactotei table of one entry.
+ * \param tag tag found in the mactotei table of one entry.
+ */
+void
+cp_msg_vs_get_mactotei_cnf_send_entry ( cp_t *ctx, cp_mme_tx_t *mme_tx,
+ mac_t mac, cp_tei_t tei, u8 tag);
+
+/**
+ * Ends sending the VS_GET_MACTOTEI.CNF
+ * \param ctx the ctx module.
+ * \param mme the MME handle.
+ */
+void
+cp_msg_vs_get_mactotei_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme);
+
+/**
* Receive a IMAC_GET_DISCOVER_LIST.REQ.
* \param ctx the control plane context.
* \param mme the MME handle.
diff --git a/cesar/cp/msg/inc/vs_get_mactotei.h b/cesar/cp/msg/inc/vs_get_mactotei.h
new file mode 100644
index 0000000000..ebd7c969a0
--- /dev/null
+++ b/cesar/cp/msg/inc/vs_get_mactotei.h
@@ -0,0 +1,22 @@
+#ifndef cp_msg_inc_vs_get_mactotei_h
+#define cp_msg_inc_vs_get_mactotei_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2011 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cp/msg/inc/vs_get_mactotei.h
+ * \brief VS_GET_MACTOTEI Structures.
+ * \ingroup cp_msg
+ */
+
+/* Dynamic payload size in byte */
+#define VS_GET_MACTOTEI_CNF_ENTRY_SIZE (ETH_MAC_ADDRESS_SIZE + 1 + 1)
+
+/* total size in byte (dynamic payload and static payload) */
+#define VS_GET_MACTOTEI_CNF_SIZE(n) ((n)*VS_GET_MACTOTEI_CNF_ENTRY_SIZE + 2)
+
+#endif /* cp_msg_inc_vs_get_mactotei_h */
diff --git a/cesar/cp/msg/src/msg.c b/cesar/cp/msg/src/msg.c
index 1885397332..5d32afdff5 100644
--- a/cesar/cp/msg/src/msg.c
+++ b/cesar/cp/msg/src/msg.c
@@ -213,6 +213,8 @@ cp_msg_mme_allowed_t cp_msg_mme_allowed[] =
CP_MSG_MME_ALLOWED_ENTRY (VS_GET_CE_STATS_CNF, STA_UNASSOC, NEK_ENC_NO, FROM_H1_NO, NO_EVENT),
CP_MSG_MME_ALLOWED_ENTRY (VS_GET_PB_STATS_REQ, STA_UNASSOC, NEK_ENC_NO, FROM_H1_YES, VS_GET_PB_STATS_REQ),
CP_MSG_MME_ALLOWED_ENTRY (VS_GET_PB_STATS_CNF, STA_UNASSOC, NEK_ENC_NO, FROM_H1_NO, NO_EVENT),
+ CP_MSG_MME_ALLOWED_ENTRY (VS_GET_MACTOTEI_REQ, STA_UNASSOC, NEK_ENC_NO, FROM_H1_YES, VS_GET_MACTOTEI_REQ),
+ CP_MSG_MME_ALLOWED_ENTRY (VS_GET_MACTOTEI_CNF, STA_UNASSOC, NEK_ENC_NO, FROM_H1_NO, NO_EVENT),
CP_MSG_MME_ALLOWED_ENTRY (IMAC_GET_DISCOVER_LIST_REQ, STA_UNASSOC, NEK_ENC_NO, FROM_H1_YES, IMAC_GET_DISCOVER_LIST_REQ),
CP_MSG_MME_ALLOWED_ENTRY (IMAC_GET_DISCOVER_LIST_CNF, STA_UNASSOC, NEK_ENC_NO, FROM_H1_NO, NO_EVENT),
diff --git a/cesar/cp/msg/src/msg_vs.c b/cesar/cp/msg/src/msg_vs.c
index e96d38c606..6b7c280700 100644
--- a/cesar/cp/msg/src/msg_vs.c
+++ b/cesar/cp/msg/src/msg_vs.c
@@ -914,3 +914,43 @@ cp_msg_vs_get_pb_stats_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme)
cp_msg_mme_send (ctx, mme);
}
+
+bool
+cp_msg_vs_get_mactotei_req_receive (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ return cp_msg_mme_read_end_check (ctx, mme);
+}
+
+cp_mme_tx_t *
+cp_msg_vs_get_mactotei_cnf_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
+ uint nb_entry)
+{
+ cp_mme_tx_t* mme;
+ uint size = VS_GET_MACTOTEI_CNF_SIZE(nb_entry);
+
+ mme = cp_msg_mme_init (ctx, peer, VS_GET_MACTOTEI_CNF, size);
+ dbg_assert (mme);
+
+ /* nb_entry */
+ bitstream_write (&mme->bitstream, nb_entry, 16);
+
+ return mme;
+}
+
+void
+cp_msg_vs_get_mactotei_cnf_send_entry (cp_t *ctx, cp_mme_tx_t *mme_tx,
+ mac_t mac, cp_tei_t tei, u8 tag)
+{
+ dbg_assert (mme_tx);
+ bitstream_write_large (
+ &mme_tx->bitstream, mac,
+ BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
+ bitstream_write (&mme_tx->bitstream, tei, 8);
+ bitstream_write (&mme_tx->bitstream, tag, 8);
+}
+
+void
+cp_msg_vs_get_mactotei_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme)
+{
+ cp_msg_mme_send (ctx, mme);
+}
diff --git a/cesar/cp/msg/stub/src/msg_vs.c b/cesar/cp/msg/stub/src/msg_vs.c
index f126443f33..45dff754af 100644
--- a/cesar/cp/msg/stub/src/msg_vs.c
+++ b/cesar/cp/msg/stub/src/msg_vs.c
@@ -249,3 +249,43 @@ cp_msg_vs_get_pb_stats_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme)
void
cp_msg_vs_get_pb_stats_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme) {}
+
+bool
+cp_msg_vs_get_mactotei_req_receive (cp_t *ctx, cp_mme_rx_t *mme)
+ __attribute__((weak));
+
+bool
+cp_msg_vs_get_mactotei_req_receive (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ return true;
+}
+
+
+cp_mme_tx_t *
+cp_msg_vs_get_mactotei_cnf_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
+ uint nb_entry)
+ __attribute__((weak));
+
+cp_mme_tx_t *
+cp_msg_vs_get_mactotei_cnf_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
+ uint nb_entry)
+{
+ return NULL;
+}
+
+void
+cp_msg_vs_get_mactotei_cnf_send_entry (cp_t *ctx, cp_mme_tx_t *mme_tx,
+ mac_t mac, cp_tei_t tei, u8 tag)
+ __attribute__((weak));
+
+void
+cp_msg_vs_get_mactotei_cnf_send_entry (cp_t *ctx, cp_mme_tx_t *mme_tx,
+ mac_t mac, cp_tei_t tei, u8 tag)
+{}
+
+void
+cp_msg_vs_get_mactotei_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme)
+ __attribute__((weak));
+
+void
+cp_msg_vs_get_mactotei_cnf_send_end (cp_t *ctx, cp_mme_tx_t *mme) {}
diff --git a/cesar/cp/msg/test/Makefile b/cesar/cp/msg/test/Makefile
index 002c15dbe7..e17ad4959c 100644
--- a/cesar/cp/msg/test/Makefile
+++ b/cesar/cp/msg/test/Makefile
@@ -44,8 +44,9 @@ relay_SOURCES = relay.c interface_stub.c misc_stub.c
relay_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
cl/stub bsu/stub mac/sar/stub
-
-test_vs_msg_SOURCES = msg_vs.c interface_stub.c misc_stub.c mac_sar_interface_stub.c
+
+test_vs_msg_SOURCES = msg_vs.c interface_stub.c misc_stub.c \
+ mac_sar_interface_stub.c cp_cl_interface_vs_stub.c
test_vs_msg_MODULES = lib cp/msg cp/secu mac/common cp/sta/mgr \
cp/fsm/stub cp/sta/core/stub cp/cco/action/stub \
cl/stub bsu/stub mac/sar/stub
diff --git a/cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c b/cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c
new file mode 100644
index 0000000000..7d185c9693
--- /dev/null
+++ b/cesar/cp/msg/test/src/cp_cl_interface_vs_stub.c
@@ -0,0 +1,41 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cp_cl_interface_stub.c
+ * \brief CL interface stub functions.
+ * \ingroup cp_msg
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "cp/cp.h"
+#include "cp/msg/msg.h"
+#include "cl/cl_mactotei.h"
+
+static cl_mactotei_entry_t fake_mactotei[2] =
+{
+ {
+ 0x0013D7010203ull,
+ 0x45,
+ 0x56
+ },{
+ 0xabcdef0abcdeull,
+ 0x78,
+ 0x89
+ }
+};
+
+void
+cl_mactotei_table_get_entry (cl_t *ctx, uint index,
+ cl_mactotei_entry_t* data)
+{
+ data->mac = fake_mactotei[index%2].mac;
+ data->tei = fake_mactotei[index%2].tei;
+ data->tag = fake_mactotei[index%2].tag;
+}
diff --git a/cesar/cp/msg/test/src/msg_vs.c b/cesar/cp/msg/test/src/msg_vs.c
index 2af0943677..ba0a1ee3bb 100644
--- a/cesar/cp/msg/test/src/msg_vs.c
+++ b/cesar/cp/msg/test/src/msg_vs.c
@@ -30,6 +30,7 @@
#include "mac/common/tonemap.h"
#include "ce/common/mod.h"
#include "mac/sar/sar_pb_stats.h"
+#include "cl/cl_mactotei.h"
struct mme_header_t
{
@@ -60,7 +61,7 @@ mac_t own_mac_addr = 0x123456789ABCull;
cp_mme_peer_t peer;
void
-pb_stats_test_change_buffer (bitstream_t *ctx, void *user_data)
+test_change_buffer (bitstream_t *ctx, void *user_data)
{
const uint header_size = (OUI_SIZE + (peer.vlan_tag ?
HPAV_MME_HEADER_LEN_WITH_VLAN :
@@ -1945,7 +1946,7 @@ test_case_msg_vs_get_pb_stats (test_t test)
BITSTREAM_READ);
bitstream_init_buffer_cb (
&stream,
- (bitstream_buffer_cb_t) pb_stats_test_change_buffer,
+ (bitstream_buffer_cb_t) test_change_buffer,
NULL);
bitstream_skip (&stream, 8 * (OUI_SIZE +
(peer.vlan_tag ?
@@ -2071,6 +2072,107 @@ test_case_msg_imac_get_discover_list (test_t test)
test_end;
}
+void
+test_case_msg_vs_get_mactotei (test_t test)
+{
+ test_case_begin (test, "VS_GET_MACTOTEI");
+
+ test_begin (test, "REQ")
+ {
+ bitstream_t stream;
+ cp_mme_rx_t *mme_rx;
+ mme_header_t header;
+
+ cp_msg_init (&cp);
+
+ /* Build MME Header. */
+ header.oda = own_mac_addr;
+ header.osa = peer.mac;
+ header.mmtype = VS_GET_MACTOTEI_REQ;
+ header.fmi_inf = 0;
+ header.fmi_mi = 0;
+ header.fmi_ssn = 0;
+ test_write_header (false, &header, &stream, 0);
+ bitstream_finalise (&stream);
+
+ /* Receive MME. */
+ uint fmi;
+ mme_rx = cp_msg_mme_read_header (&cp, GET_BUFFER(0),
+ ETH_PACKET_MIN_SIZE, peer.tei,
+ &fmi, false);
+ dbg_assert (mme_rx->mmtype == VS_GET_MACTOTEI_REQ);
+ test_fail_unless (bitstream_read (&mme_rx->bitstream, OUI_SIZE_BITS)
+ == SPC_OUI);
+
+ bool r = cp_msg_vs_get_mactotei_req_receive (&cp, mme_rx);
+ test_fail_unless (r);
+
+ slab_release (mme_rx);
+ cp_msg_uninit (&cp);
+ }
+ test_end;
+
+ test_begin (test, "CNF")
+ {
+ uint nb_entry;
+
+ /* Functions to test */
+ for (nb_entry=0; nb_entry<2000; nb_entry++)
+ {
+ cp_mme_tx_t *mme_tx;
+
+ INIT_BUFFER();
+ cp_msg_init (&cp);
+ mme_tx = cp_msg_vs_get_mactotei_cnf_send_begin (&cp, &peer,
+ nb_entry);
+ uint i;
+ for (i=0; i<nb_entry; i++)
+ {
+ cl_mactotei_entry_t data;
+ cl_mactotei_table_get_entry (cp.cl, i, &data);
+
+ cp_msg_vs_get_mactotei_cnf_send_entry (&cp, mme_tx, data.mac,
+ (cp_tei_t) data.tei,
+ data.tag);
+ }
+ cp_msg_vs_get_mactotei_cnf_send_end (&cp, mme_tx);
+
+ /* Test itself */
+ buffer_idx = 0;
+ bitstream_t stream;
+ bitstream_init (&stream, GET_BUFFER(0), ETH_PACKET_MAX_SIZE,
+ BITSTREAM_READ);
+ bitstream_init_buffer_cb (
+ &stream,
+ (bitstream_buffer_cb_t) test_change_buffer,
+ NULL);
+ bitstream_skip (&stream, 8 * (OUI_SIZE +
+ (peer.vlan_tag ?
+ HPAV_MME_HEADER_LEN_WITH_VLAN :
+ HPAV_MME_HEADER)));
+ test_fail_unless (bitstream_read (&stream, 16) == nb_entry,
+ "Wrong number of entry");
+ uint j;
+ for (j=0; j<nb_entry; j++)
+ {
+ cl_mactotei_entry_t data;
+ /* call again the stubbed function */
+ cl_mactotei_table_get_entry (cp.cl, j, &data);
+ test_fail_unless (bitstream_read_large (&stream, 48) ==
+ data.mac, "Wrong mac value");
+ test_fail_unless (bitstream_read (&stream, 8) ==
+ data.tei, "Wrong tei value");
+ test_fail_unless (bitstream_read (&stream, 8) ==
+ data.tag, "Wrong tag value");
+ }
+ /* End TEST */
+ cp_msg_uninit (&cp);
+ }
+
+ }
+ test_end;
+}
+
int
main (int argc, char **argv)
{
@@ -2095,6 +2197,7 @@ main (int argc, char **argv)
test_case_msg_vs_get_ce_stats (test);
test_case_msg_vs_get_pb_stats (test);
test_case_msg_imac_get_discover_list (test);
+ test_case_msg_vs_get_mactotei (test);
test_case_begin (test, "Memory allocation");
test_begin (test, "memory leaks")
diff --git a/cesar/cp/sta/action/src/vs.c b/cesar/cp/sta/action/src/vs.c
index 5de6fc29ab..6f307fdae2 100644
--- a/cesar/cp/sta/action/src/vs.c
+++ b/cesar/cp/sta/action/src/vs.c
@@ -21,6 +21,7 @@
#include "cp/sta/action/misc.h"
#include "ce/rx/bitloading/nsr.h"
#include "mac/sar/sar_pb_stats.h"
+#include "cl/cl_mactotei.h"
/**
* Handle STARTED => VS_GET_TONEMAP.REQ.
@@ -632,3 +633,31 @@ cp_sta_action_vs__started__vs_get_pb_stats_req (cp_t *ctx, cp_mme_rx_t *mme)
sar_read_pb_stats_end (ctx->sar);
}
}
+
+void
+cp_sta_action_vs__started__vs_get_mactotei_req (cp_t *ctx, cp_mme_rx_t *mme)
+{
+ dbg_assert(ctx);
+ dbg_assert(mme);
+
+ if (cp_msg_vs_get_mactotei_req_receive (ctx, mme))
+ {
+ cp_mme_tx_t *mme_tx;
+ uint nb_entry = cl_mactotei_table_size (ctx->cl);
+
+ mme_tx = cp_msg_vs_get_mactotei_cnf_send_begin (ctx, &mme->peer,
+ nb_entry);
+ dbg_assert (mme_tx);
+ uint i;
+ for (i=0; i<nb_entry; i++)
+ {
+ cl_mactotei_entry_t data;
+ cl_mactotei_table_get_entry (ctx->cl, i, &data);
+
+ cp_msg_vs_get_mactotei_cnf_send_entry (ctx, mme_tx, data.mac,
+ (cp_tei_t) data.tei,
+ data.tag);
+ }
+ cp_msg_vs_get_mactotei_cnf_send_end (ctx, mme_tx);
+ }
+}
diff --git a/cesar/cp/sta/action/vs.h b/cesar/cp/sta/action/vs.h
index eefb1019be..4ab9016f03 100644
--- a/cesar/cp/sta/action/vs.h
+++ b/cesar/cp/sta/action/vs.h
@@ -74,6 +74,14 @@ void
cp_sta_action_vs__started__vs_get_pb_stats_req (cp_t *ctx, cp_mme_rx_t *mme);
/**
+ * Handle STARTED => VS_GET_MACTOTEI.REQ.
+ * \param ctx control plane context
+ * \param mme received MME handle
+ */
+void
+cp_sta_action_vs__started__vs_get_mactotei_req (cp_t *ctx, cp_mme_rx_t *mme);
+
+/**
* Handle STARTED => VS_GET_CE_STATS.REQ.
* \param ctx control plane context
* \param mme received MME handle