Introduce "Remove Ignored packets" in Packet Range frames, which is used in
authorstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 26 Jan 2010 13:08:22 +0000 (13:08 +0000)
committerstig <stig@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 26 Jan 2010 13:08:22 +0000 (13:08 +0000)
Save As, Export and Print dialogs.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@31680 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/range_utils.c
packet-range.c
packet-range.h

index ccd83ecac86549ab368f6263f329d5012937597c..0a907109833d20b913a368b91469fb5d27ce20b8 100644 (file)
 #define RANGE_SELECT_USER_D_KEY         "range_select_user_range_d_lb"
 #define RANGE_SELECT_USER_ENTRY_KEY     "range_select_user_range_entry"
 
+#define RANGE_REMOVE_IGNORED_KEY        "range_remove_ignored"
+#define RANGE_IGNORED_C_KEY             "range_ignored_c_lb"
+#define RANGE_IGNORED_D_KEY             "range_ignored_d_lb"
+
 gboolean
 range_check_validity(packet_range_t *range)
 {
@@ -93,11 +97,11 @@ range_update_dynamics(gpointer data)
   gboolean      filtered_active;
   gint          selected_num;
   gboolean      can_select;
+  gboolean      selected_packets;
   gchar         label_text[100];
-
+  guint32       ignored_cnt = 0, displayed_ignored_cnt = 0;
 
   range = g_object_get_data(G_OBJECT(data), RANGE_VALUES_KEY);
-
   
   range_displayed_bt = g_object_get_data(G_OBJECT(data), RANGE_DISPLAYED_BT_KEY);
   filtered_active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(range_displayed_bt));
@@ -115,10 +119,18 @@ range_update_dynamics(gpointer data)
   }
 
   gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_ALL_C_KEY), !filtered_active);
-  g_snprintf(label_text, sizeof(label_text), "%u", cfile.count);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", cfile.count - range->ignored_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", cfile.count);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_ALL_C_KEY)), label_text);
   gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_ALL_D_KEY), filtered_active);
-  g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_cnt - range->displayed_ignored_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_ALL_D_KEY)), label_text);
 
   /* Enable saving the currently-selected packet only if there *is* a
@@ -142,18 +154,26 @@ range_update_dynamics(gpointer data)
   /* XXX: how to update the radio button label but keep the mnemonic? */
 /*g_snprintf(label_text, sizeof(label_text), "_Selected packet #%u only", selected_num);
   gtk_label_set_text(GTK_LABEL(GTK_BIN(select_curr_rb)->child), label_text);*/
-  g_snprintf(label_text, sizeof(label_text), "%u", selected_num ? 1 : 0);
+  if (range->remove_ignored && can_select && cfile.current_frame->flags.ignored) {
+    g_snprintf(label_text, sizeof(label_text), "0");
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", selected_num ? 1 : 0);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_CURR_C_KEY)), label_text);
-  g_snprintf(label_text, sizeof(label_text), "%u", selected_num ? 1 : 0);
+  if (range->remove_ignored && can_select && cfile.current_frame->flags.ignored) {
+    g_snprintf(label_text, sizeof(label_text), "0");
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", selected_num ? 1 : 0);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_CURR_D_KEY)), label_text);
 
   /* Enable the buttons for saving marked packets only if there *are*
      marked packets. */
   if (filtered_active)
-    can_select = (range->displayed_marked_cnt != 0);
+    selected_packets = (range->displayed_marked_cnt != 0);
   else
-    can_select = (cfile.marked_count > 0);
-  if (can_select) {
+    selected_packets = (cfile.marked_count > 0);
+  if (selected_packets) {
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_KEY), TRUE);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_C_KEY), !filtered_active);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_D_KEY), filtered_active);
@@ -168,18 +188,26 @@ range_update_dynamics(gpointer data)
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_C_KEY), FALSE);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_D_KEY), FALSE);
   }
-  g_snprintf(label_text, sizeof(label_text), "%u", cfile.marked_count);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", cfile.marked_count - range->ignored_marked_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", cfile.marked_count);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_C_KEY)), label_text);
-  g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_marked_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_marked_cnt - range->displayed_ignored_marked_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_marked_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_D_KEY)), label_text);
 
   /* Enable the buttons for saving the range of marked packets only if
      there *is* a range of marked packets. */
   if (filtered_active)
-    can_select = (range->displayed_mark_range_cnt != 0);
+    selected_packets = (range->displayed_mark_range_cnt != 0);
   else
