Some work on generalizing the "display filter" tap parameter dialog box

to more generally support fetching parameters for taps.

svn path=/trunk/; revision=37559
This commit is contained in:
Guy Harris 2011-06-05 22:39:23 +00:00
parent 2477298026
commit 3a1097a0ae
29 changed files with 352 additions and 128 deletions

View File

@ -199,6 +199,7 @@ LIBWIRESHARK_INCLUDES = \
oui.h \
packet.h \
packet_info.h \
params.h \
pint.h \
plugins.h \
ppptypes.h \

43
epan/params.h Normal file
View File

@ -0,0 +1,43 @@
/* params.h
* Definitions for parameter handling routines
*
* $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PARAMS_H__
#define __PARAMS_H__
/*
* Definition of a value for an enumerated type.
*
* "name" is the the name one would use on the command line for the value.
* "description" is the description of the value, used in combo boxes/
* option menus.
* "value" is the value.
*/
typedef struct {
const char *name;
const char *description;
gint value;
} enum_val_t;
#endif /* params.h */

View File

@ -29,6 +29,7 @@
#include "color.h"
#include <epan/params.h>
#include <epan/range.h>
#define PR_DEST_CMD 0
@ -328,12 +329,6 @@ extern void prefs_register_bool_preference(module_t *module, const char *name,
/*
* Register a preference with an enumerated value.
*/
typedef struct {
const char *name;
const char *description;
gint value;
} enum_val_t;
extern void prefs_register_enum_preference(module_t *module, const char *name,
const char *title, const char *description, gint *var,
const enum_val_t *enumvals, gboolean radio_buttons);

View File

@ -197,11 +197,17 @@ gtk_afpstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ss->win->window);
}
static tap_dfilter_dlg afp_stat_dlg = {
static tap_param afp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg afp_stat_dlg = {
"AFP SRT Statistics",
"afp,srt",
gtk_afpstat_init,
-1
-1,
G_N_ELEMENTS(afp_stat_params),
afp_stat_params
};
void

View File

@ -271,11 +271,17 @@ dhcpstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(sp->win->window);
}
static tap_dfilter_dlg dhcp_stat_dlg = {
static tap_param bootp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg dhcp_stat_dlg = {
"BOOTP-DHCP Packet Counter",
"bootp,stat",
dhcpstat_init,
-1
-1,
G_N_ELEMENTS(bootp_stat_params),
bootp_stat_params
};
void

View File

@ -213,11 +213,17 @@ static void gtk_camelcounter_init(const char *optarg, void *userdata _U_)
gdk_window_raise(p_camelcounter->win->window);
}
static tap_dfilter_dlg camel_counter_dlg = {
static tap_param camel_counter_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg camel_counter_dlg = {
"CAMEL Messages and Response Status",
"camel,counter",
gtk_camelcounter_init,
-1
-1,
G_N_ELEMENTS(camel_counter_params),
camel_counter_params
};
void /* Next line mandatory */

View File

@ -230,11 +230,17 @@ static void gtk_camelsrt_init(const char *optarg, void *userdata _U_)
}
static tap_dfilter_dlg camel_srt_dlg = {
static tap_param camel_srt_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg camel_srt_dlg = {
"CAMEL Service Response Time",
"camel,srt",
gtk_camelsrt_init,
-1
-1,
G_N_ELEMENTS(camel_srt_params),
camel_srt_params
};
void /* Next line mandatory */

View File

@ -218,11 +218,17 @@ gtk_diameterstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(diameter->win->window);
}
static tap_dfilter_dlg diameter_stat_dlg = {
static tap_param diameter_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg diameter_stat_dlg = {
"Diameter Service Response Time Statistics",
"diameter",
gtk_diameterstat_init,
-1
-1,
G_N_ELEMENTS(diameter_stat_params),
diameter_stat_params
};
void

View File

@ -53,7 +53,7 @@
* - "RTP Streams" rtpstream_dlg_create()
* - "Simple Dialog" display_simple_dialog()
* - "Compute SMB SRT statistics" gtk_smbstat_cb()
* - "Compute ..." tap_dfilter_dlg_cb()
* - "Compute ..." tap_param_dlg_cb()
* - "Tcp Graph" create_drawing_area()
* - "Tcp Graph Control" control_panel_create()
* - "Help for TCP graphing" callback_create_help()

View File

@ -204,11 +204,17 @@ gtk_fcstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(fc->win->window);
}
static tap_dfilter_dlg fc_stat_dlg = {
static tap_param fc_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg fc_stat_dlg = {
"Fibre Channel Service Response Time statistics",
"fc,srt",
gtk_fcstat_init,
-1
-1,
G_N_ELEMENTS(fc_stat_params),
fc_stat_params
};
void

View File

@ -221,11 +221,17 @@ gtk_gtpstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(gtp->win->window);
}
static tap_dfilter_dlg gtp_stat_dlg = {
static tap_param gtp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg gtp_stat_dlg = {
"GTP Control Plane Response Time Statistics",
"gtp",
gtk_gtpstat_init,
-1
-1,
G_N_ELEMENTS(gtp_stat_params),
gtp_stat_params
};
void

View File

@ -55,11 +55,17 @@
static void gtk_h225counter_init(const char *optarg, void *userdata);
static tap_dfilter_dlg h225_counter_dlg = {
static tap_param h225_counter_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg h225_counter_dlg = {
"H.225 Messages and Message Reasons",
"h225,counter",
gtk_h225counter_init,
-1
-1,
G_N_ELEMENTS(h225_counter_params),
h225_counter_params
};
/* following values represent the size of their valuestring arrays */

View File

@ -56,11 +56,17 @@
static void gtk_h225rassrt_init(const char *optarg, void *userdata);
static tap_dfilter_dlg h225_rassrt_dlg = {
static tap_param h225_rassrt_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg h225_rassrt_dlg = {
"H.225 RAS Service Response Time",
"h225,srt",
gtk_h225rassrt_init,
-1
-1,
G_N_ELEMENTS(h225_rassrt_params),
h225_rassrt_params
};
/* following values represent the size of their valuestring arrays */

View File

@ -236,11 +236,17 @@ gtk_ldapstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ldap->win->window);
}
static tap_dfilter_dlg ldap_stat_dlg = {
static tap_param ldap_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg ldap_stat_dlg = {
"LDAP Service Response Time Statistics",
"ldap,srt",
gtk_ldapstat_init,
-1
-1,
G_N_ELEMENTS(ldap_stat_params),
ldap_stat_params
};
void

View File

@ -1302,11 +1302,17 @@ static void gtk_mac_lte_stat_init(const char *optarg, void *userdata _U_)
}
static tap_dfilter_dlg mac_lte_stat_dlg = {
static tap_param mac_lte_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg mac_lte_stat_dlg = {
"LTE MAC Stats",
"mac-lte,stat",
gtk_mac_lte_stat_init,
-1
-1,
G_N_ELEMENTS(mac_lte_stat_params),
mac_lte_stat_params
};

View File

@ -1444,7 +1444,7 @@ main_cf_cb_file_closed(capture_file *cf _U_)
static void
main_cf_cb_file_read_started(capture_file *cf _U_)
{
tap_dfilter_dlg_update();
tap_param_dlg_update();
/* Set up main window for a capture file. */
main_set_for_capture_file(TRUE);

View File

@ -216,11 +216,17 @@ gtk_megacostat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ms->win->window);
}
static tap_dfilter_dlg megaco_srt_dlg = {
static tap_param megaco_srt_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg megaco_srt_dlg = {
"MEGACO Service Response Time (SRT) Statistics",
"megaco,srt",
gtk_megacostat_init,
-1
-1,
G_N_ELEMENTS(megaco_srt_params),
megaco_srt_params
};
void

View File

@ -302,11 +302,17 @@ gtk_mgcpstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ms->win->window);
}
static tap_dfilter_dlg mgcp_srt_dlg = {
static tap_param mgcp_srt_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg mgcp_srt_dlg = {
"MGCP Service Response Time (SRT) Statistics",
"mgcp,srt",
gtk_mgcpstat_init,
-1
-1,
G_N_ELEMENTS(mgcp_srt_params),
mgcp_srt_params
};
void

View File

@ -721,11 +721,17 @@ gtk_ncpstat_init(const char *optarg, void *userdata _U_)
cf_redissect_packets(&cfile);
}
static tap_dfilter_dlg ncp_stat_dlg = {
static tap_param ncp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg ncp_stat_dlg = {
"NCP SRT Statistics",
"ncp,srt",
gtk_ncpstat_init,
-1
-1,
G_N_ELEMENTS(ncp_stat_params),
ncp_stat_params
};
void

View File

@ -353,11 +353,17 @@ gtk_radiusstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(rs->win->window);
}
static tap_dfilter_dlg radius_srt_dlg = {
static tap_param radius_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg radius_srt_dlg = {
"RADIUS Service Response Time (SRT) Statistics",
"radius,srt",
gtk_radiusstat_init,
-1
-1,
G_N_ELEMENTS(radius_stat_params),
radius_stat_params
};
void

View File

@ -1531,11 +1531,17 @@ static void gtk_rlc_lte_stat_init(const char *optarg, void *userdata _U_)
}
static tap_dfilter_dlg rlc_lte_stat_dlg = {
static tap_param rlc_lte_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg rlc_lte_stat_dlg = {
"LTE RLC Stats",
"rlc-lte,stat",
gtk_rlc_lte_stat_init,
-1
-1,
G_N_ELEMENTS(rlc_lte_stat_params),
rlc_lte_stat_params
};

View File

@ -57,11 +57,17 @@
static void sctpstat_init(const char *optarg, void *userdata);
static tap_dfilter_dlg sctp_stat_dlg = {
static tap_param sctp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg sctp_stat_dlg = {
"SCTP Statistics",
"sctp,stat",
sctpstat_init,
-1
-1,
G_N_ELEMENTS(sctp_stat_params),
sctp_stat_params
};
typedef struct sctp_ep {

View File

@ -711,11 +711,17 @@ gtk_sipstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(sp->win->window);
}
static tap_dfilter_dlg sip_stat_dlg = {
static tap_param sip_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg sip_stat_dlg = {
"SIP Packet Counter",
"sip,stat",
gtk_sipstat_init,
-1
-1,
G_N_ELEMENTS(sip_stat_params),
sip_stat_params
};
/* Register this tap listener and add menu item. */

View File

@ -201,11 +201,17 @@ gtk_smb2stat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ss->win->window);
}
static tap_dfilter_dlg smb2_stat_dlg = {
static tap_param smb2_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg smb2_stat_dlg = {
"SMB2 SRT Statistics",
"smb2,srt",
gtk_smb2stat_init,
-1
-1,
G_N_ELEMENTS(smb2_stat_params),
smb2_stat_params
};
void

View File

@ -239,11 +239,17 @@ gtk_smbstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(ss->win->window);
}
static tap_dfilter_dlg smb_stat_dlg = {
static tap_param smb_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg smb_stat_dlg = {
"SMB SRT Statistics",
"smb,srt",
gtk_smbstat_init,
-1
-1,
G_N_ELEMENTS(smb_stat_params),
smb_stat_params
};
void

View File

@ -48,7 +48,7 @@ struct _st_node_pres {
};
struct _tree_cfg_pres {
tap_dfilter_dlg* stat_dlg;
tap_param_dlg* stat_dlg;
};
struct _tree_pres {
@ -339,7 +339,7 @@ register_gtk_stats_tree_tap (gpointer k _U_, gpointer v, gpointer p _U_)
cfg->pr = g_malloc(sizeof(tree_pres));
cfg->pr->stat_dlg = g_malloc(sizeof(tap_dfilter_dlg));
cfg->pr->stat_dlg = g_malloc(sizeof(tap_param_dlg));
cfg->pr->stat_dlg->win_title = g_strdup_printf("%s Stats Tree",cfg->name);
cfg->pr->stat_dlg->init_string = g_strdup_printf("%s,tree",cfg->abbr);

View File

@ -1,5 +1,5 @@
/* tap_dfilter_dlg.c
* Routines for display filter dialog used by gui taps
* Routines for parameter dialog used by gui taps
* Copyright 2003 Lars Roland
*
* $Id$
@ -53,27 +53,27 @@
#include "gtk/filter_autocomplete.h"
typedef struct _tap_dfilter_dlg_list_item {
typedef struct _tap_param_dlg_list_item {
GtkWidget *dlg;
GtkWidget *filter_entry;
tap_dfilter_dlg cont;
tap_param_dlg cont;
construct_args_t args;
struct _tap_dfilter_dlg_list_item *next;
} tap_dfilter_dlg_list_item;
GtkWidget **param_entries; /* items for params */
struct _tap_param_dlg_list_item *next;
} tap_param_dlg_list_item;
static tap_dfilter_dlg_list_item *start_dlg_list=NULL;
static tap_dfilter_dlg_list_item *end_dlg_list=NULL;
static tap_dfilter_dlg_list_item *current_dlg = NULL;
static tap_param_dlg_list_item *start_dlg_list=NULL;
static tap_param_dlg_list_item *end_dlg_list=NULL;
static tap_param_dlg_list_item *current_dlg = NULL;
static void
tap_dfilter_dlg_cb(GtkWidget *w, gpointer data);
tap_param_dlg_cb(GtkWidget *w, gpointer data);
/*
* Register a stat that has a display filter dialog.
* Register a stat that has a parameter dialog.
* We register it both as a command-line stat and a menu item stat.
*/
void
register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
register_dfilter_stat(tap_param_dlg *info, const char *name,
register_stat_group_t group)
{
char *full_name;
@ -85,14 +85,14 @@ register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
* to it.
*/
full_name = g_strdup_printf("%s...", name);
register_stat_menu_item(full_name, group, tap_dfilter_dlg_cb, NULL,
register_stat_menu_item(full_name, group, tap_param_dlg_cb, NULL,
NULL, info);
g_free(full_name);
}
void tap_dfilter_dlg_update (void)
void tap_param_dlg_update (void)
{
tap_dfilter_dlg_list_item *dialog = start_dlg_list;
tap_param_dlg_list_item *dialog = start_dlg_list;
char *title;
while(dialog != NULL) {
@ -108,41 +108,41 @@ void tap_dfilter_dlg_update (void)
static void
dlg_destroy_cb(GtkWidget *item _U_, gpointer dialog_data)
{
tap_dfilter_dlg_list_item *dlg_data = (tap_dfilter_dlg_list_item *) dialog_data;
tap_param_dlg_list_item *dlg_data = (tap_param_dlg_list_item *) dialog_data;
dlg_data->dlg = NULL;
}
static void
tap_dfilter_dlg_start_button_clicked(GtkWidget *item _U_, gpointer dialog_data)
tap_param_dlg_start_button_clicked(GtkWidget *item _U_, gpointer dialog_data)
{
const char *filter;
char *str;
const char *value;
GString *params;
size_t i;
tap_dfilter_dlg_list_item *dlg_data = (tap_dfilter_dlg_list_item *) dialog_data;
tap_param_dlg_list_item *dlg_data = (tap_param_dlg_list_item *) dialog_data;
filter=gtk_entry_get_text(GTK_ENTRY(dlg_data->filter_entry));
if(filter[0]==0){
str = g_strdup_printf("%s", dlg_data->cont.init_string);
} else {
str = g_strdup_printf("%s,%s", dlg_data->cont.init_string,
filter);
params = g_string_new(dlg_data->cont.init_string);
for(i=0;i<dlg_data->cont.nparams;i++) {
value=gtk_entry_get_text(GTK_ENTRY(dlg_data->param_entries[i]));
params=g_string_append_c(params, ',');
params=g_string_append(params, value);
}
(dlg_data->cont.tap_init_cb)(str,NULL);
g_free(str);
(dlg_data->cont.tap_init_cb)(params->str,NULL);
g_string_free(params, TRUE);
}
static void
tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
tap_param_dlg_cb(GtkWidget *w _U_, gpointer data)
{
const char *filter;
char *title;
GtkWidget *dlg_box;
GtkWidget *filter_box, *filter_bt;
GtkWidget *item_box, *item_entry, *label, *filter_bt;
GtkWidget *bbox, *start_button, *cancel_button;
size_t i;
tap_dfilter_dlg *dlg_data = (tap_dfilter_dlg *) data;
tap_param_dlg *dlg_data = (tap_param_dlg *) data;
if(dlg_data==NULL)
return;
@ -150,19 +150,21 @@ tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
if(dlg_data->index==-1) {
/* Dialog is not registered */
if(start_dlg_list==NULL) {
start_dlg_list = (tap_dfilter_dlg_list_item *) g_malloc(sizeof (tap_dfilter_dlg_list_item));
start_dlg_list = (tap_param_dlg_list_item *) g_malloc(sizeof (tap_param_dlg_list_item));
end_dlg_list = start_dlg_list;
end_dlg_list->cont.index = 0; /* first entry in list -> index = 0 */
} else {
end_dlg_list->next = (tap_dfilter_dlg_list_item *) g_malloc(sizeof (tap_dfilter_dlg_list_item));
end_dlg_list->next = (tap_param_dlg_list_item *) g_malloc(sizeof (tap_param_dlg_list_item));
end_dlg_list->next->cont.index = end_dlg_list->cont.index + 1;
end_dlg_list = end_dlg_list->next;
}
end_dlg_list->dlg = NULL;
end_dlg_list->filter_entry = NULL;
end_dlg_list->param_entries = g_malloc(dlg_data->nparams * sizeof (GtkWidget *));
end_dlg_list->cont.win_title = dlg_data->win_title;
end_dlg_list->cont.init_string = dlg_data->init_string;
end_dlg_list->cont.tap_init_cb = dlg_data->tap_init_cb;
end_dlg_list->cont.nparams = dlg_data->nparams;
end_dlg_list->cont.params = dlg_data->params;
end_dlg_list->args.title = g_strdup_printf("%s Filter", dlg_data->win_title);
end_dlg_list->args.wants_apply_button = TRUE;
end_dlg_list->args.activate_on_ok = FALSE;
@ -200,37 +202,68 @@ tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
gtk_container_add(GTK_CONTAINER(current_dlg->dlg), dlg_box);
gtk_widget_show(dlg_box);
/* Filter box */
filter_box=gtk_hbox_new(FALSE, 3);
/* Parameter items */
for(i=0;i<current_dlg->cont.nparams;i++) {
/* Item box */
item_box=gtk_hbox_new(FALSE, 3);
/* Filter button */
filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &(current_dlg->args));
gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, TRUE, 0);
gtk_widget_show(filter_bt);
/* Item entry */
item_entry=gtk_entry_new();
current_dlg->param_entries[i] = item_entry;
/* Filter entry */
current_dlg->filter_entry=gtk_entry_new();
g_signal_connect(current_dlg->filter_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
g_object_set_data(G_OBJECT(filter_box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
g_signal_connect(current_dlg->filter_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
g_signal_connect(current_dlg->dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
switch (current_dlg->cont.params[i].type) {
/* filter prefs dialog */
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, current_dlg->filter_entry);
/* filter prefs dialog */
case PARAM_UINT:
case PARAM_STRING:
/* Label */
label=gtk_label_new(current_dlg->cont.params[i].title);
gtk_box_pack_start(GTK_BOX(item_box), label, FALSE, TRUE, 0);
gtk_widget_show(label);
break;
case PARAM_FILTER:
/* Filter button */
filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &(current_dlg->args));
gtk_box_pack_start(GTK_BOX(item_box), filter_bt, FALSE, TRUE, 0);
gtk_widget_show(filter_bt);
g_signal_connect(item_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
g_object_set_data(G_OBJECT(item_box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
g_signal_connect(item_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
g_signal_connect(current_dlg->dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
/* prefs dialog */
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, item_entry);
/* prefs dialog */
break;
default:
/* XXX - fill me in */
break;
}
gtk_box_pack_start(GTK_BOX(filter_box), current_dlg->filter_entry, TRUE, TRUE, 0);
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
if(filter){
gtk_entry_set_text(GTK_ENTRY(current_dlg->filter_entry), filter);
} else {
colorize_filter_te_as_empty(current_dlg->filter_entry);
}
gtk_widget_show(current_dlg->filter_entry);
gtk_box_pack_start(GTK_BOX(item_box), item_entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
gtk_widget_show(filter_box);
switch(current_dlg->cont.params[i].type){
case PARAM_FILTER:
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
if(filter){
gtk_entry_set_text(GTK_ENTRY(item_entry), filter);
} else {
colorize_filter_te_as_empty(item_entry);
}
break;
default:
/* XXX - anything to do here? */
break;
}
gtk_widget_show(item_entry);
gtk_box_pack_start(GTK_BOX(dlg_box), item_box, TRUE, TRUE, 0);
gtk_widget_show(item_box);
}
/* button box */
bbox = dlg_button_row_new(WIRESHARK_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
@ -239,20 +272,24 @@ tap_dfilter_dlg_cb(GtkWidget *w _U_, gpointer data)
start_button = g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CREATE_STAT);
g_signal_connect(start_button, "clicked",
G_CALLBACK(tap_dfilter_dlg_start_button_clicked), current_dlg);
G_CALLBACK(tap_param_dlg_start_button_clicked), current_dlg);
cancel_button = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
window_set_cancel_button(current_dlg->dlg, cancel_button, window_cancel_button_cb);
/* Catch the "activate" signal on the filter text entry, so that
/* Catch the "activate" signal on all the text entries, so that
if the user types Return there, we act as if the "Create Stat"
button had been selected, as happens if Return is typed if
some widget that *doesn't* handle the Return key has the input
focus. */
dlg_set_activate(current_dlg->filter_entry, start_button);
for(i=0;i<current_dlg->cont.nparams;i++){
dlg_set_activate(current_dlg->param_entries[i], start_button);
}
/* Give the initial focus to the "Filter" entry box. */
gtk_widget_grab_focus(current_dlg->filter_entry);
/* Give the initial focus to the first entry box. */
if(current_dlg->cont.nparams>0){
gtk_widget_grab_focus(current_dlg->param_entries[0]);
}
gtk_widget_grab_default(start_button );

View File

@ -1,5 +1,5 @@
/* tap_dfilter_dlg.h
* Header file for display filter dialog used by gui taps
* Header file for parameter dialog used by gui taps
* Copyright 2003 Lars Roland
*
* $Id$
@ -27,10 +27,10 @@
#define __TAP_DFILTER_DLG_H__
/*
* You can easily add a display filter dialog for your gui tap by using
* You can easily add a parameter dialog for your gui tap by using
* the following infrastructure:
*
* Define a global structure of tap_dfilter_dlg within your tap source file.
* Define a global structure of tap_param_dlg within your stat source file.
* Initiate it with:
* 1) a title string for the Dialog Window
* 2) the init string, which is the same as the string after "-z" option without
@ -40,17 +40,22 @@
* 4) the index with "-1"
*
* Within register_tap_menu_yourtap(void), call register_dfilter_stat()
* with a pointer to the tap_dfilter_dlg structure, a string for the
* with a pointer to the tap_param_dlg structure, a string for the
* menu item (don't put "..." at the end, register_dfilter_stat() will
* add it for you), and the REGISTER_STAT_GROUP_ value for the stat
* group to which your stat should belong.
*
* Usage:
*
* tap_dfilter_dlg my_tap_dfilter_dlg = {"My Title", "myproto,mytap", gtk_mytap_init, -1};
* tap_param_dlg my_tap_param_dlg = {
* "My Title",
* "myproto,mytap",
* gtk_mytap_init,
* -1
* };
*
* register_tap_menu_mytap(void) {
* register_dfilter_stat(&my_tap_dfilter_dlg, "My Menu Item",
* register_dfilter_stat(&my_tap_param_dlg, "My Menu Item",
* REGISTER_STAT_GROUP_my_group);
* }
*
@ -58,21 +63,38 @@
*
*/
typedef struct _tap_dfilter_dlg {
#include <epan/params.h>
typedef enum {
PARAM_UINT,
PARAM_STRING,
PARAM_ENUM,
PARAM_FILTER
} param_type;
typedef struct _tap_param {
param_type type;
const char *title;
enum_val_t *enum_vals;
} tap_param;
typedef struct _tap_param_dlg {
const char *win_title; /* title */
const char *init_string; /* the string to call the tap without a filter via "-z" option */
void (* tap_init_cb)(const char *,void*); /* callback to init function of the tap */
gint index; /* initiate this value always with "-1" */
} tap_dfilter_dlg;
size_t nparams; /* number of parameters */
tap_param *params; /* pointer to table of parameter info */
} tap_param_dlg;
/*
* Register a stat that has a display filter dialog.
* We register it both as a command-line stat and a menu item stat.
*/
void register_dfilter_stat(tap_dfilter_dlg *info, const char *name,
void register_dfilter_stat(tap_param_dlg *info, const char *name,
register_stat_group_t group);
/* This will update the titles of the dialog windows when we load a new capture file. */
void tap_dfilter_dlg_update (void);
void tap_param_dlg_update (void);
#endif /* __TAP_DFILTER_DLG_H__ */

View File

@ -419,11 +419,17 @@ gtk_wspstat_init(const char *optarg, void *userdata _U_)
gdk_window_raise(sp->win->window);
}
static tap_dfilter_dlg wsp_stat_dlg = {
static tap_param wsp_stat_params[] = {
{ PARAM_FILTER, "Filter", NULL }
};
static tap_param_dlg wsp_stat_dlg = {
"WAP-WSP Packet Counter",
"wsp,stat",
gtk_wspstat_init,
-1
-1,
G_N_ELEMENTS(wsp_stat_params),
wsp_stat_params
};
void