summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authorlaranjeiro2008-06-27 15:15:08 +0000
committerlaranjeiro2008-06-27 15:15:08 +0000
commitad0e52cf18675c774d0aadc38aa379133e7be808 (patch)
treebe8004486c848eefa16b0516c80747586d370d00 /cesar
parent0a431db1a91ab3b8b85912bc9511f5271f38275d (diff)
cp2/msg : remove an useless test.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2470 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/common/tests/tests1
-rw-r--r--cesar/cp2/msg/test/Makefile6
-rw-r--r--cesar/cp2/msg/test/src/test-msg.c747
3 files changed, 1 insertions, 753 deletions
diff --git a/cesar/common/tests/tests b/cesar/common/tests/tests
index 3985f538a4..0a22bfbb20 100644
--- a/cesar/common/tests/tests
+++ b/cesar/common/tests/tests
@@ -361,7 +361,6 @@ sta_recv: ./obj/sta_recv_cb.elf
cp2/msg/test:
make: make COV=y
read-header: ./obj/test-msg-read-header
-msg: ./obj/test-msg
cc-msg: ./obj/test-msg-cc
cm-msg: ./obj/test-msg-cm
diff --git a/cesar/cp2/msg/test/Makefile b/cesar/cp2/msg/test/Makefile
index 34083f11a4..4a4e584110 100644
--- a/cesar/cp2/msg/test/Makefile
+++ b/cesar/cp2/msg/test/Makefile
@@ -2,16 +2,12 @@ BASE = ../../..
INCLUDES = cp2/msg/test/overide/
-HOST_PROGRAMS = test-msg-read-header test-msg test-msg-cc test-msg-cm
+HOST_PROGRAMS = test-msg-read-header test-msg-cc test-msg-cm
test-msg-read-header_SOURCES = test-msg-read-header.c interface_stub.c \
cp_cl_interface_stub.c cl_stub.c
test-msg-read-header_MODULES = lib cp2/msg cp2/secu cp2/sta/mgr
-test-msg_SOURCES = test-msg.c interface_stub.c cp_cl_interface_stub.c \
- cl_stub.c
-test-msg_MODULES = lib cp2/msg cp2/secu cp2/sta/mgr
-
test-msg-cc_SOURCES = msg_cc.c interface_stub.c cl_stub.c
test-msg-cc_MODULES = lib cp2/msg cp2/sta/mgr cp2/secu
diff --git a/cesar/cp2/msg/test/src/test-msg.c b/cesar/cp2/msg/test/src/test-msg.c
deleted file mode 100644
index 7c052aa32a..0000000000
--- a/cesar/cp2/msg/test/src/test-msg.c
+++ /dev/null
@@ -1,747 +0,0 @@
-/* Cesar project {{{
- *
- * Copyright (C) 2008 Spidcom
- *
- * <<<Licence>>>
- *
- * }}} */
-/**
- * \file src/test-msg.c
- * \brief « brief description »
- * \ingroup « module »
- *
- * « long description »
- */
-#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"
-
-void
-test_case_msg_messages_init (test_t test)
-{
- cp_t cp;
- cp_mme_rx_t *mme_rx;
- cp_mme_tx_t *mme_tx;
- u8 buffer[10];
-
- cp_msg_init (&cp);
-
- test_case_begin (test, "MSG Message");
-
- mme_rx = cp_msg_mme_rx_init (&cp, buffer, 70, 0xA);
- test_begin (test, "MME rx init")
- {
- test_fail_if (mme_rx == NULL, "MSG message shall not be null");
- test_fail_if (mme_rx->p_mme != buffer, "Wrong buffer address");
- test_fail_if (mme_rx->length != 70, "Wrong length");
- test_fail_if (mme_rx->peer.tei != 0xA, "Wrong TEI");
- test_fail_if (mme_rx->cp != &cp, "Wrong CP context");
- }
- test_end;
- slab_release (mme_rx);
-
- mme_tx = cp_msg_mme_tx_init (&cp);
- test_begin (test, "MME rx init")
- {
- test_fail_if (mme_tx == NULL, "MSG message shall not be null");
- test_fail_if (mme_tx->cp != &cp, "Wrong CP context");
- }
- test_end;
- slab_release (mme_tx);
-
- cp_msg_uninit (&cp);
-}
-
-void
-test_case_msg_mme_tx_init (test_t test)
-{
- cp_t cp;
- cp_mme_tx_t *mme;
- cp_mme_peer_t peer;
- bitstream_t bitstream;
- u64 data;
- cp_sta_own_data_t *sta;
- mac_config_t mac_config;
-
- cp_msg_init (&cp);
- cp.mac_config = &mac_config;
- sta = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
-
- test_case_begin (test, "Get a MME TX context");
-
- peer.mac = 0x123456789ABCull;
- peer.vlan_tag = 0xAB;
- peer.tei = 0xA;
- peer.all_sta = false;
- mme = cp_msg_mme_init (&cp, &peer, 0xb0);
- // Close the MME bitstream.
- bitstream_finalise (&mme->bitstream);
-
- bitstream_init (&bitstream, mme->p_mme, HPAV_MME_HEADER_LEN_WITH_VLAN,
- BITSTREAM_READ);
- test_begin (test, "Verify")
- {
- test_fail_if (mme->p_mme == NULL, "buffer shall not be NULL");
- test_fail_if (mme->peer.mac != peer.mac, "Wrong MAC @");
- test_fail_if (mme->peer.vlan_tag != peer.vlan_tag, "Wrong VLAN tag");
- test_fail_if (mme->peer.all_sta != peer.all_sta, "Wrong STA Flag");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != peer.mac, "Wrong destination mac address");
-
- bitstream_access (&bitstream, &data, 48);
-
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "Wrong VLAN TAG");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (swap16(data) != HPAV_MTYPE_MME, "Wrong Mtype");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0xb0, "Wrong MMTYPE");
- }
- test_end;
-
- bitstream_finalise (&bitstream);
- slab_release (mme);
-
- cp_msg_uninit (&cp);
-}
-
-void
-test_case_msg_mme_tx_init_enc (test_t test)
-{
- cp_t cp;
- cp_mme_tx_t *mme;
- cp_mme_peer_t peer;
- cp_secu_protocol_run_t prun;
- bitstream_t bitstream;
- cp_sta_own_data_t *sta;
- u64 data;
- uint i;
- mac_config_t mac_config;
-
- cp_msg_init (&cp);
- cp.mac_config = &mac_config;
- sta = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_tei (sta, 0xA, &cp);
- cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
- sta->is_cco = false;
-
- cp_sta_own_data_set_pco_status (sta, false);
-
- test_case_begin (test, "Get a MME TX enc context");
-
- peer.mac = 0x123456789ABCull;
- peer.vlan_tag = 0xAB;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.my_nonce = 0x3;
- prun.your_nonce = 0x4;
-
- mme = cp_msg_mme_init_encrypted (&cp, &peer, 0xb0, 2, &prun);
- // Close the MME bitstream.
- bitstream_finalise (&mme->bitstream);
-
- bitstream_init (&bitstream, mme->p_mme, ETH_PACKET_MAX_SIZE,
- BITSTREAM_READ);
- test_begin (test, "Verify")
- {
- test_fail_if (mme->p_mme == NULL, "buffer shall not be NULL");
- test_fail_if (mme->peer.mac != peer.mac, "Wrong MAC @");
- test_fail_if (mme->peer.vlan_tag != peer.vlan_tag, "Wrong VLAN tag");
- test_fail_if (mme->peer.all_sta != peer.all_sta, "Wrong STA Flag");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != peer.mac, "Wrong destination mac address");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != 0x123456789ABCull,
- "Wrong destination mac address");
-
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "Wrong VLAN TAG");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (swap16(data) != HPAV_MTYPE_MME, "Wrong Mtype");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != CM_ENCRYPTED_PAYLOAD_IND, "Wrong MMTYPE");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0, "Wrong FMI");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != 2, "Wrong PEKS");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != CP_MSG_AVLN_STATUS_ASSOC_NOT_PCO,
- "Wrong AVLN Status");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pid, "Wrong PID");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != prun.prn, "Wrong PRN");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pmn, "Wrong PMN");
-
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != mme->iv_uuid.key[0], "Wrong key index 0");
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != mme->iv_uuid.key[1], "Wrong key index 0");
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != mme->iv_uuid.key[2], "Wrong key index 0");
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != mme->iv_uuid.key[3], "Wrong key index 0");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != mme->length, "Wrong length");
-
- for ( i = 0; i < mme->rf_len; i++)
- bitstream_access (&bitstream, &data, 8);
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != peer.mac, "enc: Wrong destination mac address");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != 0x123456789ABCull,
- "enc: Wrong destination mac address");
-
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "enc: Wrong VLAN TAG");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (swap16(data) != HPAV_MTYPE_MME, "enc: Wrong Mtype");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "enc: Wrong MMV");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0xb0, "enc: Wrong MMTYPE");
-
- }
- test_end;
-
- bitstream_finalise (&bitstream);
- slab_release (mme);
-
- cp_msg_uninit (&cp);
-}
-
-void
-test_case_msg_mme_tx_without_vlan_tag (test_t test)
-{
- cp_t cp;
- cp_mme_peer_t peer;
- cp_sta_own_data_t *sta;
- cp_secu_protocol_run_t prun;
- cp_mme_tx_t *mme;
- u8 *buffer;
- mac_t mac;
- bitstream_t bitstream;
- cp_key_t key;
- mac_config_t mac_config;
-
- lib_rnd_init (&cp.rnd, 0x12345678);
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0;
- peer.tei = 0x2;
- peer.all_sta = false;
- uint i;
- uint data;
- aes_context aes;
- uint enc_length;
-
- cp_msg_init (&cp);
- cp.mac_config = &mac_config;
-
- sta = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
- sta->is_cco = false;
- cp_sta_own_data_set_pco_status (sta, false);
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.my_nonce = 0x3;
- prun.your_nonce = 0x4;
-
- mme = cp_msg_mme_init_encrypted (&cp, &peer, 0xb0, 2, &prun);
- mme->length = 200-19;
- key = mme->iv_uuid;
- slab_addref (mme);
-
- // Store the buffer to the buffer variable.
- buffer = mme->p_mme;
-
- // Fill the MME payload.
- for ( i = 0; i < mme->length - 19; i++)
- {
- data = 0xAA;
- bitstream_access (&mme->bitstream, &data, 8);
- }
-
- cp_msg_mme_send (&cp, mme);
-
- cp_msg_uninit (&cp);
-
- // Verify the data.
- test_case_begin (test, "Encrypted Payload without Vlan");
-
- bitstream_init (&bitstream, buffer, ETH_PACKET_MAX_SIZE, BITSTREAM_READ);
- test_begin (test, "verify")
- {
- // ODA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != peer.mac, "Wrong mac address");
-
- // OSA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != 0x123456789ABCull, "Wrong mac address");
-
- // MType
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != swap16(HPAV_MTYPE_MME), "Wrong MType");
-
- // MMV
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- // MMTYPE.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != CM_ENCRYPTED_PAYLOAD_IND, "Wrong MMType");
-
- // FMI.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0, "Wrong FMI");
-
- // PEKS.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != 2, "Wrong PEKS");
-
- // AVLN STATUS.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != CP_MSG_AVLN_STATUS_ASSOC_NOT_PCO,
- "Wrong AVLN Status");
-
- // PID.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pid, "Wrong PID");
-
- // PRN.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != prun.prn, "Wrong PRN");
-
- // PMN.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pmn, "Wrong PMN");
-
- // IV.
- for ( i = 0; i < 4; i++)
- {
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != key.key[i], "Wrong Key");
- }
-
- // Len.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 200-19, "Wrong MME payload length");
-
- // Decrypt the buffer.
- enc_length = 19 + 9 + mme->rf_len + mme->length
- + ((mme->length + mme->rf_len) / 16);
- aes_set_key (&aes, (u8 *) &key);
- aes_cbc_decrypt (&aes, (u8*) &key,
- buffer + mme->payload_offset - mme->rf_len,
- buffer + mme->payload_offset - mme->rf_len,
- enc_length);
-
- // RF.
- for (i = 0; i < mme->rf_len; i++)
- bitstream_access (&bitstream, &data, 8);
-
- /* Payload. */
- // ODA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != peer.mac, "Wrong mac address");
-
- // OSA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != 0x123456789ABCull, "Wrong mac address");
-
- // MType
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != swap16(HPAV_MTYPE_MME), "Wrong MType");
-
- // MMV
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- // MMTYPE.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0xb0, "Wrong MMType");
- }
- test_end;
-
- slab_release (mme);
-}
-
-void
-test_case_msg_mme_tx_with_vlan_tag (test_t test)
-{
- cp_t cp;
- cp_mme_peer_t peer;
- cp_sta_own_data_t *sta;
- cp_secu_protocol_run_t prun;
- cp_mme_tx_t *mme;
- u8 *buffer;
- mac_t mac;
- bitstream_t bitstream;
- cp_key_t key;
- mac_config_t mac_config;
-
- lib_rnd_init (&cp.rnd, 0x12345678);
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x21;
- peer.tei = 0x2;
- peer.all_sta = false;
- uint i;
- uint data;
- aes_context aes;
- uint enc_length;
-
- cp_msg_init (&cp);
- cp.mac_config = &mac_config;
-
- sta = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
- sta->is_cco = false;
- cp_sta_own_data_set_pco_status (sta, false);
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.my_nonce = 0x3;
- prun.your_nonce = 0x4;
-
- mme = cp_msg_mme_init_encrypted (&cp, &peer, 0xb0, 2, &prun);
- mme->length = 200-23;
- key = mme->iv_uuid;
- slab_addref (mme);
-
- // Store the buffer to the buffer variable.
- buffer = mme->p_mme;
-
- // Fill the MME payload.
- for ( i = 0; i < mme->length - 19; i++)
- {
- data = 0xAA;
- bitstream_access (&mme->bitstream, &data, 8);
- }
-
- cp_msg_mme_send (&cp, mme);
-
- cp_msg_uninit (&cp);
-
- // Verify the data.
- test_case_begin (test, "Encrypted Payload without Vlan");
-
- bitstream_init (&bitstream, buffer, ETH_PACKET_MAX_SIZE, BITSTREAM_READ);
- test_begin (test, "verify")
- {
- // ODA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != peer.mac, "Wrong mac address");
-
- // OSA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != 0x123456789ABCull, "Wrong mac address");
-
- // VLAN Tag.
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "Wrong VLAN tag");
-
- // MType
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != swap16(HPAV_MTYPE_MME), "Wrong MType");
-
- // MMV
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- // MMTYPE.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != CM_ENCRYPTED_PAYLOAD_IND, "Wrong MMType");
-
- // FMI.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0, "Wrong FMI");
-
- // PEKS.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != 2, "Wrong PEKS");
-
- // AVLN STATUS.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != CP_MSG_AVLN_STATUS_ASSOC_NOT_PCO,
- "Wrong AVLN Status");
-
- // PID.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pid, "Wrong PID");
-
- // PRN.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != prun.prn, "Wrong PRN");
-
- // PMN.
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != prun.pmn, "Wrong PMN");
-
- // IV.
- for ( i = 0; i < 4; i++)
- {
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != key.key[i], "Wrong Key");
- }
-
- // Len.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 200-23, "Wrong MME payload length");
-
- // Decrypt the buffer.
- enc_length = 23 + 9 + mme->rf_len + mme->length
- + ((mme->length + mme->rf_len) / 16);
- aes_set_key (&aes, (u8 *) &key);
- aes_cbc_decrypt (&aes, (u8*) &key,
- buffer + mme->payload_offset - mme->rf_len,
- buffer + mme->payload_offset - mme->rf_len,
- enc_length);
-
- // RF.
- for (i = 0; i < mme->rf_len; i++)
- bitstream_access (&bitstream, &data, 8);
-
- /* Payload. */
- // ODA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != peer.mac, "Wrong mac address");
-
- // OSA.
- bitstream_access (&bitstream, &mac, 48);
- test_fail_if (mac != 0x123456789ABCull, "Wrong mac address");
-
- // VLAN Tag.
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "Wrong VLAN tag");
-
- // MType
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != swap16(HPAV_MTYPE_MME), "Wrong MType");
-
- // MMV
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- // MMTYPE.
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0xb0, "Wrong MMType");
- }
- test_end;
-
- slab_release (mme);
-}
-
-void
-test_case_msg_not_enc (test_t test)
-{
- cp_t cp;
- cp_mme_tx_t *mme;
- cp_mme_peer_t peer;
- bitstream_t bitstream;
- u64 data;
- u8 *buffer;
- cp_sta_own_data_t *own;
- mac_config_t mac_config;
-
- cp_msg_init (&cp);
- cp.mac_config = &mac_config;
-
- test_case_begin (test, "Send a MME not encrypted");
-
- peer.mac = 0x123456789ABCull;
- peer.vlan_tag = 0xAB;
- peer.tei = 0xA;
- peer.all_sta = false;
-
- own = cp_sta_mgr_get_sta_own_data (&cp);
- cp_sta_own_data_set_mac_address (own, 0x123456789ABCull, &cp);
-
- mme = cp_msg_mme_init (&cp, &peer, 0xb0);
- slab_addref (mme);
- buffer = mme->p_mme;
- cp_msg_mme_send (&cp, mme);
-
- bitstream_init (&bitstream, buffer, HPAV_MME_HEADER_LEN_WITH_VLAN,
- BITSTREAM_READ);
- test_begin (test, "Verify")
- {
- test_fail_if (mme->peer.mac != peer.mac, "Wrong MAC @");
- test_fail_if (mme->peer.vlan_tag != peer.vlan_tag, "Wrong VLAN tag");
- test_fail_if (mme->peer.all_sta != peer.all_sta, "Wrong STA Flag");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != peer.mac, "Wrong Destination mac address");
-
- bitstream_access (&bitstream, &data, 48);
- test_fail_if (data != 0x123456789ABCull,
- "Wrong Source mac address");
-
- bitstream_access (&bitstream, &data, 32);
- test_fail_if (data != peer.vlan_tag, "Wrong VLAN TAG");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (swap16(data) != HPAV_MTYPE_MME, "Wrong Mtype");
-
- bitstream_access (&bitstream, &data, 8);
- test_fail_if (data != HPAV_MMV, "Wrong MMV");
-
- bitstream_access (&bitstream, &data, 16);
- test_fail_if (data != 0xb0, "Wrong MMTYPE");
- }
- test_end;
-
- bitstream_finalise (&bitstream);
- slab_release (mme);
-
- cp_msg_uninit (&cp);
-}
-
-void
-test_case_msg_mme_rx_with_vlan_tag (test_t test)
-{
- cp_t cp;
- cp_mme_peer_t peer;
- cp_sta_own_data_t *sta;
- cp_secu_protocol_run_t prun;
- cp_mme_tx_t *mme;
- u8 *buffer;
- cp_key_t key;
- cp_mme_rx_t *mme_rx;
-
- lib_rnd_init (&cp.rnd, 0x12345678);
- peer.mac = 0x23456789ABCDull;
- peer.vlan_tag = 0x21;
- peer.tei = 0x2;
- peer.all_sta = false;
- uint i;
- uint data;
- uint fmi;
-
- cp_msg_init (&cp);
-
- sta = cp_sta_mgr_get_sta_own_data (&cp);
- sta->is_cco = false;
- cp_sta_own_data_set_pco_status (sta, false);
-
- prun.pid = 2;
- prun.pmn = 2;
- prun.my_nonce = 0x3;
- prun.your_nonce = 0x4;
-
- test_case_begin (test, "Reading a CM_ENC_Payload");
-
- cp_sta_own_data_set_mac_address (sta, 0x123456789ABCull, &cp);
- mme = cp_msg_mme_init_encrypted (&cp, &peer, 0xb0, 2, &prun);
- mme->length = 200-23;
- slab_addref (mme);
- key = mme->iv_uuid;
-
- // Store the buffer to the buffer variable.
- buffer = mme->p_mme;
-
- // Fill the MME payload.
- for ( i = 0; i < mme->length; i++)
- {
- data = 0xAA;
- bitstream_access (&mme->bitstream, &data, 8);
- }
-
- cp_msg_mme_send (&cp, mme);
-
- // Receiving the MME.
- //Change the MAC address of the station.
- cp_sta_own_data_set_mac_address (sta, 0x23456789ABCDull, &cp);
- mme_rx = cp_msg_mme_read_header (&cp, buffer, mme->length,
- 0xA, &fmi);
- slab_release (mme);
-
- data = cp_msg_mme_read_header_enc (&cp, mme_rx);
- dbg_check (data);
-
- // Test the data.
- test_begin (test, "Verify")
- {
- test_fail_if (mme_rx->mmtype != 0xb0, "Wrong MMType");
- test_fail_if (mme_rx->length != 200-23, "Wrong Length");
-
- for (i = 0; i < mme_rx->length - 2; i++)
- {
- bitstream_access (&mme_rx->bitstream, &data, 8);
- test_fail_if (data != 0xAA, "Wrong data index : %d", i);
- }
- }
- test_end;
-
-
- slab_release (mme_rx);
- cp_msg_uninit (&cp);
-}
-
-
-int
-main (void)
-{
- test_t test;
- test_init (test, 0, NULL);
-
- test_case_msg_messages_init (test);
- test_case_msg_mme_tx_init (test);
- test_case_msg_mme_tx_init_enc (test);
- test_case_msg_mme_tx_without_vlan_tag (test);
- test_case_msg_mme_tx_with_vlan_tag (test);
- test_case_msg_not_enc (test);
- test_case_msg_mme_rx_with_vlan_tag (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;
-}