Add simple bpf(9) regression tests and test cases.

This commit is contained in:
Jung-uk Kim 2008-08-18 19:01:58 +00:00
parent 3bfea8682f
commit b0729b181a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181847
76 changed files with 2739 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# $FreeBSD$
SUBDIR= bpf_filter
.include <bsd.subdir.mk>

View File

@ -0,0 +1,65 @@
# $FreeBSD$
TEST_CASES= test0001 test0002 test0003 test0004 \
test0005 test0006 test0007 test0008 \
test0009 test0010 test0011 test0012 \
test0013 test0014 test0015 test0016 \
test0017 test0018 test0019 test0020 \
test0021 test0022 test0023 test0024 \
test0025 test0026 test0027 test0028 \
test0029 test0030 test0031 test0032 \
test0033 test0034 test0035 test0036 \
test0037 test0038 test0039 test0040 \
test0041 test0042 test0043 test0044 \
test0045 test0046 test0047 test0048 \
test0049 test0050 test0051 test0052 \
test0053 test0054 test0055 test0056 \
test0057 test0058 test0059 test0060 \
test0061 test0062 test0063 test0064 \
test0065 test0066 test0067 test0068 \
test0069 test0070 test0071 test0072 \
test0073
SYSDIR?= ${.CURDIR}/../../../../sys
SRCS= ${.CURDIR}/bpf_test.c
CFLAGS+= -g -fno-builtin-abort -I${.CURDIR}/tests
.if defined(LOG_LEVEL)
CFLAGS+= -DLOG_LEVEL="${LOG_LEVEL}"
.endif
.if defined(BPF_VALIDATE)
CFLAGS+= -DBPF_VALIDATE
.endif
.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386") && defined(BPF_JIT)
SRCS+= ${SYSDIR}/${MACHINE_ARCH}/${MACHINE_ARCH}/bpf_jit_machdep.c
CFLAGS+= -I${SYSDIR} -DBPF_JIT_COMPILER
WARNS?= 6
.else
SRCS+= ${SYSDIR}/net/bpf_filter.c
WARNS?= 1
.endif
.for TEST in ${TEST_CASES}
${TEST}: ${.CURDIR}/tests/${TEST}.h ${SRCS}
@${CC} ${CFLAGS} -DBPF_TEST_H=\"${TEST}.h\" -o ${.CURDIR}/${TEST} ${SRCS}
.endfor
all: ${TEST_CASES}
.for TEST in ${TEST_CASES}
.if !defined(LOG_LEVEL) || (${LOG_LEVEL} > 0)
@${ECHO} -n "${TEST}: "
.endif
@-${.CURDIR}/${TEST}
@rm -f ${.CURDIR}/${TEST}
.endfor
clean:
.for TEST in ${TEST_CASES}
@rm -f ${.CURDIR}/${TEST}
.endfor
.include <bsd.prog.mk>

View File

