From 4394cf0740dac2a606951f1a5a8ee77676e21cec Mon Sep 17 00:00:00 2001
From: winckel <winckel@eurecom.fr>
Date: Tue, 14 Jan 2014 23:28:51 +0000
Subject: [PATCH] Added emty and text ITTI message types. Modified struct type
 display for text messages.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4874 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 common/utils/itti/intertask_messages_def.h    | 22 +++++-----
 common/utils/itti/intertask_messages_types.h  | 21 ++++++++++
 .../itti_analyzer/libparser/struct_type.c     | 40 +++++++++++++------
 3 files changed, 60 insertions(+), 23 deletions(-)
 create mode 100644 common/utils/itti/intertask_messages_types.h

diff --git a/common/utils/itti/intertask_messages_def.h b/common/utils/itti/intertask_messages_def.h
index 685b036385..0023afb27d 100644
--- a/common/utils/itti/intertask_messages_def.h
+++ b/common/utils/itti/intertask_messages_def.h
@@ -1,28 +1,28 @@
 /* This message asks for task initialization */
-MESSAGE_DEF(INITIALIZE_MESSAGE, MESSAGE_PRIORITY_MED, struct {}, initialize_message)
+MESSAGE_DEF(INITIALIZE_MESSAGE, MESSAGE_PRIORITY_MED, IttiMsgEmpty, initialize_message)
 
 /* This message asks for task activation */
-MESSAGE_DEF(ACTIVATE_MESSAGE,   MESSAGE_PRIORITY_MED, struct {}, activate_message)
+MESSAGE_DEF(ACTIVATE_MESSAGE,   MESSAGE_PRIORITY_MED, IttiMsgEmpty, activate_message)
 
 /* This message asks for task deactivation */
-MESSAGE_DEF(DEACTIVATE_MESSAGE, MESSAGE_PRIORITY_MED, struct {}, deactivate_message)
+MESSAGE_DEF(DEACTIVATE_MESSAGE, MESSAGE_PRIORITY_MED, IttiMsgEmpty, deactivate_message)
 
 /* This message asks for task termination */
-MESSAGE_DEF(TERMINATE_MESSAGE,  MESSAGE_PRIORITY_MAX, struct {}, terminate_message)
+MESSAGE_DEF(TERMINATE_MESSAGE,  MESSAGE_PRIORITY_MAX, IttiMsgEmpty, terminate_message)
 
 /* Test message used for debug */
-MESSAGE_DEF(MESSAGE_TEST,       MESSAGE_PRIORITY_MED, struct {}, message_test)
+MESSAGE_DEF(MESSAGE_TEST,       MESSAGE_PRIORITY_MED, IttiMsgEmpty, message_test)
 
 /* Error message  */
-MESSAGE_DEF(ERROR_LOG,          MESSAGE_PRIORITY_MAX, struct {}, error_log)
+MESSAGE_DEF(ERROR_LOG,          MESSAGE_PRIORITY_MAX, IttiMsgEmpty, error_log)
 /* Warning message  */
-MESSAGE_DEF(WARNING_LOG,        MESSAGE_PRIORITY_MAX, struct {}, warning_log)
+MESSAGE_DEF(WARNING_LOG,        MESSAGE_PRIORITY_MAX, IttiMsgEmpty, warning_log)
 /* Notice message  */
-MESSAGE_DEF(NOTICE_LOG,         MESSAGE_PRIORITY_MED, struct {}, notice_log)
+MESSAGE_DEF(NOTICE_LOG,         MESSAGE_PRIORITY_MED, IttiMsgEmpty, notice_log)
 /* Info message  */
-MESSAGE_DEF(INFO_LOG,           MESSAGE_PRIORITY_MED, struct {}, info_log)
+MESSAGE_DEF(INFO_LOG,           MESSAGE_PRIORITY_MED, IttiMsgEmpty, info_log)
 /* Debug message  */
-MESSAGE_DEF(DEBUG_LOG,          MESSAGE_PRIORITY_MED, struct {}, debug_log)
+MESSAGE_DEF(DEBUG_LOG,          MESSAGE_PRIORITY_MED, IttiMsgEmpty, debug_log)
 
 /* Generic log message for text */
