Added an option to Conversations and Endpoints to limit the list to match

the current display filter.

Some Hosts -> Endpoints cleanup.

svn path=/trunk/; revision=24368
This commit is contained in:
Stig Bjørlykke 2008-02-17 00:35:55 +00:00
parent 17504c44ad
commit 43272f9435
19 changed files with 230 additions and 22 deletions

View File

@ -787,6 +787,7 @@ se_tree_create
se_tree_create_non_persistent
set_actual_length
set_profile_name
set_tap_dfilter
show_fragment_seq_tree
show_fragment_tree
sid_name_snooping DATA

View File

@ -411,6 +411,53 @@ register_tap_listener(const char *tapname, void *tapdata, const char *fstring, t
return NULL;
}
/* this function sets a new dfilter to a tap listener
*/
GString *
set_tap_dfilter(void *tapdata, const char *fstring)
{
tap_listener_t *tl=NULL,*tl2;
GString *error_string;
if(!tap_listener_queue){
return NULL;
}
if(tap_listener_queue->tapdata==tapdata){
tl=(tap_listener_t *)tap_listener_queue;
} else {
for(tl2=(tap_listener_t *)tap_listener_queue;tl2->next;tl2=tl2->next){
if(tl2->next->tapdata==tapdata){
tl=tl2->next;
break;
}
}
}
if(tl){
if(tl->code){
dfilter_free(tl->code);
num_tap_filters--;
tl->code=NULL;
}
tl->needs_redraw=1;
if(fstring){
if(!dfilter_compile(fstring, &tl->code)){
error_string = g_string_new("");
g_string_sprintf(error_string,
"Filter \"%s\" is invalid - %s",
fstring, dfilter_error_msg);
return error_string;
} else {
num_tap_filters++;
}
}
}
return NULL;
}
/* this function removes a tap listener
*/
void

View File

@ -52,6 +52,7 @@ extern void draw_tap_listeners(gboolean draw_all);
extern GString *register_tap_listener(const char *tapname, void *tapdata,
const char *fstring, tap_reset_cb tap_reset, tap_packet_cb tap_packet,
tap_draw_cb tap_draw);
extern GString *set_tap_dfilter(void *tapdata, const char *fstring);
extern void remove_tap_listener(void *tapdata);
extern gboolean have_tap_listeners(void);
extern gboolean have_tap_listener(int tap_id);

View File

