Module Name:    src
Committed By:   christos
Date:           Fri Mar 23 21:29:46 UTC 2012

Added Files:
        src/external/bsd/ipf: Makefile Makefile.inc
        src/external/bsd/ipf/bin: Makefile Makefile.inc
        src/external/bsd/ipf/bin/ipf: Makefile
        src/external/bsd/ipf/bin/ipfs: Makefile
        src/external/bsd/ipf/bin/ipfstat: Makefile
        src/external/bsd/ipf/bin/ipftest: Makefile bpf-ipf.h bpf_filter.c
        src/external/bsd/ipf/bin/ipmon: Makefile
        src/external/bsd/ipf/bin/ipnat: Makefile
        src/external/bsd/ipf/bin/ippool: Makefile
        src/external/bsd/ipf/bin/ipresend: Makefile
        src/external/bsd/ipf/bin/ipsend: Makefile
        src/external/bsd/ipf/bin/iptest: Makefile
        src/external/bsd/ipf/lib: Makefile
        src/external/bsd/ipf/rules: Makefile

Log Message:
Build gluons


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/Makefile \
    src/external/bsd/ipf/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/Makefile \
    src/external/bsd/ipf/bin/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipf/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipfs/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipfstat/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipftest/Makefile \
    src/external/bsd/ipf/bin/ipftest/bpf-ipf.h \
    src/external/bsd/ipf/bin/ipftest/bpf_filter.c
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipmon/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipnat/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ippool/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipresend/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/ipsend/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/bin/iptest/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/lib/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/ipf/rules/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/external/bsd/ipf/Makefile
diff -u /dev/null src/external/bsd/ipf/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/Makefile	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,5 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:44 christos Exp $
+
+SUBDIR+=	lib .WAIT bin rules
+
+.include <bsd.subdir.mk>
Index: src/external/bsd/ipf/Makefile.inc
diff -u /dev/null src/external/bsd/ipf/Makefile.inc:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/Makefile.inc	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,36 @@
+#	$NetBSD: Makefile.inc,v 1.1 2012/03/23 21:29:44 christos Exp $
+
+WARNS?=	1	# XXX -Wcast-qual -Wshadow
+CWARNFLAGS.clang+=	-Wno-format -Wno-tautological-compare \
+			-Wno-self-assign -Wno-array-bounds
+
+.include <bsd.own.mk>
+
+USE_FORT?= yes	# network client/server
+
+UDIST=${NETBSDSRCDIR}/external/bsd/ipf/dist
+SDIST=${NETBSDSRCDIR}/sys/external/bsd/ipf
+
+CPPFLAGS+=	-I${UDIST}
+CPPFLAGS+=	-I${UDIST}/tools
+CPPFLAGS+=	-I${SDIST}
+CPPFLAGS+=	-I${SDIST}/netinet
+CPPFLAGS+=	-DSTATETOP -D__UIO_EXPOSE
+CPPFLAGS+=	-DINET
+
+.if (${USE_INET6} == "no")
+CPPFLAGS+=	-DNOINET6
+.else
+CPPFLAGS+=	-DINET6
+.endif
+
+IPFOBJDIR!=	cd ${UDIST}/../lib && ${PRINTOBJDIR}
+DPADD+=		${IPFOBJDIR}/libipf.a ${LIBKVM}
+LDADD+=		-L${IPFOBJDIR} -lipf -lkvm
+
+CLEANFILES+=	y.tab.c y.tab.h
+
+.PATH:	${UDIST}	\
+	${UDIST}/lib	\
+	${UDIST}/tools	\
+	${UDIST}/man

Index: src/external/bsd/ipf/bin/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/Makefile	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,6 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:44 christos Exp $
+
+SUBDIR+=	ipf ipfs ipfstat ipftest ipmon ipnat ippool ipresend
+SUBDIR+=	ipsend iptest
+
+.include <bsd.subdir.mk>
Index: src/external/bsd/ipf/bin/Makefile.inc
diff -u /dev/null src/external/bsd/ipf/bin/Makefile.inc:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/Makefile.inc	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,2 @@
+# $NetBSD: Makefile.inc,v 1.1 2012/03/23 21:29:44 christos Exp $
+.include "../Makefile.inc"

