2006-03-09 16:00:33 +00:00
|
|
|
/*
|
2004-09-07 07:54:50 +00:00
|
|
|
* Copyright 2004, Irene Ruengeler <i.ruengeler [AT] fh-muenster.de>
|
|
|
|
*
|
2004-09-07 20:07:08 +00:00
|
|
|
* $Id$
|
2004-09-07 07:54:50 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-09-07 07:54:50 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "globals.h"
|
|
|
|
#include "epan/filesystem.h"
|
|
|
|
#include "../color.h"
|
|
|
|
#include "dlg_utils.h"
|
2005-12-01 15:15:42 +00:00
|
|
|
#include "ui_util.h"
|
2004-09-07 07:54:50 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "compat_macros.h"
|
|
|
|
#include "simple_dialog.h"
|
|
|
|
#include "sctp_stat.h"
|
|
|
|
|
|
|
|
#define DEFAULT_PIXELS_PER_TICK 2
|
2005-05-01 13:53:53 +00:00
|
|
|
#define MAX_PIXELS_PER_TICK 4
|
|
|
|
#define AUTO_MAX_YSCALE 0
|
|
|
|
#define MAX_TICK_VALUES 5
|
|
|
|
#define DEFAULT_TICK_VALUE 3
|
|
|
|
#define MAX_YSCALE 22
|
|
|
|
#define MAX_COUNT_TYPES 3
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
#define COUNT_TYPE_FRAMES 0
|
|
|
|
#define COUNT_TYPE_BYTES 1
|
|
|
|
#define COUNT_TYPE_ADVANCED 2
|
|
|
|
|
2005-12-01 15:15:42 +00:00
|
|
|
#define LEFT_BORDER 80
|
2005-05-01 13:53:53 +00:00
|
|
|
#define RIGHT_BORDER 10
|
|
|
|
#define TOP_BORDER 10
|
2004-09-07 07:54:50 +00:00
|
|
|
#define BOTTOM_BORDER 50
|
|
|
|
|
|
|
|
#define SUB_32(a, b) a-b
|
|
|
|
|
|
|
|
struct chunk_header {
|
2005-03-22 10:25:07 +00:00
|
|
|
guint8 type;
|
|
|
|
guint8 flags;
|
|
|
|
guint16 length;
|
2004-09-07 07:54:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct data_chunk_header {
|
2005-03-22 10:25:07 +00:00
|
|
|
guint8 type;
|
|
|
|
guint8 flags;
|
|
|
|
guint16 length;
|
|
|
|
guint32 tsn;
|
|
|
|
guint16 sid;
|
|
|
|
guint16 ssn;
|
|
|
|
guint32 ppi;
|
2004-09-07 07:54:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct init_chunk_header {
|
2005-03-22 10:25:07 +00:00
|
|
|
guint8 type;
|
|
|
|
guint8 flags;
|
|
|
|
guint16 length;
|
|
|
|
guint32 initiate_tag;
|
|
|
|
guint32 a_rwnd;
|
|
|
|
guint16 mos;
|
|
|
|
guint16 mis;
|
|
|
|
guint32 initial_tsn;
|
2004-09-07 07:54:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct sack_chunk_header {
|
2005-03-22 10:25:07 +00:00
|
|
|
guint8 type;
|
|
|
|
guint8 flags;
|
|
|
|
guint16 length;
|
|
|
|
guint32 cum_tsn_ack;
|
|
|
|
guint32 a_rwnd;
|
|
|
|
guint16 nr_of_gaps;
|
|
|
|
guint16 nr_of_dups;
|
|
|
|
guint8 *tsns;
|
2004-09-07 07:54:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gaps {
|
|
|
|
guint16 start;
|
|
|
|
guint16 end;
|
|
|
|
};
|
|
|
|
|
2006-01-23 11:56:49 +00:00
|
|
|
static gboolean label_set = FALSE;
|
|
|
|
static guint32 max_tsn=0, min_tsn=0;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void sctp_graph_set_title(struct sctp_udata *u_data);
|
|
|
|
static void create_draw_area(GtkWidget *box, struct sctp_udata *u_data);
|
2006-05-31 15:26:41 +00:00
|
|
|
static GtkWidget *zoomout_bt;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
static void draw_sack_graph(struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
GdkColor red_color = {0, 65535, 0, 0};
|
|
|
|
GdkColor green_color = {0, 0, 65535, 0};
|
|
|
|
GdkGC *red_gc, *green_gc;
|
2005-12-01 15:15:42 +00:00
|
|
|
gint diff;
|
2005-05-01 13:53:53 +00:00
|
|
|
GPtrArray *array = NULL;
|
2005-12-01 15:15:42 +00:00
|
|
|
guint32 i, size = 0, start=0, end;
|
2005-05-01 13:53:53 +00:00
|
|
|
gboolean more = FALSE;
|
2005-12-01 15:15:42 +00:00
|
|
|
gint width;
|
2005-03-22 10:25:07 +00:00
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GdkColormap *colormap;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
red_gc = gdk_gc_new(u_data->io->draw_area->window);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
colormap = gtk_widget_get_colormap (u_data->io->draw_area);
|
|
|
|
if (!gdk_color_alloc (colormap, &red_color))
|
|
|
|
{
|
|
|
|
g_warning ("Couldn't allocate color");
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_gc_set_foreground(red_gc, &red_color);
|
|
|
|
#else
|
|
|
|
gdk_gc_set_rgb_fg_color(red_gc, &red_color);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
green_gc = gdk_gc_new(u_data->io->draw_area->window);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
colormap = gtk_widget_get_colormap (u_data->io->draw_area);
|
|
|
|
if (!gdk_color_alloc (colormap, &green_color))
|
|
|
|
{
|
|
|
|
g_warning ("Couldn't allocate color");
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_gc_set_foreground(green_gc, &green_color);
|
|
|
|
#else
|
|
|
|
gdk_gc_set_rgb_fg_color(green_gc, &green_color);
|
|
|
|
#endif
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->dir == 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
array = u_data->assoc->sort_sack1;
|
|
|
|
size=u_data->assoc->n_sack_chunks_ep1;
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = 0;
|
|
|
|
max_tsn = u_data->assoc->max_bytes1;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = u_data->io->tmp_min_tsn1;
|
|
|
|
max_tsn = u_data->io->tmp_max_tsn1;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
else if (u_data->dir == 2)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
array = u_data->assoc->sort_sack2;
|
2005-05-01 13:53:53 +00:00
|
|
|
size = u_data->assoc->n_sack_chunks_ep2;
|
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = 0;
|
|
|
|
max_tsn = u_data->assoc->max_bytes2;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = u_data->io->tmp_min_tsn2;
|
|
|
|
max_tsn = u_data->io->tmp_max_tsn2;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-01 15:15:42 +00:00
|
|
|
width = u_data->io->max_x - u_data->io->min_x;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
for (i=0; i<size; i++)
|
|
|
|
{
|
2006-05-31 15:26:41 +00:00
|
|
|
if (u_data->io->uoff)
|
|
|
|
diff = (gint)((struct tsn_sort*)(g_ptr_array_index(array, i)))->secs - u_data->io->min_x;
|
|
|
|
else
|
|
|
|
diff = (gint)((struct tsn_sort*)(g_ptr_array_index(array, i)))->secs * 1000000 + ((struct tsn_sort*)(g_ptr_array_index(array, i)))->usecs - u_data->io->min_x;
|
2005-03-22 10:25:07 +00:00
|
|
|
end = start + ((struct tsn_sort*)(g_ptr_array_index(array, i)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
if (end>max_tsn)
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
end = max_tsn;
|
|
|
|
more = TRUE;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2005-12-01 15:15:42 +00:00
|
|
|
if (start >= min_tsn && diff > 0 && diff <= width)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
gdk_draw_line(u_data->io->pixmap,red_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval)),
|
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)));
|
|
|
|
if (more == TRUE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
gdk_draw_line(u_data->io->pixmap,green_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)),
|
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end+10,min_tsn))*u_data->io->y_interval)));
|
|
|
|
more = FALSE;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#if GTK_MAJOR_VERSION >= 2
|
|
|
|
g_object_unref(G_OBJECT(red_gc));
|
|
|
|
g_object_unref(G_OBJECT(green_gc));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void draw_tsn_graph(struct sctp_udata *u_data)
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
GPtrArray *array = NULL;
|
2005-12-01 15:15:42 +00:00
|
|
|
guint32 i, size = 0, start, end;
|
|
|
|
gint diff, width;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->dir == 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
array = u_data->assoc->sort_tsn1;
|
2005-05-01 13:53:53 +00:00
|
|
|
size = u_data->assoc->n_data_chunks_ep1;
|
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = 0;
|
|
|
|
max_tsn = u_data->assoc->max_bytes1;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = u_data->io->tmp_min_tsn1;
|
|
|
|
max_tsn = u_data->io->tmp_max_tsn1;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
else if (u_data->dir == 2)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
array = u_data->assoc->sort_tsn2;
|
2005-05-01 13:53:53 +00:00
|
|
|
size = u_data->assoc->n_data_chunks_ep2;
|
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = 0;
|
|
|
|
max_tsn = u_data->assoc->max_bytes2;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
min_tsn = u_data->io->tmp_min_tsn2;
|
|
|
|
max_tsn = u_data->io->tmp_max_tsn2;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-12-01 15:15:42 +00:00
|
|
|
width = u_data->io->max_x - u_data->io->min_x;
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
for (i=0; i<size; i++)
|
|
|
|
{
|
2006-05-31 15:26:41 +00:00
|
|
|
if (u_data->io->uoff)
|
|
|
|
diff = (gint)((struct tsn_sort*)(g_ptr_array_index(array, i)))->secs -u_data->io->min_x;
|
|
|
|
else
|
|
|
|
diff = (gint)((struct tsn_sort*)(g_ptr_array_index(array, i)))->secs*1000000 + ((struct tsn_sort*)(g_ptr_array_index(array, i)))->usecs-u_data->io->min_x;
|
2005-03-22 10:25:07 +00:00
|
|
|
start = ((struct tsn_sort*)(g_ptr_array_index(array, i)))->offset;
|
|
|
|
end = start + ((struct tsn_sort*)(g_ptr_array_index(array, i)))->length;
|
2005-12-01 15:15:42 +00:00
|
|
|
if (start >= min_tsn && diff > 0 && diff <= width)
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(start,min_tsn))*u_data->io->y_interval)),
|
|
|
|
(guint32)(LEFT_BORDER+u_data->io->offset+u_data->io->x_interval*diff),
|
|
|
|
(guint32)(u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-((SUB_32(end,min_tsn))*u_data->io->y_interval)));
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sctp_graph_draw(struct sctp_udata *u_data)
|
|
|
|
{
|
2006-05-31 15:26:41 +00:00
|
|
|
int length, lwidth;
|
|
|
|
guint32 distance=5, i, e, sec, w, start, a, j, b;
|
2006-03-30 22:17:42 +00:00
|
|
|
gint label_width, label_height;
|
2005-03-22 10:25:07 +00:00
|
|
|
char label_string[15];
|
|
|
|
gfloat dis;
|
2006-05-31 15:26:41 +00:00
|
|
|
gboolean write_label = FALSE;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GdkFont *font;
|
|
|
|
#else
|
2005-03-22 10:25:07 +00:00
|
|
|
PangoLayout *layout;
|
2004-09-07 07:54:50 +00:00
|
|
|
#endif
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->x1_tmp_sec == 0 && u_data->io->x1_tmp_usec == 0)
|
|
|
|
u_data->io->offset = 0;
|
2004-09-07 07:54:50 +00:00
|
|
|
else
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->offset = 5;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2006-05-31 15:26:41 +00:00
|
|
|
if (u_data->io->x2_tmp_sec - u_data->io->x1_tmp_sec > 1500)
|
|
|
|
{
|
|
|
|
u_data->io->min_x=u_data->io->x1_tmp_sec;
|
|
|
|
u_data->io->max_x=u_data->io->x2_tmp_sec;
|
|
|
|
u_data->io->uoff = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-21 03:26:26 +00:00
|
|
|
u_data->io->min_x=((guint32) (u_data->io->x1_tmp_sec*1000000.0))+u_data->io->x1_tmp_usec;
|
|
|
|
u_data->io->max_x=((guint32) (u_data->io->x2_tmp_sec*1000000.0))+u_data->io->x2_tmp_usec;
|
2006-05-31 15:26:41 +00:00
|
|
|
u_data->io->uoff = FALSE;
|
|
|
|
}
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->tmp_width = u_data->io->max_x - u_data->io->min_x;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->dir == 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->assoc->sort_tsn1 != NULL)
|
|
|
|
u_data->io->max_y = u_data->io->tmp_max_tsn1 - u_data->io->tmp_min_tsn1;
|
2004-09-07 07:54:50 +00:00
|
|
|
else
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->max_y = 0;
|
2004-09-07 07:54:50 +00:00
|
|
|
u_data->io->min_y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->max_y = u_data->io->tmp_max_tsn1;
|
|
|
|
u_data->io->min_y = u_data->io->tmp_min_tsn1;
|
|
|
|
}
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
else if (u_data->dir == 2)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->tmp == FALSE)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->assoc->tsn2 != NULL)
|
|
|
|
u_data->io->max_y = u_data->io->tmp_max_tsn2 - u_data->io->tmp_min_tsn2;
|
2004-09-07 07:54:50 +00:00
|
|
|
else
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->max_y = 0;
|
2004-09-07 07:54:50 +00:00
|
|
|
u_data->io->min_y = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->max_y = u_data->io->tmp_max_tsn2;
|
|
|
|
u_data->io->min_y = u_data->io->tmp_min_tsn2;
|
|
|
|
}
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_rectangle(u_data->io->pixmap, u_data->io->draw_area->style->white_gc,
|
|
|
|
TRUE, 0, 0, u_data->io->draw_area->allocation.width,
|
|
|
|
u_data->io->draw_area->allocation.height);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = 5;
|
2004-12-10 11:20:48 +00:00
|
|
|
/* x_axis */
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER+u_data->io->offset,u_data->io->pixmap_height - BOTTOM_BORDER,
|
|
|
|
u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset, u_data->io->pixmap_height - BOTTOM_BORDER);
|
|
|
|
gdk_draw_line(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
|
|
|
u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset, u_data->io->pixmap_height - BOTTOM_BORDER, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5, u_data->io->pixmap_height - BOTTOM_BORDER - 5);
|
|
|
|
gdk_draw_line(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
|
|
|
u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset, u_data->io->pixmap_height - BOTTOM_BORDER, u_data->io->pixmap_width - RIGHT_BORDER + u_data->io->offset - 5, u_data->io->pixmap_height - BOTTOM_BORDER + 5);
|
|
|
|
u_data->io->axis_width = u_data->io->pixmap_width - LEFT_BORDER - RIGHT_BORDER - u_data->io->offset;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2006-05-31 15:26:41 +00:00
|
|
|
if(u_data->io->tmp_width>0){
|
|
|
|
u_data->io->x_interval = (float)((u_data->io->axis_width*1.0)/u_data->io->tmp_width); /*distance in pixels between 2 data points*/
|
|
|
|
} else {
|
|
|
|
u_data->io->x_interval = (float)(u_data->io->axis_width);
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
e=0;
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->x_interval < 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
dis = 1 / u_data->io->x_interval;
|
2004-09-07 07:54:50 +00:00
|
|
|
while (dis >1)
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
dis /= 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
e++;
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = 1;
|
2004-09-07 07:54:50 +00:00
|
|
|
for (i=0; i<=e+1; i++)
|
2005-05-01 13:53:53 +00:00
|
|
|
distance *= 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = 5;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
font = u_data->io->draw_area->style->font;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
label_width = gdk_string_width(font, label_string);
|
|
|
|
label_height = gdk_string_height(font, label_string);
|
2004-09-07 07:54:50 +00:00
|
|
|
#else
|
|
|
|
g_snprintf(label_string, 15, "%d", 0);
|
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
2005-03-22 10:25:07 +00:00
|
|
|
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
|
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->x1_tmp_usec == 0)
|
|
|
|
sec = u_data->io->x1_tmp_sec;
|
2004-09-07 07:54:50 +00:00
|
|
|
else
|
2005-05-01 13:53:53 +00:00
|
|
|
sec = u_data->io->x1_tmp_sec+1;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->offset != 0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
g_snprintf(label_string, 15, "%u", u_data->io->x1_tmp_sec);
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
lwidth = gdk_string_width(font, label_string);
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_string(u_data->io->pixmap,font,u_data->io->draw_area->style->black_gc,
|
2006-05-31 15:26:41 +00:00
|
|
|
LEFT_BORDER - 25,
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 20,
|
2005-03-22 10:25:07 +00:00
|
|
|
label_string);
|
2004-09-07 07:54:50 +00:00
|
|
|
#else
|
2005-03-22 10:25:07 +00:00
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_layout(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
2006-05-31 15:26:41 +00:00
|
|
|
LEFT_BORDER - 25,
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 20,
|
2005-03-22 10:25:07 +00:00
|
|
|
layout);
|
2004-09-07 07:54:50 +00:00
|
|
|
#endif
|
2005-03-22 10:25:07 +00:00
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
w = (guint32)(500 / (guint32)(distance * u_data->io->x_interval));
|
|
|
|
if (w == 0)
|
|
|
|
w = 1;
|
2006-05-31 15:26:41 +00:00
|
|
|
if (w == 4 || w==3 || w==2)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
w = 5;
|
|
|
|
a = distance / 10;
|
2006-05-31 15:26:41 +00:00
|
|
|
b = (guint32)((u_data->io->min_x/100000))%10; /* start for labels*/
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
a = distance / 5;
|
|
|
|
b = 0;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2006-05-31 15:26:41 +00:00
|
|
|
if (!u_data->io->uoff)
|
|
|
|
{
|
|
|
|
if (a>=1000000)
|
|
|
|
{
|
|
|
|
start=u_data->io->min_x/1000000*1000000;
|
|
|
|
if (a==1000000)
|
|
|
|
b = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start=u_data->io->min_x/100000;
|
|
|
|
if (start%2!=0)
|
|
|
|
start--;
|
|
|
|
start*=100000;
|
|
|
|
b = (guint32)((start/100000))%10;
|
|
|
|
}
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
else
|
|
|
|
{
|
2006-05-31 15:26:41 +00:00
|
|
|
start = u_data->io->min_x;
|
|
|
|
if (start%2!=0)
|
2004-09-07 07:54:50 +00:00
|
|
|
start--;
|
2006-05-31 15:26:41 +00:00
|
|
|
b = 0;
|
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=start, j=b; i<=u_data->io->max_x; i+=a, j++)
|
|
|
|
{
|
2006-05-31 15:26:41 +00:00
|
|
|
if (!u_data->io->uoff)
|
2005-05-01 13:53:53 +00:00
|
|
|
if (i >= u_data->io->min_x && i % 1000000 != 0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
length = 5;
|
2004-09-07 07:54:50 +00:00
|
|
|
g_snprintf(label_string, 15, "%d", i%1000000);
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (j % w == 0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
length = 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
lwidth = gdk_string_width(font, label_string);
|
2004-09-07 07:54:50 +00:00
|
|
|
gdk_draw_string(u_data->io->pixmap,font,u_data->io->draw_area->style->black_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i-u_data->io->min_x) * u_data->io->x_interval - lwidth / 2),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 10,
|
|
|
|
label_string);
|
2004-09-07 07:54:50 +00:00
|
|
|
#else
|
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_layout(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval - lwidth / 2),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 10,
|
|
|
|
layout);
|
2004-09-07 07:54:50 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER,
|
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + length);
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2006-05-31 15:26:41 +00:00
|
|
|
if (!u_data->io->uoff)
|
|
|
|
{
|
|
|
|
if (i%1000000==0 && j%w==0)
|
|
|
|
{
|
|
|
|
sec=i/1000000;
|
|
|
|
write_label = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (j%w == 0)
|
|
|
|
{
|
|
|
|
sec = i;
|
|
|
|
write_label = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (write_label)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
gdk_draw_line(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER,
|
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval),
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 10);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
g_snprintf(label_string, 15, "%d", sec);
|
2005-03-22 10:25:07 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
lwidth = gdk_string_width(font, label_string);
|
2004-09-07 07:54:50 +00:00
|
|
|
gdk_draw_string(u_data->io->pixmap,font,u_data->io->draw_area->style->black_gc,
|
2006-05-31 15:26:41 +00:00
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval-10),
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 20,
|
|
|
|
label_string);
|
2005-03-22 10:25:07 +00:00
|
|
|
#else
|
2004-09-07 07:54:50 +00:00
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
|
|
|
|
|
|
|
gdk_draw_layout(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
2006-05-31 15:26:41 +00:00
|
|
|
(guint32)(LEFT_BORDER + u_data->io->offset + (i - u_data->io->min_x) * u_data->io->x_interval-10),
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 20,
|
|
|
|
layout);
|
2005-03-22 10:25:07 +00:00
|
|
|
#endif
|
2006-05-31 15:26:41 +00:00
|
|
|
write_label = FALSE;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(label_string, "sec");
|
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
lwidth = gdk_string_width(font, label_string);
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_string(u_data->io->pixmap,
|
|
|
|
font,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_width - RIGHT_BORDER - 10,
|
2006-05-31 15:26:41 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 30,
|
2005-03-22 10:25:07 +00:00
|
|
|
label_string);
|
|
|
|
#else
|
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
|
|
|
gdk_draw_layout(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap_width - RIGHT_BORDER - 10,
|
2006-05-31 15:26:41 +00:00
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER + 30,
|
2005-03-22 10:25:07 +00:00
|
|
|
layout);
|
|
|
|
#endif
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = 5;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2004-12-10 11:20:48 +00:00
|
|
|
/* y-axis */
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER,TOP_BORDER - u_data->io->offset,
|
|
|
|
LEFT_BORDER,
|
|
|
|
u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset);
|
|
|
|
gdk_draw_line(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER,
|
2006-03-09 16:00:33 +00:00
|
|
|
TOP_BORDER - u_data->io->offset,
|
|
|
|
LEFT_BORDER - 5,
|
2005-05-01 13:53:53 +00:00
|
|
|
TOP_BORDER - u_data->io->offset + 5);
|
|
|
|
gdk_draw_line(u_data->io->pixmap,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER,
|
2006-03-09 16:00:33 +00:00
|
|
|
TOP_BORDER - u_data->io->offset,
|
|
|
|
LEFT_BORDER + 5,
|
2005-05-01 13:53:53 +00:00
|
|
|
TOP_BORDER - u_data->io->offset + 5);
|
|
|
|
|
|
|
|
u_data->io->y_interval = (float)(((u_data->io->pixmap_height - TOP_BORDER - BOTTOM_BORDER) * 1.0)/(u_data->io->max_y - u_data->io->min_y));
|
|
|
|
|
|
|
|
e = 0;
|
|
|
|
if (u_data->io->y_interval < 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
dis = 1 / u_data->io->y_interval;
|
|
|
|
while (dis > 1)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
dis /= 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
e++;
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = 1;
|
2004-09-07 07:54:50 +00:00
|
|
|
for (i=0; i<=e; i++)
|
2005-05-01 13:53:53 +00:00
|
|
|
distance = distance * 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
2006-05-31 15:26:41 +00:00
|
|
|
else if (u_data->io->y_interval<2)
|
|
|
|
distance = 10;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (u_data->io->max_y > 0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
for (i=u_data->io->min_y/distance*distance; i<=u_data->io->max_y; i+=distance/5)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
if (i >= u_data->io->min_y)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
length = 5;
|
2005-03-22 10:25:07 +00:00
|
|
|
g_snprintf(label_string, 15, "%d", i);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
if (i%distance == 0 || (distance <= 5 && u_data->io->y_interval > 10))
|
2005-03-22 10:25:07 +00:00
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
length = 10;
|
2005-03-22 10:25:07 +00:00
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2005-05-01 13:53:53 +00:00
|
|
|
lwidth = gdk_string_width(font, label_string);
|
|
|
|
gdk_draw_string(u_data->io->pixmap,font,
|
|
|
|
u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER - length - lwidth - 5,
|
|
|
|
(guint32)(u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval - 3),
|
2005-03-22 10:25:07 +00:00
|
|
|
label_string);
|
|
|
|
#else
|
2004-09-07 07:54:50 +00:00
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
|
|
|
gdk_draw_layout(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
2005-05-01 13:53:53 +00:00
|
|
|
LEFT_BORDER - length - lwidth - 5,
|
|
|
|
(guint32)(u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval - 3),
|
2005-03-22 10:25:07 +00:00
|
|
|
layout);
|
|
|
|
#endif
|
|
|
|
}
|
2005-05-01 13:53:53 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
|
|
|
LEFT_BORDER - length,
|
|
|
|
(guint32)(u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval),
|
|
|
|
LEFT_BORDER,
|
|
|
|
(guint32)(u_data->io->pixmap_height - BOTTOM_BORDER - u_data->io->offset - (i - u_data->io->min_y) * u_data->io->y_interval));
|
2005-03-22 10:25:07 +00:00
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-04 22:45:15 +00:00
|
|
|
else
|
|
|
|
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, "No Data Chunks sent");
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sctp_graph_redraw(struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_graph_t *ios;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->needs_redraw = TRUE;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
sctp_graph_draw(u_data);
|
|
|
|
switch (u_data->io->graph_type)
|
|
|
|
{
|
|
|
|
case 0:
|
2005-03-22 10:25:07 +00:00
|
|
|
draw_sack_graph(u_data);
|
|
|
|
draw_tsn_graph(u_data);
|
|
|
|
break;
|
2006-03-09 16:00:33 +00:00
|
|
|
case 1:
|
2005-03-22 10:25:07 +00:00
|
|
|
draw_tsn_graph(u_data);
|
|
|
|
break;
|
2004-09-07 07:54:50 +00:00
|
|
|
case 2:
|
2005-03-22 10:25:07 +00:00
|
|
|
draw_sack_graph(u_data);
|
|
|
|
break;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
ios=(sctp_graph_t *)OBJECT_GET_DATA(u_data->io->draw_area, "sctp_graph_t");
|
|
|
|
|
|
|
|
if(!ios){
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gdk_draw_pixmap(u_data->io->draw_area->window,
|
2005-03-22 10:25:07 +00:00
|
|
|
u_data->io->draw_area->style->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)],
|
|
|
|
ios->pixmap,
|
|
|
|
0,0,
|
|
|
|
0, 0,
|
|
|
|
u_data->io->draw_area->allocation.width,
|
|
|
|
u_data->io->draw_area->allocation.height);
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void on_sack_bt(GtkWidget *widget _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
|
|
|
u_data = (struct sctp_udata *) u_data;
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->graph_type = 2;
|
2004-09-07 07:54:50 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_tsn_bt(GtkWidget *widget _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->graph_type = 1;
|
2004-09-07 07:54:50 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_both_bt(GtkWidget *widget _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->graph_type = 0;
|
2004-09-07 07:54:50 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
sctp_graph_close_cb(GtkWidget* widget _U_, gpointer u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
struct sctp_udata *udata;
|
|
|
|
int dir;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
udata = (struct sctp_udata *)u_data;
|
2005-05-01 13:53:53 +00:00
|
|
|
dir = udata->dir - 1;
|
2004-09-07 07:54:50 +00:00
|
|
|
gtk_grab_remove(GTK_WIDGET(udata->io->window));
|
2005-03-22 10:25:07 +00:00
|
|
|
gtk_widget_destroy(GTK_WIDGET(udata->io->window));
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
|
|
|
if(!u_data->io){
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(u_data->io->pixmap){
|
|
|
|
gdk_pixmap_unref(u_data->io->pixmap);
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap = NULL;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2005-05-01 13:53:53 +00:00
|
|
|
u_data->io->pixmap = gdk_pixmap_new(widget->window,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height,
|
|
|
|
-1);
|
|
|
|
u_data->io->pixmap_width = widget->allocation.width;
|
|
|
|
u_data->io->pixmap_height = widget->allocation.height;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
gdk_draw_rectangle(u_data->io->pixmap,
|
2005-03-22 10:25:07 +00:00
|
|
|
widget->style->white_gc,
|
|
|
|
TRUE,
|
|
|
|
0, 0,
|
|
|
|
widget->allocation.width,
|
|
|
|
widget->allocation.height);
|
2005-02-04 22:45:15 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
2004-09-07 07:54:50 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
expose_event(GtkWidget *widget, GdkEventExpose *event)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_graph_t *ios;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
ios=(sctp_graph_t *)OBJECT_GET_DATA(widget, "sctp_graph_t");
|
|
|
|
if(!ios){
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
gdk_draw_pixmap(widget->window,
|
2005-03-22 10:25:07 +00:00
|
|
|
widget->style->fg_gc[GTK_WIDGET_STATE(widget)],
|
|
|
|
ios->pixmap,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.x, event->area.y,
|
|
|
|
event->area.width, event->area.height);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_zoomin_bt (GtkWidget *widget _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_min_max_t *tmp_minmax;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
if (u_data->io->rectangle==TRUE)
|
|
|
|
{
|
|
|
|
tmp_minmax = g_malloc(sizeof(sctp_min_max_t));
|
|
|
|
|
|
|
|
u_data->io->tmp_min_tsn1=u_data->io->y1_tmp+u_data->io->min_y;
|
|
|
|
u_data->io->tmp_max_tsn1=u_data->io->y2_tmp+1+u_data->io->min_y;
|
2005-12-01 15:15:42 +00:00
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
u_data->io->tmp_min_tsn2=u_data->io->tmp_min_tsn1;
|
|
|
|
u_data->io->tmp_max_tsn2=u_data->io->tmp_max_tsn1;
|
|
|
|
tmp_minmax->tmp_min_secs=u_data->io->x1_tmp_sec;
|
|
|
|
tmp_minmax->tmp_min_usecs= u_data->io->x1_tmp_usec;
|
|
|
|
tmp_minmax->tmp_max_secs= u_data->io->x2_tmp_sec;
|
|
|
|
tmp_minmax->tmp_max_usecs= u_data->io->x2_tmp_usec;
|
|
|
|
tmp_minmax->tmp_min_tsn1=u_data->io->tmp_min_tsn1;
|
|
|
|
tmp_minmax->tmp_max_tsn1=u_data->io->tmp_max_tsn1;
|
|
|
|
tmp_minmax->tmp_min_tsn2=u_data->io->tmp_min_tsn2;
|
|
|
|
tmp_minmax->tmp_max_tsn2=u_data->io->tmp_max_tsn2;
|
|
|
|
u_data->assoc->min_max = g_slist_prepend(u_data->assoc->min_max, tmp_minmax);
|
|
|
|
u_data->io->length = g_slist_length(u_data->assoc->min_max);
|
|
|
|
u_data->io->tmp=TRUE;
|
|
|
|
u_data->io->rectangle=FALSE;
|
2006-05-31 15:26:41 +00:00
|
|
|
gtk_widget_set_sensitive(zoomout_bt, TRUE);
|
2004-09-07 07:54:50 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
2006-05-31 15:26:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "Please draw a rectangle around the area you want to zoom in!");
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2006-03-30 22:17:42 +00:00
|
|
|
static void
|
|
|
|
zoomin_bt (struct sctp_udata *u_data)
|
|
|
|
{
|
|
|
|
sctp_min_max_t *tmp_minmax;
|
|
|
|
|
|
|
|
tmp_minmax = g_malloc(sizeof(sctp_min_max_t));
|
|
|
|
|
|
|
|
u_data->io->tmp_min_tsn1=u_data->io->y1_tmp+u_data->io->min_y;
|
|
|
|
u_data->io->tmp_max_tsn1=u_data->io->y2_tmp+1+u_data->io->min_y;
|
|
|
|
|
|
|
|
u_data->io->tmp_min_tsn2=u_data->io->tmp_min_tsn1;
|
|
|
|
u_data->io->tmp_max_tsn2=u_data->io->tmp_max_tsn1;
|
|
|
|
tmp_minmax->tmp_min_secs=u_data->io->x1_tmp_sec;
|
|
|
|
tmp_minmax->tmp_min_usecs=u_data->io->x1_tmp_usec;
|
|
|
|
tmp_minmax->tmp_max_secs=u_data->io->x2_tmp_sec;
|
|
|
|
tmp_minmax->tmp_max_usecs=u_data->io->x2_tmp_usec;
|
|
|
|
tmp_minmax->tmp_min_tsn1=u_data->io->tmp_min_tsn1;
|
|
|
|
tmp_minmax->tmp_max_tsn1=u_data->io->tmp_max_tsn1;
|
|
|
|
tmp_minmax->tmp_min_tsn2=u_data->io->tmp_min_tsn2;
|
|
|
|
tmp_minmax->tmp_max_tsn2=u_data->io->tmp_max_tsn2;
|
|
|
|
u_data->assoc->min_max = g_slist_prepend(u_data->assoc->min_max, tmp_minmax);
|
|
|
|
u_data->io->length = g_slist_length(u_data->assoc->min_max);
|
|
|
|
u_data->io->tmp=TRUE;
|
|
|
|
u_data->io->rectangle=FALSE;
|
2006-05-31 15:26:41 +00:00
|
|
|
gtk_widget_set_sensitive(zoomout_bt, TRUE);
|
2006-03-30 22:17:42 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
static void
|
|
|
|
on_zoomout_bt (GtkWidget *widget _U_, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_min_max_t *tmp_minmax, *mm;
|
|
|
|
gint l;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
l = g_slist_length(u_data->assoc->min_max);
|
|
|
|
|
|
|
|
if (u_data->assoc->min_max!=NULL)
|
|
|
|
{
|
|
|
|
mm=(sctp_min_max_t *)((u_data->assoc->min_max)->data);
|
|
|
|
u_data->assoc->min_max=g_slist_remove(u_data->assoc->min_max, mm);
|
|
|
|
g_free(mm);
|
|
|
|
|
|
|
|
if (l>2)
|
|
|
|
{
|
|
|
|
tmp_minmax = (sctp_min_max_t *)u_data->assoc->min_max->data;
|
|
|
|
u_data->io->x1_tmp_sec=tmp_minmax->tmp_min_secs;
|
|
|
|
u_data->io->x1_tmp_usec=tmp_minmax->tmp_min_usecs;
|
|
|
|
u_data->io->x2_tmp_sec=tmp_minmax->tmp_max_secs;
|
|
|
|
u_data->io->x2_tmp_usec=tmp_minmax->tmp_max_usecs;
|
|
|
|
u_data->io->tmp_min_tsn1=tmp_minmax->tmp_min_tsn1;
|
|
|
|
u_data->io->tmp_max_tsn1=tmp_minmax->tmp_max_tsn1;
|
|
|
|
u_data->io->tmp_min_tsn2=tmp_minmax->tmp_min_tsn2;
|
|
|
|
u_data->io->tmp_max_tsn2=tmp_minmax->tmp_max_tsn2;
|
|
|
|
u_data->io->tmp=TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->x1_tmp_sec=u_data->assoc->min_secs;
|
|
|
|
u_data->io->x1_tmp_usec=u_data->assoc->min_usecs;
|
|
|
|
u_data->io->x2_tmp_sec=u_data->assoc->max_secs;
|
|
|
|
u_data->io->x2_tmp_usec=u_data->assoc->max_usecs;
|
|
|
|
u_data->io->tmp_min_tsn1=0;
|
|
|
|
u_data->io->tmp_max_tsn1=u_data->assoc->max_bytes1;
|
|
|
|
u_data->io->tmp_min_tsn2=0;
|
|
|
|
u_data->io->tmp_max_tsn2=u_data->assoc->max_bytes2;
|
|
|
|
u_data->io->tmp=FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->x1_tmp_sec=u_data->assoc->min_secs;
|
|
|
|
u_data->io->x1_tmp_usec=u_data->assoc->min_usecs;
|
|
|
|
u_data->io->x2_tmp_sec=u_data->assoc->max_secs;
|
|
|
|
u_data->io->x2_tmp_usec=u_data->assoc->max_usecs;
|
|
|
|
u_data->io->tmp_min_tsn1=0;
|
|
|
|
u_data->io->tmp_max_tsn1=u_data->assoc->max_bytes1;
|
|
|
|
u_data->io->tmp_min_tsn2=0;
|
|
|
|
u_data->io->tmp_max_tsn2=u_data->assoc->max_bytes2;
|
|
|
|
u_data->io->tmp=FALSE;
|
|
|
|
}
|
2006-05-31 15:26:41 +00:00
|
|
|
if (g_slist_length(u_data->assoc->min_max)==1)
|
|
|
|
gtk_widget_set_sensitive(zoomout_bt, FALSE);
|
2004-09-07 07:54:50 +00:00
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
on_button_press (GtkWidget *widget _U_, GdkEventButton *event, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_graph_t *ios;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
if (u_data->io->rectangle==TRUE)
|
|
|
|
{
|
|
|
|
gdk_draw_rectangle(u_data->io->pixmap,u_data->io->draw_area->style->white_gc,
|
2005-03-22 10:25:07 +00:00
|
|
|
FALSE,
|
2007-03-21 03:26:26 +00:00
|
|
|
(gint)floor(MIN(u_data->io->x_old,u_data->io->x_new)),
|
|
|
|
(gint)floor(MIN(u_data->io->y_old,u_data->io->y_new)),
|
2005-03-22 10:25:07 +00:00
|
|
|
(gint)abs((long)(u_data->io->x_new-u_data->io->x_old)),
|
|
|
|
(gint)abs((long)(u_data->io->y_new-u_data->io->y_old)));
|
|
|
|
ios=(sctp_graph_t *)OBJECT_GET_DATA(u_data->io->draw_area, "sctp_graph_t");
|
|
|
|
|
|
|
|
if(!ios){
|
|
|
|
exit(10);
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_pixmap(u_data->io->draw_area->window,
|
|
|
|
u_data->io->draw_area->style->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)],
|
|
|
|
ios->pixmap,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
(gint)abs((long)(u_data->io->x_new-u_data->io->x_old)),
|
|
|
|
(gint)abs((long)(u_data->io->y_new-u_data->io->y_old)));
|
|
|
|
sctp_graph_redraw(u_data);
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
u_data->io->x_old=event->x;
|
|
|
|
u_data->io->y_old=event->y;
|
|
|
|
if (u_data->io->y_old>u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
|
|
|
|
u_data->io->y_old=u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset;
|
|
|
|
if (u_data->io->x_old<LEFT_BORDER+u_data->io->offset)
|
|
|
|
u_data->io->x_old=LEFT_BORDER+u_data->io->offset;
|
|
|
|
u_data->io->rectangle=FALSE;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
return TRUE;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
|
|
|
on_button_release (GtkWidget *widget _U_, GdkEventButton *event, struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_graph_t *ios;
|
2007-04-22 10:25:26 +00:00
|
|
|
guint32 helpx, helpy, x1_tmp, x2_tmp, y_value, frame;
|
2006-03-30 22:17:42 +00:00
|
|
|
gint label_width, label_height;
|
2007-04-22 10:25:26 +00:00
|
|
|
gdouble x_value, position, tfirst;
|
2006-01-23 11:56:49 +00:00
|
|
|
gint lwidth;
|
|
|
|
char label_string[30];
|
|
|
|
GdkGC *text_color;
|
2007-04-22 10:25:26 +00:00
|
|
|
GList *tsnlist=NULL;
|
|
|
|
tsn_t *tsn, *tmptsn;
|
2006-01-23 11:56:49 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GdkFont *font;
|
|
|
|
#else
|
|
|
|
PangoLayout *layout;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
font = u_data->io->draw_area->style->font;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
label_width=gdk_string_width(font, label_string);
|
|
|
|
label_height=gdk_string_height(font, label_string);
|
|
|
|
#else
|
|
|
|
g_snprintf(label_string, 15, "%d", 0);
|
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string);
|
|
|
|
pango_layout_get_pixel_size(layout, &label_width, &label_height);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2006-01-23 11:56:49 +00:00
|
|
|
#endif
|
2005-12-01 15:15:42 +00:00
|
|
|
if (event->y > u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)
|
2005-03-22 10:25:07 +00:00
|
|
|
event->y = u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset;
|
|
|
|
if (event->x < LEFT_BORDER+u_data->io->offset)
|
|
|
|
event->x = LEFT_BORDER+u_data->io->offset;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
if (abs((long)(event->x-u_data->io->x_old))>10 || abs((long)(event->y-u_data->io->y_old))>10)
|
|
|
|
{
|
2007-03-21 03:26:26 +00:00
|
|
|
u_data->io->rect_x_min = (guint32) floor(MIN(u_data->io->x_old,event->x));
|
|
|
|
u_data->io->rect_x_max = (guint32) ceil(MAX(u_data->io->x_old,event->x));
|
|
|
|
u_data->io->rect_y_min = (guint32) floor(MIN(u_data->io->y_old,event->y));
|
|
|
|
u_data->io->rect_y_max = (guint32) ceil(MAX(u_data->io->y_old,event->y));
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_rectangle(u_data->io->pixmap,u_data->io->draw_area->style->black_gc,
|
2006-03-30 22:17:42 +00:00
|
|
|
FALSE,
|
|
|
|
u_data->io->rect_x_min, u_data->io->rect_y_min,
|
|
|
|
u_data->io->rect_x_max - u_data->io->rect_x_min,
|
|
|
|
u_data->io->rect_y_max - u_data->io->rect_y_min);
|
2005-03-22 10:25:07 +00:00
|
|
|
ios=(sctp_graph_t *)OBJECT_GET_DATA(u_data->io->draw_area, "sctp_graph_t");
|
|
|
|
|
|
|
|
if(!ios){
|
|
|
|
exit(10);
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
gdk_draw_pixmap(u_data->io->draw_area->window,
|
|
|
|
u_data->io->draw_area->style->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)],
|
|
|
|
ios->pixmap,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
u_data->io->draw_area->allocation.width,
|
|
|
|
u_data->io->draw_area->allocation.height);
|
|
|
|
|
2007-03-21 03:26:26 +00:00
|
|
|
x1_tmp=(guint32) floor(u_data->io->min_x+((u_data->io->x_old-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width));
|
|
|
|
x2_tmp=(guint32) floor(u_data->io->min_x+((event->x-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width));
|
2006-03-09 16:00:33 +00:00
|
|
|
helpx=MIN(x1_tmp, x2_tmp);
|
2005-03-22 10:25:07 +00:00
|
|
|
if (helpx==x2_tmp)
|
|
|
|
{
|
|
|
|
x2_tmp=x1_tmp;
|
|
|
|
x1_tmp=helpx;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
2006-05-31 15:26:41 +00:00
|
|
|
if (u_data->io->uoff)
|
|
|
|
{
|
|
|
|
if (x2_tmp - x1_tmp <= 1500)
|
|
|
|
u_data->io->uoff = FALSE;
|
|
|
|
u_data->io->x1_tmp_sec=(guint32)x1_tmp;
|
|
|
|
u_data->io->x1_tmp_usec=0;
|
|
|
|
u_data->io->x2_tmp_sec=(guint32)x2_tmp;
|
|
|
|
u_data->io->x2_tmp_usec=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->x1_tmp_sec=(guint32)x1_tmp/1000000;
|
|
|
|
u_data->io->x1_tmp_usec=x1_tmp%1000000;
|
|
|
|
u_data->io->x2_tmp_sec=(guint32)x2_tmp/1000000;
|
|
|
|
u_data->io->x2_tmp_usec=x2_tmp%1000000;
|
|
|
|
}
|
2006-03-30 22:17:42 +00:00
|
|
|
u_data->io->x1_akt_sec = u_data->io->x1_tmp_sec;
|
|
|
|
u_data->io->x1_akt_usec = u_data->io->x1_tmp_usec;
|
|
|
|
u_data->io->x2_akt_sec = u_data->io->x2_tmp_sec;
|
|
|
|
u_data->io->x2_akt_usec = u_data->io->x2_tmp_usec;
|
2005-03-22 10:25:07 +00:00
|
|
|
|
2005-12-01 15:15:42 +00:00
|
|
|
u_data->io->y1_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-u_data->io->y_old)/u_data->io->y_interval);
|
|
|
|
u_data->io->y2_tmp=(guint32)((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y)/u_data->io->y_interval);
|
2006-03-09 16:00:33 +00:00
|
|
|
helpy = MIN(u_data->io->y1_tmp, u_data->io->y2_tmp);
|
|
|
|
u_data->io->y2_tmp = MAX(u_data->io->y1_tmp, u_data->io->y2_tmp);
|
2005-03-22 10:25:07 +00:00
|
|
|
u_data->io->y1_tmp = helpy;
|
|
|
|
u_data->io->x_new=event->x;
|
|
|
|
u_data->io->y_new=event->y;
|
|
|
|
u_data->io->rectangle=TRUE;
|
2006-03-30 22:17:42 +00:00
|
|
|
u_data->io->rectangle_present=TRUE;
|
2006-01-23 11:56:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-30 22:17:42 +00:00
|
|
|
if (u_data->io->rectangle_present==TRUE)
|
|
|
|
{
|
|
|
|
u_data->io->rectangle_present=FALSE;
|
|
|
|
if (event->x >= u_data->io->rect_x_min && event->x <= u_data->io->rect_x_max &&
|
|
|
|
event->y >= u_data->io->rect_y_min && event->y <= u_data->io->rect_y_max)
|
|
|
|
zoomin_bt(u_data);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
u_data->io->x1_tmp_sec = u_data->io->x1_akt_sec;
|
|
|
|
u_data->io->x1_tmp_usec = u_data->io->x1_akt_usec;
|
|
|
|
u_data->io->x2_tmp_sec = u_data->io->x2_akt_sec;
|
|
|
|
u_data->io->x2_tmp_usec = u_data->io->x2_akt_usec;
|
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (label_set)
|
2006-01-23 11:56:49 +00:00
|
|
|
{
|
|
|
|
label_set = FALSE;
|
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-22 21:16:30 +00:00
|
|
|
x_value = ((event->x-LEFT_BORDER-u_data->io->offset) * ((u_data->io->x2_tmp_sec+u_data->io->x2_tmp_usec/1000000.0)-(u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0)) / (u_data->io->pixmap_width-LEFT_BORDER-RIGHT_BORDER-u_data->io->offset))+u_data->io->x1_tmp_sec+u_data->io->x1_tmp_usec/1000000.0;
|
2007-03-21 03:26:26 +00:00
|
|
|
y_value = (guint32) floor((u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset-event->y) * (max_tsn - min_tsn) / (u_data->io->pixmap_height-BOTTOM_BORDER-u_data->io->offset)) + min_tsn;
|
2006-01-23 11:56:49 +00:00
|
|
|
text_color = u_data->io->draw_area->style->black_gc;
|
2007-04-22 10:25:26 +00:00
|
|
|
|
|
|
|
if (u_data->dir == 1)
|
|
|
|
tsnlist = g_list_last(u_data->assoc->tsn1);
|
|
|
|
else
|
|
|
|
tsnlist = g_list_last(u_data->assoc->tsn2);
|
|
|
|
|
|
|
|
tsn = (tsn_t*) (tsnlist->data);
|
|
|
|
tmptsn =(tsn_t*)(tsnlist->data);
|
|
|
|
tfirst = tsn->secs + tsn->usecs/1000000.0;
|
|
|
|
frame = tsn->frame_number;
|
|
|
|
|
|
|
|
while (tsnlist)
|
|
|
|
{
|
|
|
|
tsnlist = g_list_previous(tsnlist);
|
|
|
|
tsn = (tsn_t*) (tsnlist->data);
|
|
|
|
if (tsn->secs+tsn->usecs/1000000.0<x_value)
|
|
|
|
{
|
|
|
|
tfirst = tsn->secs+tsn->usecs/1000000.0;
|
|
|
|
tmptsn =tsn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((tfirst+tsn->secs+tsn->usecs/1000000.0)/2.0<x_value)
|
|
|
|
{
|
|
|
|
x_value = tsn->secs+tsn->usecs/1000000.0;
|
|
|
|
tmptsn = tsn;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
x_value = tmptsn->secs+tmptsn->usecs/1000000.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cf_goto_frame(&cfile, tmptsn->frame_number);
|
2007-02-09 21:05:43 +00:00
|
|
|
g_snprintf(label_string, 30, "(%.6f, %u)", x_value, y_value);
|
2006-01-23 11:56:49 +00:00
|
|
|
label_set = TRUE;
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2007-03-21 03:26:26 +00:00
|
|
|
gdk_draw_line(u_data->io->pixmap,text_color, (gint)(event->x-2), (gint)(event->y), (gint)(event->x+2), (gint)(event->y));
|
|
|
|
gdk_draw_line(u_data->io->pixmap,text_color, (gint)(event->x), (gint)(event->y-2), (gint)(event->x), (gint)(event->y+2));
|
2006-01-23 11:56:49 +00:00
|
|
|
if (event->x+150>=u_data->io->pixmap_width)
|
|
|
|
position = event->x - 150;
|
|
|
|
else
|
|
|
|
position = event->x + 5;
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2006-01-23 11:56:49 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
lwidth=gdk_string_width(font, label_string);
|
|
|
|
gdk_draw_string(u_data->io->pixmap,font,text_color,
|
2007-03-21 03:26:26 +00:00
|
|
|
(gint)(position),
|
|
|
|
(gint)(event->y-10),
|
2006-01-23 11:56:49 +00:00
|
|
|
label_string);
|
|
|
|
#else
|
|
|
|
memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15);
|
|
|
|
pango_layout_set_text(layout, label_string, -1);
|
|
|
|
pango_layout_get_pixel_size(layout, &lwidth, NULL);
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2006-01-23 11:56:49 +00:00
|
|
|
gdk_draw_layout(u_data->io->pixmap,text_color,
|
2007-03-21 03:26:26 +00:00
|
|
|
(gint)(position),
|
|
|
|
(gint)(event->y-10),
|
2006-01-23 11:56:49 +00:00
|
|
|
layout);
|
2007-03-21 03:26:26 +00:00
|
|
|
#endif
|
2006-01-23 11:56:49 +00:00
|
|
|
ios=(sctp_graph_t *)OBJECT_GET_DATA(u_data->io->draw_area, "sctp_graph_t");
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2006-01-23 11:56:49 +00:00
|
|
|
if(!ios){
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
gdk_draw_pixmap(u_data->io->draw_area->window,
|
|
|
|
u_data->io->draw_area->style->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)],
|
|
|
|
ios->pixmap,
|
|
|
|
0, 0,
|
|
|
|
0, 0,
|
|
|
|
u_data->io->draw_area->allocation.width,
|
|
|
|
u_data->io->draw_area->allocation.height);
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
static void init_sctp_graph_window(struct sctp_udata *u_data)
|
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *hbox;
|
2006-05-31 15:26:41 +00:00
|
|
|
GtkWidget *bt_close, *sack_bt, *tsn_bt, *both_bt, *zoomin_bt;
|
2004-09-07 07:54:50 +00:00
|
|
|
GtkTooltips *tooltip_in, *tooltip_out;
|
|
|
|
|
|
|
|
/* create the main window */
|
|
|
|
|
|
|
|
u_data->io->window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
|
|
|
|
|
|
gtk_widget_set_name(u_data->io->window, "SCTP Graphics");
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_container_add(GTK_CONTAINER(u_data->io->window), vbox);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
|
|
|
|
create_draw_area(vbox, u_data);
|
|
|
|
|
|
|
|
sctp_graph_set_title(u_data);
|
|
|
|
|
|
|
|
hbox = gtk_hbutton_box_new();
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(hbox), 10);
|
|
|
|
gtk_button_box_set_layout(GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
|
|
|
|
gtk_button_box_set_spacing(GTK_BUTTON_BOX (hbox), 0);
|
|
|
|
gtk_box_set_child_packing(GTK_BOX(vbox), hbox, FALSE, FALSE, 0, GTK_PACK_START);
|
|
|
|
gtk_widget_show(hbox);
|
|
|
|
|
|
|
|
sack_bt = gtk_button_new_with_label ("Adv. Rec. Window");
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), sack_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(sack_bt);
|
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(sack_bt), "clicked", (GtkSignalFunc)on_sack_bt, u_data);
|
|
|
|
|
|
|
|
tsn_bt = gtk_button_new_with_label ("Data bytes sent");
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), tsn_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(tsn_bt);
|
|
|
|
SIGNAL_CONNECT(tsn_bt, "clicked", on_tsn_bt, u_data);
|
|
|
|
|
|
|
|
both_bt = gtk_button_new_with_label ("Show both");
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), both_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(both_bt);
|
|
|
|
SIGNAL_CONNECT(both_bt, "clicked", on_both_bt, u_data);
|
|
|
|
|
|
|
|
zoomin_bt = gtk_button_new_with_label ("Zoom in");
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), zoomin_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(zoomin_bt);
|
|
|
|
SIGNAL_CONNECT(zoomin_bt, "clicked", on_zoomin_bt, u_data);
|
|
|
|
tooltip_in = gtk_tooltips_new();
|
2006-05-31 15:26:41 +00:00
|
|
|
gtk_tooltips_set_tip(tooltip_in, zoomin_bt, "Zoom in the area you have selected", NULL);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
zoomout_bt = gtk_button_new_with_label ("Zoom out");
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), zoomout_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(zoomout_bt);
|
|
|
|
SIGNAL_CONNECT(zoomout_bt, "clicked", on_zoomout_bt, u_data);
|
|
|
|
tooltip_out = gtk_tooltips_new();
|
|
|
|
gtk_tooltips_set_tip(tooltip_out, zoomout_bt, "Zoom out one step", NULL);
|
2006-05-31 15:26:41 +00:00
|
|
|
gtk_widget_set_sensitive(zoomout_bt, FALSE);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
bt_close = BUTTON_NEW_FROM_STOCK(GTK_STOCK_CLOSE);
|
2004-09-07 07:54:50 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(hbox), bt_close, FALSE, FALSE, 0);
|
2005-03-22 10:25:07 +00:00
|
|
|
gtk_widget_show(bt_close);
|
|
|
|
SIGNAL_CONNECT(bt_close, "clicked", sctp_graph_close_cb, u_data);
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(u_data->io->draw_area),"button_press_event",(GtkSignalFunc)on_button_press, u_data);
|
|
|
|
gtk_signal_connect(GTK_OBJECT(u_data->io->draw_area),"button_release_event",(GtkSignalFunc)on_button_release, u_data);
|
|
|
|
gtk_widget_set_events(u_data->io->draw_area, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_EXPOSURE_MASK);
|
2004-12-10 11:20:48 +00:00
|
|
|
/* dlg_set_cancel(u_data->io->window, bt_close); */
|
2006-03-09 16:00:33 +00:00
|
|
|
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
gtk_widget_show(u_data->io->window);
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_graph_set_title(struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
char *title;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
if(!u_data->io->window)
|
|
|
|
{
|
2004-09-07 07:54:50 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
title = g_strdup_printf("SCTP Data and Adv.Rcv.Window over Time: %s Port1 %u Port2 %u Endpoint %u",
|
2005-03-22 10:25:07 +00:00
|
|
|
cf_get_display_name(&cfile), u_data->parent->assoc->port1, u_data->parent->assoc->port2, u_data->dir);
|
2004-09-07 07:54:50 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(u_data->io->window), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_sctpgraph_init(struct sctp_udata *u_data)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
sctp_graph_t *io;
|
|
|
|
gint dir;
|
|
|
|
sctp_min_max_t* tmp_minmax;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
io=g_malloc(sizeof(sctp_graph_t));
|
|
|
|
io->needs_redraw=TRUE;
|
|
|
|
io->x_interval=1000;
|
|
|
|
io->window=NULL;
|
|
|
|
io->draw_area=NULL;
|
|
|
|
io->pixmap=NULL;
|
|
|
|
io->pixmap_width=800;
|
|
|
|
io->pixmap_height=600;
|
|
|
|
io->graph_type=0;
|
|
|
|
dir=u_data->dir-1;
|
|
|
|
u_data->io=io;
|
|
|
|
|
|
|
|
|
|
|
|
u_data->io->x1_tmp_sec=u_data->assoc->min_secs;
|
|
|
|
u_data->io->x1_tmp_usec=u_data->assoc->min_usecs;
|
|
|
|
u_data->io->x2_tmp_sec=u_data->assoc->max_secs;
|
|
|
|
u_data->io->x2_tmp_usec=u_data->assoc->max_usecs;
|
|
|
|
u_data->io->tmp_min_tsn1=0;
|
|
|
|
u_data->io->tmp_max_tsn1=u_data->assoc->max_bytes1;
|
|
|
|
u_data->io->tmp_min_tsn2=0;
|
|
|
|
u_data->io->tmp_max_tsn2=u_data->assoc->max_bytes2;
|
|
|
|
u_data->io->tmp=FALSE;
|
|
|
|
tmp_minmax = g_malloc(sizeof(sctp_min_max_t));
|
|
|
|
tmp_minmax->tmp_min_secs = u_data->assoc->min_secs;
|
|
|
|
tmp_minmax->tmp_min_usecs=u_data->assoc->min_usecs;
|
|
|
|
tmp_minmax->tmp_max_secs=u_data->assoc->max_secs;
|
|
|
|
tmp_minmax->tmp_max_usecs=u_data->assoc->max_usecs;
|
|
|
|
tmp_minmax->tmp_min_tsn2=u_data->io->tmp_min_tsn2;
|
|
|
|
tmp_minmax->tmp_min_tsn1=u_data->io->tmp_min_tsn1;
|
|
|
|
tmp_minmax->tmp_max_tsn1=u_data->io->tmp_max_tsn1;
|
|
|
|
tmp_minmax->tmp_max_tsn2=u_data->io->tmp_max_tsn2;
|
|
|
|
u_data->assoc->min_max = g_slist_prepend(u_data->assoc->min_max, tmp_minmax);
|
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
/* build the GUI */
|
2004-09-07 07:54:50 +00:00
|
|
|
init_sctp_graph_window(u_data);
|
|
|
|
sctp_graph_redraw(u_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint
|
2005-03-22 10:25:07 +00:00
|
|
|
quit(GtkObject *object _U_, gpointer user_data)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
struct sctp_udata *u_data=(struct sctp_udata*)user_data;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
decrease_childcount(u_data->parent);
|
|
|
|
remove_child(u_data, u_data->parent);
|
|
|
|
g_free(u_data->io);
|
|
|
|
u_data->assoc->min_max = NULL;
|
|
|
|
g_free(u_data);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void create_draw_area(GtkWidget *box, struct sctp_udata *u_data)
|
|
|
|
{
|
|
|
|
u_data->io->draw_area=gtk_drawing_area_new();
|
|
|
|
SIGNAL_CONNECT(u_data->io->draw_area, "destroy", quit, u_data);
|
|
|
|
OBJECT_SET_DATA(u_data->io->draw_area, "sctp_graph_t", u_data->io);
|
|
|
|
|
|
|
|
WIDGET_SET_SIZE(u_data->io->draw_area, u_data->io->pixmap_width, u_data->io->pixmap_height);
|
|
|
|
|
|
|
|
/* signals needed to handle backing pixmap */
|
|
|
|
SIGNAL_CONNECT(u_data->io->draw_area, "expose_event", expose_event, NULL);
|
|
|
|
SIGNAL_CONNECT(u_data->io->draw_area, "configure_event", configure_event, u_data);
|
|
|
|
|
|
|
|
gtk_widget_show(u_data->io->draw_area);
|
|
|
|
gtk_box_pack_start(GTK_BOX(box), u_data->io->draw_area, TRUE, TRUE, 0);
|
|
|
|
}
|
|
|
|
|
2005-08-20 14:02:00 +00:00
|
|
|
static void insertion(GPtrArray *array, guint32 N)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
guint32 i, j;
|
|
|
|
guint32 v;
|
2005-03-22 10:25:07 +00:00
|
|
|
struct tsn_sort *help=NULL;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
for (i=1; i<N; i++)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
v = ((struct tsn_sort*)(g_ptr_array_index(array,i)))->tsnumber;
|
2004-09-07 07:54:50 +00:00
|
|
|
j=i;
|
2005-03-22 10:25:07 +00:00
|
|
|
while (j>=1 && ((struct tsn_sort*)(g_ptr_array_index(array, j-1)))->tsnumber > v)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
help=g_ptr_array_index(array, j);
|
|
|
|
g_ptr_array_index(array, j)=g_ptr_array_index(array, j-1);
|
|
|
|
g_ptr_array_index(array, j-1)=help;
|
2004-09-07 07:54:50 +00:00
|
|
|
j--;
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
((struct tsn_sort*)(g_ptr_array_index(array, j)))->tsnumber=v;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 14:02:00 +00:00
|
|
|
static void set_arw_offsets(struct sctp_udata *u_data)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
GPtrArray *s_array=NULL, *t_array=NULL;
|
|
|
|
guint32 i, j=0;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-02-04 22:45:15 +00:00
|
|
|
if (u_data->dir==1 && u_data->assoc->n_sack_chunks_ep1>0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
s_array=u_data->assoc->sort_sack1;
|
|
|
|
t_array=u_data->assoc->sort_tsn1;
|
|
|
|
insertion(s_array,u_data->assoc->n_sack_chunks_ep1);
|
|
|
|
|
|
|
|
for (i=0; i<u_data->assoc->n_sack_chunks_ep1; i++)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
while (((struct tsn_sort*)(g_ptr_array_index(s_array, i)))->tsnumber > ((struct tsn_sort*)(g_ptr_array_index(t_array, j)))->tsnumber)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
j++;
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
((struct tsn_sort*)(g_ptr_array_index(s_array,i)))->offset = ((struct tsn_sort*)(g_ptr_array_index(t_array, j)))->offset
|
2006-03-09 16:00:33 +00:00
|
|
|
+ ((struct tsn_sort*)(g_ptr_array_index(t_array, j)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u_data->assoc->sort_sack1=s_array;
|
|
|
|
}
|
|
|
|
|
2005-02-04 22:45:15 +00:00
|
|
|
if (u_data->dir==2 && u_data->assoc->n_sack_chunks_ep2>0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
s_array=u_data->assoc->sort_sack2;
|
|
|
|
t_array=u_data->assoc->sort_tsn2;
|
|
|
|
insertion(s_array,u_data->assoc->n_sack_chunks_ep2);
|
|
|
|
j=0;
|
|
|
|
for (i=0; i<u_data->assoc->n_sack_chunks_ep2; i++)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
while (((struct tsn_sort*)(g_ptr_array_index(s_array, i)))->tsnumber > ((struct tsn_sort*)(g_ptr_array_index(t_array,j)))->tsnumber)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
j++;
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
((struct tsn_sort*)(g_ptr_array_index(s_array, i)))->offset = ((struct tsn_sort*)(g_ptr_array_index(t_array, j)))->offset
|
|
|
|
+ ((struct tsn_sort*)(g_ptr_array_index(t_array, j)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
}
|
|
|
|
u_data->assoc->sort_sack2=s_array;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-20 14:02:00 +00:00
|
|
|
static void compute_offsets(struct sctp_udata *u_data)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
struct tsn_sort t_sort;
|
|
|
|
GPtrArray *array=NULL;
|
|
|
|
guint32 i;
|
|
|
|
guint32 sum=0;
|
|
|
|
guint32 tsntmp=0;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
2005-02-04 22:45:15 +00:00
|
|
|
if (u_data->dir==1 && u_data->assoc->n_array_tsn1>0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
array=u_data->assoc->sort_tsn1;
|
|
|
|
insertion(array,u_data->assoc->n_array_tsn1);
|
|
|
|
|
|
|
|
for (i=0; i<u_data->assoc->n_array_tsn1; i++)
|
|
|
|
{
|
2005-12-01 15:15:42 +00:00
|
|
|
((struct tsn_sort*)(g_ptr_array_index(array, i)))->offset=sum;
|
2005-03-22 10:25:07 +00:00
|
|
|
t_sort.tsnumber=((struct tsn_sort*)(g_ptr_array_index(array, i)))->tsnumber;
|
2005-02-04 22:45:15 +00:00
|
|
|
if (t_sort.tsnumber>tsntmp)
|
2005-03-22 10:25:07 +00:00
|
|
|
sum+=((struct tsn_sort*)(g_ptr_array_index(array, i)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
tsntmp=t_sort.tsnumber;
|
|
|
|
}
|
2005-03-22 10:25:07 +00:00
|
|
|
u_data->assoc->max_bytes1= ((struct tsn_sort*)(g_ptr_array_index(array, i-1)))->offset + ((struct tsn_sort*)(g_ptr_array_index(array, i-1)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
u_data->assoc->sort_tsn1=array;
|
|
|
|
}
|
2005-02-04 22:45:15 +00:00
|
|
|
if (u_data->dir==2 && u_data->assoc->n_array_tsn2>0)
|
2004-09-07 07:54:50 +00:00
|
|
|
{
|
|
|
|
sum=0;
|
|
|
|
array=u_data->assoc->sort_tsn2;
|
|
|
|
insertion(array,u_data->assoc->n_array_tsn2);
|
|
|
|
|
|
|
|
for (i=0; i<u_data->assoc->n_array_tsn2; i++)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
((struct tsn_sort*)(g_ptr_array_index(array,i)))->offset=sum;
|
|
|
|
t_sort.tsnumber=((struct tsn_sort*)(g_ptr_array_index(array, i)))->tsnumber;
|
2005-02-04 22:45:15 +00:00
|
|
|
if (t_sort.tsnumber>tsntmp)
|
2005-03-22 10:25:07 +00:00
|
|
|
sum+=((struct tsn_sort*)(g_ptr_array_index(array, i)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
tsntmp=t_sort.tsnumber;
|
|
|
|
}
|
|
|
|
|
2005-03-22 10:25:07 +00:00
|
|
|
u_data->assoc->max_bytes2= ((struct tsn_sort*)(g_ptr_array_index(array, u_data->assoc->n_data_chunks_ep2-1)))->offset + ((struct tsn_sort*)(g_ptr_array_index(array, u_data->assoc->n_data_chunks_ep2-1)))->length;
|
2004-09-07 07:54:50 +00:00
|
|
|
u_data->assoc->sort_tsn2=array;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void create_byte_graph(guint16 dir, struct sctp_analyse* userdata)
|
|
|
|
{
|
2005-03-22 10:25:07 +00:00
|
|
|
struct sctp_udata *u_data;
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
u_data=g_malloc(sizeof(struct sctp_udata));
|
|
|
|
u_data->assoc=g_malloc(sizeof(sctp_assoc_info_t));
|
|
|
|
u_data->assoc=userdata->assoc;
|
|
|
|
u_data->io=NULL;
|
|
|
|
u_data->dir = dir;
|
|
|
|
u_data->parent = userdata;
|
2005-05-02 14:04:25 +00:00
|
|
|
if ((u_data->dir==1 && (u_data->assoc->n_array_tsn1==0))|| (u_data->dir==2 && (u_data->assoc->n_array_tsn2==0)))
|
2005-03-22 10:25:07 +00:00
|
|
|
simple_dialog(ESD_TYPE_INFO, ESD_BTN_OK, "No Data Chunks sent");
|
2005-02-04 22:45:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
set_child(u_data, u_data->parent);
|
2006-03-09 16:00:33 +00:00
|
|
|
increase_childcount(u_data->parent);
|
|
|
|
compute_offsets(u_data);
|
|
|
|
set_arw_offsets(u_data);
|
2005-02-04 22:45:15 +00:00
|
|
|
gtk_sctpgraph_init(u_data);
|
2005-03-22 10:25:07 +00:00
|
|
|
}
|
2004-09-07 07:54:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|