Ethereal-dev: [Ethereal-dev] code cleanups for smb-stats and filter-dialog for mgcp-stats

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Lars Roland <Lars.Roland@xxxxxxx>
Date: Fri, 25 Apr 2003 20:53:55 +0200
Hello,

thanks to Guy and Ronnie for the latest improvements in the statistics system. Very nice: no changes to "menu.c" any more. I'd like to be able to include statistic-taps in plugins. It would be very nice to have it in ethereal version 0.9.13 or 14. Unfortunately there is still a lot to do.

I have added a filter dialog for the mgcp-stats and created a new source file, where we can put gui functions used by statistic taps.

the file contains only the add_table_entry function and is used only by the mgcp-statistics at the moment.

please check in.

I also reduced redundant code in the smb_stat functions and fixed the init in tap-smbstat.c. They use now code from timestats.c .

Please test this. I do not have smb tracefiles.



Best Regards,

Lars Roland

/* gtk_stat_util.c
 * gui functions used by stats
 * Copyright 2003 Lars Roland
 *
 * $Id:  $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@xxxxxxxxxxxx>
 * 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 <stdio.h>

#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

#include <gtk/gtk.h>
#include <string.h>
#include "gtk_stat_util.h"
#include "compat_macros.h"
#include "../simple_dialog.h"
#include "../file.h"
#include "../globals.h"

/* insert a string into a GTK_TABLE at column x and row y*/

void
add_table_entry(gtk_table *tab, char *str, int x, int y)
{
	GtkWidget *tmp;

	if(y>=tab->height){
		tab->height=y+1;
		gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
	}
	if(x>=tab->width){
		tab->width=x+1;
		gtk_table_resize(GTK_TABLE(tab->widget), tab->height, tab->width);
	}

	tmp=gtk_label_new(str);
	gtk_table_attach_defaults(GTK_TABLE(tab->widget), tmp, x, x+1, y, y+1);
	gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
	gtk_widget_show(tmp);
}

Index: ethereal/gtk/Makefile.am
===================================================================
RCS file: /cvsroot/ethereal/gtk/Makefile.am,v
retrieving revision 1.57
diff -u -r1.57 Makefile.am
--- ethereal/gtk/Makefile.am	23 Apr 2003 05:37:21 -0000	1.57
+++ ethereal/gtk/Makefile.am	25 Apr 2003 17:30:20 -0000
@@ -78,6 +78,8 @@
 	goto_dlg.c	\
 	goto_dlg.h	\
 	gtkglobals.h	\
+	gtk_stat_util.c \
+	gtk_stat_util.h \
 	gui_prefs.c	\
 	gui_prefs.h	\
 	help_dlg.c	\
@@ -153,6 +155,8 @@
 	gtkclist.c	\
 	gtkclist.h	\
 	gtkglobals.h	\
+	gtk_stat_util.c \
+	gtk_stat_util.h \
 	gui_prefs.c	\
 	gui_prefs.h	\
 	help_dlg.c	\
Index: ethereal/gtk/Makefile.nmake
===================================================================
RCS file: /cvsroot/ethereal/gtk/Makefile.nmake,v
retrieving revision 1.42
diff -u -r1.42 Makefile.nmake
--- ethereal/gtk/Makefile.nmake	16 Apr 2003 07:24:06 -0000	1.42
+++ ethereal/gtk/Makefile.nmake	25 Apr 2003 17:30:20 -0000
@@ -54,6 +54,7 @@
 	follow_dlg.obj \
 	goto_dlg.obj \
 	gui_prefs.obj \
+	gtk_stat_util.obj	\
 	help_dlg.obj \
 	main.obj 	\
 	menu.obj 	\
Index: ethereal/gtk/mgcp_stat.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/mgcp_stat.c,v
retrieving revision 1.4
diff -u -r1.4 mgcp_stat.c
--- ethereal/gtk/mgcp_stat.c	23 Apr 2003 08:20:05 -0000	1.4
+++ ethereal/gtk/mgcp_stat.c	25 Apr 2003 17:30:20 -0000
@@ -42,11 +42,14 @@
 #include "../register.h"
 #include "../plugins/mgcp/packet-mgcp.h"
 #include "../timestats.h"
+#include "gtk_stat_util.h"
 #include "compat_macros.h"
 #include "../simple_dialog.h"
 #include "../file.h"
 #include "../globals.h"
 
+
+
 #define NUM_TIMESTATS 11
 
 /* used to keep track of the statistics for an entire program interface */
@@ -54,8 +57,7 @@
 	GtkWidget *win;
 	GtkWidget *vbox;
 	char *filter;
-	GtkWidget *table;
-	int table_height;
+	gtk_table *table;
         timestat_t rtd[NUM_TIMESTATS];
 	guint32 open_req_num;
 	guint32 disc_rsp_num;
@@ -77,22 +79,6 @@
 };
 
 static void
-add_table_entry(mgcpstat_t *ss, char *str, int x, int y)
-{
-	GtkWidget *tmp;
-
-	if(y>=ss->table_height){
-		ss->table_height=y+1;
-		gtk_table_resize(GTK_TABLE(ss->table), ss->table_height, 7);
-	}
-	tmp=gtk_label_new(str);
-	gtk_table_attach_defaults(GTK_TABLE(ss->table), tmp, x, x+1, y, y+1);
-	gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT);
-	gtk_widget_show(tmp);
-}
-
-
-static void
 mgcpstat_reset(void *pms)
 {
 	mgcpstat_t *ms=(mgcpstat_t *)pms;
@@ -211,20 +197,21 @@
 	int pos;
 	char str[256];
 
-	gtk_widget_destroy(ms->table);
-	ms->table_height=5;
-	ms->table=gtk_table_new(ms->table_height, 7, TRUE);
-	gtk_container_add(GTK_CONTAINER(ms->vbox), ms->table);
+	gtk_widget_destroy(ms->table->widget);
+	ms->table->height=5;
+	ms->table->width=7;
+	ms->table->widget=gtk_table_new(ms->table->height, ms->table->width, TRUE);
+	gtk_container_add(GTK_CONTAINER(ms->vbox), ms->table->widget);
 
 	pos=0;
 
-	add_table_entry(ms, "Type", 0, pos);
-	add_table_entry(ms, "Messages", 1, pos);
-	add_table_entry(ms, "Min RTD", 2, pos);
-	add_table_entry(ms, "Max RTD", 3, pos);
-	add_table_entry(ms, "Avg RTD", 4, pos);
-	add_table_entry(ms, "Min in Frame", 5, pos);
-	add_table_entry(ms, "Max in Frame", 6, pos);
+	add_table_entry(ms->table, "Type", 0, pos);
+	add_table_entry(ms->table, "Messages", 1, pos);
+	add_table_entry(ms->table, "Min RTD", 2, pos);
+	add_table_entry(ms->table, "Max RTD", 3, pos);
+	add_table_entry(ms->table, "Avg RTD", 4, pos);
+	add_table_entry(ms->table, "Min in Frame", 5, pos);
+	add_table_entry(ms->table, "Max in Frame", 6, pos);
 	pos++;
 
 	for(i=0;i<NUM_TIMESTATS;i++) {
@@ -234,23 +221,23 @@
 		}
 
 		sprintf(str, "%s", val_to_str(i,mgcp_mesage_type,"Other"));
-		add_table_entry(ms, str, 0, pos);
+		add_table_entry(ms->table, str, 0, pos);
 		sprintf(str, "%d", ms->rtd[i].num);
-		add_table_entry(ms, str, 1, pos);
+		add_table_entry(ms->table, str, 1, pos);
 		sprintf(str, "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min)));
-		add_table_entry(ms, str, 2, pos);
+		add_table_entry(ms->table, str, 2, pos);
 		sprintf(str, "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max)));
-		add_table_entry(ms, str, 3, pos);
+		add_table_entry(ms->table, str, 3, pos);
 		sprintf(str, "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num));
-		add_table_entry(ms, str, 4, pos);
+		add_table_entry(ms->table, str, 4, pos);
 		sprintf(str, "%6u", ms->rtd[i].min_num);
-		add_table_entry(ms, str, 5, pos);
+		add_table_entry(ms->table, str, 5, pos);
 		sprintf(str, "%6u", ms->rtd[i].max_num);
-		add_table_entry(ms, str, 6, pos);
+		add_table_entry(ms->table, str, 6, pos);
 		pos++;
 	}
 
-	gtk_widget_show(ms->table);
+	gtk_widget_show(ms->table->widget);
 }
 
 void protect_thread_critical_region(void);
@@ -268,6 +255,8 @@
 		g_free(ms->filter);
 		ms->filter=NULL;
 	}
+	g_free(ms->table);
+	ms->table=NULL;
 	g_free(ms);
 }
 
@@ -312,24 +301,27 @@
 	gtk_box_pack_start(GTK_BOX(ms->vbox), filter_label, FALSE, FALSE, 0);
 	gtk_widget_show(filter_label);
 
-	ms->table_height=5;
-	ms->table=gtk_table_new(ms->table_height, 7, TRUE);
-	gtk_container_add(GTK_CONTAINER(ms->vbox), ms->table);
-
-	add_table_entry(ms, "Type", 0, 0);
-	add_table_entry(ms, "Messages", 1, 0);
-	add_table_entry(ms, "Min RTD", 2, 0);
-	add_table_entry(ms, "Max RTD", 3, 0);
-	add_table_entry(ms, "Avg RTD", 4, 0);
-	add_table_entry(ms, "Min in Frame", 5, 0);
-	add_table_entry(ms, "Max in Frame", 6, 0);
+	ms->table =(gtk_table *)g_malloc(sizeof(gtk_table));
+	ms->table->height=5;
+	ms->table->width=7;
+	ms->table->widget=gtk_table_new(ms->table->height, ms->table->width, TRUE);
+	gtk_container_add(GTK_CONTAINER(ms->vbox), ms->table->widget);
+
+	add_table_entry(ms->table, "Type", 0, 0);
+	add_table_entry(ms->table, "Messages", 1, 0);
+	add_table_entry(ms->table, "Min RTD", 2, 0);
+	add_table_entry(ms->table, "Max RTD", 3, 0);
+	add_table_entry(ms->table, "Avg RTD", 4, 0);
+	add_table_entry(ms->table, "Min in Frame", 5, 0);
+	add_table_entry(ms->table, "Max in Frame", 6, 0);
 
-	gtk_widget_show(ms->table);
+	gtk_widget_show(ms->table->widget);
 
 	error_string=register_tap_listener("mgcp", ms, filter, mgcpstat_reset, mgcpstat_packet, mgcpstat_draw);
 	if(error_string){
 		simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
 		g_string_free(error_string, TRUE);
+		g_free(ms->table);
 		g_free(ms->filter);
 		g_free(ms);
 		return;
@@ -339,17 +331,82 @@
 	redissect_packets(&cfile);
 }
 
-void
-register_tap_listener_gtkmgcpstat(void)
+
+static GtkWidget *dlg=NULL, *dlg_box;
+static GtkWidget *filter_box;
+static GtkWidget *filter_label, *filter_entry;
+static GtkWidget *start_button;
+
+static void
+dlg_destroy_cb(void)
 {
-	register_ethereal_tap("mgcp,rtd", gtk_mgcpstat_init);
+	dlg=NULL;
 }
 
