Rewrite make-tap-reg.py in C

Change-Id: Ief5b1fffecc9712c01ff10292c403b7c84a5908a
Reviewed-on: https://code.wireshark.org/review/24756
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2017-12-10 17:29:40 +00:00 committed by João Valverde
parent 224e24884a
commit 5fc43fe63a
19 changed files with 320 additions and 354 deletions

6
.gitignore vendored
View File

@ -43,7 +43,6 @@ epan/wslua/register_wslua.c
epan/wslua/taps.txt
epan/wslua/taps_wslua.c
epan/ps.c
ui/cli/tshark-tap-register-cache.pkl
plugins/*/plugin.c
plugins/mate/mate_parser.c
version.h
@ -54,7 +53,7 @@ wiretap/ascend.h
wiretap/k12text.c
wiretap/version_info.c
wireshark-tap-register.c
wireshark-tap-register-cache.pkl
ui/make-taps
ui/gtk/wireshark-gresources.c
ui/gtk/wireshark-gresources.h
@ -121,11 +120,8 @@ CPackSourceConfig.cmake
lib/
WiresharkConfig.cmake
WiresharkConfigVersion.cmake
epan/dissectors/_regc.tmp
epan/dissectors/files.txt
wireshark.pc
run/
tshark-tap-register-cache.pkl
build.ninja
rules.ninja
.ninja_deps

View File

@ -213,7 +213,7 @@ message(STATUS "V: ${PROJECT_VERSION}, MaV: ${PROJECT_MAJOR_VERSION}, MiV: ${PRO
include(UseLemon)
include(UseMakePluginReg)
include(UseMakeTapReg)
include(UseMakeTaps)
include(UseAsn2Wrs)
# The following snippet has been taken from
@ -1579,38 +1579,38 @@ if(ENABLE_EXTCAP)
endif()
set(TSHARK_TAP_SRC
ui/cli/tap-camelsrt.c
ui/cli/tap-comparestat.c
ui/cli/tap-diameter-avp.c
ui/cli/tap-expert.c
ui/cli/tap-exportobject.c
ui/cli/tap-endpoints.c
ui/cli/tap-flow.c
ui/cli/tap-follow.c
ui/cli/tap-funnel.c
ui/cli/tap-gsm_astat.c
ui/cli/tap-hosts.c
ui/cli/tap-httpstat.c
ui/cli/tap-icmpstat.c
ui/cli/tap-icmpv6stat.c
ui/cli/tap-iostat.c
ui/cli/tap-iousers.c
ui/cli/tap-macltestat.c
ui/cli/tap-protocolinfo.c
ui/cli/tap-protohierstat.c
ui/cli/tap-rlcltestat.c
ui/cli/tap-rpcprogs.c
ui/cli/tap-rtd.c
ui/cli/tap-rtp.c
ui/cli/tap-rtspstat.c
ui/cli/tap-sctpchunkstat.c
ui/cli/tap-simple_stattable.c
ui/cli/tap-sipstat.c
ui/cli/tap-smbsids.c
ui/cli/tap-srt.c
ui/cli/tap-stats_tree.c
ui/cli/tap-sv.c
ui/cli/tap-wspstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-camelsrt.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-comparestat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-diameter-avp.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-expert.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-exportobject.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-endpoints.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-flow.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-follow.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-funnel.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-gsm_astat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-hosts.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-httpstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-icmpv6stat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-iostat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-iousers.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-macltestat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-protocolinfo.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-protohierstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-rlcltestat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-rpcprogs.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-rtd.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-rtp.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-rtspstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-sctpchunkstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-simple_stattable.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-sipstat.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-smbsids.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-srt.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-stats_tree.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-sv.c
${CMAKE_SOURCE_DIR}/ui/cli/tap-wspstat.c
)
set(INSTALL_DIRS
@ -2438,7 +2438,6 @@ if(BUILD_wireshark_gtk AND GTK_FOUND)
endif()
register_tap_files(tshark-tap-register.c
tshark-taps
${TSHARK_TAP_SRC}
)

View File

@ -1,17 +0,0 @@
#
MACRO(REGISTER_TAP_FILES _outputfile _registertype )
set( _sources ${ARGN})
ADD_CUSTOM_COMMAND(
OUTPUT
${_outputfile}
COMMAND ${PYTHON_EXECUTABLE}
${CMAKE_SOURCE_DIR}/tools/make-tap-reg.py
"${CMAKE_CURRENT_SOURCE_DIR}"
${_registertype}
${_sources}
DEPENDS
${CMAKE_SOURCE_DIR}/tools/make-tap-reg.py
${_sources}
)
ENDMACRO(REGISTER_TAP_FILES)

View File

@ -0,0 +1,15 @@
#
MACRO(REGISTER_TAP_FILES _outputfile)
set(_sources ${ARGN})
ADD_CUSTOM_COMMAND(
OUTPUT
${_outputfile}
COMMAND
make-taps ${_outputfile} ${_sources}
DEPENDS
make-taps
${_sources}
COMMENT
"Making ${_outputfile}"
)
ENDMACRO(REGISTER_TAP_FILES)

View File

@ -63,8 +63,6 @@ WS_DLL_PUBLIC void register_all_protocols(register_cb cb, gpointer client_data);
*/
WS_DLL_PUBLIC void register_all_protocol_handoffs(register_cb cb, gpointer client_data);
WS_DLL_LOCAL void register_all_tap_listeners(void);
WS_DLL_PUBLIC gulong register_count(void);
#ifdef __cplusplus

View File

@ -1,191 +0,0 @@
#!/usr/bin/env python
#
# Looks for registration routines in the taps,
# and assembles C code to call all the routines.
#
# This is a Python version of the make-reg-dotc shell script.
# Running the shell script on Win32 is very very slow because of
# all the process-launching that goes on --- multiple greps and
# seds for each input file. I wrote this python version so that
# less processes would have to be started.
#
# Copyright 2010 Anders Broman <anders.broman@ericsson.com>
#
# 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.
import os
import sys
import re
import pickle
from stat import *
#
# The first argument is the directory in which the source files live.
#
srcdir = sys.argv[1]
#
# The second argument is "taps".
#
registertype = sys.argv[2]
if registertype == "taps":
tmp_filename = "wireshark-tap-register.c-tmp"
final_filename = "wireshark-tap-register.c"
cache_filename = "wireshark-tap-register-cache.pkl"
elif registertype == "tshark-taps":
tmp_filename = "tshark-tap-register.c-tmp"
final_filename = "tshark-tap-register.c"
cache_filename = "tshark-tap-register-cache.pkl"
else:
print("Unknown output type '%s'" % registertype)
sys.exit(1)
#
# All subsequent arguments are the files to scan.
#
files = sys.argv[3:]
# Create the proper list of filenames
filenames = []
for file in files:
if os.path.isfile(file):
filenames.append(file)
else:
filenames.append("%s/%s" % (srcdir, file))
if len(filenames) < 1:
print("No files found")
sys.exit(1)
# Look through all files, applying the regex to each line.
# If the pattern matches, save the "symbol" section to the
# appropriate array.
regs = {
'tap_reg': [],
}
# For those that don't know Python, r"" indicates a raw string,
# devoid of Python escapes.
tap_regex0 = r"^(?P<symbol>register_tap_listener_[_A-Za-z0-9]+)\s*\([^;]+$"
tap_regex1 = r"void\s+(?P<symbol>register_tap_listener_[_A-Za-z0-9]+)\s*\([^;]+$"
# This table drives the pattern-matching and symbol-harvesting
patterns = [
( 'tap_reg', re.compile(tap_regex0) ),
( 'tap_reg', re.compile(tap_regex1) ),
]
# Open our registration symbol cache
cache = None
if cache_filename:
try:
cache_file = open(cache_filename, 'rb')
cache = pickle.load(cache_file)
cache_file.close()
except:
cache = {}
# Grep
for filename in filenames:
file = open(filename)
cur_mtime = os.fstat(file.fileno())[ST_MTIME]
if cache and filename in cache:
cdict = cache[filename]
if cur_mtime == cdict['mtime']:
# print "Pulling %s from cache" % (filename)
regs['tap_reg'].extend(cdict['tap_reg'])
file.close()
continue
# We don't have a cache entry
if cache is not None:
cache[filename] = {
'mtime': cur_mtime,
'tap_reg': [],
}
# print "Searching %s" % (filename)
for line in file.readlines():
for action in patterns:
regex = action[1]
match = regex.search(line)
if match:
symbol = match.group("symbol")
sym_type = action[0]
regs[sym_type].append(symbol)
if cache is not None:
# print "Caching %s for %s: %s" % (sym_type, filename, symbol)
cache[filename][sym_type].append(symbol)
file.close()
if cache is not None and cache_filename is not None:
cache_file = open(cache_filename, 'wb')
pickle.dump(cache, cache_file)
cache_file.close()
# Make sure we actually processed something
if len(regs['tap_reg']) < 1:
print("No protocol registrations found")
sys.exit(1)
# Sort the lists to make them pretty
regs['tap_reg'].sort()
reg_code = open(tmp_filename, "w")
reg_code.write("/* Do not modify this file. Changes will be overwritten. */\n")
reg_code.write("/* Generated automatically from %s */\n" % (sys.argv[0]))
# Make the routine to register all taps
reg_code.write("""
#include "epan/register.h"
void register_all_tap_listeners(void) {
""");
for symbol in regs['tap_reg']:
line = " {extern void %s (void); %s ();}\n" % (symbol, symbol)
reg_code.write(line)
reg_code.write("}\n")
# Close the file
reg_code.close()
# Remove the old final_file if it exists.
try:
os.stat(final_filename)
os.remove(final_filename)
except OSError:
pass
# Move from tmp file to final file
os.rename(tmp_filename, final_filename)
#
# Editor modelines - http://www.wireshark.org/tools/modelines.html
#
# Local variables:
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
#
# vi: set shiftwidth=4 expandtab:
# :indentSize=4:noTabs=true:
#

