diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2018-08-28 21:39:55 +0100 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2018-08-29 23:22:44 +0000 |
commit | 8eddb1650d482f5eecc712967d10bba7450a2f5c (patch) | |
tree | fd1cf5b9582e6245ef84db16f9f9cf7081b1b8e6 | |
parent | b6ba314466aa33d97f4da32bb095fc0a566ed2cb (diff) |
epan: Remove unnecessary all protocols registration callback
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>
-rw-r--r-- | debian/libwireshark0.symbols | 3 | ||||
-rw-r--r-- | dftest.c | 4 | ||||
-rw-r--r-- | epan/epan.c | 25 | ||||
-rw-r--r-- | epan/epan.h | 6 | ||||
-rw-r--r-- | epan/proto.c | 20 | ||||
-rw-r--r-- | epan/proto.h | 5 | ||||
-rw-r--r-- | epan/register-int.h | 64 | ||||
-rw-r--r-- | epan/register.h | 37 | ||||
-rw-r--r-- | epan/stats_tree.h | 1 | ||||
-rw-r--r-- | epan/wslua/init_wslua.h | 1 | ||||
-rw-r--r-- | rawshark.c | 4 | ||||
-rw-r--r-- | sharkd.c | 4 | ||||
-rw-r--r-- | tfshark.c | 4 | ||||
-rw-r--r-- | tools/oss-fuzzshark/fuzzshark.c | 2 | ||||
-rw-r--r-- | tshark.c | 4 | ||||
-rw-r--r-- | ui/qt/about_dialog.cpp | 1 | ||||
-rw-r--r-- | ui/qt/main.cpp | 3 |
17 files changed, 99 insertions, 89 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index de8897f2ac..3fdfd83570 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -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 @@ -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. */ diff --git a/epan/epan.c b/epan/epan.c index 7efea6c433..ed6373e6e0 100644 --- a/epan/epan.c +++ b/epan/epan.c @@ -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(); diff --git a/epan/epan.h b/epan/epan.h index e2cd26a3da..e29fb83903 100644 --- a/epan/epan.h +++ b/epan/epan.h @@ -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. diff --git a/epan/proto.c b/epan/proto.c index 923e15420c..fa3c08df49 100644 --- a/epan/proto.c +++ b/epan/proto.c @@ -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); diff --git a/epan/proto.h b/epan/proto.h index 5814cd2c8c..d1ce17fa32 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -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 index 0000000000..2272a1a4a6 --- /dev/null +++ b/epan/register-int.h @@ -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: + */ diff --git a/epan/register.h b/epan/register.h index 491badd4af..da330fd0c0 100644 --- a/epan/register.h +++ b/epan/register.h @@ -11,12 +11,6 @@ #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__ */ /* diff --git a/epan/stats_tree.h b/epan/stats_tree.h index c2c0fc930c..e42e8ed289 100644 --- a/epan/stats_tree.h +++ b/epan/stats_tree.h @@ -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 diff --git a/epan/wslua/init_wslua.h b/epan/wslua/init_wslua.h index 8edb777029..4bac8884ce 100644 --- a/epan/wslua/init_wslua.h +++ b/epan/wslua/init_wslua.h @@ -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); diff --git a/rawshark.c b/rawshark.c index 012c6a0d54..09bd6bc58d 100644 --- a/rawshark.c +++ b/rawshark.c @@ -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; } @@ -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; } @@ -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; } diff --git a/tools/oss-fuzzshark/fuzzshark.c b/tools/oss-fuzzshark/fuzzshark.c index 8412b49f29..281dfcac39 100644 --- a/tools/oss-fuzzshark/fuzzshark.c +++ b/tools/oss-fuzzshark/fuzzshark.c @@ -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; @@ -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; } diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp index a9f42256dc..9d5fa97402 100644 --- a/ui/qt/about_dialog.cpp +++ b/ui/qt/about_dialog.cpp @@ -29,7 +29,6 @@ #endif #include "log.h" -#include "epan/register.h" #include "ui/alert_box.h" #include "ui/last_open_dir.h" diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index ccab602e70..9a6094d311 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -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; |