summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2013-12-31 16:57:18 +0000
committerchristos <christos@NetBSD.org>2013-12-31 16:57:18 +0000
commitc15d5eff1fb095a3ff2cf86c8a79b3d30fa93000 (patch)
tree711c6e31fe08312960415ee35c64a8b6a073a2d1 /external
parent669094ff456356373df86c866434c75673bde1dd (diff)
Import libpcap-1.5.2
Diffstat (limited to 'external')
-rw-r--r--external/bsd/libpcap/dist/CHANGES45
-rw-r--r--external/bsd/libpcap/dist/CREDITS34
-rw-r--r--external/bsd/libpcap/dist/Makefile-devel-adds22
-rw-r--r--external/bsd/libpcap/dist/Makefile.in101
-rw-r--r--external/bsd/libpcap/dist/README25
-rw-r--r--external/bsd/libpcap/dist/README.aix8
-rw-r--r--external/bsd/libpcap/dist/README.dag20
-rw-r--r--external/bsd/libpcap/dist/VERSION2
-rw-r--r--external/bsd/libpcap/dist/aclocal.m4472
-rw-r--r--external/bsd/libpcap/dist/bpf_image.c17
-rw-r--r--external/bsd/libpcap/dist/config.h.in29
-rwxr-xr-xexternal/bsd/libpcap/dist/configure1558
-rw-r--r--external/bsd/libpcap/dist/configure.in244
-rw-r--r--external/bsd/libpcap/dist/dlpisubs.c61
-rw-r--r--external/bsd/libpcap/dist/dlpisubs.h20
-rw-r--r--external/bsd/libpcap/dist/fad-getad.c29
-rw-r--r--external/bsd/libpcap/dist/fad-gifc.c16
-rw-r--r--external/bsd/libpcap/dist/fad-glifc.c13
-rw-r--r--external/bsd/libpcap/dist/fad-null.c4
-rw-r--r--external/bsd/libpcap/dist/fad-sita.c4
-rw-r--r--external/bsd/libpcap/dist/fad-win32.c22
-rw-r--r--external/bsd/libpcap/dist/gencode.h21
-rwxr-xr-xexternal/bsd/libpcap/dist/mkdep10
-rw-r--r--external/bsd/libpcap/dist/nametoaddr.c5
-rw-r--r--external/bsd/libpcap/dist/pcap-bt-linux.c63
-rw-r--r--external/bsd/libpcap/dist/pcap-bt-linux.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-can-linux.c69
-rw-r--r--external/bsd/libpcap/dist/pcap-can-linux.h5
-rw-r--r--external/bsd/libpcap/dist/pcap-canusb-linux.c402
-rw-r--r--external/bsd/libpcap/dist/pcap-canusb-linux.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-common.c55
-rw-r--r--external/bsd/libpcap/dist/pcap-dag.c233
-rw-r--r--external/bsd/libpcap/dist/pcap-dag.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-dbus.c281
-rw-r--r--external/bsd/libpcap/dist/pcap-dbus.h4
-rw-r--r--external/bsd/libpcap/dist/pcap-dlpi.c52
-rw-r--r--external/bsd/libpcap/dist/pcap-dos.c51
-rw-r--r--external/bsd/libpcap/dist/pcap-filter.manmisc.in108
-rw-r--r--external/bsd/libpcap/dist/pcap-int.h294
-rw-r--r--external/bsd/libpcap/dist/pcap-libdlpi.c40
-rw-r--r--external/bsd/libpcap/dist/pcap-linux.c1707
-rw-r--r--external/bsd/libpcap/dist/pcap-netfilter-linux.c287
-rw-r--r--external/bsd/libpcap/dist/pcap-netfilter-linux.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-nit.c56
-rw-r--r--external/bsd/libpcap/dist/pcap-null.c4
-rw-r--r--external/bsd/libpcap/dist/pcap-pf.c78
-rw-r--r--external/bsd/libpcap/dist/pcap-savefile.manfile.in33
-rw-r--r--external/bsd/libpcap/dist/pcap-septel.c53
-rw-r--r--external/bsd/libpcap/dist/pcap-septel.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-sita.c139
-rw-r--r--external/bsd/libpcap/dist/pcap-snf.c94
-rw-r--r--external/bsd/libpcap/dist/pcap-snf.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-snit.c56
-rw-r--r--external/bsd/libpcap/dist/pcap-snoop.c21
-rw-r--r--external/bsd/libpcap/dist/pcap-usb-linux.c99
-rw-r--r--external/bsd/libpcap/dist/pcap-usb-linux.h6
-rw-r--r--external/bsd/libpcap/dist/pcap-win32.c72
-rw-r--r--external/bsd/libpcap/dist/pcap_breakloop.3pcap19
-rw-r--r--external/bsd/libpcap/dist/pcap_datalink.3pcap.in29
-rw-r--r--external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in47
-rw-r--r--external/bsd/libpcap/dist/pcap_is_swapped.3pcap15
-rw-r--r--external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in17
-rw-r--r--external/bsd/libpcap/dist/pcap_loop.3pcap45
-rw-r--r--external/bsd/libpcap/dist/pcap_next_ex.3pcap38
-rw-r--r--external/bsd/libpcap/dist/pcap_offline_filter.3pcap2
-rw-r--r--external/bsd/libpcap/dist/pcap_open_dead.3pcap.in41
-rw-r--r--external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap47
-rw-r--r--external/bsd/libpcap/dist/pcap_set_tstamp_precision.3pcap.in61
-rw-r--r--external/bsd/libpcap/dist/pcap_snapshot.3pcap10
-rw-r--r--external/bsd/libpcap/dist/savefile.c90
-rw-r--r--external/bsd/libpcap/dist/sf-pcap-ng.h5
-rw-r--r--external/bsd/libpcap/dist/sf-pcap.h5
-rw-r--r--external/bsd/libpcap/dist/tests/valgrindtest.c410
73 files changed, 5688 insertions, 2373 deletions
diff --git a/external/bsd/libpcap/dist/CHANGES b/external/bsd/libpcap/dist/CHANGES
index 4f7fa355c75..75decb78900 100644
--- a/external/bsd/libpcap/dist/CHANGES
+++ b/external/bsd/libpcap/dist/CHANGES
@@ -1,3 +1,48 @@
+Wednesday October 30, 2013 guy@alum.mit.edu
+Summary for 1.5.0 libpcap release
+ TPACKET_V3 support added for Linux
+ Point users to the the-tcpdump-group repository on GitHub rather
+ than the mcr repository
+ Checks added for malloc()/realloc()/etc. failures
+ Fixed build on Solaris 11
+ Support filtering filtering E1 SS7 traffic on MTP2 layer Annex A
+ Use "ln -s" to link man pages by default
+ Added pcap_open_dead_with_tstamp_precision API interface.
+ Many changes to autoconf to deal better with non-GCC compilers
+ added many new DLT types
+
+Saturday April 6, 2013 guy@alum.mit.edu
+Summary for 1.4.0 libpcap release
+ Add netfilter/nfqueue interface.
+ If we don't have support for IPv6 address resolution, support,
+ in filter expressions, what IPv6 stuff we can.
+ Fix pcap-config to include -lpthread if canusb support is
+ present
+ Try to fix "pcap_parse not defined" problems when --without-flex
+ and --without-bison are used when you have Flex and Bison
+ Fix some issues with the pcap_loop man page.
+ Fix pcap_getnonblock() and pcap_setnonblock() to fill in the
+ supplied error message buffer
+ Fix typo that, it appeared, would cause pcap-libdlpi.c not to
+ compile (perhaps systems with libdlpi also have BPF and use
+ that instead)
+ Catch attempts to call pcap_compile() on a non-activated pcap_t
+ Fix crash on Linux with CAN-USB support without usbfs
+ Fix addition of VLAN tags for Linux cooked captures
+ Check for both EOPNOTSUPP and EINVAL after SIOCETHTOOL ioctl, so
+ that the driver can report either one if it doesn't support
+ SIOCETHTOOL
+ Add DLT_INFINIBAND and DLT_SCTP
+ Describe "proto XXX" and "protochain XXX" in the pcap-filter man
+ page
+ Handle either directories, or symlinks to directories, that
+ correspond to interfaces in /sys/class/net
+ Fix handling of VLAN tag insertion to check, on Linux 3.x
+ kernels, for VLAN tag valid flag
+ Clean up some man pages
+ Support libnl3 as well as libnl1 and libnl2 on Linux
+ Fix handling of Bluetooth devices on 3.x Linux kernels
+
Friday March 30, 2012. mcr@sandelman.ca
Summary for 1.3.0 libpcap release
Handle DLT_PFSYNC in {FreeBSD, other *BSD+Mac OS X, other}.
diff --git a/external/bsd/libpcap/dist/CREDITS b/external/bsd/libpcap/dist/CREDITS
index cfe84ba4e9f..69cbbf0444e 100644
--- a/external/bsd/libpcap/dist/CREDITS
+++ b/external/bsd/libpcap/dist/CREDITS
@@ -2,6 +2,7 @@ This file lists people who have contributed to libpcap:
The current maintainers:
Bill Fenner <fenner at research dot att dot com>
+ Denis Ovsienko <infrastation at yandex dot ru>
Fulvio Risso <risso at polito dot it>
Guy Harris <guy at alum dot mit dot edu>
Hannes Gredler <hannes at juniper dot net>
@@ -9,18 +10,23 @@ The current maintainers:
Additional people who have contributed patches:
+ Akos Vandra <axos88 at gmail dot com>
Alan Bawden <Alan at LCS dot MIT dot EDU>
Albert Chin <china at thewrittenword dot com>
Alexander 'Leo' Bergolth <Leo dot Bergolth at wu-wien dot ac dot at>
Alexey Kuznetsov <kuznet at ms2 dot inr dot ac dot ru>
Alon Bar-Lev <alonbl at sourceforge dot net>
+ Andres Perera <andres dot p at zoho dot com>
Andrew Brown <atatat at atatdot dot net>
<andy-1 at sourceforge dot net>
+ Ani Sinha <ani at aristanetworks dot com>
Antti Kantee <pooka at netbsd dot org>
Arien Vijn <arienvijn at sourceforge dot net>
Arkadiusz Miskiewicz <misiek at pld dot org dot pl>
Armando L. Caro Jr. <acaro at mail dot eecis dot udel dot edu>
Assar Westerlund <assar at sics dot se>
+ Bill Parker <wp02855 at gmail dot com>
+ Brent Cook <brent at boundary dot com>
Brian Ginsbach <ginsbach at cray dot com>
Charles M. Hannum <mycroft at netbsd dot org>
Chris G. Demetriou <cgd at netbsd dot org>
@@ -29,15 +35,21 @@ Additional people who have contributed patches:
Chris Pepper <pepper at mail dot reppep dot com>
Christian Bell <csbell at myri dot com>
Christian Peron <csjp at freebsd dot org>
+ Christian Svensson <blue at cmd dot nu>
Daniele Orlandi <daniele at orlandi dot com>
+ Darren Lim <darren dot lim at endace dot com>
Darren Reed <darrenr at sun dot com>
+ David Clark <david dot clark at datasoft dot com>
David Kaelbling <drk at sgi dot com>
+ David Ward <david dot ward at ll dot mit dot edu>
David Young <dyoung at ojctech dot com>
Dean Gaudet <dean at arctic dot org>
dhruv <rsrivat at sourceforge dot net>
Don Ebright <Don dot Ebright at compuware dot com>
Dug Song <dugsong at monkey dot org>
Dustin Spicuzza <dustin at virtualroadside dot com>
+ dzejarczech <dzejarczech at sourceforge dot net>
+ Edward Sheldrake <ejs1920 at sourceforge dot net>
Eric Anderson <anderse at hpl dot hp dot com>
Erik de Castro Lopo <erik dot de dot castro dot lopo at sensorynetworks dot com>
Felix Obenhuber <felix at obenhuber dot de>
@@ -46,31 +58,37 @@ Additional people who have contributed patches:
frederich <frederich at sourceforge dot net>
Fulko Hew <fulko dot hew at gmail dot com>
Fumiyuki Shimizu <fumifumi at abacustech dot jp>
+ Gabor Tatarka <gabor dot tatarka at ericsson dot com>
Garrett Cooper <yaberauneya at sourceforge dot net>
+ George Neville-Neil <gnn at freebsd dot org>
Gianluca Varenni <gianluca dot varenni at gmail dot com>
Gilbert Hoyek <gil_hoyek at hotmail dot com>
Gisle Vanem <gvanem at broadpark dot no>
Graeme Hewson <ghewson at cix dot compulink dot co dot uk>
+ Gregor Maier <gregor at net dot in dot tum dot de>
Greg Stark <gsstark at mit dot edu>
Greg Troxel <gdt at ir dot bbn dot com>
- Gregor Maier <gregor at net dot in dot tum dot de>
Guillaume Pelat <endymion_ at users dot sourceforge dot net>
+ Gustavo Zacarias <gustavo at zacarias dot com dot ar>
Hagen Paul Pfeifer <hagen at jauu dot net>
Henri Doreau <hdoreau at sourceforge dot net>
Hyung Sik Yoon <hsyn at kr dot ibm dot com>
Igor Khristophorov <igor at atdot dot org>
+ Jakub Zawadzki <darkjames at darkjames dot pl>
Jan-Philip Velders <jpv at veldersjes dot net>
Jason R. Thorpe <thorpej at netbsd dot org>
Javier Achirica <achirica at ttd dot net>
+ Jean-Louis Charton <Jean-Louis dot CHARTON at oikialog dot com>
Jean Tourrilhes <jt at hpl dot hp dot com>
- Jean-Louis Charton <Jean-Louis.CHARTON at oikialog dot com>
Jefferson Ogata <jogata at nodc dot noaa dot gov>
Jesper Dangaard Brouer <hawk at comx dot dk>
Jesper Peterson <jesper at endace dot com>
+ Jiri Slaby <jirislaby at gmail dot com>
Joerg Mayer <jmayer at loplof dot de>
John Bankier <jbankier at rainfinity dot com>
Jon Lindgren <jonl at yubyub dot net>
Jon Smirl <jonsmirl at gmail dot com>
+ Jorge Boncompte [DTI2] <jorge at dti2 dot net>
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
Julien Moutinho <julm at savines dot alpes dot fr dot eu dot org>
Jung-uk Kim <jkim at FreeBSD dot org>
@@ -84,6 +102,7 @@ Additional people who have contributed patches:
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
Luis MartinGarcia <luis dot mgarc at gmail dot com>
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
+ Mansour Behabadi <mansour at oxplot dot com>
Marcus Felipe Pereira <marcus at task dot com dot br>
Mark C. Brown <mbrown at hp dot com>
Mark Pizzolato <List-tcpdump-workers at subscriptions dot pizzolato dot net>
@@ -92,14 +111,17 @@ Additional people who have contributed patches:
Márton Németh <nm127 at freemail dot hu>
Matthew Luckie <mjl at luckie dot org dot nz>
Max Laier <max at love2party dot net>
+ Michal Labedzki
+ Michal Sekletar <msekleta at redhat dot com>
Mike Frysinger <vapier at gmail dot com>
Mike Kershaw <dragorn at kismetwireless dot net>
Mike Wiacek <mike at iroot dot net>
Miroslav Lichvar <mlichvar at redhat dot com>
Monroe Williams <monroe at pobox dot com>
- <nvercamm at sourceforge dot net>
- N. Leiten <nleiten at sourceforge dot net>
Nicolas Dade <ndade at nsd dot dyndns dot org>
+ Niko Delarich <niko dot delarich at gmail dot com>
+ N. Leiten <nleiten at sourceforge dot net>
+ <nvercamm at sourceforge dot net>
Octavian Cerna <tavy at ylabs dot com>
Olaf Kirch <okir at caldera dot de>
Ollie Wild <aaw at users dot sourceforge dot net>
@@ -143,8 +165,8 @@ Additional people who have contributed patches:
Xianjie Zhang <xzhang at cup dot hp dot com>
Xin Li <delphij at FreeBSD dot org>
Yen Yen Lim
- Yvan Vanhullebus <vanhu at sourceforge dot net>
Yoann Vandoorselaere <yoann at prelude-ids dot org>
+ Yvan Vanhullebus <vanhu at sourceforge dot net>
The original LBL crew:
Steve McCanne
@@ -152,4 +174,4 @@ The original LBL crew:
Van Jacobson
Past maintainers:
- Jun-ichiro itojun Hagino <itojun at iijlab dot net>
+ Jun-ichiro itojun Hagino <itojun at iijlab dot net> Also see: http://www.wide.ad.jp/itojun-award/
diff --git a/external/bsd/libpcap/dist/Makefile-devel-adds b/external/bsd/libpcap/dist/Makefile-devel-adds
new file mode 100644
index 00000000000..7bf6420c1c8
--- /dev/null
+++ b/external/bsd/libpcap/dist/Makefile-devel-adds
@@ -0,0 +1,22 @@
+#
+# Auto-regenerate configure script or Makefile when things change.
+# From autoconf.info . Works best with GNU Make.
+#
+${srcdir}/configure: configure.in aclocal.m4
+ cd ${srcdir} && autoconf
+
+# autoheader might not change config.h.in, so touch a stamp file.
+${srcdir}/config.h.in: ${srcdir}/stamp-h.in
+${srcdir}/stamp-h.in: configure.in aclocal.m4
+ cd ${srcdir} && autoheader
+ echo timestamp > ${srcdir}/stamp-h.in
+
+config.h: stamp-h
+stamp-h: ${srcdir}/config.h.in config.status
+ ./config.status
+
+Makefile: Makefile.in config.status
+ ./config.status
+
+config.status: ${srcdir}/configure
+ ./config.status --recheck
diff --git a/external/bsd/libpcap/dist/Makefile.in b/external/bsd/libpcap/dist/Makefile.in
index ef9b457347b..0b0e69c0670 100644
--- a/external/bsd/libpcap/dist/Makefile.in
+++ b/external/bsd/libpcap/dist/Makefile.in
@@ -47,6 +47,8 @@ VPATH = @srcdir@
LD = /usr/bin/ld
CC = @CC@
AR = @AR@
+LN_S = @LN_S@
+MKDEP = @MKDEP@
CCOPT = @V_CCOPT@
INCLS = -I. @V_INCLS@
DEFS = @DEFS@ @V_DEFS@
@@ -57,6 +59,7 @@ CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
DYEXT = @DYEXT@
V_RPATH_OPT = @V_RPATH_OPT@
+DEPENDENCY_CFLAG = @DEPENDENCY_CFLAG@
PROG=libpcap
# Standard CFLAGS
@@ -82,7 +85,7 @@ YACC = @V_YACC@
@rm -f $@
$(CC) $(FULL_CFLAGS) -c $(srcdir)/$*.c
-PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@
+PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@ @NETFILTER_SRC@ @CANUSB_SRC@ @DBUS_SRC@
FSRC = fad-@V_FINDALLDEVS@.c
SSRC = @SSRC@
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
@@ -130,7 +133,8 @@ TESTS = \
findalldevstest \
nonblocktest \
opentest \
- selpolltest
+ selpolltest \
+ valgrindtest
TESTS_SRC = \
tests/filtertest.c \
@@ -138,7 +142,8 @@ TESTS_SRC = \
tests/nonblocktest.c \
tests/opentest.c \
tests/reactivatetest.c \
- tests/selpolltest.c
+ tests/selpolltest.c \
+ tests/valgrindtest.c
GENHDR = \
scanner.h tokdefs.h version.h
@@ -157,10 +162,12 @@ MAN3PCAP_EXPAND = \
pcap_compile.3pcap.in \
pcap_datalink.3pcap.in \
pcap_dump_open.3pcap.in \
+ pcap_get_tstamp_precision.3pcap.in \
pcap_list_datalinks.3pcap.in \
pcap_list_tstamp_types.3pcap.in \
pcap_open_dead.3pcap.in \
pcap_open_offline.3pcap.in \
+ pcap_set_tstamp_precision.3pcap.in \
pcap_set_tstamp_type.3pcap.in
MAN3PCAP_NOEXPAND = \
@@ -194,6 +201,7 @@ MAN3PCAP_NOEXPAND = \
pcap_open_live.3pcap \
pcap_set_buffer_size.3pcap \
pcap_set_datalink.3pcap \
+ pcap_set_immediate_mode.3pcap \
pcap_set_promisc.3pcap \
pcap_set_rfmon.3pcap \
pcap_set_snaplen.3pcap \
@@ -227,6 +235,7 @@ EXTRA_DIST = \
INSTALL.txt \
LICENSE \
Makefile.in \
+ Makefile-devel-adds \
README \
README.aix \
README.dag \
@@ -294,6 +303,8 @@ EXTRA_DIST = \
pcap-config.in \
pcap-dag.c \
pcap-dag.h \
+ pcap-dbus.c \
+ pcap-dbus.h \
pcap-dlpi.c \
pcap-dos.c \
pcap-dos.h \
@@ -530,6 +541,9 @@ opentest: tests/opentest.c libpcap.a
selpolltest: tests/selpolltest.c libpcap.a
$(CC) $(FULL_CFLAGS) -I. -L. -o selpolltest $(srcdir)/tests/selpolltest.c libpcap.a $(LIBS)
+valgrindtest: tests/valgrindtest.c libpcap.a
+ $(CC) $(FULL_CFLAGS) -I. -L. -o valgrindtest $(srcdir)/tests/valgrindtest.c libpcap.a $(LIBS)
+
install: install-shared install-archive pcap-config
[ -d $(DESTDIR)$(libdir) ] || \
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
@@ -560,42 +574,39 @@ install: install-shared install-archive pcap-config
for i in $(MAN3PCAP_EXPAND:.in=); do \
$(INSTALL_DATA) $$i \
$(DESTDIR)$(mandir)/man3/$$i; done
- rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_name.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_dump_open.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_findalldevs.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_freealldevs.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_geterr.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_inject.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_list_datalinks.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_free_datalinks.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_list_tstamp_types.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_free_tstamp_types.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_loop.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_major_version.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_next_ex.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_open_offline.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
- rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
- ln $(DESTDIR)$(mandir)/man3/pcap_setnonblock.3pcap \
- $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
+ (cd $(DESTDIR)$(mandir)/man3 && \
+ rm -f pcap_datalink_val_to_description.3pcap && \
+ $(LN_S) pcap_datalink_val_to_name.3pcap \
+ pcap_datalink_val_to_description.3pcap && \
+ rm -f pcap_dump_fopen.3pcap && \
+ $(LN_S) pcap_dump_open.3pcap pcap_dump_fopen.3pcap && \
+ rm -f pcap_freealldevs.3pcap && \
+ $(LN_S) pcap_findalldevs.3pcap pcap_freealldevs.3pcap && \
+ rm -f pcap_perror.3pcap && \
+ $(LN_S) pcap_geterr.3pcap pcap_perror.3pcap && \
+ rm -f pcap_sendpacket.3pcap && \
+ $(LN_S) pcap_inject.3pcap pcap_sendpacket.3pcap && \
+ rm -f pcap_free_datalinks.3pcap && \
+ $(LN_S) pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap && \
+ rm -f pcap_free_tstamp_types.3pcap && \
+ $(LN_S) pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap && \
+ rm -f pcap_dispatch.3pcap && \
+ $(LN_S) pcap_loop.3pcap pcap_dispatch.3pcap && \
+ rm -f pcap_minor_version.3pcap && \
+ $(LN_S) pcap_major_version.3pcap pcap_minor_version.3pcap && \
+ rm -f pcap_next.3pcap && \
+ $(LN_S) pcap_next_ex.3pcap pcap_next.3pcap && \
+ rm -f pcap_open_dead_with_tstamp_precision.3pcap && \
+ $(LN_S) pcap_open_dead.3pcap \
+ pcap_open_dead_with_tstamp_precision.3pcap && \
+ rm -f pcap_open_offline_with_tstamp_precision.3pcap && \
+ $(LN_S) pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap && \
+ rm -f pcap_fopen_offline.3pcap && \
+ $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline.3pcap && \
+ rm -f pcap_fopen_offline_with_tstamp_precision.3pcap && \
+ $(LN_S) pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap && \
+ rm -f pcap_getnonblock.3pcap && \
+ $(LN_S) pcap_setnonblock.3pcap pcap_getnonblock.3pcap)
for i in $(MANFILE); do \
$(INSTALL_DATA) `echo $$i | sed 's/.manfile.in/.manfile/'` \
$(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
@@ -672,7 +683,10 @@ uninstall: uninstall-shared
rm -f $(DESTDIR)$(mandir)/man3/pcap_dispatch.3pcap
rm -f $(DESTDIR)$(mandir)/man3/pcap_minor_version.3pcap
rm -f $(DESTDIR)$(mandir)/man3/pcap_next.3pcap
+ rm -f $(DESTDIR)$(mandir)/man3/pcap_open_dead_with_tstamp_precision.3pcap
+ rm -f $(DESTDIR)$(mandir)/man3/pcap_open_offline_with_tstamp_precision.3pcap
rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline.3pcap
+ rm -f $(DESTDIR)$(mandir)/man3/pcap_fopen_offline_with_tstamp_precision.3pcap
rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
for i in $(MANFILE); do \
rm -f $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@/`echo $$i | sed 's/.manfile.in/.@MAN_FILE_FORMATS@/'`; done
@@ -717,7 +731,7 @@ packaging/pcap.spec: packaging/pcap.spec.in VERSION
RPMVERSION=`cat VERSION | sed s/-.*//g`; \
sed -e s/@VERSION@/$$RPMVERSION/ -e s/@NAME@/libpcap-`cat VERSION`/ $< > $@
-releasetar:
+releasetar:
@cwd=`pwd` ; dir=`basename $$cwd` ; name=$(PROG)-`cat VERSION` ; \
mkdir $$name; \
tar cf - $(CSRC) $(HDR) $(MAN1) $(MAN3PCAP_EXPAND) \
@@ -727,9 +741,4 @@ releasetar:
rm -rf $$name
depend: $(GENSRC) $(GENHDR) bpf_filter.c
- ./mkdep -c $(CC) $(DEFS) $(INCLS) $(SRC)
-
-Makefile: Makefile.in config.status
- ./config.status
- @echo your Makefile was out of date, now run $(MAKE) again
- exit 1
+ $(MKDEP) -c $(CC) -m $(DEPENDENCY_CFLAG) $(DEFS) $(INCLS) $(SRC)
diff --git a/external/bsd/libpcap/dist/README b/external/bsd/libpcap/dist/README
index 89d63aa0ff6..3f4a26f39b2 100644
--- a/external/bsd/libpcap/dist/README
+++ b/external/bsd/libpcap/dist/README
@@ -10,15 +10,15 @@ Please send inquiries/comments/reports to:
Anonymous Git is available via:
git clone git://bpf.tcpdump.org/libpcap
-Version 1.x.y of LIBPCAP can be retrieved with the CVS tag "libpcap_1_{x}rel{y}":
- cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master checkout -r libpcap_1_{x}rel{y} libpcap
+Please submit patches by forking the branch on GitHub at
-Please submit patches against the master copy to the libpcap project on
-sourceforge.net.
+ http://github.com/the-tcpdump-group/libpcap/tree/master
+
+and issuing a pull request.
formerly from Lawrence Berkeley National Laboratory
Network Research Group <libpcap@ee.lbl.gov>
- ftp://ftp.ee.lbl.gov/libpcap.tar.Z (0.4)
+ ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
This directory contains source code for libpcap, a system-independent
interface for user-level packet capture. libpcap provides a portable
@@ -91,15 +91,18 @@ a particular release of libpcap.
Problems, bugs, questions, desirable enhancements, etc. should be sent
to the address "tcpdump-workers@lists.tcpdump.org". Bugs, support
-requests, and feature requests may also be submitted on the SourceForge
-site for libpcap at
+requests, and feature requests may also be submitted on the GitHub issue
+tracker for libpcap at
- http://sourceforge.net/projects/libpcap/
+ https://github.com/the-tcpdump-group/libpcap/issues
Source code contributions, etc. should be sent to the email address
-submitted as patches on the SourceForge site for libpcap.
+above or submitted by forking the branch on GitHub at
+
+ http://github.com/the-tcpdump-group/libpcap/tree/master
+
+and issuing a pull request.
-Current versions can be found at www.tcpdump.org, or the SourceForge
-site for libpcap.
+Current versions can be found at www.tcpdump.org.
- The TCPdump team
diff --git a/external/bsd/libpcap/dist/README.aix b/external/bsd/libpcap/dist/README.aix
index b32fa5868dd..74cd9af6514 100644
--- a/external/bsd/libpcap/dist/README.aix
+++ b/external/bsd/libpcap/dist/README.aix
@@ -19,11 +19,13 @@ Using BPF:
possible a description of the symptoms, including indications of the
network link-layer type being wrong or time stamps being wrong).
- If you fix the problems yourself, please submit a patch to
+ If you fix the problems yourself, please submit a patch by forking
+ the branch at
- http://sourceforge.net/projects/libpcap/
+ https://github.com/the-tcpdump-group/libpcap/issues
- so we can incorporate them into the next release.
+ and issuing a pull request, so we can incorporate the fixes into the
+ next release.
If you don't fix the problems yourself, you can, as a workaround,
make libpcap use DLPI instead of BPF.
diff --git a/external/bsd/libpcap/dist/README.dag b/external/bsd/libpcap/dist/README.dag
index acf97edf8d0..accae7c3827 100644
--- a/external/bsd/libpcap/dist/README.dag
+++ b/external/bsd/libpcap/dist/README.dag
@@ -96,12 +96,20 @@ implemented.
DAG cards by default capture entire packets including the L2
CRC/FCS. If the card is not configured to discard the CRC/FCS, this
can confuse applications that use libpcap if they're not prepared for
-packets to have an FCS. Libpcap now reads the environment variable
-ERF_FCS_BITS to determine how many bits of CRC/FCS to strip from the
-end of the captured frame. This defaults to 32 for use with
-Ethernet. If the card is configured to strip the CRC/FCS, then set
-ERF_FCS_BITS=0. If used with a HDLC/PoS/PPP/Frame Relay link with 16
-bit CRC/FCS, then set ERF_FCS_BITS=16.
+packets to have an FCS.
+
+Libpcap now reads the environment variable ERF_FCS_BITS to determine
+how many bits of CRC/FCS to strip from the end of the captured
+frame. This defaults to 32 for use with Ethernet. If the card is
+configured to strip the CRC/FCS, then set ERF_FCS_BITS=0. If used with
+a HDLC/PoS/PPP/Frame Relay link with 16 bit CRC/FCS, then set
+ERF_FCS_BITS=16.
+
+If you wish to create a pcap file that DOES contain the Ethernet FCS,
+specify the environment variable ERF_DONT_STRIP_FCS. This will cause
+the existing FCS to be captured into the pcap file. Note some
+applications may incorrectly report capture errors or oversize packets
+when reading these files.
----------------------------------------------------------------------
diff --git a/external/bsd/libpcap/dist/VERSION b/external/bsd/libpcap/dist/VERSION
index f0bb29e7638..4cda8f19edc 100644
--- a/external/bsd/libpcap/dist/VERSION
+++ b/external/bsd/libpcap/dist/VERSION
@@ -1 +1 @@
-1.3.0
+1.5.2
diff --git a/external/bsd/libpcap/dist/aclocal.m4 b/external/bsd/libpcap/dist/aclocal.m4
index 58475b402c4..5a11a127486 100644
--- a/external/bsd/libpcap/dist/aclocal.m4
+++ b/external/bsd/libpcap/dist/aclocal.m4
@@ -38,16 +38,15 @@ dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
dnl and AC_LBL_C_INIT at the top level.
dnl
AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
- [AC_PREREQ(2.50)
+[
AC_BEFORE([$0], [AC_LBL_C_INIT])
AC_BEFORE([$0], [AC_PROG_CC])
AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
AC_BEFORE([$0], [AC_LBL_DEVEL])
AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
- $1="-O"
- $2=""
+ $1=""
if test "${srcdir}" != "." ; then
- $2="-I\$(srcdir)"
+ $1="-I\$(srcdir)"
fi
if test "${CFLAGS+set}" = set; then
LBL_CFLAGS="$CFLAGS"
@@ -73,9 +72,15 @@ AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
dnl
dnl Determine which compiler we're using (cc or gcc)
dnl If using gcc, determine the version number
-dnl If using cc, require that it support ansi prototypes
-dnl If using gcc, use -O2 (otherwise use -O)
-dnl If using cc, explicitly specify /usr/local/include
+dnl If using cc:
+dnl require that it support ansi prototypes
+dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
+dnl do that ourselves for gcc)
+dnl add -g flags, as appropriate
+dnl explicitly specify /usr/local/include
+dnl
+dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
+dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
dnl
dnl usage:
dnl
@@ -87,102 +92,106 @@ dnl $1 (copt set)
dnl $2 (incls set)
dnl CC
dnl LDFLAGS
-dnl ac_cv_lbl_gcc_vers
dnl LBL_CFLAGS
dnl
AC_DEFUN(AC_LBL_C_INIT,
- [AC_PREREQ(2.50)
+[
AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
AC_BEFORE([$0], [AC_LBL_DEVEL])
AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
if test "$GCC" = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_lbl_gcc_vers=2
- $1="-O2"
- else
- AC_MSG_CHECKING(gcc version)
- AC_CACHE_VAL(ac_cv_lbl_gcc_vers,
- ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
- sed -e '/^gcc version /!d' \
- -e 's/^gcc version //' \
- -e 's/ .*//' -e 's/^[[[^0-9]]]*//' \
- -e 's/\..*//'`)
- AC_MSG_RESULT($ac_cv_lbl_gcc_vers)
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- $1="-O2"
- fi
- fi
+ #
+ # -Werror forces warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
else
- AC_MSG_CHECKING(that $CC handles ansi prototypes)
- AC_CACHE_VAL(ac_cv_lbl_cc_ansi_prototypes,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_lbl_cc_ansi_prototypes=yes,
- ac_cv_lbl_cc_ansi_prototypes=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_ansi_prototypes)
- if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
- case "$host_os" in
-
- hpux*)
- AC_MSG_CHECKING(for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE))
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- AC_CACHE_VAL(ac_cv_lbl_cc_hpux_cc_aa,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_lbl_cc_hpux_cc_aa=yes,
- ac_cv_lbl_cc_hpux_cc_aa=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_hpux_cc_aa)
- if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- CFLAGS="$savedcflags"
- $1="-Aa $$1"
- AC_DEFINE(_HPUX_SOURCE,1,[needed on HP-UX])
- ;;
-
- osf*)
- AC_MSG_CHECKING(for ansi mode in DEC compiler ($CC -std1))
- savedcflags="$CFLAGS"
- CFLAGS="-std1"
- AC_CACHE_VAL(ac_cv_lbl_cc_osf1_cc_std1,
- AC_TRY_COMPILE(
- [#include <sys/types.h>],
- [int frob(int, char *)],
- ac_cv_lbl_cc_osf1_cc_std1=yes,
- ac_cv_lbl_cc_osf1_cc_std1=no))
- AC_MSG_RESULT($ac_cv_lbl_cc_osf1_cc_std1)
- if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
- AC_MSG_ERROR(see the INSTALL doc for more info)
- fi
- CFLAGS="$savedcflags"
- $1="-std1 $$1"
- ;;
-
- *)
- AC_MSG_ERROR(see the INSTALL doc for more info)
- ;;
- esac
- fi
$2="$$2 -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$host_os" in
+ darwin*)
+ #
+ # This is assumed either to be GCC or clang, both
+ # of which use -Werror to force warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
+ ;;
+
+ hpux*)
+ #
+ # HP C, which is what we presume we're using, doesn't
+ # exit with a non-zero exit status if we hand it an
+ # invalid -W flag, can't be forced to do so even with
+ # +We, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ ;;
+
irix*)
+ #
+ # MIPS C, which is what we presume we're using, doesn't
+ # necessarily exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # It also, apparently, defaults to "char" being
+ # unsigned, unlike most other C implementations;
+ # I suppose we could say "signed char" whenever
+ # we want to guarantee a signed "char", but let's
+ # just force signed chars.
+ #
+ # -xansi is normally the default, but the
+ # configure script was setting it; perhaps -cckr
+ # was the default in the Old Days. (Then again,
+ # that would probably be for backwards compatibility
+ # in the days when ANSI C was Shiny and New, i.e.
+ # 1989 and the early '90's, so maybe we can just
+ # drop support for those compilers.)
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
$1="$$1 -xansi -signed -g3"
;;
osf*)
- #
+ #
# Presumed to be DEC OSF/1, Digital UNIX, or
# Tru64 UNIX.
#
+ # The DEC C compiler, which is what we presume we're
+ # using, doesn't exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
$1="$$1 -g3"
;;
+ solaris*)
+ #
+ # Assumed to be Sun C, which requires -errwarn to force
+ # warnings to be treated as errors.
+ #
+ ac_lbl_cc_force_warning_errors=-errwarn
+ ;;
+
ultrix*)
AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
@@ -199,10 +208,179 @@ AC_DEFUN(AC_LBL_C_INIT,
fi
;;
esac
+ $1="$$1 -O"
fi
])
dnl
+dnl Check whether, if you pass an unknown warning option to the
+dnl compiler, it fails or just prints a warning message and succeeds.
+dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
+dnl to force an error if it would otherwise just print a warning message
+dnl and succeed.
+dnl
+AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
+ [
+ AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+ AC_TRY_COMPILE(
+ [],
+ [return 0],
+ [
+ AC_MSG_RESULT([no])
+ #
+ # We're assuming this is clang, where
+ # -Werror=unknown-warning-option is the appropriate
+ # option to force the compiler to fail.
+ #
+ ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+ ],
+ [
+ AC_MSG_RESULT([yes])
+ ])
+ CFLAGS="$save_CFLAGS"
+ ])
+
+dnl
+dnl Check whether the compiler option specified as the second argument
+dnl is supported by the compiler and, if so, add it to the macro
+dnl specified as the first argument
+dnl
+AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
+ [
+ AC_MSG_CHECKING([whether the compiler supports the $2 option])
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
+ AC_TRY_COMPILE(
+ [],
+ [return 0],
+ [
+ AC_MSG_RESULT([yes])
+ CFLAGS="$save_CFLAGS"
+ $1="$$1 $2"
+ ],
+ [
+ AC_MSG_RESULT([no])
+ CFLAGS="$save_CFLAGS"
+ ])
+ ])
+
+dnl
+dnl Check whether the compiler supports an option to generate
+dnl Makefile-style dependency lines
+dnl
+dnl GCC uses -M for this. Non-GCC compilers that support this
+dnl use a variety of flags, including but not limited to -M.
+dnl
+dnl We test whether the flag in question is supported, as older
+dnl versions of compilers might not support it.
+dnl
+dnl We don't try all the possible flags, just in case some flag means
+dnl "generate dependencies" on one compiler but means something else
+dnl on another compiler.
+dnl
+dnl Most compilers that support this send the output to the standard
+dnl output by default. IBM's XLC, however, supports -M but sends
+dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
+dnl to work around that, so we don't bother with XLC.
+dnl
+AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
+ [
+ AC_MSG_CHECKING([whether the compiler supports generating dependencies])
+ if test "$GCC" = yes ; then
+ #
+ # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
+ # though it's not); we assume that, in this case, the flag
+ # would be -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ else
+ #
+ # Not GCC or a compiler deemed to be GCC; what platform is
+ # this? (We're assuming that if the compiler isn't GCC
+ # it's the compiler from the vendor of the OS; that won't
+ # necessarily be true for x86 platforms, where it might be
+ # the Intel C compiler.)
+ #
+ case "$host_os" in
+
+ irix*|osf*|darwin*)
+ #
+ # MIPS C for IRIX, DEC C, and clang all use -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ ;;
+
+ solaris*)
+ #
+ # Sun C uses -xM.
+ #
+ ac_lbl_dependency_flag="-xM"
+ ;;
+
+ hpux*)
+ #
+ # HP's older C compilers don't support this.
+ # HP's newer C compilers support this with
+ # either +M or +Make; the older compilers
+ # interpret +M as something completely
+ # different, so we use +Make so we don't
+ # think it works with the older compilers.
+ #
+ ac_lbl_dependency_flag="+Make"
+ ;;
+
+ *)
+ #
+ # Not one of the above; assume no support for
+ # generating dependencies.
+ #
+ ac_lbl_dependency_flag=""
+ ;;
+ esac
+ fi
+
+ #
+ # Is ac_lbl_dependency_flag defined and, if so, does the compiler
+ # complain about it?
+ #
+ # Note: clang doesn't seem to exit with an error status when handed
+ # an unknown non-warning error, even if you pass it
+ # -Werror=unknown-warning-option. However, it always supports
+ # -M, so the fact that this test always succeeds with clang
+ # isn't an issue.
+ #
+ if test ! -z "$ac_lbl_dependency_flag"; then
+ AC_LANG_CONFTEST(
+ [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
+ echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
+ if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
+ AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
+ DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
+ MKDEP='${srcdir}/mkdep'
+ else
+ AC_MSG_RESULT([no])
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+ rm -rf conftest*
+ else
+ AC_MSG_RESULT([no])
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+ AC_SUBST(DEPENDENCY_CFLAG)
+ AC_SUBST(MKDEP)
+ ])
+
+dnl
dnl Determine what options are needed to build a shared library
dnl
dnl usage:
@@ -256,7 +434,7 @@ AC_DEFUN(AC_LBL_SHLIBS_INIT,
sparc64*)
case "$host_os" in
- freebsd*)
+ freebsd*|openbsd*)
PIC_OPT=-fPIC
;;
esac
@@ -458,7 +636,22 @@ dnl Check for flex, default to lex
dnl Require flex 2.4 or higher
dnl Check for bison, default to yacc
dnl Default to lex/yacc if both flex and bison are not available
-dnl Define the yy prefix string if using flex and bison
+dnl
+dnl If we're using flex and bison, pass -P to flex and -p to bison
+dnl to define a prefix string for the lexer and parser
+dnl
+dnl If we're not using flex and bison, don't pass those options
+dnl (as they might not work - although if "lex" is a wrapper for
+dnl Flex and "yacc" is a wrapper for Bison, they will work), and
+dnl define NEED_YYPARSE_WRAPPER (we *CANNOT* use YYBISON to check
+dnl whether the wrapper is needed, as some people apparently, for
+dnl some unknown reason, choose to use --without-flex and
+dnl --without-bison on systems that have Flex and Bison, which
+dnl means that the "yacc" they end up using is a wrapper that
+dnl runs "bison -y", and at least some versions of Bison define
+dnl YYBISON even if run with "-y", so we end up not compiling
+dnl the yyparse wrapper and end up with a libpcap that doesn't
+dnl define pcap_parse())
dnl
dnl usage:
dnl
@@ -510,6 +703,8 @@ AC_DEFUN(AC_LBL_LEX_AND_YACC,
if test "$$1" = flex -a -n "$3" ; then
$1="$$1 -P$3"
$2="$$2 -p $3"
+ else
+ AC_DEFINE(NEED_YYPARSE_WRAPPER,1,[if we need a pcap_parse wrapper around yyparse])
fi])
dnl
@@ -751,9 +946,8 @@ EOF
fi])
dnl
-dnl If using gcc and the file .devel exists:
-dnl Compile with -g (if supported) and -Wall
-dnl If using gcc 2 or later, do extra prototype checking
+dnl If the file .devel exists:
+dnl Add some warning flags if the compiler supports them
dnl If an os prototype include exists, symlink os-proto.h to it
dnl
dnl usage:
@@ -772,27 +966,24 @@ AC_DEFUN(AC_LBL_DEVEL,
$1="$$1 ${LBL_CFLAGS}"
fi
if test -f .devel ; then
- if test "$GCC" = yes ; then
- if test "${LBL_CFLAGS+set}" != set; then
- if test "$ac_cv_prog_cc_g" = yes ; then
- $1="-g $$1"
- fi
- $1="$$1 -Wall"
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- $1="$$1 -Wmissing-prototypes -Wstrict-prototypes"
- fi
- fi
- else
- case "$host_os" in
-
- irix6*)
- V_CCOPT="$V_CCOPT -n32"
- ;;
-
- *)
- ;;
- esac
+ #
+ # Skip all the warning option stuff on some compilers.
+ #
+ if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
+ AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
+ AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
fi
+ AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
+ #
+ # We used to set -n32 for IRIX 6 when not using GCC (presumed
+ # to mean that we're using MIPS C or MIPSpro C); it specified
+ # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
+ # not sure why that would be something to do *only* with a
+ # .devel file; why should the ABI for which we produce code
+ # depend on .devel?
+ #
os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
name="lbl/os-$os.h"
if test -f $name ; then
@@ -929,7 +1120,7 @@ dnl
AC_DEFUN(AC_C___ATTRIBUTE__, [
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
-AC_COMPILE_IFELSE(
+AC_COMPILE_IFELSE([
AC_LANG_SOURCE([[
#include <stdlib.h>
@@ -946,19 +1137,86 @@ main(int argc, char **argv)
{
foo();
}
- ]]),
+ ]])],
ac_cv___attribute__=yes,
ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
- V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
else
+ #
+ # We can't use __attribute__, so we can't use __attribute__((unused)),
+ # so we define _U_ to an empty string.
+ #
V_DEFS="$V_DEFS -D_U_=\"\""
fi
AC_MSG_RESULT($ac_cv___attribute__)
])
dnl
+dnl Test whether __attribute__((unused)) can be used without warnings
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
+AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
+AC_CACHE_VAL(ac_cv___attribute___unused, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc __attribute((unused)), char **argv __attribute((unused)))
+{
+ printf("Hello, world!\n");
+ return 0;
+}
+ ]])],
+ac_cv___attribute___unused=yes,
+ac_cv___attribute___unused=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___unused" = "yes"; then
+ V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
+else
+ V_DEFS="$V_DEFS -D_U_=\"\""
+fi
+AC_MSG_RESULT($ac_cv___attribute___unused)
+])
+
+dnl
+dnl Test whether __attribute__((format)) can be used without warnings
+dnl
+
+AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
+AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
+AC_CACHE_VAL(ac_cv___attribute___format, [
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#include <stdlib.h>
+
+extern int foo(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ foo("%s", "test");
+}
+ ]])],
+ac_cv___attribute___format=yes,
+ac_cv___attribute___format=no)])
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___format" = "yes"; then
+ AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
+ [define if your compiler allows __attribute__((format)) without a warning])
+fi
+AC_MSG_RESULT($ac_cv___attribute___format)
+])
+
+dnl
dnl Checks to see if tpacket_stats is defined in linux/if_packet.h
dnl If so then pcap-linux.c can use this to report proper statistics.
dnl
diff --git a/external/bsd/libpcap/dist/bpf_image.c b/external/bsd/libpcap/dist/bpf_image.c
index c9dadecc1aa..d76642f9e81 100644
--- a/external/bsd/libpcap/dist/bpf_image.c
+++ b/external/bsd/libpcap/dist/bpf_image.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf_image.c,v 1.1.1.3 2013/04/06 15:57:47 christos Exp $ */
+/* $NetBSD: bpf_image.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1994, 1995, 1996
@@ -294,11 +294,14 @@ bpf_image(p, n)
break;
}
(void)snprintf(operand, sizeof operand, fmt, v);
- (void)snprintf(image, sizeof image,
- (BPF_CLASS(p->code) == BPF_JMP &&
- BPF_OP(p->code) != BPF_JA) ?
- "(%03d) %-8s %-16s jt %d\tjf %d"
- : "(%03d) %-8s %s",
- n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
+ if (BPF_CLASS(p->code) == BPF_JMP && BPF_OP(p->code) != BPF_JA) {
+ (void)snprintf(image, sizeof image,
+ "(%03d) %-8s %-16s jt %d\tjf %d",
+ n, op, operand, n + 1 + p->jt, n + 1 + p->jf);
+ } else {
+ (void)snprintf(image, sizeof image,
+ "(%03d) %-8s %s",
+ n, op, operand);
+ }
return image;
}
diff --git a/external/bsd/libpcap/dist/config.h.in b/external/bsd/libpcap/dist/config.h.in
index bd5177cda8c..c6bc68eb2a6 100644
--- a/external/bsd/libpcap/dist/config.h.in
+++ b/external/bsd/libpcap/dist/config.h.in
@@ -58,6 +58,15 @@
/* if libnl exists and is version 2.x */
#undef HAVE_LIBNL_2_x
+/* if libnl exists and is version 3.x */
+#undef HAVE_LIBNL_3_x
+
+/* libnl has NLE_FAILURE */
+#undef HAVE_LIBNL_NLE
+
+/* libnl has new-style socket api */
+#undef HAVE_LIBNL_SOCKETS
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
@@ -211,6 +220,9 @@
/* path for device for USB sniffing */
#undef LINUX_USB_MON_DEV
+/* if we need a pcap_parse wrapper around yyparse */
+#undef NEED_YYPARSE_WRAPPER
+
/* Define to 1 if netinet/ether.h declares `ether_hostton' */
#undef NETINET_ETHER_H_DECLARES_ETHER_HOSTTON
@@ -250,6 +262,9 @@
/* target host supports canusb */
#undef PCAP_SUPPORT_CANUSB
+/* support D-Bus sniffing */
+#undef PCAP_SUPPORT_DBUS
+
/* target host supports netfilter sniffing */
#undef PCAP_SUPPORT_NETFILTER
@@ -259,18 +274,23 @@
/* include ACN support */
#undef SITA
+/* if struct sockaddr_hci has hci_channel member */
+#undef SOCKADDR_HCI_HAS_HCI_CHANNEL
+
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Enable parser debugging */
#undef YYDEBUG
+/* Enable large inode numbers on Mac OS X 10.5. */
+#ifndef _DARWIN_USE_64_BIT_INODE
+# define _DARWIN_USE_64_BIT_INODE 1
+#endif
+
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
-/* needed on HP-UX */
-#undef _HPUX_SOURCE
-
/* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
#undef _LARGEFILE_SOURCE
@@ -280,6 +300,9 @@
/* define on AIX to get certain functions */
#undef _SUN
+/* define if your compiler allows __attribute__((format)) without a warning */
+#undef __ATTRIBUTE___FORMAT_OK
+
/* to handle Ultrix compilers that don't support const in prototypes */
#undef const
diff --git a/external/bsd/libpcap/dist/configure b/external/bsd/libpcap/dist/configure
index 29e0f35eecc..be87668692f 100755
--- a/external/bsd/libpcap/dist/configure
+++ b/external/bsd/libpcap/dist/configure
@@ -1,12 +1,9 @@
#! /bin/sh
-# From configure.in Revision: 1.168 .
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67.
+# Generated by GNU Autoconf 2.69.
#
#
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
@@ -90,6 +87,7 @@ fi
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -134,6 +132,31 @@ export LANGUAGE
# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
emulate sh
@@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
else
exitcode=1; echo positional parameters were not saved.
fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -212,14 +236,25 @@ IFS=$as_save_IFS
if test "x$CONFIG_SHELL" != x; then :
- # We cannot yet assume a decent shell, so we have to provide a
- # neutralization value for shells without unset; and this also
- # works around shells that cannot unset nonexistent variables.
- BASH_ENV=/dev/null
- ENV=/dev/null
- (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
fi
if test x$as_have_required = xno; then :
@@ -321,6 +356,14 @@ $as_echo X"$as_dir" |
} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -442,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits
chmod +x "$as_me.lineno" ||
{ $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
# Don't try to exec as it changes $[0], causing all sort of problems
# (the dirname of $[0] is not the place where we might find the
# original and so on. Autoconf is especially sensitive to this).
@@ -476,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
+ # In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@@ -497,28 +544,8 @@ else
as_mkdir_p=false
fi
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -596,6 +623,9 @@ ac_subst_vars='LTLIBOBJS
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
+DBUS_SRC
+PCAP_SUPPORT_DBUS
+PKGCONFIG
CAN_SRC
PCAP_SUPPORT_CAN
CANUSB_SRC
@@ -621,6 +651,9 @@ V_INCLS
V_FINDALLDEVS
V_DEFS
V_CCOPT
+MKDEP
+DEPENDENCY_CFLAG
+LN_S
AR
RANLIB
V_YACC
@@ -710,9 +743,11 @@ with_snf_libraries
with_flex
with_bison
enable_universal
+enable_shared
enable_bluetooth
enable_canusb
enable_can
+enable_dbus
'
ac_precious_vars='build_alias
host_alias
@@ -1127,7 +1162,7 @@ Try \`$0 --help' for more information"
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
;;
esac
@@ -1178,8 +1213,6 @@ target=$target_alias
if test "x$host_alias" != x; then
if test "x$build_alias" = x; then
cross_compiling=maybe
- $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used" >&2
elif test "x$build_alias" != "x$host_alias"; then
cross_compiling=yes
fi
@@ -1344,13 +1377,16 @@ Optional Features:
--enable-optimizer-dbg build optimizer debugging code
--enable-yydebug build parser debugging code
--disable-universal don't build universal on OS X
+ --enable-shared build shared libraries [default=yes, if support
+ available]
--enable-bluetooth enable Bluetooth support [default=yes, if support
available]
--enable-canusb enable canusb support [default=yes, if support
available]
-
--enable-can enable CAN support [default=yes, if support
available]
+ --enable-dbus enable D-Bus capture support [default=yes, if
+ support available]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1452,9 +1488,9 @@ test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
configure
-generated by GNU Autoconf 2.67
+generated by GNU Autoconf 2.69
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
@@ -1498,7 +1534,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_compile
@@ -1535,7 +1571,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_cpp
@@ -1548,10 +1584,10 @@ fi
ac_fn_c_check_header_mongrel ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if eval "test \"\${$3+set}\"" = set; then :
+ if eval \${$3+:} false; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
@@ -1614,7 +1650,7 @@ $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=\$ac_header_compiler"
@@ -1623,7 +1659,7 @@ eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_mongrel
@@ -1664,7 +1700,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_run
@@ -1678,7 +1714,7 @@ ac_fn_c_check_header_compile ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1696,7 +1732,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_header_compile
@@ -1709,7 +1745,7 @@ ac_fn_c_check_type ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
eval "$3=no"
@@ -1750,7 +1786,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_type
@@ -1781,7 +1817,7 @@ $as_echo "$ac_try_echo"; } >&5
test ! -s conftest.err
} && test -s conftest$ac_exeext && {
test "$cross_compiling" = yes ||
- $as_test_x conftest$ac_exeext
+ test -x conftest$ac_exeext
}; then :
ac_retval=0
else
@@ -1795,7 +1831,7 @@ fi
# interfere with the next link command; also delete a directory that is
# left behind by Apple's compiler. We do this before executing the actions.
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_try_link
@@ -1808,7 +1844,7 @@ ac_fn_c_check_func ()
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1863,7 +1899,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_func
@@ -1878,7 +1914,7 @@ ac_fn_c_check_decl ()
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1909,7 +1945,7 @@ fi
eval ac_res=\$$3
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
cat >config.log <<_ACEOF
@@ -1917,7 +1953,7 @@ This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by $as_me, which was
-generated by GNU Autoconf 2.67. Invocation command line was
+generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2175,7 +2211,7 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;}
|| { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
done
@@ -2300,7 +2336,7 @@ $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
-if test "${ac_cv_build+set}" = set; then :
+if ${ac_cv_build+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_build_alias=$build_alias
@@ -2316,7 +2352,7 @@ fi
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
@@ -2334,7 +2370,7 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
-if test "${ac_cv_host+set}" = set; then :
+if ${ac_cv_host+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "x$host_alias" = x; then
@@ -2349,7 +2385,7 @@ fi
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
@@ -2367,7 +2403,7 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
$as_echo_n "checking target system type... " >&6; }
-if test "${ac_cv_target+set}" = set; then :
+if ${ac_cv_target+:} false; then :
$as_echo_n "(cached) " >&6
else
if test "x$target_alias" = x; then
@@ -2382,7 +2418,7 @@ fi
$as_echo "$ac_cv_target" >&6; }
case $ac_cv_target in
*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5 ;;
+*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
esac
target=$ac_cv_target
ac_save_IFS=$IFS; IFS='-'
@@ -2417,10 +2453,9 @@ if test "${with_gcc+set}" = set; then :
withval=$with_gcc;
fi
- V_CCOPT="-O"
- V_INCLS=""
+ V_CCOPT=""
if test "${srcdir}" != "." ; then
- V_INCLS="-I\$(srcdir)"
+ V_CCOPT="-I\$(srcdir)"
fi
if test "${CFLAGS+set}" = set; then
LBL_CFLAGS="$CFLAGS"
@@ -2433,7 +2468,7 @@ fi
set dummy shlicc2; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_SHLICC2+set}" = set; then :
+if ${ac_cv_prog_SHLICC2+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$SHLICC2"; then
@@ -2445,7 +2480,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_SHLICC2="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2489,7 +2524,7 @@ if test -n "$ac_tool_prefix"; then
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2501,7 +2536,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2529,7 +2564,7 @@ if test -z "$ac_cv_prog_CC"; then
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
@@ -2541,7 +2576,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2582,7 +2617,7 @@ if test -z "$CC"; then
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2594,7 +2629,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2622,7 +2657,7 @@ if test -z "$CC"; then
set dummy cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2635,7 +2670,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
@@ -2681,7 +2716,7 @@ if test -z "$CC"; then
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$CC"; then
@@ -2693,7 +2728,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2725,7 +2760,7 @@ do
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_CC"; then
@@ -2737,7 +2772,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -2780,7 +2815,7 @@ fi
test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
@@ -2895,7 +2930,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
@@ -2938,7 +2973,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
@@ -2997,7 +3032,7 @@ $as_echo "$ac_try_echo"; } >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
fi
fi
@@ -3008,7 +3043,7 @@ rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
-if test "${ac_cv_objext+set}" = set; then :
+if ${ac_cv_objext+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3049,7 +3084,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
@@ -3059,7 +3094,7 @@ OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+if ${ac_cv_c_compiler_gnu+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3096,7 +3131,7 @@ ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then :
+if ${ac_cv_prog_cc_g+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_save_c_werror_flag=$ac_c_werror_flag
@@ -3174,7 +3209,7 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
+if ${ac_cv_prog_cc_c89+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_prog_cc_c89=no
@@ -3183,8 +3218,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdarg.h>
#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3274,163 +3308,106 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test "$GCC" = yes ; then
- if test "$SHLICC2" = yes ; then
- ac_cv_lbl_gcc_vers=2
- V_CCOPT="-O2"
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking gcc version" >&5
-$as_echo_n "checking gcc version... " >&6; }
- if test "${ac_cv_lbl_gcc_vers+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
- ac_cv_lbl_gcc_vers=`$CC -v 2>&1 | \
- sed -e '/^gcc version /!d' \
- -e 's/^gcc version //' \
- -e 's/ .*//' -e 's/^[^0-9]*//' \
- -e 's/\..*//'`
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_gcc_vers" >&5
-$as_echo "$ac_cv_lbl_gcc_vers" >&6; }
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- V_CCOPT="-O2"
- fi
- fi
+ #
+ # -Werror forces warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking that $CC handles ansi prototypes" >&5
-$as_echo_n "checking that $CC handles ansi prototypes... " >&6; }
- if test "${ac_cv_lbl_cc_ansi_prototypes+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-int
-main ()
-{
-int frob(int, char *)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_ansi_prototypes=yes
-else
- ac_cv_lbl_cc_ansi_prototypes=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_ansi_prototypes" >&5
-$as_echo "$ac_cv_lbl_cc_ansi_prototypes" >&6; }
- if test $ac_cv_lbl_cc_ansi_prototypes = no ; then
- case "$host_os" in
-
- hpux*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)" >&5
-$as_echo_n "checking for HP-UX ansi compiler ($CC -Aa -D_HPUX_SOURCE)... " >&6; }
- savedcflags="$CFLAGS"
- CFLAGS="-Aa -D_HPUX_SOURCE $CFLAGS"
- if test "${ac_cv_lbl_cc_hpux_cc_aa+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-int
-main ()
-{
-int frob(int, char *)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_hpux_cc_aa=yes
-else
- ac_cv_lbl_cc_hpux_cc_aa=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_hpux_cc_aa" >&5
-$as_echo "$ac_cv_lbl_cc_hpux_cc_aa" >&6; }
- if test $ac_cv_lbl_cc_hpux_cc_aa = no ; then
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-Aa $V_CCOPT"
-
-$as_echo "#define _HPUX_SOURCE 1" >>confdefs.h
-
- ;;
-
- osf*)
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ansi mode in DEC compiler ($CC -std1)" >&5
-$as_echo_n "checking for ansi mode in DEC compiler ($CC -std1)... " >&6; }
- savedcflags="$CFLAGS"
- CFLAGS="-std1"
- if test "${ac_cv_lbl_cc_osf1_cc_std1+set}" = set; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/types.h>
-int
-main ()
-{
-int frob(int, char *)
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_lbl_cc_osf1_cc_std1=yes
-else
- ac_cv_lbl_cc_osf1_cc_std1=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_cc_osf1_cc_std1" >&5
-$as_echo "$ac_cv_lbl_cc_osf1_cc_std1" >&6; }
- if test $ac_cv_lbl_cc_osf1_cc_std1 = no ; then
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- fi
- CFLAGS="$savedcflags"
- V_CCOPT="-std1 $V_CCOPT"
- ;;
-
- *)
- as_fn_error $? "see the INSTALL doc for more info" "$LINENO" 5
- ;;
- esac
- fi
V_INCLS="$V_INCLS -I/usr/local/include"
LDFLAGS="$LDFLAGS -L/usr/local/lib"
case "$host_os" in
+ darwin*)
+ #
+ # This is assumed either to be GCC or clang, both
+ # of which use -Werror to force warnings to be errors.
+ #
+ ac_lbl_cc_force_warning_errors=-Werror
+ ;;
+
+ hpux*)
+ #
+ # HP C, which is what we presume we're using, doesn't
+ # exit with a non-zero exit status if we hand it an
+ # invalid -W flag, can't be forced to do so even with
+ # +We, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ ;;
+
irix*)
+ #
+ # MIPS C, which is what we presume we're using, doesn't
+ # necessarily exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # It also, apparently, defaults to "char" being
+ # unsigned, unlike most other C implementations;
+ # I suppose we could say "signed char" whenever
+ # we want to guarantee a signed "char", but let's
+ # just force signed chars.
+ #
+ # -xansi is normally the default, but the
+ # configure script was setting it; perhaps -cckr
+ # was the default in the Old Days. (Then again,
+ # that would probably be for backwards compatibility
+ # in the days when ANSI C was Shiny and New, i.e.
+ # 1989 and the early '90's, so maybe we can just
+ # drop support for those compilers.)
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
V_CCOPT="$V_CCOPT -xansi -signed -g3"
;;
osf*)
- #
+ #
# Presumed to be DEC OSF/1, Digital UNIX, or
# Tru64 UNIX.
#
+ # The DEC C compiler, which is what we presume we're
+ # using, doesn't exit with a non-zero exit status if we
+ # hand it an invalid -W flag, can't be forced to do
+ # so, and doesn't handle GCC-style -W flags, so we
+ # don't want to try using GCC-style -W flags.
+ #
+ ac_lbl_cc_dont_try_gcc_dashW=yes
+ #
+ # -g is equivalent to -g2, which turns off
+ # optimization; we choose -g3, which generates
+ # debugging information but doesn't turn off
+ # optimization (even if the optimization would
+ # cause inaccuracies in debugging).
+ #
V_CCOPT="$V_CCOPT -g3"
;;
+ solaris*)
+ #
+ # Assumed to be Sun C, which requires -errwarn to force
+ # warnings to be treated as errors.
+ #
+ ac_lbl_cc_force_warning_errors=-errwarn
+ ;;
+
ultrix*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that Ultrix $CC hacks const in prototypes" >&5
$as_echo_n "checking that Ultrix $CC hacks const in prototypes... " >&6; }
- if test "${ac_cv_lbl_cc_const_proto+set}" = set; then :
+ if ${ac_cv_lbl_cc_const_proto+:} false; then :
$as_echo_n "(cached) " >&6
else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <sys/types.h>
int
@@ -3459,6 +3436,7 @@ $as_echo "#define const /**/" >>confdefs.h
fi
;;
esac
+ V_CCOPT="$V_CCOPT -O"
fi
@@ -3499,7 +3477,7 @@ $as_echo "#define const /**/" >>confdefs.h
sparc64*)
case "$host_os" in
- freebsd*)
+ freebsd*|openbsd*)
PIC_OPT=-fPIC
;;
esac
@@ -3612,7 +3590,7 @@ $as_echo "#define const /**/" >>confdefs.h
$as_echo_n "checking for inline... " >&6; }
save_CFLAGS="$CFLAGS"
CFLAGS="$V_CCOPT"
- if test "${ac_cv_lbl_inline+set}" = set; then :
+ if ${ac_cv_lbl_inline+:} false; then :
$as_echo_n "(cached) " >&6
else
@@ -3673,13 +3651,14 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5
$as_echo_n "checking for __attribute__... " >&6; }
-if test "${ac_cv___attribute__+set}" = set; then :
+if ${ac_cv___attribute__+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+
#include <stdlib.h>
static void foo(void) __attribute__ ((noreturn));
@@ -3709,13 +3688,101 @@ if test "$ac_cv___attribute__" = "yes"; then
$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h
- V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
else
+ #
+ # We can't use __attribute__, so we can't use __attribute__((unused)),
+ # so we define _U_ to an empty string.
+ #
V_DEFS="$V_DEFS -D_U_=\"\""
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5
$as_echo "$ac_cv___attribute__" >&6; }
+if test "$ac_cv___attribute__" = "yes"; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((unused)) can be used without warnings" >&5
+$as_echo_n "checking whether __attribute__((unused)) can be used without warnings... " >&6; }
+if ${ac_cv___attribute___unused+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc __attribute((unused)), char **argv __attribute((unused)))
+{
+ printf("Hello, world!\n");
+ return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___unused=yes
+else
+ ac_cv___attribute___unused=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___unused" = "yes"; then
+ V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
+else
+ V_DEFS="$V_DEFS -D_U_=\"\""
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___unused" >&5
+$as_echo "$ac_cv___attribute___unused" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether __attribute__((format)) can be used without warnings" >&5
+$as_echo_n "checking whether __attribute__((format)) can be used without warnings... " >&6; }
+if ${ac_cv___attribute___format+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+#include <stdlib.h>
+
+extern int foo(const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
+
+int
+main(int argc, char **argv)
+{
+ foo("%s", "test");
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute___format=yes
+else
+ ac_cv___attribute___format=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+CFLAGS="$save_CFLAGS"
+if test "$ac_cv___attribute___format" = "yes"; then
+
+$as_echo "#define __ATTRIBUTE___FORMAT_OK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute___format" >&5
+$as_echo "$ac_cv___attribute___format" >&6; }
+
+fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -3729,7 +3796,7 @@ if test -n "$CPP" && test -d "$CPP"; then
CPP=
fi
if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then :
+ if ${ac_cv_prog_CPP+:} false; then :
$as_echo_n "(cached) " >&6
else
# Double quotes because CPP needs to be expanded
@@ -3845,7 +3912,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
ac_ext=c
@@ -3857,7 +3924,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
+if ${ac_cv_path_GREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$GREP"; then
@@ -3871,7 +3938,7 @@ do
for ac_prog in grep ggrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+ as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
# Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
@@ -3920,7 +3987,7 @@ $as_echo "$ac_cv_path_GREP" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then :
+if ${ac_cv_path_EGREP+:} false; then :
$as_echo_n "(cached) " >&6
else
if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
@@ -3937,7 +4004,7 @@ do
for ac_prog in egrep; do
for ac_exec_ext in '' $ac_executable_extensions; do
ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
- { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+ as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
# Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
@@ -3987,7 +4054,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4117,7 +4184,7 @@ done
for ac_header in sys/bitypes.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sys/bitypes.h" "ac_cv_header_sys_bitypes_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_bitypes_h" = x""yes; then :
+if test "x$ac_cv_header_sys_bitypes_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SYS_BITYPES_H 1
_ACEOF
@@ -4132,7 +4199,7 @@ ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_int8_t" = x""yes; then :
+if test "x$ac_cv_type_int8_t" = xyes; then :
else
@@ -4145,7 +4212,7 @@ ac_fn_c_check_type "$LINENO" "u_int8_t" "ac_cv_type_u_int8_t" "$ac_includes_defa
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_u_int8_t" = x""yes; then :
+if test "x$ac_cv_type_u_int8_t" = xyes; then :
else
@@ -4154,7 +4221,7 @@ $as_echo "#define u_int8_t unsigned char" >>confdefs.h
fi
ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
-if test "x$ac_cv_type_int16_t" = x""yes; then :
+if test "x$ac_cv_type_int16_t" = xyes; then :
else
@@ -4171,7 +4238,7 @@ ac_fn_c_check_type "$LINENO" "u_int16_t" "ac_cv_type_u_int16_t" "$ac_includes_de
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_u_int16_t" = x""yes; then :
+if test "x$ac_cv_type_u_int16_t" = xyes; then :
else
@@ -4184,7 +4251,7 @@ ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_defaul
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_int32_t" = x""yes; then :
+if test "x$ac_cv_type_int32_t" = xyes; then :
else
@@ -4197,7 +4264,7 @@ ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_de
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_u_int32_t" = x""yes; then :
+if test "x$ac_cv_type_u_int32_t" = xyes; then :
else
@@ -4210,7 +4277,7 @@ ac_fn_c_check_type "$LINENO" "int64_t" "ac_cv_type_int64_t" "$ac_includes_defaul
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_int64_t" = x""yes; then :
+if test "x$ac_cv_type_int64_t" = xyes; then :
else
@@ -4223,7 +4290,7 @@ ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_de
#include <sys/bitypes.h>
#endif
"
-if test "x$ac_cv_type_u_int64_t" = x""yes; then :
+if test "x$ac_cv_type_u_int64_t" = xyes; then :
else
@@ -4244,7 +4311,7 @@ if test "$enable_largefile" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5
$as_echo_n "checking for special C compiler options needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_CC+set}" = set; then :
+if ${ac_cv_sys_largefile_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_cv_sys_largefile_CC=no
@@ -4295,7 +4362,7 @@ $as_echo "$ac_cv_sys_largefile_CC" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5
$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; }
-if test "${ac_cv_sys_file_offset_bits+set}" = set; then :
+if ${ac_cv_sys_file_offset_bits+:} false; then :
$as_echo_n "(cached) " >&6
else
while :; do
@@ -4364,7 +4431,7 @@ rm -rf conftest*
if test $ac_cv_sys_file_offset_bits = unknown; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5
$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; }
-if test "${ac_cv_sys_large_files+set}" = set; then :
+if ${ac_cv_sys_large_files+:} false; then :
$as_echo_n "(cached) " >&6
else
while :; do
@@ -4431,11 +4498,13 @@ _ACEOF
esac
rm -rf conftest*
fi
+
+
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5
$as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; }
-if test "${ac_cv_sys_largefile_source+set}" = set; then :
+if ${ac_cv_sys_largefile_source+:} false; then :
$as_echo_n "(cached) " >&6
else
while :; do
@@ -4518,7 +4587,7 @@ done
for ac_header in linux/types.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "linux/types.h" "ac_cv_header_linux_types_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_types_h" = x""yes; then :
+if test "x$ac_cv_header_linux_types_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_TYPES_H 1
_ACEOF
@@ -4546,7 +4615,7 @@ do :
#include <sys/socket.h>
#include <net/if.h>
"
-if test "x$ac_cv_header_net_pfvar_h" = x""yes; then :
+if test "x$ac_cv_header_net_pfvar_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NET_PFVAR_H 1
_ACEOF
@@ -4594,7 +4663,7 @@ do :
ac_fn_c_check_header_compile "$LINENO" "netinet/if_ether.h" "ac_cv_header_netinet_if_ether_h" "#include <sys/types.h>
#include <sys/socket.h>
"
-if test "x$ac_cv_header_netinet_if_ether_h" = x""yes; then :
+if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NETINET_IF_ETHER_H 1
_ACEOF
@@ -4623,7 +4692,7 @@ struct mbuf;
struct rtentry;
#include <net/if.h>
"
-if test "x$ac_cv_header_netinet_if_ether_h" = x""yes; then :
+if test "x$ac_cv_header_netinet_if_ether_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NETINET_IF_ETHER_H 1
_ACEOF
@@ -4637,7 +4706,7 @@ fi
if test "$GCC" = yes ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI ioctl definitions" >&5
$as_echo_n "checking for ANSI ioctl definitions... " >&6; }
- if test "${ac_cv_lbl_gcc_fixincludes+set}" = set; then :
+ if ${ac_cv_lbl_gcc_fixincludes+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -4728,7 +4797,7 @@ fi
# Some strange OSes (SINIX) have it in libsocket:
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5
$as_echo_n "checking for library containing gethostbyname... " >&6; }
-if test "${ac_cv_search_gethostbyname+set}" = set; then :
+if ${ac_cv_search_gethostbyname+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
@@ -4762,11 +4831,11 @@ for ac_lib in '' nsl socket resolv; do
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
- if test "${ac_cv_search_gethostbyname+set}" = set; then :
+ if ${ac_cv_search_gethostbyname+:} false; then :
break
fi
done
-if test "${ac_cv_search_gethostbyname+set}" = set; then :
+if ${ac_cv_search_gethostbyname+:} false; then :
else
ac_cv_search_gethostbyname=no
@@ -4788,7 +4857,7 @@ fi
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lsocket" >&5
$as_echo_n "checking for gethostbyname in -lsocket... " >&6; }
-if test "${ac_cv_lib_socket_gethostbyname+set}" = set; then :
+if ${ac_cv_lib_socket_gethostbyname+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -4822,14 +4891,14 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_gethostbyname" >&5
$as_echo "$ac_cv_lib_socket_gethostbyname" >&6; }
-if test "x$ac_cv_lib_socket_gethostbyname" = x""yes; then :
+if test "x$ac_cv_lib_socket_gethostbyname" = xyes; then :
LIBS="-lsocket -lnsl $LIBS"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
$as_echo_n "checking for library containing socket... " >&6; }
-if test "${ac_cv_search_socket+set}" = set; then :
+if ${ac_cv_search_socket+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
@@ -4863,11 +4932,11 @@ for ac_lib in '' socket; do
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
- if test "${ac_cv_search_socket+set}" = set; then :
+ if ${ac_cv_search_socket+:} false; then :
break
fi
done
-if test "${ac_cv_search_socket+set}" = set; then :
+if ${ac_cv_search_socket+:} false; then :
else
ac_cv_search_socket=no
@@ -4884,7 +4953,7 @@ if test "$ac_res" != no; then :
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lsocket" >&5
$as_echo_n "checking for socket in -lsocket... " >&6; }
-if test "${ac_cv_lib_socket_socket+set}" = set; then :
+if ${ac_cv_lib_socket_socket+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -4918,7 +4987,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_socket" >&5
$as_echo "$ac_cv_lib_socket_socket" >&6; }
-if test "x$ac_cv_lib_socket_socket" = x""yes; then :
+if test "x$ac_cv_lib_socket_socket" = xyes; then :
LIBS="-lsocket -lnsl $LIBS"
fi
@@ -4927,7 +4996,7 @@ fi
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing putmsg" >&5
$as_echo_n "checking for library containing putmsg... " >&6; }
-if test "${ac_cv_search_putmsg+set}" = set; then :
+if ${ac_cv_search_putmsg+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
@@ -4961,11 +5030,11 @@ for ac_lib in '' str; do
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
- if test "${ac_cv_search_putmsg+set}" = set; then :
+ if ${ac_cv_search_putmsg+:} false; then :
break
fi
done
-if test "${ac_cv_search_putmsg+set}" = set; then :
+if ${ac_cv_search_putmsg+:} false; then :
else
ac_cv_search_putmsg=no
@@ -4997,7 +5066,7 @@ fi
for ac_func in ether_hostton
do :
ac_fn_c_check_func "$LINENO" "ether_hostton" "ac_cv_func_ether_hostton"
-if test "x$ac_cv_func_ether_hostton" = x""yes; then :
+if test "x$ac_cv_func_ether_hostton" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_ETHER_HOSTTON 1
_ACEOF
@@ -5024,7 +5093,7 @@ struct rtentry;
#include <netinet/if_ether.h>
"
-if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then :
+if test "x$ac_cv_have_decl_ether_hostton" = xyes; then :
$as_echo "#define NETINET_IF_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h
@@ -5043,7 +5112,7 @@ fi
for ac_header in netinet/ether.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "netinet/ether.h" "ac_cv_header_netinet_ether_h" "$ac_includes_default"
-if test "x$ac_cv_header_netinet_ether_h" = x""yes; then :
+if test "x$ac_cv_header_netinet_ether_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NETINET_ETHER_H 1
_ACEOF
@@ -5064,7 +5133,7 @@ done
#include <netinet/ether.h>
"
-if test "x$ac_cv_have_decl_ether_hostton" = x""yes; then :
+if test "x$ac_cv_have_decl_ether_hostton" = xyes; then :
$as_echo "#define NETINET_ETHER_H_DECLARES_ETHER_HOSTTON /**/" >>confdefs.h
@@ -5093,7 +5162,7 @@ struct rtentry;
#include <netinet/if_ether.h>
"
-if test "x$ac_cv_type_struct_ether_addr" = x""yes; then :
+if test "x$ac_cv_type_struct_ether_addr" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_ETHER_ADDR 1
@@ -5215,6 +5284,28 @@ $as_echo "$V_PCAP" >&6; }
case "$V_PCAP" in
dlpi)
#
+ # Needed for common functions used by pcap-[dlpi,libdlpi].c
+ #
+ SSRC="dlpisubs.c"
+
+ #
+ # Checks for some header files.
+ #
+ for ac_header in sys/bufmod.h sys/dlpi_ext.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+ #
# Checks to see if Solaris has the public libdlpi(3LIB) library.
# Note: The existence of /usr/include/libdlpi.h does not mean it is the
# public libdlpi(3LIB) version. Before libdlpi was made public, a
@@ -5229,7 +5320,7 @@ dlpi)
LDFLAGS="$LIBS -L/lib"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlpi_walk in -ldlpi" >&5
$as_echo_n "checking for dlpi_walk in -ldlpi... " >&6; }
-if test "${ac_cv_lib_dlpi_dlpi_walk+set}" = set; then :
+if ${ac_cv_lib_dlpi_dlpi_walk+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -5263,12 +5354,14 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dlpi_dlpi_walk" >&5
$as_echo "$ac_cv_lib_dlpi_dlpi_walk" >&6; }
-if test "x$ac_cv_lib_dlpi_dlpi_walk" = x""yes; then :
- LIBS="-ldlpi $LIBS"
- V_PCAP=libdlpi
+if test "x$ac_cv_lib_dlpi_dlpi_walk" = xyes; then :
+
+ LIBS="-ldlpi $LIBS"
+ V_PCAP=libdlpi
$as_echo "#define HAVE_LIBDLPI 1" >>confdefs.h
+
else
V_PCAP=dlpi
fi
@@ -5281,7 +5374,7 @@ fi
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether <sys/dlpi.h> is usable" >&5
$as_echo_n "checking whether <sys/dlpi.h> is usable... " >&6; }
- if test "${ac_cv_sys_dlpi_usable+set}" = set; then :
+ if ${ac_cv_sys_dlpi_usable+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5350,7 +5443,7 @@ $as_echo "no" >&6; }
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_passive_req_t struct exists" >&5
$as_echo_n "checking if dl_passive_req_t struct exists... " >&6; }
- if test "${ac_cv_lbl_has_dl_passive_req_t+set}" = set; then :
+ if ${ac_cv_lbl_has_dl_passive_req_t+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5395,7 +5488,7 @@ do :
#include <linux/types.h>
"
-if test "x$ac_cv_header_linux_wireless_h" = x""yes; then :
+if test "x$ac_cv_header_linux_wireless_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_WIRELESS_H 1
_ACEOF
@@ -5416,12 +5509,78 @@ fi
if test x$with_libnl != xno ; then
+ have_any_nl="no"
+
#
- # Try libnl 2.x first.
+ # Try libnl 3.x first.
#
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5
+$as_echo_n "checking for nl_socket_alloc in -lnl-3... " >&6; }
+if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnl-3 $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nl_socket_alloc ();
+int
+main ()
+{
+return nl_socket_alloc ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_nl_3_nl_socket_alloc=yes
+else
+ ac_cv_lib_nl_3_nl_socket_alloc=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_3_nl_socket_alloc" >&5
+$as_echo "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; }
+if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then :
+
+ #
+ # Yes, we have libnl 3.x.
+ #
+ LIBS="-lnl-genl-3 -lnl-3 $LIBS"
+
+$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBNL_3_x 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBNL_NLE 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h
+
+ V_INCLS="$V_INCLS -I/usr/include/libnl3"
+ have_any_nl="yes"
+
+fi
+
+
+ if test x$have_any_nl = xno ; then
+ #
+ # Try libnl 2.x
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl" >&5
$as_echo_n "checking for nl_socket_alloc in -lnl... " >&6; }
-if test "${ac_cv_lib_nl_nl_socket_alloc+set}" = set; then :
+if ${ac_cv_lib_nl_nl_socket_alloc+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -5455,12 +5614,12 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_socket_alloc" >&5
$as_echo "$ac_cv_lib_nl_nl_socket_alloc" >&6; }
-if test "x$ac_cv_lib_nl_nl_socket_alloc" = x""yes; then :
+if test "x$ac_cv_lib_nl_nl_socket_alloc" = xyes; then :
- #
- # Yes, we have libnl 2.x.
- #
- LIBS="-lnl-genl -lnl $LIBS"
+ #
+ # Yes, we have libnl 2.x.
+ #
+ LIBS="-lnl-genl -lnl $LIBS"
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
@@ -5468,14 +5627,24 @@ $as_echo "#define HAVE_LIBNL 1" >>confdefs.h
$as_echo "#define HAVE_LIBNL_2_x 1" >>confdefs.h
-else
+$as_echo "#define HAVE_LIBNL_NLE 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBNL_SOCKETS 1" >>confdefs.h
+
+ have_any_nl="yes"
+
+fi
+
+ fi
+ if test x$have_any_nl = xno ; then
#
# No, we don't; do we have libnl 1.x?
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_handle_alloc in -lnl" >&5
$as_echo_n "checking for nl_handle_alloc in -lnl... " >&6; }
-if test "${ac_cv_lib_nl_nl_handle_alloc+set}" = set; then :
+if ${ac_cv_lib_nl_nl_handle_alloc+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -5509,7 +5678,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_handle_alloc" >&5
$as_echo "$ac_cv_lib_nl_nl_handle_alloc" >&6; }
-if test "x$ac_cv_lib_nl_nl_handle_alloc" = x""yes; then :
+if test "x$ac_cv_lib_nl_nl_handle_alloc" = xyes; then :
#
# Yes.
@@ -5518,21 +5687,20 @@ if test "x$ac_cv_lib_nl_nl_handle_alloc" = x""yes; then :
$as_echo "#define HAVE_LIBNL 1" >>confdefs.h
-
-else
-
- #
- # No, we don't have libnl at all.
- #
- if test x$with_libnl = xyes ; then
- as_fn_error $? "libnl support requested but libnl not found" "$LINENO" 5
- fi
+ have_any_nl="yes"
fi
+ fi
-fi
-
+ if test x$have_any_nl = xno ; then
+ #
+ # No, we don't have libnl at all.
+ #
+ if test x$with_libnl = xyes ; then
+ as_fn_error $? "libnl support requested but libnl not found" "$LINENO" 5
+ fi
+ fi
fi
for ac_header in linux/ethtool.h
@@ -5542,7 +5710,7 @@ $ac_includes_default
#include <linux/types.h>
"
-if test "x$ac_cv_header_linux_ethtool_h" = x""yes; then :
+if test "x$ac_cv_header_linux_ethtool_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_ETHTOOL_H 1
_ACEOF
@@ -5553,7 +5721,7 @@ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if if_packet.h has tpacket_stats defined" >&5
$as_echo_n "checking if if_packet.h has tpacket_stats defined... " >&6; }
- if test "${ac_cv_lbl_tpacket_stats+set}" = set; then :
+ if ${ac_cv_lbl_tpacket_stats+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5585,7 +5753,7 @@ $as_echo "#define HAVE_TPACKET_STATS 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if tpacket_auxdata struct has tp_vlan_tci member" >&5
$as_echo_n "checking if tpacket_auxdata struct has tp_vlan_tci member... " >&6; }
- if test "${ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci+set}" = set; then :
+ if ${ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5627,7 +5795,7 @@ bpf)
for ac_header in net/if_media.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "net/if_media.h" "ac_cv_header_net_if_media_h" "$ac_includes_default"
-if test "x$ac_cv_header_net_if_media_h" = x""yes; then :
+if test "x$ac_cv_header_net_if_media_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_NET_IF_MEDIA_H 1
_ACEOF
@@ -5679,7 +5847,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
#include <net/bpf.h>
"
-if test "x$ac_cv_type_struct_BPF_TIMEVAL" = x""yes; then :
+if test "x$ac_cv_type_struct_BPF_TIMEVAL" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_STRUCT_BPF_TIMEVAL 1
@@ -5719,14 +5887,14 @@ then
V_FINDALLDEVS=null
else
ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs"
-if test "x$ac_cv_func_getifaddrs" = x""yes; then :
+if test "x$ac_cv_func_getifaddrs" = xyes; then :
#
# We have "getifaddrs()"; make sure we have <ifaddrs.h>
# as well, just in case some platform is really weird.
#
ac_fn_c_check_header_mongrel "$LINENO" "ifaddrs.h" "ac_cv_header_ifaddrs_h" "$ac_includes_default"
-if test "x$ac_cv_header_ifaddrs_h" = x""yes; then :
+if test "x$ac_cv_header_ifaddrs_h" = xyes; then :
#
# We have the header, so we use "getifaddrs()" to
@@ -5763,19 +5931,6 @@ else
case "$V_PCAP" in
dlpi|libdlpi)
- for ac_header in sys/bufmod.h sys/dlpi_ext.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
#
# This might be Solaris 8 or later, with
# SIOCGLIFCONF, or it might be some other OS
@@ -5784,7 +5939,7 @@ done
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have SIOCGLIFCONF" >&5
$as_echo_n "checking whether we have SIOCGLIFCONF... " >&6; }
- if test "${ac_cv_lbl_have_siocglifconf+set}" = set; then :
+ if ${ac_cv_lbl_have_siocglifconf+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5817,10 +5972,6 @@ $as_echo "$ac_cv_lbl_have_siocglifconf" >&6; }
else
V_FINDALLDEVS=gifc
fi
- #
- # Needed for common functions used by pcap-[dlpi,libdlpi].c
- #
- SSRC="dlpisubs.c"
;;
*)
@@ -5879,7 +6030,7 @@ fi
if test "$enable_ipv6" != "no"; then
ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo"
-if test "x$ac_cv_func_getaddrinfo" = x""yes; then :
+if test "x$ac_cv_func_getaddrinfo" = xyes; then :
$as_echo "#define INET6 1" >>confdefs.h
@@ -5891,7 +6042,7 @@ else
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "--enable-ipv6 was given, but getaddrinfo isn't available
-See \`config.log' for more details" "$LINENO" 5 ; }
+See \`config.log' for more details" "$LINENO" 5; }
fi
fi
@@ -6045,7 +6196,7 @@ if test $ac_cv_lbl_dag_api = yes; then
LDFLAGS="-L$dag_lib_dir"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_attach_stream in -ldag" >&5
$as_echo_n "checking for dag_attach_stream in -ldag... " >&6; }
-if test "${ac_cv_lib_dag_dag_attach_stream+set}" = set; then :
+if ${ac_cv_lib_dag_dag_attach_stream+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6079,7 +6230,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_attach_stream" >&5
$as_echo "$ac_cv_lib_dag_dag_attach_stream" >&6; }
-if test "x$ac_cv_lib_dag_dag_attach_stream" = x""yes; then :
+if test "x$ac_cv_lib_dag_dag_attach_stream" = xyes; then :
dag_streams="1"
else
dag_streams="0"
@@ -6087,7 +6238,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_erf_types in -ldag" >&5
$as_echo_n "checking for dag_get_erf_types in -ldag... " >&6; }
-if test "${ac_cv_lib_dag_dag_get_erf_types+set}" = set; then :
+if ${ac_cv_lib_dag_dag_get_erf_types+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6121,7 +6272,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_erf_types" >&5
$as_echo "$ac_cv_lib_dag_dag_get_erf_types" >&6; }
-if test "x$ac_cv_lib_dag_dag_get_erf_types" = x""yes; then :
+if test "x$ac_cv_lib_dag_dag_get_erf_types" = xyes; then :
$as_echo "#define HAVE_DAG_GET_ERF_TYPES 1" >>confdefs.h
@@ -6130,7 +6281,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dag_get_stream_erf_types in -ldag" >&5
$as_echo_n "checking for dag_get_stream_erf_types in -ldag... " >&6; }
-if test "${ac_cv_lib_dag_dag_get_stream_erf_types+set}" = set; then :
+if ${ac_cv_lib_dag_dag_get_stream_erf_types+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6164,7 +6315,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dag_dag_get_stream_erf_types" >&5
$as_echo "$ac_cv_lib_dag_dag_get_stream_erf_types" >&6; }
-if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = x""yes; then :
+if test "x$ac_cv_lib_dag_dag_get_stream_erf_types" = xyes; then :
$as_echo "#define HAVE_DAG_GET_STREAM_ERF_TYPES 1" >>confdefs.h
@@ -6183,7 +6334,7 @@ $as_echo "#define HAVE_DAG_STREAMS_API 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for vdag_set_device_info in -lvdag" >&5
$as_echo_n "checking for vdag_set_device_info in -lvdag... " >&6; }
-if test "${ac_cv_lib_vdag_vdag_set_device_info+set}" = set; then :
+if ${ac_cv_lib_vdag_vdag_set_device_info+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6217,7 +6368,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vdag_vdag_set_device_info" >&5
$as_echo "$ac_cv_lib_vdag_vdag_set_device_info" >&6; }
-if test "x$ac_cv_lib_vdag_vdag_set_device_info" = x""yes; then :
+if test "x$ac_cv_lib_vdag_vdag_set_device_info" = xyes; then :
ac_dag_have_vdag="1"
else
ac_dag_have_vdag="0"
@@ -6452,7 +6603,7 @@ $as_echo "$ac_cv_lbl_snf_api ($snf_root)" >&6; }
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for snf_init in -lsnf" >&5
$as_echo_n "checking for snf_init in -lsnf... " >&6; }
-if test "${ac_cv_lib_snf_snf_init+set}" = set; then :
+if ${ac_cv_lib_snf_snf_init+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -6486,7 +6637,7 @@ LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_snf_snf_init" >&5
$as_echo "$ac_cv_lib_snf_snf_init" >&6; }
-if test "x$ac_cv_lib_snf_snf_init" = x""yes; then :
+if test "x$ac_cv_lib_snf_snf_init" = xyes; then :
ac_cv_lbl_snf_api="yes"
else
ac_cv_lbl_snf_api="no"
@@ -6537,7 +6688,7 @@ do
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_V_LEX+set}" = set; then :
+if ${ac_cv_prog_V_LEX+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$V_LEX"; then
@@ -6549,7 +6700,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_V_LEX="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -6579,7 +6730,7 @@ test -n "$V_LEX" || V_LEX="lex"
# The -V flag was added in 2.4
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for flex 2.4 or higher" >&5
$as_echo_n "checking for flex 2.4 or higher... " >&6; }
- if test "${ac_cv_lbl_flex_v24+set}" = set; then :
+ if ${ac_cv_lbl_flex_v24+:} false; then :
$as_echo_n "(cached) " >&6
else
if flex -V >/dev/null 2>&1; then
@@ -6607,7 +6758,7 @@ do
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_V_YACC+set}" = set; then :
+if ${ac_cv_prog_V_YACC+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$V_YACC"; then
@@ -6619,7 +6770,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_V_YACC="$ac_prog"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -6657,13 +6808,17 @@ $as_echo "$as_me: WARNING: don't have both flex and bison; reverting to lex/yacc
if test "$V_LEX" = flex -a -n "pcap_" ; then
V_LEX="$V_LEX -Ppcap_"
V_YACC="$V_YACC -p pcap_"
+ else
+
+$as_echo "#define NEED_YYPARSE_WRAPPER 1" >>confdefs.h
+
fi
if test "$V_LEX" = lex ; then
# Some versions of lex can't handle the definitions section of scanner.l .
# Try lexing it and complain if it can't deal.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for capable lex" >&5
$as_echo_n "checking for capable lex... " >&6; }
-if test "${tcpdump_cv_capable_lex+set}" = set; then :
+if ${tcpdump_cv_capable_lex+:} false; then :
$as_echo_n "(cached) " >&6
else
if lex -t scanner.l > /dev/null 2>&1; then
@@ -6748,6 +6903,45 @@ fi
if test "$enable_universal" != "no"; then
case "$host_os" in
+ darwin0-7.*)
+ #
+ # Pre-Tiger. Build only for 32-bit PowerPC; no
+ # need for any special compiler or linker flags.
+ #
+ ;;
+
+ darwin8.0123*)
+ #
+ # Tiger, prior to Intel support. Build for 32-bit
+ # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
+ # first. (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
+ ;;
+
+ darwin8.456*)
+ #
+ # Tiger, subsequent to Intel support but prior to
+ # x86-64 support. Build for 32-bit PowerPC, 64-bit
+ # PowerPC, and x86, with 32-bit PowerPC first.
+ # (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
+ ;;
+
+ darwin8.*)
+ #
+ # All other Tiger, so subsequent to x86-64
+ # support. Build for 32-bit PowerPC, 64-bit
+ # PowerPC, x86, and x86-64, and with 32-bit PowerPC
+ # first. (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+ ;;
+
darwin9.*)
#
# Leopard. Build for 32-bit PowerPC, 64-bit
@@ -6772,11 +6966,13 @@ fi
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
;;
- darwin11.*)
+ darwin*)
#
- # Lion. Build for x86-64 and x86, with x86-64
- # first. (That's probably what Apple does,
- # given that Rosetta is gone.)
+ # Post-Snow Leopard. Build for x86-64 and
+ # x86, with x86-64 first. (That's probably what
+ # Apple does, given that Rosetta is gone.)
+ # XXX - update if and when Apple drops support
+ # for 32-bit x86 code.
#
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
@@ -6871,7 +7067,7 @@ osf*)
sinix*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if SINIX compiler defines sinix" >&5
$as_echo_n "checking if SINIX compiler defines sinix... " >&6; }
- if test "${ac_cv_cc_sinix_defined+set}" = set; then :
+ if ${ac_cv_cc_sinix_defined+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6916,12 +7112,19 @@ $as_echo "#define HAVE_SOLARIS 1" >>confdefs.h
;;
esac
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+ enableval=$enable_shared;
+fi
+
+test "x$enable_shared" = "xno" && DYEXT="none"
+
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_RANLIB+set}" = set; then :
+if ${ac_cv_prog_RANLIB+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$RANLIB"; then
@@ -6933,7 +7136,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -6961,7 +7164,7 @@ if test -z "$ac_cv_prog_RANLIB"; then
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_RANLIB"; then
@@ -6973,7 +7176,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_RANLIB="ranlib"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -7013,7 +7216,7 @@ if test -n "$ac_tool_prefix"; then
set dummy ${ac_tool_prefix}ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_AR+set}" = set; then :
+if ${ac_cv_prog_AR+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$AR"; then
@@ -7025,7 +7228,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_AR="${ac_tool_prefix}ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -7053,7 +7256,7 @@ if test -z "$ac_cv_prog_AR"; then
set dummy ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -n "$ac_ct_AR"; then
@@ -7065,7 +7268,7 @@ do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_AR="ar"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
@@ -7101,32 +7304,268 @@ else
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+
+
rm -f os-proto.h
if test "${LBL_CFLAGS+set}" = set; then
V_CCOPT="$V_CCOPT ${LBL_CFLAGS}"
fi
if test -f .devel ; then
- if test "$GCC" = yes ; then
- if test "${LBL_CFLAGS+set}" != set; then
- if test "$ac_cv_prog_cc_g" = yes ; then
- V_CCOPT="-g $V_CCOPT"
- fi
- V_CCOPT="$V_CCOPT -Wall"
- if test $ac_cv_lbl_gcc_vers -gt 1 ; then
- V_CCOPT="$V_CCOPT -Wmissing-prototypes -Wstrict-prototypes"
- fi
- fi
- else
- case "$host_os" in
+ #
+ # Skip all the warning option stuff on some compilers.
+ #
+ if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
- irix6*)
- V_CCOPT="$V_CCOPT -n32"
- ;;
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5
+$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We're assuming this is clang, where
+ # -Werror=unknown-warning-option is the appropriate
+ # option to force the compiler to fail.
+ #
+ ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5
+$as_echo_n "checking whether the compiler supports the -Wall option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wall"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wmissing-prototypes"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5
+$as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; }
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+return 0
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ CFLAGS="$save_CFLAGS"
+ V_CCOPT="$V_CCOPT -Wstrict-prototypes"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ CFLAGS="$save_CFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
- *)
- ;;
- esac
fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports generating dependencies" >&5
+$as_echo_n "checking whether the compiler supports generating dependencies... " >&6; }
+ if test "$GCC" = yes ; then
+ #
+ # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
+ # though it's not); we assume that, in this case, the flag
+ # would be -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ else
+ #
+ # Not GCC or a compiler deemed to be GCC; what platform is
+ # this? (We're assuming that if the compiler isn't GCC
+ # it's the compiler from the vendor of the OS; that won't
+ # necessarily be true for x86 platforms, where it might be
+ # the Intel C compiler.)
+ #
+ case "$host_os" in
+
+ irix*|osf*|darwin*)
+ #
+ # MIPS C for IRIX, DEC C, and clang all use -M.
+ #
+ ac_lbl_dependency_flag="-M"
+ ;;
+
+ solaris*)
+ #
+ # Sun C uses -xM.
+ #
+ ac_lbl_dependency_flag="-xM"
+ ;;
+
+ hpux*)
+ #
+ # HP's older C compilers don't support this.
+ # HP's newer C compilers support this with
+ # either +M or +Make; the older compilers
+ # interpret +M as something completely
+ # different, so we use +Make so we don't
+ # think it works with the older compilers.
+ #
+ ac_lbl_dependency_flag="+Make"
+ ;;
+
+ *)
+ #
+ # Not one of the above; assume no support for
+ # generating dependencies.
+ #
+ ac_lbl_dependency_flag=""
+ ;;
+ esac
+ fi
+
+ #
+ # Is ac_lbl_dependency_flag defined and, if so, does the compiler
+ # complain about it?
+ #
+ # Note: clang doesn't seem to exit with an error status when handed
+ # an unknown non-warning error, even if you pass it
+ # -Werror=unknown-warning-option. However, it always supports
+ # -M, so the fact that this test always succeeds with clang
+ # isn't an issue.
+ #
+ if test ! -z "$ac_lbl_dependency_flag"; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int main(void) { return 0; }
+_ACEOF
+ echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
+ if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, with $ac_lbl_dependency_flag" >&5
+$as_echo "yes, with $ac_lbl_dependency_flag" >&6; }
+ DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
+ MKDEP='${srcdir}/mkdep'
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+ rm -rf conftest*
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ #
+ # We can't run mkdep, so have "make depend" do
+ # nothing.
+ #
+ MKDEP=:
+ fi
+
+
+
+ #
+ # We used to set -n32 for IRIX 6 when not using GCC (presumed
+ # to mean that we're using MIPS C or MIPSpro C); it specified
+ # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
+ # not sure why that would be something to do *only* with a
+ # .devel file; why should the ABI for which we produce code
+ # depend on .devel?
+ #
os=`echo $host_os | sed -e 's/\([0-9][0-9]*\)[^0-9].*$/\1/'`
name="lbl/os-$os.h"
if test -f $name ; then
@@ -7142,7 +7581,7 @@ $as_echo "$as_me: WARNING: can't find $name" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr struct has the sa_len member" >&5
$as_echo_n "checking if sockaddr struct has the sa_len member... " >&6; }
- if test "${ac_cv_lbl_sockaddr_has_sa_len+set}" = set; then :
+ if ${ac_cv_lbl_sockaddr_has_sa_len+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7176,7 +7615,7 @@ $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr_storage struct exists" >&5
$as_echo_n "checking if sockaddr_storage struct exists... " >&6; }
- if test "${ac_cv_lbl_has_sockaddr_storage+set}" = set; then :
+ if ${ac_cv_lbl_has_sockaddr_storage+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7210,7 +7649,7 @@ $as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if dl_hp_ppa_info_t struct has dl_module_id_1 member" >&5
$as_echo_n "checking if dl_hp_ppa_info_t struct has dl_module_id_1 member... " >&6; }
- if test "${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+set}" = set; then :
+ if ${ac_cv_lbl_dl_hp_ppa_info_t_has_dl_module_id_1+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7245,7 +7684,7 @@ $as_echo "#define HAVE_HP_PPA_INFO_T_DL_MODULE_ID_1 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if unaligned accesses fail" >&5
$as_echo_n "checking if unaligned accesses fail... " >&6; }
- if test "${ac_cv_lbl_unaligned_fail+set}" = set; then :
+ if ${ac_cv_lbl_unaligned_fail+:} false; then :
$as_echo_n "(cached) " >&6
else
case "$host_cpu" in
@@ -7395,7 +7834,7 @@ $as_echo "$as_me: Device for USB sniffing is /dev/$ac_usb_dev_name" >&6;}
for ac_header in linux/compiler.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "linux/compiler.h" "ac_cv_header_linux_compiler_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_compiler_h" = x""yes; then :
+if test "x$ac_cv_header_linux_compiler_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_COMPILER_H 1
_ACEOF
@@ -7412,7 +7851,7 @@ done
do :
ac_fn_c_check_header_compile "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "#include <linux/compiler.h>
"
-if test "x$ac_cv_header_linux_usbdevice_fs_h" = x""yes; then :
+if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_USBDEVICE_FS_H 1
_ACEOF
@@ -7425,7 +7864,7 @@ done
for ac_header in linux/usbdevice_fs.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "linux/usbdevice_fs.h" "ac_cv_header_linux_usbdevice_fs_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_usbdevice_fs_h" = x""yes; then :
+if test "x$ac_cv_header_linux_usbdevice_fs_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_USBDEVICE_FS_H 1
_ACEOF
@@ -7444,7 +7883,7 @@ done
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if usbdevfs_ctrltransfer struct has bRequestType member" >&5
$as_echo_n "checking if usbdevfs_ctrltransfer struct has bRequestType member... " >&6; }
- if test "${ac_cv_usbdevfs_ctrltransfer_has_bRequestType+set}" = set; then :
+ if ${ac_cv_usbdevfs_ctrltransfer_has_bRequestType+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7507,7 +7946,7 @@ $as_echo "yes" >&6; }
#
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can compile the netfilter support" >&5
$as_echo_n "checking whether we can compile the netfilter support... " >&6; }
- if test "${ac_cv_netfilter_can_compile+set}" = set; then :
+ if ${ac_cv_netfilter_can_compile+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -7515,11 +7954,14 @@ else
$ac_includes_default
#include <sys/socket.h>
+#include <netinet/in.h>
#include <linux/types.h>
#include <linux/netlink.h>
+#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_log.h>
+#include <linux/netfilter/nfnetlink_queue.h>
int
main ()
{
@@ -7565,7 +8007,7 @@ if test "x$enable_bluetooth" != "xno" ; then
case "$host_os" in
linux*)
ac_fn_c_check_header_mongrel "$LINENO" "bluetooth/bluetooth.h" "ac_cv_header_bluetooth_bluetooth_h" "$ac_includes_default"
-if test "x$ac_cv_header_bluetooth_bluetooth_h" = x""yes; then :
+if test "x$ac_cv_header_bluetooth_bluetooth_h" = xyes; then :
$as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h
@@ -7574,6 +8016,45 @@ $as_echo "#define PCAP_SUPPORT_BT 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is supported" >&5
$as_echo "$as_me: Bluetooth sniffing is supported" >&6;}
+ #
+ # OK, does struct sockaddr_hci have an hci_channel
+ # member?
+ #
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct sockaddr_hci has hci_channel member" >&5
+$as_echo_n "checking if struct sockaddr_hci has hci_channel member... " >&6; }
+ if ${ac_cv_lbl_sockaddr_hci_has_hci_channel+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+
+int
+main ()
+{
+u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_lbl_sockaddr_hci_has_hci_channel=yes
+else
+ ac_cv_lbl_sockaddr_hci_has_hci_channel=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lbl_sockaddr_hci_has_hci_channel" >&5
+$as_echo "$ac_cv_lbl_sockaddr_hci_has_hci_channel" >&6; }
+ if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
+
+$as_echo "#define SOCKADDR_HCI_HAS_HCI_CHANNEL /**/" >>confdefs.h
+
+ fi
+
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&5
$as_echo "$as_me: Bluetooth sniffing is not supported; install bluez-lib devel to enable it" >&6;}
@@ -7593,7 +8074,9 @@ fi
# Check whether --enable-canusb was given.
if test "${enable_canusb+set}" = set; then :
- enableval=$enable_canusb; enable_canusb=yes
+ enableval=$enable_canusb;
+else
+ enable_canusb=yes
fi
@@ -7601,13 +8084,13 @@ if test "x$enable_canusb" != "xno" ; then
case "$host_os" in
linux*)
ac_fn_c_check_header_mongrel "$LINENO" "libusb-1.0/libusb.h" "ac_cv_header_libusb_1_0_libusb_h" "$ac_includes_default"
-if test "x$ac_cv_header_libusb_1_0_libusb_h" = x""yes; then :
+if test "x$ac_cv_header_libusb_1_0_libusb_h" = xyes; then :
$as_echo "#define PCAP_SUPPORT_CANUSB 1" >>confdefs.h
CANUSB_SRC=pcap-canusb-linux.c
- LIBS="-lusb-1.0 $LIBS"
+ LIBS="-lusb-1.0 -lpthread $LIBS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: canusb sniffing is supported" >&5
$as_echo "$as_me: canusb sniffing is supported" >&6;}
@@ -7642,7 +8125,7 @@ if test "x$enable_can" != "xno" ; then
ac_fn_c_check_header_compile "$LINENO" "linux/can.h" "ac_cv_header_linux_can_h" "#include <sys/socket.h>
"
-if test "x$ac_cv_header_linux_can_h" = x""yes; then :
+if test "x$ac_cv_header_linux_can_h" = xyes; then :
$as_echo "#define PCAP_SUPPORT_CAN 1" >>confdefs.h
@@ -7665,12 +8148,124 @@ $as_echo "$as_me: no CAN sniffing support implemented for $host_os" >&6;}
fi
+# Check whether --enable-dbus was given.
+if test "${enable_dbus+set}" = set; then :
+ enableval=$enable_dbus;
+else
+ enable_dbus=ifavailable
+fi
+
+
+if test "x$enable_dbus" != "xno"; then
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PKGCONFIG+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$PKGCONFIG"; then
+ ac_cv_prog_PKGCONFIG="$PKGCONFIG" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_PKGCONFIG="pkg-config"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_prog_PKGCONFIG" && ac_cv_prog_PKGCONFIG="no"
+fi
+fi
+PKGCONFIG=$ac_cv_prog_PKGCONFIG
+if test -n "$PKGCONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKGCONFIG" >&5
+$as_echo "$PKGCONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test "x$PKGCONFIG" != "xno"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for D-Bus" >&5
+$as_echo_n "checking for D-Bus... " >&6; }
+ if "$PKGCONFIG" dbus-1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
+ DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the D-Bus library defines dbus_connection_read_write" >&5
+$as_echo_n "checking whether the D-Bus library defines dbus_connection_read_write... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+ #include <time.h>
+ #include <sys/time.h>
+
+ #include <dbus/dbus.h>
+int
+main ()
+{
+return dbus_connection_read_write(NULL, 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define PCAP_SUPPORT_DBUS 1" >>confdefs.h
+
+ DBUS_SRC=pcap-dbus.c
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
+
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()" "$LINENO" 5
+ fi
+ LIBS="$save_LIBS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ CFLAGS="$save_CFLAGS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ if test "x$enable_dbus" = "xyes"; then
+ as_fn_error $? "--enable-dbus was given, but the dbus-1 package is not installed" "$LINENO" 5
+ fi
+ fi
+ fi
+
+
+fi
+
case "$host_os" in
linux*)
for ac_header in linux/net_tstamp.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "linux/net_tstamp.h" "ac_cv_header_linux_net_tstamp_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_net_tstamp_h" = x""yes; then :
+if test "x$ac_cv_header_linux_net_tstamp_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LINUX_NET_TSTAMP_H 1
_ACEOF
@@ -7703,7 +8298,7 @@ esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then :
+if ${ac_cv_path_install+:} false; then :
$as_echo_n "(cached) " >&6
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -7723,7 +8318,7 @@ case $as_dir/ in #((
# by default.
for ac_prog in ginstall scoinst install; do
for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
if test $ac_prog = install &&
grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
@@ -7783,7 +8378,9 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
ac_config_headers="$ac_config_headers config.h"
-ac_config_files="$ac_config_files Makefile pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_tstamp_type.3pcap"
+ac_config_commands="$ac_config_commands default-1"
+
+ac_config_files="$ac_config_files Makefile pcap-filter.manmisc pcap-linktype.manmisc pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap pcap_set_tstamp_type.3pcap"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -7849,10 +8446,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
:end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
if test -w "$cache_file"; then
- test "x$cache_file" != "x/dev/null" &&
+ if test "x$cache_file" != "x/dev/null"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
- cat confcache >$cache_file
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
@@ -7884,7 +8492,7 @@ LTLIBOBJS=$ac_ltlibobjs
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
@@ -7985,6 +8593,7 @@ fi
IFS=" "" $as_nl"
# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
case $0 in #((
*[\\/]* ) as_myself=$0 ;;
*) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -8180,16 +8789,16 @@ if (echo >conf$$.file) 2>/dev/null; then
# ... but there are two gotchas:
# 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
# 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
- # In both cases, we have to default to `cp -p'.
+ # In both cases, we have to default to `cp -pR'.
ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
elif ln conf$$.file conf$$ 2>/dev/null; then
as_ln_s=ln
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
else
- as_ln_s='cp -p'
+ as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null
@@ -8249,28 +8858,16 @@ else
as_mkdir_p=false
fi
-if test -x / >/dev/null 2>&1; then
- as_test_x='test -x'
-else
- if ls -dL / >/dev/null 2>&1; then
- as_ls_L_option=L
- else
- as_ls_L_option=
- fi
- as_test_x='
- eval sh -c '\''
- if test -d "$1"; then
- test -d "$1/.";
- else
- case $1 in #(
- -*)set "./$1";;
- esac;
- case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
- ???[sx]*):;;*)false;;esac;fi
- '\'' sh
- '
-fi
-as_executable_p=$as_test_x
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -8292,7 +8889,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# values after options handling.
ac_log="
This file was extended by $as_me, which was
-generated by GNU Autoconf 2.67. Invocation command line was
+generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
CONFIG_HEADERS = $CONFIG_HEADERS
@@ -8318,6 +8915,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
_ACEOF
@@ -8347,6 +8945,9 @@ $config_files
Configuration headers:
$config_headers
+Configuration commands:
+$config_commands
+
Report bugs to the package provider."
_ACEOF
@@ -8354,10 +8955,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
config.status
-configured by $0, generated by GNU Autoconf 2.67,
+configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."
@@ -8446,7 +9047,7 @@ fi
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
- set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
shift
\$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
CONFIG_SHELL='$SHELL'
@@ -8467,6 +9068,11 @@ _ASBOX
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+
+
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
@@ -8476,6 +9082,7 @@ for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+ "default-1") CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"pcap-filter.manmisc") CONFIG_FILES="$CONFIG_FILES pcap-filter.manmisc" ;;
"pcap-linktype.manmisc") CONFIG_FILES="$CONFIG_FILES pcap-linktype.manmisc" ;;
@@ -8485,13 +9092,15 @@ do
"pcap_compile.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_compile.3pcap" ;;
"pcap_datalink.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_datalink.3pcap" ;;
"pcap_dump_open.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_dump_open.3pcap" ;;
+ "pcap_get_tstamp_precision.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_get_tstamp_precision.3pcap" ;;
"pcap_list_datalinks.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_list_datalinks.3pcap" ;;
"pcap_list_tstamp_types.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_list_tstamp_types.3pcap" ;;
"pcap_open_dead.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_dead.3pcap" ;;
"pcap_open_offline.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_open_offline.3pcap" ;;
+ "pcap_set_tstamp_precision.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_precision.3pcap" ;;
"pcap_set_tstamp_type.3pcap") CONFIG_FILES="$CONFIG_FILES pcap_set_tstamp_type.3pcap" ;;
- *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;;
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
esac
done
@@ -8503,6 +9112,7 @@ done
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
# Have a temporary directory for convenience. Make it in the build tree
@@ -8513,9 +9123,10 @@ fi
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
- tmp=
+ tmp= ac_tmp=
trap 'exit_status=$?
- { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
trap 'as_fn_exit 1' 1 2 13 15
}
@@ -8523,12 +9134,13 @@ $debug ||
{
tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
+ test -d "$tmp"
} ||
{
tmp=./conf$$-$RANDOM
(umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
@@ -8550,7 +9162,7 @@ else
ac_cs_awk_cr=$ac_cr
fi
-echo 'BEGIN {' >"$tmp/subs1.awk" &&
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF
@@ -8578,7 +9190,7 @@ done
rm -f conf$$subs.sh
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
@@ -8626,7 +9238,7 @@ t delim
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
FS = ""
@@ -8658,7 +9270,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
cat
-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
|| as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF
@@ -8692,7 +9304,7 @@ fi # test -n "$CONFIG_FILES"
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF
@@ -8704,8 +9316,8 @@ _ACEOF
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
- ac_t=`sed -n "/$ac_delim/p" confdefs.h`
- if test -z "$ac_t"; then
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
break
elif $ac_last_try; then
as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
@@ -8797,7 +9409,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_HEADERS"
-eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS "
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
shift
for ac_tag
do
@@ -8806,7 +9418,7 @@ do
esac
case $ac_mode$ac_tag in
:[FHL]*:*);;
- :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
:[FH]-) ac_tag=-:-;;
:[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
esac
@@ -8825,7 +9437,7 @@ do
for ac_f
do
case $ac_f in
- -) ac_f="$tmp/stdin";;
+ -) ac_f="$ac_tmp/stdin";;
*) # Look for the file first in the build tree, then in the source tree
# (if the path is not absolute). The absolute path cannot be DOS-style,
# because $ac_f cannot contain `:'.
@@ -8834,7 +9446,7 @@ do
[\\/$]*) false;;
*) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
esac ||
- as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;;
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
esac
case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
as_fn_append ac_file_inputs " '$ac_f'"
@@ -8860,8 +9472,8 @@ $as_echo "$as_me: creating $ac_file" >&6;}
esac
case $ac_tag in
- *:-:* | *:-) cat >"$tmp/stdin" \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
esac
;;
esac
@@ -8991,21 +9603,22 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
$ac_datarootdir_hack
"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
- || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
- { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
- { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined. Please make sure it is defined" >&2;}
- rm -f "$tmp/stdin"
+ rm -f "$ac_tmp/stdin"
case $ac_file in
- -) cat "$tmp/out" && rm -f "$tmp/out";;
- *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
esac \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
;;
@@ -9016,27 +9629,38 @@ which seems to be undefined. Please make sure it is defined" >&2;}
if test x"$ac_file" != x-; then
{
$as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
- } >"$tmp/config.h" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
else
rm -f "$ac_file"
- mv "$tmp/config.h" "$ac_file" \
+ mv "$ac_tmp/config.h" "$ac_file" \
|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
fi
else
$as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
|| as_fn_error $? "could not create -" "$LINENO" 5
fi
;;
-
+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
esac
+
+ case $ac_file$ac_mode in
+ "default-1":C) if test -f .devel; then
+ echo timestamp > stamp-h
+ cat Makefile-devel-adds >> Makefile
+ make depend
+fi ;;
+
+ esac
done # for ac_tag
@@ -9073,8 +9697,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
-
-if test -f .devel ; then
- make depend
-fi
exit 0
diff --git a/external/bsd/libpcap/dist/configure.in b/external/bsd/libpcap/dist/configure.in
index ca6bab65dc2..1cacf2b2fd0 100644
--- a/external/bsd/libpcap/dist/configure.in
+++ b/external/bsd/libpcap/dist/configure.in
@@ -15,8 +15,7 @@ dnl
# config.sub.
#
-AC_REVISION(Revision: 1.168 )
-AC_PREREQ(2.50)
+AC_PREREQ(2.61)
AC_INIT(pcap.c)
AC_CANONICAL_SYSTEM
@@ -27,6 +26,10 @@ AC_LBL_C_INIT(V_CCOPT, V_INCLS)
AC_LBL_SHLIBS_INIT
AC_LBL_C_INLINE
AC_C___ATTRIBUTE__
+if test "$ac_cv___attribute__" = "yes"; then
+ AC_C___ATTRIBUTE___UNUSED
+ AC_C___ATTRIBUTE___FORMAT
+fi
AC_CHECK_HEADERS(sys/bitypes.h)
@@ -346,6 +349,16 @@ AC_MSG_RESULT($V_PCAP)
case "$V_PCAP" in
dlpi)
#
+ # Needed for common functions used by pcap-[dlpi,libdlpi].c
+ #
+ SSRC="dlpisubs.c"
+
+ #
+ # Checks for some header files.
+ #
+ AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
+
+ #
# Checks to see if Solaris has the public libdlpi(3LIB) library.
# Note: The existence of /usr/include/libdlpi.h does not mean it is the
# public libdlpi(3LIB) version. Before libdlpi was made public, a
@@ -359,9 +372,11 @@ dlpi)
saved_ldflags=$LDFLAGS
LDFLAGS="$LIBS -L/lib"
AC_CHECK_LIB(dlpi, dlpi_walk,
- LIBS="-ldlpi $LIBS"
- V_PCAP=libdlpi
- AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists]),
+ [
+ LIBS="-ldlpi $LIBS"
+ V_PCAP=libdlpi
+ AC_DEFINE(HAVE_LIBDLPI,1,[if libdlpi exists])
+ ],
V_PCAP=dlpi)
LDFLAGS=$saved_ldflags
@@ -430,19 +445,44 @@ linux)
with_libnl=$withval,,)
if test x$with_libnl != xno ; then
+ have_any_nl="no"
+
#
- # Try libnl 2.x first.
+ # Try libnl 3.x first.
#
- AC_CHECK_LIB(nl, nl_socket_alloc,
+ AC_CHECK_LIB(nl-3, nl_socket_alloc,
[
#
- # Yes, we have libnl 2.x.
+ # Yes, we have libnl 3.x.
#
- LIBS="-lnl-genl -lnl $LIBS"
+ LIBS="-lnl-genl-3 -lnl-3 $LIBS"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
- AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
- ],
- [
+ AC_DEFINE(HAVE_LIBNL_3_x,1,[if libnl exists and is version 3.x])
+ AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
+ AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
+ V_INCLS="$V_INCLS -I/usr/include/libnl3"
+ have_any_nl="yes"
+ ])
+
+ if test x$have_any_nl = xno ; then
+ #
+ # Try libnl 2.x
+ #
+ AC_CHECK_LIB(nl, nl_socket_alloc,
+ [
+ #
+ # Yes, we have libnl 2.x.
+ #
+ LIBS="-lnl-genl -lnl $LIBS"
+ AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
+ AC_DEFINE(HAVE_LIBNL_2_x,1,[if libnl exists and is version 2.x])
+ AC_DEFINE(HAVE_LIBNL_NLE,1,[libnl has NLE_FAILURE])
+ AC_DEFINE(HAVE_LIBNL_SOCKETS,1,[libnl has new-style socket api])
+ have_any_nl="yes"
+ ])
+ fi
+
+ if test x$have_any_nl = xno ; then
#
# No, we don't; do we have libnl 1.x?
#
@@ -453,16 +493,18 @@ linux)
#
LIBS="-lnl $LIBS"
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists])
- ],
- [
- #
- # No, we don't have libnl at all.
- #
- if test x$with_libnl = xyes ; then
- AC_MSG_ERROR([libnl support requested but libnl not found])
- fi
+ have_any_nl="yes"
])
- ])
+ fi
+
+ if test x$have_any_nl = xno ; then
+ #
+ # No, we don't have libnl at all.
+ #
+ if test x$with_libnl = xyes ; then
+ AC_MSG_ERROR([libnl support requested but libnl not found])
+ fi
+ fi
fi
AC_CHECK_HEADERS(linux/ethtool.h,,,
@@ -573,7 +615,6 @@ else
case "$V_PCAP" in
dlpi|libdlpi)
- AC_CHECK_HEADERS(sys/bufmod.h sys/dlpi_ext.h)
#
# This might be Solaris 8 or later, with
# SIOCGLIFCONF, or it might be some other OS
@@ -597,10 +638,6 @@ else
else
V_FINDALLDEVS=gifc
fi
- #
- # Needed for common functions used by pcap-[dlpi,libdlpi].c
- #
- SSRC="dlpisubs.c"
;;
*)
@@ -1076,6 +1113,45 @@ darwin*)
if test "$enable_universal" != "no"; then
case "$host_os" in
+ darwin[0-7].*)
+ #
+ # Pre-Tiger. Build only for 32-bit PowerPC; no
+ # need for any special compiler or linker flags.
+ #
+ ;;
+
+ darwin8.[0123]*)
+ #
+ # Tiger, prior to Intel support. Build for 32-bit
+ # PowerPC and 64-bit PowerPC, with 32-bit PowerPC
+ # first. (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64"
+ ;;
+
+ darwin8.[456]*)
+ #
+ # Tiger, subsequent to Intel support but prior to
+ # x86-64 support. Build for 32-bit PowerPC, 64-bit
+ # PowerPC, and x86, with 32-bit PowerPC first.
+ # (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386"
+ ;;
+
+ darwin8.*)
+ #
+ # All other Tiger, so subsequent to x86-64
+ # support. Build for 32-bit PowerPC, 64-bit
+ # PowerPC, x86, and x86-64, and with 32-bit PowerPC
+ # first. (I'm guessing that's what Apple does.)
+ #
+ V_CCOPT="$V_CCOPT -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+ LDFLAGS="$LDFLAGS -arch ppc -arch ppc64 -arch i386 -arch x86_64"
+ ;;
+
darwin9.*)
#
# Leopard. Build for 32-bit PowerPC, 64-bit
@@ -1100,11 +1176,13 @@ darwin*)
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386 -arch ppc"
;;
- darwin11.*)
+ darwin*)
#
- # Lion. Build for x86-64 and x86, with x86-64
- # first. (That's probably what Apple does,
- # given that Rosetta is gone.)
+ # Post-Snow Leopard. Build for x86-64 and
+ # x86, with x86-64 first. (That's probably what
+ # Apple does, given that Rosetta is gone.)
+ # XXX - update if and when Apple drops support
+ # for 32-bit x86 code.
#
V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
@@ -1231,6 +1309,9 @@ test "x$enable_shared" = "xno" && DYEXT="none"
AC_PROG_RANLIB
AC_CHECK_TOOL([AR], [ar])
+AC_PROG_LN_S
+AC_SUBST(LN_S)
+
AC_LBL_DEVEL(V_CCOPT)
AC_LBL_SOCKADDR_SA_LEN
@@ -1347,11 +1428,14 @@ linux*)
AC_TRY_COMPILE([
AC_INCLUDES_DEFAULT
#include <sys/socket.h>
+#include <netinet/in.h>
#include <linux/types.h>
#include <linux/netlink.h>
+#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
-#include <linux/netfilter/nfnetlink_log.h>],
+#include <linux/netfilter/nfnetlink_log.h>
+#include <linux/netfilter/nfnetlink_queue.h>],
[],
ac_cv_netfilter_can_compile=yes,
ac_cv_netfilter_can_compile=no))
@@ -1371,7 +1455,8 @@ AC_SUBST(NETFILTER_SRC)
AC_ARG_ENABLE([bluetooth],
[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
-,enable_bluetooth=yes)
+ [],
+ [enable_bluetooth=yes])
if test "x$enable_bluetooth" != "xno" ; then
dnl check for Bluetooth sniffing support
@@ -1382,6 +1467,26 @@ if test "x$enable_bluetooth" != "xno" ; then
AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
BT_SRC=pcap-bt-linux.c
AC_MSG_NOTICE(Bluetooth sniffing is supported)
+
+ #
+ # OK, does struct sockaddr_hci have an hci_channel
+ # member?
+ #
+ AC_MSG_CHECKING(if struct sockaddr_hci has hci_channel member)
+ AC_CACHE_VAL(ac_cv_lbl_sockaddr_hci_has_hci_channel,
+ AC_TRY_COMPILE(
+[
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+],
+ [u_int i = sizeof(((struct sockaddr_hci *)0)->hci_channel)],
+ ac_cv_lbl_sockaddr_hci_has_hci_channel=yes,
+ ac_cv_lbl_sockaddr_hci_has_hci_channel=no))
+ AC_MSG_RESULT($ac_cv_lbl_sockaddr_hci_has_hci_channel)
+ if test $ac_cv_lbl_sockaddr_hci_has_hci_channel = yes ; then
+ AC_DEFINE(SOCKADDR_HCI_HAS_HCI_CHANNEL,,
+ [if struct sockaddr_hci has hci_channel member])
+ fi
],
AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
)
@@ -1395,8 +1500,9 @@ if test "x$enable_bluetooth" != "xno" ; then
fi
AC_ARG_ENABLE([canusb],
-[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])]
-,enable_canusb=yes)
+[AC_HELP_STRING([--enable-canusb],[enable canusb support @<:@default=yes, if support available@:>@])],
+ [],
+ [enable_canusb=yes])
if test "x$enable_canusb" != "xno" ; then
dnl check for canusb support
@@ -1406,7 +1512,7 @@ if test "x$enable_canusb" != "xno" ; then
[
AC_DEFINE(PCAP_SUPPORT_CANUSB, 1, [target host supports canusb])
CANUSB_SRC=pcap-canusb-linux.c
- LIBS="-lusb-1.0 $LIBS"
+ LIBS="-lusb-1.0 -lpthread $LIBS"
AC_MSG_NOTICE(canusb sniffing is supported)
],
AC_MSG_NOTICE(canusb sniffing is not supported; install libusb1.0 lib devel to enable it)
@@ -1422,7 +1528,8 @@ fi
AC_ARG_ENABLE([can],
[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
-,enable_can=yes)
+ [],
+ [enable_can=yes])
if test "x$enable_can" != "xno" ; then
dnl check for CAN sniffing support
@@ -1444,6 +1551,57 @@ if test "x$enable_can" != "xno" ; then
AC_SUBST(CAN_SRC)
fi
+AC_ARG_ENABLE([dbus],
+[AC_HELP_STRING([--enable-dbus],[enable D-Bus capture support @<:@default=yes, if support available@:>@])],
+ [],
+ [enable_dbus=ifavailable])
+
+if test "x$enable_dbus" != "xno"; then
+ AC_CHECK_PROG([PKGCONFIG], [pkg-config], [pkg-config], [no])
+ if test "x$PKGCONFIG" != "xno"; then
+ AC_MSG_CHECKING([for D-Bus])
+ if "$PKGCONFIG" dbus-1; then
+ AC_MSG_RESULT([yes])
+ DBUS_CFLAGS=`"$PKGCONFIG" --cflags dbus-1`
+ DBUS_LIBS=`"$PKGCONFIG" --libs dbus-1`
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ CFLAGS="$CFLAGS $DBUS_CFLAGS"
+ LIBS="$LIBS $DBUS_LIBS"
+ AC_MSG_CHECKING(whether the D-Bus library defines dbus_connection_read_write)
+ AC_TRY_LINK(
+ [#include <string.h>
+
+ #include <time.h>
+ #include <sys/time.h>
+
+ #include <dbus/dbus.h>],
+ [return dbus_connection_read_write(NULL, 0);],
+ [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE(PCAP_SUPPORT_DBUS, 1, [support D-Bus sniffing])
+ DBUS_SRC=pcap-dbus.c
+ V_INCLS="$V_INCLS $DBUS_CFLAGS"
+ ],
+ [
+ AC_MSG_RESULT([no])
+ if test "x$enable_dbus" = "xyes"; then
+ AC_MSG_ERROR([--enable-dbus was given, but the D-Bus library doesn't define dbus_connection_read_write()])
+ fi
+ LIBS="$save_LIBS"
+ ])
+ CFLAGS="$save_CFLAGS"
+ else
+ AC_MSG_RESULT([no])
+ if test "x$enable_dbus" = "xyes"; then
+ AC_MSG_ERROR([--enable-dbus was given, but the dbus-1 package is not installed])
+ fi
+ fi
+ fi
+ AC_SUBST(PCAP_SUPPORT_DBUS)
+ AC_SUBST(DBUS_SRC)
+fi
+
dnl check for hardware timestamp support
case "$host_os" in
linux*)
@@ -1458,14 +1616,16 @@ AC_PROG_INSTALL
AC_CONFIG_HEADER(config.h)
+AC_OUTPUT_COMMANDS([if test -f .devel; then
+ echo timestamp > stamp-h
+ cat Makefile-devel-adds >> Makefile
+ make depend
+fi])
AC_OUTPUT(Makefile pcap-filter.manmisc pcap-linktype.manmisc
pcap-tstamp.manmisc pcap-savefile.manfile pcap.3pcap
pcap_compile.3pcap pcap_datalink.3pcap pcap_dump_open.3pcap
- pcap_list_datalinks.3pcap pcap_list_tstamp_types.3pcap
- pcap_open_dead.3pcap pcap_open_offline.3pcap
+ pcap_get_tstamp_precision.3pcap pcap_list_datalinks.3pcap
+ pcap_list_tstamp_types.3pcap pcap_open_dead.3pcap
+ pcap_open_offline.3pcap pcap_set_tstamp_precision.3pcap
pcap_set_tstamp_type.3pcap)
-
-if test -f .devel ; then
- make depend
-fi
exit 0
diff --git a/external/bsd/libpcap/dist/dlpisubs.c b/external/bsd/libpcap/dist/dlpisubs.c
index 3af4061543a..024a80e1e88 100644
--- a/external/bsd/libpcap/dist/dlpisubs.c
+++ b/external/bsd/libpcap/dist/dlpisubs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dlpisubs.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: dlpisubs.c,v 1.1.1.4 2013/12/31 16:57:23 christos Exp $ */
/*
* This code is derived from code formerly in pcap-dlpi.c, originally
@@ -68,6 +68,10 @@ static const char rcsid[] _U_ =
#include <stropts.h>
#include <unistd.h>
+#ifdef HAVE_LIBDLPI
+#include <libdlpi.h>
+#endif
+
#include "pcap-int.h"
#include "dlpisubs.h"
@@ -81,6 +85,7 @@ static void pcap_stream_err(const char *, int, char *);
int
pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
{
+ struct pcap_dlpi *pd = p->priv;
/*
* "ps_recv" counts packets handed to the filter, not packets
@@ -105,7 +110,7 @@ pcap_stats_dlpi(pcap_t *p, struct pcap_stat *ps)
* the kernel by libpcap, but they may include packets not
* yet read from libpcap by the application.
*/
- *ps = p->md.stat;
+ *ps = pd->stat;
/*
* Add in the drop count, as per the above comment.
@@ -122,6 +127,7 @@ int
pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
int count, u_char *bufp, int len)
{
+ struct pcap_dlpi *pd = p->priv;
int n, caplen, origlen;
u_char *ep, *pk;
struct pcap_pkthdr pkthdr;
@@ -164,7 +170,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
} else
#endif
sbp = (struct sb_hdr *)bufp;
- p->md.stat.ps_drop = sbp->sbh_drops;
+ pd->stat.ps_drop = sbp->sbh_drops;
pk = bufp + sizeof(*sbp);
bufp += sbp->sbh_totlen;
origlen = sbp->sbh_origlen;
@@ -175,7 +181,7 @@ pcap_process_pkts(pcap_t *p, pcap_handler callback, u_char *user,
pk = bufp;
bufp += caplen;
#endif
- ++p->md.stat.ps_recv;
+ ++pd->stat.ps_recv;
if (bpf_filter(p->fcode.bf_insns, pk, origlen, caplen)) {
#ifdef HAVE_SYS_BUFMOD_H
pkthdr.ts.tv_sec = sbp->sbh_timestamp.tv_sec;
@@ -269,46 +275,53 @@ pcap_process_mactype(pcap_t *p, u_int mactype)
* Push and configure the buffer module. Returns -1 for error, otherwise 0.
*/
int
-pcap_conf_bufmod(pcap_t *p, int snaplen, int timeout)
+pcap_conf_bufmod(pcap_t *p, int snaplen)
{
- int retv = 0;
-
+ struct timeval to;
bpf_u_int32 ss, chunksize;
/* Non-standard call to get the data nicely buffered. */
if (ioctl(p->fd, I_PUSH, "bufmod") != 0) {
pcap_stream_err("I_PUSH bufmod", errno, p->errbuf);
- retv = -1;
+ return (-1);
}
ss = snaplen;
if (ss > 0 &&
strioctl(p->fd, SBIOCSSNAP, sizeof(ss), (char *)&ss) != 0) {
pcap_stream_err("SBIOCSSNAP", errno, p->errbuf);
- retv = -1;
+ return (-1);
}
- /* Set up the bufmod timeout. */
- if (timeout != 0) {
- struct timeval to;
-
- to.tv_sec = timeout / 1000;
- to.tv_usec = (timeout * 1000) % 1000000;
+ if (p->opt.immediate) {
+ /* Set the timeout to zero, for immediate delivery. */
+ to.tv_sec = 0;
+ to.tv_usec = 0;
if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
pcap_stream_err("SBIOCSTIME", errno, p->errbuf);
- retv = -1;
+ return (-1);
+ }
+ } else {
+ /* Set up the bufmod timeout. */
+ if (p->opt.timeout != 0) {
+ to.tv_sec = p->opt.timeout / 1000;
+ to.tv_usec = (p->opt.timeout * 1000) % 1000000;
+ if (strioctl(p->fd, SBIOCSTIME, sizeof(to), (char *)&to) != 0) {
+ pcap_stream_err("SBIOCSTIME", errno, p->errbuf);
+ return (-1);
+ }
}
- }
- /* Set the chunk length. */
- chunksize = CHUNKSIZE;
- if (strioctl(p->fd, SBIOCSCHUNK, sizeof(chunksize), (char *)&chunksize)
- != 0) {
- pcap_stream_err("SBIOCSCHUNKP", errno, p->errbuf);
- retv = -1;
+ /* Set the chunk length. */
+ chunksize = CHUNKSIZE;
+ if (strioctl(p->fd, SBIOCSCHUNK, sizeof(chunksize), (char *)&chunksize)
+ != 0) {
+ pcap_stream_err("SBIOCSCHUNKP", errno, p->errbuf);
+ return (-1);
+ }
}
- return (retv);
+ return (0);
}
#endif /* HAVE_SYS_BUFMOD_H */
diff --git a/external/bsd/libpcap/dist/dlpisubs.h b/external/bsd/libpcap/dist/dlpisubs.h
index ea18dbee6f3..63ffab9c861 100644
--- a/external/bsd/libpcap/dist/dlpisubs.h
+++ b/external/bsd/libpcap/dist/dlpisubs.h
@@ -1,4 +1,4 @@
-/* $NetBSD: dlpisubs.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: dlpisubs.h,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */
/*
* @(#) Header: /tcpdump/master/libpcap/dlpisubs.h,v 1.2 2008-04-04 19:37:45 guy Exp
@@ -12,13 +12,27 @@ extern "C" {
#endif
/*
- * Functions used by dlpisubs.c.
+ * Private data for capturing on DLPI devices.
+ */
+struct pcap_dlpi {
+#ifdef HAVE_LIBDLPI
+ dlpi_handle_t dlpi_hd;
+#endif /* HAVE_LIBDLPI */
+#ifdef DL_HP_RAWDLS
+ int send_fd;
+#endif /* DL_HP_RAWDLS */
+
+ struct pcap_stat stat;
+};
+
+/*
+ * Functions defined by dlpisubs.c.
*/
int pcap_stats_dlpi(pcap_t *, struct pcap_stat *);
int pcap_process_pkts(pcap_t *, pcap_handler, u_char *, int, u_char *, int);
int pcap_process_mactype(pcap_t *, u_int);
#ifdef HAVE_SYS_BUFMOD_H
-int pcap_conf_bufmod(pcap_t *, int, int);
+int pcap_conf_bufmod(pcap_t *, int);
#endif
int pcap_alloc_databuf(pcap_t *);
int strioctl(int, int, int, char *);
diff --git a/external/bsd/libpcap/dist/fad-getad.c b/external/bsd/libpcap/dist/fad-getad.c
index 59ce8ed2979..7d680e47c67 100644
--- a/external/bsd/libpcap/dist/fad-getad.c
+++ b/external/bsd/libpcap/dist/fad-getad.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-getad.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: fad-getad.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
@@ -62,9 +62,15 @@ static const char rcsid[] _U_ =
#include "os-proto.h"
#endif
-#ifdef AF_PACKET
+/*
+ * We don't do this on Solaris 11 and later, as it appears there aren't
+ * any AF_PACKET addresses on interfaces, so we don't need this, and
+ * we end up including both the OS's <net/bpf.h> and our <pcap/bpf.h>,
+ * and their definitions of some data structures collide.
+ */
+#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
# ifdef HAVE_NETPACKET_PACKET_H
-/* Solaris 11 and later, Linux distributions with newer glibc */
+/* Linux distributions with newer glibc */
# include <netpacket/packet.h>
# else /* HAVE_NETPACKET_PACKET_H */
/* LynxOS, Linux distributions with older glibc */
@@ -77,7 +83,7 @@ static const char rcsid[] _U_ =
# include <linux/if_packet.h>
# endif /* __Lynx__ */
# endif /* HAVE_NETPACKET_PACKET_H */
-#endif /* AF_PACKET */
+#endif /* (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET) */
/*
* This is fun.
@@ -122,7 +128,7 @@ get_sa_len(struct sockaddr *addr)
return (sizeof (struct sockaddr_in6));
#endif
-#ifdef AF_PACKET
+#if (defined(linux) || defined(__Lynx__)) && defined(AF_PACKET)
case AF_PACKET:
return (sizeof (struct sockaddr_ll));
#endif
@@ -143,11 +149,9 @@ get_sa_len(struct sockaddr *addr)
* Returns -1 on error, 0 otherwise.
* The list, as returned through "alldevsp", may be null if no interfaces
* were up and could be opened.
- *
- * This is the implementation used on platforms that have "getifaddrs()".
*/
int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
{
pcap_if_t *devlist = NULL;
struct ifaddrs *ifap, *ifa;
@@ -275,15 +279,6 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
freeifaddrs(ifap);
- if (ret != -1) {
- /*
- * We haven't had any errors yet; do any platform-specific
- * operations to add devices.
- */
- if (pcap_platform_finddevs(&devlist, errbuf) < 0)
- ret = -1;
- }
-
if (ret == -1) {
/*
* We had an error; free the list we've been constructing.
diff --git a/external/bsd/libpcap/dist/fad-gifc.c b/external/bsd/libpcap/dist/fad-gifc.c
index 2f098aa3e62..b13fd4eb6f3 100644
--- a/external/bsd/libpcap/dist/fad-gifc.c
+++ b/external/bsd/libpcap/dist/fad-gifc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-gifc.c,v 1.1.1.3 2013/04/06 15:57:47 christos Exp $ */
+/* $NetBSD: fad-gifc.c,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
@@ -135,10 +135,11 @@ struct rtentry; /* declarations in <net/if.h> */
*
* XXX - or platforms that have other, better mechanisms but for which
* we don't yet have code to use that mechanism; I think there's a better
- * way on Linux, for example.
+ * way on Linux, for example, but if that better way is "getifaddrs()",
+ * we already have that.
*/
int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
{
pcap_if_t *devlist = NULL;
register int fd;
@@ -411,15 +412,6 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
free(buf);
(void)close(fd);
- if (ret != -1) {
- /*
- * We haven't had any errors yet; do any platform-specific
- * operations to add devices.
- */
- if (pcap_platform_finddevs(&devlist, errbuf) < 0)
- ret = -1;
- }
-
if (ret == -1) {
/*
* We had an error; free the list we've been constructing.
diff --git a/external/bsd/libpcap/dist/fad-glifc.c b/external/bsd/libpcap/dist/fad-glifc.c
index 511a9e38520..dca7f062a39 100644
--- a/external/bsd/libpcap/dist/fad-glifc.c
+++ b/external/bsd/libpcap/dist/fad-glifc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-glifc.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: fad-glifc.c,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
@@ -82,7 +82,7 @@ struct rtentry; /* declarations in <net/if.h> */
* SIOCGLIFCONF rather than SIOCGIFCONF in order to get IPv6 addresses.)
*/
int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
{
pcap_if_t *devlist = NULL;
register int fd4, fd6, fd;
@@ -364,15 +364,6 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
(void)close(fd6);
(void)close(fd4);
- if (ret != -1) {
- /*
- * We haven't had any errors yet; do any platform-specific
- * operations to add devices.
- */
- if (pcap_platform_finddevs(&devlist, errbuf) < 0)
- ret = -1;
- }
-
if (ret == -1) {
/*
* We had an error; free the list we've been constructing.
diff --git a/external/bsd/libpcap/dist/fad-null.c b/external/bsd/libpcap/dist/fad-null.c
index 7a75568219d..f5447f6225e 100644
--- a/external/bsd/libpcap/dist/fad-null.c
+++ b/external/bsd/libpcap/dist/fad-null.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-null.c,v 1.1.1.3 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: fad-null.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
@@ -55,7 +55,7 @@ static const char rcsid[] _U_ =
* packet capture.
*/
int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
{
/*
* Succeed, but don't return any interfaces; we return only those
diff --git a/external/bsd/libpcap/dist/fad-sita.c b/external/bsd/libpcap/dist/fad-sita.c
index bc5f6e1687e..c7500d9ba17 100644
--- a/external/bsd/libpcap/dist/fad-sita.c
+++ b/external/bsd/libpcap/dist/fad-sita.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-sita.c,v 1.1.1.2 2013/04/06 15:57:44 christos Exp $ */
+/* $NetBSD: fad-sita.c,v 1.1.1.3 2013/12/31 16:57:24 christos Exp $ */
/*
* fad-sita.c: Packet capture interface additions for SITA ACN devices
@@ -39,7 +39,7 @@
extern pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
-int pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf) {
+int pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf) {
//printf("pcap_findalldevs()\n"); // fulko
diff --git a/external/bsd/libpcap/dist/fad-win32.c b/external/bsd/libpcap/dist/fad-win32.c
index 103f59e897f..6b2424c4860 100644
--- a/external/bsd/libpcap/dist/fad-win32.c
+++ b/external/bsd/libpcap/dist/fad-win32.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fad-win32.c,v 1.1.1.3 2013/04/06 15:57:47 christos Exp $ */
+/* $NetBSD: fad-win32.c,v 1.1.1.4 2013/12/31 16:57:21 christos Exp $ */
/*
* Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
@@ -218,7 +218,7 @@ pcap_add_if_win32(pcap_if_t **devlist, char *name, const char *desc,
* Win32 implementation, based on WinPcap
*/
int
-pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
+pcap_findalldevs_interfaces(pcap_if_t **alldevsp, char *errbuf)
{
pcap_if_t *devlist = NULL;
int ret = 0;
@@ -227,6 +227,24 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
ULONG NameLength;
char *name;
+ /*
+ * Find out how big a buffer we need.
+ *
+ * This call should always return FALSE; if the error is
+ * ERROR_INSUFFICIENT_BUFFER, NameLength will be set to
+ * the size of the buffer we need, otherwise there's a
+ * problem, and NameLength should be set to 0.
+ *
+ * It shouldn't require NameLength to be set, but,
+ * at least as of WinPcap 4.1.3, it checks whether
+ * NameLength is big enough before it checks for a
+ * NULL buffer argument, so, while it'll still do
+ * the right thing if NameLength is uninitialized and
+ * whatever junk happens to be there is big enough
+ * (because the pointer argument will be null), it's
+ * still reading an uninitialized variable.
+ */
+ NameLength = 0;
if (!PacketGetAdapterNames(NULL, &NameLength))
{
DWORD last_error = GetLastError();
diff --git a/external/bsd/libpcap/dist/gencode.h b/external/bsd/libpcap/dist/gencode.h
index bfeeb6f6c0f..5fd439f34a3 100644
--- a/external/bsd/libpcap/dist/gencode.h
+++ b/external/bsd/libpcap/dist/gencode.h
@@ -1,4 +1,4 @@
-/* $NetBSD: gencode.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */
+/* $NetBSD: gencode.h,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -188,12 +188,23 @@
#define M_LSSU 23 /* LSSU */
#define M_MSU 24 /* MSU */
+/* MTP2 HSL types */
+#define MH_FISU 25 /* FISU for HSL */
+#define MH_LSSU 26 /* LSSU */
+#define MH_MSU 27 /* MSU */
+
/* MTP3 field types */
#define M_SIO 1
#define M_OPC 2
#define M_DPC 3
#define M_SLS 4
+/* MTP3 field types in case of MTP2 HSL */
+#define MH_SIO 5
+#define MH_OPC 6
+#define MH_DPC 7
+#define MH_SLS 8
+
struct slist;
@@ -305,7 +316,7 @@ struct block *gen_vlan(int);
struct block *gen_mpls(int);
struct block *gen_pppoed(void);
-struct block *gen_pppoes(void);
+struct block *gen_pppoes(int);
struct block *gen_atmfield_code(int atmfield, bpf_int32 jvalue, bpf_u_int32 jtype, int reverse);
struct block *gen_atmtype_abbrev(int type);
@@ -327,7 +338,11 @@ struct block *gen_p80211_fcdir(int);
void bpf_optimize(struct block **);
void bpf_error(const char *, ...)
- __attribute__((noreturn, format (printf, 1, 2)));
+ __attribute__((noreturn))
+#ifdef __ATTRIBUTE___FORMAT_OK
+ __attribute__((format (printf, 1, 2)))
+#endif /* __ATTRIBUTE___FORMAT_OK */
+ ;
void finish_parse(struct block *);
char *sdup(const char *);
diff --git a/external/bsd/libpcap/dist/mkdep b/external/bsd/libpcap/dist/mkdep
index b41a00e1da4..bfe4a2614a4 100755
--- a/external/bsd/libpcap/dist/mkdep
+++ b/external/bsd/libpcap/dist/mkdep
@@ -18,6 +18,7 @@ export PATH
MAKE=Makefile # default makefile name is "Makefile"
CC=cc # default C compiler is "cc"
+DEPENDENCY_CFLAG=-M # default dependency-generation flag is -M
while :
do case "$1" in
@@ -31,6 +32,11 @@ while :
MAKE=$2
shift; shift ;;
+ # -m allows you to specify the dependency-generation flag
+ -m)
+ DEPENDENCY_CFLAG=$2
+ shift; shift ;;
+
# the -p flag produces "program: program.c" style dependencies
# so .o's don't get produced
-p)
@@ -42,7 +48,7 @@ while :
done
if [ $# = 0 ] ; then
- echo 'usage: mkdep [-p] [-c cc] [-f makefile] [flags] file ...'
+ echo 'usage: mkdep [-p] [-c cc] [-f makefile] [-m dependency-cflag] [flags] file ...'
exit 1
fi
@@ -74,7 +80,7 @@ _EOF_
# sed -e 's/:[^"]*"\([^"]*\)".*/: \1/' -e 's/\.c/.o/' |
# XXX this doesn't work with things like "-DDECLWAITSTATUS=union\ wait"
-$CC -M $* |
+$CC $DEPENDENCY_CFLAG $* |
sed "
s; \./; ;g
$SED" |
diff --git a/external/bsd/libpcap/dist/nametoaddr.c b/external/bsd/libpcap/dist/nametoaddr.c
index 610d407665d..ef759a64248 100644
--- a/external/bsd/libpcap/dist/nametoaddr.c
+++ b/external/bsd/libpcap/dist/nametoaddr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: nametoaddr.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: nametoaddr.c,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
@@ -249,6 +249,7 @@ pcap_nametoportrange(const char *name, int *port1, int *port2, int *proto)
free(cpy);
return 0;
}
+ free(cpy);
if (*proto != save_proto)
*proto = PROTO_UNDEF;
@@ -416,6 +417,8 @@ pcap_ether_aton(const char *s)
register u_int d;
e = ep = (u_char *)malloc(6);
+ if (e == NULL)
+ return (NULL);
while (*s) {
if (*s == ':' || *s == '.' || *s == '-')
diff --git a/external/bsd/libpcap/dist/pcap-bt-linux.c b/external/bsd/libpcap/dist/pcap-bt-linux.c
index 43168cf0d46..55c91b0bf66 100644
--- a/external/bsd/libpcap/dist/pcap-bt-linux.c
+++ b/external/bsd/libpcap/dist/pcap-bt-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-bt-linux.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-bt-linux.c,v 1.1.1.4 2013/12/31 16:57:28 christos Exp $ */
/*
* Copyright (c) 2006 Paolo Abeni (Italy)
@@ -72,15 +72,21 @@ static int bt_inject_linux(pcap_t *, const void *, size_t);
static int bt_setdirection_linux(pcap_t *, pcap_direction_t);
static int bt_stats_linux(pcap_t *, struct pcap_stat *);
+/*
+ * Private data for capturing on Linux Bluetooth devices.
+ */
+struct pcap_bt {
+ int dev_id; /* device ID of device we're bound to */
+};
+
int
-bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
+bt_findalldevs(pcap_if_t **alldevsp, char *err_str)
{
- pcap_if_t *found_dev = *alldevsp;
struct hci_dev_list_req *dev_list;
struct hci_dev_req *dev_req;
int i, sock;
int ret = 0;
-
+
sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
if (sock < 0)
{
@@ -119,7 +125,7 @@ bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
snprintf(dev_name, 20, BT_IFACE"%d", dev_req->dev_id);
snprintf(dev_descr, 30, "Bluetooth adapter number %d", i);
- if (pcap_add_if(&found_dev, dev_name, 0,
+ if (pcap_add_if(alldevsp, dev_name, 0,
dev_descr, err_str) < 0)
{
ret = -1;
@@ -137,11 +143,41 @@ done:
}
pcap_t *
-bt_create(const char *device, char *ebuf)
+bt_create(const char *device, char *ebuf, int *is_ours)
{
+ const char *cp;
+ char *cpend;
+ long devnum;
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ /* Does this look like a Bluetooth device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ /* Does it begin with BT_IFACE? */
+ if (strncmp(cp, BT_IFACE, sizeof BT_IFACE - 1) != 0) {
+ /* Nope, doesn't begin with BT_IFACE */
+ *is_ours = 0;
+ return NULL;
+ }
+ /* Yes - is BT_IFACE followed by a number? */
+ cp += sizeof BT_IFACE - 1;
+ devnum = strtol(cp, &cpend, 10);
+ if (cpend == cp || *cpend != '\0') {
+ /* Not followed by a number. */
+ *is_ours = 0;
+ return NULL;
+ }
+ if (devnum < 0) {
+ /* Followed by a non-valid number. */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_bt));
if (p == NULL)
return (NULL);
@@ -152,6 +188,7 @@ bt_create(const char *device, char *ebuf)
static int
bt_activate(pcap_t* handle)
{
+ struct pcap_bt *handlep = handle->priv;
struct sockaddr_hci addr;
int opt;
int dev_id;
@@ -180,7 +217,7 @@ bt_activate(pcap_t* handle)
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
handle->stats_op = bt_stats_linux;
- handle->md.ifindex = dev_id;
+ handlep->dev_id = dev_id;
/* Create HCI socket */
handle->fd = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
@@ -225,10 +262,13 @@ bt_activate(pcap_t* handle)
/* Bind socket to the HCI device */
addr.hci_family = AF_BLUETOOTH;
- addr.hci_dev = handle->md.ifindex;
+ addr.hci_dev = handlep->dev_id;
+#ifdef SOCKADDR_HCI_HAS_HCI_CHANNEL
+ addr.hci_channel = HCI_CHANNEL_RAW;
+#endif
if (bind(handle->fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "Can't attach to device %d: %s", handle->md.ifindex,
+ "Can't attach to device %d: %s", handlep->dev_id,
strerror(errno));
goto close_fail;
}
@@ -343,10 +383,11 @@ bt_inject_linux(pcap_t *handle, const void *buf, size_t size)
static int
bt_stats_linux(pcap_t *handle, struct pcap_stat *stats)
{
+ struct pcap_bt *handlep = handle->priv;
int ret;
struct hci_dev_info dev_info;
struct hci_dev_stats * s = &dev_info.stat;
- dev_info.dev_id = handle->md.ifindex;
+ dev_info.dev_id = handlep->dev_id;
/* ignore eintr */
do {
diff --git a/external/bsd/libpcap/dist/pcap-bt-linux.h b/external/bsd/libpcap/dist/pcap-bt-linux.h
index 365c1f507bc..283959ef3a8 100644
--- a/external/bsd/libpcap/dist/pcap-bt-linux.h
+++ b/external/bsd/libpcap/dist/pcap-bt-linux.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-bt-linux.h,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */
+/* $NetBSD: pcap-bt-linux.h,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */
/*
* Copyright (c) 2006 Paolo Abeni (Italy)
@@ -38,5 +38,5 @@
/*
* Prototypes for Bluetooth-related functions
*/
-int bt_platform_finddevs(pcap_if_t **alldevsp, char *err_str);
-pcap_t *bt_create(const char *device, char *ebuf);
+int bt_findalldevs(pcap_if_t **alldevsp, char *err_str);
+pcap_t *bt_create(const char *device, char *ebuf, int *is_ours);
diff --git a/external/bsd/libpcap/dist/pcap-can-linux.c b/external/bsd/libpcap/dist/pcap-can-linux.c
index fc8c262360c..bcefc92a805 100644
--- a/external/bsd/libpcap/dist/pcap-can-linux.c
+++ b/external/bsd/libpcap/dist/pcap-can-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-can-linux.c,v 1.1.1.2 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-can-linux.c,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */
/*
* Copyright (c) 2009 Felix Obenhuber
@@ -74,12 +74,66 @@ static int can_setfilter_linux(pcap_t *, struct bpf_program *);
static int can_setdirection_linux(pcap_t *, pcap_direction_t);
static int can_stats_linux(pcap_t *, struct pcap_stat *);
+/*
+ * Private data for capturing on Linux CANbus devices.
+ */
+struct pcap_can {
+ int ifindex; /* interface index of device we're bound to */
+};
+
+int
+can_findalldevs(pcap_if_t **devlistp, char *errbuf)
+{
+ /*
+ * There are no platform-specific devices since each device
+ * exists as a regular network interface.
+ *
+ * XXX - true?
+ */
+ return 0;
+}
+
pcap_t *
-can_create(const char *device, char *ebuf)
+can_create(const char *device, char *ebuf, int *is_ours)
{
+ const char *cp;
+ char *cpend;
+ long devnum;
pcap_t* p;
- p = pcap_create_common(device, ebuf);
+ /* Does this look like a CANbus device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ /* Does it begin with "can" or "vcan"? */
+ if (strncmp(cp, "can", 3) == 0) {
+ /* Begins with "can" */
+ cp += 3; /* skip past "can" */
+ } else if (strncmp(cp, "vcan", 4) == 0) {
+ /* Begins with "vcan" */
+ cp += 4;
+ } else {
+ /* Nope, doesn't begin with "can" or "vcan" */
+ *is_ours = 0;
+ return NULL;
+ }
+ /* Yes - is "can" or "vcan" followed by a number from 0? */
+ devnum = strtol(cp, &cpend, 10);
+ if (cpend == cp || *cpend != '\0') {
+ /* Not followed by a number. */
+ *is_ours = 0;
+ return NULL;
+ }
+ if (devnum < 0) {
+ /* Followed by a non-valid number. */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_can));
if (p == NULL)
return (NULL);
@@ -91,6 +145,7 @@ can_create(const char *device, char *ebuf)
static int
can_activate(pcap_t* handle)
{
+ struct pcap_can *handlep = handle->priv;
struct sockaddr_can addr;
struct ifreq ifr;
@@ -127,7 +182,7 @@ can_activate(pcap_t* handle)
pcap_cleanup_live_common(handle);
return PCAP_ERROR;
}
- handle->md.ifindex = ifr.ifr_ifindex;
+ handlep->ifindex = ifr.ifr_ifindex;
/* allocate butter */
handle->buffer = malloc(handle->bufsize);
@@ -141,11 +196,11 @@ can_activate(pcap_t* handle)
/* Bind to the socket */
addr.can_family = AF_CAN;
- addr.can_ifindex = handle->md.ifindex;
+ addr.can_ifindex = handlep->ifindex;
if( bind( handle->fd, (struct sockaddr*)&addr, sizeof(addr) ) < 0 )
{
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't attach to device %d %d:%s",
- handle->md.ifindex, errno, strerror(errno));
+ handlep->ifindex, errno, strerror(errno));
pcap_cleanup_live_common(handle);
return PCAP_ERROR;
}
@@ -154,7 +209,7 @@ can_activate(pcap_t* handle)
{
/* Monitor mode doesn't apply to CAN devices. */
pcap_cleanup_live_common(handle);
- return PCAP_ERROR;
+ return PCAP_ERROR_RFMON_NOTSUP;
}
handle->selectable_fd = handle->fd;
diff --git a/external/bsd/libpcap/dist/pcap-can-linux.h b/external/bsd/libpcap/dist/pcap-can-linux.h
index 875454b19a1..9e48c81bf21 100644
--- a/external/bsd/libpcap/dist/pcap-can-linux.h
+++ b/external/bsd/libpcap/dist/pcap-can-linux.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-can-linux.h,v 1.1.1.2 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-can-linux.h,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */
/*
* Copyright (c) 2009 Felix Obenhuber
@@ -34,4 +34,5 @@
/*
* Prototypes for SocketCAN related functions
*/
-pcap_t* can_create(const char *device, char *ebuf);
+pcap_t* can_create(const char *device, char *ebuf, int *is_ours);
+int can_findalldevs(pcap_if_t **devlistp, char *errbuf);
diff --git a/external/bsd/libpcap/dist/pcap-canusb-linux.c b/external/bsd/libpcap/dist/pcap-canusb-linux.c
index 4503341f164..ab29ede8c09 100644
--- a/external/bsd/libpcap/dist/pcap-canusb-linux.c
+++ b/external/bsd/libpcap/dist/pcap-canusb-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-canusb-linux.c,v 1.1.1.1 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-canusb-linux.c,v 1.1.1.2 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 2009 Felix Obenhuber
@@ -40,12 +40,14 @@
#include <libusb-1.0/libusb.h>
-#include "pcap-int.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
+#include <pthread.h>
+#include "pcap-int.h"
+#include "pcap-canusb-linux.h"
#define CANUSB_IFACE "canusb"
@@ -75,31 +77,33 @@ struct CAN_Msg
uint8_t data[8];
};
-struct canusb_t
-{
- libusb_context *ctx;
- libusb_device_handle *dev;
- char* src;
- pthread_t worker;
- int rdpipe, wrpipe;
- volatile int* loop;
+/*
+ * Private data for capturing on Linux CANbus USB devices.
+ */
+struct pcap_canusb {
+ libusb_context *ctx;
+ libusb_device_handle *dev;
+ pthread_t worker;
+ int rdpipe, wrpipe;
+ volatile int loop;
};
-static struct canusb_t canusb;
-static volatile int loop;
-
-
-
-int canusb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
+int canusb_findalldevs(pcap_if_t **alldevsp, char *err_str)
{
libusb_context *fdctx;
libusb_device** devs;
unsigned char sernum[65];
- unsigned char buf[96];
int cnt, i;
- libusb_init(&fdctx);
-
+ if (libusb_init(&fdctx) != 0) {
+ /*
+ * XXX - if this doesn't just mean "no USB file system mounted",
+ * perhaps we should report a real error rather than just
+ * saying "no CANUSB devices".
+ */
+ return 0;
+ }
+
cnt = libusb_get_device_list(fdctx,&devs);
for(i=0;i<cnt;i++)
@@ -110,27 +114,28 @@ int canusb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
libusb_get_device_descriptor(devs[i],&desc);
if ((desc.idVendor != CANUSB_VID) || (desc.idProduct != CANUSB_PID))
- continue; //It is not, check next device
+ continue; //It is not, check next device
//It is!
libusb_device_handle *dh = NULL;
- if (ret = libusb_open(devs[i],&dh) == 0)
+ if ((ret = libusb_open(devs[i],&dh)) == 0)
{
- char dev_name[30];
- char dev_descr[50];
+ char dev_name[30];
+ char dev_descr[50];
int n = libusb_get_string_descriptor_ascii(dh,desc.iSerialNumber,sernum,64);
sernum[n] = 0;
- snprintf(dev_name, 30, CANUSB_IFACE"%s", sernum);
- snprintf(dev_descr, 50, "CanUSB [%s]", sernum);
+ snprintf(dev_name, 30, CANUSB_IFACE"%s", sernum);
+ snprintf(dev_descr, 50, "CanUSB [%s]", sernum);
libusb_close(dh);
if (pcap_add_if(alldevsp, dev_name, 0, dev_descr, err_str) < 0)
{
- libusb_free_device_list(devs,1);
- return -1;
+ libusb_free_device_list(devs,1);
+ libusb_exit(fdctx);
+ return -1;
}
}
}
@@ -142,7 +147,6 @@ int canusb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
static libusb_device_handle* canusb_opendevice(struct libusb_context *ctx, char* devserial)
{
- libusb_device_handle* dh;
libusb_device** devs;
unsigned char serial[65];
int cnt,i,n;
@@ -166,7 +170,7 @@ static libusb_device_handle* canusb_opendevice(struct libusb_context *ctx, char*
n = libusb_get_string_descriptor_ascii(dh,desc.iSerialNumber,serial,64);
serial[n] = 0;
- if ((devserial) && (strcmp(serial,devserial) != 0))
+ if ((devserial) && (strcmp((char *)serial,devserial) != 0))
{
libusb_close(dh);
continue;
@@ -201,144 +205,184 @@ static libusb_device_handle* canusb_opendevice(struct libusb_context *ctx, char*
pcap_t *
-canusb_create(const char *device, char *ebuf)
+canusb_create(const char *device, char *ebuf, int *is_ours)
{
- pcap_t* p;
-
- libusb_init(&canusb.ctx);
-
- p = pcap_create_common(device, ebuf);
- if (p == NULL)
- return (NULL);
-
- memset(&canusb, 0x00, sizeof(canusb));
-
-
- p->activate_op = canusb_activate;
-
- canusb.src = strdup(p->opt.source);
- return (p);
+ const char *cp;
+ char *cpend;
+ long devnum;
+ pcap_t* p;
+ struct pcap_canusb *canusb;
+
+ /* Does this look like a DAG device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ /* Does it begin with "canusb"? */
+ if (strncmp(cp, "canusb", 6) != 0) {
+ /* Nope, doesn't begin with "canusb" */
+ *is_ours = 0;
+ return NULL;
+ }
+ /* Yes - is "canusb" followed by a number? */
+ cp += 6;
+ devnum = strtol(cp, &cpend, 10);
+ if (cpend == cp || *cpend != '\0') {
+ /* Not followed by a number. */
+ *is_ours = 0;
+ return NULL;
+ }
+ if (devnum < 0) {
+ /* Followed by a non-valid number. */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_canusb));
+ if (p == NULL)
+ return (NULL);
+
+ canusb = p->priv;
+ canusb->ctx = NULL;
+ canusb->dev = NULL;
+ canusb->rdpipe = -1;
+ canusb->wrpipe = -1;
+
+ p->activate_op = canusb_activate;
+
+ return (p);
}
-static void* canusb_capture_thread(struct canusb_t *canusb)
+static void* canusb_capture_thread(void *arg)
{
- struct libusb_context *ctx;
- libusb_device_handle *dev;
-
- int i, n;
- struct
- {
- uint8_t rxsz, txsz;
- } status;
-
- libusb_init(&ctx);
-
- char *serial = canusb->src + strlen(CANUSB_IFACE);
- dev = canusb_opendevice(ctx, serial);
+ struct pcap_canusb *canusb = arg;
+ int i;
+ struct
+ {
+ uint8_t rxsz, txsz;
+ } status;
- fcntl(canusb->wrpipe, F_SETFL, O_NONBLOCK);
+ fcntl(canusb->wrpipe, F_SETFL, O_NONBLOCK);
- while(*canusb->loop)
- {
- int sz, ret;
- struct CAN_Msg msg;
+ while(canusb->loop)
+ {
+ int sz;
+ struct CAN_Msg msg;
- libusb_interrupt_transfer(dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
- //HACK!!!!! -> drop buffered data, read new one by reading twice.
- ret = libusb_interrupt_transfer(dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
+ libusb_interrupt_transfer(canusb->dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
+ //HACK!!!!! -> drop buffered data, read new one by reading twice.
+ libusb_interrupt_transfer(canusb->dev, 0x81, (unsigned char*)&status, sizeof(status), &sz, 100);
- for(i = 0; i<status.rxsz; i++)
- {
- libusb_bulk_transfer(dev, 0x85, (unsigned char*)&msg, sizeof(msg), &sz, 100);
- n = write(canusb->wrpipe, &msg, sizeof(msg));
- }
+ for(i = 0; i<status.rxsz; i++)
+ {
+ libusb_bulk_transfer(canusb->dev, 0x85, (unsigned char*)&msg, sizeof(msg), &sz, 100);
+ write(canusb->wrpipe, &msg, sizeof(msg));
+ }
- }
-
- libusb_close(dev);
- libusb_exit(ctx);
+ }
- return NULL;
+ return NULL;
}
-static int canusb_startcapture(struct canusb_t* this)
+static int canusb_startcapture(struct pcap_canusb* this)
{
- int pipefd[2];
+ int pipefd[2];
- if (pipe(pipefd) == -1) return -1;
+ if (pipe(pipefd) == -1)
+ return -1;
- canusb.rdpipe = pipefd[0];
- canusb.wrpipe = pipefd[1];
- canusb.loop = &loop;
+ this->rdpipe = pipefd[0];
+ this->wrpipe = pipefd[1];
- loop = 1;
- pthread_create(&this->worker, NULL, canusb_capture_thread, &canusb);
+ this->loop = 1;
+ pthread_create(&this->worker, NULL, canusb_capture_thread, this);
- return canusb.rdpipe;
+ return this->rdpipe;
}
-static void canusb_clearbufs(struct canusb_t* this)
+static void canusb_clearbufs(struct pcap_canusb* this)
{
- unsigned char cmd[16];
- int al;
+ unsigned char cmd[16];
+ int al;
- cmd[0] = 1; //Empty incoming buffer
- cmd[1] = 1; //Empty outgoing buffer
- cmd[3] = 0; //Not a write to serial number
- memset(&cmd[4],0,16-4);
+ cmd[0] = 1; //Empty incoming buffer
+ cmd[1] = 1; //Empty outgoing buffer
+ cmd[3] = 0; //Not a write to serial number
+ memset(&cmd[4],0,16-4);
- libusb_interrupt_transfer(this->dev, 0x1,cmd,16,&al,100);
+ libusb_interrupt_transfer(this->dev, 0x1,cmd,16,&al,100);
}
static void canusb_close(pcap_t* handle)
{
- loop = 0;
- pthread_join(canusb.worker, NULL);
-
- if (canusb.dev)
- {
- libusb_close(canusb.dev);
- canusb.dev = NULL;
- }
+ struct pcap_canusb *canusb = handle->priv;
+
+ canusb->loop = 0;
+ pthread_join(canusb->worker, NULL);
+
+ if (canusb->dev)
+ {
+ libusb_close(canusb->dev);
+ canusb->dev = NULL;
+ }
+ if (canusb->ctx)
+ {
+ libusb_exit(canusb->ctx);
+ canusb->ctx = NULL;
+ }
}
static int canusb_activate(pcap_t* handle)
{
- handle->read_op = canusb_read_linux;
-
- handle->inject_op = canusb_inject_linux;
- handle->setfilter_op = canusb_setfilter_linux;
- handle->setdirection_op = canusb_setdirection_linux;
- handle->getnonblock_op = pcap_getnonblock_fd;
- handle->setnonblock_op = pcap_setnonblock_fd;
- handle->stats_op = canusb_stats_linux;
- handle->cleanup_op = canusb_close;
-
- /* Initialize some components of the pcap structure. */
- handle->bufsize = 32;
- handle->offset = 8;
- handle->linktype = DLT_CAN_SOCKETCAN;
- handle->set_datalink_op = NULL;
-
- char* serial = handle->opt.source + strlen("canusb");
-
- canusb.dev = canusb_opendevice(canusb.ctx,serial);
- if (!canusb.dev)
- {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't open USB Device:");
- return PCAP_ERROR;
- }
-
- canusb_clearbufs(&canusb);
-
- handle->fd = canusb_startcapture(&canusb);
- handle->selectable_fd = handle->fd;
-
- return 0;
+ struct pcap_canusb *canusb = handle->priv;
+ char *serial;
+
+ if (libusb_init(&canusb->ctx) != 0) {
+ /*
+ * XXX - what causes this to fail?
+ */
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "libusb_init() failed");
+ return PCAP_ERROR;
+ }
+
+ handle->read_op = canusb_read_linux;
+
+ handle->inject_op = canusb_inject_linux;
+ handle->setfilter_op = canusb_setfilter_linux;
+ handle->setdirection_op = canusb_setdirection_linux;
+ handle->getnonblock_op = pcap_getnonblock_fd;
+ handle->setnonblock_op = pcap_setnonblock_fd;
+ handle->stats_op = canusb_stats_linux;
+ handle->cleanup_op = canusb_close;
+
+ /* Initialize some components of the pcap structure. */
+ handle->bufsize = 32;
+ handle->offset = 8;
+ handle->linktype = DLT_CAN_SOCKETCAN;
+ handle->set_datalink_op = NULL;
+
+ serial = handle->opt.source + strlen(CANUSB_IFACE);
+
+ canusb->dev = canusb_opendevice(canusb->ctx, serial);
+ if (!canusb->dev)
+ {
+ libusb_exit(canusb->ctx);
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't open USB Device");
+ return PCAP_ERROR;
+ }
+
+ canusb_clearbufs(canusb);
+
+ handle->fd = canusb_startcapture(canusb);
+ handle->selectable_fd = handle->fd;
+
+ return 0;
}
@@ -347,83 +391,83 @@ static int canusb_activate(pcap_t* handle)
static int
canusb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
{
- static struct timeval firstpacket = { -1, -1};
-
- int msgsent = 0;
- int i = 0;
- struct CAN_Msg msg;
- struct pcap_pkthdr pkth;
+ static struct timeval firstpacket = { -1, -1};
+ int i = 0;
+ struct CAN_Msg msg;
+ struct pcap_pkthdr pkth;
- while(i < max_packets)
- {
- usleep(10 * 1000);
- int n = read(handle->fd, &msg, sizeof(msg));
- if (n <= 0) break;
- pkth.caplen = pkth.len = n;
- pkth.caplen -= 4;
- pkth.caplen -= 8 - msg.length;
+ while(i < max_packets)
+ {
+ int n;
+ usleep(10 * 1000);
+ n = read(handle->fd, &msg, sizeof(msg));
+ if (n <= 0)
+ break;
+ pkth.caplen = pkth.len = n;
+ pkth.caplen -= 4;
+ pkth.caplen -= 8 - msg.length;
- if ((firstpacket.tv_sec == -1) && (firstpacket.tv_usec == -1))
- gettimeofday(&firstpacket, NULL);
+ if ((firstpacket.tv_sec == -1) && (firstpacket.tv_usec == -1))
+ gettimeofday(&firstpacket, NULL);
- pkth.ts.tv_usec = firstpacket.tv_usec + (msg.timestamp % 100) * 10000;
- pkth.ts.tv_sec = firstpacket.tv_usec + (msg.timestamp / 100);
- if (pkth.ts.tv_usec > 1000000)
- {
- pkth.ts.tv_usec -= 1000000;
- pkth.ts.tv_sec++;
- }
+ pkth.ts.tv_usec = firstpacket.tv_usec + (msg.timestamp % 100) * 10000;
+ pkth.ts.tv_sec = firstpacket.tv_usec + (msg.timestamp / 100);
+ if (pkth.ts.tv_usec > 1000000)
+ {
+ pkth.ts.tv_usec -= 1000000;
+ pkth.ts.tv_sec++;
+ }
- callback(user, &pkth, (void*)&msg.id);
- i++;
- }
+ callback(user, &pkth, (void*)&msg.id);
+ i++;
+ }
- return i;
+ return i;
}
static int
canusb_inject_linux(pcap_t *handle, const void *buf, size_t size)
{
- /* not yet implemented */
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on canusb devices");
- return (-1);
+ /* not yet implemented */
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on canusb devices");
+ return (-1);
}
static int
canusb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
{
- /* not yet implemented */
- stats->ps_recv = 0; /* number of packets received */
- stats->ps_drop = 0; /* number of packets dropped */
- stats->ps_ifdrop = 0; /* drops by interface -- only supported on some platforms */
- return 0;
+ /* not yet implemented */
+ stats->ps_recv = 0; /* number of packets received */
+ stats->ps_drop = 0; /* number of packets dropped */
+ stats->ps_ifdrop = 0; /* drops by interface -- only supported on some platforms */
+ return 0;
}
static int
canusb_setfilter_linux(pcap_t *p, struct bpf_program *fp)
{
- /* not yet implemented */
- return 0;
+ /* not yet implemented */
+ return 0;
}
static int
canusb_setdirection_linux(pcap_t *p, pcap_direction_t d)
{
- /* no support for PCAP_D_OUT */
- if (d == PCAP_D_OUT)
- {
- snprintf(p->errbuf, sizeof(p->errbuf),
- "Setting direction to PCAP_D_OUT is not supported on this interface");
- return -1;
- }
+ /* no support for PCAP_D_OUT */
+ if (d == PCAP_D_OUT)
+ {
+ snprintf(p->errbuf, sizeof(p->errbuf),
+ "Setting direction to PCAP_D_OUT is not supported on this interface");
+ return -1;
+ }
- p->direction = d;
+ p->direction = d;
- return 0;
+ return 0;
}
diff --git a/external/bsd/libpcap/dist/pcap-canusb-linux.h b/external/bsd/libpcap/dist/pcap-canusb-linux.h
index db60973ce13..aa7950eddff 100644
--- a/external/bsd/libpcap/dist/pcap-canusb-linux.h
+++ b/external/bsd/libpcap/dist/pcap-canusb-linux.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-canusb-linux.h,v 1.1.1.1 2013/04/06 15:57:44 christos Exp $ */
+/* $NetBSD: pcap-canusb-linux.h,v 1.1.1.2 2013/12/31 16:57:21 christos Exp $ */
/*
* Copyright (c) 2009 Felix Obenhuber
@@ -34,6 +34,6 @@
/*
* Prototypes for SocketCAN related functions
*/
-pcap_t* canusb_create(const char *device, char *ebuf);
-int canusb_listdevices(pcap_if_t **pdevlist, char* errbuf);
+pcap_t* canusb_create(const char *device, char *ebuf, int *is_ours);
+int canusb_findalldevs(pcap_if_t **pdevlist, char* errbuf);
diff --git a/external/bsd/libpcap/dist/pcap-common.c b/external/bsd/libpcap/dist/pcap-common.c
index 9736839fcff..f8abcfc6ecf 100644
--- a/external/bsd/libpcap/dist/pcap-common.c
+++ b/external/bsd/libpcap/dist/pcap-common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-common.c,v 1.1.1.3 2013/04/06 15:57:47 christos Exp $ */
+/* $NetBSD: pcap-common.c,v 1.1.1.4 2013/12/31 16:57:28 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -843,7 +843,7 @@
#define LINKTYPE_NETANALYZER_TRANSPARENT 241
/*
- * IP-over-Infiniband, as specified by RFC 4391.
+ * IP-over-InfiniBand, as specified by RFC 4391.
*
* Requested by Petr Sumbera <petr.sumbera@oracle.com>.
*/
@@ -885,7 +885,56 @@
*/
#define LINKTYPE_PFSYNC 246
-#define LINKTYPE_MATCHING_MAX 246 /* highest value in the "matching" range */
+/*
+ * Raw InfiniBand packets, starting with the Local Routing Header.
+ *
+ * Requested by Oren Kladnitsky <orenk@mellanox.com>.
+ */
+#define LINKTYPE_INFINIBAND 247
+
+/*
+ * SCTP, with no lower-level protocols (i.e., no IPv4 or IPv6).
+ *
+ * Requested by Michael Tuexen <Michael.Tuexen@lurchi.franken.de>.
+ */
+#define LINKTYPE_SCTP 248
+
+/*
+ * USB packets, beginning with a USBPcap header.
+ *
+ * Requested by Tomasz Mon <desowin@gmail.com>
+ */
+#define LINKTYPE_USBPCAP 249
+
+/*
+ * Schweitzer Engineering Laboratories "RTAC" product serial-line
+ * packets.
+ *
+ * Requested by Chris Bontje <chris_bontje@selinc.com>.
+ */
+#define DLT_RTAC_SERIAL 250
+
+/*
+ * Bluetooth Low Energy air interface link-layer packets.
+ *
+ * Requested by Mike Kershaw <dragorn@kismetwireless.net>.
+ */
+#define LINKTYPE_BLUETOOTH_LE_LL 251
+
+/*
+ * Link-layer header type for upper-protocol layer PDU saves from wireshark.
+ *
+ * the actual contents are determined by two TAGs stored with each
+ * packet:
+ * EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
+ * original packet.
+ *
+ * EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
+ * that can make sense of the data stored.
+ */
+#define LINKTYPE_WIRESHARK_UPPER_PDU 252
+
+#define LINKTYPE_MATCHING_MAX 252 /* highest value in the "matching" range */
static struct linktype_map {
int dlt;
diff --git a/external/bsd/libpcap/dist/pcap-dag.c b/external/bsd/libpcap/dist/pcap-dag.c
index 99ab94e09cf..30798098727 100644
--- a/external/bsd/libpcap/dist/pcap-dag.c
+++ b/external/bsd/libpcap/dist/pcap-dag.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-dag.c,v 1.1.1.3 2013/04/06 15:57:40 christos Exp $ */
+/* $NetBSD: pcap-dag.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* pcap-dag.c: Packet capture interface for Endace DAG card.
@@ -50,6 +50,15 @@ struct rtentry; /* declarations in <net/if.h> */
#include "pcap-dag.h"
+/*
+ * DAG devices have names beginning with "dag", followed by a number
+ * from 0 to DAG_MAX_BOARDS, then optionally a colon and a stream number
+ * from 0 to DAG_STREAM_MAX.
+ */
+#ifndef DAG_MAX_BOARDS
+#define DAG_MAX_BOARDS 32
+#endif
+
#define ATM_CELL_SIZE 52
#define ATM_HDR_SIZE 4
@@ -72,6 +81,27 @@ struct sunatm_hdr {
unsigned short vci; /* VCI */
};
+/*
+ * Private data for capturing on DAG devices.
+ */
+struct pcap_dag {
+ struct pcap_stat stat;
+#ifdef HAVE_DAG_STREAMS_API
+ u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
+ u_char *dag_mem_top; /* DAG card current memory top pointer */
+#else /* HAVE_DAG_STREAMS_API */
+ void *dag_mem_base; /* DAG card memory base address */
+ u_int dag_mem_bottom; /* DAG card current memory bottom offset */
+ u_int dag_mem_top; /* DAG card current memory top offset */
+#endif /* HAVE_DAG_STREAMS_API */
+ int dag_fcs_bits; /* Number of checksum bits from link layer */
+ int dag_offset_flags; /* Flags to pass to dag_offset(). */
+ int dag_stream; /* DAG stream number */
+ int dag_timeout; /* timeout specified to pcap_open_live.
+ * Same as in linux above, introduce
+ * generally? */
+};
+
typedef struct pcap_dag_node {
struct pcap_dag_node *next;
pcap_t *p;
@@ -84,15 +114,6 @@ static const unsigned short endian_test_word = 0x0100;
#define IS_BIGENDIAN() (*((unsigned char *)&endian_test_word))
-
-#ifdef DAG_ONLY
-/* This code is required when compiling for a DAG device only. */
-
-/* Replace dag function names with pcap equivalent. */
-#define dag_create pcap_create
-#define dag_platform_finddevs pcap_platform_finddevs
-#endif /* DAG_ONLY */
-
#define MAX_DAG_PACKET 65536
static unsigned char TempPkt[MAX_DAG_PACKET];
@@ -129,13 +150,15 @@ delete_pcap_dag(pcap_t *p)
static void
dag_platform_cleanup(pcap_t *p)
{
-
+ struct pcap_dag *pd;
+
if (p != NULL) {
+ pd = p->priv;
#ifdef HAVE_DAG_STREAMS_API
- if(dag_stop_stream(p->fd, p->md.dag_stream) < 0)
+ if(dag_stop_stream(p->fd, pd->dag_stream) < 0)
fprintf(stderr,"dag_stop_stream: %s\n", strerror(errno));
- if(dag_detach_stream(p->fd, p->md.dag_stream) < 0)
+ if(dag_detach_stream(p->fd, pd->dag_stream) < 0)
fprintf(stderr,"dag_detach_stream: %s\n", strerror(errno));
#else
if(dag_stop(p->fd) < 0)
@@ -207,7 +230,7 @@ dag_erf_ext_header_count(uint8_t * erf, size_t len)
do {
/* sanity check we have enough bytes */
- if ( len <= (24 + (hdr_num * 8)) )
+ if ( len < (24 + (hdr_num * 8)) )
return hdr_num;
/* get the header type */
@@ -227,13 +250,14 @@ dag_erf_ext_header_count(uint8_t * erf, size_t len)
static int
dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_dag *pd = p->priv;
unsigned int processed = 0;
- int flags = p->md.dag_offset_flags;
+ int flags = pd->dag_offset_flags;
unsigned int nonblocking = flags & DAGF_NONBLOCK;
unsigned int num_ext_hdr = 0;
/* Get the next bufferful of packets (if necessary). */
- while (p->md.dag_mem_top - p->md.dag_mem_bottom < dag_record_size) {
+ while (pd->dag_mem_top - pd->dag_mem_bottom < dag_record_size) {
/*
* Has "pcap_breakloop()" been called?
@@ -260,23 +284,23 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
* If non-block is specified it will return immediately. The user
* is then responsible for efficiency.
*/
- if ( NULL == (p->md.dag_mem_top = dag_advance_stream(p->fd, p->md.dag_stream, &(p->md.dag_mem_bottom))) ) {
+ if ( NULL == (pd->dag_mem_top = dag_advance_stream(p->fd, pd->dag_stream, &(pd->dag_mem_bottom))) ) {
return -1;
}
#else
/* dag_offset does not support timeouts */
- p->md.dag_mem_top = dag_offset(p->fd, &(p->md.dag_mem_bottom), flags);
+ pd->dag_mem_top = dag_offset(p->fd, &(pd->dag_mem_bottom), flags);
#endif /* HAVE_DAG_STREAMS_API */
- if (nonblocking && (p->md.dag_mem_top - p->md.dag_mem_bottom < dag_record_size))
+ if (nonblocking && (pd->dag_mem_top - pd->dag_mem_bottom < dag_record_size))
{
/* Pcap is configured to process only available packets, and there aren't any, return immediately. */
return 0;
}
if(!nonblocking &&
- p->md.dag_timeout &&
- (p->md.dag_mem_top - p->md.dag_mem_bottom < dag_record_size))
+ pd->dag_timeout &&
+ (pd->dag_mem_top - pd->dag_mem_bottom < dag_record_size))
{
/* Blocking mode, but timeout set and no data has arrived, return anyway.*/
return 0;
@@ -285,16 +309,16 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
/* Process the packets. */
- while (p->md.dag_mem_top - p->md.dag_mem_bottom >= dag_record_size) {
+ while (pd->dag_mem_top - pd->dag_mem_bottom >= dag_record_size) {
unsigned short packet_len = 0;
int caplen = 0;
struct pcap_pkthdr pcap_header;
#ifdef HAVE_DAG_STREAMS_API
- dag_record_t *header = (dag_record_t *)(p->md.dag_mem_bottom);
+ dag_record_t *header = (dag_record_t *)(pd->dag_mem_bottom);
#else
- dag_record_t *header = (dag_record_t *)(p->md.dag_mem_base + p->md.dag_mem_bottom);
+ dag_record_t *header = (dag_record_t *)(pd->dag_mem_base + pd->dag_mem_bottom);
#endif /* HAVE_DAG_STREAMS_API */
u_char *dp = ((u_char *)header); /* + dag_record_size; */
@@ -319,7 +343,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
strncpy(p->errbuf, "dag_read: record too small", PCAP_ERRBUF_SIZE);
return -1;
}
- p->md.dag_mem_bottom += rlen;
+ pd->dag_mem_bottom += rlen;
/* Count lost packets. */
switch((header->type & 0x7f)) {
@@ -335,10 +359,10 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
default:
if (header->lctr) {
- if (p->md.stat.ps_drop > (UINT_MAX - ntohs(header->lctr))) {
- p->md.stat.ps_drop = UINT_MAX;
+ if (pd->stat.ps_drop > (UINT_MAX - ntohs(header->lctr))) {
+ pd->stat.ps_drop = UINT_MAX;
} else {
- p->md.stat.ps_drop += ntohs(header->lctr);
+ pd->stat.ps_drop += ntohs(header->lctr);
}
}
}
@@ -446,7 +470,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case TYPE_COLOR_ETH:
case TYPE_ETH:
packet_len = ntohs(header->wlen);
- packet_len -= (p->md.dag_fcs_bits >> 3);
+ packet_len -= (pd->dag_fcs_bits >> 3);
caplen = rlen - dag_record_size - 2;
if (caplen > packet_len) {
caplen = packet_len;
@@ -459,7 +483,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case TYPE_COLOR_HDLC_POS:
case TYPE_HDLC_POS:
packet_len = ntohs(header->wlen);
- packet_len -= (p->md.dag_fcs_bits >> 3);
+ packet_len -= (pd->dag_fcs_bits >> 3);
caplen = rlen - dag_record_size;
if (caplen > packet_len) {
caplen = packet_len;
@@ -469,7 +493,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case TYPE_COLOR_MC_HDLC_POS:
case TYPE_MC_HDLC:
packet_len = ntohs(header->wlen);
- packet_len -= (p->md.dag_fcs_bits >> 3);
+ packet_len -= (pd->dag_fcs_bits >> 3);
caplen = rlen - dag_record_size - 4;
if (caplen > packet_len) {
caplen = packet_len;
@@ -550,7 +574,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
pcap_header.len = packet_len;
/* Count the packet. */
- p->md.stat.ps_recv++;
+ pd->stat.ps_recv++;
/* Call the user supplied callback function */
callback(user, &pcap_header, dp);
@@ -589,6 +613,7 @@ dag_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
*/
static int dag_activate(pcap_t* handle)
{
+ struct pcap_dag *handlep = handle->priv;
#if 0
char conf[30]; /* dag configure string */
#endif
@@ -618,13 +643,13 @@ static int dag_activate(pcap_t* handle)
}
/* Parse input name to get dag device and stream number if provided */
- if (dag_parse_name(device, newDev, strlen(device) + 16, &handle->md.dag_stream) < 0) {
+ if (dag_parse_name(device, newDev, strlen(device) + 16, &handlep->dag_stream) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: %s\n", pcap_strerror(errno));
goto fail;
}
device = newDev;
- if (handle->md.dag_stream%2) {
+ if (handlep->dag_stream%2) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_parse_name: tx (even numbered) streams not supported for capture\n");
goto fail;
}
@@ -649,7 +674,7 @@ static int dag_activate(pcap_t* handle)
#ifdef HAVE_DAG_STREAMS_API
/* Open requested stream. Can fail if already locked or on error */
- if (dag_attach_stream(handle->fd, handle->md.dag_stream, 0, 0) < 0) {
+ if (dag_attach_stream(handle->fd, handlep->dag_stream, 0, 0) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_attach_stream: %s\n", pcap_strerror(errno));
goto failclose;
}
@@ -657,32 +682,39 @@ static int dag_activate(pcap_t* handle)
/* Set up default poll parameters for stream
* Can be overridden by pcap_set_nonblock()
*/
- if (dag_get_stream_poll(handle->fd, handle->md.dag_stream,
+ if (dag_get_stream_poll(handle->fd, handlep->dag_stream,
&mindata, &maxwait, &poll) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s\n", pcap_strerror(errno));
goto faildetach;
}
- /* Amount of data to collect in Bytes before calling callbacks.
- * Important for efficiency, but can introduce latency
- * at low packet rates if to_ms not set!
- */
- mindata = 65536;
+ if (handle->opt.immediate) {
+ /* Call callback immediately.
+ * XXX - is this the right way to handle this?
+ */
+ mindata = 0;
+ } else {
+ /* Amount of data to collect in Bytes before calling callbacks.
+ * Important for efficiency, but can introduce latency
+ * at low packet rates if to_ms not set!
+ */
+ mindata = 65536;
+ }
- /* Obey md.timeout (was to_ms) if supplied. This is a good idea!
+ /* Obey opt.timeout (was to_ms) if supplied. This is a good idea!
* Recommend 10-100ms. Calls will time out even if no data arrived.
*/
- maxwait.tv_sec = handle->md.timeout/1000;
- maxwait.tv_usec = (handle->md.timeout%1000) * 1000;
+ maxwait.tv_sec = handle->opt.timeout/1000;
+ maxwait.tv_usec = (handle->opt.timeout%1000) * 1000;
- if (dag_set_stream_poll(handle->fd, handle->md.dag_stream,
+ if (dag_set_stream_poll(handle->fd, handlep->dag_stream,
mindata, &maxwait, &poll) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s\n", pcap_strerror(errno));
goto faildetach;
}
#else
- if((handle->md.dag_mem_base = dag_mmap(handle->fd)) == MAP_FAILED) {
+ if((handlep->dag_mem_base = dag_mmap(handle->fd)) == MAP_FAILED) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_mmap %s: %s\n", device, pcap_strerror(errno));
goto failclose;
}
@@ -712,7 +744,7 @@ static int dag_activate(pcap_t* handle)
#endif
#ifdef HAVE_DAG_STREAMS_API
- if(dag_start_stream(handle->fd, handle->md.dag_stream) < 0) {
+ if(dag_start_stream(handle->fd, handlep->dag_stream) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_start_stream %s: %s\n", device, pcap_strerror(errno));
goto faildetach;
}
@@ -728,8 +760,8 @@ static int dag_activate(pcap_t* handle)
* initialized to zero on startup, it won't give you
* a compiler warning if you make this mistake!
*/
- handle->md.dag_mem_bottom = 0;
- handle->md.dag_mem_top = 0;
+ handlep->dag_mem_bottom = 0;
+ handlep->dag_mem_top = 0;
/*
* Find out how many FCS bits we should strip.
@@ -738,7 +770,7 @@ static int dag_activate(pcap_t* handle)
daginf = dag_info(handle->fd);
if ((0x4200 == daginf->device_code) || (0x4230 == daginf->device_code)) {
/* DAG 4.2S and 4.23S already strip the FCS. Stripping the final word again truncates the packet. */
- handle->md.dag_fcs_bits = 0;
+ handlep->dag_fcs_bits = 0;
/* Note that no FCS will be supplied. */
handle->linktype_ext = LT_FCS_DATALINK_EXT(0);
@@ -746,12 +778,12 @@ static int dag_activate(pcap_t* handle)
/*
* Start out assuming it's 32 bits.
*/
- handle->md.dag_fcs_bits = 32;
+ handlep->dag_fcs_bits = 32;
/* Allow an environment variable to override. */
if ((s = getenv("ERF_FCS_BITS")) != NULL) {
if ((n = atoi(s)) == 0 || n == 16 || n == 32) {
- handle->md.dag_fcs_bits = n;
+ handlep->dag_fcs_bits = n;
} else {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"pcap_activate %s: bad ERF_FCS_BITS value (%d) in environment\n", device, n);
@@ -765,14 +797,14 @@ static int dag_activate(pcap_t* handle)
if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) {
/* Yes. Note the number of bytes that will be
supplied. */
- handle->linktype_ext = LT_FCS_DATALINK_EXT(handle->md.dag_fcs_bits/16);
+ handle->linktype_ext = LT_FCS_DATALINK_EXT(handlep->dag_fcs_bits/16);
/* And don't strip them. */
- handle->md.dag_fcs_bits = 0;
+ handlep->dag_fcs_bits = 0;
}
}
- handle->md.dag_timeout = handle->md.timeout;
+ handlep->dag_timeout = handle->opt.timeout;
handle->linktype = -1;
if (dag_get_datalink(handle) < 0)
@@ -803,19 +835,19 @@ static int dag_activate(pcap_t* handle)
handle->setnonblock_op = dag_setnonblock;
handle->stats_op = dag_stats;
handle->cleanup_op = dag_platform_cleanup;
- handle->md.stat.ps_drop = 0;
- handle->md.stat.ps_recv = 0;
- handle->md.stat.ps_ifdrop = 0;
+ handlep->stat.ps_drop = 0;
+ handlep->stat.ps_recv = 0;
+ handlep->stat.ps_ifdrop = 0;
return 0;
#ifdef HAVE_DAG_STREAMS_API
failstop:
- if (dag_stop_stream(handle->fd, handle->md.dag_stream) < 0) {
+ if (dag_stop_stream(handle->fd, handlep->dag_stream) < 0) {
fprintf(stderr,"dag_stop_stream: %s\n", strerror(errno));
}
faildetach:
- if (dag_detach_stream(handle->fd, handle->md.dag_stream) < 0)
+ if (dag_detach_stream(handle->fd, handlep->dag_stream) < 0)
fprintf(stderr,"dag_detach_stream: %s\n", strerror(errno));
#else
failstop:
@@ -837,11 +869,57 @@ fail:
return PCAP_ERROR;
}
-pcap_t *dag_create(const char *device, char *ebuf)
+pcap_t *dag_create(const char *device, char *ebuf, int *is_ours)
{
+ const char *cp;
+ char *cpend;
+ long devnum;
pcap_t *p;
+#ifdef HAVE_DAG_STREAMS_API
+ long stream = 0;
+#endif
- p = pcap_create_common(device, ebuf);
+ /* Does this look like a DAG device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ /* Does it begin with "dag"? */
+ if (strncmp(cp, "dag", 3) != 0) {
+ /* Nope, doesn't begin with "dag" */
+ *is_ours = 0;
+ return NULL;
+ }
+ /* Yes - is "dag" followed by a number from 0 to DAG_MAX_BOARDS-1 */
+ cp += 3;
+ devnum = strtol(cp, &cpend, 10);
+#ifdef HAVE_DAG_STREAMS_API
+ if (*cpend == ':') {
+ /* Followed by a stream number. */
+ stream = strtol(++cpend, &cpend, 10);
+ }
+#endif
+ if (cpend == cp || *cpend != '\0') {
+ /* Not followed by a number. */
+ *is_ours = 0;
+ return NULL;
+ }
+ if (devnum < 0 || devnum >= DAG_MAX_BOARDS) {
+ /* Followed by a non-valid number. */
+ *is_ours = 0;
+ return NULL;
+ }
+#ifdef HAVE_DAG_STREAMS_API
+ if (stream <0 || stream >= DAG_STREAM_MAX) {
+ /* Followed by a non-valid stream number. */
+ *is_ours = 0;
+ return NULL;
+ }
+#endif
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_dag));
if (p == NULL)
return NULL;
@@ -851,13 +929,15 @@ pcap_t *dag_create(const char *device, char *ebuf)
static int
dag_stats(pcap_t *p, struct pcap_stat *ps) {
+ struct pcap_dag *pd = p->priv;
+
/* This needs to be filled out correctly. Hopefully a dagapi call will
provide all necessary information.
*/
- /*p->md.stat.ps_recv = 0;*/
- /*p->md.stat.ps_drop = 0;*/
+ /*pd->stat.ps_recv = 0;*/
+ /*pd->stat.ps_drop = 0;*/
- *ps = p->md.stat;
+ *ps = pd->stat;
return 0;
}
@@ -872,7 +952,7 @@ dag_stats(pcap_t *p, struct pcap_stat *ps) {
* open attempts will still be much less than the naive approach.
*/
int
-dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
+dag_findalldevs(pcap_if_t **devlistp, char *errbuf)
{
char name[12]; /* XXX - pick a size */
int ret = 0;
@@ -881,8 +961,8 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
int dagstream;
int dagfd;
- /* Try all the DAGs 0-31 */
- for (c = 0; c < 32; c++) {
+ /* Try all the DAGs 0-DAG_MAX_BOARDS */
+ for (c = 0; c < DAG_MAX_BOARDS; c++) {
snprintf(name, 12, "dag%d", c);
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
{
@@ -947,8 +1027,6 @@ dag_setfilter(pcap_t *p, struct bpf_program *fp)
if (install_bpf_program(p, fp) < 0)
return -1;
- p->md.use_bpf = 0;
-
return (0);
}
@@ -963,11 +1041,13 @@ dag_set_datalink(pcap_t *p, int dlt)
static int
dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
{
+ struct pcap_dag *pd = p->priv;
+
/*
* Set non-blocking mode on the FD.
* XXX - is that necessary? If not, don't bother calling it,
* and have a "dag_getnonblock()" function that looks at
- * "p->md.dag_offset_flags".
+ * "pd->dag_offset_flags".
*/
if (pcap_setnonblock_fd(p, nonblock, errbuf) < 0)
return (-1);
@@ -977,7 +1057,7 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
struct timeval maxwait;
struct timeval poll;
- if (dag_get_stream_poll(p->fd, p->md.dag_stream,
+ if (dag_get_stream_poll(p->fd, pd->dag_stream,
&mindata, &maxwait, &poll) < 0) {
snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s\n", pcap_strerror(errno));
return -1;
@@ -992,7 +1072,7 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
else
mindata = 65536;
- if (dag_set_stream_poll(p->fd, p->md.dag_stream,
+ if (dag_set_stream_poll(p->fd, pd->dag_stream,
mindata, &maxwait, &poll) < 0) {
snprintf(errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s\n", pcap_strerror(errno));
return -1;
@@ -1000,9 +1080,9 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
}
#endif /* HAVE_DAG_STREAMS_API */
if (nonblock) {
- p->md.dag_offset_flags |= DAGF_NONBLOCK;
+ pd->dag_offset_flags |= DAGF_NONBLOCK;
} else {
- p->md.dag_offset_flags &= ~DAGF_NONBLOCK;
+ pd->dag_offset_flags &= ~DAGF_NONBLOCK;
}
return (0);
}
@@ -1010,6 +1090,7 @@ dag_setnonblock(pcap_t *p, int nonblock, char *errbuf)
static int
dag_get_datalink(pcap_t *p)
{
+ struct pcap_dag *pd = p->priv;
int index=0, dlt_index=0;
uint8_t types[255];
@@ -1024,7 +1105,7 @@ dag_get_datalink(pcap_t *p)
#ifdef HAVE_DAG_GET_STREAM_ERF_TYPES
/* Get list of possible ERF types for this card */
- if (dag_get_stream_erf_types(p->fd, p->md.dag_stream, types, 255) < 0) {
+ if (dag_get_stream_erf_types(p->fd, pd->dag_stream, types, 255) < 0) {
snprintf(p->errbuf, sizeof(p->errbuf), "dag_get_stream_erf_types: %s", pcap_strerror(errno));
return (-1);
}
diff --git a/external/bsd/libpcap/dist/pcap-dag.h b/external/bsd/libpcap/dist/pcap-dag.h
index 3c3e29f18db..18568899d29 100644
--- a/external/bsd/libpcap/dist/pcap-dag.h
+++ b/external/bsd/libpcap/dist/pcap-dag.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-dag.h,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-dag.h,v 1.1.1.4 2013/12/31 16:57:22 christos Exp $ */
/*
* pcap-dag.c: Packet capture interface for Endace DAG card.
@@ -12,8 +12,8 @@
* @(#) Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.7 2008-04-04 19:37:45 guy Exp (LBL)
*/
-pcap_t *dag_create(const char *, char *);
-int dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf);
+pcap_t *dag_create(const char *, char *, int *);
+int dag_findalldevs(pcap_if_t **devlistp, char *errbuf);
#ifndef TYPE_AAL5
#define TYPE_AAL5 4
diff --git a/external/bsd/libpcap/dist/pcap-dbus.c b/external/bsd/libpcap/dist/pcap-dbus.c
new file mode 100644
index 00000000000..e5e9fa2d43c
--- /dev/null
+++ b/external/bsd/libpcap/dist/pcap-dbus.c
@@ -0,0 +1,281 @@
+/* $NetBSD: pcap-dbus.c,v 1.1.1.1 2013/12/31 16:57:18 christos Exp $ */
+
+/*
+ * Copyright (c) 2012 Jakub Zawadzki
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string.h>
+
+#include <time.h>
+#include <sys/time.h>
+
+#include <dbus/dbus.h>
+
+#include "pcap-int.h"
+#include "pcap-dbus.h"
+
+/*
+ * Private data for capturing on D-Bus.
+ */
+struct pcap_dbus {
+ DBusConnection *conn;
+ u_int packets_read; /* count of packets read */
+};
+
+static int
+dbus_read(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
+{
+ struct pcap_dbus *handlep = handle->priv;
+
+ struct pcap_pkthdr pkth;
+ DBusMessage *message;
+
+ char *raw_msg;
+ int raw_msg_len;
+
+ int count = 0;
+
+ message = dbus_connection_pop_message(handlep->conn);
+
+ while (!message) {
+ // XXX handle->opt.timeout = timeout_ms;
+ if (!dbus_connection_read_write(handlep->conn, 100)) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Connection closed");
+ return -1;
+ }
+
+ if (handle->break_loop) {
+ handle->break_loop = 0;
+ return -2;
+ }
+
+ message = dbus_connection_pop_message(handlep->conn);
+ }
+
+ if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Disconnected");
+ return -1;
+ }
+
+ if (dbus_message_marshal(message, &raw_msg, &raw_msg_len)) {
+ pkth.caplen = pkth.len = raw_msg_len;
+ /* pkth.caplen = min (payload_len, handle->snapshot); */
+
+ gettimeofday(&pkth.ts, NULL);
+ if (handle->fcode.bf_insns == NULL ||
+ bpf_filter(handle->fcode.bf_insns, (u_char *)raw_msg, pkth.len, pkth.caplen)) {
+ handlep->packets_read++;
+ callback(user, &pkth, (u_char *)raw_msg);
+ count++;
+ }
+
+ dbus_free(raw_msg);
+ }
+ return count;
+}
+
+static int
+dbus_write(pcap_t *handle, const void *buf, size_t size)
+{
+ /* XXX, not tested */
+ struct pcap_dbus *handlep = handle->priv;
+
+ DBusError error = DBUS_ERROR_INIT;
+ DBusMessage *msg;
+
+ if (!(msg = dbus_message_demarshal(buf, size, &error))) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dbus_message_demarshal() failed: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+
+ dbus_connection_send(handlep->conn, msg, NULL);
+ dbus_connection_flush(handlep->conn);
+
+ dbus_message_unref(msg);
+ return 0;
+}
+
+static int
+dbus_stats(pcap_t *handle, struct pcap_stat *stats)
+{
+ struct pcap_dbus *handlep = handle->priv;
+
+ stats->ps_recv = handlep->packets_read;
+ stats->ps_drop = 0;
+ stats->ps_ifdrop = 0;
+ return 0;
+}
+
+static void
+dbus_cleanup(pcap_t *handle)
+{
+ struct pcap_dbus *handlep = handle->priv;
+
+ dbus_connection_unref(handlep->conn);
+
+ pcap_cleanup_live_common(handle);
+}
+
+static int
+dbus_activate(pcap_t *handle)
+{
+#define EAVESDROPPING_RULE "eavesdrop=true,"
+
+ static const char *rules[] = {
+ EAVESDROPPING_RULE "type='signal'",
+ EAVESDROPPING_RULE "type='method_call'",
+ EAVESDROPPING_RULE "type='method_return'",
+ EAVESDROPPING_RULE "type='error'",
+ };
+
+ #define N_RULES sizeof(rules)/sizeof(rules[0])
+
+ struct pcap_dbus *handlep = handle->priv;
+ const char *dev = handle->opt.source;
+
+ DBusError error = DBUS_ERROR_INIT;
+ int i;
+
+ if (strcmp(dev, "dbus-system") == 0) {
+ if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get system bus: %s", error.message);
+ dbus_error_free(&error);
+ return PCAP_ERROR;
+ }
+
+ } else if (strcmp(dev, "dbus-session") == 0) {
+ if (!(handlep->conn = dbus_bus_get(DBUS_BUS_SESSION, &error))) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to get session bus: %s", error.message);
+ dbus_error_free(&error);
+ return PCAP_ERROR;
+ }
+
+ } else if (strncmp(dev, "dbus://", 7) == 0) {
+ const char *addr = dev + 7;
+
+ if (!(handlep->conn = dbus_connection_open(addr, &error))) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to open connection to: %s: %s", addr, error.message);
+ dbus_error_free(&error);
+ return PCAP_ERROR;
+ }
+
+ if (!dbus_bus_register(handlep->conn, &error)) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to register bus %s: %s\n", addr, error.message);
+ dbus_error_free(&error);
+ return PCAP_ERROR;
+ }
+
+ } else {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get bus address from %s", handle->opt.source);
+ return PCAP_ERROR;
+ }
+
+ /* Initialize some components of the pcap structure. */
+ handle->bufsize = 0;
+ handle->offset = 0;
+ handle->linktype = DLT_DBUS;
+ handle->read_op = dbus_read;
+ handle->inject_op = dbus_write;
+ handle->setfilter_op = install_bpf_program; /* XXX, later add support for dbus_bus_add_match() */
+ handle->setdirection_op = NULL;
+ handle->set_datalink_op = NULL; /* can't change data link type */
+ handle->getnonblock_op = pcap_getnonblock_fd;
+ handle->setnonblock_op = pcap_setnonblock_fd;
+ handle->stats_op = dbus_stats;
+
+ handle->selectable_fd = handle->fd = -1;
+
+ if (handle->opt.rfmon) {
+ /*
+ * Monitor mode doesn't apply to dbus connections.
+ */
+ dbus_cleanup(handle);
+ return PCAP_ERROR_RFMON_NOTSUP;
+ }
+
+ /* dbus_connection_set_max_message_size(handlep->conn, handle->snapshot); */
+ if (handle->opt.buffer_size != 0)
+ dbus_connection_set_max_received_size(handlep->conn, handle->opt.buffer_size);
+
+ for (i = 0; i < N_RULES; i++) {
+ dbus_bus_add_match(handlep->conn, rules[i], &error);
+ if (dbus_error_is_set(&error)) {
+ dbus_error_free(&error);
+
+ /* try without eavesdrop */
+ dbus_bus_add_match(handlep->conn, rules[i] + strlen(EAVESDROPPING_RULE), &error);
+ if (dbus_error_is_set(&error)) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Failed to add bus match: %s\n", error.message);
+ dbus_error_free(&error);
+ dbus_cleanup(handle);
+ return PCAP_ERROR;
+ }
+ }
+ }
+
+ return 0;
+}
+
+pcap_t *
+dbus_create(const char *device, char *ebuf, int *is_ours)
+{
+ pcap_t *p;
+
+ if (strcmp(device, "dbus-system") &&
+ strcmp(device, "dbus-session") &&
+ strncmp(device, "dbus://", 7))
+ {
+ *is_ours = 0;
+ return NULL;
+ }
+
+ *is_ours = 1;
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_dbus));
+ if (p == NULL)
+ return (NULL);
+
+ p->activate_op = dbus_activate;
+ return (p);
+}
+
+int
+dbus_findalldevs(pcap_if_t **alldevsp, char *err_str)
+{
+ if (pcap_add_if(alldevsp, "dbus-system", 0, "D-Bus system bus", err_str) < 0)
+ return -1;
+ if (pcap_add_if(alldevsp, "dbus-session", 0, "D-Bus session bus", err_str) < 0)
+ return -1;
+ return 0;
+}
+
diff --git a/external/bsd/libpcap/dist/pcap-dbus.h b/external/bsd/libpcap/dist/pcap-dbus.h
new file mode 100644
index 00000000000..ad14f58c6e8
--- /dev/null
+++ b/external/bsd/libpcap/dist/pcap-dbus.h
@@ -0,0 +1,4 @@
+/* $NetBSD: pcap-dbus.h,v 1.1.1.1 2013/12/31 16:57:20 christos Exp $ */
+
+pcap_t *dbus_create(const char *, char *, int *);
+int dbus_findalldevs(pcap_if_t **devlistp, char *errbuf);
diff --git a/external/bsd/libpcap/dist/pcap-dlpi.c b/external/bsd/libpcap/dist/pcap-dlpi.c
index 019887e8387..b06e25f807c 100644
--- a/external/bsd/libpcap/dist/pcap-dlpi.c
+++ b/external/bsd/libpcap/dist/pcap-dlpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-dlpi.c,v 1.1.1.3 2013/04/06 15:57:40 christos Exp $ */
+/* $NetBSD: pcap-dlpi.c,v 1.1.1.4 2013/12/31 16:57:26 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -247,6 +247,9 @@ pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
static int
pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
{
+#ifdef DL_HP_RAWDLS
+ struct pcap_dlpi *pd = p->priv;
+#endif
int ret;
#if defined(DLIOCRAW)
@@ -257,12 +260,12 @@ pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
return (-1);
}
#elif defined(DL_HP_RAWDLS)
- if (p->send_fd < 0) {
+ if (pd->send_fd < 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"send: Output FD couldn't be opened");
return (-1);
}
- ret = dlrawdatareq(p->send_fd, buf, size);
+ ret = dlrawdatareq(pd->send_fd, buf, size);
if (ret == -1) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
pcap_strerror(errno));
@@ -323,16 +326,23 @@ pcap_inject_dlpi(pcap_t *p, const void *buf, size_t size)
static void
pcap_cleanup_dlpi(pcap_t *p)
{
- if (p->send_fd >= 0) {
- close(p->send_fd);
- p->send_fd = -1;
+#ifdef DL_HP_RAWDLS
+ struct pcap_dlpi *pd = p->priv;
+
+ if (pd->send_fd >= 0) {
+ close(pd->send_fd);
+ pd->send_fd = -1;
}
+#endif
pcap_cleanup_live_common(p);
}
static int
pcap_activate_dlpi(pcap_t *p)
{
+#ifdef DL_HP_RAWDLS
+ struct pcap_dlpi *pd = p->priv;
+#endif
register char *cp;
int ppa;
#ifdef HAVE_SOLARIS
@@ -400,13 +410,13 @@ pcap_activate_dlpi(pcap_t *p)
* receiving packets on the same descriptor - you need separate
* descriptors for sending and receiving, bound to different SAPs.
*
- * If the open fails, we just leave -1 in "p->send_fd" and reject
+ * If the open fails, we just leave -1 in "pd->send_fd" and reject
* attempts to send packets, just as if, in pcap-bpf.c, we fail
* to open the BPF device for reading and writing, we just try
* to open it for reading only and, if that succeeds, just let
* the send attempts fail.
*/
- p->send_fd = open(cp, O_RDWR);
+ pd->send_fd = open(cp, O_RDWR);
#endif
/*
@@ -515,8 +525,8 @@ pcap_activate_dlpi(pcap_t *p)
if (status < 0)
goto bad;
#ifdef DL_HP_RAWDLS
- if (p->send_fd >= 0) {
- if (dl_doattach(p->send_fd, ppa, p->errbuf) < 0)
+ if (pd->send_fd >= 0) {
+ if (dl_doattach(pd->send_fd, ppa, p->errbuf) < 0)
goto bad;
}
#endif
@@ -572,13 +582,13 @@ pcap_activate_dlpi(pcap_t *p)
*/
if (dl_dohpuxbind(p->fd, p->errbuf) < 0)
goto bad;
- if (p->send_fd >= 0) {
+ if (pd->send_fd >= 0) {
/*
** XXX - if this fails, just close send_fd and
** set it to -1, so that you can't send but can
** still receive?
*/
- if (dl_dohpuxbind(p->send_fd, p->errbuf) < 0)
+ if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0)
goto bad;
}
#else /* neither AIX nor HP-UX */
@@ -671,13 +681,13 @@ pcap_activate_dlpi(pcap_t *p)
** binding it anyway, just to keep the HP-UX 9/10.20 or later
** code together.
*/
- if (p->send_fd >= 0) {
+ if (pd->send_fd >= 0) {
/*
** XXX - if this fails, just close send_fd and
** set it to -1, so that you can't send but can
** still receive?
*/
- if (dl_dohpuxbind(p->send_fd, p->errbuf) < 0)
+ if (dl_dohpuxbind(pd->send_fd, p->errbuf) < 0)
goto bad;
}
#endif
@@ -731,7 +741,7 @@ pcap_activate_dlpi(pcap_t *p)
#endif
/* Push and configure bufmod. */
- if (pcap_conf_bufmod(p, ss, p->md.timeout) != 0)
+ if (pcap_conf_bufmod(p, ss) != 0)
goto bad;
#endif
@@ -1695,15 +1705,21 @@ dlpi_kread(register int fd, register off_t addr,
#endif
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
+#ifdef DL_HP_RAWDLS
+ struct pcap_dlpi *pd;
+#endif
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_dlpi));
if (p == NULL)
return (NULL);
- p->send_fd = -1; /* it hasn't been opened yet */
+#ifdef DL_HP_RAWDLS
+ pd = p->priv;
+ pd->send_fd = -1; /* it hasn't been opened yet */
+#endif
p->activate_op = pcap_activate_dlpi;
return (p);
diff --git a/external/bsd/libpcap/dist/pcap-dos.c b/external/bsd/libpcap/dist/pcap-dos.c
index bef751d7a84..d993fe2b76f 100644
--- a/external/bsd/libpcap/dist/pcap-dos.c
+++ b/external/bsd/libpcap/dist/pcap-dos.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-dos.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-dos.c,v 1.1.1.4 2013/12/31 16:57:23 christos Exp $ */
/*
* This file is part of DOS-libpcap
@@ -145,11 +145,19 @@ static struct device *get_device (int fd)
return handle_to_device [fd-1];
}
-pcap_t *pcap_create (const char *device, char *ebuf)
+/*
+ * Private data for capturing on MS-DOS.
+ */
+struct pcap_dos {
+ void (*wait_proc)(void); /* call proc while waiting */
+ struct pcap_stat stat;
+};
+
+pcap_t *pcap_create_interface (const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_dos));
if (p == NULL)
return (NULL);
@@ -163,6 +171,8 @@ pcap_t *pcap_create (const char *device, char *ebuf)
*/
static int pcap_activate_dos (pcap_t *pcap)
{
+ struct pcap_dos *pcapd = pcap->priv;
+
if (pcap->opt.rfmon) {
/*
* No monitor mode on DOS.
@@ -212,15 +222,16 @@ static int pcap_activate_dos (pcap_t *pcap)
static int
pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
{
+ struct pcap_dos *pd = p->priv;
struct pcap_pkthdr pcap;
- struct timeval now, expiry;
+ struct timeval now, expiry = { 0,0 };
BYTE *rx_buf;
int rx_len = 0;
- if (p->md.timeout > 0)
+ if (p->opt.timeout > 0)
{
gettimeofday2 (&now, NULL);
- expiry.tv_usec = now.tv_usec + 1000UL * p->md.timeout;
+ expiry.tv_usec = now.tv_usec + 1000UL * p->opt.timeout;
expiry.tv_sec = now.tv_sec;
while (expiry.tv_usec >= 1000000L)
{
@@ -289,10 +300,10 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
return (1);
}
- /* If not to wait for a packet or pcap_close() called from
+ /* If not to wait for a packet or pcap_cleanup_dos() called from
* e.g. SIGINT handler, exit loop now.
*/
- if (p->md.timeout <= 0 || (volatile int)p->fd <= 0)
+ if (p->opt.timeout <= 0 || (volatile int)p->fd <= 0)
break;
gettimeofday2 (&now, NULL);
@@ -310,7 +321,7 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
if (rx_len < 0) /* receive error */
{
- p->md.stat.ps_drop++;
+ pd->stat.ps_drop++;
#ifdef USE_32BIT_DRIVERS
if (pcap_pkt_debug > 1)
printk ("pkt-err %s\n", pktInfo.error);
@@ -323,6 +334,7 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data)
static int
pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
{
+ struct pcap_dos *pd = p->priv;
int rc, num = 0;
while (num <= cnt || (cnt < 0))
@@ -345,6 +357,7 @@ pcap_read_dos (pcap_t *p, int cnt, pcap_handler callback, u_char *data)
static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps)
{
struct net_device_stats *stats;
+ struct pcap_dos *pd;
struct device *dev = p ? get_device(p->fd) : NULL;
if (!dev)
@@ -361,12 +374,13 @@ static int pcap_stats_dos (pcap_t *p, struct pcap_stat *ps)
FLUSHK();
- p->md.stat.ps_recv = stats->rx_packets;
- p->md.stat.ps_drop += stats->rx_missed_errors;
- p->md.stat.ps_ifdrop = stats->rx_dropped + /* queue full */
+ pd = p->priv;
+ pd->stat.ps_recv = stats->rx_packets;
+ pd->stat.ps_drop += stats->rx_missed_errors;
+ pd->stat.ps_ifdrop = stats->rx_dropped + /* queue full */
stats->rx_errors; /* HW errors */
if (ps)
- *ps = p->md.stat;
+ *ps = pd->stat;
return (0);
}
@@ -430,10 +444,13 @@ u_long pcap_filter_packets (void)
*/
static void pcap_cleanup_dos (pcap_t *p)
{
+ struct pcap_dos *pd;
+
if (p && !exc_occured)
{
+ pd = p->priv;
if (pcap_stats(p,NULL) < 0)
- p->md.stat.ps_drop = 0;
+ pd->stat.ps_drop = 0;
if (!get_device(p->fd))
return;
@@ -592,10 +609,12 @@ void pcap_assert (const char *what, const char *file, unsigned line)
*/
void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait)
{
+ struct pcap_dos *pd;
if (p)
{
- p->wait_proc = yield;
- p->md.timeout = wait;
+ pd = p->priv;
+ pd->wait_proc = yield;
+ p->opt.timeout = wait;
}
}
diff --git a/external/bsd/libpcap/dist/pcap-filter.manmisc.in b/external/bsd/libpcap/dist/pcap-filter.manmisc.in
index 8ce373e15ff..5595e664526 100644
--- a/external/bsd/libpcap/dist/pcap-filter.manmisc.in
+++ b/external/bsd/libpcap/dist/pcap-filter.manmisc.in
@@ -45,6 +45,7 @@ Primitives usually consist of an
There are three
different kinds of qualifier:
.IP \fItype\fP
+.I type
qualifiers say what kind of thing the id name or number refers to.
Possible types are
.BR host ,
@@ -58,6 +59,7 @@ qualifier,
.B host
is assumed.
.IP \fIdir\fP
+.I dir
qualifiers specify a particular transfer direction to and/or from
.IR id .
Possible directions are
@@ -93,6 +95,7 @@ and
.B outbound
qualifiers can be used to specify a desired direction.
.IP \fIproto\fP
+.I proto
qualifiers restrict the match to a particular protocol.
Possible
protos are:
@@ -159,7 +162,7 @@ True if the IPv4/v6 destination field of the packet is \fIhost\fP,
which may be either an address or a name.
.IP "\fBsrc host \fIhost\fR"
True if the IPv4/v6 source field of the packet is \fIhost\fP.
-.IP "\fBhost \fIhost\fP
+.IP "\fBhost \fIhost\fP"
True if either the IPv4/v6 source or destination of the packet is \fIhost\fP.
.IP
Any of the above host expressions can be prepended with the keywords,
@@ -177,17 +180,17 @@ which is equivalent to:
.in -.5i
If \fIhost\fR is a name with multiple IP addresses, each address will
be checked for a match.
-.IP "\fBether dst \fIehost\fP
+.IP "\fBether dst \fIehost\fP"
True if the Ethernet destination address is \fIehost\fP.
\fIEhost\fP
may be either a name from /etc/ethers or a number (see
.IR ethers (3N)
for numeric format).
-.IP "\fBether src \fIehost\fP
+.IP "\fBether src \fIehost\fP"
True if the Ethernet source address is \fIehost\fP.
-.IP "\fBether host \fIehost\fP
+.IP "\fBether host \fIehost\fP"
True if either the Ethernet source or destination address is \fIehost\fP.
-.IP "\fBgateway\fP \fIhost\fP
+.IP "\fBgateway\fP \fIhost\fP"
True if the packet used \fIhost\fP as a gateway.
I.e., the Ethernet
source or destination address was \fIhost\fP but neither the IP source
@@ -302,6 +305,18 @@ Note that this primitive does not chase the protocol header chain.
.IP "\fBip6 proto \fIprotocol\fR"
True if the packet is an IPv6 packet of protocol type \fIprotocol\fP.
Note that this primitive does not chase the protocol header chain.
+.IP "\fBproto \fIprotocol\fR"
+True if the packet is an IPv4 or IPv6 packet of protocol type
+\fIprotocol\fP. Note that this primitive does not chase the protocol
+header chain.
+.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
+Abbreviations for:
+.in +.5i
+.nf
+\fBproto \fIp\fR\fB
+.fi
+.in -.5i
+where \fIp\fR is one of the above protocols.
.IP "\fBip6 protochain \fIprotocol\fR"
True if the packet is IPv6 packet,
and contains protocol header with type \fIprotocol\fR
@@ -321,6 +336,10 @@ cannot be optimized by the BPF optimizer code, so this can be somewhat
slow.
.IP "\fBip protochain \fIprotocol\fR"
Equivalent to \fBip6 protochain \fIprotocol\fR, but this is for IPv4.
+.IP "\fBprotochain \fIprotocol\fR"
+True if the packet is an IPv4 or IPv6 packet of protocol type
+\fIprotocol\fP. Note that this primitive chases the protocol
+header chain.
.IP "\fBether broadcast\fR"
True if the packet is an Ethernet broadcast packet.
The \fIether\fP
@@ -402,6 +421,25 @@ the filter checks for the IPX etype in an Ethernet frame, the IPX
DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
IPX, and the IPX etype in a SNAP frame.
.RE
+.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
+Abbreviations for:
+.in +.5i
+.nf
+\fBether proto \fIp\fR
+.fi
+.in -.5i
+where \fIp\fR is one of the above protocols.
+.IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
+Abbreviations for:
+.in +.5i
+.nf
+\fBether proto \fIp\fR
+.fi
+.in -.5i
+where \fIp\fR is one of the above protocols.
+Note that not all applications using
+.BR pcap (3PCAP)
+currently know how to parse these protocols.
.IP "\fBdecnet src \fIhost\fR"
True if the DECNET source address is
.IR host ,
@@ -503,25 +541,6 @@ True if the fourth IEEE 802.11 address, if present, is
.IR ehost .
The fourth address field is only used for
WDS (Wireless Distribution System) frames.
-.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
-Abbreviations for:
-.in +.5i
-.nf
-\fBether proto \fIp\fR
-.fi
-.in -.5i
-where \fIp\fR is one of the above protocols.
-.IP "\fBlat\fR, \fBmoprc\fR, \fBmopdl\fR"
-Abbreviations for:
-.in +.5i
-.nf
-\fBether proto \fIp\fR
-.fi
-.in -.5i
-where \fIp\fR is one of the above protocols.
-Note that not all applications using
-.BR pcap (3)
-currently know how to parse these protocols.
.IP "\fBtype \fIwlan_type\fR"
True if the IEEE 802.11 frame type matches the specified \fIwlan_type\fR.
Valid \fIwlan_type\fRs are:
@@ -638,9 +657,11 @@ any outer label.
.IP \fBpppoed\fP
True if the packet is a PPP-over-Ethernet Discovery packet (Ethernet
type 0x8863).
-.IP \fBpppoes\fP
+.IP "\fBpppoes \fI[session_id]\fR"
True if the packet is a PPP-over-Ethernet Session packet (Ethernet
type 0x8864).
+If \fI[session_id]\fR is specified, only true if the packet has the specified
+\fIsession_id\fR.
Note that the first \fBpppoes\fR keyword encountered in \fIexpression\fR
changes the decoding offsets for the remainder of \fIexpression\fR on
the assumption that the packet is a PPPoE session packet.
@@ -648,18 +669,10 @@ the assumption that the packet is a PPPoE session packet.
For example:
.in +.5i
.nf
-\fBpppoes && ip\fR
-.fi
-.in -.5i
-filters IPv4 protocols encapsulated in PPPoE.
-.IP "\fBtcp\fR, \fBudp\fR, \fBicmp\fR"
-Abbreviations for:
-.in +.5i
-.nf
-\fBip proto \fIp\fR\fB or ip6 proto \fIp\fR
+\fBpppoes 0x27 && ip\fR
.fi
.in -.5i
-where \fIp\fR is one of the above protocols.
+filters IPv4 protocols encapsulated in PPPoE session id 0x27.
.IP "\fBiso proto \fIprotocol\fR"
True if the packet is an OSI packet of protocol type \fIprotocol\fP.
\fIProtocol\fP can be a number or one of the names
@@ -674,11 +687,11 @@ Abbreviations for:
where \fIp\fR is one of the above protocols.
.IP "\fBl1\fR, \fBl2\fR, \fBiih\fR, \fBlsp\fR, \fBsnp\fR, \fBcsnp\fR, \fBpsnp\fR"
Abbreviations for IS-IS PDU types.
-.IP "\fBvpi\fP \fIn\fR
+.IP "\fBvpi\fP \fIn\fR"
True if the packet is an ATM packet, for SunATM on Solaris, with a
virtual path identifier of
.IR n .
-.IP "\fBvci\fP \fIn\fR
+.IP "\fBvci\fP \fIn\fR"
True if the packet is an ATM packet, for SunATM on Solaris, with a
virtual channel identifier of
.IR n .
@@ -918,27 +931,6 @@ icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply
.RE
.SH "SEE ALSO"
pcap(3PCAP)
-.SH AUTHORS
-The original authors are:
-.LP
-Van Jacobson,
-Craig Leres and
-Steven McCanne, all of the
-Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.
-.LP
-It is currently being maintained by tcpdump.org.
-.LP
-The current version of libpcap is available via http:
-.LP
-.RS
-.I http://www.tcpdump.org/
-.RE
-.LP
-The original distribution is available via anonymous ftp:
-.LP
-.RS
-.I ftp://ftp.ee.lbl.gov/tcpdump.tar.Z
-.RE
.SH BUGS
Please send problems, bugs, questions, desirable enhancements, etc. to:
.LP
diff --git a/external/bsd/libpcap/dist/pcap-int.h b/external/bsd/libpcap/dist/pcap-int.h
index 14b7ffdb6da..36e4a89b2c6 100644
--- a/external/bsd/libpcap/dist/pcap-int.h
+++ b/external/bsd/libpcap/dist/pcap-int.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-int.h,v 1.1.1.3 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-int.h,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 1994, 1995, 1996
@@ -44,10 +44,6 @@
extern "C" {
#endif
-#ifdef HAVE_LIBDLPI
-#include <libdlpi.h>
-#endif
-
#ifdef WIN32
#include <Packet32.h>
extern CRITICAL_SECTION g_PcapCompileCriticalSection;
@@ -58,10 +54,6 @@ extern CRITICAL_SECTION g_PcapCompileCriticalSection;
#include <io.h>
#endif
-#ifdef HAVE_SNF_API
-#include <snf.h>
-#endif
-
#if (defined(_MSC_VER) && (_MSC_VER <= 1200)) /* we are compiling with Visual Studio 6, that doesn't support the LL suffix*/
/*
@@ -94,139 +86,17 @@ extern CRITICAL_SECTION g_PcapCompileCriticalSection;
#endif /* _MSC_VER */
-/*
- * Savefile
- */
-typedef enum {
- NOT_SWAPPED,
- SWAPPED,
- MAYBE_SWAPPED
-} swapped_type_t;
-
-/*
- * Used when reading a savefile.
- */
-struct pcap_sf {
- FILE *rfile;
- int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
- int swapped;
- size_t hdrsize;
- swapped_type_t lengths_swapped;
- int version_major;
- int version_minor;
- bpf_u_int32 ifcount; /* number of interfaces seen in this capture */
- u_int tsresol; /* time stamp resolution */
- u_int tsscale; /* scaling factor for resolution -> microseconds */
- u_int64_t tsoffset; /* time stamp offset */
-};
-
-/*
- * Used when doing a live capture.
- */
-struct pcap_md {
- struct pcap_stat stat;
- /*XXX*/
- int use_bpf; /* using kernel filter */
- u_long TotPkts; /* can't oflow for 79 hrs on ether */
- u_long TotAccepted; /* count accepted by filter */
- u_long TotDrops; /* count of dropped packets */
- long TotMissed; /* missed by i/f during this run */
- long OrigMissed; /* missed by i/f before this run */
- char *device; /* device name */
- int timeout; /* timeout for buffering */
- int must_do_on_close; /* stuff we must do when we close */
- struct pcap *next; /* list of open pcaps that need stuff cleared on close */
-#ifdef linux
- int sock_packet; /* using Linux 2.0 compatible interface */
- int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
- int ifindex; /* interface index of device we're bound to */
- int lo_ifindex; /* interface index of the loopback device */
- u_int packets_read; /* count of packets read with recvfrom() */
- bpf_u_int32 oldmode; /* mode to restore when turning monitor mode off */
- char *mondevice; /* mac80211 monitor device we created */
- u_char *mmapbuf; /* memory-mapped region pointer */
- size_t mmapbuflen; /* size of region */
- u_int tp_version; /* version of tpacket_hdr for mmaped ring */
- u_int tp_hdrlen; /* hdrlen of tpacket_hdr for mmaped ring */
- u_char *oneshot_buffer; /* buffer for copy of packet */
- long proc_dropped; /* packets reported dropped by /proc/net/dev */
-#endif /* linux */
-
-#ifdef HAVE_DAG_API
-#ifdef HAVE_DAG_STREAMS_API
- u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
- u_char *dag_mem_top; /* DAG card current memory top pointer */
-#else /* HAVE_DAG_STREAMS_API */
- void *dag_mem_base; /* DAG card memory base address */
- u_int dag_mem_bottom; /* DAG card current memory bottom offset */
- u_int dag_mem_top; /* DAG card current memory top offset */
-#endif /* HAVE_DAG_STREAMS_API */
- int dag_fcs_bits; /* Number of checksum bits from link layer */
- int dag_offset_flags; /* Flags to pass to dag_offset(). */
- int dag_stream; /* DAG stream number */
- int dag_timeout; /* timeout specified to pcap_open_live.
- * Same as in linux above, introduce
- * generally? */
-#endif /* HAVE_DAG_API */
-#ifdef HAVE_SNF_API
- snf_handle_t snf_handle; /* opaque device handle */
- snf_ring_t snf_ring; /* opaque device ring handle */
- int snf_timeout;
- int snf_boardnum;
-#endif /*HAVE_SNF_API*/
-
-#ifdef HAVE_ZEROCOPY_BPF
- /*
- * Zero-copy read buffer -- for zero-copy BPF. 'buffer' above will
- * alternative between these two actual mmap'd buffers as required.
- * As there is a header on the front size of the mmap'd buffer, only
- * some of the buffer is exposed to libpcap as a whole via bufsize;
- * zbufsize is the true size. zbuffer tracks the current zbuf
- * assocated with buffer so that it can be used to decide which the
- * next buffer to read will be.
- */
- u_char *zbuf1, *zbuf2, *zbuffer;
- u_int zbufsize;
- u_int zerocopy;
- u_int interrupted;
- struct timespec firstsel;
- /*
- * If there's currently a buffer being actively processed, then it is
- * referenced here; 'buffer' is also pointed at it, but offset by the
- * size of the header.
- */
- struct bpf_zbuf_header *bzh;
-#endif /* HAVE_ZEROCOPY_BPF */
-};
-
-/*
- * Stuff to do when we close.
- */
-#define MUST_CLEAR_PROMISC 0x00000001 /* clear promiscuous mode */
-#define MUST_CLEAR_RFMON 0x00000002 /* clear rfmon (monitor) mode */
-#define MUST_DELETE_MONIF 0x00000004 /* delete monitor-mode interface */
-
struct pcap_opt {
- int buffer_size;
char *source;
+ int timeout; /* timeout for buffering */
+ int buffer_size;
int promisc;
- int rfmon;
+ int rfmon; /* monitor mode */
+ int immediate; /* immediate mode - deliver packets as soon as they arrive */
int tstamp_type;
+ int tstamp_precision;
};
-/*
- * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H
- * Tru64 UNIX, and some versions of NetBSD pad FDDI packets to make everything
- * line up on a nice boundary.
- */
-#ifdef __NetBSD__
-#include <sys/param.h> /* needed to declare __NetBSD_Version__ */
-#endif
-
-#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
-#define PCAP_FDDIPAD 3
-#endif
-
typedef int (*activate_op_t)(pcap_t *);
typedef int (*can_set_rfmon_op_t)(pcap_t *);
typedef int (*read_op_t)(pcap_t *, int cnt, pcap_handler, u_char *);
@@ -241,10 +111,25 @@ typedef int (*stats_op_t)(pcap_t *, struct pcap_stat *);
typedef int (*setbuff_op_t)(pcap_t *, int);
typedef int (*setmode_op_t)(pcap_t *, int);
typedef int (*setmintocopy_op_t)(pcap_t *, int);
+typedef Adapter *(*getadapter_op_t)(pcap_t *);
#endif
typedef void (*cleanup_op_t)(pcap_t *);
+/*
+ * We put all the stuff used in the read code path at the beginning,
+ * to try to keep it together in the same cache line or lines.
+ */
struct pcap {
+ /*
+ * Method to call to read packets on a live capture.
+ */
+ read_op_t read_op;
+
+ /*
+ * Method to call to read to read packets from a savefile.
+ */
+ int (*next_packet_op)(pcap_t *, struct pcap_pkthdr *, u_char **);
+
#ifdef WIN32
ADAPTER *adapter;
LPPACKET Packet;
@@ -252,12 +137,34 @@ struct pcap {
#else
int fd;
int selectable_fd;
- int send_fd;
#endif /* WIN32 */
-#ifdef HAVE_LIBDLPI
- dlpi_handle_t dlpi_hd;
-#endif
+ /*
+ * Read buffer.
+ */
+ int bufsize;
+ u_char *buffer;
+ u_char *bp;
+ int cc;
+
+ int break_loop; /* flag set to force break from packet-reading loop */
+
+ void *priv; /* private data for methods */
+
+ int swapped;
+ FILE *rfile; /* null if live capture, non-null if savefile */
+ int fddipad;
+ struct pcap *next; /* list of open pcaps that need stuff cleared on close */
+
+ /*
+ * File version number; meaningful only for a savefile, but we
+ * keep it here so that apps that (mistakenly) ask for the
+ * version numbers will get the same zero values that they
+ * always did.
+ */
+ int version_major;
+ int version_minor;
+
int snapshot;
int linktype; /* Network linktype */
int linktype_ext; /* Extended information stored in the linktype field of a file */
@@ -266,29 +173,9 @@ struct pcap {
int activated; /* true if the capture is really started */
int oldstyle; /* if we're opening with pcap_open_live() */
- int break_loop; /* flag set to force break from packet-reading loop */
-
-#ifdef PCAP_FDDIPAD
- int fddipad;
-#endif
-
-#ifdef MSDOS
- void (*wait_proc)(void); /* call proc while waiting */
-#endif
-
- struct pcap_sf sf;
- struct pcap_md md;
struct pcap_opt opt;
/*
- * Read buffer.
- */
- int bufsize;
- u_char *buffer;
- u_char *bp;
- int cc;
-
- /*
* Place holder for pcap_next().
*/
u_char *pkt;
@@ -297,11 +184,25 @@ struct pcap {
pcap_direction_t direction;
/*
- * Methods.
+ * Placeholder for filter code if bpf not in kernel.
+ */
+ struct bpf_program fcode;
+
+ char errbuf[PCAP_ERRBUF_SIZE + 1];
+ int dlt_count;
+ u_int *dlt_list;
+ int tstamp_type_count;
+ u_int *tstamp_type_list;
+ int tstamp_precision_count;
+ u_int *tstamp_precision_list;
+
+ struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
+
+ /*
+ * More methods.
*/
activate_op_t activate_op;
can_set_rfmon_op_t can_set_rfmon_op;
- read_op_t read_op;
inject_op_t inject_op;
setfilter_op_t setfilter_op;
setdirection_op_t setdirection_op;
@@ -323,21 +224,9 @@ struct pcap {
setbuff_op_t setbuff_op;
setmode_op_t setmode_op;
setmintocopy_op_t setmintocopy_op;
+ getadapter_op_t getadapter_op;
#endif
cleanup_op_t cleanup_op;
-
- /*
- * Placeholder for filter code if bpf not in kernel.
- */
- struct bpf_program fcode;
-
- char errbuf[PCAP_ERRBUF_SIZE + 1];
- int dlt_count;
- u_int *dlt_list;
- int tstamp_type_count;
- u_int *tstamp_type_list;
-
- struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
};
/*
@@ -376,12 +265,13 @@ struct pcap_timeval {
* the old record header as well as files with the new record header
* (using the magic number to determine the header format).
*
- * Then supply the changes as a patch at
+ * Then supply the changes by forking the branch at
*
- * http://sourceforge.net/projects/libpcap/
+ * https://github.com/the-tcpdump-group/libpcap/issues
*
- * so that future versions of libpcap and programs that use it (such as
- * tcpdump) will be able to read your new capture file format.
+ * and issuing a pull request, so that future versions of libpcap and
+ * programs that use it (such as tcpdump) will be able to read your new
+ * capture file format.
*/
struct pcap_sf_pkthdr {
@@ -456,7 +346,19 @@ int pcap_getnonblock_fd(pcap_t *, char *);
int pcap_setnonblock_fd(pcap_t *p, int, char *);
#endif
-pcap_t *pcap_create_common(const char *, char *);
+/*
+ * Internal interfaces for "pcap_create()".
+ *
+ * "pcap_create_interface()" is the routine to do a pcap_create on
+ * a regular network interface. There are multiple implementations
+ * of this, one for each platform type (Linux, BPF, DLPI, etc.),
+ * with the one used chosen by the configure script.
+ *
+ * "pcap_create_common()" allocates and fills in a pcap_t, for use
+ * by pcap_create routines.
+ */
+pcap_t *pcap_create_interface(const char *, char *);
+pcap_t *pcap_create_common(const char *, char *, size_t);
int pcap_do_addexit(pcap_t *);
void pcap_add_to_pcaps_to_close(pcap_t *);
void pcap_remove_from_pcaps_to_close(pcap_t *);
@@ -467,12 +369,16 @@ int pcap_check_activated(pcap_t *);
/*
* Internal interfaces for "pcap_findalldevs()".
*
+ * "pcap_findalldevs_interfaces()" finds interfaces using the
+ * "standard" mechanisms (SIOCGIFCONF, "getifaddrs()", etc.).
+ *
* "pcap_platform_finddevs()" is a platform-dependent routine to
- * add devices not found by the "standard" mechanisms (SIOCGIFCONF,
- * "getifaddrs()", etc..
+ * add devices not found by the "standard" mechanisms.
*
- * "pcap_add_if()" adds an interface to the list of interfaces.
+ * "pcap_add_if()" adds an interface to the list of interfaces, for
+ * use by various "find interfaces" routines.
*/
+int pcap_findalldevs_interfaces(pcap_if_t **, char *);
int pcap_platform_finddevs(pcap_if_t **, char *);
int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
@@ -482,6 +388,28 @@ struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
const char *, char *);
+/*
+ * Internal interfaces for "pcap_open_offline()".
+ *
+ * "pcap_open_offline_common()" allocates and fills in a pcap_t, for use
+ * by pcap_open_offline routines.
+ *
+ * "sf_cleanup()" closes the file handle associated with a pcap_t, if
+ * appropriate, and frees all data common to all modules for handling
+ * savefile types.
+ */
+pcap_t *pcap_open_offline_common(char *ebuf, size_t size);
+void sf_cleanup(pcap_t *p);
+
+/*
+ * Internal interfaces for both "pcap_create()" and routines that
+ * open savefiles.
+ *
+ * "pcap_oneshot()" is the standard one-shot callback for "pcap_next()"
+ * and "pcap_next_ex()".
+ */
+void pcap_oneshot(u_char *, const struct pcap_pkthdr *, const u_char *);
+
#ifdef WIN32
char *pcap_win32strerror(void);
#endif
diff --git a/external/bsd/libpcap/dist/pcap-libdlpi.c b/external/bsd/libpcap/dist/pcap-libdlpi.c
index 5626ee86020..661ca912333 100644
--- a/external/bsd/libpcap/dist/pcap-libdlpi.c
+++ b/external/bsd/libpcap/dist/pcap-libdlpi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-libdlpi.c,v 1.1.1.3 2013/04/06 15:57:44 christos Exp $ */
+/* $NetBSD: pcap-libdlpi.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -54,7 +54,6 @@ static const char rcsid[] _U_ =
static int dlpromiscon(pcap_t *, bpf_u_int32);
static int pcap_read_libdlpi(pcap_t *, int, pcap_handler, u_char *);
static int pcap_inject_libdlpi(pcap_t *, const void *, size_t);
-static void pcap_close_libdlpi(pcap_t *);
static void pcap_libdlpi_err(const char *, const char *, int, char *);
static void pcap_cleanup_libdlpi(pcap_t *);
@@ -103,6 +102,7 @@ list_interfaces(const char *linkname, void *arg)
static int
pcap_activate_libdlpi(pcap_t *p)
{
+ struct pcap_dlpi *pd = p->priv;
int retv;
dlpi_handle_t dh;
dlpi_info_t dlinfo;
@@ -124,7 +124,7 @@ pcap_activate_libdlpi(pcap_t *p)
p->errbuf);
return (err);
}
- p->dlpi_hd = dh;
+ pd->dlpi_hd = dh;
if (p->opt.rfmon) {
/*
@@ -136,7 +136,7 @@ pcap_activate_libdlpi(pcap_t *p)
}
/* Bind with DLPI_ANY_SAP. */
- if ((retv = dlpi_bind(p->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
+ if ((retv = dlpi_bind(pd->dlpi_hd, DLPI_ANY_SAP, 0)) != DLPI_SUCCESS) {
pcap_libdlpi_err(p->opt.source, "dlpi_bind", retv, p->errbuf);
goto bad;
}
@@ -183,7 +183,7 @@ pcap_activate_libdlpi(pcap_t *p)
}
/* Determine link type. */
- if ((retv = dlpi_info(p->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
+ if ((retv = dlpi_info(pd->dlpi_hd, &dlinfo, 0)) != DLPI_SUCCESS) {
pcap_libdlpi_err(p->opt.source, "dlpi_info", retv, p->errbuf);
goto bad;
}
@@ -191,10 +191,10 @@ pcap_activate_libdlpi(pcap_t *p)
if (pcap_process_mactype(p, dlinfo.di_mactype) != 0)
goto bad;
- p->fd = dlpi_fd(p->dlpi_hd);
+ p->fd = dlpi_fd(pd->dlpi_hd);
/* Push and configure bufmod. */
- if (pcap_conf_bufmod(p, p->snapshot, p->md.timeout) != 0)
+ if (pcap_conf_bufmod(p, p->snapshot) != 0)
goto bad;
/*
@@ -237,9 +237,11 @@ bad:
static int
dlpromiscon(pcap_t *p, bpf_u_int32 level)
{
+ struct pcap_dlpi *pd = p->priv;
+ int retv;
int err;
- retv = dlpi_promiscon(p->hd, level);
+ retv = dlpi_promiscon(pd->dlpi_hd, level);
if (retv != DLPI_SUCCESS) {
if (retv == DL_SYSERR &&
(errno == EPERM || errno == EACCES))
@@ -301,6 +303,7 @@ done:
static int
pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
{
+ struct pcap_dlpi *pd = p->priv;
int len;
u_char *bufp;
size_t msglen;
@@ -326,7 +329,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
msglen = p->bufsize;
bufp = p->buffer + p->offset;
- retv = dlpi_recv(p->dlpi_hd, NULL, NULL, bufp,
+ retv = dlpi_recv(pd->dlpi_hd, NULL, NULL, bufp,
&msglen, -1, NULL);
if (retv != DLPI_SUCCESS) {
/*
@@ -338,7 +341,7 @@ pcap_read_libdlpi(pcap_t *p, int count, pcap_handler callback, u_char *user)
len = 0;
continue;
}
- pcap_libdlpi_err(dlpi_linkname(p->dlpi_hd),
+ pcap_libdlpi_err(dlpi_linkname(pd->dlpi_hd),
"dlpi_recv", retv, p->errbuf);
return (-1);
}
@@ -352,11 +355,12 @@ process_pkts:
static int
pcap_inject_libdlpi(pcap_t *p, const void *buf, size_t size)
{
+ struct pcap_dlpi *pd = p->priv;
int retv;
- retv = dlpi_send(p->dlpi_hd, NULL, 0, buf, size, NULL);
+ retv = dlpi_send(pd->dlpi_hd, NULL, 0, buf, size, NULL);
if (retv != DLPI_SUCCESS) {
- pcap_libdlpi_err(dlpi_linkname(p->dlpi_hd), "dlpi_send", retv,
+ pcap_libdlpi_err(dlpi_linkname(pd->dlpi_hd), "dlpi_send", retv,
p->errbuf);
return (-1);
}
@@ -374,9 +378,11 @@ pcap_inject_libdlpi(pcap_t *p, const void *buf, size_t size)
static void
pcap_cleanup_libdlpi(pcap_t *p)
{
- if (p->dlpi_hd != NULL) {
- dlpi_close(p->dlpi_hd);
- p->dlpi_hd = NULL;
+ struct pcap_dlpi *pd = p->priv;
+
+ if (pd->dlpi_hd != NULL) {
+ dlpi_close(pd->dlpi_hd);
+ pd->dlpi_hd = NULL;
p->fd = -1;
}
pcap_cleanup_live_common(p);
@@ -393,11 +399,11 @@ pcap_libdlpi_err(const char *linkname, const char *func, int err, char *errbuf)
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_dlpi));
if (p == NULL)
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-linux.c b/external/bsd/libpcap/dist/pcap-linux.c
index fe59476a532..d6eaa378683 100644
--- a/external/bsd/libpcap/dist/pcap-linux.c
+++ b/external/bsd/libpcap/dist/pcap-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-linux.c,v 1.1.1.3 2013/04/06 15:57:48 christos Exp $ */
+/* $NetBSD: pcap-linux.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */
/*
* pcap-linux.c: Packet capture interface to the Linux kernel
@@ -28,6 +28,8 @@
*
* Modifications: Added PACKET_MMAP support
* Paolo Abeni <paolo.abeni@email.it>
+ * Added TPACKET_V3 support
+ * Gabor Tatarka <gabor.tatarka@ericsson.com>
*
* based on previous works of:
* Simon Patarin <patarin@cs.unibo.it>
@@ -129,11 +131,14 @@ static const char rcsid[] _U_ =
#include <fcntl.h>
#include <string.h>
#include <limits.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/utsname.h>
#include <sys/mman.h>
#include <linux/if.h>
+#include <linux/if_packet.h>
+#include <linux/sockios.h>
#include <netinet/in.h>
#include <linux/if_ether.h>
#include <net/if_arp.h>
@@ -144,38 +149,6 @@ static const char rcsid[] _U_ =
#include "pcap/sll.h"
#include "pcap/vlan.h"
-#ifdef HAVE_DAG_API
-#include "pcap-dag.h"
-#endif /* HAVE_DAG_API */
-
-#ifdef HAVE_SEPTEL_API
-#include "pcap-septel.h"
-#endif /* HAVE_SEPTEL_API */
-
-#ifdef HAVE_SNF_API
-#include "pcap-snf.h"
-#endif /* HAVE_SNF_API */
-
-#ifdef PCAP_SUPPORT_USB
-#include "pcap-usb-linux.h"
-#endif
-
-#ifdef PCAP_SUPPORT_BT
-#include "pcap-bt-linux.h"
-#endif
-
-#ifdef PCAP_SUPPORT_CAN
-#include "pcap-can-linux.h"
-#endif
-
-#if PCAP_SUPPORT_CANUSB
-#include "pcap-canusb-linux.h"
-#endif
-
-#ifdef PCAP_SUPPORT_NETFILTER
-#include "pcap-netfilter-linux.h"
-#endif
-
/*
* If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
* sockets rather than SOCK_PACKET sockets.
@@ -227,10 +200,13 @@ static const char rcsid[] _U_ =
* uses many ring related structs and macros */
# ifdef TPACKET_HDRLEN
# define HAVE_PACKET_RING
+# ifdef TPACKET3_HDRLEN
+# define HAVE_TPACKET3
+# endif /* TPACKET3_HDRLEN */
# ifdef TPACKET2_HDRLEN
# define HAVE_TPACKET2
-# else
-# define TPACKET_V1 0
+# else /* TPACKET2_HDRLEN */
+# define TPACKET_V1 0 /* Old kernel with only V1, so no TPACKET_Vn defined */
# endif /* TPACKET2_HDRLEN */
# endif /* TPACKET_HDRLEN */
#endif /* PF_PACKET */
@@ -240,15 +216,6 @@ static const char rcsid[] _U_ =
#include <linux/filter.h>
#endif
-/*
- * We need linux/sockios.h if we have linux/net_tstamp.h (for time stamp
- * specification) or linux/ethtool.h (for ethtool ioctls to get offloading
- * information).
- */
-#if defined(HAVE_LINUX_NET_TSTAMP_H) || defined(HAVE_LINUX_ETHTOOL_H)
-#include <linux/sockios.h>
-#endif
-
#ifdef HAVE_LINUX_NET_TSTAMP_H
#include <linux/net_tstamp.h>
#endif
@@ -316,6 +283,43 @@ typedef int socklen_t;
#define BIGGER_THAN_ALL_MTUS (64*1024)
/*
+ * Private data for capturing on Linux SOCK_PACKET or PF_PACKET sockets.
+ */
+struct pcap_linux {
+ u_int packets_read; /* count of packets read with recvfrom() */
+ long proc_dropped; /* packets reported dropped by /proc/net/dev */
+ struct pcap_stat stat;
+
+ char *device; /* device name */
+ int filtering_in_kernel; /* using kernel filter */
+ int must_do_on_close; /* stuff we must do when we close */
+ int timeout; /* timeout for buffering */
+ int sock_packet; /* using Linux 2.0 compatible interface */
+ int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
+ int ifindex; /* interface index of device we're bound to */
+ int lo_ifindex; /* interface index of the loopback device */
+ bpf_u_int32 oldmode; /* mode to restore when turning monitor mode off */
+ char *mondevice; /* mac80211 monitor device we created */
+ u_char *mmapbuf; /* memory-mapped region pointer */
+ size_t mmapbuflen; /* size of region */
+ int vlan_offset; /* offset at which to insert vlan tags; if -1, don't insert */
+ u_int tp_version; /* version of tpacket_hdr for mmaped ring */
+ u_int tp_hdrlen; /* hdrlen of tpacket_hdr for mmaped ring */
+ u_char *oneshot_buffer; /* buffer for copy of packet */
+#ifdef HAVE_TPACKET3
+ unsigned char *current_packet; /* Current packet within the TPACKET_V3 block. Move to next block if NULL. */
+ int packets_left; /* Unhandled packets left within the block from previous call to pcap_read_linux_mmap_v3 in case of TPACKET_V3. */
+#endif
+};
+
+/*
+ * Stuff to do when we close.
+ */
+#define MUST_CLEAR_PROMISC 0x00000001 /* clear promiscuous mode */
+#define MUST_CLEAR_RFMON 0x00000002 /* clear rfmon (monitor) mode */
+#define MUST_DELETE_MONIF 0x00000004 /* delete monitor-mode interface */
+
+/*
* Prototypes for internal functions and methods.
*/
static void map_arphrd_to_dlt(pcap_t *, int, int);
@@ -333,12 +337,18 @@ static int pcap_inject_linux(pcap_t *, const void *, size_t);
static int pcap_stats_linux(pcap_t *, struct pcap_stat *);
static int pcap_setfilter_linux(pcap_t *, struct bpf_program *);
static int pcap_setdirection_linux(pcap_t *, pcap_direction_t);
+static int pcap_set_datalink_linux(pcap_t *, int);
static void pcap_cleanup_linux(pcap_t *);
union thdr {
- struct tpacket_hdr *h1;
- struct tpacket2_hdr *h2;
- void *raw;
+ struct tpacket_hdr *h1;
+#ifdef HAVE_TPACKET2
+ struct tpacket2_hdr *h2;
+#endif
+#ifdef HAVE_TPACKET3
+ struct tpacket_block_desc *h3;
+#endif
+ void *raw;
};
#ifdef HAVE_PACKET_RING
@@ -348,7 +358,13 @@ static void destroy_ring(pcap_t *handle);
static int create_ring(pcap_t *handle, int *status);
static int prepare_tpacket_socket(pcap_t *handle);
static void pcap_cleanup_linux_mmap(pcap_t *);
-static int pcap_read_linux_mmap(pcap_t *, int, pcap_handler , u_char *);
+static int pcap_read_linux_mmap_v1(pcap_t *, int, pcap_handler , u_char *);
+#ifdef HAVE_TPACKET2
+static int pcap_read_linux_mmap_v2(pcap_t *, int, pcap_handler , u_char *);
+#endif
+#ifdef HAVE_TPACKET3
+static int pcap_read_linux_mmap_v3(pcap_t *, int, pcap_handler , u_char *);
+#endif
static int pcap_setfilter_linux_mmap(pcap_t *, struct bpf_program *);
static int pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf);
static int pcap_getnonblock_mmap(pcap_t *p, char *errbuf);
@@ -389,67 +405,11 @@ static struct sock_fprog total_fcode
#endif /* SO_ATTACH_FILTER */
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *handle;
- /*
- * A null device name is equivalent to the "any" device.
- */
- if (device == NULL)
- device = "any";
-
-#ifdef HAVE_DAG_API
- if (strstr(device, "dag")) {
- return dag_create(device, ebuf);
- }
-#endif /* HAVE_DAG_API */
-
-#ifdef HAVE_SEPTEL_API
- if (strstr(device, "septel")) {
- return septel_create(device, ebuf);
- }
-#endif /* HAVE_SEPTEL_API */
-
-#ifdef HAVE_SNF_API
- handle = snf_create(device, ebuf);
- if (strstr(device, "snf") || handle != NULL)
- return handle;
-
-#endif /* HAVE_SNF_API */
-
-#ifdef PCAP_SUPPORT_BT
- if (strstr(device, "bluetooth")) {
- return bt_create(device, ebuf);
- }
-#endif
-
-#if PCAP_SUPPORT_CANUSB
- if (strstr(device, "canusb")) {
- return canusb_create(device, ebuf);
- }
-#endif
-
-#ifdef PCAP_SUPPORT_CAN
- if ((strncmp(device, "can", 3) == 0 && isdigit(device[3])) ||
- (strncmp(device, "vcan", 4) == 0 && isdigit(device[4]))) {
- return can_create(device, ebuf);
- }
-#endif
-
-#ifdef PCAP_SUPPORT_USB
- if (strstr(device, "usbmon")) {
- return usb_create(device, ebuf);
- }
-#endif
-
-#ifdef PCAP_SUPPORT_NETFILTER
- if (strncmp(device, "nflog", strlen("nflog")) == 0) {
- return nflog_create(device, ebuf);
- }
-#endif
-
- handle = pcap_create_common(device, ebuf);
+ handle = pcap_create_common(device, ebuf, sizeof (struct pcap_linux));
if (handle == NULL)
return NULL;
@@ -477,6 +437,27 @@ pcap_create(const char *device, char *ebuf)
handle->tstamp_type_list[2] = PCAP_TSTAMP_ADAPTER_UNSYNCED;
#endif
+#if defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS)
+ /*
+ * We claim that we support microsecond and nanosecond time
+ * stamps.
+ *
+ * XXX - with adapter-supplied time stamps, can we choose
+ * microsecond or nanosecond time stamps on arbitrary
+ * adapters?
+ */
+ handle->tstamp_precision_count = 2;
+ handle->tstamp_precision_list = malloc(2 * sizeof(u_int));
+ if (handle->tstamp_precision_list == NULL) {
+ if (handle->tstamp_type_list != NULL)
+ free(handle->tstamp_type_list);
+ free(handle);
+ return NULL;
+ }
+ handle->tstamp_precision_list[0] = PCAP_TSTAMP_PRECISION_MICRO;
+ handle->tstamp_precision_list[1] = PCAP_TSTAMP_PRECISION_NANO;
+#endif /* defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS) */
+
return handle;
}
@@ -566,7 +547,7 @@ get_mac80211_phydev(pcap_t *handle, const char *device, char *phydev_path,
return 1;
}
-#ifdef HAVE_LIBNL_2_x
+#ifdef HAVE_LIBNL_SOCKETS
#define get_nl_errmsg nl_geterror
#else
/* libnl 2.x compatibility code */
@@ -597,7 +578,7 @@ __genl_ctrl_alloc_cache(struct nl_handle *h, struct nl_cache **cache)
return 0;
}
#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache
-#endif /* !HAVE_LIBNL_2_x */
+#endif /* !HAVE_LIBNL_SOCKETS */
struct nl80211_state {
struct nl_sock *nl_sock;
@@ -682,7 +663,7 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state,
err = nl_send_auto_complete(state->nl_sock, msg);
if (err < 0) {
-#ifdef HAVE_LIBNL_2_x
+#if defined HAVE_LIBNL_NLE
if (err == -NLE_FAILURE) {
#else
if (err == -ENFILE) {
@@ -710,7 +691,7 @@ add_mon_if(pcap_t *handle, int sock_fd, struct nl80211_state *state,
}
err = nl_wait_for_ack(state->nl_sock);
if (err < 0) {
-#ifdef HAVE_LIBNL_2_x
+#if defined HAVE_LIBNL_NLE
if (err == -NLE_FAILURE) {
#else
if (err == -ENFILE) {
@@ -808,6 +789,7 @@ nla_put_failure:
static int
enter_rfmon_mode_mac80211(pcap_t *handle, int sock_fd, const char *device)
{
+ struct pcap_linux *handlep = handle->priv;
int ret;
char phydev_path[PATH_MAX+1];
struct nl80211_state nlstate;
@@ -845,7 +827,7 @@ enter_rfmon_mode_mac80211(pcap_t *handle, int sock_fd, const char *device)
snprintf(mondevice, sizeof mondevice, "mon%u", n);
ret = add_mon_if(handle, sock_fd, &nlstate, device, mondevice);
if (ret == 1) {
- handle->md.mondevice = strdup(mondevice);
+ handlep->mondevice = strdup(mondevice);
goto added;
}
if (ret < 0) {
@@ -890,13 +872,13 @@ added:
* Now configure the monitor interface up.
*/
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, handle->md.mondevice, sizeof(ifr.ifr_name));
+ strncpy(ifr.ifr_name, handlep->mondevice, sizeof(ifr.ifr_name));
if (ioctl(sock_fd, SIOCGIFFLAGS, &ifr) == -1) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"%s: Can't get flags for %s: %s", device,
- handle->md.mondevice, strerror(errno));
+ handlep->mondevice, strerror(errno));
del_mon_if(handle, sock_fd, &nlstate, device,
- handle->md.mondevice);
+ handlep->mondevice);
nl80211_cleanup(&nlstate);
return PCAP_ERROR;
}
@@ -904,9 +886,9 @@ added:
if (ioctl(sock_fd, SIOCSIFFLAGS, &ifr) == -1) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"%s: Can't set flags for %s: %s", device,
- handle->md.mondevice, strerror(errno));
+ handlep->mondevice, strerror(errno));
del_mon_if(handle, sock_fd, &nlstate, device,
- handle->md.mondevice);
+ handlep->mondevice);
nl80211_cleanup(&nlstate);
return PCAP_ERROR;
}
@@ -920,7 +902,7 @@ added:
* Note that we have to delete the monitor device when we close
* the handle.
*/
- handle->md.must_do_on_close |= MUST_DELETE_MONIF;
+ handlep->must_do_on_close |= MUST_DELETE_MONIF;
/*
* Add this to the list of pcaps to close when we exit.
@@ -1089,6 +1071,7 @@ linux_if_drops(const char * if_name)
static void pcap_cleanup_linux( pcap_t *handle )
{
+ struct pcap_linux *handlep = handle->priv;
struct ifreq ifr;
#ifdef HAVE_LIBNL
struct nl80211_state nlstate;
@@ -1099,12 +1082,12 @@ static void pcap_cleanup_linux( pcap_t *handle )
struct iwreq ireq;
#endif /* IW_MODE_MONITOR */
- if (handle->md.must_do_on_close != 0) {
+ if (handlep->must_do_on_close != 0) {
/*
* There's something we have to do when closing this
* pcap_t.
*/
- if (handle->md.must_do_on_close & MUST_CLEAR_PROMISC) {
+ if (handlep->must_do_on_close & MUST_CLEAR_PROMISC) {
/*
* We put the interface into promiscuous mode;
* take it out of promiscuous mode.
@@ -1115,14 +1098,14 @@ static void pcap_cleanup_linux( pcap_t *handle )
* in 2.0[.x] kernels.
*/
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, handle->md.device,
+ strncpy(ifr.ifr_name, handlep->device,
sizeof(ifr.ifr_name));
if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) == -1) {
fprintf(stderr,
"Can't restore interface %s flags (SIOCGIFFLAGS failed: %s).\n"
"Please adjust manually.\n"
"Hint: This can't happen with Linux >= 2.2.0.\n",
- handle->md.device, strerror(errno));
+ handlep->device, strerror(errno));
} else {
if (ifr.ifr_flags & IFF_PROMISC) {
/*
@@ -1136,7 +1119,7 @@ static void pcap_cleanup_linux( pcap_t *handle )
"Can't restore interface %s flags (SIOCSIFFLAGS failed: %s).\n"
"Please adjust manually.\n"
"Hint: This can't happen with Linux >= 2.2.0.\n",
- handle->md.device,
+ handlep->device,
strerror(errno));
}
}
@@ -1144,24 +1127,24 @@ static void pcap_cleanup_linux( pcap_t *handle )
}
#ifdef HAVE_LIBNL
- if (handle->md.must_do_on_close & MUST_DELETE_MONIF) {
- ret = nl80211_init(handle, &nlstate, handle->md.device);
+ if (handlep->must_do_on_close & MUST_DELETE_MONIF) {
+ ret = nl80211_init(handle, &nlstate, handlep->device);
if (ret >= 0) {
ret = del_mon_if(handle, handle->fd, &nlstate,
- handle->md.device, handle->md.mondevice);
+ handlep->device, handlep->mondevice);
nl80211_cleanup(&nlstate);
}
if (ret < 0) {
fprintf(stderr,
"Can't delete monitor interface %s (%s).\n"
"Please delete manually.\n",
- handle->md.mondevice, handle->errbuf);
+ handlep->mondevice, handle->errbuf);
}
}
#endif /* HAVE_LIBNL */
#ifdef IW_MODE_MONITOR
- if (handle->md.must_do_on_close & MUST_CLEAR_RFMON) {
+ if (handlep->must_do_on_close & MUST_CLEAR_RFMON) {
/*
* We put the interface into rfmon mode;
* take it out of rfmon mode.
@@ -1179,7 +1162,7 @@ static void pcap_cleanup_linux( pcap_t *handle )
*/
oldflags = 0;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, handle->md.device,
+ strncpy(ifr.ifr_name, handlep->device,
sizeof(ifr.ifr_name));
if (ioctl(handle->fd, SIOCGIFFLAGS, &ifr) != -1) {
if (ifr.ifr_flags & IFF_UP) {
@@ -1193,11 +1176,11 @@ static void pcap_cleanup_linux( pcap_t *handle )
/*
* Now restore the mode.
*/
- strncpy(ireq.ifr_ifrn.ifrn_name, handle->md.device,
+ strncpy(ireq.ifr_ifrn.ifrn_name, handlep->device,
sizeof ireq.ifr_ifrn.ifrn_name);
ireq.ifr_ifrn.ifrn_name[sizeof ireq.ifr_ifrn.ifrn_name - 1]
= 0;
- ireq.u.mode = handle->md.oldmode;
+ ireq.u.mode = handlep->oldmode;
if (ioctl(handle->fd, SIOCSIWMODE, &ireq) == -1) {
/*
* Scientist, you've failed.
@@ -1205,7 +1188,7 @@ static void pcap_cleanup_linux( pcap_t *handle )
fprintf(stderr,
"Can't restore interface %s wireless mode (SIOCSIWMODE failed: %s).\n"
"Please adjust manually.\n",
- handle->md.device, strerror(errno));
+ handlep->device, strerror(errno));
}
/*
@@ -1218,7 +1201,7 @@ static void pcap_cleanup_linux( pcap_t *handle )
fprintf(stderr,
"Can't bring interface %s back up (SIOCSIFFLAGS failed: %s).\n"
"Please adjust manually.\n",
- handle->md.device, strerror(errno));
+ handlep->device, strerror(errno));
}
}
}
@@ -1231,13 +1214,13 @@ static void pcap_cleanup_linux( pcap_t *handle )
pcap_remove_from_pcaps_to_close(handle);
}
- if (handle->md.mondevice != NULL) {
- free(handle->md.mondevice);
- handle->md.mondevice = NULL;
+ if (handlep->mondevice != NULL) {
+ free(handlep->mondevice);
+ handlep->mondevice = NULL;
}
- if (handle->md.device != NULL) {
- free(handle->md.device);
- handle->md.device = NULL;
+ if (handlep->device != NULL) {
+ free(handlep->device);
+ handlep->device = NULL;
}
pcap_cleanup_live_common(handle);
}
@@ -1253,6 +1236,7 @@ static void pcap_cleanup_linux( pcap_t *handle )
static int
pcap_activate_linux(pcap_t *handle)
{
+ struct pcap_linux *handlep = handle->priv;
const char *device;
int status = 0;
@@ -1261,7 +1245,7 @@ pcap_activate_linux(pcap_t *handle)
handle->inject_op = pcap_inject_linux;
handle->setfilter_op = pcap_setfilter_linux;
handle->setdirection_op = pcap_setdirection_linux;
- handle->set_datalink_op = NULL; /* can't change data link type */
+ handle->set_datalink_op = pcap_set_datalink_linux;
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
handle->cleanup_op = pcap_cleanup_linux;
@@ -1283,20 +1267,23 @@ pcap_activate_linux(pcap_t *handle)
}
}
- handle->md.device = strdup(device);
- if (handle->md.device == NULL) {
+ handlep->device = strdup(device);
+ if (handlep->device == NULL) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "strdup: %s",
pcap_strerror(errno) );
return PCAP_ERROR;
}
+ /* copy timeout value */
+ handlep->timeout = handle->opt.timeout;
+
/*
* If we're in promiscuous mode, then we probably want
* to see when the interface drops packets too, so get an
* initial count from /proc/net/dev
*/
if (handle->opt.promisc)
- handle->md.proc_dropped = linux_if_drops(handle->md.device);
+ handlep->proc_dropped = linux_if_drops(handlep->device);
/*
* Current Linux kernels use the protocol family PF_PACKET to
@@ -1418,6 +1405,49 @@ pcap_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *
return pcap_read_packet(handle, callback, user);
}
+static int
+pcap_set_datalink_linux(pcap_t *handle, int dlt)
+{
+ handle->linktype = dlt;
+ return 0;
+}
+
+/*
+ * linux_check_direction()
+ *
+ * Do checks based on packet direction.
+ */
+static inline int
+linux_check_direction(const pcap_t *handle, const struct sockaddr_ll *sll)
+{
+ struct pcap_linux *handlep = handle->priv;
+
+ if (sll->sll_pkttype == PACKET_OUTGOING) {
+ /*
+ * Outgoing packet.
+ * If this is from the loopback device, reject it;
+ * we'll see the packet as an incoming packet as well,
+ * and we don't want to see it twice.
+ */
+ if (sll->sll_ifindex == handlep->lo_ifindex)
+ return 0;
+
+ /*
+ * If the user only wants incoming packets, reject it.
+ */
+ if (handle->direction == PCAP_D_IN)
+ return 0;
+ } else {
+ /*
+ * Incoming packet.
+ * If the user only wants outgoing packets, reject it.
+ */
+ if (handle->direction == PCAP_D_OUT)
+ return 0;
+ }
+ return 1;
+}
+
/*
* Read a packet from the socket calling the handler provided by
* the user. Returns the number of packets received or -1 if an
@@ -1426,6 +1456,7 @@ pcap_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *
static int
pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
{
+ struct pcap_linux *handlep = handle->priv;
u_char *bp;
int offset;
#ifdef HAVE_PF_PACKET_SOCKETS
@@ -1453,7 +1484,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
* If this is a cooked device, leave extra room for a
* fake packet header.
*/
- if (handle->md.cooked)
+ if (handlep->cooked)
offset = SLL_HDR_LEN;
else
offset = 0;
@@ -1548,7 +1579,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
}
#ifdef HAVE_PF_PACKET_SOCKETS
- if (!handle->md.sock_packet) {
+ if (!handlep->sock_packet) {
/*
* Unfortunately, there is a window between socket() and
* bind() where the kernel may queue packets from any
@@ -1561,8 +1592,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
* filter support, and it's a bit more complicated.
* It would save some instructions per packet, however.)
*/
- if (handle->md.ifindex != -1 &&
- from.sll_ifindex != handle->md.ifindex)
+ if (handlep->ifindex != -1 &&
+ from.sll_ifindex != handlep->ifindex)
return 0;
/*
@@ -1571,29 +1602,8 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
* address returned for SOCK_PACKET is a "sockaddr_pkt"
* which lacks the relevant packet type information.
*/
- if (from.sll_pkttype == PACKET_OUTGOING) {
- /*
- * Outgoing packet.
- * If this is from the loopback device, reject it;
- * we'll see the packet as an incoming packet as well,
- * and we don't want to see it twice.
- */
- if (from.sll_ifindex == handle->md.lo_ifindex)
- return 0;
-
- /*
- * If the user only wants incoming packets, reject it.
- */
- if (handle->direction == PCAP_D_IN)
- return 0;
- } else {
- /*
- * Incoming packet.
- * If the user only wants outgoing packets, reject it.
- */
- if (handle->direction == PCAP_D_OUT)
- return 0;
- }
+ if (!linux_check_direction(handle, &from))
+ return 0;
}
#endif
@@ -1601,7 +1611,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
/*
* If this is a cooked device, fill in the fake packet header.
*/
- if (handle->md.cooked) {
+ if (handlep->cooked) {
/*
* Add the length of the fake header to the length
* of packet data we read.
@@ -1620,32 +1630,40 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
}
#if defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI)
- for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- struct tpacket_auxdata *aux;
- unsigned int len;
- struct vlan_tag *tag;
+ if (handlep->vlan_offset != -1) {
+ for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
+ struct tpacket_auxdata *aux;
+ unsigned int len;
+ struct vlan_tag *tag;
- if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct tpacket_auxdata)) ||
- cmsg->cmsg_level != SOL_PACKET ||
- cmsg->cmsg_type != PACKET_AUXDATA)
- continue;
+ if (cmsg->cmsg_len < CMSG_LEN(sizeof(struct tpacket_auxdata)) ||
+ cmsg->cmsg_level != SOL_PACKET ||
+ cmsg->cmsg_type != PACKET_AUXDATA)
+ continue;
- aux = (struct tpacket_auxdata *)CMSG_DATA(cmsg);
- if (aux->tp_vlan_tci == 0)
- continue;
+ aux = (struct tpacket_auxdata *)CMSG_DATA(cmsg);
+#if defined(TP_STATUS_VLAN_VALID)
+ if ((aux->tp_vlan_tci == 0) && !(aux->tp_status & TP_STATUS_VLAN_VALID))
+#else
+ if (aux->tp_vlan_tci == 0) /* this is ambigious but without the
+ TP_STATUS_VLAN_VALID flag, there is
+ nothing that we can do */
+#endif
+ continue;
- len = packet_len > iov.iov_len ? iov.iov_len : packet_len;
- if (len < 2 * ETH_ALEN)
- break;
+ len = packet_len > iov.iov_len ? iov.iov_len : packet_len;
+ if (len < (unsigned int) handlep->vlan_offset)
+ break;
- bp -= VLAN_TAG_LEN;
- memmove(bp, bp + VLAN_TAG_LEN, 2 * ETH_ALEN);
+ bp -= VLAN_TAG_LEN;
+ memmove(bp, bp + VLAN_TAG_LEN, handlep->vlan_offset);
- tag = (struct vlan_tag *)(bp + 2 * ETH_ALEN);
- tag->vlan_tpid = htons(ETH_P_8021Q);
- tag->vlan_tci = htons(aux->tp_vlan_tci);
+ tag = (struct vlan_tag *)(bp + handlep->vlan_offset);
+ tag->vlan_tpid = htons(ETH_P_8021Q);
+ tag->vlan_tci = htons(aux->tp_vlan_tci);
- packet_len += VLAN_TAG_LEN;
+ packet_len += VLAN_TAG_LEN;
+ }
}
#endif /* defined(HAVE_PACKET_AUXDATA) && defined(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI) */
#endif /* HAVE_PF_PACKET_SOCKETS */
@@ -1687,7 +1705,7 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
caplen = handle->snapshot;
/* Run the packet filter if not using kernel filter */
- if (!handle->md.use_bpf && handle->fcode.bf_insns) {
+ if (!handlep->filtering_in_kernel && handle->fcode.bf_insns) {
if (bpf_filter(handle->fcode.bf_insns, bp,
packet_len, caplen) == 0)
{
@@ -1698,11 +1716,24 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
/* Fill in our own header data */
- if (ioctl(handle->fd, SIOCGSTAMP, &pcap_header.ts) == -1) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "SIOCGSTAMP: %s", pcap_strerror(errno));
- return PCAP_ERROR;
- }
+ /* get timestamp for this packet */
+#if defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS)
+ if (handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) {
+ if (ioctl(handle->fd, SIOCGSTAMPNS, &pcap_header.ts) == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "SIOCGSTAMPNS: %s", pcap_strerror(errno));
+ return PCAP_ERROR;
+ }
+ } else
+#endif
+ {
+ if (ioctl(handle->fd, SIOCGSTAMP, &pcap_header.ts) == -1) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "SIOCGSTAMP: %s", pcap_strerror(errno));
+ return PCAP_ERROR;
+ }
+ }
+
pcap_header.caplen = caplen;
pcap_header.len = packet_len;
@@ -1739,17 +1770,18 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
* the count is more expensive than always testing a flag
* in memory.
*
- * We keep the count in "md.packets_read", and use that for
- * "ps_recv" if we can't get the statistics from the kernel.
+ * We keep the count in "handlep->packets_read", and use that
+ * for "ps_recv" if we can't get the statistics from the kernel.
* We do that because, if we *can* get the statistics from
- * the kernel, we use "md.stat.ps_recv" and "md.stat.ps_drop"
- * as running counts, as reading the statistics from the
- * kernel resets the kernel statistics, and if we directly
- * increment "md.stat.ps_recv" here, that means it will
- * count packets *twice* on systems where we can get kernel
- * statistics - once here, and once in pcap_stats_linux().
+ * the kernel, we use "handlep->stat.ps_recv" and
+ * "handlep->stat.ps_drop" as running counts, as reading the
+ * statistics from the kernel resets the kernel statistics,
+ * and if we directly increment "handlep->stat.ps_recv" here,
+ * that means it will count packets *twice* on systems where
+ * we can get kernel statistics - once here, and once in
+ * pcap_stats_linux().
*/
- handle->md.packets_read++;
+ handlep->packets_read++;
/* Call the user supplied callback function */
callback(userdata, &pcap_header, bp);
@@ -1760,12 +1792,13 @@ pcap_read_packet(pcap_t *handle, pcap_handler callback, u_char *userdata)
static int
pcap_inject_linux(pcap_t *handle, const void *buf, size_t size)
{
+ struct pcap_linux *handlep = handle->priv;
int ret;
#ifdef HAVE_PF_PACKET_SOCKETS
- if (!handle->md.sock_packet) {
+ if (!handlep->sock_packet) {
/* PF_PACKET socket */
- if (handle->md.ifindex == -1) {
+ if (handlep->ifindex == -1) {
/*
* We don't support sending on the "any" device.
*/
@@ -1775,7 +1808,7 @@ pcap_inject_linux(pcap_t *handle, const void *buf, size_t size)
return (-1);
}
- if (handle->md.cooked) {
+ if (handlep->cooked) {
/*
* We don't support sending on the "any" device.
*
@@ -1811,10 +1844,29 @@ pcap_inject_linux(pcap_t *handle, const void *buf, size_t size)
static int
pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
{
+ struct pcap_linux *handlep = handle->priv;
#ifdef HAVE_TPACKET_STATS
+#ifdef HAVE_TPACKET3
+ /*
+ * For sockets using TPACKET_V1 or TPACKET_V2, the extra
+ * stuff at the end of a struct tpacket_stats_v3 will not
+ * be filled in, and we don't look at it so this is OK even
+ * for those sockets. In addition, the PF_PACKET socket
+ * code in the kernel only uses the length parameter to
+ * compute how much data to copy out and to indicate how
+ * much data was copied out, so it's OK to base it on the
+ * size of a struct tpacket_stats.
+ *
+ * XXX - it's probably OK, in fact, to just use a
+ * struct tpacket_stats for V3 sockets, as we don't
+ * care about the tp_freeze_q_cnt stat.
+ */
+ struct tpacket_stats_v3 kstats;
+#else /* HAVE_TPACKET3 */
struct tpacket_stats kstats;
+#endif /* HAVE_TPACKET3 */
socklen_t len = sizeof (struct tpacket_stats);
-#endif
+#endif /* HAVE_TPACKET_STATS */
long if_dropped = 0;
@@ -1823,9 +1875,9 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
*/
if (handle->opt.promisc)
{
- if_dropped = handle->md.proc_dropped;
- handle->md.proc_dropped = linux_if_drops(handle->md.device);
- handle->md.stat.ps_ifdrop += (handle->md.proc_dropped - if_dropped);
+ if_dropped = handlep->proc_dropped;
+ handlep->proc_dropped = linux_if_drops(handlep->device);
+ handlep->stat.ps_ifdrop += (handlep->proc_dropped - if_dropped);
}
#ifdef HAVE_TPACKET_STATS
@@ -1881,9 +1933,9 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
* getsockopt(handle->fd, SOL_PACKET, PACKET_STATISTICS, ....
* resets the counters to zero.
*/
- handle->md.stat.ps_recv += kstats.tp_packets;
- handle->md.stat.ps_drop += kstats.tp_drops;
- *stats = handle->md.stat;
+ handlep->stat.ps_recv += kstats.tp_packets;
+ handlep->stat.ps_drop += kstats.tp_drops;
+ *stats = handlep->stat;
return 0;
}
else
@@ -1921,15 +1973,15 @@ pcap_stats_linux(pcap_t *handle, struct pcap_stat *stats)
* the kernel by libpcap.
*
* We maintain the count of packets processed by libpcap in
- * "md.packets_read", for reasons described in the comment
+ * "handlep->packets_read", for reasons described in the comment
* at the end of pcap_read_packet(). We have no idea how many
* packets were dropped by the kernel buffers -- but we know
* how many the interface dropped, so we can return that.
*/
- stats->ps_recv = handle->md.packets_read;
+ stats->ps_recv = handlep->packets_read;
stats->ps_drop = 0;
- stats->ps_ifdrop = handle->md.stat.ps_ifdrop;
+ stats->ps_ifdrop = handlep->stat.ps_ifdrop;
return 0;
}
@@ -1953,6 +2005,8 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf)
DIR *sys_class_net_d;
int fd;
struct dirent *ent;
+ char subsystem_path[PATH_MAX+1];
+ struct stat statb;
char *p;
char name[512]; /* XXX - pick a size */
char *q, *saveq;
@@ -1997,12 +2051,43 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf)
}
/*
- * Ignore directories (".", "..", and any subdirectories).
+ * Ignore "." and "..".
+ */
+ if (strcmp(ent->d_name, ".") == 0 ||
+ strcmp(ent->d_name, "..") == 0)
+ continue;
+
+ /*
+ * Ignore plain files; they do not have subdirectories
+ * and thus have no attributes.
*/
- if (ent->d_type == DT_DIR)
+ if (ent->d_type == DT_REG)
continue;
/*
+ * Is there an "ifindex" file under that name?
+ * (We don't care whether it's a directory or
+ * a symlink; older kernels have directories
+ * for devices, newer kernels have symlinks to
+ * directories.)
+ */
+ snprintf(subsystem_path, sizeof subsystem_path,
+ "/sys/class/net/%s/ifindex", ent->d_name);
+ if (lstat(subsystem_path, &statb) != 0) {
+ /*
+ * Stat failed. Either there was an error
+ * other than ENOENT, and we don't know if
+ * this is an interface, or it's ENOENT,
+ * and either some part of "/sys/class/net/{if}"
+ * disappeared, in which case it probably means
+ * the interface disappeared, or there's no
+ * "ifindex" file, which means it's not a
+ * network interface.
+ */
+ continue;
+ }
+
+ /*
* Get the interface name.
*/
p = &ent->d_name[0];
@@ -2267,56 +2352,6 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
if (pcap_add_if(alldevsp, "any", 0, any_descr, errbuf) < 0)
return (-1);
-#ifdef HAVE_DAG_API
- /*
- * Add DAG devices.
- */
- if (dag_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif /* HAVE_DAG_API */
-
-#ifdef HAVE_SEPTEL_API
- /*
- * Add Septel devices.
- */
- if (septel_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif /* HAVE_SEPTEL_API */
-
-#ifdef HAVE_SNF_API
- if (snf_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif /* HAVE_SNF_API */
-
-#ifdef PCAP_SUPPORT_BT
- /*
- * Add Bluetooth devices.
- */
- if (bt_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif
-
-#ifdef PCAP_SUPPORT_USB
- /*
- * Add USB devices.
- */
- if (usb_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif
-
-#ifdef PCAP_SUPPORT_NETFILTER
- /*
- * Add netfilter devices.
- */
- if (netfilter_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif
-
-#if PCAP_SUPPORT_CANUSB
- if (canusb_platform_finddevs(alldevsp, errbuf) < 0)
- return (-1);
-#endif
-
return (0);
}
@@ -2327,6 +2362,7 @@ static int
pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter,
int is_mmapped)
{
+ struct pcap_linux *handlep;
#ifdef SO_ATTACH_FILTER
struct sock_fprog fcode;
int can_filter_in_kernel;
@@ -2341,6 +2377,8 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter,
return -1;
}
+ handlep = handle->priv;
+
/* Make our private copy of the filter */
if (install_bpf_program(handle, filter) < 0)
@@ -2351,7 +2389,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter,
* Run user level packet filter by default. Will be overriden if
* installing a kernel filter succeeds.
*/
- handle->md.use_bpf = 0;
+ handlep->filtering_in_kernel = 0;
/* Install kernel level filter if possible */
@@ -2440,7 +2478,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter,
if ((err = set_kernel_filter(handle, &fcode)) == 0)
{
/* Installation succeded - using kernel filter. */
- handle->md.use_bpf = 1;
+ handlep->filtering_in_kernel = 1;
}
else if (err == -1) /* Non-fatal error */
{
@@ -2465,7 +2503,7 @@ pcap_setfilter_linux_common(pcap_t *handle, struct bpf_program *filter,
* calling "pcap_setfilter()". Otherwise, the kernel filter may
* filter out packets that would pass the new userland filter.
*/
- if (!handle->md.use_bpf)
+ if (!handlep->filtering_in_kernel)
reset_kernel_filter(handle);
/*
@@ -2497,7 +2535,9 @@ static int
pcap_setdirection_linux(pcap_t *handle, pcap_direction_t d)
{
#ifdef HAVE_PF_PACKET_SOCKETS
- if (!handle->md.sock_packet) {
+ struct pcap_linux *handlep = handle->priv;
+
+ if (!handlep->sock_packet) {
handle->direction = d;
return 0;
}
@@ -2801,6 +2841,25 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
handle->linktype = DLT_LTALK;
break;
+ case 18:
+ /*
+ * RFC 4338 defines an encapsulation for IP and ARP
+ * packets that's compatible with the RFC 2625
+ * encapsulation, but that uses a different ARP
+ * hardware type and hardware addresses. That
+ * ARP hardware type is 18; Linux doesn't define
+ * any ARPHRD_ value as 18, but if it ever officially
+ * supports RFC 4338-style IP-over-FC, it should define
+ * one.
+ *
+ * For now, we map it to DLT_IP_OVER_FC, in the hopes
+ * that this will encourage its use in the future,
+ * should Linux ever officially support RFC 4338-style
+ * IP-over-FC.
+ */
+ handle->linktype = DLT_IP_OVER_FC;
+ break;
+
#ifndef ARPHRD_FCPP
#define ARPHRD_FCPP 784
#endif
@@ -2818,11 +2877,62 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
#endif
case ARPHRD_FCFABRIC:
/*
- * We assume that those all mean RFC 2625 IP-over-
- * Fibre Channel, with the RFC 2625 header at
- * the beginning of the packet.
+ * Back in 2002, Donald Lee at Cray wanted a DLT_ for
+ * IP-over-FC:
+ *
+ * http://www.mail-archive.com/tcpdump-workers@sandelman.ottawa.on.ca/msg01043.html
+ *
+ * and one was assigned.
+ *
+ * In a later private discussion (spun off from a message
+ * on the ethereal-users list) on how to get that DLT_
+ * value in libpcap on Linux, I ended up deciding that
+ * the best thing to do would be to have him tweak the
+ * driver to set the ARPHRD_ value to some ARPHRD_FCxx
+ * type, and map all those types to DLT_IP_OVER_FC:
+ *
+ * I've checked into the libpcap and tcpdump CVS tree
+ * support for DLT_IP_OVER_FC. In order to use that,
+ * you'd have to modify your modified driver to return
+ * one of the ARPHRD_FCxxx types, in "fcLINUXfcp.c" -
+ * change it to set "dev->type" to ARPHRD_FCFABRIC, for
+ * example (the exact value doesn't matter, it can be
+ * any of ARPHRD_FCPP, ARPHRD_FCAL, ARPHRD_FCPL, or
+ * ARPHRD_FCFABRIC).
+ *
+ * 11 years later, Christian Svensson wanted to map
+ * various ARPHRD_ values to DLT_FC_2 and
+ * DLT_FC_2_WITH_FRAME_DELIMS for raw Fibre Channel
+ * frames:
+ *
+ * https://github.com/mcr/libpcap/pull/29
+ *
+ * There doesn't seem to be any network drivers that uses
+ * any of the ARPHRD_FC* values for IP-over-FC, and
+ * it's not exactly clear what the "Dummy types for non
+ * ARP hardware" are supposed to mean (link-layer
+ * header type? Physical network type?), so it's
+ * not exactly clear why the ARPHRD_FC* types exist
+ * in the first place.
+ *
+ * For now, we map them to DLT_FC_2, and provide an
+ * option of DLT_FC_2_WITH_FRAME_DELIMS, as well as
+ * DLT_IP_OVER_FC just in case there's some old
+ * driver out there that uses one of those types for
+ * IP-over-FC on which somebody wants to capture
+ * packets.
*/
- handle->linktype = DLT_IP_OVER_FC;
+ handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
+ /*
+ * If that fails, just leave the list empty.
+ */
+ if (handle->dlt_list != NULL) {
+ handle->dlt_list[0] = DLT_FC_2;
+ handle->dlt_list[1] = DLT_FC_2_WITH_FRAME_DELIMS;
+ handle->dlt_list[2] = DLT_IP_OVER_FC;
+ handle->dlt_count = 3;
+ }
+ handle->linktype = DLT_FC_2;
break;
#ifndef ARPHRD_IRDA
@@ -2833,7 +2943,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
handle->linktype = DLT_LINUX_IRDA;
/* We need to save packet direction for IrDA decoding,
* so let's use "Linux-cooked" mode. Jean II */
- //handle->md.cooked = 1;
+ //handlep->cooked = 1;
break;
/* ARPHRD_LAPD is unofficial and randomly allocated, if reallocation
@@ -2883,6 +2993,7 @@ static int
activate_new(pcap_t *handle)
{
#ifdef HAVE_PF_PACKET_SOCKETS
+ struct pcap_linux *handlep = handle->priv;
const char *device = handle->opt.source;
int is_any_device = (strcmp(device, "any") == 0);
int sock_fd = -1, arptype;
@@ -2928,12 +3039,12 @@ activate_new(pcap_t *handle)
}
/* It seems the kernel supports the new interface. */
- handle->md.sock_packet = 0;
+ handlep->sock_packet = 0;
/*
* Get the interface index of the loopback device.
* If the attempt fails, don't fail, just set the
- * "md.lo_ifindex" to -1.
+ * "handlep->lo_ifindex" to -1.
*
* XXX - can there be more than one device that loops
* packets back, i.e. devices other than "lo"? If so,
@@ -2941,7 +3052,7 @@ activate_new(pcap_t *handle)
* indices for them, and check all of them in
* "pcap_read_packet()".
*/
- handle->md.lo_ifindex = iface_get_id(sock_fd, "lo", handle->errbuf);
+ handlep->lo_ifindex = iface_get_id(sock_fd, "lo", handle->errbuf);
/*
* Default value for offset to align link-layer payload
@@ -2956,7 +3067,7 @@ activate_new(pcap_t *handle)
*/
if (!is_any_device) {
/* Assume for now we don't need cooked mode. */
- handle->md.cooked = 0;
+ handlep->cooked = 0;
if (handle->opt.rfmon) {
/*
@@ -2986,8 +3097,8 @@ activate_new(pcap_t *handle)
* device to open for monitor mode. If we've
* been given a different device, use it.
*/
- if (handle->md.mondevice != NULL)
- device = handle->md.mondevice;
+ if (handlep->mondevice != NULL)
+ device = handlep->mondevice;
}
arptype = iface_get_arptype(sock_fd, device, handle->errbuf);
if (arptype < 0) {
@@ -3034,7 +3145,7 @@ activate_new(pcap_t *handle)
return PCAP_ERROR;
}
}
- handle->md.cooked = 1;
+ handlep->cooked = 1;
/*
* Get rid of any link-layer type list
@@ -3072,14 +3183,14 @@ activate_new(pcap_t *handle)
handle->linktype = DLT_LINUX_SLL;
}
- handle->md.ifindex = iface_get_id(sock_fd, device,
+ handlep->ifindex = iface_get_id(sock_fd, device,
handle->errbuf);
- if (handle->md.ifindex == -1) {
+ if (handlep->ifindex == -1) {
close(sock_fd);
return PCAP_ERROR;
}
- if ((err = iface_bind(sock_fd, handle->md.ifindex,
+ if ((err = iface_bind(sock_fd, handlep->ifindex,
handle->errbuf)) != 1) {
close(sock_fd);
if (err < 0)
@@ -3101,7 +3212,7 @@ activate_new(pcap_t *handle)
/*
* It uses cooked mode.
*/
- handle->md.cooked = 1;
+ handlep->cooked = 1;
handle->linktype = DLT_LINUX_SLL;
/*
@@ -3111,7 +3222,7 @@ activate_new(pcap_t *handle)
* if we figure out how to transmit in cooked
* mode.
*/
- handle->md.ifindex = -1;
+ handlep->ifindex = -1;
}
/*
@@ -3138,7 +3249,7 @@ activate_new(pcap_t *handle)
if (!is_any_device && handle->opt.promisc) {
memset(&mr, 0, sizeof(mr));
- mr.mr_ifindex = handle->md.ifindex;
+ mr.mr_ifindex = handlep->ifindex;
mr.mr_type = PACKET_MR_PROMISC;
if (setsockopt(sock_fd, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&mr, sizeof(mr)) == -1) {
@@ -3177,22 +3288,51 @@ activate_new(pcap_t *handle)
* 1 byte of packet data (so we don't pass a byte
* count of 0 to "recvfrom()").
*/
- if (handle->md.cooked) {
+ if (handlep->cooked) {
if (handle->snapshot < SLL_HDR_LEN + 1)
handle->snapshot = SLL_HDR_LEN + 1;
}
handle->bufsize = handle->snapshot;
+ /*
+ * Set the offset at which to insert VLAN tags.
+ */
+ switch (handle->linktype) {
+
+ case DLT_EN10MB:
+ handlep->vlan_offset = 2 * ETH_ALEN;
+ break;
+
+ case DLT_LINUX_SLL:
+ handlep->vlan_offset = 14;
+ break;
+
+ default:
+ handlep->vlan_offset = -1; /* unknown */
+ break;
+ }
+
/* Save the socket FD in the pcap structure */
handle->fd = sock_fd;
+#if defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS)
+ if (handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) {
+ int nsec_tstamps = 1;
+
+ if (setsockopt(handle->fd, SOL_SOCKET, SO_TIMESTAMPNS, &nsec_tstamps, sizeof(nsec_tstamps)) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "setsockopt: unable to set SO_TIMESTAMPNS");
+ return PCAP_ERROR;
+ }
+ }
+#endif /* defined(SIOCGSTAMPNS) && defined(SO_TIMESTAMPNS) */
+
return 1;
-#else
+#else /* HAVE_PF_PACKET_SOCKETS */
strncpy(ebuf,
"New packet capturing interface not supported by build "
"environment", PCAP_ERRBUF_SIZE);
return 0;
-#endif
+#endif /* HAVE_PF_PACKET_SOCKETS */
}
#ifdef HAVE_PACKET_RING
@@ -3211,14 +3351,15 @@ activate_new(pcap_t *handle)
static int
activate_mmap(pcap_t *handle, int *status)
{
+ struct pcap_linux *handlep = handle->priv;
int ret;
/*
* Attempt to allocate a buffer to hold the contents of one
* packet, for use by the oneshot callback.
*/
- handle->md.oneshot_buffer = malloc(handle->snapshot);
- if (handle->md.oneshot_buffer == NULL) {
+ handlep->oneshot_buffer = malloc(handle->snapshot);
+ if (handlep->oneshot_buffer == NULL) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"can't allocate oneshot buffer: %s",
pcap_strerror(errno));
@@ -3232,7 +3373,7 @@ activate_mmap(pcap_t *handle, int *status)
}
ret = prepare_tpacket_socket(handle);
if (ret == -1) {
- free(handle->md.oneshot_buffer);
+ free(handlep->oneshot_buffer);
*status = PCAP_ERROR;
return ret;
}
@@ -3242,7 +3383,7 @@ activate_mmap(pcap_t *handle, int *status)
* We don't support memory-mapped capture; our caller
* will fall back on reading from the socket.
*/
- free(handle->md.oneshot_buffer);
+ free(handlep->oneshot_buffer);
return 0;
}
if (ret == -1) {
@@ -3250,7 +3391,7 @@ activate_mmap(pcap_t *handle, int *status)
* Error attempting to enable memory-mapped capture;
* fail. create_ring() has set *status.
*/
- free(handle->md.oneshot_buffer);
+ free(handlep->oneshot_buffer);
return -1;
}
@@ -3263,7 +3404,22 @@ activate_mmap(pcap_t *handle, int *status)
* handle->offset is used to get the current position into the rx ring.
* handle->cc is used to store the ring size.
*/
- handle->read_op = pcap_read_linux_mmap;
+
+ switch (handlep->tp_version) {
+ case TPACKET_V1:
+ handle->read_op = pcap_read_linux_mmap_v1;
+ break;
+#ifdef HAVE_TPACKET2
+ case TPACKET_V2:
+ handle->read_op = pcap_read_linux_mmap_v2;
+ break;
+#endif
+#ifdef HAVE_TPACKET3
+ case TPACKET_V3:
+ handle->read_op = pcap_read_linux_mmap_v3;
+ break;
+#endif
+ }
handle->cleanup_op = pcap_cleanup_linux_mmap;
handle->setfilter_op = pcap_setfilter_linux_mmap;
handle->setnonblock_op = pcap_setnonblock_mmap;
@@ -3281,59 +3437,102 @@ activate_mmap(pcap_t *handle _U_, int *status _U_)
#endif /* HAVE_PACKET_RING */
#ifdef HAVE_PACKET_RING
+
+#if defined(HAVE_TPACKET2) || defined(HAVE_TPACKET3)
/*
- * Attempt to set the socket to version 2 of the memory-mapped header.
- * Return 1 if we succeed or if we fail because version 2 isn't
+ * Attempt to set the socket to the specified version of the memory-mapped
+ * header.
+ *
+ * Return 0 if we succeed; return 1 if we fail because that version isn't
* supported; return -1 on any other error, and set handle->errbuf.
*/
static int
-prepare_tpacket_socket(pcap_t *handle)
+init_tpacket(pcap_t *handle, int version, const char *version_str)
{
-#ifdef HAVE_TPACKET2
- socklen_t len;
- int val;
-#endif
+ struct pcap_linux *handlep = handle->priv;
+ int val = version;
+ socklen_t len = sizeof(val);
- handle->md.tp_version = TPACKET_V1;
- handle->md.tp_hdrlen = sizeof(struct tpacket_hdr);
-
-#ifdef HAVE_TPACKET2
- /* Probe whether kernel supports TPACKET_V2 */
- val = TPACKET_V2;
- len = sizeof(val);
+ /* Probe whether kernel supports the specified TPACKET version */
if (getsockopt(handle->fd, SOL_PACKET, PACKET_HDRLEN, &val, &len) < 0) {
- if (errno == ENOPROTOOPT)
- return 1; /* no - just drive on */
+ if (errno == ENOPROTOOPT || errno == EINVAL)
+ return 1; /* no */
- /* Yes - treat as a failure. */
+ /* Failed to even find out; this is a fatal error. */
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "can't get TPACKET_V2 header len on packet socket: %s",
- pcap_strerror(errno));
+ "can't get %s header len on packet socket: %s",
+ version_str,
+ pcap_strerror(errno));
return -1;
}
- handle->md.tp_hdrlen = val;
+ handlep->tp_hdrlen = val;
- val = TPACKET_V2;
+ val = version;
if (setsockopt(handle->fd, SOL_PACKET, PACKET_VERSION, &val,
- sizeof(val)) < 0) {
+ sizeof(val)) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "can't activate TPACKET_V2 on packet socket: %s",
- pcap_strerror(errno));
+ "can't activate %s on packet socket: %s",
+ version_str,
+ pcap_strerror(errno));
return -1;
}
- handle->md.tp_version = TPACKET_V2;
+ handlep->tp_version = version;
/* Reserve space for VLAN tag reconstruction */
val = VLAN_TAG_LEN;
if (setsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &val,
- sizeof(val)) < 0) {
+ sizeof(val)) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "can't set up reserve on packet socket: %s",
- pcap_strerror(errno));
+ "can't set up reserve on packet socket: %s",
+ pcap_strerror(errno));
return -1;
}
+ return 0;
+}
+#endif /* defined HAVE_TPACKET2 || defined HAVE_TPACKET3 */
+
+/*
+ * Attempt to set the socket to version 3 of the memory-mapped header and,
+ * if that fails because version 3 isn't supported, attempt to fall
+ * back to version 2. If version 2 isn't supported, just leave it at
+ * version 1.
+ *
+ * Return 1 if we succeed or if we fail because neither version 2 nor 3 is
+ * supported; return -1 on any other error, and set handle->errbuf.
+ */
+static int
+prepare_tpacket_socket(pcap_t *handle)
+{
+ struct pcap_linux *handlep = handle->priv;
+#if defined(HAVE_TPACKET2) || defined(HAVE_TPACKET3)
+ int ret;
+#endif
+
+ handlep->tp_version = TPACKET_V1;
+ handlep->tp_hdrlen = sizeof(struct tpacket_hdr);
+
+#ifdef HAVE_TPACKET3
+ ret = init_tpacket(handle, TPACKET_V3, "TPACKET_V3");
+ if (-1 == ret) {
+ /* Error during setting up TPACKET_V3. */
+ return -1;
+ } else if (1 == ret) {
+ /* TPACKET_V3 not supported - fall back to TPACKET_V2. */
+#endif /* HAVE_TPACKET3 */
+
+#ifdef HAVE_TPACKET2
+ ret = init_tpacket(handle, TPACKET_V2, "TPACKET_V2");
+ if (-1 == ret) {
+ /* Error during setting up TPACKET_V2. */
+ return -1;
+ }
#endif /* HAVE_TPACKET2 */
+
+#ifdef HAVE_TPACKET3
+ }
+#endif /* HAVE_TPACKET3 */
+
return 1;
}
@@ -3352,8 +3551,18 @@ prepare_tpacket_socket(pcap_t *handle)
static int
create_ring(pcap_t *handle, int *status)
{
+ struct pcap_linux *handlep = handle->priv;
unsigned i, j, frames_per_block;
+#ifdef HAVE_TPACKET3
+ /*
+ * For sockets using TPACKET_V1 or TPACKET_V2, the extra
+ * stuff at the end of a struct tpacket_req3 will be
+ * ignored, so this is OK even for those sockets.
+ */
+ struct tpacket_req3 req;
+#else
struct tpacket_req req;
+#endif
socklen_t len;
unsigned int sk_type, tp_reserve, maclen, tp_hdrlen, netoff, macoff;
unsigned int frame_size;
@@ -3363,115 +3572,141 @@ create_ring(pcap_t *handle, int *status)
*/
*status = 0;
- /* Note that with large snapshot length (say 64K, which is the default
- * for recent versions of tcpdump, the value that "-s 0" has given
- * for a long time with tcpdump, and the default in Wireshark/TShark),
- * if we use the snapshot length to calculate the frame length,
- * only a few frames will be available in the ring even with pretty
- * large ring size (and a lot of memory will be unused).
- *
- * Ideally, we should choose a frame length based on the
- * minimum of the specified snapshot length and the maximum
- * packet size. That's not as easy as it sounds; consider, for
- * example, an 802.11 interface in monitor mode, where the
- * frame would include a radiotap header, where the maximum
- * radiotap header length is device-dependent.
- *
- * So, for now, we just do this for Ethernet devices, where
- * there's no metadata header, and the link-layer header is
- * fixed length. We can get the maximum packet size by
- * adding 18, the Ethernet header length plus the CRC length
- * (just in case we happen to get the CRC in the packet), to
- * the MTU of the interface; we fetch the MTU in the hopes
- * that it reflects support for jumbo frames. (Even if the
- * interface is just being used for passive snooping, the driver
- * might set the size of buffers in the receive ring based on
- * the MTU, so that the MTU limits the maximum size of packets
- * that we can receive.)
- *
- * We don't do that if segmentation/fragmentation or receive
- * offload are enabled, so we don't get rudely surprised by
- * "packets" bigger than the MTU. */
- frame_size = handle->snapshot;
- if (handle->linktype == DLT_EN10MB) {
- int mtu;
- int offload;
-
- offload = iface_get_offload(handle);
- if (offload == -1) {
- *status = PCAP_ERROR;
- return -1;
- }
- if (!offload) {
- mtu = iface_get_mtu(handle->fd, handle->opt.source,
- handle->errbuf);
- if (mtu == -1) {
+ switch (handlep->tp_version) {
+
+ case TPACKET_V1:
+#ifdef HAVE_TPACKET2
+ case TPACKET_V2:
+#endif
+ /* Note that with large snapshot length (say 64K, which is
+ * the default for recent versions of tcpdump, the value that
+ * "-s 0" has given for a long time with tcpdump, and the
+ * default in Wireshark/TShark/dumpcap), if we use the snapshot
+ * length to calculate the frame length, only a few frames
+ * will be available in the ring even with pretty
+ * large ring size (and a lot of memory will be unused).
+ *
+ * Ideally, we should choose a frame length based on the
+ * minimum of the specified snapshot length and the maximum
+ * packet size. That's not as easy as it sounds; consider,
+ * for example, an 802.11 interface in monitor mode, where
+ * the frame would include a radiotap header, where the
+ * maximum radiotap header length is device-dependent.
+ *
+ * So, for now, we just do this for Ethernet devices, where
+ * there's no metadata header, and the link-layer header is
+ * fixed length. We can get the maximum packet size by
+ * adding 18, the Ethernet header length plus the CRC length
+ * (just in case we happen to get the CRC in the packet), to
+ * the MTU of the interface; we fetch the MTU in the hopes
+ * that it reflects support for jumbo frames. (Even if the
+ * interface is just being used for passive snooping, the
+ * driver might set the size of buffers in the receive ring
+ * based on the MTU, so that the MTU limits the maximum size
+ * of packets that we can receive.)
+ *
+ * We don't do that if segmentation/fragmentation or receive
+ * offload are enabled, so we don't get rudely surprised by
+ * "packets" bigger than the MTU. */
+ frame_size = handle->snapshot;
+ if (handle->linktype == DLT_EN10MB) {
+ int mtu;
+ int offload;
+
+ offload = iface_get_offload(handle);
+ if (offload == -1) {
*status = PCAP_ERROR;
return -1;
}
- if (frame_size > mtu + 18)
- frame_size = mtu + 18;
+ if (!offload) {
+ mtu = iface_get_mtu(handle->fd, handle->opt.source,
+ handle->errbuf);
+ if (mtu == -1) {
+ *status = PCAP_ERROR;
+ return -1;
+ }
+ if (frame_size > mtu + 18)
+ frame_size = mtu + 18;
+ }
}
- }
-
- /* NOTE: calculus matching those in tpacket_rcv()
- * in linux-2.6/net/packet/af_packet.c
- */
- len = sizeof(sk_type);
- if (getsockopt(handle->fd, SOL_SOCKET, SO_TYPE, &sk_type, &len) < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "getsockopt: %s", pcap_strerror(errno));
- *status = PCAP_ERROR;
- return -1;
- }
-#ifdef PACKET_RESERVE
- len = sizeof(tp_reserve);
- if (getsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE, &tp_reserve, &len) < 0) {
- if (errno != ENOPROTOOPT) {
- /*
- * ENOPROTOOPT means "kernel doesn't support
- * PACKET_RESERVE", in which case we fall back
- * as best we can.
- */
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "getsockopt: %s", pcap_strerror(errno));
+
+ /* NOTE: calculus matching those in tpacket_rcv()
+ * in linux-2.6/net/packet/af_packet.c
+ */
+ len = sizeof(sk_type);
+ if (getsockopt(handle->fd, SOL_SOCKET, SO_TYPE, &sk_type,
+ &len) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "getsockopt: %s", pcap_strerror(errno));
*status = PCAP_ERROR;
return -1;
}
- tp_reserve = 0; /* older kernel, reserve not supported */
- }
+#ifdef PACKET_RESERVE
+ len = sizeof(tp_reserve);
+ if (getsockopt(handle->fd, SOL_PACKET, PACKET_RESERVE,
+ &tp_reserve, &len) < 0) {
+ if (errno != ENOPROTOOPT) {
+ /*
+ * ENOPROTOOPT means "kernel doesn't support
+ * PACKET_RESERVE", in which case we fall back
+ * as best we can.
+ */
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "getsockopt: %s", pcap_strerror(errno));
+ *status = PCAP_ERROR;
+ return -1;
+ }
+ tp_reserve = 0; /* older kernel, reserve not supported */
+ }
#else
- tp_reserve = 0; /* older kernel, reserve not supported */
+ tp_reserve = 0; /* older kernel, reserve not supported */
#endif
- maclen = (sk_type == SOCK_DGRAM) ? 0 : MAX_LINKHEADER_SIZE;
- /* XXX: in the kernel maclen is calculated from
- * LL_ALLOCATED_SPACE(dev) and vnet_hdr.hdr_len
- * in: packet_snd() in linux-2.6/net/packet/af_packet.c
- * then packet_alloc_skb() in linux-2.6/net/packet/af_packet.c
- * then sock_alloc_send_pskb() in linux-2.6/net/core/sock.c
- * but I see no way to get those sizes in userspace,
- * like for instance with an ifreq ioctl();
- * the best thing I've found so far is MAX_HEADER in the kernel
- * part of linux-2.6/include/linux/netdevice.h
- * which goes up to 128+48=176; since pcap-linux.c defines
- * a MAX_LINKHEADER_SIZE of 256 which is greater than that,
- * let's use it.. maybe is it even large enough to directly
- * replace macoff..
- */
- tp_hdrlen = TPACKET_ALIGN(handle->md.tp_hdrlen) + sizeof(struct sockaddr_ll) ;
- netoff = TPACKET_ALIGN(tp_hdrlen + (maclen < 16 ? 16 : maclen)) + tp_reserve;
- /* NOTE: AFAICS tp_reserve may break the TPACKET_ALIGN of
- * netoff, which contradicts
- * linux-2.6/Documentation/networking/packet_mmap.txt
- * documenting that:
- * "- Gap, chosen so that packet data (Start+tp_net)
- * aligns to TPACKET_ALIGNMENT=16"
- */
- /* NOTE: in linux-2.6/include/linux/skbuff.h:
- * "CPUs often take a performance hit
- * when accessing unaligned memory locations"
- */
- macoff = netoff - maclen;
- req.tp_frame_size = TPACKET_ALIGN(macoff + frame_size);
- req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size;
+ maclen = (sk_type == SOCK_DGRAM) ? 0 : MAX_LINKHEADER_SIZE;
+ /* XXX: in the kernel maclen is calculated from
+ * LL_ALLOCATED_SPACE(dev) and vnet_hdr.hdr_len
+ * in: packet_snd() in linux-2.6/net/packet/af_packet.c
+ * then packet_alloc_skb() in linux-2.6/net/packet/af_packet.c
+ * then sock_alloc_send_pskb() in linux-2.6/net/core/sock.c
+ * but I see no way to get those sizes in userspace,
+ * like for instance with an ifreq ioctl();
+ * the best thing I've found so far is MAX_HEADER in
+ * the kernel part of linux-2.6/include/linux/netdevice.h
+ * which goes up to 128+48=176; since pcap-linux.c
+ * defines a MAX_LINKHEADER_SIZE of 256 which is
+ * greater than that, let's use it.. maybe is it even
+ * large enough to directly replace macoff..
+ */
+ tp_hdrlen = TPACKET_ALIGN(handlep->tp_hdrlen) + sizeof(struct sockaddr_ll) ;
+ netoff = TPACKET_ALIGN(tp_hdrlen + (maclen < 16 ? 16 : maclen)) + tp_reserve;
+ /* NOTE: AFAICS tp_reserve may break the TPACKET_ALIGN
+ * of netoff, which contradicts
+ * linux-2.6/Documentation/networking/packet_mmap.txt
+ * documenting that:
+ * "- Gap, chosen so that packet data (Start+tp_net)
+ * aligns to TPACKET_ALIGNMENT=16"
+ */
+ /* NOTE: in linux-2.6/include/linux/skbuff.h:
+ * "CPUs often take a performance hit
+ * when accessing unaligned memory locations"
+ */
+ macoff = netoff - maclen;
+ req.tp_frame_size = TPACKET_ALIGN(macoff + frame_size);
+ req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size;
+ break;
+
+#ifdef HAVE_TPACKET3
+ case TPACKET_V3:
+ /* The "frames" for this are actually buffers that
+ * contain multiple variable-sized frames.
+ *
+ * We pick a "frame" size of 128K to leave enough
+ * room for at least one reasonably-sized packet
+ * in the "frame". */
+ req.tp_frame_size = 131072;
+ req.tp_frame_nr = handle->opt.buffer_size/req.tp_frame_size;
+ break;
+#endif
+ }
/* compute the minumum block size that will handle this frame.
* The block has to be page size aligned.
@@ -3593,6 +3828,15 @@ retry:
/* req.tp_frame_nr is requested to match frames_per_block*req.tp_block_nr */
req.tp_frame_nr = req.tp_block_nr * frames_per_block;
+#ifdef HAVE_TPACKET3
+ /* timeout value to retire block - use the configured buffering timeout, or default if <0. */
+ req.tp_retire_blk_tov = (handlep->timeout>=0)?handlep->timeout:0;
+ /* private data not used */
+ req.tp_sizeof_priv = 0;
+ /* Rx ring - feature request bits - none (rxhash will not be filled) */
+ req.tp_feature_req_word = 0;
+#endif
+
if (setsockopt(handle->fd, SOL_PACKET, PACKET_RX_RING,
(void *) &req, sizeof(req))) {
if ((errno == ENOMEM) && (req.tp_block_nr > 1)) {
@@ -3625,10 +3869,10 @@ retry:
}
/* memory map the rx ring */
- handle->md.mmapbuflen = req.tp_block_nr * req.tp_block_size;
- handle->md.mmapbuf = mmap(0, handle->md.mmapbuflen,
+ handlep->mmapbuflen = req.tp_block_nr * req.tp_block_size;
+ handlep->mmapbuf = mmap(0, handlep->mmapbuflen,
PROT_READ|PROT_WRITE, MAP_SHARED, handle->fd, 0);
- if (handle->md.mmapbuf == MAP_FAILED) {
+ if (handlep->mmapbuf == MAP_FAILED) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"can't mmap rx ring: %s", pcap_strerror(errno));
@@ -3654,7 +3898,7 @@ retry:
/* fill the header ring with proper frame ptr*/
handle->offset = 0;
for (i=0; i<req.tp_block_nr; ++i) {
- void *base = &handle->md.mmapbuf[i*req.tp_block_size];
+ void *base = &handlep->mmapbuf[i*req.tp_block_size];
for (j=0; j<frames_per_block; ++j, ++handle->offset) {
RING_GET_FRAME(handle) = base;
base += req.tp_frame_size;
@@ -3670,6 +3914,8 @@ retry:
static void
destroy_ring(pcap_t *handle)
{
+ struct pcap_linux *handlep = handle->priv;
+
/* tell the kernel to destroy the ring*/
struct tpacket_req req;
memset(&req, 0, sizeof(req));
@@ -3677,10 +3923,10 @@ destroy_ring(pcap_t *handle)
(void *) &req, sizeof(req));
/* if ring is mapped, unmap it*/
- if (handle->md.mmapbuf) {
+ if (handlep->mmapbuf) {
/* do not test for mmap failure, as we can't recover from any error */
- munmap(handle->md.mmapbuf, handle->md.mmapbuflen);
- handle->md.mmapbuf = NULL;
+ munmap(handlep->mmapbuf, handlep->mmapbuflen);
+ handlep->mmapbuf = NULL;
}
}
@@ -3706,19 +3952,23 @@ pcap_oneshot_mmap(u_char *user, const struct pcap_pkthdr *h,
const u_char *bytes)
{
struct oneshot_userdata *sp = (struct oneshot_userdata *)user;
+ pcap_t *handle = sp->pd;
+ struct pcap_linux *handlep = handle->priv;
*sp->hdr = *h;
- memcpy(sp->pd->md.oneshot_buffer, bytes, h->caplen);
- *sp->pkt = sp->pd->md.oneshot_buffer;
+ memcpy(handlep->oneshot_buffer, bytes, h->caplen);
+ *sp->pkt = handlep->oneshot_buffer;
}
static void
pcap_cleanup_linux_mmap( pcap_t *handle )
{
+ struct pcap_linux *handlep = handle->priv;
+
destroy_ring(handle);
- if (handle->md.oneshot_buffer != NULL) {
- free(handle->md.oneshot_buffer);
- handle->md.oneshot_buffer = NULL;
+ if (handlep->oneshot_buffer != NULL) {
+ free(handlep->oneshot_buffer);
+ handlep->oneshot_buffer = NULL;
}
pcap_cleanup_linux(handle);
}
@@ -3727,34 +3977,32 @@ pcap_cleanup_linux_mmap( pcap_t *handle )
static int
pcap_getnonblock_mmap(pcap_t *p, char *errbuf)
{
+ struct pcap_linux *handlep = p->priv;
+
/* use negative value of timeout to indicate non blocking ops */
- return (p->md.timeout<0);
+ return (handlep->timeout<0);
}
static int
pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf)
{
- /* map each value to the corresponding 2's complement, to
- * preserve the timeout value provided with pcap_set_timeout */
+ struct pcap_linux *handlep = p->priv;
+
+ /*
+ * Map each value to their corresponding negation to
+ * preserve the timeout value provided with pcap_set_timeout.
+ */
if (nonblock) {
- if (p->md.timeout >= 0) {
+ if (handlep->timeout >= 0) {
/*
- * Timeout is non-negative, so we're not already
- * in non-blocking mode; set it to the 2's
- * complement, to make it negative, as an
- * indication that we're in non-blocking mode.
+ * Indicate that we're switching to
+ * non-blocking mode.
*/
- p->md.timeout = p->md.timeout*-1 - 1;
+ handlep->timeout = ~handlep->timeout;
}
} else {
- if (p->md.timeout < 0) {
- /*
- * Timeout is negative, so we're not already
- * in blocking mode; reverse the previous
- * operation, to make the timeout non-negative
- * again.
- */
- p->md.timeout = (p->md.timeout+1)*-1;
+ if (handlep->timeout < 0) {
+ handlep->timeout = ~handlep->timeout;
}
}
return 0;
@@ -3763,10 +4011,11 @@ pcap_setnonblock_mmap(pcap_t *p, int nonblock, char *errbuf)
static inline union thdr *
pcap_get_ring_frame(pcap_t *handle, int status)
{
+ struct pcap_linux *handlep = handle->priv;
union thdr h;
h.raw = RING_GET_FRAME(handle);
- switch (handle->md.tp_version) {
+ switch (handlep->tp_version) {
case TPACKET_V1:
if (status != (h.h1->tp_status ? TP_STATUS_USER :
TP_STATUS_KERNEL))
@@ -3779,6 +4028,13 @@ pcap_get_ring_frame(pcap_t *handle, int status)
return NULL;
break;
#endif
+#ifdef HAVE_TPACKET3
+ case TPACKET_V3:
+ if (status != (h.h3->hdr.bh1.block_status ? TP_STATUS_USER :
+ TP_STATUS_KERNEL))
+ return NULL;
+ break;
+#endif
}
return h.raw;
}
@@ -3787,37 +4043,34 @@ pcap_get_ring_frame(pcap_t *handle, int status)
#define POLLRDHUP 0
#endif
-static int
-pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
- u_char *user)
+/* wait for frames availability.*/
+static int pcap_wait_for_frames_mmap(pcap_t *handle)
{
- int timeout;
- int pkts = 0;
- char c;
-
- /* wait for frames availability.*/
if (!pcap_get_ring_frame(handle, TP_STATUS_USER)) {
+ struct pcap_linux *handlep = handle->priv;
+ int timeout;
+ char c;
struct pollfd pollinfo;
int ret;
pollinfo.fd = handle->fd;
pollinfo.events = POLLIN;
- if (handle->md.timeout == 0)
+ if (handlep->timeout == 0)
timeout = -1; /* block forever */
- else if (handle->md.timeout > 0)
- timeout = handle->md.timeout; /* block for that amount of time */
+ else if (handlep->timeout > 0)
+ timeout = handlep->timeout; /* block for that amount of time */
else
timeout = 0; /* non-blocking mode - poll to pick up errors */
do {
ret = poll(&pollinfo, 1, timeout);
if (ret < 0 && errno != EINTR) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"can't poll on packet socket: %s",
pcap_strerror(errno));
return PCAP_ERROR;
} else if (ret > 0 &&
- (pollinfo.revents & (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL))) {
+ (pollinfo.revents & (POLLHUP|POLLRDHUP|POLLERR|POLLNVAL))) {
/*
* There's some indication other than
* "you can read on this descriptor" on
@@ -3837,7 +4090,7 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
* XXX - make the socket non-blocking?
*/
if (recv(handle->fd, &c, sizeof c,
- MSG_PEEK) != -1)
+ MSG_PEEK) != -1)
continue; /* what, no error? */
if (errno == ENETDOWN) {
/*
@@ -3855,7 +4108,7 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
"The interface went down");
} else {
snprintf(handle->errbuf,
- PCAP_ERRBUF_SIZE,
+ PCAP_ERRBUF_SIZE,
"Error condition on packet socket: %s",
strerror(errno));
}
@@ -3863,11 +4116,11 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
}
if (pollinfo.revents & POLLNVAL) {
snprintf(handle->errbuf,
- PCAP_ERRBUF_SIZE,
+ PCAP_ERRBUF_SIZE,
"Invalid polling request on packet socket");
return PCAP_ERROR;
}
- }
+ }
/* check for break loop condition on interrupted syscall*/
if (handle->break_loop) {
handle->break_loop = 0;
@@ -3875,200 +4128,342 @@ pcap_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback,
}
} while (ret < 0);
}
+ return 0;
+}
+
+/* handle a single memory mapped packet */
+static int pcap_handle_packet_mmap(
+ pcap_t *handle,
+ pcap_handler callback,
+ u_char *user,
+ unsigned char *frame,
+ unsigned int tp_len,
+ unsigned int tp_mac,
+ unsigned int tp_snaplen,
+ unsigned int tp_sec,
+ unsigned int tp_usec,
+ int tp_vlan_tci_valid,
+ __u16 tp_vlan_tci)
+{
+ struct pcap_linux *handlep = handle->priv;
+ unsigned char *bp;
+ int run_bpf;
+ struct sockaddr_ll *sll;
+ struct pcap_pkthdr pcaphdr;
+
+ /* perform sanity check on internal offset. */
+ if (tp_mac + tp_snaplen > handle->bufsize) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "corrupted frame on kernel ring mac "
+ "offset %d + caplen %d > frame len %d",
+ tp_mac, tp_snaplen, handle->bufsize);
+ return -1;
+ }
- /* non-positive values of max_packets are used to require all
+ /* run filter on received packet
+ * If the kernel filtering is enabled we need to run the
+ * filter until all the frames present into the ring
+ * at filter creation time are processed.
+ * In such case filtering_in_kernel is used as a counter for the
+ * packet we need to filter.
+ * Note: alternatively it could be possible to stop applying
+ * the filter when the ring became empty, but it can possibly
+ * happen a lot later... */
+ bp = frame + tp_mac;
+ run_bpf = (!handlep->filtering_in_kernel) ||
+ ((handlep->filtering_in_kernel>1) && handlep->filtering_in_kernel--);
+ if (run_bpf && handle->fcode.bf_insns &&
+ (bpf_filter(handle->fcode.bf_insns, bp,
+ tp_len, tp_snaplen) == 0))
+ return 0;
+
+ sll = (void *)frame + TPACKET_ALIGN(handlep->tp_hdrlen);
+ if (!linux_check_direction(handle, sll))
+ return 0;
+
+ /* get required packet info from ring header */
+ pcaphdr.ts.tv_sec = tp_sec;
+ pcaphdr.ts.tv_usec = tp_usec;
+ pcaphdr.caplen = tp_snaplen;
+ pcaphdr.len = tp_len;
+
+ /* if required build in place the sll header*/
+ if (handlep->cooked) {
+ struct sll_header *hdrp;
+
+ /*
+ * The kernel should have left us with enough
+ * space for an sll header; back up the packet
+ * data pointer into that space, as that'll be
+ * the beginning of the packet we pass to the
+ * callback.
+ */
+ bp -= SLL_HDR_LEN;
+
+ /*/*
+ * Let's make sure that's past the end of
+ * the tpacket header, i.e. >=
+ * ((u_char *)thdr + TPACKET_HDRLEN), so we
+ * don't step on the header when we construct
+ * the sll header.
+ */
+ if (bp < (u_char *)frame +
+ TPACKET_ALIGN(handlep->tp_hdrlen) +
+ sizeof(struct sockaddr_ll)) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "cooked-mode frame doesn't have room for sll header");
+ return -1;
+ }
+
+ /*
+ * OK, that worked; construct the sll header.
+ */
+ hdrp = (struct sll_header *)bp;
+ hdrp->sll_pkttype = map_packet_type_to_sll_type(
+ sll->sll_pkttype);
+ hdrp->sll_hatype = htons(sll->sll_hatype);
+ hdrp->sll_halen = htons(sll->sll_halen);
+ memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
+ hdrp->sll_protocol = sll->sll_protocol;
+
+ /* update packet len */
+ pcaphdr.caplen += SLL_HDR_LEN;
+ pcaphdr.len += SLL_HDR_LEN;
+ }
+
+#if defined(HAVE_TPACKET2) || defined(HAVE_TPACKET3)
+ if (tp_vlan_tci_valid &&
+ handlep->vlan_offset != -1 &&
+ tp_snaplen >= (unsigned int) handlep->vlan_offset)
+ {
+ struct vlan_tag *tag;
+
+ bp -= VLAN_TAG_LEN;
+ memmove(bp, bp + VLAN_TAG_LEN, handlep->vlan_offset);
+
+ tag = (struct vlan_tag *)(bp + handlep->vlan_offset);
+ tag->vlan_tpid = htons(ETH_P_8021Q);
+ tag->vlan_tci = htons(tp_vlan_tci);
+
+ pcaphdr.caplen += VLAN_TAG_LEN;
+ pcaphdr.len += VLAN_TAG_LEN;
+ }
+#endif
+
+ /*
+ * The only way to tell the kernel to cut off the
+ * packet at a snapshot length is with a filter program;
+ * if there's no filter program, the kernel won't cut
+ * the packet off.
+ *
+ * Trim the snapshot length to be no longer than the
+ * specified snapshot length.
+ */
+ if (pcaphdr.caplen > handle->snapshot)
+ pcaphdr.caplen = handle->snapshot;
+
+ /* pass the packet to the user */
+ callback(user, &pcaphdr, bp);
+
+ return 1;
+}
+
+static int
+pcap_read_linux_mmap_v1(pcap_t *handle, int max_packets, pcap_handler callback,
+ u_char *user)
+{
+ struct pcap_linux *handlep = handle->priv;
+ int pkts = 0;
+ int ret;
+
+ /* wait for frames availability.*/
+ ret = pcap_wait_for_frames_mmap(handle);
+ if (ret) {
+ return ret;
+ }
+
+ /* non-positive values of max_packets are used to require all
* packets currently available in the ring */
while ((pkts < max_packets) || (max_packets <= 0)) {
- int run_bpf;
- struct sockaddr_ll *sll;
- struct pcap_pkthdr pcaphdr;
- unsigned char *bp;
union thdr h;
- unsigned int tp_len;
- unsigned int tp_mac;
- unsigned int tp_snaplen;
- unsigned int tp_sec;
- unsigned int tp_usec;
h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER);
if (!h.raw)
break;
- switch (handle->md.tp_version) {
- case TPACKET_V1:
- tp_len = h.h1->tp_len;
- tp_mac = h.h1->tp_mac;
- tp_snaplen = h.h1->tp_snaplen;
- tp_sec = h.h1->tp_sec;
- tp_usec = h.h1->tp_usec;
- break;
-#ifdef HAVE_TPACKET2
- case TPACKET_V2:
- tp_len = h.h2->tp_len;
- tp_mac = h.h2->tp_mac;
- tp_snaplen = h.h2->tp_snaplen;
- tp_sec = h.h2->tp_sec;
- tp_usec = h.h2->tp_nsec / 1000;
- break;
-#endif
- default:
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "unsupported tpacket version %d",
- handle->md.tp_version);
- return -1;
- }
- /* perform sanity check on internal offset. */
- if (tp_mac + tp_snaplen > handle->bufsize) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "corrupted frame on kernel ring mac "
- "offset %d + caplen %d > frame len %d",
- tp_mac, tp_snaplen, handle->bufsize);
- return -1;
+ ret = pcap_handle_packet_mmap(
+ handle,
+ callback,
+ user,
+ h.raw,
+ h.h1->tp_len,
+ h.h1->tp_mac,
+ h.h1->tp_snaplen,
+ h.h1->tp_sec,
+ h.h1->tp_usec,
+ 0,
+ 0);
+ if (ret == 1) {
+ pkts++;
+ handlep->packets_read++;
+ } else if (ret < 0) {
+ return ret;
}
- /* run filter on received packet
- * If the kernel filtering is enabled we need to run the
- * filter until all the frames present into the ring
- * at filter creation time are processed.
- * In such case md.use_bpf is used as a counter for the
- * packet we need to filter.
- * Note: alternatively it could be possible to stop applying
- * the filter when the ring became empty, but it can possibly
- * happen a lot later... */
- bp = (unsigned char*)h.raw + tp_mac;
- run_bpf = (!handle->md.use_bpf) ||
- ((handle->md.use_bpf>1) && handle->md.use_bpf--);
- if (run_bpf && handle->fcode.bf_insns &&
- (bpf_filter(handle->fcode.bf_insns, bp,
- tp_len, tp_snaplen) == 0))
- goto skip;
+ /* next packet */
+ h.h1->tp_status = TP_STATUS_KERNEL;
- /*
- * Do checks based on packet direction.
- */
- sll = (void *)h.raw + TPACKET_ALIGN(handle->md.tp_hdrlen);
- if (sll->sll_pkttype == PACKET_OUTGOING) {
- /*
- * Outgoing packet.
- * If this is from the loopback device, reject it;
- * we'll see the packet as an incoming packet as well,
- * and we don't want to see it twice.
- */
- if (sll->sll_ifindex == handle->md.lo_ifindex)
- goto skip;
+ if (++handle->offset >= handle->cc)
+ handle->offset = 0;
- /*
- * If the user only wants incoming packets, reject it.
- */
- if (handle->direction == PCAP_D_IN)
- goto skip;
- } else {
- /*
- * Incoming packet.
- * If the user only wants outgoing packets, reject it.
- */
- if (handle->direction == PCAP_D_OUT)
- goto skip;
+ /* check for break loop condition*/
+ if (handle->break_loop) {
+ handle->break_loop = 0;
+ return PCAP_ERROR_BREAK;
}
+ }
+ return pkts;
+}
- /* get required packet info from ring header */
- pcaphdr.ts.tv_sec = tp_sec;
- pcaphdr.ts.tv_usec = tp_usec;
- pcaphdr.caplen = tp_snaplen;
- pcaphdr.len = tp_len;
+#ifdef HAVE_TPACKET2
+static int
+pcap_read_linux_mmap_v2(pcap_t *handle, int max_packets, pcap_handler callback,
+ u_char *user)
+{
+ struct pcap_linux *handlep = handle->priv;
+ int pkts = 0;
+ int ret;
- /* if required build in place the sll header*/
- if (handle->md.cooked) {
- struct sll_header *hdrp;
+ /* wait for frames availability.*/
+ ret = pcap_wait_for_frames_mmap(handle);
+ if (ret) {
+ return ret;
+ }
- /*
- * The kernel should have left us with enough
- * space for an sll header; back up the packet
- * data pointer into that space, as that'll be
- * the beginning of the packet we pass to the
- * callback.
- */
- bp -= SLL_HDR_LEN;
+ /* non-positive values of max_packets are used to require all
+ * packets currently available in the ring */
+ while ((pkts < max_packets) || (max_packets <= 0)) {
+ union thdr h;
- /*
- * Let's make sure that's past the end of
- * the tpacket header, i.e. >=
- * ((u_char *)thdr + TPACKET_HDRLEN), so we
- * don't step on the header when we construct
- * the sll header.
- */
- if (bp < (u_char *)h.raw +
- TPACKET_ALIGN(handle->md.tp_hdrlen) +
- sizeof(struct sockaddr_ll)) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
- "cooked-mode frame doesn't have room for sll header");
- return -1;
- }
+ h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER);
+ if (!h.raw)
+ break;
- /*
- * OK, that worked; construct the sll header.
- */
- hdrp = (struct sll_header *)bp;
- hdrp->sll_pkttype = map_packet_type_to_sll_type(
- sll->sll_pkttype);
- hdrp->sll_hatype = htons(sll->sll_hatype);
- hdrp->sll_halen = htons(sll->sll_halen);
- memcpy(hdrp->sll_addr, sll->sll_addr, SLL_ADDRLEN);
- hdrp->sll_protocol = sll->sll_protocol;
-
- /* update packet len */
- pcaphdr.caplen += SLL_HDR_LEN;
- pcaphdr.len += SLL_HDR_LEN;
+ ret = pcap_handle_packet_mmap(
+ handle,
+ callback,
+ user,
+ h.raw,
+ h.h2->tp_len,
+ h.h2->tp_mac,
+ h.h2->tp_snaplen,
+ h.h2->tp_sec,
+ handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? h.h2->tp_nsec : h.h2->tp_nsec / 1000,
+#if defined(TP_STATUS_VLAN_VALID)
+ (h.h2->tp_vlan_tci || (h.h2->tp_status & TP_STATUS_VLAN_VALID)),
+#else
+ h.h2->tp_vlan_tci != 0,
+#endif
+ h.h2->tp_vlan_tci);
+ if (ret == 1) {
+ pkts++;
+ handlep->packets_read++;
+ } else if (ret < 0) {
+ return ret;
}
-#ifdef HAVE_TPACKET2
- if (handle->md.tp_version == TPACKET_V2 && h.h2->tp_vlan_tci &&
- tp_snaplen >= 2 * ETH_ALEN) {
- struct vlan_tag *tag;
+ /* next packet */
+ h.h2->tp_status = TP_STATUS_KERNEL;
- bp -= VLAN_TAG_LEN;
- memmove(bp, bp + VLAN_TAG_LEN, 2 * ETH_ALEN);
+ if (++handle->offset >= handle->cc)
+ handle->offset = 0;
- tag = (struct vlan_tag *)(bp + 2 * ETH_ALEN);
- tag->vlan_tpid = htons(ETH_P_8021Q);
- tag->vlan_tci = htons(h.h2->tp_vlan_tci);
+ /* check for break loop condition*/
+ if (handle->break_loop) {
+ handle->break_loop = 0;
+ return PCAP_ERROR_BREAK;
+ }
+ }
+ return pkts;
+}
+#endif /* HAVE_TPACKET2 */
- pcaphdr.caplen += VLAN_TAG_LEN;
- pcaphdr.len += VLAN_TAG_LEN;
+#ifdef HAVE_TPACKET3
+static int
+pcap_read_linux_mmap_v3(pcap_t *handle, int max_packets, pcap_handler callback,
+ u_char *user)
+{
+ struct pcap_linux *handlep = handle->priv;
+ union thdr h;
+ int pkts = 0;
+ int ret;
+
+ if (handlep->current_packet == NULL) {
+ /* wait for frames availability.*/
+ ret = pcap_wait_for_frames_mmap(handle);
+ if (ret) {
+ return ret;
}
-#endif
+ }
+ h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER);
+ if (!h.raw)
+ return pkts;
- /*
- * The only way to tell the kernel to cut off the
- * packet at a snapshot length is with a filter program;
- * if there's no filter program, the kernel won't cut
- * the packet off.
- *
- * Trim the snapshot length to be no longer than the
- * specified snapshot length.
- */
- if (pcaphdr.caplen > handle->snapshot)
- pcaphdr.caplen = handle->snapshot;
+ /* non-positive values of max_packets are used to require all
+ * packets currently available in the ring */
+ while ((pkts < max_packets) || (max_packets <= 0)) {
+ if (handlep->current_packet == NULL) {
+ h.raw = pcap_get_ring_frame(handle, TP_STATUS_USER);
+ if (!h.raw)
+ break;
- /* pass the packet to the user */
- pkts++;
- callback(user, &pcaphdr, bp);
- handle->md.packets_read++;
+ handlep->current_packet = h.raw + h.h3->hdr.bh1.offset_to_first_pkt;
+ handlep->packets_left = h.h3->hdr.bh1.num_pkts;
+ }
+ int packets_to_read = handlep->packets_left;
-skip:
- /* next packet */
- switch (handle->md.tp_version) {
- case TPACKET_V1:
- h.h1->tp_status = TP_STATUS_KERNEL;
- break;
-#ifdef HAVE_TPACKET2
- case TPACKET_V2:
- h.h2->tp_status = TP_STATUS_KERNEL;
- break;
+ if (max_packets >= 0 && packets_to_read > max_packets) {
+ packets_to_read = max_packets;
+ }
+
+ while(packets_to_read--) {
+ struct tpacket3_hdr* tp3_hdr = (struct tpacket3_hdr*) handlep->current_packet;
+ ret = pcap_handle_packet_mmap(
+ handle,
+ callback,
+ user,
+ handlep->current_packet,
+ tp3_hdr->tp_len,
+ tp3_hdr->tp_mac,
+ tp3_hdr->tp_snaplen,
+ tp3_hdr->tp_sec,
+ handle->opt.tstamp_precision == PCAP_TSTAMP_PRECISION_NANO ? tp3_hdr->tp_nsec : tp3_hdr->tp_nsec / 1000,
+#if defined(TP_STATUS_VLAN_VALID)
+ (tp3_hdr->hv1.tp_vlan_tci || (tp3_hdr->tp_status & TP_STATUS_VLAN_VALID)),
+#else
+ tp3_hdr->hv1.tp_vlan_tci != 0,
#endif
+ tp3_hdr->hv1.tp_vlan_tci);
+ if (ret == 1) {
+ pkts++;
+ handlep->packets_read++;
+ } else if (ret < 0) {
+ handlep->current_packet = NULL;
+ return ret;
+ }
+ handlep->current_packet += tp3_hdr->tp_next_offset;
+ handlep->packets_left--;
+ }
+
+ if (handlep->packets_left <= 0) {
+ /* next block */
+ h.h3->hdr.bh1.block_status = TP_STATUS_KERNEL;
+
+ if (++handle->offset >= handle->cc)
+ handle->offset = 0;
+
+ handlep->current_packet = NULL;
}
- if (++handle->offset >= handle->cc)
- handle->offset = 0;
/* check for break loop condition*/
if (handle->break_loop) {
@@ -4078,10 +4473,12 @@ skip:
}
return pkts;
}
+#endif /* HAVE_TPACKET3 */
static int
pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter)
{
+ struct pcap_linux *handlep = handle->priv;
int n, offset;
int ret;
@@ -4098,7 +4495,7 @@ pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter)
/* if the kernel filter is enabled, we need to apply the filter on
* all packets present into the ring. Get an upper bound of their number
*/
- if (!handle->md.use_bpf)
+ if (!handlep->filtering_in_kernel)
return ret;
/* walk the ring backward and count the free slot */
@@ -4116,7 +4513,7 @@ pcap_setfilter_linux_mmap(pcap_t *handle, struct bpf_program *filter)
handle->offset = offset;
/* store the number of packets currently present in the ring */
- handle->md.use_bpf = 1 + (handle->cc - n);
+ handlep->filtering_in_kernel = 1 + (handle->cc - n);
return ret;
}
@@ -4318,6 +4715,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device)
* value of -ENFILE. (Return values are negative errnos.) We
* could probably use that to find an unused device.
*/
+ struct pcap_linux *handlep = handle->priv;
int err;
struct iwreq ireq;
struct iw_priv_args *priv;
@@ -4598,7 +4996,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device)
/*
* Save the old mode.
*/
- handle->md.oldmode = ireq.u.mode;
+ handlep->oldmode = ireq.u.mode;
/*
* Put the adapter in rfmon mode. How we do this depends
@@ -4625,7 +5023,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device)
* Note that we have to put the old mode back
* when we close the device.
*/
- handle->md.must_do_on_close |= MUST_CLEAR_RFMON;
+ handlep->must_do_on_close |= MUST_CLEAR_RFMON;
/*
* Add this to the list of pcaps to close
@@ -4872,7 +5270,7 @@ enter_rfmon_mode_wext(pcap_t *handle, int sock_fd, const char *device)
* Note that we have to put the old mode back when we
* close the device.
*/
- handle->md.must_do_on_close |= MUST_CLEAR_RFMON;
+ handlep->must_do_on_close |= MUST_CLEAR_RFMON;
/*
* Add this to the list of pcaps to close when we exit.
@@ -4935,9 +5333,10 @@ iface_ethtool_ioctl(pcap_t *handle, int cmd, const char *cmdname)
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name));
eval.cmd = cmd;
+ eval.data = 0;
ifr.ifr_data = (caddr_t)&eval;
if (ioctl(handle->fd, SIOCETHTOOL, &ifr) == -1) {
- if (errno == EOPNOTSUPP) {
+ if (errno == EOPNOTSUPP || errno == EINVAL) {
/*
* OK, let's just return 0, which, in our
* case, either means "no, what we're asking
@@ -5034,6 +5433,7 @@ iface_get_offload(pcap_t *handle _U_)
static int
activate_old(pcap_t *handle)
{
+ struct pcap_linux *handlep = handle->priv;
int arptype;
struct ifreq ifr;
const char *device = handle->opt.source;
@@ -5061,10 +5461,10 @@ activate_old(pcap_t *handle)
}
/* It worked - we are using the old interface */
- handle->md.sock_packet = 1;
+ handlep->sock_packet = 1;
/* ...which means we get the link-layer header. */
- handle->md.cooked = 0;
+ handlep->cooked = 0;
/* Bind to the given device */
@@ -5133,7 +5533,7 @@ activate_old(pcap_t *handle)
pcap_strerror(errno));
return PCAP_ERROR;
}
- handle->md.must_do_on_close |= MUST_CLEAR_PROMISC;
+ handlep->must_do_on_close |= MUST_CLEAR_PROMISC;
/*
* Add this to the list of pcaps
@@ -5215,6 +5615,12 @@ activate_old(pcap_t *handle)
*/
handle->offset = 0;
+ /*
+ * SOCK_PACKET sockets don't supply information from
+ * stripped VLAN tags.
+ */
+ handlep->vlan_offset = -1; /* unknown */
+
return 1;
}
@@ -5310,6 +5716,7 @@ iface_get_arptype(int fd, const char *device, char *ebuf)
static int
fix_program(pcap_t *handle, struct sock_fprog *fcode, int is_mmapped)
{
+ struct pcap_linux *handlep = handle->priv;
size_t prog_size;
register int i;
register struct bpf_insn *p;
@@ -5385,7 +5792,7 @@ fix_program(pcap_t *handle, struct sock_fprog *fcode, int is_mmapped)
/*
* Yes; are we in cooked mode?
*/
- if (handle->md.cooked) {
+ if (handlep->cooked) {
/*
* Yes, so we need to fix this
* instruction.
diff --git a/external/bsd/libpcap/dist/pcap-netfilter-linux.c b/external/bsd/libpcap/dist/pcap-netfilter-linux.c
index f9656136169..76f250db207 100644
--- a/external/bsd/libpcap/dist/pcap-netfilter-linux.c
+++ b/external/bsd/libpcap/dist/pcap-netfilter-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-netfilter-linux.c,v 1.1.1.1 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-netfilter-linux.c,v 1.1.1.2 2013/12/31 16:57:19 christos Exp $ */
/*
* Copyright (c) 2011 Jakub Zawadzki
@@ -53,18 +53,42 @@
#include <linux/types.h>
#include <linux/netlink.h>
+#include <linux/netfilter.h>
#include <linux/netfilter/nfnetlink.h>
#include <linux/netfilter/nfnetlink_log.h>
+#include <linux/netfilter/nfnetlink_queue.h>
+/* NOTE: if your program drops privilages after pcap_activate() it WON'T work with nfqueue.
+ * It took me quite some time to debug ;/
+ *
+ * Sending any data to nfnetlink socket requires CAP_NET_ADMIN privilages,
+ * and in nfqueue we need to send verdict reply after recving packet.
+ *
+ * In tcpdump you can disable dropping privilages with -Z root
+ */
+
#include "pcap-netfilter-linux.h"
#define HDR_LENGTH (NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg))))
#define NFLOG_IFACE "nflog"
+#define NFQUEUE_IFACE "nfqueue"
+
+typedef enum { OTHER = -1, NFLOG, NFQUEUE } nftype_t;
+
+/*
+ * Private data for capturing on Linux netfilter sockets.
+ */
+struct pcap_netfilter {
+ u_int packets_read; /* count of packets read with recvfrom() */
+};
+
+static int nfqueue_send_verdict(const pcap_t *handle, u_int16_t group_id, u_int32_t id, u_int32_t verdict);
static int
-nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
+netfilter_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
{
+ struct pcap_netfilter *handlep = handle->priv;
const unsigned char *buf;
int count = 0;
int len;
@@ -87,6 +111,7 @@ nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char
while (len >= NLMSG_SPACE(0)) {
const struct nlmsghdr *nlh = (const struct nlmsghdr *) buf;
u_int32_t msg_len;
+ nftype_t type = OTHER;
if (nlh->nlmsg_len < sizeof(struct nlmsghdr) || len < nlh->nlmsg_len) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Message truncated: (got: %d) (nlmsg_len: %u)", len, nlh->nlmsg_len);
@@ -95,10 +120,19 @@ nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char
if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_ULOG &&
NFNL_MSG_TYPE(nlh->nlmsg_type) == NFULNL_MSG_PACKET)
- {
+ type = NFLOG;
+
+ if (NFNL_SUBSYS_ID(nlh->nlmsg_type) == NFNL_SUBSYS_QUEUE &&
+ NFNL_MSG_TYPE(nlh->nlmsg_type) == NFQNL_MSG_PACKET)
+ type = NFQUEUE;
+
+ if (type != OTHER) {
const unsigned char *payload = NULL;
struct pcap_pkthdr pkth;
+ const struct nfgenmsg *nfg;
+ int id = 0;
+
if (handle->linktype != DLT_NFLOG) {
const struct nfattr *payload_attr = NULL;
@@ -107,15 +141,32 @@ nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char
return -1;
}
+ nfg = NLMSG_DATA(nlh);
if (nlh->nlmsg_len > HDR_LENGTH) {
- struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
+ struct nfattr *attr = NFM_NFA(nfg);
int attr_len = nlh->nlmsg_len - NLMSG_ALIGN(HDR_LENGTH);
while (NFA_OK(attr, attr_len)) {
- switch (NFA_TYPE(attr)) {
- case NFULA_PAYLOAD:
- payload_attr = attr;
- break;
+ if (type == NFQUEUE) {
+ switch (NFA_TYPE(attr)) {
+ case NFQA_PACKET_HDR:
+ {
+ const struct nfqnl_msg_packet_hdr *pkt_hdr = (const struct nfqnl_msg_packet_hdr *) NFA_DATA(attr);
+
+ id = ntohl(pkt_hdr->packet_id);
+ break;
+ }
+ case NFQA_PAYLOAD:
+ payload_attr = attr;
+ break;
+ }
+
+ } else if (type == NFLOG) {
+ switch (NFA_TYPE(attr)) {
+ case NFULA_PAYLOAD:
+ payload_attr = attr;
+ break;
+ }
}
attr = NFA_NEXT(attr, attr_len);
}
@@ -138,11 +189,16 @@ nflog_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char
if (handle->fcode.bf_insns == NULL ||
bpf_filter(handle->fcode.bf_insns, payload, pkth.len, pkth.caplen))
{
- handle->md.packets_read++;
+ handlep->packets_read++;
callback(user, &pkth, payload);
count++;
}
}
+
+ if (type == NFQUEUE) {
+ /* XXX, possible responses: NF_DROP, NF_ACCEPT, NF_STOLEN, NF_QUEUE, NF_REPEAT, NF_STOP */
+ nfqueue_send_verdict(handle, ntohs(nfg->res_id), id, NF_ACCEPT);
+ }
}
msg_len = NLMSG_ALIGN(nlh->nlmsg_len);
@@ -165,7 +221,9 @@ netfilter_set_datalink(pcap_t *handle, int dlt)
static int
netfilter_stats_linux(pcap_t *handle, struct pcap_stat *stats)
{
- stats->ps_recv = handle->md.packets_read;
+ struct pcap_netfilter *handlep = handle->priv;
+
+ stats->ps_recv = handlep->packets_read;
stats->ps_drop = 0;
stats->ps_ifdrop = 0;
return 0;
@@ -185,7 +243,7 @@ struct my_nfattr {
};
static int
-nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t res_id, const struct my_nfattr *mynfa)
+netfilter_send_config_msg(const pcap_t *handle, u_int16_t msg_type, int ack, u_int8_t family, u_int16_t res_id, const struct my_nfattr *mynfa)
{
char buf[1024] __attribute__ ((aligned));
@@ -200,8 +258,8 @@ nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t res_id, c
++seq_id;
nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct nfgenmsg));
- nlh->nlmsg_type = (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_CONFIG;
- nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ nlh->nlmsg_type = msg_type;
+ nlh->nlmsg_flags = NLM_F_REQUEST | (ack ? NLM_F_ACK : 0);
nlh->nlmsg_pid = 0; /* to kernel */
nlh->nlmsg_seq = seq_id;
@@ -224,6 +282,9 @@ nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t res_id, c
if (sendto(handle->fd, nlh, nlh->nlmsg_len, 0, (struct sockaddr *) &snl, sizeof(snl)) == -1)
return -1;
+ if (!ack)
+ return 0;
+
/* waiting for reply loop */
do {
socklen_t addrlen = sizeof(snl);
@@ -263,6 +324,12 @@ nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t res_id, c
}
static int
+nflog_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t group_id, const struct my_nfattr *mynfa)
+{
+ return netfilter_send_config_msg(handle, (NFNL_SUBSYS_ULOG << 8) | NFULNL_MSG_CONFIG, 1, family, group_id, mynfa);
+}
+
+static int
nflog_send_config_cmd(const pcap_t *handle, u_int16_t group_id, u_int8_t cmd, u_int8_t family)
{
struct nfulnl_msg_config_cmd msg;
@@ -294,20 +361,79 @@ nflog_send_config_mode(const pcap_t *handle, u_int16_t group_id, u_int8_t copy_m
}
static int
-nflog_activate(pcap_t* handle)
+nfqueue_send_verdict(const pcap_t *handle, u_int16_t group_id, u_int32_t id, u_int32_t verdict)
+{
+ struct nfqnl_msg_verdict_hdr msg;
+ struct my_nfattr nfa;
+
+ msg.id = htonl(id);
+ msg.verdict = htonl(verdict);
+
+ nfa.data = &msg;
+ nfa.nfa_type = NFQA_VERDICT_HDR;
+ nfa.nfa_len = sizeof(msg);
+
+ return netfilter_send_config_msg(handle, (NFNL_SUBSYS_QUEUE << 8) | NFQNL_MSG_VERDICT, 0, AF_UNSPEC, group_id, &nfa);
+}
+
+static int
+nfqueue_send_config_msg(const pcap_t *handle, u_int8_t family, u_int16_t group_id, const struct my_nfattr *mynfa)
+{
+ return netfilter_send_config_msg(handle, (NFNL_SUBSYS_QUEUE << 8) | NFQNL_MSG_CONFIG, 1, family, group_id, mynfa);
+}
+
+static int
+nfqueue_send_config_cmd(const pcap_t *handle, u_int16_t group_id, u_int8_t cmd, u_int16_t pf)
+{
+ struct nfqnl_msg_config_cmd msg;
+ struct my_nfattr nfa;
+
+ msg.command = cmd;
+ msg.pf = htons(pf);
+
+ nfa.data = &msg;
+ nfa.nfa_type = NFQA_CFG_CMD;
+ nfa.nfa_len = sizeof(msg);
+
+ return nfqueue_send_config_msg(handle, AF_UNSPEC, group_id, &nfa);
+}
+
+static int
+nfqueue_send_config_mode(const pcap_t *handle, u_int16_t group_id, u_int8_t copy_mode, u_int32_t copy_range)
+{
+ struct nfqnl_msg_config_params msg;
+ struct my_nfattr nfa;
+
+ msg.copy_range = htonl(copy_range);
+ msg.copy_mode = copy_mode;
+
+ nfa.data = &msg;
+ nfa.nfa_type = NFQA_CFG_PARAMS;
+ nfa.nfa_len = sizeof(msg);
+
+ return nfqueue_send_config_msg(handle, AF_UNSPEC, group_id, &nfa);
+}
+
+static int
+netfilter_activate(pcap_t* handle)
{
const char *dev = handle->opt.source;
unsigned short groups[32];
int group_count = 0;
+ nftype_t type = OTHER;
int i;
- if (strncmp(dev, NFLOG_IFACE, strlen(NFLOG_IFACE)) == 0) {
- dev += strlen(NFLOG_IFACE);
-
- /* nflog:30,33,42 looks nice, allow it */
- if (*dev == ':')
- dev++;
+ if (strncmp(dev, NFLOG_IFACE, strlen(NFLOG_IFACE)) == 0) {
+ dev += strlen(NFLOG_IFACE);
+ type = NFLOG;
+ } else if (strncmp(dev, NFQUEUE_IFACE, strlen(NFQUEUE_IFACE)) == 0) {
+ dev += strlen(NFQUEUE_IFACE);
+ type = NFQUEUE;
+ }
+
+ if (type != OTHER && *dev == ':') {
+ dev++;
while (*dev) {
long int group_id;
char *end_dev;
@@ -337,7 +463,7 @@ nflog_activate(pcap_t* handle)
}
}
- if (*dev) {
+ if (type == OTHER || *dev) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"Can't get netfilter group(s) index from %s",
handle->opt.source);
@@ -353,12 +479,10 @@ nflog_activate(pcap_t* handle)
/* Initialize some components of the pcap structure. */
handle->bufsize = 128 + handle->snapshot;
handle->offset = 0;
- handle->linktype = DLT_NFLOG;
- handle->read_op = nflog_read_linux;
+ handle->read_op = netfilter_read_linux;
handle->inject_op = netfilter_inject_linux;
handle->setfilter_op = install_bpf_program; /* no kernel filtering */
handle->setdirection_op = NULL;
- handle->set_datalink_op = NULL;
handle->set_datalink_op = netfilter_set_datalink;
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
@@ -371,12 +495,17 @@ nflog_activate(pcap_t* handle)
return PCAP_ERROR;
}
- handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
- if (handle->dlt_list != NULL) {
- handle->dlt_list[0] = DLT_NFLOG;
- handle->dlt_list[1] = DLT_IPV4;
- handle->dlt_count = 2;
- }
+ if (type == NFLOG) {
+ handle->linktype = DLT_NFLOG;
+ handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2);
+ if (handle->dlt_list != NULL) {
+ handle->dlt_list[0] = DLT_NFLOG;
+ handle->dlt_list[1] = DLT_IPV4;
+ handle->dlt_count = 2;
+ }
+
+ } else
+ handle->linktype = DLT_IPV4;
handle->buffer = malloc(handle->bufsize);
if (!handle->buffer) {
@@ -384,27 +513,53 @@ nflog_activate(pcap_t* handle)
goto close_fail;
}
- if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_UNBIND: %s", pcap_strerror(errno));
- goto close_fail;
- }
+ if (type == NFLOG) {
+ if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_UNBIND: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
- if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_BIND, AF_INET) < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_BIND: %s", pcap_strerror(errno));
- goto close_fail;
- }
+ if (nflog_send_config_cmd(handle, 0, NFULNL_CFG_CMD_PF_BIND, AF_INET) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_CFG_CMD_PF_BIND: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
- /* Bind socket to the nflog groups */
- for (i = 0; i < group_count; i++) {
- if (nflog_send_config_cmd(handle, groups[i], NFULNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't listen on group group index: %s", pcap_strerror(errno));
+ /* Bind socket to the nflog groups */
+ for (i = 0; i < group_count; i++) {
+ if (nflog_send_config_cmd(handle, groups[i], NFULNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't listen on group group index: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
+
+ if (nflog_send_config_mode(handle, groups[i], NFULNL_COPY_PACKET, handle->snapshot) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_COPY_PACKET: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
+ }
+
+ } else {
+ if (nfqueue_send_config_cmd(handle, 0, NFQNL_CFG_CMD_PF_UNBIND, AF_INET) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFQNL_CFG_CMD_PF_UNBIND: %s", pcap_strerror(errno));
goto close_fail;
}
- if (nflog_send_config_mode(handle, groups[i], NFULNL_COPY_PACKET, handle->snapshot) < 0) {
- snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFULNL_COPY_PACKET: %s", pcap_strerror(errno));
+ if (nfqueue_send_config_cmd(handle, 0, NFQNL_CFG_CMD_PF_BIND, AF_INET) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFQNL_CFG_CMD_PF_BIND: %s", pcap_strerror(errno));
goto close_fail;
}
+
+ /* Bind socket to the nfqueue groups */
+ for (i = 0; i < group_count; i++) {
+ if (nfqueue_send_config_cmd(handle, groups[i], NFQNL_CFG_CMD_BIND, AF_UNSPEC) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't listen on group group index: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
+
+ if (nfqueue_send_config_mode(handle, groups[i], NFQNL_COPY_PACKET, handle->snapshot) < 0) {
+ snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "NFQNL_COPY_PACKET: %s", pcap_strerror(errno));
+ goto close_fail;
+ }
+ }
}
if (handle->opt.rfmon) {
@@ -434,22 +589,51 @@ close_fail:
}
pcap_t *
-nflog_create(const char *device, char *ebuf)
+netfilter_create(const char *device, char *ebuf, int *is_ours)
{
+ const char *cp;
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ /* Does this look like an netfilter device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+
+ /* Does it begin with NFLOG_IFACE or NFQUEUE_IFACE? */
+ if (strncmp(cp, NFLOG_IFACE, sizeof NFLOG_IFACE - 1) == 0)
+ cp += sizeof NFLOG_IFACE - 1;
+ else if (strncmp(cp, NFQUEUE_IFACE, sizeof NFQUEUE_IFACE - 1) == 0)
+ cp += sizeof NFQUEUE_IFACE - 1;
+ else {
+ /* Nope, doesn't begin with NFLOG_IFACE nor NFQUEUE_IFACE */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /*
+ * Yes - is that either the end of the name, or is it followed
+ * by a colon?
+ */
+ if (*cp != ':' && *cp != '\0') {
+ /* Nope */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_netfilter));
if (p == NULL)
return (NULL);
- p->activate_op = nflog_activate;
+ p->activate_op = netfilter_activate;
return (p);
}
int
-netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
+netfilter_findalldevs(pcap_if_t **alldevsp, char *err_str)
{
- pcap_if_t *found_dev = *alldevsp;
int sock;
sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);
@@ -463,8 +647,9 @@ netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
}
close(sock);
- if (pcap_add_if(&found_dev, NFLOG_IFACE, 0, "Linux netfilter log (NFLOG) interface", err_str) < 0)
+ if (pcap_add_if(alldevsp, NFLOG_IFACE, 0, "Linux netfilter log (NFLOG) interface", err_str) < 0)
+ return -1;
+ if (pcap_add_if(alldevsp, NFQUEUE_IFACE, 0, "Linux netfilter queue (NFQUEUE) interface", err_str) < 0)
return -1;
return 0;
}
-
diff --git a/external/bsd/libpcap/dist/pcap-netfilter-linux.h b/external/bsd/libpcap/dist/pcap-netfilter-linux.h
index 870d991cc0b..1834bbcd82c 100644
--- a/external/bsd/libpcap/dist/pcap-netfilter-linux.h
+++ b/external/bsd/libpcap/dist/pcap-netfilter-linux.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-netfilter-linux.h,v 1.1.1.1 2013/04/06 15:57:47 christos Exp $ */
+/* $NetBSD: pcap-netfilter-linux.h,v 1.1.1.2 2013/12/31 16:57:28 christos Exp $ */
/*
* Copyright (c) 2011 Jakub Zawadzki
@@ -33,5 +33,5 @@
/*
* Prototypes for netlink-related functions
*/
-int netfilter_platform_finddevs(pcap_if_t **alldevsp, char *err_str);
-pcap_t *nflog_create(const char *device, char *ebuf);
+int netfilter_findalldevs(pcap_if_t **alldevsp, char *err_str);
+pcap_t *netfilter_create(const char *device, char *ebuf, int *is_ours);
diff --git a/external/bsd/libpcap/dist/pcap-nit.c b/external/bsd/libpcap/dist/pcap-nit.c
index 39018fbb399..08482d353e2 100644
--- a/external/bsd/libpcap/dist/pcap-nit.c
+++ b/external/bsd/libpcap/dist/pcap-nit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-nit.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-nit.c,v 1.1.1.4 2013/12/31 16:57:19 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -73,9 +73,17 @@ static const char rcsid[] _U_ =
/* Forwards */
static int nit_setflags(int, int, int, char *);
+/*
+ * Private data for capturing on NIT devices.
+ */
+struct pcap_nit {
+ struct pcap_stat stat;
+};
+
static int
pcap_stats_nit(pcap_t *p, struct pcap_stat *ps)
{
+ struct pcap_nit *pn = p->priv;
/*
* "ps_recv" counts packets handed to the filter, not packets
@@ -93,13 +101,14 @@ pcap_stats_nit(pcap_t *p, struct pcap_stat *ps)
* kernel by libpcap or packets not yet read from libpcap by the
* application.
*/
- *ps = p->md.stat;
+ *ps = pn->stat;
return (0);
}
static int
pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_nit *pn = p->priv;
register int cc, n;
register u_char *bp, *cp, *ep;
register struct nit_hdr *nh;
@@ -158,7 +167,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case NIT_NOMBUF:
case NIT_NOCLUSTER:
case NIT_NOSPACE:
- p->md.stat.ps_drop = nh->nh_dropped;
+ pn->stat.ps_drop = nh->nh_dropped;
continue;
case NIT_SEQNO:
@@ -169,7 +178,7 @@ pcap_read_nit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
"bad nit state %d", nh->nh_state);
return (-1);
}
- ++p->md.stat.ps_recv;
+ ++pn->stat.ps_recv;
bp += ((sizeof(struct nit_hdr) + nh->nh_datalen +
sizeof(int) - 1) & ~(sizeof(int) - 1));
@@ -211,28 +220,42 @@ pcap_inject_nit(pcap_t *p, const void *buf, size_t size)
}
static int
-nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
+nit_setflags(pcap_t *p)
{
struct nit_ioc nioc;
memset(&nioc, 0, sizeof(nioc));
- nioc.nioc_bufspace = BUFSPACE;
- nioc.nioc_chunksize = CHUNKSIZE;
nioc.nioc_typetomatch = NT_ALLTYPES;
nioc.nioc_snaplen = p->snapshot;
nioc.nioc_bufalign = sizeof(int);
nioc.nioc_bufoffset = 0;
- if (to_ms != 0) {
+ if (p->opt.buffer_size != 0)
+ nioc.nioc_bufspace = p->opt.buffer_size;
+ else {
+ /* Default buffer size */
+ nioc.nioc_bufspace = BUFSPACE;
+ }
+
+ if (p->opt.immediate) {
+ /*
+ * XXX - will this cause packets to be delivered immediately?
+ * XXX - given that this is for SunOS prior to 4.0, do
+ * we care?
+ */
+ nioc.nioc_chunksize = 0;
+ } else
+ nioc.nioc_chunksize = CHUNKSIZE;
+ if (p->opt.timeout != 0) {
nioc.nioc_flags |= NF_TIMEOUT;
- nioc.nioc_timeout.tv_sec = to_ms / 1000;
- nioc.nioc_timeout.tv_usec = (to_ms * 1000) % 1000000;
+ nioc.nioc_timeout.tv_sec = p->opt.timeout / 1000;
+ nioc.nioc_timeout.tv_usec = (p->opt.timeout * 1000) % 1000000;
}
- if (promisc)
+ if (p->opt.promisc)
nioc.nioc_flags |= NF_PROMISC;
- if (ioctl(fd, SIOCSNIT, &nioc) < 0) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "SIOCSNIT: %s",
+ if (ioctl(p->fd, SIOCSNIT, &nioc) < 0) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "SIOCSNIT: %s",
pcap_strerror(errno));
return (-1);
}
@@ -275,7 +298,8 @@ pcap_activate_nit(pcap_t *p)
"bind: %s: %s", snit.snit_ifname, pcap_strerror(errno));
goto bad;
}
- nit_setflags(p->fd, p->opt.promisc, p->md.timeout, p->errbuf);
+ if (nit_setflags(p) < 0)
+ goto bad;
/*
* NIT supports only ethernets.
@@ -330,11 +354,11 @@ pcap_activate_nit(pcap_t *p)
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_nit));
if (p == NULL)
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-null.c b/external/bsd/libpcap/dist/pcap-null.c
index c78e97e2697..c027f41e411 100644
--- a/external/bsd/libpcap/dist/pcap-null.c
+++ b/external/bsd/libpcap/dist/pcap-null.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-null.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-null.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 1994, 1995, 1996
@@ -42,7 +42,7 @@ static const char rcsid[] _U_ =
static char nosup[] = "live packet capture not supported on this system";
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-pf.c b/external/bsd/libpcap/dist/pcap-pf.c
index fc66d91321f..5fbd3b6590f 100644
--- a/external/bsd/libpcap/dist/pcap-pf.c
+++ b/external/bsd/libpcap/dist/pcap-pf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-pf.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-pf.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -76,6 +76,24 @@ struct rtentry;
#include "os-proto.h"
#endif
+/*
+ * FDDI packets are padded to make everything line up on a nice boundary.
+ */
+#define PCAP_FDDIPAD 3
+
+/*
+ * Private data for capturing on Ultrix and DEC OSF/1^WDigital UNIX^W^W
+ * Tru64 UNIX packetfilter devices.
+ */
+struct pcap_pf {
+ int filtering_in_kernel; /* using kernel filter */
+ u_long TotPkts; /* can't oflow for 79 hrs on ether */
+ u_long TotAccepted; /* count accepted by filter */
+ u_long TotDrops; /* count of dropped packets */
+ long TotMissed; /* missed by i/f during this run */
+ long OrigMissed; /* missed by i/f before this run */
+};
+
static int pcap_setfilter_pf(pcap_t *, struct bpf_program *);
/*
@@ -89,15 +107,14 @@ static int pcap_setfilter_pf(pcap_t *, struct bpf_program *);
static int
pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_pf *pf = pc->priv;
register u_char *p, *bp;
register int cc, n, buflen, inc;
register struct enstamp *sp;
#ifdef LBL_ALIGN
struct enstamp stamp;
#endif
-#ifdef PCAP_FDDIPAD
register int pad;
-#endif
again:
cc = pc->cc;
@@ -128,9 +145,7 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user)
* Loop through each packet.
*/
n = 0;
-#ifdef PCAP_FDDIPAD
pad = pc->fddipad;
-#endif
while (cc > 0) {
/*
* Has "pcap_breakloop()" been called?
@@ -179,39 +194,31 @@ pcap_read_pf(pcap_t *pc, int cnt, pcap_handler callback, u_char *user)
inc = ENALIGN(buflen + sp->ens_stamplen);
cc -= inc;
bp += inc;
- pc->md.TotPkts++;
- pc->md.TotDrops += sp->ens_dropped;
- pc->md.TotMissed = sp->ens_ifoverflows;
- if (pc->md.OrigMissed < 0)
- pc->md.OrigMissed = pc->md.TotMissed;
+ pf->TotPkts++;
+ pf->TotDrops += sp->ens_dropped;
+ pf->TotMissed = sp->ens_ifoverflows;
+ if (pf->OrigMissed < 0)
+ pf->OrigMissed = pf->TotMissed;
/*
* Short-circuit evaluation: if using BPF filter
* in kernel, no need to do it now - we already know
* the packet passed the filter.
*
-#ifdef PCAP_FDDIPAD
* Note: the filter code was generated assuming
* that pc->fddipad was the amount of padding
* before the header, as that's what's required
* in the kernel, so we run the filter before
* skipping that padding.
-#endif
*/
- if (pc->md.use_bpf ||
+ if (pf->filtering_in_kernel ||
bpf_filter(pc->fcode.bf_insns, p, sp->ens_count, buflen)) {
struct pcap_pkthdr h;
- pc->md.TotAccepted++;
+ pf->TotAccepted++;
h.ts = sp->ens_tstamp;
-#ifdef PCAP_FDDIPAD
h.len = sp->ens_count - pad;
-#else
- h.len = sp->ens_count;
-#endif
-#ifdef PCAP_FDDIPAD
p += pad;
buflen -= pad;
-#endif
h.caplen = buflen;
(*callback)(user, &h, p);
if (++n >= cnt && cnt > 0) {
@@ -242,6 +249,7 @@ pcap_inject_pf(pcap_t *p, const void *buf, size_t size)
static int
pcap_stats_pf(pcap_t *p, struct pcap_stat *ps)
{
+ struct pcap_pf *pf = p->priv;
/*
* If packet filtering is being done in the kernel:
@@ -279,9 +287,9 @@ pcap_stats_pf(pcap_t *p, struct pcap_stat *ps)
* the kernel by libpcap, but they may include packets not
* yet read from libpcap by the application.
*/
- ps->ps_recv = p->md.TotAccepted;
- ps->ps_drop = p->md.TotDrops;
- ps->ps_ifdrop = p->md.TotMissed - p->md.OrigMissed;
+ ps->ps_recv = pf->TotAccepted;
+ ps->ps_drop = pf->TotDrops;
+ ps->ps_ifdrop = pf->TotMissed - pf->OrigMissed;
return (0);
}
@@ -296,6 +304,7 @@ pcap_stats_pf(pcap_t *p, struct pcap_stat *ps)
static int
pcap_activate_pf(pcap_t *p)
{
+ struct pcap_pf *pf = p->priv;
short enmode;
int backlog = -1; /* request the most */
struct enfilter Filter;
@@ -329,8 +338,10 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
p->opt.source, pcap_strerror(errno));
goto bad;
}
- p->md.OrigMissed = -1;
- enmode = ENTSTAMP|ENBATCH|ENNONEXCL;
+ pf->OrigMissed = -1;
+ enmode = ENTSTAMP|ENNONEXCL;
+ if (!p->opt.immediate)
+ enmode |= ENBATCH;
if (p->opt.promisc)
enmode |= ENPROMISC;
if (ioctl(p->fd, EIOCMBIS, (caddr_t)&enmode) < 0) {
@@ -438,7 +449,6 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
goto bad;
}
/* set truncation */
-#ifdef PCAP_FDDIPAD
if (p->linktype == DLT_FDDI) {
p->fddipad = PCAP_FDDIPAD;
@@ -446,7 +456,6 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
p->snapshot += PCAP_FDDIPAD;
} else
p->fddipad = 0;
-#endif
if (ioctl(p->fd, EIOCTRUNCATE, (caddr_t)&p->snapshot) < 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "EIOCTRUNCATE: %s",
pcap_strerror(errno));
@@ -462,10 +471,10 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
goto bad;
}
- if (p->md.timeout != 0) {
+ if (p->opt.timeout != 0) {
struct timeval timeout;
- timeout.tv_sec = p->md.timeout / 1000;
- timeout.tv_usec = (p->md.timeout * 1000) % 1000000;
+ timeout.tv_sec = p->opt.timeout / 1000;
+ timeout.tv_usec = (p->opt.timeout * 1000) % 1000000;
if (ioctl(p->fd, EIOCSRTIMEOUT, (caddr_t)&timeout) < 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "EIOCSRTIMEOUT: %s",
pcap_strerror(errno));
@@ -501,11 +510,11 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_pf));
if (p == NULL)
return (NULL);
@@ -522,6 +531,7 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
static int
pcap_setfilter_pf(pcap_t *p, struct bpf_program *fp)
{
+ struct pcap_pf *pf = p->priv;
struct bpf_version bv;
/*
@@ -563,7 +573,7 @@ pcap_setfilter_pf(pcap_t *p, struct bpf_program *fp)
* a window to annoy the user.
*/
fprintf(stderr, "tcpdump: Using kernel BPF filter\n");
- p->md.use_bpf = 1;
+ pf->filtering_in_kernel = 1;
/*
* Discard any previously-received packets,
@@ -601,6 +611,6 @@ pcap_setfilter_pf(pcap_t *p, struct bpf_program *fp)
* a warning of some sort.
*/
fprintf(stderr, "tcpdump: Filtering in user process\n");
- p->md.use_bpf = 0;
+ pf->filtering_in_kernel = 0;
return (0);
}
diff --git a/external/bsd/libpcap/dist/pcap-savefile.manfile.in b/external/bsd/libpcap/dist/pcap-savefile.manfile.in
index 46a86e40ad4..60bf7bcf198 100644
--- a/external/bsd/libpcap/dist/pcap-savefile.manfile.in
+++ b/external/bsd/libpcap/dist/pcap-savefile.manfile.in
@@ -55,16 +55,24 @@ Link-layer header type
.RE
.PP
All fields in the per-file header are in the byte order of the host
-writing the file. The first field in the per-file header is a 4-byte
-magic number, with the value 0xa1b2c3d4. The magic number, when read by
-a host with the same byte order as the host that wrote the file, will
-have the value 0xa1b2c3d4, and, when read by a host with the opposite
-byte order as the host that wrote the file, will have the value
+writing the file. Normally, the first field in the per-file header is a
+4-byte magic number, with the value 0xa1b2c3d4. The magic number, when
+read by a host with the same byte order as the host that wrote the file,
+will have the value 0xa1b2c3d4, and, when read by a host with the
+opposite byte order as the host that wrote the file, will have the value
0xd4c3b2a1. That allows software reading the file to determine whether
the byte order of the host that wrote the file is the same as the byte
order of the host on which the file is being read, and thus whether the
values in the per-file and per-packet headers need to be byte-swapped.
.PP
+If the magic number has the value 0xa1b23c4d (with the two nibbles of
+the two lower-order bytes of the magic number swapped), which would be
+read as 0xa1b23c4d by a host with the same byte order as the host that
+wrote the file and as 0x4d3cb2a1 by a host with the opposite byte order
+as the host that wrote the file, the file format is the same as for
+regular files, except that the time stamps for packets are given in
+seconds and nanoseconds rather than seconds and microseconds.
+.PP
Following this are:
.IP
A 2-byte file format major version number; the current version number is
@@ -104,7 +112,7 @@ box;
c.
Time stamp, seconds value
_
-Time stamp, microseconds value
+Time stamp, microseconds or nanoseconds value
_
Length of captured packet data
_
@@ -117,11 +125,12 @@ writing the file. The per-packet header begins with a time stamp giving
the approximate time the packet was captured; the time stamp consists of
a 4-byte value, giving the time in seconds since January 1, 1970,
00:00:00 UTC, followed by a 4-byte value, giving the time in
-microseconds since that second. Following that are a 4-byte value
-giving the number of bytes of captured data that follow the per-packet
-header and a 4-byte value giving the number of bytes that would have
-been present had the packet not been truncated by the snapshot length.
-The two lengths will be equal if the number of bytes of packet data are
-less than or equal to the snapshot length.
+microseconds or nanoseconds since that second, depending on the magic
+number in the file header. Following that are a 4-byte value giving the
+number of bytes of captured data that follow the per-packet header and a
+4-byte value giving the number of bytes that would have been present had
+the packet not been truncated by the snapshot length. The two lengths
+will be equal if the number of bytes of packet data are less than or
+equal to the snapshot length.
.SH SEE ALSO
pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@)
diff --git a/external/bsd/libpcap/dist/pcap-septel.c b/external/bsd/libpcap/dist/pcap-septel.c
index 245ee5193de..74ee24c15ca 100644
--- a/external/bsd/libpcap/dist/pcap-septel.c
+++ b/external/bsd/libpcap/dist/pcap-septel.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-septel.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-septel.c,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */
/*
* pcap-septel.c: Packet capture interface for Intel/Septel card.
@@ -40,34 +40,33 @@ static const char rcsid[] _U_ =
#include <sys/types.h>
#include <unistd.h>
-#ifdef HAVE_SEPTEL_API
#include <msg.h>
#include <ss7_inc.h>
#include <sysgct.h>
#include <pack.h>
#include <system.h>
-#endif /* HAVE_SEPTEL_API */
-#ifdef SEPTEL_ONLY
-/* This code is required when compiling for a Septel device only. */
#include "pcap-septel.h"
-/* Replace septel function names with pcap equivalent. */
-#define septel_create pcap_create
-#define septel_platform_finddevs pcap_platform_finddevs
-#endif /* SEPTEL_ONLY */
-
static int septel_setfilter(pcap_t *p, struct bpf_program *fp);
static int septel_stats(pcap_t *p, struct pcap_stat *ps);
static int septel_setnonblock(pcap_t *p, int nonblock, char *errbuf);
/*
+ * Private data for capturing on Septel devices.
+ */
+struct pcap_septel {
+ struct pcap_stat stat;
+}
+
+/*
* Read at most max_packets from the capture queue and call the callback
* for each of them. Returns the number of packets handled, -1 if an
* error occured, or -2 if we were told to break out of the loop.
*/
static int septel_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user) {
+ struct pcap_septel *ps = p->priv;
HDR *h;
MSG *m;
int processed = 0 ;
@@ -165,7 +164,7 @@ loop:
pcap_header.len = packet_len;
/* Count the packet. */
- p->md.stat.ps_recv++;
+ ps->stat.ps_recv++;
/* Call the user supplied callback function */
callback(user, &pcap_header, dp);
@@ -223,10 +222,24 @@ static pcap_t *septel_activate(pcap_t* handle) {
return 0;
}
-pcap_t *septel_create(const char *device, char *ebuf) {
+pcap_t *septel_create(const char *device, char *ebuf, int *is_ours) {
+ const char *cp;
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ /* Does this look like the Septel device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ if (strcmp(cp, "septel") != 0) {
+ /* Nope, it's not "septel" */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_septel));
if (p == NULL)
return NULL;
@@ -235,17 +248,18 @@ pcap_t *septel_create(const char *device, char *ebuf) {
}
static int septel_stats(pcap_t *p, struct pcap_stat *ps) {
- /*p->md.stat.ps_recv = 0;*/
- /*p->md.stat.ps_drop = 0;*/
+ struct pcap_septel *handlep = p->priv;
+ /*handlep->stat.ps_recv = 0;*/
+ /*handlep->stat.ps_drop = 0;*/
- *ps = p->md.stat;
+ *ps = handlep->stat;
return 0;
}
int
-septel_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
+septel_findalldevs(pcap_if_t **devlistp, char *errbuf)
{
unsigned char *p;
const char description[512]= "Intel/Septel device";
@@ -279,8 +293,6 @@ static int septel_setfilter(pcap_t *p, struct bpf_program *fp) {
return -1;
}
- p->md.use_bpf = 0;
-
return (0);
}
@@ -288,5 +300,6 @@ static int septel_setfilter(pcap_t *p, struct bpf_program *fp) {
static int
septel_setnonblock(pcap_t *p, int nonblock, char *errbuf)
{
- return (0);
+ fprintf(errbuf, PCAP_ERRBUF_SIZE, "Non-blocking mode not supported on Septel devices");
+ return (-1);
}
diff --git a/external/bsd/libpcap/dist/pcap-septel.h b/external/bsd/libpcap/dist/pcap-septel.h
index 077b05f3710..fe80117c795 100644
--- a/external/bsd/libpcap/dist/pcap-septel.h
+++ b/external/bsd/libpcap/dist/pcap-septel.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-septel.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-septel.h,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */
/*
* pcap-septel.c: Packet capture interface for Intel Septel card
@@ -13,5 +13,5 @@
* @(#) Header: /tcpdump/master/libpcap/pcap-septel.h,v 1.2 2008-04-04 19:37:45 guy Exp
*/
-pcap_t *septel_create(const char *device, char *ebuf);
-
+pcap_t *septel_create(const char *device, char *ebuf, int *is_ours);
+int septel_findalldevs(pcap_if_t **devlistp, char *errbuf);
diff --git a/external/bsd/libpcap/dist/pcap-sita.c b/external/bsd/libpcap/dist/pcap-sita.c
index 33c9c9dd9df..0ea1c864e69 100644
--- a/external/bsd/libpcap/dist/pcap-sita.c
+++ b/external/bsd/libpcap/dist/pcap-sita.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-sita.c,v 1.1.1.2 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-sita.c,v 1.1.1.3 2013/12/31 16:57:26 christos Exp $ */
/*
* pcap-sita.c: Packet capture interface additions for SITA ACN devices
@@ -57,40 +57,37 @@
#define LIVE 1
typedef struct iface {
- struct iface *next; /* a pointer to the next interface */
- char *name; /* this interface's name on Wireshark */
- char *IOPname; /* this interface's name on an IOP */
- uint32_t iftype; /* the type of interface (DLT values) */
+ struct iface *next; /* a pointer to the next interface */
+ char *name; /* this interface's name */
+ char *IOPname; /* this interface's name on an IOP */
+ uint32_t iftype; /* the type of interface (DLT values) */
} iface_t;
typedef struct unit {
- char *ip; /* this unit's IP address (as extracted from /etc/hosts) */
- int fd; /* the connection to this unit (if it exists) */
- int find_fd; /* a big kludge to avoid my programming limitations since I could have this unit open for findalldevs purposes */
- int first_time; /* 0 = just opened via acn_open_live(), ie. the first time, NZ = nth time */
- struct sockaddr_in *serv_addr; /* the address control block for comms to this unit */
- int chassis;
- int geoslot;
- iface_t *iface; /* a pointer to a linked list of interface structures */
- char *imsg; /* a pointer to an inbound message */
- int len; /* the current size of the inbound message */
+ char *ip; /* this unit's IP address (as extracted from /etc/hosts) */
+ int fd; /* the connection to this unit (if it exists) */
+ int find_fd; /* a big kludge to avoid my programming limitations since I could have this unit open for findalldevs purposes */
+ int first_time; /* 0 = just opened via acn_open_live(), ie. the first time, NZ = nth time */
+ struct sockaddr_in *serv_addr; /* the address control block for comms to this unit */
+ int chassis;
+ int geoslot;
+ iface_t *iface; /* a pointer to a linked list of interface structures */
+ char *imsg; /* a pointer to an inbound message */
+ int len; /* the current size of the inbound message */
} unit_t;
-static char *errorString;
static unit_t units[MAX_CHASSIS+1][MAX_GEOSLOT+1]; /* we use indexes of 1 through 8, but we reserve/waste index 0 */
-static fd_set readfds; /* a place to store the file descriptors for the connections to the IOPs */
-static fd_set working_set;
-static int max_fs;
-static char static_buf[32];
+static fd_set readfds; /* a place to store the file descriptors for the connections to the IOPs */
+static int max_fs;
-pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
+pcap_if_t *acn_if_list; /* pcap's list of available interfaces */
static void dump_interface_list(void) {
pcap_if_t *iff;
pcap_addr_t *addr;
- int longest_name_len = 0;
+ int longest_name_len = 0;
char *n, *d, *f;
- int if_number = 0;
+ int if_number = 0;
iff = acn_if_list;
while (iff) {
@@ -216,6 +213,9 @@ static void empty_unit(int chassis, int geoslot) {
empty_unit_iface(u);
if (u->imsg) { /* then if an inbound message buffer exists */
u->imsg = (char *)realloc(u->imsg, 1); /* and re-allocate the old large buffer into a new small one */
+ if (u->imsg == NULL) { /* oops, realloc call failed */
+ fprintf(stderr, "Warning...call to realloc() failed, value of errno is %d\n", errno);
+
}
}
@@ -313,9 +313,17 @@ static int open_with_IOP(unit_t *u, int flag) {
if (u->serv_addr == NULL) {
u->serv_addr = malloc(sizeof(struct sockaddr_in));
+
+ /* since we called malloc(), lets check to see if we actually got the memory */
+ if (u->serv_addr == NULL) { /* oops, we didn't get the memory requested */
+ fprintf(stderr, "malloc() request for u->serv_addr failed, value of errno is: %d\n", errno);
+ return 0;
+ }
+
}
ip = u->ip;
- bzero((char *)u->serv_addr, sizeof(struct sockaddr_in));
+ /* bzero() is deprecated, replaced with memset() */
+ memset((char *)u->serv_addr, 0, sizeof(struct sockaddr_in));
u->serv_addr->sin_family = AF_INET;
u->serv_addr->sin_addr.s_addr = inet_addr(ip);
u->serv_addr->sin_port = htons(IOP_SNIFFER_PORT);
@@ -396,18 +404,16 @@ static void acn_freealldevs(void) {
}
}
-static char *nonUnified_port_num(unit_t *u, int IOPportnum) {
+static void nonUnified_IOP_port_name(char *buf, size_t bufsize, const char *proto, unit_t *u) {
- sprintf(static_buf, "%d_%d", u->chassis, u->geoslot);
- return static_buf;
+ snprintf(buf, bufsize, "%s_%d_%d", proto, u->chassis, u->geoslot);
}
-static char *unified_port_num(unit_t *u, int IOPportnum) {
+static void unified_IOP_port_name(char *buf, size_t bufsize, const char *proto, unit_t *u, int IOPportnum) {
int portnum;
portnum = ((u->chassis - 1) * 64) + ((u->geoslot - 1) * 8) + IOPportnum + 1;
- sprintf(static_buf, "%d", portnum);
- return static_buf;
+ snprintf(buf, bufsize, "%s_%d", proto, portnum);
}
static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 iftype) {
@@ -419,36 +425,64 @@ static char *translate_IOP_to_pcap_name(unit_t *u, char *IOPname, bpf_u_int32 if
int IOPportnum = 0;
iface = malloc(sizeof(iface_t)); /* get memory for a structure */
- bzero((char *)iface, sizeof(iface_t));
+ if (iface == NULL) { /* oops, we didn't get the memory requested */
+ fprintf(stderr, "Error...couldn't allocate memory for interface structure...value of errno is: %d\n", errno);
+ return NULL;
+ }
+ memset((char *)iface, 0, sizeof(iface_t)); /* bzero is deprecated(), replaced with memset() */
iface->iftype = iftype; /* remember the interface type of this interface */
name = malloc(strlen(IOPname) + 1); /* get memory for the IOP's name */
+ if (name == NULL) { /* oops, we didn't get the memory requested */
+ fprintf(stderr, "Error...couldn't allocate memory for IOPname...value of errno is: %d\n", errno);
+ return NULL;
+ }
+
strcpy(name, IOPname); /* and copy it in */
iface->IOPname = name; /* and stick it into the structure */
if (strncmp(IOPname, "lo", 2) == 0) {
IOPportnum = atoi(&IOPname[2]);
switch (iftype) {
- case DLT_EN10MB: proto = "lo"; port = nonUnified_port_num(u, IOPportnum); break;
- default: proto = "???"; port = unified_port_num(u, IOPportnum); break;
+ case DLT_EN10MB:
+ nonUnified_IOP_port_name(buf, sizeof buf, "lo", u);
+ break;
+ default:
+ unified_IOP_port_name(buf, sizeof buf, "???", u, IOPportnum);
+ break;
}
} else if (strncmp(IOPname, "eth", 3) == 0) {
IOPportnum = atoi(&IOPname[3]);
switch (iftype) {
- case DLT_EN10MB: proto = "eth"; port = nonUnified_port_num(u, IOPportnum); break;
- default: proto = "???"; port = unified_port_num(u, IOPportnum); break;
+ case DLT_EN10MB:
+ nonUnified_IOP_port_name(buf, sizeof buf, "eth", u);
+ break;
+ default:
+ unified_IOP_port_name(buf, sizeof buf, "???", u, IOPportnum);
+ break;
}
} else if (strncmp(IOPname, "wan", 3) == 0) {
IOPportnum = atoi(&IOPname[3]);
switch (iftype) {
- case DLT_SITA: proto = "wan"; port = unified_port_num(u, IOPportnum); break;
- default: proto = "???"; port = unified_port_num(u, IOPportnum); break;
+ case DLT_SITA:
+ unified_IOP_port_name(buf, sizeof buf, "wan", u, IOPportnum);
+ break;
+ default:
+ unified_IOP_port_name(buf, sizeof buf, "???", u, IOPportnum);
+ break;
}
+ } else {
+ fprintf(stderr, "Error... invalid IOP name %s\n", IOPname);
+ return NULL;
}
- sprintf(buf, "%s_%s", proto, port); /* compose the user's name for that IOP port name */
name = malloc(strlen(buf) + 1); /* get memory for that name */
+ if (name == NULL) { /* oops, we didn't get the memory requested */
+ fprintf(stderr, "Error...couldn't allocate memory for IOP port name...value of errno is: %d\n", errno);
+ return NULL;
+ }
+
strcpy(name, buf); /* and copy it in */
iface->name = name; /* and stick it into the structure */
@@ -550,7 +584,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)iff, sizeof(pcap_if_t));
+ memset((char *)iff, 0, sizeof(pcap_if_t)); /* bzero() is deprecated, replaced with memset() */
if (acn_if_list == 0) acn_if_list = iff; /* remember the head of the list */
if (prev_iff) prev_iff->next = iff; /* insert a forward link */
@@ -590,7 +624,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)addr, sizeof(pcap_addr_t));
++ memset((char *)addr, 0, sizeof(pcap_addr_t)); /* bzero() is deprecated, replaced with memset() */
if (iff->addresses == 0) iff->addresses = addr;
if (prev_addr) prev_addr->next = addr; /* insert a forward link */
if (*ptr) { /* if there is a count for the address */
@@ -598,7 +632,7 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)s, sizeof(struct sockaddr_in));
+ memset((char *)s, 0, sizeof(struct sockaddr_in)); /* bzero() is deprecated, replaced with memset() */
addr->addr = (struct sockaddr *)s;
s->sin_family = AF_INET;
s->sin_addr.s_addr = *(bpf_u_int32 *)(ptr + 1); /* copy the address in */
@@ -610,7 +644,9 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)s, sizeof(struct sockaddr_in));
+ /* bzero() is deprecated, replaced with memset() */
+ memset((char *)s, 0, sizeof(struct sockaddr_in));
+
addr->netmask = (struct sockaddr *)s;
s->sin_family = AF_INET;
s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
@@ -622,7 +658,9 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)s, sizeof(struct sockaddr_in));
+ /* bzero() is deprecated, replaced with memset() */
+ memset((char *)s, 0, sizeof(struct sockaddr_in));
+
addr->broadaddr = (struct sockaddr *)s;
s->sin_family = AF_INET;
s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
@@ -634,7 +672,9 @@ static int process_client_data (char *errbuf) { /* returns: -1 = error, 0
snprintf(errbuf, PCAP_ERRBUF_SIZE, "malloc: %s", pcap_strerror(errno));
return -1;
}
- bzero((char *)s, sizeof(struct sockaddr_in));
+ /* bzero() is deprecated, replaced with memset() */
+ memset((char *)s, 0, sizeof(struct sockaddr_in));
+
addr->dstaddr = (struct sockaddr *)s;
s->sin_family = AF_INET;
s->sin_addr.s_addr = *(bpf_u_int32*)(ptr + 1);
@@ -685,6 +725,8 @@ static void wait_for_all_answers(void) {
while (1) {
int flag = 0;
+ fd_set working_set;
+
for (fd = 0; fd <= max_fs; fd++) { /* scan the list of descriptors we may be listening to */
if (FD_ISSET(fd, &readfds)) flag = 1; /* and see if there are any still set */
}
@@ -778,7 +820,7 @@ static int acn_open_live(const char *name, char *errbuf, int *linktype) { /* re
iface_t *p;
pcap_if_t *alldevsp;
- pcap_findalldevs(&alldevsp, errbuf);
+ pcap_findalldevs_interfaces(&alldevsp, errbuf);
for (chassis = 0; chassis <= MAX_CHASSIS; chassis++) { /* scan the table... */
for (geoslot = 0; geoslot <= MAX_GEOSLOT; geoslot++) {
u = &units[chassis][geoslot];
@@ -902,7 +944,7 @@ static int pcap_read_acn(pcap_t *handle, int max_packets, pcap_handler callback,
struct pcap_pkthdr pcap_header;
//printf("pcap_read_acn()\n"); // fulko
- acn_start_monitor(handle->fd, handle->snapshot, handle->md.timeout, handle->md.clear_promisc, handle->direction); /* maybe tell him to start monitoring */
+ acn_start_monitor(handle->fd, handle->snapshot, handle->opt.timeout, handle->opt.promisc, handle->direction); /* maybe tell him to start monitoring */
//printf("pcap_read_acn() after start monitor\n"); // fulko
handle->bp = packet_header;
@@ -947,7 +989,6 @@ static int pcap_activate_sita(pcap_t *handle) {
&handle->linktype);
if (fd == -1)
return PCAP_ERROR;
- handle->md.clear_promisc = handle->md.promisc;
handle->fd = fd;
handle->bufsize = handle->snapshot;
@@ -970,10 +1011,10 @@ static int pcap_activate_sita(pcap_t *handle) {
return 0;
}
-pcap_t *pcap_create(const char *device, char *ebuf) {
+pcap_t *pcap_create_interface(const char *device, char *ebuf) {
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, 0);
if (p == NULL)
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-snf.c b/external/bsd/libpcap/dist/pcap-snf.c
index f26253d6774..b1b524676b1 100644
--- a/external/bsd/libpcap/dist/pcap-snf.c
+++ b/external/bsd/libpcap/dist/pcap-snf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-snf.c,v 1.1.1.2 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-snf.c,v 1.1.1.3 2013/12/31 16:57:23 christos Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -17,13 +17,20 @@
#include <sys/types.h>
#include <unistd.h>
-#include "snf.h"
-#include "pcap-int.h"
+#include <snf.h>
-#ifdef SNF_ONLY
-#define snf_create pcap_create
-#define snf_platform_finddevs pcap_platform_finddevs
-#endif
+#include "pcap-int.h"
+#include "pcap-snf.h"
+
+/*
+ * Private data for capturing on SNF devices.
+ */
+struct pcap_snf {
+ snf_handle_t snf_handle; /* opaque device handle */
+ snf_ring_t snf_ring; /* opaque device ring handle */
+ int snf_timeout;
+ int snf_boardnum;
+};
static int
snf_set_datalink(pcap_t *p, int dlt)
@@ -38,7 +45,7 @@ snf_pcap_stats(pcap_t *p, struct pcap_stat *ps)
struct snf_ring_stats stats;
int rc;
- if ((rc = snf_ring_getstats(p->md.snf_ring, &stats))) {
+ if ((rc = snf_ring_getstats(ps->snf_ring, &stats))) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snf_get_stats: %s",
pcap_strerror(rc));
return -1;
@@ -52,30 +59,36 @@ snf_pcap_stats(pcap_t *p, struct pcap_stat *ps)
static void
snf_platform_cleanup(pcap_t *p)
{
+ struct pcap_snf *ps = p->priv;
+
if (p == NULL)
return;
- snf_ring_close(p->md.snf_ring);
- snf_close(p->md.snf_handle);
+ snf_ring_close(ps->snf_ring);
+ snf_close(ps->snf_handle);
pcap_cleanup_live_common(p);
}
static int
snf_getnonblock(pcap_t *p, char *errbuf)
{
- return (p->md.snf_timeout == 0);
+ struct pcap_snf *ps = p->priv;
+
+ return (ps->snf_timeout == 0);
}
static int
snf_setnonblock(pcap_t *p, int nonblock, char *errbuf)
{
+ struct pcap_snf *ps = p->priv;
+
if (nonblock)
- p->md.snf_timeout = 0;
+ ps->snf_timeout = 0;
else {
- if (p->md.timeout <= 0)
- p->md.snf_timeout = -1; /* forever */
+ if (p->opt.timeout <= 0)
+ ps->snf_timeout = -1; /* forever */
else
- p->md.snf_timeout = p->md.timeout;
+ ps->snf_timeout = p->opt.timeout;
}
return (0);
}
@@ -98,6 +111,7 @@ snf_timestamp_to_timeval(const int64_t ts_nanosec)
static int
snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_snf *ps = p->priv;
struct pcap_pkthdr hdr;
int i, flags, err, caplen, n;
struct snf_recv_req req;
@@ -119,7 +133,7 @@ snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
}
- err = snf_ring_recv(p->md.snf_ring, p->md.snf_timeout, &req);
+ err = snf_ring_recv(ps->snf_ring, ps->snf_timeout, &req);
if (err) {
if (err == EBUSY || err == EAGAIN)
@@ -165,8 +179,6 @@ snf_setfilter(pcap_t *p, struct bpf_program *fp)
if (install_bpf_program(p, fp) < 0)
return -1;
- p->md.use_bpf = 0;
-
return (0);
}
@@ -181,6 +193,7 @@ snf_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
static int
snf_activate(pcap_t* p)
{
+ struct pcap_snf *ps = p->priv;
char *device = p->opt.source;
const char *nr = NULL;
int err;
@@ -199,31 +212,31 @@ snf_activate(pcap_t* p)
else
nr = NULL;
- err = snf_open(p->md.snf_boardnum,
+ err = snf_open(ps->snf_boardnum,
0, /* let SNF API parse SNF_NUM_RINGS, if set */
NULL, /* default RSS, or use SNF_RSS_FLAGS env */
0, /* default to SNF_DATARING_SIZE from env */
flags, /* may want pshared */
- &p->md.snf_handle);
+ &ps->snf_handle);
if (err != 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"snf_open failed: %s", pcap_strerror(err));
return -1;
}
- err = snf_ring_open(p->md.snf_handle, &p->md.snf_ring);
+ err = snf_ring_open(ps->snf_handle, &ps->snf_ring);
if (err != 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"snf_ring_open failed: %s", pcap_strerror(err));
return -1;
}
- if (p->md.timeout <= 0)
- p->md.snf_timeout = -1;
+ if (p->opt.timeout <= 0)
+ ps->snf_timeout = -1;
else
- p->md.snf_timeout = p->md.timeout;
+ ps->snf_timeout = p->opt.timeout;
- err = snf_start(p->md.snf_handle);
+ err = snf_start(ps->snf_handle);
if (err != 0) {
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
"snf_start failed: %s", pcap_strerror(err));
@@ -244,14 +257,11 @@ snf_activate(pcap_t* p)
p->setnonblock_op = snf_setnonblock;
p->stats_op = snf_pcap_stats;
p->cleanup_op = snf_platform_cleanup;
- p->md.stat.ps_recv = 0;
- p->md.stat.ps_drop = 0;
- p->md.stat.ps_ifdrop = 0;
return 0;
}
int
-snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
+snf_findalldevs(pcap_if_t **devlistp, char *errbuf)
{
/*
* There are no platform-specific devices since each device
@@ -261,22 +271,29 @@ snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
}
pcap_t *
-snf_create(const char *device, char *ebuf)
+snf_create(const char *device, char *ebuf, int *is_ours)
{
pcap_t *p;
int boardnum = -1;
struct snf_ifaddrs *ifaddrs, *ifa;
size_t devlen;
+ struct pcap_snf *ps;
- if (snf_init(SNF_VERSION_API))
+ if (snf_init(SNF_VERSION_API)) {
+ /* Can't initialize the API, so no SNF devices */
+ *is_ours = 0;
return NULL;
+ }
/*
* Match a given interface name to our list of interface names, from
* which we can obtain the intended board number
*/
- if (snf_getifaddrs(&ifaddrs) || ifaddrs == NULL)
+ if (snf_getifaddrs(&ifaddrs) || ifaddrs == NULL) {
+ /* Can't get SNF addresses */
+ *is_ours = 0;
return NULL;
+ }
devlen = strlen(device) + 1;
ifa = ifaddrs;
while (ifa) {
@@ -294,15 +311,22 @@ snf_create(const char *device, char *ebuf)
* and "snf10gX" where X is the board number.
*/
if (sscanf(device, "snf10g%d", &boardnum) != 1 &&
- sscanf(device, "snf%d", &boardnum) != 1)
+ sscanf(device, "snf%d", &boardnum) != 1) {
+ /* Nope, not a supported name */
+ *is_ours = 0;
return NULL;
+ }
}
- p = pcap_create_common(device, ebuf);
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_snf));
if (p == NULL)
return NULL;
+ ps = p->priv;
p->activate_op = snf_activate;
- p->md.snf_boardnum = boardnum;
+ ps->snf_boardnum = boardnum;
return p;
}
diff --git a/external/bsd/libpcap/dist/pcap-snf.h b/external/bsd/libpcap/dist/pcap-snf.h
index c8242807b97..4e9fb0a66e4 100644
--- a/external/bsd/libpcap/dist/pcap-snf.h
+++ b/external/bsd/libpcap/dist/pcap-snf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-snf.h,v 1.1.1.2 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-snf.h,v 1.1.1.3 2013/12/31 16:57:20 christos Exp $ */
-pcap_t *snf_create(const char *, char *);
-int snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf);
+pcap_t *snf_create(const char *, char *, int *);
+int snf_findalldevs(pcap_if_t **devlistp, char *errbuf);
diff --git a/external/bsd/libpcap/dist/pcap-snit.c b/external/bsd/libpcap/dist/pcap-snit.c
index e43c3077325..a8548061503 100644
--- a/external/bsd/libpcap/dist/pcap-snit.c
+++ b/external/bsd/libpcap/dist/pcap-snit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-snit.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-snit.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996
@@ -86,9 +86,17 @@ static const char rcsid[] _U_ =
/* Forwards */
static int nit_setflags(int, int, int, char *);
+/*
+ * Private data for capturing on STREAMS NIT devices.
+ */
+struct pcap_snit {
+ struct pcap_stat stat;
+};
+
static int
pcap_stats_snit(pcap_t *p, struct pcap_stat *ps)
{
+ struct pcap_snit *psn = p->priv;
/*
* "ps_recv" counts packets handed to the filter, not packets
@@ -107,13 +115,14 @@ pcap_stats_snit(pcap_t *p, struct pcap_stat *ps)
* kernel by libpcap or packets not yet read from libpcap by the
* application.
*/
- *ps = p->md.stat;
+ *ps = psn->stat;
return (0);
}
static int
pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_snit *psn = p->priv;
register int cc, n;
register u_char *bp, *cp, *ep;
register struct nit_bufhdr *hdrp;
@@ -162,7 +171,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
}
}
- ++p->md.stat.ps_recv;
+ ++psn->stat.ps_recv;
cp = bp;
/* get past NIT buffer */
@@ -174,7 +183,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
cp += sizeof(*ntp);
ndp = (struct nit_ifdrops *)cp;
- p->md.stat.ps_drop = ndp->nh_drops;
+ psn->stat.ps_drop = ndp->nh_drops;
cp += sizeof *ndp;
/* get past packet len */
@@ -229,33 +238,48 @@ pcap_inject_snit(pcap_t *p, const void *buf, size_t size)
}
static int
-nit_setflags(int fd, int promisc, int to_ms, char *ebuf)
+nit_setflags(pcap_t *p)
{
bpf_u_int32 flags;
struct strioctl si;
+ u_int zero = 0;
struct timeval timeout;
+ if (p->opt.immediate) {
+ /*
+ * Set the chunk size to zero, so that chunks get sent
+ * up immediately.
+ */
+ si.ic_cmd = NIOCSCHUNK;
+ si.ic_len = sizeof(zero);
+ si.ic_dp = (char *)&zero;
+ if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "NIOCSCHUNK: %s",
+ pcap_strerror(errno));
+ return (-1);
+ }
+ }
si.ic_timout = INFTIM;
- if (to_ms != 0) {
- timeout.tv_sec = to_ms / 1000;
- timeout.tv_usec = (to_ms * 1000) % 1000000;
+ if (p->opt.timeout != 0) {
+ timeout.tv_sec = p->opt.timeout / 1000;
+ timeout.tv_usec = (p->opt.timeout * 1000) % 1000000;
si.ic_cmd = NIOCSTIME;
si.ic_len = sizeof(timeout);
si.ic_dp = (char *)&timeout;
- if (ioctl(fd, I_STR, (char *)&si) < 0) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSTIME: %s",
+ if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "NIOCSTIME: %s",
pcap_strerror(errno));
return (-1);
}
}
flags = NI_TIMESTAMP | NI_LEN | NI_DROPS;
- if (promisc)
+ if (p->opt.promisc)
flags |= NI_PROMISC;
si.ic_cmd = NIOCSFLAGS;
si.ic_len = sizeof(flags);
si.ic_dp = (char *)&flags;
- if (ioctl(fd, I_STR, (char *)&si) < 0) {
- snprintf(ebuf, PCAP_ERRBUF_SIZE, "NIOCSFLAGS: %s",
+ if (ioctl(p->fd, I_STR, (char *)&si) < 0) {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "NIOCSFLAGS: %s",
pcap_strerror(errno));
return (-1);
}
@@ -351,7 +375,7 @@ pcap_activate_snit(pcap_t *p)
pcap_strerror(errno));
goto bad;
}
- if (nit_setflags(p->fd, p->opt.promisc, p->md.timeout, p->errbuf) < 0)
+ if (nit_setflags(p) < 0)
goto bad;
(void)ioctl(fd, I_FLUSH, (char *)FLUSHR);
@@ -409,11 +433,11 @@ pcap_activate_snit(pcap_t *p)
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_snit));
if (p == NULL)
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-snoop.c b/external/bsd/libpcap/dist/pcap-snoop.c
index 46f9cc66cf4..f1822454eec 100644
--- a/external/bsd/libpcap/dist/pcap-snoop.c
+++ b/external/bsd/libpcap/dist/pcap-snoop.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-snoop.c,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-snoop.c,v 1.1.1.4 2013/12/31 16:57:20 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -60,9 +60,17 @@ static const char rcsid[] _U_ =
#include "os-proto.h"
#endif
+/*
+ * Private data for capturing on snoop devices.
+ */
+struct pcap_snoop {
+ struct pcap_stat stat;
+};
+
static int
pcap_read_snoop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_snoop *psn = p->priv;
int cc;
register struct snoopheader *sh;
register u_int datalen;
@@ -126,7 +134,7 @@ again:
if (p->fcode.bf_insns == NULL ||
bpf_filter(p->fcode.bf_insns, cp, datalen, caplen)) {
struct pcap_pkthdr h;
- ++p->md.stat.ps_recv;
+ ++psn->stat.ps_recv;
h.ts.tv_sec = sh->snoop_timestamp.tv_sec;
h.ts.tv_usec = sh->snoop_timestamp.tv_usec;
h.len = datalen;
@@ -158,6 +166,7 @@ pcap_inject_snoop(pcap_t *p, const void *buf, size_t size)
static int
pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
{
+ struct pcap_snoop *psn = p->priv;
register struct rawstats *rs;
struct rawstats rawstats;
@@ -182,7 +191,7 @@ pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
* rather than just this socket? If not, why does it have
* both Snoop and Drain statistics?
*/
- p->md.stat.ps_drop =
+ psn->stat.ps_drop =
rs->rs_snoop.ss_ifdrops + rs->rs_snoop.ss_sbdrops +
rs->rs_drain.ds_ifdrops + rs->rs_drain.ds_sbdrops;
@@ -191,7 +200,7 @@ pcap_stats_snoop(pcap_t *p, struct pcap_stat *ps)
* As filtering is done in userland, this does not include
* packets dropped because we ran out of buffer space.
*/
- *ps = p->md.stat;
+ *ps = psn->stat;
return (0);
}
@@ -396,11 +405,11 @@ pcap_activate_snoop(pcap_t *p)
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_snoop));
if (p == NULL)
return (NULL);
diff --git a/external/bsd/libpcap/dist/pcap-usb-linux.c b/external/bsd/libpcap/dist/pcap-usb-linux.c
index e4d746ba7bf..fe2a470f258 100644
--- a/external/bsd/libpcap/dist/pcap-usb-linux.c
+++ b/external/bsd/libpcap/dist/pcap-usb-linux.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-usb-linux.c,v 1.1.1.3 2013/04/06 15:57:49 christos Exp $ */
+/* $NetBSD: pcap-usb-linux.c,v 1.1.1.4 2013/12/31 16:57:24 christos Exp $ */
/*
* Copyright (c) 2006 Paolo Abeni (Italy)
@@ -123,6 +123,16 @@ struct mon_bin_mfetch {
#define MON_BIN_DATA_ZERO 0x4 /* data buffer is not available */
#define MON_BIN_ERROR 0x8
+/*
+ * Private data for capturing on Linux USB.
+ */
+struct pcap_usb_linux {
+ u_char *mmapbuf; /* memory-mapped region pointer */
+ size_t mmapbuflen; /* size of region */
+ int bus_index;
+ u_int packets_read;
+};
+
/* forward declaration */
static int usb_activate(pcap_t *);
static int usb_stats_linux(pcap_t *, struct pcap_stat *);
@@ -150,7 +160,7 @@ usb_dev_add(pcap_if_t** alldevsp, int n, char *err_str)
}
int
-usb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
+usb_findalldevs(pcap_if_t **alldevsp, char *err_str)
{
struct dirent* data;
int ret = 0;
@@ -206,14 +216,15 @@ usb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
static
int usb_mmap(pcap_t* handle)
{
+ struct pcap_usb_linux *handlep = handle->priv;
int len = ioctl(handle->fd, MON_IOCQ_RING_SIZE);
if (len < 0)
return 0;
- handle->md.mmapbuflen = len;
- handle->md.mmapbuf = mmap(0, handle->md.mmapbuflen, PROT_READ,
+ handlep->mmapbuflen = len;
+ handlep->mmapbuf = mmap(0, handlep->mmapbuflen, PROT_READ,
MAP_SHARED, handle->fd, 0);
- return handle->md.mmapbuf != MAP_FAILED;
+ return handlep->mmapbuf != MAP_FAILED;
}
#define CTRL_TIMEOUT (5*1000) /* milliseconds */
@@ -286,11 +297,41 @@ probe_devices(int bus)
}
pcap_t *
-usb_create(const char *device, char *ebuf)
+usb_create(const char *device, char *ebuf, int *is_ours)
{
+ const char *cp;
+ char *cpend;
+ long devnum;
pcap_t *p;
- p = pcap_create_common(device, ebuf);
+ /* Does this look like a USB monitoring device? */
+ cp = strrchr(device, '/');
+ if (cp == NULL)
+ cp = device;
+ /* Does it begin with USB_IFACE? */
+ if (strncmp(cp, USB_IFACE, sizeof USB_IFACE - 1) != 0) {
+ /* Nope, doesn't begin with USB_IFACE */
+ *is_ours = 0;
+ return NULL;
+ }
+ /* Yes - is USB_IFACE followed by a number? */
+ cp += sizeof USB_IFACE - 1;
+ devnum = strtol(cp, &cpend, 10);
+ if (cpend == cp || *cpend != '\0') {
+ /* Not followed by a number. */
+ *is_ours = 0;
+ return NULL;
+ }
+ if (devnum < 0) {
+ /* Followed by a non-valid number. */
+ *is_ours = 0;
+ return NULL;
+ }
+
+ /* OK, it's probably ours. */
+ *is_ours = 1;
+
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_usb_linux));
if (p == NULL)
return (NULL);
@@ -301,6 +342,7 @@ usb_create(const char *device, char *ebuf)
static int
usb_activate(pcap_t* handle)
{
+ struct pcap_usb_linux *handlep = handle->priv;
char full_path[USB_LINE_LEN];
/* Initialize some components of the pcap structure. */
@@ -316,7 +358,7 @@ usb_activate(pcap_t* handle)
handle->setnonblock_op = pcap_setnonblock_fd;
/*get usb bus index from device name */
- if (sscanf(handle->opt.source, USB_IFACE"%d", &handle->md.ifindex) != 1)
+ if (sscanf(handle->opt.source, USB_IFACE"%d", &handlep->bus_index) != 1)
{
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
"Can't get USB bus index from %s", handle->opt.source);
@@ -324,7 +366,7 @@ usb_activate(pcap_t* handle)
}
/*now select the read method: try to open binary interface */
- snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handle->md.ifindex);
+ snprintf(full_path, USB_LINE_LEN, LINUX_USB_MON_DEV"%d", handlep->bus_index);
handle->fd = open(full_path, O_RDONLY, 0);
if (handle->fd >= 0)
{
@@ -342,7 +384,7 @@ usb_activate(pcap_t* handle)
handle->stats_op = usb_stats_linux_bin;
handle->read_op = usb_read_linux_mmap;
handle->cleanup_op = usb_cleanup_linux_mmap;
- probe_devices(handle->md.ifindex);
+ probe_devices(handlep->bus_index);
/*
* "handle->fd" is a real file, so "select()" and
@@ -355,11 +397,11 @@ usb_activate(pcap_t* handle)
/* can't mmap, use plain binary interface access */
handle->stats_op = usb_stats_linux_bin;
handle->read_op = usb_read_linux_bin;
- probe_devices(handle->md.ifindex);
+ probe_devices(handlep->bus_index);
}
else {
/*Binary interface not available, try open text interface */
- snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR"/%dt", handle->md.ifindex);
+ snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR"/%dt", handlep->bus_index);
handle->fd = open(full_path, O_RDONLY, 0);
if (handle->fd < 0)
{
@@ -369,7 +411,7 @@ usb_activate(pcap_t* handle)
* Not found at the new location; try
* the old location.
*/
- snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex);
+ snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handlep->bus_index);
handle->fd = open(full_path, O_RDONLY, 0);
}
if (handle->fd < 0) {
@@ -428,6 +470,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
* /usr/src/linux/Documentation/usb/usbmon.txt
* for message format
*/
+ struct pcap_usb_linux *handlep = handle->priv;
unsigned timestamp;
int tag, cnt, ep_num, dev_addr, dummy, ret, urb_len, data_len;
char etype, pipeid1, pipeid2, status[16], urb_tag, line[USB_LINE_LEN];
@@ -472,7 +515,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
}
uhdr->id = tag;
uhdr->device_address = dev_addr;
- uhdr->bus_id = handle->md.ifindex;
+ uhdr->bus_id = handlep->bus_index;
uhdr->status = 0;
string += cnt;
@@ -611,7 +654,7 @@ got:
if (handle->fcode.bf_insns == NULL ||
bpf_filter(handle->fcode.bf_insns, handle->buffer,
pkth.len, pkth.caplen)) {
- handle->md.packets_read++;
+ handlep->packets_read++;
callback(user, &pkth, handle->buffer);
return 1;
}
@@ -629,13 +672,14 @@ usb_inject_linux(pcap_t *handle, const void *buf, size_t size)
static int
usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
{
+ struct pcap_usb_linux *handlep = handle->priv;
int dummy, ret, consumed, cnt;
char string[USB_LINE_LEN];
char token[USB_LINE_LEN];
char * ptr = string;
int fd;
- snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
+ snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handlep->bus_index);
fd = open(string, O_RDONLY, 0);
if (fd < 0)
{
@@ -645,7 +689,7 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
* Not found at the new location; try the old
* location.
*/
- snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex);
+ snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handlep->bus_index);
fd = open(string, O_RDONLY, 0);
}
if (fd < 0) {
@@ -696,7 +740,7 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
ptr += cnt;
}
- stats->ps_recv = handle->md.packets_read;
+ stats->ps_recv = handlep->packets_read;
stats->ps_ifdrop = 0;
return 0;
}
@@ -712,6 +756,7 @@ usb_setdirection_linux(pcap_t *p, pcap_direction_t d)
static int
usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
{
+ struct pcap_usb_linux *handlep = handle->priv;
int ret;
struct mon_bin_stats st;
ret = ioctl(handle->fd, MON_IOCG_STATS, &st);
@@ -722,7 +767,7 @@ usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
return -1;
}
- stats->ps_recv = handle->md.packets_read + st.queued;
+ stats->ps_recv = handlep->packets_read + st.queued;
stats->ps_drop = st.dropped;
stats->ps_ifdrop = 0;
return 0;
@@ -735,6 +780,7 @@ usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
static int
usb_read_linux_bin(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
{
+ struct pcap_usb_linux *handlep = handle->priv;
struct mon_bin_get info;
int ret;
struct pcap_pkthdr pkth;
@@ -777,7 +823,7 @@ usb_read_linux_bin(pcap_t *handle, int max_packets, pcap_handler callback, u_cha
if (handle->fcode.bf_insns == NULL ||
bpf_filter(handle->fcode.bf_insns, handle->buffer,
pkth.len, pkth.caplen)) {
- handle->md.packets_read++;
+ handlep->packets_read++;
callback(user, &pkth, handle->buffer);
return 1;
}
@@ -793,6 +839,7 @@ usb_read_linux_bin(pcap_t *handle, int max_packets, pcap_handler callback, u_cha
static int
usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
{
+ struct pcap_usb_linux *handlep = handle->priv;
struct mon_bin_mfetch fetch;
int32_t vec[VEC_SIZE];
struct pcap_pkthdr pkth;
@@ -838,7 +885,7 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
nflush = fetch.nfetch;
for (i=0; i<fetch.nfetch; ++i) {
/* discard filler */
- hdr = (pcap_usb_header*) &handle->md.mmapbuf[vec[i]];
+ hdr = (pcap_usb_header*) &handlep->mmapbuf[vec[i]];
if (hdr->event_type == '@')
continue;
@@ -857,7 +904,7 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
if (handle->fcode.bf_insns == NULL ||
bpf_filter(handle->fcode.bf_insns, (u_char*) hdr,
pkth.len, pkth.caplen)) {
- handle->md.packets_read++;
+ handlep->packets_read++;
callback(user, &pkth, (u_char*) hdr);
packets++;
}
@@ -876,10 +923,12 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
static void
usb_cleanup_linux_mmap(pcap_t* handle)
{
+ struct pcap_usb_linux *handlep = handle->priv;
+
/* if we have a memory-mapped buffer, unmap it */
- if (handle->md.mmapbuf != NULL) {
- munmap(handle->md.mmapbuf, handle->md.mmapbuflen);
- handle->md.mmapbuf = NULL;
+ if (handlep->mmapbuf != NULL) {
+ munmap(handlep->mmapbuf, handlep->mmapbuflen);
+ handlep->mmapbuf = NULL;
}
pcap_cleanup_live_common(handle);
}
diff --git a/external/bsd/libpcap/dist/pcap-usb-linux.h b/external/bsd/libpcap/dist/pcap-usb-linux.h
index 6a3841bb13b..d1f95745276 100644
--- a/external/bsd/libpcap/dist/pcap-usb-linux.h
+++ b/external/bsd/libpcap/dist/pcap-usb-linux.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-usb-linux.h,v 1.1.1.3 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: pcap-usb-linux.h,v 1.1.1.4 2013/12/31 16:57:25 christos Exp $ */
/*
* Copyright (c) 2006 Paolo Abeni (Italy)
@@ -38,5 +38,5 @@
/*
* Prototypes for USB-related functions
*/
-int usb_platform_finddevs(pcap_if_t **alldevsp, char *err_str);
-pcap_t *usb_create(const char *device, char *ebuf);
+int usb_findalldevs(pcap_if_t **alldevsp, char *err_str);
+pcap_t *usb_create(const char *device, char *ebuf, int *is_ours);
diff --git a/external/bsd/libpcap/dist/pcap-win32.c b/external/bsd/libpcap/dist/pcap-win32.c
index 2c728867402..6470cec3496 100644
--- a/external/bsd/libpcap/dist/pcap-win32.c
+++ b/external/bsd/libpcap/dist/pcap-win32.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pcap-win32.c,v 1.1.1.3 2013/04/06 15:57:45 christos Exp $ */
+/* $NetBSD: pcap-win32.c,v 1.1.1.4 2013/12/31 16:57:21 christos Exp $ */
/*
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
@@ -74,6 +74,17 @@ static int pcap_setnonblock_win32(pcap_t *, int, char *);
#define SWAPS(_X) ((_X & 0xff) << 8) | (_X >> 8)
/*
+ * Private data for capturing on WinPcap devices.
+ */
+struct pcap_win {
+ int nonblock;
+
+#ifdef HAVE_DAG_API
+ int dag_fcs_bits; /* Number of checksum bits from link layer */
+#endif
+};
+
+/*
* Header that the WinPcap driver associates to the packets.
* Once was in bpf.h
*/
@@ -167,6 +178,13 @@ pcap_setmintocopy_win32(pcap_t *p, int size)
return 0;
}
+/*return the Adapter for a pcap_t*/
+static Adapter *
+pcap_getadapter_win32(pcap_t *p)
+{
+ return p->adapter;
+}
+
static int
pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
@@ -255,6 +273,7 @@ pcap_read_win32_npf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
static int
pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
{
+ struct pcap_win *pw = p->priv;
u_char *dp = NULL;
int packet_len = 0, caplen = 0;
struct pcap_pkthdr pcap_header;
@@ -297,7 +316,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
break;
/* Increase the number of captured packets */
- p->md.stat.ps_recv++;
+ pw->stat.ps_recv++;
/* Find the beginning of the packet */
dp = ((u_char *)header) + dag_record_size;
@@ -314,7 +333,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case TYPE_ETH:
swt = SWAPS(header->wlen);
- packet_len = swt - (p->md.dag_fcs_bits);
+ packet_len = swt - (pw->dag_fcs_bits);
caplen = erf_record_len - dag_record_size - 2;
if (caplen > packet_len)
{
@@ -326,7 +345,7 @@ pcap_read_win32_dag(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
case TYPE_HDLC_POS:
swt = SWAPS(header->wlen);
- packet_len = swt - (p->md.dag_fcs_bits);
+ packet_len = swt - (pw->dag_fcs_bits);
caplen = erf_record_len - dag_record_size;
if (caplen > packet_len)
{
@@ -459,6 +478,7 @@ pcap_cleanup_win32(pcap_t *p)
static int
pcap_activate_win32(pcap_t *p)
{
+ struct pcap_win *pw = p->priv;
NetType type;
if (p->opt.rfmon) {
@@ -624,11 +644,23 @@ pcap_activate_win32(pcap_t *p)
PacketInitPacket(p->Packet,(BYTE*)p->buffer,p->bufsize);
- /* tell the driver to copy the buffer only if it contains at least 16K */
- if(PacketSetMinToCopy(p->adapter,16000)==FALSE)
+ if (p-opt.immediate)
{
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,"Error calling PacketSetMinToCopy: %s", pcap_win32strerror());
- goto bad;
+ /* tell the driver to copy the buffer as soon as data arrives */
+ if(PacketSetMinToCopy(p->adapter,0)==FALSE)
+ {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,"Error calling PacketSetMinToCopy: %s", pcap_win32strerror());
+ goto bad;
+ }
+ }
+ else
+ {
+ /* tell the driver to copy the buffer only if it contains at least 16K */
+ if(PacketSetMinToCopy(p->adapter,16000)==FALSE)
+ {
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,"Error calling PacketSetMinToCopy: %s", pcap_win32strerror());
+ goto bad;
+ }
}
}
else
@@ -674,13 +706,13 @@ pcap_activate_win32(pcap_t *p)
/* Set the length of the FCS associated to any packet. This value
* will be subtracted to the packet length */
- p->md.dag_fcs_bits = p->adapter->DagFcsLen;
+ pw->dag_fcs_bits = p->adapter->DagFcsLen;
}
#else
goto bad;
#endif /* HAVE_DAG_API */
- PacketSetReadTimeout(p->adapter, p->md.timeout);
+ PacketSetReadTimeout(p->adapter, p->opt.timeout);
#ifdef HAVE_DAG_API
if(p->adapter->Flags & INFO_FLAG_DAG_CARD)
@@ -708,6 +740,7 @@ pcap_activate_win32(pcap_t *p)
p->setbuff_op = pcap_setbuff_win32;
p->setmode_op = pcap_setmode_win32;
p->setmintocopy_op = pcap_setmintocopy_win32;
+ p->getadapter_op = pcap_getadapter_win32;
p->cleanup_op = pcap_cleanup_win32;
return (0);
@@ -717,7 +750,7 @@ bad:
}
pcap_t *
-pcap_create(const char *device, char *ebuf)
+pcap_create_interface(const char *device, char *ebuf)
{
pcap_t *p;
@@ -745,12 +778,12 @@ pcap_create(const char *device, char *ebuf)
}
snprintf(deviceAscii, length + 1, "%ws", (wchar_t*)device);
- p = pcap_create_common(deviceAscii, ebuf);
+ p = pcap_create_common(deviceAscii, ebuf, sizeof (struct pcap_win));
free(deviceAscii);
}
else
{
- p = pcap_create_common(device, ebuf);
+ p = pcap_create_common(device, ebuf, sizeof (struct pcap_win));
}
if (p == NULL)
@@ -803,25 +836,26 @@ pcap_setfilter_win32_dag(pcap_t *p, struct bpf_program *fp) {
return -1;
}
- p->md.use_bpf = 0;
-
return (0);
}
static int
pcap_getnonblock_win32(pcap_t *p, char *errbuf)
{
+ struct pcap_win *pw = p->priv;
+
/*
* XXX - if there were a PacketGetReadTimeout() call, we
* would use it, and return 1 if the timeout is -1
* and 0 otherwise.
*/
- return (p->nonblock);
+ return (pw->nonblock);
}
static int
pcap_setnonblock_win32(pcap_t *p, int nonblock, char *errbuf)
{
+ struct pcap_win *pw = p->priv;
int newtimeout;
if (nonblock) {
@@ -835,14 +869,14 @@ pcap_setnonblock_win32(pcap_t *p, int nonblock, char *errbuf)
* (Note that this may be -1, in which case we're not
* really leaving non-blocking mode.)
*/
- newtimeout = p->md.timeout;
+ newtimeout = p->opt.timeout;
}
if (!PacketSetReadTimeout(p->adapter, newtimeout)) {
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ snprintf(errbuf, PCAP_ERRBUF_SIZE,
"PacketSetReadTimeout: %s", pcap_win32strerror());
return (-1);
}
- p->nonblock = (newtimeout == -1);
+ pw->nonblock = (newtimeout == -1);
return (0);
}
diff --git a/external/bsd/libpcap/dist/pcap_breakloop.3pcap b/external/bsd/libpcap/dist/pcap_breakloop.3pcap
index 93a2834da57..83203b50abf 100644
--- a/external/bsd/libpcap/dist/pcap_breakloop.3pcap
+++ b/external/bsd/libpcap/dist/pcap_breakloop.3pcap
@@ -58,20 +58,15 @@ if the signal interrupted a call reading packets in a live capture,
when your signal handler returns after calling pcap_breakloop(), the
call will be restarted, and the loop will not terminate until more
packets arrive and the call completes.
+.ft R
.PP
+.ft B
Note also that, in a multi-threaded application, if one thread is
-blocked in
-.BR pcap_dispatch() ,
-.BR pcap_loop() ,
-.BR pcap_next() ,
-or
-.BR pcap_next_ex() ,
-a call to
-.B pcap_breakloop()
-in a different thread will not unblock that thread; you will need to use
-whatever mechanism the OS provides for breaking a thread out of blocking
-calls in order to unblock the thread, such as thread cancellation in
-systems that support POSIX threads.
+blocked in pcap_dispatch(), pcap_loop(), pcap_next(), or pcap_next_ex(),
+a call to pcap_breakloop() in a different thread will not unblock that
+thread; you will need to use whatever mechanism the OS provides for
+breaking a thread out of blocking calls in order to unblock the thread,
+such as thread cancellation in systems that support POSIX threads.
.ft R
.PP
Note that
diff --git a/external/bsd/libpcap/dist/pcap_datalink.3pcap.in b/external/bsd/libpcap/dist/pcap_datalink.3pcap.in
index 1f1f20f47ed..c37fa83daec 100644
--- a/external/bsd/libpcap/dist/pcap_datalink.3pcap.in
+++ b/external/bsd/libpcap/dist/pcap_datalink.3pcap.in
@@ -37,5 +37,34 @@ int pcap_datalink(pcap_t *p);
returns the link-layer header type for the live capture or ``savefile''
specified by
.IR p .
+.PP
+It must not be called on a pcap descriptor created by
+.B pcap_create()
+that has not yet been activated by
+.BR pcap_activate() .
+.PP
+.I http://www.tcpdump.org/linktypes.html
+lists the values
+.B pcap_datalink()
+can return and describes the packet formats that
+correspond to those values.
+.PP
+Do
+.B NOT
+assume that the packets for a given capture or ``savefile`` will have
+any given link-layer header type, such as
+.B DLT_EN10MB
+for Ethernet. For example, the "any" device on Linux will have a
+link-layer header type of
+.B DLT_LINUX_SLL
+even if all devices on the system at the time the "any" device is opened
+have some other data link type, such as
+.B DLT_EN10MB
+for Ethernet.
+.SH RETURN VALUE
+.B pcap_datalink()
+returns the link-layer header type on success and
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated.
.SH SEE ALSO
pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@)
diff --git a/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in b/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in
new file mode 100644
index 00000000000..7633a36ed98
--- /dev/null
+++ b/external/bsd/libpcap/dist/pcap_get_tstamp_precision.3pcap.in
@@ -0,0 +1,47 @@
+.\"Copyright (c) 2013, Michal Sekletar
+.\"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.
+.\" 3. The names of the authors may not be used to endorse or promote
+.\" products derived from this software without specific prior
+.\" written permission.
+.\"
+.\"THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+.\"IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+.\"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+.TH PCAP_GET_TSTAMP_PRECISION 3PCAP "27 August 2013"
+.SH NAME
+pcap_get_tstamp_precision \- get the time stamp precision returned in
+captures
+.SH SYNOPSIS
+.nf
+.ft B
+#include <pcap/pcap.h>
+.ft
+.LP
+.ft B
+int pcap_get_tstamp_precision(pcap_t *p);
+.ft
+.fi
+.SH DESCRIPTION
+.B pcap_get_tstamp_precision()
+returns the precision of the time stamp returned in packet captures on the pcap
+descriptor.
+.SH RETURN VALUE
+.B pcap_get_tstamp_precision()
+returns PCAP_TSTAMP_PRECISION_MICRO or PCAP_TSTAMP_PRECISION_NANO, which indicates
+that pcap captures contains time stamps in microseconds or nanoseconds respectively.
+.SH SEE ALSO
+pcap(3PCAP),
+pcap_set_tstamp_precision(3PCAP),
+pcap-tstamp(@MAN_MISC_INFO@)
diff --git a/external/bsd/libpcap/dist/pcap_is_swapped.3pcap b/external/bsd/libpcap/dist/pcap_is_swapped.3pcap
index e6e0facb765..0c1bf45108b 100644
--- a/external/bsd/libpcap/dist/pcap_is_swapped.3pcap
+++ b/external/bsd/libpcap/dist/pcap_is_swapped.3pcap
@@ -34,9 +34,20 @@ int pcap_is_swapped(pcap_t *p);
.fi
.SH DESCRIPTION
.B pcap_is_swapped()
-returns true if
+returns true (1) if
.I p
refers to a ``savefile'' that uses a different byte order
-than the current system. For a live capture, it always returns false.
+than the current system. For a live capture, it always returns false
+(0).
+.PP
+It must not be called on a pcap descriptor created by
+.B pcap_create()
+that has not yet been activated by
+.BR pcap_activate() .
+.SH RETURN VALUE
+.B pcap_datalink()
+returns true (1) or false (0) on success and
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated.
.SH SEE ALSO
pcap(3PCAP)
diff --git a/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in b/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in
index c0f4eb323c2..67cd241dae2 100644
--- a/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in
+++ b/external/bsd/libpcap/dist/pcap_list_datalinks.3pcap.in
@@ -47,11 +47,22 @@ The caller is responsible for freeing the array with
.BR pcap_free_datalinks() ,
which frees the list of link-layer header types pointed to by
.IR dlt_list .
+.LP
+It must not be called on a pcap descriptor created by
+.B pcap_create()
+that has not yet been activated by
+.BR pcap_activate() .
.SH RETURN VALUE
.B pcap_list_datalinks()
-returns the number of link-layer header types in the array on success
-and \-1 on failure.
-If \-1 is returned,
+returns the number of link-layer header types in the array on success,
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated,
+and
+.B PCAP_ERROR
+(\-1) on other errors.
+If
+.B PCAP_ERROR
+is returned,
.B pcap_geterr()
or
.B pcap_perror()
diff --git a/external/bsd/libpcap/dist/pcap_loop.3pcap b/external/bsd/libpcap/dist/pcap_loop.3pcap
index fc8e442501a..180bb0ef0ab 100644
--- a/external/bsd/libpcap/dist/pcap_loop.3pcap
+++ b/external/bsd/libpcap/dist/pcap_loop.3pcap
@@ -84,7 +84,7 @@ processed when reading a ``savefile''.
\fIcnt\fP
was 0 was undefined; different platforms and devices behaved
differently, so code that must work with older versions of libpcap
-should use \-1, nor 0, as the value of
+should use \-1, not 0, as the value of
\fIcnt\fP.)
.ft R
.PP
@@ -115,12 +115,48 @@ and the packet data are not to be freed by the callback routine, and are
not guaranteed to be valid after the callback routine returns; if the
code needs them to be valid after the callback, it must make a copy of
them.
+.PP
+The bytes of data from the packet begin with a link-layer header. The
+format of the link-layer header is indicated by the return value of the
+.B pcap_datalink()
+routine when handed the
+.B pcap_t
+value also passed to
+.B pcap_loop()
+or
+.BR pcap_dispatch() .
+.I http://www.tcpdump.org/linktypes.html
+lists the values
+.B pcap_datalink()
+can return and describes the packet formats that
+correspond to those values. The value it returns will be valid for all
+packets received unless and until
+.B pcap_set_datalink()
+is called; after a successful call to
+.BR pcap_set_datalink() ,
+all subsequent packets will have a link-layer header of the type
+specified by the link-layer header type value passed to
+.BR pcap_set_datalink() .
+.PP
+Do
+.B NOT
+assume that the packets for a given capture or ``savefile`` will have
+any given link-layer header type, such as
+.B DLT_EN10MB
+for Ethernet. For example, the "any" device on Linux will have a
+link-layer header type of
+.B DLT_LINUX_SLL
+even if all devices on the system at the time the "any" device is opened
+have some other data link type, such as
+.B DLT_EN10MB
+for Ethernet.
.SH RETURN VALUE
.B pcap_loop()
returns 0 if
.I cnt
-is exhausted, \-1 if an error occurs, or \-2 if the loop terminated due
-to a call to
+is exhausted or if, when reading from a ``savefile'', no more packets
+are available. It returns \-1 if an error occurs or \-2 if the loop
+terminated due to a call to
.B pcap_breakloop()
before any packets were processed.
It does
@@ -154,4 +190,5 @@ may be called with
.I p
as an argument to fetch or display the error text.
.SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_breakloop(3PCAP)
+pcap(3PCAP), pcap_geterr(3PCAP), pcap_breakloop(3PCAP),
+pcap_datalink(3PCAP)
diff --git a/external/bsd/libpcap/dist/pcap_next_ex.3pcap b/external/bsd/libpcap/dist/pcap_next_ex.3pcap
index 3ad6ca64874..89870bc5d07 100644
--- a/external/bsd/libpcap/dist/pcap_next_ex.3pcap
+++ b/external/bsd/libpcap/dist/pcap_next_ex.3pcap
@@ -77,6 +77,41 @@ The
structure pointed to by
.I h
is filled in with the appropriate values for the packet.
+.PP
+The bytes of data from the packet begin with a link-layer header. The
+format of the link-layer header is indicated by the return value of the
+.B pcap_datalink()
+routine when handed the
+.B pcap_t
+value also passed to
+.B pcap_loop()
+or
+.BR pcap_dispatch() .
+.I http://www.tcpdump.org/linktypes.html
+lists the values
+.B pcap_datalink()
+can return and describes the packet formats that
+correspond to those values. The value it returns will be valid for all
+packets received unless and until
+.B pcap_set_datalink()
+is called; after a successful call to
+.BR pcap_set_datalink() ,
+all subsequent packets will have a link-layer header of the type
+specified by the link-layer header type value passed to
+.BR pcap_set_datalink() .
+.PP
+Do
+.B NOT
+assume that the packets for a given capture or ``savefile`` will have
+any given link-layer header type, such as
+.B DLT_EN10MB
+for Ethernet. For example, the "any" device on Linux will have a
+link-layer header type of
+.B DLT_LINUX_SLL
+even if all devices on the system at the time the "any" device is opened
+have some other data link type, such as
+.B DLT_EN10MB
+for Ethernet.
.SH RETURN VALUE
.B pcap_next_ex()
returns 1 if the packet was read without problems, 0
@@ -104,4 +139,5 @@ non-blocking mode and no packets were available to be read), or if no
more packets are available in a ``savefile.'' Unfortunately, there is
no way to determine whether an error occurred or not.
.SH SEE ALSO
-pcap(3PCAP), pcap_geterr(3PCAP), pcap_dispatch(3PCAP)
+pcap(3PCAP), pcap_geterr(3PCAP), pcap_dispatch(3PCAP),
+pcap_datalink(3PCAP)
diff --git a/external/bsd/libpcap/dist/pcap_offline_filter.3pcap b/external/bsd/libpcap/dist/pcap_offline_filter.3pcap
index 4e35d1a226b..84aa191924a 100644
--- a/external/bsd/libpcap/dist/pcap_offline_filter.3pcap
+++ b/external/bsd/libpcap/dist/pcap_offline_filter.3pcap
@@ -29,7 +29,7 @@ pcap_offline_filter \- check whether a filter matches a packet
.ft
.LP
.ft B
-int pcap_offline_filter(struct bpf_program *fp,
+int pcap_offline_filter(const struct bpf_program *fp,
.ti +8
const struct pcap_pkthdr *h, const u_char *pkt)
.ft
diff --git a/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in b/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in
index ceceadcc10b..34078989456 100644
--- a/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in
+++ b/external/bsd/libpcap/dist/pcap_open_dead.3pcap.in
@@ -19,10 +19,10 @@
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
-.TH PCAP_OPEN_DEAD 3PCAP "5 April 2008"
+.TH PCAP_OPEN_DEAD 3PCAP "1 July 2013"
.SH NAME
-pcap_open_dead \- open a fake pcap_t for compiling filters or opening a
-capture for output
+pcap_open_dead, pcap_open_dead_with_tstamp_precision \- open a fake
+pcap_t for compiling filters or opening a capture for output
.SH SYNOPSIS
.nf
.ft B
@@ -31,15 +31,27 @@ capture for output
.LP
.ft B
pcap_t *pcap_open_dead(int linktype, int snaplen);
+pcap_t *pcap_open_dead_with_tstamp_precision(int linktype, int snaplen,
+ u_int precision);
.ft
.fi
.SH DESCRIPTION
.PP
.B pcap_open_dead()
-is used for creating a
+and
+.B pcap_open_dead_with_tstamp_precision()
+are used for creating a
.B pcap_t
structure to use when calling the other functions in libpcap. It is
-typically used when just using libpcap for compiling BPF code.
+typically used when just using libpcap for compiling BPF code; it can
+also be used if using
+.BR pcap_dump_open() ,
+.BR pcap_dump() ,
+and
+.B pcap_dump_close()
+to write a savefile if there is no
+.B pcap_t
+that supplies the packets to be written.
.PP
.I linktype
specifies the link-layer type for the
@@ -48,5 +60,22 @@ specifies the link-layer type for the
.I snaplen
specifies the snapshot length for the
.BR pcap_t .
+.PP
+When
+.BR pcap_open_dead_with_tstamp_precision() ,
+is used to create a
+.B pcap_t
+for use with
+.BR pcap_dump_open() ,
+.I precision
+specifies the time stamp precision for packets;
+.B PCAP_TSTAMP_PRECISION_MICRO
+should be specified if the packets to be written have time stamps in
+seconds and microseconds, and
+.B PCAP_TSTAMP_PRECISION_NANO
+should be specified if the packets to be written have time stamps in
+seconds and nanoseconds. Its value does not affect
+.BR pcap_compile() .
.SH SEE ALSO
-pcap(3PCAP), pcap-linktype(@MAN_MISC_INFO@)
+pcap(3PCAP), pcap_compile(3PCAP), pcap_dump_open(3PCAP),
+pcap-linktype(@MAN_MISC_INFO@)
diff --git a/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap b/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap
new file mode 100644
index 00000000000..fef5dcdf997
--- /dev/null
+++ b/external/bsd/libpcap/dist/pcap_set_immediate_mode.3pcap
@@ -0,0 +1,47 @@
+.\"
+.\" Copyright (c) 1994, 1996, 1997
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that: (1) source code distributions
+.\" retain the above copyright notice and this paragraph in its entirety, (2)
+.\" distributions including binary code include the above copyright notice and
+.\" this paragraph in its entirety in the documentation or other materials
+.\" provided with the distribution, and (3) all advertising materials mentioning
+.\" features or use of this software display the following acknowledgement:
+.\" ``This product includes software developed by the University of California,
+.\" Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+.\"
+.TH PCAP_SET_IMMEDIATE_MODE 3PCAP "8 May 20013"
+.SH NAME
+pcap_set_immediate_mode \- set immediate mode for a not-yet-activated capture
+handle
+.SH SYNOPSIS
+.nf
+.ft B
+#include <pcap/pcap.h>
+.LP
+.ft B
+int pcap_set_immediate_mode(pcap_t *p, int immediate_mode);
+.ft
+.fi
+.SH DESCRIPTION
+.B pcap_set_immediate_mode()
+sets whether immediate mode should be set on a capture handle when
+the handle is activated.
+If
+.I immediate_mode
+is non-zero, immediate mode will be set, otherwise it will not be set.
+.SH RETURN VALUE
+.B pcap_set_immediate_mode()
+returns 0 on success or
+.B PCAP_ERROR_ACTIVATED
+if called on a capture handle that has been activated.
+.SH SEE ALSO
+pcap(3PCAP), pcap_create(3PCAP), pcap_activate(3PCAP)
diff --git a/external/bsd/libpcap/dist/pcap_set_tstamp_precision.3pcap.in b/external/bsd/libpcap/dist/pcap_set_tstamp_precision.3pcap.in
new file mode 100644
index 00000000000..053a4c6bcef
--- /dev/null
+++ b/external/bsd/libpcap/dist/pcap_set_tstamp_precision.3pcap.in
@@ -0,0 +1,61 @@
+.\"Copyright (c) 2013, Michal Sekletar
+.\"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.
+.\" 3. The names of the authors may not be used to endorse or promote
+.\" products derived from this software without specific prior
+.\" written permission.
+.\"
+.\"THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+.\"IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+.\"WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+.TH PCAP_SET_TSTAMP_PRECISION 3PCAP "27 August 2013"
+.SH NAME
+pcap_set_tstamp_precision \- set the time stamp precision returned in
+captures
+.SH SYNOPSIS
+.nf
+.ft B
+#include <pcap/pcap.h>
+.ft
+.LP
+.ft B
+int pcap_set_tstamp_precision(pcap_t *p, int tstamp_precision);
+.ft
+.fi
+.SH DESCRIPTION
+.B pcap_set_tstamp_precision()
+sets the precision of the time stamp desired for packets captured on the pcap
+descriptor to the type specified by
+.IR tstamp_precision .
+It must be called on a pcap descriptor created by
+.B pcap_create()
+that has not yet been activated by
+.BR pcap_activate() .
+Two time stamp precisions are supported, microseconds and nanoseconds. One can
+use options
+.B PCAP_TSTAMP_PRECISION_MICRO and
+.B PCAP_TSTAMP_PRECISION_NANO
+to request desired precision. By default, time stamps are in microseconds.
+.SH RETURN VALUE
+.B pcap_set_tstamp_type()
+returns 0 on success if the specified time stamp precision is expected to be
+supported by the operating system,
+.B PCAP_ERROR_TSTAMP_PRECISION_NOTSUP
+if operating system does not support requested time stamp precision,
+.B PCAP_ERROR_ACTIVATED
+if called on a capture handle that has been activated.
+.SH SEE ALSO
+pcap(3PCAP),
+pcap_get_tstamp_precision(3PCAP),
+pcap-tstamp(@MAN_MISC_INFO@)
diff --git a/external/bsd/libpcap/dist/pcap_snapshot.3pcap b/external/bsd/libpcap/dist/pcap_snapshot.3pcap
index 749ce1fcaef..e5ea6f99b84 100644
--- a/external/bsd/libpcap/dist/pcap_snapshot.3pcap
+++ b/external/bsd/libpcap/dist/pcap_snapshot.3pcap
@@ -40,5 +40,15 @@ or
.B pcap_open_live()
was called, for a live capture, or the snapshot length from the capture
file, for a ``savefile''.
+.PP
+It must not be called on a pcap descriptor created by
+.B pcap_create()
+that has not yet been activated by
+.BR pcap_activate() .
+.SH RETURN VALUE
+.B pcap_snapshot()
+returns the snapshot length on success and
+.B PCAP_ERROR_NOT_ACTIVATED
+if called on a capture handle that has been created but not activated.
.SH SEE ALSO
pcap(3PCAP)
diff --git a/external/bsd/libpcap/dist/savefile.c b/external/bsd/libpcap/dist/savefile.c
index edff2151bf0..1766675b06f 100644
--- a/external/bsd/libpcap/dist/savefile.c
+++ b/external/bsd/libpcap/dist/savefile.c
@@ -1,4 +1,4 @@
-/* $NetBSD: savefile.c,v 1.1.1.3 2013/04/06 15:57:44 christos Exp $ */
+/* $NetBSD: savefile.c,v 1.1.1.4 2013/12/31 16:57:18 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -162,18 +162,19 @@ sf_setdirection(pcap_t *p, pcap_direction_t d)
return (-1);
}
-static void
+void
sf_cleanup(pcap_t *p)
{
- if (p->sf.rfile != stdin)
- (void)fclose(p->sf.rfile);
+ if (p->rfile != stdin)
+ (void)fclose(p->rfile);
if (p->buffer != NULL)
free(p->buffer);
pcap_freecode(&p->fcode);
}
pcap_t *
-pcap_open_offline(const char *fname, char *errbuf)
+pcap_open_offline_with_tstamp_precision(const char *fname, u_int precision,
+ char *errbuf)
{
FILE *fp;
pcap_t *p;
@@ -201,7 +202,7 @@ pcap_open_offline(const char *fname, char *errbuf)
return (NULL);
}
}
- p = pcap_fopen_offline(fp, errbuf);
+ p = pcap_fopen_offline_with_tstamp_precision(fp, precision, errbuf);
if (p == NULL) {
if (fp != stdin)
fclose(fp);
@@ -209,8 +210,16 @@ pcap_open_offline(const char *fname, char *errbuf)
return (p);
}
+pcap_t *
+pcap_open_offline(const char *fname, char *errbuf)
+{
+ return (pcap_open_offline_with_tstamp_precision(fname,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf));
+}
+
#ifdef WIN32
-pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf)
+pcap_t* pcap_hopen_offline_with_tstamp_precision(intptr_t osfd, u_int precision,
+ char *errbuf)
{
int fd;
FILE *file;
@@ -229,11 +238,18 @@ pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf)
return NULL;
}
- return pcap_fopen_offline(file, errbuf);
+ return pcap_fopen_offline_with_tstamp_precision(file, precision,
+ errbuf);
+}
+
+pcap_t* pcap_hopen_offline(intptr_t osfd, char *errbuf)
+{
+ return pcap_hopen_offline_with_tstamp_precision(osfd,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf);
}
#endif
-static int (*check_headers[])(pcap_t *, bpf_u_int32, FILE *, char *) = {
+static pcap_t *(*check_headers[])(bpf_u_int32, FILE *, u_int, char *, int *) = {
pcap_check_header,
pcap_ng_check_header
};
@@ -244,16 +260,14 @@ static int (*check_headers[])(pcap_t *, bpf_u_int32, FILE *, char *) = {
static
#endif
pcap_t *
-pcap_fopen_offline(FILE *fp, char *errbuf)
+pcap_fopen_offline_with_tstamp_precision(FILE *fp, u_int precision,
+ char *errbuf)
{
register pcap_t *p;
bpf_u_int32 magic;
size_t amt_read;
u_int i;
-
- p = pcap_create_common("(savefile)", errbuf);
- if (p == NULL)
- return (NULL);
+ int err;
/*
* Read the first 4 bytes of the file; the network analyzer dump
@@ -274,26 +288,23 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
(unsigned long)sizeof(magic),
(unsigned long)amt_read);
}
- goto bad;
+ return (NULL);
}
/*
* Try all file types.
*/
for (i = 0; i < N_FILE_TYPES; i++) {
- switch ((*check_headers[i])(p, magic, fp, errbuf)) {
-
- case -1:
+ p = (*check_headers[i])(magic, fp, precision, errbuf, &err);
+ if (p != NULL) {
+ /* Yup, that's it. */
+ goto found;
+ }
+ if (err) {
/*
* Error trying to read the header.
*/
- goto bad;
-
- case 1:
- /*
- * Yup, that's it.
- */
- goto found;
+ return (NULL);
}
}
@@ -301,15 +312,13 @@ pcap_fopen_offline(FILE *fp, char *errbuf)
* Well, who knows what this mess is....
*/
snprintf(errbuf, PCAP_ERRBUF_SIZE, "unknown file format");
- goto bad;
+ return (NULL);
found:
- p->sf.rfile = fp;
+ p->rfile = fp;
-#ifdef PCAP_FDDIPAD
/* Padding only needed for live capture fcode */
p->fddipad = 0;
-#endif
#if !defined(WIN32) && !defined(MSDOS)
/*
@@ -335,13 +344,26 @@ found:
p->setmode_op = sf_setmode;
p->setmintocopy_op = sf_setmintocopy;
#endif
- p->cleanup_op = sf_cleanup;
+
+ /*
+ * For offline captures, the standard one-shot callback can
+ * be used for pcap_next()/pcap_next_ex().
+ */
+ p->oneshot_callback = pcap_oneshot;
+
p->activated = 1;
return (p);
- bad:
- free(p);
- return (NULL);
+}
+
+#ifdef WIN32
+static
+#endif
+pcap_t *
+pcap_fopen_offline(FILE *fp, char *errbuf)
+{
+ return (pcap_fopen_offline_with_tstamp_precision(fp,
+ PCAP_TSTAMP_PRECISION_MICRO, errbuf));
}
/*
@@ -377,7 +399,7 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
return (n);
}
- status = p->sf.next_packet_op(p, &h, &data);
+ status = p->next_packet_op(p, &h, &data);
if (status) {
if (status == 1)
return (0);
diff --git a/external/bsd/libpcap/dist/sf-pcap-ng.h b/external/bsd/libpcap/dist/sf-pcap-ng.h
index c66bdda8428..ca8740a27ee 100644
--- a/external/bsd/libpcap/dist/sf-pcap-ng.h
+++ b/external/bsd/libpcap/dist/sf-pcap-ng.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sf-pcap-ng.h,v 1.1.1.2 2013/04/06 15:57:39 christos Exp $ */
+/* $NetBSD: sf-pcap-ng.h,v 1.1.1.3 2013/12/31 16:57:21 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -28,6 +28,7 @@
#ifndef sf_pcap_ng_h
#define sf_pcap_ng_h
-extern int pcap_ng_check_header(pcap_t *, bpf_u_int32, FILE *, char *);
+extern pcap_t *pcap_ng_check_header(bpf_u_int32 magic, FILE *fp,
+ u_int precision, char *errbuf, int *err);
#endif
diff --git a/external/bsd/libpcap/dist/sf-pcap.h b/external/bsd/libpcap/dist/sf-pcap.h
index aea891d3973..ccbc21c0417 100644
--- a/external/bsd/libpcap/dist/sf-pcap.h
+++ b/external/bsd/libpcap/dist/sf-pcap.h
@@ -1,4 +1,4 @@
-/* $NetBSD: sf-pcap.h,v 1.1.1.2 2013/04/06 15:57:46 christos Exp $ */
+/* $NetBSD: sf-pcap.h,v 1.1.1.3 2013/12/31 16:57:25 christos Exp $ */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -33,6 +33,7 @@
#ifndef sf_pcap_h
#define sf_pcap_h
-extern int pcap_check_header(pcap_t *, bpf_u_int32, FILE *, char *);
+extern pcap_t *pcap_check_header(bpf_u_int32 magic, FILE *fp,
+ u_int precision, char *errbuf, int *err);
#endif
diff --git a/external/bsd/libpcap/dist/tests/valgrindtest.c b/external/bsd/libpcap/dist/tests/valgrindtest.c
new file mode 100644
index 00000000000..1d749cd6aa1
--- /dev/null
+++ b/external/bsd/libpcap/dist/tests/valgrindtest.c
@@ -0,0 +1,410 @@
+/* $NetBSD: valgrindtest.c,v 1.1.1.1 2013/12/31 16:57:29 christos Exp $ */
+
+/*
+ * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 2000
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that: (1) source code distributions
+ * retain the above copyright notice and this paragraph in its entirety, (2)
+ * distributions including binary code include the above copyright notice and
+ * this paragraph in its entirety in the documentation or other materials
+ * provided with the distribution, and (3) all advertising materials mentioning
+ * features or use of this software display the following acknowledgement:
+ * ``This product includes software developed by the University of California,
+ * Lawrence Berkeley Laboratory and its contributors.'' 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+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
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+/* BSD-flavored OS - use BPF */
+#define USE_BPF
+#elif defined(linux)
+/* Linux - use socket filters */
+#define USE_SOCKET_FILTERS
+#else
+#error "Unknown platform or platform that doesn't support Valgrind"
+#endif
+
+#if defined(USE_BPF)
+
+#include <sys/ioctl.h>
+#include <net/bpf.h>
+
+/*
+ * Make "pcap.h" not include "pcap/bpf.h"; we are going to include the
+ * native OS version, as we're going to be doing our own ioctls to
+ * make sure that, in the uninitialized-data tests, the filters aren't
+ * checked by libpcap before being handed to BPF.
+ */
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H
+
+#elif defined(USE_SOCKET_FILTERS)
+
+#include <sys/socket.h>
+#include <linux/types.h>
+#include <linux/filter.h>
+
+#endif
+
+#include <pcap.h>
+#ifndef HAVE___ATTRIBUTE__
+#define __attribute__(x)
+#endif
+
+static char *program_name;
+
+/* Forwards */
+static void usage(void) __attribute__((noreturn));
+static void error(const char *, ...)
+ __attribute__((noreturn, format (printf, 1, 2)));
+static void warning(const char *, ...)
+ __attribute__((format (printf, 1, 2)));
+
+extern int optind;
+extern int opterr;
+extern char *optarg;
+
+/*
+ * On Windows, we need to open the file in binary mode, so that
+ * we get all the bytes specified by the size we get from "fstat()".
+ * On UNIX, that's not necessary. O_BINARY is defined on Windows;
+ * we define it as 0 if it's not defined, so it does nothing.
+ */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+static char *
+read_infile(char *fname)
+{
+ register int i, fd, cc;
+ register char *cp;
+ struct stat buf;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd < 0)
+ error("can't open %s: %s", fname, pcap_strerror(errno));
+
+ if (fstat(fd, &buf) < 0)
+ error("can't stat %s: %s", fname, pcap_strerror(errno));
+
+ cp = malloc((u_int)buf.st_size + 1);
+ if (cp == NULL)
+ error("malloc(%d) for %s: %s", (u_int)buf.st_size + 1,
+ fname, pcap_strerror(errno));
+ cc = read(fd, cp, (u_int)buf.st_size);
+ if (cc < 0)
+ error("read %s: %s", fname, pcap_strerror(errno));
+ if (cc != buf.st_size)
+ error("short read %s (%d != %d)", fname, cc, (int)buf.st_size);
+
+ close(fd);
+ /* replace "# comment" with spaces */
+ for (i = 0; i < cc; i++) {
+ if (cp[i] == '#')
+ while (i < cc && cp[i] != '\n')
+ cp[i++] = ' ';
+ }
+ cp[cc] = '\0';
+ return (cp);
+}
+
+/* VARARGS */
+static void
+error(const char *fmt, ...)
+{
+ va_list ap;
+
+ (void)fprintf(stderr, "%s: ", 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);
+ }
+ exit(1);
+ /* NOTREACHED */
+}
+
+/* VARARGS */
+static void
+warning(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.
+ */
+static char *
+copy_argv(register char **argv)
+{
+ register char **p;
+ register u_int len = 0;
+ char *buf;
+ char *src, *dst;
+
+ p = argv;
+ if (*p == 0)
+ return 0;
+
+ while (*p)
+ len += strlen(*p++) + 1;
+
+ buf = (char *)malloc(len);
+ if (buf == NULL)
+ error("copy_argv: malloc");
+
+ p = argv;
+ dst = buf;
+ while ((src = *p++) != NULL) {
+ while ((*dst++ = *src++) != '\0')
+ ;
+ dst[-1] = ' ';
+ }
+ dst[-1] = '\0';
+
+ return buf;
+}
+
+#define INSN_COUNT 17
+
+int
+main(int argc, char **argv)
+{
+ char *cp, *device;
+ int op;
+ int dorfmon, useactivate;
+ char ebuf[PCAP_ERRBUF_SIZE];
+ char *infile;
+ char *cmdbuf;
+ pcap_t *pd;
+ int status = 0;
+ int pcap_fd;
+#if defined(USE_BPF)
+ struct bpf_program bad_fcode;
+ struct bpf_insn uninitialized[INSN_COUNT];
+#elif defined(USE_SOCKET_FILTERS)
+ struct sock_fprog bad_fcode;
+ struct sock_filter uninitialized[INSN_COUNT];
+#endif
+ struct bpf_program fcode;
+
+ device = NULL;
+ dorfmon = 0;
+ useactivate = 0;
+ infile = NULL;
+
+ if ((cp = strrchr(argv[0], '/')) != NULL)
+ program_name = cp + 1;
+ else
+ program_name = argv[0];
+
+ opterr = 0;
+ while ((op = getopt(argc, argv, "aF:i:I")) != -1) {
+ switch (op) {
+
+ case 'a':
+ useactivate = 1;
+ break;
+
+ case 'F':
+ infile = optarg;
+ break;
+
+ case 'i':
+ device = optarg;
+ break;
+
+ case 'I':
+ dorfmon = 1;
+ useactivate = 1; /* required for rfmon */
+ break;
+
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+
+ if (device == NULL) {
+ /*
+ * No interface specified; get whatever pcap_lookupdev()
+ * finds.
+ */
+ device = pcap_lookupdev(ebuf);
+ if (device == NULL) {
+ error("couldn't find interface to use: %s",
+ ebuf);
+ }
+ }
+
+ if (infile != NULL) {
+ /*
+ * Filter specified with "-F" and a file containing
+ * a filter.
+ */
+ cmdbuf = read_infile(infile);
+ } else {
+ if (optind < argc) {
+ /*
+ * Filter specified with arguments on the
+ * command line.
+ */
+ cmdbuf = copy_argv(&argv[optind+1]);
+ } else {
+ /*
+ * No filter specified; use an empty string, which
+ * compiles to an "accept all" filter.
+ */
+ cmdbuf = "";
+ }
+ }
+
+ if (useactivate) {
+ pd = pcap_create(device, ebuf);
+ if (pd == NULL)
+ error("%s: pcap_create() failed: %s", device, ebuf);
+ status = pcap_set_snaplen(pd, 65535);
+ if (status != 0)
+ error("%s: pcap_set_snaplen failed: %s",
+ device, pcap_statustostr(status));
+ status = pcap_set_promisc(pd, 1);
+ if (status != 0)
+ error("%s: pcap_set_promisc failed: %s",
+ device, pcap_statustostr(status));
+ if (dorfmon) {
+ status = pcap_set_rfmon(pd, 1);
+ if (status != 0)
+ error("%s: pcap_set_rfmon failed: %s",
+ device, pcap_statustostr(status));
+ }
+ status = pcap_set_timeout(pd, 1000);
+ if (status != 0)
+ error("%s: pcap_set_timeout failed: %s",
+ device, pcap_statustostr(status));
+ status = pcap_activate(pd);
+ if (status < 0) {
+ /*
+ * pcap_activate() failed.
+ */
+ error("%s: %s\n(%s)", device,
+ pcap_statustostr(status), pcap_geterr(pd));
+ } else if (status > 0) {
+ /*
+ * pcap_activate() succeeded, but it's warning us
+ * of a problem it had.
+ */
+ warning("%s: %s\n(%s)", device,
+ pcap_statustostr(status), pcap_geterr(pd));
+ }
+ } else {
+ *ebuf = '\0';
+ pd = pcap_open_live(device, 65535, 1, 1000, ebuf);
+ if (pd == NULL)
+ error("%s", ebuf);
+ else if (*ebuf)
+ warning("%s", ebuf);
+ }
+
+ pcap_fd = pcap_fileno(pd);
+
+ /*
+ * Try setting a filter with an uninitialized bpf_program
+ * structure. This should cause valgrind to report a
+ * problem.
+ *
+ * We don't check for errors, because it could get an
+ * error due to a bad pointer or count.
+ */
+#if defined(USE_BPF)
+ ioctl(pcap_fd, BIOCSETF, &bad_fcode);
+#elif defined(USE_SOCKET_FILTERS)
+ setsockopt(pcap_fd, SOL_SOCKET, SO_ATTACH_FILTER, &bad_fcode,
+ sizeof(bad_fcode));
+#endif
+
+ /*
+ * Try setting a filter with an initialized bpf_program
+ * structure that points to an uninitialized program.
+ * That should also cause valgrind to report a problem.
+ *
+ * We don't check for errors, because it could get an
+ * error due to a bad pointer or count.
+ */
+#if defined(USE_BPF)
+ bad_fcode.bf_len = INSN_COUNT;
+ bad_fcode.bf_insns = uninitialized;
+ ioctl(pcap_fd, BIOCSETF, &bad_fcode);
+#elif defined(USE_SOCKET_FILTERS)
+ bad_fcode.len = INSN_COUNT;
+ bad_fcode.filter = uninitialized;
+ setsockopt(pcap_fd, SOL_SOCKET, SO_ATTACH_FILTER, &bad_fcode,
+ sizeof(bad_fcode));
+#endif
+
+ /*
+ * Now compile a filter and set the filter with that.
+ * That should *not* cause valgrind to report a
+ * problem.
+ */
+ if (pcap_compile(pd, &fcode, cmdbuf, 1, 0) < 0)
+ error("can't compile filter: %s", pcap_geterr(pd));
+ if (pcap_setfilter(pd, &fcode) < 0)
+ error("can't set filter: %s", pcap_geterr(pd));
+
+ pcap_close(pd);
+ exit(status < 0 ? 1 : 0);
+}
+
+static void
+usage(void)
+{
+ (void)fprintf(stderr, "%s, with %s\n", program_name,
+ pcap_lib_version());
+ (void)fprintf(stderr,
+ "Usage: %s [-aI] [ -F file ] [ -I interface ] [ expression ]\n",
+ program_name);
+ exit(1);
+}