Commit 5e258662 authored by Cedric Roux's avatar Cedric Roux

- Added new feature to ITTI:

	* Possibilty to dump formatted strings directly to the analyzer
- Updated itti_analyzer accordingly

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4413 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 0a060e68
......@@ -189,7 +189,7 @@ int itti_send_broadcast_message(MessageDef *message_p) {
DevAssert(message_p != NULL);
origin_thread_id = TASK_GET_THREAD_ID(message_p->header.originTaskId);
origin_thread_id = TASK_GET_THREAD_ID(message_p->ittiMsgHeader.originTaskId);
destination_task_id = TASK_FIRST;
for (thread_id = THREAD_FIRST; thread_id < itti_desc.thread_max; thread_id++) {
......@@ -208,7 +208,7 @@ int itti_send_broadcast_message(MessageDef *message_p) {
memcpy (new_message_p, message_p, sizeof(MessageDef));
result = itti_send_msg_to_task (destination_task_id, INSTANCE_DEFAULT, new_message_p);
DevCheck(result >= 0, message_p->header.messageId, thread_id, destination_task_id);
DevCheck(result >= 0, message_p->ittiMsgHeader.messageId, thread_id, destination_task_id);
}
}
}
......@@ -217,22 +217,29 @@ int itti_send_broadcast_message(MessageDef *message_p) {
return ret;
}
inline MessageDef *itti_alloc_new_message(task_id_t origin_task_id, MessagesIds message_id) {
inline MessageDef *itti_alloc_new_message_sized(task_id_t origin_task_id, MessagesIds message_id, MessageHeaderSize size)
{
MessageDef *temp = NULL;
DevCheck(message_id < itti_desc.messages_id_max, message_id, itti_desc.messages_id_max, 0);
temp = calloc (1, MESSAGE_SIZE(message_id));
temp = calloc (1, sizeof(MessageHeader) + size);
DevAssert(temp != NULL);
temp->header.messageId = message_id;
temp->header.originTaskId = origin_task_id;
temp->header.size = itti_desc.messages_info[message_id].size;
temp->ittiMsgHeader.messageId = message_id;
temp->ittiMsgHeader.originTaskId = origin_task_id;
temp->ittiMsgHeader.ittiMsgSize = size;
return temp;
}
int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *message) {
inline MessageDef *itti_alloc_new_message(task_id_t origin_task_id, MessagesIds message_id)
{
return itti_alloc_new_message_sized(origin_task_id, message_id, itti_desc.messages_info[message_id].size);
}
int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *message)
{
thread_id_t thread_id = TASK_GET_THREAD_ID(task_id);
message_list_t *new;
uint32_t priority;
......@@ -242,11 +249,11 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
DevAssert(message != NULL);
DevCheck(task_id < itti_desc.task_max, task_id, itti_desc.task_max, 0);
message->header.destinationTaskId = task_id;
message->header.instance = instance;
message->header.lte_time.frame = itti_desc.lte_time.frame;
message->header.lte_time.slot = itti_desc.lte_time.slot;
message_id = message->header.messageId;
message->ittiMsgHeader.destinationTaskId = task_id;
message->ittiMsgHeader.instance = instance;
message->ittiMsgHeader.lte_time.frame = itti_desc.lte_time.frame;
message->ittiMsgHeader.lte_time.slot = itti_desc.lte_time.slot;
message_id = message->ittiMsgHeader.messageId;
DevCheck(message_id < itti_desc.messages_id_max, itti_desc.messages_id_max, message_id, 0);
priority = itti_get_message_priority (message_id);
......@@ -255,7 +262,7 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
message_number = itti_increment_message_number ();
itti_dump_queue_message (message_number, message, itti_desc.messages_info[message_id].name,
MESSAGE_SIZE(message_id));
sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize);
if (task_id != TASK_UNKNOWN)
{
......@@ -521,8 +528,8 @@ void itti_poll_msg(task_id_t task_id, MessageDef **received_msg) {
itti_desc.tasks[task_id].message_in_queue--;
ITTI_DEBUG(
"Receiver queue[(%u:%s)] got new message %s, number %lu\n",
task_id, itti_get_task_name(task_id), itti_desc.messages_info[temp->msg->header.messageId].name, temp->message_number);
"Receiver queue[(%u:%s)] got new message %s, number %lu\n",
task_id, itti_get_task_name(task_id), itti_desc.messages_info[temp->msg->ittiMsgHeader.messageId].name, temp->message_number);
break;
}
......
......@@ -48,10 +48,13 @@
#include "intertask_interface_conf.h"
#include "intertask_interface_types.h"
#define ITTI_MSG_NAME(mSGpTR) itti_get_message_name((mSGpTR)->header.messageId)
#define ITTI_MSG_ORIGIN_NAME(mSGpTR) itti_get_task_name((mSGpTR)->header.originTaskId)
#define ITTI_MSG_DESTINATION_NAME(mSGpTR) itti_get_task_name((mSGpTR)->header.destinationTaskId)
#define ITTI_MSG_INSTANCE(mSGpTR) (mSGpTR)->header.instance
#define ITTI_MSG_ID(mSGpTR) ((mSGpTR)->ittiMsgHeader.messageId)
#define ITTI_MSG_ORIGIN_ID(mSGpTR) ((mSGpTR)->ittiMsgHeader.originTaskId)
#define ITTI_MSG_DESTINATION_ID(mSGpTR) ((mSGpTR)->ittiMsgHeader.destinationTaskId)
#define ITTI_MSG_INSTANCE(mSGpTR) ((mSGpTR)->ittiMsgHeader.instance)
#define ITTI_MSG_NAME(mSGpTR) itti_get_message_name(ITTI_MSG_ID(mSGpTR))
#define ITTI_MSG_ORIGIN_NAME(mSGpTR) itti_get_task_name(ITTI_MSG_ORIGIN_ID(mSGpTR))
#define ITTI_MSG_DESTINATION_NAME(mSGpTR) itti_get_task_name(ITTI_MSG_DESTINATION_ID(mSGpTR))
/* Make the message number platform specific */
typedef unsigned long message_number_t;
......@@ -190,8 +193,19 @@ const char *itti_get_task_name(task_id_t task_id);
* @returns NULL in case of failure or newly allocated mesage ref
**/
inline MessageDef *itti_alloc_new_message(
task_id_t origin_task_id,
MessagesIds message_id);
task_id_t origin_task_id,
MessagesIds message_id);
/** \brief Alloc and memset(0) a new itti message.
* \param origin_task_id Task ID of the sending task
* \param message_id Message ID
* \param size size of the payload to send
* @returns NULL in case of failure or newly allocated mesage ref
**/
inline MessageDef *itti_alloc_new_message_sized(
task_id_t origin_task_id,
MessagesIds message_id,
MessageHeaderSize size);
/** \brief handle signals and wait for all threads to join when the process complete.
* This function should be called from the main thread after having created all ITTI tasks.
......
......@@ -65,6 +65,11 @@ extern int itti_debug;
#define ITTI_ERROR(x, args...) do { fprintf(stdout, "[ITTI][E]"x, ##args); } \
while(0)
/* Message sent is an intertask dump type */
#define ITTI_DUMP_MESSAGE_TYPE 0x1
#define ITTI_STATISTIC_MESSAGE_TYPE 0x2
#define ITTI_DUMP_XML_DEFINITION 0x3
typedef struct itti_queue_item_s {
STAILQ_ENTRY(itti_queue_item_s) entry;
void *data;
......@@ -102,11 +107,6 @@ typedef struct itti_desc_s {
itti_client_desc_t itti_clients[ITTI_DUMP_MAX_CON];
} itti_desc_t;
/* Message sent is an intertask dump type */
#define ITTI_DUMP_MESSAGE_TYPE 0x1
#define ITTI_STATISTIC_MESSAGE_TYPE 0x2
#define ITTI_DUMP_XML_DEFINITION 0x3
typedef struct {
/* The size of this structure */
uint32_t message_size;
......@@ -222,13 +222,62 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
return 0;
}
static int itti_enqueue_message(itti_queue_item_t *new, uint32_t message_size,
uint32_t message_type)
{
itti_queue_item_t *head = NULL;
DevAssert(new != NULL);
/* Lock the queue mutex for writing to insert the new element */
pthread_mutex_lock(&itti_queue.queue_mutex);
/* We reached the maximum size for the queue of messages -> remove the head */
if (itti_queue.queue_size + message_size > ITTI_QUEUE_SIZE_MAX) {
head = STAILQ_FIRST(&itti_queue.itti_message_queue);
/* Remove the head */
STAILQ_REMOVE_HEAD(&itti_queue.itti_message_queue, entry);
} else {
itti_queue.queue_size += message_size;
}
/* Insert the packet at tail */
STAILQ_INSERT_TAIL(&itti_queue.itti_message_queue, new, entry);
itti_queue.itti_queue_last = new;
if (dump_file != NULL)
{
itti_socket_header_t header;
header.message_size = message_size + sizeof(itti_dump_message_t);
header.message_type = message_type;
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (&new->message_number, sizeof(new->message_number), 1, dump_file);
fwrite (new->message_name, sizeof(new->message_name), 1, dump_file);
fwrite (new->data, new->data_size, 1, dump_file);
}
/* Release the mutex */
pthread_mutex_unlock(&itti_queue.queue_mutex);
/* No need to have the mutex locked to free data as at this point the message
* is no more in the list.
*/
if (head) {
free(head->data);
free(head);
head = NULL;
}
return 0;
}
int itti_dump_queue_message(message_number_t message_number,
MessageDef *message_p,
const char *message_name,
const uint32_t message_size)
{
itti_queue_item_t *new;
itti_queue_item_t *head = NULL;
size_t message_name_length;
int i;
......@@ -251,7 +300,7 @@ int itti_dump_queue_message(message_number_t message_number,
return -1;
}
memcpy(new->data, message_p, message_size);
new->data_size = message_size;
new->data_size = message_size;
new->message_number = message_number;
message_name_length = strlen(message_name) + 1;
......@@ -259,36 +308,7 @@ int itti_dump_queue_message(message_number_t message_number,
SIGNAL_NAME_LENGTH, 0);
memcpy(new->message_name, message_name, message_name_length);
/* Lock the queue mutex for writing to insert the new element */
pthread_mutex_lock(&itti_queue.queue_mutex);
/* We reached the maximum size for the queue of messages -> remove the head */
if (itti_queue.queue_size + message_size > ITTI_QUEUE_SIZE_MAX) {
head = STAILQ_FIRST(&itti_queue.itti_message_queue);
/* Remove the head */
STAILQ_REMOVE_HEAD(&itti_queue.itti_message_queue, entry);
} else {
itti_queue.queue_size += message_size;
}
/* Insert the packet at tail */
STAILQ_INSERT_TAIL(&itti_queue.itti_message_queue, new, entry);
itti_queue.itti_queue_last = new;
if (dump_file != NULL)
{
itti_socket_header_t header;
header.message_size = sizeof(itti_dump_message_t) + message_size;
header.message_type = ITTI_DUMP_MESSAGE_TYPE;
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
fwrite (&new->message_number, sizeof(new->message_number), 1, dump_file);
fwrite (new->message_name, sizeof(new->message_name), 1, dump_file);
fwrite (new->data, new->data_size, 1, dump_file);
}
/* Release the mutex */
pthread_mutex_unlock(&itti_queue.queue_mutex);
itti_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE);
for (i = 0; i < ITTI_DUMP_MAX_CON; i++) {
if (pthread_mutex_trylock(&itti_queue.itti_clients[i].client_lock) == 0) {
......@@ -301,15 +321,6 @@ int itti_dump_queue_message(message_number_t message_number,
itti_dump_send_message(itti_queue.itti_clients[i].sd, new);
}
/* No need to have the mutex locked to free data as at this point the message
* is no more in the list.
*/
if (head) {
free(head->data);
free(head);
head = NULL;
}
return 0;
}
......
......@@ -34,6 +34,10 @@
int itti_dump_queue_message(message_number_t message_number, MessageDef *message_p, const char *message_name,
const uint32_t message_size);
int itti_dump_queue_generic_string_message(message_number_t message_number,
char *string_message,
const uint32_t string_message_length);
int itti_dump_init(const char * const messages_definition_xml, const char * const dump_file_name);
void itti_dump_exit(void);
......
......@@ -58,7 +58,7 @@
/* Defines to extract task ID fields */
#define TASK_GET_THREAD_ID(tASKiD) (itti_desc.tasks_info[tASKiD].thread)
/* Extract the instance from a message */
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE) ((mESSAGE)->header.instance)
#define ITTI_MESSAGE_GET_INSTANCE(mESSAGE) ((mESSAGE)->ittiMsgHeader.instance)
#include <messages_types.h>
......@@ -140,7 +140,7 @@ typedef struct MessageHeader_s
task_id_t destinationTaskId; /**< ID of the destination task */
instance_t instance; /**< Task instance for virtualization */
MessageHeaderSize size; /**< Message size (not including header size) */
MessageHeaderSize ittiMsgSize; /**< Message size (not including header size) */
itti_lte_time_t lte_time; /**< Reference LTE time */
} MessageHeader;
......@@ -150,7 +150,7 @@ typedef struct MessageHeader_s
*/
typedef struct MessageDef_s
{
MessageHeader header; /**< Message header */
MessageHeader ittiMsgHeader; /**< Message header */
msg_t msg; /**< Union of payloads as defined in x_messages_def.h headers */
} MessageDef;
......
......@@ -2,4 +2,5 @@
MESSAGE_DEF(TERMINATE_MESSAGE, MESSAGE_PRIORITY_MAX, struct {}, terminate_message)
/* Test message used for debug */
MESSAGE_DEF(MESSAGE_TEST, MESSAGE_PRIORITY_MAX, struct {}, message_test)
/* Test message used for debug */
MESSAGE_DEF(GENERIC_LOG, MESSAGE_PRIORITY_MAX, char, generic_log)
......@@ -208,3 +208,11 @@ int buffer_has_enouch_data(buffer_t *buffer, uint32_t offset, uint32_t to_get)
offset, to_get, buffer->size_bytes);
return underflow;
}
void *buffer_at_offset(buffer_t *buffer, uint32_t offset)
{
// if (buffer_has_enouch_data(buffer, 0, offset) != 0) {
// return NULL;
// }
return &buffer->data[offset / 8];
}
......@@ -40,4 +40,6 @@ int buffer_new_from_data(buffer_t **buffer, uint8_t *data, const uint32_t length
int buffer_has_enouch_data(buffer_t *buffer, uint32_t offset, uint32_t to_get);
void *buffer_at_offset(buffer_t *buffer, uint32_t offset);
#endif /* BUFFERS_H_ */
......@@ -19,9 +19,7 @@ types_t *type_new(enum type_e type)
{
types_t *new_p;
new_p = malloc(sizeof(types_t));
memset(new_p, 0, sizeof(types_t));
new_p = calloc(1, sizeof(types_t));
new_p->type = type;
......
......@@ -785,12 +785,17 @@ static int xml_parse_doc(xmlDocPtr doc) {
/* Locate the message id field */
CHECK_FCT(locate_type("MessagesIds", head, &messages_id_enum));
/* Locate the header part of a message */
CHECK_FCT(locate_type("ittiMsgHeader", head, &message_header_type));
/* Locate the origin task id field */
CHECK_FCT(locate_type("originTaskId", head, &origin_task_id_type));
CHECK_FCT(locate_type("originTaskId", message_header_type, &origin_task_id_type));
/* Locate the destination task id field */
CHECK_FCT(locate_type("destinationTaskId", head, &destination_task_id_type));
CHECK_FCT(locate_type("destinationTaskId", message_header_type, &destination_task_id_type));
/* Locate the instance field */
CHECK_FCT(locate_type("instance", head, &instance_type));
CHECK_FCT(locate_type("instance", message_header_type, &instance_type));
/* Locate the message size field */
CHECK_FCT(locate_type("ittiMsgSize", message_header_type, &message_size_type));
// root->type_hr_display(root, 0);
......@@ -810,8 +815,28 @@ static int xml_parse_doc(xmlDocPtr doc) {
return ret;
}
int dissect_signal_header(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb,
gpointer cb_user_data)
{
if (message_header_type == NULL) {
g_error("No messages format definition provided");
return RC_FAIL;
}
if (buffer == NULL) {
g_error("Failed buffer is NULL");
return RC_FAIL;
}
message_header_type->type_dissect_from_buffer(
message_header_type, ui_set_signal_text_cb, cb_user_data,
buffer, 0, 0, INDENT_START);
return RC_OK;
}
int dissect_signal(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb,
gpointer user_data)
gpointer cb_user_data)
{
if (root == NULL) {
g_error("No messages format definition provided");
......@@ -823,7 +848,7 @@ int dissect_signal(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_
return RC_FAIL;
}
root->type_dissect_from_buffer(root, ui_set_signal_text_cb, user_data,
root->type_dissect_from_buffer(root, ui_set_signal_text_cb, cb_user_data,
buffer, 0, 0, INDENT_START);
return RC_OK;
......
......@@ -13,4 +13,7 @@ int xml_parse_buffer(const char *xml_buffer, const int size);
int dissect_signal(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb,
gpointer user_data);
int dissect_signal_header(buffer_t *buffer, ui_set_signal_text_cb_t ui_set_signal_text_cb,
gpointer cb_user_data);
#endif /* XML_PARSE_H_ */
......@@ -17,6 +17,8 @@ types_t *lte_time_slot_type = NULL;
types_t *origin_task_id_type = NULL;
types_t *destination_task_id_type = NULL;
types_t *instance_type = NULL;
types_t *message_header_type = NULL;
types_t *message_size_type = NULL;
int locate_root(const char *root_name, types_t *head, types_t **root_elm) {
types_t *next_type;
......@@ -77,6 +79,37 @@ int locate_type(const char *type_name, types_t *head, types_t **type) {
return (next_type == NULL) ? RC_FAIL : RC_OK;
}
uint32_t get_message_header_type_size(void)
{
/* Typedef */
if (message_header_type->child != NULL) {
/* Struct */
if (message_header_type->child->child != NULL) {
return message_header_type->child->child->size;
}
}
return 0;
}
uint32_t get_message_size(buffer_t *buffer)
{
uint32_t value = 0;
if (message_size_type != NULL)
{
types_t *temp = message_size_type;
while (temp->size == -1) {
temp = temp->child;
}
/* Fetch instance value */
buffer_fetch_bits (buffer, message_size_type->offset, temp->size, &value);
}
return value;
}
uint32_t get_lte_frame(buffer_t *buffer) {
uint32_t value = 0;
......
......@@ -8,11 +8,17 @@ extern types_t *lte_time_slot_type;
extern types_t *origin_task_id_type;
extern types_t *destination_task_id_type;
extern types_t *instance_type;
extern types_t *message_header_type;
extern types_t *message_size_type;
int locate_root(const char *root_name, types_t *head, types_t **root);
int locate_type(const char *type_name, types_t *head, types_t **type);
uint32_t get_message_header_type_size(void);
uint32_t get_message_size(buffer_t *buffer);
uint32_t get_lte_frame(buffer_t *buffer);
uint32_t get_lte_slot(buffer_t *buffer);
......
......@@ -127,17 +127,40 @@ gboolean ui_callback_on_select_signal(GtkTreeSelection *selection, GtkTreeModel
GValue buffer_store = G_VALUE_INIT;
gpointer buffer;
gtk_tree_model_get_value (model, &iter, COL_BUFFER, &buffer_store);
GValue message_id_store = G_VALUE_INIT;
guint message_id;
gtk_tree_model_get_value (model, &iter, COL_BUFFER, &buffer_store);
buffer = g_value_get_pointer (&buffer_store);
gtk_tree_model_get_value (model, &iter, COL_MESSAGE_ID, &message_id_store);
message_id = g_value_get_uint(&message_id_store);
if (!path_currently_selected)
{
/* Clear the view */
CHECK_FCT_DO(ui_signal_dissect_clear_view(text_view), return FALSE);
/* Dissect the signal */
CHECK_FCT_DO(dissect_signal((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE);
if (strcmp(message_id_to_string(message_id), "GENERIC_LOG") == 0) {
gchar *data;
gint data_size;
uint32_t message_header_type_size;
CHECK_FCT_DO(dissect_signal_header((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE);
message_header_type_size = get_message_header_type_size();
data = (gchar *)buffer_at_offset((buffer_t*)buffer, message_header_type_size);
data_size = get_message_size((buffer_t*)buffer);
g_debug("message header type size: %u, data size: %u\n",
message_header_type_size, data_size);
ui_signal_set_text(text_view, "\n", 1);
ui_signal_set_text(text_view, data, data_size);
} else {
/* Dissect the signal */
CHECK_FCT_DO(dissect_signal((buffer_t*)buffer, ui_signal_set_text, text_view), return FALSE);
}
}
}
return TRUE;
......
......@@ -3,7 +3,7 @@ import datetime
import getopt
import getpass
version = "1.0.1"
version = "1.0.2"
lines = ""
iesDefs = {}
......@@ -304,7 +304,8 @@ for key in iesDefs:
f.write(" * \\param file File descriptor to write output.\n")
f.write(" **/\n")
f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('item', 'list', firstlower.lower())))
f.write(" FILE *file,\n")
f.write(" asn_app_consume_bytes_f *cb,\n")
f.write(" void *app_key,\n")
f.write(" %sIEs_t *%sIEs);\n\n" % (re.sub('item', 'list', asn1cStruct), firstlower))
else:
f.write("/** \\brief Display %s message using XER encoding.\n" % (asn1cStruct))
......@@ -312,8 +313,13 @@ for key in iesDefs:
f.write(" * \\param file File descriptor to write output.\n")
f.write(" **/\n")
f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, firstlower.lower()))
f.write(" FILE *file,\n")
f.write(" asn_app_consume_bytes_f *cb,\n")
f.write(" void *app_key,\n")
f.write(" %s_message *message_p);\n\n" % (fileprefix))
f.write("int %s_xer__print2sp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
f.write("int %s_xer__print2fp(const void *buffer, size_t size, void *app_key);\n\n" % (fileprefix.lower()))
f.write("extern size_t %s_string_total_size;\n\n" % (fileprefix.lower()))
f.write("#endif /* %s_IES_DEFS_H_ */\n\n" % (fileprefix.upper()))
#Generate Decode functions
......@@ -574,8 +580,9 @@ f.write("#include <stdio.h>\n\n")
f.write("#include <asn_application.h>\n#include <asn_internal.h>\n\n")
f.write("#include \"%s_common.h\"\n#include \"%s_ies_defs.h\"\n\n" % (fileprefix, fileprefix))
f.write("""static int
xer__print2fp(const void *buffer, size_t size, void *app_key) {
f.write("size_t %s_string_total_size = 0;\n\n" % (fileprefix.lower()))
f.write("""int
%s_xer__print2fp(const void *buffer, size_t size, void *app_key) {
FILE *stream = (FILE *)app_key;
if(fwrite(buffer, 1, size, stream) != size)
......@@ -584,7 +591,22 @@ xer__print2fp(const void *buffer, size_t size, void *app_key) {
return 0;
}
static asn_enc_rval_t
""" % (fileprefix.lower()))
f.write("""int %s_xer__print2sp(const void *buffer, size_t size, void *app_key) {
char *string = (char *)app_key;
/* Copy buffer to the formatted string */
memcpy(&string[%s_string_total_size], buffer, size);
%s_string_total_size += size;
return 0;
}
""" % (fileprefix.lower(), fileprefix.lower(), fileprefix.lower()))
f.write("""static asn_enc_rval_t
xer_encode_local(asn_TYPE_descriptor_t *td, void *sptr,
asn_app_consume_bytes_f *cb, void *app_key, int indent) {
asn_enc_rval_t er, tmper;
......@@ -625,7 +647,9 @@ for (key, value) in iesDefs.items():
f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('item', 'list', re.sub('-', '_', key).lower()))))
else:
f.write("asn_enc_rval_t %s_xer_print_%s(\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', key).lower())))
f.write(" FILE *file,\n")
#f.write(" FILE *file,\n")
f.write(" asn_app_consume_bytes_f *cb,\n")
f.write(" void *app_key,\n")
if key in ieofielist.values():
iesStructName = lowerFirstCamelWord(re.sub('Item', 'List', re.sub('-', '_', key)))
f.write(" %sIEs_t *%s) {\n\n" % (re.sub('IEs', '', re.sub('Item', 'List', re.sub('-', '_', key))), iesStructName))
......@@ -635,21 +659,23 @@ for (key, value) in iesDefs.items():
f.write(" %s_message *message_p)\n{\n" % (fileprefix))
f.write(" %s_t *%s;\n" % (re.sub('-', '_', key), iesStructName))
f.write(" asn_enc_rval_t er;\n")
f.write(" void *app_key = (void *)file;\n")
f.write(" asn_app_consume_bytes_f *cb = xer__print2fp;\n\n")
#f.write(" void *app_key = (void *)file;\n")
#f.write(" asn_app_consume_bytes_f *cb = %s_xer__print2fp;\n\n" % (fileprefix.lower()))
f.write(" %s = &message_p->msg.%s;\n\n" % (iesStructName, iesStructName))
if key in ieofielist.values():
# Increase indentation level
f.write(" for (i = 0; i < %s->%s.count; i++) {\n" % (iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
f.write(" xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
#f.write(" xer_fprint(file, &asn_DEF_%s, %s->%s.array[i]);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
f.write(" er = xer_encode(&asn_DEF_%s, %s->%s.array[i], XER_F_BASIC, cb, app_key);\n" % (ietypeunderscore, iesStructName, re.sub('IEs', '', lowerFirstCamelWord(re.sub('-', '_', key)))))
f.write(" }\n")
else:
f.write(" fprintf(file, \"<%s-PDU>\\n\");\n" % (fileprefix.upper()))
f.write(" cb(\"<%s-PDU>\\n\", %d, app_key);\n" % (key, len("<%s-PDU>\n" % (key))))
f.write(" xer_encode_local(&asn_DEF_%s_Criticality, &message_p->criticality, cb, app_key, 1);\n" % fileprefix_first_upper)
f.write(" xer_encode_local(&asn_DEF_%s_ProcedureCode, &message_p->procedureCode, cb, app_key, 1);\n" % fileprefix_first_upper)
f.write(" fprintf(file, \" <%s>\\n\");\n" % (key))
f.write(" cb(\" <%s>\\n\", %d, app_key);\n" % (key, len(" <%s>\n" % (key))))
for ie in iesDefs[key]["ies"]:
iename = re.sub('-', '_', re.sub('id-', '', ie[0]))
......@@ -667,12 +693,11 @@ for (key, value) in iesDefs.items():
# Is it an encapsulated IE ?
if ie[2] in ieofielist.keys():
f.write(" %s_xer_print_%s(file, &%s->%s);\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', ie[2]).lower()), iesStructName, ienamefirstwordlower))
f.write(" %s_xer_print_%s(cb, app_key, &%s->%s);\n" % (fileprefix, re.sub('ies', '', re.sub('-', '_', ie[2]).lower()), iesStructName, ienamefirstwordlower))
else:
f.write(" xer_encode_local(&asn_DEF_%s, &%s->%s, cb, app_key, 2);\n" % (ietypeunderscore, iesStructName, ienamefirstwordlower))
#f.write(" _i_ASN_TEXT_INDENT(1, 1);\n")
f.write(" fprintf(file, \" </%s>\\n\");\n" % (key))
f.write(" fprintf(file, \"</%s-PDU>\\n\");\n" % (fileprefix.upper()))
f.write(" cb(\" </%s>\\n\", %d, app_key);\n" % (key, len(" </%s>\n" % (key))))
f.write(" cb(\"</%s-PDU>\\n\", %d, app_key);\n" % (key, len("</%s-PDU>\n" % (key))))
f.write(" _ASN_ENCODED_OK(er);\n")
#if key not in ieofielist.values():
......
......@@ -41,7 +41,7 @@
#include "S1AP-PDU.h"
int asn_debug = 0;
int asn1_xer_print = 1;
int asn1_xer_print = 0;
#if defined(EMIT_ASN_DEBUG_EXTERN)
inline void ASN_DEBUG(const char *fmt, ...)
......
......@@ -229,7 +229,7 @@ void *s1ap_eNB_task(void *arg)
while (1) {
itti_receive_msg(TASK_S1AP, &received_msg);
switch (received_msg->header.messageId) {
switch (ITTI_MSG_ID(received_msg)) {
case TERMINATE_MESSAGE:
itti_exit_task();
break;
......@@ -263,8 +263,8 @@ void *s1ap_eNB_task(void *arg)
&received_msg->msg.s1ap_initial_context_setup_resp);
} break;
default:
S1AP_ERROR("Received unhandled message with id %d\n",
received_msg->header.messageId);
S1AP_ERROR("Received unhandled message: %d:%s\n",
ITTI_MSG_ID(received_msg), ITTI_MSG_NAME(received_msg));
break;
}
......
......@@ -39,6 +39,8 @@
#include "assertions.h"
#include "intertask_interface.h"
#include "s1ap_common.h"
#include "s1ap_ies_defs.h"
#include "s1ap_eNB_decoder.h"
......@@ -46,6 +48,8 @@
static int s1ap_eNB_decode_initiating_message(s1ap_message *message,
S1ap_InitiatingMessage_t *initiating_p)
{
char message_string[10000];
int ret = -1;
DevAssert(initiating_p != NULL);
message->procedureCode = initiating_p->procedureCode;
......@@ -53,8 +57,10 @@ static int s1ap_eNB_decode_initiating_message(s1ap_message *message,
switch(initiating_p->procedureCode) {
case S1ap_ProcedureCode_id_downlinkNASTransport:
return s1ap_decode_s1ap_downlinknastransporties(
ret = s1ap_decode_s1ap_downlinknastransporties(
&message->msg.s1ap_DownlinkNASTransportIEs, &initiating_p->value);
s1ap_xer_print_s1ap_downlinknastransport(s1ap_xer__print2sp, message_string, message);
break;
case S1ap_ProcedureCode_id_InitialContextSetup:
return s1ap_decode_s1ap_initialcontextsetuprequesties(
......@@ -65,12 +71,17 @@ static int s1ap_eNB_decode_initiating_message(s1ap_message *message,
(int)initiating_p->procedureCode);
break;
}
return -1;
return ret;
}
static int s1ap_eNB_decode_successful_outcome(s1ap_message *message,
S1ap_SuccessfulOutcome_t *successfullOutcome_p)
{
int ret = -1;
MessageDef *message_p;
char *message_string = NULL;
size_t message_string_size;
DevAssert(successfullOutcome_p != NULL);
message->procedureCode = successfullOutcome_p->procedureCode;
......@@ -78,20 +89,33 @@ static int s1ap_eNB_decode_successful_outcome(s1ap_message *message,
switch(successfullOutcome_p->procedureCode) {
case S1ap_ProcedureCode_id_S1Setup:
return s1ap_decode_s1ap_s1setupresponseies(
message_string = malloc(sizeof(char) * 10000);
ret = s1ap_decode_s1ap_s1setupresponseies(
&message->msg.s1ap_S1SetupResponseIEs, &successfullOutcome_p->value);
s1ap_xer_print_s1ap_s1setupresponse(s1ap_xer__print2sp, message_string, message);
break;
default:
S1AP_DEBUG("Unknown procedure ID (%d) for successfull outcome message\n",
(int)successfullOutcome_p->procedureCode);
break;
return -1;
}
return -1;
message_string_size = strlen(message_string);
message_p = itti_alloc_new_message_sized(TASK_S1AP, GENERIC_LOG, message_string_size);
memcpy(&message_p->msg.generic_log, message_string, message_string_size);
itti_send_msg_to_task(TASK_UNKNOWN, INSTANCE_DEFAULT, message_p);
free(message_string);
return ret;
}
static int s1ap_eNB_decode_unsuccessful_outcome(s1ap_message *message,
S1ap_UnsuccessfulOutcome_t *unSuccessfullOutcome_p)
{
int ret = -1;
DevAssert(unSuccessfullOutcome_p != NULL);
message->procedureCode = unSuccessfullOutcome_p->procedureCode;
......@@ -107,7 +131,7 @@ static int s1ap_eNB_decode_unsuccessful_outcome(s1ap_message *message,
(int)unSuccessfullOutcome_p->procedureCode);
break;
}
return -1;
return ret;
}
int s1ap_eNB_decode_pdu(s1ap_message *message, const uint8_t * const buffer,
......
......@@ -515,23 +515,23 @@ void *sctp_eNB_task(void *arg)
/* Check if there is a packet to handle */
if (received_msg != NULL) {
switch (received_msg->header.messageId) {
switch (ITTI_MSG_ID(received_msg)) {
case TERMINATE_MESSAGE:
itti_exit_task();
break;
case SCTP_NEW_ASSOCIATION_REQ: {
sctp_handle_new_association_req(ITTI_MESSAGE_GET_INSTANCE(received_msg),
received_msg->header.originTaskId,
ITTI_MSG_ORIGIN_ID(received_msg),
&received_msg->msg.sctp_new_association_req);
} break;
case SCTP_DATA_REQ: {
sctp_send_data(ITTI_MESSAGE_GET_INSTANCE(received_msg),
received_msg->header.originTaskId,
ITTI_MSG_ORIGIN_ID(received_msg),
&received_msg->msg.sctp_data_req);
} break;
default:
SCTP_ERROR("Received unhandled message with id %d\n",
received_msg->header.messageId);
ITTI_MSG_ID(received_msg));
break;
}
}
......
......@@ -4218,7 +4218,7 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf
msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p);
switch (msg_p->header.messageId) {
switch (ITTI_MSG_ID(msg_p)) {
case RRC_MAC_BCCH_DATA_REQ:
LOG_D(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n",
msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
......
......@@ -1295,7 +1295,7 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire
msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p);
switch (msg_p->header.messageId) {
switch (ITTI_MSG_ID(msg_p)) {
case RRC_MAC_CCCH_DATA_REQ:
LOG_D(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n",
msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
......
......@@ -506,7 +506,7 @@ void pdcp_run (u32_t frame, u8 eNB_flag, u8 UE_index, u8 eNB_index) {
msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p);
switch (msg_p->header.messageId) {
switch (ITTI_MSG_ID(msg_p)) {
case RRC_DCCH_DATA_REQ:
LOG_D(PDCP, "Received %s from %s: instance %d, frame %d, eNB_flag %d, rb_id %d, muiP %d, confirmP %d, mode %d\n",
msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance,
......
......@@ -2235,7 +2235,7 @@ void *rrc_ue_task(void *args_p) {
instance = ITTI_MSG_INSTANCE (msg_p);
Mod_id = instance - NB_eNB_INST;
switch (msg_p->header.messageId) {
switch (ITTI_MSG_ID(msg_p)) {
case TERMINATE_MESSAGE:
itti_exit_task ();
break;
......
......@@ -2984,7 +2984,7 @@ void *rrc_enb_task(void *args_p) {
msg_name = ITTI_MSG_NAME (msg_p);
instance = ITTI_MSG_INSTANCE (msg_p);
switch (msg_p->header.messageId) {
switch (ITTI_MSG_ID(msg_p)) {
case TERMINATE_MESSAGE:
itti_exit_task ();
break;
......
......@@ -432,17 +432,17 @@ void *l2l1_task(void *args_p) {
itti_poll_msg (TASK_L2L1, &message_p);
if (message_p != NULL) {
switch (message_p->header.messageId) {
switch (ITTI_MSG_ID(message_p)) {
case TERMINATE_MESSAGE:
itti_exit_task ();
break;
case MESSAGE_TEST:
LOG_D(EMU, "Received %s\n", itti_get_message_name(message_p->header.messageId));
LOG_D(EMU, "Received %s\n", ITTI_MSG_NAME(message_p));
break;
default:
LOG_E(EMU, "Received unexpected message %s\n", itti_get_message_name(message_p->header.messageId));
LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p));
break;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment