2005-12-06 00:07:13 +00:00
|
|
|
/* capture-pcap-util.h
|
2004-07-18 00:24:25 +00:00
|
|
|
* Utility definitions for packet capture
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2004-07-18 00:24:25 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-04-30 07:47:58 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
#ifndef __CAPTURE_PCAP_UTIL_H__
|
|
|
|
#define __CAPTURE_PCAP_UTIL_H__
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2014-06-23 21:55:56 +00:00
|
|
|
#ifdef HAVE_LIBPCAP
|
|
|
|
|
2019-05-01 18:02:34 +00:00
|
|
|
#include "wspcap.h"
|
2014-06-23 21:55:56 +00:00
|
|
|
|
2016-01-05 21:54:02 +00:00
|
|
|
#include "capture_opts.h"
|
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBPCAP
|
2004-07-18 00:24:25 +00:00
|
|
|
/*
|
2020-03-12 18:30:03 +00:00
|
|
|
* A snapshot length of 0 is useless - and libpcap/WinPcap/Npcap don't guarantee
|
2009-02-23 19:00:30 +00:00
|
|
|
* that a snapshot length of 0 will work, and, on some platforms, it won't
|
|
|
|
* (with BPF, for example, the kernel is told the snapshot length via the
|
|
|
|
* return value of the BPF program, and a return value of 0 means "drop
|
|
|
|
* the packet"), so the minimum packet size is 1 byte.
|
2004-07-18 00:24:25 +00:00
|
|
|
*/
|
2009-02-23 19:00:30 +00:00
|
|
|
#define MIN_PACKET_SIZE 1 /* minimum amount of packet data we can read */
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
GList *get_interface_list(int *err, char **err_str);
|
2007-12-04 11:19:29 +00:00
|
|
|
#ifdef HAVE_PCAP_REMOTE
|
2021-03-18 04:22:41 +00:00
|
|
|
GList *get_remote_interface_list(const char *hostname, const char *port,
|
|
|
|
int auth_type, const char *username,
|
|
|
|
const char *passwd, int *err, char **err_str);
|
2016-01-07 05:28:35 +00:00
|
|
|
#endif /* HAVE_PCAP_REMOTE */
|
2004-07-18 00:24:25 +00:00
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
const char *linktype_val_to_name(int dlt);
|
|
|
|
int linktype_name_to_val(const char *linktype);
|
2006-02-17 02:18:48 +00:00
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
int get_pcap_datalink(pcap_t *pch, const char *devicename);
|
2014-11-05 02:08:47 +00:00
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
gboolean set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
|
2016-01-05 21:54:02 +00:00
|
|
|
char *errmsg, size_t errmsg_len,
|
|
|
|
char *secondary_errmsg, size_t secondary_errmsg_len);
|
|
|
|
|
|
|
|
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
|
2014-11-05 02:08:47 +00:00
|
|
|
/*
|
|
|
|
* Return TRUE if the pcap_t in question is set up for high-precision
|
|
|
|
* time stamps, FALSE otherwise.
|
|
|
|
*/
|
2021-03-18 04:22:41 +00:00
|
|
|
gboolean have_high_resolution_timestamp(pcap_t *pcap_h);
|
2014-11-05 01:49:29 +00:00
|
|
|
#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */
|
|
|
|
|
2018-06-10 06:39:12 +00:00
|
|
|
/*
|
|
|
|
* Error values.
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
CAP_DEVICE_OPEN_NO_ERR, /* No error */
|
|
|
|
CAP_DEVICE_OPEN_ERR_PERMISSIONS, /* Error is known to be a permissions error */
|
|
|
|
CAP_DEVICE_OPEN_ERR_NOT_PERMISSIONS, /* Error is known not to be a permissions error */
|
|
|
|
CAP_DEVICE_OPEN_ERR_GENERIC /* Error is not known to be one or the other */
|
|
|
|
} cap_device_open_err;
|
2021-03-18 04:22:41 +00:00
|
|
|
extern if_capabilities_t *get_if_capabilities(interface_options *interface_opts,
|
2018-06-10 06:39:12 +00:00
|
|
|
cap_device_open_err *err, char **err_str);
|
2021-03-18 04:22:41 +00:00
|
|
|
extern pcap_t *open_capture_device(capture_options *capture_opts,
|
2018-06-11 01:26:40 +00:00
|
|
|
interface_options *interface_opts,
|
|
|
|
int timeout, cap_device_open_err *open_err,
|
2016-01-05 21:54:02 +00:00
|
|
|
char (*open_err_str)[PCAP_ERRBUF_SIZE]);
|
|
|
|
|
2016-01-07 05:28:35 +00:00
|
|
|
#endif /* HAVE_LIBPCAP */
|
|
|
|
|
2021-03-18 04:22:41 +00:00
|
|
|
extern void get_compiled_caplibs_version(GString *str);
|
2004-07-18 00:24:25 +00:00
|
|
|
|
|
|
|
/*
|
2014-07-04 07:24:02 +00:00
|
|
|
* Append to a GString an indication of the version of capture libraries
|
2004-07-18 00:24:25 +00:00
|
|
|
* with which we're running, or an indication that we're not running
|
2020-03-12 18:30:03 +00:00
|
|
|
* with capture libraries, if we were compiled with WinPcap or Npcap but
|
|
|
|
* WinPcap/Npcap wasn't loaded, or nothing, if we weren't compiled with
|
|
|
|
* libpcap/WinPcap/Npcap.
|
2004-07-18 00:24:25 +00:00
|
|
|
*/
|
2021-03-18 04:22:41 +00:00
|
|
|
extern void get_runtime_caplibs_version(GString *str);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
2014-06-23 21:55:56 +00:00
|
|
|
|
2010-03-04 01:12:04 +00:00
|
|
|
#endif /* __CAPTURE_PCAP_UTIL_H__ */
|