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
This commit is contained in:
parent
81ebec370d
commit
1b872b3648
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
11
tap-iostat.c
11
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
28
tap.c
28
tap.c
|
@ -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
|
||||
|
|
6
tap.h
6
tap.h
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue