aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-data.c
diff options
context:
space:
mode:
authorBalint Reczey <balint.reczey@ericsson.com>2009-06-29 22:22:30 +0000
committerBalint Reczey <balint.reczey@ericsson.com>2009-06-29 22:22:30 +0000
commitaa2c87df8791a94f397ce219ca1c8481be626897 (patch)
tree089563a5b5c258c2e0e285f95afab8e613f57bf6 /epan/dissectors/packet-data.c
parentec28353bb47918e45e37291d83c191ef0196e68a (diff)
Added option to show not dissected packet data on a separate packet bytes pane.
It makes offsets in the not dissected data easier to follow. svn path=/trunk/; revision=28885
Diffstat (limited to 'epan/dissectors/packet-data.c')
-rw-r--r--epan/dissectors/packet-data.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/epan/dissectors/packet-data.c b/epan/dissectors/packet-data.c
index 27d49b3638..73e382fd59 100644
--- a/epan/dissectors/packet-data.c
+++ b/epan/dissectors/packet-data.c
@@ -29,6 +29,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include <epan/prefs.h>
#include "packet-data.h"
/* proto_data cannot be static because it's referenced in the
@@ -38,9 +39,12 @@ int proto_data = -1;
static int hf_data_data = -1;
static int hf_data_len = -1;
+static gboolean hf_pref_data_new_pane = FALSE;
static gint ett_data = -1;
+void proto_reg_handoff_data(void);
+
static void
dissect_data(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
{
@@ -49,15 +53,26 @@ dissect_data(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
if (tree) {
bytes = tvb_length_remaining(tvb, 0);
if (bytes > 0) {
- proto_item *ti = proto_tree_add_protocol_format(tree, proto_data, tvb,
+ tvbuff_t *data_tvb;
+ proto_item *ti;
+ proto_tree *data_tree;
+ if (hf_pref_data_new_pane) {
+ guint8 *real_data = tvb_memdup(tvb, 0, bytes);
+ data_tvb = tvb_new_child_real_data(tvb,real_data,bytes,bytes);
+ tvb_set_free_cb(data_tvb, g_free);
+ add_new_data_source(pinfo, data_tvb, "Not dissected data bytes");
+ } else {
+ data_tvb = tvb;
+ }
+ ti = proto_tree_add_protocol_format(tree, proto_data, tvb,
0,
bytes, "Data (%d byte%s)", bytes,
plurality(bytes, "", "s"));
- proto_tree *data_tree = proto_item_add_subtree(ti, ett_data);
+ data_tree = proto_item_add_subtree(ti, ett_data);
- proto_tree_add_item(data_tree, hf_data_data, tvb, 0, bytes, FALSE);
+ proto_tree_add_item(data_tree, hf_data_data, data_tvb, 0, bytes, FALSE);
- ti = proto_tree_add_int(data_tree, hf_data_len, tvb, 0, 0, bytes);
+ ti = proto_tree_add_int(data_tree, hf_data_len, data_tvb, 0, 0, bytes);
PROTO_ITEM_SET_GENERATED (ti);
}
}
@@ -76,7 +91,9 @@ proto_register_data(void)
static gint *ett[] = {
&ett_data
};
-
+
+ module_t *module_data;
+
proto_data = proto_register_protocol (
"Data", /* name */
"Data", /* short name */
@@ -87,10 +104,21 @@ proto_register_data(void)
proto_register_field_array(proto_data, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
-
+
+ module_data = prefs_register_protocol( proto_data, proto_reg_handoff_data);
+ prefs_register_bool_preference(module_data,
+ "datapref.newpane",
+ "Show not dissected data on new Packet Bytes pane",
+ "Show not dissected data on new Packet Bytes pane",
+ &hf_pref_data_new_pane);
/*
* "Data" is used to dissect something whose normal dissector
* is disabled, so it cannot itself be disabled.
*/
proto_set_cant_toggle(proto_data);
}
+
+void
+proto_reg_handoff_data(void)
+{
+}