int count; /* Total number of frames */
int displayed_count; /* Number of displayed frames */
int marked_count; /* Number of marked frames */
+ int ignored_count; /* Number of ignored frames */
gboolean drops_known; /* TRUE if we know how many packets were dropped */
guint32 drops; /* Dropped packets */
nstime_t elapsed_time; /* Elapsed time */
static int hf_frame_file_off = -1;
static int hf_frame_md5_hash = -1;
static int hf_frame_marked = -1;
+static int hf_frame_ignored = -1;
static int hf_link_number = -1;
static int hf_frame_protocols = -1;
static int hf_frame_color_filter_name = -1;
ti = proto_tree_add_boolean(fh_tree, hf_frame_marked, tvb, 0, 0,pinfo->fd->flags.marked);
PROTO_ITEM_SET_GENERATED(ti);
+ ti = proto_tree_add_boolean(fh_tree, hf_frame_ignored, tvb, 0, 0,pinfo->fd->flags.ignored);
+ PROTO_ITEM_SET_GENERATED(ti);
+
if(proto_field_is_referenced(tree, hf_frame_protocols)) {
/* we are going to be using proto_item_append_string() on
* hf_frame_protocols, and we must therefore disable the
}
}
+ if (pinfo->fd->flags.ignored) {
+ /* Ignored package, stop handling here */
+ col_set_str(pinfo->cinfo, COL_INFO, "<Ignored>");
+ proto_tree_add_text (tree, tvb, 0, -1, "This frame is marked as ignored");
+ return;
+ }
+
/* Portable Exception Handling to trap Wireshark specific exceptions like BoundsError exceptions */
TRY {
#ifdef _MSC_VER
{ "Frame is marked", "frame.marked", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
"Frame is marked in the GUI", HFILL }},
+ { &hf_frame_ignored,
+ { "Frame is ignored", "frame.ignored", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ "Frame is ignored by the dissectors", HFILL }},
+
{ &hf_frame_protocols,
{ "Protocols in frame", "frame.protocols", FT_STRING, BASE_NONE, NULL, 0x0,
"Protocols carried by this frame", HFILL }},
fdata->flags.visited = 0;
fdata->flags.marked = 0;
fdata->flags.ref_time = 0;
+ fdata->flags.ignored = 0;
fdata->color_filter = NULL;
#ifdef NEW_PACKET_LIST
fdata->col_text_len = NULL;
unsigned int visited : 1; /* Has this packet been visited yet? 1=Yes,0=No*/
unsigned int marked : 1; /* 1 = marked by user, 0 = normal */
unsigned int ref_time : 1; /* 1 = marked as a reference time frame, 0 = normal */
+ unsigned int ignored : 1; /* 1 = ignore this frame, 0 = normal */
} flags;
const void *color_filter; /* Per-packet matching color_filter_t object */
prefs.gui_marked_bg.red = 0;
prefs.gui_marked_bg.green = 0;
prefs.gui_marked_bg.blue = 0;
+ prefs.gui_ignored_fg.pixel = 32767;
+ prefs.gui_ignored_fg.red = 32767;
+ prefs.gui_ignored_fg.green = 32767;
+ prefs.gui_ignored_fg.blue = 32767;
+ prefs.gui_ignored_bg.pixel = 65535;
+ prefs.gui_ignored_bg.red = 65535;
+ prefs.gui_ignored_bg.green = 65535;
+ prefs.gui_ignored_bg.blue = 65535;
prefs.gui_colorized_fg = g_strdup("000000,000000,000000,000000,000000,000000,000000,000000,000000,000000");
prefs.gui_colorized_bg = g_strdup("ffc0c0,ffc0ff,e0c0e0,c0c0ff,c0e0e0,c0ffff,c0ffc0,ffffc0,e0e0c0,e0e0e0");
prefs.gui_geometry_save_position = FALSE;
#define PRS_GUI_FONT_NAME_2 "gui.gtk2.font_name"
#define PRS_GUI_MARKED_FG "gui.marked_frame.fg"
#define PRS_GUI_MARKED_BG "gui.marked_frame.bg"
+#define PRS_GUI_IGNORED_FG "gui.ignored_frame.fg"
+#define PRS_GUI_IGNORED_BG "gui.ignored_frame.bg"
#define PRS_GUI_COLORIZED_FG "gui.colorized_frame.fg"
#define PRS_GUI_COLORIZED_BG "gui.colorized_frame.bg"
#define PRS_GUI_CONSOLE_OPEN "gui.console_open"
prefs.gui_marked_bg.red = RED_COMPONENT(cval);
prefs.gui_marked_bg.green = GREEN_COMPONENT(cval);
prefs.gui_marked_bg.blue = BLUE_COMPONENT(cval);
+ } else if (strcmp(pref_name, PRS_GUI_IGNORED_FG) == 0) {
+ cval = strtoul(value, NULL, 16);
+ prefs.gui_ignored_fg.pixel = 0;
+ prefs.gui_ignored_fg.red = RED_COMPONENT(cval);
+ prefs.gui_ignored_fg.green = GREEN_COMPONENT(cval);
+ prefs.gui_ignored_fg.blue = BLUE_COMPONENT(cval);
+ } else if (strcmp(pref_name, PRS_GUI_IGNORED_BG) == 0) {
+ cval = strtoul(value, NULL, 16);
+ prefs.gui_ignored_bg.pixel = 0;
+ prefs.gui_ignored_bg.red = RED_COMPONENT(cval);
+ prefs.gui_ignored_bg.green = GREEN_COMPONENT(cval);
+ prefs.gui_ignored_bg.blue = BLUE_COMPONENT(cval);
} else if (strcmp(pref_name, PRS_GUI_COLORIZED_FG) == 0) {
g_free(prefs.gui_colorized_fg);
prefs.gui_colorized_fg = g_strdup(value);
(prefs.gui_marked_bg.green * 255 / 65535),
(prefs.gui_marked_bg.blue * 255 / 65535));
+ fprintf (pf, "\n# Color preferences for a ignored frame.\n");
+ fprintf (pf, "# Each value is a six digit hexadecimal color value in the form rrggbb.\n");
+ fprintf (pf, "%s: %02x%02x%02x\n", PRS_GUI_IGNORED_FG,
+ (prefs.gui_ignored_fg.red * 255 / 65535),
+ (prefs.gui_ignored_fg.green * 255 / 65535),
+ (prefs.gui_ignored_fg.blue * 255 / 65535));
+ fprintf (pf, "%s: %02x%02x%02x\n", PRS_GUI_IGNORED_BG,
+ (prefs.gui_ignored_bg.red * 255 / 65535),
+ (prefs.gui_ignored_bg.green * 255 / 65535),
+ (prefs.gui_ignored_bg.blue * 255 / 65535));
+
/* Don't write the colors of the 10 easy-access-colorfilters to the preferences
* file until the colors can be changed in the GUI. Currently this is not really
* possible since the STOCK-icons for these colors are hardcoded.
dest->gui_font_name = g_strdup(src->gui_font_name);
dest->gui_marked_fg = src->gui_marked_fg;
dest->gui_marked_bg = src->gui_marked_bg;
+ dest->gui_ignored_fg = src->gui_ignored_fg;
+ dest->gui_ignored_bg = src->gui_ignored_bg;
dest->gui_geometry_save_position = src->gui_geometry_save_position;
dest->gui_geometry_save_size = src->gui_geometry_save_size;
dest->gui_geometry_save_maximized = src->gui_geometry_save_maximized;
gchar *gui_font_name;
color_t gui_marked_fg;
color_t gui_marked_bg;
+ color_t gui_ignored_fg;
+ color_t gui_ignored_bg;
gchar *gui_colorized_fg;
gchar *gui_colorized_bg;
gboolean gui_geometry_save_position;
cf->count = 0;
cf->displayed_count = 0;
cf->marked_count = 0;
+ cf->ignored_count = 0;
cf->drops_known = FALSE;
cf->drops = 0;
cf->snap = wtap_snapshot_length(cf->wth);
if (fdata->flags.marked) {
packet_list_set_colors(row, &prefs.gui_marked_fg, &prefs.gui_marked_bg);
}
+ if (fdata->flags.ignored) {
+ packet_list_set_colors(row, &prefs.gui_ignored_fg, &prefs.gui_ignored_bg);
+ }
cf->displayed_count++;
}
}
}
+/*
+ * Ignore a particular frame.
+ */
+void
+cf_ignore_frame(capture_file *cf, frame_data *frame)
+{
+ if (! frame->flags.ignored) {
+ frame->flags.ignored = TRUE;
+ if (cf->count > cf->ignored_count)
+ cf->ignored_count++;
+ }
+}
+
+/*
+ * Un-ignore a particular frame.
+ */
+void
+cf_unignore_frame(capture_file *cf, frame_data *frame)
+{
+ if (frame->flags.ignored) {
+ frame->flags.ignored = FALSE;
+ if (cf->ignored_count > 0)
+ cf->ignored_count--;
+ }
+}
+
typedef struct {
wtap_dumper *pdh;
const char *fname;
*/
void cf_unmark_frame(capture_file *cf, frame_data *frame);
+/**
+ * Ignore a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be ignored
+ */
+void cf_ignore_frame(capture_file *cf, frame_data *frame);
+
+/**
+ * Unignore a particular frame in a particular capture.
+ *
+ * @param cf the capture file
+ * @param frame the frame to be unignored
+ */
+void cf_unignore_frame(capture_file *cf, frame_data *frame);
+
/**
* Convert error number and info to a complete message.
*
}
}
+/* ignore packet */
+static void
+set_frame_ignore(gboolean set, frame_data *frame, gint row)
+{
+ GdkColor fg, bg;
+
+ if (row == -1)
+ return;
+ if (set) {
+ cf_ignore_frame(&cfile, frame);
+ color_t_to_gdkcolor(&fg, &prefs.gui_ignored_fg);
+ color_t_to_gdkcolor(&bg, &prefs.gui_ignored_bg);
+ gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg);
+ gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg);
+ } else {
+ const color_filter_t *cfilter = frame->color_filter;
+
+ cf_unignore_frame(&cfile, frame);
+ /* Restore the color from the matching color filter if any */
+ if (cfilter) { /* The packet matches a color filter */
+ color_t_to_gdkcolor(&fg, &cfilter->fg_color);
+ color_t_to_gdkcolor(&bg, &cfilter->bg_color);
+ gtk_clist_set_foreground(GTK_CLIST(packet_list), row, &fg);
+ gtk_clist_set_background(GTK_CLIST(packet_list), row, &bg);
+ } else { /* No color filter match */
+ gtk_clist_set_foreground(GTK_CLIST(packet_list), row, NULL);
+ gtk_clist_set_background(GTK_CLIST(packet_list), row, NULL);
+ }
+ }
+}
+
/* call this after last set_frame_mark is done */
static void mark_frames_ready(void)
{
mark_all_frames(FALSE);
}
-#ifndef NEW_PACKET_LIST
+void packet_list_ignore_frame_cb(GtkWidget *w _U_, gpointer data _U_)
+{
+ if (cfile.current_frame) {
+ set_frame_ignore(!cfile.current_frame->flags.ignored,
+ cfile.current_frame, cfile.current_row);
+ redissect_packets();
+ }
+}
+
+void packet_list_update_ignored_frames(void)
+{
+ frame_data *fdata;
+
+ if (cfile.plist_start == NULL) return;
+
+ /* XXX: we might need a progressbar here */
+ for (fdata = cfile.plist_start; fdata != NULL; fdata = fdata->next) {
+ if (fdata->flags.ignored)
+ set_frame_ignore(TRUE, fdata,
+ gtk_clist_find_row_from_data(GTK_CLIST(packet_list),
+ fdata));
+ }
+ mark_frames_ready();
+}
+
gboolean
packet_list_get_event_row_column(GtkWidget *w, GdkEventButton *event_button,
gint *row, gint *column)
(gint) event_button->x, (gint) event_button->y,
row, column);
}
-#endif /* NEW_PACKET_LIST */
static gint
packet_list_button_pressed_cb(GtkWidget *w, GdkEvent *event, gpointer data _U_)
/** Update packet marks. */
extern void packet_list_update_marked_frames(void);
+/** Ignore the currently selected packet.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+extern void packet_list_ignore_frame_cb(GtkWidget *w _U_, gpointer data _U_);
+
+/** Update ignored packages. */
+extern void packet_list_update_ignored_frames(void);
+
/** Gdk button click appeared, get row and column number in packet list from that position.
*
* @param widget the packet list widget from packet_list_new()
if(cfile.drops_known) {
packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Dropped: %u",
cfile.count, cfile.displayed_count, cfile.marked_count, cfile.drops);
+ } else if (cfile.ignored_count > 0) {
+ packets_str = g_strdup_printf(" Packets: %u Displayed: %u Marked: %u Ignored: %u",
+ cfile.count, cfile.displayed_count, cfile.marked_count, cfile.ignored_count);
} else {
gulong computed_elapsed = cf_get_computed_elapsed();
{
#ifdef NEW_PACKET_LIST
{"/Mark Packet (toggle)", NULL, GTK_MENU_FUNC(new_packet_list_mark_frame_cb), 0, NULL, NULL,},
+ {"/Ignore Packet (toggle)", NULL, GTK_MENU_FUNC(new_packet_list_ignore_frame_cb), 0, NULL, NULL,},
#else
{"/Mark Packet (toggle)", NULL, GTK_MENU_FUNC(packet_list_mark_frame_cb), 0, NULL, NULL,},
+ {"/Ignore Packet (toggle)", NULL, GTK_MENU_FUNC(packet_list_ignore_frame_cb), 0, NULL, NULL,},
#endif /* NEW_PACKET_LIST */
{"/Set Time Reference (toggle)", NULL, GTK_MENU_FUNC(reftime_frame_cb), REFTIME_TOGGLE, "<StockItem>", WIRESHARK_STOCK_TIME,},
g_assert(cell_text);
- if((fdata->color_filter)||(fdata->flags.marked)){
+ if((fdata->color_filter)||(fdata->flags.marked)||(fdata->flags.ignored)){
gboolean color_on = enable_color;
GdkColor fg_gdk;
GdkColor bg_gdk;
- if(fdata->flags.marked){
+ if(fdata->flags.ignored){
+ color_t_to_gdkcolor(&fg_gdk, &prefs.gui_ignored_fg);
+ color_t_to_gdkcolor(&bg_gdk, &prefs.gui_ignored_bg);
+ color_on = TRUE;
+ }else if(fdata->flags.marked){
color_t_to_gdkcolor(&fg_gdk, &prefs.gui_marked_fg);
color_t_to_gdkcolor(&bg_gdk, &prefs.gui_marked_bg);
color_on = TRUE;
cf_unmark_frame(&cfile, fdata);
}
+static void
+set_frame_ignored(gboolean set, frame_data *fdata)
+{
+ if (set)
+ cf_ignore_frame(&cfile, fdata);
+ else
+ cf_unignore_frame(&cfile, fdata);
+}
+
static void mark_all_frames(gboolean set)
{
frame_data *fdata;
mark_frames_ready();
}
+void new_packet_list_ignore_frame_cb(GtkWidget *w _U_, gpointer data _U_)
+{
+ GtkTreeModel *model;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
+ PacketListRecord *record;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(packetlist->view));
+ /* model is filled with the current model as a convenience. */
+ gtk_tree_selection_get_selected(selection, &model, &iter);
+ record = new_packet_list_get_record(model, &iter);
+
+ set_frame_ignored(!record->fdata->flags.ignored, record->fdata);
+ redissect_packets();
+}
+
static gboolean
get_col_text_from_record( PacketListRecord *record, gint col_num, gchar** cell_text){
*/
extern void new_packet_list_mark_frame_cb(GtkWidget *widget, gpointer data);
+/** Mark all packets in the list.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
void new_packet_list_mark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_);
+
+/** Unmark all packets in the list.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
void new_packet_list_unmark_all_frames_cb(GtkWidget *w _U_, gpointer data _U_);
+/** Ignore the currently selected packet.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+extern void new_packet_list_ignore_frame_cb(GtkWidget *widget, gpointer data);
+
/* Different modes of copying summary data */
typedef enum {
CS_TEXT, /* Packet summary data (tab separated) */
#include "gtk/main_packet_list.h"
-#define SAMPLE_MARKED_TEXT "Sample marked packet text\n"
-#define SAMPLE_CLIENT_TEXT "Sample TCP stream client text\n"
-#define SAMPLE_SERVER_TEXT "Sample TCP stream server text\n"
+#define SAMPLE_MARKED_TEXT "Sample marked packet text\n"
+#define SAMPLE_IGNORED_TEXT "Sample ignored packet text\n"
+#define SAMPLE_CLIENT_TEXT "Sample TCP stream client text\n"
+#define SAMPLE_SERVER_TEXT "Sample TCP stream server text\n"
#define MFG_IDX 0
#define MBG_IDX 1
-#define CFG_IDX 2
-#define CBG_IDX 3
-#define SFG_IDX 4
-#define SBG_IDX 5
-#define MAX_IDX 6 /* set this to the number of IDX values */
+#define IFG_IDX 2
+#define IBG_IDX 3
+#define CFG_IDX 4
+#define CBG_IDX 5
+#define SFG_IDX 6
+#define SBG_IDX 7
+#define MAX_IDX 8 /* set this to the number of IDX values */
#define STREAM_SAMPLE_KEY "stream_entry"
#define STREAM_CS_KEY "stream_colorselection"
#define CS_RED 0
const gchar *mt[] = {
"Marked packet foreground", /* MFG_IDX 0*/
"Marked packet background", /* MBG_IDX 1*/
- "TCP stream client foreground", /* CFG_IDX 2*/
- "TCP stream client background", /* CBG_IDX 3*/
- "TCP stream server foreground", /* SFG_IDX 4*/
- "TCP stream server background" /* SBG_IDX 5*/
+ "Ignored packet foreground", /* IFG_IDX 2*/
+ "Ignored packet background", /* IBG_IDX 3*/
+ "TCP stream client foreground", /* CFG_IDX 4*/
+ "TCP stream client background", /* CBG_IDX 5*/
+ "TCP stream server foreground", /* SFG_IDX 6*/
+ "TCP stream server background" /* SBG_IDX 7*/
};
int mcount = sizeof(mt) / sizeof (gchar *);
GtkTextBuffer *buf;
color_t_to_gdkcolor(&tcolors[MFG_IDX], &prefs.gui_marked_fg);
color_t_to_gdkcolor(&tcolors[MBG_IDX], &prefs.gui_marked_bg);
+ color_t_to_gdkcolor(&tcolors[IFG_IDX], &prefs.gui_ignored_fg);
+ color_t_to_gdkcolor(&tcolors[IBG_IDX], &prefs.gui_ignored_bg);
color_t_to_gdkcolor(&tcolors[CFG_IDX], &prefs.st_client_fg);
color_t_to_gdkcolor(&tcolors[CBG_IDX], &prefs.st_client_bg);
color_t_to_gdkcolor(&tcolors[SFG_IDX], &prefs.st_server_fg);
gtk_text_buffer_create_tag(buf, "marked",
"foreground-gdk", &tcolors[MFG_IDX],
"background-gdk", &tcolors[MBG_IDX], NULL);
+ gtk_text_buffer_create_tag(buf, "ignored",
+ "foreground-gdk", &tcolors[IFG_IDX],
+ "background-gdk", &tcolors[IBG_IDX], NULL);
gtk_text_buffer_create_tag(buf, "client",
"foreground-gdk", &tcolors[CFG_IDX],
"background-gdk", &tcolors[CBG_IDX], NULL);
"background-gdk", &tcolors[SBG_IDX], NULL);
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_MARKED_TEXT, -1,
"marked", NULL);
+ gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_IGNORED_TEXT, -1,
+ "ignored", NULL);
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_CLIENT_TEXT, -1,
"client", NULL);
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_SERVER_TEXT, -1,
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buf), "marked");
g_object_set(tag, "foreground-gdk", &tcolors[MFG_IDX], "background-gdk",
&tcolors[MBG_IDX], NULL);
+ tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buf), "ignored");
+ g_object_set(tag, "foreground-gdk", &tcolors[IFG_IDX], "background-gdk",
+ &tcolors[IBG_IDX], NULL);
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buf), "client");
g_object_set(tag, "foreground-gdk", &tcolors[CFG_IDX], "background-gdk",
&tcolors[CBG_IDX], NULL);
{
gdkcolor_to_color_t(&prefs.gui_marked_fg, &tcolors[MFG_IDX]);
gdkcolor_to_color_t(&prefs.gui_marked_bg, &tcolors[MBG_IDX]);
+ gdkcolor_to_color_t(&prefs.gui_ignored_fg, &tcolors[IFG_IDX]);
+ gdkcolor_to_color_t(&prefs.gui_ignored_bg, &tcolors[IBG_IDX]);
gdkcolor_to_color_t(&prefs.st_client_fg, &tcolors[CFG_IDX]);
gdkcolor_to_color_t(&prefs.st_client_bg, &tcolors[CBG_IDX]);
gdkcolor_to_color_t(&prefs.st_server_fg, &tcolors[SFG_IDX]);
#ifndef NEW_PACKET_LIST
packet_list_update_marked_frames();
+ packet_list_update_ignored_frames();
#endif
}