aboutsummaryrefslogtreecommitdiffstats
path: root/epan
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
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')
-rw-r--r--epan/dissectors/Makefile.common1
-rw-r--r--epan/dissectors/packet-data.c1
-rw-r--r--epan/dissectors/packet-data.h33
-rw-r--r--epan/dissectors/packet-frame.c10
-rw-r--r--epan/dissectors/packet-frame.h9
-rw-r--r--epan/epan.c2
-rw-r--r--epan/print.c21
-rw-r--r--epan/print.h2
8 files changed, 28 insertions, 51 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common
index 0f10691728..fe8cdd89f8 100644
--- a/epan/dissectors/Makefile.common
+++ b/epan/dissectors/Makefile.common
@@ -1432,7 +1432,6 @@ DISSECTOR_INCLUDES = \
packet-crmf.h \
packet-csn1.h \
packet-dap.h \
- packet-data.h \
packet-dcc.h \
packet-dccp.h \
packet-dcerpc.h \
diff --git a/epan/dissectors/packet-data.c b/epan/dissectors/packet-data.c
index 3dc21aac19..c28b6cc5b1 100644
--- a/epan/dissectors/packet-data.c
+++ b/epan/dissectors/packet-data.c
@@ -29,7 +29,6 @@
#include <epan/prefs.h>
#include <epan/to_str.h>
#include <wsutil/md5.h>
-#include "packet-data.h"
/* proto_data cannot be static because it's referenced in the
* print routines
diff --git a/epan/dissectors/packet-data.h b/epan/dissectors/packet-data.h
deleted file mode 100644
index 5ac3668487..0000000000
--- a/epan/dissectors/packet-data.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* packet-data.h
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __PACKET_DATA_H__
-#define __PACKET_DATA_H__
-
-#include "ws_symbol_export.h"
-
-/*
- "proto_data" is exported from libwireshark.dll.
- * Thus we need a special declaration.
- */
-WS_DLL_PUBLIC int proto_data;
-
-#endif /* __PACKET_DATA_H__ */
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index f7f47d86a3..3781ec32a6 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -48,18 +48,18 @@
void proto_register_frame(void);
void proto_reg_handoff_frame(void);
-int proto_frame = -1;
+static int proto_frame = -1;
static int proto_pkt_comment = -1;
-int hf_frame_arrival_time = -1;
+static int hf_frame_arrival_time = -1;
static int hf_frame_shift_offset = -1;
static int hf_frame_arrival_time_epoch = -1;
static int hf_frame_time_delta = -1;
static int hf_frame_time_delta_displayed = -1;
static int hf_frame_time_relative = -1;
static int hf_frame_time_reference = -1;
-int hf_frame_number = -1;
-int hf_frame_len = -1;
-int hf_frame_capture_len = -1;
+static int hf_frame_number = -1;
+static int hf_frame_len = -1;
+static int hf_frame_capture_len = -1;
static int hf_frame_p2p_dir = -1;
static int hf_frame_file_off = -1;
static int hf_frame_md5_hash = -1;
diff --git a/epan/dissectors/packet-frame.h b/epan/dissectors/packet-frame.h
index c6bc2a5005..899ab7a9ad 100644
--- a/epan/dissectors/packet-frame.h
+++ b/epan/dissectors/packet-frame.h
@@ -35,12 +35,3 @@ register_frame_end_routine(packet_info *pinfo, void (*func)(void));
* The frame dissector and the PPI dissector both use this
*/
extern dissector_table_t wtap_encap_dissector_table;
-
-/* following variables are exported from libwireshark.dll.
- * Thus we need a special declaration.
- */
-WS_DLL_PUBLIC int proto_frame;
-WS_DLL_PUBLIC int hf_frame_arrival_time;
-WS_DLL_PUBLIC int hf_frame_number;
-WS_DLL_PUBLIC int hf_frame_len;
-WS_DLL_PUBLIC int hf_frame_capture_len;
diff --git a/epan/epan.c b/epan/epan.c
index 50cd80b7bc..4fb797dbd7 100644
--- a/epan/epan.c
+++ b/epan/epan.c
@@ -47,6 +47,7 @@
#include "oids.h"
#include "wmem/wmem.h"
#include "expert.h"
+#include "print.h"
#ifdef HAVE_LUA
#include <lua.h>
@@ -118,6 +119,7 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
packet_cache_proto_handles();
dfilter_init();
final_registration_all_protocols();
+ print_cache_field_handles();
expert_packet_init();
#ifdef HAVE_LUA
wslua_init(cb, client_data);
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)
diff --git a/epan/print.h b/epan/print.h
index 95bc6a9da2..334de3a29b 100644
--- a/epan/print.h
+++ b/epan/print.h
@@ -123,6 +123,8 @@ WS_DLL_PUBLIC void write_fields_finale(output_fields_t* fields, FILE *fh);
WS_DLL_PUBLIC gchar* get_node_field_value(field_info* fi, epan_dissect_t* edt);
+extern void print_cache_field_handles(void);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */