summaryrefslogtreecommitdiff
path: root/epan/epan.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-21 01:11:41 -0500
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-02-25 21:06:50 +0000
commitbd36fe1bcbe19dd1b63836cc60d7351d7d8b4aa8 (patch)
treeb70a11dd3fc984900da52bd3bdfd1b40f56b29ac /epan/epan.c
parent860747e1e78aefdaf31e77408ad590b9d759d1aa (diff)
downloadwireshark-bd36fe1bcbe19dd1b63836cc60d7351d7d8b4aa8.tar.gz
Fix bug 6357: Lua all_field_infos() broken within tap/listener
The current API for Lua provides a global function "all_field_infos()" which returns all the populated field_info nodes in the current proto_tree. By default all_field_infos() "works", in the literal sense: it returns exactly the fields the previous dissectors of the packet have populated at that instant of time. But of course dissectors don't populate all the applicable fields most of the time, because of the TRY_TO_FAKE_THIS_ITEM optimization where they don't fill in things that aren't needed at the time by a display, color, or tap's dfilter. So this commit offers a way to force the dissectors to populate all the applicable field_infos in the tree, by setting the proto_tree to be visible. Obviously that is going to impact performance, since it basically bypasses the TRY_TO_FAKE_THIS_ITEM optimization; so the patch only does this if the Lua script author told it to explicitly, by adding an argument to Listener.new() and register_postdissector(). Change-Id: I11d3559fbe8c14fbadf1b51415a3701dc1200b7b Reviewed-on: https://code.wireshark.org/review/286 Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/epan.c')
-rw-r--r--epan/epan.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/epan/epan.c b/epan/epan.c
index 2a9533fc89..85c09ab474 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -229,6 +229,21 @@ epan_circuit_cleanup(void)
circuit_cleanup();
}
+/* Overrides proto_tree_visible i epan_dissect_init to make all fields visible.
+ * This is > 0 if a Lua script wanted to see all fields all the time.
+ * This is ref-counted, so clearing it won't override other taps/scripts wanting it.
+ */
+static gint always_visible_refcount = 0;
+
+void
+epan_set_always_visible(gboolean force)
+{
+ if (force)
+ always_visible_refcount++;
+ else if (always_visible_refcount > 0)
+ always_visible_refcount--;
+}
+
epan_dissect_t*
epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_proto_tree, const gboolean proto_tree_visible)
{
@@ -247,7 +262,7 @@ epan_dissect_init(epan_dissect_t *edt, epan_t *session, const gboolean create_pr
if (create_proto_tree) {
edt->tree = proto_tree_create_root(&edt->pi);
- proto_tree_set_visible(edt->tree, proto_tree_visible);
+ proto_tree_set_visible(edt->tree, (always_visible_refcount > 0) ? TRUE : proto_tree_visible);
}
else {
edt->tree = NULL;