@ -296,9 +296,24 @@ reset_ct_table_data(conversations_table *ct)
{
guint32 i;
char title[256];
GString *error_string;
const char *filter;
/* Allow clist to update */
gtk_clist_thaw(ct->table);
if (ct->use_dfilter) {
filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
} else {
filter = ct->filter;
}
error_string = set_tap_dfilter (ct, filter);
if (error_string) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
g_string_free(error_string, TRUE);
return;
}
/* Allow clist to update */
gtk_clist_thaw(ct->table);
if(ct->page_lb) {
g_snprintf(title, 255, "Conversations: %s", cf_get_display_name(&cfile));
@ -306,6 +321,17 @@ reset_ct_table_data(conversations_table *ct)
g_snprintf(title, 255, "%s", ct->name);
gtk_label_set_text(GTK_LABEL(ct->page_lb), title);
gtk_widget_set_sensitive(ct->page_lb, FALSE);
if (ct->use_dfilter) {
if (filter && strlen(filter)) {
g_snprintf(title, 255, "%s Conversations - Filter: %s", ct->name, filter);
} else {
g_snprintf(title, 255, "%s Conversations - No Filter", ct->name);
}
} else {
g_snprintf(title, 255, "%s Conversations", ct->name);
}
gtk_label_set_text(GTK_LABEL(ct->name_lb), title);
} else {
g_snprintf(title, 255, "%s Conversations: %s", ct->name, cf_get_display_name(&cfile));
gtk_window_set_title(GTK_WINDOW(ct->win), title);
@ -1160,6 +1186,13 @@ draw_ct_table_data(conversations_table *ct)
}
gtk_label_set_text(GTK_LABEL(ct->page_lb), title);
gtk_widget_set_sensitive(ct->page_lb, ct->num_conversations);
} else {
if(ct->num_conversations) {
g_snprintf(title, 255, "%s Conversations: %u", ct->name, ct->num_conversations);
} else {
g_snprintf(title, 255, "%s Conversations", ct->name);
}
gtk_label_set_text(GTK_LABEL(ct->name_lb), title);
}
for(i=0;i<ct->num_conversations;i++){
@ -1270,7 +1303,6 @@ init_ct_table_page(conversations_table *conversations, GtkWidget *vbox, gboolean
GtkStyle *win_style;
GtkWidget *column_lb;
GString *error_string;
GtkWidget *label;
char title[256];
conversations->page_lb=NULL;
@ -1297,8 +1329,8 @@ init_ct_table_page(conversations_table *conversations, GtkWidget *vbox, gboolean
}
g_snprintf(title, 255, "%s Conversations", table_name);
label=gtk_label_new(title);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
conversations->name_lb=gtk_label_new(title);
gtk_box_pack_start(GTK_BOX(vbox), conversations->name_lb, FALSE, FALSE, 0);
conversations->scrolled_window=scrolled_window_new(NULL, NULL);
@ -1385,6 +1417,8 @@ init_conversation_table(gboolean hide_ports, const char *table_name, const char
conversations=g_malloc(sizeof(conversations_table));
conversations->name=table_name;
conversations->filter=filter;
conversations->use_dfilter=FALSE;
g_snprintf(title, 255, "%s Conversations: %s", table_name, cf_get_display_name(&cfile));
conversations->win=window_new(GTK_WINDOW_TOPLEVEL, title);
@ -1490,7 +1524,9 @@ init_ct_notebook_page_cb(gboolean hide_ports, const char *table_name, const char
conversations=g_malloc(sizeof(conversations_table));
conversations->name=table_name;
conversations->filter=filter;
conversations->resolve_names=TRUE;
conversations->use_dfilter=FALSE;
page_vbox=gtk_vbox_new(FALSE, 6);
conversations->win = page_vbox;
@ -1557,6 +1593,32 @@ ct_resolve_toggle_dest(GtkWidget *widget, gpointer data)
}
}
static void
ct_filter_toggle_dest(GtkWidget *widget, gpointer data)
{
int page;
void ** pages = data;
gboolean use_filter;
conversations_table *conversations;
use_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
conversations = pages[page];
conversations->use_dfilter = use_filter;
reset_ct_table_data(conversations);
}
cf_retap_packets(&cfile, FALSE);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
draw_ct_table_data(pages[page]);
}
}
void
init_conversation_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
{
@ -1568,6 +1630,7 @@ init_conversation_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
GtkWidget *close_bt, *help_bt;
GtkWidget *win;
GtkWidget *resolv_cb;
GtkWidget *filter_cb;
int page;
void ** pages;
GtkWidget *nb;
@ -1623,6 +1686,13 @@ init_conversation_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
SIGNAL_CONNECT(resolv_cb, "toggled", ct_resolve_toggle_dest, pages);
filter_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Limit to display filter", NULL);
gtk_container_add(GTK_CONTAINER(hbox), filter_cb);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(filter_cb), FALSE);
gtk_tooltips_set_tip(tooltips, filter_cb, "Limit the list to conversations matching the current display filter.", NULL);
SIGNAL_CONNECT(filter_cb, "toggled", ct_filter_toggle_dest, pages);
/* Button row. */
/* XXX - maybe we want to have a "Copy as CSV" stock button here? */
/*copy_bt = gtk_button_new_with_label ("Copy content to clipboard as CSV");*/

View File

@ -51,8 +51,11 @@ typedef struct _conversation_t {
/** Conversation widget */
typedef struct _conversations_table {
const char *name; /**< the name of the table */
const char *filter; /**< the filter used */
gboolean use_dfilter; /**< use display filter */
GtkWidget *win; /**< GTK window */
GtkWidget *page_lb; /**< label */
GtkWidget *page_lb; /**< page label */
GtkWidget *name_lb; /**< name label */
GtkWidget *scrolled_window; /**< the scrolled window */
GtkCList *table; /**< the GTK table */
guint32 num_columns; /**< number of columns in the above table */

View File

@ -71,7 +71,7 @@ gtk_eth_hostlist_init(const char *optarg,
filter=NULL;
}
init_hostlist_table(TRUE, "Ethernet Hosts", "eth", filter, eth_hostlist_packet);
init_hostlist_table(TRUE, "Ethernet", "eth", filter, eth_hostlist_packet);
}

View File

@ -72,7 +72,7 @@ gtk_fc_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "Fibre Channel Hosts", "fc", filter, fc_hostlist_packet);
init_hostlist_table(TRUE, "Fibre Channel", "fc", filter, fc_hostlist_packet);
}

View File

@ -70,7 +70,7 @@ gtk_fddi_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "FDDI Hosts", "fddi", filter, fddi_hostlist_packet);
init_hostlist_table(TRUE, "FDDI", "fddi", filter, fddi_hostlist_packet);
}

