Kerberos: add kerberos_inject_longterm_key() helper function
[wireshark-sm.git] / capture / capture-pcap-util-unix.c
blob88dc3e3d3e7e6aae7128f8ae07399b0ec16b772f
1 /* capture-pcap-util-unix.c
2 * UN*X-specific utility routines for packet capture
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include "config.h"
13 #include <wireshark.h>
15 #include <string.h>
16 #include <ws_attributes.h>
17 #include <wsutil/feature_list.h>
19 #ifdef HAVE_LIBPCAP
21 #include <pcap/pcap.h>
23 #ifdef HAVE_LIBCAP
24 # include <sys/capability.h>
25 #endif
27 #include "capture/capture_ifinfo.h"
28 #include "capture/capture-pcap-util.h"
29 #include "capture/capture-pcap-util-int.h"
31 #ifdef HAVE_PCAP_REMOTE
32 GList *
33 get_remote_interface_list(const char *hostname, const char *port,
34 int auth_type, const char *username,
35 const char *passwd, int *err, char **err_str)
37 return get_interface_list_findalldevs_ex(hostname, port, auth_type,
38 username, passwd, err, err_str);
40 #endif
42 GList *
43 get_interface_list(int *err, char **err_str)
45 return get_interface_list_findalldevs(err, err_str);
49 * Get an error message string for a CANT_GET_INTERFACE_LIST error from
50 * "get_interface_list()".
52 char *
53 cant_get_if_list_error_message(const char *err_str)
55 return ws_strdup_printf("Can't get list of interfaces: %s", err_str);
58 if_capabilities_t *
59 get_if_capabilities_local(interface_options *interface_opts,
60 cap_device_open_status *status, char **status_str)
62 return get_if_capabilities_pcap_create(interface_opts, status,
63 status_str);
66 pcap_t *
67 open_capture_device_local(capture_options *capture_opts,
68 interface_options *interface_opts, int timeout,
69 cap_device_open_status *open_status,
70 char (*open_status_str)[PCAP_ERRBUF_SIZE])
73 * We're not opening a remote device; use pcap_create() and
74 * pcap_activate() so that we can set various options.
76 return open_capture_device_pcap_create(capture_opts,
77 interface_opts, timeout, open_status, open_status_str);
81 * Get the versions of libpcap, libpcap, and libnl with which we were
82 * compiled, and append them to a GString.
84 void
85 gather_caplibs_compile_info(feature_list l)
88 * NOTE: in *some* flavors of UN*X, the data from a shared
89 * library might be linked into executable images that are
90 * linked with that shared library, in which case you could
91 * look at pcap_version[] to get the version with which
92 * the program was compiled.
94 * In other flavors of UN*X, that doesn't happen, so
95 * pcap_version[] gives you the version the program is
96 * running with, not the version it was built with, and,
97 * in at least some of them, if the length of a data item
98 * referred to by the executable - such as the pcap_version[]
99 * string - isn't the same in the version of the library
100 * with which the program was built and the version with
101 * which it was run, the run-time linker will complain,
102 * which is Not Good.
104 * So, for now, we just give up on reporting the version
105 * of libpcap with which we were compiled.
107 #ifdef HAVE_PCAP_REMOTE
109 * We have remote pcap support in libpcap.
111 with_feature(l, "libpcap (including remote capture support)");
112 #else
113 with_feature(l, "libpcap");
114 #endif
117 * XXX - these libraries are actually used only by dumpcap,
118 * but we mention them here so that a user reporting a bug
119 * can get information about dumpcap's libraries without
120 * having to run dumpcap.
122 /* LIBCAP */
123 #ifdef HAVE_LIBCAP
124 #ifdef _LINUX_CAPABILITY_VERSION
125 with_feature(l, "POSIX capabilities (Linux)");
126 #else /* _LINUX_CAPABILITY_VERSION */
127 with_feature(l, "POSIX capabilities");
128 #endif /* _LINUX_CAPABILITY_VERSION */
129 #else /* HAVE_LIBCAP */
130 without_feature(l, "POSIX capabilities");
131 #endif /* HAVE_LIBCAP */
133 #ifdef __linux__
134 /* This is a Linux-specific library. */
135 /* LIBNL */
136 #if defined(HAVE_LIBNL1)
137 with_feature(l, "libnl 1");
138 #elif defined(HAVE_LIBNL2)
139 with_feature(l, "libnl 2");
140 #elif defined(HAVE_LIBNL3)
141 with_feature(l, "libnl 3");
142 #else /* no libnl */
143 without_feature(l, "libnl");
144 #endif /* libnl version */
145 #endif /* __linux__ */
148 void
149 gather_caplibs_runtime_info(feature_list l)
151 with_feature(l, "%s", pcap_lib_version());
154 #else /* HAVE_LIBPCAP */
157 * Append an indication that we were not compiled with libpcap
158 * to a GString. Don't even bother mentioning the other
159 * libraries.
161 void
162 gather_caplibs_compile_info(feature_list l)
164 without_feature(l, "libpcap");
167 void
168 gather_caplibs_runtime_info(feature_list l _U_)
172 #endif /* HAVE_LIBPCAP */
175 * Editor modelines - https://www.wireshark.org/tools/modelines.html
177 * Local variables:
178 * c-basic-offset: 8
179 * tab-width: 8
180 * indent-tabs-mode: t
181 * End:
183 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
184 * :indentSize=8:tabSize=8:noTabs=false: