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
This commit is contained in:
Guy Harris 2005-04-01 09:08:27 +00:00
parent 0f8018692f
commit 80c1907a36
71 changed files with 182 additions and 191 deletions

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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));

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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));

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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 {

View File

@ -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));

View File

@ -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));

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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);

View File

@ -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));

View File

@ -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__ */

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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) {