Index: src/external/bsd/ipf/bin/ipf/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipf/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipf/Makefile	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,44 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:44 christos Exp $
+
+.include <bsd.own.mk>		# for MKDYNAMICROOT definition
+
+PROG=		ipf
+SRCS=		ipf.c ipfcomp.c ipf_y.c ipf_l.c
+MAN=		ipf.8 ipf.4 ipf.5 ipl.4
+MLINKS=		ipl.4 ipfilter.4 ipf.5 ipf.conf.5 ipf.5 ipf6.conf.5
+CPPFLAGS+=	-I.
+
+DPSRCS+=	ipf_l.h ipf_y.h
+
+CLEANFILES+=	ipf_y.c ipf_y.h
+CLEANFILES+=	ipf_l.c ipf_l.h
+
+ipf_y.c: ipf_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    -e 's/"ipf_y.y"/"..\/tools\/ipf_y.y"/' \
+	    y.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    y.tab.h > ${.TARGET:.c=.h}
+
+ipf_y.h: ipf_y.c
+
+ipf_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    -e 's/y.tab.h/ipf_y.h/' \
+	    -e 's/lexer.h/ipf_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipf_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+BINDIR=		/sbin
+.if (${MKDYNAMICROOT} == "no")
+LDSTATIC?=	-static
+.endif
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipfs/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipfs/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipfs/Makefile	Fri Mar 23 17:29:44 2012
@@ -0,0 +1,6 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:44 christos Exp $
+
+PROG=	ipfs
+MAN=	ipfs.8
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipfstat/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipfstat/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipfstat/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,9 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+PROG=		ipfstat
+SRCS=		ipfstat.c
+MAN=		ipfstat.8
+DPADD+=  	${LIBCURSES} ${LIBTERMINFO}
+LDADD+=  	-lcurses -lterminfo
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipftest/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipftest/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipftest/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,105 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+.include <bsd.own.mk>
+
+PROG=		ipftest
+SRCS=		ipftest.c fil.c ip_frag.c ip_state.c ip_nat.c ip_nat6.c \
+		ip_proxy.c ip_auth.c ip_htable.c ip_lookup.c \
+		ip_dstlist.c ip_pool.c ip_sync.c \
+		ip_fil.c ip_log.c ippool_y.c ippool_l.c ipf_y.c \
+		ipf_l.c ipnat_y.c ipnat_l.c md5.c radix_ipf.c bpf_filter.c
+MAN=		ipftest.1
+
+CPPFLAGS+=	-DIPFILTER_LOG -DIPFILTER_LOOKUP \
+		-DIPFILTER_SYNC -DIPFILTER_CKSUM \
+		-I.
+
+COPTS.radix.c=	-Wno-error
+COPTS+=		-fno-strict-aliasing
+
+.PATH:		${NETBSDSRCDIR}/sys/dist/ipf/netinet
+
+DPSRCS+=	ipnat_l.h ipnat_y.h ippool_l.h ippool_y.h ipf_l.h ipf_y.h
+
+CLEANFILES+=	ipf_y.c ipf_y.h
+CLEANFILES+=	ipf_l.c ipf_l.h
+CLEANFILES+=	ipf.tab.c ipf.tab.h
+CLEANFILES+=	ipnat_y.c ipnat_y.h
+CLEANFILES+=	ipnat_l.c ipnat_l.h
+CLEANFILES+=	ipnat.tab.c ipnat.tab.h
+CLEANFILES+=	ippool_y.c ippool_y.h
+CLEANFILES+=	ippool_l.c ippool_l.h
+CLEANFILES+=	ippool.tab.c ippool.tab.h
+
+ipnat_y.c: ipnat_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -b ipnat -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.c/ipnat_y.c/' \
+	    -e s/\"ipnat_y.y\"/\"..\\/tools\\/ipnat_y.y\"/ \
+	    ipnat.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.h/ipnat_y.h/' \
+	    ipnat.tab.h > ${.TARGET:.c=.h}
+
+ipnat_y.h: ipnat_y.c
+
+ipnat_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.h/ipnat_y.h/' \
+	    -e 's/lexer.h/ipnat_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipnat_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ippool_y.c: ippool_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -b ippool -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    -e 's/"ippool_y.y"/"..\/tools\/ippool_y.y"/' \
+	    ippool.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    ippool.tab.h > ${.TARGET:.c=.h}
+
+ippool_y.h: ippool_y.c
+
+ippool_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    -e 's/y.tab.h/ippool_y.h/' \
+	    -e 's/lexer.h/ippool_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ippool_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipf_y.c: ipf_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -b ipf -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    -e 's/"ipf_y.y"/"..\/tools\/ipf_y.y"/' \
+		ipf.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+		ipf.tab.h > ${.TARGET:.c=.h}
+
+ipf_y.h: ipf_y.c
+
+ipf_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	     -e 's/y.tab.h/ipf_y.h/' \
+	     -e 's/lexer.h/ipf_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipf_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipf_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+.include <bsd.prog.mk>
Index: src/external/bsd/ipf/bin/ipftest/bpf-ipf.h
diff -u /dev/null src/external/bsd/ipf/bin/ipftest/bpf-ipf.h:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipftest/bpf-ipf.h	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,452 @@
+/*	$NetBSD: bpf-ipf.h,v 1.1 2012/03/23 21:29:45 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * 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 University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 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.
+ *
+ *      @(#)bpf.h       7.1 (Berkeley) 5/7/91
+ *
+ * @(#) Header: /devel/CVS/IP-Filter/bpf-ipf.h,v 2.2 2007/10/25 17:03:18 darrenr Exp (LBL)
+ */
+
+#ifndef BPF_MAJOR_VERSION
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* BSD style release date */
+#define BPF_RELEASE 199606
+
+typedef	int bpf_int32;
+typedef	u_int bpf_u_int32;
+
+/*
+ * Alignment macros.  BPF_WORDALIGN rounds up to the next
+ * even multiple of BPF_ALIGNMENT.
+ */
+#ifndef __NetBSD__
+#define BPF_ALIGNMENT sizeof(bpf_int32)
+#else
+#define BPF_ALIGNMENT sizeof(long)
+#endif
+#define BPF_WORDALIGN(x) (((x)+(BPF_ALIGNMENT-1))&~(BPF_ALIGNMENT-1))
+
+#define BPF_MAXINSNS 512
+#define BPF_MAXBUFSIZE 0x8000
+#define BPF_MINBUFSIZE 32
+
+/*
+ *  Structure for BIOCSETF.
+ */
+struct bpf_program {
+	u_int bf_len;
+	struct bpf_insn *bf_insns;
+};
+
+/*
+ * Struct returned by BIOCGSTATS.
+ */
+struct bpf_stat {
+	u_int bs_recv;		/* number of packets received */
+	u_int bs_drop;		/* number of packets dropped */
+};
+
+/*
+ * Struct return by BIOCVERSION.  This represents the version number of
+ * the filter language described by the instruction encodings below.
+ * bpf understands a program iff kernel_major == filter_major &&
+ * kernel_minor >= filter_minor, that is, if the value returned by the
+ * running kernel has the same major number and a minor number equal
+ * equal to or less than the filter being downloaded.  Otherwise, the
+ * results are undefined, meaning an error may be returned or packets
+ * may be accepted haphazardly.
+ * It has nothing to do with the source code version.
+ */
+struct bpf_version {
+	u_short bv_major;
+	u_short bv_minor;
+};
+/* Current version number of filter architecture. */
+#define BPF_MAJOR_VERSION 1
+#define BPF_MINOR_VERSION 1
+
+/*
+ * BPF ioctls
+ *
+ * The first set is for compatibility with Sun's pcc style
+ * header files.  If your using gcc, we assume that you
+ * have run fixincludes so the latter set should work.
+ */
+#if (defined(sun) || defined(ibm032)) && !defined(__GNUC__)
+#define	BIOCGBLEN	_IOR(B,102, u_int)
+#define	BIOCSBLEN	_IOWR(B,102, u_int)
+#define	BIOCSETF	_IOW(B,103, struct bpf_program)
+#define	BIOCFLUSH	_IO(B,104)
+#define BIOCPROMISC	_IO(B,105)
+#define	BIOCGDLT	_IOR(B,106, u_int)
+#define BIOCGETIF	_IOR(B,107, struct ifreq)
+#define BIOCSETIF	_IOW(B,108, struct ifreq)
+#define BIOCSRTIMEOUT	_IOW(B,109, struct timeval)
+#define BIOCGRTIMEOUT	_IOR(B,110, struct timeval)
+#define BIOCGSTATS	_IOR(B,111, struct bpf_stat)
+#define BIOCIMMEDIATE	_IOW(B,112, u_int)
+#define BIOCVERSION	_IOR(B,113, struct bpf_version)
+#define BIOCSTCPF	_IOW(B,114, struct bpf_program)
+#define BIOCSUDPF	_IOW(B,115, struct bpf_program)
+#else
+#define	BIOCGBLEN	_IOR('B',102, u_int)
+#define	BIOCSBLEN	_IOWR('B',102, u_int)
+#define	BIOCSETF	_IOW('B',103, struct bpf_program)
+#define	BIOCFLUSH	_IO('B',104)
+#define BIOCPROMISC	_IO('B',105)
+#define	BIOCGDLT	_IOR('B',106, u_int)
+#define BIOCGETIF	_IOR('B',107, struct ifreq)
+#define BIOCSETIF	_IOW('B',108, struct ifreq)
+#define BIOCSRTIMEOUT	_IOW('B',109, struct timeval)
+#define BIOCGRTIMEOUT	_IOR('B',110, struct timeval)
+#define BIOCGSTATS	_IOR('B',111, struct bpf_stat)
+#define BIOCIMMEDIATE	_IOW('B',112, u_int)
+#define BIOCVERSION	_IOR('B',113, struct bpf_version)
+#define BIOCSTCPF	_IOW('B',114, struct bpf_program)
+#define BIOCSUDPF	_IOW('B',115, struct bpf_program)
+#endif
+
+/*
+ * Structure prepended to each packet.
+ */
+struct bpf_hdr {
+	struct timeval	bh_tstamp;	/* time stamp */
+	bpf_u_int32	bh_caplen;	/* length of captured portion */
+	bpf_u_int32	bh_datalen;	/* original length of packet */
+	u_short		bh_hdrlen;	/* length of bpf header (this struct
+					   plus alignment padding) */
+};
+/*
+ * Because the structure above is not a multiple of 4 bytes, some compilers
+ * will insist on inserting padding; hence, sizeof(struct bpf_hdr) won't work.
+ * Only the kernel needs to know about it; applications use bh_hdrlen.
+ */
+#if defined(KERNEL) || defined(_KERNEL)
+#define SIZEOF_BPF_HDR 18
+#endif
+
+/*
+ * Data-link level type codes.
+ */
+
+/*
+ * These are the types that are the same on all platforms; on other
+ * platforms, a <net/bpf.h> should be supplied that defines the additional
+ * DLT_* codes appropriately for that platform (the BSDs, for example,
+ * should not just pick up this version of "bpf.h"; they should also define
+ * the additional DLT_* codes used by their kernels, as well as the values
+ * defined here - and, if the values they use for particular DLT_ types
+ * differ from those here, they should use their values, not the ones
+ * here).
+ */
+#define DLT_NULL	0	/* no link-layer encapsulation */
+#define DLT_EN10MB	1	/* Ethernet (10Mb) */
+#define DLT_EN3MB	2	/* Experimental Ethernet (3Mb) */
+#define DLT_AX25	3	/* Amateur Radio AX.25 */
+#define DLT_PRONET	4	/* Proteon ProNET Token Ring */
+#define DLT_CHAOS	5	/* Chaos */
+#define DLT_IEEE802	6	/* IEEE 802 Networks */
+#define DLT_ARCNET	7	/* ARCNET */
+#define DLT_SLIP	8	/* Serial Line IP */
+#define DLT_PPP		9	/* Point-to-point Protocol */
+#define DLT_FDDI	10	/* FDDI */
+
+/*
+ * These are values from the traditional libpcap "bpf.h".
+ * Ports of this to particular platforms should replace these definitions
+ * with the ones appropriate to that platform, if the values are
+ * different on that platform.
+ */
+#define DLT_ATM_RFC1483	11	/* LLC/SNAP encapsulated atm */
+#define DLT_RAW		12	/* raw IP */
+
+/*
+ * These are values from BSD/OS's "bpf.h".
+ * These are not the same as the values from the traditional libpcap
+ * "bpf.h"; however, these values shouldn't be generated by any
+ * OS other than BSD/OS, so the correct values to use here are the
+ * BSD/OS values.
+ *
+ * Platforms that have already assigned these values to other
+ * DLT_ codes, however, should give these codes the values
+ * from that platform, so that programs that use these codes will
+ * continue to compile - even though they won't correctly read
+ * files of these types.
+ */
+#ifdef __NetBSD__
+#ifndef DLT_SLIP_BSDOS
+#define DLT_SLIP_BSDOS	13	/* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS	14	/* BSD/OS Point-to-point Protocol */
+#endif
+#else
+#define DLT_SLIP_BSDOS	15	/* BSD/OS Serial Line IP */
+#define DLT_PPP_BSDOS	16	/* BSD/OS Point-to-point Protocol */
+#endif
+
+#define DLT_ATM_CLIP	19	/* Linux Classical-IP over ATM */
+
+/*
+ * These values are defined by NetBSD; other platforms should refrain from
+ * using them for other purposes, so that NetBSD savefiles with link
+ * types of 50 or 51 can be read as this type on all platforms.
+ */
+#define DLT_PPP_SERIAL	50	/* PPP over serial with HDLC encapsulation */
+#define DLT_PPP_ETHER	51	/* PPP over Ethernet */
+
+/*
+ * Values between 100 and 103 are used in capture file headers as
+ * link-layer types corresponding to DLT_ types that differ
+ * between platforms; don't use those values for new DLT_ new types.
+ */
+
+/*
+ * This value was defined by libpcap 0.5; platforms that have defined
+ * it with a different value should define it here with that value -
+ * a link type of 104 in a save file will be mapped to DLT_C_HDLC,
+ * whatever value that happens to be, so programs will correctly
+ * handle files with that link type regardless of the value of
+ * DLT_C_HDLC.
+ *
+ * The name DLT_C_HDLC was used by BSD/OS; we use that name for source
+ * compatibility with programs written for BSD/OS.
+ *
+ * libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
+ * for source compatibility with programs written for libpcap 0.5.
+ */
+#define DLT_C_HDLC	104	/* Cisco HDLC */
+#define DLT_CHDLC	DLT_C_HDLC
+
+#define DLT_IEEE802_11	105	/* IEEE 802.11 wireless */
+
+/*
+ * Values between 106 and 107 are used in capture file headers as
+ * link-layer types corresponding to DLT_ types that might differ
+ * between platforms; don't use those values for new DLT_ new types.
+ */
+
+/*
+ * OpenBSD DLT_LOOP, for loopback devices; it's like DLT_NULL, except
+ * that the AF_ type in the link-layer header is in network byte order.
+ *
+ * OpenBSD defines it as 12, but that collides with DLT_RAW, so we
+ * define it as 108 here.  If OpenBSD picks up this file, it should
+ * define DLT_LOOP as 12 in its version, as per the comment above -
+ * and should not use 108 as a DLT_ value.
+ */
+#define DLT_LOOP	108
+
+/*
+ * Values between 109 and 112 are used in capture file headers as
+ * link-layer types corresponding to DLT_ types that might differ
+ * between platforms; don't use those values for new DLT_ types
+ * other than the corresponding DLT_ types.
+ */
+
+/*
+ * This is for Linux cooked sockets.
+ */
+#define DLT_LINUX_SLL	113
+
+/*
+ * Apple LocalTalk hardware.
+ */
+#define DLT_LTALK	114
+
+/*
+ * Acorn Econet.
+ */
+#define DLT_ECONET	115
+
+/*
+ * Reserved for use with OpenBSD ipfilter.
+ */
+#define DLT_IPFILTER	116
+
+/*
+ * Reserved for use in capture-file headers as a link-layer type
+ * corresponding to OpenBSD DLT_PFLOG; DLT_PFLOG is 17 in OpenBSD,
+ * but that's DLT_LANE8023 in SuSE 6.3, so we can't use 17 for it
+ * in capture-file headers.
+ */
+#define DLT_PFLOG	117
+
+/*
+ * Registered for Cisco-internal use.
+ */
+#define DLT_CISCO_IOS	118
+
+/*
+ * Reserved for 802.11 cards using the Prism II chips, with a link-layer
+ * header including Prism monitor mode information plus an 802.11
+ * header.
+ */
+#define DLT_PRISM_HEADER	119
+
+/*
+ * Reserved for Aironet 802.11 cards, with an Aironet link-layer header
+ * (see Doug Ambrisko's FreeBSD patches).
+ */
+#define DLT_AIRONET_HEADER	120
+
+/*
+ * Reserved for Siemens HiPath HDLC.
+ */
+#define DLT_HHDLC		121
+
+/*
+ * Reserved for RFC 2625 IP-over-Fibre Channel, as per a request from
+ * Don Lee <[email protected]>.
+ *
+ * This is not for use with raw Fibre Channel, where the link-layer
+ * header starts with a Fibre Channel frame header; it's for IP-over-FC,
+ * where the link-layer header starts with an RFC 2625 Network_Header
+ * field.
+ */
+#define DLT_IP_OVER_FC		122
+
+/*
+ * The instruction encodings.
+ */
+/* instruction classes */
+#define BPF_CLASS(code) ((code) & 0x07)
+#define		BPF_LD		0x00
+#define		BPF_LDX		0x01
+#define		BPF_ST		0x02
+#define		BPF_STX		0x03
+#define		BPF_ALU		0x04
+#define		BPF_JMP		0x05
+#define		BPF_RET		0x06
+#define		BPF_MISC	0x07
+
+/* ld/ldx fields */
+#define BPF_SIZE(code)	((code) & 0x18)
+#define		BPF_W		0x00
+#define		BPF_H		0x08
+#define		BPF_B		0x10
+#define BPF_MODE(code)	((code) & 0xe0)
+#define		BPF_IMM 	0x00
+#define		BPF_ABS		0x20
+#define		BPF_IND		0x40
+#define		BPF_MEM		0x60
+#define		BPF_LEN		0x80
+#define		BPF_MSH		0xa0
+
+/* alu/jmp fields */
+#define BPF_OP(code)	((code) & 0xf0)
+#define		BPF_ADD		0x00
+#define		BPF_SUB		0x10
+#define		BPF_MUL		0x20
+#define		BPF_DIV		0x30
+#define		BPF_OR		0x40
+#define		BPF_AND		0x50
+#define		BPF_LSH		0x60
+#define		BPF_RSH		0x70
+#define		BPF_NEG		0x80
+#define		BPF_JA		0x00
+#define		BPF_JEQ		0x10
+#define		BPF_JGT		0x20
+#define		BPF_JGE		0x30
+#define		BPF_JSET	0x40
+#define BPF_SRC(code)	((code) & 0x08)
+#define		BPF_K		0x00
+#define		BPF_X		0x08
+
+/* ret - BPF_K and BPF_X also apply */
+#define BPF_RVAL(code)	((code) & 0x18)
+#define		BPF_A		0x10
+
+/* misc */
+#define BPF_MISCOP(code) ((code) & 0xf8)
+#define		BPF_TAX		0x00
+#define		BPF_TXA		0x80
+
+/*
+ * The instruction data structure.
+ */
+struct bpf_insn {
+	u_short	code;
+	u_char 	jt;
+	u_char 	jf;
+	bpf_int32 k;
+};
+
+/*
+ * Macros for insn array initializers.
+ */
+#define BPF_STMT(code, k) { (u_short)(code), 0, 0, k }
+#define BPF_JUMP(code, k, jt, jf) { (u_short)(code), jt, jf, k }
+
+#if defined(BSD) && (defined(KERNEL) || defined(_KERNEL))
+/*
+ * Systems based on non-BSD kernels don't have ifnet's (or they don't mean
+ * anything if it is in <net/if.h>) and won't work like this.
+ */
+# if __STDC__
+extern void bpf_tap(struct ifnet *, u_char *, u_int);
+extern void bpf_mtap(struct ifnet *, struct mbuf *);
+extern void bpfattach(struct ifnet *, u_int, u_int);
+extern void bpfilterattach(int);
+# else
+extern void bpf_tap();
+extern void bpf_mtap();
+extern void bpfattach();
+extern void bpfilterattach();
+# endif /* __STDC__ */
+#endif /* BSD && (_KERNEL || KERNEL) */
+#if __STDC__ || defined(__cplusplus)
+extern int bpf_validate(struct bpf_insn *, int);
+extern u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
+#else
+extern int bpf_validate();
+extern u_int bpf_filter();
+#endif
+
+/*
+ * Number of scratch memory words (for BPF_LD|BPF_MEM and BPF_ST).
+ */
+#define BPF_MEMWORDS 16
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: src/external/bsd/ipf/bin/ipftest/bpf_filter.c
diff -u /dev/null src/external/bsd/ipf/bin/ipftest/bpf_filter.c:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipftest/bpf_filter.c	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,595 @@
+/*	$NetBSD: bpf_filter.c,v 1.1 2012/03/23 21:29:45 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
+ *	The Regents of the University of California.  All rights reserved.
+ *
+ * This code is derived from the Stanford/CMU enet packet filter,
+ * (net/enet.c) distributed as part of 4.3BSD, and code contributed
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
+ * Berkeley Laboratory.
+ *
+ * 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 University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 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.
+ *
+ *	@(#)bpf.c	7.5 (Berkeley) 7/15/91
+ */
+
+#if !(defined(lint) || defined(KERNEL) || defined(_KERNEL))
+static const char rcsid[] =
+    "@(#) Header: /devel/CVS/IP-Filter/bpf_filter.c,v 2.2.2.3 2006/10/03 11:25:56 darrenr Exp (LBL)";
+#endif
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <net/if.h>
+
+#include "netinet/ip_compat.h"
+#include "bpf-ipf.h"
+
+
+#if (defined(__hpux) || SOLARIS) && (defined(_KERNEL) || defined(KERNEL))
+# include <sys/sysmacros.h>
+# include <sys/stream.h>
+#endif
+
+#include "pcap-ipf.h"
+
+#if !defined(KERNEL) && !defined(_KERNEL)
+#include <stdlib.h>
+#endif
+
+#define int32 bpf_int32
+#define u_int32 bpf_u_int32
+
+static int m_xword __P((mb_t *, int, int *));
+static int m_xhalf __P((mb_t *, int, int *));
+
+#ifndef LBL_ALIGN
+/*
+ * XXX - IA-64?  If not, this probably won't work on Win64 IA-64
+ * systems, unless LBL_ALIGN is defined elsewhere for them.
+ * XXX - SuperH?  If not, this probably won't work on WinCE SuperH
+ * systems, unless LBL_ALIGN is defined elsewhere for them.
+ */
+#if defined(sparc) || defined(__sparc__) || defined(mips) || \
+    defined(ibm032) || defined(__alpha) || defined(__hpux) || \
+    defined(__arm__)
+#define LBL_ALIGN
+#endif
+#endif
+
+#ifndef LBL_ALIGN
+
+#define EXTRACT_SHORT(p)	((u_short)ntohs(*(u_short *)p))
+#define EXTRACT_LONG(p)		(ntohl(*(u_int32 *)p))
+#else
+#define EXTRACT_SHORT(p)\
+	((u_short)\
+		((u_short)*((u_char *)p+0)<<8|\
+		 (u_short)*((u_char *)p+1)<<0))
+#define EXTRACT_LONG(p)\
+		((u_int32)*((u_char *)p+0)<<24|\
+		 (u_int32)*((u_char *)p+1)<<16|\
+		 (u_int32)*((u_char *)p+2)<<8|\
+		 (u_int32)*((u_char *)p+3)<<0)
+#endif
+
+#define MINDEX(len, _m, _k) \
+{ \
+	len = M_LEN(m); \
+	while ((_k) >= len) { \
+		(_k) -= len; \
+		(_m) = (_m)->m_next; \
+		if ((_m) == 0) \
+			return 0; \
+		len = M_LEN(m); \
+	} \
+}
+
+static int
+m_xword(m, k, err)
+	register mb_t *m;
+	register int k, *err;
+{
+	register int len;
+	register u_char *cp, *np;
+	register mb_t *m0;
+
+	MINDEX(len, m, k);
+	cp = MTOD(m, u_char *) + k;
+	if (len - k >= 4) {
+		*err = 0;
+		return EXTRACT_LONG(cp);
+	}
+	m0 = m->m_next;
+	if (m0 == 0 || M_LEN(m0) + len - k < 4)
+		goto bad;
+	*err = 0;
+	np = MTOD(m0, u_char *);
+	switch (len - k) {
+
+	case 1:
+		return (cp[0] << 24) | (np[0] << 16) | (np[1] << 8) | np[2];
+
+	case 2:
+		return (cp[0] << 24) | (cp[1] << 16) | (np[0] << 8) | np[1];
+
+	default:
+		return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | np[0];
+	}
+    bad:
+	*err = 1;
+	return 0;
+}
+
+static int
+m_xhalf(m, k, err)
+	register mb_t *m;
+	register int k, *err;
+{
+	register int len;
+	register u_char *cp;
+	register mb_t *m0;
+
+	MINDEX(len, m, k);
+	cp = MTOD(m, u_char *) + k;
+	if (len - k >= 2) {
+		*err = 0;
+		return EXTRACT_SHORT(cp);
+	}
+	m0 = m->m_next;
+	if (m0 == 0)
+		goto bad;
+	*err = 0;
+	return (cp[0] << 8) | MTOD(m0, u_char *)[0];
+ bad:
+	*err = 1;
+	return 0;
+}
+
+/*
+ * Execute the filter program starting at pc on the packet p
+ * wirelen is the length of the original packet
+ * buflen is the amount of data present
+ * For the kernel, p is assumed to be a pointer to an mbuf if buflen is 0,
+ * in all other cases, p is a pointer to a buffer and buflen is its size.
+ */
+u_int
+bpf_filter(pc, p, wirelen, buflen)
+	register struct bpf_insn *pc;
+	register u_char *p;
+	u_int wirelen;
+	register u_int buflen;
+{
+	register u_int32 A, X;
+	register int k;
+	int32 mem[BPF_MEMWORDS];
+	mb_t *m, *n;
+	int merr = 0;	/* XXX: GCC */
+	int len;
+
+	if (buflen == 0) {
+		m = (mb_t *)p;
+		p = MTOD(m, u_char *);
+		buflen = M_LEN(m);
+	} else
+		m = NULL;
+
+	if (pc == 0)
+		/*
+		 * No filter means accept all.
+		 */
+		return (u_int)-1;
+	A = 0;
+	X = 0;
+	--pc;
+	while (1) {
+		++pc;
+		switch (pc->code) {
+
+		default:
+			return 0;
+		case BPF_RET|BPF_K:
+			return (u_int)pc->k;
+
+		case BPF_RET|BPF_A:
+			return (u_int)A;
+
+		case BPF_LD|BPF_W|BPF_ABS:
+			k = pc->k;
+			if (k + sizeof(int32) > buflen) {
+				if (m == NULL)
+					return 0;
+				A = m_xword(m, k, &merr);
+				if (merr != 0)
+					return 0;
+				continue;
+			}
+			A = EXTRACT_LONG(&p[k]);
+			continue;
+
+		case BPF_LD|BPF_H|BPF_ABS:
+			k = pc->k;
+			if (k + sizeof(short) > buflen) {
+				if (m == NULL)
+					return 0;
+				A = m_xhalf(m, k, &merr);
+				if (merr != 0)
+					return 0;
+				continue;
+			}
+			A = EXTRACT_SHORT(&p[k]);
+			continue;
+
+		case BPF_LD|BPF_B|BPF_ABS:
+			k = pc->k;
+			if (k >= buflen) {
+				if (m == NULL)
+					return 0;
+				n = m;
+				MINDEX(len, n, k);
+				A = MTOD(n, u_char *)[k];
+				continue;
+			}
+			A = p[k];
+			continue;
+
+		case BPF_LD|BPF_W|BPF_LEN:
+			A = wirelen;
+			continue;
+
+		case BPF_LDX|BPF_W|BPF_LEN:
+			X = wirelen;
+			continue;
+
+		case BPF_LD|BPF_W|BPF_IND:
+			k = X + pc->k;
+			if (k + sizeof(int32) > buflen) {
+				if (m == NULL)
+					return 0;
+				A = m_xword(m, k, &merr);
+				if (merr != 0)
+					return 0;
+				continue;
+			}
+			A = EXTRACT_LONG(&p[k]);
+			continue;
+
+		case BPF_LD|BPF_H|BPF_IND:
+			k = X + pc->k;
+			if (k + sizeof(short) > buflen) {
+				if (m == NULL)
+					return 0;
+				A = m_xhalf(m, k, &merr);
+				if (merr != 0)
+					return 0;
+				continue;
+			}
+			A = EXTRACT_SHORT(&p[k]);
+			continue;
+
+		case BPF_LD|BPF_B|BPF_IND:
+			k = X + pc->k;
+			if (k >= buflen) {
+				if (m == NULL)
+					return 0;
+				n = m;
+				MINDEX(len, n, k);
+				A = MTOD(n, u_char *)[k];
+				continue;
+			}
+			A = p[k];
+			continue;
+
+		case BPF_LDX|BPF_MSH|BPF_B:
+			k = pc->k;
+			if (k >= buflen) {
+				if (m == NULL)
+					return 0;
+				n = m;
+				MINDEX(len, n, k);
+				X = (MTOD(n, char *)[k] & 0xf) << 2;
+				continue;
+			}
+			X = (p[pc->k] & 0xf) << 2;
+			continue;
+
+		case BPF_LD|BPF_IMM:
+			A = pc->k;
+			continue;
+
+		case BPF_LDX|BPF_IMM:
+			X = pc->k;
+			continue;
+
+		case BPF_LD|BPF_MEM:
+			A = mem[pc->k];
+			continue;
+
+		case BPF_LDX|BPF_MEM:
+			X = mem[pc->k];
+			continue;
+
+		case BPF_ST:
+			mem[pc->k] = A;
+			continue;
+
+		case BPF_STX:
+			mem[pc->k] = X;
+			continue;
+
+		case BPF_JMP|BPF_JA:
+			pc += pc->k;
+			continue;
+
+		case BPF_JMP|BPF_JGT|BPF_K:
+			pc += (A > pc->k) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JGE|BPF_K:
+			pc += (A >= pc->k) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JEQ|BPF_K:
+			pc += (A == pc->k) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JSET|BPF_K:
+			pc += (A & pc->k) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JGT|BPF_X:
+			pc += (A > X) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JGE|BPF_X:
+			pc += (A >= X) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JEQ|BPF_X:
+			pc += (A == X) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_JMP|BPF_JSET|BPF_X:
+			pc += (A & X) ? pc->jt : pc->jf;
+			continue;
+
+		case BPF_ALU|BPF_ADD|BPF_X:
+			A += X;
+			continue;
+
+		case BPF_ALU|BPF_SUB|BPF_X:
+			A -= X;
+			continue;
+
+		case BPF_ALU|BPF_MUL|BPF_X:
+			A *= X;
+			continue;
+
+		case BPF_ALU|BPF_DIV|BPF_X:
+			if (X == 0)
+				return 0;
+			A /= X;
+			continue;
+
+		case BPF_ALU|BPF_AND|BPF_X:
+			A &= X;
+			continue;
+
+		case BPF_ALU|BPF_OR|BPF_X:
+			A |= X;
+			continue;
+
+		case BPF_ALU|BPF_LSH|BPF_X:
+			A <<= X;
+			continue;
+
+		case BPF_ALU|BPF_RSH|BPF_X:
+			A >>= X;
+			continue;
+
+		case BPF_ALU|BPF_ADD|BPF_K:
+			A += pc->k;
+			continue;
+
+		case BPF_ALU|BPF_SUB|BPF_K:
+			A -= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_MUL|BPF_K:
+			A *= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_DIV|BPF_K:
+			A /= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_AND|BPF_K:
+			A &= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_OR|BPF_K:
+			A |= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_LSH|BPF_K:
+			A <<= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_RSH|BPF_K:
+			A >>= pc->k;
+			continue;
+
+		case BPF_ALU|BPF_NEG:
+			A = -A;
+			continue;
+
+		case BPF_MISC|BPF_TAX:
+			X = A;
+			continue;
+
+		case BPF_MISC|BPF_TXA:
+			A = X;
+			continue;
+		}
+	}
+}
+
+
+/*
+ * Return true if the 'fcode' is a valid filter program.
+ * The constraints are that each jump be forward and to a valid
+ * code, that memory accesses are within valid ranges (to the
+ * extent that this can be checked statically; loads of packet
+ * data have to be, and are, also checked at run time), and that
+ * the code terminates with either an accept or reject.
+ *
+ * The kernel needs to be able to verify an application's filter code.
+ * Otherwise, a bogus program could easily crash the system.
+ */
+int
+bpf_validate(f, len)
+	struct bpf_insn *f;
+	int len;
+{
+	u_int i, from;
+	const struct bpf_insn *p;
+
+	if (len == 0)
+		return 1;
+
+	if (len < 1 || len > BPF_MAXINSNS)
+		return 0;
+
+	for (i = 0; i < len; ++i) {
+		p = &f[i];
+		switch (BPF_CLASS(p->code)) {
+		/*
+		 * Check that memory operations use valid addresses.
+		 */
+		case BPF_LD:
+		case BPF_LDX:
+			switch (BPF_MODE(p->code)) {
+			case BPF_IMM:
+				break;
+			case BPF_ABS:
+			case BPF_IND:
+			case BPF_MSH:
+				/*
+				 * More strict check with actual packet length
+				 * is done runtime.
+				 */
+#if 0
+				if (p->k >= bpf_maxbufsize)
+					return 0;
+#endif
+				break;
+			case BPF_MEM:
+				if (p->k >= BPF_MEMWORDS)
+					return 0;
+				break;
+			case BPF_LEN:
+				break;
+			default:
+				return 0;
+			}
+			break;
+		case BPF_ST:
+		case BPF_STX:
+			if (p->k >= BPF_MEMWORDS)
+				return 0;
+			break;
+		case BPF_ALU:
+			switch (BPF_OP(p->code)) {
+			case BPF_ADD:
+			case BPF_SUB:
+			case BPF_OR:
+			case BPF_AND:
+			case BPF_LSH:
+			case BPF_RSH:
+			case BPF_NEG:
+				break;
+			case BPF_DIV:
+				/*
+				 * Check for constant division by 0.
+				 */
+				if (BPF_RVAL(p->code) == BPF_K && p->k == 0)
+					return 0;
+			default:
+				return 0;
+			}
+			break;
+		case BPF_JMP:
+			/*
+			 * Check that jumps are within the code block,
+			 * and that unconditional branches don't go
+			 * backwards as a result of an overflow.
+			 * Unconditional branches have a 32-bit offset,
+			 * so they could overflow; we check to make
+			 * sure they don't.  Conditional branches have
+			 * an 8-bit offset, and the from address is <=
+			 * BPF_MAXINSNS, and we assume that BPF_MAXINSNS
+			 * is sufficiently small that adding 255 to it
+			 * won't overflow.
+			 *
+			 * We know that len is <= BPF_MAXINSNS, and we
+			 * assume that BPF_MAXINSNS is < the maximum size
+			 * of a u_int, so that i + 1 doesn't overflow.
+			 */
+			from = i + 1;
+			switch (BPF_OP(p->code)) {
+			case BPF_JA:
+				if (from + p->k < from || from + p->k >= len)
+					return 0;
+				break;
+			case BPF_JEQ:
+			case BPF_JGT:
+			case BPF_JGE:
+			case BPF_JSET:
+				if (from + p->jt >= len || from + p->jf >= len)
+					return 0;
+				break;
+			default:
+				return 0;
+			}
+			break;
+		case BPF_RET:
+			break;
+		case BPF_MISC:
+			break;
+		default:
+			return 0;
+		}
+	}
+	return BPF_CLASS(f[len - 1].code) == BPF_RET;
+}

