2005-05-29 17:46:52 +00:00
|
|
|
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the Computer Systems
|
|
|
|
* Engineering Group at Lawrence Berkeley Laboratory.
|
|
|
|
* 4. Neither the name of the University nor of the Laboratory may be used
|
|
|
|
* to endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#ifndef lib_pcap_pcap_h
|
|
|
|
#define lib_pcap_pcap_h
|
2005-05-29 17:46:52 +00:00
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#if defined(WIN32)
|
|
|
|
#include <pcap-stdinc.h>
|
|
|
|
#elif defined(MSDOS)
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h> /* u_int, u_char etc. */
|
|
|
|
#else /* UN*X */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif /* WIN32/MSDOS/UN*X */
|
2005-05-29 17:46:52 +00:00
|
|
|
|
2009-04-02 13:04:17 +00:00
|
|
|
#include <net/bpf.h>
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
Update libpcap to 1.1.1.
Changes:
Thu. April 1, 2010. guy@alum.mit.edu.
Summary for 1.1.1 libpcap release
Update CHANGES to reflect more of the changes in 1.1.0.
Fix build on RHEL5.
Fix shared library build on AIX.
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Summary for 1.1.0 libpcap release
Add SocketCAN capture support
Add Myricom SNF API support
Update Endace DAG and ERF support
Add support for shared libraries on Solaris, HP-UX, and AIX
Build, install, and un-install shared libraries by default;
don't build/install shared libraries on platforms we don't support
Fix building from a directory other than the source directory
Fix compiler warnings and builds on some platforms
Update config.guess and config.sub
Support monitor mode on mac80211 devices on Linux
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
value
On Linux, scan /sys/class/net for devices if we have it; scan
it, or /proc/net/dev if we don't have /sys/class/net, even if
we have getifaddrs(), as it'll find interfaces with no
addresses
Add limited support for reading pcap-ng files
Fix BPF driver-loading error handling on AIX
Support getting the full-length interface description on FreeBSD
In the lexical analyzer, free up any addrinfo structure we got back
from getaddrinfo().
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
Hyphenate "link-layer" everywhere
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
In pcap_read_linux_mmap(), if there are no frames available, call
poll() even if we're in non-blocking mode, so we pick up
errors, and check for the errors in question.
Note that poll() works on BPF devices is Snow Leopard
If an ENXIO or ENETDOWN is received, it may mean the device has
gone away. Deal with it.
For BPF, raise the default capture buffer size to from 32k to 512k
Support ps_ifdrop on Linux
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
under cygwin.
Changes to Linux mmapped captures.
Fix bug where create_ring would fail for particular snaplen and
buffer size combinations
Update pcap-config so that it handles libpcap requiring
additional libraries
Add workaround for threadsafeness on Windows
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
DLT: Add DLT_CAN_SOCKETCAN
DLT: Add Solaris ipnet
Don't check for DLT_IPNET if it's not defined
Add link-layer types for Fibre Channel FC-2
Add link-layer types for Wireless HART
Add link-layer types for AOS
Add link-layer types for DECT
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
Install headers unconditionally, and include vlan.h/bluetooth.h if
enabled
Autoconf fixes+cleanup
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
Support disabling SITA support (--without-sita)
Return -1 on failure to create packet ring (if supported but
creation failed)
Fix handling of 'any' device, so that it can be opened, and no longer
attempt to open it in Monitor mode
Add support for snapshot length for USB Memory-Mapped Interface
Fix configure and build on recent Linux kernels
Fix memory-mapped Linux capture to support pcap_next() and
pcap_next_ex()
Fixes for Linux USB capture
DLT: Add DLT_LINUX_EVDEV
DLT: Add DLT_GSMTAP_UM
DLT: Add DLT_GSMTAP_ABIS
2010-10-28 16:22:13 +00:00
|
|
|
/*
|
|
|
|
* Version number of the current version of the pcap file format.
|
|
|
|
*
|
|
|
|
* NOTE: this is *NOT* the version number of the libpcap library.
|
|
|
|
* To fetch the version information for the version of libpcap
|
|
|
|
* you're using, use pcap_lib_version().
|
|
|
|
*/
|
2009-03-21 20:43:56 +00:00
|
|
|
#define PCAP_VERSION_MAJOR 2
|
|
|
|
#define PCAP_VERSION_MINOR 4
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
#define PCAP_ERRBUF_SIZE 256
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Compatibility for systems that have a bpf.h that
|
|
|
|
* predates the bpf typedefs for 64-bit support.
|
|
|
|
*/
|
|
|
|
#if BPF_RELEASE - 0 < 199406
|
|
|
|
typedef int bpf_int32;
|
|
|
|
typedef u_int bpf_u_int32;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct pcap pcap_t;
|
|
|
|
typedef struct pcap_dumper pcap_dumper_t;
|
|
|
|
typedef struct pcap_if pcap_if_t;
|
|
|
|
typedef struct pcap_addr pcap_addr_t;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The first record in the file contains saved values for some
|
|
|
|
* of the flags used in the printout phases of tcpdump.
|
|
|
|
* Many fields here are 32 bit ints so compilers won't insert unwanted
|
|
|
|
* padding; these files need to be interchangeable across architectures.
|
|
|
|
*
|
|
|
|
* Do not change the layout of this structure, in any way (this includes
|
|
|
|
* changes that only affect the length of fields in this structure).
|
|
|
|
*
|
|
|
|
* Also, do not change the interpretation of any of the members of this
|
|
|
|
* structure, in any way (this includes using values other than
|
|
|
|
* LINKTYPE_ values, as defined in "savefile.c", in the "linktype"
|
|
|
|
* field).
|
|
|
|
*
|
|
|
|
* Instead:
|
|
|
|
*
|
|
|
|
* introduce a new structure for the new format, if the layout
|
|
|
|
* of the structure changed;
|
|
|
|
*
|
2009-03-21 20:43:56 +00:00
|
|
|
* send mail to "tcpdump-workers@lists.tcpdump.org", requesting
|
|
|
|
* a new magic number for your new capture file format, and, when
|
2005-05-29 17:46:52 +00:00
|
|
|
* you get the new magic number, put it in "savefile.c";
|
|
|
|
*
|
|
|
|
* use that magic number for save files with the changed file
|
|
|
|
* header;
|
|
|
|
*
|
|
|
|
* make the code in "savefile.c" capable of reading files with
|
|
|
|
* the old file header as well as files with the new file header
|
|
|
|
* (using the magic number to determine the header format).
|
|
|
|
*
|
2013-05-30 06:41:26 +00:00
|
|
|
* Then supply the changes by forking the branch at
|
2009-03-21 20:43:56 +00:00
|
|
|
*
|
2015-01-06 18:58:31 +00:00
|
|
|
* https://github.com/the-tcpdump-group/libpcap/issues
|
2009-03-21 20:43:56 +00:00
|
|
|
*
|
2013-05-30 06:41:26 +00:00
|
|
|
* and issuing a pull request, so that future versions of libpcap and
|
|
|
|
* programs that use it (such as tcpdump) will be able to read your new
|
|
|
|
* capture file format.
|
2005-05-29 17:46:52 +00:00
|
|
|
*/
|
2009-03-21 20:43:56 +00:00
|
|
|
struct pcap_file_header {
|
|
|
|
bpf_u_int32 magic;
|
|
|
|
u_short version_major;
|
|
|
|
u_short version_minor;
|
|
|
|
bpf_int32 thiszone; /* gmt to local correction */
|
|
|
|
bpf_u_int32 sigfigs; /* accuracy of timestamps */
|
|
|
|
bpf_u_int32 snaplen; /* max length saved portion of each pkt */
|
2005-05-29 17:46:52 +00:00
|
|
|
bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
|
|
|
|
};
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
/*
|
|
|
|
* Macros for the value returned by pcap_datalink_ext().
|
2015-01-06 18:58:31 +00:00
|
|
|
*
|
2009-03-21 20:43:56 +00:00
|
|
|
* If LT_FCS_LENGTH_PRESENT(x) is true, the LT_FCS_LENGTH(x) macro
|
|
|
|
* gives the FCS length of packets in the capture.
|
|
|
|
*/
|
|
|
|
#define LT_FCS_LENGTH_PRESENT(x) ((x) & 0x04000000)
|
|
|
|
#define LT_FCS_LENGTH(x) (((x) & 0xF0000000) >> 28)
|
|
|
|
#define LT_FCS_DATALINK_EXT(x) ((((x) & 0xF) << 28) | 0x04000000)
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PCAP_D_INOUT = 0,
|
|
|
|
PCAP_D_IN,
|
|
|
|
PCAP_D_OUT
|
|
|
|
} pcap_direction_t;
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
/*
|
2009-03-21 20:43:56 +00:00
|
|
|
* Generic per-packet information, as supplied by libpcap.
|
|
|
|
*
|
|
|
|
* The time stamp can and should be a "struct timeval", regardless of
|
|
|
|
* whether your system supports 32-bit tv_sec in "struct timeval",
|
|
|
|
* 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit
|
|
|
|
* and 64-bit applications. The on-disk format of savefiles uses 32-bit
|
|
|
|
* tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit
|
|
|
|
* and 64-bit versions of libpcap, even if they're on the same platform,
|
|
|
|
* should supply the appropriate version of "struct timeval", even if
|
|
|
|
* that's not what the underlying packet capture mechanism supplies.
|
2005-05-29 17:46:52 +00:00
|
|
|
*/
|
2009-03-21 20:43:56 +00:00
|
|
|
struct pcap_pkthdr {
|
|
|
|
struct timeval ts; /* time stamp */
|
|
|
|
bpf_u_int32 caplen; /* length of portion present */
|
|
|
|
bpf_u_int32 len; /* length this packet (off wire) */
|
|
|
|
};
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* As returned by the pcap_stats()
|
|
|
|
*/
|
|
|
|
struct pcap_stat {
|
|
|
|
u_int ps_recv; /* number of packets received */
|
|
|
|
u_int ps_drop; /* number of packets dropped */
|
Update libpcap to 1.1.1.
Changes:
Thu. April 1, 2010. guy@alum.mit.edu.
Summary for 1.1.1 libpcap release
Update CHANGES to reflect more of the changes in 1.1.0.
Fix build on RHEL5.
Fix shared library build on AIX.
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Summary for 1.1.0 libpcap release
Add SocketCAN capture support
Add Myricom SNF API support
Update Endace DAG and ERF support
Add support for shared libraries on Solaris, HP-UX, and AIX
Build, install, and un-install shared libraries by default;
don't build/install shared libraries on platforms we don't support
Fix building from a directory other than the source directory
Fix compiler warnings and builds on some platforms
Update config.guess and config.sub
Support monitor mode on mac80211 devices on Linux
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
value
On Linux, scan /sys/class/net for devices if we have it; scan
it, or /proc/net/dev if we don't have /sys/class/net, even if
we have getifaddrs(), as it'll find interfaces with no
addresses
Add limited support for reading pcap-ng files
Fix BPF driver-loading error handling on AIX
Support getting the full-length interface description on FreeBSD
In the lexical analyzer, free up any addrinfo structure we got back
from getaddrinfo().
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
Hyphenate "link-layer" everywhere
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
In pcap_read_linux_mmap(), if there are no frames available, call
poll() even if we're in non-blocking mode, so we pick up
errors, and check for the errors in question.
Note that poll() works on BPF devices is Snow Leopard
If an ENXIO or ENETDOWN is received, it may mean the device has
gone away. Deal with it.
For BPF, raise the default capture buffer size to from 32k to 512k
Support ps_ifdrop on Linux
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
under cygwin.
Changes to Linux mmapped captures.
Fix bug where create_ring would fail for particular snaplen and
buffer size combinations
Update pcap-config so that it handles libpcap requiring
additional libraries
Add workaround for threadsafeness on Windows
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
DLT: Add DLT_CAN_SOCKETCAN
DLT: Add Solaris ipnet
Don't check for DLT_IPNET if it's not defined
Add link-layer types for Fibre Channel FC-2
Add link-layer types for Wireless HART
Add link-layer types for AOS
Add link-layer types for DECT
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
Install headers unconditionally, and include vlan.h/bluetooth.h if
enabled
Autoconf fixes+cleanup
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
Support disabling SITA support (--without-sita)
Return -1 on failure to create packet ring (if supported but
creation failed)
Fix handling of 'any' device, so that it can be opened, and no longer
attempt to open it in Monitor mode
Add support for snapshot length for USB Memory-Mapped Interface
Fix configure and build on recent Linux kernels
Fix memory-mapped Linux capture to support pcap_next() and
pcap_next_ex()
Fixes for Linux USB capture
DLT: Add DLT_LINUX_EVDEV
DLT: Add DLT_GSMTAP_UM
DLT: Add DLT_GSMTAP_ABIS
2010-10-28 16:22:13 +00:00
|
|
|
u_int ps_ifdrop; /* drops by interface -- only supported on some platforms */
|
2005-05-29 17:46:52 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
u_int bs_capt; /* number of packets that reach the application */
|
|
|
|
#endif /* WIN32 */
|
|
|
|
};
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#ifdef MSDOS
|
|
|
|
/*
|
|
|
|
* As returned by the pcap_stats_ex()
|
|
|
|
*/
|
|
|
|
struct pcap_stat_ex {
|
|
|
|
u_long rx_packets; /* total packets received */
|
|
|
|
u_long tx_packets; /* total packets transmitted */
|
|
|
|
u_long rx_bytes; /* total bytes received */
|
|
|
|
u_long tx_bytes; /* total bytes transmitted */
|
|
|
|
u_long rx_errors; /* bad packets received */
|
|
|
|
u_long tx_errors; /* packet transmit problems */
|
|
|
|
u_long rx_dropped; /* no space in Rx buffers */
|
|
|
|
u_long tx_dropped; /* no space available for Tx */
|
|
|
|
u_long multicast; /* multicast packets received */
|
|
|
|
u_long collisions;
|
|
|
|
|
|
|
|
/* detailed rx_errors: */
|
|
|
|
u_long rx_length_errors;
|
|
|
|
u_long rx_over_errors; /* receiver ring buff overflow */
|
|
|
|
u_long rx_crc_errors; /* recv'd pkt with crc error */
|
|
|
|
u_long rx_frame_errors; /* recv'd frame alignment error */
|
|
|
|
u_long rx_fifo_errors; /* recv'r fifo overrun */
|
|
|
|
u_long rx_missed_errors; /* recv'r missed packet */
|
|
|
|
|
|
|
|
/* detailed tx_errors */
|
|
|
|
u_long tx_aborted_errors;
|
|
|
|
u_long tx_carrier_errors;
|
|
|
|
u_long tx_fifo_errors;
|
|
|
|
u_long tx_heartbeat_errors;
|
|
|
|
u_long tx_window_errors;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2005-05-29 17:46:52 +00:00
|
|
|
/*
|
|
|
|
* Item in a list of interfaces.
|
|
|
|
*/
|
|
|
|
struct pcap_if {
|
|
|
|
struct pcap_if *next;
|
|
|
|
char *name; /* name to hand to "pcap_open_live()" */
|
|
|
|
char *description; /* textual description of interface, or NULL */
|
|
|
|
struct pcap_addr *addresses;
|
|
|
|
bpf_u_int32 flags; /* PCAP_IF_ interface flags */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */
|
2015-01-06 18:58:31 +00:00
|
|
|
#define PCAP_IF_UP 0x00000002 /* interface is up */
|
|
|
|
#define PCAP_IF_RUNNING 0x00000004 /* interface is running */
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Representation of an interface address.
|
|
|
|
*/
|
|
|
|
struct pcap_addr {
|
|
|
|
struct pcap_addr *next;
|
|
|
|
struct sockaddr *addr; /* address */
|
|
|
|
struct sockaddr *netmask; /* netmask for that address */
|
|
|
|
struct sockaddr *broadaddr; /* broadcast address for that address */
|
|
|
|
struct sockaddr *dstaddr; /* P2P destination address for that address */
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
|
|
|
|
const u_char *);
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
/*
|
|
|
|
* Error codes for the pcap API.
|
|
|
|
* These will all be negative, so you can check for the success or
|
|
|
|
* failure of a call that returns these codes by checking for a
|
|
|
|
* negative value.
|
|
|
|
*/
|
|
|
|
#define PCAP_ERROR -1 /* generic error code */
|
|
|
|
#define PCAP_ERROR_BREAK -2 /* loop terminated by pcap_breakloop */
|
|
|
|
#define PCAP_ERROR_NOT_ACTIVATED -3 /* the capture needs to be activated */
|
|
|
|
#define PCAP_ERROR_ACTIVATED -4 /* the operation can't be performed on already activated captures */
|
|
|
|
#define PCAP_ERROR_NO_SUCH_DEVICE -5 /* no such device exists */
|
|
|
|
#define PCAP_ERROR_RFMON_NOTSUP -6 /* this device doesn't support rfmon (monitor) mode */
|
|
|
|
#define PCAP_ERROR_NOT_RFMON -7 /* operation supported only in monitor mode */
|
|
|
|
#define PCAP_ERROR_PERM_DENIED -8 /* no permission to open the device */
|
|
|
|
#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */
|
2012-01-31 17:22:07 +00:00
|
|
|
#define PCAP_ERROR_CANTSET_TSTAMP_TYPE -10 /* this device doesn't support setting the time stamp type */
|
|
|
|
#define PCAP_ERROR_PROMISC_PERM_DENIED -11 /* you don't have permission to capture in promiscuous mode */
|
2015-01-06 18:58:31 +00:00
|
|
|
#define PCAP_ERROR_TSTAMP_PRECISION_NOTSUP -12 /* the requested time stamp precision is not supported */
|
2009-03-21 20:43:56 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Warning codes for the pcap API.
|
|
|
|
* These will all be positive and non-zero, so they won't look like
|
|
|
|
* errors.
|
|
|
|
*/
|
|
|
|
#define PCAP_WARNING 1 /* generic warning code */
|
|
|
|
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
|
2012-01-31 17:22:07 +00:00
|
|
|
#define PCAP_WARNING_TSTAMP_TYPE_NOTSUP 3 /* the requested time stamp type is not supported */
|
2009-03-21 20:43:56 +00:00
|
|
|
|
Update libpcap to 1.1.1.
Changes:
Thu. April 1, 2010. guy@alum.mit.edu.
Summary for 1.1.1 libpcap release
Update CHANGES to reflect more of the changes in 1.1.0.
Fix build on RHEL5.
Fix shared library build on AIX.
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
Summary for 1.1.0 libpcap release
Add SocketCAN capture support
Add Myricom SNF API support
Update Endace DAG and ERF support
Add support for shared libraries on Solaris, HP-UX, and AIX
Build, install, and un-install shared libraries by default;
don't build/install shared libraries on platforms we don't support
Fix building from a directory other than the source directory
Fix compiler warnings and builds on some platforms
Update config.guess and config.sub
Support monitor mode on mac80211 devices on Linux
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
value
On Linux, scan /sys/class/net for devices if we have it; scan
it, or /proc/net/dev if we don't have /sys/class/net, even if
we have getifaddrs(), as it'll find interfaces with no
addresses
Add limited support for reading pcap-ng files
Fix BPF driver-loading error handling on AIX
Support getting the full-length interface description on FreeBSD
In the lexical analyzer, free up any addrinfo structure we got back
from getaddrinfo().
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
Hyphenate "link-layer" everywhere
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
In pcap_read_linux_mmap(), if there are no frames available, call
poll() even if we're in non-blocking mode, so we pick up
errors, and check for the errors in question.
Note that poll() works on BPF devices is Snow Leopard
If an ENXIO or ENETDOWN is received, it may mean the device has
gone away. Deal with it.
For BPF, raise the default capture buffer size to from 32k to 512k
Support ps_ifdrop on Linux
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
under cygwin.
Changes to Linux mmapped captures.
Fix bug where create_ring would fail for particular snaplen and
buffer size combinations
Update pcap-config so that it handles libpcap requiring
additional libraries
Add workaround for threadsafeness on Windows
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
DLT: Add DLT_CAN_SOCKETCAN
DLT: Add Solaris ipnet
Don't check for DLT_IPNET if it's not defined
Add link-layer types for Fibre Channel FC-2
Add link-layer types for Wireless HART
Add link-layer types for AOS
Add link-layer types for DECT
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
Install headers unconditionally, and include vlan.h/bluetooth.h if
enabled
Autoconf fixes+cleanup
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
Support disabling SITA support (--without-sita)
Return -1 on failure to create packet ring (if supported but
creation failed)
Fix handling of 'any' device, so that it can be opened, and no longer
attempt to open it in Monitor mode
Add support for snapshot length for USB Memory-Mapped Interface
Fix configure and build on recent Linux kernels
Fix memory-mapped Linux capture to support pcap_next() and
pcap_next_ex()
Fixes for Linux USB capture
DLT: Add DLT_LINUX_EVDEV
DLT: Add DLT_GSMTAP_UM
DLT: Add DLT_GSMTAP_ABIS
2010-10-28 16:22:13 +00:00
|
|
|
/*
|
|
|
|
* Value to pass to pcap_compile() as the netmask if you don't know what
|
|
|
|
* the netmask is.
|
|
|
|
*/
|
|
|
|
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
|
|
|
|
2005-05-29 17:46:52 +00:00
|
|
|
char *pcap_lookupdev(char *);
|
|
|
|
int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
|
|
|
|
pcap_t *pcap_create(const char *, char *);
|
|
|
|
int pcap_set_snaplen(pcap_t *, int);
|
|
|
|
int pcap_set_promisc(pcap_t *, int);
|
|
|
|
int pcap_can_set_rfmon(pcap_t *);
|
|
|
|
int pcap_set_rfmon(pcap_t *, int);
|
|
|
|
int pcap_set_timeout(pcap_t *, int);
|
2012-01-31 17:22:07 +00:00
|
|
|
int pcap_set_tstamp_type(pcap_t *, int);
|
2015-01-06 18:58:31 +00:00
|
|
|
int pcap_set_immediate_mode(pcap_t *, int);
|
2009-03-21 20:43:56 +00:00
|
|
|
int pcap_set_buffer_size(pcap_t *, int);
|
2015-01-06 18:58:31 +00:00
|
|
|
int pcap_set_tstamp_precision(pcap_t *, int);
|
|
|
|
int pcap_get_tstamp_precision(pcap_t *);
|
2009-03-21 20:43:56 +00:00
|
|
|
int pcap_activate(pcap_t *);
|
|
|
|
|
2012-01-31 17:22:07 +00:00
|
|
|
int pcap_list_tstamp_types(pcap_t *, int **);
|
|
|
|
void pcap_free_tstamp_types(int *);
|
|
|
|
int pcap_tstamp_type_name_to_val(const char *);
|
|
|
|
const char *pcap_tstamp_type_val_to_name(int);
|
|
|
|
const char *pcap_tstamp_type_val_to_description(int);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Time stamp types.
|
|
|
|
* Not all systems and interfaces will necessarily support all of these.
|
|
|
|
*
|
|
|
|
* A system that supports PCAP_TSTAMP_HOST is offering time stamps
|
|
|
|
* provided by the host machine, rather than by the capture device,
|
|
|
|
* but not committing to any characteristics of the time stamp;
|
|
|
|
* it will not offer any of the PCAP_TSTAMP_HOST_ subtypes.
|
|
|
|
*
|
|
|
|
* PCAP_TSTAMP_HOST_LOWPREC is a time stamp, provided by the host machine,
|
|
|
|
* that's low-precision but relatively cheap to fetch; it's normally done
|
|
|
|
* using the system clock, so it's normally synchronized with times you'd
|
|
|
|
* fetch from system calls.
|
|
|
|
*
|
|
|
|
* PCAP_TSTAMP_HOST_HIPREC is a time stamp, provided by the host machine,
|
|
|
|
* that's high-precision; it might be more expensive to fetch. It might
|
|
|
|
* or might not be synchronized with the system clock, and might have
|
|
|
|
* problems with time stamps for packets received on different CPUs,
|
|
|
|
* depending on the platform.
|
|
|
|
*
|
|
|
|
* PCAP_TSTAMP_ADAPTER is a high-precision time stamp supplied by the
|
|
|
|
* capture device; it's synchronized with the system clock.
|
|
|
|
*
|
|
|
|
* PCAP_TSTAMP_ADAPTER_UNSYNCED is a high-precision time stamp supplied by
|
|
|
|
* the capture device; it's not synchronized with the system clock.
|
|
|
|
*
|
|
|
|
* Note that time stamps synchronized with the system clock can go
|
|
|
|
* backwards, as the system clock can go backwards. If a clock is
|
|
|
|
* not in sync with the system clock, that could be because the
|
|
|
|
* system clock isn't keeping accurate time, because the other
|
|
|
|
* clock isn't keeping accurate time, or both.
|
|
|
|
*
|
|
|
|
* Note that host-provided time stamps generally correspond to the
|
|
|
|
* time when the time-stamping code sees the packet; this could
|
|
|
|
* be some unknown amount of time after the first or last bit of
|
|
|
|
* the packet is received by the network adapter, due to batching
|
|
|
|
* of interrupts for packet arrival, queueing delays, etc..
|
|
|
|
*/
|
|
|
|
#define PCAP_TSTAMP_HOST 0 /* host-provided, unknown characteristics */
|
|
|
|
#define PCAP_TSTAMP_HOST_LOWPREC 1 /* host-provided, low precision */
|
|
|
|
#define PCAP_TSTAMP_HOST_HIPREC 2 /* host-provided, high precision */
|
|
|
|
#define PCAP_TSTAMP_ADAPTER 3 /* device-provided, synced with the system clock */
|
|
|
|
#define PCAP_TSTAMP_ADAPTER_UNSYNCED 4 /* device-provided, not synced with the system clock */
|
|
|
|
|
2015-01-06 18:58:31 +00:00
|
|
|
/*
|
|
|
|
* Time stamp resolution types.
|
|
|
|
* Not all systems and interfaces will necessarily support all of these
|
|
|
|
* resolutions when doing live captures; all of them can be requested
|
|
|
|
* when reading a savefile.
|
|
|
|
*/
|
|
|
|
#define PCAP_TSTAMP_PRECISION_MICRO 0 /* use timestamps with microsecond precision, default */
|
|
|
|
#define PCAP_TSTAMP_PRECISION_NANO 1 /* use timestamps with nanosecond precision */
|
|
|
|
|
2005-05-29 17:46:52 +00:00
|
|
|
pcap_t *pcap_open_live(const char *, int, int, int, char *);
|
|
|
|
pcap_t *pcap_open_dead(int, int);
|
2015-01-06 18:58:31 +00:00
|
|
|
pcap_t *pcap_open_dead_with_tstamp_precision(int, int, u_int);
|
|
|
|
pcap_t *pcap_open_offline_with_tstamp_precision(const char *, u_int, char *);
|
2005-05-29 17:46:52 +00:00
|
|
|
pcap_t *pcap_open_offline(const char *, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
#if defined(WIN32)
|
2015-01-06 18:58:31 +00:00
|
|
|
pcap_t *pcap_hopen_offline_with_tstamp_precision(intptr_t, u_int, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
pcap_t *pcap_hopen_offline(intptr_t, char *);
|
|
|
|
#if !defined(LIBPCAP_EXPORTS)
|
2015-01-06 18:58:31 +00:00
|
|
|
#define pcap_fopen_offline_with_tstamp_precision(f,p,b) \
|
|
|
|
pcap_hopen_offline_with_tstamp_precision(_get_osfhandle(_fileno(f)), p, b)
|
2009-03-21 20:43:56 +00:00
|
|
|
#define pcap_fopen_offline(f,b) \
|
|
|
|
pcap_hopen_offline(_get_osfhandle(_fileno(f)), b)
|
|
|
|
#else /*LIBPCAP_EXPORTS*/
|
2015-01-06 18:58:31 +00:00
|
|
|
static pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
static pcap_t *pcap_fopen_offline(FILE *, char *);
|
|
|
|
#endif
|
|
|
|
#else /*WIN32*/
|
2015-01-06 18:58:31 +00:00
|
|
|
pcap_t *pcap_fopen_offline_with_tstamp_precision(FILE *, u_int, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
pcap_t *pcap_fopen_offline(FILE *, char *);
|
|
|
|
#endif /*WIN32*/
|
|
|
|
|
2005-05-29 17:46:52 +00:00
|
|
|
void pcap_close(pcap_t *);
|
|
|
|
int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
|
|
|
|
int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
|
|
|
|
const u_char*
|
|
|
|
pcap_next(pcap_t *, struct pcap_pkthdr *);
|
|
|
|
int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
|
|
|
|
void pcap_breakloop(pcap_t *);
|
|
|
|
int pcap_stats(pcap_t *, struct pcap_stat *);
|
|
|
|
int pcap_setfilter(pcap_t *, struct bpf_program *);
|
2009-03-21 20:43:56 +00:00
|
|
|
int pcap_setdirection(pcap_t *, pcap_direction_t);
|
2005-05-29 17:46:52 +00:00
|
|
|
int pcap_getnonblock(pcap_t *, char *);
|
|
|
|
int pcap_setnonblock(pcap_t *, int, char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
int pcap_inject(pcap_t *, const void *, size_t);
|
|
|
|
int pcap_sendpacket(pcap_t *, const u_char *, int);
|
|
|
|
const char *pcap_statustostr(int);
|
|
|
|
const char *pcap_strerror(int);
|
2005-05-29 17:46:52 +00:00
|
|
|
char *pcap_geterr(pcap_t *);
|
2009-03-21 20:43:56 +00:00
|
|
|
void pcap_perror(pcap_t *, char *);
|
|
|
|
int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,
|
2005-05-29 17:46:52 +00:00
|
|
|
bpf_u_int32);
|
|
|
|
int pcap_compile_nopcap(int, int, struct bpf_program *,
|
2009-03-21 20:43:56 +00:00
|
|
|
const char *, int, bpf_u_int32);
|
2005-05-29 17:46:52 +00:00
|
|
|
void pcap_freecode(struct bpf_program *);
|
2013-05-30 06:41:26 +00:00
|
|
|
int pcap_offline_filter(const struct bpf_program *,
|
|
|
|
const struct pcap_pkthdr *, const u_char *);
|
2005-05-29 17:46:52 +00:00
|
|
|
int pcap_datalink(pcap_t *);
|
2009-03-21 20:43:56 +00:00
|
|
|
int pcap_datalink_ext(pcap_t *);
|
2005-05-29 17:46:52 +00:00
|
|
|
int pcap_list_datalinks(pcap_t *, int **);
|
|
|
|
int pcap_set_datalink(pcap_t *, int);
|
2009-03-21 20:43:56 +00:00
|
|
|
void pcap_free_datalinks(int *);
|
2005-05-29 17:46:52 +00:00
|
|
|
int pcap_datalink_name_to_val(const char *);
|
|
|
|
const char *pcap_datalink_val_to_name(int);
|
|
|
|
const char *pcap_datalink_val_to_description(int);
|
|
|
|
int pcap_snapshot(pcap_t *);
|
|
|
|
int pcap_is_swapped(pcap_t *);
|
|
|
|
int pcap_major_version(pcap_t *);
|
|
|
|
int pcap_minor_version(pcap_t *);
|
|
|
|
|
|
|
|
/* XXX */
|
|
|
|
FILE *pcap_file(pcap_t *);
|
|
|
|
int pcap_fileno(pcap_t *);
|
|
|
|
|
|
|
|
pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
|
2009-03-21 20:43:56 +00:00
|
|
|
pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
|
|
|
|
FILE *pcap_dump_file(pcap_dumper_t *);
|
|
|
|
long pcap_dump_ftell(pcap_dumper_t *);
|
2005-05-29 17:46:52 +00:00
|
|
|
int pcap_dump_flush(pcap_dumper_t *);
|
|
|
|
void pcap_dump_close(pcap_dumper_t *);
|
|
|
|
void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
|
|
|
|
|
|
|
|
int pcap_findalldevs(pcap_if_t **, char *);
|
|
|
|
void pcap_freealldevs(pcap_if_t *);
|
|
|
|
|
|
|
|
const char *pcap_lib_version(void);
|
|
|
|
|
2012-01-31 17:22:07 +00:00
|
|
|
/*
|
|
|
|
* On at least some versions of NetBSD, we don't want to declare
|
|
|
|
* bpf_filter() here, as it's also be declared in <net/bpf.h>, with a
|
|
|
|
* different signature, but, on other BSD-flavored UN*Xes, it's not
|
|
|
|
* declared in <net/bpf.h>, so we *do* want to declare it here, so it's
|
|
|
|
* declared when we build pcap-bpf.c.
|
|
|
|
*/
|
|
|
|
#ifndef __NetBSD__
|
2013-10-31 20:03:59 +00:00
|
|
|
u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
|
2012-01-31 17:22:07 +00:00
|
|
|
#endif
|
2009-03-21 20:43:56 +00:00
|
|
|
int bpf_validate(const struct bpf_insn *f, int len);
|
2013-10-31 20:03:59 +00:00
|
|
|
char *bpf_image(const struct bpf_insn *, int);
|
|
|
|
void bpf_dump(const struct bpf_program *, int);
|
2009-03-21 20:43:56 +00:00
|
|
|
|
|
|
|
#if defined(WIN32)
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Win32 definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
int pcap_setbuff(pcap_t *p, int dim);
|
|
|
|
int pcap_setmode(pcap_t *p, int mode);
|
|
|
|
int pcap_setmintocopy(pcap_t *p, int size);
|
2015-01-06 18:58:31 +00:00
|
|
|
Adapter *pcap_get_adapter(pcap_t *p);
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
#ifdef WPCAP
|
|
|
|
/* Include file with the wpcap-specific extensions */
|
|
|
|
#include <Win32-Extensions.h>
|
2009-03-21 20:43:56 +00:00
|
|
|
#endif /* WPCAP */
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
#define MODE_CAPT 0
|
|
|
|
#define MODE_STAT 1
|
2009-03-21 20:43:56 +00:00
|
|
|
#define MODE_MON 2
|
|
|
|
|
|
|
|
#elif defined(MSDOS)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MS-DOS definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);
|
|
|
|
void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);
|
|
|
|
u_long pcap_mac_packets (void);
|
|
|
|
|
|
|
|
#else /* UN*X */
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* UN*X definitions
|
|
|
|
*/
|
|
|
|
|
|
|
|
int pcap_get_selectable_fd(pcap_t *);
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#endif /* WIN32/MSDOS/UN*X */
|
2005-05-29 17:46:52 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-01-31 17:22:07 +00:00
|
|
|
#endif /* lib_pcap_pcap_h */
|