pcap-int.h revision 26175
1290000Sglebius/*
2181834Sroberto * Copyright (c) 1994, 1995, 1996
3290000Sglebius *	The Regents of the University of California.  All rights reserved.
4310419Sdelphij *
5181834Sroberto * Redistribution and use in source and binary forms, with or without
6181834Sroberto * modification, are permitted provided that the following conditions
7181834Sroberto * are met:
8290000Sglebius * 1. Redistributions of source code must retain the above copyright
9181834Sroberto *    notice, this list of conditions and the following disclaimer.
10290000Sglebius * 2. Redistributions in binary form must reproduce the above copyright
11290000Sglebius *    notice, this list of conditions and the following disclaimer in the
12290000Sglebius *    documentation and/or other materials provided with the distribution.
13290000Sglebius * 3. All advertising materials mentioning features or use of this software
14290000Sglebius *    must display the following acknowledgement:
15290000Sglebius *	This product includes software developed by the Computer Systems
16290000Sglebius *	Engineering Group at Lawrence Berkeley Laboratory.
17181834Sroberto * 4. Neither the name of the University nor of the Laboratory may be used
18290000Sglebius *    to endorse or promote products derived from this software without
19290000Sglebius *    specific prior written permission.
20181834Sroberto *
21294904Sdelphij * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22290000Sglebius * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23290000Sglebius * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24290000Sglebius * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25290000Sglebius * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26290000Sglebius * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27290000Sglebius * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28290000Sglebius * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29290000Sglebius * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30290000Sglebius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31290000Sglebius * SUCH DAMAGE.
32290000Sglebius *
33290000Sglebius * @(#) $Header: pcap-int.h,v 1.18 96/11/27 18:43:09 leres Exp $ (LBL)
34290000Sglebius */
35290000Sglebius
36290000Sglebius#ifndef pcap_int_h
37181834Sroberto#define pcap_int_h
38290000Sglebius
39181834Sroberto#include <pcap.h>
40181834Sroberto
41181834Sroberto/*
42181834Sroberto * Savefile
43181834Sroberto */
44181834Srobertostruct pcap_sf {
45290000Sglebius	FILE *rfile;
46181834Sroberto	int swapped;
47181834Sroberto	int version_major;
48181834Sroberto	int version_minor;
49290000Sglebius	u_char *base;
50181834Sroberto};
51181834Sroberto
52181834Srobertostruct pcap_md {
53181834Sroberto	struct pcap_stat stat;
54181834Sroberto	/*XXX*/
55181834Sroberto	int use_bpf;
56290000Sglebius	u_long	TotPkts;	/* can't oflow for 79 hrs on ether */
57181834Sroberto	u_long	TotAccepted;	/* count accepted by filter */
58181834Sroberto	u_long	TotDrops;	/* count of dropped packets */
59181834Sroberto	long	TotMissed;	/* missed by i/f during this run */
60181834Sroberto	long	OrigMissed;	/* missed by i/f before this run */
61181834Sroberto#ifdef linux
62181834Sroberto	int pad;
63290000Sglebius	int skip;
64290000Sglebius	char *device;
65181834Sroberto#endif
66181834Sroberto};
67290000Sglebius
68290000Sglebiusstruct pcap {
69290000Sglebius	int fd;
70290000Sglebius	int snapshot;
71290000Sglebius	int linktype;
72290000Sglebius	int tzoff;		/* timezone offset */
73290000Sglebius	int offset;		/* offset for proper alignment */
74290000Sglebius
75290000Sglebius	struct pcap_sf sf;
76290000Sglebius	struct pcap_md md;
77290000Sglebius
78290000Sglebius	/*
79290000Sglebius	 * Read buffer.
80290000Sglebius	 */
81290000Sglebius	int bufsize;
82290000Sglebius	u_char *buffer;
83290000Sglebius	u_char *bp;
84290000Sglebius	int cc;
85290000Sglebius
86290000Sglebius	/*
87290000Sglebius	 * Place holder for pcap_next().
88290000Sglebius	 */
89290000Sglebius	u_char *pkt;
90290000Sglebius
91290000Sglebius
92290000Sglebius	/*
93181834Sroberto	 * Placeholder for filter code if bpf not in kernel.
94290000Sglebius	 */
95290000Sglebius	struct bpf_program fcode;
96290000Sglebius
97310419Sdelphij	char errbuf[PCAP_ERRBUF_SIZE];
98290000Sglebius};
99310419Sdelphij
100181834Srobertoint	yylex(void);
101290000Sglebius
102181834Sroberto#ifndef min
103181834Sroberto#define min(a, b) ((a) > (b) ? (b) : (a))
104290000Sglebius#endif
105181834Sroberto
106181834Sroberto/* XXX should these be in pcap.h? */
107290000Sglebiusint	pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
108181834Srobertoint	pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
109290000Sglebius
110181834Sroberto/* Ultrix pads to make everything line up on a nice boundary */
111290000Sglebius#if defined(ultrix) || defined(__alpha)
112290000Sglebius#define       PCAP_FDDIPAD 3
113290000Sglebius#endif
114290000Sglebius
115181834Sroberto/* XXX */
116290000Sglebiusextern	int pcap_fddipad;
117181834Sroberto#endif
118290000Sglebius