diff options
author | Guy Harris <guy@alum.mit.edu> | 2002-10-31 22:16:01 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2002-10-31 22:16:01 +0000 |
commit | 8442ad9a325bbfa3a19f9d55bb4df9c7a01f87f4 (patch) | |
tree | e75e61ee1cff0099bba850493b73b51b9a4f0e4f /tethereal.c | |
parent | 05c9a9709146670ee19fd068a8de69d750f98728 (diff) | |
download | wireshark-8442ad9a325bbfa3a19f9d55bb4df9c7a01f87f4.tar.gz wireshark-8442ad9a325bbfa3a19f9d55bb4df9c7a01f87f4.tar.bz2 wireshark-8442ad9a325bbfa3a19f9d55bb4df9c7a01f87f4.zip |
From Ronnie Sahlberg: have a registration interface for tap listeners,
and generate the table of stuff to register from tap source files, so
Tethereal doesn't need to know what tap listeners exist.
Get rid of "tap-xxx.h" files, as they're now empty.
Add "tethereal-tap-register.c" to the .cvsignore file, as it's a new
generated file.
Update "Makefile.nmake" to generate "tethereal-tap-register.c".
Clean up "Makefile.am" and "Makefile.nmake" a bit.
svn path=/trunk/; revision=6525
Diffstat (limited to 'tethereal.c')
-rw-r--r-- | tethereal.c | 96 |
1 files changed, 35 insertions, 61 deletions
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; |