packet-ldap: fix regression for SASL handling
[wireshark-sm.git] / extcap.h
blob8f05d0c6619fcee47921cc19972fb26802956572
1 /* extcap.h
2 * Definitions for extcap external capture
3 * Copyright 2013, Mike Ryan <mikeryan@lacklustre.net>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __EXTCAP_H__
13 #define __EXTCAP_H__
15 #include <config.h>
17 #include <glib.h>
19 #ifdef _WIN32
20 #include <wsutil/unicode-utils.h>
21 #endif
23 #include <wsutil/plugins.h>
25 #include <ui/capture_ui_utils.h>
27 /* As boolean flags will be allowed any form of yes, true or any number != 0 (or starting with 0)
28 * The regex will be matched case-insensitive, so only the lower-case is defined here. */
29 #define EXTCAP_BOOLEAN_REGEX "^.*([yt1-9])"
31 /* Prefix for the pipe interfaces */
32 #define EXTCAP_PIPE_PREFIX "wireshark_extcap"
33 #define EXTCAP_CONTROL_IN_PREFIX "wireshark_control_ext_to_ws"
34 #define EXTCAP_CONTROL_OUT_PREFIX "wireshark_control_ws_to_ext"
36 #define EXTCAP_ARGUMENT_CONFIG "--extcap-config"
37 #define EXTCAP_ARGUMENT_RELOAD_OPTION "--extcap-reload-option"
38 #define EXTCAP_ARGUMENT_LIST_INTERFACES "--extcap-interfaces"
39 #define EXTCAP_ARGUMENT_INTERFACE "--extcap-interface"
40 #define EXTCAP_ARGUMENT_LIST_DLTS "--extcap-dlts"
41 #define EXTCAP_ARGUMENT_VERSION "--extcap-version"
43 #define EXTCAP_ARGUMENT_RUN_CAPTURE "--capture"
44 #define EXTCAP_ARGUMENT_CAPTURE_FILTER "--extcap-capture-filter"
45 #define EXTCAP_ARGUMENT_RUN_PIPE "--fifo"
46 #define EXTCAP_ARGUMENT_CONTROL_IN "--extcap-control-in"
47 #define EXTCAP_ARGUMENT_CONTROL_OUT "--extcap-control-out"
49 typedef struct _extcap_info {
50 gchar * basename;
51 gchar * full_path;
52 gchar * version;
53 gchar * help;
55 GList * interfaces;
56 } extcap_info;
58 typedef enum {
59 EXTCAP_FILTER_UNKNOWN,
60 EXTCAP_FILTER_VALID,
61 EXTCAP_FILTER_INVALID
62 } extcap_filter_status;
64 struct _extcap_arg;
66 #ifdef __cplusplus
67 extern "C" {
68 #endif /* __cplusplus */
70 /**
71 * Registers preferences for all interfaces.
72 * Initializes the extcap interface list if that hasn't already been done.
74 void
75 extcap_register_preferences(void);
77 /**
78 * Fetches the interface capabilities for the named extcap interface.
79 * Initializes the extcap interface list if that hasn't already been done.
80 * @param ifname The interface name.
81 * @param err_str Set to NULL on success, error description on failure.
82 * @return The interface capabilities on success, NULL on failure.
84 if_capabilities_t *
85 extcap_get_if_dlts(const gchar * ifname, char ** err_str);
87 /**
88 * Append a list of all extcap capture interfaces to the specified list.
89 * Initializes the extcap interface list if that hasn't already been done.
90 * @param list An existing GList of if_info_t.
91 * @param err_str Set to NULL on success, error description on failure.
92 * @return An updated list on success, an unchanged list on failure.
94 GList *
95 append_extcap_interface_list(GList *list, char **err_str);
97 /**
98 * Retrieves information about an extcap executable.
99 * Initializes the extcap interface list if that hasn't already been done.
100 * @param toolname The extcap name.
101 * @return The extcap information on success, NULL on failure.
103 extcap_info *
104 extcap_get_tool_info(const gchar * toolname);
107 * Retrieves information about an extcap interface.
108 * Initializes the extcap interface list if that hasn't already been done.
109 * @param ifname The extcap interface name.
110 * @return The extcap information on success, NULL on failure.
112 extcap_info *
113 extcap_get_tool_by_ifname(const gchar *ifname);
116 * Retrieves help information for an extcap interface.
117 * Initializes the extcap interface list if that hasn't already been done.
118 * @param ifname The extcap interface name.
119 * @return A help string on success or NULL on failure.
121 gchar *
122 extcap_get_help_for_ifname(const char *ifname);
125 * Remove all loaded extcap interfaces.
127 void
128 extcap_clear_interfaces(void);
131 * Retrieves information about all available extcap executables.
132 * Initializes the extcap interface list if that hasn't already been done.
133 * @param callback The description callback routine.
134 * @param callback_data Data to be passed to the callback routine.
136 void
137 extcap_get_descriptions(plugin_description_callback callback, void *callback_data);
140 * Print information about all available extcap executables.
141 * Initializes the extcap interface list if that hasn't already been done.
143 void
144 extcap_dump_all(void);
147 * Returns the configuration for the given interface name, or an
148 * empty list, if no configuration has been found.
149 * Initializes the extcap interface list if that hasn't already been done.
150 * @param ifname The interface name.
152 GList *
153 extcap_get_if_configuration(const char * ifname);
156 * Returns the configuration values for the given argument, or an
157 * empty list, if no values could been found.
158 * Initializes the extcap interface list if that hasn't already been done.
159 * @param ifname The interface name.
160 * @param argname The name of the argument for which the values should be retrieved.
162 GList *
163 extcap_get_if_configuration_values(const char * ifname, const char * argname, GHashTable * arguments);
166 * Check if the capture filter for the given interface name is valid.
167 * Initializes the extcap interface list if that hasn't already been done.
168 * @param ifname Interface to check
169 * @param filter Capture filter to check
170 * @param err_str Error string returned if filter is invalid
171 * @return Filter check status.
173 extcap_filter_status
174 extcap_verify_capture_filter(const char *ifname, const char *filter, gchar **err_str);
177 * Frees the memory from extcap_get_if_configuration.
178 * @param list The list returned by extcap_get_if_configuration.
179 * @param free_args TRUE if all arguments in the list must be freed too or FALSE
180 * if the ownership of the arguments is taken by the caller.
182 void
183 extcap_free_if_configuration(GList *list, gboolean free_args);
186 * Checks to see if an interface has configurable options.
187 * If is_required is FALSE: returns TRUE if the extcap interface has
188 * configurable options.
189 * If is_required is TRUE: returns TRUE when the extcap interface has
190 * configurable options that required modification. (For example, when an
191 * argument is required but empty.)
192 * Initializes the extcap interface list if that hasn't already been done.
193 * @param ifname Interface to check.
194 * @param is_required Required configuration flag.
196 gboolean
197 extcap_has_configuration(const char * ifname, gboolean is_required);
200 * Checks to see if the interface has an associated toolbar.
201 * Initializes the extcap interface list if that hasn't already been done.
202 * @param ifname Interface to check.
203 * @return TRUE if the interface has a toolbar, FALSE otherwise.
205 gboolean
206 extcap_has_toolbar(const char *ifname);
209 * Initializes each extcap interface with the supplied capture options.
210 * Initializes the extcap interface list if that hasn't already been done.
211 * @param capture_opts Capture options.
212 * @return TRUE on success, FALSE on failure.
214 gboolean
215 extcap_init_interfaces(capture_options * capture_opts);
218 * Clean up all if related stuff.
219 * @param capture_opts Capture options.
220 * @param errormsg Set to NULL on success, error description on failure.
222 void
223 extcap_if_cleanup(capture_options * capture_opts, gchar ** errormsg);
226 * Fetch an extcap preference for a given argument.
227 * Initializes the extcap interface list if that hasn't already been done.
228 * @param ifname The interface to check.
229 * @param arg The command line argument to check.
230 * @return The associated preference on success, NULL on failure.
232 struct preference *
233 extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg * arg);
236 * Clean up global extcap stuff on program exit.
238 void extcap_cleanup(void);
240 #ifdef __cplusplus
242 #endif /* __cplusplus */
244 #endif
247 * Editor modelines - https://www.wireshark.org/tools/modelines.html
249 * Local variables:
250 * c-basic-offset: 4
251 * tab-width: 8
252 * indent-tabs-mode: nil
253 * End:
255 * vi: set shiftwidth=4 tabstop=8 expandtab:
256 * :indentSize=4:tabSize=8:noTabs=true: