diff options
-rw-r--r-- | gtk/dcerpc_stat.c | 22 | ||||
-rw-r--r-- | gtk/io_stat.c | 10 | ||||
-rw-r--r-- | gtk/main.c | 4 | ||||
-rw-r--r-- | gtk/mgcp_stat.c | 13 | ||||
-rw-r--r-- | gtk/rpc_progs.c | 11 | ||||
-rw-r--r-- | gtk/rpc_stat.c | 12 | ||||
-rw-r--r-- | gtk/smb_stat.c | 12 | ||||
-rw-r--r-- | gtk/tap_rtp.c | 9 | ||||
-rw-r--r-- | packet-smb-sidsnooping.c | 10 | ||||
-rw-r--r-- | tap-dcerpcstat.c | 10 | ||||
-rw-r--r-- | tap-iostat.c | 11 | ||||
-rw-r--r-- | tap-iousers.c | 10 | ||||
-rw-r--r-- | tap-mgcpstat.c | 11 | ||||
-rw-r--r-- | tap-protocolinfo.c | 12 | ||||
-rw-r--r-- | tap-protohierstat.c | 10 | ||||
-rw-r--r-- | tap-rpcprogs.c | 11 | ||||
-rw-r--r-- | tap-rpcstat.c | 11 | ||||
-rw-r--r-- | tap-smbstat.c | 11 | ||||
-rw-r--r-- | tap.c | 28 | ||||
-rw-r--r-- | tap.h | 6 |
20 files changed, 149 insertions, 85 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); } diff --git a/packet-smb-sidsnooping.c b/packet-smb-sidsnooping.c index 226431694a..270968deba 100644 --- a/packet-smb-sidsnooping.c +++ b/packet-smb-sidsnooping.c @@ -2,7 +2,7 @@ * Routines for snooping SID to name mappings * Copyright 2003, Ronnie Sahlberg * - * $Id: packet-smb-sidsnooping.c,v 1.2 2003/03/25 19:52:56 guy Exp $ + * $Id: packet-smb-sidsnooping.c,v 1.3 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -162,6 +162,7 @@ static void sid_snooping_init(void) { header_field_info *hfi; + GString *error_string; if(lsa_QueryInfoPolicy_l3_reply_flag){ remove_tap_listener(lsa_QueryInfoPolicy_l3_reply_flag); @@ -209,10 +210,13 @@ sid_snooping_init(void) - if(register_tap_listener("dcerpc", lsa_QueryInfoPolicy_l3_reply, "dcerpc.pkt_type==2 and lsa.opnum==7 and lsa.info.level==3 and lsa.domain and smb.sid", NULL, lsa_QueryInfoPolicy_l3_reply, NULL)){ + error_string=register_tap_listener("dcerpc", lsa_QueryInfoPolicy_l3_reply, "dcerpc.pkt_type==2 and lsa.opnum==7 and lsa.info.level==3 and lsa.domain and smb.sid", NULL, lsa_QueryInfoPolicy_l3_reply, NULL); + if(error_string){ /* error, we failed to attach to the tap. clean up */ - fprintf(stderr,"tethereal: proto_reg_handoff_smb_sidsnooping()/lsa_QueryInfoPolicy_l3_reply failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register proto_reg_handoff_smb_sidsnooping()/lsa_QueryInfoPolicy_l3_reply tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } lsa_QueryInfoPolicy_l3_reply_flag=lsa_QueryInfoPolicy_l3_reply; diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c index 96b155fb44..df5e48c473 100644 --- a/tap-dcerpcstat.c +++ b/tap-dcerpcstat.c @@ -1,7 +1,7 @@ /* tap-dcerpcstat.c * dcerpcstat 2002 Ronnie Sahlberg * - * $Id: tap-dcerpcstat.c,v 1.4 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-dcerpcstat.c,v 1.5 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -197,6 +197,7 @@ 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){ uuid.Data1=d1; @@ -263,13 +264,16 @@ dcerpcstat_init(char *optarg) rs->procedures[i].tot.nsecs=0; } - if(register_tap_listener("dcerpc", rs, filter, NULL, dcerpcstat_packet, dcerpcstat_draw)){ + error_string=register_tap_listener("dcerpc", rs, filter, NULL, dcerpcstat_packet, dcerpcstat_draw); + if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(rs->procedures); g_free(rs->filter); g_free(rs); - fprintf(stderr,"tethereal: dcerpcstat_init() failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register dcerpc,rtt tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-iostat.c b/tap-iostat.c index 07f10717dc..7638d4aba8 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -1,7 +1,7 @@ /* tap-iostat.c * iostat 2002 Ronnie Sahlberg * - * $Id: tap-iostat.c,v 1.5 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-iostat.c,v 1.6 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -220,6 +220,8 @@ iostat_draw(io_stat_item_t *mit) static void register_io_tap(io_stat_t *io, int i, char *filter) { + GString *error_string; + io->items[i].prev=&io->items[i]; io->items[i].next=NULL; io->items[i].parent=io; @@ -228,10 +230,13 @@ register_io_tap(io_stat_t *io, int i, char *filter) io->items[i].bytes=0; io->filters[i]=filter; - if(register_tap_listener("frame", &io->items[i], filter, NULL, (void*)iostat_packet, i?NULL:(void*)iostat_draw)){ + error_string=register_tap_listener("frame", &io->items[i], filter, NULL, (void*)iostat_packet, i?NULL:(void*)iostat_draw); + if(error_string){ g_free(io->items); g_free(io); - fprintf(stderr,"tethereal: iostat_init() failed to attach tap\n"); + fprintf(stderr, "tethereal: Couldn't register io,stat tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-iousers.c b/tap-iousers.c index 95aeb7e541..7fdd50ae3e 100644 --- a/tap-iousers.c +++ b/tap-iousers.c @@ -1,7 +1,7 @@ /* tap-iousers.c * iostat 2003 Ronnie Sahlberg * - * $Id: tap-iousers.c,v 1.5 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-iousers.c,v 1.6 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -383,6 +383,7 @@ iousers_init(char *optarg) char *tap_type; static int (*packet_func)(io_users_t *, packet_info *, epan_dissect_t *, void *); io_users_t *iu=NULL; + GString *error_string; if(!strncmp(optarg,"io,users,eth",12)){ if(optarg[12]==','){ @@ -445,12 +446,15 @@ iousers_init(char *optarg) iu->filter=NULL; } - if(register_tap_listener(tap_type, iu, filter, NULL, (void*)packet_func, (void*)iousers_draw)){ + error_string=register_tap_listener(tap_type, iu, filter, NULL, (void*)packet_func, (void*)iousers_draw); + if(error_string){ if(iu->items){ g_free(iu->items); } g_free(iu); - fprintf(stderr,"tethereal: iousers_init() failed to attach tap\n"); + fprintf(stderr, "tethereal: Couldn't register io,users tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } diff --git a/tap-mgcpstat.c b/tap-mgcpstat.c index 8313b7f42b..193b2d5135 100644 --- a/tap-mgcpstat.c +++ b/tap-mgcpstat.c @@ -1,7 +1,7 @@ /* tap-mgcpstat.c * mgcpstat 2003 Lars Roland * - * $Id: tap-mgcpstat.c,v 1.5 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-mgcpstat.c,v 1.6 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -186,7 +186,7 @@ mgcpstat_init(char *optarg) mgcpstat_t *ms; int i; char *filter=NULL; - + GString *error_string; if(!strncmp(optarg,"mgcp,rtd,",9)){ filter=optarg+9; @@ -216,12 +216,15 @@ mgcpstat_init(char *optarg) ms->req_dup_num=0; ms->rsp_dup_num=0; - if(register_tap_listener("mgcp", ms, filter, NULL, mgcpstat_packet, mgcpstat_draw)){ + error_string=register_tap_listener("mgcp", ms, filter, NULL, mgcpstat_packet, mgcpstat_draw); + if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(ms->filter); g_free(ms); - fprintf(stderr,"tethereal: mgcpstat_init() failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register mgcp,rtd tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-protocolinfo.c b/tap-protocolinfo.c index bdc88e8a48..c2025a3ae8 100644 --- a/tap-protocolinfo.c +++ b/tap-protocolinfo.c @@ -1,7 +1,7 @@ /* tap-protocolinfo.c * protohierstat 2002 Ronnie Sahlberg * - * $Id: tap-protocolinfo.c,v 1.2 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-protocolinfo.c,v 1.3 2003/04/23 08:20:01 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -77,6 +77,7 @@ protocolinfo_init(char *optarg) char *field=NULL; char *filter=NULL; header_field_info *hfi; + GString *error_string; if(!strncmp("proto,colinfo,",optarg,14)){ filter=optarg+14; @@ -106,14 +107,17 @@ protocolinfo_init(char *optarg) rs->filter=NULL; } - if(register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL)){ - /* error, we failed to attach to the tap. clean up */ + error_string=register_tap_listener("frame", rs, rs->filter, NULL, protocolinfo_packet, NULL); + if(error_string){ + /* error, we failed to attach to the tap. complain and clean up */ + fprintf(stderr, "tethereal: Couldn't register proto,colinfo tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); if(rs->filter){ g_free(rs->filter); } g_free(rs); - fprintf(stderr,"tethereal: protocolinfo_init() failed to attach to tap.\n"); exit(1); } } diff --git a/tap-protohierstat.c b/tap-protohierstat.c index 00131f0910..1e04f028d8 100644 --- a/tap-protohierstat.c +++ b/tap-protohierstat.c @@ -1,7 +1,7 @@ /* tap-protohierstat.c * protohierstat 2002 Ronnie Sahlberg * - * $Id: tap-protohierstat.c,v 1.2 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-protohierstat.c,v 1.3 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -171,6 +171,7 @@ protohierstat_init(char *optarg) phs_t *rs; int pos=0; char *filter=NULL; + GString *error_string; if(!strcmp("io,phs",optarg)){ filter="frame"; @@ -198,12 +199,15 @@ protohierstat_init(char *optarg) rs->filter=NULL; } - if(register_tap_listener("frame", rs, filter, NULL, protohierstat_packet, protohierstat_draw)){ + error_string=register_tap_listener("frame", rs, filter, NULL, protohierstat_packet, protohierstat_draw); + if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(rs->filter); g_free(rs); - fprintf(stderr,"tethereal: protohierstat_init() failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register io,phs tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c index d544234388..7b6155a6fc 100644 --- a/tap-rpcprogs.c +++ b/tap-rpcprogs.c @@ -1,7 +1,7 @@ /* tap-rpcprogs.c * rpcstat 2002 Ronnie Sahlberg * - * $Id: tap-rpcprogs.c,v 1.4 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-rpcprogs.c,v 1.5 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -222,13 +222,18 @@ rpcprogs_draw(void *dummy _U_) static void rpcprogs_init(char *optarg _U_) { + GString *error_string; + if(already_enabled){ return; } already_enabled=1; - if(register_tap_listener("rpc", NULL, NULL, NULL, rpcprogs_packet, rpcprogs_draw)){ - fprintf(stderr,"tethereal: rpcprogs_init() failed to attach to tap.\n"); + error_string=register_tap_listener("rpc", NULL, NULL, NULL, rpcprogs_packet, rpcprogs_draw); + if(error_string){ + fprintf(stderr,"tethereal: Couldn't register rpc,programs tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-rpcstat.c b/tap-rpcstat.c index e6e743c0e0..70f3b91f30 100644 --- a/tap-rpcstat.c +++ b/tap-rpcstat.c @@ -1,7 +1,7 @@ /* tap-rpcstat.c * rpcstat 2002 Ronnie Sahlberg * - * $Id: tap-rpcstat.c,v 1.7 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-rpcstat.c,v 1.8 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -285,7 +285,7 @@ rpcstat_init(char *optarg) int program, version; int pos=0; char *filter=NULL; - + GString *error_string; if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){ if(pos){ @@ -343,13 +343,16 @@ rpcstat_init(char *optarg) * */ - if(register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw)){ + error_string=register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw); + if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(rs->procedures); g_free(rs->filter); g_free(rs); - fprintf(stderr,"tethereal: rpcstat_init() failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register rpc,rtt tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } diff --git a/tap-smbstat.c b/tap-smbstat.c index 7683ac3a3f..cb42739494 100644 --- a/tap-smbstat.c +++ b/tap-smbstat.c @@ -1,7 +1,7 @@ /* tap-smbstat.c * smbstat 2003 Ronnie Sahlberg * - * $Id: tap-smbstat.c,v 1.2 2003/04/23 03:50:59 guy Exp $ + * $Id: tap-smbstat.c,v 1.3 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -247,7 +247,7 @@ smbstat_init(char *optarg) smbstat_t *ss; guint32 i; char *filter=NULL; - + GString *error_string; if(!strncmp(optarg,"smb,rtt,",8)){ filter=optarg+8; @@ -281,12 +281,15 @@ smbstat_init(char *optarg) ss->trans2[i].tot.nsecs=0; } - if(register_tap_listener("smb", ss, filter, NULL, smbstat_packet, smbstat_draw)){ + error_string=register_tap_listener("smb", ss, filter, NULL, smbstat_packet, smbstat_draw); + if(error_string){ /* error, we failed to attach to the tap. clean up */ g_free(ss->filter); g_free(ss); - fprintf(stderr,"tethereal: smbstat_init() failed to attach to tap.\n"); + fprintf(stderr, "tethereal: Couldn't register smb,rtt tap: %s\n", + error_string->str); + g_string_free(error_string, TRUE); exit(1); } } @@ -1,7 +1,7 @@ /* tap.c * packet tap interface 2002 Ronnie Sahlberg * - * $Id: tap.c,v 1.8 2002/11/28 20:28:28 guy Exp $ + * $Id: tap.c,v 1.9 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -335,29 +335,35 @@ find_tap_id(char *name) /* this function attaches the tap_listener to the named tap. * function returns : - * 0: ok. - * !0: error -*/ -int + * NULL: ok. + * non-NULL: error, return value points to GString containing error + * message. + */ +GString * register_tap_listener(char *tapname, void *tapdata, char *fstring, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw) { tap_listener_t *tl; int tap_id; + GString *error_string; tap_id=find_tap_id(tapname); if(!tap_id){ - fprintf(stderr, "tap not found\n"); - exit(10); + error_string = g_string_new(""); + g_string_sprintf(error_string, "Tap %s not found", tapname); + return error_string; } tl=g_malloc(sizeof(tap_listener_t)); tl->code=NULL; tl->needs_redraw=1; if(fstring){ - if(!dfilter_compile(fstring ,&tl->code)){ + if(!dfilter_compile(fstring, &tl->code)){ + error_string = g_string_new(""); + g_string_sprintf(error_string, + "Filter \"%s\" is invalid - %s", + fstring, dfilter_error_msg); g_free(tl); - fprintf(stderr,"register_tap_listener(): %s\n", dfilter_error_msg); - return 1; + return error_string; } else { num_tap_filters++; } @@ -372,7 +378,7 @@ register_tap_listener(char *tapname, void *tapdata, char *fstring, tap_reset_cb tap_listener_queue=tl; - return 0; + return NULL; } /* this function removes a tap listener @@ -1,7 +1,7 @@ /* tap.h * packet tap interface 2002 Ronnie Sahlberg * - * $Id: tap.h,v 1.7 2003/03/06 19:04:28 guy Exp $ + * $Id: tap.h,v 1.8 2003/04/23 08:20:02 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -42,7 +42,9 @@ extern void tap_queue_init(epan_dissect_t *edt); extern void tap_push_tapped_queue(epan_dissect_t *edt); extern void reset_tap_listeners(void); extern void draw_tap_listeners(gboolean draw_all); -extern int register_tap_listener(char *tapname, void *tapdata, char *fstring, tap_reset_cb tap_reset, tap_packet_cb tap_packet, tap_draw_cb tap_draw); +extern GString *register_tap_listener(char *tapname, void *tapdata, + char *fstring, tap_reset_cb tap_reset, tap_packet_cb tap_packet, + tap_draw_cb tap_draw); extern void remove_tap_listener(void *tapdata); #endif |