summaryrefslogtreecommitdiff
path: root/cesar/cp2/msg
diff options
context:
space:
mode:
authorschodet2008-08-29 14:52:33 +0000
committerschodet2008-08-29 14:52:33 +0000
commit61addbb1e20e382581c3bee165b8c253adb69d84 (patch)
treef106646632de478a1bc08b12a043f83336435e98 /cesar/cp2/msg
parent1b5b41d79cf71a1d5a784576aa1fa9d9bd704a71 (diff)
* cp2 -> cp:
- renamed. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2798 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/msg')
-rw-r--r--cesar/cp2/msg/Module1
-rw-r--r--cesar/cp2/msg/inc/cc_assoc.h64
-rw-r--r--cesar/cp2/msg/inc/cc_leave.h33
-rw-r--r--cesar/cp2/msg/inc/cc_set_tei_map.h51
-rw-r--r--cesar/cp2/msg/inc/cc_who_ru.h28
-rw-r--r--cesar/cp2/msg/inc/cm_get_key.h59
-rw-r--r--cesar/cp2/msg/inc/cm_key.h28
-rw-r--r--cesar/cp2/msg/inc/cm_mme_error.h39
-rw-r--r--cesar/cp2/msg/inc/cm_set_key.h50
-rw-r--r--cesar/cp2/msg/inc/context.h28
-rw-r--r--cesar/cp2/msg/inc/msg.h55
-rw-r--r--cesar/cp2/msg/inc/msg_cc.h364
-rw-r--r--cesar/cp2/msg/inc/msg_cm.h203
-rw-r--r--cesar/cp2/msg/inc/msg_drv.h177
-rw-r--r--cesar/cp2/msg/msg.h188
-rw-r--r--cesar/cp2/msg/src/mme.c109
-rw-r--r--cesar/cp2/msg/src/msg.c764
-rw-r--r--cesar/cp2/msg/src/msg_cc.c828
-rw-r--r--cesar/cp2/msg/src/msg_cm.c543
-rw-r--r--cesar/cp2/msg/test/Makefile20
-rw-r--r--cesar/cp2/msg/test/doc/Makefile20
-rw-r--r--cesar/cp2/msg/test/doc/read-header.txt69
-rw-r--r--cesar/cp2/msg/test/overide/cp2/inc/context.h48
-rw-r--r--cesar/cp2/msg/test/overide/cp2/sta/core/core.h18
-rw-r--r--cesar/cp2/msg/test/overide/cp_fsm_defs.h38
-rw-r--r--cesar/cp2/msg/test/src/cc_set_tei_map_frag.c261
-rw-r--r--cesar/cp2/msg/test/src/cl_stub.c119
-rw-r--r--cesar/cp2/msg/test/src/cp_cl_interface_stub.c44
-rw-r--r--cesar/cp2/msg/test/src/fsm_stub.c29
-rw-r--r--cesar/cp2/msg/test/src/interface_stub.c27
-rw-r--r--cesar/cp2/msg/test/src/msg_cc.c646
-rw-r--r--cesar/cp2/msg/test/src/msg_cm.c634
-rw-r--r--cesar/cp2/msg/test/src/sta_mgr_stub.c67
-rw-r--r--cesar/cp2/msg/test/src/test-msg-read-header.c184
34 files changed, 0 insertions, 5836 deletions
diff --git a/cesar/cp2/msg/Module b/cesar/cp2/msg/Module
deleted file mode 100644
index ea8a9bae40..0000000000
--- a/cesar/cp2/msg/Module
+++ /dev/null
@@ -1 +0,0 @@
-SOURCES := msg.c mme.c msg_cc.c msg_cm.c
diff --git a/cesar/cp2/msg/inc/cc_assoc.h b/cesar/cp2/msg/inc/cc_assoc.h
deleted file mode 100644
index d28d5ee614..0000000000
--- a/cesar/cp2/msg/inc/cc_assoc.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef cp2_msg_inc_cc_assoc_h
-#define cp2_msg_inc_cc_assoc_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cc_assoc.h
- * \brief CC_ASSOC messages.
- * \ingroup cp2_msg
- */
-
-/** CC_ASSOC.REQ request type. */
-enum cp_msg_cc_assoc_req_type_t
-{
- CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
- CP_MSG_CC_ASSOC_REQ_TYPE_RENEW,
- CP_MSG_CC_ASSOC_REQ_TYPE_NB
-};
-
-/** CC_ASSOC.CNF result. */
-enum cp_msg_cc_assoc_cnf_result_t
-{
- CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
- CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_TEMPORARY_RESSOURCE_EXHAUSTION,
- CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_PERMANANT_RESSOURCE_EXHAUSTION,
- CP_MSG_CC_ASSOC_CNF_RESULT_FAILURE_OTHER_REASON,
- CP_MSG_CC_ASSOC_CNF_RESULT_NB
-};
-
-/** Data associated with a CC_ASSOC.REQ message. */
-struct cp_msg_cc_assoc_req_t
-{
- /** Request type. */
- enum cp_msg_cc_assoc_req_type_t request_type;
- /** NID of the AVLN. */
- cp_nid_t nid;
- /** Station CCo capability. */
- u8 cco_cap;
- /** Station proxy capability. */
- u8 proxy_cap;
-};
-typedef struct cp_msg_cc_assoc_req_t cp_msg_cc_assoc_req_t;
-
-/** Data associated with a CC_ASSOC.CNF message. */
-struct cp_msg_cc_assoc_cnf_t
-{
- /** Association result. */
- enum cp_msg_cc_assoc_cnf_result_t result;
- /** NID of the AVLN. */
- cp_nid_t nid;
- /** SNID of the AVLN. */
- cp_snid_t snid;
- /** Station TEI. */
- cp_tei_t sta_tei;
- /** Lease time for the TEI. */
- u16 lease_time_min;
-};
-typedef struct cp_msg_cc_assoc_cnf_t cp_msg_cc_assoc_cnf_t;
-
-#endif /* cp2_msg_inc_cc_assoc_h */
diff --git a/cesar/cp2/msg/inc/cc_leave.h b/cesar/cp2/msg/inc/cc_leave.h
deleted file mode 100644
index 004e32dd6b..0000000000
--- a/cesar/cp2/msg/inc/cc_leave.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef cp2_msg_inc_cc_leave_h
-#define cp2_msg_inc_cc_leave_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cc_leave.h
- * \brief CC_LEAVE messages.
- * \ingroup cp2_msg
- */
-
-/** CC_LEAVE.REQ reason for the disassociation. */
-enum cp_msg_cc_leave_req_reason_t
-{
- CP_MSG_CC_LEAVE_REQ_REASON_USER_REQUEST,
- CP_MSG_CC_LEAVE_REQ_REASON_POWER_DOWN,
- CP_MSG_CC_LEAVE_REQ_REASON_NB
-};
-
-/** CC_LEAVE.IND reason for the disassociation. */
-enum cp_msg_cc_leave_ind_reason_t
-{
- CP_MSG_CC_LEAVE_IND_REASON_USER_REQUEST,
- CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
- CP_MSG_CC_LEAVE_IND_REASON_CCO_SHUTTING_DOWN,
- CP_MSG_CC_LEAVE_IND_REASON_NB
-};
-
-#endif /* cp2_msg_inc_cc_leave_h */
diff --git a/cesar/cp2/msg/inc/cc_set_tei_map.h b/cesar/cp2/msg/inc/cc_set_tei_map.h
deleted file mode 100644
index f1885c2343..0000000000
--- a/cesar/cp2/msg/inc/cc_set_tei_map.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef cp2_msg_inc_cc_set_tei_map_h
-#define cp2_msg_inc_cc_set_tei_map_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cc_set_tei_map.h
- * \brief CC_SET_TEI_MAP messages.
- * \ingroup cp2_msg
- */
-
-/** CC_SET_TEI_MAP.IND mode. */
-enum cp_msg_cc_set_tei_map_ind_mode_t
-{
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_UPDATE,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_DELETE,
- CP_MSG_CC_SET_TEI_MAP_IND_MODE_NB
-};
-
-/** CC_SET_TEI_MAP.IND station status. */
-enum cp_msg_cc_set_tei_map_ind_status_t
-{
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_AUTHENTICATED,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_DISASSOCIATED,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_NB
-};
-
-/** CC_SET_TEI_MAP change buffer data. */
-struct cp_msg_cc_set_tei_map_change_buffer_t
-{
- /** CP context. */
- cp_t *cp;
- /** MSG context. */
- void *msg;
- /** FMI data, number of fragment. */
- uint fmi_nbFrag;
- /** Fragment number. */
- uint fmi_fnmi;
- /** Sequence number. */
- uint fmi_ssn;
-};
-typedef struct cp_msg_cc_set_tei_map_change_buffer_t
-cp_msg_cc_set_tei_map_change_buffer_t;
-
-#endif /* cp2_msg_inc_cc_set_tei_map_h */
diff --git a/cesar/cp2/msg/inc/cc_who_ru.h b/cesar/cp2/msg/inc/cc_who_ru.h
deleted file mode 100644
index 8cf13baf81..0000000000
--- a/cesar/cp2/msg/inc/cc_who_ru.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef cp2_msg_inc_cc_who_ru_h
-#define cp2_msg_inc_cc_who_ru_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cc_who_ru.h
- * \brief CC_WHO_RU messages.
- * \ingroup cp2_msg
- */
-
-/** Data associated with a CC_WHO_RU.CNF message. */
-struct cp_msg_cc_who_ru_cnf_t
-{
- /** NID of network being queried. */
- cp_nid_t nid;
- /** CCo MAC address. */
- mac_t cco_mac;
- /** HFID of AVLN. */
- char avln_hfid[CP_HFID_SIZE + 1];
-};
-typedef struct cp_msg_cc_who_ru_cnf_t cp_msg_cc_who_ru_cnf_t;
-
-#endif /* cp2_msg_inc_cc_who_ru_h */
diff --git a/cesar/cp2/msg/inc/cm_get_key.h b/cesar/cp2/msg/inc/cm_get_key.h
deleted file mode 100644
index a1f74adbcc..0000000000
--- a/cesar/cp2/msg/inc/cm_get_key.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef cp2_msg_inc_cm_get_key_h
-#define cp2_msg_inc_cm_get_key_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cm_get_key.h
- * \brief CM_GET_KEY messages.
- * \ingroup cp2_msg
- */
-
-/** CM_GET_KEY.CNF result. */
-enum cp_msg_cm_get_key_cnf_result_t
-{
- CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
- CP_MSG_CM_GET_KEY_CNF_RESULT_REQUEST_REFUSED,
- CP_MSG_CM_GET_KEY_CNF_RESULT_UNSUPPORTED_METHOD_KEY_TYPE,
- CP_MSG_CM_GET_KEY_CNF_RESULT_NB
-};
-
-/** Data associated with a CM_GET_KEY.REQ message. */
-struct cp_msg_cm_get_key_req_t
-{
- /** Request type: direct or relayed. */
- bool relayed;
- /** Requested key type. */
- enum cp_msg_key_type_t key_type;
- /** NID. */
- cp_nid_t nid;
- /** Hash key if present. */
- u8 hash_key[CP_HASH_KEY_SIZE];
-};
-typedef struct cp_msg_cm_get_key_req_t cp_msg_cm_get_key_req_t;
-
-/** Data associated with a CM_GET_KEY.CNF message. */
-struct cp_msg_cm_get_key_cnf_t
-{
- /** Result. */
- enum cp_msg_cm_get_key_cnf_result_t result;
- /** Requested key type. */
- enum cp_msg_key_type_t key_type;
- /** NID. */
- cp_nid_t nid;
- /** EKS. */
- u8 eks;
- union {
- /** Hash key if present. */
- u8 hash_key[CP_HASH_KEY_SIZE];
- /** Key if present. */
- cp_key_t key;
- };
-};
-typedef struct cp_msg_cm_get_key_cnf_t cp_msg_cm_get_key_cnf_t;
-
-#endif /* cp2_msg_inc_cm_get_key_h */
diff --git a/cesar/cp2/msg/inc/cm_key.h b/cesar/cp2/msg/inc/cm_key.h
deleted file mode 100644
index d11e13e167..0000000000
--- a/cesar/cp2/msg/inc/cm_key.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef cp2_msg_inc_cm_key_h
-#define cp2_msg_inc_cm_key_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cm_key.h
- * \brief CM_SET_KEY and CM_GET_KEY messages.
- * \ingroup cp2_msg
- */
-
-/** Key type, used in CM_SET_KEY and CM_GET_KEY. */
-enum cp_msg_key_type_t
-{
- CP_MSG_KEY_DAK,
- CP_MSG_KEY_NMK,
- CP_MSG_KEY_NEK,
- CP_MSG_KEY_TEK,
- CP_MSG_KEY_HASH_KEY,
- CP_MSG_KEY_NONCE_ONLY,
- CP_MSG_KEY_NB
-};
-
-#endif /* cp2_msg_inc_cm_key_h */
diff --git a/cesar/cp2/msg/inc/cm_mme_error.h b/cesar/cp2/msg/inc/cm_mme_error.h
deleted file mode 100644
index cae087fafc..0000000000
--- a/cesar/cp2/msg/inc/cm_mme_error.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef cp2_msg_inc_cm_mme_error_h
-#define cp2_msg_inc_cm_mme_error_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cm_mme_error.h
- * \brief CM_MME_ERROR messages.
- * \ingroup cp2_msg
- */
-
-/** CM_MME_ERROR.IND reason. */
-enum cp_msg_cm_mme_error_ind_reason_t
-{
- CP_MSG_CM_MME_ERROR_IND_REASON_MME_NOT_SUPPORTED,
- CP_MSG_CM_MME_ERROR_IND_REASON_INVALID_MME_FIELDS,
- CP_MSG_CM_MME_ERROR_IND_REASON_UNSUPPORTED_FEATURE,
- CP_MSG_CM_MME_ERROR_IND_REASON_NB
-};
-
-/** Data associated with a CM_MME_ERROR.IND message. */
-struct cp_msg_cm_mme_error_ind_t
-{
- /** Reason of error. */
- enum cp_msg_cm_mme_error_ind_reason_t reason;
- /** Version of received MME. */
- u8 rx_mmv;
- /** MMTYPE of received MME. */
- cp_mmtype_t rx_mmtype;
- /** Offset of first invalid field. */
- uint offset;
-};
-typedef struct cp_msg_cm_mme_error_ind_t cp_msg_cm_mme_error_ind_t;
-
-#endif /* cp2_msg_inc_cm_mme_error_h */
diff --git a/cesar/cp2/msg/inc/cm_set_key.h b/cesar/cp2/msg/inc/cm_set_key.h
deleted file mode 100644
index 60ce168c75..0000000000
--- a/cesar/cp2/msg/inc/cm_set_key.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef cp2_msg_inc_cm_set_key_h
-#define cp2_msg_inc_cm_set_key_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/cm_set_key.h
- * \brief CM_SET_KEY messages.
- * \ingroup cp2_msg
- */
-
-/** CM_SET_KEY.CNF result. */
-enum cp_msg_cm_set_key_cnf_result_t
-{
- CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
- CP_MSG_CM_SET_KEY_CNF_RESULT_FAILURE,
- CP_MSG_CM_SET_KEY_CNF_RESULT_NB
-};
-
-/** Data associated with a CM_SET_KEY.REQ message. */
-struct cp_msg_cm_set_key_req_t
-{
- /** Key type. */
- enum cp_msg_key_type_t key_type;
- /** CCo capability. */
- u8 cco_cap;
- /** NID. */
- cp_nid_t nid;
- /** New EKS. */
- u8 new_eks;
- /** New key if present. */
- cp_key_t new_key;
-};
-typedef struct cp_msg_cm_set_key_req_t cp_msg_cm_set_key_req_t;
-
-/** Data associated with a CM_SET_KEY.CNF message. */
-struct cp_msg_cm_set_key_cnf_t
-{
- /** Result. */
- enum cp_msg_cm_set_key_cnf_result_t result;
- /** CCo capability. */
- u8 cco_cap;
-};
-typedef struct cp_msg_cm_set_key_cnf_t cp_msg_cm_set_key_cnf_t;
-
-#endif /* cp2_msg_inc_cm_set_key_h */
diff --git a/cesar/cp2/msg/inc/context.h b/cesar/cp2/msg/inc/context.h
deleted file mode 100644
index 2e77e61552..0000000000
--- a/cesar/cp2/msg/inc/context.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef cp2_msg_inc_context_h
-#define cp2_msg_inc_context_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/msg.h
- * \brief MSG context.
- * \ingroup cp2_msg
- *
- */
-#include "lib/slab.h"
-
-/** Message context. */
-struct cp_msg_t
-{
- /** Slab cache for the MME TX. */
- slab_cache_t mme_tx_slab_cache;
- /** Slab cache for the MME RX. */
- slab_cache_t mme_rx_slab_cache;
-};
-typedef struct cp_msg_t cp_msg_t;
-
-#endif /* cp2_msg_inc_context_h */
diff --git a/cesar/cp2/msg/inc/msg.h b/cesar/cp2/msg/inc/msg.h
deleted file mode 100644
index d2a7877d8a..0000000000
--- a/cesar/cp2/msg/inc/msg.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef cp2_msg_inc_msg_h
-#define cp2_msg_inc_msg_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/msg.h
- * \brief Private function headers.
- * \ingroup cp2_msg
- */
-#include "cp2/mme.h"
-
-#define CP_MSG_ENCRYPTED_DATA_HEADER_SIZE 24
-#define CP_MSG_ENCRYPTED_DATA_FOOTER_SIZE 9
-
-/**
- * Function to init the mme rx t messages.
- * \param ctx the module context.
- * \param mme the MME received.
- * \param length the MME length.
- * \param tei the source TEI.
- * \return the mme rx message initialised.
- */
-cp_mme_rx_t *
-cp_msg_mme_rx_init (cp_t *ctx, u8 *mme, uint length, cp_tei_t tei);
-
-/**
- * Function to init the mme rx t messages.
- * \param ctx the module context.
- * \return the mme rx message initialised.
- */
-cp_mme_tx_t *
-cp_msg_mme_tx_init (cp_t *ctx);
-
-/**
- * Function destructor for the MME RX messages.
- * \param ctx the module context.
- * \param msg the message context.
- */
-void
-cp_msg_mme_rx_destructor (cp_mme_rx_t *mme);
-
-/**
- * Function destructor for the MME TX messages.
- * \param ctx the module context.
- * \param msg the message context.
- */
-void
-cp_msg_mme_tx_destructor (cp_mme_tx_t *mme);
-
-#endif /* cp2_msg_inc_msg_h */
diff --git a/cesar/cp2/msg/inc/msg_cc.h b/cesar/cp2/msg/inc/msg_cc.h
deleted file mode 100644
index a367c8095d..0000000000
--- a/cesar/cp2/msg/inc/msg_cc.h
+++ /dev/null
@@ -1,364 +0,0 @@
-#ifndef cp2_msg_inc_msg_cc_h
-#define cp2_msg_inc_msg_cc_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/msg_cc.h
- * \brief CC family MME.
- * \ingroup cp2_msg
- */
-#include "cc_who_ru.h"
-#include "cc_assoc.h"
-#include "cc_leave.h"
-#include "cc_set_tei_map.h"
-
-#include "cp2/mme.h"
-
-BEGIN_DECLS
-
-/**
- * Send a CC_WHO_RU.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param nid NID of the requested AVLN
- */
-void
-cp_msg_cc_who_ru_req_send (cp_t *ctx, cp_mme_peer_t *peer, cp_nid_t nid);
-
-/**
- * Receive a CC_WHO_RU.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param nid received NID of the requested AVLN
- * \return true on success
- */
-bool
-cp_msg_cc_who_ru_req_receive (cp_t *ctx, cp_mme_rx_t *mme, cp_nid_t *nid);
-
-/**
- * Send a CC_WHO_RU.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_who_ru_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_who_ru_cnf_t *data);
-
-/**
- * Receive a CC_WHO_RU.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_who_ru_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_who_ru_cnf_t *data);
-
-/**
- * Send a CC_ASSOC.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_assoc_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_assoc_req_t *data);
-
-/**
- * Receive a CC_ASSOC.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_assoc_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_assoc_req_t *data);
-
-/**
- * Send a CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_assoc_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_assoc_cnf_t *data);
-
-/**
- * Receive a CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_assoc_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_assoc_cnf_t *data);
-
-/**
- * Send a CC_LEAVE.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param reason reason for the disassociation
- */
-void
-cp_msg_cc_leave_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_leave_req_reason_t reason);
-
-/**
- * Receive a CC_LEAVE.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param reason received reason for the disassociation
- * \return true on success
- */
-bool
-cp_msg_cc_leave_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_leave_req_reason_t *reason);
-
-/**
- * Send a CC_LEAVE.CNF.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_leave_cnf_send (cp_t *ctx, cp_mme_peer_t *peer);
-
-/**
- * Receive a CC_LEAVE.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_leave_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Send a CC_LEAVE.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param reason reason for the disassociation
- * \param nid NID
- */
-void
-cp_msg_cc_leave_ind_send (cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_leave_ind_reason_t reason,
- cp_nid_t nid);
-
-/**
- * Receive a CC_LEAVE.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param reason received reason for the disassociation
- * \param nid received NID
- * \return true on success
- */
-bool
-cp_msg_cc_leave_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_leave_ind_reason_t *reason,
- cp_nid_t *nid);
-
-/**
- * Send a CC_LEAVE.RSP.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_leave_rsp_send (cp_t *ctx, cp_mme_peer_t *peer);
-
-/**
- * Receive a CC_LEAVE.RSP.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_leave_rsp_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Send a CC_SET_TEI_MAP.REQ.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_set_tei_map_req_send (cp_t *ctx, cp_mme_peer_t *peer);
-
-/**
- * Receive a CC_SET_TEI_MAP.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_req_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Begin a CC_SET_TEI_MAP.IND construction.
- * \param ctx control plane context
- * \param peer peer information
- * \param mode update, add or delete
- * \param sta_nb number of stations sent
- * \return the MME being constructed
- */
-cp_mme_tx_t *
-cp_msg_cc_set_tei_map_ind_send_begin (
- cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_set_tei_map_ind_mode_t mode, uint sta_nb);
-
-/**
- * Write a station to a CC_SET_TEI_MAP.IND being constructed.
- * \param ctx control plane context
- * \param mme MME being constructed
- * \param tei STA TEI
- * \param mac STA mac address
- * \param status STA status
- */
-void
-cp_msg_cc_set_tei_map_ind_send_sta (
- cp_t *ctx, cp_mme_tx_t *mme, cp_tei_t tei, mac_t mac,
- enum cp_msg_cc_set_tei_map_ind_status_t status);
-
-/**
- * Finalise and send a CC_SET_TEI_MAP.IND message.
- * \param ctx control plane context
- * \param mme MME being constructed
- */
-void
-cp_msg_cc_set_tei_map_ind_send_end (cp_t *ctx, cp_mme_tx_t *mme);
-
-/**
- * Begin a CC_SET_TEI_MAP.IND reception.
- * \param ctx control plane context
- * \param mme MME handle
- * \param mode received mode: update, add or delete
- * \param sta_nb received number of STA
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_begin (
- cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_set_tei_map_ind_mode_t *mode, uint *sta_nb);
-
-/**
- * Read a station from a received CC_SET_TEI_MAP.IND.
- * \param ctx control plane context
- * \param mme MME being received
- * \param tei received STA TEI
- * \param mac received STA mac address
- * \param status received STA status
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_sta (
- cp_t *ctx, cp_mme_rx_t *mme, cp_tei_t *tei, mac_t *mac,
- enum cp_msg_cc_set_tei_map_ind_status_t *status);
-
-/**
- * Finalise a CC_SET_TEI_MAP.IND reception.
- * \param ctx control plane context
- * \param mme MME being received
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_end (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Write the header of a CC_RELAY MME.
- * \param ctx the module context.
- * \param peer the peer information.
- * \param mmtype the MMType of the MME CC_RELAY_REQ or CC_RELAY_IND.
- * \param prun if the MME shall be encrypted.
- * \param peks the Payload encryption key select.
- * \param fda the final destination mac address.
- * \param ftei the final TEI.
- */
-cp_mme_tx_t *
-cp_msg_cc_relay_send_begin (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- const cp_secu_protocol_run_t *prun,
- cp_mme_peks_t peks,
- mac_t fda, cp_tei_t ftei);
-
-/**
- * Finalise the MME CC_RELAY.*.
- * \param ctx the module context.
- * \param msg the MME to send.
- * \param length the MME length corresponding (header included).
- *
- * Patch the Length of the MME payload in the MSG CC_RELAY.REQ MME.
- */
-void
-cp_msg_cc_relay_send_finalise (cp_t *ctx, cp_mme_tx_t *msg, uint length);
-
-/**
- * Write the header of a CC_RELAY MME.
- * \param ctx the module context.
- * \param peer the peer information.
- * \param mmtype the MMType of the MME CC_RELAY_REQ or CC_RELAY_IND.
- * \param prun if the MME shall be encrypted.
- * \param peks the Payload encryption key select.
- * \param fda the final destination mac address.
- * \param ftei the final TEI.
- */
-extern inline cp_mme_tx_t *
-cp_msg_cc_relay_req_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_secu_protocol_run_t *prun,
- cp_mme_peks_t peks,
- mac_t fda, cp_tei_t ftei)
-{
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (fda);
- dbg_assert (ftei);
-
- return cp_msg_cc_relay_send_begin (ctx, peer, CC_RELAY_REQ,
- prun, peks,
- fda, ftei);
-}
-
-/**
- * Write the header of a CC_RELAY MME.
- * \param ctx the module context.
- * \param peer the peer information.
- * \param prun if the MME shall be encrypted.
- * \param peks the Payload encryption key select.
- * \param fda the final destination mac address.
- * \param ftei the final TEI.
- */
-extern inline cp_mme_tx_t *
-cp_msg_cc_relay_ind_send_begin (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_secu_protocol_run_t *prun,
- cp_mme_peks_t peks,
- mac_t fda, cp_tei_t ftei)
-{
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (fda);
- dbg_assert (ftei);
-
- return cp_msg_cc_relay_send_begin (ctx, peer, CC_RELAY_IND,
- prun, peks,
- fda, ftei);
-}
-
-/**
- * Receive a CC_RELAY.*
- * \param ctx the control plane context.
- * \param msg the MME context.
- * \param length the MME payload length contained.
- *
- * Initialise the Relay MME.
- */
-void
-cp_msg_cc_relay_receive (cp_t *ctx, cp_mme_rx_t *msg, uint *length);
-
-END_DECLS
-
-#endif /* cp2_msg_inc_msg_cc_h */
diff --git a/cesar/cp2/msg/inc/msg_cm.h b/cesar/cp2/msg/inc/msg_cm.h
deleted file mode 100644
index 7e76eac688..0000000000
--- a/cesar/cp2/msg/inc/msg_cm.h
+++ /dev/null
@@ -1,203 +0,0 @@
-#ifndef cp2_msg_inc_msg_cm_h
-#define cp2_msg_inc_msg_cm_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/msg_cm.h
- * \brief CM family MME.
- * \ingroup cp2_msg
- */
-#include "cm_key.h"
-#include "cm_set_key.h"
-#include "cm_get_key.h"
-#include "cm_mme_error.h"
-
-BEGIN_DECLS
-
-/**
- * Send a CM_UNASSOCIATED_STA.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param nid NID of the transmitting STA
- * \param cco_cap CCo capability of the transmitting STA
- */
-void
-cp_msg_cm_unassociated_sta_ind_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_nid_t nid, u8 cco_cap);
-
-/**
- * Receive a CM_UNASSOCIATED_STA.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param nid received NID of the transmitting STA
- * \param cco_cap received CCo capability of the transmitting STA
- * \return true on success
- */
-bool
-cp_msg_cm_unassociated_sta_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_nid_t *nid, u8 *cco_cap);
-
-/**
- * Get the PID of the CM_SET_KEY.CNF.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_set_key_get_pid (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Send a CM_SET_KEY.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_set_key_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_set_key_req_t *data);
-
-/**
- * Receive a CM_SET_KEY.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_set_key_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_set_key_req_t *data);
-
-/**
- * Get the PID of the CM_GET_KEY.CNF.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_get_key_cnf_get_pid (cp_t *ctx, cp_mme_rx_t *mme);
-
-
-/**
- * Send a CM_SET_KEY.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_set_key_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_set_key_cnf_t *data);
-
-/**
- * Receive a CM_SET_KEY.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_set_key_cnf_t *data);
-
-/**
- * Get the PID of the CM_GET_KEY.REQ.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_get_key_req_get_pid (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Send a CM_GET_KEY.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_get_key_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_get_key_req_t *data);
-
-/**
- * Receive a CM_GET_KEY.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_get_key_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_get_key_req_t *data);
-
-/**
- * Send a CM_GET_KEY.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_get_key_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_get_key_cnf_t *data);
-
-/**
- * Receive a CM_GET_KEY.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_get_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_get_key_cnf_t *data);
-
-/**
- * Send a CM_MME_ERROR.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cm_mme_error_ind_send (cp_t *ctx, cp_mme_peer_t *peer_info,
- const cp_msg_cm_mme_error_ind_t *data);
-/**
- * Receive a CM_MME_ERROR.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cm_mme_error_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_mme_error_ind_t *data);
-
-END_DECLS
-
-#endif /* cp2_msg_inc_msg_cm_h */
diff --git a/cesar/cp2/msg/inc/msg_drv.h b/cesar/cp2/msg/inc/msg_drv.h
deleted file mode 100644
index 228d77d0ef..0000000000
--- a/cesar/cp2/msg/inc/msg_drv.h
+++ /dev/null
@@ -1,177 +0,0 @@
-#ifndef cp2_msg_inc_msg_drv_h
-#define cp2_msg_inc_msg_drv_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/inc/msg_drv.h
- * \brief DRV family MME.
- * \ingroup cp2_msg
- */
-
-/** Result of a DRV family request. */
-enum cp_msg_drv_result_t
-{
- CP_MSG_DRV_RESULT_SUCCESS,
- CP_MSG_DRV_RESULT_FAILURE,
- CP_MSG_DRV_RESULT_NB,
-};
-typedef enum cp_msg_drv_result_t cp_msg_drv_result_t;
-
-BEGIN_DECLS
-
-/**
- * Receive a DRV_STA_SET_MAC_ADDR.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param mac received mac address
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_mac_addr_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- mac_t *mac);
-
-/**
- * Receive a DRV_STA_SET_CCO_PREF.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param cco_pref received CCo preferred flag
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_cco_pref_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- bool *cco_pref);
-
-/**
- * Receive a DRV_STA_SET_WAS_CCO.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param was_cco received was CCo flag
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_was_cco_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- bool *was_cco);
-
-/**
- * Receive a DRV_STA_SET_NPW.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param npw received NPW
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_npw_req_receive (cp_t *ctx, cp_mme_rx_t *mme, char *npw);
-
-/**
- * Receive a DRV_STA_SET_DPW.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param dpw received device password
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_dpw_req_receive (cp_t *ctx, cp_mme_rx_t *mme, char *dpw);
-
-/**
- * Receive a DRV_STA_SET_SL.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param sl received SL
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_sl_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_security_level_t *sl);
-
-/**
- * Receive a DRV_STA_SET_NID.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param nid received NID
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_nid_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_nid_t *nid);
-
-/**
- * Receive a DRV_STA_SET_M_STA_HFID.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param m_sta_hfid received manufacturer STA HFID
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_m_sta_hfid_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- char *m_sta_hfid);
-
-/**
- * Receive a DRV_STA_SET_U_STA_HFID.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param u_sta_hfid received user STA HFID
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_u_sta_hfid_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- char *u_sta_hfid);
-
-/**
- * Receive a DRV_STA_SET_AVLN_HFID.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param avln_hfid received AVLN HFID
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_avln_hfid_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- char *avln_hfid);
-
-/**
- * Receive a DRV_STA_SET_TONEMASK.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param tonemask received tonemask
- * \return true on success
- */
-bool
-cp_msg_drv_sta_set_tonemask_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- u32 *tonemask);
-
-/**
- * Receive a DRV_STA_MAC_START.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_drv_sta_mac_start_req_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Receive a DRV_STA_MAC_STOP.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_drv_sta_mac_stop_req_receive (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Send a DRV_....CNF, works for any DRV messages.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype MMTYPE to respond to
- * \param result result code
- */
-void
-cp_msg_drv_any_cnf_send (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- cp_msg_drv_result_t result);
-
-END_DECLS
-
-#endif /* cp2_msg_inc_msg_drv_h */
diff --git a/cesar/cp2/msg/msg.h b/cesar/cp2/msg/msg.h
deleted file mode 100644
index 4331a0e399..0000000000
--- a/cesar/cp2/msg/msg.h
+++ /dev/null
@@ -1,188 +0,0 @@
-#ifndef cp2_msg_msg_h
-#define cp2_msg_msg_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/msg.h
- * \brief MME creation and decoding.
- * \ingroup cp2_msg
- *
- * The msg module handles:
- *
- * - messages decoding,
- * - messages encoding,
- * - messages dispatch,
- * - encrypted payload encapsulation,
- * - relaying encapsulation.
- */
-#include "cp2/cp.h"
-#include "cp2/mme.h"
-#include "cp2/defs.h"
-
-#include "inc/msg_cc.h"
-#include "inc/msg_cm.h"
-#include "inc/msg_drv.h"
-
-enum cp_msg_avln_status_t
-{
- CP_MSG_AVLN_STATUS_UNASSOC_CCO_0,
- CP_MSG_AVLN_STATUS_UNASSOC_CCO_1,
- CP_MSG_AVLN_STATUS_UNASSOC_CCO_2,
- CP_MSG_AVLN_STATUS_UNASSOC_CCO_3,
- CP_MSG_AVLN_STATUS_ASSOC_NOT_PCO,
- CP_MSG_AVLN_STATUS_ASSOC_PCO,
- CP_MSG_AVLN_STATUS_CCO = 0x8,
- CP_MSG_AVLN_STATUS_NB
-};
-
-BEGIN_DECLS
-
-/**
- * Initialise the MSG module.
- * \param ctx control plane context
- */
-void
-cp_msg_init (cp_t *ctx);
-
-/**
- * Uninitialise the MSG module.
- * \param ctx control plane context
- */
-void
-cp_msg_uninit (cp_t *ctx);
-
-
-/**
- * Examine message type and post an event to the FSM.
- * \param ctx control plane context
- * \param mme received MME
- *
- * This function looks up the message type and translates it to a FSM event,
- * while checking the encryption is compliant with the message type.
- *
- * It also extracts and checks payload from encrypted messages.
- */
-void
-cp_msg_dispatch (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Initialise a MME handle for a new message to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMTYPE.
- * \return the newly created message
- *
- * This function:
- *
- * - gets a buffer for MME transmission,
- * - encapsulates the MME in a CC_RELAY.REQ if necessary,
- * - writes the MME header.
- */
-cp_mme_tx_t *
-cp_msg_mme_init (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype);
-
-/**
- * Initialise a MME handle for a new encrypted message to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMType.
- * \param pid protocol identifier
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \return the newly created message
- *
- * This does the same as cp_msg_mme_init(), but also encapsulate the MME in a
- * CM_ENCRYPTED_PAYLOAD.IND.
- */
-cp_mme_tx_t *
-cp_msg_mme_init_encrypted (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mmtype_t mmtype,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun);
-
- /** Write the header of a fragmented MME.
- * \param ctx the ctx module.
- * \param msg the message allocate previously.
- * \param peer the peer data.
- * \param mmtype the mmtype of the MME.
- * \param fmi_nbFrag The number of fragments.
- * \param fmi_fnmi the number of the fragment.
- * \param fmi_ssn the sequence number of the fragment.
- */
-void
-cp_msg_mme_write_frag_header (cp_t *ctx, cp_mme_tx_t *msg,
- cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- uint fmi_nbFrag, uint fmi_fnmi, uint fmi_ssn);
-
-/**
- * Initialise a MME handle for a new message fragment to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMTYPE.
- * \param fmi_nbFrag The number of fragments.
- * \param fmi_fnmi the number of the fragment.
- * \param fmi_ssn the sequence number of the fragment.
- * \return the newly created message
- *
- * This function:
- *
- * - gets a buffer for MME transmission,
- * - encapsulates the MME in a CC_RELAY.REQ if necessary,
- * - writes the MME header.
- */
-cp_mme_tx_t *
-cp_msg_mme_init_frag (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- uint fmi_nbFrag, uint fmi_fnmi, uint fmi_ssn);
-
-/**
- * Finalise and send a MME.
- * \param ctx control plane context
- * \param mme MME handle
- *
- * If the MME is encapsulated, write any pending footer, then send the
- * message.
- */
-void
-cp_msg_mme_send (cp_t *ctx, cp_mme_tx_t *mme);
-
-/**
- * Read the header of a received MME and return the MME context.
- * \param ctx the module context.
- * \param mme the MME received.
- * \param length the MME length.
- * \param tei the source TEI (0xFF if coming from the HLE).
- * \param fmi the FMI data.
- * \return cp_mme_rx_t object associated.
- */
-cp_mme_rx_t *
-cp_msg_mme_read_header (cp_t *ctx, u8 *mme, uint length, cp_tei_t tei,
- uint *fmi);
-
-/**
- * Read an encrypted header and decrypt the payload.
- * \param ctx the module context.
- * \param mme the mme context.
- * \return true if decoded correctly, false otherwise.
- */
-bool
-cp_msg_mme_read_header_enc (cp_t *ctx, cp_mme_rx_t *mme);
-
-/**
- * Change the current buffer of the reception message.
- * \param ctx the module context.
- * \param msg the message RX to change the buffer.
- *
- * This shall be used only on the RX MMEs which are received as fragmented
- * ones.
- */
-void
-cp_msg_mme_rx_change_buffer (cp_t *ctx, cp_mme_rx_t *msg);
-
-END_DECLS
-
-#endif /* cp2_msg_msg_h */
diff --git a/cesar/cp2/msg/src/mme.c b/cesar/cp2/msg/src/mme.c
deleted file mode 100644
index 4a8898aef0..0000000000
--- a/cesar/cp2/msg/src/mme.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/src/mme.c
- * \brief Function to init and destroy the MME messages.
- * \ingroup cp2_msg
- *
- */
-#include "common/std.h"
-
-#include "common/defs/ethernet.h"
-#include "lib/slab.h"
-
-#include "interface/interface.h"
-#include "cp2/cl_interf/cl_interf.h"
-
-#include "cp2/msg/inc/msg.h"
-#include "cp2/inc/context.h"
-
-/**
- * Function to init the mme rx t messages.
- * \param ctx the module context.
- * \param mme the MME received.
- * \param length the MME length.
- * \param tei the source TEI.
- * \return the mme rx message initialised.
- */
-cp_mme_rx_t *
-cp_msg_mme_rx_init (cp_t *ctx, u8 *mme, uint length, cp_tei_t tei)
-{
- cp_mme_rx_t *mme_rx;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (length >= ETH_PACKET_MIN_SIZE
- && length <= ETH_PACKET_MAX_SIZE);
-
- // Allocate the MME with the slab allocator.
- mme_rx = slab_alloc (&ctx->msg.mme_rx_slab_cache);
-
- dbg_assert (mme_rx);
- memset (mme_rx, 0, sizeof (cp_mme_rx_t));
- mme_rx->p_mme = mme;
- mme_rx->length = length;
- mme_rx->peer.tei = tei;
- mme_rx->cp = ctx;
-
- return mme_rx;
-}
-
-/**
- * Function to init the mme rx t messages.
- * \param ctx the module context.
- * \return the mme rx message initialised.
- */
-cp_mme_tx_t *
-cp_msg_mme_tx_init (cp_t *ctx)
-{
- cp_mme_tx_t *mme;
-
- dbg_assert (ctx);
- mme = slab_alloc (&ctx->msg.mme_tx_slab_cache);
- memset (mme, 0, sizeof (cp_mme_tx_t));
-
- mme->cp = ctx;
- return mme;
-}
-
-/**
- * Function destructor for the MME RX messages.
- * \param ctx the module context.
- * \param msg the message context.
- */
-void
-cp_msg_mme_rx_destructor (cp_mme_rx_t *mme)
-{
- blk_t *blk;
-
- dbg_assert (mme);
-
- if (mme->p_mme)
- interface_mme_recv_done (mme->cp->interface, mme->cl_data);
-
- while (mme->p_frag)
- {
- blk = mme->p_frag;
- mme->p_frag = blk->next;
- blk_release (blk);
- }
-}
-
-/**
- * Function destructor for the MME TX messages.
- * \param msg the message context.
- */
-void
-cp_msg_mme_tx_destructor (cp_mme_tx_t *mme)
-{
- dbg_assert (mme);
-
- if (mme->p_mme)
- cp_cl_interf_add_buffer_tx (mme->cp, mme->p_mme);
-}
-
diff --git a/cesar/cp2/msg/src/msg.c b/cesar/cp2/msg/src/msg.c
deleted file mode 100644
index a557ae32ba..0000000000
--- a/cesar/cp2/msg/src/msg.c
+++ /dev/null
@@ -1,764 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/src/msg.c
- * \brief MSG functions.
- * \ingroup cp2_msg
- *
- */
-#include "common/std.h"
-#include "lib/read_word.h"
-#include "lib/swap.h"
-#include "lib/crc.h"
-#include "lib/rnd.h"
-
-#include "common/defs/homeplugAV.h"
-#include "common/defs/ethernet.h"
-
-#include "cp2/cp.h"
-#include "cp2/msg/msg.h"
-#include "cp2/cl_interf/cl_interf.h"
-#include "cp2/sta/mgr/sta_mgr.h"
-#include "cp2/sta/mgr/sta_own_data.h"
-#include "cp2/secu/aes.h"
-
-#include "cp2/msg/inc/msg.h"
-#include "cp2/inc/context.h"
-
-#include <stdio.h>
-
-/** Padd the MME to reach the minimal length. */
-static void
-cp_msg_mme_pad (cp_t *ctx, cp_mme_tx_t *msg)
-{
- uint data;
-
- dbg_assert (ctx);
- dbg_assert (msg);
-
- data = 0;
- while (bitstream_bytes_processed (&msg->bitstream) < ETH_PACKET_MIN_SIZE)
- {
- bitstream_access (&msg->bitstream, &data, 8);
- }
-}
-
-/**
- * Initialise the MSG module.
- * \param ctx control plane context
- */
-void
-cp_msg_init (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- slab_cache_init (&ctx->msg.mme_tx_slab_cache, "MME TX",
- sizeof (cp_mme_tx_t),
- (slab_object_destructor_t) cp_msg_mme_tx_destructor);
-
- slab_cache_init (&ctx->msg.mme_rx_slab_cache, "MME RX",
- sizeof (cp_mme_rx_t),
- (slab_object_destructor_t) cp_msg_mme_rx_destructor);
-}
-
-/**
- * Uninitialise the MSG module.
- * \param ctx control plane context
- */
-void
-cp_msg_uninit (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- slab_cache_uninit (&ctx->msg.mme_tx_slab_cache);
- slab_cache_uninit (&ctx->msg.mme_rx_slab_cache);
-}
-
-/**
- * Examine message type and post an event to the FSM.
- * \param ctx control plane context
- * \param mme received MME
- *
- * This function looks up the message type and translates it to a FSM event,
- * while checking the encryption is compliant with the message type.
- *
- * It also extracts and checks payload from encrypted messages.
- */
-void
-cp_msg_dispatch (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- if (mme->mmtype == CM_ENCRYPTED_PAYLOAD_IND)
- cp_msg_mme_read_header_enc (ctx, mme);
-
- // TODO : Post the event.
-}
-
-/**
- * Initialise a MME handle for a new message to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMTYPE.
- * \return the newly created message
- *
- * This function:
- *
- * - gets a buffer for MME transmission,
- * - encapsulates the MME in a CC_RELAY.REQ if necessary,
- * - writes the MME header.
- */
-cp_mme_tx_t *
-cp_msg_mme_init (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype)
-{
- cp_mme_tx_t *msg;
- cp_sta_own_data_t *own_data;
- u64 data;
-
- dbg_assert (ctx);
- dbg_assert (peer);
-
- // Allocate the new message.
- msg = cp_msg_mme_tx_init (ctx);
- dbg_assert (msg);
-
- // Get a buffer.
- msg->p_mme = cp_cl_interf_get_buffer_tx (ctx);
- msg->peer = *peer;
- msg->peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- // Get the station own data.
- own_data = cp_sta_mgr_get_sta_own_data (ctx);
-
- // Initialise the bitstream context and fill the MME header.
- bitstream_init (&msg->bitstream, msg->p_mme, ETH_PACKET_MAX_SIZE,
- BITSTREAM_WRITE);
-
- // Store the Destination Mac address.
- bitstream_access (&msg->bitstream, &peer->mac,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Store the source mac address.
- data = cp_sta_own_data_get_mac_address (ctx);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Vlan tag.
- if (peer->vlan_tag)
- bitstream_access (&msg->bitstream, &peer->vlan_tag,
- BYTES_SIZE_TO_BITS(ETH_VLAN_TAG_SIZE));
-
- // MTYPE.
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MTYPE_SIZE));
-
- // MMV
- data = HPAV_MMV;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MMV_SIZE));
-
- //MMTYPE.
- bitstream_access (&msg->bitstream, &mmtype,
- BYTES_SIZE_TO_BITS (HPAV_MMTYPE_SIZE));
-
- //FMI = 0.
- data = 0;
- bitstream_access (&msg->bitstream, &data, 16);
-
- return msg;
-}
-
-/**
- * Initialise a MME handle for a new encrypted message to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMType.
- * \param pid protocol identifier
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \return the newly created message
- *
- * This does the same as cp_msg_mme_init(), but also encapsulate the MME in a
- * CM_ENCRYPTED_PAYLOAD.IND.
- */
-cp_mme_tx_t *
-cp_msg_mme_init_encrypted (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mmtype_t mmtype,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun)
-{
- cp_mme_tx_t *msg;
- cp_sta_own_data_t *own_data;
- u64 data;
- uint i;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (prun);
-
- if (peks == CP_MME_PEKS_SPC_NOT_EMBEDDED)
- {
- msg = cp_msg_mme_init (ctx, peer, mmtype);
- return msg;
- }
-
- // Initialise the message context.
- msg = cp_msg_mme_tx_init (ctx);
- dbg_assert (msg);
-
- // Get a buffer
- msg->p_mme = cp_cl_interf_get_buffer_tx (ctx);
- msg->peer = *peer;
- msg->peks = peks;
- msg->prun = *prun;
-
- // Compute the random filler.
-
- own_data = cp_sta_mgr_get_sta_own_data (ctx);
-
- // Initialise the bitstream context.
- bitstream_init (&msg->bitstream, msg->p_mme, ETH_PACKET_MAX_SIZE,
- BITSTREAM_WRITE);
-
- // Store the ODA.
- bitstream_access (&msg->bitstream, &msg->peer.mac,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Store the OSA.
- data = cp_sta_own_data_get_mac_address (ctx);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Vlan tag.
- if (peer->vlan_tag)
- bitstream_access (&msg->bitstream, &peer->vlan_tag,
- BYTES_SIZE_TO_BITS(ETH_VLAN_TAG_SIZE));
-
- // MTYPE.
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MTYPE_SIZE));
-
- // MMV
- data = HPAV_MMV;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MMV_SIZE));
-
- //MMTYPE.
- data = CM_ENCRYPTED_PAYLOAD_IND;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MMTYPE_SIZE));
-
- // FMI = 0.
- data = 0;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_FMI_SIZE));
-
- // PKES.
- bitstream_access (&msg->bitstream, &msg->peks, 8);
-
- // AVLN status.
- if (own_data->is_cco)
- data = CP_MSG_AVLN_STATUS_CCO;
- else if (!cp_sta_own_data_get_tei (ctx))
- data = CP_MSG_AVLN_STATUS_UNASSOC_CCO_0 + CP_CCO_LEVEL;
- else if (cp_sta_own_data_get_pco_status(ctx)
- && cp_sta_own_data_get_tei(ctx))
- data = CP_MSG_AVLN_STATUS_ASSOC_PCO;
- else if (!cp_sta_own_data_get_pco_status(ctx)
- && cp_sta_own_data_get_tei(ctx))
- data = CP_MSG_AVLN_STATUS_ASSOC_NOT_PCO;
-
- bitstream_access (&msg->bitstream, &data, 8);
-
- // PID.
- bitstream_access (&msg->bitstream, &msg->prun.pid, 8);
-
- // PRN.
- bitstream_access (&msg->bitstream, &msg->prun.prn, 16);
-
- // PMN.
- bitstream_access (&msg->bitstream, &msg->prun.pmn, 8);
-
- // IV or UUID.
- for (i = 0; i< 4; i++)
- {
- msg->iv_uuid.key[i] = lib_rnd32 (&ctx->rnd);
- bitstream_access (&msg->bitstream, &msg->iv_uuid.key[i], 32);
- }
-
- // Length of the MME TO be patch at the end.
- data = 0;
- bitstream_access (&msg->bitstream, &data, 16);
-
- // RFLen
- msg->rf_len = lib_rnd32 (&ctx->rnd) % 0xF;
- for (i = 0; i < msg->rf_len; i++)
- {
- data = lib_rnd32 (&ctx->rnd);
- bitstream_access (&msg->bitstream, &data, 8);
- }
-
- // Compute the payload offset.
- msg->payload_offset = bitstream_bytes_processed (&msg->bitstream);
-
- // The payload
- // Store the ODA.
- bitstream_access (&msg->bitstream, &msg->peer.mac,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Store the OSA.
- data = cp_sta_own_data_get_mac_address (ctx);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Vlan tag.
- if (peer->vlan_tag)
- bitstream_access (&msg->bitstream, &peer->vlan_tag,
- BYTES_SIZE_TO_BITS(ETH_VLAN_TAG_SIZE));
-
- // MTYPE.
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MTYPE_SIZE));
-
- // MMV
- data = HPAV_MMV;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MMV_SIZE));
-
- //MMTYPE.
- bitstream_access (&msg->bitstream, &mmtype,
- BYTES_SIZE_TO_BITS (HPAV_MMTYPE_SIZE));
-
- //FMI.
- data = 0;
- bitstream_access (&msg->bitstream, &data, 16);
-
- return msg;
-}
-
-/** Write the header of a fragmented MME.
- * \param ctx the ctx module.
- * \param msg the message allocate previously.
- * \param peer the peer data.
- * \param mmtype the mmtype of the MME.
- * \param fmi_nbFrag The number of fragments.
- * \param fmi_fnmi the number of the fragment.
- * \param fmi_ssn the sequence number of the fragment.
- */
-void
-cp_msg_mme_write_frag_header (cp_t *ctx, cp_mme_tx_t *msg,
- cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- uint fmi_nbFrag, uint fmi_fnmi, uint fmi_ssn)
-{
- cp_sta_own_data_t *own_data;
- u64 data;
-
- // Get the station own data.
- own_data = cp_sta_mgr_get_sta_own_data (ctx);
-
- // Initialise the bitstream context and fill the MME header.
- bitstream_init (&msg->bitstream, msg->p_mme, ETH_PACKET_MAX_SIZE,
- BITSTREAM_WRITE);
-
- // Store the Destination Mac address.
- bitstream_access (&msg->bitstream, &peer->mac,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Store the source mac address.
- data = cp_sta_own_data_get_mac_address (ctx);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (ETH_MAC_ADDRESS_SIZE));
-
- // Vlan tag.
- if (peer->vlan_tag)
- bitstream_access (&msg->bitstream, &peer->vlan_tag,
- BYTES_SIZE_TO_BITS(ETH_VLAN_TAG_SIZE));
-
- // MTYPE.
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MTYPE_SIZE));
-
- // MMV
- data = HPAV_MMV;
- bitstream_access (&msg->bitstream, &data,
- BYTES_SIZE_TO_BITS (HPAV_MMV_SIZE));
-
- //MMTYPE.
- bitstream_access (&msg->bitstream, &mmtype,
- BYTES_SIZE_TO_BITS (HPAV_MMTYPE_SIZE));
-
- // FMI.
- bitstream_access (&msg->bitstream, &fmi_nbFrag, 4);
- /* frag number. */
- bitstream_access (&msg->bitstream, &fmi_fnmi, 4);
- /* MME ssn. */
- bitstream_access (&msg->bitstream, &fmi_ssn, 8);
-}
-
-/**
- * Initialise a MME handle for a new message fragment to be transmitted.
- * \param ctx control plane context
- * \param peer peer information
- * \param mmtype the MME MMTYPE.
- * \param fmi_nbFrag The number of fragments.
- * \param fmi_fnmi the number of the fragment.
- * \param fmi_ssn the sequence number of the fragment.
- * \return the newly created message
- *
- * This function:
- *
- * - gets a buffer for MME transmission,
- * - encapsulates the MME in a CC_RELAY.REQ if necessary,
- * - writes the MME header.
- */
-cp_mme_tx_t *
-cp_msg_mme_init_frag (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- uint fmi_nbFrag, uint fmi_fnmi, uint fmi_ssn)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (fmi_fnmi <= fmi_nbFrag);
- dbg_assert (fmi_ssn <= fmi_nbFrag);
-
- // Allocate the new message.
- msg = cp_msg_mme_tx_init (ctx);
- dbg_assert (msg);
-
- // Get a buffer.
- msg->p_mme = cp_cl_interf_get_buffer_tx (ctx);
- msg->peer = *peer;
- msg->peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- cp_msg_mme_write_frag_header (ctx, msg, peer, mmtype,
- fmi_nbFrag, fmi_fnmi, fmi_ssn);
-
- return msg;
-}
-
-
-/**
- * Finalise and send a MME.
- * \param ctx control plane context
- * \param mme MME handle
- *
- * If the MME is encapsulated, write any pending footer, then send the
- * message.
- */
-void
-cp_msg_mme_send (cp_t *ctx, cp_mme_tx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- /* Ends the MME. See HPAV table 11-253. */
- if ((mme->peks != CP_MME_PEKS_SPC_NOT_EMBEDDED)
- && (mme->prun.pid != 0x4))
- {
- crc_t crc;
- aes_context aes;
- uint crc_value;
- u32 enc_tab[256];
- uint word;
- uint padding_len;
- uint i;
- uint enc_length;
-
- crc.width = 32;
- crc.generator = HPAV_CRC32_GENERATOR;
- crc.init = HPAV_CRC32_INIT;
- crc.refin = true;
- crc.refout = true;
- crc.xorout = 0xffffffff;
- crc.reg_init = 0;
- crc.table.t32 = enc_tab;
- crc_init(&crc);
-
- /* Patch the length of the MME in the header.
- * 22 Bytes in after the head of the encrypted payload to reach the
- * length field.
- * + The MME header.
- * - 1 for the alignment.
- */
- mme->length = (bitstream_bytes_processed (&mme->bitstream)
- - mme->payload_offset);
- word = *((uint *) (mme->p_mme + (mme->peer.vlan_tag ?
- HPAV_MME_HEADER_LEN_WITH_VLAN:
- HPAV_MME_HEADER)
- + 21));
- word &= 0xFF0000FF;
- word |= mme->length << 8;
- *((uint*)(mme->p_mme + (mme->peer.vlan_tag ?
- HPAV_MME_HEADER_LEN_WITH_VLAN:
- HPAV_MME_HEADER)
- + 21)) = word;
-
-
-
- /* Compute the CRC. */
- crc_value = crc_compute_block_le (&crc,
- mme->p_mme + mme->payload_offset,
- mme->length
- + (mme->peer.vlan_tag ?
- HPAV_MME_HEADER_LEN_WITH_VLAN:
- HPAV_MME_HEADER));
- /* Store the CRC. */
- bitstream_access (&mme->bitstream, &crc_value, 32);
-
- /* PID. */
- bitstream_access (&mme->bitstream, &mme->prun.pid, 8);
-
- /* PRN. */
- bitstream_access (&mme->bitstream, &mme->prun.prn, 16);
-
- /* PMN. */
- bitstream_access (&mme->bitstream, &mme->prun.pmn, 8);
-
- /* Padding. crc_value variable used as Padding. */
- padding_len = 16 - ((mme->length + mme->rf_len
- + CP_MSG_ENCRYPTED_DATA_FOOTER_SIZE) % 16);
-
- word = 0;
- for ( i = 0; i < padding_len; i++)
- bitstream_access (&mme->bitstream, &word, 8);
-
- /* RF Len. */
- bitstream_access (&mme->bitstream, &mme->rf_len, 8);
-
- /* Finalise the bitstream. */
- cp_msg_mme_pad (ctx, mme);
- bitstream_finalise (&mme->bitstream);
-
- /* AES encryption. */
- enc_length = mme->length
- + mme->rf_len
- + CP_MSG_ENCRYPTED_DATA_FOOTER_SIZE
- + padding_len;
-
- aes_set_key (&aes, (u8 *) &mme->iv_uuid);
- aes_cbc_encrypt (&aes, (u8 *) &mme->iv_uuid,
- mme->p_mme + mme->payload_offset - mme->rf_len,
- mme->p_mme + mme->payload_offset - mme->rf_len,
- enc_length);
- }
- else
- {
- /* Finalise the bitstream. */
- cp_msg_mme_pad (ctx, mme);
- bitstream_finalise (&mme->bitstream);
- }
-
- mme->length = bitstream_bytes_processed (&mme->bitstream);
- /* Send the MME. */
- cp_cl_interf_mme_send (ctx, mme);
-
- /* Release the mme. */
- slab_release (mme);
-}
-
-
-/**
- * Read the header of a received MME and return the MME context.
- * \param ctx the module context.
- * \param mme the MME received.
- * \param length the MME length.
- * \param tei the source TEI (0xFF if coming from the HLE).
- * \param fmi the FMI data.
- * \return cp_mme_rx_t object associated.
- */
-cp_mme_rx_t *
-cp_msg_mme_read_header (cp_t *ctx, u8 *mme, uint length, cp_tei_t tei,
- uint *fmi)
-{
- cp_mme_rx_t *mme_rx;
- bool vlantag_present;
- uint mtype;
- uint mmv;
-
- dbg_assert (ctx);
- dbg_assert (mme);
-
- if (read_u16_from_word (mme + 12) == swap16 (HPAV_MTYPE_MME))
- vlantag_present = false;
- else
- vlantag_present = true;
-
- mme_rx = cp_msg_mme_rx_init (ctx, mme, length, tei);
-
- bitstream_init (&mme_rx->bitstream, mme + ETH_MAC_ADDRESS_SIZE,
- length, BITSTREAM_READ);
- bitstream_access (&mme_rx->bitstream, &mme_rx->peer.mac,
- BYTES_SIZE_TO_BITS(ETH_MAC_ADDRESS_SIZE));
- if (vlantag_present)
- bitstream_access (&mme_rx->bitstream, &mme_rx->peer.vlan_tag, 32);
- else
- mme_rx->peer.vlan_tag = 0;
-
- bitstream_access (&mme_rx->bitstream, &mtype, 16);
- bitstream_access (&mme_rx->bitstream, &mmv, 8);
- bitstream_access (&mme_rx->bitstream, &mme_rx->mmtype, 16);
- bitstream_access (&mme_rx->bitstream, fmi, 16);
-
- // Verify some data.
- if ((mmv != HPAV_MMV1) || (swap16(mtype) != HPAV_MTYPE_MME))
- {
- slab_release (mme_rx);
- mme_rx = NULL;
- }
-
- return mme_rx;
-}
-
-/**
- * Read an encrypted header and decrypt the payload.
- * \param ctx the module context.
- * \param mme the mme context.
- * \return true if decoded correctly, false otherwise.
- */
-bool
-cp_msg_mme_read_header_enc (cp_t *ctx, cp_mme_rx_t *mme)
-{
- uint data;
- uint i;
- uint enc_length;
- uint full_length;
- uint payload_offset;
- uint rf_len;
-
- mac_t oda = 0;
- mac_t osa = 0;
- uint vlan_tag = 0;
- uint mtype = 0;
- uint mmv = 0;
-
- aes_context aes;
- cp_sta_own_data_t *owndata;
-
- dbg_assert (ctx);
- dbg_assert (mme);
-
- full_length = mme->length;
- owndata = cp_sta_mgr_get_sta_own_data (ctx);
-
- // Continue reading the MME.
- // PEKS.
- bitstream_access (&mme->bitstream, &mme->peks, 8);
-
- // AVLN STATUS.
- bitstream_access (&mme->bitstream, &data, 8);
-
- // PID.
- bitstream_access (&mme->bitstream, &mme->prun.pid, 8);
-
- // PRN.
- bitstream_access (&mme->bitstream, &mme->prun.prn, 16);
-
- // PMN.
- bitstream_access (&mme->bitstream, &mme->prun.pmn, 8);
-
- // IV.
- for ( i = 0; i < 4; i++)
- {
- bitstream_access (&mme->bitstream, &mme->iv_uuid.key[i], 32);
- }
-
- // Len of the payload.
- bitstream_access (&mme->bitstream, &mme->length, 16);
-
- // Decrypt the buffer.
-
- /* Compute a first payload offset position. The RF is still in contained
- * in this length because the RF length is encrypted. */
- payload_offset = CP_MSG_ENCRYPTED_DATA_HEADER_SIZE
- + (mme->peer.vlan_tag ? HPAV_MME_HEADER_LEN_WITH_VLAN :
- HPAV_MME_HEADER);
-
- enc_length = full_length - payload_offset;
-
- aes_set_key (&aes, (u8 *) &mme->iv_uuid);
- aes_cbc_decrypt (&aes, (u8*) &mme->iv_uuid,
- mme->p_mme + payload_offset,
- mme->p_mme + payload_offset,
- enc_length);
-
- /* The length provided in the mme->length corresponds to the full size of
- * the MME (header included). The RF length is setted to the length - 1
- * bytes. */
- rf_len = read_u8_from_word (mme->p_mme + full_length - 1);
-
-
- // RF.
- for (i = 0; i < rf_len; i++)
- bitstream_access (&mme->bitstream, &data, 8);
-
- /* Payload. */
- // ODA.
- bitstream_access (&mme->bitstream, &oda, 48);
-
- // OSA.
- bitstream_access (&mme->bitstream, &osa, 48);
-
- if (mme->peer.vlan_tag)
- bitstream_access (&mme->bitstream, &vlan_tag, 32);
-
- // MType
- bitstream_access (&mme->bitstream, &mtype, 16);
-
- // MMV
- bitstream_access (&mme->bitstream, &mmv, 8);
-
- if ((mmv != HPAV_MMV1)
- || (mtype != swap16(HPAV_MTYPE_MME))
- || (oda != cp_sta_own_data_get_mac_address (ctx))
- || (osa != mme->peer.mac)
- || (vlan_tag != mme->peer.vlan_tag))
- {
- slab_release (mme);
- return false;
- }
-
- // MMTYPE.
- bitstream_access (&mme->bitstream, &mme->mmtype, 16);
-
- // FMI
- bitstream_access (&mme->bitstream, &data, 16);
-
- return true;
-}
-
-/**
- * Change the current buffer of the reception message.
- * \param ctx the module context.
- * \param msg the message RX to change the buffer.
- *
- * This shall be used only on the RX MMEs which are received as fragmented
- * ones.
- */
-void
-cp_msg_mme_rx_change_buffer (cp_t *ctx, cp_mme_rx_t *msg)
-{
- dbg_assert (ctx);
- dbg_assert (msg);
-
- dbg_assert (msg->p_frag);
- dbg_assert (msg->p_frag_current);
- dbg_assert (msg->p_frag_current->next);
-
- // Change the current pointer to the next one.
- msg->p_frag_current = msg->p_frag_current->next;
-
- bitstream_init (&msg->bitstream, msg->p_frag_current->data, BLK_SIZE,
- BITSTREAM_READ);
-}
-
diff --git a/cesar/cp2/msg/src/msg_cc.c b/cesar/cp2/msg/src/msg_cc.c
deleted file mode 100644
index 207b344486..0000000000
--- a/cesar/cp2/msg/src/msg_cc.c
+++ /dev/null
@@ -1,828 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/src/msg_cc.c
- * \brief CC family MME.
- * \ingroup cp2_msg
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-#include "lib/slab.h"
-
-#include "cp2/cp.h"
-#include "cp2/cl_interf/cl_interf.h"
-#include "cp2/msg/msg.h"
-
-#include "cp2/sta/mgr/net.h"
-#include "cp2/sta/mgr/sta_mgr.h"
-
-#include "cp2/msg/inc/msg_cc.h"
-
-/**
- * Send a CC_WHO_RU.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param nid NID of the requested AVLN
- */
-void
-cp_msg_cc_who_ru_req_send (cp_t *ctx, cp_mme_peer_t *peer, cp_nid_t nid)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (nid);
-
- msg = cp_msg_mme_init (ctx, peer, CC_WHO_RU_REQ);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &nid, 56);
-
- msg->length = 7;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_WHO_RU.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param nid received NID of the requested AVLN
- * \return true on success
- */
-bool
-cp_msg_cc_who_ru_req_receive (cp_t *ctx, cp_mme_rx_t *mme, cp_nid_t *nid)
-{
- cp_net_t *net;
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (nid);
-
- bitstream_access (&mme->bitstream, nid, 56);
-
- net = cp_sta_mgr_get_our_avln (ctx);
- if (*nid != cp_net_get_nid (ctx, net))
- return false;
- return true;
-}
-
-/**
- * Send a CC_WHO_RU.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_who_ru_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_who_ru_cnf_t *data)
-{
- uint i;
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (data);
-
- dbg_assert (data->nid);
- dbg_assert (data->cco_mac);
-
- msg = cp_msg_mme_init (ctx, peer, CC_WHO_RU_CNF);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &data->nid, 56);
- bitstream_access (&msg->bitstream, (mac_t *) &data->cco_mac, 48);
-
- for (i = 0; i < CP_HFID_SIZE; i++)
- bitstream_access (&msg->bitstream, (u8*) &data->avln_hfid[i], 8);
-
- msg->length = 77;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_WHO_RU.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_who_ru_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_who_ru_cnf_t *data)
-{
- uint i;
- cp_net_t *net;
- cp_sta_t *cco;
- cp_sta_own_data_t *own;
-
- mac_t mac;
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- bitstream_access (&mme->bitstream, &data->nid, 56);
- bitstream_access (&mme->bitstream, (mac_t *) &data->cco_mac, 48);
-
- for ( i = 0; i < CP_HFID_SIZE; i++)
- bitstream_access (&mme->bitstream, &data->avln_hfid[i], 8);
-
- own = cp_sta_mgr_get_sta_own_data (ctx);
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if (own->is_cco)
- mac = cp_sta_own_data_get_mac_address (ctx);
- else
- {
- cco = cp_net_get_cco (ctx, net);
- dbg_check (cco);
- mac = cp_sta_get_mac_address (cco);
- }
-
- if ((cp_net_get_nid (ctx, net) != data->nid)
- || mac != data->cco_mac)
- return false;
-
- return true;
-}
-
-/**
- * Send a CC_ASSOC.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_assoc_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_assoc_req_t *data)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (data);
-
- dbg_assert ((data->request_type < CP_MSG_CC_ASSOC_REQ_TYPE_NB)
- || (data->cco_cap < 4)
- || (data->proxy_cap < 2));
-
-
- msg = cp_msg_mme_init (ctx, peer, CC_ASSOC_REQ);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &data->request_type, 8);
- bitstream_access (&msg->bitstream, &data->nid, 56);
- bitstream_access (&msg->bitstream, &data->cco_cap, 8);
- bitstream_access (&msg->bitstream, &data->proxy_cap, 8);
-
- msg->length = 10;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_ASSOC.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_assoc_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_assoc_req_t *data)
-{
- cp_net_t *net;
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- bitstream_access (&mme->bitstream, &data->request_type, 8);
- bitstream_access (&mme->bitstream, &data->nid, 56);
- bitstream_access (&mme->bitstream, &data->cco_cap, 8);
- bitstream_access (&mme->bitstream, &data->proxy_cap, 8);
-
- // Verify the data read.
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((data->request_type >= CP_MSG_CC_ASSOC_REQ_TYPE_NB)
- || (cp_net_get_nid(ctx, net) != data->nid)
- || (data->cco_cap >= 4)
- || (data->proxy_cap >= 2))
- {
- return false;
- }
-
- return true;
-}
-
-/**
- * Send a CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cc_assoc_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- const cp_msg_cc_assoc_cnf_t *data)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (data);
-
- dbg_assert ((data->result < CP_MSG_CC_ASSOC_CNF_RESULT_NB)
- || data->nid
- || data->sta_tei
- || data->lease_time_min);
-
- msg = cp_msg_mme_init (ctx, peer, CC_ASSOC_CNF);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &data->result, 8);
- bitstream_access (&msg->bitstream, &data->nid, 56);
- bitstream_access (&msg->bitstream, &data->snid, 8);
- bitstream_access (&msg->bitstream, &data->sta_tei, 8);
- bitstream_access (&msg->bitstream, &data->lease_time_min, 16);
-
- msg->length = 12;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_ASSOC.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cc_assoc_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cc_assoc_cnf_t *data)
-{
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- bitstream_access (&mme->bitstream, &data->result, 8);
- bitstream_access (&mme->bitstream, &data->nid, 56);
- bitstream_access (&mme->bitstream, &data->snid, 8);
- bitstream_access (&mme->bitstream, &data->sta_tei, 8);
- bitstream_access (&mme->bitstream, &data->lease_time_min, 16);
-
- /* Verify. */
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((cp_net_get_nid (ctx, net) != data->nid)
- || (cp_net_get_snid (ctx, net) != data->snid)
- || (data->result < CP_MSG_CC_ASSOC_CNF_RESULT_NB))
- {
- return false;
- }
-
- return true;
-}
-
-/**
- * Send a CC_LEAVE.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param reason reason for the disassociation
- */
-void
-cp_msg_cc_leave_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_leave_req_reason_t reason)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (reason < CP_MSG_CC_LEAVE_IND_REASON_NB);
-
- msg = cp_msg_mme_init (ctx, peer, CC_LEAVE_REQ);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &reason, 8);
-
- msg->length = 1;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_LEAVE.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param reason received reason for the disassociation
- * \return true on success
- */
-bool
-cp_msg_cc_leave_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_leave_req_reason_t *reason)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (reason);
-
- bitstream_access (&mme->bitstream, reason, 8);
-
-
- if (*reason >= CP_MSG_CC_LEAVE_IND_REASON_NB)
- return false;
- return true;
-}
-
-/**
- * Send a CC_LEAVE.CNF.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_leave_cnf_send (cp_t *ctx, cp_mme_peer_t *peer)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
-
- msg = cp_msg_mme_init (ctx, peer, CC_LEAVE_CNF);
- dbg_check (msg);
-
- msg->length = 0;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_LEAVE.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_leave_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- return true;
-}
-
-/**
- * Send a CC_LEAVE.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param reason reason for the disassociation
- * \param nid NID
- */
-void
-cp_msg_cc_leave_ind_send (cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_leave_ind_reason_t reason,
- cp_nid_t nid)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (reason < CP_MSG_CC_LEAVE_IND_REASON_NB);
- dbg_assert (nid);
-
- msg = cp_msg_mme_init (ctx, peer, CC_LEAVE_IND);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &reason, 8);
- bitstream_access (&msg->bitstream, &nid, 56);
-
- msg->length = 8;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_LEAVE.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param reason received reason for the disassociation
- * \param nid received NID
- * \return true on success
- */
-bool
-cp_msg_cc_leave_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_leave_ind_reason_t *reason,
- cp_nid_t *nid)
-{
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (reason);
- dbg_assert (nid);
-
- bitstream_access (&mme->bitstream, reason, 8);
- bitstream_access (&mme->bitstream, nid, 56);
-
- /* Verify. */
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((cp_net_get_nid (ctx, net) != *nid)
- || (*reason < CP_MSG_CC_LEAVE_IND_REASON_NB))
- {
- return false;
- }
-
- return true;
-}
-
-/**
- * Send a CC_LEAVE.RSP.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_leave_rsp_send (cp_t *ctx, cp_mme_peer_t *peer)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
-
- msg = cp_msg_mme_init (ctx, peer, CC_LEAVE_RSP);
- dbg_check (msg);
-
- msg->length = 0;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_LEAVE.RSP.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_leave_rsp_receive (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- return true;
-}
-
-/**
- * Send a CC_SET_TEI_MAP.REQ.
- * \param ctx control plane context
- * \param peer peer information
- */
-void
-cp_msg_cc_set_tei_map_req_send (cp_t *ctx, cp_mme_peer_t *peer)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
-
- msg = cp_msg_mme_init (ctx, peer, CC_SET_TEI_MAP_REQ);
- dbg_check (msg);
-
- msg->length = 0;
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CC_SET_TEI_MAP.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_req_receive (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- return true;
-}
-
-/** CC_SET_TEI_MAP Function to call when the buffer is full.
- * \param ctx the bitstream context.
- * \param data the structure registered.
- */
-static void
-cp_msg_set_tei_map_send_change_buffer (bitstream_t *ctx,
- cp_msg_cc_set_tei_map_change_buffer_t *data)
-{
- bitstream_t bitstream_old;
- cp_mme_tx_t *msg;
- dbg_assert (ctx);
- dbg_assert (data);
- dbg_assert (data->cp);
- dbg_assert (data->msg);
-
- msg = data->msg;
-
- // Finalise the MME.
- slab_addref (msg);
- cp_msg_mme_send (data->cp, msg);
-
- // Initialise the header of the new buffer.
- msg->p_mme = cp_cl_interf_get_buffer_tx (data->cp);
- bitstream_old = msg->bitstream;
-
- cp_msg_mme_write_frag_header (data->cp, msg, &msg->peer,
- CC_SET_TEI_MAP_IND, data->fmi_nbFrag,
- ++data->fmi_fnmi, ++data->fmi_ssn);
- // Finalise the stream.
- bitstream_finalise (&msg->bitstream);
-
- // Set newly the boolean indicating the buffer change callback is present.
- bitstream_old.start = msg->bitstream.start;
- bitstream_old.stream = msg->bitstream.stream;
- bitstream_old.bit_offset = msg->bitstream.bit_offset;
- msg->bitstream = bitstream_old;
-}
-
-
-/**
- * Begin a CC_SET_TEI_MAP.IND construction.
- * \param ctx control plane context
- * \param peer peer information
- * \param mode update, add or delete
- * \param sta_nb number of stations sent
- * \return the MME being constructed
- */
-cp_mme_tx_t *
-cp_msg_cc_set_tei_map_ind_send_begin (
- cp_t *ctx, cp_mme_peer_t *peer,
- enum cp_msg_cc_set_tei_map_ind_mode_t mode, uint sta_nb)
-{
- cp_mme_tx_t *msg;
- cp_msg_cc_set_tei_map_change_buffer_t *data = NULL;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (mode < CP_MSG_CC_SET_TEI_MAP_IND_MODE_NB);
- dbg_assert (sta_nb);
-
- if (sta_nb * 8 > (peer->vlan_tag ? CP_MME_PAYLOAD_MAX_SIZE_WITH_VLAN :
- CP_MME_PAYLOAD_MAX_SIZE) - 2)
- {
- data = blk_alloc ();
- data->cp = ctx;
- data->fmi_nbFrag = 1;
- data->fmi_fnmi = 0;
- data->fmi_ssn = 0;
-
- msg = cp_msg_mme_init_frag (ctx, peer, CC_SET_TEI_MAP_IND, 1, 0, 0);
- data->msg = msg;
- bitstream_buffer_full_init_cb (&msg->bitstream,
- (bitstream_buffer_cb_t) cp_msg_set_tei_map_send_change_buffer,
- data);
- }
- else
- msg = cp_msg_mme_init (ctx, peer, CC_SET_TEI_MAP_IND);
- dbg_check (msg);
-
- bitstream_access (&msg->bitstream, &mode, 8);
- bitstream_access (&msg->bitstream, &sta_nb, 8);
-
- return msg;
-}
-
-/**
- * Write a station to a CC_SET_TEI_MAP.IND being constructed.
- * \param ctx control plane context
- * \param mme MME being constructed
- * \param tei STA TEI
- * \param mac STA mac address
- * \param status STA status
- */
-void
-cp_msg_cc_set_tei_map_ind_send_sta (
- cp_t *ctx, cp_mme_tx_t *mme, cp_tei_t tei, mac_t mac,
- enum cp_msg_cc_set_tei_map_ind_status_t status)
-{
- dbg_assert (mme);
- dbg_assert (tei);
- dbg_assert (mac);
- dbg_assert (status < CP_MSG_CC_SET_TEI_MAP_IND_STATUS_NB);
-
- bitstream_access (&mme->bitstream, &tei, 8);
- bitstream_access (&mme->bitstream, &mac, 48);
- bitstream_access (&mme->bitstream, &status, 8);
-}
-
-/**
- * Finalise and send a CC_SET_TEI_MAP.IND message.
- * \param ctx control plane context
- * \param mme MME being constructed
- */
-void
-cp_msg_cc_set_tei_map_ind_send_end (cp_t *ctx, cp_mme_tx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- if (mme->bitstream.buffer_cb_present)
- blk_release (mme->bitstream.user_data);
- cp_msg_mme_send (ctx, mme);
-}
-
-/**
- * Change the bitstream buffer for the CC_SET_TEI_MAP.IND reception.
- * \param ctx the bitstream context.
- * \param data the data buffer.
- */
-static void
-cp_msg_cc_set_tei_map_recv_change_buffer (bitstream_t *ctx,
- cp_msg_cc_set_tei_map_change_buffer_t *data)
-{
- cp_mme_rx_t *msg;
- dbg_assert (ctx);
- dbg_assert (data);
- dbg_assert (data->cp);
- dbg_assert (data->msg);
-
- msg = data->msg;
-
- cp_msg_mme_rx_change_buffer (data->cp, msg);
-
- // Set newly the boolean indicating the buffer change callback is present.
- msg->bitstream.buffer_cb_present = true;
-}
-
-/**
- * Begin a CC_SET_TEI_MAP.IND reception.
- * \param ctx control plane context
- * \param mme MME handle
- * \param mode received mode: update, add or delete
- * \param sta_nb received number of STA
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_begin (
- cp_t *ctx, cp_mme_rx_t *mme,
- enum cp_msg_cc_set_tei_map_ind_mode_t *mode, uint *sta_nb)
-{
- cp_msg_cc_set_tei_map_change_buffer_t *data;
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (mode);
- dbg_assert (sta_nb);
-
- if (mme->p_mme == NULL)
- {
- data = blk_alloc ();
- data->msg = mme;
- data->cp = ctx;
- bitstream_buffer_full_init_cb (&mme->bitstream,
- (bitstream_buffer_cb_t)
- cp_msg_cc_set_tei_map_recv_change_buffer,
- data);
- }
-
- bitstream_access (&mme->bitstream, mode, 8);
- bitstream_access (&mme->bitstream, sta_nb, 8);
-
- // Point to the current fragment.
-
- if (*mode >= CP_MSG_CC_SET_TEI_MAP_IND_MODE_NB)
- return false;
- return true;
-}
-
-/**
- * Read a station from a received CC_SET_TEI_MAP.IND.
- * \param ctx control plane context
- * \param mme MME being received
- * \param tei received STA TEI
- * \param mac received STA mac address
- * \param status received STA status
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_sta (
- cp_t *ctx, cp_mme_rx_t *mme, cp_tei_t *tei, mac_t *mac,
- enum cp_msg_cc_set_tei_map_ind_status_t *status)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (tei);
- dbg_assert (mac);
- dbg_assert (status);
-
- bitstream_access (&mme->bitstream, tei, 8);
- bitstream_access (&mme->bitstream, mac, 48);
- bitstream_access (&mme->bitstream, status, 8);
-
- if (*status >= CP_MSG_CC_SET_TEI_MAP_IND_STATUS_NB)
- return false;
- return true;
-}
-
-/**
- * Finalise a CC_SET_TEI_MAP.IND reception.
- * \param ctx control plane context
- * \param mme MME being received
- * \return true on success
- */
-bool
-cp_msg_cc_set_tei_map_ind_receive_end (cp_t *ctx, cp_mme_rx_t *mme)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
-
- return true;
-}
-
-/**
- * Write the header of a CC_RELAY MME.
- * \param ctx the module context.
- * \param peer the peer information.
- * \param mmtype the MMType of the MME CC_RELAY_REQ or CC_RELAY_IND.
- * \param prun if the MME shall be encrypted.
- * \param peks the Payload encryption key select.
- * \param fda the final destination mac address.
- * \param ftei the final TEI.
- */
-cp_mme_tx_t *
-cp_msg_cc_relay_send_begin (cp_t *ctx, cp_mme_peer_t *peer, cp_mmtype_t mmtype,
- const cp_secu_protocol_run_t *prun,
- cp_mme_peks_t peks,
- mac_t fda, cp_tei_t ftei)
-{
- cp_mme_tx_t * msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (fda);
- dbg_assert (ftei);
-
- dbg_assert ((mmtype != CC_RELAY_REQ) || (mmtype != CC_RELAY_IND));
-
- // Get a TX buffer.
- if (peks == CP_MME_PEKS_SPC_NOT_EMBEDDED)
- msg = cp_msg_mme_init (ctx, peer, mmtype);
- else
- msg = cp_msg_mme_init_encrypted (ctx, peer, mmtype, peks, prun);
-
- // Fill the data of the MME.
- bitstream_access (&msg->bitstream, &fda, 48);
- // Fill the TEI of the final destination station.
- bitstream_access (&msg->bitstream, &ftei, 8);
- // Go forward inserting a zero length MME payload length.
- bitstream_write (&msg->bitstream, 0, 16);
-
- return msg;
-}
-
-/**
- * Finalise the MME CC_RELAY.*.
- * \param ctx the module context.
- * \param msg the MME to send.
- * \param length the MME length corresponding (header included).
- *
- * Patch the Length of the MME payload in the MSG CC_RELAY.REQ MME.
- */
-void
-cp_msg_cc_relay_send_finalise (cp_t *ctx, cp_mme_tx_t *msg, uint length)
-{
- uint word;
-
- dbg_assert (ctx);
- dbg_assert (msg);
- dbg_assert (length);
-
- // Get the word containing the length of MME relay payload length field.
- word = *((uint *) (msg->p_mme + (msg->peer.vlan_tag ? 28 : 24)));
- // Add the length to the 16bits MSB in the word.
- word = (word & 0xFFFF) | (length << 16);
- // Store the word at the same address.
- *((uint *) (msg->p_mme + (msg->peer.vlan_tag ? 28 : 24))) = word;
-}
-
-/**
- * Receive a CC_RELAY.*
- * \param ctx the control plane context.
- * \param msg the MME context.
- * \param length the MME payload length contained.
- *
- * Initialise the Relay MME.
- */
-void
-cp_msg_cc_relay_receive (cp_t *ctx, cp_mme_rx_t *msg, uint *length)
-{
- dbg_assert (ctx);
- dbg_assert (msg);
- dbg_assert (length);
-
- // Read the FDA.
- bitstream_access (&msg->bitstream, &msg->relay.mac_fa, 48);
- bitstream_access (&msg->bitstream, &msg->relay.ftei, 8);
- bitstream_access (&msg->bitstream, length, 16);
-}
-
diff --git a/cesar/cp2/msg/src/msg_cm.c b/cesar/cp2/msg/src/msg_cm.c
deleted file mode 100644
index d446a152a0..0000000000
--- a/cesar/cp2/msg/src/msg_cm.c
+++ /dev/null
@@ -1,543 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/src/msg_cm.c
- * \brief CM family MME.
- * \ingroup cp2_msg
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-
-#include "lib/read_word.h"
-
-#include "cp2/cp.h"
-#include "cp2/mme.h"
-#include "cp2/msg/msg.h"
-
-#include "cp2/sta/mgr/net.h"
-#include "cp2/sta/mgr/sta_mgr.h"
-
-#include "cp2/msg/inc/msg_cm.h"
-
-/**
- * Send a CM_UNASSOCIATED_STA.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param nid NID of the transmitting STA
- * \param cco_cap CCo capability of the transmitting STA
- */
-void
-cp_msg_cm_unassociated_sta_ind_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_nid_t nid, u8 cco_cap);
-
-/**
- * Receive a CM_UNASSOCIATED_STA.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param nid received NID of the transmitting STA
- * \param cco_cap received CCo capability of the transmitting STA
- * \return true on success
- */
-bool
-cp_msg_cm_unassociated_sta_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_nid_t *nid, u8 *cco_cap);
-
-/**
- * Access to the data in the buffer.
- * \param stream the stream to access the buffer.
- * \param prun the protocol run.
- * \param data the data.
- */
-static void
-cp_msg_cm_set_key_req_access (bitstream_t *stream,
- cp_secu_protocol_run_t *prun,
- cp_msg_cm_set_key_req_t *data)
-{
- uint i;
-
- dbg_assert (stream);
- dbg_assert (prun);
- dbg_assert (data);
-
- bitstream_access (stream, &data->key_type, 8);
- bitstream_access (stream, &prun->my_nonce, 32);
- bitstream_access (stream, &prun->your_nonce, 32);
- bitstream_access (stream, &prun->pid, 8);
- bitstream_access (stream, &prun->prn, 16);
- bitstream_access (stream, &prun->pmn, 8);
- bitstream_write (stream, CP_CCO_LEVEL, 8);
- bitstream_access (stream, &data->nid, 56);
- bitstream_access (stream, &data->new_eks, 8);
- for (i = 0; i < 4; i ++)
- bitstream_access (stream, &data->new_key.key[i], 32);
-}
-
-/**
- * Get the PID of the CM_SET_KEY.CNF.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_set_key_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
-{
- uint offset;
- uint pid;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED);
-
-
- if (mme->peer.vlan_tag)
- offset = HPAV_MME_HEADER_LEN_WITH_VLAN;
- else
- offset = HPAV_MME_HEADER;
-
- pid = read_u8_from_word (mme->p_mme + offset + 9);
-
- return pid;
-}
-
-/**
- * Send a CM_SET_KEY.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_set_key_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_set_key_req_t *data)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (peer);
- dbg_assert (prun);
- dbg_assert (data);
-
- msg = cp_msg_mme_init_encrypted (ctx, peer, CM_SET_KEY_REQ, peks,
- prun);
- dbg_check (msg);
-
- cp_msg_cm_set_key_req_access (&msg->bitstream,
- (cp_secu_protocol_run_t *) prun,
- (cp_msg_cm_set_key_req_t *) data);
-
- /* request type is HASH Key. */
- /* if (data->key_type == CP_MSG_KEY_HASH_KEY)
- {
- }
- */
-
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CM_SET_KEY.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_set_key_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_set_key_req_t *data)
-{
- cp_net_t *net;
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- cp_msg_cm_set_key_req_access (&mme->bitstream, &mme->prun, data);
- XCH(mme->prun.my_nonce, mme->prun.your_nonce);
-
- /* Verify some data. */
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((cp_net_get_nid (ctx, net) != data->nid)
- || (data->key_type >= CP_MSG_KEY_NB))
- return false;
-
- return true;
-}
-
-/**
- * CM_SET_KEY.CNF access.
- * \param stream the bitstream context.
- * \param prun the protocol run context.
- * \param data the structure to use to read or write the data.
- */
-static void
-cp_msg_cm_set_key_cnf_access (bitstream_t *stream,
- cp_secu_protocol_run_t *prun,
- cp_msg_cm_set_key_cnf_t *data)
-{
- dbg_assert (stream);
- dbg_assert (prun);
- dbg_assert (data);
-
- bitstream_access (stream, &data->result, 8);
- bitstream_access (stream, &prun->my_nonce, 32);
- bitstream_access (stream, &prun->your_nonce, 32);
- bitstream_access (stream, &prun->pid, 8);
- bitstream_access (stream, &prun->prn, 16);
- bitstream_access (stream, &prun->pmn, 8);
- bitstream_access (stream, &data->cco_cap, 8);
-}
-
-/**
- * Send a CM_SET_KEY.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_set_key_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_set_key_cnf_t *data)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (prun);
- dbg_assert (data);
-
- dbg_assert (data->result < CP_MSG_CM_SET_KEY_CNF_RESULT_NB);
-
- msg = cp_msg_mme_init (ctx, peer, CM_SET_KEY_CNF);
- dbg_check (msg);
-
- cp_msg_cm_set_key_cnf_access (&msg->bitstream,
- (cp_secu_protocol_run_t *) prun,
- (cp_msg_cm_set_key_cnf_t *) data);
-
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CM_SET_KEY.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_set_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_set_key_cnf_t *data)
-{
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- cp_msg_cm_set_key_cnf_access (&mme->bitstream,
- &mme->prun,
- data);
- XCH (mme->prun.my_nonce, mme->prun.your_nonce);
-
- /* Verify data. */
- if ((data->result > CP_MSG_CM_SET_KEY_CNF_RESULT_NB)
- || (data->cco_cap >= 0x3))
- return false;
- return false;
-}
-
-/**
- * Get the PID of the CM_GET_KEY.REQ.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_get_key_req_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
-{
- uint offset;
- uint pid;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED);
-
-
- if (mme->peer.vlan_tag)
- offset = HPAV_MME_HEADER_LEN_WITH_VLAN;
- else
- offset = HPAV_MME_HEADER;
-
- pid = read_u8_from_word (mme->p_mme + offset + 13);
-
- return pid;
-}
-
-
-/**
- * CM_GET_KEY.REQ Access.
- * \param stream the bitstream context.
- * \param prun the protocol run context.
- * \param data the structure to use to read or write the data.
- */
-static void
-cp_msg_cm_get_key_req_access (bitstream_t *stream,
- cp_secu_protocol_run_t *prun,
- cp_msg_cm_get_key_req_t *data)
-{
- uint i;
- dbg_assert (stream);
- dbg_assert (prun);
- dbg_assert (data);
-
- bitstream_access (stream, &data->relayed, 8);
- bitstream_access (stream, &data->key_type, 8);
- bitstream_access (stream, &data->nid, 56);
- bitstream_access (stream, &prun->my_nonce, 8);
- bitstream_access (stream, &prun->pid, 8);
- bitstream_access (stream, &prun->prn, 16);
- bitstream_access (stream, &prun->pmn, 8);
-
- if (data->key_type == CP_MSG_KEY_HASH_KEY)
- {
- for (i = 0; i < CP_HASH_KEY_SIZE; i++);
- bitstream_access (stream, &data->hash_key[i], 8);
- }
-}
-
-/**
- * Send a CM_GET_KEY.REQ.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_get_key_req_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_get_key_req_t *data)
-{
- cp_mme_tx_t *mme;
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (prun);
- dbg_assert (data);
-
- dbg_assert (data->key_type < CP_MSG_KEY_NB);
- dbg_assert (data->nid);
-
- mme = cp_msg_mme_init_encrypted (ctx, peer, CM_GET_KEY_REQ, peks,
- prun);
- dbg_check (mme);
-
- cp_msg_cm_get_key_req_access (&mme->bitstream,
- (cp_secu_protocol_run_t *) prun,
- (cp_msg_cm_get_key_req_t *) data);
-
-
- cp_msg_mme_send (ctx, mme);
-}
-
-/**
- * Receive a CM_GET_KEY.REQ.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_get_key_req_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_get_key_req_t *data)
-{
- cp_net_t *net;
- dbg_assert (mme);
- dbg_assert (data);
-
- cp_msg_cm_get_key_req_access (&mme->bitstream,
- &mme->prun,
- data);
- XCH (mme->prun.my_nonce, mme->prun.your_nonce);
-
- /* Verify */
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((cp_net_get_nid (ctx, net) != data->nid)
- || (data->key_type >= CP_MSG_KEY_NB))
- return false;
- return true;
-}
-
-/**
- * CM_GET_KEY_CNF_access.
- * \param stream the bitstream context.
- * \param prun the protocol run context.
- * \param data the structure to use to read or write the data.
- */
-static void
-cp_msg_cm_get_key_cnf_access (bitstream_t *stream,
- cp_secu_protocol_run_t *prun,
- cp_msg_cm_get_key_cnf_t *data)
-{
- uint i;
-
- dbg_assert (stream);
- dbg_assert (prun);
- dbg_assert (data);
-
- bitstream_access (stream, &data->result, 8);
- bitstream_access (stream, &data->key_type, 8);
- bitstream_access (stream, &prun->my_nonce, 32);
- bitstream_access (stream, &prun->your_nonce, 32);
- bitstream_access (stream, &data->nid, 56);
- bitstream_access (stream, &data->eks, 8);
- bitstream_access (stream, &prun->pid, 8);
- bitstream_access (stream, &prun->prn, 16);
- bitstream_access (stream, &prun->pmn, 8);
-
- if (data->key_type == CP_MSG_KEY_HASH_KEY)
- {
- for ( i = 0; i < CP_HASH_KEY_SIZE; i++)
- bitstream_access (stream, &data->hash_key[i], 8);
- }
- else if (data->key_type != CP_MSG_KEY_NONCE_ONLY)
- {
- for ( i = 0; i < sizeof (cp_key_t); i++)
- bitstream_access (stream, &data->hash_key[i], 8);
- }
-}
-
-/**
- * Get the PID of the CM_GET_KEY.CNF.
- * \param ctx the Control plane context.
- * \param mme the MME handle.
- * \return pid the pid of the MME.
- */
-uint
-cp_msg_cm_get_key_cnf_get_pid (cp_t *ctx, cp_mme_rx_t *mme)
-{
- uint offset;
- uint pid;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (mme->peks == CP_MME_PEKS_SPC_NOT_EMBEDDED);
-
-
- if (mme->peer.vlan_tag)
- offset = HPAV_MME_HEADER_LEN_WITH_VLAN;
- else
- offset = HPAV_MME_HEADER;
-
- pid = read_u8_from_word (mme->p_mme + offset + 18);
-
- return pid;
-}
-
-
-/**
- * Send a CM_GET_KEY.CNF.
- * \param ctx control plane context
- * \param peer peer information
- * \param peks payload encryption key select
- * \param prun protocol run information
- * \param data MME data to send
- */
-void
-cp_msg_cm_get_key_cnf_send (cp_t *ctx, cp_mme_peer_t *peer,
- cp_mme_peks_t peks,
- const cp_secu_protocol_run_t *prun,
- const cp_msg_cm_get_key_cnf_t *data)
-{
- cp_mme_tx_t *msg;
-
- dbg_assert (ctx);
- dbg_assert (peer);
- dbg_assert (prun);
- dbg_assert (data);
-
- dbg_assert (data->key_type < CP_MSG_KEY_NB);
-
- msg = cp_msg_mme_init_encrypted (ctx, peer, CM_GET_KEY_CNF, peks, prun);
- dbg_check (msg);
-
- cp_msg_cm_get_key_cnf_access (&msg->bitstream,
- (cp_secu_protocol_run_t *) prun,
- (cp_msg_cm_get_key_cnf_t *) data);
-
-
- cp_msg_mme_send (ctx, msg);
-}
-
-/**
- * Receive a CM_GET_KEY.CNF.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- *
- * Encryption and protocol run information is available in the MME handle.
- */
-bool
-cp_msg_cm_get_key_cnf_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_get_key_cnf_t *data)
-{
- cp_net_t *net;
-
- dbg_assert (ctx);
- dbg_assert (mme);
- dbg_assert (data);
-
- cp_msg_cm_get_key_cnf_access (&mme->bitstream,
- &mme->prun,
- data);
- XCH (mme->prun.my_nonce, mme->prun.your_nonce);
-
- /* Verify data. */
- net = cp_sta_mgr_get_our_avln (ctx);
- dbg_check (net);
-
- if ((cp_net_get_nid (ctx, net) != data->nid)
- || (data->key_type >= CP_MSG_KEY_NB))
- return false;
- return true;
-}
-
-/**
- * Send a CM_MME_ERROR.IND.
- * \param ctx control plane context
- * \param peer peer information
- * \param data MME data to send
- */
-void
-cp_msg_cm_mme_error_ind_send (cp_t *ctx, cp_mme_peer_t *peer_info,
- const cp_msg_cm_mme_error_ind_t *data);
-/**
- * Receive a CM_MME_ERROR.IND.
- * \param ctx control plane context
- * \param mme MME handle
- * \param data received MME data
- * \return true on success
- */
-bool
-cp_msg_cm_mme_error_ind_receive (cp_t *ctx, cp_mme_rx_t *mme,
- cp_msg_cm_mme_error_ind_t *data);
-
-
diff --git a/cesar/cp2/msg/test/Makefile b/cesar/cp2/msg/test/Makefile
deleted file mode 100644
index 291d35f811..0000000000
--- a/cesar/cp2/msg/test/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-BASE = ../../..
-
-INCLUDES = cp2/msg/test/overide/
-
-HOST_PROGRAMS = test-msg-read-header test-msg-cc test-msg-cm test_frag
-
-test-msg-read-header_SOURCES = test-msg-read-header.c interface_stub.c \
- cp_cl_interface_stub.c cl_stub.c fsm_stub.c
-test-msg-read-header_MODULES = lib cp2/msg cp2/secu cp2/sta/mgr
-
-test-msg-cc_SOURCES = msg_cc.c interface_stub.c cl_stub.c fsm_stub.c
-test-msg-cc_MODULES = lib cp2/msg cp2/sta/mgr cp2/secu
-
-test-msg-cm_SOURCES = msg_cm.c interface_stub.c cl_stub.c fsm_stub.c
-test-msg-cm_MODULES = lib cp2/msg cp2/sta/mgr cp2/secu
-
-test_frag_SOURCES = cc_set_tei_map_frag.c interface_stub.c cl_stub.c fsm_stub.c
-test_frag_MODULES = lib cp2/msg cp2/sta/mgr cp2/secu
-
-include $(BASE)/common/make/top.mk
diff --git a/cesar/cp2/msg/test/doc/Makefile b/cesar/cp2/msg/test/doc/Makefile
deleted file mode 100644
index 50006394a5..0000000000
--- a/cesar/cp2/msg/test/doc/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-PAGES = read-header.txt
-
-ODT=$(PAGES:%.txt=%.odt)
-HTML=$(PAGES:%.txt=%.html)
-
-all: $(ODT) $(HTML)
-
-odt: $(ODT)
-
-html: $(HTML)
-
-%.odt: %.txt
- rst2odt.py $< $@
-
-%.html: %.txt
- rst2html $< $@
-
-clean:
- rm -f $(ODT)
- rm -f $(HTML)
diff --git a/cesar/cp2/msg/test/doc/read-header.txt b/cesar/cp2/msg/test/doc/read-header.txt
deleted file mode 100644
index 482609d42b..0000000000
--- a/cesar/cp2/msg/test/doc/read-header.txt
+++ /dev/null
@@ -1,69 +0,0 @@
-MSG read MME header
-===================
-
- MME used for the test with :
-
-* a length of 92 bytes.
-* TEI = 1
-
-+-------+-------------------+-----------------+
-|Name | Value | length (bytes) |
-+-------+-------------------+-----------------+
-|oda | 12:34:56:78:9A:BC | 6 |
-+-------+-------------------+-----------------+
-|osa | 34:56:78:9A:BC:DE | 6 |
-+-------+-------------------+-----------------+
-|[vlan] | 0x12 | 4 |
-+-------+-------------------+-----------------+
-|Mtype | 0x88E1 | 2 |
-+-------+-------------------+-----------------+
-|MMV | 0x1 | 1 |
-+-------+-------------------+-----------------+
-|MMTYPE | 0x3245 | 2 |
-+-------+-------------------+-----------------+
-|FMI | 0x432 | 2 |
-+-------+-------------------+-----------------+
-
-Test 1 : Read a MME with a VLAN tag.
-------------------------------------
-
-The result shall be the following one.
-
-The MME rx object returned shall not be NULL and shall contain:
-
-* p_mme = buffer address containing the MME.
-* mmtype = 0x3245
-* length = 92.
-* peer
-
- * mac = 34:56:78:9A:BC:DE
- * vlan = 0x12
- * tei = 1 (provided in argument).
- * all_sta = false.
-
-Test 2 : Read a MME without a VLAN tag.
----------------------------------------
-
-The result shall be the following one.
-
-The MME rx object returned shall not be NULL and shall contain:
-
-* p_mme = buffer address containing the MME.
-* mmtype = 0x3245
-* length = 92.
-* peer
-
- * mac = 34:56:78:9A:BC:DE
- * vlan = 0
- * tei = 1 (provided in argument).
- * all_sta = false.
-
-Test 3 : Read a MME with the MMV equal to 0
--------------------------------------------
-
-The returned value shall be NULL.
-
-Test 4 : Read the MME with MType different of 0x88E1
-----------------------------------------------------
-
-The returned value shall be NULL.
diff --git a/cesar/cp2/msg/test/overide/cp2/inc/context.h b/cesar/cp2/msg/test/overide/cp2/inc/context.h
deleted file mode 100644
index 526c7efd34..0000000000
--- a/cesar/cp2/msg/test/overide/cp2/inc/context.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef overide_cp2_inc_context_h
-#define overide_cp2_inc_context_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file overide/cp2/inc/context.h
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-#include "lib/rnd.h"
-#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. */
- cp_msg_t msg;
-
- /** 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
deleted file mode 100644
index e1448e37e8..0000000000
--- a/cesar/cp2/msg/test/overide/cp2/sta/core/core.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#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/overide/cp_fsm_defs.h b/cesar/cp2/msg/test/overide/cp_fsm_defs.h
deleted file mode 100644
index c29fa69e19..0000000000
--- a/cesar/cp2/msg/test/overide/cp_fsm_defs.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef overide_cp_fsm_defs_h
-#define overide_cp_fsm_defs_h
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file overide/cp_fsm_defs.h
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-
-struct cp_fsm_transition_t
-{
- uint titi;
-};
-typedef struct cp_fsm_transition_t cp_fsm_transition_t;
-
-enum cp_fsm_event_type_t
-{
- CP_FSM_EVENT_TYPE_all_sta_leaved,
- CP_FSM_EVENT_TYPE_net_list_empty,
- CP_FSM_EVENT_TYPE_snid_conflict
-};
-typedef enum cp_fsm_event_type_t cp_fsm_event_type_t;
-
-struct cp_fsm_branch_t
-{
- uint titi;
-};
-typedef struct cp_fsm_branch_t cp_fsm_branch_t;
-
-#endif /* overide_cp_fsm_defs_h */
diff --git a/cesar/cp2/msg/test/src/cc_set_tei_map_frag.c b/cesar/cp2/msg/test/src/cc_set_tei_map_frag.c
deleted file mode 100644
index 06444463a9..0000000000
--- a/cesar/cp2/msg/test/src/cc_set_tei_map_frag.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/cc_set_tei_map_frag.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-#include "common/defs/ethernet.h"
-#include "lib/test.h"
-#include "lib/swap.h"
-#include "lib/blk.h"
-#include <stdio.h>
-
-#include "cp2/cp.h"
-#include "cp2/inc/context.h"
-#include "cp2/msg/msg.h"
-
-struct mme_header_t
-{
- mac_t oda;
- mac_t osa;
- uint vlan;
- uint mtype;
- uint mmv;
- cp_mmtype_t mmtype;
- uint fmi_inf;
- uint fmi_mi;
- uint fmi_ssn;
-};
-typedef struct mme_header_t mme_header_t;
-
-static u8 buffer_list[3][2048];
-static uint next_buffer = 0;
-static test_t test;
-
-void
-test_case_msg_cc_set_tei_map_frag (void)
-{
- cp_mme_peer_t peer;
- cp_mme_tx_t *mme_tx;
- uint mode;
- uint nb_sta;
- u64 data;
- uint i;
- uint offset;
- cp_t cp;
- bitstream_t stream;
- mme_header_t header;
- mac_config_t mac_config;
- cp_mme_rx_t msg_rx;
-
- mac_t mac;
- cp_tei_t tei;
- uint status;
-
- u8 *buffer1;
- u8 *buffer2;
-
- blk_t *frag_first;
- blk_t *frag_last;
-
- cp.mac_config = &mac_config;
- test_init (test, 0, NULL);
-
- cp_sta_own_data_set_tei (&cp, 0xA);
- cp_sta_own_data_set_mac_address (&cp, 0x123456789ABCull);
- cp_sta_mgr_update_our_avln_nid (&cp, 0x123456789ABCDEFull);
- cp_sta_mgr_update_our_avln_snid (&cp, 0x2);
-
-
- test_case_begin (test, "CC_SET_TEI_MAP.IND : Send");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0x0;
- peer.all_sta = false;
-
- mode = CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD;
- nb_sta = 200;
-
- mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (&cp, &peer, mode, nb_sta);
- // get the first buffer.
- buffer1 = mme_tx->p_mme;
-
- for (i = 0; i < nb_sta; i++)
- {
- cp_msg_cc_set_tei_map_ind_send_sta (&cp, mme_tx, i + 1, i + 1,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED);
- }
- // get the second buffer.
- buffer2 = mme_tx->p_mme;
-
- cp_msg_cc_set_tei_map_ind_send_end (&cp, mme_tx);
-
- bitstream_init (&stream, buffer1, 1518, BITSTREAM_READ);
-
- bitstream_access (&stream, &header.oda, 48);
- bitstream_access (&stream, &header.osa, 48);
- bitstream_access (&stream, &header.mtype, 16);
- header.mtype = swap16 (header.mtype);
- bitstream_access (&stream, &header.mmv, 8);
- bitstream_access (&stream, &header.mmtype, 16);
- bitstream_access (&stream, &header.fmi_inf, 4);
- bitstream_access (&stream, &header.fmi_mi, 4);
- bitstream_access (&stream, &header.fmi_ssn, 8);
-
- test_begin (test, "Verify buffer 1")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != mode, "Wrong mode");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != nb_sta, "Wrong number of entries");
-
- for ( i = 0; bitstream_bytes_processed (&stream) < ETH_PACKET_MAX_SIZE; i++)
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != i + 1, "Wrong TEI");
- bitstream_access (&stream, &data, 48);
- test_fail_if (data != i + 1, "Wrong Mac Address");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED,
- "Wrong status");
- }
- }
- test_end
- bitstream_finalise (&stream);
-
- bitstream_init (&stream, buffer2, 1518, BITSTREAM_READ);
-
- bitstream_access (&stream, &header.oda, 48);
- bitstream_access (&stream, &header.osa, 48);
- bitstream_access (&stream, &header.mtype, 16);
- header.mtype = swap16 (header.mtype);
- bitstream_access (&stream, &header.mmv, 8);
- bitstream_access (&stream, &header.mmtype, 16);
- bitstream_access (&stream, &header.fmi_inf, 4);
- bitstream_access (&stream, &header.fmi_mi, 4);
- bitstream_access (&stream, &header.fmi_ssn, 8);
-
- test_begin (test, "Verify buffer 2")
- {
- bitstream_access (&stream, &data, 48);
- test_fail_if (data != 188, "Wrong mac address");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != 0, "Wrong status");
- for ( i = 0; i < 12; i++)
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != i + 189, "Wrong TEI");
- bitstream_access (&stream, &data, 48);
- test_fail_if (data != i + 189, "Wrong Mac Address");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED,
- "Wrong status");
- }
- }
- test_end
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_SET_TEI_MAP.IND received frag");
- // Store the payload of the first buffer to the blocks.
- frag_first = blk_alloc_desc_range (4, &frag_last);
-
- /* First frag. */
- offset = 19;
- memcpy (frag_first->data, buffer1 + offset, BLK_SIZE);
-
- /* Second frag. */
- offset += BLK_SIZE;
- memcpy (frag_first->next->data, buffer1 + offset, BLK_SIZE);
-
- /* Third frag. */
- offset += BLK_SIZE;
- memcpy (frag_first->next->next->data, buffer1 + offset, 475);
- offset = 19;
- memcpy (frag_first->next->next->data + 475, buffer2 + offset, BLK_SIZE -
- 475);
-
- /* Fourth frag. */
- offset += BLK_SIZE - 475;
- memcpy (frag_first->next->next->next->data, buffer2 + offset, BLK_SIZE);
- frag_last->next = NULL;
-
- msg_rx.p_frag = frag_first;
- msg_rx.p_frag_current = frag_first;
- msg_rx.length = 1600;
- bitstream_init (&msg_rx.bitstream, msg_rx.p_frag->data, 512,
- BITSTREAM_READ);
- cp_msg_cc_set_tei_map_ind_receive_begin (&cp, &msg_rx, &mode, &nb_sta);
-
- test_begin (test, "Verify")
- {
- for (i = 0; i < nb_sta; i++)
- {
- cp_msg_cc_set_tei_map_ind_receive_sta (&cp, &msg_rx, &tei, &mac,
- &status);
- test_fail_if (mac != i + 1, "Wrong mac address");
- test_fail_if (tei != i + 1, "Wrong TEI");
- test_fail_if (status != 0, "Wrong status");
- }
- }
- test_end;
-
- cp_msg_cc_set_tei_map_ind_receive_end (&cp, &msg_rx);
- /* Release the blocks allocated. */
- blk_release_desc_range ((blk_t *) frag_first, (blk_t *) frag_last);
- blk_release (msg_rx.bitstream.user_data);
-}
-
-int
-main (void)
-{
- test_case_msg_cc_set_tei_map_frag ();
-
- test_case_begin (test, "Memory allocation");
- test_begin (test, "memory leaks")
- {
- test_fail_if (blk_check_memory () != true, "Memory leaks");
- }
- test_end;
-
- test_result (test);
- return test_nb_failed (test) == 0 ? 0 : 1;
-}
-
-u8 *
-cp_cl_interf_get_buffer_tx (cp_t *ctx)
-{
- u8 *buffer;
- dbg_assert (ctx);
-
- buffer = buffer_list[next_buffer];
- next_buffer = (next_buffer + 1) % 3;
- return buffer;
-}
-
-void
-cp_cl_interf_add_buffer_tx (cp_t *ctx, u8 * buffer)
-{
-}
-
-/**
- * Send a MME over the PWL or the HLE.
- * \param ctx the module context.
- * \param mme The MME to send.
- *
- */
-void
-cp_cl_interf_mme_send (cp_t *ctx, cp_mme_tx_t * mme)
-{
- dbg_assert (mme);
- mme->p_mme = NULL;
-}
diff --git a/cesar/cp2/msg/test/src/cl_stub.c b/cesar/cp2/msg/test/src/cl_stub.c
deleted file mode 100644
index e9ff2f1556..0000000000
--- a/cesar/cp2/msg/test/src/cl_stub.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* 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"
-#include <string.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);
-
- 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/cp_cl_interface_stub.c b/cesar/cp2/msg/test/src/cp_cl_interface_stub.c
deleted file mode 100644
index bbb364f7fb..0000000000
--- a/cesar/cp2/msg/test/src/cp_cl_interface_stub.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/cp_cl_interface_stub.c
- * \brief CL interface stub functions.
- * \ingroup cp2_msg
- *
- * « long description »
- */
-#include "common/std.h"
-
-#include "cp2/cp.h"
-#include "cp2/msg/msg.h"
-
-static u8 buffer[2048] __attribute__((aligned(2048)));
-
-u8 *
-cp_cl_interf_get_buffer_tx (cp_t *ctx)
-{
- dbg_assert (ctx);
- return buffer;
-}
-
-void
-cp_cl_interf_add_buffer_tx (cp_t *ctx, u8 * buffer)
-{
-}
-
-/**
- * Send a MME over the PWL or the HLE.
- * \param ctx the module context.
- * \param mme The MME to send.
- *
- */
-void
-cp_cl_interf_mme_send (cp_t *ctx, cp_mme_tx_t * mme)
-{
- mme->p_mme = NULL;
-}
diff --git a/cesar/cp2/msg/test/src/fsm_stub.c b/cesar/cp2/msg/test/src/fsm_stub.c
deleted file mode 100644
index a2f607bd1c..0000000000
--- a/cesar/cp2/msg/test/src/fsm_stub.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/fsm_stub.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-#include "cp2/fsm/fsm.h"
-
-static cp_fsm_event_t fsm_event;
-
-cp_fsm_event_t *
-cp_fsm_event_bare_new (cp_t *ctx, cp_fsm_event_type_t type)
-{
- return &fsm_event;
-}
-
-void
-cp_fsm_post (cp_t *ctx, cp_fsm_event_t *event)
-{
-}
diff --git a/cesar/cp2/msg/test/src/interface_stub.c b/cesar/cp2/msg/test/src/interface_stub.c
deleted file mode 100644
index 904b3f1ecb..0000000000
--- a/cesar/cp2/msg/test/src/interface_stub.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/interface_stub.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-
-#include "cp2/cp.h"
-
-/**
- * Inform the Data plane when the MME as been processed by the CP.
- * \param ctx the interface context
- * \param mme_recv the cl data (as a void pointer).
- */
-void
-interface_mme_recv_done (interface_t *ctx, void *mme_recv)
-{
-}
diff --git a/cesar/cp2/msg/test/src/msg_cc.c b/cesar/cp2/msg/test/src/msg_cc.c
deleted file mode 100644
index 370dfde18e..0000000000
--- a/cesar/cp2/msg/test/src/msg_cc.c
+++ /dev/null
@@ -1,646 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/test/src/msg_cc.c
- * \brief Test the MSG_CC Family functions.
- * \ingroup cp2_msg
- *
- */
-#include "common/std.h"
-
-#include "common/defs/ethernet.h"
-#include "common/defs/homeplugAV.h"
-
-#include "lib/test.h"
-#include "lib/swap.h"
-#include "lib/bitstream.h"
-
-#include "cp2/cp.h"
-#include "cp2/msg/msg.h"
-#include "cp2/sta/mgr/sta_mgr.h"
-#include "cp2/sta/mgr/sta_own_data.h"
-
-#include "cp2/inc/context.h"
-#include "cp2/msg/inc/msg.h"
-
-#include "stdio.h"
-
-struct mme_header_t
-{
- mac_t oda;
- mac_t osa;
- uint vlan;
- uint mtype;
- uint mmv;
- cp_mmtype_t mmtype;
- uint fmi_inf;
- uint fmi_mi;
- uint fmi_ssn;
-};
-typedef struct mme_header_t mme_header_t;
-
-static u8 buffer[2048] __attribute__((aligned(2048)));
-cp_t cp;
-mac_config_t mac_config;
-bitstream_t stream;
-mme_header_t header;
-mac_t own_mac_addr = 0x123456789ABCull;
-
-mme_header_t expected;
-test_t test;
-
-static void
-test_read_header (bool vlan_present)
-{
- bitstream_init (&stream, buffer, 1518, BITSTREAM_READ);
-
- bitstream_access (&stream, &header.oda, 48);
- bitstream_access (&stream, &header.osa, 48);
- if (vlan_present)
- bitstream_access (&stream, &header.vlan, 32);
- bitstream_access (&stream, &header.mtype, 16);
- header.mtype = swap16 (header.mtype);
- bitstream_access (&stream, &header.mmv, 8);
- bitstream_access (&stream, &header.mmtype, 16);
- bitstream_access (&stream, &header.fmi_inf, 4);
- bitstream_access (&stream, &header.fmi_mi, 4);
- bitstream_access (&stream, &header.fmi_ssn, 8);
-
- test_begin (test, "Header")
- {
- test_fail_if (header.oda != expected.oda, "Wrong dest mac address");
- test_fail_if (header.osa != expected.osa, "Wrong source mac address");
- test_fail_if (header.mtype != HPAV_MTYPE_MME,
- "Wrong MTYPE");
- test_fail_if (header.mmv != HPAV_MMV, "Wrong source mac address");
- test_fail_if (header.mmtype != expected.mmtype,
- "Wrong MMTYPE");
- test_fail_if (header.fmi_inf != expected.fmi_inf, "Wrong FMI");
- test_fail_if (header.fmi_mi != expected.fmi_mi, "Wrong FMI ni");
- test_fail_if (header.fmi_ssn != expected.fmi_ssn, "Wrong FMI SSN");
- }
- test_end;
-}
-
-void
-test_case_msg_cc_who_ru (void)
-{
- cp_mme_peer_t peer;
- cp_nid_t nid;
- u64 data;
- cp_mme_rx_t *mme;
- cp_msg_cc_who_ru_cnf_t cnf;
- cp_sta_own_data_t *own_data;
- u8 hfid[CP_HFID_SIZE+1];
- uint i;
-
- test_case_begin (test, "CC_WHO_RU.REQ : Send");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- cp_msg_cc_who_ru_req_send (&cp, &peer, nid);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_WHO_RU_REQ;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "NID")
- {
- bitstream_access (&stream, &data, 56);
- test_fail_if (data != nid, "Wrong NID");
- }
- test_end;
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_WHO_RU.REQ : Receive");
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint*) &data);
- cp_msg_cc_who_ru_req_receive (&cp, mme, &data);
-
- test_begin (test, "Verify")
- {
- test_fail_if (nid != data, "Wrong NID");
- }
- test_end;
-
- slab_release (mme);
-
-
- test_case_begin (test, "CC_WHO_RU.CNF : Send");
-
- cnf.nid = nid;
- cnf.cco_mac = own_mac_addr;
- strcpy (cnf.avln_hfid, "Hello world\0");
- cp_msg_cc_who_ru_cnf_send (&cp, &peer, &cnf);
-
- expected.mmtype = CC_WHO_RU_CNF;
- test_read_header (false);
-
- test_begin (test, "verify")
- {
- bitstream_access (&stream, &data, 56);
- test_fail_if (data != nid, "Wrong NID");
- bitstream_access (&stream, &data, 48);
- test_fail_if (data != own_mac_addr, "Wrong Mac @");
-
- for (i = 0; i < CP_HFID_SIZE; i++)
- bitstream_access (&stream, &hfid[i], 8);
-
- data = strcmp ((char *)hfid, "Hello world\0");
- test_fail_if (data != 0, "Wrong HFID");
- }
- test_end;
-
-
- test_case_begin (test, "CC_WHO_RU.CNF : Receive");
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- own_data->is_cco = true;
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint *) &data);
- cp_msg_cc_who_ru_cnf_receive (&cp, mme, &cnf);
-
- test_begin (test, "Verify")
- {
- test_fail_if (mme->mmtype != CC_WHO_RU_CNF, "Wrong MMTYPE");
- test_fail_if (cnf.nid != nid, "Wrong NID");
- test_fail_if (cnf.cco_mac != own_mac_addr, "Wrong mac @");
- data = strcmp (cnf.avln_hfid, "Hello world\0");
- test_fail_if (data != 0, "Wrong HFID");
- }
- test_end;
-
- slab_release (mme);
-}
-
-void
-test_case_msg_cc_assoc (void)
-{
- cp_mme_peer_t peer;
- u64 data;
- cp_nid_t nid;
- cp_snid_t snid;
- cp_mme_rx_t *mme;
- cp_msg_cc_assoc_req_t req;
- cp_msg_cc_assoc_cnf_t cnf;
-
- test_case_begin (test, "CC_ASSOC.REQ : Send");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0x0;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDull;
- snid = 0xf;
-
- req.request_type = CP_MSG_CC_ASSOC_REQ_TYPE_NEW;
- req.nid = nid;
- req.cco_cap = CP_CCO_LEVEL;
- req.proxy_cap = 1;
-
- cp_msg_cc_assoc_req_send (&cp, &peer, &req);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_ASSOC_REQ;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "NID")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
- "Wrong request type");
-
- bitstream_access (&stream, &data, 56);
- test_fail_if (data != nid, "Wrong NID");
-
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != req.cco_cap, "Wrong CCO cap");
-
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != req.proxy_cap, "Wrong Proxy cap");
- }
- test_end;
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_ASSOC.REQ : Receive");
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint *) &data);
- cp_msg_cc_assoc_req_receive (&cp, mme, &req);
-
- test_begin (test, "Verify")
- {
- test_fail_if (mme->mmtype != CC_ASSOC_REQ, "Wrong MMtype");
- test_fail_if (req.request_type != CP_MSG_CC_ASSOC_REQ_TYPE_NEW,
- "Wrong request type");
- test_fail_if (req.nid != nid, "Wrong NID");
- test_fail_if (req.cco_cap != CP_CCO_LEVEL, "Wrong CCO cap");
- test_fail_if (req.proxy_cap != 1, "Wrong proxy type");
- }
- test_end;
-
- slab_release (mme);
-
- test_case_begin (test, "CC_ASSOC.CNF : SEND");
-
- cnf.result = CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS;
- cnf.nid = nid;
- cnf.snid = snid;
- cnf.sta_tei = 0xB;
- cnf.lease_time_min = 10;
-
- cp_msg_cc_assoc_cnf_send (&cp, &peer, &cnf);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_ASSOC_CNF;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "SEND")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
- "Wrong result type");
-
- bitstream_access (&stream, &data, 56);
- test_fail_if (data != nid, "Wrong NID");
-
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != snid, "Wrong SNID");
-
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != cnf.sta_tei, "Wrong TEI");
-
- bitstream_access (&stream, &data, 16);
- test_fail_if (data != cnf.lease_time_min, "Wrong Lease time");
- }
- test_end;
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_ASSOC.CNF : Receive");
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint *) &data);
- cp_msg_cc_assoc_cnf_receive (&cp, mme, &cnf);
-
- test_begin (test, "Verify")
- {
- test_fail_if (mme->mmtype != CC_ASSOC_CNF, "Wrong MMtype");
- test_fail_if (cnf.result != CP_MSG_CC_ASSOC_CNF_RESULT_SUCCESS,
- "Wrong result type");
- test_fail_if (cnf.nid != nid, "Wrong NID");
- test_fail_if (cnf.snid != snid , "Wrong SNID");
- test_fail_if (cnf.sta_tei != 0xB, "Wrong TEI");
- test_fail_if (cnf.lease_time_min != 10, "Wrong lease time");
- }
- test_end;
-
- slab_release (mme);
-}
-
-void
-test_case_msg_cc_leave (void)
-{
- cp_mme_peer_t peer;
- u64 data;
- cp_nid_t nid;
- cp_snid_t snid;
- cp_mme_rx_t *mme;
- uint reason;
-
- test_case_begin (test, "CC_LEAVE.REQ : Send");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0x0;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDull;
- snid = 0xf;
-
- reason = CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED;
- cp_msg_cc_leave_req_send (&cp, &peer, reason);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_LEAVE_REQ;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "Verify")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != reason,
- "Wrong reason type");
- }
- test_end;
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_LEAVE.REQ : Receive");
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint *) &data);
- cp_msg_cc_leave_req_receive (&cp, mme, &reason);
-
- test_begin (test, "Verify")
- {
- test_fail_if (mme->mmtype != CC_LEAVE_REQ, "Wrong MMtype");
- test_fail_if (reason != CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
- "Wrong request type");
- }
- test_end;
-
- slab_release (mme);
-
- test_case_begin (test, "CC_LEAVE.IND : SEND");
-
- cp_msg_cc_leave_ind_send (&cp, &peer, reason, nid);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_LEAVE_IND;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "SEND")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
- "Wrong reason");
-
- bitstream_access (&stream, &data, 56);
- test_fail_if (data != nid, "Wrong NID");
- }
- test_end;
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_LEAVE.IND : Receive");
-
- mme = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint *) &data);
- cp_msg_cc_leave_ind_receive (&cp, mme, &reason, &nid);
-
- test_begin (test, "Verify")
- {
- test_fail_if (mme->mmtype != CC_LEAVE_IND, "Wrong MMtype");
- test_fail_if (reason != CP_MSG_CC_LEAVE_IND_REASON_TEI_LEASE_EXPIRED,
- "Wrong reason type");
- test_fail_if (nid != 0x123456789ABCDull, "Wrong NID");
- }
- test_end;
-
- slab_release (mme);
-}
-
-void
-test_case_msg_cc_set_tei_map (void)
-{
- cp_mme_peer_t peer;
- cp_nid_t nid;
- cp_snid_t snid;
- cp_mme_tx_t *mme_tx;
- cp_mme_rx_t *mme_rx;
- uint mode;
- uint nb_sta;
- u64 data;
- cp_tei_t tei;
- mac_t mac;
- uint status;
-
- test_case_begin (test, "CC_SET_TEI_MAP.IND : Send");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0x0;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDull;
- snid = 0xf;
-
- mode = CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD;
- nb_sta = 1;
-
- mme_tx = cp_msg_cc_set_tei_map_ind_send_begin (&cp, &peer, mode, nb_sta);
- cp_msg_cc_set_tei_map_ind_send_sta (&cp, mme_tx, 0xA, own_mac_addr,
- CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED);
- cp_msg_cc_set_tei_map_ind_send_end (&cp, mme_tx);
-
- expected.oda = peer.mac;
- expected.osa = own_mac_addr;
- expected.mmtype = CC_SET_TEI_MAP_IND;
- expected.fmi_inf = 0;
- expected.fmi_mi = 0;
- expected.fmi_ssn = 0;
-
- test_read_header (false);
- test_begin (test, "Verify")
- {
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != mode, "Wrong mode");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != nb_sta, "Wrong number of entries");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != 0xA, "Wrong TEI");
- bitstream_access (&stream, &data, 48);
- test_fail_if (data != own_mac_addr, "Wrong Mac Address");
- bitstream_access (&stream, &data, 8);
- test_fail_if (data != CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED,
- "Wrong status");
- }
- test_end
- bitstream_finalise (&stream);
-
- test_case_begin (test, "CC_SET_TEI_MAP.IND : Receive");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0x0;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDull;
- snid = 0xf;
-
- mode = CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD;
- nb_sta = 1;
-
- mme_rx = cp_msg_mme_read_header (&cp, buffer, 60, 0xA, (uint*) &data);
- cp_msg_cc_set_tei_map_ind_receive_begin (&cp, mme_rx, &mode,
- &nb_sta);
- cp_msg_cc_set_tei_map_ind_receive_sta (&cp, mme_rx, &tei, &mac, &status);
- cp_msg_cc_set_tei_map_ind_receive_end (&cp, mme_rx);
-
- expected.mmtype = CC_SET_TEI_MAP_IND;
-
- test_read_header (false);
- test_begin (test, "Verify")
- {
- test_fail_if (mode != CP_MSG_CC_SET_TEI_MAP_IND_MODE_ADD,
- "Wrong mode");
- test_fail_if (nb_sta != 1, "Wrong number of entries");
- test_fail_if (tei != 0xA, "Wrong TEI");
- test_fail_if (mac != own_mac_addr, "Wrong Mac Address");
- test_fail_if (status != CP_MSG_CC_SET_TEI_MAP_IND_STATUS_ASSOCIATED,
- "Wrong status");
- }
- test_end
- bitstream_finalise (&stream);
-
- slab_release (mme_rx);
-}
-
-void
-test_case_cc_relay (void)
-{
- cp_mme_peer_t peer;
- cp_nid_t nid;
- cp_secu_protocol_run_t prun;
- cp_mme_tx_t *msg_tx;
- cp_mme_rx_t *msg_rx;
- uint fmi;
- uint length;
-
- test_case_begin (test, "CC_RELAY.REQ");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.prn = 2;
- prun.my_nonce = 0x12;
- prun.your_nonce = 0x13;
-
- msg_tx = cp_msg_cc_relay_req_send_begin (&cp, &peer, &prun,
- CP_MME_PEKS_SPC_NOT_EMBEDDED,
- MAC_BROADCAST, 0xFF);
-
- for (length = 100; length; length --)
- {
- bitstream_access (&msg_tx->bitstream, &length, 8);
- }
- cp_msg_cc_relay_send_finalise (&cp, msg_tx, 100);
- cp_msg_mme_send (&cp, msg_tx);
-
- msg_rx = cp_msg_mme_read_header (&cp, buffer, 100 + 19, 0x0, &fmi);
- cp_msg_cc_relay_receive (&cp, msg_rx, &length);
-
- test_begin (test, "verify")
- {
- test_fail_if (msg_rx->mmtype != CC_RELAY_REQ, "Wrong MME Type");
- test_fail_if (length != 100, "Wrong length");
- test_fail_if (msg_rx->relay.mac_fa != MAC_BROADCAST,
- "Wrong mac address");
- test_fail_if (msg_rx->relay.ftei != 0xFF, "Wrong FTEI");
- }
- test_end;
-
- peer = msg_tx->peer;
- slab_release (msg_tx);
-
- test_case_begin (test, "CC_RELAY.IND");
- msg_tx = cp_msg_cc_relay_ind_send_begin (&cp, &peer, &prun,
- CP_MME_PEKS_SPC_NOT_EMBEDDED,
- 0x3456789ABCDEull,
- 0x3);
- for (length = 102; length; length --)
- {
- bitstream_access (&msg_tx->bitstream, &length, 8);
- }
- cp_msg_cc_relay_send_finalise (&cp, msg_tx, 102);
- cp_msg_mme_send (&cp, msg_tx);
-
- msg_rx = cp_msg_mme_read_header (&cp, buffer, 102 + 19, 0x0, &fmi);
- cp_msg_cc_relay_receive (&cp, msg_rx, &length);
-
- test_begin (test, "verify")
- {
- test_fail_if (msg_rx->mmtype != CC_RELAY_IND, "Wrong MME Type");
- test_fail_if (length != 102, "Wrong length");
- test_fail_if (msg_rx->relay.mac_fa != 0x3456789ABCDEull,
- "Wrong mac address");
- test_fail_if (msg_rx->relay.ftei != 0x3, "Wrong FTEI");
- }
- test_end;
-
- slab_release (msg_tx);
-}
-
-int
-main (void)
-{
- cp_sta_own_data_t *own_data;
-
- cp.mac_config = &mac_config;
- test_init (test, 0, NULL);
-
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_tei (&cp, 0xA);
- cp_sta_own_data_set_mac_address (&cp, own_mac_addr);
- cp_sta_mgr_update_our_avln_nid (&cp, 0x123456789ABCDEFull);
- cp_sta_mgr_update_our_avln_snid (&cp, 0x2);
-
- test_case_msg_cc_who_ru ();
- test_case_msg_cc_assoc ();
- test_case_msg_cc_leave ();
- test_case_msg_cc_set_tei_map ();
- test_case_cc_relay ();
-
- test_case_begin (test, "Memory allocation");
- test_begin (test, "memory leaks")
- {
- test_fail_if (blk_check_memory () != true, "Memory leaks");
- }
- test_end;
-
- test_result (test);
- return test_nb_failed (test) == 0 ? 0 : 1;
-}
-
-u8 *
-cp_cl_interf_get_buffer_tx (cp_t *ctx)
-{
- dbg_assert (ctx);
- return buffer;
-}
-
-void
-cp_cl_interf_add_buffer_tx (cp_t *ctx, u8 * buffer)
-{
-}
-
-/**
- * Send a MME over the PWL or the HLE.
- * \param ctx the module context.
- * \param mme The MME to send.
- *
- */
-void
-cp_cl_interf_mme_send (cp_t *ctx, cp_mme_tx_t * mme)
-{
- mme->p_mme = NULL;
-}
diff --git a/cesar/cp2/msg/test/src/msg_cm.c b/cesar/cp2/msg/test/src/msg_cm.c
deleted file mode 100644
index 221c54b929..0000000000
--- a/cesar/cp2/msg/test/src/msg_cm.c
+++ /dev/null
@@ -1,634 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file cp2/msg/test/src/msg_cm.c
- * \brief Test the MSG_CM Family functions.
- * \ingroup cp2_msg
- *
- */
-#include "common/std.h"
-
-#include "common/defs/ethernet.h"
-#include "common/defs/homeplugAV.h"
-
-#include "lib/test.h"
-#include "lib/swap.h"
-#include "lib/bitstream.h"
-
-#include "cp2/cp.h"
-#include "cp2/msg/msg.h"
-#include "cp2/sta/mgr/sta_mgr.h"
-#include "cp2/sta/mgr/sta_own_data.h"
-
-#include "cp2/inc/context.h"
-#include "cp2/msg/inc/msg.h"
-
-struct mme_header_t
-{
- mac_t oda;
- mac_t osa;
- uint vlan;
- uint mtype;
- uint mmv;
- cp_mmtype_t mmtype;
- uint fmi_inf;
- uint fmi_mi;
- uint fmi_ssn;
-};
-typedef struct mme_header_t mme_header_t;
-
-static u8 buffer[2048] __attribute__((aligned(2048)));
-static uint buffer_len;
-cp_t cp;
-mac_config_t mac_config;
-bitstream_t stream;
-mme_header_t header;
-mac_t own_mac_addr = 0x123456789ABCull;
-
-mme_header_t expected;
-test_t test;
-
-void
-test_case_cm_set_key (void)
-{
- cp_mme_peer_t peer;
- cp_nid_t nid;
- cp_secu_protocol_run_t prun;
- cp_msg_cm_set_key_req_t key_req;
- cp_msg_cm_set_key_cnf_t key_cnf;
- cp_mme_rx_t *msg;
- uint fmi;
- cp_sta_own_data_t *own_data;
-
- test_case_begin (test, "CM_SET_KEY.REQ");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.prn = 2;
- prun.my_nonce = 0x12;
- prun.your_nonce = 0x13;
-
- key_req.key_type = CP_MSG_KEY_DAK;
- key_req.cco_cap = CP_CCO_LEVEL;
- key_req.new_eks = 2;
- key_req.new_key.key[0] = 0;
- key_req.new_key.key[1] = 1;
- key_req.new_key.key[2] = 2;
- key_req.new_key.key[3] = 3;
- key_req.nid = nid;
-
- cp_msg_cm_set_key_req_send (&cp, &peer, 2, &prun, &key_req);
-
- // Read the MME.
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (&cp, peer.mac);
-
- msg = cp_msg_mme_read_header (&cp, (u8*)buffer, buffer_len, 0xa, &fmi);
- cp_msg_mme_read_header_enc (&cp, msg);
-
- cp_msg_cm_set_key_req_receive (&cp, msg, &key_req);
- test_begin (test, "Verify")
- {
- test_fail_if (key_req.key_type != CP_MSG_KEY_DAK, "Wrong key type");
- test_fail_if (key_req.cco_cap != CP_CCO_LEVEL, "Wrong CCo level");
- test_fail_if (key_req.nid != nid, "Wrong NID");
- test_fail_if (msg->prun.pid != prun.pid, "Wrong PID");
- test_fail_if (msg->prun.prn != prun.prn, "Wrong PRN");
- test_fail_if (msg->prun.pmn != prun.pmn, "Wrong PMN");
- test_fail_if (msg->prun.your_nonce != prun.my_nonce , "Wrong nonce");
- }
- test_end;
-
- slab_release (msg);
-
- test_case_begin (test, "CM_SET_KEY.CNF");
-
- cp_sta_own_data_set_mac_address (&cp, own_mac_addr);
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.prn = 2;
- prun.my_nonce = 0x12;
- prun.your_nonce = 0x13;
-
- key_cnf.result = CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS;
- key_cnf.cco_cap = CP_CCO_LEVEL;
-
- cp_msg_cm_set_key_cnf_send (&cp, &peer, 2, &prun, &key_cnf);
-
- // Read the MME.
- cp_sta_own_data_set_mac_address (&cp, peer.mac);
-
- msg = cp_msg_mme_read_header (&cp, (u8*)buffer, buffer_len, 0xa, &fmi);
-
- cp_msg_cm_set_key_cnf_receive (&cp, msg, &key_cnf);
- test_begin (test, "Verify")
- {
- test_fail_if (key_cnf.result != CP_MSG_CM_SET_KEY_CNF_RESULT_SUCCESS,
- "Wrong result type");
- test_fail_if (key_cnf.cco_cap != CP_CCO_LEVEL, "Wrong CCo level");
- test_fail_if (msg->prun.pid != prun.pid, "Wrong PID");
- test_fail_if (msg->prun.prn != prun.prn, "Wrong PRN");
- test_fail_if (msg->prun.pmn != prun.pmn, "Wrong PMN");
- test_fail_if (msg->prun.your_nonce != prun.my_nonce , "Wrong nonce");
- }
- test_end;
-
- slab_release (msg);
-}
-
-void
-test_case_cm_get_key (void)
-{
- cp_mme_peer_t peer;
- cp_nid_t nid;
- cp_secu_protocol_run_t prun;
- cp_mme_rx_t *msg;
- uint fmi;
- cp_sta_own_data_t *own_data;
- cp_msg_cm_get_key_req_t data;
- cp_msg_cm_get_key_cnf_t cnf;
-
- test_case_begin (test, "CM_SET_GET_KEY.REQ");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.prn = 2;
- prun.my_nonce = 0x12;
- prun.your_nonce = 0x13;
-
- data.relayed = false;
- data.key_type = CP_MSG_KEY_DAK;
- data.nid = nid;
-
- cp_msg_cm_get_key_req_send (&cp, &peer, 2, &prun, &data);
-
- // Read the MME.
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (&cp, peer.mac);
-
- msg = cp_msg_mme_read_header (&cp, (u8*)buffer, buffer_len, 0xa, &fmi);
- cp_msg_mme_read_header_enc (&cp, msg);
-
- cp_msg_cm_get_key_req_receive (&cp, msg, &data);
- test_begin (test, "Verify")
- {
- test_fail_if (data.relayed != false, "Wrong relayed data");
- test_fail_if (data.key_type != CP_MSG_KEY_DAK, "Wrong key type");
- test_fail_if (data.nid != nid, "Wrong NID");
- test_fail_if (msg->prun.pid != prun.pid, "Wrong PID");
- test_fail_if (msg->prun.prn != prun.prn, "Wrong PRN");
- test_fail_if (msg->prun.pmn != prun.pmn, "Wrong PMN");
- test_fail_if (msg->prun.your_nonce != prun.my_nonce , "Wrong nonce");
- }
- test_end;
-
- slab_release (msg);
-
- test_case_begin (test, "CM_SET_GET_KEY.CNF");
-
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x0;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- nid = 0x123456789ABCDEull;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.prn = 2;
- prun.my_nonce = 0x12;
- prun.your_nonce = 0x13;
-
- cnf.result = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- cnf.key_type = CP_MSG_KEY_DAK;
- cnf.nid = nid;
- cnf.eks = 2;
- cnf.key.key[0] = 0;
- cnf.key.key[1] = 1;
- cnf.key.key[2] = 2;
- cnf.key.key[3] = 3;
-
- cp_msg_cm_get_key_cnf_send (&cp, &peer, 2, &prun, &cnf);
-
- // Read the MME.
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (&cp, peer.mac);
-
- msg = cp_msg_mme_read_header (&cp, (u8*)buffer, buffer_len, 0xa, &fmi);
- cp_msg_mme_read_header_enc (&cp, msg);
-
- cp_msg_cm_get_key_cnf_receive (&cp, msg, &cnf);
- test_begin (test, "Verify")
- {
- test_fail_if (cnf.result != CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED,
- "Wrong result data");
- test_fail_if (cnf.key_type != CP_MSG_KEY_DAK, "Wrong key type");
- test_fail_if (cnf.nid != nid, "Wrong NID");
- test_fail_if (cnf.eks != 2, "Wrong EKS");
- test_fail_if (cnf.key.key[0] != 0, "Wrong Key 0");
- test_fail_if (cnf.key.key[1] != 1, "Wrong Key 1");
- test_fail_if (cnf.key.key[2] != 2, "Wrong Key 2");
- test_fail_if (cnf.key.key[3] != 3, "Wrong Key 3");
- test_fail_if (msg->prun.pid != prun.pid, "Wrong PID");
- test_fail_if (msg->prun.prn != prun.prn, "Wrong PRN");
- test_fail_if (msg->prun.pmn != prun.pmn, "Wrong PMN");
- test_fail_if (msg->prun.your_nonce != prun.my_nonce , "Wrong nonce");
- }
- test_end;
-
- slab_release (msg);
-}
-
-void
-test_case_cm_get_key_get_pid (void)
-{
- bitstream_t bitstream;
- cp_mme_rx_t mme_rx;
- u8 buffer[1024];
- u64 data;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_REQ;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Request type. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* Requested key type. */
- data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- bitstream_access (&bitstream, &data, 8);
- /* NID. */
- data = 0x123456789ABCDEFull;
- bitstream_access (&bitstream, &data, 56);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* PID. */
- data = 0x2;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_case_begin (test, "Get PID");
-
- test_begin (test, "PID = 0x2")
- {
- test_fail_if (cp_msg_cm_get_key_req_get_pid (&cp, &mme_rx) != 0x2);
- }
- test_end;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_REQ;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Request type. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* Requested key type. */
- data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- bitstream_access (&bitstream, &data, 8);
- /* NID. */
- data = 0x123456789ABCDEFull;
- bitstream_access (&bitstream, &data, 56);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* PID. */
- data = 0x3;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_begin (test, "PID = 0x3")
- {
- test_fail_if (cp_msg_cm_get_key_req_get_pid (&cp, &mme_rx) != 0x3);
- }
- test_end;
-
-}
-
-void
-test_case_cm_get_key_cnf_get_pid (void)
-{
- bitstream_t bitstream;
- cp_mme_rx_t mme_rx;
- u8 buffer[1024];
- u64 data;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_CNF;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Result. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* Requested key type. */
- data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- bitstream_access (&bitstream, &data, 8);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* your nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* NID. */
- data = 0x123456789ABCDEFull;
- bitstream_access (&bitstream, &data, 56);
- /* EKS. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* PID. */
- data = 0x2;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_case_begin (test, "Get PID");
-
- test_begin (test, "PID = 0x2")
- {
- test_fail_if (cp_msg_cm_get_key_cnf_get_pid (&cp, &mme_rx) != 0x2);
- }
- test_end;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_CNF;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Result. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* Requested key type. */
- data = CP_MSG_CM_GET_KEY_CNF_RESULT_KEY_GRANTED;
- bitstream_access (&bitstream, &data, 8);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* your nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* NID. */
- data = 0x123456789ABCDEFull;
- bitstream_access (&bitstream, &data, 56);
- /* EKS. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* PID. */
- data = 0x3;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_begin (test, "PID = 0x3")
- {
- test_fail_if (cp_msg_cm_get_key_cnf_get_pid (&cp, &mme_rx) != 0x3);
- }
- test_end;
-}
-
-void
-test_case_cm_set_key_get_pid (void)
-{
- bitstream_t bitstream;
- cp_mme_rx_t mme_rx;
- u8 buffer[1024];
- u64 data;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_CNF;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Result. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* your nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* PID. */
- data = 0x2;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_case_begin (test, "Get PID");
-
- test_begin (test, "PID = 0x2")
- {
- test_fail_if (cp_msg_cm_set_key_get_pid (&cp, &mme_rx) != 0x2);
- }
- test_end;
-
- bitstream_init (&bitstream, buffer, 60, BITSTREAM_WRITE);
- /* ODA. */
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- /* OSA. */
- data = 0x23456789ABCDull;
- bitstream_access (&bitstream, &data, 48);
- /* Mtype. */
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- /* MMV. */
- data = HPAV_MMV;
- bitstream_access (&bitstream, &data, 8);
- /* MMTYPE. */
- data = CM_GET_KEY_CNF;
- bitstream_access (&bitstream, &data, 16);
- /* FMI. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 16);
- /* Result. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 8);
- /* my nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* your nonce. */
- data = 0x0;
- bitstream_access (&bitstream, &data, 32);
- /* PID. */
- data = 0x3;
- bitstream_access (&bitstream, &data, 8);
- bitstream_finalise (&bitstream);
-
- mme_rx.p_mme = buffer;
- mme_rx.peks = CP_MME_PEKS_SPC_NOT_EMBEDDED;
-
- test_begin (test, "PID = 0x3")
- {
- test_fail_if (cp_msg_cm_set_key_get_pid (&cp, &mme_rx) != 0x3);
- }
- test_end;
-}
-
-int
-main (void)
-{
- cp_sta_own_data_t *own_data;
-
- cp.mac_config = &mac_config;
- test_init (test, 0, NULL);
-
- own_data = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_tei (&cp, 0xA);
- cp_sta_own_data_set_mac_address (&cp, own_mac_addr);
- cp_sta_mgr_update_our_avln_nid (&cp, 0x123456789ABCDEFull);
- cp_sta_mgr_update_our_avln_snid (&cp, 0x2);
-
- lib_rnd_init (&cp.rnd, 0x12345678);
-
- test_case_cm_set_key ();
- test_case_cm_get_key ();
- test_case_cm_get_key_get_pid ();
- test_case_cm_get_key_cnf_get_pid ();
- test_case_cm_set_key_get_pid ();
-
- test_case_begin (test, "Memory allocation");
- test_begin (test, "memory leaks")
- {
- test_fail_if (blk_check_memory () != true, "Memory leaks");
- }
- test_end;
-
- test_result (test);
- return test_nb_failed (test) == 0 ? 0 : 1;
-}
-
-u8 *
-cp_cl_interf_get_buffer_tx (cp_t *ctx)
-{
- dbg_assert (ctx);
- return buffer;
-}
-
-void
-cp_cl_interf_add_buffer_tx (cp_t *ctx, u8 * buffer)
-{
-}
-
-/**
- * Send a MME over the PWL or the HLE.
- * \param ctx the module context.
- * \param mme The MME to send.
- *
- */
-void
-cp_cl_interf_mme_send (cp_t *ctx, cp_mme_tx_t * mme)
-{
- buffer_len = mme->length;
- mme->p_mme = NULL;
-}
diff --git a/cesar/cp2/msg/test/src/sta_mgr_stub.c b/cesar/cp2/msg/test/src/sta_mgr_stub.c
deleted file mode 100644
index e587393d9b..0000000000
--- a/cesar/cp2/msg/test/src/sta_mgr_stub.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/sta_mgr_stub.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#include "common/std.h"
-
-#include "cp2/sta/mgr/sta_own_data.h"
-#include "cp2/sta/mgr/inc/sta_own_data.h"
-
-static cp_sta_own_data_private_t own;
-
-/**
- * Returns a reference on our own station data.
- * \param ctx the module context.
- * \return A reference on the sta own data. Do not release It it not a block.
- */
-cp_sta_own_data_t *
-cp_sta_mgr_get_sta_own_data (cp_t *ctx)
-{
- dbg_assert (ctx);
-
- return (cp_sta_own_data_t *) &own;
-}
-
-/**
- * Get the station mac address.
- * \param ctx the module context.
- * \return Get the station Mac address.
- *
- */
-mac_t
-cp_sta_own_data_get_mac_address (cp_sta_own_data_t *ctx)
-{
- dbg_assert (ctx);
- return ((cp_sta_own_data_private_t *) ctx)->mac_addr;
-}
-
-/**
- * Set the station Mac address.
- * \param ctx the module context.
- * \param mac_addr The Mac address of the station.
- * \param cp The control plane context.
- *
- */
-void
-cp_sta_own_data_set_mac_address (cp_sta_own_data_t *ctx,
- mac_t mac_addr, cp_t * cp)
-{
- dbg_assert (ctx);
- ((cp_sta_own_data_private_t *) ctx)->mac_addr = mac_addr;
-}
-
-cp_tei_t
-cp_sta_own_data_get_tei (cp_sta_own_data_t *ctx)
-{
- return 0xA;
-}
diff --git a/cesar/cp2/msg/test/src/test-msg-read-header.c b/cesar/cp2/msg/test/src/test-msg-read-header.c
deleted file mode 100644
index 484a148f46..0000000000
--- a/cesar/cp2/msg/test/src/test-msg-read-header.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file test/src/test-msg.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * http://pessac/cesar/trac/wiki/UT-CPM1-MSG-MSG
- */
-#include "common/std.h"
-#include "common/defs/homeplugAV.h"
-
-#include "lib/bitstream.h"
-#include "lib/test.h"
-#include "lib/swap.h"
-
-#include "cp2/cp.h"
-#include "cp2/msg/msg.h"
-
-#include "cp2/inc/context.h"
-
-/**
- * Test the msg_read header function with a MME containing a VLAN Tag.
- * \param test the test object.
- */
-void
-test_case_msg_read_header_mme_without_vlan (test_t test)
-{
- cp_t cp;
- bitstream_t bitstream;
- u8 buffer[256] __attribute__((aligned(256)));
- uint fmi;
- cp_mme_rx_t *mme;
-
- u64 data;
-
- cp_msg_init (&cp);
-
- test_case_begin (test, "TEST 1");
-
- bitstream_init (&bitstream, buffer, 23, BITSTREAM_WRITE);
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- data = 0x3456789ABCDEull;
- bitstream_access (&bitstream, &data, 48);
- data = 0x12;
- bitstream_access (&bitstream, &data, 32);
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- data = 1;
- bitstream_access (&bitstream, &data, 8);
- data = 0x3245;
- bitstream_access (&bitstream, &data, 16);
- data = 0x432;
- bitstream_access (&bitstream, &data, 16);
- bitstream_finalise (&bitstream);
-
- mme = cp_msg_mme_read_header (&cp, buffer, 92, 0x1, &fmi);
-
- test_begin (test, "Read a MME with vlan")
- {
- test_fail_if (mme->p_mme != buffer, "Wrong buffer address");
- test_fail_if (mme->length != 92, "Wrong length");
- test_fail_if (mme->mmtype != 0x3245, "Wrong MMTYPE");
- test_fail_if (mme->peer.mac != 0x3456789ABCDEull,
- "Wrong mac address");
- test_fail_if (mme->peer.tei != 1, "wrong TEI");
- test_fail_if (mme->peer.vlan_tag != 0x12, "Wrong VLAN tag");
- test_fail_if (mme->peer.all_sta != false, "all_sta shall be false");
- test_fail_if (fmi != 0x432, "wrong FMI value");
- }
- test_end;
- slab_release (mme);
-
- test_case_begin (test, "TEST 2");
-
- bitstream_init (&bitstream, buffer, 19, BITSTREAM_WRITE);
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- data = 0x3456789ABCDEull;
- bitstream_access (&bitstream, &data, 48);
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- data = 1;
- bitstream_access (&bitstream, &data, 8);
- data = 0x3245;
- bitstream_access (&bitstream, &data, 16);
- data = 0x432;
- bitstream_access (&bitstream, &data, 16);
- bitstream_finalise (&bitstream);
-
- mme = cp_msg_mme_read_header (&cp, buffer, 92, 0x1, &fmi);
-
- test_begin (test, "Read a MME without vlan")
- {
- test_fail_if (mme->p_mme != buffer, "Wrong buffer address");
- test_fail_if (mme->length != 92, "Wrong length");
- test_fail_if (mme->mmtype != 0x3245, "Wrong MMTYPE");
- test_fail_if (mme->peer.mac != 0x3456789ABCDEull,
- "Wrong mac address");
- test_fail_if (mme->peer.tei != 1, "wrong TEI");
- test_fail_if (mme->peer.vlan_tag != 0, "Wrong VLAN tag");
- test_fail_if (mme->peer.all_sta != false, "all_sta shall be false");
- test_fail_if (fmi != 0x432, "wrong FMI value");
- }
- test_end;
- slab_release (mme);
-
- test_case_begin (test, "TEST 3");
-
- bitstream_init (&bitstream, buffer, 23, BITSTREAM_WRITE);
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- data = 0x3456789ABCDEull;
- bitstream_access (&bitstream, &data, 48);
- data = swap16(HPAV_MTYPE_MME);
- bitstream_access (&bitstream, &data, 16);
- data = 0;
- bitstream_access (&bitstream, &data, 8);
- data = 0x3245;
- bitstream_access (&bitstream, &data, 16);
- data = 0x432;
- bitstream_access (&bitstream, &data, 16);
- bitstream_finalise (&bitstream);
-
- mme = cp_msg_mme_read_header (&cp, buffer, 92, 0x1, &fmi);
-
- test_begin (test, "Read a MME without vlan")
- {
- test_fail_if (mme != NULL, "Shall be null");
- }
- test_end;
-
- test_case_begin (test, "TEST 4");
-
- bitstream_init (&bitstream, buffer, 23, BITSTREAM_WRITE);
- data = 0x123456789ABCull;
- bitstream_access (&bitstream, &data, 48);
- data = 0x3456789ABCDEull;
- bitstream_access (&bitstream, &data, 48);
- data = swap16(HPAV_MTYPE_MME + 1);
- bitstream_access (&bitstream, &data, 16);
- data = 1;
- bitstream_access (&bitstream, &data, 8);
- data = 0x3245;
- bitstream_access (&bitstream, &data, 16);
- data = 0x432;
- bitstream_access (&bitstream, &data, 16);
- bitstream_finalise (&bitstream);
-
- mme = cp_msg_mme_read_header (&cp, buffer, 92, 0x1, &fmi);
-
- test_begin (test, "Read a MME without vlan")
- {
- test_fail_if (mme != NULL, "Shall be null");
- }
- test_end;
-
- cp_msg_uninit (&cp);
-}
-
-int
-main (void)
-{
- test_t test;
- test_init (test, 0, NULL);
-
- test_case_msg_read_header_mme_without_vlan (test);
-
- test_case_begin (test, "Memory allocation");
- test_begin (test, "memory leaks")
- {
- test_fail_if (blk_check_memory () != true, "Memory leaks");
- }
- test_end;
-
- test_result (test);
- return test_nb_failed (test) == 0 ? 0 : 1;
-}