forked from osmocom/wireshark
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>
This commit is contained in:
parent
d8e2bee9ea
commit
b695b3e2f7
|
@ -1552,6 +1552,7 @@ endif()
|
|||
set(SHARK_COMMON_SRC
|
||||
cfile.c
|
||||
frame_tvbuff.c
|
||||
register.c
|
||||
sync_pipe_write.c
|
||||
version_info.c
|
||||
)
|
||||
|
@ -2523,6 +2524,7 @@ if(BUILD_dftest)
|
|||
)
|
||||
set(dftest_FILES
|
||||
dftest.c
|
||||
register.c
|
||||
)
|
||||
add_executable(dftest ${dftest_FILES})
|
||||
add_dependencies(dftest version)
|
||||
|
@ -3003,7 +3005,6 @@ set(SHARK_PUBLIC_HEADERS
|
|||
file.h
|
||||
globals.h
|
||||
log.h
|
||||
register.h
|
||||
ws_attributes.h
|
||||
ws_compiler_tests.h
|
||||
ws_diag_control.h
|
||||
|
|
|
@ -395,6 +395,7 @@ EXTCAP_COMMON_SRC = \
|
|||
SHARK_COMMON_SRC = \
|
||||
cfile.c \
|
||||
frame_tvbuff.c \
|
||||
register.c \
|
||||
sync_pipe_write.c
|
||||
|
||||
# wireshark specifics
|
||||
|
@ -677,7 +678,8 @@ randpkt_LDADD = \
|
|||
@C_ARES_LIBS@
|
||||
|
||||
dftest_SOURCES = \
|
||||
dftest.c
|
||||
dftest.c \
|
||||
register.c
|
||||
|
||||
dftest_CPPFLAGS = $(AM_CPPFLAGS) $(GLIB_CFLAGS)
|
||||
|
||||
|
@ -723,7 +725,6 @@ pkginclude_HEADERS = \
|
|||
file.h \
|
||||
globals.h \
|
||||
log.h \
|
||||
register.h \
|
||||
ws_attributes.h \
|
||||
ws_compiler_tests.h \
|
||||
ws_diag_control.h \
|
||||
|
@ -740,6 +741,7 @@ noinst_HEADERS = \
|
|||
extcap_spawn.h \
|
||||
fileset.h \
|
||||
frame_tvbuff.h \
|
||||
register.h \
|
||||
ringbuffer.h \
|
||||
summary.h \
|
||||
sync_pipe.h \
|
||||
|
|
|
@ -451,6 +451,10 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
dissector_handle_get_protocol_index@Base 1.9.1
|
||||
dissector_handle_get_short_name@Base 1.9.1
|
||||
dissector_hostlist_init@Base 1.99.0
|
||||
dissector_reg_handoff@Base 2.5.0
|
||||
dissector_reg_handoff_count@Base 2.5.0
|
||||
dissector_reg_proto@Base 2.5.0
|
||||
dissector_reg_proto_count@Base 2.5.0
|
||||
dissector_reset_payload@Base 2.5.0
|
||||
dissector_reset_string@Base 1.9.1
|
||||
dissector_reset_uint@Base 1.9.1
|
||||
|
@ -1280,8 +1284,6 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
reassembly_table_destroy@Base 1.9.1
|
||||
reassembly_table_init@Base 1.9.1
|
||||
register_all_plugin_tap_listeners@Base 1.9.1
|
||||
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
|
||||
|
@ -1291,7 +1293,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
|
||||
|
|
|
@ -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}
|
||||
)
|
||||
|
|
|
@ -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 = \
|
||||
|
|
|
@ -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:
|
||||
*/
|
|
@ -0,0 +1,123 @@
|
|||
/* register.c
|
||||
* Definitions for protocol registration
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#include "register.h"
|
||||
#include "ws_attributes.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include "epan/dissectors/dissectors.h"
|
||||
|
||||
static const char *cur_cb_name = NULL;
|
||||
//static GMutex register_cb_mtx;
|
||||
static GAsyncQueue *register_cb_done_q;
|
||||
|
||||
#define CB_WAIT_TIME (150 * 1000) // microseconds
|
||||
|
||||
static void set_cb_name(const char *proto) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cur_cb_name = proto;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
}
|
||||
|
||||
static void *
|
||||
register_all_protocols_worker(void *arg _U_)
|
||||
{
|
||||
for (gulong i = 0; i < dissector_reg_proto_count(); i++) {
|
||||
set_cb_name(dissector_reg_proto[i].cb_name);
|
||||
dissector_reg_proto[i].cb_func();
|
||||
}
|
||||
|
||||
g_async_queue_push(register_cb_done_q, GINT_TO_POINTER(TRUE));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
register_all_protocols(register_cb cb, gpointer cb_data)
|
||||
{
|
||||
const char *cb_name;
|
||||
register_cb_done_q = g_async_queue_new();
|
||||
gboolean called_back = FALSE;
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
g_thread_new("register_all_protocols_worker", ®ister_all_protocols_worker, NULL);
|
||||
#else
|
||||
g_thread_create(®ister_all_protocols_worker, TRUE, FALSE, NULL);
|
||||
#endif
|
||||
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cb_name = cur_cb_name;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
if (cb && cb_name) {
|
||||
cb(RA_REGISTER, cb_name, cb_data);
|
||||
called_back = TRUE;
|
||||
}
|
||||
}
|
||||
if (cb && !called_back) {
|
||||
cb(RA_REGISTER, "Registration finished", cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void *
|
||||
register_all_protocol_handoffs_worker(void *arg _U_)
|
||||
{
|
||||
for (gulong i = 0; i < dissector_reg_handoff_count(); i++) {
|
||||
set_cb_name(dissector_reg_handoff[i].cb_name);
|
||||
dissector_reg_handoff[i].cb_func();
|
||||
}
|
||||
|
||||
g_async_queue_push(register_cb_done_q, GINT_TO_POINTER(TRUE));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
register_all_protocol_handoffs(register_cb cb, gpointer cb_data)
|
||||
{
|
||||
cur_cb_name = NULL;
|
||||
const char *cb_name;
|
||||
gboolean called_back = FALSE;
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
g_thread_new("register_all_protocol_handoffs_worker", ®ister_all_protocol_handoffs_worker, NULL);
|
||||
#else
|
||||
g_thread_create(®ister_all_protocol_handoffs_worker, TRUE, FALSE, NULL);
|
||||
#endif
|
||||
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cb_name = cur_cb_name;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
if (cb && cb_name) {
|
||||
cb(RA_HANDOFF, cb_name, cb_data);
|
||||
called_back = TRUE;
|
||||
}
|
||||
}
|
||||
if (cb && !called_back) {
|
||||
cb(RA_HANDOFF, "Registration finished", cb_data);
|
||||
}
|
||||
|
||||
g_async_queue_unref(register_cb_done_q);
|
||||
}
|
||||
|
||||
gulong register_count(void)
|
||||
{
|
||||
return dissector_reg_proto_count() + dissector_reg_handoff_count();
|
||||
}
|
||||
|
||||
/*
|
||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||
*
|
||||
* Local Variables:
|
||||
* c-basic-offset: 2
|
||||
* tab-width: 8
|
||||
* indent-tabs-mode: nil
|
||||
* End:
|
||||
*
|
||||
* vi: set shiftwidth=2 tabstop=8 expandtab:
|
||||
* :indentSize=2:tabSize=8:noTabs=true:
|
||||
*/
|
|
@ -49,7 +49,7 @@ typedef void (*register_cb)(register_action_e action, const char *message, gpoin
|
|||
* 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);
|
||||
void register_all_protocols(register_cb cb, gpointer client_data);
|
||||
|
||||
/** Call each dissector's protocol handoff routine.
|
||||
*
|
||||
|
@ -61,9 +61,11 @@ WS_DLL_PUBLIC void register_all_protocols(register_cb cb, gpointer client_data);
|
|||
* 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);
|
||||
void register_all_protocol_handoffs(register_cb cb, gpointer client_data);
|
||||
|
||||
extern void register_all_tap_listeners(void);
|
||||
WS_DLL_PUBLIC gulong register_count(void);
|
||||
|
||||
gulong register_count(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ if registertype in ("plugin", "plugin_wtap"):
|
|||
*/
|
||||
""" % (sys.argv[0])
|
||||
elif registertype in ("dissectors", "dissectorsinfile"):
|
||||
final_filename = "register.c"
|
||||
cache_filename = "register-cache.pkl"
|
||||
final_filename = "dissectors.c"
|
||||
cache_filename = "dissectors-cache.pkl"
|
||||
preamble = """\
|
||||
/*
|
||||
* Do not modify this file. Changes will be overwritten.
|
||||
|
@ -208,91 +208,23 @@ WS_DLL_PUBLIC_DEF const gchar plugin_version[] = VERSION;
|
|||
WS_DLL_PUBLIC_DEF const gchar plugin_release[] = VERSION_RELEASE;
|
||||
|
||||
"""
|
||||
else:
|
||||
for symbol in regs['proto_reg']:
|
||||
reg_code += "extern void %s(void);\n" % (symbol)
|
||||
|
||||
reg_code += """
|
||||
#include "register.h"
|
||||
#include "ws_attributes.h"
|
||||
|
||||
#include <glib.h>
|
||||
"""
|
||||
|
||||
for symbol in regs['proto_reg']:
|
||||
reg_code += "extern void %s(void);\n" % (symbol)
|
||||
|
||||
if registertype == "plugin" or registertype == "plugin_wtap":
|
||||
reg_code += """
|
||||
/* Start the functions we need for the plugin stuff */
|
||||
|
||||
WS_DLL_PUBLIC_DEF void
|
||||
plugin_register (void)
|
||||
{
|
||||
"""
|
||||
else:
|
||||
reg_code += """
|
||||
static const char *cur_cb_name = NULL;
|
||||
//static GMutex register_cb_mtx;
|
||||
static GAsyncQueue *register_cb_done_q;
|
||||
|
||||
#define CB_WAIT_TIME (150 * 1000) // microseconds
|
||||
for symbol in regs['proto_reg']:
|
||||
reg_code += " %s();\n" % (symbol)
|
||||
|
||||
static void set_cb_name(const char *proto) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cur_cb_name = proto;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
}
|
||||
reg_code += "}\n\n"
|
||||
|
||||
static void *register_all_protocols_worker(void *arg _U_);
|
||||
for symbol in regs['handoff_reg']:
|
||||
reg_code += "extern void %s(void);\n" % (symbol)
|
||||
|
||||
void
|
||||
register_all_protocols(register_cb cb, gpointer cb_data)
|
||||
{
|
||||
const char *cb_name;
|
||||
register_cb_done_q = g_async_queue_new();
|
||||
gboolean called_back = FALSE;
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
g_thread_new("register_all_protocols_worker", ®ister_all_protocols_worker, NULL);
|
||||
#else
|
||||
g_thread_create(®ister_all_protocols_worker, TRUE, FALSE, NULL);
|
||||
#endif
|
||||
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cb_name = cur_cb_name;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
if (cb && cb_name) {
|
||||
cb(RA_REGISTER, cb_name, cb_data);
|
||||
called_back = TRUE;
|
||||
}
|
||||
}
|
||||
if (cb && !called_back) {
|
||||
cb(RA_REGISTER, "Registration finished", cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
*register_all_protocols_worker(void *arg _U_)
|
||||
{
|
||||
"""
|
||||
|
||||
for symbol in regs['proto_reg']:
|
||||
if registertype != "plugin" and registertype != "plugin_wtap":
|
||||
reg_code += " set_cb_name(\"%s\");\n" % (symbol)
|
||||
reg_code += " %s();\n" % (symbol)
|
||||
|
||||
if registertype != "plugin" and registertype != "plugin_wtap":
|
||||
reg_code += """
|
||||
g_async_queue_push(register_cb_done_q, GINT_TO_POINTER(TRUE));
|
||||
return NULL;
|
||||
"""
|
||||
reg_code += "}\n\n"
|
||||
|
||||
|
||||
# Make the routine to register all protocol handoffs
|
||||
|
||||
for symbol in regs['handoff_reg']:
|
||||
reg_code += "extern void %s(void);\n" % (symbol)
|
||||
|
||||
if registertype == "plugin" or registertype == "plugin_wtap":
|
||||
reg_code += """
|
||||
WS_DLL_PUBLIC_DEF void plugin_reg_handoff(void);
|
||||
|
||||
|
@ -300,94 +232,67 @@ WS_DLL_PUBLIC_DEF void
|
|||
plugin_reg_handoff(void)
|
||||
{
|
||||
"""
|
||||
else:
|
||||
reg_code += """
|
||||
static void *register_all_protocol_handoffs_worker(void *arg _U_);
|
||||
for symbol in regs['handoff_reg']:
|
||||
reg_code += " %s();\n" % (symbol)
|
||||
reg_code += "}\n"
|
||||
|
||||
void
|
||||
register_all_protocol_handoffs(register_cb cb, gpointer cb_data)
|
||||
{
|
||||
cur_cb_name = NULL;
|
||||
const char *cb_name;
|
||||
gboolean called_back = FALSE;
|
||||
|
||||
#if GLIB_CHECK_VERSION(2,31,0)
|
||||
g_thread_new("register_all_protocol_hadoffss_worker", ®ister_all_protocol_handoffs_worker, NULL);
|
||||
#else
|
||||
g_thread_create(®ister_all_protocol_handoffs_worker, TRUE, FALSE, NULL);
|
||||
#endif
|
||||
while (!g_async_queue_timeout_pop(register_cb_done_q, CB_WAIT_TIME)) {
|
||||
// g_mutex_lock(register_cb_mtx);
|
||||
cb_name = cur_cb_name;
|
||||
// g_mutex_unlock(register_cb_mtx);
|
||||
if (cb && cb_name) {
|
||||
cb(RA_HANDOFF, cb_name, cb_data);
|
||||
called_back = TRUE;
|
||||
}
|
||||
}
|
||||
if (cb && !called_back) {
|
||||
cb(RA_HANDOFF, "Registration finished", cb_data);
|
||||
}
|
||||
|
||||
g_async_queue_unref(register_cb_done_q);
|
||||
}
|
||||
|
||||
void
|
||||
*register_all_protocol_handoffs_worker(void *arg _U_)
|
||||
{
|
||||
"""
|
||||
|
||||
for symbol in regs['handoff_reg']:
|
||||
if registertype != "plugin" and registertype != "plugin_wtap":
|
||||
reg_code += " set_cb_name(\"%s\");\n" % (symbol)
|
||||
reg_code += " %s();\n" % (symbol)
|
||||
|
||||
if registertype != "plugin" and registertype != "plugin_wtap":
|
||||
reg_code += """
|
||||
g_async_queue_push(register_cb_done_q, GINT_TO_POINTER(TRUE));
|
||||
return NULL;
|
||||
"""
|
||||
reg_code += "}\n"
|
||||
|
||||
if registertype == "plugin":
|
||||
reg_code += "#endif\n"
|
||||
elif registertype == "plugin_wtap":
|
||||
reg_code += """
|
||||
if registertype == "plugin":
|
||||
reg_code += "#endif\n"
|
||||
elif registertype == "plugin_wtap":
|
||||
reg_code += """
|
||||
WS_DLL_PUBLIC_DEF void
|
||||
register_wtap_module(void)
|
||||
{
|
||||
"""
|
||||
|
||||
for symbol in regs['wtap_register']:
|
||||
line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
|
||||
reg_code += line
|
||||
|
||||
reg_code += """
|
||||
for symbol in regs['wtap_register']:
|
||||
reg_code += " {extern void %s (void); %s ();}\n" % (symbol, symbol)
|
||||
reg_code += """
|
||||
}
|
||||
#endif
|
||||
"""
|
||||
|
||||
else:
|
||||
|
||||
reg_code += "\n#include <ws_symbol_export.h>"
|
||||
reg_code += "\n#include <dissectors.h>"
|
||||
reg_code += "\n"
|
||||
|
||||
for i in range(len(regs['proto_reg'])):
|
||||
reg_code += "\nvoid %s(void);" % regs['proto_reg'][i]
|
||||
|
||||
reg_code += "\n\ndissector_reg_t dissector_reg_proto[] = {\n"
|
||||
|
||||
reg_code += " { \"%s\", %s }" % (regs['proto_reg'][0], regs['proto_reg'][0])
|
||||
for i in range(1, len(regs['proto_reg'])):
|
||||
reg_code += ",\n { \"%s\", %s }" % (regs['proto_reg'][i], regs['proto_reg'][i])
|
||||
|
||||
reg_code += "\n};\n"
|
||||
|
||||
for i in range(len(regs['handoff_reg'])):
|
||||
reg_code += "\nvoid %s(void);" % regs['handoff_reg'][i]
|
||||
|
||||
reg_code += "\n\n\ndissector_reg_t dissector_reg_handoff[] = {\n"
|
||||
|
||||
reg_code += " { \"%s\", %s }" % (regs['handoff_reg'][0], regs['handoff_reg'][0])
|
||||
for i in range(1, len(regs['handoff_reg'])):
|
||||
reg_code += ",\n { \"%s\", %s }" % (regs['handoff_reg'][i], regs['handoff_reg'][i])
|
||||
|
||||
reg_code += "\n};\n"
|
||||
|
||||
reg_code += """
|
||||
static gulong proto_reg_count(void)
|
||||
gulong dissector_reg_proto_count(void)
|
||||
{
|
||||
return %(proto_reg_len)d;
|
||||
}
|
||||
|
||||
static gulong handoff_reg_count(void)
|
||||
gulong dissector_reg_handoff_count(void)
|
||||
{
|
||||
return %(handoff_reg_len)d;
|
||||
}
|
||||
|
||||
gulong register_count(void)
|
||||
{
|
||||
return proto_reg_count() + handoff_reg_count();
|
||||
}
|
||||
""" % {
|
||||
'proto_reg_len': len(regs['proto_reg']),
|
||||
'handoff_reg_len': len(regs['handoff_reg'])
|
||||
}
|
||||
|
||||
'proto_reg_len': len(regs['proto_reg']),
|
||||
'handoff_reg_len': len(regs['handoff_reg'])
|
||||
}
|
||||
|
||||
# Compare current and new content and update the file if anything has changed.
|
||||
|
||||
|
|
Loading…
Reference in New Issue