Wireshark  4.3.0
The Wireshark network protocol analyzer
plugins.h
Go to the documentation of this file.
1 
11 #ifndef __PLUGINS_H__
12 #define __PLUGINS_H__
13 
14 #include <wireshark.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
20 typedef enum {
21  WS_PLUGIN_NONE,
22  WS_PLUGIN_EPAN,
23  WS_PLUGIN_WIRETAP,
24  WS_PLUGIN_CODEC
25 } plugin_type_e;
26 
27 typedef enum {
28  WS_PLUGIN_SCOPE_NONE,
29  WS_PLUGIN_SCOPE_USER,
30  WS_PLUGIN_SCOPE_GLOBAL,
31  WS_PLUGIN_SCOPE_CLI,
32 } plugin_scope_e;
33 
34 #define WS_PLUGIN_SPDX_GPLv2 "GPL-2.0-or-later"
35 #define WS_PLUGIN_GITLAB_URL "https://gitlab.com/wireshark/wireshark"
36 
37 #define WS_PLUGIN_DESC_DISSECTOR (1UL << 0)
38 #define WS_PLUGIN_DESC_FILE_TYPE (1UL << 1)
39 #define WS_PLUGIN_DESC_CODEC (1UL << 2)
40 #define WS_PLUGIN_DESC_EPAN (1UL << 3)
41 #define WS_PLUGIN_DESC_TAP_LISTENER (1UL << 4)
42 #define WS_PLUGIN_DESC_DFUNCTION (1UL << 5)
43 
44 #if defined(SHARED_MODULE_SUFFIX)
45 #define WS_PLUGIN_MODULE_SUFFIX SHARED_MODULE_SUFFIX
46 #elif defined(_WIN32)
47 #define WS_PLUGIN_MODULE_SUFFIX ".dll"
48 #else
49 #define WS_PLUGIN_MODULE_SUFFIX ".so"
50 #endif
51 
52 typedef void plugins_t;
53 
54 typedef void (*module_register_func)(void);
55 
56 struct ws_module {
57  uint32_t flags;
58  const char *version;
59  const char *spdx_id;
60  const char *home_url;
61  const char *blurb;
62  module_register_func register_cb;
63 };
64 
65 typedef plugin_type_e (*ws_load_module_func)(int *, int *, struct ws_module **);
66 
67 WS_DLL_PUBLIC plugins_t *plugins_init(plugin_type_e type);
68 
69 typedef void (*plugin_description_callback)(const char *name, const char *version,
70  uint32_t flags, const char *spdx_id,
71  const char *blurb, const char *home_url,
72  const char *filename, plugin_scope_e scope,
73  void *user_data);
74 
75 WS_DLL_PUBLIC void plugins_get_descriptions(plugin_description_callback callback, void *user_data);
76 
77 WS_DLL_PUBLIC void plugins_print_description(const char *name, const char *version,
78  uint32_t flags, const char *spdx_id,
79  const char *blurb, const char *home_url,
80  const char *filename, plugin_scope_e scope,
81  void *user_data _U_);
82 
83 WS_DLL_PUBLIC void plugins_dump_all(void);
84 
85 WS_DLL_PUBLIC int plugins_get_count(void);
86 
87 WS_DLL_PUBLIC void plugins_cleanup(plugins_t *plugins);
88 
89 WS_DLL_PUBLIC bool plugins_supported(void);
90 
91 WS_DLL_PUBLIC plugin_type_e plugins_check_file(const char *path);
92 
93 WS_DLL_PUBLIC char *plugins_pers_type_folder(plugin_type_e type);
94 
95 WS_DLL_PUBLIC char *plugins_file_suffix(plugin_type_e type);
96 
97 WS_DLL_PUBLIC
98 int plugins_api_max_level(plugin_type_e type);
99 
100 WS_DLL_PUBLIC
101 int plugins_abi_version(plugin_type_e type);
102 
103 #define WIRESHARK_PLUGIN_REGISTER(type, ptr_, api_level_) \
104  WS_DLL_PUBLIC plugin_type_e \
105  wireshark_load_module(int *abi_version_ptr, int *min_api_level_ptr, \
106  struct ws_module **module_ptr) \
107  { \
108  if (abi_version_ptr) \
109  *abi_version_ptr = WIRESHARK_ABI_VERSION_ ## type; \
110  if (min_api_level_ptr) \
111  *min_api_level_ptr = api_level_; \
112  if (module_ptr) \
113  *module_ptr = ptr_; \
114  return WS_PLUGIN_ ## type; \
115  }
116 
117 #define WIRESHARK_PLUGIN_REGISTER_EPAN(ptr, level) \
118  WIRESHARK_PLUGIN_REGISTER(EPAN, ptr, level)
119 
120 #define WIRESHARK_PLUGIN_REGISTER_WIRETAP(ptr, level) \
121  WIRESHARK_PLUGIN_REGISTER(WIRETAP, ptr, level)
122 
123 #define WIRESHARK_PLUGIN_REGISTER_CODEC(ptr, level) \
124  WIRESHARK_PLUGIN_REGISTER(CODEC, ptr, level)
125 
126 #ifdef __cplusplus
127 }
128 #endif /* __cplusplus */
129 
130 #endif /* __PLUGINS_H__ */
131 
132 /*
133  * Editor modelines
134  *
135  * Local Variables:
136  * c-basic-offset: 4
137  * tab-width: 8
138  * indent-tabs-mode: nil
139  * End:
140  *
141  * ex: set shiftwidth=4 tabstop=8 expandtab:
142  * :indentSize=4:tabSize=8:noTabs=true:
143  */
Definition: plugins.h:56