aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/menu.c7
-rw-r--r--gtk/proto_dlg.c96
-rw-r--r--gtk/proto_dlg.h7
3 files changed, 90 insertions, 20 deletions
diff --git a/gtk/menu.c b/gtk/menu.c
index b741c74917..b66d4b973e 100644
--- a/gtk/menu.c
+++ b/gtk/menu.c
@@ -1048,6 +1048,7 @@ static GtkItemFactoryEntry tree_view_menu_items[] =
0, NULL, NULL),
ITEM_FACTORY_ENTRY("/<separator>", NULL, NULL, 0, "<Separator>", NULL),
ITEM_FACTORY_STOCK_ENTRY("/Decode As...", NULL, decode_as_cb, 0, WIRESHARK_STOCK_DECODE_AS),
+ ITEM_FACTORY_STOCK_ENTRY("/Disable Protocol...", NULL, proto_disable_cb, 0, WIRESHARK_STOCK_CHECKBOX),
ITEM_FACTORY_ENTRY("/_Resolve Name", NULL, resolve_name_cb, 0, NULL, NULL),
ITEM_FACTORY_ENTRY("/_Go to Corresponding Packet", NULL, goto_framenum_cb, 0, NULL, NULL),
};
@@ -2809,14 +2810,17 @@ void
set_menus_for_selected_tree_row(capture_file *cf)
{
gboolean properties;
+ gint id;
if (cf->finfo_selected != NULL) {
header_field_info *hfinfo = cf->finfo_selected->hfinfo;
if (hfinfo->parent == -1) {
properties = prefs_is_registered_protocol(hfinfo->abbrev);
+ id = proto_get_id((protocol_t *)hfinfo->strings);
} else {
properties = prefs_is_registered_protocol(proto_registrar_get_abbrev(hfinfo->parent));
+ id = hfinfo->parent;
}
set_menu_sensitivity(main_menu_factory,
"/File/Export/Selected Packet Bytes...", TRUE);
@@ -2842,6 +2846,8 @@ set_menus_for_selected_tree_row(capture_file *cf)
proto_can_match_selected(cf->finfo_selected, cf->edt));
set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...",
properties);
+ set_menu_sensitivity(tree_view_menu_factory, "/Disable Protocol...",
+ proto_can_toggle_protocol(id));
set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", cf->finfo_selected->tree_type != -1);
set_menu_sensitivity(tree_view_menu_factory, "/Expand Subtrees", cf->finfo_selected->tree_type != -1);
set_menu_sensitivity(tree_view_menu_factory, "/Wiki Protocol Page",
@@ -2864,6 +2870,7 @@ set_menus_for_selected_tree_row(capture_file *cf)
set_menu_sensitivity(tree_view_menu_factory, "/Colorize with Filter", FALSE);
set_menu_sensitivity(tree_view_menu_factory, "/Protocol Preferences...",
FALSE);
+ set_menu_sensitivity(tree_view_menu_factory, "/Disable Protocol...", FALSE);
set_menu_sensitivity(main_menu_factory, "/View/Expand Subtrees", FALSE);
set_menu_sensitivity(tree_view_menu_factory, "/Expand Subtrees", FALSE);
set_menu_sensitivity(tree_view_menu_factory, "/Wiki Protocol Page",
diff --git a/gtk/proto_dlg.c b/gtk/proto_dlg.c
index 6043d5f7c8..b49f16e4cb 100644
--- a/gtk/proto_dlg.c
+++ b/gtk/proto_dlg.c
@@ -130,12 +130,12 @@ proto_cb(GtkWidget *w _U_, gpointer data _U_)
gtk_widget_show(proto_frame);
/* Protocol list */
-
+
proto_vb = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(proto_frame), proto_vb);
gtk_container_border_width(GTK_CONTAINER(proto_vb), 5);
gtk_widget_show(proto_vb);
-
+
proto_sw = scrolled_window_new(NULL, NULL);
#if GTK_MAJOR_VERSION >= 2
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(proto_sw),
@@ -268,7 +268,7 @@ static void
proto_list_select_cb(GtkCList *proto_list, gint row, gint col,
GdkEventButton *ev _U_, gpointer gp _U_) {
protocol_data_t *p = gtk_clist_get_row_data(proto_list, row);
-
+
if (row < 0 || col < 0)
return;
@@ -283,7 +283,7 @@ proto_list_select_cb(GtkCList *proto_list, gint row, gint col,
static gboolean
proto_list_keypress_cb(GtkWidget *pl, GdkEventKey *ev, gpointer gp _U_) {
GtkCList *proto_list = GTK_CLIST(pl);
-
+
if (ev->keyval == GDK_space) {
proto_list_select_cb(proto_list, proto_list->focus_row, 0, NULL, gp);
}
@@ -334,7 +334,7 @@ toggle_all_cb(GtkWidget *button _U_, gpointer pl)
p->enabled = FALSE;
else
p->enabled = TRUE;
-
+
#if GTK_MAJOR_VERSION < 2
gtk_clist_set_text(proto_list, p->row, 0, STATUS_TXT(p->enabled) );
#else
@@ -360,7 +360,7 @@ set_active_all(GtkWidget *w, gboolean new_state)
#endif
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
protocol_data_t *p = entry->data;
-
+
p->enabled = new_state;
#if GTK_MAJOR_VERSION < 2
gtk_clist_set_text(proto_list, p->row, 0, STATUS_TXT(new_state) );
@@ -377,14 +377,14 @@ set_active_all(GtkWidget *w, gboolean new_state)
static void
enable_all_cb(GtkWidget *button _U_, gpointer pl)
{
- set_active_all(pl, TRUE);
+ set_active_all(pl, TRUE);
}
/* Disable All */
static void
disable_all_cb(GtkWidget *button _U_, gpointer pl)
{
- set_active_all(pl, FALSE);
+ set_active_all(pl, FALSE);
}
static void
@@ -393,7 +393,6 @@ proto_destroy_cb(GtkWidget *w _U_, gpointer data _U_)
GSList *entry;
proto_w = NULL;
-
/* remove protocol list */
if (protocol_list) {
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
@@ -416,7 +415,8 @@ proto_delete_event_cb(GtkWidget *proto_w, GdkEvent *event _U_,
return FALSE;
}
-static void proto_write(gpointer parent_w _U_)
+static void
+proto_write(gpointer parent_w _U_)
{
char *pf_dir_path;
char *pf_path;
@@ -553,20 +553,12 @@ protocol_data_compare(gconstpointer a, gconstpointer b)
}
static void
-#if GTK_MAJOR_VERSION < 2
-show_proto_selection(GtkCList *proto_list)
-#else
-show_proto_selection(GtkListStore *proto_store)
-#endif
+create_protocol_list(void)
{
- GSList *entry;
gint i;
void *cookie;
protocol_t *protocol;
protocol_data_t *p;
-#if GTK_MAJOR_VERSION < 2
- const gchar *proto_text[3];
-#endif
/* Iterate over all the protocols */
@@ -579,11 +571,28 @@ show_proto_selection(GtkListStore *proto_store)
p->abbrev = proto_get_protocol_short_name(protocol);
p->hfinfo_index = i;
p->enabled = proto_is_protocol_enabled(protocol);
- p->was_enabled = p->enabled;
+ p->was_enabled = p->enabled;
protocol_list = g_slist_insert_sorted(protocol_list,
p, protocol_data_compare);
}
}
+}
+
+static void
+#if GTK_MAJOR_VERSION < 2
+show_proto_selection(GtkCList *proto_list)
+#else
+show_proto_selection(GtkListStore *proto_store)
+#endif
+{
+ GSList *entry;
+ protocol_data_t *p;
+#if GTK_MAJOR_VERSION < 2
+ const gchar *proto_text[3];
+#endif
+
+ if (protocol_list == NULL)
+ create_protocol_list();
for (entry = protocol_list; entry != NULL; entry = g_slist_next(entry)) {
p = entry->data;
@@ -611,3 +620,50 @@ show_proto_selection(GtkListStore *proto_store)
}
} /* show_proto_selection */
+
+static void
+proto_disable_dialog_cb(gpointer dialog _U_, gint btn, gpointer data)
+{
+ protocol_t *protocol;
+ gint id = GPOINTER_TO_INT(data);
+
+ if (btn == ESD_BTN_OK) {
+ /* Allow proto_dlg to work with the original settings */
+ if (protocol_list == NULL)
+ create_protocol_list();
+ /* Toggle the protocol if it's enabled and allowed */
+ protocol = find_protocol_by_id(id);
+ if (proto_is_protocol_enabled(protocol) == TRUE) {
+ if (proto_can_toggle_protocol(id) == TRUE) {
+ proto_set_decoding(id, FALSE);
+ cf_redissect_packets(&cfile);
+ }
+ }
+ }
+}
+
+void
+proto_disable_cb(GtkWidget *w _U_, gpointer data _U_)
+{
+ header_field_info *hfinfo;
+ gint id;
+ gpointer dialog;
+
+ if (cfile.finfo_selected == NULL) {
+ /* There is no field selected */
+ return;
+ }
+
+ /* Find the id for the protocol for the selected field. */
+ hfinfo = cfile.finfo_selected->hfinfo;
+ if (hfinfo->parent == -1)
+ id = proto_get_id((protocol_t *)hfinfo->strings);
+ else
+ id = hfinfo->parent;
+
+ dialog = simple_dialog(ESD_TYPE_CONFIRMATION, ESD_BTNS_OK_CANCEL,
+ "Do you want to temporarily disable protocol: %s ?",
+ proto_registrar_get_abbrev(id));
+
+ simple_dialog_set_cb(dialog, proto_disable_dialog_cb, GINT_TO_POINTER(id));
+}
diff --git a/gtk/proto_dlg.h b/gtk/proto_dlg.h
index 2d37814014..a636a16bdb 100644
--- a/gtk/proto_dlg.h
+++ b/gtk/proto_dlg.h
@@ -39,4 +39,11 @@
*/
void proto_cb(GtkWidget *widget, gpointer data);
+/** Disable (temporarily) the selected protocol.
+ *
+ * @param widget parent widget (unused)
+ * @param data unused
+ */
+void proto_disable_cb(GtkWidget *widget, gpointer data);
+
#endif