aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/main.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2002-11-06 10:53:36 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2002-11-06 10:53:36 +0000
commitb3e0a56390fdce140228692d9ad3389bfa71c876 (patch)
tree15aec5df6848a3bc189cae2e8a4ef9fc354f49f0 /gtk/main.c
parentd4e632c5ea3e69eeb958582246ec185fb7832efc (diff)
First step in creating an API to register TAPs for use with ethereal instead of hardcoding them in main.c/menu.c
This adds functions to register the command line arguments to use the API in the same way as is done for tethereal. Later it may be extended to also register the GUI/Menu entry point to ethereal using this api but that iwll be later since the changes required to menu.c are not as intrusive as the main.c command line parsing ones were. Some of the latest changes (before this checkin) has made ethereal to produce lots of GTK errors when starting up the extension windows. They were there before this checking but will be investigated. svn path=/trunk/; revision=6566
Diffstat (limited to 'gtk/main.c')
-rw-r--r--gtk/main.c106
1 files changed, 40 insertions, 66 deletions
diff --git a/gtk/main.c b/gtk/main.c
index a6442c469d..5cf2c3f7f1 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.272 2002/11/03 17:38:33 oabad Exp $
+ * $Id: main.c,v 1.273 2002/11/06 10:53:36 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -129,10 +129,6 @@
#include "image/clist_ascend.xpm"
#include "image/clist_descend.xpm"
#include "../tap.h"
-#include "rpc_stat.h"
-#include "rpc_progs.h"
-#include "../packet-dcerpc.h"
-#include "dcerpc_stat.h"
#ifdef WIN32
#include "capture-wpcap.h"
@@ -1339,6 +1335,28 @@ unprotect_thread_critical_region(void)
#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;
+
+}
+
/* And now our feature presentation... [ fade to music ] */
int
main(int argc, char *argv[])
@@ -1391,6 +1409,7 @@ main(int argc, char *argv[])
#endif
gint desk_x, desk_y;
gboolean prefs_write_needed = FALSE;
+ ethereal_tap_list *tli;
#define OPTSTRING_INIT "a:b:B:c:f:hi:klm:nN:o:pP:Qr:R:Ss:t:T:w:vz:"
@@ -1441,6 +1460,7 @@ main(int argc, char *argv[])
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. */
@@ -1815,68 +1835,22 @@ main(int argc, char *argv[])
cfile.save_file_fd = atoi(optarg);
break;
#endif
- 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){
- gtk_rpcstat_init(rpcprogram,rpcversion,optarg+pos);
- } else {
- gtk_rpcstat_init(rpcprogram,rpcversion,NULL);
- }
- } else {
- fprintf(stderr, "ethereal: invalid \"-z rpc,rtt,<program>,<version>[,<filter>]\" argument\n");
- exit(1);
- }
- } else if(!strncmp(optarg,"rpc,programs",12)){
- gtk_rpcprogs_init();
- } else {
- fprintf(stderr, "ethereal: 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);
- }
- } 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){
- gtk_dcerpcstat_init(&uuid,major,minor,optarg+pos);
- } else {
- gtk_dcerpcstat_init(&uuid,major,minor,NULL);
- }
- } else {
- fprintf(stderr, "ethereal: 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);
- }
- } else {
- fprintf(stderr, "ethereal: invalid -z argument. Argument must be one of:\n");
- fprintf(stderr, " \"-z rpc,...\"\n");
- fprintf(stderr, " \"-z dcerpc,...\"\n");
- exit(1);
- }
+ case 'z':
+ for(tli=tap_list;tli;tli=tli->next){
+ if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){
+ (*tli->func)(optarg);
break;
+ }
+ }
+ if(!tli){
+ fprintf(stderr,"ethereal: 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);
+ }
+ exit(1);
+ }
+ break;
#ifdef _WIN32
#ifdef HAVE_LIBPCAP