aboutsummaryrefslogtreecommitdiff
path: root/tests/filtertest.c
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2015-01-06 18:58:31 +0000
committerXin LI <delphij@FreeBSD.org>2015-01-06 18:58:31 +0000
commit50224b10fa4e157f09ee1cd03c790c9e61e76c5e (patch)
tree2a457967e5c853893b53d8dc147937913dcbd8fc /tests/filtertest.c
parent59ed76438047aa730b3a617abd873b84457fc4fd (diff)
Vendor import of libpcap 1.6.2.vendor/libpcap/1.6.2
Notes
Notes: svn path=/vendor/libpcap/dist/; revision=276759 svn path=/vendor/libpcap/1.6.2/; revision=276760; tag=vendor/libpcap/1.6.2
Diffstat (limited to 'tests/filtertest.c')
-rw-r--r--tests/filtertest.c23
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);