| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
capture-pcap-util.h
Go to the documentation of this file.
1
12#ifndef __CAPTURE_PCAP_UTIL_H__
13#define __CAPTURE_PCAP_UTIL_H__
14
15#include <wsutil/feature_list.h>
16
17#ifdef HAVE_LIBPCAP
18
19#include <pcap/pcap.h>
20
21#include "ui/capture_opts.h"
22
23#endif
24
25#ifdef __cplusplus
26 extern "C" {
27#endif /* __cplusplus */
28
29#ifdef HAVE_LIBPCAP
30/*
31 * A snapshot length of 0 is useless - and libpcap/WinPcap/Npcap don't guarantee
32 * that a snapshot length of 0 will work, and, on some platforms, it won't
33 * (with BPF, for example, the kernel is told the snapshot length via the
34 * return value of the BPF program, and a return value of 0 means "drop
35 * the packet"), so the minimum packet size is 1 byte.
36 */
37#define MIN_PACKET_SIZE 1 /* minimum amount of packet data we can read */
38
39GList *get_local_interface_list_ws(int *err, char **err_str);
40GList* get_local_interface_list_ss(int* err, char** err_str);
41#ifdef HAVE_PCAP_REMOTE
42GList *get_remote_interface_list(const char *hostname, const char *port,
43 bool wireshark_remote,
44 int auth_type, const char *username,
45 const char *passwd,
46 int *err, char **err_str);
47#endif /* HAVE_PCAP_REMOTE */
48
49 const char *linktype_val_to_name(int dlt);
50 int linktype_name_to_val(const char *linktype);
51
52 int get_pcap_datalink(pcap_t *pch, const char *devicename);
53
54 bool set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
55 char *errmsg, size_t errmsg_len,
56 char *secondary_errmsg, size_t secondary_errmsg_len);
57
58/*
59 * Return true if the pcap_t in question is set up for high-precision
60 * time stamps, false otherwise.
61 */
62 bool have_high_resolution_timestamp(pcap_t *pcap_h);
63
64/*
65 * Capture device open status values.
66 */
67 typedef enum {
68 /* No error and no warning */
69 CAP_DEVICE_OPEN_NO_ERR,
70
71 /* Errors corresponding to libpcap errors */
72 CAP_DEVICE_OPEN_ERROR_NO_SUCH_DEVICE,
73 CAP_DEVICE_OPEN_ERROR_RFMON_NOTSUP,
74 CAP_DEVICE_OPEN_ERROR_PERM_DENIED,
75 CAP_DEVICE_OPEN_ERROR_IFACE_NOT_UP,
76 CAP_DEVICE_OPEN_ERROR_PROMISC_PERM_DENIED,
77
78 /* Error, none of the above */
79 CAP_DEVICE_OPEN_ERROR_OTHER,
80
81 /* Error from pcap_open_live() or pcap_open() rather than pcap_activate() */
82 CAP_DEVICE_OPEN_ERROR_GENERIC,
83
84 /* Warnings corresponding to libpcap warnings */
85 CAP_DEVICE_OPEN_WARNING_PROMISC_NOTSUP,
86 CAP_DEVICE_OPEN_WARNING_TSTAMP_TYPE_NOTSUP,
87
88 /* Warning, none of the above */
89 CAP_DEVICE_OPEN_WARNING_OTHER
90} cap_device_open_status;
91 extern if_capabilities_t *get_if_capabilities(interface_options *interface_opts,
92 cap_device_open_status *status, char **status_str);
93 extern pcap_t *open_capture_device(capture_options *capture_opts,
94 interface_options *interface_opts,
95 int timeout, cap_device_open_status *open_status,
96 char (*open_status_str)[PCAP_ERRBUF_SIZE]);
97
98#endif /* HAVE_LIBPCAP */
99
100 extern void gather_caplibs_compile_info(feature_list l);
101
102/*
103 * Append to a GString an indication of the version of capture libraries
104 * with which we're running, or an indication that we're not running
105 * with capture libraries, if we were compiled with WinPcap or Npcap but
106 * WinPcap/Npcap wasn't loaded, or nothing, if we weren't compiled with
107 * libpcap/WinPcap/Npcap.
108 */
109 extern void gather_caplibs_runtime_info(feature_list l);
110
111#ifdef _WIN32
112 extern bool caplibs_have_npcap(void);
113 extern bool caplibs_get_npcap_version(unsigned int *major,
114 unsigned int *minor);
115#endif
116
117#ifdef __cplusplus
118}
119#endif /* __cplusplus */
120
121#endif /* __CAPTURE_PCAP_UTIL_H__ */
capture_opts.h
feature_list.h
feature_list
GList ** feature_list
Semi-opaque handle to a list of features or dependencies.
Definition feature_list.h:33
capture_options_tag
Definition capture_opts.h:236
if_capabilities_t
Definition capture_ifinfo.h:45
interface_options_tag
Definition capture_opts.h:185