debug keys
[metze/wireshark/wip.git] / caputils / 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 /*
58  * Error values.
59  */
60 typedef enum {
61     CAP_DEVICE_OPEN_NO_ERR,              /* No error */
62     CAP_DEVICE_OPEN_ERR_PERMISSIONS,     /* Error is known to be a permissions error */
63     CAP_DEVICE_OPEN_ERR_NOT_PERMISSIONS, /* Error is known not to be a permissions error */
64     CAP_DEVICE_OPEN_ERR_GENERIC          /* Error is not known to be one or the other */
65 } cap_device_open_err;
66 extern if_capabilities_t *get_if_capabilities(interface_options *interface_opts,
67     cap_device_open_err *err, char **err_str);
68 extern pcap_t *open_capture_device(capture_options *capture_opts,
69     interface_options *interface_opts,
70     int timeout, cap_device_open_err *open_err,
71     char (*open_err_str)[PCAP_ERRBUF_SIZE]);
72
73 #endif /* HAVE_LIBPCAP */
74
75 extern void get_compiled_caplibs_version(GString *str);
76
77 /*
78  * Append to a GString an indication of the version of capture libraries
79  * with which we're running, or an indication that we're not running
80  * with capture libraries, if we were compiled with WinPcap but
81  * WinPcap wasn't loaded, or nothing, if we weren't compiled with
82  * libpcap/WinPcap.
83  */
84 extern void get_runtime_caplibs_version(GString *str);
85
86 #ifdef __cplusplus
87 }
88 #endif /* __cplusplus */
89
90 #endif /* __CAPTURE_PCAP_UTIL_H__ */