aboutsummaryrefslogtreecommitdiffstats
path: root/epan/print.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-03-19 20:59:42 -0400
committerAnders Broman <a.broman58@gmail.com>2015-03-20 05:30:52 +0000
commite7fd1bfdf75a76c1d39f9ba809a40e3c0859c7fa (patch)
treeba351512fefa11a51d9fa23a9ee1ccd9865269be /epan/print.c
parent019c3af0b1a1720a83b3b174649ba8837156ce09 (diff)
Reduce epan dependence on dissectors by having print module "cache" the protocol and field ids that it needs.
Change-Id: I4ec48067e9ca2cbe88e1cf2e6c9dc1e382379221 Reviewed-on: https://code.wireshark.org/review/7767 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/print.c')
-rw-r--r--epan/print.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/epan/print.c b/epan/print.c
index 66946ec9da..8072f8393c 100644
--- a/epan/print.c
+++ b/epan/print.c
@@ -35,8 +35,6 @@
#include <epan/packet-range.h>
#include <epan/print.h>
#include <epan/charsets.h>
-#include <epan/dissectors/packet-data.h>
-#include <epan/dissectors/packet-frame.h>
#include <wsutil/filesystem.h>
#include <wsutil/ws_version_info.h>
#include <ftypes/ftypes-int.h>
@@ -93,6 +91,25 @@ static void print_pdml_geninfo(proto_tree *tree, FILE *fh);
static void proto_tree_get_node_field_values(proto_node *node, gpointer data);
+/* Cache the protocols and field handles that the print functionality needs
+ This helps break explicit dependency on the dissectors. */
+static int proto_data = -1;
+static int proto_frame = -1;
+static int hf_frame_arrival_time = -1;
+static int hf_frame_number = -1;
+static int hf_frame_len = -1;
+static int hf_frame_capture_len = -1;
+
+void print_cache_field_handles(void)
+{
+ proto_data = proto_get_id_by_short_name("Data");
+ proto_frame = proto_get_id_by_short_name("Frame");
+ hf_frame_arrival_time = proto_registrar_get_id_byname("frame.time");
+ hf_frame_number = proto_registrar_get_id_byname("frame.number");
+ hf_frame_len = proto_registrar_get_id_byname("frame.len");
+ hf_frame_capture_len = proto_registrar_get_id_byname("frame.cap_len");
+}
+
gboolean
proto_tree_print(print_args_t *print_args, epan_dissect_t *edt,
GHashTable *output_only_tables, print_stream_t *stream)