cdma2k: Fix Dead Store (Dead assignement/Dead increment) Warning found by Clang
[metze/wireshark/wip.git] / extcap.h
1 /* extcap.h
2  * Definitions for extcap external capture
3  * Copyright 2013, Mike Ryan <mikeryan@lacklustre.net>
4  *
5  * Wireshark - Network traffic analyzer
6  * By Gerald Combs <gerald@wireshark.org>
7  * Copyright 1998 Gerald Combs
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11
12 #ifndef __EXTCAP_H__
13 #define __EXTCAP_H__
14
15 #include <config.h>
16
17 #include <glib.h>
18
19 #ifdef _WIN32
20 #include <wsutil/unicode-utils.h>
21 #endif
22
23 #include <ui/capture_ui_utils.h>
24
25 /* As boolean flags will be allowed any form of yes, true or any number != 0 (or starting with 0)
26  * The regex will be matched case-insensitive, so only the lower-case is defined here. */
27 #define EXTCAP_BOOLEAN_REGEX "^.*([yt1-9])"
28
29 /* Prefix for the pipe interfaces */
30 #define EXTCAP_PIPE_PREFIX "wireshark_extcap"
31 #define EXTCAP_CONTROL_IN_PREFIX  "wireshark_control_ext_to_ws"
32 #define EXTCAP_CONTROL_OUT_PREFIX "wireshark_control_ws_to_ext"
33
34 #define EXTCAP_ARGUMENT_CONFIG                  "--extcap-config"
35 #define EXTCAP_ARGUMENT_RELOAD_OPTION           "--extcap-reload-option"
36 #define EXTCAP_ARGUMENT_LIST_INTERFACES         "--extcap-interfaces"
37 #define EXTCAP_ARGUMENT_INTERFACE               "--extcap-interface"
38 #define EXTCAP_ARGUMENT_LIST_DLTS               "--extcap-dlts"
39 #define EXTCAP_ARGUMENT_VERSION                 "--extcap-version"
40
41 #define EXTCAP_ARGUMENT_RUN_CAPTURE             "--capture"
42 #define EXTCAP_ARGUMENT_CAPTURE_FILTER          "--extcap-capture-filter"
43 #define EXTCAP_ARGUMENT_RUN_PIPE                "--fifo"
44 #define EXTCAP_ARGUMENT_CONTROL_IN              "--extcap-control-in"
45 #define EXTCAP_ARGUMENT_CONTROL_OUT             "--extcap-control-out"
46
47 typedef struct _extcap_info {
48     gchar * basename;
49     gchar * full_path;
50     gchar * version;
51     gchar * help;
52
53     GList * interfaces;
54 } extcap_info;
55
56 typedef enum {
57     EXTCAP_FILTER_UNKNOWN,
58     EXTCAP_FILTER_VALID,
59     EXTCAP_FILTER_INVALID
60 } extcap_filter_status;
61
62 struct _extcap_arg;
63
64 #ifdef __cplusplus
65 extern "C" {
66 #endif /* __cplusplus */
67
68 /* Registers preferences for all interfaces */
69 void
70 extcap_register_preferences(void);
71
72 /* try to get if capabilities from extcap */
73 if_capabilities_t *
74 extcap_get_if_dlts(const gchar * ifname, char ** err_str);
75
76 /* append a list of all extcap capture interfaces to the specified list */
77 GList *
78 append_extcap_interface_list(GList *list, char **err_str);
79
80 extcap_info *
81 extcap_get_tool_info(const gchar * toolname);
82
83 extcap_info *
84 extcap_get_tool_by_ifname(const gchar *ifname);
85
86 /* return the help page or NULL for the given ifname */
87 gchar *
88 extcap_get_help_for_ifname(const char *ifname);
89
90 /* get a list of all available extcap executables and their interfaces */
91 GHashTable *
92 extcap_loaded_interfaces(void);
93
94 /* remove all loaded interfaces */
95 void
96 extcap_clear_interfaces(void);
97
98 /* returns the configuration for the given interface name, or an
99  * empty list, if no configuration has been found
100  * @param ifname the interface name
101  */
102 GList *
103 extcap_get_if_configuration(const char * ifname);
104
105 /* returns the configuration values for the given argument, or an
106  * empty list, if no values could been found
107  * @param ifname the interface name
108  * @param argname the name of the argument, for which the values should be retrieved
109  */
110 GList *
111 extcap_get_if_configuration_values(const char * ifname, const char * argname, GHashTable * arguments);
112
113 /**
114  * Check if the capture filter for the given interface name is valid.
115  * @param ifname Interface to check
116  * @param filter Capture filter to check
117  * @param err_str Error string returned if filter is invalid
118  * @return Filter check status.
119  */
120 extcap_filter_status
121 extcap_verify_capture_filter(const char *ifname, const char *filter, gchar **err_str);
122
123 /**
124  * Frees the memory from extcap_get_if_configuration.
125  * @param list The list returned by extcap_get_if_configuration.
126  * @param free_args TRUE if all arguments in the list must be freed too or FALSE
127  * if the ownership of the arguments is taken by the caller.
128  */
129 void
130 extcap_free_if_configuration(GList *list, gboolean free_args);
131
132 gboolean
133 extcap_has_configuration(const char * ifname, gboolean is_required);
134
135 gboolean
136 extcap_has_toolbar(const char *ifname);
137
138 gboolean
139 extcap_init_interfaces(capture_options * capture_opts);
140
141 gboolean
142 extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe_prefix);
143
144 /* Clean up all if related stuff */
145 void
146 extcap_if_cleanup(capture_options * capture_opts, gchar ** errormsg);
147
148 struct preference *
149 extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg * arg);
150
151 /* Clean up global extcap stuff on program exit */
152 void extcap_cleanup(void);
153
154 #ifdef __cplusplus
155 }
156 #endif /* __cplusplus */
157
158 #endif
159
160 /*
161  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
162  *
163  * Local variables:
164  * c-basic-offset: 4
165  * tab-width: 8
166  * indent-tabs-mode: nil
167  * End:
168  *
169  * vi: set shiftwidth=4 tabstop=8 expandtab:
170  * :indentSize=4:tabSize=8:noTabs=true:
171  */