-MESSAGE_DEF(GENERIC_LOG,        MESSAGE_PRIORITY_MED, struct {}, generic_log)
+MESSAGE_DEF(GENERIC_LOG,        MESSAGE_PRIORITY_MED, IttiMsgEmpty, generic_log)
diff --git a/common/utils/itti/intertask_messages_types.h b/common/utils/itti/intertask_messages_types.h
new file mode 100644
index 0000000000..37281e0ebb
--- /dev/null
+++ b/common/utils/itti/intertask_messages_types.h
@@ -0,0 +1,21 @@
+/*
+ * intertask_messages_types.h
+ *
+ *  Created on: Jan 14, 2014
+ *      Author: laurent winckel
+ */
+
+#ifndef INTERTASK_MESSAGES_TYPES_H_
+#define INTERTASK_MESSAGES_TYPES_H_
+
+typedef struct IttiMsgEmpty_s
+{
+} IttiMsgEmpty;
+
+typedef struct IttiMsgText_s
+{
+    uint32_t  size;
+    char      text[];
+} IttiMsgText;
+
+#endif /* INTERTASK_MESSAGES_TYPES_H_ */
diff --git a/common/utils/itti_analyzer/libparser/struct_type.c b/common/utils/itti_analyzer/libparser/struct_type.c
index 487c884691..cfc667b6c3 100644
--- a/common/utils/itti_analyzer/libparser/struct_type.c
+++ b/common/utils/itti_analyzer/libparser/struct_type.c
@@ -16,14 +16,14 @@ int struct_dissect_from_buffer(
     buffer_t *buffer, uint32_t offset, uint32_t parent_offset, int indent, gboolean new_line)
 {
     int i;
-    int length = 0;
     char cbuf[50 + (type->name ? strlen (type->name) : 0)];
+    int length = 0;
     char *name;
 
-    DISPLAY_PARSE_INFO("structure", type->name, offset, parent_offset);
-
     memset (cbuf, 0, sizeof(cbuf));
 
+    DISPLAY_PARSE_INFO("structure", type->name, offset, parent_offset);
+
     if (new_line) {
         DISPLAY_TYPE("Str");
     }
@@ -34,16 +34,32 @@ int struct_dissect_from_buffer(
     else {
         name = "_anonymous_";
     }
-    INDENTED_STRING(cbuf, new_line ? indent : 0, length = sprintf (cbuf, "%s :", name));
-    DISPLAY_BRACE(length += sprintf(&cbuf[length], " {"););
-    length += sprintf(&cbuf[length], "\n");
-    ui_set_signal_text_cb(user_data, cbuf, length);
 
-    for (i = 0; i < type->nb_members; i++) {
-        if (type->members_child[i] != NULL)
-            type->members_child[i]->type_dissect_from_buffer (
-                type->members_child[i], ui_set_signal_text_cb, user_data,
-                buffer, offset, parent_offset, indent + DISPLAY_TAB_SIZE, TRUE);
+    if ((strcmp (type->name, "IttiMsgText_s") == 0) &&
+        (type->members_child[0] != NULL) && (strcmp (type->members_child[0]->name, "size") == 0) &&
+        (type->members_child[1] != NULL) && (strcmp (type->members_child[1]->name, "text") == 0))
+    {
+        uint8_t *buf;
+
+        length = buffer_get_uint32_t (buffer, offset + parent_offset);
+        buf = malloc (length + 1);
+        buf[0] = '\n';
+        buffer_fetch_nbytes(buffer, parent_offset + offset + 32, length, &buf[1]);
+        ui_set_signal_text_cb(user_data, buf, length);
+    }
+    else
+    {
+        INDENTED_STRING(cbuf, new_line ? indent : 0, length = sprintf (cbuf, "%s :", name));
+        DISPLAY_BRACE(length += sprintf(&cbuf[length], " {"););
+        length += sprintf(&cbuf[length], "\n");
+        ui_set_signal_text_cb(user_data, cbuf, length);
+
+        for (i = 0; i < type->nb_members; i++) {
+            if (type->members_child[i] != NULL)
+                type->members_child[i]->type_dissect_from_buffer (
+                    type->members_child[i], ui_set_signal_text_cb, user_data,
+                    buffer, offset, parent_offset, indent + DISPLAY_TAB_SIZE, TRUE);
+        }
     }
 
     DISPLAY_BRACE(
-- 
GitLab