Index: src/external/bsd/ipf/bin/ipmon/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipmon/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipmon/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,37 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+PROG=		ipmon
+SRCS=		ipmon.c ipmon_y.c ipmon_l.c
+MAN=		ipmon.5 ipmon.8
+
+CPPFLAGS+=	-DLOGFAC=LOG_LOCAL0 -I.
+
+DPSRCS+=	ipmon_l.h ipmon_y.h
+
+CLEANFILES+=	ipmon_y.c ipmon_y.h
+CLEANFILES+=	ipmon_l.c ipmon_l.h
+
+ipmon_y.c: ipmon_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ipmon_yy/g' \
+	    -e 's/"ipmon_y.y"/"..\/tools\/ipmon_y.y"/' \
+	    y.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ipmon_yy/g' \
+	    y.tab.h > ${.TARGET:.c=.h}
+
+ipmon_y.h: ipmon_y.c
+
+ipmon_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipmon_yy/g' \
+	    -e 's/y.tab.h/ipmon_y.h/' \
+	    -e 's/lexer.h/ipmon_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipmon_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipmon_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipnat/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipnat/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipnat/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,39 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+PROG=		ipnat
+SRCS=		ipnat.c ipnat_y.c ipnat_l.c
+MAN=		ipnat.8 ipnat.4 ipnat.5
+MLINKS=		ipnat.5 ipnat.conf.5
+CPPFLAGS+=	-I.
+
+DPSRCS+=	ipnat_l.h ipnat_y.h
+
+CLEANFILES+=	ipnat_y.c ipnat_y.h
+CLEANFILES+=	ipnat_l.c ipnat_l.h
+
+ipnat_y.c: ipnat_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.c/ipnat_y.c/' \
+	    -e s/\"ipnat_y.y\"/\"..\\/tools\\/ipnat_y.y\"/ \
+	    y.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.h/ipnat_y.h/' \
+	    y.tab.h > ${.TARGET:.c=.h}
+
+ipnat_y.h: ipnat_y.c
+
+ipnat_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    -e 's/y.tab.h/ipnat_y.h/' \
+	    -e 's/lexer.h/ipnat_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ipnat_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ipnat_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ippool/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ippool/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ippool/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,37 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+PROG=		ippool
+SRCS=		ippool_y.c ippool_l.c kmem.c ippool.c
+MAN=		ippool.5 ippool.8
+MLINKS=		ippool.5 ippool.conf.5
+CPPFLAGS+=	-I.
+
+DPSRCS+=	ippool_l.h ippool_y.h
+
+CLEANFILES+=	ippool_y.c ippool_y.h
+CLEANFILES+=	ippool_l.c ippool_l.h
+
+ippool_y.c: ippool_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -d ${.ALLSRC}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    -e 's/"ippool_y.y"/"..\/tools\/ippool_y.y"/' \
+	    y.tab.c > ${.TARGET}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    y.tab.h > ${.TARGET:.c=.h}
+
+ippool_y.h: ippool_y.c
+
+ippool_l.c: lexer.c
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    -e 's/y.tab.h/ippool_y.h/' \
+	    -e 's/lexer.h/ippool_l.h/' \
+	    ${.ALLSRC} > ${.TARGET}
+
+ippool_l.h: lexer.h
+	${_MKTARGET_CREATE}
+	${TOOL_SED} -e 's/yy/ippool_yy/g' \
+	    ${.ALLSRC} > ${.TARGET}
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipresend/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipresend/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipresend/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,11 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+.include <bsd.own.mk>
+
+PROG=		ipresend
+SRCS=		ipresend.c ip.c resend.c sbpf.c sock.c 44arp.c
+MAN=		ipresend.1
+
+.PATH:		${NETBSDSRCDIR}/dist/ipf/ipsend
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/ipsend/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/ipsend/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/ipsend/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,38 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+.include <bsd.own.mk>
+
+PROG=		ipsend
+SRCS=		ipsend.c ip.c ipsopt.c iplang_y.c iplang_l.l sbpf.c \
+		sock.c 44arp.c
+MAN=		ipsend.1 ipsend.5
+DPADD+=		${LIBL}
+LDADD+=		-ll
+
+CPPFLAGS+=	-I${NETBSDSRCDIR}/dist/ipf/ipsend
+CPPFLAGS+=	-I${NETBSDSRCDIR}/dist/ipf/iplang
+CPPFLAGS+=	-I.
+
+CLEANFILES+=	iplang_y.c iplang_y.h
+
+DPSRCS+=	iplang_y.h
+
+.PATH:		${NETBSDSRCDIR}/dist/ipf/ipsend \
+		${NETBSDSRCDIR}/dist/ipf/iplang
+
+iplang_y.c: iplang_y.y
+	${_MKTARGET_CREATE}
+	${YACC} -d ${.ALLSRC}
+	mv y.tab.c ${.TARGET}
+	mv y.tab.h ${.TARGET:.c=.h}
+
+iplang_y.h: iplang_y.c
+
+# XXX
+# We have a problem with make and linking ipsend
+# cc   -o /home/source/src/usr.sbin/ipf/ipsend/../../../dist/ipf/ipsend .....
+# isn't correct.
+# Use .NOPATH as an workaround for that problem
+.NOPATH: ipsend
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/bin/iptest/Makefile
diff -u /dev/null src/external/bsd/ipf/bin/iptest/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/bin/iptest/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,11 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+.include <bsd.own.mk>
+
+PROG=		iptest
+SRCS=		iptest.c iptests.c ip.c sbpf.c sock.c 44arp.c
+MAN=		iptest.1
+
+.PATH:		${NETBSDSRCDIR}/dist/ipf/ipsend
+
+.include <bsd.prog.mk>

