fix no marker pdu fragmentation epan/dissectors/packet-iwarp-mpa.c
[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 /* Count the number of extcap binaries */
69 guint
70 extcap_count(void);
71
72 /* Registers preferences for all interfaces */
73 void
74 extcap_register_preferences(void);
75
76 /* try to get if capabilities from extcap */
77 if_capabilities_t *
78 extcap_get_if_dlts(const gchar * ifname, char ** err_str);
79
80 /* append a list of all extcap capture interfaces to the specified list */
81 GList *
82 append_extcap_interface_list(GList *list, char **err_str);
83
84 extcap_info *
85 extcap_get_tool_info(const gchar * toolname);
86
87 extcap_info *
88 extcap_get_tool_by_ifname(const gchar *ifname);
89
90 /* return the help page or NULL for the given ifname */
91 gchar *
92 extcap_get_help_for_ifname(const char *ifname);
93
94 /* get a list of all available extcap executables and their interfaces */
95 GHashTable *
96 extcap_loaded_interfaces(void);
97
98 /* remove all loaded interfaces */
99 void
100 extcap_clear_interfaces(void);
101
102 /* returns the configuration for the given interface name, or an
103  * empty list, if no configuration has been found
104  * @param ifname the interface name
105  */
106 GList *
107 extcap_get_if_configuration(const char * ifname);
108
109 /* returns the configuration values for the given argument, or an
110  * empty list, if no values could been found
111  * @param ifname the interface name
112  * @param argname the name of the argument, for which the values should be retrieved
113  */
114 GList *
115 extcap_get_if_configuration_values(const char * ifname, const char * argname, GHashTable * arguments);
116
117 /**
118  * Check if the capture filter for the given interface name is valid.
119  * @param ifname Interface to check
120  * @param filter Capture filter to check
121  * @param err_str Error string returned if filter is invalid
122  * @return Filter check status.
123  */
124 extcap_filter_status
125 extcap_verify_capture_filter(const char *ifname, const char *filter, gchar **err_str);
126
127 /**
128  * Frees the memory from extcap_get_if_configuration.
129  * @param list The list returned by extcap_get_if_configuration.
130  * @param free_args TRUE if all arguments in the list must be freed too or FALSE
131  * if the ownership of the arguments is taken by the caller.
132  */
133 void
134 extcap_free_if_configuration(GList *list, gboolean free_args);
135
136 gboolean
137 extcap_has_configuration(const char * ifname, gboolean is_required);
138
139 gboolean
140 extcap_has_toolbar(const char *ifname);
141
142 gboolean
143 extcap_init_interfaces(capture_options * capture_opts);
144
145 gboolean
146 extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe_prefix);
147
148 /* Clean up all if related stuff */
149 void
150 extcap_if_cleanup(capture_options * capture_opts, gchar ** errormsg);
151
152 struct preference *
153 extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg * arg);
154
155 /* Clean up global extcap stuff on program exit */
156 void extcap_cleanup(void);
157
158 #ifdef __cplusplus
159 }
160 #endif /* __cplusplus */
161
162 #endif
163
164 /*
165  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
166  *
167  * Local variables:
168  * c-basic-offset: 4
169  * tab-width: 8
170  * indent-tabs-mode: nil
171  * End:
172  *
173  * vi: set shiftwidth=4 tabstop=8 expandtab:
174  * :indentSize=4:tabSize=8:noTabs=true:
175  */