aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-04-23 08:20:06 +0000
committerGuy Harris <guy@alum.mit.edu>2003-04-23 08:20:06 +0000
commit1b872b3648180aa042e36dd5b3ff38a03fa131e3 (patch)
tree04f0fba9423fc1a57c5f559ee0a5fc49138ddb6e /gtk
parent81ebec370d30901623ef24b2112e91f8004c6ad0 (diff)
Make "register_tap_listener()" return NULL on success and a "GString *"
referring to a GString containing an error message on failure, and don't have it print anything on failure. If it fails, have its Tethereal-tap callers print an error message before exiting, and have its Ethereal callers pop up a dialog box with the error (except in cases where the failure is guaranteed not to be the user's fault, and where we exit, in which case we just print an error message before we exit). In all cases, the error message includes the text of the GString. Fix a scanf format string in the DCE RPC statistics Ethereal tap, so that it properly skips the comma before the filter string. Fix some Ethereal error messages not to say "tethereal". svn path=/trunk/; revision=7542
Diffstat (limited to 'gtk')
-rw-r--r--gtk/dcerpc_stat.c22
-rw-r--r--gtk/io_stat.c10
-rw-r--r--gtk/main.c4
-rw-r--r--gtk/mgcp_stat.c13
-rw-r--r--gtk/rpc_progs.c11
-rw-r--r--gtk/rpc_stat.c12
-rw-r--r--gtk/smb_stat.c12
-rw-r--r--gtk/tap_rtp.c9
8 files changed, 55 insertions, 38 deletions
diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c
index ab455ee151..226f7fbbc4 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.5 2003/04/23 05:37:22 guy Exp $
+ * $Id: dcerpc_stat.c,v 1.6 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -22,8 +22,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/* This module provides rpc call/reply RTT statistics to tethereal.
- * It is only used by tethereal and not ethereal
+/* This module provides rpc call/reply RTT statistics to ethereal,
+ * and displays them graphically.
+ * It is only used by ethereal and not tethereal
*
* It serves as an example on how to use the tap api.
*/
@@ -262,8 +263,9 @@ gtk_dcerpcstat_init(char *optarg)
int major, minor;
int pos=0;
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,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){
uuid.Data1=d1;
uuid.Data2=d2;
uuid.Data3=d3;
@@ -281,7 +283,7 @@ gtk_dcerpcstat_init(char *optarg)
filter=NULL;
}
} else {
- fprintf(stderr, "tethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
+ fprintf(stderr, "ethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
exit(1);
}
@@ -290,7 +292,7 @@ gtk_dcerpcstat_init(char *optarg)
rs->prog=dcerpc_get_proto_name(&uuid, (minor<<8)|(major&0xff) );
if(!rs->prog){
g_free(rs);
- fprintf(stderr,"tethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%d.%d not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
+ fprintf(stderr,"ethereal: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%d.%d not supported\n",uuid.Data1,uuid.Data2,uuid.Data3,uuid.Data4[0],uuid.Data4[1],uuid.Data4[2],uuid.Data4[3],uuid.Data4[4],uuid.Data4[5],uuid.Data4[6],uuid.Data4[7],major,minor);
exit(1);
}
procs=dcerpc_get_proto_sub_dissector(&uuid, (minor<<8)|(major&0xff) );
@@ -402,11 +404,11 @@ gtk_dcerpcstat_init(char *optarg)
gtk_widget_show(rs->table);
- if(register_tap_listener("dcerpc", rs, filter, (void*)dcerpcstat_reset, (void*)dcerpcstat_packet, (void*)dcerpcstat_draw)){
- char str[256];
+ 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 */
- snprintf(str,255,"Could not attach to tap using filter:%s",filter?filter:"");
- simple_dialog(ESD_TYPE_WARN, NULL, str);
+ simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
+ g_string_free(error_string, TRUE);
g_free(rs->procedures);
g_free(rs);
return;
diff --git a/gtk/io_stat.c b/gtk/io_stat.c
index ccb7238a3f..649ee04321 100644
--- a/gtk/io_stat.c
+++ b/gtk/io_stat.c
@@ -1,7 +1,7 @@
/* io_stat.c
* io_stat 2002 Ronnie Sahlberg
*
- * $Id: io_stat.c,v 1.20 2003/04/23 05:37:22 guy Exp $
+ * $Id: io_stat.c,v 1.21 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,6 +39,7 @@
#include <gtk/gtk.h>
#include "gtkglobals.h"
+#include "menu.h"
#include "epan/epan_dissect.h"
#include "epan/packet_info.h"
#include "../tap.h"
@@ -824,6 +825,7 @@ gtk_iostat_init(char *optarg _U_)
{0, 0x0000, 0x0000, 0xffff},
{0, 0xffff, 0x5000, 0xffff}
};
+ GString *error_string;
io=g_malloc(sizeof(io_stat_t));
io->needs_redraw=1;
@@ -871,7 +873,11 @@ gtk_iostat_init(char *optarg _U_)
io->graphs[i].filter_bt=NULL;
}
- if(register_tap_listener("frame", &io->graphs[0], NULL, gtk_iostat_reset, gtk_iostat_packet, gtk_iostat_draw)){
+ error_string=register_tap_listener("frame", &io->graphs[0], NULL, gtk_iostat_reset, gtk_iostat_packet, gtk_iostat_draw);
+ if(error_string){
+ fprintf(stderr, "ethereal: Can't attach io_stat tap: %s\n",
+ error_string->str);
+ g_string_free(error_string, TRUE);
g_free(io->graphs[0].counts);
io->graphs[0].counts=NULL;
io->graphs[0].display=0;
diff --git a/gtk/main.c b/gtk/main.c
index 4c3fd87588..a079fdea60 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.289 2003/04/23 03:51:03 guy Exp $
+ * $Id: main.c,v 1.290 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1504,7 +1504,7 @@ main(int argc, char *argv[])
else if (strcmp(argv[2], "protocols") == 0)
proto_registrar_dump_protocols();
else {
- fprintf(stderr, "tethereal: Invalid \"%s\" option for -G flag\n",
+ fprintf(stderr, "ethereal: Invalid \"%s\" option for -G flag\n",
argv[2]);
exit(1);
}
diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c
index 1cb9b1052d..18119e5a75 100644
--- a/gtk/mgcp_stat.c
+++ b/gtk/mgcp_stat.c
@@ -2,7 +2,7 @@
* mgcp-statistics for ethereal
* Copyright 2003 Lars Roland
*
- * $Id: mgcp_stat.c,v 1.3 2003/04/23 05:37:22 guy Exp $
+ * $Id: mgcp_stat.c,v 1.4 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -35,6 +35,7 @@
#include <gtk/gtk.h>
#include <string.h>
+#include "menu.h"
#include "../epan/packet_info.h"
#include "../tap.h"
#include "../epan/value_string.h"
@@ -278,6 +279,7 @@ gtk_mgcpstat_init(char *optarg)
GtkWidget *stat_label;
GtkWidget *filter_label;
char filter_string[256];
+ GString *error_string;
if(!strncmp(optarg,"mgcp,rtd,",9)){
filter=optarg+9;
@@ -324,11 +326,10 @@ gtk_mgcpstat_init(char *optarg)
gtk_widget_show(ms->table);
- if(register_tap_listener("mgcp", ms, filter, mgcpstat_reset, mgcpstat_packet, mgcpstat_draw)){
- char str[256];
- /* error, we failed to attach to the tap. clean up */
- snprintf(str,255,"Could not attach to tap using filter:%s",filter?filter:"");
- simple_dialog(ESD_TYPE_WARN, NULL, str);
+ 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->filter);
g_free(ms);
return;
diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c
index f54d68881b..ac444d9898 100644
--- a/gtk/rpc_progs.c
+++ b/gtk/rpc_progs.c
@@ -1,7 +1,7 @@
/* rpc_progs.c
* rpc_progs 2002 Ronnie Sahlberg
*
- * $Id: rpc_progs.c,v 1.8 2003/04/23 05:37:23 guy Exp $
+ * $Id: rpc_progs.c,v 1.9 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -33,6 +33,7 @@
#endif
#include <gtk/gtk.h>
+#include "menu.h"
#include "epan/packet_info.h"
#include "tap.h"
#include "../register.h"
@@ -320,6 +321,7 @@ gtk_rpcprogs_init(char *optarg _U_)
GtkWidget *vbox;
GtkWidget *stat_label;
GtkWidget *tmp;
+ GString *error_string;
if(win){
gdk_window_raise(win->window);
@@ -377,8 +379,11 @@ gtk_rpcprogs_init(char *optarg _U_)
gtk_widget_show(table);
- if(register_tap_listener("rpc", win, NULL, (void*)rpcprogs_reset, (void*)rpcprogs_packet, (void*)rpcprogs_draw)){
- fprintf(stderr, "ethereal: gtk_rpcprogs_init() failed to register tap\n");
+ error_string=register_tap_listener("rpc", win, NULL, (void*)rpcprogs_reset, (void*)rpcprogs_packet, (void*)rpcprogs_draw);
+ if(error_string){
+ fprintf(stderr, "ethereal: Couldn't register rpc,programs tap: %s\n",
+ error_string->str);
+ g_string_free(error_string, TRUE);
exit(1);
}
diff --git a/gtk/rpc_stat.c b/gtk/rpc_stat.c
index 3800c32f32..43490eb71a 100644
--- a/gtk/rpc_stat.c
+++ b/gtk/rpc_stat.c
@@ -1,7 +1,7 @@
/* rpc_stat.c
* rpc_stat 2002 Ronnie Sahlberg
*
- * $Id: rpc_stat.c,v 1.8 2003/04/23 05:37:23 guy Exp $
+ * $Id: rpc_stat.c,v 1.9 2003/04/23 08:20:05 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -283,6 +283,7 @@ gtk_rpcstat_init(char *optarg)
GtkWidget *tmp;
int program, version, pos;
char *filter=NULL;
+ GString *error_string;
pos=0;
if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){
@@ -397,11 +398,10 @@ gtk_rpcstat_init(char *optarg)
gtk_widget_show(rs->table);
- if(register_tap_listener("rpc", rs, filter, (void*)rpcstat_reset, (void*)rpcstat_packet, (void*)rpcstat_draw)){
- char str[256];
- /* error, we failed to attach to the tap. clean up */
- snprintf(str,255,"Could not attach to tap using filter:%s",filter?filter:"");
- simple_dialog(ESD_TYPE_WARN, NULL, str);
+ error_string=register_tap_listener("rpc", rs, filter, (void*)rpcstat_reset, (void*)rpcstat_packet, (void*)rpcstat_draw);
+ if(error_string){
+ simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
+ g_string_free(error_string, TRUE);
g_free(rs->procedures);
g_free(rs);
return;
diff --git a/gtk/smb_stat.c b/gtk/smb_stat.c
index 51e70a2e6f..29ff8e5832 100644
--- a/gtk/smb_stat.c
+++ b/gtk/smb_stat.c
@@ -1,7 +1,7 @@
/* smb_stat.c
* smb_stat 2003 Ronnie Sahlberg
*
- * $Id: smb_stat.c,v 1.4 2003/04/23 05:37:23 guy Exp $
+ * $Id: smb_stat.c,v 1.5 2003/04/23 08:20:06 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -376,6 +376,7 @@ gtk_smbstat_init(char *optarg)
GtkWidget *stat_label;
GtkWidget *filter_label;
char filter_string[256];
+ GString *error_string;
if(!strncmp(optarg,"smb,rtt,",8)){
filter=optarg+8;
@@ -472,11 +473,10 @@ gtk_smbstat_init(char *optarg)
gtk_widget_show(ss->table);
- if(register_tap_listener("smb", ss, filter, smbstat_reset, smbstat_packet, smbstat_draw)){
- char str[256];
- /* error, we failed to attach to the tap. clean up */
- snprintf(str,255,"Could not attach to tap using filter:%s\nMaybe the filter string is invalid?",filter?filter:"");
- simple_dialog(ESD_TYPE_WARN, NULL, str);
+ error_string=register_tap_listener("smb", ss, filter, smbstat_reset, smbstat_packet, smbstat_draw);
+ if(error_string){
+ simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
+ g_string_free(error_string, TRUE);
g_free(ss->filter);
g_free(ss);
return;
diff --git a/gtk/tap_rtp.c b/gtk/tap_rtp.c
index b4f51b1662..825ed1c827 100644
--- a/gtk/tap_rtp.c
+++ b/gtk/tap_rtp.c
@@ -1,7 +1,7 @@
/*
* tap_rtp.c
*
- * $Id: tap_rtp.c,v 1.9 2003/04/23 03:51:03 guy Exp $
+ * $Id: tap_rtp.c,v 1.10 2003/04/23 08:20:06 guy Exp $
*
* RTP analysing addition for ethereal
*
@@ -1621,6 +1621,7 @@ static void rtp_analyse_cb(GtkWidget *w _U_, gpointer data _U_)
gint err;
gboolean frame_matched;
frame_data *fdata;
+ GString *error_string;
/* There's already a "Display Options" dialog box; reactivate it. */
if (rtp_w != NULL) {
@@ -1694,9 +1695,11 @@ static void rtp_analyse_cb(GtkWidget *w _U_, gpointer data _U_)
edt->pi.srcport
);
/* XXX compiler warning:passing arg 5 of `register_tap_listener' from incompatible pointer type */
- if(register_tap_listener("rtp", rs, filter_text, rtp_reset, rtp_packet, rtp_draw)){
- printf("ethereal: rtp_init() failed to attach the tap.\n");
+ error_string = register_tap_listener("rtp", rs, filter_text, rtp_reset, rtp_packet, rtp_draw);
+ if (error_string != NULL) {
+ simple_dialog(ESD_TYPE_WARN, NULL, error_string->str);
/* XXX is this enough or do I have to free anything else? */
+ g_string_free(error_string, TRUE);
g_free(rs);
exit(1);
}