Index: src/external/bsd/ipf/lib/Makefile
diff -u /dev/null src/external/bsd/ipf/lib/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/lib/Makefile	Fri Mar 23 17:29:45 2012
@@ -0,0 +1,147 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:45 christos Exp $
+
+LIBISPRIVATE=	yes
+
+LIB=		ipf
+
+SRCS=		addicmp.c \
+		addipopt.c \
+		alist_free.c \
+		alist_new.c \
+		allocmbt.c \
+		assigndefined.c \
+		bcopywrap.c \
+		binprint.c \
+		buildopts.c \
+		checkrev.c \
+		connecttcp.c \
+		count4bits.c \
+		count6bits.c \
+		debug.c \
+		dupmbt.c \
+		facpri.c \
+		familyname.c \
+		fill6bits.c \
+		findword.c \
+		flags.c \
+		freembt.c \
+		ftov.c \
+		genmask.c \
+		gethost.c \
+		geticmptype.c \
+		getifname.c \
+		getnattype.c \
+		getport.c \
+		getportproto.c \
+		getproto.c \
+		getsumd.c \
+		hostname.c \
+		icmpcode.c \
+		icmptypename.c \
+		icmptypes.c \
+		initparse.c \
+		interror.c \
+		ionames.c \
+		ipferror.c \
+		ipf_perror.c \
+		ipf_dotuning.c \
+		ipft_hx.c \
+		ipft_pc.c \
+		ipft_tx.c \
+		ipoptsec.c \
+		kmem.c \
+		kmemcpywrap.c \
+		kvatoname.c \
+		load_file.c \
+		load_dstlist.c \
+		load_dstlistnode.c \
+		load_hash.c \
+		load_hashnode.c \
+		load_http.c \
+		load_pool.c \
+		load_poolnode.c \
+		load_url.c \
+		msgdsize.c \
+		mutex_emul.c \
+		nametokva.c \
+		nat_setgroupmap.c \
+		ntomask.c \
+		optname.c \
+		optprint.c \
+		optprintv6.c \
+		optvalue.c \
+		parsefields.c \
+		parseipfexpr.c \
+		parsewhoisline.c \
+		poolio.c \
+		portname.c \
+		print_toif.c \
+		printactiveaddr.c \
+		printactivenat.c \
+		printaddr.c \
+		printaps.c \
+		printbuf.c \
+		printdstlist.o \
+		printdstlistdata.o \
+		printdstlistnode.o \
+		printdstlistpolicy.o \
+		printdstl_live.o \
+		printfieldhdr.c \
+		printfr.c \
+		printfraginfo.c \
+		printhash.c \
+		printhashdata.c \
+		printhashnode.c \
+		printhash_live.c \
+		printhost.c \
+		printhostmap.c \
+		printhostmask.c \
+		printifname.c \
+		printip.c \
+		printipfexpr.c \
+		printlog.c \
+		printlookup.c \
+		printmask.c \
+		printnat.c \
+		printnataddr.c \
+		printnatfield.c \
+		printnatside.c \
+		printpool.c \
+		printpooldata.c \
+		printpoolfield.c \
+		printpoolnode.c \
+		printpool_live.c \
+		printproto.c \
+		printportcmp.c \
+		printpacket.c \
+		printpacket6.c \
+		printsbuf.c \
+		printstate.c \
+		printstatefields.c \
+		printtcpflags.c \
+		printtqtable.c \
+		printtunable.c \
+		printunit.c \
+		remove_hash.c \
+		remove_hashnode.c \
+		remove_pool.c \
+		remove_poolnode.c \
+		resetlexer.c \
+		rwlock_emul.c \
+		save_execute.c \
+		save_file.c \
+		save_nothing.c \
+		save_syslog.c \
+		save_v1trap.c \
+		save_v2trap.c \
+		tcpflags.c \
+		tcp_flags.c \
+		var.c \
+		verbose.c \
+		vtof.c \
+		v6ionames.c \
+		v6optvalue.c
+
+#CPPFLAGS.printstate.c=	-Wno-error
+
+.include <bsd.lib.mk>

Index: src/external/bsd/ipf/rules/Makefile
diff -u /dev/null src/external/bsd/ipf/rules/Makefile:1.1
--- /dev/null	Fri Mar 23 17:29:46 2012
+++ src/external/bsd/ipf/rules/Makefile	Fri Mar 23 17:29:46 2012
@@ -0,0 +1,17 @@
+#	$NetBSD: Makefile,v 1.1 2012/03/23 21:29:46 christos Exp $
+
+.include <bsd.own.mk>
+
+MAN=	mkfilters.1
+.if ${MKSHARE} != "no"
+FILESDIR= /usr/share/examples/ipf
+
+FILES=	BASIC.NAT BASIC_1.FW BASIC_2.FW example.1 example.2 example.3 \
+	example.4 example.5 example.6 example.7 example.8 example.9 \
+	example.10 example.11 example.12 example.13 example.sr \
+	firewall ftp-proxy ftppxy mediaone nat-setup \
+	nat.eg server tcpstate mkfilters
+.endif
+
+.PATH:  ${NETBSDSRCDIR}/dist/ipf/rules
+.include <bsd.prog.mk>

Reply via email to