Modified ITTI log file format:
- removed signal_name. - added message start and end markers. Added a "cancel" button for some dialog box. git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4861 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#include "assertions.h"
|
||||
#include "liblfds611.h"
|
||||
|
||||
#include "itti_types.h"
|
||||
#include "intertask_interface.h"
|
||||
#include "intertask_interface_dump.h"
|
||||
|
||||
@@ -62,8 +63,6 @@
|
||||
#include "vcd_signal_dumper.h"
|
||||
#endif
|
||||
|
||||
#define SIGNAL_NAME_LENGTH 48
|
||||
|
||||
static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2;
|
||||
|
||||
#ifdef RTAI
|
||||
@@ -80,18 +79,10 @@ static const int itti_dump_debug = 0; // 0x8 | 0x4 | 0x2;
|
||||
# define KERNEL_VERSION_PRE_2_6_30 1
|
||||
#endif
|
||||
|
||||
/* 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
|
||||
/* This signal is not meant to be used by remote analyzer */
|
||||
#define ITTI_DUMP_EXIT_SIGNAL 0x4
|
||||
|
||||
typedef struct itti_dump_queue_item_s {
|
||||
MessageDef *data;
|
||||
uint32_t data_size;
|
||||
uint32_t message_number;
|
||||
char message_name[SIGNAL_NAME_LENGTH];
|
||||
uint32_t message_type;
|
||||
uint32_t message_size;
|
||||
} itti_dump_queue_item_t;
|
||||
@@ -128,25 +119,20 @@ typedef struct itti_desc_s {
|
||||
} itti_desc_t;
|
||||
|
||||
typedef struct {
|
||||
/* The size of this structure */
|
||||
uint32_t message_size;
|
||||
uint32_t message_type;
|
||||
} itti_socket_header_t;
|
||||
itti_socket_header_t socket_header;
|
||||
|
||||
typedef struct {
|
||||
itti_socket_header_t header;
|
||||
|
||||
uint32_t message_number;
|
||||
char signal_name[SIGNAL_NAME_LENGTH];
|
||||
itti_signal_header_t signal_header;
|
||||
|
||||
/* Message payload is added here, this struct is used as an header */
|
||||
} itti_dump_message_t;
|
||||
|
||||
typedef struct {
|
||||
itti_socket_header_t header;
|
||||
|
||||
itti_socket_header_t socket_header;
|
||||
} itti_statistic_message_t;
|
||||
|
||||
static const itti_message_types_t itti_dump_xml_definition_end = ITTI_DUMP_XML_DEFINITION_END;
|
||||
static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESSAGE_TYPE_END;
|
||||
|
||||
static itti_desc_t itti_dump_queue;
|
||||
static FILE *dump_file = NULL;
|
||||
static int itti_dump_running = 1;
|
||||
@@ -161,24 +147,24 @@ static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message)
|
||||
uint8_t *data_ptr;
|
||||
|
||||
/* Allocate memory for message header and payload */
|
||||
size_t size = sizeof(itti_dump_message_t) + message->data_size;
|
||||
size_t size = sizeof(itti_dump_message_t) + message->data_size + sizeof(itti_message_types_t);
|
||||
|
||||
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
|
||||
AssertFatal (message != NULL, "Message is NULL!\n");
|
||||
|
||||
new_message = calloc(1, size);
|
||||
new_message = malloc(size);
|
||||
AssertFatal (new_message != NULL, "New message allocation failed!\n");
|
||||
|
||||
/* Preparing the header */
|
||||
new_message->header.message_size = size;
|
||||
new_message->header.message_type = ITTI_DUMP_MESSAGE_TYPE;
|
||||
new_message->socket_header.message_size = size;
|
||||
new_message->socket_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
|
||||
|
||||
new_message->message_number = message->message_number;
|
||||
/* Copy the name, but leaves last byte set to 0 in case name is too long */
|
||||
memcpy(new_message->signal_name, message->message_name, SIGNAL_NAME_LENGTH - 1);
|
||||
new_message->signal_header.message_number = message->message_number;
|
||||
/* Appends message payload */
|
||||
memcpy(&new_message[1], message->data, message->data_size);
|
||||
|
||||
memcpy(((void *) &new_message[1]) + message->data_size, &itti_dump_message_type_end, sizeof(itti_message_types_t));
|
||||
|
||||
data_ptr = (uint8_t *)&new_message[0];
|
||||
|
||||
do {
|
||||
@@ -202,13 +188,13 @@ static int itti_dump_fwrite_message(itti_dump_queue_item_t *message)
|
||||
|
||||
if ((dump_file != NULL) && (message != NULL)) {
|
||||
|
||||
header.message_size = message->message_size + sizeof(itti_dump_message_t);
|
||||
header.message_size = message->message_size + sizeof(itti_dump_message_t) + sizeof(itti_message_types_t);
|
||||
header.message_type = message->message_type;
|
||||
|
||||
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
|
||||
fwrite (&message->message_number, sizeof(message->message_number), 1, dump_file);
|
||||
fwrite (message->message_name, sizeof(message->message_name), 1, dump_file);
|
||||
fwrite (message->data, message->data_size, 1, dump_file);
|
||||
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, dump_file);
|
||||
// #if !defined(RTAI)
|
||||
fflush (dump_file);
|
||||
// #endif
|
||||
@@ -229,7 +215,7 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
|
||||
AssertFatal (sd > 0, "Socket descriptor (%d) is invalid!\n", sd);
|
||||
AssertFatal (message_definition_xml != NULL, "Message definition XML is NULL!\n");
|
||||
|
||||
itti_dump_message_size = sizeof(itti_socket_header_t) + message_definition_xml_length;
|
||||
itti_dump_message_size = sizeof(itti_socket_header_t) + message_definition_xml_length + sizeof(itti_message_types_t);
|
||||
|
||||
itti_dump_message = calloc(1, itti_dump_message_size);
|
||||
|
||||
@@ -240,7 +226,8 @@ static int itti_dump_send_xml_definition(const int sd, const char *message_defin
|
||||
itti_dump_message->message_type = ITTI_DUMP_XML_DEFINITION;
|
||||
|
||||
/* Copying message definition */
|
||||
memcpy(&itti_dump_message[1], message_definition_xml, message_definition_xml_length);
|
||||
memcpy (&itti_dump_message[1], message_definition_xml, message_definition_xml_length);
|
||||
memcpy (((void *) &itti_dump_message[1]) + message_definition_xml_length, &itti_dump_xml_definition_end, sizeof(itti_message_types_t));
|
||||
|
||||
data_ptr = (uint8_t *)&itti_dump_message[0];
|
||||
|
||||
@@ -743,7 +730,6 @@ int itti_dump_queue_message(task_id_t sender_task,
|
||||
if (itti_dump_running)
|
||||
{
|
||||
itti_dump_queue_item_t *new;
|
||||
size_t message_name_length;
|
||||
|
||||
AssertFatal (message_name != NULL, "Message name is NULL!\n");
|
||||
AssertFatal (message_p != NULL, "Message is NULL!\n");
|
||||
@@ -768,10 +754,6 @@ int itti_dump_queue_message(task_id_t sender_task,
|
||||
new->data_size = message_size;
|
||||
new->message_number = message_number;
|
||||
|
||||
message_name_length = strlen(message_name) + 1;
|
||||
AssertError (message_name_length <= SIGNAL_NAME_LENGTH, {}, "Message name too long (%d/%d)!\n", (int) message_name_length, SIGNAL_NAME_LENGTH);
|
||||
memcpy(new->message_name, message_name, message_name_length);
|
||||
|
||||
itti_dump_enqueue_message(new, message_size, ITTI_DUMP_MESSAGE_TYPE);
|
||||
}
|
||||
|
||||
@@ -805,11 +787,12 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
|
||||
uint32_t message_size = strlen(messages_definition_xml) + 1;
|
||||
itti_socket_header_t header;
|
||||
|
||||
header.message_size = sizeof(itti_socket_header_t) + message_size;
|
||||
header.message_size = sizeof(itti_socket_header_t) + message_size + sizeof(itti_message_types_t);
|
||||
header.message_type = ITTI_DUMP_XML_DEFINITION;
|
||||
|
||||
fwrite (&header, sizeof(itti_socket_header_t), 1, dump_file);
|
||||
fwrite (messages_definition_xml, message_size, 1, dump_file);
|
||||
fwrite (&itti_dump_xml_definition_end, sizeof(itti_message_types_t), 1, dump_file);
|
||||
fflush (dump_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../../itti/itti_types.h
|
||||
@@ -110,7 +110,7 @@ static int socket_read_itti_message(socket_data_t *socket_data,
|
||||
}
|
||||
|
||||
/* Create the new buffer */
|
||||
if (buffer_new_from_data(&buffer, data, data_length, 1) != RC_OK) {
|
||||
if (buffer_new_from_data(&buffer, data, data_length - sizeof(itti_message_types_t), 1) != RC_OK) {
|
||||
g_error("Failed to create new buffer");
|
||||
g_assert_not_reached();
|
||||
}
|
||||
@@ -162,7 +162,7 @@ static int socket_read_xml_definition(socket_data_t *socket_data,
|
||||
} while (total_data_read != xml_definition_length);
|
||||
|
||||
pipe_xml_definition_message.xml_definition = xml_definition;
|
||||
pipe_xml_definition_message.xml_definition_length = xml_definition_length;
|
||||
pipe_xml_definition_message.xml_definition_length = xml_definition_length - sizeof(itti_message_types_t);
|
||||
|
||||
g_debug("Received XML definition of size %zu, effectively read %zu bytes",
|
||||
xml_definition_length, total_data_read);
|
||||
@@ -186,12 +186,14 @@ static int socket_read(socket_data_t *socket_data)
|
||||
}
|
||||
|
||||
switch(message_header.message_type) {
|
||||
case ITTI_DUMP_MESSAGE_TYPE:
|
||||
socket_read_itti_message(socket_data, &message_header);
|
||||
break;
|
||||
case ITTI_DUMP_XML_DEFINITION:
|
||||
socket_read_xml_definition(socket_data, &message_header);
|
||||
break;
|
||||
|
||||
case ITTI_DUMP_MESSAGE_TYPE:
|
||||
socket_read_itti_message(socket_data, &message_header);
|
||||
break;
|
||||
|
||||
case ITTI_STATISTIC_MESSAGE_TYPE:
|
||||
default:
|
||||
g_warning("Received unknow (or not implemented) message from socket type: %d",
|
||||
|
||||
@@ -712,7 +712,7 @@ int xml_parse_buffer(char *xml_buffer, const int size) {
|
||||
|
||||
if (doc == NULL) {
|
||||
g_warning("Failed to parse XML buffer: %s", xml_buffer);
|
||||
ui_notification_dialog(GTK_MESSAGE_ERROR, "parse messages format definition", "Fail to parse XML buffer");
|
||||
ui_notification_dialog(GTK_MESSAGE_ERROR, FALSE, "parse messages format definition", "Fail to parse XML buffer");
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ int xml_parse_file(const char *filename) {
|
||||
doc = xmlReadFile (filename, NULL, 0);
|
||||
|
||||
if (doc == NULL) {
|
||||
ui_notification_dialog(GTK_MESSAGE_ERROR, "parse messages format definition", "Failed to parse file \"%s\"", filename);
|
||||
ui_notification_dialog(GTK_MESSAGE_ERROR, FALSE, "parse messages format definition", "Failed to parse file \"%s\"", filename);
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ gboolean ui_callback_on_enable_filters(GtkWidget *widget, gpointer data)
|
||||
gboolean ui_callback_on_about(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
#if defined(PACKAGE_STRING)
|
||||
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom %s", PACKAGE_STRING);
|
||||
ui_notification_dialog (GTK_MESSAGE_INFO, FALSE, "about", "Eurecom %s", PACKAGE_STRING);
|
||||
#else
|
||||
ui_notification_dialog (GTK_MESSAGE_INFO, "about", "Eurecom itti_analyzer");
|
||||
ui_notification_dialog (GTK_MESSAGE_INFO, FALSE, "about", "Eurecom itti_analyzer");
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
@@ -533,12 +533,16 @@ gboolean ui_pipe_callback(gint source, gpointer user_data)
|
||||
{
|
||||
case UI_PIPE_CONNECTION_FAILED:
|
||||
return ui_handle_socket_connection_failed (source);
|
||||
case UI_PIPE_XML_DEFINITION:
|
||||
return ui_handle_socket_xml_definition (source, input_data, input_data_length);
|
||||
|
||||
case UI_PIPE_CONNECTION_LOST:
|
||||
return ui_handle_socket_connection_lost (source);
|
||||
|
||||
case UI_PIPE_XML_DEFINITION:
|
||||
return ui_handle_socket_xml_definition (source, input_data, input_data_length);
|
||||
|
||||
case UI_PIPE_UPDATE_SIGNAL_LIST:
|
||||
return ui_handle_update_signal_list (source, input_data, input_data_length);
|
||||
|
||||
default:
|
||||
g_warning("[gui] Unhandled message type %u", input_header.message_type);
|
||||
g_assert_not_reached();
|
||||
@@ -560,13 +564,13 @@ gboolean ui_callback_on_connect(GtkWidget *widget, gpointer data)
|
||||
|
||||
if (strlen (ip) == 0)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Empty host ip address");
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Empty host ip address");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (port == 0)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, "Connect", "Invalid host port value");
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "Connect", "Invalid host port value");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -376,14 +376,14 @@ int ui_filters_read(const char *file_name)
|
||||
doc = xmlReadFile (file_name, NULL, 0);
|
||||
if (doc == NULL)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, "open filters", "Failed to parse file \"%s\"", file_name);
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open filters", "Failed to parse file \"%s\"", file_name);
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
ret = xml_parse_filters (doc, file_name);
|
||||
if (ret != RC_OK)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, "open filters", "Found no filter definitions in \"%s\"",
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, FALSE, "open filters", "Found no filter definitions in \"%s\"",
|
||||
file_name);
|
||||
return RC_FAIL;
|
||||
}
|
||||
@@ -427,7 +427,7 @@ int ui_filters_file_write(const char *file_name)
|
||||
filter_file = fopen (file_name, "w");
|
||||
if (filter_file == NULL)
|
||||
{
|
||||
g_warning("Failed to open file \"%s\": %s", file_name, g_strerror (errno));
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Failed to open file \"%s\": %s", file_name, g_strerror (errno));
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
|
||||
#include "itti_types.h"
|
||||
|
||||
#define COLOR_SIZE 10
|
||||
#define SIGNAL_NAME_LENGTH 100
|
||||
#define COLOR_SIZE 10
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
||||
@@ -8,11 +8,12 @@
|
||||
static const char * const title_type[] =
|
||||
{"Info", "Warning", "Question", "Error", "Other"};
|
||||
|
||||
int ui_notification_dialog(GtkMessageType type, const char *title, const char *fmt, ...)
|
||||
int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
GtkWidget *dialogbox;
|
||||
char buffer[200];
|
||||
va_list args;
|
||||
GtkWidget *dialogbox;
|
||||
char buffer[200];
|
||||
int result = RC_OK;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
@@ -20,17 +21,22 @@ int ui_notification_dialog(GtkMessageType type, const char *title, const char *f
|
||||
|
||||
g_warning("%s", buffer);
|
||||
|
||||
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type, GTK_BUTTONS_OK, "%s",
|
||||
dialogbox = gtk_message_dialog_new (GTK_WINDOW(ui_main_data.window), GTK_DIALOG_MODAL, type,
|
||||
cancel ? GTK_BUTTONS_OK_CANCEL : GTK_BUTTONS_OK, "%s",
|
||||
buffer);
|
||||
gtk_dialog_set_default_response (GTK_DIALOG(dialogbox), GTK_RESPONSE_OK);
|
||||
|
||||
snprintf (buffer, sizeof(buffer), "%s: %s", title_type[type], title);
|
||||
gtk_window_set_title (GTK_WINDOW(dialogbox), buffer);
|
||||
|
||||
gtk_dialog_run (GTK_DIALOG (dialogbox));
|
||||
if (gtk_dialog_run (GTK_DIALOG (dialogbox)) == GTK_RESPONSE_CANCEL)
|
||||
{
|
||||
result = RC_FAIL;
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialogbox);
|
||||
|
||||
va_end(args);
|
||||
|
||||
return RC_OK;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
#ifndef UI_NOTIF_DLG_H_
|
||||
#define UI_NOTIF_DLG_H_
|
||||
|
||||
extern int ui_notification_dialog(GtkMessageType type, const char *title, const char *fmt, ...);
|
||||
extern int ui_notification_dialog(GtkMessageType type, gboolean cancel, const char *title, const char *fmt, ...);
|
||||
|
||||
#endif /* UI_NOTIF_DLG_H_ */
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
#include "locate_root.h"
|
||||
#include "xml_parse.h"
|
||||
|
||||
static const itti_message_types_t itti_dump_xml_definition_end = ITTI_DUMP_XML_DEFINITION_END;
|
||||
static const itti_message_types_t itti_dump_message_type_end = ITTI_DUMP_MESSAGE_TYPE_END;
|
||||
|
||||
static gboolean chooser_running;
|
||||
static FILE *messages_file;
|
||||
static uint32_t message_number;
|
||||
@@ -100,7 +103,7 @@ int ui_messages_read(char *file_name)
|
||||
source = open (file_name, O_RDONLY);
|
||||
if (source < 0)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, "open messages", "Failed to open file \"%s\": %s", file_name,
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open messages", "Failed to open file \"%s\": %s", file_name,
|
||||
g_strerror (errno));
|
||||
result = RC_FAIL;
|
||||
}
|
||||
@@ -113,7 +116,7 @@ int ui_messages_read(char *file_name)
|
||||
|
||||
if (stat (file_name, &st) < 0)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, "get file length",
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "get file length",
|
||||
"Failed to retrieve length for file \"%s\": %s", file_name, g_strerror (errno));
|
||||
result = RC_FAIL;
|
||||
}
|
||||
@@ -131,7 +134,7 @@ int ui_messages_read(char *file_name)
|
||||
|
||||
if (read_data == -1)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, "open messages", "Failed to read from file \"%s\": %s",
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open messages", "Failed to read from file \"%s\": %s",
|
||||
file_name, g_strerror (errno));
|
||||
result = RC_FAIL;
|
||||
break;
|
||||
@@ -144,8 +147,11 @@ int ui_messages_read(char *file_name)
|
||||
|
||||
if (read_data < sizeof(itti_socket_header_t))
|
||||
{
|
||||
g_warning(
|
||||
"Failed to read a complete message header from file \"%s\": %s", file_name, g_strerror (errno));
|
||||
if (ui_notification_dialog (GTK_MESSAGE_WARNING, TRUE, "open messages",
|
||||
"Failed to read a complete message header from file \"%s\": %s", file_name, g_strerror (errno)) == RC_FAIL)
|
||||
{
|
||||
read_data = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,8 +169,11 @@ int ui_messages_read(char *file_name)
|
||||
read_data = read (source, input_data, input_data_length);
|
||||
if (read_data < input_data_length)
|
||||
{
|
||||
g_warning(
|
||||
"Failed to read a complete message from file \"%s\": %s", file_name, g_strerror (errno));
|
||||
if (ui_notification_dialog (GTK_MESSAGE_WARNING, TRUE, "open messages",
|
||||
"Failed to read a complete message from file \"%s\": %s", file_name, g_strerror (errno)) == RC_FAIL)
|
||||
{
|
||||
read_data = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -173,54 +182,80 @@ int ui_messages_read(char *file_name)
|
||||
|
||||
switch (message_header.message_type)
|
||||
{
|
||||
case ITTI_DUMP_XML_DEFINITION:
|
||||
ui_gtk_flush_events ();
|
||||
if (memcmp (&(((char *) input_data)[input_data_length - sizeof (itti_message_types_t)]),
|
||||
&itti_dump_xml_definition_end, sizeof (itti_message_types_t)) == 0)
|
||||
{
|
||||
result = xml_parse_buffer (input_data, input_data_length - sizeof (itti_message_types_t));
|
||||
if (result != RC_OK)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open messages",
|
||||
"Error in parsing XML definitions in file \"%s\": %s", file_name,
|
||||
rc_strings[-result]);
|
||||
read_data = 0;
|
||||
}
|
||||
ui_gtk_flush_events ();
|
||||
g_message("Parsed XML definition from file \"%s\"", file_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "open messages",
|
||||
"Error in parsing XML definitions in file \"%s\", end mark is missing", file_name);
|
||||
}
|
||||
/* Data input buffer is kept in case user when to save the log file later */
|
||||
break;
|
||||
|
||||
case ITTI_DUMP_MESSAGE_TYPE:
|
||||
{
|
||||
itti_signal_header_t *itti_signal_header = input_data;
|
||||
buffer_t *buffer;
|
||||
|
||||
/* Create the new buffer */
|
||||
if (buffer_new_from_data (&buffer, input_data + sizeof(itti_signal_header_t),
|
||||
input_data_length - sizeof(itti_signal_header_t), 0) != RC_OK)
|
||||
if (memcmp (&(((char *) input_data)[input_data_length - sizeof (itti_message_types_t)]),
|
||||
&itti_dump_message_type_end, sizeof (itti_message_types_t)) == 0)
|
||||
{
|
||||
g_error("Failed to create new buffer");
|
||||
g_assert_not_reached ();
|
||||
/* Create the new buffer */
|
||||
if (buffer_new_from_data (&buffer, input_data + sizeof(itti_signal_header_t),
|
||||
input_data_length - sizeof(itti_signal_header_t) - sizeof(itti_message_types_t), 0) != RC_OK)
|
||||
{
|
||||
g_error("Failed to create new buffer");
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
buffer->message_number = itti_signal_header->message_number;
|
||||
|
||||
ui_signal_add_to_list (buffer, ((read_messages % 1000) == 0) ? (gpointer) 1 : NULL);
|
||||
|
||||
if ((read_messages % 100) == 0)
|
||||
{
|
||||
ui_progress_bar_set_fraction (read_fraction);
|
||||
ui_gtk_flush_events ();
|
||||
}
|
||||
|
||||
read_messages++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ui_notification_dialog (GTK_MESSAGE_WARNING, TRUE, "open messages",
|
||||
"Failed to read a message from file \"%s\", end mark is missing", file_name) == RC_FAIL)
|
||||
{
|
||||
read_data = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
buffer->message_number = itti_signal_header->message_number;
|
||||
|
||||
ui_signal_add_to_list (buffer, ((read_messages % 1000) == 0) ? (gpointer) 1 : NULL);
|
||||
|
||||
if ((read_messages % 100) == 0)
|
||||
{
|
||||
ui_progress_bar_set_fraction (read_fraction);
|
||||
ui_gtk_flush_events ();
|
||||
}
|
||||
|
||||
read_messages++;
|
||||
free (input_data);
|
||||
break;
|
||||
}
|
||||
|
||||
case ITTI_DUMP_XML_DEFINITION:
|
||||
ui_gtk_flush_events ();
|
||||
result = xml_parse_buffer (input_data, input_data_length);
|
||||
if (result != RC_OK)
|
||||
{
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, "open messages",
|
||||
"Error in parsing XML definitions in file \"%s\": %s", file_name,
|
||||
rc_strings[-result]);
|
||||
read_data = 0;
|
||||
}
|
||||
ui_gtk_flush_events ();
|
||||
g_message("Parsed XML definition from file \"%s\"", file_name);
|
||||
/* Data input buffer is kept in case user when to save the log file later */
|
||||
break;
|
||||
|
||||
case ITTI_STATISTIC_MESSAGE_TYPE:
|
||||
default:
|
||||
ui_notification_dialog (GTK_MESSAGE_WARNING, "open messages",
|
||||
"Unknown (or not implemented) record type: %d in file \"%s\"",
|
||||
message_header.message_type, file_name);
|
||||
if (ui_notification_dialog (GTK_MESSAGE_WARNING, TRUE, "open messages",
|
||||
"Unknown (or not implemented) record type: %d in file \"%s\"",
|
||||
message_header.message_type, file_name) == RC_FAIL)
|
||||
{
|
||||
read_data = 0;
|
||||
}
|
||||
|
||||
free (input_data);
|
||||
break;
|
||||
@@ -266,17 +301,16 @@ static void ui_message_write_callback(const gpointer buffer, const gchar *signal
|
||||
|
||||
message_size = signal_buffer->size_bytes;
|
||||
|
||||
message_header.message_size = sizeof(itti_socket_header_t) + sizeof(itti_signal_header) + message_size;
|
||||
message_header.message_size = sizeof(itti_socket_header_t) + sizeof(itti_signal_header) + message_size + sizeof(itti_message_types_t);
|
||||
message_header.message_type = ITTI_DUMP_MESSAGE_TYPE;
|
||||
|
||||
itti_signal_header.message_number = message_number;
|
||||
message_number++;
|
||||
memset (itti_signal_header.signal_name, 0, sizeof(itti_signal_header.signal_name));
|
||||
strncpy (itti_signal_header.signal_name, signal_name, sizeof(itti_signal_header.signal_name));
|
||||
|
||||
fwrite (&message_header, sizeof(message_header), 1, messages_file);
|
||||
fwrite (&itti_signal_header, sizeof(itti_signal_header), 1, messages_file);
|
||||
fwrite (signal_buffer->data, message_size, 1, messages_file);
|
||||
fwrite (&itti_dump_message_type_end, sizeof(itti_message_types_t), 1, messages_file);
|
||||
}
|
||||
|
||||
static int ui_messages_file_write(char *file_name)
|
||||
@@ -290,7 +324,7 @@ static int ui_messages_file_write(char *file_name)
|
||||
messages_file = fopen (file_name, "w");
|
||||
if (messages_file == NULL)
|
||||
{
|
||||
g_warning("Failed to open file \"%s\": %s", file_name, g_strerror (errno));
|
||||
ui_notification_dialog (GTK_MESSAGE_ERROR, FALSE, "Failed to open file \"%s\": %s", file_name, g_strerror (errno));
|
||||
return RC_FAIL;
|
||||
}
|
||||
|
||||
@@ -298,11 +332,12 @@ static int ui_messages_file_write(char *file_name)
|
||||
{
|
||||
itti_socket_header_t message_header;
|
||||
|
||||
message_header.message_size = xml_raw_data_size + sizeof(itti_socket_header_t);
|
||||
message_header.message_size = sizeof(itti_socket_header_t) + xml_raw_data_size + sizeof(itti_message_types_t);
|
||||
message_header.message_type = ITTI_DUMP_XML_DEFINITION;
|
||||
|
||||
fwrite (&message_header, sizeof(message_header), 1, messages_file);
|
||||
fwrite (xml_raw_data, xml_raw_data_size, 1, messages_file);
|
||||
fwrite (&itti_dump_xml_definition_end, sizeof(itti_message_types_t), 1, messages_file);
|
||||
}
|
||||
|
||||
/* Write messages */
|
||||
|
||||
@@ -107,7 +107,7 @@ static void ui_tree_view_init_list(GtkWidget *list)
|
||||
|
||||
column = gtk_tree_view_column_new_with_attributes ("Message", renderer_left, "text", COL_MESSAGE, "foreground",
|
||||
COL_FOREGROUND, "background", COL_BACKGROUND, "strikethrough",
|
||||
COL_STRIKETHROUGH, NULL);
|
||||
COL_STRIKETHROUGH, "style", COL_STYLE, "weight", COL_WEIGHT, "underline", COL_UNDERLINE, NULL);
|
||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||
gtk_tree_view_column_set_alignment (column, 0.5);
|
||||
gtk_tree_view_append_column (GTK_TREE_VIEW(list), column);
|
||||
@@ -151,6 +151,9 @@ static void ui_tree_view_init_list(GtkWidget *list)
|
||||
G_TYPE_STRING, // COL_FOREGROUND
|
||||
G_TYPE_STRING, // COL_BACKGROUND
|
||||
G_TYPE_BOOLEAN, // COL_STRIKETHROUGH
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_UINT,
|
||||
// Reference to the buffer here to avoid maintaining multiple lists.
|
||||
G_TYPE_POINTER);
|
||||
|
||||
@@ -173,6 +176,8 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
|
||||
const char *origin_task_name, const uint32_t destination_task_id,
|
||||
const char *destination_task_name, uint32_t instance_id, const char *instance_name, gpointer buffer)
|
||||
{
|
||||
static int counter = 0;
|
||||
|
||||
GtkTreeIter iter;
|
||||
gboolean enabled;
|
||||
int message_index;
|
||||
@@ -193,8 +198,15 @@ static void ui_tree_view_add_to_list(GtkWidget *list, const gchar *lte_time, con
|
||||
COL_FROM_TASK_ID, origin_task_id, COL_TO_TASK_ID, destination_task_id, COL_INSTANCE_ID, instance_id,
|
||||
COL_BUFFER, buffer, COL_FOREGROUND, ui_filters.messages.items[message_index].foreground, COL_BACKGROUND,
|
||||
ui_filters.messages.items[message_index].background, COL_STRIKETHROUGH, !enabled,
|
||||
// COL_STYLE, (counter % 2) == 0 ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL,
|
||||
// COL_WEIGHT, ((counter + 2) % 4) < 2 ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
|
||||
// COL_UNDERLINE, ((counter + 4) % 8) < 4 ?PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE,
|
||||
COL_STYLE, PANGO_STYLE_NORMAL,
|
||||
COL_WEIGHT, PANGO_WEIGHT_NORMAL,
|
||||
COL_UNDERLINE, PANGO_UNDERLINE_NONE,
|
||||
/* End of columns */
|
||||
-1);
|
||||
counter++;
|
||||
}
|
||||
|
||||
void ui_tree_view_destroy_list(GtkWidget *list)
|
||||
|
||||
@@ -20,6 +20,9 @@ typedef enum col_type_e
|
||||
COL_FOREGROUND,
|
||||
COL_BACKGROUND,
|
||||
COL_STRIKETHROUGH,
|
||||
COL_STYLE,
|
||||
COL_WEIGHT,
|
||||
COL_UNDERLINE,
|
||||
|
||||
COL_BUFFER,
|
||||
NUM_COLS
|
||||
|
||||
Reference in New Issue
Block a user