-    can_select = (range->mark_range_cnt != 0);
-  if (can_select) {
+    selected_packets = (range->mark_range_cnt != 0);
+  if (selected_packets) {
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_KEY), TRUE);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_C_KEY), !filtered_active);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_D_KEY), filtered_active);
@@ -195,18 +223,78 @@ range_update_dynamics(gpointer data)
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_C_KEY), FALSE);
     gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_D_KEY), FALSE);
   }
-  g_snprintf(label_text, sizeof(label_text), "%u", range->mark_range_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->mark_range_cnt - range->ignored_mark_range_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->mark_range_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_C_KEY)), label_text);
-  g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_mark_range_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_mark_range_cnt - range->displayed_ignored_mark_range_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_mark_range_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_MARKED_RANGE_D_KEY)), label_text);
 
   gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_USER_KEY), TRUE);
   gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_USER_C_KEY), !filtered_active);
   gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_SELECT_USER_D_KEY), filtered_active);
-  g_snprintf(label_text, sizeof(label_text), "%u", range->user_range_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->user_range_cnt - range->ignored_user_range_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->user_range_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_USER_C_KEY)), label_text);
-  g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_user_range_cnt);
+  if (range->remove_ignored) {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_user_range_cnt - range->displayed_ignored_user_range_cnt);
+  } else {
+    g_snprintf(label_text, sizeof(label_text), "%u", range->displayed_user_range_cnt);
+  }
   gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_SELECT_USER_D_KEY)), label_text);
+
+  switch(range->process) {
+  case(range_process_all):
+    ignored_cnt = range->ignored_cnt;
+    displayed_ignored_cnt = range->displayed_ignored_cnt;
+    break;
+  case(range_process_selected):
+    ignored_cnt = (can_select && cfile.current_frame->flags.ignored) ? 1 : 0;
+    displayed_ignored_cnt = ignored_cnt;
+    break;
+  case(range_process_marked):
+    ignored_cnt = range->ignored_marked_cnt;
+    displayed_ignored_cnt = range->displayed_ignored_marked_cnt;
+    break;
+  case(range_process_marked_range):
+    ignored_cnt = range->ignored_mark_range_cnt;
+    displayed_ignored_cnt = range->displayed_ignored_mark_range_cnt;
+    break;
+  case(range_process_user_range):
+    ignored_cnt = range->ignored_user_range_cnt;
+    displayed_ignored_cnt = range->displayed_ignored_user_range_cnt;
+    break;
+  default:
+    g_assert_not_reached();
+  }
+
+  if (filtered_active)
+    selected_packets = (displayed_ignored_cnt != 0);
+  else
+    selected_packets = (ignored_cnt != 0);
+
+  if (selected_packets) {
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_REMOVE_IGNORED_KEY), TRUE);
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_C_KEY), !filtered_active);
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_D_KEY), filtered_active);
+  } else {
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_REMOVE_IGNORED_KEY), FALSE);
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_C_KEY), FALSE);
+    gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_D_KEY), FALSE);
+  }
+
+  g_snprintf(label_text, sizeof(label_text), "%u", ignored_cnt);
+  gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_C_KEY)), label_text);  g_snprintf(label_text, sizeof(label_text), "%u", displayed_ignored_cnt);
+  gtk_label_set_text(GTK_LABEL(g_object_get_data(G_OBJECT(data), RANGE_IGNORED_D_KEY)), label_text);
 }
 
 
@@ -337,6 +425,22 @@ toggle_select_user_range(GtkWidget *widget, gpointer data)
 
 }
 
+static void
+toggle_remove_ignored(GtkWidget *widget, gpointer data)
+{
+  packet_range_t *range;
+
+  range = g_object_get_data(G_OBJECT(data), RANGE_VALUES_KEY);
+  
+  /* is the button now active? */
+  if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget))) {
+    range->remove_ignored = TRUE;
+  } else {
+    range->remove_ignored = FALSE;
+  }
+
+  range_update_dynamics(data);
+}
 
 static void
 range_entry(GtkWidget *widget _U_, gpointer data)
@@ -398,6 +502,9 @@ GtkWidget *range_new(packet_range_t *range)
   GtkWidget     *select_user_range_c_lb;
   GtkWidget     *select_user_range_d_lb;
   GtkWidget     *select_user_range_entry;
+  GtkWidget     *remove_ignored_cb;
+  GtkWidget     *ignored_c_lb;
+  GtkWidget     *ignored_d_lb;
  
   GtkTooltips   *tooltips;
 