View File

@ -72,6 +72,7 @@
#ifdef HAVE_LIBPCAP
#include "ui/capture_ui_utils.h"
#endif
#include "ui/taps.h"
#include "ui/util.h"
#include "ui/ws_ui_util.h"
#include "ui/decode_as_utils.h"
@ -933,7 +934,10 @@ main(int argc, char *argv[])
#ifdef HAVE_EXTCAP
extcap_register_preferences();
#endif
register_all_tap_listeners();
/* Register all tap listeners. */
for (tap_reg_t *t = tap_reg_listener; t->cb_func != NULL; t++) {
t->cb_func();
}
conversation_table_set_gui_info(init_iousers);
hostlist_table_set_gui_info(init_hostlists);
srt_table_iterate_tables(register_srt_tables, NULL);

View File

@ -96,6 +96,9 @@ set_target_properties(ui PROPERTIES
FOLDER "UI"
)
add_executable(make-taps make-taps.c)
target_link_libraries(make-taps ${GLIB2_LIBRARIES})
if (HTML_HELP_COMPILER)
add_definitions(-DHHC_DIR)
target_link_libraries(ui Htmlhelp.lib)

View File

@ -166,6 +166,14 @@ BUILT_SOURCES = $(GENERATED_HEADER_FILES)
#
libui_a_CFLAGS = $(AM_CFLAGS) $(PIE_CFLAGS)
noinst_PROGRAMS = make-taps
make_taps_CFLAGS = $(WS_CPPFLAGS) $(GLIB_CFLAGS)
make_taps_LDADD = \
$(GLIB_LIBS) \
${top_builddir}/wsutil/libwsutil.la
CLEANFILES = \
doxygen-ui.tag

View File

@ -94,30 +94,11 @@ EXTRA_DIST = \
.editorconfig \
$(GENERATOR_FILES)
CLEANFILES = \
tshark-tap-register.c-tmp \
tshark-tap-register-cache.pkl
MAINTAINERCLEANFILES = \
$(GENERATED_FILES)
#
# Build "tshark-tap-register.c", which contains a function
# "register_all_tap_listeners()"
# that calls the register routines for all tshark tap listeners.
#
# We do this by grepping through sources.
#
# Formatting conventions: The name of the tap_listener_register_*
# routines must start in column zero, or must be preceded only by
# "void " starting in column zero, and must not be inside #if.
#
# The first argument is the directory in which the source files live.
# All subsequent arguments are the files to scan.
#
tshark-tap-register.c: $(TSHARK_TAP_SRC) $(top_srcdir)/tools/make-tap-reg.py
@echo Making tshark-tap-register.c
@$(PYTHON) $(top_srcdir)/tools/make-tap-reg.py $(srcdir) tshark-taps $(TSHARK_TAP_SRC)
tshark-tap-register.c: $(TSHARK_TAP_SRC) ../make-taps
$(AM_V_GEN)../make-taps $@ $(filter %.c,$^)
doxygen:
if HAVE_DOXYGEN

View File

@ -258,7 +258,7 @@ static stat_tap_ui camelsrt_ui = {
NULL
};
void /* Next line mandatory */
void
register_tap_listener_camelsrt(void)
{
register_stat_tap_ui(&camelsrt_ui, NULL);

View File

@ -193,31 +193,31 @@ if(ENABLE_EXTCAP)
endif()
set(WIRESHARK_TAP_SRC
compare_stat.c
dcerpc_stat.c
expert_comp_dlg.c
flow_graph.c
funnel_stat.c
gsm_map_summary.c
iax2_analysis.c
io_stat.c
lbm_stream_dlg.c
mac_lte_stat_dlg.c
mcast_stream_dlg.c
mtp3_summary.c
rlc_lte_graph.c
rlc_lte_stat_dlg.c
rpc_stat.c
rtp_analysis.c
rtp_stream_dlg.c
sctp_assoc_analyse.c
sctp_chunk_stat.c
sctp_chunk_stat_dlg.c
sctp_stat_dlg.c
stats_tree_stat.c
tcp_graph.c
voip_calls_dlg.c
wlan_stat_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/compare_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/dcerpc_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/expert_comp_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/flow_graph.c
${CMAKE_CURRENT_SOURCE_DIR}/funnel_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/gsm_map_summary.c
${CMAKE_CURRENT_SOURCE_DIR}/iax2_analysis.c
${CMAKE_CURRENT_SOURCE_DIR}/io_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/lbm_stream_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/mac_lte_stat_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/mcast_stream_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/mtp3_summary.c
${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_graph.c
${CMAKE_CURRENT_SOURCE_DIR}/rlc_lte_stat_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/rpc_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/rtp_analysis.c
${CMAKE_CURRENT_SOURCE_DIR}/rtp_stream_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/sctp_assoc_analyse.c
${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/sctp_chunk_stat_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/sctp_stat_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/stats_tree_stat.c
${CMAKE_CURRENT_SOURCE_DIR}/tcp_graph.c
${CMAKE_CURRENT_SOURCE_DIR}/voip_calls_dlg.c
${CMAKE_CURRENT_SOURCE_DIR}/wlan_stat_dlg.c
${WIRESHARK_CUSTOM_TAP_SRC}
)
@ -263,7 +263,6 @@ if(WIN32)
endif()
register_tap_files(wireshark-tap-register.c
taps
${WIRESHARK_TAP_SRC}
)

View File

@ -269,10 +269,6 @@ endif
AM_CPPFLAGS = $(INCLUDEDIRS) $(WS_CPPFLAGS) $(GTK_CFLAGS) \
$(PORTAUDIO_INCLUDES)
CLEANFILES = \
wireshark-tap-register.c-tmp \
wireshark-tap-register-cache.pkl
DISTCLEANFILES = \
$(NODIST_GENERATED_FILES)
@ -314,23 +310,8 @@ nodist_libgtkui_a_SOURCES = \
libgtkui_a_DEPENDENCIES =
#
# Build "wireshark-tap-register.c", which contains a function
# "register_all_tap_listeners()"
# that calls the register routines for all wireshark tap listeners.
#
# We do this by grepping through sources.
#
# Formatting conventions: The name of the tap_listener_register_*
# routines must start in column zero, or must be preceded only by
# "void " starting in column zero, and must not be inside #if.
#
# The first argument is the directory in which the source files live.
# All subsequent arguments are the files to scan.
#
wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) Makefile_custom.common $(top_srcdir)/tools/make-tap-reg.py
@echo Making wireshark-tap-register.c
@$(PYTHON) $(top_srcdir)/tools/make-tap-reg.py $(srcdir) taps $(WIRESHARK_TAP_SRC)
wireshark-tap-register.c: $(WIRESHARK_TAP_SRC) ../make-taps
$(AM_V_GEN)../make-taps $@ $(filter %.c,$^)
wireshark-gresources.c: main.gresources.xml $(shell glib-compile-resources --sourcedir=$(top_srcdir) --generate-dependencies $(srcdir)/main.gresources.xml)
@echo Making $@

View File

@ -112,6 +112,7 @@
#include "ui/util.h"
#include "ui/dissect_opts.h"
#include "ui/commandline.h"
#include "ui/taps.h"
#ifdef HAVE_LIBPCAP
#include "ui/capture_ui_utils.h"
@ -2236,7 +2237,10 @@ main(int argc, char *argv[])
register_all_plugin_tap_listeners();
#endif
register_all_tap_listeners();
/* Register all tap listeners. */
for (tap_reg_t *t = tap_reg_listener; t->cb_func != NULL; t++) {
t->cb_func();
}
conversation_table_set_gui_info(init_conversation_table);
hostlist_table_set_gui_info(init_hostlist_table);
srt_table_iterate_tables(register_service_response_tables, NULL);

154
ui/make-taps.c Normal file
View File

@ -0,0 +1,154 @@
/* make-taps.c
* Tool to build the tap registration arrays.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <glib.h>
#include <wsutil/glib-compat.h>
#define ARRAY_RESERVED_SIZE 128
#define STRING_RESERVED_SIZE (8 * 1024)
GRegex *taps_regex;
static int
compare_symbols(gconstpointer a, gconstpointer b)
{
return g_strcmp0(*(const char **)a, *(const char **)b);
}
static void
scan_matches(GRegex *regex, const char *string, GPtrArray *dst)
{
GMatchInfo *match_info;
char *match;
g_regex_match(regex, string, G_REGEX_MATCH_NOTEMPTY, &match_info);
while (g_match_info_matches(match_info)) {
match = g_match_info_fetch(match_info, 1);
g_ptr_array_add(dst, match);
g_match_info_next(match_info, NULL);
}
g_match_info_free(match_info);
}
static void
scan_file(const char *file, GPtrArray *taps)
{
char *contents;
GError *err = NULL;
if (!g_file_get_contents(file, &contents, NULL, &err)) {
fprintf(stderr, "%s: %s\n", file, err->message);
exit(1);
}
scan_matches(taps_regex, contents, taps);
g_free(contents);
}
int main(int argc, char **argv)
{
GPtrArray *taps = NULL;
GError *err = NULL;
guint i;
GString *s;
const char *outfile;
guint count_taps;
if (argc < 3) {
fprintf(stderr, "Usage: %s <outfile> <infiles...>\n", argv[0]);
exit(1);
}
taps = g_ptr_array_new_full(ARRAY_RESERVED_SIZE, g_free);
taps_regex = g_regex_new("void\\s+(register_tap_listener_[[:alnum:]_]+)\\s*\\(\\s*void\\s*\\)\\s*{",
G_REGEX_OPTIMIZE, G_REGEX_MATCH_NOTEMPTY, &err);
if (err) {
fprintf(stderr, "GRegex: %s\n", err->message);
exit(1);
}
outfile = argv[1];
for (int arg = 2; arg < argc; arg++) {
scan_file(argv[arg], taps);
}
if (taps->len == 0) {
fprintf(stderr, "No tap registrations found.\n");
exit(1);
}
g_ptr_array_sort(taps, compare_symbols);
s = g_string_sized_new(STRING_RESERVED_SIZE);
g_string_append(s,
"/*\n"
" * Do not modify this file. Changes will be overwritten.\n"
" *\n"
" * Generated automatically using \"make-taps\".\n"
" */\n"
"\n"
"#include \"ui/taps.h\"\n"
"\n");
g_string_append_printf(s,
"const gulong tap_reg_listener_count = %d;\n"
"\n",
taps->len);
for (i = 0; i < taps->len; i++) {
g_string_append_printf(s,
"void %s(void);\n",
(char *)taps->pdata[i]);
}
g_string_append(s,
"\n"
"tap_reg_t tap_reg_listener[] = {\n");
for (i = 0; i < taps->len; i++) {
g_string_append_printf(s,
" { \"%s\", %s },\n",
(char *)taps->pdata[i], (char *)taps->pdata[i]);
}
g_string_append(s,
" { NULL, NULL }\n"
"};\n"
"\n");
if (!g_file_set_contents(outfile, s->str, s->len, &err)) {
fprintf(stderr, "%s: %s\n", outfile, err->message);
exit(1);
}
count_taps = taps->len;
g_string_free(s, TRUE);
g_regex_unref(taps_regex);
g_ptr_array_free(taps, TRUE);
printf("Found %u registrations.\n", count_taps);
}
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -422,19 +422,19 @@ if(ENABLE_EXTCAP)
endif()
set(WIRESHARK_QT_TAP_SRC
expert_info_dialog.cpp
funnel_statistics.cpp
gsm_map_summary_dialog.cpp
io_graph_dialog.cpp
lte_mac_statistics_dialog.cpp
lte_rlc_statistics_dialog.cpp
mtp3_summary_dialog.cpp
multicast_statistics_dialog.cpp
rtp_stream_dialog.cpp
sctp_all_assocs_dialog.cpp
sctp_assoc_analyse_dialog.cpp
stats_tree_dialog.cpp
wlan_statistics_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/expert_info_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/funnel_statistics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gsm_map_summary_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/io_graph_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lte_mac_statistics_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/lte_rlc_statistics_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mtp3_summary_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multicast_statistics_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rtp_stream_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sctp_all_assocs_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sctp_assoc_analyse_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stats_tree_dialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wlan_statistics_dialog.cpp
${WIRESHARK_CUSTOM_TAP_SRC}
)
@ -613,7 +613,6 @@ set_source_files_properties(
add_definitions(${QT_DEFINITIONS})
register_tap_files(wireshark-tap-register.c
taps
${WIRESHARK_QT_TAP_SRC}
)

View File

@ -691,23 +691,8 @@ WIRESHARK_QT_SRC += \
extcap_options_dialog.cpp
endif
#
# Build "wireshark-tap-register.c", which contains a function
# "register_all_tap_listeners()"
# that calls the register routines for all wireshark tap listeners.
#
# We do this by grepping through sources.
#
# Formatting conventions: The name of the tap_listener_register_*
# routines must start in column zero, or must be preceded only by
# "void " starting in column zero, and must not be inside #if.
#
# The first argument is the directory in which the source files live.
# All subsequent arguments are the files to scan.
#
wireshark-tap-register.c: $(WIRESHARK_QT_TAP_SRC) $(top_srcdir)/tools/make-tap-reg.py
@echo Making wireshark-tap-register.c
@$(PYTHON) $(top_srcdir)/tools/make-tap-reg.py $(srcdir) taps $(WIRESHARK_QT_TAP_SRC)
wireshark-tap-register.c: $(WIRESHARK_QT_TAP_SRC) ../make-taps
$(AM_V_GEN)../make-taps $@ $(filter %.cpp,$^)
libqtui_a_SOURCES = \
$(WIRESHARK_QT_SRC) \
@ -725,8 +710,6 @@ nodist_libqtui_a_SOURCES = \
libqtui_a_DEPENDENCIES =
CLEANFILES = \
wireshark-tap-register.c-tmp \
wireshark-tap-register-cache.pkl \
*.moc.cpp \
qrc_*.cpp \
ui_*.h

46
ui/taps.h Normal file
View File

@ -0,0 +1,46 @@
/* 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 __TAP_REGISTER_H__
#define __TAP_REGISTER_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <glib.h>
typedef struct _tap_reg {
const char *cb_name;
void (*cb_func)(void);
} tap_reg_t;
extern tap_reg_t tap_reg_listener[];
extern const gulong tap_reg_listener_count;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __TAP_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=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

View File

@ -80,6 +80,7 @@
#include "ui/dissect_opts.h"
#include "ui/commandline.h"
#include "ui/capture_ui_utils.h"
#include "ui/taps.h"
#include "ui/qt/conversation_dialog.h"
#include "ui/qt/utils/color_utils.h"
@ -658,7 +659,10 @@ int main(int argc, char *qt_argv[])
register_all_plugin_tap_listeners();
#endif
register_all_tap_listeners();
/* Register all tap listeners. */
for (tap_reg_t *t = tap_reg_listener; t->cb_func != NULL; t++) {
t->cb_func();
}
conversation_table_set_gui_info(init_conversation_table);
hostlist_table_set_gui_info(init_endpoint_table);
srt_table_iterate_tables(register_service_response_tables, NULL);