Revert "plugins: Add a codecs API level"
This reverts commit 7f32c90ab9b7c6f19fb38011d5cb0b7ce815046c.
This commit is contained in:
parent
3d42d1dce7
commit
6d1b32b688
@ -1,5 +1,5 @@
|
||||
#
|
||||
function(make_plugin_register _outputfile _registertype _api_level _blurb)
|
||||
function(register_plugin_files _outputfile _registertype _blurb)
|
||||
file(RELATIVE_PATH output "${CMAKE_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/${_outputfile}")
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
@ -9,7 +9,6 @@ function(make_plugin_register _outputfile _registertype _api_level _blurb)
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${_registertype}
|
||||
${_blurb}
|
||||
${_api_level}
|
||||
${ARGN}
|
||||
COMMENT "Generating ${output}"
|
||||
DEPENDS
|
||||
@ -18,11 +17,3 @@ function(make_plugin_register _outputfile _registertype _api_level _blurb)
|
||||
VERBATIM
|
||||
)
|
||||
endfunction()
|
||||
|
||||
macro(register_plugin_files _outputfile _registertype _blurb)
|
||||
make_plugin_register(${_outputfile} ${_registertype} 0 ${_blurb} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
macro(register_codec_files _outputfile _api_level _blurb)
|
||||
make_plugin_register(${_outputfile} plugin_codec ${_api_level} ${_blurb} ${ARGN})
|
||||
endmacro()
|
||||
|
@ -169,9 +169,7 @@ by going to the plugins/foo directory and running
|
||||
|
||||
make install
|
||||
|
||||
5. Plugin registration
|
||||
|
||||
5.1 Registration API common to all plugin types
|
||||
5. Plugin registration API common to all plugin types
|
||||
|
||||
You must include the plugin API header:
|
||||
|
||||
@ -220,24 +218,7 @@ WIRESHARK_PLUGIN_REGISTER_CODEC(&module, 0)
|
||||
As the name implies each plugin binary type has a specific registration
|
||||
macro (but they all have the same arguments). The macro takes a pointer to
|
||||
the struct ws_module as the first argument. The second argument is
|
||||
unused only by codec plugins and explained in the next section. For all
|
||||
other plugin types it is ignored and should be zero.
|
||||
|
||||
5.2 The plugin minimum API level argument
|
||||
|
||||
The ABI version test for equality is the main check for compatibility for
|
||||
all plugin types but additionally the codec plugin API has an extra
|
||||
check called the API level. The codec API is very small and changes very
|
||||
infrequently. Codecs plugins that only use the API in wsutil/codecs.h should
|
||||
declare a minimum API level required. If the API needs to be changed and that
|
||||
can be done in a backward-compatible manner for the ABI/API then only the
|
||||
maximum API level will be increased and the minimum API level can stay the same.
|
||||
|
||||
This means the same plugin can still be loaded successfully without
|
||||
recompilation using the older API (possibly with reduced functionality).
|
||||
|
||||
This is currently experimental and may change in the future or be removed
|
||||
entirely.
|
||||
currently unused and should be zero.
|
||||
|
||||
6 How to plugin related interface options
|
||||
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"A-law G.711"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"G.722"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"G.726"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"G.729"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"OpenCORE Adaptive Multi Rate (AMR)"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"Internet Low Bitrate Codec (iLBC)"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"16-bit audio, mono"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"Opus audio"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
@ -27,7 +27,8 @@ set_source_files_properties(
|
||||
COMPILE_FLAGS "${WERROR_COMMON_FLAGS}"
|
||||
)
|
||||
|
||||
register_codec_files(plugin.c 1
|
||||
register_plugin_files(plugin.c
|
||||
plugin_codec
|
||||
"Bluetooth SBC"
|
||||
${CODEC_SRC}
|
||||
)
|
||||
|
2
sharkd.c
2
sharkd.c
@ -54,7 +54,7 @@
|
||||
#include <epan/uat-int.h>
|
||||
#include <epan/secrets.h>
|
||||
|
||||
#include <wsutil/codecs_priv.h>
|
||||
#include <wsutil/codecs.h>
|
||||
|
||||
#include <wsutil/str_util.h>
|
||||
#include <wsutil/utf8_entities.h>
|
||||
|
@ -23,13 +23,9 @@ registertype = sys.argv[2]
|
||||
#
|
||||
plugin_blurb = sys.argv[3]
|
||||
#
|
||||
# The fourth argument is the plugin minimum api level
|
||||
#
|
||||
min_api_level = sys.argv[4]
|
||||
#
|
||||
# All subsequent arguments are the files to scan.
|
||||
#
|
||||
files = sys.argv[5:]
|
||||
files = sys.argv[4:]
|
||||
|
||||
final_filename = "plugin.c"
|
||||
preamble = """\
|
||||
@ -205,8 +201,8 @@ static struct ws_module module = {
|
||||
.register_cb = &plugin_register,
|
||||
};
|
||||
|
||||
%s(&module, %s)
|
||||
""" % (DESCRIPTION_FLAG[registertype], plugin_blurb, PLUGIN_REGISTER[registertype], min_api_level)
|
||||
%s(&module, 0)
|
||||
""" % (DESCRIPTION_FLAG[registertype], plugin_blurb, PLUGIN_REGISTER[registertype])
|
||||
|
||||
try:
|
||||
fh = open(final_filename, 'w')
|
||||
|
2
tshark.c
2
tshark.c
@ -125,7 +125,7 @@
|
||||
#include "extcap.h"
|
||||
|
||||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/codecs_priv.h>
|
||||
#include <wsutil/codecs.h>
|
||||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include <epan/dissectors/packet-kerberos.h>
|
||||
#endif
|
||||
|
||||
#include <wsutil/codecs_priv.h>
|
||||
#include <wsutil/codecs.h>
|
||||
|
||||
#include <extcap.h>
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include <epan/dissectors/packet-kerberos.h>
|
||||
#endif
|
||||
|
||||
#include <wsutil/codecs_priv.h>
|
||||
#include <wsutil/codecs.h>
|
||||
|
||||
#include <extcap.h>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <wsutil/codecs_priv.h>
|
||||
#include <wsutil/codecs.h>
|
||||
|
||||
#include <epan/rtp_pt.h>
|
||||
#include <epan/dissectors/packet-rtp.h>
|
||||
|
@ -12,13 +12,4 @@
|
||||
#define WIRESHARK_ABI_VERSION_WIRETAP @PROJECT_ABI_VERSION_WIRETAP@
|
||||
#define WIRESHARK_ABI_VERSION_CODEC @PROJECT_ABI_VERSION_CODEC@
|
||||
|
||||
/*
|
||||
* API level for codec plugins
|
||||
*/
|
||||
/* The minimum level is the minimum API requirement for a codec
|
||||
* to be used with this version of Wireshark (possibly with reduced functionality). */
|
||||
#define WIRESHARK_API_MIN_LEVEL_CODEC 1
|
||||
/* The maximum level supported for this version of Wireshark. */
|
||||
#define WIRESHARK_API_MAX_LEVEL_CODEC 1
|
||||
|
||||
#endif /* __WS_VERSION_H__ */
|
||||
|
@ -10,8 +10,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "codecs_priv.h"
|
||||
#include "codecs.h"
|
||||
|
||||
#include <wsutil/wslog.h>
|
||||
#ifdef HAVE_PLUGINS
|
||||
#include <wsutil/plugins.h>
|
||||
#endif
|
||||
|
@ -11,31 +11,38 @@
|
||||
#ifndef _CODECS_H_
|
||||
#define _CODECS_H_
|
||||
|
||||
#include <wireshark.h>
|
||||
#include "ws_symbol_export.h"
|
||||
#include "ws_attributes.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "wsutil/wmem/wmem_map.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* IMPORTANT: This header is the public plugin API for codecs.
|
||||
*
|
||||
* When this API changes the API level must be bumped in ws_version.h.in.
|
||||
* If the change is backward-compatible only the maximum (codec) API level is increased by one.
|
||||
* If the change is backward-incompatible, meaning a plugin that does not use
|
||||
* new functionaly may not compile anymore, both the maximum (codec) API level is increased by one
|
||||
* and the minimum (codec) API level is bumped to the new maximum (codec) API level.
|
||||
*
|
||||
* API functionality above level one should be annotated with a comment indicating
|
||||
* the API level required (when it was first introduced).
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
void (*register_codec_module)(void); /* routine to call to register a codec */
|
||||
} codecs_plugin;
|
||||
|
||||
WS_DLL_PUBLIC void codecs_register_plugin(const codecs_plugin *plug);
|
||||
|
||||
/**
|
||||
* For all built-in codecs and codec plugins, call their register routines.
|
||||
*/
|
||||
WS_DLL_PUBLIC void codecs_init(void);
|
||||
|
||||
WS_DLL_PUBLIC void codecs_cleanup(void);
|
||||
|
||||
/**
|
||||
* Get compile-time information for libraries used by libwscodecs.
|
||||
*/
|
||||
WS_DLL_PUBLIC void codec_get_compiled_version_info(GString *str);
|
||||
|
||||
struct codec_handle;
|
||||
typedef struct codec_handle *codec_handle_t;
|
||||
|
||||
typedef struct _codec_context_t {
|
||||
unsigned sample_rate;
|
||||
unsigned channels;
|
||||
@ -112,6 +119,15 @@ typedef size_t (*codec_decode_fn)(codec_context_t *context,
|
||||
WS_DLL_PUBLIC bool register_codec(const char *name, codec_init_fn init_fn,
|
||||
codec_release_fn release_fn, codec_get_channels_fn channels_fn,
|
||||
codec_get_frequency_fn frequency_fn, codec_decode_fn decode_fn);
|
||||
WS_DLL_PUBLIC bool deregister_codec(const char *name);
|
||||
WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
|
||||
WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
|
||||
WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
|
||||
WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
|
||||
WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
|
||||
WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
|
||||
const void *inputBytes, size_t inputBytesSize,
|
||||
void *outputSamples, size_t *outputSamplesSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
/** @file
|
||||
* codecs interface 2007 Tomas Kukosa
|
||||
*
|
||||
* Wireshark - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@wireshark.org>
|
||||
* Copyright 1998 Gerald Combs
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _CODECS_INT_H_
|
||||
#define _CODECS_INT_H_
|
||||
|
||||
#include "codecs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
struct codec_handle;
|
||||
typedef struct codec_handle *codec_handle_t;
|
||||
|
||||
WS_DLL_PUBLIC bool deregister_codec(const char *name);
|
||||
|
||||
WS_DLL_PUBLIC codec_handle_t find_codec(const char *name);
|
||||
|
||||
WS_DLL_PUBLIC void *codec_init(codec_handle_t codec, codec_context_t *context);
|
||||
|
||||
WS_DLL_PUBLIC void codec_release(codec_handle_t codec, codec_context_t *context);
|
||||
|
||||
WS_DLL_PUBLIC unsigned codec_get_channels(codec_handle_t codec, codec_context_t *context);
|
||||
|
||||
WS_DLL_PUBLIC unsigned codec_get_frequency(codec_handle_t codec, codec_context_t *context);
|
||||
|
||||
WS_DLL_PUBLIC size_t codec_decode(codec_handle_t codec, codec_context_t *context,
|
||||
const void *inputBytes, size_t inputBytesSize,
|
||||
void *outputSamples, size_t *outputSamplesSize);
|
||||
|
||||
/**
|
||||
* For all built-in codecs and codec plugins, call their register routines.
|
||||
*/
|
||||
WS_DLL_PUBLIC void codecs_init(void);
|
||||
|
||||
WS_DLL_PUBLIC void codecs_cleanup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _CODECS_INT_H_ */
|
||||
|
||||
/*
|
||||
* Editor modelines - https://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:
|
||||
*/
|
@ -111,7 +111,7 @@ compare_plugins(gconstpointer a, gconstpointer b)
|
||||
|
||||
static bool
|
||||
pass_plugin_compatibility(const char *name, plugin_type_e type,
|
||||
int abi_version, int min_api_level)
|
||||
int abi_version)
|
||||
{
|
||||
if (abi_version != plugins_abi_version(type)) {
|
||||
report_failure("The plugin '%s' has incompatible ABI, have version %d, expected %d",
|
||||
@ -119,14 +119,6 @@ pass_plugin_compatibility(const char *name, plugin_type_e type,
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check if the minimum requested API level is supported by this version
|
||||
* of Wireshark (only used with codec plugins). */
|
||||
if (min_api_level > 0 && min_api_level > plugins_api_max_level(type)) {
|
||||
report_failure("The plugin '%s' requires API level %d, have %d",
|
||||
name, min_api_level, plugins_api_max_level(type));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -144,7 +136,6 @@ scan_plugins_dir(GHashTable *plugins_module, const char *dirpath,
|
||||
plugin *new_plug;
|
||||
plugin_type_e have_type;
|
||||
int abi_version;
|
||||
int min_api_level;
|
||||
struct ws_module *module;
|
||||
char *s;
|
||||
|
||||
@ -205,7 +196,7 @@ scan_plugins_dir(GHashTable *plugins_module, const char *dirpath,
|
||||
|
||||
DIAG_OFF_PEDANTIC
|
||||
/* Found it, load module. */
|
||||
have_type = ((ws_load_module_func)symbol)(&abi_version, &min_api_level, &module);
|
||||
have_type = ((ws_load_module_func)symbol)(&abi_version, NULL, &module);
|
||||
DIAG_ON_PEDANTIC
|
||||
|
||||
if (have_type != type) {
|
||||
@ -217,7 +208,7 @@ DIAG_ON_PEDANTIC
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!pass_plugin_compatibility(name, type, abi_version, min_api_level)) {
|
||||
if (!pass_plugin_compatibility(name, type, abi_version)) {
|
||||
g_module_close(handle);
|
||||
g_free(plugin_file);
|
||||
continue;
|
||||
@ -376,7 +367,6 @@ plugins_check_file(const char *from_filename)
|
||||
void *symbol;
|
||||
plugin_type_e have_type;
|
||||
int abi_version;
|
||||
int min_api_level;
|
||||
|
||||
handle = g_module_open(from_filename, G_MODULE_BIND_LAZY);
|
||||
if (handle == NULL) {
|
||||
@ -393,12 +383,12 @@ plugins_check_file(const char *from_filename)
|
||||
|
||||
DIAG_OFF_PEDANTIC
|
||||
/* Load module. */
|
||||
have_type = ((ws_load_module_func)symbol)(&abi_version, &min_api_level, NULL);
|
||||
have_type = ((ws_load_module_func)symbol)(&abi_version, NULL, NULL);
|
||||
DIAG_ON_PEDANTIC
|
||||
|
||||
name = g_path_get_basename(from_filename);
|
||||
|
||||
if (!pass_plugin_compatibility(name, have_type, abi_version, min_api_level)) {
|
||||
if (!pass_plugin_compatibility(name, have_type, abi_version)) {
|
||||
g_module_close(handle);
|
||||
g_free(name);
|
||||
return WS_PLUGIN_NONE;
|
||||
@ -422,23 +412,6 @@ plugins_file_suffix(plugin_type_e type)
|
||||
return ws_strdup_printf("%s.%d", WS_PLUGIN_MODULE_SUFFIX, plugins_abi_version(type));
|
||||
}
|
||||
|
||||
int
|
||||
plugins_api_max_level(plugin_type_e type)
|
||||
{
|
||||
/*
|
||||
* The API level is only defined for codecs because it is a small
|
||||
* and easy to define API.
|
||||
* Maybe we could do the same for wiretap (file type) plugins?
|
||||
* For the various epan plugin types it seems pointless and futile.
|
||||
*/
|
||||
switch (type) {
|
||||
case WS_PLUGIN_CODEC: return WIRESHARK_API_MAX_LEVEL_CODEC;
|
||||
default: return 0;
|
||||
}
|
||||
ws_assert_not_reached();
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
plugins_abi_version(plugin_type_e type)
|
||||
{
|
||||
|
@ -94,9 +94,6 @@ WS_DLL_PUBLIC char *plugins_pers_type_folder(plugin_type_e type);
|
||||
|
||||
WS_DLL_PUBLIC char *plugins_file_suffix(plugin_type_e type);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
int plugins_api_max_level(plugin_type_e type);
|
||||
|
||||
WS_DLL_PUBLIC
|
||||
int plugins_abi_version(plugin_type_e type);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user