+static void
+mgcpstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
+{
+	char *filter;
+	char str[256];
+
+	filter=(char *)gtk_entry_get_text(GTK_ENTRY(filter_entry));
+	if(filter[0]==0){
+		gtk_mgcpstat_init("mgcp,rtd");
+	} else {
+		sprintf(str,"mgcp,rtd,%s", filter);
+		gtk_mgcpstat_init(str);
+	}
+}
+
+
 
 static void
 gtk_mgcpstat_cb(GtkWidget *w _U_, gpointer d _U_)
 {
-	gtk_mgcpstat_init("mgcp,rtd");
+	/* if the window is already open, bring it to front */
+	if(dlg){
+		gdk_window_raise(dlg->window);
+		return;
+	}
+
+	dlg=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+	gtk_window_set_title(GTK_WINDOW(dlg), "MGCP RTD Statistics");
+	SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
+	dlg_box=gtk_vbox_new(FALSE, 0);
+	gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
+	gtk_widget_show(dlg_box);
+
+
+	/* filter box */
+	filter_box=gtk_hbox_new(FALSE, 10);
+	/* Filter label */
+	gtk_container_set_border_width(GTK_CONTAINER(filter_box), 10);
+	filter_label=gtk_label_new("Filter:");
+	gtk_box_pack_start(GTK_BOX(filter_box), filter_label, FALSE, FALSE, 0);
+	gtk_widget_show(filter_label);
+
+	filter_entry=gtk_entry_new_with_max_length(250);
+	gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, FALSE, FALSE, 0);
+	gtk_widget_show(filter_entry);
+
+	gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
+	gtk_widget_show(filter_box);
+
+
+	/* the start button */
+	start_button=gtk_button_new_with_label("Create Stat");
+        SIGNAL_CONNECT_OBJECT(start_button, "clicked",
+                              mgcpstat_start_button_clicked, NULL);
+	gtk_box_pack_start(GTK_BOX(dlg_box), start_button, TRUE, TRUE, 0);
+	gtk_widget_show(start_button);
+
+	gtk_widget_show_all(dlg);
+}
+
+void
+register_tap_listener_gtkmgcpstat(void)
+{
+	register_ethereal_tap("mgcp,rtd", gtk_mgcpstat_init);
 }
 
 void
Index: ethereal/gtk/smb_stat.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/smb_stat.c,v
retrieving revision 1.5
diff -u -r1.5 smb_stat.c
--- ethereal/gtk/smb_stat.c	23 Apr 2003 08:20:06 -0000	1.5
+++ ethereal/gtk/smb_stat.c	25 Apr 2003 17:30:21 -0000
@@ -6,17 +6,17 @@
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@xxxxxxxxxxxx>
  * 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.
@@ -40,18 +40,12 @@
 #include "../epan/value_string.h"
 #include "../smb.h"
 #include "../register.h"
+#include "../timestats.h"
 #include "compat_macros.h"
 #include "../simple_dialog.h"
 #include "../file.h"
 #include "../globals.h"
 
-typedef struct _smb_procedure_t {
-	int num;
-	nstime_t min;
-	nstime_t max;
-	nstime_t tot;
-} smb_procedure_t;
-
 /* used to keep track of the statistics for an entire program interface */
 typedef struct _smbstat_t {
 	GtkWidget *win;
@@ -60,9 +54,9 @@
 	GtkWidget *table;
 	int table_height;
 	GtkWidget *table_widgets[768];
-	smb_procedure_t proc[256];
-	smb_procedure_t trans2[256];
-	smb_procedure_t nt_trans[256];
+	timestat_t proc[256];
+	timestat_t trans2[256];
+	timestat_t nt_trans[256];
 } smbstat_t;
 
 
