aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-06-21 01:42:46 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-06-21 01:42:46 +0000
commitdea1a0a6e46299b799395a0e40fef7beb9839858 (patch)
tree27280932b0a12e10a02acb2ddd18086105e4c1fe /gtk
parent8d241c2d68ebb33ba0546587118299c1abe3a6ce (diff)
Break out the code for the ahndling of the Service Response Time (formerly known as RoundTripTime) table and change the table into a scrollable
CList. As a first conversion to use the helper routines, convert DCERPC SRT statistics to use the new interface. This prevents some interfaces (SAMR/LSA) that contains a huge number of procedures from creating a huge table that does not fir on the screen. Later changes to the helpers may be to make the different columns sortable or to hide those procedures that has not been seen in the capture. svn path=/trunk/; revision=7903
Diffstat (limited to 'gtk')
-rw-r--r--gtk/Makefile.am6
-rw-r--r--gtk/Makefile.nmake3
-rw-r--r--gtk/dcerpc_stat.c206
-rw-r--r--gtk/service_response_time_table.c234
-rw-r--r--gtk/service_response_time_table.h57
5 files changed, 321 insertions, 185 deletions
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 5bf89c5270..9cefde8f62 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for the GTK interface routines for Ethereal
#
-# $Id: Makefile.am,v 1.59 2003/04/25 20:54:18 guy Exp $
+# $Id: Makefile.am,v 1.60 2003/06/21 01:42:45 sahlberg Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -108,6 +108,8 @@ libui_a_SOURCES = \
proto_hier_stats_dlg.h \
proto_hier_stats_dlg.c \
simple_dialog.c \
+ service_response_time_table.c \
+ service_response_time_table.h \
stream_prefs.c \
stream_prefs.h \
summary_dlg.c \
@@ -184,6 +186,8 @@ libui_a_SOURCES = \
proto_draw.h \
proto_hier_stats_dlg.h \
proto_hier_stats_dlg.c \
+ service_response_time_table.c \
+ service_response_time_table.h \
simple_dialog.c \
stream_prefs.c \
stream_prefs.h \
diff --git a/gtk/Makefile.nmake b/gtk/Makefile.nmake
index 73b6e42b5c..bd8aa481af 100644
--- a/gtk/Makefile.nmake
+++ b/gtk/Makefile.nmake
@@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
-# $Id: Makefile.nmake,v 1.44 2003/06/14 20:35:57 guy Exp $
+# $Id: Makefile.nmake,v 1.45 2003/06/21 01:42:45 sahlberg Exp $
include ..\config.nmake
@@ -68,6 +68,7 @@ OBJECTS=capture_dlg.obj \
proto_dlg.obj \
proto_draw.obj \
proto_hier_stats_dlg.obj \
+ service_response_time_table.obj \
simple_dialog.obj \
stream_prefs.obj \
summary_dlg.obj \
diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c
index 9de2217bb1..ade905aca0 100644
--- a/gtk/dcerpc_stat.c
+++ b/gtk/dcerpc_stat.c
@@ -1,7 +1,7 @@
/* dcerpc_stat.c
* dcerpc_stat 2002 Ronnie Sahlberg
*
- * $Id: dcerpc_stat.c,v 1.8 2003/04/25 05:50:20 guy Exp $
+ * $Id: dcerpc_stat.c,v 1.9 2003/06/21 01:42:45 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* This module provides rpc call/reply RTT statistics to ethereal,
+/* This module provides rpc call/reply SRT statistics to ethereal,
* and displays them graphically.
* It is only used by ethereal and not tethereal
*
@@ -44,32 +44,17 @@
#include "packet-dcerpc.h"
#include "../globals.h"
#include "compat_macros.h"
+#include "service_response_time_table.h"
-/* used to keep track of statistics for a specific procedure */
-typedef struct _rpc_procedure_t {
- GtkWidget *wnum;
- GtkWidget *wmin;
- GtkWidget *wmax;
- GtkWidget *wavg;
- gchar snum[8];
- gchar smin[16];
- gchar smax[16];
- gchar savg[16];
- int num;
- nstime_t min;
- nstime_t max;
- nstime_t tot;
-} rpc_procedure_t;
/* used to keep track of the statistics for an entire program interface */
typedef struct _rpcstat_t {
GtkWidget *win;
- GtkWidget *table;
+ srt_stat_table srt_table;
char *prog;
e_uuid_t uuid;
guint16 ver;
- guint32 num_procedures;
- rpc_procedure_t *procedures;
+ int num_procedures;
} rpcstat_t;
@@ -96,26 +81,13 @@ uuid_equal(e_uuid_t *uuid1, e_uuid_t *uuid2)
static void
dcerpcstat_reset(rpcstat_t *rs)
{
- guint32 i;
-
- for(i=0;i<rs->num_procedures;i++){
- rs->procedures[i].num=0;
- rs->procedures[i].min.secs=0;
- rs->procedures[i].min.nsecs=0;
- rs->procedures[i].max.secs=0;
- rs->procedures[i].max.nsecs=0;
- rs->procedures[i].tot.secs=0;
- rs->procedures[i].tot.nsecs=0;
- }
+ reset_srt_table_data(&rs->srt_table);
}
static int
dcerpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, dcerpc_info *ri)
{
- nstime_t delta;
- rpc_procedure_t *rp;
-
if(!ri->call_data){
return 0;
}
@@ -139,49 +111,9 @@ dcerpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, dc
return 0;
}
- rp=&(rs->procedures[ri->call_data->opnum]);
- /* calculate time delta between request and reply */
- delta.secs=pinfo->fd->abs_secs-ri->call_data->req_time.secs;
- delta.nsecs=pinfo->fd->abs_usecs*1000-ri->call_data->req_time.nsecs;
- if(delta.nsecs<0){
- delta.nsecs+=1000000000;
- delta.secs--;
- }
+ add_srt_table_data(&rs->srt_table, ri->call_data->opnum, &ri->call_data->req_time, pinfo);
- if((rp->max.secs==0)
- && (rp->max.nsecs==0) ){
- rp->max.secs=delta.secs;
- rp->max.nsecs=delta.nsecs;
- }
-
- if((rp->min.secs==0)
- && (rp->min.nsecs==0) ){
- rp->min.secs=delta.secs;
- rp->min.nsecs=delta.nsecs;
- }
-
- if( (delta.secs<rp->min.secs)
- ||( (delta.secs==rp->min.secs)
- &&(delta.nsecs<rp->min.nsecs) ) ){
- rp->min.secs=delta.secs;
- rp->min.nsecs=delta.nsecs;
- }
-
- if( (delta.secs>rp->max.secs)
- ||( (delta.secs==rp->max.secs)
- &&(delta.nsecs>rp->max.nsecs) ) ){
- rp->max.secs=delta.secs;
- rp->max.nsecs=delta.nsecs;
- }
-
- rp->tot.secs += delta.secs;
- rp->tot.nsecs += delta.nsecs;
- if(rp->tot.nsecs>1000000000){
- rp->tot.nsecs-=1000000000;
- rp->tot.secs++;
- }
- rp->num++;
return 1;
}
@@ -189,37 +121,7 @@ dcerpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, dc
static void
dcerpcstat_draw(rpcstat_t *rs)
{
- guint32 i;
-#ifdef G_HAVE_UINT64
- guint64 td;
-#else
- guint32 td;
-#endif
-
- for(i=0;i<rs->num_procedures;i++){
- /* scale it to units of 10us.*/
- /* for long captures with a large tot time, this can overflow on 32bit */
- td=(int)rs->procedures[i].tot.secs;
- td=td*100000+(int)rs->procedures[i].tot.nsecs/10000;
- if(rs->procedures[i].num){
- td/=rs->procedures[i].num;
- } else {
- td=0;
- }
-
- sprintf(rs->procedures[i].snum,"%d", rs->procedures[i].num);
- gtk_label_set_text(GTK_LABEL(rs->procedures[i].wnum), rs->procedures[i].snum);
-
- sprintf(rs->procedures[i].smin,"%3d.%05d", (int)rs->procedures[i].min.secs,rs->procedures[i].min.nsecs/10000);
- gtk_label_set_text(GTK_LABEL(rs->procedures[i].wmin), rs->procedures[i].smin);
-
- sprintf(rs->procedures[i].smax,"%3d.%05d", (int)rs->procedures[i].max.secs,rs->procedures[i].max.nsecs/10000);
- gtk_label_set_text(GTK_LABEL(rs->procedures[i].wmax), rs->procedures[i].smax);
-
- sprintf(rs->procedures[i].savg,"%3d.%05d", td/100000, td%100000);
- gtk_label_set_text(GTK_LABEL(rs->procedures[i].wavg), rs->procedures[i].savg);
-
- }
+ draw_srt_table_data(&rs->srt_table);
}
@@ -240,7 +142,7 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data)
remove_tap_listener(rs);
unprotect_thread_critical_region();
- g_free(rs->procedures);
+ free_srt_table_data(&rs->srt_table);
g_free(rs);
}
@@ -258,7 +160,6 @@ gtk_dcerpcstat_init(char *optarg)
GtkWidget *vbox;
GtkWidget *stat_label;
GtkWidget *filter_label;
- GtkWidget *tmp;
dcerpc_sub_dissector *procs;
e_uuid_t uuid;
int d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
@@ -267,7 +168,7 @@ gtk_dcerpcstat_init(char *optarg)
char *filter=NULL;
GString *error_string;
- if(sscanf(optarg,"dcerpc,rtt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%n", &d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,&major,&minor,&pos)==13){
+ if(sscanf(optarg,"dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%n", &d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,&major,&minor,&pos)==13){
uuid.Data1=d1;
uuid.Data2=d2;
uuid.Data3=d3;
@@ -285,7 +186,7 @@ gtk_dcerpcstat_init(char *optarg)
filter=NULL;
}
} else {
- fprintf(stderr, "ethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
+ fprintf(stderr, "ethereal: invalid \"-z dcerpc,srt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
exit(1);
}
@@ -302,7 +203,8 @@ gtk_dcerpcstat_init(char *optarg)
rs->ver=(minor<<8)|(major&0xff);
rs->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- sprintf(title_string,"DCE-RPC RTT Stat for %s version %d.%d", rs->prog, rs->ver&0xff,rs->ver>>8);
+ gtk_window_set_default_size(rs->win, 550, 400);
+ sprintf(title_string,"DCE-RPC Service Response Time statistics for %s version %d.%d", rs->prog, rs->ver&0xff,rs->ver>>8);
gtk_window_set_title(GTK_WINDOW(rs->win), title_string);
SIGNAL_CONNECT(rs->win, "destroy", win_destroy_cb, rs);
@@ -327,38 +229,9 @@ gtk_dcerpcstat_init(char *optarg)
}
}
rs->num_procedures=max_procs+1;
- rs->procedures=g_malloc(sizeof(rpc_procedure_t)*(rs->num_procedures+1));
-
- rs->table=gtk_table_new(rs->num_procedures+1, 5, TRUE);
- gtk_container_add(GTK_CONTAINER(vbox), rs->table);
-
- tmp=gtk_label_new("Procedure");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 0,1,0,1);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
- gtk_widget_show(tmp);
-
- tmp=gtk_label_new("Calls");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 1,2,0,1);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(tmp);
-
- tmp=gtk_label_new("Min RTT");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 2,3,0,1);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(tmp);
-
- tmp=gtk_label_new("Max RTT");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 3,4,0,1);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(tmp);
-
- tmp=gtk_label_new("Avg RTT");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 4,5,0,1);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(tmp);
-
- for(i=0;i<rs->num_procedures;i++){
- GtkWidget *tmp;
+ init_srt_table(&rs->srt_table, max_procs+1, vbox);
+
+ for(i=0;i<(max_procs+1);i++){
int j;
char *proc_name;
@@ -369,49 +242,16 @@ gtk_dcerpcstat_init(char *optarg)
}
}
- tmp=gtk_label_new(proc_name);
- gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
- gtk_table_attach_defaults(GTK_TABLE(rs->table), tmp, 0,1,i+1,i+2);
- gtk_widget_show(tmp);
-
- rs->procedures[i].wnum=gtk_label_new("0");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), rs->procedures[i].wnum, 1,2,i+1,i+2);
- gtk_label_set_justify(GTK_LABEL(rs->procedures[i].wnum), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(rs->procedures[i].wnum);
-
- rs->procedures[i].wmin=gtk_label_new("0");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), rs->procedures[i].wmin, 2,3,i+1,i+2);
- gtk_label_set_justify(GTK_LABEL(rs->procedures[i].wmin), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(rs->procedures[i].wmin);
-
- rs->procedures[i].wmax=gtk_label_new("0");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), rs->procedures[i].wmax, 3,4,i+1,i+2);
- gtk_label_set_justify(GTK_LABEL(rs->procedures[i].wmax), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(rs->procedures[i].wmax);
-
- rs->procedures[i].wavg=gtk_label_new("0");
- gtk_table_attach_defaults(GTK_TABLE(rs->table), rs->procedures[i].wavg, 4,5,i+1,i+2);
- gtk_label_set_justify(GTK_LABEL(rs->procedures[i].wavg), GTK_JUSTIFY_RIGHT);
- gtk_widget_show(rs->procedures[i].wavg);
-
- rs->procedures[i].num=0;
- rs->procedures[i].min.secs=0;
- rs->procedures[i].min.nsecs=0;
- rs->procedures[i].max.secs=0;
- rs->procedures[i].max.nsecs=0;
- rs->procedures[i].tot.secs=0;
- rs->procedures[i].tot.nsecs=0;
+ init_srt_table_row(&rs->srt_table, i, proc_name);
}
- gtk_widget_show(rs->table);
-
error_string=register_tap_listener("dcerpc", rs, filter, (void*)dcerpcstat_reset, (void*)dcerpcstat_packet, (void*)dcerpcstat_draw);
if(error_string){
/* error, we failed to attach to the tap. clean up */
simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
g_string_free(error_string, TRUE);
- g_free(rs->procedures);
+ free_srt_table_data(&rs->srt_table);
g_free(rs);
return;
}
@@ -442,10 +282,10 @@ dcerpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
if(filter[0]==0){
- sprintf(str, "dcerpc,rtt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d",dcerpc_uuid_program->Data1,dcerpc_uuid_program->Data2,dcerpc_uuid_program->Data3,dcerpc_uuid_program->Data4[0],dcerpc_uuid_program->Data4[1],dcerpc_uuid_program->Data4[2],dcerpc_uuid_program->Data4[3],dcerpc_uuid_program->Data4[4],dcerpc_uuid_program->Data4[5],dcerpc_uuid_program->Data4[6],dcerpc_uuid_program->Data4[7],dcerpc_version&0xff,dcerpc_version>>8);
+ sprintf(str, "dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d",dcerpc_uuid_program->Data1,dcerpc_uuid_program->Data2,dcerpc_uuid_program->Data3,dcerpc_uuid_program->Data4[0],dcerpc_uuid_program->Data4[1],dcerpc_uuid_program->Data4[2],dcerpc_uuid_program->Data4[3],dcerpc_uuid_program->Data4[4],dcerpc_uuid_program->Data4[5],dcerpc_uuid_program->Data4[6],dcerpc_uuid_program->Data4[7],dcerpc_version&0xff,dcerpc_version>>8);
} else {
- sprintf(str, "dcerpc,rtt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%s",dcerpc_uuid_program->Data1,dcerpc_uuid_program->Data2,dcerpc_uuid_program->Data3,dcerpc_uuid_program->Data4[0],dcerpc_uuid_program->Data4[1],dcerpc_uuid_program->Data4[2],dcerpc_uuid_program->Data4[3],dcerpc_uuid_program->Data4[4],dcerpc_uuid_program->Data4[5],dcerpc_uuid_program->Data4[6],dcerpc_uuid_program->Data4[7],dcerpc_version&0xff,dcerpc_version>>8, filter);
+ sprintf(str, "dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%s",dcerpc_uuid_program->Data1,dcerpc_uuid_program->Data2,dcerpc_uuid_program->Data3,dcerpc_uuid_program->Data4[0],dcerpc_uuid_program->Data4[1],dcerpc_uuid_program->Data4[2],dcerpc_uuid_program->Data4[3],dcerpc_uuid_program->Data4[4],dcerpc_uuid_program->Data4[5],dcerpc_uuid_program->Data4[6],dcerpc_uuid_program->Data4[7],dcerpc_version&0xff,dcerpc_version>>8, filter);
}
gtk_dcerpcstat_init(str);
@@ -552,7 +392,7 @@ gtk_dcerpcstat_cb(GtkWidget *w _U_, gpointer d _U_)
return;
}
- dlg=dlg_window_new("Ethereal: DCE-RPC RTT Statistics");
+ dlg=dlg_window_new("Ethereal: DCE-RPC SRT Statistics");
SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
dlg_box=gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
@@ -655,11 +495,11 @@ gtk_dcerpcstat_cb(GtkWidget *w _U_, gpointer d _U_)
void
register_tap_listener_gtkdcerpcstat(void)
{
- register_ethereal_tap("dcerpc,rtt,", gtk_dcerpcstat_init);
+ register_ethereal_tap("dcerpc,srt,", gtk_dcerpcstat_init);
}
void
register_tap_menu_gtkdcerpcstat(void)
{
- register_tap_menu_item("DCE-RPC/RTT", gtk_dcerpcstat_cb);
+ register_tap_menu_item("Service Response Time/DCE-RPC", gtk_dcerpcstat_cb);
}
diff --git a/gtk/service_response_time_table.c b/gtk/service_response_time_table.c
new file mode 100644
index 0000000000..2b89f80098
--- /dev/null
+++ b/gtk/service_response_time_table.c
@@ -0,0 +1,234 @@
+/* service_response_time_table.c
+ * service_response_time_table 2003 Ronnie Sahlberg
+ * Helper routines common to all service response time statistics
+ * tap.
+ *
+ * $Id: service_response_time_table.c,v 1.1 2003/06/21 01:42:45 sahlberg Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include "epan/packet_info.h"
+#include "service_response_time_table.h"
+
+
+void
+init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox)
+{
+ int i, j;
+ char *title[] = { "Index", "Procedure", "Calls", "Min SRT", "Max SRT", "Avg SRT" };
+
+ rst->scrolled_window=gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(rst->scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
+ gtk_box_pack_start(GTK_BOX(vbox), rst->scrolled_window, TRUE, TRUE, 0);
+ gtk_widget_show(rst->scrolled_window);
+
+
+ rst->table=(GtkCList *)gtk_clist_new_with_titles(6, title);
+
+ /*XXX instead of this we should probably have some code to
+ dynamically adjust the width of the columns */
+ gtk_clist_set_column_width(rst->table, 0, 32);
+ gtk_clist_set_column_width(rst->table, 1, 160);
+ gtk_clist_set_column_width(rst->table, 2, 50);
+ gtk_clist_set_column_width(rst->table, 3, 60);
+ gtk_clist_set_column_width(rst->table, 4, 60);
+ gtk_clist_set_column_width(rst->table, 5, 60);
+
+ gtk_clist_set_shadow_type(rst->table, GTK_SHADOW_IN);
+ gtk_clist_column_titles_show(rst->table);
+ gtk_container_add(GTK_CONTAINER(rst->scrolled_window), (GtkWidget *)rst->table);
+ gtk_widget_show((GtkWidget *)rst->table);
+
+ rst->num_procs=num_procs;
+ rst->procedures=g_malloc(sizeof(srt_procedure_t)*num_procs);
+ for(i=0;i<num_procs;i++){
+ rst->procedures[i].num=0;
+ rst->procedures[i].min.secs=0;
+ rst->procedures[i].min.nsecs=0;
+ rst->procedures[i].max.secs=0;
+ rst->procedures[i].max.nsecs=0;
+ rst->procedures[i].tot.secs=0;
+ rst->procedures[i].tot.nsecs=0;
+ for(j=0;j<6;j++){
+ rst->procedures[i].entries[j]=NULL;
+ }
+ }
+}
+
+void
+init_srt_table_row(srt_stat_table *rst, int index, char *procedure)
+{
+ char str[10];
+
+
+ sprintf(str,"%d",index);
+ rst->procedures[index].entries[0]=g_strdup(str);
+
+ rst->procedures[index].entries[1]=g_strdup(procedure);
+
+ rst->procedures[index].entries[2]=g_strdup("0");
+ rst->procedures[index].entries[3]=g_strdup("0");
+ rst->procedures[index].entries[4]=g_strdup("0");
+ rst->procedures[index].entries[5]=g_strdup("0");
+
+ gtk_clist_append(rst->table, rst->procedures[index].entries);
+}
+
+void
+add_srt_table_data(srt_stat_table *rst, int index, nstime_t *req_time, packet_info *pinfo)
+{
+ srt_procedure_t *rp;
+ nstime_t delta;
+
+ rp=&rst->procedures[index];
+
+ /* calculate time delta between request and reply */
+ delta.secs=pinfo->fd->abs_secs-req_time->secs;
+ delta.nsecs=pinfo->fd->abs_usecs*1000-req_time->nsecs;
+ if(delta.nsecs<0){
+ delta.nsecs+=1000000000;
+ delta.secs--;
+ }
+
+ if((rp->max.secs==0)
+ && (rp->max.nsecs==0) ){
+ rp->max.secs=delta.secs;
+ rp->max.nsecs=delta.nsecs;
+ }
+
+ if((rp->min.secs==0)
+ && (rp->min.nsecs==0) ){
+ rp->min.secs=delta.secs;
+ rp->min.nsecs=delta.nsecs;
+ }
+
+ if( (delta.secs<rp->min.secs)
+ ||( (delta.secs==rp->min.secs)
+ &&(delta.nsecs<rp->min.nsecs) ) ){
+ rp->min.secs=delta.secs;
+ rp->min.nsecs=delta.nsecs;
+ }
+
+ if( (delta.secs>rp->max.secs)
+ ||( (delta.secs==rp->max.secs)
+ &&(delta.nsecs>rp->max.nsecs) ) ){
+ rp->max.secs=delta.secs;
+ rp->max.nsecs=delta.nsecs;
+ }
+
+ rp->tot.secs += delta.secs;
+ rp->tot.nsecs += delta.nsecs;
+ if(rp->tot.nsecs>1000000000){
+ rp->tot.nsecs-=1000000000;
+ rp->tot.secs++;
+ }
+ rp->num++;
+}
+
+void
+draw_srt_table_data(srt_stat_table *rst)
+{
+ int i;
+#ifdef G_HAVE_UINT64
+ guint64 td;
+#else
+ guint32 td;
+#endif
+ char str[256], *strp;
+
+ for(i=0;i<rst->num_procs;i++){
+ /* scale it to units of 10us.*/
+ /* for long captures with a large tot time, this can overflow on 32bit */
+ td=(int)rst->procedures[i].tot.secs;
+ td=td*100000+(int)rst->procedures[i].tot.nsecs/10000;
+ if(rst->procedures[i].num){
+ td/=rst->procedures[i].num;
+ } else {
+ td=0;
+ }
+
+ sprintf(str,"%d", rst->procedures[i].num);
+ strp=g_strdup(str);
+ gtk_clist_set_text(rst->table, i, 2, strp);
+ g_free(rst->procedures[i].entries[2]);
+ rst->procedures[i].entries[2]=strp;
+
+
+ sprintf(str,"%3d.%05d", (int)rst->procedures[i].min.secs,rst->procedures[i].min.nsecs/10000);
+ strp=g_strdup(str);
+ gtk_clist_set_text(rst->table, i, 3, strp);
+ g_free(rst->procedures[i].entries[3]);
+ rst->procedures[i].entries[3]=strp;
+
+
+ sprintf(str,"%3d.%05d", (int)rst->procedures[i].max.secs,rst->procedures[i].max.nsecs/10000);
+ strp=g_strdup(str);
+ gtk_clist_set_text(rst->table, i, 4, strp);
+ g_free(rst->procedures[i].entries[4]);
+ rst->procedures[i].entries[4]=strp;
+
+ sprintf(str,"%3d.%05d", td/100000, td%100000);
+ strp=g_strdup(str);
+ gtk_clist_set_text(rst->table, i, 5, strp);
+ g_free(rst->procedures[i].entries[5]);
+ rst->procedures[i].entries[5]=strp;
+ }
+}
+
+
+void
+reset_srt_table_data(srt_stat_table *rst)
+{
+ int i;
+
+ for(i=0;i<rst->num_procs;i++){
+ rst->procedures[i].num=0;
+ rst->procedures[i].min.secs=0;
+ rst->procedures[i].min.nsecs=0;
+ rst->procedures[i].max.secs=0;
+ rst->procedures[i].max.nsecs=0;
+ rst->procedures[i].tot.secs=0;
+ rst->procedures[i].tot.nsecs=0;
+ }
+}
+
+void
+free_srt_table_data(srt_stat_table *rst)
+{
+ int i,j;
+
+ for(i=0;i<rst->num_procs;i++){
+ for(j=0;j<6;j++){
+ if(rst->procedures[i].entries[j]){
+ g_free(rst->procedures[i].entries[j]);
+ rst->procedures[i].entries[j]=NULL;
+ }
+ }
+ }
+ g_free(rst->procedures);
+ rst->procedures=NULL;
+ rst->num_procs=0;
+}
+
diff --git a/gtk/service_response_time_table.h b/gtk/service_response_time_table.h
new file mode 100644
index 0000000000..cd28b1afcd
--- /dev/null
+++ b/gtk/service_response_time_table.h
@@ -0,0 +1,57 @@
+/* service_response_time_table.h
+ * service_response_time_table 2003 Ronnie Sahlberg
+ * Helper routines common to all service response time statistics
+ * tap.
+ *
+ * $Id: service_response_time_table.h,v 1.1 2003/06/21 01:42:46 sahlberg Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@ethereal.com>
+ * 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.
+ */
+
+#include <gtk/gtk.h>
+#include "epan/nstime.h"
+
+
+typedef struct _srt_procedure_t {
+ char *entries[6];
+ int num;
+ nstime_t min;
+ nstime_t max;
+ nstime_t tot;
+} srt_procedure_t;
+
+typedef struct _srt_stat_table {
+ GtkWidget *scrolled_window;
+ GtkCList *table;
+ int num_procs;
+ srt_procedure_t *procedures;
+} srt_stat_table;
+
+void init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox);
+
+void init_srt_table_row(srt_stat_table *rst, int index, char *procedure);
+
+void add_srt_table_data(srt_stat_table *rst, int index, nstime_t *req_time, packet_info *pinfo);
+
+void draw_srt_table_data(srt_stat_table *rst);
+
+void reset_srt_table_data(srt_stat_table *rst);
+
+void free_srt_table_data(srt_stat_table *rst);
+