Ethereal-dev: [Ethereal-dev] patch to docs and to mgcp-stat
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: Sun, 27 Apr 2003 17:09:45 +0200
Hello, Attached are patches to docu and to mgcp-stat.I am new to gtk-programming. please take a look at it and commit, if acceptable.
I started using a gtkclist. I do not have GTK2, so I just did it for old GTK. May be someone else can make it for GTK2.
If necessary, my GtkCList makes vertical scrolling. No sorting of table at the moment.
I added two functions to gtk_stat_util.c "init_main_stat_window" makes the settings for standard rtt-stat window.It can be used in smb_stat.c, dcerpc_stat.c and rpc_stat.c without any modifications. This is just for reducing redundant code. No change in functionality.
"init_stat_table" makes the settings for a GtkCList including the scrolling. This may be useful, when changing the other statistic windows to a GtkCList
Best Regards, Lars Roland
Index: ethereal/gtk/gtk_stat_util.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/gtk_stat_util.c,v
retrieving revision 1.1
diff -u -r1.1 gtk_stat_util.c
--- ethereal/gtk/gtk_stat_util.c 25 Apr 2003 20:54:18 -0000 1.1
+++ ethereal/gtk/gtk_stat_util.c 27 Apr 2003 13:54:06 -0000
@@ -63,3 +63,58 @@
gtk_widget_show(tmp);
}
+/* init a main windowfor stats, set title and display used filter in window */
+
+void
+init_main_stat_window(GtkWidget *window, GtkWidget *mainbox, char *title, char *filter)
+{
+ GtkWidget *main_label;
+ GtkWidget *filter_label;
+ char filter_string[256];
+
+
+ gtk_window_set_title(GTK_WINDOW(window), title);
+
+ gtk_container_add(GTK_CONTAINER(window), mainbox);
+ gtk_container_set_border_width(GTK_CONTAINER(mainbox), 10);
+ gtk_widget_show(mainbox);
+
+ main_label=gtk_label_new(title);
+ gtk_box_pack_start(GTK_BOX(mainbox), main_label, FALSE, FALSE, 0);
+ gtk_widget_show(main_label);
+
+ snprintf(filter_string,255,"Filter:%s",filter?filter:"");
+ filter_label=gtk_label_new(filter_string);
+ gtk_box_pack_start(GTK_BOX(mainbox), filter_label, FALSE, FALSE, 0);
+ gtk_widget_show(filter_label);
+
+}
+
+/* init a table, using a scrollable gtkclist */
+
+#if GTK_MAJOR_VERSION < 2
+void
+init_stat_table(GtkWidget *scrolled_window, GtkWidget *vbox ,GtkCList *table, int columns, char *titles[])
+{
+ int i;
+
+ /* configure scrolling window*/
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
+
+ /* configure clist */
+ gtk_clist_column_titles_passive(table);
+ gtk_clist_column_titles_show(table);
+ for (i = 0; i < columns; i++)
+ gtk_clist_set_column_auto_resize(table, i, TRUE);
+ gtk_clist_set_selection_mode(table, GTK_SELECTION_EXTENDED);
+
+ /* Put clist into a scrolled window */
+ gtk_container_add(GTK_CONTAINER(scrolled_window),
+ GTK_WIDGET(table));
+ gtk_widget_show(GTK_WIDGET(table));
+ gtk_widget_show(scrolled_window);
+
+}
+#endif
\ No newline at end of file
Index: ethereal/gtk/gtk_stat_util.h
===================================================================
RCS file: /cvsroot/ethereal/gtk/gtk_stat_util.h,v
retrieving revision 1.1
diff -u -r1.1 gtk_stat_util.h
--- ethereal/gtk/gtk_stat_util.h 25 Apr 2003 20:54:18 -0000 1.1
+++ ethereal/gtk/gtk_stat_util.h 27 Apr 2003 13:54:06 -0000
@@ -36,5 +36,9 @@
}gtk_table;
extern void add_table_entry(gtk_table *tab, char *str, int x, int y);
+extern void init_main_stat_window(GtkWidget *window, GtkWidget *mainbox, char *title, char *filter);
+#if GTK_MAJOR_VERSION < 2
+extern void init_stat_table(GtkWidget *scrolled_window, GtkWidget *vbox ,GtkCList *table, int columns, char *titles[]);
+#endif
#endif
Index: ethereal/gtk/mgcp_stat.c
===================================================================
RCS file: /cvsroot/ethereal/gtk/mgcp_stat.c,v
retrieving revision 1.5
diff -u -r1.5 mgcp_stat.c
--- ethereal/gtk/mgcp_stat.c 25 Apr 2003 20:54:18 -0000 1.5
+++ ethereal/gtk/mgcp_stat.c 27 Apr 2003 13:54:06 -0000
@@ -57,7 +57,12 @@
GtkWidget *win;
GtkWidget *vbox;
char *filter;
+#if GTK_MAJOR_VERSION >= 2
gtk_table *table;
+#else /* gtk1 using a scrollable clist*/
+ GtkWidget *scrolled_window;
+ GtkCList *table;
+#endif
timestat_t rtd[NUM_TIMESTATS];
guint32 open_req_num;
guint32 disc_rsp_num;
@@ -194,6 +199,7 @@
{
mgcpstat_t *ms=(mgcpstat_t *)pms;
int i;
+#if GTK_MAJOR_VERSION >= 2
int pos;
char str[256];
@@ -238,6 +244,37 @@
}
gtk_widget_show(ms->table->widget);
+#else /* gtk1 using a scrollable clist*/
+ char *str[7];
+
+ for(i=0;i<7;i++) {
+ str[i]=g_malloc(sizeof(char[256]));
+ }
+
+ /* clear list before printing */
+ gtk_clist_clear(ms->table);
+
+ for(i=0;i<NUM_TIMESTATS;i++) {
+ /* nothing seen, nothing to do */
+ if(ms->rtd[i].num==0){
+ continue;
+ }
+
+ sprintf(str[0], "%s", val_to_str(i,mgcp_mesage_type,"Other"));
+ sprintf(str[1], "%d", ms->rtd[i].num);
+ sprintf(str[2], "%8.2f msec", nstime_to_msec(&(ms->rtd[i].min)));
+ sprintf(str[3], "%8.2f msec", nstime_to_msec(&(ms->rtd[i].max)));;
+ sprintf(str[4], "%8.2f msec", get_average(&(ms->rtd[i].tot), ms->rtd[i].num));
+ sprintf(str[5], "%6u", ms->rtd[i].min_num);
+ sprintf(str[6], "%6u", ms->rtd[i].max_num);
+ gtk_clist_append(ms->table, str);
+ }
+
+ gtk_widget_show(GTK_WIDGET(ms->table));
+ for(i=0;i<7;i++) {
+ g_free(str[i]);
+ }
+#endif
}
void protect_thread_critical_region(void);
@@ -255,20 +292,35 @@
g_free(ms->filter);
ms->filter=NULL;
}
+#if GTK_MAJOR_VERSION >= 2
g_free(ms->table);
ms->table=NULL;
+#endif
g_free(ms);
}
+static gchar *titles[]={"Type",
+ "Messages",
+ "Min RTD",
+ "Max RTD",
+ "Avg RTD",
+ "Min in Frame",
+ "Max in Frame" };
+
void
gtk_mgcpstat_init(char *optarg)
{
mgcpstat_t *ms;
char *filter=NULL;
+ GString *error_string;
+#if GTK_MAJOR_VERSION >= 2
GtkWidget *stat_label;
GtkWidget *filter_label;
char filter_string[256];
- GString *error_string;
+#else /* GTK1 using a clist */
+ int i;
+#endif
+
if(!strncmp(optarg,"mgcp,rtd,",9)){
filter=optarg+9;
@@ -284,22 +336,13 @@
mgcpstat_reset(ms);
ms->win=gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(ms->win), "MGCP Response Time Delay (RTD) Statistics");
SIGNAL_CONNECT(ms->win, "destroy", win_destroy_cb, ms);
ms->vbox=gtk_vbox_new(FALSE, 0);
- gtk_container_add(GTK_CONTAINER(ms->win), ms->vbox);
- gtk_container_set_border_width(GTK_CONTAINER(ms->vbox), 10);
- gtk_widget_show(ms->vbox);
-
- stat_label=gtk_label_new("MGCP Response Time Delay (RTD) Statistics");
- gtk_box_pack_start(GTK_BOX(ms->vbox), stat_label, FALSE, FALSE, 0);
- gtk_widget_show(stat_label);
-
- snprintf(filter_string,255,"Filter:%s",filter?filter:"");
- filter_label=gtk_label_new(filter_string);
- gtk_box_pack_start(GTK_BOX(ms->vbox), filter_label, FALSE, FALSE, 0);
- gtk_widget_show(filter_label);
+
+ init_main_stat_window(ms->win, ms->vbox, "MGCP Response Time Delay (RTD) Statistics", filter);
+
+#if GTK_MAJOR_VERSION >= 2
ms->table =(gtk_table *)g_malloc(sizeof(gtk_table));
ms->table->height=5;
@@ -317,11 +360,23 @@
gtk_widget_show(ms->table->widget);
+#else /* GTK1 using a scrollable clist*/
+ /* init a scrolled window*/
+ ms->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
+ WIDGET_SET_SIZE(ms->scrolled_window, 550, 100);
+
+ ms->table = GTK_CLIST(gtk_clist_new_with_titles(7, titles));
+
+ init_stat_table(ms->scrolled_window, ms->vbox ,ms->table, 7, titles);
+#endif
+
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);
+#if GTK_MAJOR_VERSION >= 2
g_free(ms->table);
+#endif
g_free(ms->filter);
g_free(ms);
return;
Index: ethereal.pod.template =================================================================== RCS file: /cvsroot/ethereal/doc/ethereal.pod.template,v retrieving revision 1.403 diff -u -r1.403 ethereal.pod.template --- ethereal.pod.template 27 Apr 2003 00:41:52 -0000 1.403 +++ ethereal.pod.template 27 Apr 2003 14:40:28 -0000 @@ -345,6 +345,20 @@ Example: use B<-z "smb,rtt,ip.addr==1.2.3.4"> to only collect stats for SMB packets echanged by the host at IP address 1.2.3.4 . +B<-z> mgcp,rtd[I<,filter>] + +Collect requests/response RTD (Response Time Delay) data for MGCP. +This is similar to B<-z smb,rtt>). Data collected is number of calls +for each known MGCP Type, MinRTD, MaxRTD and AvgRTD. +Example: use B<-z mgcp,rtd>. + +This option can be used multiple times on the command line. + +If the optional filterstring is provided, the stats will only be calculated +on those calls that match that filter. +Example: use B<-z "mgcp,rtd,ip.addr==1.2.3.4"> to only collect stats for +MGCP packets exchanged by the host at IP address 1.2.3.4 . + =back =head1 INTERFACE @@ -711,6 +725,20 @@ calculation. So for common SessionSetupAndX + TreeConnectAndX chains, only the SessionSetupAndX call will be used in the statistics. This is a flaw that might be fixed in the future. + +You can apply an optional filter string in a dialog box, before starting +the calculation. The stats will only be calculated +on those calls matching that filter. + +=item Tools:Statistics:MGCP:RTD + +Collect requests/response RTD (Response Time Delay) data for MGCP. +Data collected is number of calls for each known MGCP Type, +MinRTD, MaxRTD and AvgRTD. The data will be presented in a table. + +You can apply an optional filter string in a dialog box, before starting +the calculation. The stats will only be calculated +on those calls matching that filter. =back Index: tethereal.pod.template =================================================================== RCS file: /cvsroot/ethereal/doc/tethereal.pod.template,v retrieving revision 1.75 diff -u -r1.75 tethereal.pod.template --- tethereal.pod.template 26 Apr 2003 05:38:07 -0000 1.75 +++ tethereal.pod.template 27 Apr 2003 14:40:30 -0000 @@ -501,14 +501,15 @@ Example: use B<-z "smb,rtt,ip.addr==1.2.3.4"> to only collect stats for SMB packets echanged by the host at IP address 1.2.3.4 . -B<-z> mgcp,rtd,[I<filter>] +B<-z> mgcp,rtd[I<,filter>] Collect requests/response RTD (Response Time Delay) data for MGCP. -This is similar to B<-z smb,rtt>). You get the number of duplicate -requests/responses, unresponded requests, responses ,which don't match with -any request, and in a seperate line the number of responded requests, -Minimum RTD, Maximum RTD and Average RTD. -Example: use B<-z mgcp,rtd,>. +This is similar to B<-z smb,rtt>). Data collected is number of calls +for each known MGCP Type, MinRTD, MaxRTD and AvgRTD. +Additionally you get the number of duplicate requests/responses, +unresponded requests, responses ,which don't match with +any request. +Example: use B<-z mgcp,rtd>. This option can be used multiple times on the command line.
- Follow-Ups:
- Re: [Ethereal-dev] patch to docs and to mgcp-stat
- From: Guy Harris
- Re: [Ethereal-dev] patch to docs and to mgcp-stat
- Prev by Date: [Ethereal-dev] Two requests for enhancements
- Next by Date: [Ethereal-dev] Writing Decoders for Ethereal
- Previous by thread: [Ethereal-dev] Two requests for enhancements
- Next by thread: Re: [Ethereal-dev] patch to docs and to mgcp-stat
- Index(es):





