epan: Remove unnecessary all protocols registration callback
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>
Tue, 28 Aug 2018 20:39:55 +0000 (21:39 +0100)
committerJoão Valverde <j@v6e.pt>
Wed, 29 Aug 2018 23:22:44 +0000 (23:22 +0000)
We are exporting a registration function from libwireshark just
to have it passed back as a callback. Seems unnecessary.

Change-Id: I7621005c9be11691d319102326824c5e3520a6f3
Reviewed-on: https://code.wireshark.org/review/29328
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
17 files changed:
debian/libwireshark0.symbols
dftest.c
epan/epan.c
epan/epan.h
epan/proto.c
epan/proto.h
epan/register-int.h [new file with mode: 0644]
epan/register.h
epan/stats_tree.h
epan/wslua/init_wslua.h
rawshark.c
sharkd.c
tfshark.c
tools/oss-fuzzshark/fuzzshark.c
tshark.c
ui/qt/about_dialog.cpp
ui/qt/main.cpp

index de8897f2ac2c024b99c70df7fdc2d1f473883d4e..3fdfd83570e9c03a16e49958df95cd75335c6797 100644 (file)
@@ -1296,8 +1296,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
  reassembly_table_init@Base 1.9.1
  reassembly_table_register@Base 2.3.0
  register_all_plugin_tap_listeners@Base 2.5.0
- register_all_protocol_handoffs@Base 1.9.1
- register_all_protocols@Base 1.9.1
  register_ber_oid_dissector@Base 2.1.0
  register_ber_oid_dissector_handle@Base 1.9.1
  register_ber_oid_syntax@Base 1.9.1
@@ -1307,7 +1305,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
  register_cleanup_routine@Base 1.99.8
  register_conversation_filter@Base 2.0.0
  register_conversation_table@Base 2.5.0
- register_count@Base 1.9.1
  register_custom_dissector_table@Base 1.99.8
  register_custom_dissector_table@Base 1.99.8
  register_decode_as@Base 1.12.0~rc1
index e6e09b41e1945b604558de74024cf6663f213047..8ee0e09e516b6f66ce7cc140470476aab5df0c46 100644 (file)
--- a/dftest.c
+++ b/dftest.c
@@ -33,7 +33,6 @@
 #include <wiretap/wtap.h>
 
 #include "ui/util.h"
