1996-08-19 20:36:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1994, 1995, 1996
|
|
|
|
* 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.
|
|
|
|
*
|
2000-01-30 00:43:38 +00:00
|
|
|
* $FreeBSD$
|
2009-03-21 20:43:56 +00:00
|
|
|
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.85.2.9 2008-09-16 00:21:08 guy Exp $ (LBL)
|
1996-08-19 20:36:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef pcap_int_h
|
2009-03-21 20:43:56 +00:00
|
|
|
#define pcap_int_h
|
|
|
|
|
|
|
|
#include <pcap/pcap.h>
|
1996-08-19 20:36:34 +00:00
|
|
|
|
1998-08-07 06:20:58 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#ifdef HAVE_LIBDLPI
|
|
|
|
#include <libdlpi.h>
|
|
|
|
#endif
|
1996-08-19 20:36:34 +00:00
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
#ifdef WIN32
|
2007-10-16 02:07:55 +00:00
|
|
|
#include <Packet32.h>
|
2004-03-31 09:15:09 +00:00
|
|
|
#endif /* WIN32 */
|
|
|
|
|
2005-05-29 18:09:04 +00:00
|
|
|
#ifdef MSDOS
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <io.h>
|
|
|
|
#endif
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#if (defined(_MSC_VER) && (_MSC_VER <= 1200)) /* we are compiling with Visual Studio 6, that doesn't support the LL suffix*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Swap byte ordering of unsigned long long timestamp on a big endian
|
|
|
|
* machine.
|
|
|
|
*/
|
|
|
|
#define SWAPLL(ull) ((ull & 0xff00000000000000) >> 56) | \
|
|
|
|
((ull & 0x00ff000000000000) >> 40) | \
|
|
|
|
((ull & 0x0000ff0000000000) >> 24) | \
|
|
|
|
((ull & 0x000000ff00000000) >> 8) | \
|
|
|
|
((ull & 0x00000000ff000000) << 8) | \
|
|
|
|
((ull & 0x0000000000ff0000) << 24) | \
|
|
|
|
((ull & 0x000000000000ff00) << 40) | \
|
|
|
|
((ull & 0x00000000000000ff) << 56)
|
|
|
|
|
|
|
|
#else /* A recent Visual studio compiler or not VC */
|
|
|
|
|
2007-10-16 02:07:55 +00:00
|
|
|
/*
|
|
|
|
* Swap byte ordering of unsigned long long timestamp on a big endian
|
|
|
|
* machine.
|
|
|
|
*/
|
|
|
|
#define SWAPLL(ull) ((ull & 0xff00000000000000LL) >> 56) | \
|
|
|
|
((ull & 0x00ff000000000000LL) >> 40) | \
|
|
|
|
((ull & 0x0000ff0000000000LL) >> 24) | \
|
|
|
|
((ull & 0x000000ff00000000LL) >> 8) | \
|
|
|
|
((ull & 0x00000000ff000000LL) << 8) | \
|
|
|
|
((ull & 0x0000000000ff0000LL) << 24) | \
|
|
|
|
((ull & 0x000000000000ff00LL) << 40) | \
|
|
|
|
((ull & 0x00000000000000ffLL) << 56)
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
/*
|
|
|
|
* Savefile
|
|
|
|
*/
|
2004-03-31 09:15:09 +00:00
|
|
|
typedef enum {
|
|
|
|
NOT_SWAPPED,
|
|
|
|
SWAPPED,
|
|
|
|
MAYBE_SWAPPED
|
|
|
|
} swapped_type_t;
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
/*
|
|
|
|
* Used when reading a savefile.
|
|
|
|
*/
|
1996-08-19 20:36:34 +00:00
|
|
|
struct pcap_sf {
|
|
|
|
FILE *rfile;
|
|
|
|
int swapped;
|
2009-03-21 20:43:56 +00:00
|
|
|
size_t hdrsize;
|
2004-03-31 09:15:09 +00:00
|
|
|
swapped_type_t lengths_swapped;
|
1996-08-19 20:36:34 +00:00
|
|
|
int version_major;
|
|
|
|
int version_minor;
|
|
|
|
u_char *base;
|
|
|
|
};
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
/*
|
|
|
|
* Used when doing a live capture.
|
|
|
|
*/
|
1996-08-19 20:36:34 +00:00
|
|
|
struct pcap_md {
|
|
|
|
struct pcap_stat stat;
|
|
|
|
/*XXX*/
|
2001-04-03 04:32:48 +00:00
|
|
|
int use_bpf; /* using kernel filter */
|
1996-08-19 20:36:34 +00:00
|
|
|
u_long TotPkts; /* can't oflow for 79 hrs on ether */
|
|
|
|
u_long TotAccepted; /* count accepted by filter */
|
|
|
|
u_long TotDrops; /* count of dropped packets */
|
|
|
|
long TotMissed; /* missed by i/f during this run */
|
|
|
|
long OrigMissed; /* missed by i/f before this run */
|
2005-05-29 18:09:04 +00:00
|
|
|
char *device; /* device name */
|
2009-03-21 20:43:56 +00:00
|
|
|
int timeout; /* timeout for buffering */
|
|
|
|
int must_clear; /* stuff we must clear when we close */
|
|
|
|
struct pcap *next; /* list of open pcaps that need stuff cleared on close */
|
1997-05-27 00:01:12 +00:00
|
|
|
#ifdef linux
|
2001-04-03 04:32:48 +00:00
|
|
|
int sock_packet; /* using Linux 2.0 compatible interface */
|
|
|
|
int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
|
2005-05-29 18:09:04 +00:00
|
|
|
int ifindex; /* interface index of device we're bound to */
|
2001-04-03 04:32:48 +00:00
|
|
|
int lo_ifindex; /* interface index of the loopback device */
|
2007-10-16 02:07:55 +00:00
|
|
|
u_int packets_read; /* count of packets read with recvfrom() */
|
2009-03-21 20:43:56 +00:00
|
|
|
bpf_u_int32 oldmode; /* mode to restore when turning monitor mode off */
|
|
|
|
u_int tp_version; /* version of tpacket_hdr for mmaped ring */
|
|
|
|
u_int tp_hdrlen; /* hdrlen of tpacket_hdr for mmaped ring */
|
|
|
|
#endif /* linux */
|
2004-03-31 09:15:09 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_DAG_API
|
2006-09-04 19:54:21 +00:00
|
|
|
#ifdef HAVE_DAG_STREAMS_API
|
|
|
|
u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
|
|
|
|
u_char *dag_mem_top; /* DAG card current memory top pointer */
|
2009-03-21 20:43:56 +00:00
|
|
|
#else /* HAVE_DAG_STREAMS_API */
|
2004-03-31 09:15:09 +00:00
|
|
|
void *dag_mem_base; /* DAG card memory base address */
|
2006-09-04 19:54:21 +00:00
|
|
|
u_int dag_mem_bottom; /* DAG card current memory bottom offset */
|
|
|
|
u_int dag_mem_top; /* DAG card current memory top offset */
|
|
|
|
#endif /* HAVE_DAG_STREAMS_API */
|
2004-03-31 09:15:09 +00:00
|
|
|
int dag_fcs_bits; /* Number of checksum bits from link layer */
|
2005-05-29 18:09:04 +00:00
|
|
|
int dag_offset_flags; /* Flags to pass to dag_offset(). */
|
2006-09-04 19:54:21 +00:00
|
|
|
int dag_stream; /* DAG stream number */
|
|
|
|
int dag_timeout; /* timeout specified to pcap_open_live.
|
|
|
|
* Same as in linux above, introduce
|
|
|
|
* generally? */
|
|
|
|
#endif /* HAVE_DAG_API */
|
2009-03-21 20:43:56 +00:00
|
|
|
#ifdef HAVE_ZEROCOPY_BPF
|
|
|
|
/*
|
|
|
|
* Zero-copy read buffer -- for zero-copy BPF. 'buffer' above will
|
|
|
|
* alternative between these two actual mmap'd buffers as required.
|
|
|
|
* As there is a header on the front size of the mmap'd buffer, only
|
|
|
|
* some of the buffer is exposed to libpcap as a whole via bufsize;
|
|
|
|
* zbufsize is the true size. zbuffer tracks the current zbuf
|
|
|
|
* assocated with buffer so that it can be used to decide which the
|
|
|
|
* next buffer to read will be.
|
|
|
|
*/
|
|
|
|
u_char *zbuf1, *zbuf2, *zbuffer;
|
|
|
|
u_int zbufsize;
|
|
|
|
u_int zerocopy;
|
|
|
|
u_int interrupted;
|
|
|
|
struct timespec firstsel;
|
|
|
|
/*
|
|
|
|
* If there's currently a buffer being actively processed, then it is
|
|
|
|
* referenced here; 'buffer' is also pointed at it, but offset by the
|
|
|
|
* size of the header.
|
|
|
|
*/
|
|
|
|
struct bpf_zbuf_header *bzh;
|
|
|
|
#endif /* HAVE_ZEROCOPY_BPF */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stuff to clear when we close.
|
|
|
|
*/
|
|
|
|
#define MUST_CLEAR_PROMISC 0x00000001 /* promiscuous mode */
|
|
|
|
#define MUST_CLEAR_RFMON 0x00000002 /* rfmon (monitor) mode */
|
|
|
|
|
|
|
|
struct pcap_opt {
|
|
|
|
int buffer_size;
|
|
|
|
char *source;
|
|
|
|
int promisc;
|
|
|
|
int rfmon;
|
1996-08-19 20:36:34 +00:00
|
|
|
};
|
|
|
|
|
2005-07-11 03:43:25 +00:00
|
|
|
/*
|
|
|
|
* Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H
|
2007-10-16 02:07:55 +00:00
|
|
|
* Tru64 UNIX, and some versions of NetBSD pad FDDI packets to make everything
|
|
|
|
* line up on a nice boundary.
|
2005-07-11 03:43:25 +00:00
|
|
|
*/
|
2007-10-16 02:07:55 +00:00
|
|
|
#ifdef __NetBSD__
|
|
|
|
#include <sys/param.h> /* needed to declare __NetBSD_Version__ */
|
|
|
|
#endif
|
|
|
|
|
2005-07-11 03:43:25 +00:00
|
|
|
#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
|
|
|
|
#define PCAP_FDDIPAD 3
|
|
|
|
#endif
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
typedef int (*activate_op_t)(pcap_t *);
|
|
|
|
typedef int (*can_set_rfmon_op_t)(pcap_t *);
|
|
|
|
typedef int (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
|
|
|
|
typedef int (*inject_op_t)(pcap_t *, const void *, size_t);
|
|
|
|
typedef int (*setfilter_op_t)(pcap_t *, struct bpf_program *);
|
|
|
|
typedef int (*setdirection_op_t)(pcap_t *, pcap_direction_t);
|
|
|
|
typedef int (*set_datalink_op_t)(pcap_t *, int);
|
|
|
|
typedef int (*getnonblock_op_t)(pcap_t *, char *);
|
|
|
|
typedef int (*setnonblock_op_t)(pcap_t *, int, char *);
|
|
|
|
typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
|
|
|
|
#ifdef WIN32
|
|
|
|
typedef int (*setbuff_op_t)(pcap_t *, int);
|
|
|
|
typedef int (*setmode_op_t)(pcap_t *, int);
|
|
|
|
typedef int (*setmintocopy_op_t)(pcap_t *, int);
|
|
|
|
#endif
|
|
|
|
typedef void (*cleanup_op_t)(pcap_t *);
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
struct pcap {
|
2004-03-31 09:15:09 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
ADAPTER *adapter;
|
|
|
|
LPPACKET Packet;
|
|
|
|
int nonblock;
|
|
|
|
#else
|
1996-08-19 20:36:34 +00:00
|
|
|
int fd;
|
2004-03-31 09:15:09 +00:00
|
|
|
int selectable_fd;
|
2005-05-29 18:09:04 +00:00
|
|
|
int send_fd;
|
2004-03-31 09:15:09 +00:00
|
|
|
#endif /* WIN32 */
|
2009-03-21 20:43:56 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBDLPI
|
|
|
|
dlpi_handle_t dlpi_hd;
|
|
|
|
#endif
|
1996-08-19 20:36:34 +00:00
|
|
|
int snapshot;
|
2009-03-21 20:43:56 +00:00
|
|
|
int linktype; /* Network linktype */
|
|
|
|
int linktype_ext; /* Extended information stored in the linktype field of a file */
|
1996-08-19 20:36:34 +00:00
|
|
|
int tzoff; /* timezone offset */
|
|
|
|
int offset; /* offset for proper alignment */
|
2009-03-21 20:43:56 +00:00
|
|
|
int activated; /* true if the capture is really started */
|
|
|
|
int oldstyle; /* if we're opening with pcap_open_live() */
|
1996-08-19 20:36:34 +00:00
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
int break_loop; /* flag set to force break from packet-reading loop */
|
|
|
|
|
2005-05-29 18:09:04 +00:00
|
|
|
#ifdef PCAP_FDDIPAD
|
|
|
|
int fddipad;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MSDOS
|
|
|
|
void (*wait_proc)(void); /* call proc while waiting */
|
|
|
|
#endif
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
struct pcap_sf sf;
|
|
|
|
struct pcap_md md;
|
2009-03-21 20:43:56 +00:00
|
|
|
struct pcap_opt opt;
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
/*
|
2008-09-16 20:32:29 +00:00
|
|
|
* Read buffer -- for file descriptor read buffer model.
|
1996-08-19 20:36:34 +00:00
|
|
|
*/
|
|
|
|
int bufsize;
|
|
|
|
u_char *buffer;
|
|
|
|
u_char *bp;
|
|
|
|
int cc;
|
2008-09-16 20:32:29 +00:00
|
|
|
int to_ms;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Zero-copy read buffer -- for zero-copy BPF. 'buffer' above will
|
|
|
|
* alternative between these two actual mmap'd buffers as required.
|
|
|
|
* As there is a header on the front size of the mmap'd buffer, only
|
|
|
|
* some of the buffer is exposed to libpcap as a whole via bufsize;
|
|
|
|
* zbufsize is the true size. zbuffer tracks the current zbuf
|
|
|
|
* assocated with buffer so that it can be used to decide which the
|
|
|
|
* next buffer to read will be.
|
|
|
|
*/
|
|
|
|
u_char *zbuf1, *zbuf2, *zbuffer;
|
|
|
|
u_int zbufsize;
|
|
|
|
u_int timeout;
|
|
|
|
u_int zerocopy;
|
|
|
|
u_int interrupted;
|
|
|
|
struct timespec firstsel;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's currently a buffer being actively processed, then it is
|
|
|
|
* referenced here; 'buffer' is also pointed at it, but offset by the
|
|
|
|
* size of the header.
|
|
|
|
*/
|
|
|
|
struct bpf_zbuf_header *bzh;
|
1996-08-19 20:36:34 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Place holder for pcap_next().
|
|
|
|
*/
|
|
|
|
u_char *pkt;
|
|
|
|
|
2005-07-11 03:43:25 +00:00
|
|
|
/* We're accepting only packets in this direction/these directions. */
|
2006-09-04 19:54:21 +00:00
|
|
|
pcap_direction_t direction;
|
2005-07-11 03:43:25 +00:00
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
/*
|
|
|
|
* Methods.
|
|
|
|
*/
|
2009-03-21 20:43:56 +00:00
|
|
|
activate_op_t activate_op;
|
|
|
|
can_set_rfmon_op_t can_set_rfmon_op;
|
|
|
|
read_op_t read_op;
|
|
|
|
inject_op_t inject_op;
|
|
|
|
setfilter_op_t setfilter_op;
|
|
|
|
setdirection_op_t setdirection_op;
|
|
|
|
set_datalink_op_t set_datalink_op;
|
|
|
|
getnonblock_op_t getnonblock_op;
|
|
|
|
setnonblock_op_t setnonblock_op;
|
|
|
|
stats_op_t stats_op;
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
/*
|
|
|
|
* These are, at least currently, specific to the Win32 NPF
|
|
|
|
* driver.
|
|
|
|
*/
|
|
|
|
setbuff_op_t setbuff_op;
|
|
|
|
setmode_op_t setmode_op;
|
|
|
|
setmintocopy_op_t setmintocopy_op;
|
|
|
|
#endif
|
|
|
|
cleanup_op_t cleanup_op;
|
2004-03-31 09:15:09 +00:00
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
/*
|
|
|
|
* Placeholder for filter code if bpf not in kernel.
|
|
|
|
*/
|
|
|
|
struct bpf_program fcode;
|
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
char errbuf[PCAP_ERRBUF_SIZE + 1];
|
2003-01-26 01:21:53 +00:00
|
|
|
int dlt_count;
|
2005-05-29 18:09:04 +00:00
|
|
|
u_int *dlt_list;
|
2004-03-31 09:15:09 +00:00
|
|
|
|
|
|
|
struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
|
1996-08-19 20:36:34 +00:00
|
|
|
};
|
|
|
|
|
2000-01-30 00:43:38 +00:00
|
|
|
/*
|
2007-10-16 02:07:55 +00:00
|
|
|
* This is a timeval as stored in a savefile.
|
2000-01-30 00:43:38 +00:00
|
|
|
* It has to use the same types everywhere, independent of the actual
|
2007-10-16 02:07:55 +00:00
|
|
|
* `struct timeval'; `struct timeval' has 32-bit tv_sec values on some
|
|
|
|
* platforms and 64-bit tv_sec values on other platforms, and writing
|
|
|
|
* out native `struct timeval' values would mean files could only be
|
|
|
|
* read on systems with the same tv_sec size as the system on which
|
|
|
|
* the file was written.
|
2000-01-30 00:43:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct pcap_timeval {
|
|
|
|
bpf_int32 tv_sec; /* seconds */
|
|
|
|
bpf_int32 tv_usec; /* microseconds */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2007-10-16 02:07:55 +00:00
|
|
|
* This is a `pcap_pkthdr' as actually stored in a savefile.
|
2001-04-03 04:32:48 +00:00
|
|
|
*
|
|
|
|
* Do not change the format of this structure, in any way (this includes
|
|
|
|
* changes that only affect the length of fields in this structure),
|
|
|
|
* and do not make the time stamp anything other than seconds and
|
|
|
|
* microseconds (e.g., seconds and nanoseconds). Instead:
|
|
|
|
*
|
|
|
|
* introduce a new structure for the new format;
|
|
|
|
*
|
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
|
2001-04-03 04:32:48 +00:00
|
|
|
* you get the new magic number, put it in "savefile.c";
|
|
|
|
*
|
|
|
|
* use that magic number for save files with the changed record
|
|
|
|
* header;
|
|
|
|
*
|
|
|
|
* make the code in "savefile.c" capable of reading files with
|
|
|
|
* the old record header as well as files with the new record header
|
|
|
|
* (using the magic number to determine the header format).
|
|
|
|
*
|
2009-03-21 20:43:56 +00:00
|
|
|
* Then supply the changes as a patch at
|
|
|
|
*
|
|
|
|
* http://sourceforge.net/projects/libpcap/
|
|
|
|
*
|
|
|
|
* so that future versions of libpcap and programs that use it (such as
|
|
|
|
* tcpdump) will be able to read your new capture file format.
|
2000-01-30 00:43:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct pcap_sf_pkthdr {
|
|
|
|
struct pcap_timeval ts; /* time stamp */
|
|
|
|
bpf_u_int32 caplen; /* length of portion present */
|
|
|
|
bpf_u_int32 len; /* length this packet (off wire) */
|
|
|
|
};
|
|
|
|
|
2001-04-03 04:32:48 +00:00
|
|
|
/*
|
2007-10-16 02:07:55 +00:00
|
|
|
* How a `pcap_pkthdr' is actually stored in savefiles written
|
2001-04-03 04:32:48 +00:00
|
|
|
* by some patched versions of libpcap (e.g. the ones in Red
|
|
|
|
* Hat Linux 6.1 and 6.2).
|
|
|
|
*
|
|
|
|
* Do not change the format of this structure, in any way (this includes
|
|
|
|
* changes that only affect the length of fields in this structure).
|
|
|
|
* Instead, introduce a new structure, as per the above.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct pcap_sf_patched_pkthdr {
|
|
|
|
struct pcap_timeval ts; /* time stamp */
|
|
|
|
bpf_u_int32 caplen; /* length of portion present */
|
|
|
|
bpf_u_int32 len; /* length this packet (off wire) */
|
|
|
|
int index;
|
|
|
|
unsigned short protocol;
|
|
|
|
unsigned char pkt_type;
|
|
|
|
};
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
int yylex(void);
|
|
|
|
|
|
|
|
#ifndef min
|
|
|
|
#define min(a, b) ((a) > (b) ? (b) : (a))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* XXX should these be in pcap.h? */
|
|
|
|
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
|
|
|
|
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
|
|
|
|
|
2005-07-11 03:43:25 +00:00
|
|
|
#ifndef HAVE_STRLCPY
|
|
|
|
#define strlcpy(x, y, z) \
|
|
|
|
(strncpy((x), (y), (z)), \
|
|
|
|
((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
|
|
|
|
strlen((y)))
|
1996-08-19 20:36:34 +00:00
|
|
|
#endif
|
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Routines that most pcap implementations can use for non-blocking mode.
|
|
|
|
*/
|
2005-05-29 18:09:04 +00:00
|
|
|
#if !defined(WIN32) && !defined(MSDOS)
|
2004-03-31 09:15:09 +00:00
|
|
|
int pcap_getnonblock_fd(pcap_t *, char *);
|
|
|
|
int pcap_setnonblock_fd(pcap_t *p, int, char *);
|
|
|
|
#endif
|
|
|
|
|
2009-03-21 20:43:56 +00:00
|
|
|
pcap_t *pcap_create_common(const char *, char *);
|
|
|
|
int pcap_do_addexit(pcap_t *);
|
|
|
|
void pcap_add_to_pcaps_to_close(pcap_t *);
|
|
|
|
void pcap_remove_from_pcaps_to_close(pcap_t *);
|
|
|
|
void pcap_cleanup_live_common(pcap_t *);
|
|
|
|
int pcap_not_initialized(pcap_t *);
|
|
|
|
int pcap_check_activated(pcap_t *);
|
2005-05-29 18:09:04 +00:00
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
/*
|
|
|
|
* Internal interfaces for "pcap_findalldevs()".
|
|
|
|
*
|
|
|
|
* "pcap_platform_finddevs()" is a platform-dependent routine to
|
|
|
|
* add devices not found by the "standard" mechanisms (SIOCGIFCONF,
|
|
|
|
* "getifaddrs()", etc..
|
|
|
|
*
|
|
|
|
* "pcap_add_if()" adds an interface to the list of interfaces.
|
|
|
|
*/
|
|
|
|
int pcap_platform_finddevs(pcap_if_t **, char *);
|
2005-05-29 18:09:04 +00:00
|
|
|
int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
|
2004-03-31 09:15:09 +00:00
|
|
|
size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
|
|
|
|
struct sockaddr *, size_t, char *);
|
2005-05-29 18:09:04 +00:00
|
|
|
int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *);
|
2004-03-31 09:15:09 +00:00
|
|
|
struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
|
|
|
|
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
|
|
|
|
const char *, char *);
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
char *pcap_win32strerror(void);
|
2001-04-03 04:32:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int install_bpf_program(pcap_t *, struct bpf_program *);
|
|
|
|
|
2004-03-31 09:15:09 +00:00
|
|
|
int pcap_strcasecmp(const char *, const char *);
|
|
|
|
|
1998-08-07 06:20:58 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1996-08-19 20:36:34 +00:00
|
|
|
#endif
|