@@ -91,15 +85,19 @@
 	guint32 i;
 
 	for(i=0;i<256;i++){
-		ss->proc[i].num=0;	
+		ss->proc[i].num=0;
+		ss->proc[i].min_num=0;
+		ss->proc[i].max_num=0;
 		ss->proc[i].min.secs=0;
 		ss->proc[i].min.nsecs=0;
 		ss->proc[i].max.secs=0;
 		ss->proc[i].max.nsecs=0;
 		ss->proc[i].tot.secs=0;
 		ss->proc[i].tot.nsecs=0;
-		
-		ss->trans2[i].num=0;	
+
+		ss->trans2[i].num=0;
+		ss->trans2[i].min_num=0;
+		ss->trans2[i].max_num=0;
 		ss->trans2[i].min.secs=0;
 		ss->trans2[i].min.nsecs=0;
 		ss->trans2[i].max.secs=0;
@@ -107,7 +105,9 @@
 		ss->trans2[i].tot.secs=0;
 		ss->trans2[i].tot.nsecs=0;
 
-		ss->nt_trans[i].num=0;	
+		ss->nt_trans[i].num=0;
+		ss->nt_trans[i].min_num=0;
+		ss->nt_trans[i].max_num=0;
 		ss->nt_trans[i].min.secs=0;
 		ss->nt_trans[i].min.nsecs=0;
 		ss->nt_trans[i].max.secs=0;
@@ -123,7 +123,7 @@
 	smbstat_t *ss=(smbstat_t *)pss;
 	smb_info_t *si=psi;
 	nstime_t delta;
-	smb_procedure_t *sp;
+	timestat_t *sp;
 
 	/* we are only interested in reply packets */
 	if(si->request){
@@ -156,39 +156,7 @@
 		delta.secs--;
 	}
 
-	if((sp->max.secs==0)
-	&& (sp->max.nsecs==0) ){
-		sp->max.secs=delta.secs;
-		sp->max.nsecs=delta.nsecs;
-	}
-
-	if((sp->min.secs==0)
-	&& (sp->min.nsecs==0) ){
-		sp->min.secs=delta.secs;
-		sp->min.nsecs=delta.nsecs;
-	}
-
-	if( (delta.secs<sp->min.secs)
-	||( (delta.secs==sp->min.secs)
-	  &&(delta.nsecs<sp->min.nsecs) ) ){
-		sp->min.secs=delta.secs;
-		sp->min.nsecs=delta.nsecs;
-	}
-
-	if( (delta.secs>sp->max.secs)
-	||( (delta.secs==sp->max.secs)
-	  &&(delta.nsecs>sp->max.nsecs) ) ){
-		sp->max.secs=delta.secs;
-		sp->max.nsecs=delta.nsecs;
-	}
-	
-	sp->tot.secs += delta.secs;
-	sp->tot.nsecs += delta.nsecs;
-	if(sp->tot.nsecs>1000000000){
-		sp->tot.nsecs-=1000000000;
-		sp->tot.secs++;
-	}
-	sp->num++;
+	time_stat_update(sp,&delta, pinfo);
 
 	return 1;
 }
@@ -392,31 +360,7 @@
 		ss->filter=NULL;
 	}
 
-	for(i=0;i<256;i++){
-		ss->proc[i].num=0;	
-		ss->proc[i].min.secs=0;
-		ss->proc[i].min.nsecs=0;
-		ss->proc[i].max.secs=0;
-		ss->proc[i].max.nsecs=0;
-		ss->proc[i].tot.secs=0;
-		ss->proc[i].tot.nsecs=0;
-		
-		ss->trans2[i].num=0;	
-		ss->trans2[i].min.secs=0;
-		ss->trans2[i].min.nsecs=0;
-		ss->trans2[i].max.secs=0;
-		ss->trans2[i].max.nsecs=0;
-		ss->trans2[i].tot.secs=0;
-		ss->trans2[i].tot.nsecs=0;
-
-		ss->nt_trans[i].num=0;	
-		ss->nt_trans[i].min.secs=0;
-		ss->nt_trans[i].min.nsecs=0;
-		ss->nt_trans[i].max.secs=0;
-		ss->nt_trans[i].max.nsecs=0;
-		ss->nt_trans[i].tot.secs=0;
-		ss->nt_trans[i].tot.nsecs=0;
-	}
+	smbstat_reset(ss);
 
 	ss->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	gtk_window_set_title(GTK_WINDOW(ss->win), "SMB RTT Statistics");
@@ -542,7 +486,7 @@
 	filter_entry=gtk_entry_new_with_max_length(250);
 	gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, FALSE, FALSE, 0);
 	gtk_widget_show(filter_entry);
-	
+
 	gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
 	gtk_widget_show(filter_box);
 
Index: ethereal/tap-smbstat.c
===================================================================
RCS file: /cvsroot/ethereal/tap-smbstat.c,v
retrieving revision 1.3
diff -u -r1.3 tap-smbstat.c
--- ethereal/tap-smbstat.c	23 Apr 2003 08:20:02 -0000	1.3
+++ ethereal/tap-smbstat.c	25 Apr 2003 17:38:08 -0000
@@ -6,17 +6,17 @@
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@xxxxxxxxxxxx>
  * 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.
@@ -38,21 +38,14 @@
 #include "epan/value_string.h"
 #include "smb.h"
 #include "register.h"
