diff options
71 files changed, 182 insertions, 191 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); diff --git a/gtk/ansi_a_stat.c b/gtk/ansi_a_stat.c index f34754ada9..7c2337e524 100644 --- a/gtk/ansi_a_stat.c +++ b/gtk/ansi_a_stat.c @@ -460,7 +460,7 @@ register_tap_listener_gtkansi_a_stat(void) GString *err_p; - register_ethereal_tap("ansi_a,", ansi_a_stat_gtk_init); + register_tap_listener_cmd_arg("ansi_a,", ansi_a_stat_gtk_init); memset((void *) &stat, 0, sizeof(ansi_a_stat_t)); diff --git a/gtk/ansi_map_stat.c b/gtk/ansi_map_stat.c index 16bc2b76a6..9260822724 100644 --- a/gtk/ansi_map_stat.c +++ b/gtk/ansi_map_stat.c @@ -424,7 +424,7 @@ register_tap_listener_gtkansi_map_stat(void) GString *err_p; - register_ethereal_tap("ansi_map,", ansi_map_stat_gtk_init); + register_tap_listener_cmd_arg("ansi_map,", ansi_map_stat_gtk_init); memset((void *) &stat, 0, sizeof(ansi_map_stat_t)); diff --git a/gtk/bootp_stat.c b/gtk/bootp_stat.c index cf8e910ca9..261cd851cc 100644 --- a/gtk/bootp_stat.c +++ b/gtk/bootp_stat.c @@ -281,7 +281,7 @@ static tap_dfilter_dlg dhcp_stat_dlg = { void register_tap_listener_gtkdhcpstat(void) { - register_ethereal_tap("bootp,stat", dhcpstat_init); + register_tap_listener_cmd_arg("bootp,stat", dhcpstat_init); register_tap_menu_item("BOOTP-DHCP", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(dhcp_stat_dlg)); diff --git a/gtk/conversations_eth.c b/gtk/conversations_eth.c index 4196f25124..4ed203c483 100644 --- a/gtk/conversations_eth.c +++ b/gtk/conversations_eth.c @@ -78,7 +78,7 @@ eth_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_eth_conversation(void) { - register_ethereal_tap("conv,eth", eth_conversation_init); + register_tap_listener_cmd_arg("conv,eth", eth_conversation_init); register_tap_menu_item("Ethernet", REGISTER_TAP_GROUP_CONVERSATION_LIST, eth_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_fc.c b/gtk/conversations_fc.c index 01b9662560..8cbd055a46 100644 --- a/gtk/conversations_fc.c +++ b/gtk/conversations_fc.c @@ -78,7 +78,7 @@ fc_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_fc_conversation(void) { - register_ethereal_tap("conv,fc", fc_conversation_init); + register_tap_listener_cmd_arg("conv,fc", fc_conversation_init); register_tap_menu_item("Fibre Channel", REGISTER_TAP_GROUP_CONVERSATION_LIST, fc_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_fddi.c b/gtk/conversations_fddi.c index 317423305b..c9db23f57a 100644 --- a/gtk/conversations_fddi.c +++ b/gtk/conversations_fddi.c @@ -78,7 +78,7 @@ fddi_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_fddi_conversation(void) { - register_ethereal_tap("conv,fddi", fddi_conversation_init); + register_tap_listener_cmd_arg("conv,fddi", fddi_conversation_init); register_tap_menu_item("FDDI", REGISTER_TAP_GROUP_CONVERSATION_LIST, fddi_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_ip.c b/gtk/conversations_ip.c index d2811801e4..e5b29dbdae 100644 --- a/gtk/conversations_ip.c +++ b/gtk/conversations_ip.c @@ -76,7 +76,7 @@ ip_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_ip_conversation(void) { - register_ethereal_tap("conv,ip", ip_conversation_init); + register_tap_listener_cmd_arg("conv,ip", ip_conversation_init); register_tap_menu_item("IPv4", REGISTER_TAP_GROUP_CONVERSATION_LIST, ip_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_ipx.c b/gtk/conversations_ipx.c index 634d7d56e7..ad564bf043 100644 --- a/gtk/conversations_ipx.c +++ b/gtk/conversations_ipx.c @@ -78,7 +78,7 @@ ipx_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_ipx_conversation(void) { - register_ethereal_tap("conv,ipx", ipx_conversation_init); + register_tap_listener_cmd_arg("conv,ipx", ipx_conversation_init); register_tap_menu_item("IPX", REGISTER_TAP_GROUP_CONVERSATION_LIST, ipx_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_sctp.c b/gtk/conversations_sctp.c index 1b9a94bbe0..cfe36031dc 100644 --- a/gtk/conversations_sctp.c +++ b/gtk/conversations_sctp.c @@ -87,7 +87,7 @@ sctp_conversation_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_sctp_conversation(void) { - register_ethereal_tap("conv,sctp", sctp_conversation_init); + register_tap_listener_cmd_arg("conv,sctp", sctp_conversation_init); register_tap_menu_item("SCTP", REGISTER_TAP_GROUP_CONVERSATION_LIST, sctp_conversation_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_tcpip.c b/gtk/conversations_tcpip.c index 4e85e08964..7500e65fb1 100644 --- a/gtk/conversations_tcpip.c +++ b/gtk/conversations_tcpip.c @@ -78,7 +78,7 @@ tcpip_conversation_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_tcpip_conversation(void) { - register_ethereal_tap("conv,tcp", tcpip_conversation_init); + register_tap_listener_cmd_arg("conv,tcp", tcpip_conversation_init); register_tap_menu_item("TCP (IPv4 & IPv6)", REGISTER_TAP_GROUP_CONVERSATION_LIST, tcpip_conversation_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_tr.c b/gtk/conversations_tr.c index 93d5a65a92..8884e66249 100644 --- a/gtk/conversations_tr.c +++ b/gtk/conversations_tr.c @@ -78,7 +78,7 @@ tr_conversation_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_tr_conversation(void) { - register_ethereal_tap("conv,tr", tr_conversation_init); + register_tap_listener_cmd_arg("conv,tr", tr_conversation_init); register_tap_menu_item("Token Ring", REGISTER_TAP_GROUP_CONVERSATION_LIST, tr_conversation_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_udpip.c b/gtk/conversations_udpip.c index a78b42550c..f24dae9b26 100644 --- a/gtk/conversations_udpip.c +++ b/gtk/conversations_udpip.c @@ -78,7 +78,7 @@ udpip_conversation_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_udpip_conversation(void) { - register_ethereal_tap("conv,udp", udpip_conversation_init); + register_tap_listener_cmd_arg("conv,udp", udpip_conversation_init); register_tap_menu_item("UDP (IPv4 & IPv6)", REGISTER_TAP_GROUP_CONVERSATION_LIST, udpip_conversation_cb, NULL, NULL, NULL); diff --git a/gtk/conversations_wlan.c b/gtk/conversations_wlan.c index 0faf6132a9..a2312a04c4 100644 --- a/gtk/conversations_wlan.c +++ b/gtk/conversations_wlan.c @@ -78,7 +78,7 @@ wlan_endpoints_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_wlan_conversation(void) { - register_ethereal_tap("conv,wlan", wlan_conversation_init); + register_tap_listener_cmd_arg("conv,wlan", wlan_conversation_init); register_tap_menu_item("WLAN", REGISTER_TAP_GROUP_CONVERSATION_LIST, wlan_endpoints_cb, NULL, NULL, NULL); diff --git a/gtk/dcerpc_stat.c b/gtk/dcerpc_stat.c index 3ef040435d..2947fa1b3d 100644 --- a/gtk/dcerpc_stat.c +++ b/gtk/dcerpc_stat.c @@ -675,7 +675,7 @@ gtk_dcerpcstat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtkdcerpcstat(void) { - register_ethereal_tap("dcerpc,srt,", gtk_dcerpcstat_init); + register_tap_listener_cmd_arg("dcerpc,srt,", gtk_dcerpcstat_init); register_tap_menu_item("DCE-RPC...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_dcerpcstat_cb, NULL, NULL, NULL); diff --git a/gtk/fc_stat.c b/gtk/fc_stat.c index 376b8abf56..99378e72bd 100644 --- a/gtk/fc_stat.c +++ b/gtk/fc_stat.c @@ -312,7 +312,7 @@ gtk_fcstat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtkfcstat(void) { - register_ethereal_tap("fc,srt", gtk_fcstat_init); + register_tap_listener_cmd_arg("fc,srt", gtk_fcstat_init); register_tap_menu_item("Fibre Channel...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_fcstat_cb, NULL, NULL, NULL); diff --git a/gtk/gsm_a_stat.c b/gtk/gsm_a_stat.c index b45d2a93d5..a6c0e6fc6c 100644 --- a/gtk/gsm_a_stat.c +++ b/gtk/gsm_a_stat.c @@ -620,7 +620,7 @@ register_tap_listener_gtkgsm_a_stat(void) GString *err_p; - register_ethereal_tap("gsm_a,", gsm_a_stat_gtk_init); + register_tap_listener_cmd_arg("gsm_a,", gsm_a_stat_gtk_init); memset((void *) &stat, 0, sizeof(gsm_a_stat_t)); diff --git a/gtk/gsm_map_stat.c b/gtk/gsm_map_stat.c index 883fe71305..c4f7d03f2b 100644 --- a/gtk/gsm_map_stat.c +++ b/gtk/gsm_map_stat.c @@ -458,7 +458,7 @@ register_tap_listener_gtkgsm_map_stat(void) GString *err_p; - register_ethereal_tap("gsm_map,", gsm_map_stat_gtk_init); + register_tap_listener_cmd_arg("gsm_map,", gsm_map_stat_gtk_init); memset((void *) &gsm_map_stat, 0, sizeof(gsm_map_stat_t)); diff --git a/gtk/h225_counter.c b/gtk/h225_counter.c index df45102b1f..2b4bf3df24 100644 --- a/gtk/h225_counter.c +++ b/gtk/h225_counter.c @@ -562,7 +562,7 @@ gtk_h225counter_init(char *optarg) void register_tap_listener_gtk_h225counter(void) { - register_ethereal_tap("h225,counter", gtk_h225counter_init); + register_tap_listener_cmd_arg("h225,counter", gtk_h225counter_init); register_tap_menu_item("H.225...", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(h225_counter_dlg)); diff --git a/gtk/h225_ras_srt.c b/gtk/h225_ras_srt.c index daedacccae..add30db5cf 100644 --- a/gtk/h225_ras_srt.c +++ b/gtk/h225_ras_srt.c @@ -342,7 +342,7 @@ gtk_h225rassrt_init(char *optarg) void register_tap_listener_gtk_h225rassrt(void) { - register_ethereal_tap("h225,srt", gtk_h225rassrt_init); + register_tap_listener_cmd_arg("h225,srt", gtk_h225rassrt_init); register_tap_menu_item("H.225 RAS...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(h225_rassrt_dlg)); diff --git a/gtk/hostlist_eth.c b/gtk/hostlist_eth.c index 2a7ebfc502..b7a93c3cd5 100644 --- a/gtk/hostlist_eth.c +++ b/gtk/hostlist_eth.c @@ -83,7 +83,7 @@ gtk_eth_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_eth_hostlist(void) { - register_ethereal_tap("hosts,eth", gtk_eth_hostlist_init); + register_tap_listener_cmd_arg("hosts,eth", gtk_eth_hostlist_init); register_tap_menu_item("Ethernet", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_eth_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_fc.c b/gtk/hostlist_fc.c index 22b18e956e..886e58a7b3 100644 --- a/gtk/hostlist_fc.c +++ b/gtk/hostlist_fc.c @@ -83,7 +83,7 @@ gtk_fc_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_fc_hostlist(void) { - register_ethereal_tap("hosts,fc", gtk_fc_hostlist_init); + register_tap_listener_cmd_arg("hosts,fc", gtk_fc_hostlist_init); register_tap_menu_item("Fibre Channel", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_fc_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_fddi.c b/gtk/hostlist_fddi.c index 5f2083005d..81198fde01 100644 --- a/gtk/hostlist_fddi.c +++ b/gtk/hostlist_fddi.c @@ -83,7 +83,7 @@ gtk_fddi_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_fddi_hostlist(void) { - register_ethereal_tap("hosts,fddi", gtk_fddi_hostlist_init); + register_tap_listener_cmd_arg("hosts,fddi", gtk_fddi_hostlist_init); register_tap_menu_item("FDDI", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_fddi_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_ip.c b/gtk/hostlist_ip.c index cc6294e4ba..57f456cd6c 100644 --- a/gtk/hostlist_ip.c +++ b/gtk/hostlist_ip.c @@ -82,7 +82,7 @@ gtk_ip_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_ip_hostlist(void) { - register_ethereal_tap("hosts,ip", gtk_ip_hostlist_init); + register_tap_listener_cmd_arg("hosts,ip", gtk_ip_hostlist_init); register_tap_menu_item("IPv4", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_ip_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_ipx.c b/gtk/hostlist_ipx.c index a266796fcd..b48930af21 100644 --- a/gtk/hostlist_ipx.c +++ b/gtk/hostlist_ipx.c @@ -83,7 +83,7 @@ gtk_ipx_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_ipx_hostlist(void) { - register_ethereal_tap("hosts,ipx", gtk_ipx_hostlist_init); + register_tap_listener_cmd_arg("hosts,ipx", gtk_ipx_hostlist_init); register_tap_menu_item("IPX", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_ipx_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_tcpip.c b/gtk/hostlist_tcpip.c index 13a4ae0e21..72f28fc9ca 100644 --- a/gtk/hostlist_tcpip.c +++ b/gtk/hostlist_tcpip.c @@ -83,7 +83,7 @@ gtk_tcpip_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_tcpip_hostlist(void) { - register_ethereal_tap("endpoints,tcp", gtk_tcpip_hostlist_init); + register_tap_listener_cmd_arg("endpoints,tcp", gtk_tcpip_hostlist_init); register_tap_menu_item("TCP (IPv4 & IPv6)", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_tcpip_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_tr.c b/gtk/hostlist_tr.c index 1cac21c34f..af21ca6ca3 100644 --- a/gtk/hostlist_tr.c +++ b/gtk/hostlist_tr.c @@ -83,7 +83,7 @@ gtk_tr_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_tr_hostlist(void) { - register_ethereal_tap("hosts,tr", gtk_tr_hostlist_init); + register_tap_listener_cmd_arg("hosts,tr", gtk_tr_hostlist_init); register_tap_menu_item("Token Ring", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_tr_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_udpip.c b/gtk/hostlist_udpip.c index 1e4ecebc04..6d86a16ba7 100644 --- a/gtk/hostlist_udpip.c +++ b/gtk/hostlist_udpip.c @@ -83,7 +83,7 @@ gtk_udpip_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_udpip_hostlist(void) { - register_ethereal_tap("endpoints,udp", gtk_udpip_hostlist_init); + register_tap_listener_cmd_arg("endpoints,udp", gtk_udpip_hostlist_init); register_tap_menu_item("UDP (IPv4 & IPv6)", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_udpip_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/hostlist_wlan.c b/gtk/hostlist_wlan.c index 00034c5863..07de604544 100644 --- a/gtk/hostlist_wlan.c +++ b/gtk/hostlist_wlan.c @@ -81,7 +81,7 @@ gtk_wlan_hostlist_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_wlan_hostlist(void) { - register_ethereal_tap("hosts,wlan", gtk_wlan_hostlist_init); + register_tap_listener_cmd_arg("hosts,wlan", gtk_wlan_hostlist_init); register_tap_menu_item("WLAN", REGISTER_TAP_GROUP_ENDPOINT_LIST, gtk_wlan_hostlist_cb, NULL, NULL, NULL); diff --git a/gtk/http_stat.c b/gtk/http_stat.c index 195e12898c..0defcfebe6 100644 --- a/gtk/http_stat.c +++ b/gtk/http_stat.c @@ -515,7 +515,7 @@ static tap_dfilter_dlg http_stat_dlg = { void register_tap_listener_gtkhttpstat(void) { - register_ethereal_tap("http,stat", gtk_httpstat_init); + register_tap_listener_cmd_arg("http,stat", gtk_httpstat_init); register_tap_menu_item("HTTP/Packet Counter", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(http_stat_dlg)); diff --git a/gtk/io_stat.c b/gtk/io_stat.c index 8bb636789a..1bef7e107c 100644 --- a/gtk/io_stat.c +++ b/gtk/io_stat.c @@ -1930,7 +1930,7 @@ gtk_iostat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtk_iostat(void) { - register_ethereal_tap("io,stat", gtk_iostat_init); + register_tap_listener_cmd_arg("io,stat", gtk_iostat_init); register_tap_menu_item("_IO Graphs", REGISTER_TAP_GROUP_GENERIC, gtk_iostat_cb, NULL, NULL, NULL); diff --git a/gtk/isup_stat.c b/gtk/isup_stat.c index befac9102a..795f4a64c0 100644 --- a/gtk/isup_stat.c +++ b/gtk/isup_stat.c @@ -398,7 +398,7 @@ register_tap_listener_gtkisup_stat(void) GString *err_p; - register_ethereal_tap("isup,", isup_stat_gtk_init); + register_tap_listener_cmd_arg("isup,", isup_stat_gtk_init); memset((void *) &stat, 0, sizeof(isup_stat_t)); diff --git a/gtk/ldap_stat.c b/gtk/ldap_stat.c index 2b6e638a43..da6149ef4b 100644 --- a/gtk/ldap_stat.c +++ b/gtk/ldap_stat.c @@ -347,7 +347,7 @@ gtk_ldapstat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtkldapstat(void) { - register_ethereal_tap("ldap,srt", gtk_ldapstat_init); + register_tap_listener_cmd_arg("ldap,srt", gtk_ldapstat_init); register_tap_menu_item("LDAP...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_ldapstat_cb, NULL, NULL, NULL); diff --git a/gtk/main.c b/gtk/main.c index 0a2544e450..9b2666b1ca 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1172,28 +1172,6 @@ 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)) -{ - ethereal_tap_list *newtl; - - newtl=malloc(sizeof(ethereal_tap_list)); - newtl->next=tap_list; - tap_list=newtl; - newtl->cmd=cmd; - newtl->func=func; - -} - /* Set the file name in the status line, in the name for the main window, and in the name for the main window's icon. */ static void @@ -1478,11 +1456,6 @@ void main_cf_callback(gint event, gpointer data, gpointer user_data _U_) } } -typedef struct { - ethereal_tap_list *tli; - char *arg; -} tap_to_run_t; - /* And now our feature presentation... [ fade to music ] */ int main(int argc, char *argv[]) @@ -1530,9 +1503,6 @@ main(int argc, char *argv[]) gboolean rfilter_parse_failed = FALSE; e_prefs *prefs; char badopt; - ethereal_tap_list *tli; - tap_to_run_t *tap_to_run; - GSList *taps_to_run = NULL; GtkWidget *splash_win = NULL; gboolean capture_child; /* True if this is the child for "-S" */ @@ -1972,28 +1942,17 @@ main(int argc, char *argv[]) exit(0); break; case 'z': - for(tli=tap_list;tli;tli=tli->next){ - if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){ - /* We won't call the init function for the tap this soon - as it would disallow MATE's fields (which are registered - by the preferences set callback) from being used as - part of a tap filter. Instead, we just add the argument - to a list of tap arguments. */ - tap_to_run = g_malloc(sizeof (tap_to_run_t)); - tap_to_run->tli = tli; - tap_to_run->arg = g_strdup(optarg); - taps_to_run = g_slist_append(taps_to_run, tap_to_run); - 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); - } + /* We won't call the init function for the tap this soon + as it would disallow MATE's fields (which are registered + by the preferences set callback) from being used as + part of a tap filter. Instead, we just add the argument + to a list of tap arguments. */ + if (!process_tap_cmd_arg(optarg)) { + fprintf(stderr,"ethereal: invalid -z argument.\n"); + fprintf(stderr," -z argument must be one of :\n"); + list_tap_cmd_args(); + exit(1); + } break; default: case '?': /* Bad flag - print usage message */ @@ -2338,13 +2297,7 @@ main(int argc, char *argv[]) registered its field array and we can have a filter with one of MATE's late-registered fields as part of the tap's filter. */ - while (taps_to_run != NULL) { - tap_to_run = taps_to_run->data; - (*tap_to_run->tli->func)(tap_to_run->arg); - g_free(tap_to_run->arg); - g_free(tap_to_run); - taps_to_run = g_slist_remove(taps_to_run, tap_to_run); - } + start_requested_taps(); /* Read the capture file. */ switch (cf_read(&cfile)) { @@ -2398,13 +2351,7 @@ main(int argc, char *argv[]) registered its field array and we can have a filter with one of MATE's late-registered fields as part of the tap's filter. */ - while (taps_to_run != NULL) { - tap_to_run = taps_to_run->data; - (*tap_to_run->tli->func)(tap_to_run->arg); - g_free(tap_to_run->arg); - g_free(tap_to_run); - taps_to_run = g_slist_remove(taps_to_run, tap_to_run); - } + start_requested_taps(); } } else { diff --git a/gtk/mgcp_stat.c b/gtk/mgcp_stat.c index 1f4d8b67a4..9775071601 100644 --- a/gtk/mgcp_stat.c +++ b/gtk/mgcp_stat.c @@ -326,7 +326,7 @@ register_tap_listener_gtkmgcpstat(void) { /* We don't register this tap, if we don't have the mgcp plugin loaded.*/ if (find_tap_id("mgcp")) { - register_ethereal_tap("mgcp,srt", gtk_mgcpstat_init); + register_tap_listener_cmd_arg("mgcp,srt", gtk_mgcpstat_init); register_tap_menu_item("MGCP...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(mgcp_srt_dlg)); diff --git a/gtk/mtp3_stat.c b/gtk/mtp3_stat.c index 76b9206704..70dc5ee566 100644 --- a/gtk/mtp3_stat.c +++ b/gtk/mtp3_stat.c @@ -447,7 +447,7 @@ register_tap_listener_gtkmtp3_stat(void) GString *err_p; - register_ethereal_tap("mtp3,", mtp3_stat_gtk_init); + register_tap_listener_cmd_arg("mtp3,", mtp3_stat_gtk_init); memset((void *) &mtp3_stat, 0, sizeof(mtp3_stat_t)); diff --git a/gtk/rpc_progs.c b/gtk/rpc_progs.c index f585c49070..9d674deb18 100644 --- a/gtk/rpc_progs.c +++ b/gtk/rpc_progs.c @@ -418,7 +418,7 @@ gtk_rpcprogs_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtkrpcprogs(void) { - register_ethereal_tap("rpc,programs", gtk_rpcprogs_init); + register_tap_listener_cmd_arg("rpc,programs", gtk_rpcprogs_init); register_tap_menu_item("ONC-RPC Programs", REGISTER_TAP_GROUP_NONE, gtk_rpcprogs_cb, NULL, NULL, NULL); diff --git a/gtk/rpc_stat.c b/gtk/rpc_stat.c index 5da4615889..cffc0db23a 100644 --- a/gtk/rpc_stat.c +++ b/gtk/rpc_stat.c @@ -536,7 +536,7 @@ gtk_rpcstat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtkrpcstat(void) { - register_ethereal_tap("rpc,srt,", gtk_rpcstat_init); + register_tap_listener_cmd_arg("rpc,srt,", gtk_rpcstat_init); register_tap_menu_item("ONC-RPC...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_rpcstat_cb, NULL, NULL, NULL); diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 066b84a32d..b1f4ab43ae 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -3649,7 +3649,7 @@ rtp_analysis_init(char *dummy _U_) void register_tap_listener_rtp_analysis(void) { - register_ethereal_tap("rtp", rtp_analysis_init); + register_tap_listener_cmd_arg("rtp", rtp_analysis_init); register_tap_menu_item("RTP/Stream Analysis...", REGISTER_TAP_GROUP_NONE, rtp_analysis_cb, NULL, NULL, NULL); diff --git a/gtk/rtp_stream.c b/gtk/rtp_stream.c index feb1f1bbf2..4ddb0b9c70 100644 --- a/gtk/rtp_stream.c +++ b/gtk/rtp_stream.c @@ -438,7 +438,7 @@ register_tap_listener_rtp_stream(void) GString *error_string; if (!the_tapinfo_struct.is_registered) { - register_ethereal_tap("rtp", rtpstream_init_tap); + register_tap_listener_cmd_arg("rtp", rtpstream_init_tap); error_string = register_tap_listener("rtp", &the_tapinfo_struct, NULL, rtpstream_reset_cb, rtpstream_packet, diff --git a/gtk/sctp_chunk_stat.c b/gtk/sctp_chunk_stat.c index 9ae5141f7c..94e051d583 100644 --- a/gtk/sctp_chunk_stat.c +++ b/gtk/sctp_chunk_stat.c @@ -344,7 +344,7 @@ sctpstat_init(char *optarg) void register_tap_listener_sctpstat(void) { - register_ethereal_tap("sctp,stat", sctpstat_init); + register_tap_listener_cmd_arg("sctp,stat", sctpstat_init); register_tap_menu_item("SCTP/Chunk Counter", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(sctp_stat_dlg)); diff --git a/gtk/sctp_stat.c b/gtk/sctp_stat.c index 9ffc6ac2dd..68dbe8515e 100644 --- a/gtk/sctp_stat.c +++ b/gtk/sctp_stat.c @@ -1448,7 +1448,7 @@ register_tap_listener_sctp_stat(void) if (!sctp_tapinfo_struct.is_registered) { - register_ethereal_tap("sctp",gtk_sctpstat_init); + register_tap_listener_cmd_arg("sctp",gtk_sctpstat_init); if ((error_string = register_tap_listener("sctp", &sctp_tapinfo_struct, NULL, reset, packet, sctp_update))) { simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str); g_string_free(error_string, TRUE); diff --git a/gtk/sip_stat.c b/gtk/sip_stat.c index 9560bf321b..c0de0c4379 100644 --- a/gtk/sip_stat.c +++ b/gtk/sip_stat.c @@ -662,7 +662,7 @@ static tap_dfilter_dlg sip_stat_dlg = { void register_tap_listener_gtksipstat(void) { - register_ethereal_tap("sip,stat", gtk_sipstat_init); + register_tap_listener_cmd_arg("sip,stat", gtk_sipstat_init); register_tap_menu_item("SIP", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(sip_stat_dlg)); diff --git a/gtk/smb_stat.c b/gtk/smb_stat.c index 240cbfb0d7..4b87d871d7 100644 --- a/gtk/smb_stat.c +++ b/gtk/smb_stat.c @@ -351,7 +351,7 @@ gtk_smbstat_cb(GtkWidget *w _U_, gpointer d _U_) void register_tap_listener_gtksmbstat(void) { - register_ethereal_tap("smb,srt", gtk_smbstat_init); + register_tap_listener_cmd_arg("smb,srt", gtk_smbstat_init); register_tap_menu_item("SMB...", REGISTER_TAP_GROUP_RESPONSE_TIME, gtk_smbstat_cb, NULL, NULL, NULL); diff --git a/gtk/stats_tree_stat.c b/gtk/stats_tree_stat.c index 2573b229e3..07394ebe54 100644 --- a/gtk/stats_tree_stat.c +++ b/gtk/stats_tree_stat.c @@ -370,7 +370,7 @@ static void register_gtk_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p s = g_strdup_printf("%s,tree",cfg->abbr); - register_ethereal_tap(s, init_gtk_tree); + register_tap_listener_cmd_arg(s, init_gtk_tree); cfg->pr = g_malloc(sizeof(tree_pres)); diff --git a/gtk/voip_calls_dlg.c b/gtk/voip_calls_dlg.c index 00e8319b39..2e718d2dc3 100644 --- a/gtk/voip_calls_dlg.c +++ b/gtk/voip_calls_dlg.c @@ -766,7 +766,7 @@ void voip_calls_launch(GtkWidget *w _U_, gpointer data _U_) void register_tap_listener_voip_calls_dlg(void) { - register_ethereal_tap("voip,calls",voip_calls_init_tap); + register_tap_listener_cmd_arg("voip,calls",voip_calls_init_tap); register_tap_menu_item("VoIP Calls...", REGISTER_TAP_GROUP_NONE, voip_calls_launch, NULL, NULL, NULL); diff --git a/gtk/wsp_stat.c b/gtk/wsp_stat.c index 6a9e143f19..903987bbb7 100644 --- a/gtk/wsp_stat.c +++ b/gtk/wsp_stat.c @@ -425,7 +425,7 @@ static tap_dfilter_dlg wsp_stat_dlg = { void register_tap_listener_gtkwspstat(void) { - register_ethereal_tap("wsp,stat", gtk_wspstat_init); + register_tap_listener_cmd_arg("wsp,stat", gtk_wspstat_init); register_tap_menu_item("WAP-WSP...", REGISTER_TAP_GROUP_NONE, gtk_tap_dfilter_dlg_cb, NULL, NULL, &(wsp_stat_dlg)); diff --git a/register.h b/register.h index 3888df3608..683c5fd27a 100644 --- a/register.h +++ b/register.h @@ -28,5 +28,4 @@ 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 *)); #endif /* __REGISTER_H__ */ diff --git a/tap-ansi_astat.c b/tap-ansi_astat.c index b2fc6e0bac..376345ce93 100644 --- a/tap-ansi_astat.c +++ b/tap-ansi_astat.c @@ -165,5 +165,5 @@ ansi_a_stat_init(char *optarg) void register_tap_listener_ansi_astat(void) { - register_ethereal_tap("ansi_a,", ansi_a_stat_init); + register_tap_listener_cmd_arg("ansi_a,", ansi_a_stat_init); } diff --git a/tap-bootpstat.c b/tap-bootpstat.c index 7f75d85024..8063aa39f1 100644 --- a/tap-bootpstat.c +++ b/tap-bootpstat.c @@ -181,6 +181,6 @@ dhcpstat_init(char *optarg) void register_tap_listener_gtkdhcpstat(void) { - register_ethereal_tap("bootp,stat,", dhcpstat_init); + register_tap_listener_cmd_arg("bootp,stat,", dhcpstat_init); } diff --git a/tap-dcerpcstat.c b/tap-dcerpcstat.c index 70ebf8923a..1a03dddbcc 100644 --- a/tap-dcerpcstat.c +++ b/tap-dcerpcstat.c @@ -305,5 +305,5 @@ dcerpcstat_init(char *optarg) void register_tap_listener_dcerpcstat(void) { - register_ethereal_tap("dcerpc,rtt,", dcerpcstat_init); + register_tap_listener_cmd_arg("dcerpc,rtt,", dcerpcstat_init); } diff --git a/tap-gsm_astat.c b/tap-gsm_astat.c index 91895d9f3a..dd940f7d6e 100644 --- a/tap-gsm_astat.c +++ b/tap-gsm_astat.c @@ -300,5 +300,5 @@ gsm_a_stat_init(char *optarg) void register_tap_listener_gsm_astat(void) { - register_ethereal_tap("gsm_a,", gsm_a_stat_init); + register_tap_listener_cmd_arg("gsm_a,", gsm_a_stat_init); } diff --git a/tap-h225counter.c b/tap-h225counter.c index d487aea0a1..b48dee6c35 100644 --- a/tap-h225counter.c +++ b/tap-h225counter.c @@ -423,5 +423,5 @@ h225counter_init(char *optarg) void register_tap_listener_h225counter(void) { - register_ethereal_tap("h225,counter", h225counter_init); + register_tap_listener_cmd_arg("h225,counter", h225counter_init); } diff --git a/tap-h225rassrt.c b/tap-h225rassrt.c index 2782dcb955..55abf24b80 100644 --- a/tap-h225rassrt.c +++ b/tap-h225rassrt.c @@ -247,5 +247,5 @@ h225rassrt_init(char *optarg) void register_tap_listener_h225rassrt(void) { - register_ethereal_tap("h225,srt", h225rassrt_init); + register_tap_listener_cmd_arg("h225,srt", h225rassrt_init); } diff --git a/tap-httpstat.c b/tap-httpstat.c index 2e5e3454ad..f3201d2fc4 100644 --- a/tap-httpstat.c +++ b/tap-httpstat.c @@ -325,5 +325,5 @@ gtk_httpstat_init(char *optarg) void register_tap_listener_gtkhttpstat(void) { - register_ethereal_tap("http,stat,", gtk_httpstat_init); + register_tap_listener_cmd_arg("http,stat,", gtk_httpstat_init); } diff --git a/tap-iostat.c b/tap-iostat.c index 2821ffdade..b0c0659bd2 100644 --- a/tap-iostat.c +++ b/tap-iostat.c @@ -650,5 +650,5 @@ iostat_init(char *optarg) void register_tap_listener_iostat(void) { - register_ethereal_tap("io,stat,", iostat_init); + register_tap_listener_cmd_arg("io,stat,", iostat_init); } diff --git a/tap-iousers.c b/tap-iousers.c index 4d0ed164fc..f20137e816 100644 --- a/tap-iousers.c +++ b/tap-iousers.c @@ -710,5 +710,5 @@ iousers_init(char *optarg) void register_tap_listener_iousers(void) { - register_ethereal_tap("conv,", iousers_init); + register_tap_listener_cmd_arg("conv,", iousers_init); } diff --git a/tap-mgcpstat.c b/tap-mgcpstat.c index f8b92b6192..bd96b07468 100644 --- a/tap-mgcpstat.c +++ b/tap-mgcpstat.c @@ -235,7 +235,7 @@ register_tap_listener_mgcpstat(void) { /* We don't register this tap, if we don't have the mgcp plugin loaded.*/ if (find_tap_id("mgcp")) { - register_ethereal_tap("mgcp,rtd", mgcpstat_init); + register_tap_listener_cmd_arg("mgcp,rtd", mgcpstat_init); } } diff --git a/tap-protocolinfo.c b/tap-protocolinfo.c index 3e07d6839e..562bfc23f2 100644 --- a/tap-protocolinfo.c +++ b/tap-protocolinfo.c @@ -142,6 +142,6 @@ protocolinfo_init(char *optarg) void register_tap_listener_protocolinfo(void) { - register_ethereal_tap("proto,colinfo,", protocolinfo_init); + register_tap_listener_cmd_arg("proto,colinfo,", protocolinfo_init); } diff --git a/tap-protohierstat.c b/tap-protohierstat.c index 039f532896..8a26136d1c 100644 --- a/tap-protohierstat.c +++ b/tap-protohierstat.c @@ -216,6 +216,6 @@ protohierstat_init(char *optarg) void register_tap_listener_protohierstat(void) { - register_ethereal_tap("io,phs", protohierstat_init); + register_tap_listener_cmd_arg("io,phs", protohierstat_init); } diff --git a/tap-rpcprogs.c b/tap-rpcprogs.c index 28e3c86e4d..be08010ca3 100644 --- a/tap-rpcprogs.c +++ b/tap-rpcprogs.c @@ -242,7 +242,7 @@ rpcprogs_init(char *optarg _U_) void register_tap_listener_rpcprogs(void) { - register_ethereal_tap("rpc,programs", rpcprogs_init); + register_tap_listener_cmd_arg("rpc,programs", rpcprogs_init); } diff --git a/tap-rpcstat.c b/tap-rpcstat.c index ec188af03f..8c53e0ab23 100644 --- a/tap-rpcstat.c +++ b/tap-rpcstat.c @@ -360,6 +360,6 @@ rpcstat_init(char *optarg) void register_tap_listener_rpcstat(void) { - register_ethereal_tap("rpc,rtt,", rpcstat_init); + register_tap_listener_cmd_arg("rpc,rtt,", rpcstat_init); } diff --git a/tap-sctpchunkstat.c b/tap-sctpchunkstat.c index 8cdf8e5bdc..d928912c9d 100644 --- a/tap-sctpchunkstat.c +++ b/tap-sctpchunkstat.c @@ -261,5 +261,5 @@ sctpstat_init(char *optarg) void register_tap_listener_sctpstat(void) { - register_ethereal_tap("sctp,stat", sctpstat_init); + register_tap_listener_cmd_arg("sctp,stat", sctpstat_init); } diff --git a/tap-sipstat.c b/tap-sipstat.c index 3bacac0911..345c73f7a9 100644 --- a/tap-sipstat.c +++ b/tap-sipstat.c @@ -390,5 +390,5 @@ sipstat_init(char *optarg) void register_tap_listener_sipstat(void) { - register_ethereal_tap("sip,stat", sipstat_init); + register_tap_listener_cmd_arg("sip,stat", sipstat_init); } diff --git a/tap-smbsids.c b/tap-smbsids.c index 867f668c04..7aa7aec364 100644 --- a/tap-smbsids.c +++ b/tap-smbsids.c @@ -95,6 +95,6 @@ smbsids_init(char *optarg _U_) void register_tap_listener_smbsids(void) { - register_ethereal_tap("smb,sids", smbsids_init); + register_tap_listener_cmd_arg("smb,sids", smbsids_init); } diff --git a/tap-smbstat.c b/tap-smbstat.c index 8e9b74f1b4..1b0b487c7d 100644 --- a/tap-smbstat.c +++ b/tap-smbstat.c @@ -279,6 +279,6 @@ smbstat_init(char *optarg) void register_tap_listener_smbstat(void) { - register_ethereal_tap("smb,rtt", smbstat_init); + register_tap_listener_cmd_arg("smb,rtt", smbstat_init); } diff --git a/tap-stats_tree.c b/tap-stats_tree.c index 1cf1a4fe42..3e400edd2c 100644 --- a/tap-stats_tree.c +++ b/tap-stats_tree.c @@ -113,7 +113,7 @@ void register_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_) { cfg->pr = g_malloc(sizeof(tree_cfg_pres)); cfg->pr->init_string = g_strdup_printf("%s,tree",cfg->abbr); - register_ethereal_tap(cfg->pr->init_string, init_stats_tree); + register_tap_listener_cmd_arg(cfg->pr->init_string, init_stats_tree); } diff --git a/tap-wspstat.c b/tap-wspstat.c index 64c5125527..3582179f89 100644 --- a/tap-wspstat.c +++ b/tap-wspstat.c @@ -280,5 +280,5 @@ wspstat_init(char *optarg) void register_tap_listener_wspstat(void) { - register_ethereal_tap("wsp,stat,", wspstat_init); + register_tap_listener_cmd_arg("wsp,stat,", wspstat_init); } diff --git a/tethereal.c b/tethereal.c index 5027bb59ca..22495ff100 100644 --- a/tethereal.c +++ b/tethereal.c @@ -266,28 +266,6 @@ print_usage(gboolean print_ver) fprintf(output, "\tdefault is libpcap\n"); } -/* 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)) -{ - ethereal_tap_list *newtl; - - newtl=malloc(sizeof(ethereal_tap_list)); - newtl->next=tap_list; - tap_list=newtl; - newtl->cmd=cmd; - newtl->func=func; - -} - /* * For a dissector table, print on the stream described by output, * its short name (which is what's used in the "-d" option) and its @@ -634,11 +612,6 @@ add_decode_as(const gchar *cl_param) return TRUE; } -typedef struct { - ethereal_tap_list *tli; - char *arg; -} tap_to_run_t; - int main(int argc, char *argv[]) { @@ -685,9 +658,6 @@ main(int argc, char *argv[]) dfilter_t *rfcode = NULL; e_prefs *prefs; char badopt; - ethereal_tap_list *tli; - tap_to_run_t *tap_to_run; - GSList *taps_to_run = NULL; #ifdef HAVE_LIBPCAP capture_opts_init(&capture_opts, NULL /* cfile */); @@ -1049,28 +1019,17 @@ main(int argc, char *argv[]) print_hex = TRUE; break; case 'z': - for(tli=tap_list;tli;tli=tli->next){ - if(!strncmp(tli->cmd,optarg,strlen(tli->cmd))){ - /* We won't call the init function for the tap this soon - as it would disallow MATE's fields (which are registered - by the preferences set callback) from being used as - part of a tap filter. Instead, we just add the argument - to a list of tap arguments. */ - tap_to_run = g_malloc(sizeof (tap_to_run_t)); - tap_to_run->tli = tli; - tap_to_run->arg = g_strdup(optarg); - taps_to_run = g_slist_append(taps_to_run, tap_to_run); - break; - } - } - 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); - } - exit(1); - } + /* We won't call the init function for the tap this soon + as it would disallow MATE's fields (which are registered + by the preferences set callback) from being used as + part of a tap filter. Instead, we just add the argument + to a list of tap arguments. */ + if (!process_tap_cmd_arg(optarg)) { + fprintf(stderr,"tethereal: invalid -z argument.\n"); + fprintf(stderr," -z argument must be one of :\n"); + list_tap_cmd_args(); + exit(1); + } break; default: case '?': /* Bad flag - print usage message */ @@ -1249,13 +1208,7 @@ main(int argc, char *argv[]) /* At this point MATE will have registered its field array so we can have a filter with one of MATE's late-registered fields as part of the tap's filter. We can now process all the "-z" arguments. */ - while (taps_to_run != NULL) { - tap_to_run = taps_to_run->data; - (*tap_to_run->tli->func)(tap_to_run->arg); - g_free(tap_to_run->arg); - g_free(tap_to_run); - taps_to_run = g_slist_remove(taps_to_run, tap_to_run); - } + start_requested_taps(); /* disabled protocols as per configuration file */ if (gdp_path == NULL && dp_path == NULL) { |