Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
capture-pcap-util.h
1 /* capture-pcap-util.h
2  * Utility definitions for packet capture
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef __CAPTURE_PCAP_UTIL_H__
12 #define __CAPTURE_PCAP_UTIL_H__
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif /* __cplusplus */
17 
18 #ifdef HAVE_LIBPCAP
19 
20 #include <wsutil/wspcap.h>
21 
22 #include "capture_opts.h"
23 
24 /*
25  * A snapshot length of 0 is useless - and libpcap/WinPcap don't guarantee
26  * that a snapshot length of 0 will work, and, on some platforms, it won't
27  * (with BPF, for example, the kernel is told the snapshot length via the
28  * return value of the BPF program, and a return value of 0 means "drop
29  * the packet"), so the minimum packet size is 1 byte.
30  */
31 #define MIN_PACKET_SIZE 1 /* minimum amount of packet data we can read */
32 
33 GList *get_interface_list(int *err, char **err_str);
34 #ifdef HAVE_PCAP_REMOTE
35 GList *get_remote_interface_list(const char *hostname, const char *port,
36  int auth_type, const char *username,
37  const char *passwd, int *err, char **err_str);
38 #endif /* HAVE_PCAP_REMOTE */
39 
40 const char *linktype_val_to_name(int dlt);
41 int linktype_name_to_val(const char *linktype);
42 
43 int get_pcap_datalink(pcap_t *pch, const char *devicename);
44 
45 gboolean set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
46  char *errmsg, size_t errmsg_len,
47  char *secondary_errmsg, size_t secondary_errmsg_len);
48 
49 #ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
50 /*
51  * Return TRUE if the pcap_t in question is set up for high-precision
52  * time stamps, FALSE otherwise.
53  */
54 gboolean have_high_resolution_timestamp(pcap_t *pcap_h);
55 #endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */
56 
57 extern if_capabilities_t *get_if_capabilities(interface_options *interface_opts,
58  char **err_str);
59 extern pcap_t *open_capture_device(capture_options *capture_opts,
60  interface_options *interface_opts, int timeout,
61  char (*open_err_str)[PCAP_ERRBUF_SIZE]);
62 
63 #endif /* HAVE_LIBPCAP */
64 
65 extern void get_compiled_caplibs_version(GString *str);
66 
67 /*
68  * Append to a GString an indication of the version of capture libraries
69  * with which we're running, or an indication that we're not running
70  * with capture libraries, if we were compiled with WinPcap but
71  * WinPcap wasn't loaded, or nothing, if we weren't compiled with
72  * libpcap/WinPcap.
73  */
74 extern void get_runtime_caplibs_version(GString *str);
75 
76 #ifdef __cplusplus
77 }
78 #endif /* __cplusplus */
79 
80 #endif /* __CAPTURE_PCAP_UTIL_H__ */
Definition: capture_ifinfo.h:83
Definition: capture_opts.h:201
Definition: capture_opts.h:249