-
-
-typedef struct _smb_procedure_t {
-	int num;
-	nstime_t min;
-	nstime_t max;
-	nstime_t tot;
-} smb_procedure_t;
+#include "timestats.h"
 
 /* used to keep track of the statistics for an entire program interface */
 typedef struct _smbstat_t {
 	char *filter;
-	smb_procedure_t proc[256];
-	smb_procedure_t trans2[256];
-	smb_procedure_t nt_trans[256];
+	timestat_t proc[256];
+	timestat_t trans2[256];
+	timestat_t nt_trans[256];
 } smbstat_t;
 
 
@@ -63,7 +56,7 @@
 	smbstat_t *ss=(smbstat_t *)pss;
 	smb_info_t *si=psi;
 	nstime_t delta;
-	smb_procedure_t *sp;
+	timestat_t *sp;
 
 	/* we are only interested in reply packets */
 	if(si->request){
@@ -96,39 +89,7 @@
 		delta.secs--;
 	}
 
-	if((sp->max.secs==0)
-	&& (sp->max.nsecs==0) ){
-		sp->max.secs=delta.secs;
-		sp->max.nsecs=delta.nsecs;
-	}
-
-	if((sp->min.secs==0)
-	&& (sp->min.nsecs==0) ){
-		sp->min.secs=delta.secs;
-		sp->min.nsecs=delta.nsecs;
-	}
-
-	if( (delta.secs<sp->min.secs)
-	||( (delta.secs==sp->min.secs)
-	  &&(delta.nsecs<sp->min.nsecs) ) ){
-		sp->min.secs=delta.secs;
-		sp->min.nsecs=delta.nsecs;
-	}
-
-	if( (delta.secs>sp->max.secs)
-	||( (delta.secs==sp->max.secs)
-	  &&(delta.nsecs>sp->max.nsecs) ) ){
-		sp->max.secs=delta.secs;
-		sp->max.nsecs=delta.nsecs;
-	}
-	
-	sp->tot.secs += delta.secs;
-	sp->tot.nsecs += delta.nsecs;
-	if(sp->tot.nsecs>1000000000){
-		sp->tot.nsecs-=1000000000;
-		sp->tot.secs++;
-	}
-	sp->num++;
+	time_stat_update(sp,&delta, pinfo);
 
 	return 1;
 }
@@ -264,21 +225,35 @@
 	}
 
 	for(i=0;i<256;i++){
-		ss->proc[i].num=0;	
+		ss->proc[i].num=0;
+		ss->proc[i].min_num=0;
+		ss->proc[i].max_num=0;
 		ss->proc[i].min.secs=0;
 		ss->proc[i].min.nsecs=0;
 		ss->proc[i].max.secs=0;
 		ss->proc[i].max.nsecs=0;
 		ss->proc[i].tot.secs=0;
 		ss->proc[i].tot.nsecs=0;
-		
-		ss->trans2[i].num=0;	
+
+		ss->trans2[i].num=0;
+		ss->trans2[i].min_num=0;
+		ss->trans2[i].max_num=0;
 		ss->trans2[i].min.secs=0;
 		ss->trans2[i].min.nsecs=0;
 		ss->trans2[i].max.secs=0;
 		ss->trans2[i].max.nsecs=0;
 		ss->trans2[i].tot.secs=0;
 		ss->trans2[i].tot.nsecs=0;
+
+		ss->nt_trans[i].num=0;
+		ss->nt_trans[i].min_num=0;
+		ss->nt_trans[i].max_num=0;
+		ss->nt_trans[i].min.secs=0;
+		ss->nt_trans[i].min.nsecs=0;
+		ss->nt_trans[i].max.secs=0;
+		ss->nt_trans[i].max.nsecs=0;
+		ss->nt_trans[i].tot.secs=0;
+		ss->nt_trans[i].tot.nsecs=0;
 	}
 
 	error_string=register_tap_listener("smb", ss, filter, NULL, smbstat_packet, smbstat_draw);
/* gtk_stat_util.h
 * gui functions used by stats
 * Copyright 2003 Lars Roland
 *
 * $Id:  $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@xxxxxxxxxxxx>
 * 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.
 */


#ifndef __gtk_stat_util__
#define __gtk_stat_util__

#include <gtk/gtk.h>

typedef struct _gtk_table {
	GtkWidget *widget;
	int height;
	int width;
}gtk_table;

extern void add_table_entry(gtk_table *tab, char *str, int x, int y);

#endif