@@ -492,6 +599,16 @@ GtkWidget *range_new(packet_range_t *range)
   g_signal_connect(select_user_range_entry,"changed", G_CALLBACK(range_entry), range_tb);
   g_signal_connect(select_user_range_entry,"activate", G_CALLBACK(range_entry_in_event), range_tb);
 
+  /* Remove ignored packets */
+  remove_ignored_cb = gtk_check_button_new_with_mnemonic("Remove _Ignored packets");
+  gtk_table_attach_defaults(GTK_TABLE(range_tb), remove_ignored_cb, 0, 1, 7, 8);
+  gtk_tooltips_set_tip (tooltips,remove_ignored_cb,("Remove all packets marked as Ignored"), NULL);
+  g_signal_connect(remove_ignored_cb, "toggled", G_CALLBACK(toggle_remove_ignored), range_tb);
+
+  ignored_c_lb = gtk_label_new("?");
+  gtk_table_attach_defaults(GTK_TABLE(range_tb), ignored_c_lb, 1, 2, 7, 8);
+  ignored_d_lb = gtk_label_new("?");
+  gtk_table_attach_defaults(GTK_TABLE(range_tb), ignored_d_lb, 2, 3, 7, 8);
 
   gtk_widget_show_all(range_tb);
 
@@ -519,6 +636,10 @@ GtkWidget *range_new(packet_range_t *range)
   g_object_set_data(G_OBJECT(range_tb), RANGE_SELECT_USER_D_KEY,        select_user_range_d_lb);
   g_object_set_data(G_OBJECT(range_tb), RANGE_SELECT_USER_ENTRY_KEY,    select_user_range_entry);
 
+  g_object_set_data(G_OBJECT(range_tb), RANGE_REMOVE_IGNORED_KEY,       remove_ignored_cb);
+  g_object_set_data(G_OBJECT(range_tb), RANGE_IGNORED_C_KEY,            ignored_c_lb);
+  g_object_set_data(G_OBJECT(range_tb), RANGE_IGNORED_D_KEY,            ignored_d_lb);
+
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(captured_bt), !range->process_filtered);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(displayed_bt), range->process_filtered);
 
