117683Spst/*
217683Spst * Copyright (c) 1994, 1995, 1996
317683Spst *	The Regents of the University of California.  All rights reserved.
417683Spst *
517683Spst * Redistribution and use in source and binary forms, with or without
617683Spst * modification, are permitted provided that the following conditions
717683Spst * are met:
817683Spst * 1. Redistributions of source code must retain the above copyright
917683Spst *    notice, this list of conditions and the following disclaimer.
1017683Spst * 2. Redistributions in binary form must reproduce the above copyright
1117683Spst *    notice, this list of conditions and the following disclaimer in the
1217683Spst *    documentation and/or other materials provided with the distribution.
1317683Spst * 3. All advertising materials mentioning features or use of this software
1417683Spst *    must display the following acknowledgement:
1517683Spst *	This product includes software developed by the Computer Systems
1617683Spst *	Engineering Group at Lawrence Berkeley Laboratory.
1717683Spst * 4. Neither the name of the University nor of the Laboratory may be used
1817683Spst *    to endorse or promote products derived from this software without
1917683Spst *    specific prior written permission.
2017683Spst *
2117683Spst * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2217683Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2317683Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2417683Spst * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2517683Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2617683Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2717683Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2817683Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2917683Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3017683Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3117683Spst * SUCH DAMAGE.
3217683Spst *
33214518Srpaulo * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.94 2008-09-16 00:20:23 guy Exp $ (LBL)
3417683Spst */
3517683Spst
3617683Spst#ifndef pcap_int_h
37190225Srpaulo#define	pcap_int_h
3817683Spst
39190225Srpaulo#include <pcap/pcap.h>
40190225Srpaulo
4138151Sphk#ifdef __cplusplus
4238151Sphkextern "C" {
4338151Sphk#endif
4438151Sphk
45190225Srpaulo#ifdef HAVE_LIBDLPI
46190225Srpaulo#include <libdlpi.h>
47190225Srpaulo#endif
4817683Spst
49127667Sbms#ifdef WIN32
50172680Smlaier#include <Packet32.h>
51214518Srpauloextern CRITICAL_SECTION g_PcapCompileCriticalSection;
52127667Sbms#endif /* WIN32 */
53127667Sbms
54146771Ssam#ifdef MSDOS
55146771Ssam#include <fcntl.h>
56146771Ssam#include <io.h>
57146771Ssam#endif
58146771Ssam
59214518Srpaulo#ifdef HAVE_SNF_API
60214518Srpaulo#include <snf.h>
61214518Srpaulo#endif
62214518Srpaulo
63190225Srpaulo#if (defined(_MSC_VER) && (_MSC_VER <= 1200)) /* we are compiling with Visual Studio 6, that doesn't support the LL suffix*/
64190225Srpaulo
6517683Spst/*
66172680Smlaier * Swap byte ordering of unsigned long long timestamp on a big endian
67172680Smlaier * machine.
68172680Smlaier */
69190225Srpaulo#define SWAPLL(ull)  ((ull & 0xff00000000000000) >> 56) | \
70190225Srpaulo                      ((ull & 0x00ff000000000000) >> 40) | \
71190225Srpaulo                      ((ull & 0x0000ff0000000000) >> 24) | \
72190225Srpaulo                      ((ull & 0x000000ff00000000) >> 8)  | \
73190225Srpaulo                      ((ull & 0x00000000ff000000) << 8)  | \
74190225Srpaulo                      ((ull & 0x0000000000ff0000) << 24) | \
75190225Srpaulo                      ((ull & 0x000000000000ff00) << 40) | \
76190225Srpaulo                      ((ull & 0x00000000000000ff) << 56)
77190225Srpaulo
78190225Srpaulo#else /* A recent Visual studio compiler or not VC */
79190225Srpaulo
80190225Srpaulo/*
81190225Srpaulo * Swap byte ordering of unsigned long long timestamp on a big endian
82190225Srpaulo * machine.
83190225Srpaulo */
84172680Smlaier#define SWAPLL(ull)  ((ull & 0xff00000000000000LL) >> 56) | \
85172680Smlaier                      ((ull & 0x00ff000000000000LL) >> 40) | \
86172680Smlaier                      ((ull & 0x0000ff0000000000LL) >> 24) | \
87172680Smlaier                      ((ull & 0x000000ff00000000LL) >> 8)  | \
88172680Smlaier                      ((ull & 0x00000000ff000000LL) << 8)  | \
89172680Smlaier                      ((ull & 0x0000000000ff0000LL) << 24) | \
90172680Smlaier                      ((ull & 0x000000000000ff00LL) << 40) | \
91172680Smlaier                      ((ull & 0x00000000000000ffLL) << 56)
92172680Smlaier
93190225Srpaulo#endif /* _MSC_VER */
94190225Srpaulo
95172680Smlaier/*
9617683Spst * Savefile
9717683Spst */
98127667Sbmstypedef enum {
99127667Sbms	NOT_SWAPPED,
100127667Sbms	SWAPPED,
101127667Sbms	MAYBE_SWAPPED
102127667Sbms} swapped_type_t;
103127667Sbms
104190225Srpaulo/*
105190225Srpaulo * Used when reading a savefile.
106190225Srpaulo */
10717683Spststruct pcap_sf {
10817683Spst	FILE *rfile;
109214518Srpaulo	int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
11017683Spst	int swapped;
111190225Srpaulo	size_t hdrsize;
112127667Sbms	swapped_type_t lengths_swapped;
11317683Spst	int version_major;
11417683Spst	int version_minor;
115214518Srpaulo	bpf_u_int32 ifcount;	/* number of interfaces seen in this capture */
116214518Srpaulo	u_int tsresol;		/* time stamp resolution */
117214518Srpaulo	u_int tsscale;		/* scaling factor for resolution -> microseconds */
118214518Srpaulo	u_int64_t tsoffset;	/* time stamp offset */
11917683Spst};
12017683Spst
121190225Srpaulo/*
122190225Srpaulo * Used when doing a live capture.
123190225Srpaulo */
12417683Spststruct pcap_md {
12517683Spst	struct pcap_stat stat;
12617683Spst	/*XXX*/
12775110Sfenner	int use_bpf;		/* using kernel filter */
12817683Spst	u_long	TotPkts;	/* can't oflow for 79 hrs on ether */
12917683Spst	u_long	TotAccepted;	/* count accepted by filter */
13017683Spst	u_long	TotDrops;	/* count of dropped packets */
13117683Spst	long	TotMissed;	/* missed by i/f during this run */
13217683Spst	long	OrigMissed;	/* missed by i/f before this run */
133146771Ssam	char	*device;	/* device name */
134190225Srpaulo	int	timeout;	/* timeout for buffering */
135214518Srpaulo	int	must_do_on_close; /* stuff we must do when we close */
136190225Srpaulo	struct pcap *next;	/* list of open pcaps that need stuff cleared on close */
13726175Sfenner#ifdef linux
13875110Sfenner	int	sock_packet;	/* using Linux 2.0 compatible interface */
13975110Sfenner	int	cooked;		/* using SOCK_DGRAM rather than SOCK_RAW */
140146771Ssam	int	ifindex;	/* interface index of device we're bound to */
14175110Sfenner	int	lo_ifindex;	/* interface index of the loopback device */
142172680Smlaier	u_int	packets_read;	/* count of packets read with recvfrom() */
143190225Srpaulo	bpf_u_int32 oldmode;	/* mode to restore when turning monitor mode off */
144214518Srpaulo	char	*mondevice;	/* mac80211 monitor device we created */
145214518Srpaulo	u_char	*mmapbuf;	/* memory-mapped region pointer */
146214518Srpaulo	size_t	mmapbuflen;	/* size of region */
147252281Sdelphij	int	vlan_offset;	/* offset at which to insert vlan tags; if -1, don't insert */
148190225Srpaulo	u_int	tp_version;	/* version of tpacket_hdr for mmaped ring */
149190225Srpaulo	u_int	tp_hdrlen;	/* hdrlen of tpacket_hdr for mmaped ring */
150214518Srpaulo	u_char	*oneshot_buffer; /* buffer for copy of packet */
151214518Srpaulo	long	proc_dropped; /* packets reported dropped by /proc/net/dev */
152190225Srpaulo#endif /* linux */
153127667Sbms
154127667Sbms#ifdef HAVE_DAG_API
155162015Ssam#ifdef HAVE_DAG_STREAMS_API
156162015Ssam	u_char	*dag_mem_bottom;	/* DAG card current memory bottom pointer */
157162015Ssam	u_char	*dag_mem_top;	/* DAG card current memory top pointer */
158190225Srpaulo#else /* HAVE_DAG_STREAMS_API */
159127667Sbms	void	*dag_mem_base;	/* DAG card memory base address */
160162015Ssam	u_int	dag_mem_bottom;	/* DAG card current memory bottom offset */
161162015Ssam	u_int	dag_mem_top;	/* DAG card current memory top offset */
162162015Ssam#endif /* HAVE_DAG_STREAMS_API */
163127667Sbms	int	dag_fcs_bits;	/* Number of checksum bits from link layer */
164146771Ssam	int	dag_offset_flags; /* Flags to pass to dag_offset(). */
165162015Ssam	int	dag_stream;	/* DAG stream number */
166162015Ssam	int	dag_timeout;	/* timeout specified to pcap_open_live.
167162015Ssam				 * Same as in linux above, introduce
168162015Ssam				 * generally? */
169162015Ssam#endif /* HAVE_DAG_API */
170214518Srpaulo#ifdef HAVE_SNF_API
171214518Srpaulo	snf_handle_t snf_handle; /* opaque device handle */
172214518Srpaulo	snf_ring_t   snf_ring;   /* opaque device ring handle */
173214518Srpaulo        int          snf_timeout;
174214518Srpaulo        int          snf_boardnum;
175214518Srpaulo#endif /*HAVE_SNF_API*/
176214518Srpaulo
177190225Srpaulo#ifdef HAVE_ZEROCOPY_BPF
178190225Srpaulo       /*
179190225Srpaulo        * Zero-copy read buffer -- for zero-copy BPF.  'buffer' above will
180190225Srpaulo        * alternative between these two actual mmap'd buffers as required.
181190225Srpaulo        * As there is a header on the front size of the mmap'd buffer, only
182190225Srpaulo        * some of the buffer is exposed to libpcap as a whole via bufsize;
183190225Srpaulo        * zbufsize is the true size.  zbuffer tracks the current zbuf
184190225Srpaulo        * assocated with buffer so that it can be used to decide which the
185190225Srpaulo        * next buffer to read will be.
186190225Srpaulo        */
187190225Srpaulo       u_char *zbuf1, *zbuf2, *zbuffer;
188190225Srpaulo       u_int zbufsize;
189190225Srpaulo       u_int zerocopy;
190190225Srpaulo       u_int interrupted;
191190225Srpaulo       struct timespec firstsel;
192190225Srpaulo       /*
193190225Srpaulo        * If there's currently a buffer being actively processed, then it is
194190225Srpaulo        * referenced here; 'buffer' is also pointed at it, but offset by the
195190225Srpaulo        * size of the header.
196190225Srpaulo        */
197190225Srpaulo       struct bpf_zbuf_header *bzh;
198190225Srpaulo#endif /* HAVE_ZEROCOPY_BPF */
19917683Spst};
20017683Spst
201147897Ssam/*
202214518Srpaulo * Stuff to do when we close.
203190225Srpaulo */
204214518Srpaulo#define MUST_CLEAR_PROMISC	0x00000001	/* clear promiscuous mode */
205214518Srpaulo#define MUST_CLEAR_RFMON	0x00000002	/* clear rfmon (monitor) mode */
206214518Srpaulo#define MUST_DELETE_MONIF	0x00000004	/* delete monitor-mode interface */
207190225Srpaulo
208190225Srpaulostruct pcap_opt {
209190225Srpaulo	int	buffer_size;
210190225Srpaulo	char	*source;
211190225Srpaulo	int	promisc;
212190225Srpaulo	int	rfmon;
213236167Sdelphij	int	tstamp_type;
214190225Srpaulo};
215190225Srpaulo
216190225Srpaulo/*
217147897Ssam * 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
218172680Smlaier * Tru64 UNIX, and some versions of NetBSD pad FDDI packets to make everything
219172680Smlaier * line up on a nice boundary.
220147897Ssam */
221172680Smlaier#ifdef __NetBSD__
222172680Smlaier#include <sys/param.h>	/* needed to declare __NetBSD_Version__ */
223172680Smlaier#endif
224172680Smlaier
225147897Ssam#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
226147897Ssam#define       PCAP_FDDIPAD 3
227147897Ssam#endif
228147897Ssam
229190225Srpaulotypedef int	(*activate_op_t)(pcap_t *);
230190225Srpaulotypedef int	(*can_set_rfmon_op_t)(pcap_t *);
231190225Srpaulotypedef int	(*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
232190225Srpaulotypedef int	(*inject_op_t)(pcap_t *, const void *, size_t);
233190225Srpaulotypedef int	(*setfilter_op_t)(pcap_t *, struct bpf_program *);
234190225Srpaulotypedef int	(*setdirection_op_t)(pcap_t *, pcap_direction_t);
235190225Srpaulotypedef int	(*set_datalink_op_t)(pcap_t *, int);
236190225Srpaulotypedef int	(*getnonblock_op_t)(pcap_t *, char *);
237190225Srpaulotypedef int	(*setnonblock_op_t)(pcap_t *, int, char *);
238190225Srpaulotypedef int	(*stats_op_t)(pcap_t *, struct pcap_stat *);
239190225Srpaulo#ifdef WIN32
240190225Srpaulotypedef int	(*setbuff_op_t)(pcap_t *, int);
241190225Srpaulotypedef int	(*setmode_op_t)(pcap_t *, int);
242190225Srpaulotypedef int	(*setmintocopy_op_t)(pcap_t *, int);
243190225Srpaulo#endif
244190225Srpaulotypedef void	(*cleanup_op_t)(pcap_t *);
245190225Srpaulo
24617683Spststruct pcap {
247127667Sbms#ifdef WIN32
248127667Sbms	ADAPTER *adapter;
249127667Sbms	LPPACKET Packet;
250127667Sbms	int nonblock;
251127667Sbms#else
25217683Spst	int fd;
253127667Sbms	int selectable_fd;
254146771Ssam	int send_fd;
255127667Sbms#endif /* WIN32 */
256190225Srpaulo
257190225Srpaulo#ifdef HAVE_LIBDLPI
258190225Srpaulo	dlpi_handle_t dlpi_hd;
259190225Srpaulo#endif
26017683Spst	int snapshot;
261190225Srpaulo	int linktype;		/* Network linktype */
262190225Srpaulo	int linktype_ext;       /* Extended information stored in the linktype field of a file */
26317683Spst	int tzoff;		/* timezone offset */
26417683Spst	int offset;		/* offset for proper alignment */
265190225Srpaulo	int activated;		/* true if the capture is really started */
266190225Srpaulo	int oldstyle;		/* if we're opening with pcap_open_live() */
26717683Spst
268127667Sbms	int break_loop;		/* flag set to force break from packet-reading loop */
269127667Sbms
270146771Ssam#ifdef PCAP_FDDIPAD
271146771Ssam	int fddipad;
272146771Ssam#endif
273146771Ssam
274146771Ssam#ifdef MSDOS
275146771Ssam        void (*wait_proc)(void); /*          call proc while waiting */
276146771Ssam#endif
277146771Ssam
27817683Spst	struct pcap_sf sf;
27917683Spst	struct pcap_md md;
280190225Srpaulo	struct pcap_opt opt;
28117683Spst
28217683Spst	/*
283214518Srpaulo	 * Read buffer.
28417683Spst	 */
28517683Spst	int bufsize;
28617683Spst	u_char *buffer;
28717683Spst	u_char *bp;
28817683Spst	int cc;
28917683Spst
29017683Spst	/*
29117683Spst	 * Place holder for pcap_next().
29217683Spst	 */
29317683Spst	u_char *pkt;
29417683Spst
295147897Ssam	/* We're accepting only packets in this direction/these directions. */
296162015Ssam	pcap_direction_t direction;
297147897Ssam
29817683Spst	/*
299127667Sbms	 * Methods.
300127667Sbms	 */
301190225Srpaulo	activate_op_t activate_op;
302190225Srpaulo	can_set_rfmon_op_t can_set_rfmon_op;
303190225Srpaulo	read_op_t read_op;
304190225Srpaulo	inject_op_t inject_op;
305190225Srpaulo	setfilter_op_t setfilter_op;
306190225Srpaulo	setdirection_op_t setdirection_op;
307190225Srpaulo	set_datalink_op_t set_datalink_op;
308190225Srpaulo	getnonblock_op_t getnonblock_op;
309190225Srpaulo	setnonblock_op_t setnonblock_op;
310190225Srpaulo	stats_op_t stats_op;
311127667Sbms
312214518Srpaulo	/*
313214518Srpaulo	 * Routine to use as callback for pcap_next()/pcap_next_ex().
314214518Srpaulo	 */
315214518Srpaulo	pcap_handler oneshot_callback;
316214518Srpaulo
317190225Srpaulo#ifdef WIN32
318127667Sbms	/*
319190225Srpaulo	 * These are, at least currently, specific to the Win32 NPF
320190225Srpaulo	 * driver.
321190225Srpaulo	 */
322190225Srpaulo	setbuff_op_t setbuff_op;
323190225Srpaulo	setmode_op_t setmode_op;
324190225Srpaulo	setmintocopy_op_t setmintocopy_op;
325190225Srpaulo#endif
326190225Srpaulo	cleanup_op_t cleanup_op;
327190225Srpaulo
328190225Srpaulo	/*
32917683Spst	 * Placeholder for filter code if bpf not in kernel.
33017683Spst	 */
33117683Spst	struct bpf_program fcode;
33217683Spst
333127667Sbms	char errbuf[PCAP_ERRBUF_SIZE + 1];
334109841Sfenner	int dlt_count;
335146771Ssam	u_int *dlt_list;
336236167Sdelphij	int tstamp_type_count;
337236167Sdelphij	u_int *tstamp_type_list;
338127667Sbms
339127667Sbms	struct pcap_pkthdr pcap_header;	/* This is needed for the pcap_next_ex() to work */
34017683Spst};
34117683Spst
34256891Sfenner/*
343172680Smlaier * This is a timeval as stored in a savefile.
34456891Sfenner * It has to use the same types everywhere, independent of the actual
345172680Smlaier * `struct timeval'; `struct timeval' has 32-bit tv_sec values on some
346172680Smlaier * platforms and 64-bit tv_sec values on other platforms, and writing
347172680Smlaier * out native `struct timeval' values would mean files could only be
348172680Smlaier * read on systems with the same tv_sec size as the system on which
349172680Smlaier * the file was written.
35056891Sfenner */
35156891Sfenner
35256891Sfennerstruct pcap_timeval {
35356891Sfenner    bpf_int32 tv_sec;		/* seconds */
35456891Sfenner    bpf_int32 tv_usec;		/* microseconds */
35556891Sfenner};
35656891Sfenner
35756891Sfenner/*
358172680Smlaier * This is a `pcap_pkthdr' as actually stored in a savefile.
35975110Sfenner *
36075110Sfenner * Do not change the format of this structure, in any way (this includes
36175110Sfenner * changes that only affect the length of fields in this structure),
36275110Sfenner * and do not make the time stamp anything other than seconds and
36375110Sfenner * microseconds (e.g., seconds and nanoseconds).  Instead:
36475110Sfenner *
36575110Sfenner *	introduce a new structure for the new format;
36675110Sfenner *
367190225Srpaulo *	send mail to "tcpdump-workers@lists.tcpdump.org", requesting
368190225Srpaulo *	a new magic number for your new capture file format, and, when
36975110Sfenner *	you get the new magic number, put it in "savefile.c";
37075110Sfenner *
37175110Sfenner *	use that magic number for save files with the changed record
37275110Sfenner *	header;
37375110Sfenner *
37475110Sfenner *	make the code in "savefile.c" capable of reading files with
37575110Sfenner *	the old record header as well as files with the new record header
37675110Sfenner *	(using the magic number to determine the header format).
37775110Sfenner *
378252281Sdelphij * Then supply the changes by forking the branch at
379190225Srpaulo *
380252281Sdelphij *	https://github.com/mcr/libpcap/issues
381190225Srpaulo *
382252281Sdelphij * and issuing a pull request, so that future versions of libpcap and
383252281Sdelphij * programs that use it (such as tcpdump) will be able to read your new
384252281Sdelphij * capture file format.
38556891Sfenner */
38656891Sfenner
38756891Sfennerstruct pcap_sf_pkthdr {
38856891Sfenner    struct pcap_timeval ts;	/* time stamp */
38956891Sfenner    bpf_u_int32 caplen;		/* length of portion present */
39056891Sfenner    bpf_u_int32 len;		/* length this packet (off wire) */
39156891Sfenner};
39256891Sfenner
39375110Sfenner/*
394172680Smlaier * How a `pcap_pkthdr' is actually stored in savefiles written
39575110Sfenner * by some patched versions of libpcap (e.g. the ones in Red
39675110Sfenner * Hat Linux 6.1 and 6.2).
39775110Sfenner *
39875110Sfenner * Do not change the format of this structure, in any way (this includes
39975110Sfenner * changes that only affect the length of fields in this structure).
40075110Sfenner * Instead, introduce a new structure, as per the above.
40175110Sfenner */
40275110Sfenner
40375110Sfennerstruct pcap_sf_patched_pkthdr {
40475110Sfenner    struct pcap_timeval ts;	/* time stamp */
40575110Sfenner    bpf_u_int32 caplen;		/* length of portion present */
40675110Sfenner    bpf_u_int32 len;		/* length this packet (off wire) */
40775110Sfenner    int		index;
40875110Sfenner    unsigned short protocol;
40975110Sfenner    unsigned char pkt_type;
41075110Sfenner};
41175110Sfenner
412214518Srpaulo/*
413214518Srpaulo * User data structure for the one-shot callback used for pcap_next()
414214518Srpaulo * and pcap_next_ex().
415214518Srpaulo */
416214518Srpaulostruct oneshot_userdata {
417214518Srpaulo	struct pcap_pkthdr *hdr;
418214518Srpaulo	const u_char **pkt;
419214518Srpaulo	pcap_t *pd;
420214518Srpaulo};
421214518Srpaulo
42217683Spstint	yylex(void);
42317683Spst
42417683Spst#ifndef min
42517683Spst#define min(a, b) ((a) > (b) ? (b) : (a))
42617683Spst#endif
42717683Spst
42817683Spst/* XXX should these be in pcap.h? */
42917683Spstint	pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
43017683Spstint	pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
43117683Spst
432147897Ssam#ifndef HAVE_STRLCPY
433147897Ssam#define strlcpy(x, y, z) \
434147897Ssam	(strncpy((x), (y), (z)), \
435147897Ssam	 ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \
436147897Ssam	 strlen((y)))
43717683Spst#endif
43817683Spst
439127667Sbms#include <stdarg.h>
440127667Sbms
441214518Srpaulo#if !defined(HAVE_SNPRINTF)
442214518Srpaulo#define snprintf pcap_snprintf
443214518Srpauloextern int snprintf (char *, size_t, const char *, ...);
444214518Srpaulo#endif
445214518Srpaulo
446214518Srpaulo#if !defined(HAVE_VSNPRINTF)
447214518Srpaulo#define vsnprintf pcap_vsnprintf
448214518Srpauloextern int vsnprintf (char *, size_t, const char *, va_list ap);
449214518Srpaulo#endif
450214518Srpaulo
451127667Sbms/*
452127667Sbms * Routines that most pcap implementations can use for non-blocking mode.
453127667Sbms */
454146771Ssam#if !defined(WIN32) && !defined(MSDOS)
455127667Sbmsint	pcap_getnonblock_fd(pcap_t *, char *);
456127667Sbmsint	pcap_setnonblock_fd(pcap_t *p, int, char *);
457127667Sbms#endif
458127667Sbms
459252281Sdelphij/*
460252281Sdelphij * Internal interfaces for "pcap_create()".
461252281Sdelphij *
462252281Sdelphij * "pcap_create_interface()" is the routine to do a pcap_create on
463252281Sdelphij * a regular network interface.  There are multiple implementations
464252281Sdelphij * of this, one for each platform type (Linux, BPF, DLPI, etc.),
465252281Sdelphij * with the one used chosen by the configure script.
466252281Sdelphij *
467252281Sdelphij * "pcap_create_common()" allocates and fills in a pcap_t, for use
468252281Sdelphij * by pcap_create routines.
469252281Sdelphij */
470252281Sdelphijpcap_t	*pcap_create_interface(const char *, char *);
471190225Srpaulopcap_t	*pcap_create_common(const char *, char *);
472190225Srpauloint	pcap_do_addexit(pcap_t *);
473190225Srpaulovoid	pcap_add_to_pcaps_to_close(pcap_t *);
474190225Srpaulovoid	pcap_remove_from_pcaps_to_close(pcap_t *);
475190225Srpaulovoid	pcap_cleanup_live_common(pcap_t *);
476190225Srpauloint	pcap_not_initialized(pcap_t *);
477190225Srpauloint	pcap_check_activated(pcap_t *);
478146771Ssam
479127667Sbms/*
480127667Sbms * Internal interfaces for "pcap_findalldevs()".
481127667Sbms *
482252281Sdelphij * "pcap_findalldevs_interfaces()" finds interfaces using the
483252281Sdelphij * "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.).
484252281Sdelphij *
485127667Sbms * "pcap_platform_finddevs()" is a platform-dependent routine to
486252281Sdelphij * add devices not found by the "standard" mechanisms.
487127667Sbms *
488252281Sdelphij * "pcap_add_if()" adds an interface to the list of interfaces, for
489252281Sdelphij * use by various "find interfaces" routines.
490127667Sbms */
491252281Sdelphijint	pcap_findalldevs_interfaces(pcap_if_t **, char *);
492127667Sbmsint	pcap_platform_finddevs(pcap_if_t **, char *);
493146771Ssamint	add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
494127667Sbms	    size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
495127667Sbms	    struct sockaddr *, size_t, char *);
496146771Ssamint	pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *);
497127667Sbmsstruct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
498127667Sbmsint	add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
499127667Sbms	    const char *, char *);
500127667Sbms
501127667Sbms#ifdef WIN32
502127667Sbmschar	*pcap_win32strerror(void);
503127667Sbms#endif
504127667Sbms
50575110Sfennerint	install_bpf_program(pcap_t *, struct bpf_program *);
50675110Sfenner
507127667Sbmsint	pcap_strcasecmp(const char *, const char *);
508127667Sbms
50938151Sphk#ifdef __cplusplus
51038151Sphk}
51117683Spst#endif
51238151Sphk
51338151Sphk#endif
514