View File

@ -69,7 +69,7 @@ gtk_ip_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "IPv4 Hosts", "ip", filter, ip_hostlist_packet);
init_hostlist_table(TRUE, "IPv4", "ip", filter, ip_hostlist_packet);
}

View File

@ -70,7 +70,7 @@ gtk_ipx_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "IPX Hosts", "ipx", filter, ipx_hostlist_packet);
init_hostlist_table(TRUE, "IPX", "ipx", filter, ipx_hostlist_packet);
}

View File

@ -73,7 +73,7 @@ gtk_rsvp_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "RSVP Hosts", "rsvp", filter,
init_hostlist_table(TRUE, "RSVP", "rsvp", filter,
rsvp_hostlist_packet);
}

View File

@ -69,7 +69,7 @@ gtk_sctp_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(FALSE, "SCTP Hosts", "sctp", filter, sctp_hostlist_packet);
init_hostlist_table(FALSE, "SCTP", "sctp", filter, sctp_hostlist_packet);
}

View File

@ -167,8 +167,22 @@ reset_hostlist_table_data(hostlist_table *hosts)
{
guint32 i;
char title[256];
GString *error_string;
const char *filter;
if (hosts->use_dfilter) {
filter = gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
} else {
filter = hosts->filter;
}
error_string = set_tap_dfilter (hosts, filter);
if (error_string) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, error_string->str);
g_string_free(error_string, TRUE);
return;
}
/* Allow clist to update */
/* Allow clist to update */
gtk_clist_thaw(hosts->table);
if(hosts->page_lb) {
@ -177,6 +191,17 @@ reset_hostlist_table_data(hostlist_table *hosts)
g_snprintf(title, 255, "%s", hosts->name);
gtk_label_set_text(GTK_LABEL(hosts->page_lb), title);
gtk_widget_set_sensitive(hosts->page_lb, FALSE);
if (hosts->use_dfilter) {
if (filter && strlen(filter)) {
g_snprintf(title, 255, "%s Endpoints - Filter: %s", hosts->name, filter);
} else {
g_snprintf(title, 255, "%s Endpoints - No Filter", hosts->name);
}
} else {
g_snprintf(title, 255, "%s Endpoints", hosts->name);
}
gtk_label_set_text(GTK_LABEL(hosts->name_lb), title);
} else {
g_snprintf(title, 255, "%s Endpoints: %s", hosts->name, cf_get_display_name(&cfile));
gtk_window_set_title(GTK_WINDOW(hosts->win), title);
@ -557,6 +582,13 @@ draw_hostlist_table_data(hostlist_table *hl)
}
gtk_label_set_text(GTK_LABEL(hl->page_lb), title);
gtk_widget_set_sensitive(hl->page_lb, hl->num_hosts);
} else {
if(hl->num_hosts) {
g_snprintf(title, 255, "%s Endpoints: %u", hl->name, hl->num_hosts);
} else {
g_snprintf(title, 255, "%s Endpoints", hl->name);
}
gtk_label_set_text(GTK_LABEL(hl->name_lb), title);
}
for(i=0;i<hl->num_hosts;i++){
@ -662,10 +694,11 @@ init_hostlist_table_page(hostlist_table *hosttable, GtkWidget *vbox, gboolean hi
hosttable->has_ports=!hide_ports;
hosttable->num_hosts = 0;
hosttable->resolve_names=TRUE;
hosttable->page_lb = NULL;
g_snprintf(title, 255, "%s Endpoints", table_name);
hosttable->page_lb = gtk_label_new(title);
gtk_box_pack_start(GTK_BOX(vbox), hosttable->page_lb, FALSE, FALSE, 0);
hosttable->name_lb = gtk_label_new(title);
gtk_box_pack_start(GTK_BOX(vbox), hosttable->name_lb, FALSE, FALSE, 0);
hosttable->scrolled_window=scrolled_window_new(NULL, NULL);
gtk_box_pack_start(GTK_BOX(vbox), hosttable->scrolled_window, TRUE, TRUE, 0);
@ -750,6 +783,8 @@ init_hostlist_table(gboolean hide_ports, const char *table_name, const char *tap
hosttable=g_malloc(sizeof(hostlist_table));
hosttable->name=table_name;
hosttable->filter=filter;
hosttable->use_dfilter=FALSE;
g_snprintf(title, 255, "%s Endpoints: %s", table_name, cf_get_display_name(&cfile));
hosttable->win=window_new(GTK_WINDOW_TOPLEVEL, title);
@ -858,7 +893,9 @@ init_hostlist_notebook_page_cb(gboolean hide_ports, const char *table_name, cons
hosttable=g_malloc(sizeof(hostlist_table));
hosttable->name=table_name;
hosttable->filter=filter;
hosttable->resolve_names=TRUE;
hosttable->use_dfilter=FALSE;
page_vbox=gtk_vbox_new(FALSE, 6);
hosttable->win = page_vbox;
@ -925,6 +962,31 @@ hostlist_resolve_toggle_dest(GtkWidget *widget, gpointer data)
}
static void
hostlist_filter_toggle_dest(GtkWidget *widget, gpointer data)
{
int page;
void ** pages = data;
gboolean use_filter;
hostlist_table *hosttable;
use_filter = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget));
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
hosttable = pages[page];
hosttable->use_dfilter = use_filter;
reset_hostlist_table_data(hosttable);
}
cf_retap_packets(&cfile, FALSE);
/* after retapping, redraw table */
for (page=1; page<=GPOINTER_TO_INT(pages[0]); page++) {
draw_hostlist_table_data(pages[page]);
}
}
void
init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
{
@ -936,6 +998,7 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
GtkWidget *close_bt, *help_bt;
GtkWidget *win;
GtkWidget *resolv_cb;
GtkWidget *filter_cb;
int page;
void ** pages;
GtkWidget *nb;
@ -993,6 +1056,13 @@ init_hostlist_notebook_cb(GtkWidget *w _U_, gpointer d _U_)
SIGNAL_CONNECT(resolv_cb, "toggled", hostlist_resolve_toggle_dest, pages);
filter_cb = CHECK_BUTTON_NEW_WITH_MNEMONIC("Limit to display filter", NULL);
gtk_container_add(GTK_CONTAINER(hbox), filter_cb);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(filter_cb), FALSE);
gtk_tooltips_set_tip(tooltips, filter_cb, "Limit the list to endpoints matching the current display filter.", NULL);
SIGNAL_CONNECT(filter_cb, "toggled", hostlist_filter_toggle_dest, pages);
/* Button row. */
#if (GTK_MAJOR_VERSION >= 2)
if(topic_available(HELP_STATS_CONVERSATIONS_DIALOG)) {
@ -1135,3 +1205,16 @@ add_hostlist_table_data(hostlist_table *hl, const address *addr, guint32 port, g
draw_hostlist_table_address(hl, talker_idx);
}
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -45,8 +45,11 @@ typedef struct _hostlist_talker_t {
/** Hostlist widget */
typedef struct _hostlist_table {
const char *name; /**< the name of the table */
const char *filter; /**< the filter used */
gboolean use_dfilter; /**< use display filter */
GtkWidget *win; /**< GTK window */
GtkWidget *page_lb; /**< label */
GtkWidget *page_lb; /**< page label */
GtkWidget *name_lb; /**< name label */
GtkWidget *scrolled_window; /**< the scrolled window */
GtkCList *table; /**< the GTK table */
guint32 num_columns; /**< number of columns in the above table */

View File

@ -71,7 +71,7 @@ gtk_tcpip_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(FALSE, "TCP Endpoints", "tcp", filter, tcpip_hostlist_packet);
init_hostlist_table(FALSE, "TCP", "tcp", filter, tcpip_hostlist_packet);
}

View File

@ -70,7 +70,7 @@ gtk_tr_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "Token Ring Hosts", "tr", filter, tr_hostlist_packet);
init_hostlist_table(TRUE, "Token Ring", "tr", filter, tr_hostlist_packet);
}

View File

@ -70,7 +70,7 @@ gtk_udpip_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(FALSE, "UDP Endpoints", "udp", filter, udpip_hostlist_packet);
init_hostlist_table(FALSE, "UDP", "udp", filter, udpip_hostlist_packet);
}

View File

@ -68,7 +68,7 @@ gtk_usb_hostlist_init(const char *optarg, void* userdata _U_)
filter = NULL;
}
init_hostlist_table(TRUE, "USB Hosts", "usb", filter, usb_hostlist_packet);
init_hostlist_table(TRUE, "USB", "usb", filter, usb_hostlist_packet);
}

View File

@ -68,7 +68,7 @@ gtk_wlan_hostlist_init(const char *optarg, void* userdata _U_)
filter=NULL;
}
init_hostlist_table(TRUE, "WLAN Hosts", "wlan", filter, wlan_hostlist_packet);
init_hostlist_table(TRUE, "WLAN", "wlan", filter, wlan_hostlist_packet);
}