diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2017-11-16 23:55:57 +0000 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2017-11-18 14:43:10 +0000 |
commit | b695b3e2f72998d66ca4b7a6826d4ce1688060c8 (patch) | |
tree | df1bd7e3db0e50fc5d9b1fa41538fe40420026fa /epan | |
parent | d8e2bee9ea84ec5123d2023f32c0f0d191834d32 (diff) |
Begin cleanup of make-dissector-reg.py
Move registration code to a new register.c file so it is readable.
Dissector load points are stored in a generated function pointer
array instead.
Simplify python script somewhat by not interleaving the plugin and
dissector logic.
Change-Id: I5ec21270f4e1550a5c911efa7f0dc4fc7fcb13a5
Reviewed-on: https://code.wireshark.org/review/24474
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r-- | epan/dissectors/CMakeLists.txt | 5 | ||||
-rw-r--r-- | epan/dissectors/Makefile.am | 30 | ||||
-rw-r--r-- | epan/dissectors/dissectors.h | 51 |
3 files changed, 66 insertions, 20 deletions
diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt index 5046ec4d3f..4df86f63fe 100644 --- a/epan/dissectors/CMakeLists.txt +++ b/epan/dissectors/CMakeLists.txt @@ -210,6 +210,7 @@ set(NCP2222_DISSECTOR_SRC source_group(dissectors-ncp2222 FILES ${NCP2222_DISSECTOR_SRC}) set(DISSECTOR_PUBLIC_HEADERS + dissectors.h packet-6lowpan.h packet-a21.h packet-acp133.h @@ -1814,7 +1815,7 @@ set(DISSECTOR_SUPPORT_SRC packet-dcerpc-nt.c usb.c snort-config.c - register.c + dissectors.c ) source_group(dissector-support FILES ${DISSECTOR_SUPPORT_SRC}) @@ -1834,7 +1835,7 @@ set(ALL_DISSECTOR_SRC ${CORBA_IDL_DISSECTOR_SRC} ) -register_dissector_files(register.c +register_dissector_files(dissectors.c dissectors ${ALL_DISSECTOR_SRC} ) diff --git a/epan/dissectors/Makefile.am b/epan/dissectors/Makefile.am index 7c6f08f92c..cbfe2bbb05 100644 --- a/epan/dissectors/Makefile.am +++ b/epan/dissectors/Makefile.am @@ -28,14 +28,14 @@ include Custom.common # "BUILT_SOURCES" are built before any "make all" or "make check" targets. BUILT_SOURCES = \ - register.c + dissectors.c # Header files generated from source files. NODIST_GENERATED_HEADER_FILES = # C source files generated from source files. NODIST_GENERATED_C_FILES = \ - register.c + dissectors.c # All the generated files. NODIST_GENERATED_FILES = \ @@ -1474,6 +1474,7 @@ FILE_DISSECTOR_INCLUDES = \ # DISSECTOR_INCLUDES = \ $(PIDL_DISSECTOR_INCLUDES) \ + dissectors.h \ packet-6lowpan.h \ packet-a21.h \ packet-acp133.h \ @@ -1853,7 +1854,7 @@ DISSECTOR_INCLUDES = \ # Dissector helpers. They're included in the source files in this # directory, but they're not dissectors themselves, i.e. they're not -# used to generate "register.c"). +# used to generate "dissectors.c"). DISSECTOR_SUPPORT_SRC = \ errno.c \ packet-dcerpc-nt.c \ @@ -1924,10 +1925,9 @@ x11-dissector: $(top_srcdir)/tools/process-x11-fields.pl $(srcdir)/x11-fields $( $(PERL) $(top_srcdir)/tools/process-x11-xcb.pl $(srcdir) # -# Build register.c, which contains a function register_all_protocols() -# that calls the register routines for all protocols and a function -# register_all_protocol_handoffs() that calls the handoff registration -# routines for all protocols. +# Build dissectors.c, which contains a function pointer array +# with the register routines for all protocols and a function pointer array +# with the handoff registration routines for all protocols. # # We do this by scanning through sources. If that turns out to be too slow, # maybe we could just require every .o file to have an register routine @@ -1940,20 +1940,15 @@ x11-dissector: $(top_srcdir)/tools/process-x11-fields.pl $(srcdir)/x11-fields $( # # ALL_DISSECTORS_SRC is assumed to have all the files that need to be scanned. # -# For some unknown reason, having a big "for" loop in the Makefile -# to scan all the files doesn't work with some "make"s; they seem to -# pass only the first few names in the list to the shell, for some -# reason. -# -# Therefore, we use a script to generate the register.c file. +# We use a script to generate the dissectors.c file. # The first argument is the directory in which the source files live. # The second argument is "dissectors", to indicate that we should build -# a register.c file for libwireshark. +# a dissectors.c file for libwireshark. # All subsequent arguments are the files to scan. # -register.c: $(plugin_src) $(ALL_DISSECTORS_SRC) Custom.common \ +dissectors.c: $(plugin_src) $(ALL_DISSECTORS_SRC) Custom.common \ $(top_srcdir)/tools/make-dissector-reg.py - @echo Making register.c ; \ + @echo Making dissectors.c ; \ $(PYTHON) $(top_srcdir)/tools/make-dissector-reg.py $(srcdir) \ dissectors $(ALL_DISSECTORS_SRC) ; @@ -1962,8 +1957,7 @@ CLEANFILES = \ libdissectors.la \ libdirtydissectors.a \ libdirtydissectors.la \ - register.c-tmp \ - register-cache.pkl \ + dissectors-cache.pkl \ *~ DISTCLEANFILES = \ diff --git a/epan/dissectors/dissectors.h b/epan/dissectors/dissectors.h new file mode 100644 index 0000000000..1fca975136 --- /dev/null +++ b/epan/dissectors/dissectors.h @@ -0,0 +1,51 @@ +/* dissectors.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+ + */ + +#ifndef __DISSECTOR_REGISTER_H__ +#define __DISSECTOR_REGISTER_H__ + +#include "ws_symbol_export.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include <glib.h> + +typedef struct _dissector_reg { + const char *cb_name; + void (*cb_func)(void); +} dissector_reg_t; + +WS_DLL_PUBLIC dissector_reg_t dissector_reg_proto[]; +WS_DLL_PUBLIC dissector_reg_t dissector_reg_handoff[]; + +WS_DLL_PUBLIC gulong dissector_reg_proto_count(void); + +WS_DLL_PUBLIC gulong dissector_reg_handoff_count(void); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __DISSECTOR_REGISTER_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=2 tabstop=8 expandtab: + * :indentSize=2:tabSize=8:noTabs=true: + */ |