summaryrefslogtreecommitdiff
path: root/ui/qt/decode_as_dialog.cpp
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-10-07 16:25:01 -0400
committerMichael Mann <mmann78@netscape.net>2016-10-08 02:44:53 +0000
commit268841f3e00b7cf0f16c81dd2b3b952172130b8b (patch)
tree359e01cf5eba83308760531888713fe0ff0bc10b /ui/qt/decode_as_dialog.cpp
parent11d3224142c0531879fb8e415daf9639a4eace66 (diff)
downloadwireshark-268841f3e00b7cf0f16c81dd2b3b952172130b8b.tar.gz
Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for a (TCP) port, but the underlying data is actually part of Decode As functionality. For now the APIs are intentionally separate from the regular APIs that register a dissector within a dissector table. It may be possible to eventually combine the two so that all dissectors that register with a dissector table have an opportunity to "automatically" have a preference to adjust the "table value" through the preferences dialog. The tcp.port dissector table was used as the guinea pig. This will eventually be expanded to other dissector tables as well (most notably UDP ports). Some dissectors that "shared" a TCP/UDP port preference were also converted. It also removed the need for some preference callback functions (mostly when the callback function was the proto_reg_handoff function) so there is cleanup around that. Dissectors that has a port preference whose default was 0 were switched to using the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference Also added comments for TCP ports used that aren't IANA registered. Change-Id: I99604f95d426ad345f4b494598d94178b886eb67 Reviewed-on: https://code.wireshark.org/review/17724 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui/qt/decode_as_dialog.cpp')
-rw-r--r--ui/qt/decode_as_dialog.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp
index ce59057616..139914076b 100644
--- a/ui/qt/decode_as_dialog.cpp
+++ b/ui/qt/decode_as_dialog.cpp
@@ -25,6 +25,8 @@
#include "epan/decode_as.h"
#include "epan/dissectors/packet-dcerpc.h"
#include "epan/epan_dissect.h"
+#include "epan/prefs.h"
+#include "epan/prefs-int.h"
#include "ui/decode_as_utils.h"
#include "ui/simple_dialog.h"
@@ -601,6 +603,9 @@ void DecodeAsDialog::applyChanges()
if (!g_strcmp0(decode_as_entry->table_name, ui_name_to_name_[item->text(table_col_)])) {
gpointer selector_value;
QByteArray byteArray;
+ module_t *module;
+ pref_t* pref_value;
+ dissector_table_t sub_dissectors;
switch (selector_type) {
case FT_UINT8:
@@ -622,9 +627,56 @@ void DecodeAsDialog::applyChanges()
if (item->text(proto_col_) == DECODE_AS_NONE || !dissector_info->dissector_handle) {
decode_as_entry->reset_value(decode_as_entry->table_name, selector_value);
+ sub_dissectors = find_dissector_table(decode_as_entry->table_name);
+
+ /* For now, only numeric dissector tables can use preferences */
+ if (IS_FT_UINT(dissector_table_get_type(sub_dissectors))) {
+ if (dissector_info->dissector_handle != NULL) {
+ module = prefs_find_module(proto_get_protocol_filter_name(dissector_handle_get_protocol_index(dissector_info->dissector_handle)));
+ pref_value = prefs_find_preference(module, decode_as_entry->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(selector_value));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
break;
} else {
decode_as_entry->change_value(decode_as_entry->table_name, selector_value, &dissector_info->dissector_handle, (char *) item->text(proto_col_).toUtf8().constData());
+ sub_dissectors = find_dissector_table(decode_as_entry->table_name);
+
+ /* 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(dissector_info->dissector_handle)));
+ pref_value = prefs_find_preference(module, decode_as_entry->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(selector_value);
+ break;
+ case PREF_DECODE_AS_RANGE:
+ range_add_value(pref_value->varp.range, GPOINTER_TO_UINT(selector_value));
+ break;
+ default:
+ break;
+ }
+ }
+ }
break;
}
}