-#include "epan/register.h"
 
 static void failure_warning_message(const char *msg_format, va_list ap);
 static void open_failure_message(const char *filename, int err,
@@ -78,8 +77,7 @@ main(int argc, char **argv)
           "-g" flag, as the "-g" flag dumps a list of fields registered
           by the dissectors, and we must do it before we read the preferences,
           in case any dissectors register preferences. */
-       if (!epan_init(register_all_protocols, register_all_protocol_handoffs,
-           NULL, NULL))
+       if (!epan_init(NULL, NULL))
                return 2;
 
        /* set the c-language locale to the native environment. */
index 7efea6c43348e1b22a105233596cc3b7f23c00bd..ed6373e6e047999e76d0b8a94f83ce03a9093141 100644 (file)
@@ -88,8 +88,8 @@
 #include <signal.h>
 #endif
 
-static GSList *epan_register_all_procotols = NULL;
-static GSList *epan_register_all_handoffs = NULL;
+static GSList *epan_plugin_register_all_procotols = NULL;
+static GSList *epan_plugin_register_all_handoffs = NULL;
 
 static wmem_allocator_t *pinfo_pool_cache = NULL;
 
@@ -169,17 +169,14 @@ void epan_register_plugin(const epan_plugin *plug)
 {
        epan_plugins = g_slist_prepend(epan_plugins, (epan_plugin *)plug);
        if (plug->register_all_protocols)
-               epan_register_all_procotols = g_slist_prepend(epan_register_all_procotols, plug->register_all_protocols);
+               epan_plugin_register_all_procotols = g_slist_prepend(epan_plugin_register_all_procotols, plug->register_all_protocols);
        if (plug->register_all_handoffs)
-               epan_register_all_handoffs = g_slist_prepend(epan_register_all_handoffs, plug->register_all_handoffs);
+               epan_plugin_register_all_handoffs = g_slist_prepend(epan_plugin_register_all_handoffs, plug->register_all_handoffs);
 }
 #endif
 
 gboolean
-epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
-         void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
-         register_cb cb,
-         gpointer client_data)
+epan_init(register_cb cb, gpointer client_data)
 {
        volatile gboolean status = TRUE;
 
@@ -236,9 +233,7 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
 #ifdef HAVE_PLUGINS
                g_slist_foreach(epan_plugins, epan_plugin_init, NULL);
 #endif
-               epan_register_all_procotols = g_slist_prepend(epan_register_all_procotols, register_all_protocols_func);
-               epan_register_all_handoffs = g_slist_prepend(epan_register_all_handoffs, register_all_handoffs_func);
-               proto_init(epan_register_all_procotols, epan_register_all_handoffs, cb, client_data);
+               proto_init(epan_plugin_register_all_procotols, epan_plugin_register_all_handoffs, cb, client_data);
                packet_cache_proto_handles();
                dfilter_init();
                final_registration_all_protocols();
@@ -301,10 +296,10 @@ epan_cleanup(void)
        g_slist_free(epan_plugins);
        epan_plugins = NULL;
 #endif
-       g_slist_free(epan_register_all_procotols);
-       epan_register_all_procotols = NULL;
-       g_slist_free(epan_register_all_handoffs);
-       epan_register_all_handoffs = NULL;
+       g_slist_free(epan_plugin_register_all_procotols);
+       epan_plugin_register_all_procotols = NULL;
+       g_slist_free(epan_plugin_register_all_handoffs);
+       epan_plugin_register_all_handoffs = NULL;
 
        dfilter_cleanup();
        decode_clear_all();
index e2cd26a3daa8a2de3250d5a3882d77bbd489c989..e29fb839034768bb71b398b4d153a9a1b3968125 100644 (file)
@@ -19,7 +19,7 @@ extern "C" {
 #include <epan/prefs.h>
 #include <epan/frame_data.h>
 #include <wsutil/plugins.h>
-#include "register.h"
+#include <epan/register.h>
 #include "ws_symbol_export.h"
 
 typedef struct epan_dissect epan_dissect_t;
@@ -100,9 +100,7 @@ Ref2 for further edits - delete when done
  * Returns TRUE on success, FALSE on failure.
  */
 WS_DLL_PUBLIC
-gboolean epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_data),
-                  void (*register_all_handoffs_func)(register_cb cb, gpointer client_data),
-                  register_cb cb, void *client_data);
+gboolean epan_init(register_cb cb, void *client_data);
 
 /**
  * Load all settings, from the current profile, that affect epan.
index 923e15420cc48e70e7a84a15a76401444b271fb3..fa3c08df496e0b9ad940ffc8f4965a7ad12f3f5c 100644 (file)
@@ -42,6 +42,7 @@
 #include "expert.h"
 #include "show_exception.h"
 #include "in_cksum.h"
+#include "register-int.h"
 
 #include <wsutil/ws_printf.h> /* ws_debug_printf/ws_g_warning */
 #include <wsutil/crash_info.h>
@@ -448,8 +449,8 @@ call_plugin_register_handoff(gpointer data, gpointer user_data _U_)
 
 /* initialize data structures and register protocols and fields */
 void
