pcap-int.h revision 26175
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 *
3326175Sfenner * @(#) $Header: pcap-int.h,v 1.18 96/11/27 18:43:09 leres Exp $ (LBL)
3417683Spst */
3517683Spst
3617683Spst#ifndef pcap_int_h
3717683Spst#define pcap_int_h
3817683Spst
3917683Spst#include <pcap.h>
4017683Spst
4117683Spst/*
4217683Spst * Savefile
4317683Spst */
4417683Spststruct pcap_sf {
4517683Spst	FILE *rfile;
4617683Spst	int swapped;
4717683Spst	int version_major;
4817683Spst	int version_minor;
4917683Spst	u_char *base;
5017683Spst};
5117683Spst
5217683Spststruct pcap_md {
5317683Spst	struct pcap_stat stat;
5417683Spst	/*XXX*/
5517683Spst	int use_bpf;
5617683Spst	u_long	TotPkts;	/* can't oflow for 79 hrs on ether */
5717683Spst	u_long	TotAccepted;	/* count accepted by filter */
5817683Spst	u_long	TotDrops;	/* count of dropped packets */
5917683Spst	long	TotMissed;	/* missed by i/f during this run */
6017683Spst	long	OrigMissed;	/* missed by i/f before this run */
6126175Sfenner#ifdef linux
6226175Sfenner	int pad;
6326175Sfenner	int skip;
6426175Sfenner	char *device;
6526175Sfenner#endif
6617683Spst};
6717683Spst
6817683Spststruct pcap {
6917683Spst	int fd;
7017683Spst	int snapshot;
7117683Spst	int linktype;
7217683Spst	int tzoff;		/* timezone offset */
7317683Spst	int offset;		/* offset for proper alignment */
7417683Spst
7517683Spst	struct pcap_sf sf;
7617683Spst	struct pcap_md md;
7717683Spst
7817683Spst	/*
7917683Spst	 * Read buffer.
8017683Spst	 */
8117683Spst	int bufsize;
8217683Spst	u_char *buffer;
8317683Spst	u_char *bp;
8417683Spst	int cc;
8517683Spst
8617683Spst	/*
8717683Spst	 * Place holder for pcap_next().
8817683Spst	 */
8917683Spst	u_char *pkt;
9017683Spst
9117683Spst
9217683Spst	/*
9317683Spst	 * Placeholder for filter code if bpf not in kernel.
9417683Spst	 */
9517683Spst	struct bpf_program fcode;
9617683Spst
9717683Spst	char errbuf[PCAP_ERRBUF_SIZE];
9817683Spst};
9917683Spst
10017683Spstint	yylex(void);
10117683Spst
10217683Spst#ifndef min
10317683Spst#define min(a, b) ((a) > (b) ? (b) : (a))
10417683Spst#endif
10517683Spst
10617683Spst/* XXX should these be in pcap.h? */
10717683Spstint	pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
10817683Spstint	pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
10917683Spst
11017683Spst/* Ultrix pads to make everything line up on a nice boundary */
11117683Spst#if defined(ultrix) || defined(__alpha)
11217683Spst#define       PCAP_FDDIPAD 3
11317683Spst#endif
11417683Spst
11517683Spst/* XXX */
11617683Spstextern	int pcap_fddipad;
11717683Spst#endif
118