aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-04-01 09:08:27 +0000
committerGuy Harris <guy@alum.mit.edu>2005-04-01 09:08:27 +0000
commit80c1907a3650bd7ce3486deaf8bfe03998cc53cf (patch)
treef40c994e197238fcb60ea9206222296805d55dfb /epan
parent0f8018692fed4def8c299c3c6485c416c986e717 (diff)
Rename "register_ethereal_tap()" to "register_tap_listener_cmd_arg()" as
it's used to register a callback for a tap listener invoked if the specified command line argument is specified to the "-z" flag. Move it, along with routines to: look up a "-z" argument in the table constructed by "register_tap_listener_cmd_arg()" and either save the full argument to "-z" and the corresponding listener if it's found or return a failure indication if it isn't; list the available tap listeners; call the "init" routines for the tap listeners saved in the table above; and have Ethereal and Tethereal use those routines. svn path=/trunk/; revision=13993
Diffstat (limited to 'epan')
-rw-r--r--epan/libethereal.def4
-rw-r--r--epan/tap.c84
-rw-r--r--epan/tap.h4
3 files changed, 92 insertions, 0 deletions
diff --git a/epan/libethereal.def b/epan/libethereal.def
index 0d2169e026..23cb0f37d9 100644
--- a/epan/libethereal.def
+++ b/epan/libethereal.def
@@ -319,6 +319,7 @@ isup_message_type_value DATA
isup_message_type_value_acro DATA
is_big_endian
is_tpkt
+list_tap_cmd_args
LocationRejectReason_vals DATA
match_strval
mkstemp
@@ -347,6 +348,7 @@ prefs_register_range_preference
prefs_register_string_preference
prefs_register_uint_preference
prefs_set_pref
+process_tap_cmd_arg
protocols_module DATA
proto_can_match_selected
proto_can_toggle_protocol
@@ -464,6 +466,7 @@ register_init_routine
register_postseq_cleanup_routine
register_tap
register_tap_listener
+register_tap_listener_cmd_arg
RegistrationRejectReason_vals DATA
ReleaseCompleteReason_vals DATA
remove_tap_listener
@@ -493,6 +496,7 @@ sid_name_snooping DATA
sid_name_table DATA
smb_cmd_vals DATA
sminmpec_values DATA
+start_requested_taps
stats_tree_branch_max_namelen
stats_tree_branch_to_str
stats_tree_create_node
diff --git a/epan/tap.c b/epan/tap.c
index 4d89056b2b..ad3cb4af68 100644
--- a/epan/tap.c
+++ b/epan/tap.c
@@ -80,6 +80,25 @@ typedef struct _tap_listener_t {
} tap_listener_t;
static volatile tap_listener_t *tap_listener_queue=NULL;
+/* structure to keep track of what tap listeners have registered
+ command-line arguments.
+ */
+typedef struct _tap_cmd_arg {
+ struct _tap_cmd_arg *next;
+ char *cmd;
+ void (*func)(char *arg);
+} tap_cmd_arg;
+static tap_cmd_arg *tap_cmd_arg_list=NULL;
+
+/* structure to keep track of what taps have been specified on the
+ command line.
+ */
+typedef struct {
+ tap_cmd_arg *tca;
+ char *arg;
+} tap_requested;
+static GSList *taps_requested = NULL;
+
/* **********************************************************************
* Init routine only called from epan at application startup
* ********************************************************************** */
@@ -102,7 +121,72 @@ tap_init(void)
return;
}
+/* **********************************************************************
+ * Function called from tap to register the tap's command-line argument
+ * and initialization routine
+ * ********************************************************************** */
+void
+register_tap_listener_cmd_arg(char *cmd, void (*func)(char *arg))
+{
+ tap_cmd_arg *newtca;
+
+ newtca=malloc(sizeof(tap_cmd_arg));
+ newtca->next=tap_cmd_arg_list;
+ tap_cmd_arg_list=newtca;
+ newtca->cmd=cmd;
+ newtca->func=func;
+}
+/* **********************************************************************
+ * Function called for a tap command-line argument
+ * ********************************************************************** */
+gboolean
+process_tap_cmd_arg(char *optarg)
+{
+ tap_cmd_arg *tca;
+ tap_requested *tr;
+
+ for(tca=tap_cmd_arg_list;tca;tca=tca->next){
+ if(!strncmp(tca->cmd,optarg,strlen(tca->cmd))){
+ tr=g_malloc(sizeof (tap_requested));
+ tr->tca = tca;
+ tr->arg=g_strdup(optarg);
+ taps_requested=g_slist_append(taps_requested, tr);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+/* **********************************************************************
+ * Function to list all possible tap command-line arguments
+ * ********************************************************************** */
+void
+list_tap_cmd_args(void)
+{
+ tap_cmd_arg *tca;
+
+ for(tca=tap_cmd_arg_list;tca;tca=tca->next){
+ fprintf(stderr," %s\n",tca->cmd);
+ }
+}
+
+/* **********************************************************************
+ * Function to process taps requested with command-line arguments
+ * ********************************************************************** */
+void
+start_requested_taps(void)
+{
+ tap_requested *tr;
+
+ while(taps_requested){
+ tr=taps_requested->data;
+ (*tr->tca->func)(tr->arg);
+ g_free(tr->arg);
+ g_free(tr);
+ taps_requested=g_slist_remove(taps_requested, tr);
+ }
+}
/* **********************************************************************
* Functions called from dissector when made tappable
diff --git a/epan/tap.h b/epan/tap.h
index e8b27f2e9d..53774bf745 100644
--- a/epan/tap.h
+++ b/epan/tap.h
@@ -38,6 +38,10 @@ typedef void (*tap_draw_cb)(void *tapdata);
extern void tap_init(void);
+extern void register_tap_listener_cmd_arg(char *cmd, void (*func)(char *arg));
+extern gboolean process_tap_cmd_arg(char *optarg);
+extern void list_tap_cmd_args(void);
+extern void start_requested_taps(void);
extern int register_tap(char *name);
extern int find_tap_id(char *name);
extern void tap_queue_packet(int tap_id, packet_info *pinfo, const void *tap_specific_data);