summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlaranjeiro2008-07-15 15:05:50 +0000
committerlaranjeiro2008-07-15 15:05:50 +0000
commit7751f912ac0eac6e3d1f32b93b8dc284ea70a257 (patch)
tree901032701c10fe7ab1606df3c2384b5c79203a33
parent965269cca23cdf98d69edb3e571b56ad4e598f87 (diff)
cp2/msg: Tested the CC_SET_TEI_MAP.IND on the RX way.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2609 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--cesar/cp2/mme.h2
-rw-r--r--cesar/cp2/msg/inc/cc_set_tei_map.h2
-rw-r--r--cesar/cp2/msg/msg.h11
-rw-r--r--cesar/cp2/msg/src/msg.c26
-rw-r--r--cesar/cp2/msg/src/msg_cc.c54
-rw-r--r--cesar/cp2/msg/test/src/cc_set_tei_map_frag.c41
6 files changed, 128 insertions, 8 deletions
diff --git a/cesar/cp2/mme.h b/cesar/cp2/mme.h
index 843082803a..6ed94c34db 100644
--- a/cesar/cp2/mme.h
+++ b/cesar/cp2/mme.h
@@ -241,6 +241,8 @@ struct cp_mme_rx_t
u8 *p_mme;
/** pointer to the MME's fragments. */
blk_t *p_frag;
+ /** Pointer to the current frag. */
+ blk_t *p_frag_current;
/** MMType the type of MME. */
uint mmtype;
/** size of the MME (including header). */
diff --git a/cesar/cp2/msg/inc/cc_set_tei_map.h b/cesar/cp2/msg/inc/cc_set_tei_map.h
index 1b5f8c19b7..f1885c2343 100644
--- a/cesar/cp2/msg/inc/cc_set_tei_map.h
+++ b/cesar/cp2/msg/inc/cc_set_tei_map.h
@@ -37,7 +37,7 @@ struct cp_msg_cc_set_tei_map_change_buffer_t
/** CP context. */
cp_t *cp;
/** MSG context. */
- cp_mme_tx_t *msg;
+ void *msg;
/** FMI data, number of fragment. */
uint fmi_nbFrag;
/** Fragment number. */
diff --git a/cesar/cp2/msg/msg.h b/cesar/cp2/msg/msg.h
index bf93843d07..7f5ff6136d 100644
--- a/cesar/cp2/msg/msg.h
+++ b/cesar/cp2/msg/msg.h
@@ -172,6 +172,17 @@ cp_msg_mme_read_header (cp_t *ctx, u8 *mme, uint length, cp_tei_t tei,
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/msg.c b/cesar/cp2/msg/src/msg.c
index 298a9f9732..701bb83683 100644
--- a/cesar/cp2/msg/src/msg.c
+++ b/cesar/cp2/msg/src/msg.c
@@ -737,3 +737,29 @@ cp_msg_mme_read_header_enc (cp_t *ctx, cp_mme_rx_t *mme)
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 (ctx, msg->p_frag_current->data, BLK_SIZE, BITSTREAM_READ);
+ msg->bitstream.start = msg->p_frag_current->data;
+ msg->bitstream.stream = (uint *) msg->p_frag_current->data;
+}
+
diff --git a/cesar/cp2/msg/src/msg_cc.c b/cesar/cp2/msg/src/msg_cc.c
index 5d4a7c5fc8..5741bd1f52 100644
--- a/cesar/cp2/msg/src/msg_cc.c
+++ b/cesar/cp2/msg/src/msg_cc.c
@@ -513,27 +513,30 @@ cp_msg_cc_set_tei_map_req_receive (cp_t *ctx, cp_mme_rx_t *mme)
* \param data the structure registered.
*/
static void
-cp_msg_set_tei_map_change_buffer (bitstream_t *ctx,
+cp_msg_set_tei_map_send_change_buffer (bitstream_t *ctx,
cp_msg_cc_set_tei_map_change_buffer_t *data)
{
+ 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 (data->msg);
- cp_msg_mme_send (data->cp, data->msg);
+ slab_addref (msg);
+ cp_msg_mme_send (data->cp, msg);
// Initialise the header of the new buffer.
- data->msg->p_mme = cp_cl_interf_get_buffer_tx (data->cp);
+ msg->p_mme = cp_cl_interf_get_buffer_tx (data->cp);
- cp_msg_mme_write_frag_header (data->cp, data->msg, &data->msg->peer,
+ 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);
// Set newly the boolean indicating the buffer change callback is present.
- data->msg->bitstream.buffer_cb_present = true;
+ msg->bitstream.buffer_cb_present = true;
}
@@ -570,7 +573,7 @@ cp_msg_cc_set_tei_map_ind_send_begin (
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_change_buffer,
+ (bitstream_buffer_cb_t) cp_msg_set_tei_map_send_change_buffer,
data);
}
else
@@ -623,6 +626,29 @@ cp_msg_cc_set_tei_map_ind_send_end (cp_t *ctx, cp_mme_tx_t *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_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
@@ -635,14 +661,28 @@ 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_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;
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
index 6299a0e0c4..771cde0df6 100644
--- a/cesar/cp2/msg/test/src/cc_set_tei_map_frag.c
+++ b/cesar/cp2/msg/test/src/cc_set_tei_map_frag.c
@@ -16,6 +16,7 @@
#include "common/defs/ethernet.h"
#include "lib/test.h"
#include "lib/swap.h"
+#include "lib/blk.h"
#include "cp2/cp.h"
#include "cp2/inc/context.h"
@@ -52,10 +53,18 @@ test_case_msg_cc_set_tei_map_frag (void)
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);
@@ -151,6 +160,38 @@ test_case_msg_cc_set_tei_map_frag (void)
}
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);
+
+ memcpy (frag_first->data, buffer1 + 19, BLK_SIZE);
+ memcpy (frag_first->next->data, buffer1 + BLK_SIZE + 19, BLK_SIZE);
+ memcpy (frag_first->next->next->data, buffer1 + 2 * BLK_SIZE + 19, BLK_SIZE);
+ memcpy (frag_first->next->next->next->data, buffer2 + 19, BLK_SIZE);
+ frag_last->next = NULL;
+
+ msg_rx->p_frag = frag_first;
+ msg_rx->length = 1600;
+ bitstream_init (&msg_rx->bitstream, msg_rx->p_frag, 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);
+ slab_release (msg_rx);
}
int