diff options
Diffstat (limited to 'tests/filtertest.c')
-rw-r--r-- | tests/filtertest.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tests/filtertest.c b/tests/filtertest.c index a56d1e49e923..d603376da64e 100644 --- a/tests/filtertest.c +++ b/tests/filtertest.c @@ -23,8 +23,6 @@ static const char copyright[] _U_ = "@(#) Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000\n\ The Regents of the University of California. All rights reserved.\n"; -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/libpcap/filtertest.c,v 1.2 2005-08-08 17:50:13 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -53,6 +51,8 @@ static char *program_name; static void usage(void) __attribute__((noreturn)); static void error(const char *, ...) __attribute__((noreturn, format (printf, 1, 2))); +static void warn(const char *, ...) + __attribute__((format (printf, 1, 2))); extern int optind; extern int opterr; @@ -122,6 +122,23 @@ error(const char *fmt, ...) /* NOTREACHED */ } +/* VARARGS */ +static void +warn(const char *fmt, ...) +{ + va_list ap; + + (void)fprintf(stderr, "%s: WARNING: ", program_name); + va_start(ap, fmt); + (void)vfprintf(stderr, fmt, ap); + va_end(ap); + if (*fmt) { + fmt += strlen(fmt); + if (fmt[-1] != '\n') + (void)fputc('\n', stderr); + } +} + /* * Copy arg vector into a new buffer, concatenating arguments with spaces. */ @@ -249,6 +266,8 @@ main(int argc, char **argv) if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0) error("%s", pcap_geterr(pd)); + if (!bpf_validate(fcode.bf_insns, fcode.bf_len)) + warn("Filter doesn't pass validation"); bpf_dump(&fcode, dflag); pcap_close(pd); exit(0); |