Reduce epan dependence on dissectors by having print module "cache" the protocol...
authorMichael Mann <mmann78@netscape.net>
Fri, 20 Mar 2015 00:59:42 +0000 (20:59 -0400)
committerAnders Broman <a.broman58@gmail.com>
Fri, 20 Mar 2015 05:30:52 +0000 (05:30 +0000)
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>
debian/libwireshark0.symbols
epan/dissectors/Makefile.common
epan/dissectors/packet-data.c
epan/dissectors/packet-data.h [deleted file]
epan/dissectors/packet-frame.c
epan/dissectors/packet-frame.h
epan/epan.c
epan/print.c
epan/print.h
file.c

index f6aae54821ce548247a652a4e3ebd2df123371ef..20bef859c0ca47687b913572cd886f394c2cca2b 100644 (file)
@@ -712,10 +712,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
  heur_dissector_table_foreach@Base 1.99.2
  hex_str_to_bytes@Base 1.9.1
  hex_str_to_bytes_encoding@Base 1.12.0~rc1
- hf_frame_arrival_time@Base 1.9.1
- hf_frame_capture_len@Base 1.9.1
- hf_frame_len@Base 1.9.1
- hf_frame_number@Base 1.9.1
  hf_text_only@Base 1.9.1
  hfinfo_bitshift@Base 1.12.0~rc1
  host_ip_af@Base 1.9.1
@@ -869,14 +865,12 @@ libwireshark.so.0 libwireshark0 #MINVER#
  proto_can_toggle_protocol@Base 1.9.1
  proto_check_field_name@Base 1.9.1
  proto_construct_match_selected_string@Base 1.9.1
- proto_data@Base 1.9.1
  proto_enable_all@Base 1.9.1
  proto_expert@Base 1.9.1
  proto_field_is_referenced@Base 1.9.1
  proto_find_field_from_offset@Base 1.9.1
  proto_find_finfo@Base 1.9.1
  proto_find_undecoded_data@Base 1.99.3
- proto_frame@Base 1.9.1
  proto_free_deregistered_fields@Base 1.12.0~rc1
  proto_get_data_protocol@Base 1.9.1
  proto_get_finfo_ptr_array@Base 1.9.1
index 0f10691728d30ef2cd48e6751e1ffbf441c70794..fe8cdd89f8dd5392beaf8454786914f0af72ce9c 100644 (file)
@@ -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 \
index 3dc21aac19da88031ea54296cea320877ffb63e8..c28b6cc5b1f265fc7e7052ed89bc4e460ffa90ba 100644 (file)
@@ -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 (file)
index 5ac3668..0000000
+++ /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__ */
index f7f47d86a3caae9da6d150958843fc02251dd133..3781ec32a62b655cbea6cd5d3d8c87a21c8f83f3 100644 (file)
 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;
index c6bc2a50059fa1b61b655b649a6bca0c3715312c..899ab7a9ad606f326636db821a4e0a97c1394d9d 100644 (file)
@@ -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;
index 50cd80b7bca6b393c555d5d7629cbb3ed57a2084..4fb797dbd7b18178ae43d0bfc2f15ff85013fa94 100644 (file)
@@ -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);
index 66946ec9dac95018454c50f4086208ff1968fdd7..8072f8393c858e704f30bd71ce37bf292610fc92 100644 (file)
@@ -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)
index 95bc6a9da261942c921ff91663c6f2fe6ddba6cb..334de3a29bbf867a6aac87fbe7c697913312c8a0 100644 (file)
@@ -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 */
diff --git a/file.c b/file.c
index ff396c7181f9df521cfb83feb8427de7a0da52ea..cc919aa09666b0619dbb6fe4abc3a8085d992d06 100644 (file)
--- a/file.c
+++ b/file.c
@@ -56,7 +56,6 @@
 #include <epan/dfilter/dfilter.h>
 #include <epan/epan_dissect.h>
 #include <epan/tap.h>
-#include <epan/dissectors/packet-data.h>
 #include <epan/dissectors/packet-ber.h>
 #include <epan/timestamp.h>
 #include <epan/dfilter/dfilter-macro.h>