@ -0,0 +1,238 @@
/*-
* Copyright (C) 2008 Jung-uk Kim <jkim@FreeBSD.org>. All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <net/bpf.h>
#include BPF_TEST_H
#define PASSED 0
#define FAILED 1
#define FATAL -1
#ifndef LOG_LEVEL
#define LOG_LEVEL 1
#endif
static void sig_handler(int);
static int nins = sizeof(pc) / sizeof(pc[0]);
static int verbose = LOG_LEVEL;
#ifdef BPF_JIT_COMPILER
#include <string.h>
#include <net/bpf_jitter.h>
bpf_filter_func bpf_jit_compile(struct bpf_insn *, u_int, int *);
static u_int
bpf_compile_and_filter(void)
{
bpf_jit_filter filter;
u_int ret;
/* Do not use BPF JIT compiler for an empty program */
if (nins == 0)
return (0);
/* Allocate the filter's memory */
if ((filter.mem = (int *)malloc(BPF_MEMWORDS * sizeof(int))) == NULL)
goto fail;
/* Create the binary */
if ((filter.func = bpf_jit_compile(pc, nins, filter.mem)) == NULL)
goto fail;
ret = (*(filter.func))(pkt, wirelen, buflen);
free(filter.mem);
free(filter.func);
return (ret);
fail:
if (filter.mem != NULL)
free(filter.mem);
if (verbose > 1)
printf("Failed to allocate memory:\t");
if (verbose > 0)
printf("FATAL\n");
exit(FATAL);
}
#else
u_int bpf_filter(struct bpf_insn *, u_char *, u_int, u_int);
#endif
#ifdef BPF_VALIDATE
/*
* XXX Copied from sys/net/bpf_filter.c and modified.
*
* Return true if the 'fcode' is a valid filter program.
* The constraints are that each jump be forward and to a valid
* code. The code must terminate 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.
*/
static int
bpf_validate(const struct bpf_insn *f, int len)
{
register int i;
register const struct bpf_insn *p;
/* Do not accept negative length filter. */
if (len < 0)
return (0);
/* An empty filter means accept all. */
if (len == 0)
return (1);
for (i = 0; i < len; ++i) {
/*
* Check that that jumps are forward, and within
* the code block.
*/
p = &f[i];
if (BPF_CLASS(p->code) == BPF_JMP) {
register int from = i + 1;
if (BPF_OP(p->code) == BPF_JA) {
if (from >= len || p->k >= (u_int)len - from)
return (0);
}
else if (from >= len || p->jt >= len - from ||
p->jf >= len - from)
return (0);
}
/*
* Check that memory operations use valid addresses.
*/
if ((BPF_CLASS(p->code) == BPF_ST ||
(BPF_CLASS(p->code) == BPF_LD &&
(p->code & 0xe0) == BPF_MEM)) &&
p->k >= BPF_MEMWORDS)
return (0);
/*
* Check for constant division by 0.
*/
if (p->code == (BPF_ALU|BPF_DIV|BPF_K) && p->k == 0)
return (0);
}
return (BPF_CLASS(f[len - 1].code) == BPF_RET);
}
#endif
int
main(void)
{
u_int ret;
int sig;
#ifdef BPF_VALIDATE
int valid;
#endif
/* Try to catch all signals */
for (sig = SIGHUP; sig <= SIGUSR2; sig++)
signal(sig, sig_handler);
#ifdef BPF_VALIDATE
valid = bpf_validate(pc, nins);
if (valid != 0 && invalid != 0) {
if (verbose > 1)
printf("Validated invalid instructions:\t");
if (verbose > 0)
printf("FAILED\n");
return (FAILED);
} else if (valid == 0 && invalid == 0) {
if (verbose > 1)
printf("Invalidated valid instructions:\t");
if (verbose > 0)
printf("FAILED\n");
return (FAILED);
}
#endif
#ifdef BPF_JIT_COMPILER
ret = bpf_compile_and_filter();
#else
ret = bpf_filter(pc, pkt, wirelen, buflen);
#endif
if (ret != expect) {
if (verbose > 1)
printf("Expected 0x%x but got 0x%x:\t", expect, ret);
if (verbose > 0)
printf("FAILED\n");
return (FAILED);
}
if (verbose > 1)
printf("Expected and got 0x%x:\t", ret);
if (verbose > 0)
printf("PASSED\n");
return (PASSED);
}
static void
sig_handler(int sig)
{
if (expect_signal == 0) {
if (verbose > 1)
printf("Received unexpected signal %d:\t", sig);
if (verbose > 0)
printf("FATAL\n");
exit(FATAL);
}
if (expect_signal != sig) {
if (verbose > 1)
printf("Expected signal %d but got %d:\t",
expect_signal, sig);
if (verbose > 0)
printf("FAILED\n");
exit(FAILED);
}
if (verbose > 1)
printf("Expected and got signal %d:\t", sig);
if (verbose > 0)
printf("PASSED\n");
exit(PASSED);
}

View File

@ -0,0 +1,30 @@
/*-
* Test 0001: Catch illegal instruction.
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(0xdead, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 1;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = SIGABRT;

View File

@ -0,0 +1,30 @@
/*-
* Test 0002: BPF_RET+BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_RET+BPF_K, 0xdeadc0de),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,31 @@
/*-
* Test 0003: BPF_LD+BPF_IMM & BPF_RET+BPF_A
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD+BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,31 @@
/*-
* Test 0004: BPF_LD|BPF_W|BPF_ABS
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_W|BPF_ABS, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x23456789;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,31 @@
/*-
* Test 0005: BPF_LD|BPF_H|BPF_ABS
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x2345;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,31 @@
/*-
* Test 0006: BPF_LD|BPF_B|BPF_ABS
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x23;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,29 @@
/*-
* Test 0007: BPF_LD|BPF_W|BPF_LEN
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_W|BPF_LEN, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[0xdeadc0de];
/* Packet length seen on wire */
u_int wirelen = 0xdeadc0de;
/* Packet length passed on buffer */
u_int buflen = 0xdeadc0de;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,30 @@
/*-
* Test 0008: BPF_LDX|BPF_W|BPF_LEN & BPF_MISC|BPF_TXA
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_W|BPF_LEN, 0),
BPF_STMT(BPF_MISC|BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[0xdeadc0de];
/* Packet length seen on wire */
u_int wirelen = 0xdeadc0de;
/* Packet length passed on buffer */
u_int buflen = 0xdeadc0de;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0009: BPF_LDX|BPF_IMM & BPF_LD|BPF_W|BPF_IND
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x456789ab;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0010: BPF_LD|BPF_H|BPF_IND
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x4567;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0011: BPF_LD|BPF_B|BPF_IND
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x45;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0012: BPF_LDX|BPF_MSH|BPF_B
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_MSH|BPF_B, 1),
BPF_STMT(BPF_MISC|BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = (0x23 & 0xf) << 2;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,34 @@
/*-
* Test 0013: BPF_ST & BPF_LDX|BPF_MEM
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_ST, 7),
BPF_STMT(BPF_LDX|BPF_MEM, 7),
BPF_STMT(BPF_MISC|BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0014: BPF_STX & BPF_LD|BPF_MEM
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LDX|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_STX, 7),
BPF_STMT(BPF_LD|BPF_MEM, 7),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0015: BPF_JMP|BPF_JA
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_JMP|BPF_JA, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,37 @@
/*-
* Test 0016: BPF_JMP|BPF_JGT|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_K, 0x01234568, 2, 0),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_K, 0x01234566, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_K, 0x01234567, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,37 @@
/*-
* Test 0017: BPF_JMP|BPF_JGE|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 0x01234568, 2, 0),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 0x01234567, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_K, 0x01234566, 0, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,37 @@
/*-
* Test 0018: BPF_JMP|BPF_JEQ|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x01234568, 2, 0),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x01234567, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_K, 0x01234566, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,42 @@
/*-
* Test 0019: BPF_JMP|BPF_JSET|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x80000000, 5, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x40000000, 4, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x20000000, 3, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x10000000, 2, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x1, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x08000000, 3, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x04000000, 2, 0),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_K, 0x02000000, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,40 @@
/*-
* Test 0020: BPF_JMP|BPF_JGT|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234568),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_X, 0, 3, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234566),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_X, 0, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JGT|BPF_X, 0, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,40 @@
/*-
* Test 0021: BPF_JMP|BPF_JGE|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234568),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_X, 0, 3, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_X, 0, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234566),
BPF_JUMP(BPF_JMP|BPF_JGE|BPF_X, 0, 0, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,40 @@
/*-
* Test 0022: BPF_JMP|BPF_JEQ|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234568),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_X, 0, 3, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234567),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_X, 0, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x01234566),
BPF_JUMP(BPF_JMP|BPF_JEQ|BPF_X, 0, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,50 @@
/*-
* Test 0023: BPF_JMP|BPF_JSET|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x01234567),
BPF_STMT(BPF_LDX|BPF_IMM, 0x80000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 9, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x40000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 7, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x20000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 5, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x10000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 3, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x1),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0x1, 2, 1),
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_RET+BPF_A, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x08000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 5, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x04000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 3, 0),
BPF_STMT(BPF_LDX|BPF_IMM, 0x02000000),
BPF_JUMP(BPF_JMP|BPF_JSET|BPF_X, 0, 1, 0),
BPF_STMT(BPF_LD|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0decafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0024: BPF_ALU|BPF_ADD|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xbeadb8dd),
BPF_STMT(BPF_LDX|BPF_IMM, 0x20000801),
BPF_STMT(BPF_ALU|BPF_ADD|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0025: BPF_ALU|BPF_SUB|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0x20000801),
BPF_STMT(BPF_ALU|BPF_SUB|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xbeadb8dd;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0026: BPF_ALU|BPF_MUL|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdead),
BPF_STMT(BPF_LDX|BPF_IMM, 0xc0de),
BPF_STMT(BPF_ALU|BPF_MUL|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xa7c2da06;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0027: BPF_ALU|BPF_DIV|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xa7c2da06),
BPF_STMT(BPF_LDX|BPF_IMM, 0xdead),
BPF_STMT(BPF_ALU|BPF_DIV|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0028: BPF_ALU|BPF_AND|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_ALU|BPF_AND|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc08cc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0029: BPF_ALU|BPF_OR|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0xc0decafe),
BPF_STMT(BPF_ALU|BPF_OR|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeffcafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0030: BPF_ALU|BPF_LSH|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdefc0),
BPF_STMT(BPF_LDX|BPF_IMM, 9),
BPF_STMT(BPF_ALU|BPF_LSH|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x1bdf8000;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0031: BPF_ALU|BPF_RSH|BPF_X
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 13),
BPF_STMT(BPF_ALU|BPF_RSH|BPF_X, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x6f56e;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0032: BPF_ALU|BPF_ADD|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xbeadb8dd),
BPF_STMT(BPF_ALU|BPF_ADD|BPF_K, 0x20000801),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0033: BPF_ALU|BPF_SUB|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_ALU|BPF_SUB|BPF_K, 0x20000801),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xbeadb8dd;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0034: BPF_ALU|BPF_MUL|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdead),
BPF_STMT(BPF_ALU|BPF_MUL|BPF_K, 0xc0de),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xa7c2da06;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0035: BPF_ALU|BPF_DIV|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xa7c2da06),
BPF_STMT(BPF_ALU|BPF_DIV|BPF_K, 0xdead),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0036: BPF_ALU|BPF_AND|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_ALU|BPF_AND|BPF_K, 0xc0decafe),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xc08cc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0037: BPF_ALU|BPF_OR|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_ALU|BPF_OR|BPF_K, 0xc0decafe),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeffcafe;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0038: BPF_ALU|BPF_LSH|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdefc0),
BPF_STMT(BPF_ALU|BPF_LSH|BPF_K, 9),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x1bdf8000;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0039: BPF_ALU|BPF_RSH|BPF_K
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_ALU|BPF_RSH|BPF_K, 13),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0x6f56e;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0040: BPF_ALU|BPF_NEG
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0x21523f22),
BPF_STMT(BPF_ALU|BPF_NEG, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,34 @@
/*-
* Test 0041: BPF_MISC|BPF_TAX
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_MISC|BPF_TAX, 0),
BPF_STMT(BPF_STX, 0),
BPF_STMT(BPF_LD|BPF_MEM, 0),
BPF_STMT(BPF_RET|BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x00,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0xdeadc0de;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0042: Check boundary conditions (BPF_LD|BPF_W|BPF_ABS)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LD|BPF_W|BPF_ABS, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0043: Check boundary conditions (BPF_LD|BPF_H|BPF_ABS)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0044: Check boundary conditions (BPF_LD|BPF_B|BPF_ABS)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LD|BPF_B|BPF_ABS, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0045: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0046: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0047: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 2),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0048: Check boundary conditions (BPF_LDX|BPF_MSH|BPF_B)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_MSH|BPF_B, 2),
BPF_STMT(BPF_MISC|BPF_TXA, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0049: Check boundary conditions (BPF_LD|BPF_W|BPF_ABS)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LD|BPF_W|BPF_ABS, 6),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,32 @@
/*-
* Test 0050: Check boundary conditions (BPF_LD|BPF_H|BPF_ABS)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LD|BPF_H|BPF_ABS, 4),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0051: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 6),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0052: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 4),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0053: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 3),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0054: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 6),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0055: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 4),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0056: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 0xffffffff),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0057: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 0xffffffff),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0058: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 0xffffffff),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0059: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0xffffffff),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0060: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0xffffffff),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0061: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0xffffffff),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = sizeof(pkt);
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0062: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0063: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0064: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0065: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0066: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0067: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 1),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0068: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0069: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0070: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 1),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0071: Check boundary conditions (BPF_LD|BPF_W|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_W|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67, 0x89, 0xab,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0072: Check boundary conditions (BPF_LD|BPF_H|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_H|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45, 0x67,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;

View File

@ -0,0 +1,33 @@
/*-
* Test 0073: Check boundary conditions (BPF_LD|BPF_B|BPF_IND)
*
* $FreeBSD$
*/
/* BPF program */
struct bpf_insn pc[] = {
BPF_STMT(BPF_LD|BPF_IMM, 0xdeadc0de),
BPF_STMT(BPF_LDX|BPF_IMM, 0),
BPF_STMT(BPF_LD|BPF_B|BPF_IND, 0),
BPF_STMT(BPF_RET+BPF_A, 0),
};
/* Packet */
u_char pkt[] = {
0x01, 0x23, 0x45,
};
/* Packet length seen on wire */
u_int wirelen = sizeof(pkt);
/* Packet length passed on buffer */
u_int buflen = 0;
/* Invalid instruction */
int invalid = 0;
/* Expected return value */
u_int expect = 0;
/* Expeced signal */
int expect_signal = 0;