-proto_init(GSList *register_all_protocols_list,
-          GSList *register_all_handoffs_list,
+proto_init(GSList *register_all_plugin_protocols_list,
+          GSList *register_all_plugin_handoffs_list,
           register_cb cb,
           gpointer client_data)
 {
@@ -486,13 +487,15 @@ proto_init(GSList *register_all_protocols_list,
           dissector tables, and dissectors to be called through a
           handle, and do whatever one-time initialization it needs to
           do. */
-       for (GSList *l = register_all_protocols_list; l != NULL; l = l->next) {
+       register_all_protocols(cb, client_data);
+
+       /* Now call the registration routines for all epan plugins. */
+       for (GSList *l = register_all_plugin_protocols_list; l != NULL; l = l->next) {
                ((void (*)(register_cb, gpointer))l->data)(cb, client_data);
        }
 
 #ifdef HAVE_PLUGINS
-       /* Now call the registration routines for all disssector
-          plugins. */
+       /* Now call the registration routines for all dissector plugins. */
        if (cb)
                (*cb)(RA_PLUGIN_REGISTER, NULL, client_data);
        g_slist_foreach(dissector_plugins, call_plugin_register_protoinfo, NULL);
@@ -502,12 +505,15 @@ proto_init(GSList *register_all_protocols_list,
           dissectors; those routines register the dissector in other
           dissectors' handoff tables, and fetch any dissector handles
           they need. */
-       for (GSList *l = register_all_handoffs_list; l != NULL; l = l->next) {
+       register_all_protocol_handoffs(cb, client_data);
+
+       /* Now do the same with epan plugins. */
+       for (GSList *l = register_all_plugin_handoffs_list; l != NULL; l = l->next) {
                ((void (*)(register_cb, gpointer))l->data)(cb, client_data);
        }
 
 #ifdef HAVE_PLUGINS
-       /* Now do the same with plugins. */
+       /* Now do the same with dissector plugins. */
        if (cb)
                (*cb)(RA_PLUGIN_HANDOFF, NULL, client_data);
        g_slist_foreach(dissector_plugins, call_plugin_register_handoff, NULL);
index 5814cd2c8cdbd1e7d6fc33f76eeedf674e53522f..d1ce17fa3220a3e331174b4fac197e8ecba930ad 100644 (file)
@@ -907,8 +907,9 @@ WS_DLL_PUBLIC void proto_register_plugin(const proto_plugin *plugin);
 #endif
 
 /** Sets up memory used by proto routines. Called at program startup */
-void proto_init(GSList *register_all_protocols_list, GSList *register_all_handoffs_list,
-                      register_cb cb, void *client_data);
+void proto_init(GSList *register_all_plugin_protocols_list,
+                       GSList *register_all_plugin_handoffs_list,
+                       register_cb cb, void *client_data);
 
 
 /** Frees memory used by proto routines. Called at program shutdown */
diff --git a/epan/register-int.h b/epan/register-int.h
new file mode 100644 (file)
index 0000000..2272a1a
--- /dev/null
@@ -0,0 +1,64 @@
+/* register-int.h
+ * Definitions for protocol registration
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __REGISTER_INT_H__
+#define __REGISTER_INT_H__
+
+#include "register.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** Call each dissector's protocol registration routine.
+ *
+ * Each routine is called in alphabetical order from a worker thread.
+ * Registration routines might call any number of routines which are not
+ * thread safe, such as wmem_alloc. Callbacks should handle themselves
+ * accordingly.
+ *
+ * @param cb Callback routine which is called for each protocol.
+ * Messages have the format "proto_register_XXX".
+ * @param client_data Data pointer for the callback.
+ */
+void register_all_protocols(register_cb cb, gpointer client_data);
+
+/** Call each dissector's protocol handoff routine.
+ *
+ * Each routine is called from a worker thread. Registration routines
+ * might call any number of routines which are not thread safe, such as
+ * wmem_alloc. Callbacks should handle themselves accordingly.
+ *
+ * @param cb Callback routine which is called for each protocol.
+ * Messages have the format "proto_reg_handoff_XXX".
+ * @param client_data Data pointer for the callback.
+ */
+void register_all_protocol_handoffs(register_cb cb, gpointer client_data);
+
+gulong register_count(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __REGISTER_INT_H__ */
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */
index 491badd4af0fef9b9af6660612f8f84582f4ef0f..da330fd0c0ead35167d01b4edc819b2ac125e8cc 100644 (file)
 #ifndef __REGISTER_H__
 #define __REGISTER_H__
 
-#include "ws_symbol_export.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
 #include <glib.h>
 
 typedef enum {
@@ -38,37 +32,6 @@ typedef enum {
 
 typedef void (*register_cb)(register_action_e action, const char *message, gpointer client_data);
 
-/** Call each dissector's protocol registration routine.
- *
- * Each routine is called in alphabetical order from a worker thread.
- * Registration routines might call any number of routines which are not
- * thread safe, such as wmem_alloc. Callbacks should handle themselves
- * accordingly.
- *
- * @param cb Callback routine which is called for each protocol.
- * Messages have the format "proto_register_XXX".
- * @param client_data Data pointer for the callback.
- */
-WS_DLL_PUBLIC void register_all_protocols(register_cb cb, gpointer client_data);
-
-/** Call each dissector's protocol handoff routine.
- *
- * Each routine is called from a worker thread. Registration routines
- * might call any number of routines which are not thread safe, such as
- * wmem_alloc. Callbacks should handle themselves accordingly.
- *
- * @param cb Callback routine which is called for each protocol.
- * Messages have the format "proto_reg_handoff_XXX".
- * @param client_data Data pointer for the callback.
- */
-WS_DLL_PUBLIC void register_all_protocol_handoffs(register_cb cb, gpointer client_data);
-
-WS_DLL_PUBLIC gulong register_count(void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
 #endif /* __REGISTER_H__ */
 
 /*
index c2c0fc930c3993141c0464b2dad2c5d3ab501bcd..e42e8ed2891a520eae2a9e20e9c9e5f9b7554e81 100644 (file)
@@ -16,7 +16,6 @@
 #include <epan/packet_info.h>
 #include <epan/tap.h>
 #include <epan/stat_groups.h>
-#include "register.h"
 #include "ws_symbol_export.h"
 
 #ifdef __cplusplus
index 8edb77702973a81c5223190183e5b27830a16142..4bac8884ce349042af00ca8afa9abba460addc3a 100644 (file)
@@ -15,7 +15,6 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#include "epan/register.h"
 #include "ws_symbol_export.h"
 
 WS_DLL_PUBLIC int wslua_count_plugins(void);
index 012c6a0d54374e1cd3d8b572b901866f56381551..09bd6bc58d10838817eec08333a924e605462918 100644 (file)
@@ -70,7 +70,6 @@
 #include "ui/util.h"
 #include "ui/dissect_opts.h"
 #include "ui/failure_message.h"
-#include "epan/register.h"
 #include "conditions.h"
 #include "capture_stop_conditions.h"
 #include <epan/epan_dissect.h>
@@ -520,8 +519,7 @@ main(int argc, char *argv[])
        "-G" flag, as the "-G" flag dumps information registered by the
        dissectors, and we must do it before we read the preferences, in
        case any dissectors register preferences. */
-    if (!epan_init(register_all_protocols, register_all_protocol_handoffs,
-                   NULL, NULL)) {
+    if (!epan_init(NULL, NULL)) {
         ret = INIT_ERROR;
         goto clean_exit;
     }
index 98ce2fc603c46be2e1a87854da7ad9e548cb60c0..28d53cd12bcccf0366ef5491a99d1b05341e2bfa 100644 (file)
--- a/sharkd.c
+++ b/sharkd.c
@@ -49,7 +49,6 @@
 #include "ui/filter_files.h"
 #include "ui/tap_export_pdu.h"
 #include "ui/failure_message.h"
-#include "epan/register.h"
 #include <epan/epan_dissect.h>
 #include <epan/tap.h>
 #include <epan/uat-int.h>
@@ -168,8 +167,7 @@ main(int argc, char *argv[])
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
      case any dissectors register preferences. */
-  if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
-                 NULL)) {
+  if (!epan_init(NULL, NULL)) {
     ret = EPAN_INIT_FAIL;
     goto clean_exit;
   }
index 935fae76f7c79be8229fc9264ec163966c6be96b..fd59dc25be152a156e02af696ba7008b01790288 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -57,7 +57,6 @@
 #include "ui/util.h"
 #include "ui/decode_as_utils.h"
 #include "ui/dissect_opts.h"
-#include "epan/register.h"
 #include <epan/epan_dissect.h>
 #include <epan/tap.h>
 #include <epan/stat_tap_ui.h>
@@ -491,8 +490,7 @@ main(int argc, char *argv[])
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
      case any dissectors register preferences. */
-  if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
-                 NULL)) {
+  if (!epan_init(NULL, NULL)) {
     exit_status = INIT_ERROR;
     goto clean_exit;
   }
index 8412b49f29a790f17304d451c500dcb2d8108739..281dfcac396367352c393a4156567185ea062eb5 100644 (file)
@@ -269,7 +269,7 @@ fuzz_init(int argc _U_, char **argv)
           "-G" flag, as the "-G" flag dumps information registered by the
           dissectors, and we must do it before we read the preferences, in
           case any dissectors register preferences. */
-       if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL, NULL))
+       if (!epan_init(NULL, NULL))
        {
                ret = EPAN_INIT_FAIL;
                goto clean_exit;
index 4b5f451653130681add84e78a3c7e289f1a886a5..9314ac1a7b5715e8922e1dd86e4ebdd19110e035 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -86,7 +86,6 @@
 #include "epan/oids.h"
 #endif
 #include "epan/maxmind_db.h"
-#include "epan/register.h"
 #include <epan/epan_dissect.h>
 #include <epan/tap.h>
 #include <epan/stat_tap_ui.h>
@@ -924,8 +923,7 @@ main(int argc, char *argv[])
      "-G" flag, as the "-G" flag dumps information registered by the
      dissectors, and we must do it before we read the preferences, in
      case any dissectors register preferences. */
-  if (!epan_init(register_all_protocols, register_all_protocol_handoffs, NULL,
-                 NULL)) {
+  if (!epan_init(NULL, NULL)) {
     exit_status = INIT_FAILED;
     goto clean_exit;
   }
index a9f42256dcd1ab31f4ed801a07f4ff0bbfe5f44e..9d5fa9740202e9bc38aaf026d73cbf0a8d32f1f0 100644 (file)
@@ -29,7 +29,6 @@
 #endif
 
 #include "log.h"
-#include "epan/register.h"
 
 #include "ui/alert_box.h"
 #include "ui/last_open_dir.h"
index ccab602e7096c95bd9f851fa9cb929be26d68028..9a6094d3116d4ea9864eddb67a979727bcf1c99b 100644 (file)
@@ -618,8 +618,7 @@ int main(int argc, char *qt_argv[])
        "-G" flag, as the "-G" flag dumps information registered by the
        dissectors, and we must do it before we read the preferences, in
        case any dissectors register preferences. */
-    if (!epan_init(register_all_protocols,register_all_protocol_handoffs,
-                   splash_update, NULL)) {
+    if (!epan_init(splash_update, NULL)) {
         SimpleDialog::displayQueuedMessages(main_w);
         ret_val = INIT_FAILED;
         goto clean_exit;