/*
 *----------------------------------------------------------------------------
 * Copyright (c) 2001, 2002, C.S. Peron
 * All rights reserved.
 *----------------------------------------------------------------------------
 *
 *  * Redistribution and use in source and binary forms, with or without 
 *    modification, are permitted provided that the following conditions are met:
 *
 *  * Redistributions of source code must retain the above copyright notice, this 
 *    list of conditions and the following disclaimer.
 *
 *  * 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.
 *
 *  * Neither the name of the ipex developers nor the names of its contributors 
 *    may be used to endorse or promote products derived from this software 
 *    without specific prior written permission. 
 *
 *----------------------------------------------------------------------------
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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.
 *----------------------------------------------------------------------------
 */

#if (!defined(IPEX_H_))
#define IPEX_H_

#if defined(linux) && !_BSD_SOURCE
#define _BSD_SOURCE
#endif
#include <netinet/in.h>
#include <pcap.h>
#include <sys/types.h>
#include <sys/time.h>
#include <time.h>

struct offset {
	u_long		base;		/* offset in buffer where match starts */
	u_long		len;		/* length of match after base */
};

struct dump_info {
	char		*WFileName;
        pcap_t		*pd;
        pcap_dumper_t	*p;
};

struct ehdr {
	char		smac[20];
	char		dmac[20];
};

struct cmdopts {
	int		 cflag;		/* process cflag packets then exit */
	int		 dflag;		/* dump bpf program XXX hide in verbose? */
	char		*eflag;		/* date/time expression compiler */
	char		*fflag;		/* read pcap expression from this file */
	char		*iflag;		/* process packets from this interface */
	int		 nflag;		/* do not lookup DNS entries */
	int		 pflag;		/* do not resolve service names */
	int		 qflag;		/* promiscuous mode */
	char		*rflag;		/* read pcap data in from this file */
	int		 tflag;		/* timeout for TCP state logging in seconds */
	int		 uflag;		/* setuid in case we get owned. */
	char		*wflag;		/* write packets to this file */
	int		 xflag;		/* provide full frame hex dumps */
	char		*Bflag;		/* binary signature */
	int		 Cflag;		/* dump'n'trunc pcap trace file: REQ -w */
	int		 Dflag;		/* unconditional hex dump? XXX revisit */
	char		*Eflag;		/* extended regular expression */
	int		 Hflag;		/* dump headers only XXX revisit */
	int		 Lflag;		/* dump hardware addresses */
	int		 Oflag;		/* run pcap code generation optimizer */
	char		*Pflag;		/* proc kvm code XXX broken */
	int		 Rflag;		/* XXX realtime operation */
	int		 Tflag;		/* tcp session tracking */
	int		 Xflag;		/* dump hex addresses? XXX deprecate me */

	/* XXX save me from becoming a gross hack */
	int		loffset;	/* link offset */
	int		thiszone;	/* timezone offset */
	int		op;
	int		arg;
	char		*pcap_logic;
};

struct cmdopts opts;
struct datespec *dsp;
typedef unsigned int    u_32_t;
#if (!defined(MAXHOSTNAMELEN))
#define MAXHOSTNAMELEN 256
#endif	/* MAXHOSTNAMELEN */

/*
 * default snapshot length. keep the amount of unwanted data down.
 * This still allows for all the neccessary headers.
 */
#define DEFAULT_SNAPLEN 68
#define ETHHDR_SIZE     14
#define PPPHDR_SIZE     4
#define SLIPHDR_SIZE    16
#define RAWHDR_SIZE     0
#define LOOPHDR_SIZE    4
#define FDDIHDR_SIZE    21
#ifndef IP_OFFMASK
#define IP_OFFMASK 0x1fff
#if (defined(HAVE_NET_IF_PFLOG_H)) 
#define PFLOG_HDRLEN        sizeof(struct pfloghdr)
#endif
#endif
#ifndef LOG_SECURITY
#define LOG_SECURITY LOG_AUTHPRIV
#endif
#endif	/* IPEX_H_ */


syntax highlighted by Code2HTML, v. 0.9.1