Revert "TODO: smb2: simplify preauth_hash calculation..."
[wireshark-sm.git] / extcap.h
blob6848e481ff7161e405583b98e546c02161d672c2
1 /** @file
3 * Definitions for extcap external capture
4 * Copyright 2013, Mike Ryan <mikeryan@lacklustre.net>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
13 #ifndef __EXTCAP_H__
14 #define __EXTCAP_H__
17 #include <glib.h>
19 #ifdef _WIN32
20 #include <wsutil/unicode-utils.h>
21 #endif
23 #include <wsutil/plugins.h>
25 #include "capture/capture_session.h"
26 #include <ui/capture_ui_utils.h>
28 /* As boolean flags will be allowed any form of yes, true or any number != 0 (or starting with 0)
29 * The regex will be matched case-insensitive, so only the lower-case is defined here. */
30 #define EXTCAP_BOOLEAN_REGEX "^.*([yt1-9])"
32 /* Prefix for the pipe interfaces */
33 #define EXTCAP_PIPE_PREFIX "wireshark_extcap"
34 #define EXTCAP_CONTROL_IN_PREFIX "wireshark_control_ext_to_ws"
35 #define EXTCAP_CONTROL_OUT_PREFIX "wireshark_control_ws_to_ext"
37 #define EXTCAP_ARGUMENT_CONFIG "--extcap-config"
38 #define EXTCAP_ARGUMENT_RELOAD_OPTION "--extcap-reload-option"
39 #define EXTCAP_ARGUMENT_LIST_INTERFACES "--extcap-interfaces"
40 #define EXTCAP_ARGUMENT_INTERFACE "--extcap-interface"
41 #define EXTCAP_ARGUMENT_LIST_DLTS "--extcap-dlts"
42 #define EXTCAP_ARGUMENT_VERSION "--extcap-version"
44 #define EXTCAP_ARGUMENT_RUN_CAPTURE "--capture"
45 #define EXTCAP_ARGUMENT_CAPTURE_FILTER "--extcap-capture-filter"
46 #define EXTCAP_ARGUMENT_RUN_PIPE "--fifo"
47 #define EXTCAP_ARGUMENT_CONTROL_IN "--extcap-control-in"
48 #define EXTCAP_ARGUMENT_CONTROL_OUT "--extcap-control-out"
50 typedef struct _extcap_info {
51 char * basename;
52 char * full_path;
53 char * version;
54 char * help;
56 GList * interfaces;
57 } extcap_info;
59 typedef enum {
60 EXTCAP_FILTER_UNKNOWN,
61 EXTCAP_FILTER_VALID,
62 EXTCAP_FILTER_INVALID
63 } extcap_filter_status;
65 typedef void (*extcap_plugin_description_callback)(const char *, const char *,
66 const char *, const char *,
67 void *);
69 struct _extcap_arg;
71 #ifdef __cplusplus
72 extern "C" {
73 #endif /* __cplusplus */
75 /**
76 * Registers preferences for all interfaces.
77 * Initializes the extcap interface list if that hasn't already been done.
79 void
80 extcap_register_preferences(void);
82 /**
83 * Fetches the interface capabilities for the named extcap interface.
84 * Initializes the extcap interface list if that hasn't already been done.
85 * @param ifname The interface name.
86 * @param err_str Set to NULL on success, error description on failure.
87 * @return The interface capabilities on success, NULL on failure.
89 if_capabilities_t *
90 extcap_get_if_dlts(const char * ifname, char ** err_str);
92 /**
93 * Append a list of all extcap capture interfaces to the specified list.
94 * Initializes the extcap interface list if that hasn't already been done.
95 * @param list An existing GList of if_info_t.
96 * @return An updated list on success, an unchanged list on failure.
98 GList *
99 append_extcap_interface_list(GList *list);
102 * Retrieves information about an extcap executable.
103 * Initializes the extcap interface list if that hasn't already been done.
104 * @param toolname The extcap name.
105 * @return The extcap information on success, NULL on failure.
107 extcap_info *
108 extcap_get_tool_info(const char * toolname);
111 * Retrieves information about an extcap interface.
112 * Initializes the extcap interface list if that hasn't already been done.
113 * @param ifname The extcap interface name.
114 * @return The extcap information on success, NULL on failure.
116 extcap_info *
117 extcap_get_tool_by_ifname(const char *ifname);
120 * Retrieves help information for an extcap interface.
121 * Initializes the extcap interface list if that hasn't already been done.
122 * @param ifname The extcap interface name.
123 * @return A help string on success or NULL on failure.
125 char *
126 extcap_get_help_for_ifname(const char *ifname);
129 * Remove all loaded extcap interfaces.
131 void
132 extcap_clear_interfaces(void);
135 * Retrieves information about all available extcap executables.
136 * Initializes the extcap interface list if that hasn't already been done.
137 * @param callback The description callback routine.
138 * @param callback_data Data to be passed to the callback routine.
140 void
141 extcap_get_descriptions(extcap_plugin_description_callback callback, void *callback_data);
144 * Print information about all available extcap executables.
145 * Initializes the extcap interface list if that hasn't already been done.
147 void
148 extcap_dump_all(void);
151 * Returns the configuration for the given interface name, or an
152 * empty list, if no configuration has been found.
153 * Initializes the extcap interface list if that hasn't already been done.
154 * @param ifname The interface name.
156 GList *
157 extcap_get_if_configuration(const char * ifname);
160 * Returns the configuration values for the given argument, or an
161 * empty list, if no values could been found.
162 * Initializes the extcap interface list if that hasn't already been done.
163 * @param ifname The interface name.
164 * @param argname The name of the argument for which the values should be retrieved.
166 GList *
167 extcap_get_if_configuration_values(const char * ifname, const char * argname, GHashTable * arguments);
170 * Check if the capture filter for the given interface name is valid.
171 * Initializes the extcap interface list if that hasn't already been done.
172 * @param ifname Interface to check
173 * @param filter Capture filter to check
174 * @param err_str Error string returned if filter is invalid
175 * @return Filter check status.
177 extcap_filter_status
178 extcap_verify_capture_filter(const char *ifname, const char *filter, char **err_str);
181 * Frees the memory from extcap_get_if_configuration.
182 * @param list The list returned by extcap_get_if_configuration.
183 * @param free_args true if all arguments in the list must be freed too or false
184 * if the ownership of the arguments is taken by the caller.
186 void
187 extcap_free_if_configuration(GList *list, bool free_args);
190 * Checks to see if an interface has configurable options.
191 * Initializes the extcap interface list if that hasn't already been done.
192 * @param ifname Interface to check.
194 bool
195 extcap_has_configuration(const char * ifname);
198 * Checks if an interface has configurable options and if all are configured.
199 * Returns true when the extcap interface has
200 * configurable options that required modification. (For example, when an
201 * argument is required but empty.)
202 * Initializes the extcap interface list if that hasn't already been done.
203 * @param ifname Interface to check.
205 bool
206 extcap_requires_configuration(const char * ifname);
209 * Checks to see if the interface has an associated toolbar.
210 * Initializes the extcap interface list if that hasn't already been done.
211 * @param ifname Interface to check.
212 * @return true if the interface has a toolbar, false otherwise.
214 bool
215 extcap_has_toolbar(const char *ifname);
217 #ifdef HAVE_LIBPCAP
219 * Cleanup after capture session.
220 * @param cap_session Capture session.
221 * @return true if session can be stopped, false if there are remaining tasks.
223 bool
224 extcap_session_stop(capture_session *cap_session);
227 * Initializes each extcap interface with the supplied capture session.
228 * Initializes the extcap interface list if that hasn't already been done.
229 * @param cap_session Capture session.
230 * @return true on success, false on failure.
232 bool
233 extcap_init_interfaces(capture_session *cap_session);
234 #endif /* HAVE_LIBPCAP */
237 * Notify all extcaps that capture session should be stopped.
238 * Forcefully stop session if extcaps do not finish before timeout.
239 * @param cap_session Capture session.
241 void
242 extcap_request_stop(capture_session *cap_session);
245 * Fetch an extcap preference for a given argument.
246 * Initializes the extcap interface list if that hasn't already been done.
247 * @param ifname The interface to check.
248 * @param arg The command line argument to check.
249 * @return The associated preference on success, NULL on failure.
251 struct preference *
252 extcap_pref_for_argument(const char *ifname, struct _extcap_arg * arg);
255 * Clean up global extcap stuff on program exit.
257 void extcap_cleanup(void);
259 #ifdef __cplusplus
261 #endif /* __cplusplus */
263 #endif
266 * Editor modelines - https://www.wireshark.org/tools/modelines.html
268 * Local variables:
269 * c-basic-offset: 4
270 * tab-width: 8
271 * indent-tabs-mode: nil
272 * End:
274 * vi: set shiftwidth=4 tabstop=8 expandtab:
275 * :indentSize=4:tabSize=8:noTabs=true: