Commit fef704c7 authored by winckel's avatar winckel

Completed log file read in itti_analyzer.

Creates a common types definition file for itti_analyzer.
Set message start number to 1.
Changed message name field to 48 char to avoid alignment issues.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4311 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 5d434368
......@@ -392,7 +392,7 @@ void itti_terminate_tasks(task_id_t task_id) {
int itti_init(thread_id_t thread_max, MessagesIds messages_id_max, const char * const *threads_name,
const message_info_t *messages_info, const char * const messages_definition_xml, const char * const dump_file_name) {
int i;
itti_desc.message_number = 0;
itti_desc.message_number = 1;
ITTI_DEBUG( "Init: %d threads, %d messages\n", thread_max, messages_id_max);
......
......@@ -55,7 +55,7 @@
#include "intertask_interface.h"
#include "intertask_interface_dump.h"
#define SIGNAL_NAME_LENGTH 50
#define SIGNAL_NAME_LENGTH 48
/* Declared in intertask_interface.c */
extern int itti_debug;
......@@ -282,7 +282,6 @@ int itti_dump_queue_message(message_number_t message_number,
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_size, sizeof(new->data_size), 1, dump_file);
fwrite (new->data, new->data_size, 1, dump_file);
}
......
/*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)queue.h 8.5 (Berkeley) 8/20/94
*/
#ifndef _ITTI_TYPES_H_
#define _ITTI_TYPES_H_
/* 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
/* Message header is the common part that should never change between
* remote process and this one.
*/
typedef struct {
/* The size of this structure */
uint32_t message_size;
uint32_t message_type;
} itti_socket_header_t;
#define SIGNAL_NAME_LENGTH 48
typedef struct {
uint32_t message_number;
char signal_name[SIGNAL_NAME_LENGTH];
} itti_signal_header_t;
#endif
......@@ -9,6 +9,7 @@
#include <gtk/gtk.h>
#include "itti_types.h"
#include "rc.h"
#include "ui_interface.h"
......@@ -23,20 +24,6 @@
#define SOCKET_NB_SIGNALS_BEFORE_SIGNALLING 10
#define SOCKET_MS_BEFORE_SIGNALLING 100
/* Message header is the common part that should never change between
* remote process and this one.
*/
typedef struct {
/* The size of this structure */
uint32_t message_size;
uint32_t message_type;
} itti_socket_header_t;
typedef struct {
uint32_t message_number;
char signal_name[50];
} itti_signal_header_t;
void *socket_thread_fct(void *arg);
static ssize_t socket_read_data(socket_data_t *socket_data, void *buffer, size_t size, int flags)
......@@ -196,13 +183,13 @@ static int socket_read(socket_data_t *socket_data)
}
switch(message_header.message_type) {
case 1:
case ITTI_DUMP_MESSAGE_TYPE:
socket_read_itti_message(socket_data, &message_header);
break;
case 3:
case ITTI_DUMP_XML_DEFINITION:
socket_read_xml_definition(socket_data, &message_header);
break;
case 2:
case ITTI_STATISTIC_MESSAGE_TYPE:
default:
g_debug("Received unknow (or not implemented) message from socket type: %d",
message_header.message_type);
......
......@@ -73,7 +73,6 @@ ui_callback_on_select_signal(GtkTreeSelection *selection,
return TRUE;
}
static
void ui_signal_add_to_list(gpointer data, gpointer user_data)
{
buffer_t *signal_buffer;
......
......@@ -9,6 +9,9 @@ gboolean ui_callback_on_about(GtkWidget *widget,
GdkEvent *event,
gpointer data);
void ui_signal_add_to_list(gpointer data,
gpointer user_data);
gboolean ui_callback_on_connect(GtkWidget *widget,
GdkEvent *event,
gpointer data);
......
#include <fcntl.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdarg.h>
#include <gtk/gtk.h>
#include "itti_types.h"
#include "rc.h"
#include "ui_interface.h"
#include "ui_main_screen.h"
#include "ui_notifications.h"
#include "ui_callbacks.h"
#include "xml_parse.h"
int ui_disable_connect_button(void)
{
/* Disable Connect button and enable disconnect button */
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.connect), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.disconnect), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (ui_main_data.connect), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (ui_main_data.disconnect), TRUE);
return RC_OK;
}
......@@ -24,8 +27,8 @@ int ui_disable_connect_button(void)
int ui_enable_connect_button(void)
{
/* Disable Disconnect button and enable connect button */
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.connect), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(ui_main_data.disconnect), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (ui_main_data.connect), TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (ui_main_data.disconnect), FALSE);
return RC_OK;
}
......@@ -33,25 +36,105 @@ int ui_enable_connect_button(void)
int ui_file_chooser(void)
{
GtkWidget *filechooser;
int result = RC_OK;
filechooser = gtk_file_chooser_dialog_new(
"Select file", GTK_WINDOW(ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
filechooser = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (ui_main_data.window),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
/* Process the response */
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
char *filename;
int source;
int read_data = 0;
void *input_data = NULL;
size_t input_data_length = 0;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
xml_parse_file(filename);
g_free(filename);
source = open (filename, O_RDONLY);
if (source >= 0)
{
itti_socket_header_t message_header;
do
{
read_data = read (source, &message_header, sizeof(itti_socket_header_t));
if (read_data == -1)
{
g_warning ("Failed to read from file \"%s\": %s", filename, g_strerror (errno));
result = RC_FAIL;
break;
}
if (read_data > 0)
{
input_data_length = message_header.message_size - sizeof(itti_socket_header_t);
// g_debug ("%x, %x ,%x\n", message_header.message_type, message_header.message_size, input_data_length);
/* Checking for non-header part */
if (input_data_length > 0)
{
input_data = malloc (input_data_length);
if (read (source, input_data, input_data_length) < 0)
{
g_warning ("Failed to read from file \"%s\": %s", filename, g_strerror (errno));
result = RC_FAIL;
break;
}
}
switch (message_header.message_type)
{
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)
{
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, NULL);
break;
}
case ITTI_DUMP_XML_DEFINITION:
xml_parse_buffer (input_data, input_data_length);
break;
case ITTI_STATISTIC_MESSAGE_TYPE:
default:
g_debug ("Received unknow (or not implemented) message from socket type: %d",
message_header.message_type);
break;
}
free (input_data);
}
} while (read_data > 0);
g_debug ("Read %d message from file \"%s\"\n", ui_main_data.nb_message_received, filename);
close (source);
}
g_free (filename);
}
gtk_widget_destroy (filechooser);
return RC_OK;
return result;
}
int ui_progress_bar_set_fraction(double fraction)
......
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