extcap: Reduce number of scans and storage
[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  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  */
23
24 #ifndef __EXTCAP_H__
25 #define __EXTCAP_H__
26
27 #include <config.h>
28
29 #include <glib.h>
30
31 #ifdef _WIN32
32 #include <windows.h>
33 #include <wsutil/unicode-utils.h>
34 #endif
35
36 #include <ui/capture_ui_utils.h>
37
38 /* As boolean flags will be allowed any form of yes, true or any number != 0 (or starting with 0)
39  * The regex will be matched case-insensitive, so only the lower-case is defined here. */
40 #define EXTCAP_BOOLEAN_REGEX "^.*([yt1-9])"
41
42 /* Prefix for the pipe interfaces */
43 #define EXTCAP_PIPE_PREFIX "wireshark_extcap"
44
45 #define EXTCAP_ARGUMENT_CONFIG                  "--extcap-config"
46 #define EXTCAP_ARGUMENT_LIST_INTERFACES "--extcap-interfaces"
47 #define EXTCAP_ARGUMENT_INTERFACE               "--extcap-interface"
48 #define EXTCAP_ARGUMENT_LIST_DLTS               "--extcap-dlts"
49
50 #define EXTCAP_ARGUMENT_RUN_CAPTURE             "--capture"
51 #define EXTCAP_ARGUMENT_CAPTURE_FILTER          "--extcap-capture-filter"
52 #define EXTCAP_ARGUMENT_RUN_PIPE                "--fifo"
53
54 typedef struct _extcap_info {
55     gchar * basename;
56     gchar * full_path;
57     gchar * version;
58
59     GList * interfaces;
60 } extcap_info;
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 /* return the help page or NULL for the given ifname */
85 gchar *
86 extcap_get_help_for_ifname(const char *ifname);
87
88 /* get a list of all available extcap executables and their interfaces */
89 GHashTable *
90 extcap_loaded_interfaces(void);
91
92 /* remove all loaded interfaces */
93 void
94 extcap_clear_interfaces(void);
95
96 /* returns the configuration for the given interface name, or an
97  * empty list, if no configuration has been found */
98 GList *
99 extcap_get_if_configuration(const char * ifname);
100
101 /**
102  * Frees the memory from extcap_get_if_configuration.
103  * @param list The list returned by extcap_get_if_configuration.
104  * @param free_args TRUE if all arguments in the list must be freed too or FALSE
105  * if the ownership of the arguments is taken by the caller.
106  */
107 void
108 extcap_free_if_configuration(GList *list, gboolean free_args);
109
110 gboolean
111 extcap_has_configuration(const char * ifname, gboolean is_required);
112
113 #ifdef WIN32
114 HANDLE
115 extcap_get_win32_handle();
116 #endif
117
118 gboolean
119 extcap_init_interfaces(capture_options * capture_opts);
120
121 gboolean
122 extcap_create_pipe(char ** fifo);
123
124 /* Clean up all if related stuff */
125 void
126 extcap_if_cleanup(capture_options * capture_opts _U_, gchar ** errormsg);
127
128 struct preference *
129 extcap_pref_for_argument(const gchar *ifname, struct _extcap_arg * arg);
130
131 void
132 extcap_pref_store(struct _extcap_arg * arg, const char * newval);
133
134 /* Clean up global extcap stuff on program exit */
135 void extcap_cleanup(void);
136
137 #ifdef __cplusplus
138 }
139 #endif /* __cplusplus */
140
141 #endif
142
143 /*
144  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
145  *
146  * Local variables:
147  * c-basic-offset: 4
148  * tab-width: 8
149  * indent-tabs-mode: nil
150  * End:
151  *
152  * vi: set shiftwidth=4 tabstop=8 expandtab:
153  * :indentSize=4:tabSize=8:noTabs=true:
154  */