isup_message_type_value_acro DATA
is_big_endian
is_tpkt
+list_tap_cmd_args
LocationRejectReason_vals DATA
match_strval
mkstemp
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
register_postseq_cleanup_routine
register_tap
register_tap_listener
+register_tap_listener_cmd_arg
RegistrationRejectReason_vals DATA
ReleaseCompleteReason_vals DATA
remove_tap_listener
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
} 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
* ********************************************************************** */
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
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);
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));
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));
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));
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);
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));
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));
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));
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));
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);
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);
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);
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);
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);
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);
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);
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);
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);
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));
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);
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));
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);
#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
}
}
-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[])
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" */
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 */
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)) {
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 {
{
/* 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));
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));
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);
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);
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);
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,
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));
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);
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));
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);
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));
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);
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));
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__ */
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);
}
void
register_tap_listener_gtkdhcpstat(void)
{
- register_ethereal_tap("bootp,stat,", dhcpstat_init);
+ register_tap_listener_cmd_arg("bootp,stat,", dhcpstat_init);
}
void
register_tap_listener_dcerpcstat(void)
{
- register_ethereal_tap("dcerpc,rtt,", dcerpcstat_init);
+ register_tap_listener_cmd_arg("dcerpc,rtt,", dcerpcstat_init);
}
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);
}
void
register_tap_listener_h225counter(void)
{
- register_ethereal_tap("h225,counter", h225counter_init);
+ register_tap_listener_cmd_arg("h225,counter", h225counter_init);
}
void
register_tap_listener_h225rassrt(void)
{
- register_ethereal_tap("h225,srt", h225rassrt_init);
+ register_tap_listener_cmd_arg("h225,srt", h225rassrt_init);
}
void
register_tap_listener_gtkhttpstat(void)
{
- register_ethereal_tap("http,stat,", gtk_httpstat_init);
+ register_tap_listener_cmd_arg("http,stat,", gtk_httpstat_init);
}
void
register_tap_listener_iostat(void)
{
- register_ethereal_tap("io,stat,", iostat_init);
+ register_tap_listener_cmd_arg("io,stat,", iostat_init);
}
void
register_tap_listener_iousers(void)
{
- register_ethereal_tap("conv,", iousers_init);
+ register_tap_listener_cmd_arg("conv,", iousers_init);
}
{
/* 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);
}
}
void
register_tap_listener_protocolinfo(void)
{
- register_ethereal_tap("proto,colinfo,", protocolinfo_init);
+ register_tap_listener_cmd_arg("proto,colinfo,", protocolinfo_init);
}
void
register_tap_listener_protohierstat(void)
{
- register_ethereal_tap("io,phs", protohierstat_init);
+ register_tap_listener_cmd_arg("io,phs", protohierstat_init);
}
void
register_tap_listener_rpcprogs(void)
{
- register_ethereal_tap("rpc,programs", rpcprogs_init);
+ register_tap_listener_cmd_arg("rpc,programs", rpcprogs_init);
}
void
register_tap_listener_rpcstat(void)
{
- register_ethereal_tap("rpc,rtt,", rpcstat_init);
+ register_tap_listener_cmd_arg("rpc,rtt,", rpcstat_init);
}
void
register_tap_listener_sctpstat(void)
{
- register_ethereal_tap("sctp,stat", sctpstat_init);
+ register_tap_listener_cmd_arg("sctp,stat", sctpstat_init);
}
void
register_tap_listener_sipstat(void)
{
- register_ethereal_tap("sip,stat", sipstat_init);
+ register_tap_listener_cmd_arg("sip,stat", sipstat_init);
}
void
register_tap_listener_smbsids(void)
{
- register_ethereal_tap("smb,sids", smbsids_init);
+ register_tap_listener_cmd_arg("smb,sids", smbsids_init);
}
void
register_tap_listener_smbstat(void)
{
- register_ethereal_tap("smb,rtt", smbstat_init);
+ register_tap_listener_cmd_arg("smb,rtt", smbstat_init);
}
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);
}
void
register_tap_listener_wspstat(void)
{
- register_ethereal_tap("wsp,stat,", wspstat_init);
+ register_tap_listener_cmd_arg("wsp,stat,", wspstat_init);
}
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
return TRUE;
}
-typedef struct {
- ethereal_tap_list *tli;
- char *arg;
-} tap_to_run_t;
-
int
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 */);
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 */
/* 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) {