index 12b4454b5bc452d6eeca7ccad18b577587ad7328..e6838f62f7ca810f67854db7c90b4f8dd4f0a656 100644 (file)
@@ -56,12 +56,20 @@ static void packet_range_calc(packet_range_t *range) {
   mark_low                      = 0L;
   mark_high                     = 0L;
   range->mark_range_cnt         = 0L;
+  range->ignored_cnt            = 0L;
+  range->ignored_marked_cnt     = 0L;
+  range->ignored_mark_range_cnt = 0L;
+  range->ignored_user_range_cnt = 0L;
 
   displayed_mark_low            = 0L;
   displayed_mark_high           = 0L;
   range->displayed_cnt          = 0L;
   range->displayed_marked_cnt   = 0L;
   range->displayed_mark_range_cnt=0L;
+  range->displayed_ignored_cnt            = 0L;
+  range->displayed_ignored_marked_cnt     = 0L;
+  range->displayed_ignored_mark_range_cnt = 0L;
+  range->displayed_ignored_user_range_cnt = 0L;
 
   /* The next for-loop is used to obtain the amount of packets to be processed
    * and is used to present the information in the Save/Print As widget.
@@ -81,8 +89,14 @@ static void packet_range_calc(packet_range_t *range) {
           range->displayed_cnt++;
       }
       if (packet->flags.marked) {
+            if (packet->flags.ignored) {
+                range->ignored_marked_cnt++;
+            }
             if (packet->flags.passed_dfilter) {
                 range->displayed_marked_cnt++;
+                if (packet->flags.ignored) {
+                    range->displayed_ignored_marked_cnt++;
+                }
                 if (displayed_mark_low == 0) {
                    displayed_mark_low = current_count;
                 }
@@ -98,6 +112,12 @@ static void packet_range_calc(packet_range_t *range) {
                mark_high = current_count;
             }
       }
+      if (packet->flags.ignored) {
+          range->ignored_cnt++;
+          if (packet->flags.passed_dfilter) {
+              range->displayed_ignored_cnt++;
+          }
+      }
   }
 
   current_count = 0;
@@ -108,6 +128,9 @@ static void packet_range_calc(packet_range_t *range) {
           current_count <= mark_high)
       {
           range->mark_range_cnt++;
+          if (packet->flags.ignored) {
+              range->ignored_mark_range_cnt++;
+          }
       }
 
       if (current_count >= displayed_mark_low &&
@@ -115,6 +138,9 @@ static void packet_range_calc(packet_range_t *range) {
       {
           if (packet->flags.passed_dfilter) {
             range->displayed_mark_range_cnt++;
+            if (packet->flags.ignored) {
+                range->displayed_ignored_mark_range_cnt++;
+            }
           }
       }
   }
@@ -137,7 +163,9 @@ static void packet_range_calc_user(packet_range_t *range) {
   frame_data    *packet;
 
   range->user_range_cnt             = 0L;
+  range->ignored_user_range_cnt     = 0L;
   range->displayed_user_range_cnt   = 0L;
+  range->displayed_ignored_user_range_cnt = 0L;
 
   current_count = 0;
   for(packet = cfile.plist_start; packet != NULL; packet = packet->next) {
@@ -145,8 +173,14 @@ static void packet_range_calc_user(packet_range_t *range) {
 
       if (value_is_in_range(range->user_range, current_count)) {
           range->user_range_cnt++;
+          if (packet->flags.ignored) {
+              range->ignored_user_range_cnt++;
+          }
           if (packet->flags.passed_dfilter) {
             range->displayed_user_range_cnt++;
+            if (packet->flags.ignored) {
+                range->displayed_ignored_user_range_cnt++;
+            }
           }
       }
   }
@@ -158,6 +192,7 @@ void packet_range_init(packet_range_t *range) {
 
   range->process            = range_process_all;
   range->process_filtered   = FALSE;
+  range->remove_ignored     = FALSE;
   range->user_range         = range_empty();
 
   /* calculate all packet range counters */
@@ -190,12 +225,16 @@ void packet_range_process_init(packet_range_t *range) {
 
 /* do we have to process all packets? */
 gboolean packet_range_process_all(packet_range_t *range) {
-    return range->process == range_process_all && !range->process_filtered;
+    return range->process == range_process_all && !range->process_filtered && !range->remove_ignored;
 }
 
 /* do we have to process this packet? */
 range_process_e packet_range_process_packet(packet_range_t *range, frame_data *fdata) {
 
+    if (range->remove_ignored && fdata->flags.ignored) {
+        return range_process_next;
+    }
+
     switch(range->process) {
     case(range_process_all):
         break;
@@ -268,7 +307,9 @@ void packet_range_convert_str(packet_range_t *range, const gchar *es)
         range->user_range                 = NULL;
         range->user_range_status          = ret;
         range->user_range_cnt             = 0L;
+        range->ignored_user_range_cnt     = 0L;
         range->displayed_user_range_cnt   = 0L;
+        range->displayed_ignored_user_range_cnt = 0L;
         return;
     }
     range->user_range = new_range;
index 3b970f50fa30ab116cf909c1ef52470393d26f15..0a00af2e2e63e1406de6aba341d794407de5c3f8 100644 (file)
@@ -48,6 +48,7 @@ typedef struct packet_range_tag {
     /* values coming from the UI */
     packet_range_e  process;            /* which range to process */
     gboolean        process_filtered;   /* captured or filtered packets */
+    gboolean        remove_ignored;     /* remove ignored packets */
 
     /* user specified range(s) and, if null, error status */
     range_t         *user_range;
@@ -61,12 +62,20 @@ typedef struct packet_range_tag {
     /* cfile.marked_count */        /* packets marked */
     guint32  mark_range_cnt;        /* packets in marked range */
     guint32  user_range_cnt;        /* packets in user specified range */
+    guint32  ignored_cnt;           /* packets ignored */
+    guint32  ignored_marked_cnt;    /* packets ignored and marked */
+    guint32  ignored_mark_range_cnt;/* packets ignored in marked range */
+    guint32  ignored_user_range_cnt;/* packets ignored in user specified range */
 
     /* current packet counts (displayed) */
     guint32  displayed_cnt;
     guint32  displayed_marked_cnt;
     guint32  displayed_mark_range_cnt;
     guint32  displayed_user_range_cnt;
+    guint32  displayed_ignored_cnt;
+    guint32  displayed_ignored_marked_cnt;
+    guint32  displayed_ignored_mark_range_cnt;
+    guint32  displayed_ignored_user_range_cnt;
 
     /* "enumeration" values */
     gboolean marked_range_active;   /* marked range is currently processed */