summaryrefslogtreecommitdiff
path: root/cp/msg/src/msg.c
diff options
context:
space:
mode:
authorGuillaume2007-09-11 08:51:56 +0000
committerGuillaume2007-09-11 08:51:56 +0000
commite212ed516dcbcf390807a2cbe413f18220ca8b50 (patch)
tree4795b4d69d84c0b8c41a1d79e49723dc212bf9c3 /cp/msg/src/msg.c
parentfece8b856111c67a1c571208fa503afc9d835917 (diff)
work in progress...
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@693 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cp/msg/src/msg.c')
-rw-r--r--cp/msg/src/msg.c126
1 files changed, 73 insertions, 53 deletions
diff --git a/cp/msg/src/msg.c b/cp/msg/src/msg.c
index 75f5c63924..2efcd177b9 100644
--- a/cp/msg/src/msg.c
+++ b/cp/msg/src/msg.c
@@ -14,88 +14,108 @@
#include "common/std.h"
#include "cp/msg/msg.h"
-msg_list_mme_t msg_list[] =
+/*
+ * this array describe messages, their prefered destination and the function
+ * which process it.
+ * the array must be ordered on the first field of each line.
+ */
+const msg_list_mme_t msg_list[] =
{
- { "CC_CCO_APPOINT.REQ", MSG_STA, NULL },
- { "CC_CCO_APPOINT.CNF", MSG_STA, NULL },
- { "CC_CCO_APPOINT.", MSG_STA, NULL },
- { "CC_CCO_APPOINT.", MSG_STA, NULL },
-
- { "CC_BACKUP_APPOINT.REQ", MSG_STA, NULL },
- { "CC_BACKUP_APPOINT.CNF", MSG_CCO, NULL },
- { "CC_BACKUP_APPOINT.", MSG_STA, NULL },
- { "CC_BACKUP_APPOINT.", MSG_STA, NULL },
-
- { "CC_LINK_INFO.REQ", MSG_CCO, NULL },
- { "CC_LINK_INFO.CNF", MSG_STA, NULL },
- { "CC_LINK_INFO.IND", MSG_STA, NULL }, // le msg est STA car le destinataire n'a pas encore changé
- { "CC_LINK_INFO.RSP", MSG_CCO, NULL },
-
- { "CC_HANDOVER.REQ", MSG_STA, NULL },
- { "CC_HANDOVER.CNF", MSG_CCO, NULL },
- { "CC_HANDOVER.", MSG_STA, NULL },
- { "CC_HANDOVER.", MSG_STA, NULL },
-
- { "CC_HANDOVER_INFO.", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.IND", MSG_STA, NULL },
- { "CC_HANDOVER_INFO.RSP", MSG_CCO, NULL }
+ { CC_CCO_APPOINT_REQ, MSG_STA, NULL },
+ { CC_CCO_APPOINT_CNF, MSG_STA, NULL },
+ { CC_BACKUP_APPOINT_REQ, MSG_STA, NULL },
+ { CC_BACKUP_APPOINT_CNF, MSG_CCO, NULL },
+ { CC_LINK_INFO_REQ, MSG_CCO, NULL },
+ { CC_LINK_INFO_CNF, MSG_STA, NULL },
+ { CC_LINK_INFO_IND, MSG_STA, NULL },
+ { CC_LINK_INFO_RSP, MSG_CCO, NULL },
+ { CC_HANDOVER_REQ, MSG_STA, NULL },
+ { CC_HANDOVER_CNF, MSG_CCO, NULL },
+ { CC_HANDOVER_INFO_IND, MSG_STA, NULL },
+ { CC_HANDOVER_INFO_RSP, MSG_STA, NULL },
+ // TBC ...
+ { CM_UNASSOCIATED_STA_IND, MSG_STA, msg_cm_unassociated_sta_ind_rcv}
+ // TBC ...
};
+void msg_init(void)
+// it is not really useful to call this function from anywhere but a unit test.
+{
+ uint i;
+ for(i=1 ; i<COUNT(msg_list) ; i++)
+ dbg_assert(msg_list[i].mm_type > msg_list[i-1].mm_type);
+}
+
u16
msg_get_number (msg_mme_t *msg)
{
- msg_mme_t * mme;
u16 mme_num;
-
+
dbg_assert ( !msg_check_wrong_mme_const_values (msg));
-
- mme = msg;
- mme_num = mme->mm_type;
-
- if (mme->mm_type >= MSG_CM_START ) mme_num -= (MSG_CM_START - (MSG_NN_STOP + 1));
- if (mme->mm_type >= MSG_NN_START ) mme_num -= (MSG_NN_START - (MSG_CP_STOP + 1));
- if (mme->mm_type >= MSG_CP_START ) mme_num -= (MSG_CP_START - (MSG_CC_STOP + 1));
-
- if (mme_num >= COUNT (msg_list))
- {
- dbg_assert (0);
- return MSG_UNKNOW;
- }
+ //TODO this is maybe not very efficient, to check with more messages ...
+ DICHOTOMY_SEARCH(0, COUNT(msg_list), mme_num, msg->mm_type <= msg_list[mme_num].mm_type);
+ //printf("requested msg : %i, index found : %i\n", msg->mm_type, mme_num);
+ if(msg->mm_type != msg_list[mme_num].mm_type) return MSG_UNKNOW;
return mme_num;
}
-void *
-msg_dispatch (msg_mme_t *msg)
+void
+msg_dispatch (void)
{
u16 mme_num;
+ msg_mme_t *msg;
- dbg_assert ( !msg_check_wrong_mme_const_values (msg));
-
- mme_num = msg_get_number (msg);
- if ( (mme_num == MSG_UNKNOW) || (msg_list[mme_num].msg_func == NULL))
+ // process all the messages in the fifo
+ // TODO, in the next line, replace MSG_STA
+ msg = interf_msg_get_last(MSG_STA);
+ while(msg)
{
- // unknown or not implemented message
- return NULL;
+ dbg_assert ( !msg_check_wrong_mme_const_values (msg));
+ mme_num = msg_get_number (msg);
+ if (mme_num != MSG_UNKNOW)
+ {
+ dbg_assert(msg_list[mme_num].msg_func);
+ // process the message
+ msg_list[mme_num].msg_func (msg);
+ }
+ // release the message's buffer(s)
+ interf_release_buf(msg);
+ // and look for the next message
+ // TODO, in the next line, replace MSG_STA
+ msg = interf_msg_get_previous(MSG_STA);
}
- msg_list[mme_num].msg_func (msg);
- return msg_list[mme_num].msg_func;
}
void
msg_set_mme_const_values (msg_mme_t *msg)
{
dbg_assert (msg);
-
+ #if CHECK_BUFFER_OVERFLOW
+ interf_buffer_t *buffer = NULL;
+ #endif
+
msg->m_type = MSG_MTYPE; // 11.1.4
- msg->mmv = 0x01; // 11.1.5
+ msg->mmv = MSG_MM_VERSION;
+ #if CHECK_BUFFER_OVERFLOW
+ buffer = PARENT_OF(interf_buffer_t, msg, msg);
+ buffer->signature = BUFFER_SIGNATURE;
+ #endif
}
bool
msg_check_wrong_mme_const_values (msg_mme_t *msg)
{
+ #if CHECK_BUFFER_OVERFLOW
+ interf_buffer_t *buffer = NULL;
+ #endif
+
dbg_assert (msg);
+ #if CHECK_BUFFER_OVERFLOW
+ buffer = PARENT_OF(interf_buffer_t, msg, msg);
+ dbg_assert(buffer->signature == BUFFER_SIGNATURE);
+ #endif
+
return (msg->m_type != MSG_MTYPE);
}
@@ -106,7 +126,7 @@ msg_send(msg_mme_t *msg, uint msg_size, interf_id_t interf_id)
dbg_assert(msg_size <= SAR_MSDU_PAYLOAD_MAX_SIZE);
dbg_assert(interf_id < INTERF_MAX);
// set the values common to all MME
- // TODO set the ODA
+ // TODO set the OSA
// and then, send the message
interf_send (msg, msg_size, interf_id);
}