aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cvsignore1
-rw-r--r--Makefile.am42
-rw-r--r--Makefile.nmake67
-rwxr-xr-xmake-tapreg-dotc42
-rw-r--r--register.h5
-rw-r--r--tap-dcerpcstat.c58
-rw-r--r--tap-dcerpcstat.h28
-rw-r--r--tap-rpcprogs.c19
-rw-r--r--tap-rpcprogs.h28
-rw-r--r--tap-rpcstat.c42
-rw-r--r--tap-rpcstat.h28
-rw-r--r--tap.c10
-rw-r--r--tap.h9
-rw-r--r--tethereal.c96
14 files changed, 276 insertions, 199 deletions
diff --git a/.cvsignore b/.cvsignore
index 565f7cd854..0a19603532 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -53,6 +53,7 @@ stamp-h1
tethereal
tethereal.1
tethereal_static
+tethereal-tap-register.c
text2pcap
text2pcap-scanner.c
text2pcap.1
diff --git a/Makefile.am b/Makefile.am
index e7a7e5658d..981a81971f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.511 2002/10/31 07:12:23 guy Exp $
+# $Id: Makefile.am,v 1.512 2002/10/31 22:16:00 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@ethereal.com>
@@ -638,12 +638,6 @@ ETHEREAL_COMMON_SRC = \
smb.h \
tap.c \
tap.h \
- tap-dcerpcstat.c \
- tap-dcerpcstat.h \
- tap-rpcstat.c \
- tap-rpcstat.h \
- tap-rpcprogs.c \
- tap-rpcprogs.h \
util.c \
util.h \
x11-declarations.h \
@@ -669,8 +663,6 @@ ethereal_SOURCES = \
filters.h \
globals.h \
menu.h \
- \
- \
progress_dlg.h \
proto_hier_stats.h \
proto_hier_stats.c \
@@ -691,8 +683,6 @@ ethereal_static_SOURCES = \
filters.h \
globals.h \
menu.h \
- \
- \
progress_dlg.h \
proto_hier_stats.h \
proto_hier_stats.c \
@@ -779,15 +769,24 @@ ethereal_static_LDADD = \
ethereal_LDFLAGS = -export-dynamic
ethereal_static_LDFLAGS = -Wl,-static
+TETHEREAL_TAP_SRC = \
+ tap-dcerpcstat.c \
+ tap-rpcstat.c \
+ tap-rpcprogs.c
+
tethereal_SOURCES = \
$(DISSECTOR_SRC) \
$(ETHEREAL_COMMON_SRC) \
+ $(TETHEREAL_TAP_SRC) \
+ tethereal-tap-register.c \
register.c \
tethereal.c
tethereal_static_SOURCES = \
$(DISSECTOR_SRC) \
$(ETHEREAL_COMMON_SRC) \
+ $(TETHEREAL_TAP_SRC) \
+ tethereal-tap-register.c \
register-static.c \
tethereal.c
@@ -892,7 +891,8 @@ SUFFIXES = .sh
#
# Therefore, we have a script to generate the "register.c" file.
#
-# The first argument is the directory in which the source files live.
+# The first argument is the name of the file to write.
+# The second argument is the directory in which the source files live.
# All subsequent arguments are the files to scan.
#
register.c: $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
@@ -903,6 +903,24 @@ register-static.c: $(plugin_src) $(DISSECTOR_SRC) $(srcdir)/make-reg-dotc
@echo Making register-static.c
@$(srcdir)/make-reg-dotc register-static.c $(srcdir) $(plugin_src) $(DISSECTOR_SRC)
+#
+# Build "tethereal-tap-register.c", which contains a function
+# "register_all_tap_listeners()"
+# that calls the register routines for all tehtereal tap listeners.
+#
+# We do this by grepping through sources.
+#
+# Formatting conventions: The name of the tap_listener_register_*
+# routines must start in column zero, or must be preceded only by
+# "void " starting in column zero, and must not be inside #if.
+#
+# The first argument is the directory in which the source files live.
+# All subsequent arguments are the files to scan.
+#
+tethereal-tap-register.c: $(TETHEREAL_TAP_SRC) $(srcdir)/make-tapreg-dotc
+ @echo Making tethereal-tap-register.c
+ @$(srcdir)/make-tapreg-dotc tethereal-tap-register.c $(srcdir) $(TETHEREAL_TAP_SRC)
+
ps.c: print.ps rdps
./rdps $(srcdir)/print.ps ps.c
diff --git a/Makefile.nmake b/Makefile.nmake
index ff250f62dc..0a524345d3 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -1,7 +1,7 @@
## Makefile for building ethereal.exe with Microsoft C and nmake
## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
#
-# $Id: Makefile.nmake,v 1.246 2002/10/31 07:12:23 guy Exp $
+# $Id: Makefile.nmake,v 1.247 2002/10/31 22:16:01 guy Exp $
include config.nmake
include <win32.mak>
@@ -321,6 +321,13 @@ DISSECTOR_SRC = \
DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
+TETHEREAL_TAP_SRC = \
+ tap-dcerpcstat.c \
+ tap-rpcstat.c \
+ tap-rpcprogs.c
+
+TETHEREAL_TAP_OBJECTS = $(TETHEREAL_TAP_SRC:.c=.obj)
+
ETHEREAL_COMMON_OBJECTS = \
afn.obj \
asn1.obj \
@@ -342,9 +349,6 @@ ETHEREAL_COMMON_OBJECTS = \
register.obj \
ringbuffer.obj \
tap.obj \
- tap-dcerpcstat.obj \
- tap-rpcstat.obj \
- tap-rpcprogs.obj \
util.obj \
xdlc.obj \
xmlstub.obj \
@@ -361,6 +365,8 @@ ethereal_OBJECTS = \
tethereal_OBJECTS = \
$(DISSECTOR_OBJECTS) \
$(ETHEREAL_COMMON_OBJECTS) \
+ $(TETHEREAL_TAP_OBJECTS) \
+ tethereal-tap-register.obj \
tethereal.obj
dftest_OBJECTS = \
@@ -498,15 +504,66 @@ packet-ncp2222.c : ncp2222.py
touch packet-ncp.c $@
!ENDIF
+#
+# Build "register.c", which contains a function "register_all_protocols()"
+# that calls the register routines for all protocols.
+#
+# We do this by grepping through sources. If that turns out to be too slow,
+# maybe we could just require every .o file to have an register routine
+# of a given name (packet-aarp.o -> proto_register_aarp, etc.).
+#
+# Formatting conventions: The name of the proto_register_* routines must
+# start in column zero, or must be preceded only by "void " starting in
+# column zero, and must not be inside #if.
+#
+# We assume that all dissector routines are in "packet-XXX.c" files.
+#
+# For some unknown reason, having a big "for" loop in the Makefile
+# to scan all the "packet-XXX.c" files doesn't work with some "make"s;
+# they seem to pass only the first few names in the list to the shell,
+# for some reason.
+#
+# Therefore, we have a script to generate the "register.c" file.
+#
+# The first argument is the name of the file to write.
+# The second argument is the directory in which the source files live.
+# All subsequent arguments are the files to scan.
+#
+# On Windows, however, that script runs slowly, as multiple greps
+# and seds are run for each input file, so, if Python is present
+# (as indicated by PYTHON being defined), we run a faster Python
+# script to do that work instead. That script doesn't take the name
+# of the file to write as an argument; it always writes to
+# "register.c".
+#
register.c: $(DISSECTOR_SRC)
!IFDEF PYTHON
@echo Making register.c (using python)
@$(PYTHON) make-reg-dotc.py . $(DISSECTOR_SRC)
!ELSE
@echo Making register.c (using sh)
- @sh make-reg-dotc register.c $(DISSECTOR_SRC)
+ @sh make-reg-dotc register.c . $(DISSECTOR_SRC)
!ENDIF
+#
+# Build "tethereal-tap-register.c", which contains a function
+# "register_all_tap_listeners()"
+# that calls the register routines for all tehtereal tap listeners.
+#
+# We do this by grepping through sources.
+#
+# Formatting conventions: The name of the tap_listener_register_*
+# routines must start in column zero, or must be preceded only by
+# "void " starting in column zero, and must not be inside #if.
+#
+# The first argument is the name of the file to write.
+# The second argument is the directory in which the source files live.
+# All subsequent arguments are the files to scan.
+#
+tethereal-tap-register.c: $(TETHEREAL_TAP_SRC)
+ @echo Making tethereal-tap-register.c
+ @sh make-tapreg-dotc tethereal-tap-register.c . $(TETHEREAL_TAP_SRC)
+
text2pcap-scanner.c : text2pcap-scanner.l
$(LEX) -otext2pcap-scanner.c text2pcap-scanner.l
diff --git a/make-tapreg-dotc b/make-tapreg-dotc
new file mode 100755
index 0000000000..d3c470529c
--- /dev/null
+++ b/make-tapreg-dotc
@@ -0,0 +1,42 @@
+#! /bin/sh
+
+#
+# The first argument is the output filename.
+#
+
+outfile="$1"
+shift
+
+#
+# The second argument is the directory in which the source files live.
+#
+srcdir="$1"
+shift
+
+#
+# All subsequent arguments are the files to scan.
+#
+rm -f ${outfile}-tmp
+echo '/* Do not modify this file. */' >${outfile}-tmp
+echo '/* It is created automatically by the Makefile. */'>>${outfile}-tmp
+
+#
+# Build code to call all the tap listener registration routines.
+#
+echo 'void register_all_tap_listeners(void) {' >>${outfile}-tmp
+for f in "$@"
+do
+ if [ -f $f ]
+ then
+ srcfile=$f
+ else
+ srcfile=$srcdir/$f
+ fi
+ grep '^register_tap_listener_[a-z_0-9A-Z]* *(' $srcfile 2>/dev/null | grep -v ';' | sed -e 's/(.*//'
+done | while read func; do
+ echo " { extern void $func (void);" >>${outfile}-tmp
+ echo " $func ();}" >>${outfile}-tmp
+done
+echo '}' >>${outfile}-tmp
+
+mv ${outfile}-tmp ${outfile}
diff --git a/register.h b/register.h
index 1660839259..cd17238c77 100644
--- a/register.h
+++ b/register.h
@@ -1,7 +1,7 @@
/* register.h
* Definitions for protocol registration
*
- * $Id: register.h,v 1.3 2002/08/28 21:00:41 jmayer Exp $
+ * $Id: register.h,v 1.4 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -28,5 +28,6 @@
extern void register_all_protocols(void);
extern void register_all_protocol_handoffs(void);
-
+extern void register_all_tap_listeners(void);
+extern void register_ethereal_tap(char *str, void (*init)(char *), char *menu, void(*menu_init)(void));
#endif /* __REGISTER_H__ */
diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c
index d70cd08b8d..8433125ff0 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.2 2002/10/25 01:02:49 guy Exp $
+ * $Id: tap-dcerpcstat.c,v 1.3 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -36,7 +36,7 @@
#include "epan/packet_info.h"
#include "tap.h"
#include "packet-dcerpc.h"
-#include "tap-dcerpcstat.h"
+#include "register.h"
/* used to keep track of statistics for a specific procedure */
typedef struct _rpc_procedure_t {
@@ -60,8 +60,10 @@ typedef struct _rpcstat_t {
static int
-dcerpcstat_packet(rpcstat_t *rs, packet_info *pinfo, dcerpc_info *ri)
+dcerpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, void *pri)
{
+ dcerpc_info *ri=pri;
+ rpcstat_t *rs=prs;
nstime_t delta;
rpc_procedure_t *rp;
@@ -146,8 +148,9 @@ dcerpcstat_packet(rpcstat_t *rs, packet_info *pinfo, dcerpc_info *ri)
}
static void
-dcerpcstat_draw(rpcstat_t *rs)
+dcerpcstat_draw(void *prs)
{
+ rpcstat_t *rs=prs;
guint32 i;
#ifdef G_HAVE_UINT64
guint64 td;
@@ -183,22 +186,50 @@ dcerpcstat_draw(rpcstat_t *rs)
-void
-dcerpcstat_init(e_uuid_t *uuid, int major, int minor, char *filter)
+static void
+dcerpcstat_init(char *optarg)
{
rpcstat_t *rs;
guint32 i, max_procs;
dcerpc_sub_dissector *procs;
+ e_uuid_t uuid;
+ int d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
+ int major, minor;
+ int pos=0;
+ char *filter=NULL;
+
+ 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;
+ uuid.Data4[0]=d40;
+ uuid.Data4[1]=d41;
+ uuid.Data4[2]=d42;
+ uuid.Data4[3]=d43;
+ uuid.Data4[4]=d44;
+ uuid.Data4[5]=d45;
+ uuid.Data4[6]=d46;
+ uuid.Data4[7]=d47;
+ if(pos){
+ filter=optarg+pos;
+ } else {
+ filter=NULL;
+ }
+ } else {
+ fprintf(stderr, "tethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
+ exit(1);
+ }
+
rs=g_malloc(sizeof(rpcstat_t));
- rs->prog=dcerpc_get_proto_name(uuid, (minor<<8)|(major&0xff) );
+ 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,"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);
exit(1);
}
- procs=dcerpc_get_proto_sub_dissector(uuid, (minor<<8)|(major&0xff) );
- rs->uuid=*uuid;
+ procs=dcerpc_get_proto_sub_dissector(&uuid, (minor<<8)|(major&0xff) );
+ rs->uuid=uuid;
rs->ver=(minor<<8)|(major&0xff);
if(filter){
@@ -232,7 +263,7 @@ dcerpcstat_init(e_uuid_t *uuid, int major, int minor, char *filter)
rs->procedures[i].tot.nsecs=0;
}
- if(register_tap_listener("dcerpc", rs, filter, NULL, (void*)dcerpcstat_packet, (void*)dcerpcstat_draw)){
+ if(register_tap_listener("dcerpc", rs, filter, NULL, dcerpcstat_packet, dcerpcstat_draw)){
/* error, we failed to attach to the tap. clean up */
g_free(rs->procedures);
g_free(rs->filter);
@@ -243,3 +274,8 @@ dcerpcstat_init(e_uuid_t *uuid, int major, int minor, char *filter)
}
}
+void
+register_tap_listener_dcerpcstat(void)
+{
+ register_ethereal_tap("dcerpc,rtt,", dcerpcstat_init, NULL, NULL);
+}
diff --git a/tap-dcerpcstat.h b/tap-dcerpcstat.h
deleted file mode 100644
index afe5d65441..0000000000
--- a/tap-dcerpcstat.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* tap-dcerpcstat.h
- * dcerpcstat 2002 Ronnie Sahlberg
- *
- * $Id: tap-dcerpcstat.h,v 1.1 2002/10/23 03:49:10 guy Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * 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.
- */
-
-void dcerpcstat_init(e_uuid_t *program, int major, int minor, char *filter);
-
-
-
diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c
index 83da9823d1..50d3f0c21d 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.2 2002/10/23 23:12:34 guy Exp $
+ * $Id: tap-rpcprogs.c,v 1.3 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,9 +39,8 @@
#include <string.h>
#include "epan/packet_info.h"
#include "tap.h"
-#include "tap-rpcprogs.h"
#include "packet-rpc.h"
-
+#include "register.h"
/* used to keep track of statistics for a specific program/version */
typedef struct _rpc_program_t {
@@ -58,8 +57,9 @@ static rpc_program_t *prog_list=NULL;
static int already_enabled=0;
static int
-rpcprogs_packet(void *dummy1 _U_, packet_info *pinfo, epan_dissect_t *edt _U_, rpc_call_info_value *ri)
+rpcprogs_packet(void *dummy1 _U_, packet_info *pinfo, epan_dissect_t *edt _U_, void *pri)
{
+ rpc_call_info_value *ri=pri;
nstime_t delta;
rpc_program_t *rp=NULL;
@@ -219,20 +219,25 @@ rpcprogs_draw(void *dummy _U_)
}
-void
-rpcprogs_init(void)
+static void
+rpcprogs_init(char *optarg _U_)
{
if(already_enabled){
return;
}
already_enabled=1;
- if(register_tap_listener("rpc", NULL, NULL, NULL, (void*)rpcprogs_packet, (void*)rpcprogs_draw)){
+ if(register_tap_listener("rpc", NULL, NULL, NULL, rpcprogs_packet, rpcprogs_draw)){
fprintf(stderr,"tethereal: rpcprogs_init() failed to attach to tap.\n");
exit(1);
}
}
+void
+register_tap_listener_rpcprogs(void)
+{
+ register_ethereal_tap("rpc,programs", rpcprogs_init, NULL, NULL);
+}
diff --git a/tap-rpcprogs.h b/tap-rpcprogs.h
deleted file mode 100644
index 81171cf1c2..0000000000
--- a/tap-rpcprogs.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* tap-rpcprogs.h
- * rpcprogs 2002 Ronnie Sahlberg
- *
- * $Id: tap-rpcprogs.h,v 1.1 2002/09/05 09:27:50 sahlberg Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * 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.
- */
-
-void rpcprogs_init(void);
-
-
-
diff --git a/tap-rpcstat.c b/tap-rpcstat.c
index 79dfe99bfd..069baa4b39 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.4 2002/10/23 23:12:34 guy Exp $
+ * $Id: tap-rpcstat.c,v 1.5 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -41,9 +41,8 @@
#include <string.h>
#include "epan/packet_info.h"
#include "tap.h"
-#include "tap-rpcstat.h"
#include "packet-rpc.h"
-
+#include "register.h"
/* used to keep track of statistics for a specific procedure */
typedef struct _rpc_procedure_t {
@@ -77,8 +76,9 @@ typedef struct _rpcstat_t {
* situations, here is a good place to put that code.
*/
static void
-rpcstat_reset(rpcstat_t *rs)
+rpcstat_reset(void *prs)
{
+ rpcstat_t *rs=prs;
guint32 i;
for(i=0;i<rs->num_procedures;i++){
@@ -124,8 +124,10 @@ rpcstat_reset(rpcstat_t *rs)
* !0: state has changed, call (*draw) sometime later
*/
static int
-rpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, rpc_call_info_value *ri)
+rpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, void *pri)
{
+ rpcstat_t *rs=prs;
+ rpc_call_info_value *ri=pri;
nstime_t delta;
rpc_procedure_t *rp;
@@ -201,8 +203,9 @@ rpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, rpc_c
* beneath us. Beware.
*/
static void
-rpcstat_draw(rpcstat_t *rs)
+rpcstat_draw(void *prs)
{
+ rpcstat_t *rs=prs;
guint32 i;
#ifdef G_HAVE_UINT64
guint64 td;
@@ -274,11 +277,26 @@ rpcstat_find_procs(gpointer *key, gpointer *value _U_, gpointer *user_data _U_)
* and it creates a new instance to store statistics in and registers this
* new instance for the rpc tap.
*/
-void
-rpcstat_init(guint32 program, guint32 version, char *filter)
+static void
+rpcstat_init(char *optarg)
{
rpcstat_t *rs;
guint32 i;
+ int program, version;
+ int pos=0;
+ char *filter=NULL;
+
+ if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&program,&version,&pos)==2){
+ if(pos){
+ filter=optarg+pos;
+ } else {
+ filter=NULL;
+ }
+ } else {
+ fprintf(stderr, "tethereal: invalid \"-z rpc,rtt,<program>,<version>[,<filter>]\" argument\n");
+ exit(1);
+ }
+
rs=g_malloc(sizeof(rpcstat_t));
rs->prog=rpc_prog_name(program);
@@ -325,7 +343,7 @@ rpcstat_init(guint32 program, guint32 version, char *filter)
*
*/
- if(register_tap_listener("rpc", rs, filter, (void*)rpcstat_reset, (void*)rpcstat_packet, (void*)rpcstat_draw)){
+ if(register_tap_listener("rpc", rs, filter, rpcstat_reset, rpcstat_packet, rpcstat_draw)){
/* error, we failed to attach to the tap. clean up */
g_free(rs->procedures);
g_free(rs->filter);
@@ -337,5 +355,9 @@ rpcstat_init(guint32 program, guint32 version, char *filter)
}
-
+void
+register_tap_listener_rpcstat(void)
+{
+ register_ethereal_tap("rpc,rtt,", rpcstat_init, NULL, NULL);
+}
diff --git a/tap-rpcstat.h b/tap-rpcstat.h
deleted file mode 100644
index 114ad33b19..0000000000
--- a/tap-rpcstat.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* tap-rpcstat.h
- * rpcstat 2002 Ronnie Sahlberg
- *
- * $Id: tap-rpcstat.h,v 1.2 2002/09/26 01:13:02 sahlberg Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
- * 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.
- */
-
-void rpcstat_init(guint32 program, guint32 version, char *filter);
-
-
-
diff --git a/tap.c b/tap.c
index e8332875ea..1fad0d06f5 100644
--- a/tap.c
+++ b/tap.c
@@ -1,7 +1,7 @@
/* tap.c
* packet tap interface 2002 Ronnie Sahlberg
*
- * $Id: tap.c,v 1.6 2002/10/23 23:12:34 guy Exp $
+ * $Id: tap.c,v 1.7 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -74,9 +74,9 @@ typedef struct _tap_listener_t {
int needs_redraw;
dfilter_t *code;
void *tapdata;
- void (*reset)(void *tapdata);
- int (*packet)(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, void *data);
- void (*draw)(void *tapdata);
+ tap_reset_cb reset;
+ tap_packet_cb packet;
+ tap_draw_cb draw;
} tap_listener_t;
static volatile tap_listener_t *tap_listener_queue=NULL;
@@ -339,7 +339,7 @@ find_tap_id(char *name)
* !0: error
*/
int
-register_tap_listener(char *tapname, void *tapdata, char *fstring, void (*reset)(void *tapdata), int (*packet)(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, void *data), void (*draw)(void *tapdata))
+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;
diff --git a/tap.h b/tap.h
index bfd8e7bbaf..b2825c37c0 100644
--- a/tap.h
+++ b/tap.h
@@ -1,7 +1,7 @@
/* tap.h
* packet tap interface 2002 Ronnie Sahlberg
*
- * $Id: tap.h,v 1.4 2002/10/23 23:12:34 guy Exp $
+ * $Id: tap.h,v 1.5 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -26,6 +26,11 @@
extern int num_tap_filters;
+typedef void (*tap_reset_cb)(void *tapdata);
+typedef int (*tap_packet_cb)(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, void *data);
+typedef void (*tap_draw_cb)(void *tapdata);
+
+
void tap_init(void);
int register_tap(char *name);
int find_tap_id(char *name);
@@ -35,7 +40,7 @@ void tap_push_tapped_queue(epan_dissect_t *edt);
extern int tapping_is_active;
void reset_tap_listeners(void);
void draw_tap_listeners(gboolean draw_all);
-int register_tap_listener(char *tapname, void *tapdata, char *fstring, void (*reset)(void *tapdata), int (*packet)(void *tapdata, packet_info *pinfo, epan_dissect_t *edt, void *data), void (*draw)(void *tapdata));
+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);
void remove_tap_listener(void *tapdata);
diff --git a/tethereal.c b/tethereal.c
index 4d5bbe0b97..bcab936b21 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.166 2002/10/31 20:24:41 guy Exp $
+ * $Id: tethereal.c,v 1.167 2002/10/31 22:16:01 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -104,10 +104,6 @@
#include "ringbuffer.h"
#include <epan/epan_dissect.h>
#include "tap.h"
-#include "tap-rpcstat.h"
-#include "tap-rpcprogs.h"
-#include "packet-dcerpc.h"
-#include "tap-dcerpcstat.h"
#ifdef HAVE_LIBPCAP
#include <wiretap/wtap-capture.h>
@@ -307,6 +303,28 @@ set_autostop_criterion(const char *autostoparg)
}
#endif
+/* structure to keep track of what tap listeners have been registered.
+ */
+typedef struct _ethereal_tap_list {
+ struct _ethereal_tap_list *next;
+ char *cmd;
+ void (*func)(char *arg);
+} ethereal_tap_list;
+static ethereal_tap_list *tap_list=NULL;
+
+void
+register_ethereal_tap(char *cmd, void (*func)(char *arg), char *dummy _U_, void (*dummy2)(void) _U_)
+{
+ ethereal_tap_list *newtl;
+
+ newtl=malloc(sizeof(ethereal_tap_list));
+ newtl->next=tap_list;
+ tap_list=newtl;
+ newtl->cmd=cmd;
+ newtl->func=func;
+
+}
+
int
main(int argc, char *argv[])
{
@@ -347,12 +365,14 @@ main(int argc, char *argv[])
dfilter_t *rfcode = NULL;
e_prefs *prefs;
char badopt;
+ ethereal_tap_list *tli;
/* Register all dissectors; we must do this before checking for the
"-G" flag, as the "-G" flag dumps information registered by the
dissectors, and we must do it before we read the preferences, in
case any dissectors register preferences. */
epan_init(PLUGIN_DIR,register_all_protocols,register_all_protocol_handoffs);
+ register_all_tap_listeners();
/* Now register the preferences for any non-dissector modules.
We must do that before we read the preferences as well. */
@@ -652,64 +672,18 @@ main(int argc, char *argv[])
print_hex = TRUE;
break;
case 'z':
- if(!strncmp(optarg,"rpc,",4)){
- if(!strncmp(optarg,"rpc,rtt,",8)){
- int rpcprogram, rpcversion;
- int pos=0;
- if(sscanf(optarg,"rpc,rtt,%d,%d,%n",&rpcprogram,&rpcversion,&pos)==2){
- if(pos){
- rpcstat_init(rpcprogram,rpcversion,optarg+pos);
- } else {
- rpcstat_init(rpcprogram,rpcversion,NULL);
- }
- } else {
- fprintf(stderr, "tethereal: invalid \"-z rpc,rtt,<program>,<version>[,<filter>]\" argument\n");
- exit(1);
- }
- } else if(!strncmp(optarg,"rpc,programs",12)){
- rpcprogs_init();
- } else {
- fprintf(stderr, "tethereal: invalid -z argument. Argument must be one of:\n");
- fprintf(stderr, " \"-z rpc,rtt,<program>,<version>[,<filter>]\"\n");
- fprintf(stderr, " \"-z rpc,programs\"\n");
- exit(1);
+ for(tli=tap_list;tli;tli=tli->next){
+ if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){
+ (*tli->func)(optarg);
+ break;
}
- } else if(!strncmp(optarg,"dcerpc,",7)){
- if(!strncmp(optarg,"dcerpc,rtt,",11)){
- e_uuid_t uuid;
- int d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47;
- int major, minor;
- int pos=0;
- 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;
- uuid.Data4[0]=d40;
- uuid.Data4[1]=d41;
- uuid.Data4[2]=d42;
- uuid.Data4[3]=d43;
- uuid.Data4[4]=d44;
- uuid.Data4[5]=d45;
- uuid.Data4[6]=d46;
- uuid.Data4[7]=d47;
- if(pos){
- dcerpcstat_init(&uuid,major,minor,optarg+pos);
- } else {
- dcerpcstat_init(&uuid,major,minor,NULL);
- }
- } else {
- fprintf(stderr, "tethereal: invalid \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n");
- exit(1);
- }
- } else {
- fprintf(stderr, "tethereal: invalid -z argument. Argument must be one of:\n");
- fprintf(stderr, " \"-z dcerpc,rtt,<uuid>,<major version>.<minor version>[,<filter>]\"\n");
- exit(1);
+ }
+ if(!tli){
+ fprintf(stderr,"tethereal: invalid -z argument.\n");
+ fprintf(stderr," -z argument must be one of :\n");
+ for(tli=tap_list;tli;tli=tli->next){
+ fprintf(stderr," %s\n",tli->cmd);
}
- } else {
- fprintf(stderr, "tethereal: invalid -z argument. Argument must be one of:\n");
- fprintf(stderr, " \"-z rpc,...\"\n");
- fprintf(stderr, " \"-z dcerpc,...\"\n");
exit(1);
}
break;