aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/decode_as_dlg.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gtk/decode_as_dlg.c')
-rw-r--r--ui/gtk/decode_as_dlg.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/ui/gtk/decode_as_dlg.c b/ui/gtk/decode_as_dlg.c
index c38f686cd1..1d9d14780e 100644
--- a/ui/gtk/decode_as_dlg.c
+++ b/ui/gtk/decode_as_dlg.c
@@ -30,6 +30,8 @@
#include <epan/packet.h>
#include <epan/epan_dissect.h>
#include <epan/decode_as.h>
+#include <epan/prefs.h>
+#include <epan/prefs-int.h>
#include <epan/dissectors/packet-dcerpc.h>
#include "ui/decode_as_utils.h"
@@ -648,6 +650,7 @@ decode_simple (GtkWidget *notebook_pg)
gpointer ptr, value_ptr;
gint requested_index = 0;
gboolean add_reset_list = FALSE;
+ dissector_table_t sub_dissectors;
list = (GtkWidget *)g_object_get_data(G_OBJECT(notebook_pg), E_PAGE_LIST);
if (requested_action == E_DECODE_NO)
@@ -655,6 +658,7 @@ decode_simple (GtkWidget *notebook_pg)
entry = (decode_as_t *)g_object_get_data(G_OBJECT(notebook_pg), E_PAGE_DECODE_AS_DATA);
table_name = (gchar *)g_object_get_data(G_OBJECT(notebook_pg), E_PAGE_TABLE);
+ sub_dissectors = find_dissector_table(table_name);
/* (sub)dissector selection */
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
@@ -678,13 +682,65 @@ decode_simple (GtkWidget *notebook_pg)
/* Apply values to dissector table (stored in entry) */
for (value_loop = 0; value_loop < entry->values[requested_index].num_values; value_loop++)
{
+ pref_t* pref_value;
+ dissector_handle_t temp_handle;
+ module_t *module;
+
guint8 saved_curr_layer_num = cfile.edt->pi.curr_layer_num;
cfile.edt->pi.curr_layer_num = (guint8)GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(notebook_pg), E_PAGE_CURR_LAYER_NUM));
value_ptr = entry->values[requested_index].build_values[value_loop](&cfile.edt->pi);
if (abbrev != NULL && strcmp(abbrev, "(default)") == 0) {
+ /* Find the handle currently associated with the value */
+ temp_handle = dissector_get_uint_handle(sub_dissectors, GPOINTER_TO_UINT(value_ptr));
+
add_reset_list = entry->reset_value(table_name, value_ptr);
+
+ /* For now, only numeric dissector tables can use preferences */
+ if (IS_FT_UINT(dissector_table_get_type(sub_dissectors))) {
+ if (temp_handle != NULL) {
+ module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(temp_handle)));
+ pref_value = prefs_find_preference(module, table_name);
+ if (pref_value != NULL) {
+ module->prefs_changed = TRUE;
+ switch(pref_value->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ *pref_value->varp.uint = pref_value->default_val.uint;
+ break;
+ case PREF_DECODE_AS_RANGE:
+ range_remove_value(pref_value->varp.range, GPOINTER_TO_UINT(value_ptr));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
} else {
add_reset_list = entry->change_value(table_name, value_ptr, &handle, abbrev);
+
+ /* For now, only numeric dissector tables can use preferences */
+ if (IS_FT_UINT(dissector_table_get_type(sub_dissectors))) {
+ module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(handle)));
+ pref_value = prefs_find_preference(module, table_name);
+ if (pref_value != NULL) {
+ module->prefs_changed = TRUE;
+ switch(pref_value->type)
+ {
+ case PREF_DECODE_AS_UINT:
+ /* This doesn't support multiple values for a dissector in Decode As because the
+ preference only supports a single value. This leads to a "last port for
+ dissector in Decode As wins" */
+ *pref_value->varp.uint = GPOINTER_TO_UINT(value_ptr);
+ break;
+ case PREF_DECODE_AS_RANGE:
+ range_add_value(pref_value->varp.range, GPOINTER_TO_UINT(value_ptr));
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
cfile.edt->pi.curr_layer_num = saved_curr_layer_num;