mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Upgrade our included libpcap to 1.1.1.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o Upgraded the included libpcap to version 1.1.1. [David]
|
||||
|
||||
o [NSE] Add some special use IPv4 addresses to isPrivate which are described in
|
||||
RFC 5736 and RFC 5737, published in Jan 2010. Improve performance of isPrivate
|
||||
for IPv4 addresses by using ip_in_range less frequently. Add an extra return
|
||||
|
||||
@@ -1,4 +1,77 @@
|
||||
@(#) $Header: /tcpdump/master/libpcap/CHANGES,v 1.67.2.4 2008-10-28 00:27:42 ken Exp $ (LBL)
|
||||
Thu. April 1, 2010. guy@alum.mit.edu.
|
||||
Summary for 1.1.1 libpcap release
|
||||
Update CHANGES to reflect more of the changes in 1.1.0.
|
||||
Fix build on RHEL5.
|
||||
Fix shared library build on AIX.
|
||||
|
||||
Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu.
|
||||
Summary for 1.1.0 libpcap release
|
||||
Add SocketCAN capture support
|
||||
Add Myricom SNF API support
|
||||
Update Endace DAG and ERF support
|
||||
Add support for shared libraries on Solaris, HP-UX, and AIX
|
||||
Build, install, and un-install shared libraries by default;
|
||||
don't build/install shared libraries on platforms we don't support
|
||||
Fix building from a directory other than the source directory
|
||||
Fix compiler warnings and builds on some platforms
|
||||
Update config.guess and config.sub
|
||||
Support monitor mode on mac80211 devices on Linux
|
||||
Fix USB memory-mapped capturing on Linux; it requires a new DLT_
|
||||
value
|
||||
On Linux, scan /sys/class/net for devices if we have it; scan
|
||||
it, or /proc/net/dev if we don't have /sys/class/net, even if
|
||||
we have getifaddrs(), as it'll find interfaces with no
|
||||
addresses
|
||||
Add limited support for reading pcap-ng files
|
||||
Fix BPF driver-loading error handling on AIX
|
||||
Support getting the full-length interface description on FreeBSD
|
||||
In the lexical analyzer, free up any addrinfo structure we got back
|
||||
from getaddrinfo().
|
||||
Add support for BPF and libdlpi in OpenSolaris (and SXCE)
|
||||
Hyphenate "link-layer" everywhere
|
||||
Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations
|
||||
In pcap_read_linux_mmap(), if there are no frames available, call
|
||||
poll() even if we're in non-blocking mode, so we pick up
|
||||
errors, and check for the errors in question.
|
||||
Note that poll() works on BPF devices is Snow Leopard
|
||||
If an ENXIO or ENETDOWN is received, it may mean the device has
|
||||
gone away. Deal with it.
|
||||
For BPF, raise the default capture buffer size to from 32k to 512k
|
||||
Support ps_ifdrop on Linux
|
||||
Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile
|
||||
under cygwin.
|
||||
Changes to Linux mmapped captures.
|
||||
Fix bug where create_ring would fail for particular snaplen and
|
||||
buffer size combinations
|
||||
Update pcap-config so that it handles libpcap requiring
|
||||
additional libraries
|
||||
Add workaround for threadsafeness on Windows
|
||||
Add missing mapping for DLT_ENC <-> LINKTYPE_ENC
|
||||
DLT: Add DLT_CAN_SOCKETCAN
|
||||
DLT: Add Solaris ipnet
|
||||
Don't check for DLT_IPNET if it's not defined
|
||||
Add link-layer types for Fibre Channel FC-2
|
||||
Add link-layer types for Wireless HART
|
||||
Add link-layer types for AOS
|
||||
Add link-layer types for DECT
|
||||
Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups)
|
||||
Install headers unconditionally, and include vlan.h/bluetooth.h if
|
||||
enabled
|
||||
Autoconf fixes+cleanup
|
||||
Support enabling/disabling bluetooth (--{en,dis}able-bluetooth)
|
||||
Support disabling SITA support (--without-sita)
|
||||
Return -1 on failure to create packet ring (if supported but
|
||||
creation failed)
|
||||
Fix handling of 'any' device, so that it can be opened, and no longer
|
||||
attempt to open it in Monitor mode
|
||||
Add support for snapshot length for USB Memory-Mapped Interface
|
||||
Fix configure and build on recent Linux kernels
|
||||
Fix memory-mapped Linux capture to support pcap_next() and
|
||||
pcap_next_ex()
|
||||
Fixes for Linux USB capture
|
||||
DLT: Add DLT_LINUX_EVDEV
|
||||
DLT: Add DLT_GSMTAP_UM
|
||||
DLT: Add DLT_GSMTAP_ABIS
|
||||
|
||||
Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap release
|
||||
Compile with IPv6 support by default
|
||||
@@ -12,7 +85,10 @@ Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap rele
|
||||
Variable length 802.11 header support
|
||||
X2E data type support
|
||||
SITA ACN Interface support - see README.sita
|
||||
Support for memory-mapped capture on Linux
|
||||
Support for zerocopy BPF on platforms that support it
|
||||
Support for setting buffer size when opening devices
|
||||
Support for setting monitor mode when opening 802.11 devices
|
||||
Better support for dealing with VLAN tagging/stripping on Linux
|
||||
Fix dynamic library support on OSX
|
||||
Return PCAP_ERROR_IFACE_NOT_UP if the interface isn't 'UP', so applications
|
||||
@@ -22,7 +98,7 @@ Mon. October 27, 2008. ken@netfunctional.ca. Summary for 1.0.0 libpcap rele
|
||||
On Linux, ignore ENETDOWN so we can continue to capture packets if the
|
||||
interface goes down and comes back up again.
|
||||
On Linux, support new tpacket frame headers (2.6.27+)
|
||||
On Mac OS X, add scripts for changing permissions on /dev/pbf* and launchd plist
|
||||
On Mac OS X, add scripts for changing permissions on /dev/bpf* and launchd plist
|
||||
On Solaris, support 'passive mode' on systems that support it
|
||||
Fixes to autoconf and general build environment
|
||||
Man page reorganization + cleanup
|
||||
|
||||
@@ -10,9 +10,10 @@ The current maintainers:
|
||||
Additional people who have contributed patches:
|
||||
|
||||
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>
|
||||
Albert Chin <china at thewrittenword dot com>
|
||||
Alon Bar-Lev <alonbl at sourceforge dot net>
|
||||
Andrew Brown <atatat at atatdot dot net>
|
||||
Antti Kantee <pooka at netbsd dot org>
|
||||
Arien Vijn <arienvijn at sourceforge dot net>
|
||||
@@ -23,24 +24,28 @@ Additional people who have contributed patches:
|
||||
Charles M. Hannum <mycroft at netbsd dot org>
|
||||
Chris G. Demetriou <cgd at netbsd dot org>
|
||||
Chris Lightfoot <cwrl at users dot sourceforge dot net>
|
||||
Chris Maynard <Chris dot Maynard at gtech dot com>
|
||||
Chris Pepper <pepper at mail dot reppep dot com>
|
||||
Christian Bell <csbell at myri dot com>
|
||||
Christian Peron <csjp at freebsd dot org>
|
||||
Daniele Orlandi <daniele at orlandi dot com>
|
||||
Darren Reed <darrenr at reed dot wattle dot id dot au>
|
||||
Darren Reed <darrenr at sun dot com>
|
||||
David Kaelbling <drk at sgi dot com>
|
||||
David Young <dyoung at ojctech dot com>
|
||||
Dean Gaudet <dean at arctic dot org>
|
||||
Don Ebright <Don dot Ebright at compuware dot com>
|
||||
Dug Song <dugsong at monkey dot org>
|
||||
Dustin Spicuzza <dustin at virtualroadside dot com>
|
||||
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>
|
||||
Florent Drouin <Florent dot Drouin at alcatel-lucent dot fr>
|
||||
Franz Schaefer <schaefer at mond dot at>
|
||||
Fulko Hew <fulko dot hew at gmail dot com>
|
||||
Fumiyuki Shimizu <fumifumi at abacustech dot jp>
|
||||
Gianluca Varenni <varenni at netgroup-serv dot polito dot it>
|
||||
Gilbert Hoyek <gil_hoyek at hotmail dot com>
|
||||
Gisle Vanem <gvanem at broadpark dot no>
|
||||
Gisle Vanem <giva at bgnett dot no>
|
||||
Graeme Hewson <ghewson at cix dot compulink dot co dot uk>
|
||||
Greg Stark <gsstark at mit dot edu>
|
||||
Greg Troxel <gdt at ir dot bbn dot com>
|
||||
@@ -53,11 +58,13 @@ Additional people who have contributed patches:
|
||||
Jason R. Thorpe <thorpej at netbsd dot org>
|
||||
Javier Achirica <achirica at ttd dot net>
|
||||
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 Peterson <jesper at endace 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>
|
||||
Juergen Schoenwaelder <schoenw at ibr dot cs dot tu-bs dot de>
|
||||
Jung-uk Kim <jkim at FreeBSD dot org>
|
||||
Kazushi Sugyo <sugyo at pb dot jp dot nec dot com>
|
||||
@@ -67,19 +74,22 @@ Additional people who have contributed patches:
|
||||
Krzysztof Halasa <khc at pm dot waw dot pl>
|
||||
Lorenzo Cavallaro <sullivan at sikurezza dot org>
|
||||
Loris Degioanni <loris at netgroup-serv dot polito dot it>
|
||||
Love H<EFBFBD>rnquist-<EFBFBD>strand <lha at stacken dot kth dot se>
|
||||
Love Hörnquist-Åstrand <lha at stacken dot kth dot se>
|
||||
Luis Martin Garcia <luis dot mgarc at gmail dot com>
|
||||
Maciej W. Rozycki <macro at ds2 dot pg dot gda dot pl>
|
||||
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>
|
||||
Markus Mayer <markus_mayer at sourceforge dot net>
|
||||
Martin Husemann <martin at netbsd dot org>
|
||||
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>
|
||||
Mike Frysinger <vapier at gmail dot com>
|
||||
Mike Kershaw <dragorn at kismetwireless dot net>
|
||||
Mike Wiacek <mike at iroot dot net>
|
||||
Monroe Williams <monroe at pobox dot com>
|
||||
N. Leiten <nleiten at sourceforge dot net>
|
||||
Nicolas Dade <ndade at nsd dot dyndns dot org>
|
||||
Octavian Cerna <tavy at ylabs dot com>
|
||||
Olaf Kirch <okir at caldera dot de>
|
||||
@@ -93,15 +103,20 @@ Additional people who have contributed patches:
|
||||
Pawel Pokrywka <publicpp at gmail dot com>
|
||||
Peter Fales <peter at fales-lorenz dot net>
|
||||
Peter Jeremy <peter dot jeremy at alcatel dot com dot au>
|
||||
Peter Volkov <pva at gentoo dot org>
|
||||
Phil Wood <cpw at lanl dot gov>
|
||||
Rafal Maszkowski <rzm at icm dot edu dot pl>
|
||||
<rcb-isis at users dot sourceforge dot net>
|
||||
Richard Stearn <richard at rns-stearn dot demon dot co dot uk>
|
||||
Rick Jones <raj at cup dot hp dot com>
|
||||
Robert Edmonds <stu-42 at sourceforge dot net>
|
||||
Roberto Mariani <jelot-tcpdump at jelot dot it>
|
||||
Romain Francoise <rfrancoise at debian dot org>
|
||||
Sagun Shakya <sagun dot shakya at sun dot com>
|
||||
Scott Barron <sb125499 at ohiou dot edu>
|
||||
Scott Gifford <sgifford at tir dot com>
|
||||
Sebastian Krahmer <krahmer at cs dot uni-potsdam dot de>
|
||||
Sebastien Roy <Sebastien dot Roy at Sun dot COM>
|
||||
Sepherosa Ziehau <sepherosa at gmail dot com>
|
||||
Shaun Clowes <delius at progsoc dot uts dot edu dot au>
|
||||
Solomon Peachy <pizza at shaftnet dot org>
|
||||
@@ -109,12 +124,16 @@ Additional people who have contributed patches:
|
||||
Stephen Donnelly <stephen at endace dot com>
|
||||
Takashi Yamamoto <yamt at mwd dot biglobe dot ne dot jp>
|
||||
Tanaka Shin-ya <zstanaka at archer dot livedoor dot com>
|
||||
Tobias Poschwatta <posch at sourceforge dot net>
|
||||
Tony Li <tli at procket dot com>
|
||||
Torsten Landschoff <torsten at debian dot org>
|
||||
Uns Lider <unslider at miranda dot org>
|
||||
Uwe Girlich <Uwe dot Girlich at philosys dot de>
|
||||
Wesley Shields <wxs at FreeBSD dot org>
|
||||
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>
|
||||
|
||||
The original LBL crew:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
Description = "Change BPF permissions";
|
||||
Provides = ("Non-root permission to capture or send raw packets");
|
||||
Provides = ("ChmodBPF");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.21.2.8 2008-06-12 20:25:38 guy Exp $ (LBL)
|
||||
@(#) $Header: /tcpdump/master/libpcap/INSTALL.txt,v 1.29 2008-06-12 20:21:51 guy Exp $ (LBL)
|
||||
|
||||
To build libpcap, run "./configure" (a shell script). The configure
|
||||
script will determine your system attributes and generate an
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.108.2.28 2008-10-23 22:13:21 guy Exp $ (LBL)
|
||||
# @(#) $Header: /tcpdump/master/libpcap/Makefile.in,v 1.142 2008-11-22 17:30:24 guy Exp $ (LBL)
|
||||
|
||||
#
|
||||
# Various configurable paths (remember to edit Makefile.in, not Makefile)
|
||||
@@ -44,14 +44,17 @@ VPATH = @srcdir@
|
||||
# You shouldn't need to edit anything below.
|
||||
#
|
||||
|
||||
LD = /usr/bin/ld
|
||||
CC = @CC@
|
||||
CCOPT = @V_CCOPT@
|
||||
INCLS = -I. @V_INCLS@
|
||||
DEFS = @DEFS@ @V_DEFS@
|
||||
LIBS = @V_LIBS@
|
||||
DAGLIBS = @DAGLIBS@
|
||||
DEPLIBS = @DEPLIBS@
|
||||
ADDLOBJS = @ADDLOBJS@
|
||||
ADDLARCHIVEOBJS = @ADDLARCHIVEOBJS@
|
||||
LIBS = @LIBS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
DYEXT = @DYEXT@
|
||||
V_RPATH_OPT = @V_RPATH_OPT@
|
||||
PROG=libpcap
|
||||
|
||||
# Standard CFLAGS
|
||||
@@ -69,12 +72,13 @@ RANLIB = @RANLIB@
|
||||
@rm -f $@
|
||||
$(CC) $(CFLAGS) -c $(srcdir)/$*.c
|
||||
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@
|
||||
PSRC = pcap-@V_PCAP@.c @USB_SRC@ @BT_SRC@ @CAN_SRC@
|
||||
FSRC = fad-@V_FINDALLDEVS@.c
|
||||
SSRC = @SSRC@
|
||||
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c \
|
||||
etherent.c savefile.c bpf_filter.c bpf_image.c bpf_dump.c
|
||||
GENSRC = scanner.c grammar.c version.c
|
||||
CSRC = pcap.c inet.c gencode.c optimize.c nametoaddr.c etherent.c \
|
||||
savefile.c sf-pcap.c sf-pcap-ng.c pcap-common.c \
|
||||
bpf_image.c bpf_dump.c
|
||||
GENSRC = scanner.c grammar.c bpf_filter.c version.c
|
||||
LIBOBJS = @LIBOBJS@
|
||||
|
||||
SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||
@@ -82,8 +86,20 @@ SRC = $(PSRC) $(FSRC) $(CSRC) $(SSRC) $(GENSRC)
|
||||
# We would like to say "OBJ = $(SRC:.c=.o)" but Ultrix's make cannot
|
||||
# hack the extra indirection
|
||||
OBJ = $(PSRC:.c=.o) $(FSRC:.c=.o) $(CSRC:.c=.o) $(SSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS)
|
||||
HDR = \
|
||||
acconfig.h \
|
||||
PUBHDR = \
|
||||
pcap.h \
|
||||
pcap-bpf.h \
|
||||
pcap-namedb.h \
|
||||
pcap/bpf.h \
|
||||
pcap/bluetooth.h \
|
||||
pcap/ipnet.h \
|
||||
pcap/namedb.h \
|
||||
pcap/pcap.h \
|
||||
pcap/sll.h \
|
||||
pcap/vlan.h \
|
||||
pcap/usb.h
|
||||
|
||||
HDR = $(PUBHDR) \
|
||||
arcnet.h \
|
||||
atmuni31.h \
|
||||
ethertype.h \
|
||||
@@ -91,30 +107,23 @@ HDR = \
|
||||
ieee80211.h \
|
||||
llc.h \
|
||||
nlpid.h \
|
||||
pcap/bluetooth.h \
|
||||
pcap/bpf.h \
|
||||
pcap/namedb.h \
|
||||
pcap/pcap.h \
|
||||
pcap/sll.h \
|
||||
pcap/usb.h \
|
||||
pcap/vlan.h \
|
||||
pcap.h \
|
||||
pcap-common.h \
|
||||
pcap-int.h \
|
||||
pcap-namedb.h \
|
||||
pcap-stdinc.h \
|
||||
ppp.h \
|
||||
sf-pcap.h \
|
||||
sf-pcap-ng.h \
|
||||
sunatmpos.h
|
||||
|
||||
GENHDR = \
|
||||
scanner.h tokdefs.h version.h
|
||||
|
||||
TAGHDR = \
|
||||
pcap-bpf.h
|
||||
|
||||
TAGFILES = \
|
||||
$(SRC) $(HDR) $(TAGHDR)
|
||||
$(SRC) $(HDR)
|
||||
|
||||
CLEANFILES = $(OBJ) libpcap.a lex.yy.c
|
||||
CLEANFILES = $(OBJ) libpcap.* filtertest findalldevstest selpolltest \
|
||||
opentest $(PROG)-`cat $(srcdir)/VERSION`.tar.gz \
|
||||
lex.yy.c pcap-config
|
||||
|
||||
MAN1 = pcap-config.1
|
||||
|
||||
@@ -246,13 +255,14 @@ EXTRA_DIST = \
|
||||
msdos/pktdrvr.c \
|
||||
msdos/pktdrvr.h \
|
||||
msdos/readme.dos \
|
||||
net/bpf_filter.c \
|
||||
opentest.c \
|
||||
org.tcpdump.chmod_bpf.plist \
|
||||
packaging/pcap.spec.in \
|
||||
pcap-bpf.c \
|
||||
pcap-bpf.h \
|
||||
pcap-bt-linux.c \
|
||||
pcap-bt-linux.h \
|
||||
pcap-can-linux.c \
|
||||
pcap-can-linux.h \
|
||||
pcap-config.in \
|
||||
pcap-dag.c \
|
||||
pcap-dag.h \
|
||||
@@ -272,6 +282,8 @@ EXTRA_DIST = \
|
||||
pcap-sita.h \
|
||||
pcap-sita.c \
|
||||
pcap-sita.html \
|
||||
pcap-snf.c \
|
||||
pcap-snf.h \
|
||||
pcap-snit.c \
|
||||
pcap-snoop.c \
|
||||
pcap-usb-linux.c \
|
||||
@@ -279,6 +291,7 @@ EXTRA_DIST = \
|
||||
pcap-win32.c \
|
||||
runlex.sh \
|
||||
scanner.l \
|
||||
selpolltest.c \
|
||||
Win32/Include/Gnuc.h \
|
||||
Win32/Include/addrinfo.h \
|
||||
Win32/Include/bittypes.h \
|
||||
@@ -303,7 +316,7 @@ EXTRA_DIST = \
|
||||
Win32/Src/inet_net.c \
|
||||
Win32/Src/inet_pton.c
|
||||
|
||||
all: libpcap.a pcap-config
|
||||
all: libpcap.a shared pcap-config
|
||||
|
||||
# Inhibit implicit rule Make seems to have for using yacc/lex to
|
||||
# recompile new scanner.c/grammar.c -- we ship ones which we want to
|
||||
@@ -316,34 +329,86 @@ scanner.c:
|
||||
|
||||
libpcap.a: $(OBJ)
|
||||
@rm -f $@
|
||||
$(AR) rc $@ $(OBJ) $(LIBS)
|
||||
ar rc $@ $(OBJ) $(ADDLARCHIVEOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
shared: libpcap.$(DYEXT)
|
||||
|
||||
#
|
||||
# XXX - this works with GNU ld, but won't necessarily work with native
|
||||
# ld on, for example, various SVR4-flavored platforms, or Digital UNIX.
|
||||
#
|
||||
libpcap.so: $(OBJ)
|
||||
@rm -f $@
|
||||
$(CC) -shared -Wl,-soname,$@.1 -o $@.`cat $(srcdir)/VERSION` $(OBJ) $(DAGLIBS)
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
@V_SHLIB_CMD@ @V_SHLIB_OPT@ @V_SONAME_OPT@$@.$$MAJOR_VER $(LDFLAGS) \
|
||||
-o $@.$$VER $(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# The following rule succeeds, but the result is untested.
|
||||
#
|
||||
# XXX - OS X installs the library as "libpcap.A.dylib", with that as the
|
||||
# install_name, and sets the current version to 1 as well. VERSION
|
||||
# might contain a not-purely-numeric version number, but
|
||||
# -current_version requires a purely numeric version, so this won't
|
||||
# work with top-of-tree builds.
|
||||
# In Mac OS X, the libpcap dylib has the name "libpcap.A.dylib", with
|
||||
# its full path as the install_name, and with the compatibility and
|
||||
# current version both set to 1. The compatibility version is set to
|
||||
# 1 so that programs built with a newer version of the library will run
|
||||
# against older versions; multi-platform software probably will fail if
|
||||
# it uses APIs added in the newer version, but Mac OS X-specific software
|
||||
# will use weak linking and check at run time whether those APIs are
|
||||
# available.
|
||||
#
|
||||
# We also use "A" as the major version, and 1 as the compatibility version,
|
||||
# but set the current version to the value in VERSION, with any non-numeric
|
||||
# stuff stripped off (the compatibility and current version must be of the
|
||||
# form X[.Y[.Z]], with Y and Z possibly absent, and with all components
|
||||
# numeric).
|
||||
#
|
||||
libpcap.dylib: $(OBJ)
|
||||
rm -f libpcap*.dylib
|
||||
$(CC) -dynamiclib -undefined error -o libpcap.`cat $(srcdir)/VERSION`.dylib $(OBJ) \
|
||||
-install_name $(libdir)/libpcap.A.dylib \
|
||||
-compatibility_version 1 \
|
||||
-current_version `sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
COMPAT_VER=1; \
|
||||
CURRENT_VER=`sed 's/[^0-9.].*$$//' $(srcdir)/VERSION`; \
|
||||
$(CC) -dynamiclib -undefined error $(LDFLAGS) \
|
||||
-o libpcap.$$VER.dylib $(OBJ) $(ADDLOBJS) $(LIBS) \
|
||||
-install_name $(libdir)/libpcap.$$MAJOR_VER.dylib \
|
||||
-compatibility_version $$COMPAT_VER \
|
||||
-current_version $$CURRENT_VER
|
||||
|
||||
#
|
||||
# The HP-UX linker manual says that the convention for a versioned library
|
||||
# is libXXX.{number}, not libXXX.sl.{number}. That appears to be the case
|
||||
# on at least one HP-UX 11.00 system; libXXX.sl is a symlink to
|
||||
# libXXX.{number}.
|
||||
#
|
||||
# The manual also says "library-level versioning" (think "sonames") was
|
||||
# added in HP-UX 10.0.
|
||||
#
|
||||
# XXX - this assumes we're using the HP linker, rather than the GNU
|
||||
# linker, even with GCC.
|
||||
#
|
||||
libpcap.sl: $(OBJ)
|
||||
@MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f libpcap.$$MAJOR_VER
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
ld -b $(LDFLAGS) -o libpcap.$$MAJOR_VER +h libpcap.$$MAJOR_VER \
|
||||
$(OBJ) $(ADDLOBJS) $(LIBS)
|
||||
|
||||
#
|
||||
# AIX is different from everybody else. A shared library is an archive
|
||||
# library with one or more shared-object components. We still build a
|
||||
# normal static archive library on AIX, for the benefit of the traditional
|
||||
# scheme of building libpcap and tcpdump in subdirectories of the
|
||||
# same directory, with tcpdump statically linked with the libpcap
|
||||
# in question, but we also build a shared library as "libpcap.shareda"
|
||||
# and install *it*, rather than the static library, as "libpcap.a".
|
||||
#
|
||||
libpcap.shareda: $(OBJ)
|
||||
@rm -f $@ shr.o
|
||||
$(CC) @V_SHLIB_OPT@ -o shr.o $(OBJ) $(ADDLOBJS) $(LDFLAGS) $(LIBS)
|
||||
ar rc $@ shr.o
|
||||
|
||||
#
|
||||
# For platforms that don't support shared libraries (or on which we
|
||||
# don't support shared libraries).
|
||||
#
|
||||
libpcap.none:
|
||||
|
||||
scanner.o: scanner.c tokdefs.h
|
||||
$(CC) $(CFLAGS) -c scanner.c
|
||||
@@ -362,7 +427,13 @@ snprintf.o: $(srcdir)/missing/snprintf.c
|
||||
|
||||
version.c: $(srcdir)/VERSION
|
||||
@rm -f $@
|
||||
sed -e 's/.*/char pcap_version[] = "&";/' $(srcdir)/VERSION > $@
|
||||
if grep GIT ${srcdir}/VERSION >/dev/null; then \
|
||||
read ver <${srcdir}/VERSION; \
|
||||
echo $$ver | tr -d '\012'; \
|
||||
date +_%Y_%m_%d; \
|
||||
else \
|
||||
cat ${srcdir}/VERSION; \
|
||||
fi | sed -e 's/.*/char pcap_version[] = "&";/' > $@
|
||||
|
||||
#
|
||||
# NOTE: this really is supposed to be static; importing a string
|
||||
@@ -373,7 +444,13 @@ version.c: $(srcdir)/VERSION
|
||||
#
|
||||
version.h: $(srcdir)/VERSION
|
||||
@rm -f $@
|
||||
sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' $(srcdir)/VERSION > $@
|
||||
if grep GIT ${srcdir}/VERSION >/dev/null; then \
|
||||
read ver <${srcdir}/VERSION; \
|
||||
echo $$ver | tr -d '\012'; \
|
||||
date +_%Y_%m_%d; \
|
||||
else \
|
||||
cat ${srcdir}/VERSION; \
|
||||
fi | sed -e 's/.*/static const char pcap_version_string[] = "libpcap version &";/' > $@
|
||||
|
||||
bpf_filter.c: $(srcdir)/bpf/net/bpf_filter.c
|
||||
rm -f bpf_filter.c
|
||||
@@ -385,12 +462,13 @@ bpf_filter.o: bpf_filter.c
|
||||
#
|
||||
# Generate the pcap-config script.
|
||||
#
|
||||
pcap-config: pcap-config.in Makefile
|
||||
pcap-config: $(srcdir)/pcap-config.in
|
||||
@rm -f $@ $@.tmp
|
||||
sed -e 's|@includedir[@]|$(includedir)|g' \
|
||||
-e 's|@libdir[@]|$(libdir)|g' \
|
||||
-e 's|@DEPLIBS[@]|$(DEPLIBS)|g' \
|
||||
pcap-config.in >$@.tmp
|
||||
-e 's|@LIBS[@]|$(LIBS)|g' \
|
||||
-e 's|@V_RPATH_OPT[@]|$(V_RPATH_OPT)|g' \
|
||||
$(srcdir)/pcap-config.in >$@.tmp
|
||||
mv $@.tmp $@
|
||||
chmod a+x $@
|
||||
|
||||
@@ -398,16 +476,20 @@ pcap-config: pcap-config.in Makefile
|
||||
# Test programs - not built by default, and not installed.
|
||||
#
|
||||
filtertest: filtertest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o filtertest filtertest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o filtertest $(srcdir)/filtertest.c libpcap.a $(LIBS)
|
||||
|
||||
findalldevstest: findalldevstest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o findalldevstest findalldevstest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o findalldevstest $(srcdir)/findalldevstest.c libpcap.a $(LIBS)
|
||||
|
||||
install: libpcap.a pcap-config
|
||||
selpolltest: selpolltest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o selpolltest $(srcdir)/selpolltest.c libpcap.a $(LIBS)
|
||||
|
||||
opentest: opentest.c libpcap.a
|
||||
$(CC) $(CFLAGS) -I. -L. -o opentest $(srcdir)/opentest.c libpcap.a $(LIBS)
|
||||
|
||||
install: install-shared install-archive pcap-config
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
||||
[ -d $(DESTDIR)$(includedir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(includedir); chmod 755 $(DESTDIR)$(includedir))
|
||||
[ -d $(DESTDIR)$(includedir)/pcap ] || \
|
||||
@@ -420,91 +502,151 @@ install: libpcap.a pcap-config
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_FILE_FORMATS@)
|
||||
[ -d $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@ ] || \
|
||||
(mkdir -p $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@; chmod 755 $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@)
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/pcap.h \
|
||||
$(DESTDIR)$(includedir)/pcap/pcap.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/bpf.h \
|
||||
$(DESTDIR)$(includedir)/pcap/bpf.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/namedb.h \
|
||||
$(DESTDIR)$(includedir)/pcap/namedb.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/sll.h \
|
||||
$(DESTDIR)$(includedir)/pcap/sll.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap/usb.h \
|
||||
$(DESTDIR)$(includedir)/pcap/usb.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap.h $(DESTDIR)$(includedir)/pcap.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap-bpf.h \
|
||||
$(DESTDIR)$(includedir)/pcap-bpf.h
|
||||
$(INSTALL_DATA) $(srcdir)/pcap-namedb.h \
|
||||
$(DESTDIR)$(includedir)/pcap-namedb.h
|
||||
for i in $(PUBHDR); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(includedir)/$$i; done
|
||||
[ -d $(DESTDIR)$(bindir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir))
|
||||
$(INSTALL_PROGRAM) pcap-config $(DESTDIR)$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP); do \
|
||||
for i in $(MAN3PCAP_NOEXPAND); do \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i \
|
||||
$(DESTDIR)$(mandir)/man3/$$i; done
|
||||
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_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_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
|
||||
for i in $(MANFILE); do \
|
||||
$(INSTALL_DATA) $(srcdir)/`echo $$i | sed 's/.manfile.in/.manfile/'` \
|
||||
$(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
|
||||
for i in $(MANMISC); do \
|
||||
$(INSTALL_DATA) $(srcdir)/`echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
$(INSTALL_DATA) `echo $$i | sed 's/.manmisc.in/.manmisc/'` \
|
||||
$(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
install-shared: install-shared-$(DYEXT)
|
||||
install-shared-so: libpcap.so
|
||||
$(INSTALL_PROGRAM) libpcap.so.`cat VERSION` $(DESTDIR)$(libdir)/libpcap.so.`cat VERSION`
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
ln -sf libpcap.so.$$VER $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
ln -sf libpcap.so.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.so
|
||||
install-shared-dylib: libpcap.dylib
|
||||
$(INSTALL_PROGRAM) libpcap.`cat VERSION`.dylib $(DESTDIR)$(libdir)/libpcap.`cat VERSION`.dylib
|
||||
VER=`cat VERSION`; cd $(DESTDIR)$(libdir) && ln -sf libpcap.$$VER.dylib libpcap.A.dylib; ln -sf libpcap.A.dylib libpcap.dylib
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
ln -sf libpcap.$$VER.dylib $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
ln -sf libpcap.$$MAJOR_VER.dylib $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
install-shared-sl: libpcap.sl
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
$(INSTALL_PROGRAM) libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)
|
||||
ln -sf libpcap.$$MAJOR_VER $(DESTDIR)$(libdir)/libpcap.sl
|
||||
install-shared-shareda: libpcap.shareda
|
||||
#
|
||||
# AIX shared libraries are weird. They're archive libraries
|
||||
# with one or more shared object components.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_PROGRAM) libpcap.shareda $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-shared-none:
|
||||
|
||||
uninstall:
|
||||
install-archive: install-archive-$(DYEXT)
|
||||
install-archive-so install-archive-dylib install-archive-sl install-archive-none: libpcap.a
|
||||
#
|
||||
# Most platforms have separate suffixes for shared and
|
||||
# archive libraries, so we install both.
|
||||
#
|
||||
[ -d $(DESTDIR)$(libdir) ] || \
|
||||
(mkdir -p $(DESTDIR)$(libdir); chmod 755 $(DESTDIR)$(libdir))
|
||||
$(INSTALL_DATA) libpcap.a $(DESTDIR)$(libdir)/libpcap.a
|
||||
$(RANLIB) $(DESTDIR)$(libdir)/libpcap.a
|
||||
install-archive-shareda:
|
||||
#
|
||||
# AIX, however, doesn't, so we don't install the archive
|
||||
# library on AIX.
|
||||
#
|
||||
|
||||
uninstall: uninstall-shared
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
rm -f $(DESTDIR)$(includedir)/pcap/pcap.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap/bpf.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap/namedb.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap/sll.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap/usb.h
|
||||
for i in $(PUBHDR); do \
|
||||
rm -f $(DESTDIR)$(includedir)/$$i; done
|
||||
-rmdir $(DESTDIR)$(includedir)/pcap
|
||||
rm -f $(DESTDIR)$(includedir)/pcap.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap-bpf.h
|
||||
rm -f $(DESTDIR)$(includedir)/pcap-namedb.h
|
||||
rm -f $(DESTDIR)/$(bindir)/pcap-config
|
||||
for i in $(MAN1); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man1/$$i; done
|
||||
for i in $(MAN3PCAP); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man3/$$i; done
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
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_fopen_offline.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_getnonblock.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_datalink_val_to_description.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_dump_fopen.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_perror.3pcap
|
||||
rm -f $(DESTDIR)$(mandir)/man3/pcap_sendpacket.3pcap
|
||||
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_fopen_offline.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
|
||||
for i in $(MANMISC); do \
|
||||
rm -f $(DESTDIR)$(mandir)/man@MAN_MISC_INFO@/`echo $$i | sed 's/.manmisc.in/.@MAN_MISC_INFO@/'`; done
|
||||
|
||||
uninstall-shared: uninstall-shared-$(DYEXT)
|
||||
uninstall-shared-so:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.so
|
||||
uninstall-shared-dylib:
|
||||
VER=`cat $(srcdir)/VERSION`; \
|
||||
MAJOR_VER=A; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER.dylib; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.dylib
|
||||
uninstall-shared-sl:
|
||||
MAJOR_VER=`sed 's/\([0-9][0-9]*\)\..*/\1/' $(srcdir)/VERSION`; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.$$MAJOR_VER; \
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.sl
|
||||
uninstall-shared-shareda:
|
||||
rm -f $(DESTDIR)$(libdir)/libpcap.a
|
||||
uninstall-shared-none:
|
||||
|
||||
clean:
|
||||
rm -f $(CLEANFILES) libpcap*.dylib libpcap.so*
|
||||
rm -f $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile config.cache config.log config.status \
|
||||
@@ -520,7 +662,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) \
|
||||
|
||||
@@ -1,29 +1,5 @@
|
||||
o Included this file, renamed directory from libpcap-1.0.0 to libpcap.
|
||||
|
||||
o Applied this configure.in patch which removes a useless test which caused configure to
|
||||
fail on Solaris 9 (and other versions). This was fixed by libpcap in SVN a year and a half
|
||||
ago but they haven't made a release since then. Details:
|
||||
http://sourceforge.net/tracker/index.php?func=detail&aid=2224954&group_id=53067&atid=469577
|
||||
|
||||
--- configure.in (revision 17039)
|
||||
+++ configure.in (working copy)
|
||||
@@ -358,7 +358,6 @@
|
||||
#include <net/if.h>
|
||||
#include <linux/types.h>
|
||||
])
|
||||
- AC_CHECK_HEADERS()
|
||||
AC_LBL_TPACKET_STATS
|
||||
AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
;;
|
||||
|
||||
o Removed these files and directories:
|
||||
packaging/
|
||||
config.guess
|
||||
config.sub
|
||||
install-sh
|
||||
Win32
|
||||
msdos
|
||||
|
||||
o Added @CFLAGS@ to the CFLAGS definition in Makefile.in to pick up -g
|
||||
if configure determines that it is supported:
|
||||
|
||||
@@ -157,129 +133,4 @@ o Eliminated Lex/Yacc requirement and added the generated files:
|
||||
AC_SUBST(DYEXT)
|
||||
AC_SUBST(DAGLIBS)
|
||||
|
||||
o The following patch removes some code that apparently causes libpcap
|
||||
on Solaris to wait for 64K chunks before returning in some cases,
|
||||
regardless of the timeout values. Problem report and original patch
|
||||
came from Ben Harris (bjh21(a)cam.ac.uk)
|
||||
|
||||
--- dlpisubs.c.orig 2009-10-27 10:24:45.000000000 -0600
|
||||
+++ dlpisubs.c 2009-10-27 10:24:49.000000000 -0600
|
||||
@@ -291,14 +291,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
- /* 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;
|
||||
- }
|
||||
-
|
||||
return (retv);
|
||||
}
|
||||
#endif /* HAVE_SYS_BUFMOD_H */
|
||||
|
||||
o Merged commit 43acbb77a8e0b3346b574b3e28793de2d6985e69 from
|
||||
git://bpf.tcpdump.org/libpcap, whose log message is "Work around an
|
||||
annoying Snow Leopard BPF bug that causes sub-second timeouts not to
|
||||
work in 64-bit userland code (Snow Leopard's GCC builds 64-bit by
|
||||
default on 64-bit machines)."
|
||||
|
||||
Index: configure.in
|
||||
===================================================================
|
||||
--- configure.in (revision 17348)
|
||||
+++ configure.in (revision 17349)
|
||||
@@ -381,6 +381,19 @@
|
||||
[define if the system supports zerocopy BPF])
|
||||
],
|
||||
AC_MSG_RESULT(no))
|
||||
+
|
||||
+ #
|
||||
+ # Check whether we have struct BPF_TIMEVAL.
|
||||
+ #
|
||||
+ AC_CHECK_TYPES(struct BPF_TIMEVAL,,,
|
||||
+ [
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/ioctl.h>
|
||||
+#ifdef HAVE_SYS_IOCCOM_H
|
||||
+#include <sys/ioccom.h>
|
||||
+#endif
|
||||
+#include <net/bpf.h>
|
||||
+ ])
|
||||
;;
|
||||
|
||||
dag)
|
||||
Index: config.h.in
|
||||
===================================================================
|
||||
--- config.h.in (revision 17348)
|
||||
+++ config.h.in (revision 17349)
|
||||
@@ -128,6 +128,9 @@
|
||||
/* Define to 1 if you have the `strlcpy' function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
+/* Define to 1 if the system has the type `struct BPF_TIMEVAL'. */
|
||||
+#undef HAVE_STRUCT_BPF_TIMEVAL
|
||||
+
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
#undef HAVE_STRUCT_ETHER_ADDR
|
||||
|
||||
Index: pcap-bpf.c
|
||||
===================================================================
|
||||
--- pcap-bpf.c (revision 17348)
|
||||
+++ pcap-bpf.c (revision 17349)
|
||||
@@ -1859,16 +1859,45 @@
|
||||
* XXX - is this seconds/nanoseconds in AIX?
|
||||
* (Treating it as such doesn't fix the timeout
|
||||
* problem described below.)
|
||||
+ *
|
||||
+ * XXX - Mac OS X 10.6 mishandles BIOCSRTIMEOUT in
|
||||
+ * 64-bit userland - it takes, as an argument, a
|
||||
+ * "struct BPF_TIMEVAL", which has 32-bit tv_sec
|
||||
+ * and tv_usec, rather than a "struct timeval".
|
||||
+ *
|
||||
+ * If this platform defines "struct BPF_TIMEVAL",
|
||||
+ * we check whether the structure size in BIOCSRTIMEOUT
|
||||
+ * is that of a "struct timeval" and, if not, we use
|
||||
+ * a "struct BPF_TIMEVAL" rather than a "struct timeval".
|
||||
+ * (That way, if the bug is fixed in a future release,
|
||||
+ * we will still do the right thing.)
|
||||
*/
|
||||
struct timeval to;
|
||||
- to.tv_sec = p->md.timeout / 1000;
|
||||
- to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
- if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
|
||||
- snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSRTIMEOUT: %s",
|
||||
- pcap_strerror(errno));
|
||||
- status = PCAP_ERROR;
|
||||
- goto bad;
|
||||
+#ifdef HAVE_STRUCT_BPF_TIMEVAL
|
||||
+ struct BPF_TIMEVAL bpf_to;
|
||||
+
|
||||
+ if (IOCPARM_LEN(BIOCSRTIMEOUT) != sizeof(struct timeval)) {
|
||||
+ bpf_to.tv_sec = p->md.timeout / 1000;
|
||||
+ bpf_to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
+ if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&bpf_to) < 0) {
|
||||
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
+ "BIOCSRTIMEOUT: %s", pcap_strerror(errno));
|
||||
+ status = PCAP_ERROR;
|
||||
+ goto bad;
|
||||
+ }
|
||||
+ } else {
|
||||
+#endif
|
||||
+ to.tv_sec = p->md.timeout / 1000;
|
||||
+ to.tv_usec = (p->md.timeout * 1000) % 1000000;
|
||||
+ if (ioctl(p->fd, BIOCSRTIMEOUT, (caddr_t)&to) < 0) {
|
||||
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
+ "BIOCSRTIMEOUT: %s", pcap_strerror(errno));
|
||||
+ status = PCAP_ERROR;
|
||||
+ goto bad;
|
||||
+ }
|
||||
+#ifdef HAVE_STRUCT_BPF_TIMEVAL
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
|
||||
#ifdef _AIX
|
||||
|
||||
o Regenerated configure.
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
@(#) $Header: /tcpdump/master/libpcap/README,v 1.30.4.3 2008-10-17 10:39:20 ken Exp $ (LBL)
|
||||
@(#) $Header: /tcpdump/master/libpcap/README,v 1.34 2008-12-14 19:44:14 guy Exp $ (LBL)
|
||||
|
||||
LIBPCAP 1.0.0
|
||||
LIBPCAP 1.x.y
|
||||
|
||||
www.tcpdump.org
|
||||
|
||||
Please send inquiries/comments/reports to:
|
||||
tcpdump-workers@lists.tcpdump.org
|
||||
|
||||
Anonymous CVS is available via:
|
||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master login
|
||||
(password "anoncvs")
|
||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master checkout libpcap
|
||||
Anonymous Git is available via:
|
||||
git clone git://bpf.tcpdump.org/libpcap
|
||||
|
||||
Version 1.0.0 of LIBPCAP can be retrieved with the CVS tag "libpcap_1_0":
|
||||
cvs -d :pserver:tcpdump@cvs.tcpdump.org:/tcpdump/master checkout -r libpcap_1_0 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 against the master copy to the libpcap project on
|
||||
sourceforge.net.
|
||||
@@ -80,10 +78,10 @@ information on configuring that option.
|
||||
Note to Linux distributions and *BSD systems that include libpcap:
|
||||
|
||||
There's now a rule to make a shared library, which should work on Linux
|
||||
and *BSD (and OS X).
|
||||
and *BSD, among other platforms.
|
||||
|
||||
It sets the soname of the library to "libpcap.so.1"; this is what it
|
||||
should be, *NOT* libpcap.so.1.0 or libpcap.so.1.0.0 or something such as
|
||||
should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
|
||||
that.
|
||||
|
||||
We've been maintaining binary compatibility between libpcap releases for
|
||||
|
||||
@@ -21,7 +21,7 @@ The WinPcap source code already contains a recent (usually the latest
|
||||
stable) version of libpcap. If you need to compile a different one,
|
||||
simply download it from www.tcpdump.org and copy the sources in the
|
||||
winpcap\wpcap\libpcap folder of the WinPcap distribution. If you want to
|
||||
compile a libpcap source retrieved from the tcpdump.org CVS, you will
|
||||
compile a libpcap source retrieved from the tcpdump.org Git, you will
|
||||
have to create the scanner and the grammar by hand (with lex and yacc)
|
||||
or with the cygnus makefile, since The Visual Studio project is not able
|
||||
to build them.
|
||||
|
||||
@@ -69,6 +69,26 @@ file says:
|
||||
file linux/Documentation/networking/filter.txt for more information.
|
||||
If unsure, say N.
|
||||
|
||||
Note that, by default, libpcap will, if libnl is present, build with it;
|
||||
it uses libnl to support monitor mode on mac80211 devices. There is a
|
||||
configuration option to disable building with libnl, but, if that option
|
||||
is chosen, the monitor-mode APIs (as used by tcpdump's "-I" flag, and as
|
||||
will probably be used by other applications in the future) won't work
|
||||
properly on mac80211 devices.
|
||||
|
||||
Linux's run-time linker allows shared libraries to be linked with other
|
||||
shared libraries, which means that if an older version of a shared
|
||||
library doesn't require routines from some other shared library, and a
|
||||
later version of the shared library does require those routines, the
|
||||
later version of the shared library can be linked with that other shared
|
||||
library and, if it's otherwise binary-compatible with the older version,
|
||||
can replace that older version without breaking applications built with
|
||||
the older version, and without breaking configure scripts or the build
|
||||
procedure for applications whose configure script doesn't use the
|
||||
pcap-config script if they build with the shared library. (The build
|
||||
procedure for applications whose configure scripts use the pcap-config
|
||||
script if present will not break even if they build with the static
|
||||
library.)
|
||||
|
||||
Statistics:
|
||||
Statistics reported by pcap are platform specific. The statistics
|
||||
|
||||
@@ -67,3 +67,8 @@ give the administrative users permission to read but not write the BPF
|
||||
devices, you can have the script change the owner to that user, the
|
||||
group to "admin", and the permissions to rw-r-----. Other possibilities
|
||||
are left as an exercise for the reader.
|
||||
|
||||
(NOTE: due to a bug in Snow Leopard, if you change the permissions not
|
||||
to grant write permission to everybody who should be allowed to capture
|
||||
traffic, non-root users who cannot open the BPF devices for writing will
|
||||
not be able to capture outgoing packets.)
|
||||
|
||||
@@ -6,7 +6,7 @@ Important stuff (to be done before the next release)
|
||||
|
||||
General
|
||||
|
||||
- configure should not be in the CVS. Most open source projects have an
|
||||
- configure should not be in Git. Most open source projects have an
|
||||
autogen.sh script to run autoconf etc. after checkout. I think we
|
||||
should stick to the standard.
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.0
|
||||
1.1.1
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Long story short: aclocal.m4 depends on autoconf 2.13
|
||||
* implementation details wrt "const"; newer versions
|
||||
* have different implementation details so for now we
|
||||
* put "const" here. This may cause duplicate definitions
|
||||
* in config.h but that should be OK since they're the same.
|
||||
*/
|
||||
#undef const
|
||||
400
libpcap/aclocal.m4
vendored
400
libpcap/aclocal.m4
vendored
@@ -1,4 +1,4 @@
|
||||
dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.86.2.6 2008-09-28 17:13:37 guy Exp $ (LBL)
|
||||
dnl @(#) $Header: /tcpdump/master/libpcap/aclocal.m4,v 1.93 2008-11-18 07:29:48 guy Exp $ (LBL)
|
||||
dnl
|
||||
dnl Copyright (c) 1995, 1996, 1997, 1998
|
||||
dnl The Regents of the University of California. All rights reserved.
|
||||
@@ -23,27 +23,23 @@ dnl LBL autoconf macros
|
||||
dnl
|
||||
|
||||
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 Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl It appears that newer versions of autoconf (2.64 and later) will,
|
||||
dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
|
||||
dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
|
||||
dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
|
||||
dnl in the Autoconf documentation.
|
||||
dnl
|
||||
dnl AC_LBL_C_INIT(copt, incls)
|
||||
dnl This causes a steaming heap of fail in our case, as we were, in
|
||||
dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
|
||||
dnl calling AC_PROG_CC, and then doing the tests we now do in
|
||||
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
|
||||
dnl results:
|
||||
dnl
|
||||
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.12)
|
||||
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])
|
||||
@@ -72,7 +68,33 @@ AC_DEFUN(AC_LBL_C_INIT,
|
||||
CC=cc
|
||||
export CC
|
||||
fi
|
||||
AC_PROG_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
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_C_INIT(copt, incls)
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
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
|
||||
@@ -117,10 +139,28 @@ AC_DEFUN(AC_LBL_C_INIT,
|
||||
AC_MSG_ERROR(see the INSTALL doc for more info)
|
||||
fi
|
||||
CFLAGS="$savedcflags"
|
||||
V_CCOPT="-Aa $V_CCOPT"
|
||||
$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)
|
||||
;;
|
||||
@@ -132,11 +172,15 @@ AC_DEFUN(AC_LBL_C_INIT,
|
||||
case "$host_os" in
|
||||
|
||||
irix*)
|
||||
V_CCOPT="$V_CCOPT -xansi -signed -g3"
|
||||
$1="$$1 -xansi -signed -g3"
|
||||
;;
|
||||
|
||||
osf*)
|
||||
V_CCOPT="$V_CCOPT -std1 -g3"
|
||||
#
|
||||
# Presumed to be DEC OSF/1, Digital UNIX, or
|
||||
# Tru64 UNIX.
|
||||
#
|
||||
$1="$$1 -g3"
|
||||
;;
|
||||
|
||||
ultrix*)
|
||||
@@ -150,13 +194,161 @@ AC_DEFUN(AC_LBL_C_INIT,
|
||||
ac_cv_lbl_cc_const_proto=no))
|
||||
AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
|
||||
if test $ac_cv_lbl_cc_const_proto = no ; then
|
||||
AC_DEFINE(const,)
|
||||
AC_DEFINE(const,[],
|
||||
[to handle Ultrix compilers that don't support const in prototypes])
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Determine what options are needed to build a shared library
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_SHLIBS_INIT
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
dnl V_CCOPT (modified to build position-independent code)
|
||||
dnl V_SHLIB_CMD
|
||||
dnl V_SHLIB_OPT
|
||||
dnl V_SONAME_OPT
|
||||
dnl V_RPATH_OPT
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_SHLIBS_INIT,
|
||||
[AC_PREREQ(2.50)
|
||||
if test "$GCC" = yes ; then
|
||||
#
|
||||
# On platforms where we build a shared library:
|
||||
#
|
||||
# add options to generate position-independent code,
|
||||
# if necessary (it's the default in AIX and Darwin/OS X);
|
||||
#
|
||||
# define option to set the soname of the shared library,
|
||||
# if the OS supports that;
|
||||
#
|
||||
# add options to specify, at link time, a directory to
|
||||
# add to the run-time search path, if that's necessary.
|
||||
#
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
case "$host_os" in
|
||||
|
||||
aix*)
|
||||
;;
|
||||
|
||||
freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
|
||||
#
|
||||
# Platforms where the linker is the GNU linker
|
||||
# or accepts command-line arguments like
|
||||
# those the GNU linker accepts.
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -fpic"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
V_CCOPT="$V_CCOPT -fpic"
|
||||
#
|
||||
# XXX - this assumes GCC is using the HP linker,
|
||||
# rather than the GNU linker, and that the "+h"
|
||||
# option is used on all HP-UX platforms, both .sl
|
||||
# and .so.
|
||||
#
|
||||
V_SONAME_OPT="-Wl,+h,"
|
||||
#
|
||||
# By default, directories specifed with -L
|
||||
# are added to the run-time search path, so
|
||||
# we don't add them in pcap-config.
|
||||
#
|
||||
;;
|
||||
|
||||
solaris*)
|
||||
V_CCOPT="$V_CCOPT -fpic"
|
||||
#
|
||||
# XXX - this assumes GCC is using the Sun linker,
|
||||
# rather than the GNU linker.
|
||||
#
|
||||
V_SONAME_OPT="-Wl,-h,"
|
||||
V_RPATH_OPT="-Wl,-R,"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
#
|
||||
# Set the appropriate compiler flags and, on platforms
|
||||
# where we build a shared library:
|
||||
#
|
||||
# add options to generate position-independent code,
|
||||
# if necessary (it's the default in Darwin/OS X);
|
||||
#
|
||||
# if we generate ".so" shared libraries, define the
|
||||
# appropriate options for building the shared library;
|
||||
#
|
||||
# add options to specify, at link time, a directory to
|
||||
# add to the run-time search path, if that's necessary.
|
||||
#
|
||||
# Note: spaces after V_SONAME_OPT are significant; on
|
||||
# some platforms the soname is passed with a GCC-like
|
||||
# "-Wl,-soname,{soname}" option, with the soname part
|
||||
# of the option, while on other platforms the C compiler
|
||||
# driver takes it as a regular option with the soname
|
||||
# following the option. The same applies to V_RPATH_OPT.
|
||||
#
|
||||
case "$host_os" in
|
||||
|
||||
aix*)
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-G -bnoentry -bexpall"
|
||||
;;
|
||||
|
||||
freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
|
||||
#
|
||||
# "cc" is GCC.
|
||||
#
|
||||
V_CCOPT="$V_CCOPT -fpic"
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
V_SONAME_OPT="-Wl,-soname,"
|
||||
V_RPATH_OPT="-Wl,-rpath,"
|
||||
;;
|
||||
|
||||
hpux*)
|
||||
V_CCOPT="$V_CCOPT +z"
|
||||
V_SHLIB_CMD="\$(LD)"
|
||||
V_SHLIB_OPT="-b"
|
||||
V_SONAME_OPT="+h "
|
||||
#
|
||||
# By default, directories specifed with -L
|
||||
# are added to the run-time search path, so
|
||||
# we don't add them in pcap-config.
|
||||
#
|
||||
;;
|
||||
|
||||
osf*)
|
||||
#
|
||||
# Presumed to be DEC OSF/1, Digital UNIX, or
|
||||
# Tru64 UNIX.
|
||||
#
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-shared"
|
||||
V_SONAME_OPT="-soname "
|
||||
V_RPATH_OPT="-rpath "
|
||||
;;
|
||||
|
||||
solaris*)
|
||||
V_CCOPT="$V_CCOPT -Kpic"
|
||||
V_SHLIB_CMD="\$(CC)"
|
||||
V_SHLIB_OPT="-G"
|
||||
V_SONAME_OPT="-h "
|
||||
V_RPATH_OPT="-R"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
])
|
||||
|
||||
#
|
||||
# Try compiling a sample of the type of code that appears in
|
||||
# gencode.c with "inline", "__inline__", and "__inline".
|
||||
@@ -208,114 +400,6 @@ AC_DEFUN(AC_LBL_C_INLINE,
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
|
||||
|
||||
dnl
|
||||
dnl Use pfopen.c if available and pfopen() not in standard libraries
|
||||
dnl Require libpcap
|
||||
dnl Look for libpcap in ..
|
||||
dnl Use the installed libpcap if there is no local version
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_LIBPCAP(pcapdep, incls)
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
dnl $1 (pcapdep set)
|
||||
dnl $2 (incls appended)
|
||||
dnl LIBS
|
||||
dnl LBL_LIBS
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_LIBPCAP,
|
||||
[AC_REQUIRE([AC_LBL_LIBRARY_NET])
|
||||
dnl
|
||||
dnl save a copy before locating libpcap.a
|
||||
dnl
|
||||
LBL_LIBS="$LIBS"
|
||||
pfopen=/usr/examples/packetfilter/pfopen.c
|
||||
if test -f $pfopen ; then
|
||||
AC_CHECK_FUNCS(pfopen)
|
||||
if test $ac_cv_func_pfopen = "no" ; then
|
||||
AC_MSG_RESULT(Using $pfopen)
|
||||
LIBS="$LIBS $pfopen"
|
||||
fi
|
||||
fi
|
||||
AC_MSG_CHECKING(for local pcap library)
|
||||
libpcap=FAIL
|
||||
lastdir=FAIL
|
||||
places=`ls .. | sed -e 's,/$,,' -e 's,^,../,' | \
|
||||
egrep '/libpcap-[[0-9]]*\.[[0-9]]*(\.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
|
||||
for dir in $places ../libpcap libpcap ; do
|
||||
basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//'`
|
||||
if test $lastdir = $basedir ; then
|
||||
dnl skip alphas when an actual release is present
|
||||
continue;
|
||||
fi
|
||||
lastdir=$dir
|
||||
if test -r $dir/pcap.c ; then
|
||||
libpcap=$dir/libpcap.a
|
||||
d=$dir
|
||||
dnl continue and select the last one that exists
|
||||
fi
|
||||
done
|
||||
if test $libpcap = FAIL ; then
|
||||
AC_MSG_RESULT(not found)
|
||||
AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
|
||||
if test $libpcap = FAIL ; then
|
||||
AC_MSG_ERROR(see the INSTALL doc for more info)
|
||||
fi
|
||||
else
|
||||
$1=$libpcap
|
||||
$2="-I$d $$2"
|
||||
AC_MSG_RESULT($libpcap)
|
||||
fi
|
||||
LIBS="$libpcap $LIBS"
|
||||
case "$host_os" in
|
||||
|
||||
aix*)
|
||||
pseexe="/lib/pse.exp"
|
||||
AC_MSG_CHECKING(for $pseexe)
|
||||
if test -f $pseexe ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBS="$LIBS -I:$pseexe"
|
||||
fi
|
||||
;;
|
||||
esac])
|
||||
|
||||
dnl
|
||||
dnl Define RETSIGTYPE and RETSIGVAL
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_TYPE_SIGNAL
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
dnl RETSIGTYPE (defined)
|
||||
dnl RETSIGVAL (defined)
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_TYPE_SIGNAL,
|
||||
[AC_BEFORE([$0], [AC_LBL_LIBPCAP])
|
||||
AC_TYPE_SIGNAL
|
||||
if test "$ac_cv_type_signal" = void ; then
|
||||
AC_DEFINE(RETSIGVAL,[],[return value of signal handlers])
|
||||
else
|
||||
AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers])
|
||||
fi
|
||||
case "$host_os" in
|
||||
|
||||
irix*)
|
||||
AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix])
|
||||
;;
|
||||
|
||||
*)
|
||||
dnl prefer sigset() to sigaction()
|
||||
AC_CHECK_FUNCS(sigset)
|
||||
if test $ac_cv_func_sigset = no ; then
|
||||
AC_CHECK_FUNCS(sigaction)
|
||||
fi
|
||||
;;
|
||||
esac])
|
||||
|
||||
dnl
|
||||
dnl If using gcc, make sure we have ANSI ioctl definitions
|
||||
dnl
|
||||
@@ -452,7 +536,7 @@ dnl
|
||||
dnl HAVE_SOCKADDR_SA_LEN (defined)
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
|
||||
[AC_MSG_CHECKING(if sockaddr struct has sa_len member)
|
||||
[AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
|
||||
AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
|
||||
AC_TRY_COMPILE([
|
||||
# include <sys/types.h>
|
||||
@@ -462,7 +546,7 @@ AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
|
||||
ac_cv_lbl_sockaddr_has_sa_len=no))
|
||||
AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
|
||||
if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
|
||||
AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has sa_len])
|
||||
AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
|
||||
fi])
|
||||
|
||||
dnl
|
||||
@@ -545,40 +629,10 @@ AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
|
||||
else
|
||||
ac_cv_lbl_have_run_path=no
|
||||
fi
|
||||
rm -f conftest*])
|
||||
rm -f -r conftest*])
|
||||
AC_MSG_RESULT($ac_cv_lbl_have_run_path)
|
||||
])
|
||||
|
||||
dnl
|
||||
dnl Due to the stupid way it's implemented, AC_CHECK_TYPE is nearly useless.
|
||||
dnl
|
||||
dnl usage:
|
||||
dnl
|
||||
dnl AC_LBL_CHECK_TYPE
|
||||
dnl
|
||||
dnl results:
|
||||
dnl
|
||||
dnl int32_t (defined)
|
||||
dnl u_int32_t (defined)
|
||||
dnl
|
||||
AC_DEFUN(AC_LBL_CHECK_TYPE,
|
||||
[AC_MSG_CHECKING(for $1 using $CC)
|
||||
AC_CACHE_VAL(ac_cv_lbl_have_$1,
|
||||
AC_TRY_COMPILE([
|
||||
# include "confdefs.h"
|
||||
# include <sys/types.h>
|
||||
# if STDC_HEADERS
|
||||
# include <stdlib.h>
|
||||
# include <stddef.h>
|
||||
# endif],
|
||||
[$1 i],
|
||||
ac_cv_lbl_have_$1=yes,
|
||||
ac_cv_lbl_have_$1=no))
|
||||
AC_MSG_RESULT($ac_cv_lbl_have_$1)
|
||||
if test $ac_cv_lbl_have_$1 = no ; then
|
||||
AC_DEFINE($1, $2, [if we have $1])
|
||||
fi])
|
||||
|
||||
dnl
|
||||
dnl Checks to see if unaligned memory accesses fail
|
||||
dnl
|
||||
@@ -671,7 +725,7 @@ EOF
|
||||
ac_cv_lbl_unaligned_fail=no
|
||||
fi
|
||||
fi
|
||||
rm -f conftest* core core.conftest
|
||||
rm -f -r conftest* core core.conftest
|
||||
;;
|
||||
esac])
|
||||
AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
|
||||
@@ -726,7 +780,8 @@ AC_DEFUN(AC_LBL_DEVEL,
|
||||
name="lbl/os-$os.h"
|
||||
if test -f $name ; then
|
||||
ln -s $name os-proto.h
|
||||
AC_DEFINE(HAVE_OS_PROTO_H,1,[if there's an os_proto.h])
|
||||
AC_DEFINE(HAVE_OS_PROTO_H, 1,
|
||||
[if there's an os_proto.h for this platform, to use additional prototypes])
|
||||
else
|
||||
AC_MSG_WARN(can't find $name)
|
||||
fi
|
||||
@@ -754,10 +809,11 @@ dnl
|
||||
|
||||
define(AC_LBL_CHECK_LIB,
|
||||
[AC_MSG_CHECKING([for $2 in -l$1])
|
||||
dnl Use a cache variable name containing both the library and function name,
|
||||
dnl because the test really is for library $1 defining function $2, not
|
||||
dnl just for library $1. Separate tests with the same $1 and different $2's
|
||||
dnl may have different results.
|
||||
dnl Use a cache variable name containing the library, function
|
||||
dnl name, and extra libraries to link with, because the test really is
|
||||
dnl for library $1 defining function $2, when linked with potinal
|
||||
dnl library $5, not just for library $1. Separate tests with the same
|
||||
dnl $1 and different $2's or $5's may have different results.
|
||||
ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
|
||||
AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
|
||||
[ac_save_LIBS="$LIBS"
|
||||
@@ -930,6 +986,8 @@ AC_DEFUN(AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,
|
||||
ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci=no))
|
||||
AC_MSG_RESULT($ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci)
|
||||
if test $ac_cv_lbl_linux_tpacket_auxdata_tp_vlan_tci = yes ; then
|
||||
HAVE_LINUX_TPACKET_AUXDATA=tp_vlan_tci
|
||||
AC_SUBST(HAVE_LINUX_TPACKET_AUXDATA)
|
||||
AC_DEFINE(HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI,1,[if tp_vlan_tci exists])
|
||||
fi])
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Id: arcnet.h,v 1.2 2001/04/24 02:17:52 guy Exp $ (LBL)
|
||||
* @(#) $Id: arcnet.h,v 1.2 2001-04-24 02:17:52 guy Exp $ (LBL)
|
||||
*
|
||||
* from: NetBSD: if_arc.h,v 1.13 1999/11/19 20:41:19 thorpej Exp
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/atmuni31.h,v 1.1.6.2 2007/10/22 19:30:14 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/atmuni31.h,v 1.3 2007-10-22 19:28:58 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Based on UNI3.1 standard by ATM Forum */
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#if !(defined(lint) || defined(KERNEL) || defined(_KERNEL))
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.45.2.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf/net/bpf_filter.c,v 1.46 2008-01-02 04:16:46 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -53,6 +53,15 @@ static const char rcsid[] _U_ =
|
||||
|
||||
#else /* WIN32 */
|
||||
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -65,9 +74,9 @@ static const char rcsid[] _U_ =
|
||||
# define m_next b_cont
|
||||
# define MLEN(m) ((m)->b_wptr - (m)->b_rptr)
|
||||
# define mtod(m,t) ((t)(m)->b_rptr)
|
||||
#else
|
||||
#else /* defined(__hpux) || SOLARIS */
|
||||
# define MLEN(m) ((m)->m_len)
|
||||
#endif
|
||||
#endif /* defined(__hpux) || SOLARIS */
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.14.4.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf_dump.c,v 1.15 2008-01-02 04:16:46 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -21,13 +21,27 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf_image.c,v 1.27.2.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/bpf_image.c,v 1.28 2008-01-02 04:16:46 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
/* config.h.in. Generated from configure.in by autoheader. */
|
||||
/* Long story short: aclocal.m4 depends on autoconf 2.13
|
||||
* implementation details wrt "const"; newer versions
|
||||
* have different implementation details so for now we
|
||||
* put "const" here. This may cause duplicate definitions
|
||||
* in config.h but that should be OK since they're the same.
|
||||
*/
|
||||
#undef const
|
||||
|
||||
/* Enable optimizer debugging */
|
||||
#undef BDEBUG
|
||||
@@ -56,12 +49,18 @@
|
||||
/* if libdlpi exists */
|
||||
#undef HAVE_LIBDLPI
|
||||
|
||||
/* if libnl exists */
|
||||
#undef HAVE_LIBNL
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* if tp_vlan_tci exists */
|
||||
#undef HAVE_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
|
||||
/* Define to 1 if you have the <linux/usbdevice_fs.h> header file. */
|
||||
#undef HAVE_LINUX_USBDEVICE_FS_H
|
||||
|
||||
/* Define to 1 if you have the <linux/wireless.h> header file. */
|
||||
#undef HAVE_LINUX_WIRELESS_H
|
||||
|
||||
@@ -80,7 +79,7 @@
|
||||
/* Define to 1 if you have the <net/pfvar.h> header file. */
|
||||
#undef HAVE_NET_PFVAR_H
|
||||
|
||||
/* if there's an os_proto.h */
|
||||
/* if there's an os_proto.h for this platform, to use additional prototypes */
|
||||
#undef HAVE_OS_PROTO_H
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
@@ -89,16 +88,16 @@
|
||||
/* define if net/pfvar.h defines PF_NAT through PF_NORDR */
|
||||
#undef HAVE_PF_NAT_THROUGH_PF_NORDR
|
||||
|
||||
/* define if you have a /proc/net/dev */
|
||||
#undef HAVE_PROC_NET_DEV
|
||||
|
||||
/* define if you have a Septel API */
|
||||
#undef HAVE_SEPTEL_API
|
||||
|
||||
/* define if you have Myricom SNF API */
|
||||
#undef HAVE_SNF_API
|
||||
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* if struct sockaddr has sa_len */
|
||||
/* if struct sockaddr has the sa_len member */
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
|
||||
/* if struct sockaddr_storage exists */
|
||||
@@ -134,6 +133,9 @@
|
||||
/* Define to 1 if the system has the type `struct ether_addr'. */
|
||||
#undef HAVE_STRUCT_ETHER_ADDR
|
||||
|
||||
/* Define to 1 if you have the <sys/bitypes.h> header file. */
|
||||
#undef HAVE_SYS_BITYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/bufmod.h> header file. */
|
||||
#undef HAVE_SYS_BUFMOD_H
|
||||
|
||||
@@ -158,6 +160,9 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* if struct usbdevfs_ctrltransfer has bRequestType */
|
||||
#undef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
||||
|
||||
/* define if version.h is generated in the build procedure */
|
||||
#undef HAVE_VERSION_H
|
||||
|
||||
@@ -209,6 +214,9 @@
|
||||
/* target host supports Bluetooth sniffing */
|
||||
#undef PCAP_SUPPORT_BT
|
||||
|
||||
/* target host supports CAN sniffing */
|
||||
#undef PCAP_SUPPORT_CAN
|
||||
|
||||
/* target host supports USB sniffing */
|
||||
#undef PCAP_SUPPORT_USB
|
||||
|
||||
@@ -236,20 +244,35 @@
|
||||
/* define on AIX to get certain functions */
|
||||
#undef _SUN
|
||||
|
||||
/* to handle Ultrix compilers that don't support const in prototypes */
|
||||
#undef const
|
||||
|
||||
/* Define as token for inline if inlining supported */
|
||||
#undef inline
|
||||
|
||||
/* Define to `short' if int16_t not defined. */
|
||||
#undef int16_t
|
||||
|
||||
/* Define to `int' if int32_t not defined. */
|
||||
#undef int32_t
|
||||
|
||||
/* Define to `long long' if int64_t not defined. */
|
||||
#undef int64_t
|
||||
|
||||
/* Define to `signed char' if int8_t not defined. */
|
||||
#undef int8_t
|
||||
|
||||
/* on sinix */
|
||||
#undef sinix
|
||||
|
||||
/* if we have u_int16_t */
|
||||
/* Define to `unsigned short' if u_int16_t not defined. */
|
||||
#undef u_int16_t
|
||||
|
||||
/* if we have u_int32_t */
|
||||
/* Define to `unsigned int' if u_int32_t not defined. */
|
||||
#undef u_int32_t
|
||||
|
||||
/* if we have u_int64_t */
|
||||
/* Define to `unsigned long long' if u_int64_t not defined. */
|
||||
#undef u_int64_t
|
||||
|
||||
/* if we have u_int8_t */
|
||||
/* Define to `unsigned char' if u_int8_t not defined. */
|
||||
#undef u_int8_t
|
||||
|
||||
7949
libpcap/configure
vendored
7949
libpcap/configure
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.138.2.22 2008-10-24 07:30:18 guy Exp $ (LBL)
|
||||
dnl @(#) $Header: /tcpdump/master/libpcap/configure.in,v 1.168 2008-12-23 20:49:26 guy Exp $ (LBL)
|
||||
dnl
|
||||
dnl Copyright (c) 1994, 1995, 1996, 1997
|
||||
dnl The Regents of the University of California. All rights reserved.
|
||||
@@ -6,20 +6,86 @@ dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_REVISION($Revision: 1.138.2.22 $)
|
||||
#
|
||||
# See
|
||||
#
|
||||
# http://ftp.gnu.org/gnu/config/README
|
||||
#
|
||||
# for the URLs to use to fetch new versions of config.guess and
|
||||
# config.sub.
|
||||
#
|
||||
|
||||
AC_REVISION($Revision: 1.168 $)
|
||||
AC_PREREQ(2.50)
|
||||
AC_INIT(pcap.c)
|
||||
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
AC_LBL_C_INIT(V_CCOPT, V_INCLS, V_LIBS)
|
||||
AC_LBL_C_INIT_BEFORE_CC(V_CCOPT, V_INCLS)
|
||||
AC_PROG_CC
|
||||
AC_LBL_C_INIT(V_CCOPT, V_INCLS)
|
||||
AC_LBL_SHLIBS_INIT
|
||||
AC_LBL_C_INLINE
|
||||
AC_C___ATTRIBUTE__
|
||||
|
||||
AC_LBL_CHECK_TYPE(u_int8_t, u_char)
|
||||
AC_LBL_CHECK_TYPE(u_int16_t, u_short)
|
||||
AC_LBL_CHECK_TYPE(u_int32_t, u_int)
|
||||
AC_LBL_CHECK_TYPE(u_int64_t, unsigned long long)
|
||||
AC_CHECK_HEADERS(sys/bitypes.h)
|
||||
|
||||
AC_CHECK_TYPE([int8_t], ,
|
||||
[AC_DEFINE([int8_t], [signed char],
|
||||
[Define to `signed char' if int8_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([u_int8_t], ,
|
||||
[AC_DEFINE([u_int8_t], [unsigned char],
|
||||
[Define to `unsigned char' if u_int8_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([int16_t], ,
|
||||
[AC_DEFINE([int16_t], [short],
|
||||
[Define to `short' if int16_t not defined.])]
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([u_int16_t], ,
|
||||
[AC_DEFINE([u_int16_t], [unsigned short],
|
||||
[Define to `unsigned short' if u_int16_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([int32_t], ,
|
||||
[AC_DEFINE([int32_t], [int],
|
||||
[Define to `int' if int32_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([u_int32_t], ,
|
||||
[AC_DEFINE([u_int32_t], [unsigned int],
|
||||
[Define to `unsigned int' if u_int32_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([int64_t], ,
|
||||
[AC_DEFINE([int64_t], [long long],
|
||||
[Define to `long long' if int64_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
AC_CHECK_TYPE([u_int64_t], ,
|
||||
[AC_DEFINE([u_int64_t], [unsigned long long],
|
||||
[Define to `unsigned long long' if u_int64_t not defined.])],
|
||||
[AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif])
|
||||
|
||||
#
|
||||
# Try to arrange for large file support.
|
||||
@@ -28,10 +94,13 @@ AC_SYS_LARGEFILE
|
||||
AC_FUNC_FSEEKO
|
||||
|
||||
dnl
|
||||
dnl libpcap doesn't itself use <sys/ioccom.h>; however, the test program
|
||||
dnl in "AC_LBL_FIXINCLUDES" in "aclocal.m4" uses it, so we have to
|
||||
dnl test for it and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
||||
dnl "AC_LBL_FIXINCLUDES" won't work on some platforms such as Solaris.
|
||||
dnl Even if <net/bpf.h> were, on all OSes that support BPF, fixed to
|
||||
dnl include <sys/ioccom.h>, and we were to drop support for older
|
||||
dnl releases without that fix, so that pcap-bpf.c doesn't need to
|
||||
dnl include <sys/ioccom.h>, the test program in "AC_LBL_FIXINCLUDES"
|
||||
dnl in "aclocal.m4" uses it, so we would still have to test for it
|
||||
dnl and set "HAVE_SYS_IOCCOM_H" if we have it, otherwise
|
||||
dnl "AC_LBL_FIXINCLUDES" wouldn't work on some platforms such as Solaris.
|
||||
dnl
|
||||
AC_CHECK_HEADERS(sys/ioccom.h sys/sockio.h limits.h paths.h)
|
||||
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
|
||||
@@ -185,7 +254,8 @@ fi
|
||||
|
||||
dnl to pacify those who hate protochain insn
|
||||
AC_MSG_CHECKING(if --disable-protochain option is specified)
|
||||
AC_ARG_ENABLE(protochain, [ --disable-protochain disable \"protochain\" insn])
|
||||
AC_ARG_ENABLE(protochain,
|
||||
AC_HELP_STRING([--disable-protochain],[disable \"protochain\" insn]))
|
||||
case "x$enable_protochain" in
|
||||
xyes) enable_protochain=enabled ;;
|
||||
xno) enable_protochain=disabled ;;
|
||||
@@ -201,12 +271,15 @@ AC_MSG_RESULT(${enable_protochain})
|
||||
# SITA support is mutually exclusive with native capture support;
|
||||
# "--with-sita" selects SITA support.
|
||||
#
|
||||
AC_ARG_WITH(sita, [ --with-sita include SITA support],
|
||||
AC_ARG_WITH(sita,
|
||||
AC_HELP_STRING([--with-sita],[include SITA support]),
|
||||
[
|
||||
AC_DEFINE(SITA,1,[include ACN support])
|
||||
AC_MSG_NOTICE(Enabling SITA ACN support)
|
||||
V_PCAP=sita
|
||||
V_FINDALLDEVS=sita
|
||||
if test ! "x$withval" = "xno" ; then
|
||||
AC_DEFINE(SITA,1,[include ACN support])
|
||||
AC_MSG_NOTICE(Enabling SITA ACN support)
|
||||
V_PCAP=sita
|
||||
V_FINDALLDEVS=sita
|
||||
fi
|
||||
],
|
||||
[
|
||||
dnl
|
||||
@@ -220,11 +293,12 @@ dnl
|
||||
if test -z "$with_pcap" && test "$cross_compiling" = yes; then
|
||||
AC_MSG_ERROR(pcap type not determined when cross-compiling; use --with-pcap=...)
|
||||
fi
|
||||
AC_ARG_WITH(pcap, [ --with-pcap=TYPE use packet capture TYPE])
|
||||
AC_ARG_WITH(pcap,
|
||||
AC_HELP_STRING([--with-pcap=TYPE],[use packet capture TYPE]))
|
||||
AC_MSG_CHECKING(packet capture type)
|
||||
if test ! -z "$with_pcap" ; then
|
||||
V_PCAP="$withval"
|
||||
elif test -r /dev/bpf ; then
|
||||
elif test -r /dev/bpf -o -h /dev/bpf ; then
|
||||
#
|
||||
# Cloning BPF device.
|
||||
#
|
||||
@@ -251,10 +325,10 @@ elif test -r /usr/include/odmi.h ; then
|
||||
# We check for odmi.h instead.
|
||||
#
|
||||
V_PCAP=bpf
|
||||
elif test -r /usr/include/sys/dlpi.h ; then
|
||||
V_PCAP=dlpi
|
||||
elif test -c /dev/bpf0 ; then # check again in case not readable
|
||||
V_PCAP=bpf
|
||||
elif test -r /usr/include/sys/dlpi.h ; then
|
||||
V_PCAP=dlpi
|
||||
elif test -c /dev/enet ; then # check again in case not readable
|
||||
V_PCAP=enet
|
||||
elif test -c /dev/nit ; then # check again in case not readable
|
||||
@@ -352,12 +426,34 @@ linux)
|
||||
if test $ac_cv_linux_vers -lt 2 ; then
|
||||
AC_MSG_ERROR(version 2 or higher required; see the INSTALL doc for more info)
|
||||
fi
|
||||
|
||||
#
|
||||
# Do we have the wireless extensions?
|
||||
#
|
||||
AC_CHECK_HEADERS(linux/wireless.h, [], [],
|
||||
[
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/types.h>
|
||||
])
|
||||
|
||||
#
|
||||
# Do we have libnl?
|
||||
#
|
||||
AC_ARG_WITH(libnl,
|
||||
AC_HELP_STRING([--without-libnl],[disable libnl support @<:@default=yes, on Linux, if present@:>@]),
|
||||
with_libnl=$withval,,)
|
||||
|
||||
if test x$with_libnl != xno ; then
|
||||
AC_CHECK_LIB(nl, nl_handle_alloc,
|
||||
LIBS="-lnl $LIBS"
|
||||
AC_DEFINE(HAVE_LIBNL,1,[if libnl exists]),
|
||||
if test x$with_libnl = xyes ; then
|
||||
AC_MSG_ERROR([libnl support requested but libnl not found])
|
||||
fi
|
||||
)
|
||||
fi
|
||||
|
||||
AC_LBL_TPACKET_STATS
|
||||
AC_LBL_LINUX_TPACKET_AUXDATA_TP_VLAN_TCI
|
||||
;;
|
||||
@@ -404,6 +500,10 @@ septel)
|
||||
V_DEFS="$V_DEFS -DSEPTEL_ONLY"
|
||||
;;
|
||||
|
||||
snf)
|
||||
V_DEFS="$V_DEFS -DSNF_ONLY"
|
||||
;;
|
||||
|
||||
null)
|
||||
AC_MSG_WARN(cannot determine packet capture interface)
|
||||
AC_MSG_WARN((see the INSTALL doc for more info))
|
||||
@@ -513,7 +613,8 @@ if test "x$have_socklen_t" = "xyes"; then
|
||||
fi
|
||||
AC_MSG_RESULT($have_socklen_t)
|
||||
|
||||
AC_ARG_ENABLE(ipv6, [ --enable-ipv6 build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@],
|
||||
AC_ARG_ENABLE(ipv6,
|
||||
AC_HELP_STRING([--enable-ipv6],[build IPv6-capable version @<:@default=yes, if getaddrinfo available@:>@]),
|
||||
[],
|
||||
[enable_ipv6=ifavailable])
|
||||
if test "$enable_ipv6" != "no"; then
|
||||
@@ -529,32 +630,24 @@ if test "$enable_ipv6" != "no"; then
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(whether to build optimizer debugging code)
|
||||
AC_ARG_ENABLE(optimizer-dbg, [ --enable-optimizer-dbg build optimizer debugging code])
|
||||
AC_ARG_ENABLE(optimizer-dbg,
|
||||
AC_HELP_STRING([--enable-optimizer-dbg],[build optimizer debugging code]))
|
||||
if test "$enable_optimizer_dbg" = "yes"; then
|
||||
AC_DEFINE(BDEBUG,1,[Enable optimizer debugging])
|
||||
fi
|
||||
AC_MSG_RESULT(${enable_optimizer_dbg-no})
|
||||
|
||||
AC_MSG_CHECKING(whether to build parser debugging code)
|
||||
AC_ARG_ENABLE(yydebug, [ --enable-yydebug build parser debugging code])
|
||||
AC_ARG_ENABLE(yydebug,
|
||||
AC_HELP_STRING([--enable-yydebug],[build parser debugging code]))
|
||||
if test "$enable_yydebug" = "yes"; then
|
||||
AC_DEFINE(YYDEBUG,1,[Enable parser debugging])
|
||||
fi
|
||||
AC_MSG_RESULT(${enable_yydebug-no})
|
||||
|
||||
AC_MSG_CHECKING(whether we have /proc/net/dev)
|
||||
if test -r /proc/net/dev ; then
|
||||
ac_cv_lbl_proc_net_dev=yes
|
||||
else
|
||||
ac_cv_lbl_proc_net_dev=no
|
||||
fi
|
||||
if test $ac_cv_lbl_proc_net_dev = yes; then
|
||||
AC_DEFINE(HAVE_PROC_NET_DEV, 1, [define if you have a /proc/net/dev])
|
||||
fi
|
||||
AC_MSG_RESULT($ac_cv_lbl_proc_net_dev)
|
||||
|
||||
# Check for Endace DAG card support.
|
||||
AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes", "no" or DIR; default="yes" on BSD and Linux if present)],
|
||||
AC_ARG_WITH([dag],
|
||||
AC_HELP_STRING([--with-dag@<:@=DIR@:>@],[include Endace DAG support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
|
||||
[
|
||||
if test "$withval" = no
|
||||
then
|
||||
@@ -576,14 +669,16 @@ AC_ARG_WITH([dag], [ --with-dag[[=DIR]] include Endace DAG support ("yes
|
||||
want_dag=ifpresent
|
||||
])
|
||||
|
||||
AC_ARG_WITH([dag-includes], [ --with-dag-includes=DIR Endace DAG include directory],
|
||||
AC_ARG_WITH([dag-includes],
|
||||
AC_HELP_STRING([--with-dag-includes=DIR],[Endace DAG include directory]),
|
||||
[
|
||||
# User wants DAG support and has specified a header directory, so use the provided value.
|
||||
want_dag=yes
|
||||
dag_include_dir=$withval
|
||||
],[])
|
||||
|
||||
AC_ARG_WITH([dag-libraries], [ --with-dag-libraries=DIR Endace DAG library directory],
|
||||
AC_ARG_WITH([dag-libraries],
|
||||
AC_HELP_STRING([--with-dag-libraries=DIR],[Endace DAG library directory]),
|
||||
[
|
||||
# User wants DAG support and has specified a library directory, so use the provided value.
|
||||
want_dag=yes
|
||||
@@ -732,9 +827,39 @@ if test $ac_cv_lbl_dag_api = yes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
# Under 2.5.x only we need to add dagutil.o.
|
||||
if test -r $dag_include_dir/dagutil.h; then
|
||||
AC_MSG_CHECKING([dagutil.o])
|
||||
dagutil_obj=no
|
||||
if test -r $dag_lib_dir/dagutil.o; then
|
||||
# Object file is ready and waiting.
|
||||
dagutil_obj=$dag_lib_dir/dagutil.o
|
||||
elif test -r $dag_lib_dir/libdag.a; then
|
||||
# Extract from libdag.a.
|
||||
ar x $dag_lib_dir/libdag.a dagutil.o 2>/dev/null
|
||||
if test -r ./dagutil.o; then
|
||||
dagutil_obj=./dagutil.o
|
||||
else
|
||||
ar x $dag_lib_dir/libdag.a libdag_la-dagutil.o 2>/dev/null
|
||||
if test -r ./libdag_la-dagutil.o; then
|
||||
dagutil_obj=./libdag_la-dagutil.o
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $dagutil_obj = no; then
|
||||
AC_MSG_RESULT([no (checked $dag_lib_dir $dag_lib_dir/libdag.a)])
|
||||
ac_cv_lbl_dag_api=no
|
||||
else
|
||||
AC_MSG_RESULT([yes ($dagutil_obj)])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $ac_cv_lbl_dag_api = yes; then
|
||||
V_INCLS="$V_INCLS -I$dag_include_dir"
|
||||
V_LIBS="$V_LIBS $dagapi_obj $dagopts_obj $dagreg_obj"
|
||||
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $dagapi_obj $dagopts_obj $dagreg_obj $dagutil_obj"
|
||||
if test $V_PCAP != dag ; then
|
||||
SSRC="pcap-dag.c"
|
||||
fi
|
||||
@@ -753,7 +878,7 @@ if test $ac_cv_lbl_dag_api = yes; then
|
||||
|
||||
if test "$dag_streams" = 1; then
|
||||
AC_DEFINE(HAVE_DAG_STREAMS_API, 1, [define if you have streams capable DAG API])
|
||||
DAGLIBS="-ldag"
|
||||
LIBS="$LIBS -ldag"
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_DAG_API, 1, [define if you have the DAG API])
|
||||
@@ -777,7 +902,8 @@ else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
|
||||
AC_ARG_WITH(septel, [ --with-septel[[=DIR]] include Septel support (located in directory DIR, if supplied). [default=yes, on Linux, if present]],
|
||||
AC_ARG_WITH(septel,
|
||||
AC_HELP_STRING([--with-septel@<:@=DIR@:>@],[include Septel support (located in directory DIR, if supplied). @<:@default=yes, on Linux, if present@:>@]),
|
||||
[
|
||||
if test "$withval" = no
|
||||
then
|
||||
@@ -825,22 +951,19 @@ if test "$with_septel" != no; then
|
||||
|
||||
if test -z "$septel_root"; then
|
||||
septel_root=$srcdir/../septel
|
||||
|
||||
fi
|
||||
|
||||
septel_tools_dir="$septel_root"
|
||||
septel_include_dir="$septel_root/INC"
|
||||
DEF="-DHAVE_SEPTEL_API"
|
||||
|
||||
ac_cv_lbl_septel_api=no
|
||||
if test -r "$septel_include_dir/msg.h"; then
|
||||
V_INCLS="$V_INCLS -I$septel_include_dir"
|
||||
V_DEFS="$V_DEFS $DEF"
|
||||
V_LIBS="$V_LIBS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o "
|
||||
ADDLOBJS="$ADDLOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
||||
ADDLARCHIVEOBJS="$ADDLARCHIVEOBJS $septel_tools_dir/asciibin.o $septel_tools_dir/bit2byte.o $septel_tools_dir/confirm.o $septel_tools_dir/fmtmsg.o $septel_tools_dir/gct_unix.o $septel_tools_dir/hqueue.o $septel_tools_dir/ident.o $septel_tools_dir/mem.o $septel_tools_dir/pack.o $septel_tools_dir/parse.o $septel_tools_dir/pool.o $septel_tools_dir/sdlsig.o $septel_tools_dir/strtonum.o $septel_tools_dir/timer.o $septel_tools_dir/trace.o"
|
||||
|
||||
if test "$V_PCAP" != septel ; then
|
||||
SSRC="pcap-septel.c"
|
||||
|
||||
fi
|
||||
ac_cv_lbl_septel_api=yes
|
||||
fi
|
||||
@@ -859,13 +982,126 @@ if test "$V_PCAP" = septel -a "$ac_cv_lbl_septel_api" = no; then
|
||||
AC_MSG_ERROR(Specifying the capture type as 'septel' requires the Septel API to be present; use --with-septel=DIR)
|
||||
fi
|
||||
|
||||
# Check for Myricom SNF support.
|
||||
AC_ARG_WITH([snf],
|
||||
AC_HELP_STRING([--with-snf@<:@=DIR@:>@],[include Myricom SNF support @<:@"yes", "no" or DIR; default="yes" on BSD and Linux if present@:>@]),
|
||||
[
|
||||
if test "$withval" = no
|
||||
then
|
||||
# User explicitly doesn't want SNF
|
||||
want_snf=no
|
||||
elif test "$withval" = yes
|
||||
then
|
||||
# User wants SNF support but hasn't specific a directory.
|
||||
want_snf=yes
|
||||
else
|
||||
# User wants SNF support with a specified directory.
|
||||
want_snf=yes
|
||||
snf_root=$withval
|
||||
fi
|
||||
],[
|
||||
#
|
||||
# Use Sniffer API if present, otherwise don't
|
||||
#
|
||||
want_snf=ifpresent
|
||||
])
|
||||
|
||||
AC_ARG_WITH([snf-includes],
|
||||
AC_HELP_STRING([--with-snf-includes=DIR],[Myricom SNF include directory]),
|
||||
[
|
||||
# User wants SNF with specific header directory
|
||||
want_snf=yes
|
||||
snf_include_dir=$withval
|
||||
],[])
|
||||
|
||||
AC_ARG_WITH([snf-libraries],
|
||||
AC_HELP_STRING([--with-snf-libraries=DIR],[Myricom SNF library directory]),
|
||||
[
|
||||
# User wants SNF with specific lib directory
|
||||
want_snf=yes
|
||||
snf_lib_dir=$withval
|
||||
],[])
|
||||
|
||||
case "$V_PCAP" in
|
||||
bpf|linux|snf)
|
||||
#
|
||||
# We support the Sniffer API if we're on BSD, Linux, or if we're
|
||||
# building a Sniffer-only libpcap.
|
||||
#
|
||||
;;
|
||||
*)
|
||||
#
|
||||
# If the user explicitly requested Sniffer, tell them it's not
|
||||
# supported.
|
||||
#
|
||||
# If they expressed no preference, don't include it.
|
||||
#
|
||||
if test $want_snf = yes; then
|
||||
AC_MSG_ERROR(Myricom SNF support only available with 'bpf' 'linux' and 'snf' packet capture types)
|
||||
elif test $want_snf = yes; then
|
||||
want_snf=no
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
ac_cv_lbl_snf_api=no
|
||||
if test "$with_snf" != no; then
|
||||
|
||||
AC_MSG_CHECKING(whether we have Myricom Sniffer API)
|
||||
|
||||
if test -z "$snf_root"; then
|
||||
snf_root=/opt/snf
|
||||
fi
|
||||
|
||||
if test -z "$snf_include_dir"; then
|
||||
snf_include_dir="$snf_root/include"
|
||||
fi
|
||||
|
||||
if test -z "$snf_lib_dir"; then
|
||||
snf_lib_dir="$snf_root/lib"
|
||||
fi
|
||||
|
||||
if test -f "$snf_include_dir/snf.h"; then
|
||||
ac_cv_lbl_snf_api=yes
|
||||
fi
|
||||
AC_MSG_RESULT([$ac_cv_lbl_snf_api ($snf_root)])
|
||||
|
||||
if test $ac_cv_lbl_snf_api = no; then
|
||||
if test "$want_snf" = yes; then
|
||||
AC_MSG_ERROR(SNF API headers not found under $snf_include_dir; use --without-snf)
|
||||
fi
|
||||
else
|
||||
saved_ldflags=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
||||
AC_CHECK_LIB([snf], [snf_init], [ac_cv_lbl_snf_api="yes"], [ac_cv_lbl_snf_api="no"])
|
||||
LDFLAGS="$saved_ldflags"
|
||||
|
||||
if test $ac_cv_lbl_snf_api = no; then
|
||||
if test "$want_snf" = yes; then
|
||||
AC_MSG_ERROR(SNF API cannot correctly be linked check config.log; use --without-snf)
|
||||
fi
|
||||
else
|
||||
V_INCLS="$V_INCLS -I$snf_include_dir"
|
||||
LIBS="$LIBS -lsnf"
|
||||
LDFLAGS="$LDFLAGS -L$snf_lib_dir"
|
||||
if test "$V_PCAP" != snf ; then
|
||||
SSRC="pcap-snf.c"
|
||||
fi
|
||||
AC_DEFINE(HAVE_SNF_API, 1, [define if you have Myricom SNF API])
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$V_PCAP" = snf -a "$ac_cv_lbl_snf_api" = no; then
|
||||
AC_MSG_ERROR(Specifying the capture type as 'snf' requires the Myricom Sniffer API to be present; use --with-snf=DIR)
|
||||
fi
|
||||
|
||||
#
|
||||
# Assume a.out/ELF convention for shared library names (".so"), and
|
||||
# V7/BSD convention for man pages (file formats in section 5,
|
||||
# miscellaneous info in section 7).
|
||||
# Assume, by default, no support for shared libraries and V7/BSD convention
|
||||
# for man pages (file formats in section 5, miscellaneous info in section 7).
|
||||
# Individual cases can override this.
|
||||
#
|
||||
DYEXT="so"
|
||||
DYEXT="none"
|
||||
MAN_FILE_FORMATS=5
|
||||
MAN_MISC_INFO=7
|
||||
case "$host_os" in
|
||||
@@ -874,9 +1110,42 @@ aix*)
|
||||
dnl Workaround to enable certain features
|
||||
AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
|
||||
|
||||
# We need "-lodm" and "-lcfg", as libpcap requires them on
|
||||
# AIX.
|
||||
DEPLIBS="-lodm -lcfg"
|
||||
#
|
||||
# AIX makes it fun to build shared and static libraries,
|
||||
# because they're *both* ".a" archive libraries. We
|
||||
# build the static library for the benefit of the traditional
|
||||
# scheme of building libpcap and tcpdump in subdirectories of
|
||||
# the same directory, with tcpdump statically linked with the
|
||||
# libpcap in question, but we also build a shared library as
|
||||
# "libpcap.shareda" and install *it*, rather than the static
|
||||
# library, as "libpcap.a".
|
||||
#
|
||||
DYEXT="shareda"
|
||||
|
||||
case "$V_PCAP" in
|
||||
|
||||
dlpi)
|
||||
#
|
||||
# If we're using DLPI, applications will need to
|
||||
# use /lib/pse.exp if present, as we use the
|
||||
# STREAMS routines.
|
||||
#
|
||||
pseexe="/lib/pse.exp"
|
||||
AC_MSG_CHECKING(for $pseexe)
|
||||
if test -f $pseexe ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
LIBS="-I:$pseexe"
|
||||
fi
|
||||
;;
|
||||
|
||||
bpf)
|
||||
#
|
||||
# If we're using BPF, we need "-lodm" and "-lcfg", as
|
||||
# we use them to load the BPF module.
|
||||
#
|
||||
LIBS="-lodm -lcfg"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
darwin*)
|
||||
@@ -920,6 +1189,17 @@ hpux*)
|
||||
dnl for 32-bit PA-RISC, but should be left as "so" for
|
||||
dnl 64-bit PA-RISC or, I suspect, IA-64.
|
||||
AC_DEFINE(HAVE_HPUX10_20_OR_LATER,1,[on HP-UX 10.20 or later])
|
||||
if test "`uname -m`" = "ia64"; then
|
||||
DYEXT="so"
|
||||
else
|
||||
DYEXT="sl"
|
||||
fi
|
||||
|
||||
#
|
||||
# "-b" builds a shared library; "+h" sets the soname.
|
||||
#
|
||||
SHLIB_OPT="-b"
|
||||
SONAME_OPT="+h"
|
||||
|
||||
#
|
||||
# Use System V conventions for man pages.
|
||||
@@ -936,11 +1216,21 @@ irix*)
|
||||
MAN_MISC_INFO=5
|
||||
;;
|
||||
|
||||
linux*)
|
||||
V_CCOPT="$V_CCOPT -fPIC"
|
||||
linux*|freebsd*|netbsd*|openbsd*|dragonfly*)
|
||||
DYEXT="so"
|
||||
|
||||
#
|
||||
# Compiler assumed to be GCC; run-time linker may require a -R
|
||||
# flag.
|
||||
#
|
||||
if test "$libdir" != "/usr/lib"; then
|
||||
V_RFLAGS=-Wl,-R$libdir
|
||||
fi
|
||||
;;
|
||||
|
||||
osf*)
|
||||
DYEXT="so"
|
||||
|
||||
#
|
||||
# Use System V conventions for man pages.
|
||||
#
|
||||
@@ -965,6 +1255,7 @@ sinix*)
|
||||
solaris*)
|
||||
AC_DEFINE(HAVE_SOLARIS,1,[On solaris])
|
||||
|
||||
DYEXT="so"
|
||||
#
|
||||
# Use System V conventions for man pages.
|
||||
#
|
||||
@@ -996,14 +1287,17 @@ ln -s ${srcdir}/bpf/net net
|
||||
|
||||
AC_SUBST(V_CCOPT)
|
||||
AC_SUBST(V_DEFS)
|
||||
AC_SUBST(V_INCLS)
|
||||
AC_SUBST(V_LIBS)
|
||||
AC_SUBST(V_PCAP)
|
||||
AC_SUBST(V_FINDALLDEVS)
|
||||
AC_SUBST(V_INCLS)
|
||||
AC_SUBST(V_PCAP)
|
||||
AC_SUBST(V_SHLIB_CMD)
|
||||
AC_SUBST(V_SHLIB_OPT)
|
||||
AC_SUBST(V_SONAME_OPT)
|
||||
AC_SUBST(V_RPATH_OPT)
|
||||
AC_SUBST(ADDLOBJS)
|
||||
AC_SUBST(ADDLARCHIVEOBJS)
|
||||
AC_SUBST(SSRC)
|
||||
AC_SUBST(DYEXT)
|
||||
AC_SUBST(DAGLIBS)
|
||||
AC_SUBST(DEPLIBS)
|
||||
AC_SUBST(MAN_FILE_FORMATS)
|
||||
AC_SUBST(MAN_MISC_INFO)
|
||||
|
||||
@@ -1020,6 +1314,31 @@ linux*)
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(LINUX_USB_MON_DEV, "/dev/$ac_usb_dev_name", [path for device for USB sniffing])
|
||||
AC_MSG_NOTICE(Device for USB sniffing is /dev/$ac_usb_dev_name)
|
||||
AC_CHECK_HEADERS(linux/usbdevice_fs.h)
|
||||
if test "$ac_cv_header_linux_usbdevice_fs_h" = yes; then
|
||||
#
|
||||
# OK, does it define bRequestType? Older versions of the kernel
|
||||
# define fields with names like "requesttype, "request", and
|
||||
# "value", rather than "bRequestType", "bRequest", and
|
||||
# "wValue".
|
||||
#
|
||||
AC_MSG_CHECKING(if usbdevfs_ctrltransfer struct has bRequestType member)
|
||||
AC_CACHE_VAL(ac_cv_usbdevfs_ctrltransfer_has_bRequestType,
|
||||
AC_TRY_COMPILE([
|
||||
AC_INCLUDES_DEFAULT
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
# include <linux/usbdevice_fs.h>],
|
||||
[u_int i = sizeof(((struct usbdevfs_ctrltransfer *)0)->bRequestType)],
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=yes,
|
||||
ac_cv_usbdevfs_ctrltransfer_has_bRequestType=no))
|
||||
AC_MSG_RESULT($ac_cv_usbdevfs_ctrltransfer_has_bRequestType)
|
||||
if test $ac_cv_usbdevfs_ctrltransfer_has_bRequestType = yes ; then
|
||||
AC_DEFINE(HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE,1,
|
||||
[if struct usbdevfs_ctrltransfer has bRequestType])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
AC_MSG_RESULT(no)
|
||||
@@ -1028,24 +1347,54 @@ esac
|
||||
AC_SUBST(PCAP_SUPPORT_USB)
|
||||
AC_SUBST(USB_SRC)
|
||||
|
||||
dnl check for bluetooth sniffing support
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_CHECK_HEADER(bluetooth/bluetooth.h,
|
||||
[
|
||||
AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
|
||||
BT_SRC=pcap-bt-linux.c
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is supported)
|
||||
],
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
|
||||
)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_NOTICE(no Bluetooth sniffing support)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_BT)
|
||||
AC_SUBST(BT_SRC)
|
||||
AC_ARG_ENABLE([bluetooth],
|
||||
[AC_HELP_STRING([--enable-bluetooth],[enable Bluetooth support @<:@default=yes, if support available@:>@])],
|
||||
,enable_bluetooth=yes)
|
||||
|
||||
if test "x$enable_bluetooth" != "xno" ; then
|
||||
dnl check for Bluetooth sniffing support
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_CHECK_HEADER(bluetooth/bluetooth.h,
|
||||
[
|
||||
AC_DEFINE(PCAP_SUPPORT_BT, 1, [target host supports Bluetooth sniffing])
|
||||
BT_SRC=pcap-bt-linux.c
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is supported)
|
||||
],
|
||||
AC_MSG_NOTICE(Bluetooth sniffing is not supported; install bluez-lib devel to enable it)
|
||||
)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_NOTICE(no Bluetooth sniffing support implemented for $host_os)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_BT)
|
||||
AC_SUBST(BT_SRC)
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([can],
|
||||
[AC_HELP_STRING([--enable-can],[enable CAN support @<:@default=yes, if support available@:>@])],
|
||||
,enable_can=yes)
|
||||
|
||||
if test "x$enable_can" != "xno" ; then
|
||||
dnl check for CAN sniffing support
|
||||
case "$host_os" in
|
||||
linux*)
|
||||
AC_CHECK_HEADER(linux/can.h,
|
||||
[ AC_DEFINE(PCAP_SUPPORT_CAN, 1, [target host supports CAN sniffing])
|
||||
CAN_SRC=pcap-can-linux.c
|
||||
AC_MSG_NOTICE(CAN sniffing is supported)],
|
||||
AC_MSG_NOTICE(CAN sniffing is not supported),
|
||||
[#include <sys/socket.h>]
|
||||
)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_NOTICE(no CAN sniffing support implemented for $host_os)
|
||||
;;
|
||||
esac
|
||||
AC_SUBST(PCAP_SUPPORT_CAN)
|
||||
AC_SUBST(CAN_SRC)
|
||||
fi
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
|
||||
@@ -12,13 +12,17 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/dlpisubs.c,v 1.1.2.2 2008-04-04 19:39:05 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/dlpisubs.c,v 1.3 2008-12-02 16:40:19 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef DL_IPATM
|
||||
#define DL_IPATM 0x12 /* ATM Classical IP interface */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/*
|
||||
* Size of a bufmod chunk to pass upstream; that appears to be the
|
||||
@@ -41,6 +45,7 @@ static const char rcsid[] _U_ =
|
||||
* what the value used to be - there's no particular reason why it
|
||||
* should be tied to MAXDLBUF, but we'll leave it as this for now.
|
||||
*/
|
||||
#define MAXDLBUF 8192
|
||||
#define PKTBUFSIZE (MAXDLBUF * sizeof(bpf_u_int32))
|
||||
|
||||
#endif
|
||||
@@ -64,7 +69,9 @@ static const char rcsid[] _U_ =
|
||||
#include "pcap-int.h"
|
||||
#include "dlpisubs.h"
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
static void pcap_stream_err(const char *, int, char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the packet statistics.
|
||||
@@ -291,6 +298,14 @@ pcap_conf_bufmod(pcap_t *p, int snaplen, int timeout)
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
return (retv);
|
||||
}
|
||||
#endif /* HAVE_SYS_BUFMOD_H */
|
||||
@@ -331,6 +346,7 @@ strioctl(int fd, int cmd, int len, char *dp)
|
||||
return (str.ic_len);
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/*
|
||||
* Write stream error message to errbuf.
|
||||
*/
|
||||
@@ -339,3 +355,4 @@ pcap_stream_err(const char *func, int err, char *errbuf)
|
||||
{
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", func, pcap_strerror(err));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/dlpisubs.h,v 1.1.2.2 2008-04-04 19:39:05 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/dlpisubs.h,v 1.2 2008-04-04 19:37:45 guy Exp $
|
||||
*/
|
||||
|
||||
#ifndef dlpisubs_h
|
||||
|
||||
@@ -21,14 +21,26 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/etherent.c,v 1.23 2006/10/04 18:09:22 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/etherent.c,v 1.23 2006-10-04 18:09:22 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <memory.h>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/ethertype.h,v 1.14 2005/09/05 09:06:58 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/ethertype.h,v 1.14 2005-09-05 09:06:58 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-getad.c,v 1.12 2007/09/14 00:44:55 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-getad.c,v 1.12 2007-09-14 00:44:55 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -62,9 +62,12 @@ static const char rcsid[] _U_ =
|
||||
|
||||
#ifdef AF_PACKET
|
||||
# ifdef __Lynx__
|
||||
# include <netpacket/if_packet.h> /* LynxOS */
|
||||
/* LynxOS */
|
||||
# include <netpacket/if_packet.h>
|
||||
# else
|
||||
# include <linux/if_packet.h> /* Linux */
|
||||
/* Linux */
|
||||
# include <linux/types.h>
|
||||
# include <linux/if_packet.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-gifc.c,v 1.11.2.1 2008-08-06 07:35:01 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-gifc.c,v 1.12 2008-08-06 07:34:09 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -122,136 +122,6 @@ struct rtentry; /* declarations in <net/if.h> */
|
||||
*/
|
||||
#define MAX_SA_LEN 255
|
||||
|
||||
#ifdef HAVE_PROC_NET_DEV
|
||||
/*
|
||||
* Get from "/proc/net/dev" all interfaces listed there; if they're
|
||||
* already in the list of interfaces we have, that won't add another
|
||||
* instance, but if they're not, that'll add them.
|
||||
*
|
||||
* We don't bother getting any addresses for them; it appears you can't
|
||||
* use SIOCGIFADDR on Linux to get IPv6 addresses for interfaces, and,
|
||||
* although some other types of addresses can be fetched with SIOCGIFADDR,
|
||||
* we don't bother with them for now.
|
||||
*
|
||||
* We also don't fail if we couldn't open "/proc/net/dev"; we just leave
|
||||
* the list of interfaces as is.
|
||||
*/
|
||||
static int
|
||||
scan_proc_net_dev(pcap_if_t **devlistp, int fd, char *errbuf)
|
||||
{
|
||||
FILE *proc_net_f;
|
||||
char linebuf[512];
|
||||
int linenum;
|
||||
unsigned char *p;
|
||||
char name[512]; /* XXX - pick a size */
|
||||
char *q, *saveq;
|
||||
struct ifreq ifrflags;
|
||||
int ret = 0;
|
||||
|
||||
proc_net_f = fopen("/proc/net/dev", "r");
|
||||
if (proc_net_f == NULL)
|
||||
return (0);
|
||||
|
||||
for (linenum = 1;
|
||||
fgets(linebuf, sizeof linebuf, proc_net_f) != NULL; linenum++) {
|
||||
/*
|
||||
* Skip the first two lines - they're headers.
|
||||
*/
|
||||
if (linenum <= 2)
|
||||
continue;
|
||||
|
||||
p = &linebuf[0];
|
||||
|
||||
/*
|
||||
* Skip leading white space.
|
||||
*/
|
||||
while (*p != '\0' && isspace(*p))
|
||||
p++;
|
||||
if (*p == '\0' || *p == '\n')
|
||||
continue; /* blank line */
|
||||
|
||||
/*
|
||||
* Get the interface name.
|
||||
*/
|
||||
q = &name[0];
|
||||
while (*p != '\0' && !isspace(*p)) {
|
||||
if (*p == ':') {
|
||||
/*
|
||||
* This could be the separator between a
|
||||
* name and an alias number, or it could be
|
||||
* the separator between a name with no
|
||||
* alias number and the next field.
|
||||
*
|
||||
* If there's a colon after digits, it
|
||||
* separates the name and the alias number,
|
||||
* otherwise it separates the name and the
|
||||
* next field.
|
||||
*/
|
||||
saveq = q;
|
||||
while (isdigit(*p))
|
||||
*q++ = *p++;
|
||||
if (*p != ':') {
|
||||
/*
|
||||
* That was the next field,
|
||||
* not the alias number.
|
||||
*/
|
||||
q = saveq;
|
||||
}
|
||||
break;
|
||||
} else
|
||||
*q++ = *p++;
|
||||
}
|
||||
*q = '\0';
|
||||
|
||||
/*
|
||||
* Get the flags for this interface, and skip it if
|
||||
* it's not up.
|
||||
*/
|
||||
strncpy(ifrflags.ifr_name, name, sizeof(ifrflags.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifrflags) < 0) {
|
||||
if (errno == ENXIO)
|
||||
continue;
|
||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFFLAGS: %.*s: %s",
|
||||
(int)sizeof(ifrflags.ifr_name),
|
||||
ifrflags.ifr_name,
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
if (!(ifrflags.ifr_flags & IFF_UP))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Add an entry for this interface, with no addresses.
|
||||
*/
|
||||
if (pcap_add_if(devlistp, name, ifrflags.ifr_flags, NULL,
|
||||
errbuf) == -1) {
|
||||
/*
|
||||
* Failure.
|
||||
*/
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ret != -1) {
|
||||
/*
|
||||
* Well, we didn't fail for any other reason; did we
|
||||
* fail due to an error reading the file?
|
||||
*/
|
||||
if (ferror(proc_net_f)) {
|
||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Error reading /proc/net/dev: %s",
|
||||
pcap_strerror(errno));
|
||||
ret = -1;
|
||||
}
|
||||
}
|
||||
|
||||
(void)fclose(proc_net_f);
|
||||
return (ret);
|
||||
}
|
||||
#endif /* HAVE_PROC_NET_DEV */
|
||||
|
||||
/*
|
||||
* Get a list of all interfaces that are up and that we can open.
|
||||
* Returns -1 on error, 0 otherwise.
|
||||
@@ -537,20 +407,6 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
|
||||
#ifdef HAVE_PROC_NET_DEV
|
||||
if (ret != -1) {
|
||||
/*
|
||||
* We haven't had any errors yet; now read "/proc/net/dev",
|
||||
* and add to the list of interfaces all interfaces listed
|
||||
* there that we don't already have, because, on Linux,
|
||||
* SIOCGIFCONF reports only interfaces with IPv4 addresses,
|
||||
* so you need to read "/proc/net/dev" to get the names of
|
||||
* the rest of the interfaces.
|
||||
*/
|
||||
ret = scan_proc_net_dev(&devlist, fd, errbuf);
|
||||
}
|
||||
#endif
|
||||
(void)close(fd);
|
||||
|
||||
if (ret != -1) {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-glifc.c,v 1.6.2.1 2008/01/30 09:36:09 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-glifc.c,v 1.7 2008-01-30 09:35:48 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-null.c,v 1.2 2003/11/15 23:23:58 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-null.c,v 1.2 2003-11-15 23:23:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.15 2007/09/25 20:34:36 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.15 2007-09-25 20:34:36 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -24,7 +24,7 @@ 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)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/filtertest.c,v 1.2 2005-08-08 17:50:13 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -39,6 +39,7 @@ static const char rcsid[] _U_ =
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -165,6 +166,7 @@ main(int argc, char **argv)
|
||||
int Oflag;
|
||||
long snaplen;
|
||||
int dlt;
|
||||
bpf_u_int32 netmask = PCAP_NETMASK_UNKNOWN;
|
||||
char *cmdbuf;
|
||||
pcap_t *pd;
|
||||
struct bpf_program fcode;
|
||||
@@ -184,7 +186,7 @@ main(int argc, char **argv)
|
||||
program_name = argv[0];
|
||||
|
||||
opterr = 0;
|
||||
while ((op = getopt(argc, argv, "dF:Os:")) != -1) {
|
||||
while ((op = getopt(argc, argv, "dF:m:Os:")) != -1) {
|
||||
switch (op) {
|
||||
|
||||
case 'd':
|
||||
@@ -199,6 +201,16 @@ main(int argc, char **argv)
|
||||
Oflag = 0;
|
||||
break;
|
||||
|
||||
case 'm': {
|
||||
in_addr_t addr;
|
||||
|
||||
addr = inet_addr(optarg);
|
||||
if (addr == INADDR_NONE)
|
||||
error("invalid netmask %s", optarg);
|
||||
netmask = addr;
|
||||
break;
|
||||
}
|
||||
|
||||
case 's': {
|
||||
char *end;
|
||||
|
||||
@@ -235,7 +247,7 @@ main(int argc, char **argv)
|
||||
if (pd == NULL)
|
||||
error("Can't open fake pcap_t");
|
||||
|
||||
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, 0) < 0)
|
||||
if (pcap_compile(pd, &fcode, cmdbuf, Oflag, netmask) < 0)
|
||||
error("%s", pcap_geterr(pd));
|
||||
bpf_dump(&fcode, dflag);
|
||||
pcap_close(pd);
|
||||
@@ -248,7 +260,7 @@ usage(void)
|
||||
(void)fprintf(stderr, "%s, with %s\n", program_name,
|
||||
pcap_lib_version());
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [-dO] [ -F file ] [ -s snaplen ] dlt [ expression ]\n",
|
||||
"Usage: %s [-dO] [ -F file ] [ -m netmask] [ -s snaplen ] dlt [ expression ]\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.290.2.16 2008-09-22 20:16:01 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.309 2008-12-23 20:13:29 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -31,6 +31,14 @@ static const char rcsid[] _U_ =
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif /* WIN32 */
|
||||
@@ -49,6 +57,7 @@ static const char rcsid[] _U_ =
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
@@ -73,6 +82,7 @@ static const char rcsid[] _U_ =
|
||||
#include "sunatmpos.h"
|
||||
#include "ppp.h"
|
||||
#include "pcap/sll.h"
|
||||
#include "pcap/ipnet.h"
|
||||
#include "arcnet.h"
|
||||
#ifdef HAVE_NET_PFVAR_H
|
||||
#include <sys/socket.h>
|
||||
@@ -155,6 +165,17 @@ enum e_offrel {
|
||||
OR_TRAN_IPV6 /* relative to the transport-layer header, with IPv6 network layer */
|
||||
};
|
||||
|
||||
#ifdef INET6
|
||||
/*
|
||||
* As errors are handled by a longjmp, anything allocated must be freed
|
||||
* in the longjmp handler, so it must be reachable from that handler.
|
||||
* One thing that's allocated is the result of pcap_nametoaddrinfo();
|
||||
* it must be freed with freeaddrinfo(). This variable points to any
|
||||
* addrinfo structure that would need to be freed.
|
||||
*/
|
||||
static struct addrinfo *ai;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We divy out chunks of memory rather than call malloc each time so
|
||||
* we don't have to worry about leaking memory. It's probably
|
||||
@@ -200,6 +221,7 @@ static struct block *gen_uncond(int);
|
||||
static inline struct block *gen_true(void);
|
||||
static inline struct block *gen_false(void);
|
||||
static struct block *gen_ether_linktype(int);
|
||||
static struct block *gen_ipnet_linktype(int);
|
||||
static struct block *gen_linux_sll_linktype(int);
|
||||
static struct slist *gen_load_prism_llprefixlen(void);
|
||||
static struct slist *gen_load_avs_llprefixlen(void);
|
||||
@@ -365,10 +387,34 @@ syntax()
|
||||
static bpf_u_int32 netmask;
|
||||
static int snaplen;
|
||||
int no_optimize;
|
||||
#ifdef WIN32
|
||||
static int
|
||||
pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
|
||||
const char *buf, int optimize, bpf_u_int32 mask);
|
||||
|
||||
int
|
||||
pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
const char *buf, int optimize, bpf_u_int32 mask)
|
||||
{
|
||||
int result;
|
||||
|
||||
EnterCriticalSection(&g_PcapCompileCriticalSection);
|
||||
|
||||
result = pcap_compile_unsafe(p, program, buf, optimize, mask);
|
||||
|
||||
LeaveCriticalSection(&g_PcapCompileCriticalSection);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int
|
||||
pcap_compile_unsafe(pcap_t *p, struct bpf_program *program,
|
||||
const char *buf, int optimize, bpf_u_int32 mask)
|
||||
#else /* WIN32 */
|
||||
int
|
||||
pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
const char *buf, int optimize, bpf_u_int32 mask)
|
||||
#endif /* WIN32 */
|
||||
{
|
||||
extern int n_errors;
|
||||
const char * volatile xbuf = buf;
|
||||
@@ -380,6 +426,12 @@ pcap_compile(pcap_t *p, struct bpf_program *program,
|
||||
bpf_pcap = p;
|
||||
init_regs();
|
||||
if (setjmp(top_ctx)) {
|
||||
#ifdef INET6
|
||||
if (ai != NULL) {
|
||||
freeaddrinfo(ai);
|
||||
ai = NULL;
|
||||
}
|
||||
#endif
|
||||
lex_cleanup();
|
||||
freechunks();
|
||||
return (-1);
|
||||
@@ -1112,6 +1164,8 @@ init_linktype(p)
|
||||
return;
|
||||
|
||||
case DLT_RAW:
|
||||
case DLT_IPV4:
|
||||
case DLT_IPV6:
|
||||
off_linktype = -1;
|
||||
off_macpl = 0;
|
||||
off_nl = 0;
|
||||
@@ -1497,6 +1551,43 @@ init_linktype(p)
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_MPLS:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_USB_LINUX_MMAPPED:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_CAN_SOCKETCAN:
|
||||
/*
|
||||
* Currently, only raw "link[N:M]" filtering is supported.
|
||||
*/
|
||||
off_linktype = -1;
|
||||
off_macpl = -1;
|
||||
off_nl = -1;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
|
||||
case DLT_IPNET:
|
||||
off_linktype = 1;
|
||||
off_macpl = 24; /* ipnet header length */
|
||||
off_nl = 0;
|
||||
off_nl_nosnap = -1;
|
||||
return;
|
||||
}
|
||||
bpf_error("unknown data link type %d", linktype);
|
||||
/* NOTREACHED */
|
||||
@@ -1930,6 +2021,33 @@ gen_ether_linktype(proto)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* "proto" is an Ethernet type value and for IPNET, if it is not IPv4
|
||||
* or IPv6 then we have an error.
|
||||
*/
|
||||
static struct block *
|
||||
gen_ipnet_linktype(proto)
|
||||
register int proto;
|
||||
{
|
||||
switch (proto) {
|
||||
|
||||
case ETHERTYPE_IP:
|
||||
return gen_cmp(OR_LINK, off_linktype, BPF_B,
|
||||
(bpf_int32)IPH_AF_INET);
|
||||
/* NOTREACHED */
|
||||
|
||||
case ETHERTYPE_IPV6:
|
||||
return gen_cmp(OR_LINK, off_linktype, BPF_B,
|
||||
(bpf_int32)IPH_AF_INET6);
|
||||
/* NOTREACHED */
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return gen_false();
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate code to match a particular packet type.
|
||||
*
|
||||
@@ -3071,6 +3189,32 @@ gen_linktype(proto)
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
|
||||
case DLT_IPV4:
|
||||
/*
|
||||
* Raw IPv4, so no type field.
|
||||
*/
|
||||
if (proto == ETHERTYPE_IP)
|
||||
return gen_true(); /* always true */
|
||||
|
||||
/* Checking for something other than IPv4; always false */
|
||||
return gen_false();
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
|
||||
case DLT_IPV6:
|
||||
/*
|
||||
* Raw IPv6, so no type field.
|
||||
*/
|
||||
#ifdef INET6
|
||||
if (proto == ETHERTYPE_IPV6)
|
||||
return gen_true(); /* always true */
|
||||
#endif
|
||||
|
||||
/* Checking for something other than IPv6; always false */
|
||||
return gen_false();
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
|
||||
case DLT_PPP:
|
||||
case DLT_PPP_PPPD:
|
||||
case DLT_PPP_SERIAL:
|
||||
@@ -3327,6 +3471,9 @@ gen_linktype(proto)
|
||||
*/
|
||||
return gen_mcmp(OR_LINK, 0, BPF_W, 0x4d474300, 0xffffff00); /* compare the magic number */
|
||||
|
||||
case DLT_IPNET:
|
||||
return gen_ipnet_linktype(proto);
|
||||
|
||||
case DLT_LINUX_IRDA:
|
||||
bpf_error("IrDA link-layer type filtering not implemented");
|
||||
|
||||
@@ -3350,6 +3497,7 @@ gen_linktype(proto)
|
||||
|
||||
case DLT_USB:
|
||||
case DLT_USB_LINUX:
|
||||
case DLT_USB_LINUX_MMAPPED:
|
||||
bpf_error("USB link-layer type filtering not implemented");
|
||||
|
||||
case DLT_BLUETOOTH_HCI_H4:
|
||||
@@ -3357,7 +3505,8 @@ gen_linktype(proto)
|
||||
bpf_error("Bluetooth link-layer type filtering not implemented");
|
||||
|
||||
case DLT_CAN20B:
|
||||
bpf_error("CAN20B link-layer type filtering not implemented");
|
||||
case DLT_CAN_SOCKETCAN:
|
||||
bpf_error("CAN link-layer type filtering not implemented");
|
||||
|
||||
case DLT_IEEE802_15_4:
|
||||
case DLT_IEEE802_15_4_LINUX:
|
||||
@@ -4514,29 +4663,30 @@ gen_gateway(eaddr, alist, proto, dir)
|
||||
b0 = gen_wlanhostop(eaddr, Q_OR);
|
||||
break;
|
||||
case DLT_SUNATM:
|
||||
if (is_lane) {
|
||||
/*
|
||||
* Check that the packet doesn't begin with an
|
||||
* LE Control marker. (We've already generated
|
||||
* a test for LANE.)
|
||||
*/
|
||||
b1 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
|
||||
BPF_H, 0xFF00);
|
||||
gen_not(b1);
|
||||
if (!is_lane)
|
||||
bpf_error(
|
||||
"'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
|
||||
/*
|
||||
* Check that the packet doesn't begin with an
|
||||
* LE Control marker. (We've already generated
|
||||
* a test for LANE.)
|
||||
*/
|
||||
b1 = gen_cmp(OR_LINK, SUNATM_PKT_BEGIN_POS,
|
||||
BPF_H, 0xFF00);
|
||||
gen_not(b1);
|
||||
|
||||
/*
|
||||
* Now check the MAC address.
|
||||
*/
|
||||
b0 = gen_ehostop(eaddr, Q_OR);
|
||||
gen_and(b1, b0);
|
||||
}
|
||||
/*
|
||||
* Now check the MAC address.
|
||||
*/
|
||||
b0 = gen_ehostop(eaddr, Q_OR);
|
||||
gen_and(b1, b0);
|
||||
break;
|
||||
case DLT_IP_OVER_FC:
|
||||
b0 = gen_ipfchostop(eaddr, Q_OR);
|
||||
break;
|
||||
default:
|
||||
bpf_error(
|
||||
"'gateway' supported only on ethernet/FDDI/token ring/802.11/Fibre Channel");
|
||||
"'gateway' supported only on ethernet/FDDI/token ring/802.11/ATM LANE/Fibre Channel");
|
||||
}
|
||||
b1 = gen_host(**alist++, 0xffffffff, proto, Q_OR, Q_HOST);
|
||||
while (*alist) {
|
||||
@@ -5966,6 +6116,7 @@ gen_scode(name, q)
|
||||
res0 = res = pcap_nametoaddrinfo(name);
|
||||
if (res == NULL)
|
||||
bpf_error("unknown host '%s'", name);
|
||||
ai = res;
|
||||
b = tmp = NULL;
|
||||
tproto = tproto6 = proto;
|
||||
if (off_linktype == -1 && tproto == Q_DEFAULT) {
|
||||
@@ -5999,6 +6150,7 @@ gen_scode(name, q)
|
||||
gen_or(b, tmp);
|
||||
b = tmp;
|
||||
}
|
||||
ai = NULL;
|
||||
freeaddrinfo(res0);
|
||||
if (b == NULL) {
|
||||
bpf_error("unknown host '%s'%s", name,
|
||||
@@ -6311,6 +6463,7 @@ gen_mcode6(s1, s2, masklen, q)
|
||||
res = pcap_nametoaddrinfo(s1);
|
||||
if (!res)
|
||||
bpf_error("invalid ip6 address %s", s1);
|
||||
ai = res;
|
||||
if (res->ai_next)
|
||||
bpf_error("%s resolved to multiple address", s1);
|
||||
addr = &((struct sockaddr_in6 *)res->ai_addr)->sin6_addr;
|
||||
@@ -6341,6 +6494,7 @@ gen_mcode6(s1, s2, masklen, q)
|
||||
|
||||
case Q_NET:
|
||||
b = gen_host6(addr, &mask, q.proto, q.dir, q.addr);
|
||||
ai = NULL;
|
||||
freeaddrinfo(res);
|
||||
return b;
|
||||
|
||||
@@ -7003,6 +7157,13 @@ gen_broadcast(proto)
|
||||
break;
|
||||
|
||||
case Q_IP:
|
||||
/*
|
||||
* We treat a netmask of PCAP_NETMASK_UNKNOWN (0xffffffff)
|
||||
* as an indication that we don't know the netmask, and fail
|
||||
* in that case.
|
||||
*/
|
||||
if (netmask == PCAP_NETMASK_UNKNOWN)
|
||||
bpf_error("netmask not known, so 'ip broadcast' not supported");
|
||||
b0 = gen_linktype(ETHERTYPE_IP);
|
||||
hostmask = ~netmask;
|
||||
b1 = gen_mcmp(OR_NET, 16, BPF_W, (bpf_int32)0, hostmask);
|
||||
@@ -7250,6 +7411,16 @@ gen_inbound(dir)
|
||||
dir);
|
||||
break;
|
||||
|
||||
case DLT_IPNET:
|
||||
if (dir) {
|
||||
/* match outgoing packets */
|
||||
b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_OUTBOUND);
|
||||
} else {
|
||||
/* match incoming packets */
|
||||
b0 = gen_cmp(OR_LINK, 2, BPF_H, IPNET_INBOUND);
|
||||
}
|
||||
break;
|
||||
|
||||
case DLT_LINUX_SLL:
|
||||
if (dir) {
|
||||
/*
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.70.2.1 2007/11/18 02:04:55 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/gencode.h,v 1.71 2007-11-18 02:03:52 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.99.2.2 2007/11/18 02:04:55 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/grammar.y,v 1.101 2007-11-18 02:03:52 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -45,6 +45,7 @@ struct rtentry;
|
||||
#endif
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.75.2.4 2008-04-20 18:19:24 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.79 2008-04-20 18:19:02 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -366,26 +366,38 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name,
|
||||
* a Cisco 340 or 350, rather than an old Aironet card, it should use
|
||||
* that in the description.
|
||||
*
|
||||
* Do NetBSD, DragonflyBSD, or OpenBSD support this as well? OpenBSD
|
||||
* lets you get a description, but it's not generated by the OS, it's
|
||||
* set with another ioctl that ifconfig supports; we use that to get
|
||||
* the description in OpenBSD.
|
||||
* Do NetBSD, DragonflyBSD, or OpenBSD support this as well? FreeBSD
|
||||
* and OpenBSD let you get a description, but it's not generated by the OS,
|
||||
* it's set with another ioctl that ifconfig supports; we use that to get
|
||||
* a description in FreeBSD and OpenBSD, but if there is no such
|
||||
* description available, it still might be nice to get some description
|
||||
* string based on the device type or something such as that.
|
||||
*
|
||||
* In OS X, the System Configuration framework can apparently return
|
||||
* names in 10.4 and later; it also appears that freedesktop.org's HAL
|
||||
* offers an "info.product" string, but the HAL specification says
|
||||
* it "should not be used in any UI" and "subsystem/capability
|
||||
* specific properties" should be used instead. Using that would
|
||||
* require that libpcap applications be linked with the frameworks/
|
||||
* libraries in question, which would be a bit of a pain unless we
|
||||
* offer, for example, a pkg-config:
|
||||
* names in 10.4 and later.
|
||||
*
|
||||
* http://pkg-config.freedesktop.org/wiki/
|
||||
* It also appears that freedesktop.org's HAL offers an "info.product"
|
||||
* string, but the HAL specification says it "should not be used in any
|
||||
* UI" and "subsystem/capability specific properties" should be used
|
||||
* instead and, in any case, I think HAL is being deprecated in
|
||||
* favor of other stuff such as DeviceKit. DeviceKit doesn't appear
|
||||
* to have any obvious product information for devices, but maybe
|
||||
* I haven't looked hard enough.
|
||||
*
|
||||
* script, so applications can just use that script to find out what
|
||||
* libraries you need to link with when linking with libpcap.
|
||||
* pkg-config is GPLed; I don't know whether that would prevent its
|
||||
* use with a BSD-licensed library such as libpcap.
|
||||
* Using the System Configuration framework, or HAL, or DeviceKit, or
|
||||
* whatever, would require that libpcap applications be linked with
|
||||
* the frameworks/libraries in question. That shouldn't be a problem
|
||||
* for programs linking with the shared version of libpcap (unless
|
||||
* you're running on AIX - which I think is the only UN*X that doesn't
|
||||
* support linking a shared library with other libraries on which it
|
||||
* depends, and having an executable linked only with the first shared
|
||||
* library automatically pick up the other libraries when started -
|
||||
* and using HAL or whatever). Programs linked with the static
|
||||
* version of libpcap would have to use pcap-config with the --static
|
||||
* flag in order to get the right linker flags in order to pick up
|
||||
* the additional libraries/frameworks; those programs need that anyway
|
||||
* for libpcap 1.1 and beyond on Linux, as, by default, it requires
|
||||
* -lnl.
|
||||
*
|
||||
* Do any other UN*Xes, or desktop environments support getting a
|
||||
* description?
|
||||
@@ -402,10 +414,14 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
|
||||
char *description = NULL;
|
||||
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
|
||||
#ifdef SIOCGIFDESCR
|
||||
struct ifreq ifrdesc;
|
||||
char ifdescr[IFDESCRSIZE];
|
||||
int s;
|
||||
#endif
|
||||
struct ifreq ifrdesc;
|
||||
#ifndef IFDESCRSIZE
|
||||
size_t descrlen = 64;
|
||||
#else
|
||||
size_t descrlen = IFDESCRSIZE;
|
||||
#endif /* IFDESCRSIZE */
|
||||
#endif /* SIOCGIFDESCR */
|
||||
|
||||
#ifdef SIOCGIFDESCR
|
||||
/*
|
||||
@@ -413,23 +429,45 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
|
||||
*/
|
||||
memset(&ifrdesc, 0, sizeof ifrdesc);
|
||||
strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
|
||||
ifrdesc.ifr_data = (caddr_t)&ifdescr;
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s >= 0) {
|
||||
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0 &&
|
||||
strlen(ifrdesc.ifr_data) != 0)
|
||||
description = ifrdesc.ifr_data;
|
||||
for (;;) {
|
||||
free(description);
|
||||
if ((description = malloc(descrlen)) != NULL) {
|
||||
#ifdef __FreeBSD__
|
||||
ifrdesc.ifr_buffer.buffer = description;
|
||||
ifrdesc.ifr_buffer.length = descrlen;
|
||||
#else /* __FreeBSD__ */
|
||||
ifrdesc.ifr_data = (caddr_t)description;
|
||||
#endif /* __FreeBSD__ */
|
||||
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0)
|
||||
break;
|
||||
#ifdef __FreeBSD__
|
||||
else if (errno == ENAMETOOLONG)
|
||||
descrlen = ifrdesc.ifr_buffer.length;
|
||||
#endif /* __FreeBSD__ */
|
||||
else
|
||||
break;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
close(s);
|
||||
if (description != NULL && strlen(description) == 0) {
|
||||
free(description);
|
||||
description = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* SIOCGIFDESCR */
|
||||
|
||||
if (add_or_find_if(&curdev, alldevs, name, flags, description,
|
||||
errbuf) == -1) {
|
||||
free(description);
|
||||
/*
|
||||
* Error - give up.
|
||||
*/
|
||||
return (-1);
|
||||
}
|
||||
free(description);
|
||||
if (curdev == NULL) {
|
||||
/*
|
||||
* Device wasn't added because it can't be opened.
|
||||
@@ -669,7 +707,10 @@ pcap_lookupnet(device, netp, maskp, errbuf)
|
||||
|| strstr(device, "bluetooth") != NULL
|
||||
#endif
|
||||
#ifdef PCAP_SUPPORT_USB
|
||||
|| strstr(device, "usb") != NULL
|
||||
|| strstr(device, "usbmon") != NULL
|
||||
#endif
|
||||
#ifdef HAVE_SNF_API
|
||||
|| strstr(device, "snf") != NULL
|
||||
#endif
|
||||
) {
|
||||
*netp = *maskp = 0;
|
||||
@@ -702,6 +743,12 @@ pcap_lookupnet(device, netp, maskp, errbuf)
|
||||
}
|
||||
sin4 = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||
*netp = sin4->sin_addr.s_addr;
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
#ifdef linux
|
||||
/* XXX Work around Linux kernel bug */
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
#endif
|
||||
(void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name));
|
||||
if (ioctl(fd, SIOCGIFNETMASK, (char *)&ifr) < 0) {
|
||||
(void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFNETMASK: %s: %s", device, pcap_strerror(errno));
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-aix4.h,v 1.1 2002/06/01 09:37:40 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-aix4.h,v 1.1 2002-06-01 09:37:40 guy Exp $
|
||||
*/
|
||||
|
||||
/* Prototypes missing in AIX 4.x */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-hpux11.h,v 1.1 2002/06/01 09:37:41 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-hpux11.h,v 1.1 2002-06-01 09:37:41 guy Exp $
|
||||
*/
|
||||
|
||||
/* Prototypes missing in HP-UX 11.x */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf4.h,v 1.2 2000/12/22 11:51:33 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf4.h,v 1.2 2000-12-22 11:51:33 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Digital UNIX 4.x */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf5.h,v 1.2 2002/08/02 03:24:15 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-osf5.h,v 1.2 2002-08-02 03:24:15 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-solaris2.h,v 1.19 2000/10/11 04:02:52 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-solaris2.h,v 1.19 2000-10-11 04:02:52 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 5 */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-sunos4.h,v 1.32.1.1 1999/10/07 23:46:41 mcr Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-sunos4.h,v 1.32 1999-10-07 23:46:41 mcr Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Prototypes missing in SunOS 4 */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-ultrix4.h,v 1.19.1.1 1999/10/07 23:46:41 mcr Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/lbl/os-ultrix4.h,v 1.19 1999-10-07 23:46:41 mcr Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/* Prototypes missing in Ultrix 4 */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/llc.h,v 1.2 2001/01/28 09:44:50 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/llc.h,v 1.2 2001-01-28 09:44:50 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* $Id: snprintf.c,v 1.1 2004/04/05 22:43:51 guy Exp $ */
|
||||
/* $Id: snprintf.c,v 1.1 2004-04-05 22:43:51 guy Exp $ */
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/missing/snprintf.c,v 1.1 2004/04/05 22:43:51 guy Exp $";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/missing/snprintf.c,v 1.1 2004-04-05 22:43:51 guy Exp $";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -24,13 +24,18 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.82.2.1 2008/02/06 10:21:47 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.83 2008-02-06 10:21:30 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef DECNETLIB
|
||||
#include <sys/types.h>
|
||||
#include <netdnet/dnetdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
|
||||
@@ -44,13 +49,6 @@ static const char rcsid[] _U_ =
|
||||
#include <netinet/in.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*
|
||||
* XXX - why was this included even on UNIX?
|
||||
*/
|
||||
#ifdef __MINGW32__
|
||||
#include "IP6_misc.h"
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#ifdef HAVE_ETHER_HOSTTON
|
||||
/*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/nlpid.h,v 1.2 2002/12/06 00:01:34 hannes Exp $ (Juniper)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/nlpid.h,v 1.2 2002-12-06 00:01:34 hannes Exp $ (Juniper)
|
||||
*/
|
||||
|
||||
/* Types missing from some systems */
|
||||
|
||||
216
libpcap/opentest.c
Normal file
216
libpcap/opentest.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
* 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[] =
|
||||
"@(#) 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";
|
||||
#endif
|
||||
|
||||
#include <pcap.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define MAXIMUM_SNAPLEN 65535
|
||||
|
||||
static char *program_name;
|
||||
|
||||
/* Forwards */
|
||||
static void usage(void) __attribute__((noreturn));
|
||||
static void error(const char *, ...);
|
||||
static void warning(const char *, ...);
|
||||
|
||||
extern int optind;
|
||||
extern int opterr;
|
||||
extern char *optarg;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
register int op;
|
||||
register char *cp, *device;
|
||||
int dorfmon, dopromisc, snaplen, useactivate, bufsize;
|
||||
char ebuf[PCAP_ERRBUF_SIZE];
|
||||
pcap_t *pd;
|
||||
int status = 0;
|
||||
|
||||
device = NULL;
|
||||
dorfmon = 0;
|
||||
dopromisc = 0;
|
||||
snaplen = MAXIMUM_SNAPLEN;
|
||||
bufsize = 0;
|
||||
useactivate = 0;
|
||||
if ((cp = strrchr(argv[0], '/')) != NULL)
|
||||
program_name = cp + 1;
|
||||
else
|
||||
program_name = argv[0];
|
||||
|
||||
opterr = 0;
|
||||
while ((op = getopt(argc, argv, "i:Ips:aB:")) != -1) {
|
||||
switch (op) {
|
||||
|
||||
case 'i':
|
||||
device = optarg;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
dorfmon = 1;
|
||||
useactivate = 1; /* required for rfmon */
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
dopromisc = 1;
|
||||
break;
|
||||
|
||||
case 's': {
|
||||
char *end;
|
||||
|
||||
snaplen = strtol(optarg, &end, 0);
|
||||
if (optarg == end || *end != '\0'
|
||||
|| snaplen < 0 || snaplen > MAXIMUM_SNAPLEN)
|
||||
error("invalid snaplen %s", optarg);
|
||||
else if (snaplen == 0)
|
||||
snaplen = MAXIMUM_SNAPLEN;
|
||||
break;
|
||||
}
|
||||
|
||||
case 'B':
|
||||
bufsize = atoi(optarg)*1024;
|
||||
if (bufsize <= 0)
|
||||
error("invalid packet buffer size %s", optarg);
|
||||
useactivate = 1; /* required for bufsize */
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
useactivate = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
/* NOTREACHED */
|
||||
}
|
||||
}
|
||||
|
||||
if (useactivate) {
|
||||
pd = pcap_create(device, ebuf);
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
status = pcap_set_snaplen(pd, snaplen);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_snaplen failed: %s",
|
||||
device, pcap_statustostr(status));
|
||||
if (dopromisc) {
|
||||
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));
|
||||
if (bufsize != 0) {
|
||||
status = pcap_set_buffer_size(pd, bufsize);
|
||||
if (status != 0)
|
||||
error("%s: pcap_set_buffer_size 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, 0, 1000, ebuf);
|
||||
if (pd == NULL)
|
||||
error("%s", ebuf);
|
||||
else if (*ebuf)
|
||||
warning("%s", ebuf);
|
||||
}
|
||||
pcap_close(pd);
|
||||
exit(status < 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"Usage: %s [ -Ipa ] [ -i interface ] [ -s snaplen ] [ -B bufsize ]\n",
|
||||
program_name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,27 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.90.2.1 2008/01/02 04:22:16 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/optimize.c,v 1.91 2008-01-02 04:16:46 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.99.2.17 2008-09-16 18:43:02 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bpf.c,v 1.116 2008-09-16 18:42:29 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -32,10 +32,24 @@ static const char rcsid[] _U_ =
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#include <sys/timeb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/file.h>
|
||||
/*
|
||||
* <net/bpf.h> defines ioctls, but doesn't include <sys/ioccom.h>.
|
||||
*
|
||||
* We include <sys/ioctl.h> as it might be necessary to declare ioctl();
|
||||
* at least on *BSD and Mac OS X, it also defines various SIOC ioctls -
|
||||
* we could include <sys/sockio.h>, but if we're already including
|
||||
* <sys/ioctl.h>, which includes <sys/sockio.h> on those platforms,
|
||||
* there's not much point in doing so.
|
||||
*
|
||||
* If we have <sys/ioccom.h>, we include it as well, to handle systems
|
||||
* such as Solaris which don't arrange to include <sys/ioccom.h> if you
|
||||
* include <sys/ioctl.h>
|
||||
*/
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef HAVE_SYS_IOCCOM_H
|
||||
#include <sys/ioccom.h>
|
||||
#endif
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
@@ -85,6 +99,8 @@ static const char rcsid[] _U_ =
|
||||
static int bpfloadedflag = 0;
|
||||
static int odmlockid = 0;
|
||||
|
||||
static int bpf_load(char *errbuf);
|
||||
|
||||
#else /* _AIX */
|
||||
|
||||
#include <net/bpf.h>
|
||||
@@ -92,6 +108,7 @@ static int odmlockid = 0;
|
||||
#endif /* _AIX */
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
@@ -109,6 +126,10 @@ static int odmlockid = 0;
|
||||
#include "pcap-dag.h"
|
||||
#endif /* HAVE_DAG_API */
|
||||
|
||||
#ifdef HAVE_SNF_API
|
||||
#include "pcap-snf.h"
|
||||
#endif /* HAVE_SNF_API */
|
||||
|
||||
#ifdef HAVE_OS_PROTO_H
|
||||
#include "os-proto.h"
|
||||
#endif
|
||||
@@ -192,11 +213,26 @@ pcap_setnonblock_zbuf(pcap_t *p, int nonblock, char *errbuf)
|
||||
* (from pcap-linux.c).
|
||||
*/
|
||||
if (nonblock) {
|
||||
if (p->md.timeout > 0)
|
||||
if (p->md.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.
|
||||
*/
|
||||
p->md.timeout = p->md.timeout * -1 - 1;
|
||||
} else
|
||||
if (p->md.timeout < 0)
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -385,6 +421,10 @@ pcap_create(const char *device, char *ebuf)
|
||||
if (strstr(device, "dag"))
|
||||
return (dag_create(device, ebuf));
|
||||
#endif /* HAVE_DAG_API */
|
||||
#ifdef HAVE_SNF_API
|
||||
if (strstr(device, "snf"))
|
||||
return (snf_create(device, ebuf));
|
||||
#endif /* HAVE_SNF_API */
|
||||
|
||||
p = pcap_create_common(device, ebuf);
|
||||
if (p == NULL)
|
||||
@@ -506,11 +546,20 @@ get_dlt_list(int fd, int v, struct bpf_dltlist *bdlp, char *ebuf)
|
||||
* right thing to do, but I suspect it is - Ethernet <->
|
||||
* 802.11 bridges would probably badly mishandle frames
|
||||
* that don't have Ethernet headers).
|
||||
*
|
||||
* On Solaris with BPF, Ethernet devices also offer
|
||||
* DLT_IPNET, so we, if DLT_IPNET is defined, we don't
|
||||
* treat it as an indication that the device isn't an
|
||||
* Ethernet.
|
||||
*/
|
||||
if (v == DLT_EN10MB) {
|
||||
is_ethernet = 1;
|
||||
for (i = 0; i < bdlp->bfl_len; i++) {
|
||||
if (bdlp->bfl_list[i] != DLT_EN10MB) {
|
||||
if (bdlp->bfl_list[i] != DLT_EN10MB
|
||||
#ifdef DLT_IPNET
|
||||
&& bdlp->bfl_list[i] != DLT_IPNET
|
||||
#endif
|
||||
) {
|
||||
is_ethernet = 0;
|
||||
break;
|
||||
}
|
||||
@@ -712,6 +761,7 @@ pcap_stats_bpf(pcap_t *p, struct pcap_stat *ps)
|
||||
|
||||
ps->ps_recv = s.bs_recv;
|
||||
ps->ps_drop = s.bs_drop;
|
||||
ps->ps_ifdrop = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -801,7 +851,22 @@ pcap_read_bpf(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
|
||||
case EWOULDBLOCK:
|
||||
return (0);
|
||||
#if defined(sun) && !defined(BSD)
|
||||
|
||||
case ENXIO:
|
||||
/*
|
||||
* The device on which we're capturing
|
||||
* went away.
|
||||
*
|
||||
* XXX - we should really return
|
||||
* PCAP_ERROR_IFACE_NOT_UP, but
|
||||
* pcap_dispatch() etc. aren't
|
||||
* defined to retur that.
|
||||
*/
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"The interface went down");
|
||||
return (PCAP_ERROR);
|
||||
|
||||
#if defined(sun) && !defined(BSD) && !defined(__svr4__) && !defined(__SVR4)
|
||||
/*
|
||||
* Due to a SunOS bug, after 2^31 bytes, the kernel
|
||||
* file offset overflows and read fails with EINVAL.
|
||||
@@ -989,6 +1054,7 @@ bpf_odminit(char *errbuf)
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: odm_lock of /etc/objrepos/config_lock failed: %s",
|
||||
errstr);
|
||||
(void)odm_terminate();
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
@@ -1001,20 +1067,24 @@ bpf_odmcleanup(char *errbuf)
|
||||
char *errstr;
|
||||
|
||||
if (odm_unlock(odmlockid) == -1) {
|
||||
if (odm_err_msg(odmerrno, &errstr) == -1)
|
||||
errstr = "Unknown error";
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: odm_unlock failed: %s",
|
||||
errstr);
|
||||
if (errbuf != NULL) {
|
||||
if (odm_err_msg(odmerrno, &errstr) == -1)
|
||||
errstr = "Unknown error";
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: odm_unlock failed: %s",
|
||||
errstr);
|
||||
}
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
if (odm_terminate() == -1) {
|
||||
if (odm_err_msg(odmerrno, &errstr) == -1)
|
||||
errstr = "Unknown error";
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: odm_terminate failed: %s",
|
||||
errstr);
|
||||
if (errbuf != NULL) {
|
||||
if (odm_err_msg(odmerrno, &errstr) == -1)
|
||||
errstr = "Unknown error";
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: odm_terminate failed: %s",
|
||||
errstr);
|
||||
}
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
@@ -1047,6 +1117,7 @@ bpf_load(char *errbuf)
|
||||
if (major == -1) {
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: genmajor failed: %s", pcap_strerror(errno));
|
||||
(void)bpf_odmcleanup(NULL);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
@@ -1057,6 +1128,7 @@ bpf_load(char *errbuf)
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE,
|
||||
"bpf_load: genminor failed: %s",
|
||||
pcap_strerror(errno));
|
||||
(void)bpf_odmcleanup(NULL);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -1133,13 +1205,13 @@ pcap_cleanup_bpf(pcap_t *p)
|
||||
struct ifreq ifr;
|
||||
#endif
|
||||
|
||||
if (p->md.must_clear != 0) {
|
||||
if (p->md.must_do_on_close != 0) {
|
||||
/*
|
||||
* There's something we have to do when closing this
|
||||
* pcap_t.
|
||||
*/
|
||||
#ifdef HAVE_BSD_IEEE80211
|
||||
if (p->md.must_clear & MUST_CLEAR_RFMON) {
|
||||
if (p->md.must_do_on_close & MUST_CLEAR_RFMON) {
|
||||
/*
|
||||
* We put the interface into rfmon mode;
|
||||
* take it out of rfmon mode.
|
||||
@@ -1194,7 +1266,7 @@ pcap_cleanup_bpf(pcap_t *p)
|
||||
* have to take the interface out of some mode.
|
||||
*/
|
||||
pcap_remove_from_pcaps_to_close(p);
|
||||
p->md.must_clear = 0;
|
||||
p->md.must_do_on_close = 0;
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZEROCOPY_BPF
|
||||
@@ -1251,7 +1323,9 @@ check_setif_failure(pcap_t *p, int error)
|
||||
* exist.
|
||||
*/
|
||||
err = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
strcpy(p->errbuf, "");
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFFLAGS on %s failed: %s",
|
||||
ifr.ifr_name, pcap_strerror(errno));
|
||||
} else {
|
||||
/*
|
||||
* The underlying "enN" device
|
||||
@@ -1273,7 +1347,9 @@ check_setif_failure(pcap_t *p, int error)
|
||||
* just report "no such device".
|
||||
*/
|
||||
err = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
strcpy(p->errbuf, "");
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"socket() failed: %s",
|
||||
pcap_strerror(errno));
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
@@ -1281,7 +1357,8 @@ check_setif_failure(pcap_t *p, int error)
|
||||
/*
|
||||
* No such device.
|
||||
*/
|
||||
strcpy(p->errbuf, "");
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "BIOCSETIF failed: %s",
|
||||
pcap_strerror(errno));
|
||||
return (PCAP_ERROR_NO_SUCH_DEVICE);
|
||||
} else if (errno == ENETDOWN) {
|
||||
/*
|
||||
@@ -1303,6 +1380,13 @@ check_setif_failure(pcap_t *p, int error)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Default capture buffer size.
|
||||
* 32K isn't very much for modern machines with fast networks; we
|
||||
* pick .5M, as that's the maximum on at least some systems with BPF.
|
||||
*/
|
||||
#define DEFAULT_BUFSIZE 524288
|
||||
|
||||
static int
|
||||
pcap_activate_bpf(pcap_t *p)
|
||||
{
|
||||
@@ -1413,7 +1497,10 @@ pcap_activate_bpf(pcap_t *p)
|
||||
* exist.
|
||||
*/
|
||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
strcpy(p->errbuf, "");
|
||||
snprintf(p->errbuf,
|
||||
PCAP_ERRBUF_SIZE,
|
||||
"SIOCGIFFLAGS failed: %s",
|
||||
pcap_strerror(errno));
|
||||
} else
|
||||
status = PCAP_ERROR_RFMON_NOTSUP;
|
||||
close(sockfd);
|
||||
@@ -1424,7 +1511,10 @@ pcap_activate_bpf(pcap_t *p)
|
||||
* report "no such device".
|
||||
*/
|
||||
status = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
strcpy(p->errbuf, "");
|
||||
snprintf(p->errbuf,
|
||||
PCAP_ERRBUF_SIZE,
|
||||
"socket() failed: %s",
|
||||
pcap_strerror(errno));
|
||||
}
|
||||
goto bad;
|
||||
}
|
||||
@@ -1491,8 +1581,8 @@ pcap_activate_bpf(pcap_t *p)
|
||||
v = p->opt.buffer_size;
|
||||
} else {
|
||||
if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) ||
|
||||
v < 32768)
|
||||
v = 32768;
|
||||
v < DEFAULT_BUFSIZE)
|
||||
v = DEFAULT_BUFSIZE;
|
||||
}
|
||||
#ifndef roundup
|
||||
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
|
||||
@@ -1558,14 +1648,15 @@ pcap_activate_bpf(pcap_t *p)
|
||||
/*
|
||||
* No buffer size was explicitly specified.
|
||||
*
|
||||
* Try finding a good size for the buffer; 32768 may
|
||||
* be too big, so keep cutting it in half until we
|
||||
* find a size that works, or run out of sizes to try.
|
||||
* Try finding a good size for the buffer;
|
||||
* DEFAULT_BUFSIZE may be too big, so keep
|
||||
* cutting it in half until we find a size
|
||||
* that works, or run out of sizes to try.
|
||||
* If the default is larger, don't make it smaller.
|
||||
*/
|
||||
if ((ioctl(fd, BIOCGBLEN, (caddr_t)&v) < 0) ||
|
||||
v < 32768)
|
||||
v = 32768;
|
||||
v < DEFAULT_BUFSIZE)
|
||||
v = DEFAULT_BUFSIZE;
|
||||
for ( ; v != 0; v >>= 1) {
|
||||
/*
|
||||
* Ignore the return value - this is because the
|
||||
@@ -2087,6 +2178,10 @@ pcap_platform_finddevs(pcap_if_t **alldevsp, char *errbuf)
|
||||
if (dag_platform_finddevs(alldevsp, errbuf) < 0)
|
||||
return (-1);
|
||||
#endif /* HAVE_DAG_API */
|
||||
#ifdef HAVE_SNF_API
|
||||
if (snf_platform_finddevs(alldevsp, errbuf) < 0)
|
||||
return (-1);
|
||||
#endif /* HAVE_SNF_API */
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -2221,7 +2316,7 @@ monitor_mode(pcap_t *p, int set)
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
p->md.must_clear |= MUST_CLEAR_RFMON;
|
||||
p->md.must_do_on_close |= MUST_CLEAR_RFMON;
|
||||
|
||||
/*
|
||||
* Add this to the list of pcaps to close when we exit.
|
||||
@@ -2306,7 +2401,8 @@ find_802_11(struct bpf_dltlist *bdlp)
|
||||
|
||||
#if defined(__APPLE__) && defined(BIOCGDLTLIST)
|
||||
/*
|
||||
* Remove DLT_EN10MB from the list of DLT_ values.
|
||||
* Remove DLT_EN10MB from the list of DLT_ values, as we're in monitor mode,
|
||||
* and DLT_EN10MB isn't supported in monitor mode.
|
||||
*/
|
||||
static void
|
||||
remove_en(pcap_t *p)
|
||||
@@ -2347,10 +2443,9 @@ remove_en(pcap_t *p)
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove DLT_EN10MB from the list of DLT_ values, and look for the
|
||||
* best 802.11 link-layer type in that list and return it.
|
||||
* Radiotap is better than anything else; 802.11 with any other radio
|
||||
* header is better than 802.11 with no radio header.
|
||||
* Remove 802.11 link-layer types from the list of DLT_ values, as
|
||||
* we're not in monitor mode, and those DLT_ values will switch us
|
||||
* to monitor mode.
|
||||
*/
|
||||
static void
|
||||
remove_802_11(pcap_t *p)
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.50 2007/04/01 21:43:55 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.50 2007-04-01 21:43:55 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.c,v 1.9.2.6 2008-07-01 07:06:37 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.c,v 1.15 2008-07-01 07:05:54 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* Bluetooth sniffing API implementation for Linux platform
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.h,v 1.4.2.1 2008-04-04 19:39:05 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-bt-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
264
libpcap/pcap-can-linux.c
Normal file
264
libpcap/pcap-can-linux.c
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Felix Obenhuber
|
||||
* 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.
|
||||
*
|
||||
* SocketCan sniffing API implementation for Linux platform
|
||||
* By Felix Obenhuber <felix@obenhuber.de>
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "pcap-int.h"
|
||||
#include "pcap-can-linux.h"
|
||||
|
||||
#ifdef NEED_STRERROR_H
|
||||
#include "strerror.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <linux/can.h>
|
||||
#include <linux/can/raw.h>
|
||||
|
||||
/* not yet defined anywhere */
|
||||
#ifndef PF_CAN
|
||||
#define PF_CAN 29
|
||||
#endif
|
||||
#ifndef AF_CAN
|
||||
#define AF_CAN PF_CAN
|
||||
#endif
|
||||
|
||||
/* forward declaration */
|
||||
static int can_activate(pcap_t *);
|
||||
static int can_read_linux(pcap_t *, int , pcap_handler , u_char *);
|
||||
static int can_inject_linux(pcap_t *, const void *, size_t);
|
||||
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 *);
|
||||
|
||||
pcap_t *
|
||||
can_create(const char *device, char *ebuf)
|
||||
{
|
||||
pcap_t* p;
|
||||
|
||||
p = pcap_create_common(device, ebuf);
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
|
||||
p->activate_op = can_activate;
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_activate(pcap_t* handle)
|
||||
{
|
||||
struct sockaddr_can addr;
|
||||
struct ifreq ifr;
|
||||
|
||||
/* Initialize some components of the pcap structure. */
|
||||
handle->bufsize = 24;
|
||||
handle->offset = 8;
|
||||
handle->linktype = DLT_CAN_SOCKETCAN;
|
||||
handle->read_op = can_read_linux;
|
||||
handle->inject_op = can_inject_linux;
|
||||
handle->setfilter_op = can_setfilter_linux;
|
||||
handle->setdirection_op = can_setdirection_linux;
|
||||
handle->set_datalink_op = NULL;
|
||||
handle->getnonblock_op = pcap_getnonblock_fd;
|
||||
handle->setnonblock_op = pcap_setnonblock_fd;
|
||||
handle->stats_op = can_stats_linux;
|
||||
|
||||
/* Create socket */
|
||||
handle->fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
|
||||
if (handle->fd < 0)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't create raw socket %d:%s",
|
||||
errno, strerror(errno));
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
/* get interface index */
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
strncpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name));
|
||||
if (ioctl(handle->fd, SIOCGIFINDEX, &ifr) < 0)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Unable to get interface index: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
handle->md.ifindex = ifr.ifr_ifindex;
|
||||
|
||||
/* allocate butter */
|
||||
handle->buffer = malloc(handle->bufsize);
|
||||
if (!handle->buffer)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't allocate dump buffer: %s",
|
||||
pcap_strerror(errno));
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
/* Bind to the socket */
|
||||
addr.can_family = AF_CAN;
|
||||
addr.can_ifindex = handle->md.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));
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
if (handle->opt.rfmon)
|
||||
{
|
||||
/* Monitor mode doesn't apply to CAN devices. */
|
||||
pcap_cleanup_live_common(handle);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
|
||||
handle->selectable_fd = handle->fd;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *user)
|
||||
{
|
||||
struct msghdr msg;
|
||||
struct pcap_pkthdr pkth;
|
||||
struct iovec iv;
|
||||
struct can_frame* cf;
|
||||
|
||||
iv.iov_base = &handle->buffer[handle->offset];
|
||||
iv.iov_len = handle->snapshot;
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.msg_iov = &iv;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = handle->buffer;
|
||||
msg.msg_controllen = handle->offset;
|
||||
|
||||
do
|
||||
{
|
||||
pkth.caplen = recvmsg(handle->fd, &msg, 0);
|
||||
if (handle->break_loop)
|
||||
{
|
||||
handle->break_loop = 0;
|
||||
return -2;
|
||||
}
|
||||
} while ((pkth.caplen == -1) && (errno == EINTR));
|
||||
|
||||
if (pkth.caplen < 0)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't receive packet %d:%s",
|
||||
errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* adjust capture len according to frame len */
|
||||
cf = (struct can_frame*)&handle->buffer[8];
|
||||
pkth.caplen -= 8 - cf->can_dlc;
|
||||
pkth.len = pkth.caplen;
|
||||
|
||||
cf->can_id = htonl( cf->can_id );
|
||||
|
||||
if( -1 == gettimeofday(&pkth.ts, NULL) )
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Can't get time of day %d:%s",
|
||||
errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
callback(user, &pkth, &handle->buffer[8]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_inject_linux(pcap_t *handle, const void *buf, size_t size)
|
||||
{
|
||||
/* not yet implemented */
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "inject not supported on "
|
||||
"can devices");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_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;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_setfilter_linux(pcap_t *p, struct bpf_program *fp)
|
||||
{
|
||||
/* not yet implemented */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
can_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 can");
|
||||
return -1;
|
||||
}
|
||||
|
||||
p->direction = d;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* eof */
|
||||
35
libpcap/pcap-can-linux.h
Normal file
35
libpcap/pcap-can-linux.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Felix Obenhuber
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Prototypes for SocketCAN related functions
|
||||
*/
|
||||
pcap_t* can_create(const char *device, char *ebuf);
|
||||
1179
libpcap/pcap-common.c
Normal file
1179
libpcap/pcap-common.c
Normal file
File diff suppressed because it is too large
Load Diff
25
libpcap/pcap-common.h
Normal file
25
libpcap/pcap-common.h
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/*
|
||||
* We use the "receiver-makes-right" approach to byte order,
|
||||
* because time is at a premium when we are writing the file.
|
||||
* In other words, the pcap_file_header and pcap_pkthdr,
|
||||
* records are written in host byte order.
|
||||
* Note that the bytes of packet data are written out in the order in
|
||||
* which they were received, so multi-byte fields in packets are not
|
||||
* written in host byte order, they're written in whatever order the
|
||||
* sending machine put them in.
|
||||
*
|
||||
* ntoh[ls] aren't sufficient because we might need to swap on a big-endian
|
||||
* machine (if the file was written in little-end order).
|
||||
*/
|
||||
#define SWAPLONG(y) \
|
||||
((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff))
|
||||
#define SWAPSHORT(y) \
|
||||
( (((y)&0xff)<<8) | ((u_short)((y)&0xff00)>>8) )
|
||||
|
||||
extern int dlt_to_linktype(int dlt);
|
||||
|
||||
extern int linktype_to_dlt(int linktype);
|
||||
|
||||
extern void swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
|
||||
int header_len_64_bytes);
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-config.1,v 1.1.2.2 2008-09-23 18:06:01 guy Exp $ (LBL)
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-config.1,v 1.1 2008-09-23 18:04:01 guy Exp $ (LBL)
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -20,14 +20,17 @@
|
||||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.\"
|
||||
.TH PCAP-CONFIG 1 "23 September 2008"
|
||||
.TH PCAP-CONFIG 1 "26 March 2009"
|
||||
.SH NAME
|
||||
pcap-config \- write libpcap compiler and linker flags to standard output
|
||||
.SH SYNOPSIS
|
||||
.na
|
||||
.B pcap-config
|
||||
[
|
||||
.B \-\-cflags | \-\-libs
|
||||
.B \-\-static
|
||||
]
|
||||
[
|
||||
.B \-\-cflags | \-\-libs | \-\-additional-libs
|
||||
]
|
||||
.ad
|
||||
.SH DESCRIPTION
|
||||
@@ -47,8 +50,25 @@ writes to the standard output the
|
||||
.B \-L
|
||||
and
|
||||
.B \-l
|
||||
linker required to link with libpcap, including
|
||||
linker flags required to link with libpcap, including
|
||||
.B \-l
|
||||
flags for libraries required by libpcap.
|
||||
When run with the
|
||||
.B \-\-additional-libs
|
||||
option,
|
||||
.I pcap-config
|
||||
writes to the standard output the
|
||||
.B \-L
|
||||
and
|
||||
.B \-l
|
||||
flags for libraries required by libpcap, but not the
|
||||
.B \-lpcap
|
||||
flag to link with libpcap itself.
|
||||
.LP
|
||||
By default, it writes flags appropriate for compiling with a
|
||||
dynamically-linked version of libpcap; the
|
||||
.B \-\-static
|
||||
flag causes it to write flags appropriate for compiling with a
|
||||
statically-linked version of libpcap.
|
||||
.SH "SEE ALSO"
|
||||
pcap(3PCAP)
|
||||
|
||||
@@ -4,13 +4,79 @@
|
||||
# Script to give the appropriate compiler flags and linker flags
|
||||
# to use when building code that uses libpcap.
|
||||
#
|
||||
case "$1" in
|
||||
static=0
|
||||
show_cflags=0
|
||||
show_libs=0
|
||||
while [ "$#" != 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
|
||||
--cflags)
|
||||
echo "-I @includedir@"
|
||||
;;
|
||||
--static)
|
||||
static=1
|
||||
;;
|
||||
|
||||
--libs)
|
||||
echo "-L @libdir@ -lpcap @DEPLIBS@"
|
||||
;;
|
||||
esac
|
||||
--cflags)
|
||||
show_cflags=1
|
||||
;;
|
||||
|
||||
--libs)
|
||||
show_libs=1
|
||||
;;
|
||||
|
||||
--additional-libs)
|
||||
show_additional_libs=1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
if [ "@V_RPATH_OPT@" != "" ]
|
||||
then
|
||||
#
|
||||
# If libdir isn't /usr/lib, add it to the run-time linker path.
|
||||
#
|
||||
if [ "@libdir@" != "/usr/lib" ]
|
||||
then
|
||||
RPATH=@V_RPATH_OPT@@libdir@
|
||||
fi
|
||||
fi
|
||||
if [ "$static" = 1 ]
|
||||
then
|
||||
#
|
||||
# Include LIBS so that the flags include libraries containing
|
||||
# routines that libpcap uses.
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ -lpcap @LIBS@"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ @LIBS@"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L@libdir@ -lpcap @LIBS@"
|
||||
elif [ "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "@LIBS@"
|
||||
fi
|
||||
else
|
||||
#
|
||||
# Omit LIBS - libpcap is assumed to be linked with those
|
||||
# libraries, so there's no need to do so explicitly.
|
||||
#
|
||||
if [ "$show_cflags" = 1 -a "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@ -L@libdir@ $RPATH -lpcap"
|
||||
elif [ "$show_cflags" = 1 -a "$show_additional_libs" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
elif [ "$show_cflags" = 1 ]
|
||||
then
|
||||
echo "-I@includedir@"
|
||||
elif [ "$show_libs" = 1 ]
|
||||
then
|
||||
echo "-L@libdir@ $RPATH -lpcap"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.31.2.8 2008-04-14 20:41:51 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dag.c,v 1.39 2008-04-14 20:40:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -368,6 +368,10 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
case TYPE_MC_AAL5:
|
||||
case TYPE_MC_ATM:
|
||||
case TYPE_MC_HDLC:
|
||||
case TYPE_MC_RAW_CHANNEL:
|
||||
case TYPE_MC_RAW:
|
||||
case TYPE_MC_AAL2:
|
||||
case TYPE_COLOR_MC_HDLC_POS:
|
||||
packet_len += 4; /* MC header */
|
||||
break;
|
||||
|
||||
@@ -487,6 +491,7 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
break;
|
||||
|
||||
case TYPE_IPV4:
|
||||
case TYPE_IPV6:
|
||||
packet_len = ntohs(header->wlen);
|
||||
caplen = rlen - dag_record_size;
|
||||
if (caplen > packet_len) {
|
||||
@@ -494,6 +499,14 @@ dag_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
}
|
||||
break;
|
||||
|
||||
/* These types have no matching 'native' DLT, but can be used with DLT_ERF above */
|
||||
case TYPE_MC_RAW:
|
||||
case TYPE_MC_RAW_CHANNEL:
|
||||
case TYPE_IP_COUNTER:
|
||||
case TYPE_TCP_FLOW_COUNTER:
|
||||
case TYPE_INFINIBAND:
|
||||
case TYPE_RAW_LINK:
|
||||
case TYPE_INFINIBAND_LINK:
|
||||
default:
|
||||
/* Unhandled ERF type.
|
||||
* Ignore rather than generating error
|
||||
@@ -790,6 +803,7 @@ static int dag_activate(pcap_t* handle)
|
||||
handle->cleanup_op = dag_platform_cleanup;
|
||||
handle->md.stat.ps_drop = 0;
|
||||
handle->md.stat.ps_recv = 0;
|
||||
handle->md.stat.ps_ifdrop = 0;
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_DAG_STREAMS_API
|
||||
@@ -1089,6 +1103,7 @@ dag_get_datalink(pcap_t *p)
|
||||
break;
|
||||
|
||||
case TYPE_IPV4:
|
||||
case TYPE_IPV6:
|
||||
if(!p->linktype)
|
||||
p->linktype = DLT_RAW;
|
||||
break;
|
||||
@@ -1099,10 +1114,11 @@ dag_get_datalink(pcap_t *p)
|
||||
case TYPE_IP_COUNTER:
|
||||
case TYPE_TCP_FLOW_COUNTER:
|
||||
case TYPE_INFINIBAND:
|
||||
case TYPE_IPV6:
|
||||
case TYPE_RAW_LINK:
|
||||
case TYPE_INFINIBAND_LINK:
|
||||
default:
|
||||
/* Libpcap cannot deal with these types yet */
|
||||
/* Add no DLTs, but still covered by DLT_ERF */
|
||||
/* Add no 'native' DLTs, but still covered by DLT_ERF */
|
||||
break;
|
||||
|
||||
} /* switch */
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* Author: Richard Littin, Sean Irvine ({richard,sean}@reeltwo.com)
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dag.h,v 1.4.2.3 2008-04-04 19:39:06 guy Exp $ (LBL)
|
||||
* @(#) $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 *);
|
||||
@@ -93,6 +93,14 @@ int dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf);
|
||||
#define TYPE_IPV6 23
|
||||
#endif
|
||||
|
||||
#ifndef TYPE_RAW_LINK
|
||||
#define TYPE_RAW_LINK 24
|
||||
#endif
|
||||
|
||||
#ifndef TYPE_INFINIBAND_LINK
|
||||
#define TYPE_INFINIBAND_LINK 25
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef TYPE_PAD
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.116.2.11 2008-04-14 20:41:51 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-dlpi.c,v 1.128 2008-12-02 16:20:23 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -180,6 +180,12 @@ static struct strbuf ctl = {
|
||||
(char *)ctlbuf
|
||||
};
|
||||
|
||||
/*
|
||||
* Cast a buffer to "union DL_primitives" without provoking warnings
|
||||
* from the compiler.
|
||||
*/
|
||||
#define MAKE_DL_PRIMITIVES(ptr) ((union DL_primitives *)(void *)(ptr))
|
||||
|
||||
static int
|
||||
pcap_read_dlpi(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
{
|
||||
@@ -498,7 +504,7 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
if (dlinforeq(p->fd, p->errbuf) < 0 ||
|
||||
dlinfoack(p->fd, (char *)buf, p->errbuf) < 0)
|
||||
goto bad;
|
||||
infop = &((union DL_primitives *)buf)->info_ack;
|
||||
infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
|
||||
#ifdef HAVE_SOLARIS
|
||||
if (infop->dl_mac_type == DL_IPATM)
|
||||
isatm = 1;
|
||||
@@ -674,7 +680,7 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
dlinfoack(p->fd, (char *)buf, p->errbuf) < 0)
|
||||
goto bad;
|
||||
|
||||
infop = &((union DL_primitives *)buf)->info_ack;
|
||||
infop = &(MAKE_DL_PRIMITIVES(buf))->info_ack;
|
||||
if (pcap_process_mactype(p, infop->dl_mac_type) != 0)
|
||||
goto bad;
|
||||
|
||||
@@ -690,6 +696,7 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
ss = p->snapshot;
|
||||
|
||||
/*
|
||||
@@ -712,7 +719,6 @@ pcap_activate_dlpi(pcap_t *p)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_BUFMOD_H
|
||||
/* Push and configure bufmod. */
|
||||
if (pcap_conf_bufmod(p, ss, p->md.timeout) != 0)
|
||||
goto bad;
|
||||
@@ -959,7 +965,7 @@ recv_ack(int fd, int size, const char *what, char *bufp, char *ebuf, int *uerror
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
dlp = (union DL_primitives *) ctl.buf;
|
||||
dlp = MAKE_DL_PRIMITIVES(ctl.buf);
|
||||
switch (dlp->dl_primitive) {
|
||||
|
||||
case DL_INFO_ACK:
|
||||
@@ -1319,7 +1325,7 @@ dlrawdatareq(int fd, const u_char *datap, int datalen)
|
||||
union DL_primitives *dlp;
|
||||
int dlen;
|
||||
|
||||
dlp = (union DL_primitives*) buf;
|
||||
dlp = MAKE_DL_PRIMITIVES(buf);
|
||||
|
||||
dlp->dl_primitive = DL_HP_RAWDATA_REQ;
|
||||
dlen = DL_HP_RAWDATA_REQ_SIZE;
|
||||
@@ -1491,8 +1497,8 @@ get_dlpi_ppa(register int fd, register const char *device, register int unit,
|
||||
}
|
||||
if (ctl.len < dlp->dl_length) {
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE,
|
||||
"get_dlpi_ppa: hpppa ack too small (%d < %d)",
|
||||
ctl.len, dlp->dl_length);
|
||||
"get_dlpi_ppa: hpppa ack too small (%d < %lu)",
|
||||
ctl.len, (unsigned long)dlp->dl_length);
|
||||
free(ppa_data_buf);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* pcap-dos.c: Interface to PKTDRVR, NDIS2 and 32-bit pmode
|
||||
* network drivers.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.2.2.5 2008-04-22 17:16:49 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.c,v 1.7 2008-04-22 17:16:30 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Internal details for libpcap on DOS.
|
||||
* 32-bit targets: djgpp, Pharlap or DOS4GW.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.h,v 1.1 2004/12/18 08:52:10 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.h,v 1.1 2004-12-18 08:52:10 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef __PCAP_DOS_H
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-enet.c,v 1.9 2006/10/04 18:09:22 guy Exp $";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-enet.c,v 1.9 2006-10-04 18:09:22 guy Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-filter.manmisc.in,v 1.1.2.2 2008-10-21 07:44:56 guy Exp $ (LBL)
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-filter.manmisc.in,v 1.1 2008-10-21 07:33:01 guy Exp $ (LBL)
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.85.2.9 2008-09-16 00:21:08 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.94 2008-09-16 00:20:23 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef pcap_int_h
|
||||
@@ -48,6 +48,7 @@ extern "C" {
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Packet32.h>
|
||||
extern CRITICAL_SECTION g_PcapCompileCriticalSection;
|
||||
#endif /* WIN32 */
|
||||
|
||||
#ifdef MSDOS
|
||||
@@ -55,6 +56,10 @@ extern "C" {
|
||||
#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*/
|
||||
|
||||
/*
|
||||
@@ -101,12 +106,16 @@ typedef enum {
|
||||
*/
|
||||
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;
|
||||
u_char *base;
|
||||
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 */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -123,7 +132,7 @@ struct pcap_md {
|
||||
long OrigMissed; /* missed by i/f before this run */
|
||||
char *device; /* device name */
|
||||
int timeout; /* timeout for buffering */
|
||||
int must_clear; /* stuff we must clear when we close */
|
||||
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 */
|
||||
@@ -132,8 +141,13 @@ struct pcap_md {
|
||||
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
|
||||
@@ -152,6 +166,13 @@ struct pcap_md {
|
||||
* 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
|
||||
@@ -177,10 +198,11 @@ struct pcap_md {
|
||||
};
|
||||
|
||||
/*
|
||||
* Stuff to clear when we close.
|
||||
* Stuff to do when we close.
|
||||
*/
|
||||
#define MUST_CLEAR_PROMISC 0x00000001 /* promiscuous mode */
|
||||
#define MUST_CLEAR_RFMON 0x00000002 /* rfmon (monitor) mode */
|
||||
#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;
|
||||
@@ -285,6 +307,11 @@ struct pcap {
|
||||
setnonblock_op_t setnonblock_op;
|
||||
stats_op_t stats_op;
|
||||
|
||||
/*
|
||||
* Routine to use as callback for pcap_next()/pcap_next_ex().
|
||||
*/
|
||||
pcap_handler oneshot_callback;
|
||||
|
||||
#ifdef WIN32
|
||||
/*
|
||||
* These are, at least currently, specific to the Win32 NPF
|
||||
@@ -377,6 +404,16 @@ struct pcap_sf_patched_pkthdr {
|
||||
unsigned char pkt_type;
|
||||
};
|
||||
|
||||
/*
|
||||
* User data structure for the one-shot callback used for pcap_next()
|
||||
* and pcap_next_ex().
|
||||
*/
|
||||
struct oneshot_userdata {
|
||||
struct pcap_pkthdr *hdr;
|
||||
const u_char **pkt;
|
||||
pcap_t *pd;
|
||||
};
|
||||
|
||||
int yylex(void);
|
||||
|
||||
#ifndef min
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-libdlpi.c,v 1.1.2.6 2008-04-14 20:41:52 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-libdlpi.c,v 1.6 2008-04-14 20:40:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -53,6 +53,7 @@ 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 *);
|
||||
|
||||
/*
|
||||
* list_interfaces() will list all the network links that are
|
||||
@@ -113,7 +114,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (retv == DLPI_ELINKNAMEINVAL || retv == DLPI_ENOLINK)
|
||||
err = PCAP_ERROR_NO_SUCH_DEVICE;
|
||||
else if (retv == DLPI_SYSERR && errno == EACCES)
|
||||
else if (retv == DL_SYSERR && errno == EACCES)
|
||||
err = PCAP_ERROR_PERM_DENIED;
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_open", retv,
|
||||
p->errbuf);
|
||||
@@ -155,8 +156,9 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
}
|
||||
|
||||
/* Try to enable SAP promiscuity. */
|
||||
if ((retv = dlpi_promiscon(p->dlpi_hd, DL_PROMISC_SAP)) != DLPI_SUCCESS) {
|
||||
if (!promisc) {
|
||||
retv = dlpi_promiscon(p->dlpi_hd, DL_PROMISC_SAP);
|
||||
if (retv != DLPI_SUCCESS) {
|
||||
if (p->opt.promisc) {
|
||||
pcap_libdlpi_err(p->opt.source, "dlpi_promisc(SAP)",
|
||||
retv, p->errbuf);
|
||||
goto bad;
|
||||
@@ -179,7 +181,7 @@ pcap_activate_libdlpi(pcap_t *p)
|
||||
p->fd = dlpi_fd(p->dlpi_hd);
|
||||
|
||||
/* Push and configure bufmod. */
|
||||
if (pcap_conf_bufmod(p, snaplen, p->md.timeout) != 0)
|
||||
if (pcap_conf_bufmod(p, p->snapshot, p->md.timeout) != 0)
|
||||
goto bad;
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-linktype.manmisc.in,v 1.1.2.4 2008-10-27 22:52:05 guy Exp $
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-linktype.manmisc.in,v 1.3 2008-10-27 22:52:30 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1987, 1988, 1989, 1990, 1991, 1992, 1994, 1995, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
@@ -56,7 +56,7 @@ values by name.
|
||||
.RS 5
|
||||
.TP 5
|
||||
.BR DLT_NULL "; " LINKTYPE_NULL = 0
|
||||
BSD loopback encapsulation; the link layer header is a 4-byte field, in
|
||||
BSD loopback encapsulation; the link-layer header is a 4-byte field, in
|
||||
.I host
|
||||
byte order, containing a PF_ value from
|
||||
.B socket.h
|
||||
@@ -90,7 +90,7 @@ name is historical.
|
||||
ARCNET
|
||||
.TP 5
|
||||
.BR DLT_SLIP "; " LINKTYPE_SLIP = 8
|
||||
SLIP; the link layer header contains, in order:
|
||||
SLIP; the link-layer header contains, in order:
|
||||
.RS 10
|
||||
.LP
|
||||
a 1-byte flag, which is 0 for packets received by the machine and 1 for
|
||||
@@ -155,7 +155,7 @@ IEEE 802.11 wireless LAN
|
||||
Frame Relay
|
||||
.TP 5
|
||||
.BR DLT_LOOP "; " LINKTYPE_LOOP = 108
|
||||
OpenBSD loopback encapsulation; the link layer header is a 4-byte field, in
|
||||
OpenBSD loopback encapsulation; the link-layer header is a 4-byte field, in
|
||||
.I network
|
||||
byte order, containing a PF_ value from OpenBSD's
|
||||
.B socket.h
|
||||
@@ -166,7 +166,7 @@ Note that, if a ``savefile'' is being read, those PF_ values are
|
||||
necessarily those of the machine reading the capture file.
|
||||
.TP 5
|
||||
.BR DLT_LINUX_SLL "; " LINKTYPE_LINUX_SLL = 113
|
||||
Linux "cooked" capture encapsulation; the link layer header contains, in
|
||||
Linux "cooked" capture encapsulation; the link-layer header contains, in
|
||||
order:
|
||||
.RS 10
|
||||
.LP
|
||||
@@ -190,13 +190,15 @@ packet was sent by us
|
||||
.RE
|
||||
.LP
|
||||
a 2-byte field, in network byte order, containing a Linux ARPHRD_ value
|
||||
for the link layer device type;
|
||||
for the link-layer device type;
|
||||
.LP
|
||||
a 2-byte field, in network byte order, containing the length of the
|
||||
link layer address of the sender of the packet (which could be 0);
|
||||
link-layer address of the sender of the packet (which could be 0);
|
||||
.LP
|
||||
an 8-byte field containing that number of bytes of the link layer header
|
||||
(if there are more than 8 bytes, only the first 8 are present);
|
||||
an 8-byte field containing that number of bytes of the link-layer
|
||||
address of the sender (if there are more than 8 bytes, only the first
|
||||
8 are present, and if there are fewer than 8 bytes, there are padding
|
||||
bytes after the address to pad the field to 8 bytes);
|
||||
.LP
|
||||
a 2-byte field containing an Ethernet protocol type, in network byte
|
||||
order, or containing 1 for Novell 802.3 frames without an 802.2 LLC
|
||||
@@ -207,7 +209,7 @@ header or 4 for frames beginning with an 802.2 LLC header.
|
||||
Apple LocalTalk; the packet begins with an AppleTalk LLAP header.
|
||||
.TP 5
|
||||
.BR DLT_PFLOG "; " LINKTYPE_PFLOG = 117
|
||||
OpenBSD pflog; the link layer header contains a
|
||||
OpenBSD pflog; the link-layer header contains a
|
||||
.B "struct pfloghdr"
|
||||
structure, as defined by the host on which the file was saved. (This
|
||||
differs from operating system to operating system and release to
|
||||
@@ -222,7 +224,7 @@ RFC 2625 IP-over-Fibre Channel, with the link-layer header being the
|
||||
Network_Header as described in that RFC.
|
||||
.TP 5
|
||||
.BR DLT_SUNATM "; " LINKTYPE_SUNATM = 123
|
||||
SunATM devices; the link layer header contains, in order:
|
||||
SunATM devices; the link-layer header contains, in order:
|
||||
.RS 10
|
||||
.LP
|
||||
a 1-byte flag field, containing a direction flag in the uppermost bit,
|
||||
|
||||
1645
libpcap/pcap-linux.c
1645
libpcap/pcap-linux.c
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.13 2006/10/04 18:13:32 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-namedb.h,v 1.13 2006-10-04 18:13:32 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.58.2.4 2008-04-14 20:41:52 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-nit.c,v 1.62 2008-04-14 20:40:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -323,6 +323,7 @@ pcap_activate_nit(pcap_t *p)
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.21.4.1 2008-04-04 19:39:06 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-null.c,v 1.22 2008-04-04 19:37:45 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -40,9 +40,9 @@ static const char rcsid[] _U_ =
|
||||
static char nosup[] = "live packet capture not supported on this system";
|
||||
|
||||
pcap_t *
|
||||
pcap_activate(pcap_t *p)
|
||||
pcap_create(const char *device, char *ebuf)
|
||||
{
|
||||
(void)strlcpy(p->errbuf, nosup, PCAP_ERRBUF_SIZE);
|
||||
(void)strlcpy(ebuf, nosup, PCAP_ERRBUF_SIZE);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.94.2.3 2008-04-14 20:41:52 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-pf.c,v 1.97 2008-04-14 20:40:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -494,6 +494,7 @@ your system may not be properly configured; see the packetfilter(4) man page\n",
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
'\" t
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-savefile.manfile.in,v 1.1.2.3 2008-10-24 07:34:06 guy Exp $
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap-savefile.manfile.in,v 1.2 2008-10-24 07:33:50 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-septel.c,v 1.2.2.2 2008-04-14 20:41:52 guy Exp $";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-septel.c,v 1.4 2008-04-14 20:40:58 guy Exp $";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Authors: Gilbert HOYEK (gil_hoyek@hotmail.com), Elias M. KHOURY
|
||||
* (+961 3 485343);
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-septel.h,v 1.1.4.1 2008-04-04 19:39:06 guy Exp $
|
||||
* @(#) $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);
|
||||
|
||||
@@ -20,7 +20,7 @@ A { text-decoration:none }
|
||||
|
||||
<H3>SUMMARY</H3>
|
||||
<UL>
|
||||
<STRONG>Note:</STRONG> This document is part of the libpcap CVS and was derived from 'pcap.3' (circa Aug/07).
|
||||
<STRONG>Note:</STRONG> This document is part of the libpcap Git and was derived from 'pcap.3' (circa Aug/07).
|
||||
<P>
|
||||
The ACN provides a customized/distributed version of this library that alows SMPs to
|
||||
interact with the various IOPs within the site providing a standard mechanism
|
||||
|
||||
306
libpcap/pcap-snf.c
Normal file
306
libpcap/pcap-snf.c
Normal file
@@ -0,0 +1,306 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "snf.h"
|
||||
#include "pcap-int.h"
|
||||
|
||||
#ifdef SNF_ONLY
|
||||
#define snf_create pcap_create
|
||||
#define snf_platform_finddevs pcap_platform_finddevs
|
||||
#endif
|
||||
|
||||
static int
|
||||
snf_set_datalink(pcap_t *p, int dlt)
|
||||
{
|
||||
p->linktype = dlt;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
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))) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snf_get_stats: %s",
|
||||
pcap_strerror(rc));
|
||||
return -1;
|
||||
}
|
||||
ps->ps_recv = stats.ring_pkt_recv + stats.ring_pkt_overflow;
|
||||
ps->ps_drop = stats.ring_pkt_overflow;
|
||||
ps->ps_ifdrop = stats.nic_pkt_overflow + stats.nic_pkt_bad;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
snf_platform_cleanup(pcap_t *p)
|
||||
{
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
snf_ring_close(p->md.snf_ring);
|
||||
snf_close(p->md.snf_handle);
|
||||
pcap_cleanup_live_common(p);
|
||||
}
|
||||
|
||||
static int
|
||||
snf_getnonblock(pcap_t *p, char *errbuf)
|
||||
{
|
||||
return (p->md.snf_timeout == 0);
|
||||
}
|
||||
|
||||
static int
|
||||
snf_setnonblock(pcap_t *p, int nonblock, char *errbuf)
|
||||
{
|
||||
if (nonblock)
|
||||
p->md.snf_timeout = 0;
|
||||
else {
|
||||
if (p->md.timeout <= 0)
|
||||
p->md.snf_timeout = -1; /* forever */
|
||||
else
|
||||
p->md.snf_timeout = p->md.timeout;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define _NSEC_PER_SEC 1000000000
|
||||
|
||||
static inline
|
||||
struct timeval
|
||||
snf_timestamp_to_timeval(const int64_t ts_nanosec)
|
||||
{
|
||||
struct timeval tv;
|
||||
int32_t rem;
|
||||
if (ts_nanosec == 0)
|
||||
return (struct timeval) { 0, 0 };
|
||||
tv.tv_sec = ts_nanosec / _NSEC_PER_SEC;
|
||||
tv.tv_usec = (ts_nanosec % _NSEC_PER_SEC) / 1000;
|
||||
return tv;
|
||||
}
|
||||
|
||||
static int
|
||||
snf_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
{
|
||||
struct pcap_pkthdr hdr;
|
||||
int i, flags, err, caplen, n;
|
||||
struct snf_recv_req req;
|
||||
|
||||
if (!p || cnt == 0)
|
||||
return -1;
|
||||
|
||||
n = 0;
|
||||
while (n < cnt || cnt < 0) {
|
||||
/*
|
||||
* Has "pcap_breakloop()" been called?
|
||||
*/
|
||||
if (p->break_loop) {
|
||||
if (n == 0) {
|
||||
p->break_loop = 0;
|
||||
return (-2);
|
||||
} else {
|
||||
return (n);
|
||||
}
|
||||
}
|
||||
|
||||
err = snf_ring_recv(p->md.snf_ring, p->md.snf_timeout, &req);
|
||||
|
||||
if (err) {
|
||||
if (err == EBUSY || err == EAGAIN)
|
||||
return (0);
|
||||
if (err == EINTR)
|
||||
continue;
|
||||
if (err != 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "snf_read: %s",
|
||||
pcap_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
caplen = req.length;
|
||||
if (caplen > p->snapshot)
|
||||
caplen = p->snapshot;
|
||||
|
||||
if ((p->fcode.bf_insns == NULL) ||
|
||||
bpf_filter(p->fcode.bf_insns, req.pkt_addr, req.length, caplen)) {
|
||||
hdr.ts = snf_timestamp_to_timeval(req.timestamp);
|
||||
hdr.caplen = caplen;
|
||||
hdr.len = req.length;
|
||||
callback(user, &hdr, req.pkt_addr);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
return (n);
|
||||
}
|
||||
|
||||
static int
|
||||
snf_setfilter(pcap_t *p, struct bpf_program *fp)
|
||||
{
|
||||
if (!p)
|
||||
return -1;
|
||||
if (!fp) {
|
||||
strncpy(p->errbuf, "setfilter: No filter specified",
|
||||
sizeof(p->errbuf));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Make our private copy of the filter */
|
||||
|
||||
if (install_bpf_program(p, fp) < 0)
|
||||
return -1;
|
||||
|
||||
p->md.use_bpf = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
snf_inject(pcap_t *p, const void *buf _U_, size_t size _U_)
|
||||
{
|
||||
strlcpy(p->errbuf, "Sending packets isn't supported with snf",
|
||||
PCAP_ERRBUF_SIZE);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static int
|
||||
snf_activate(pcap_t* p)
|
||||
{
|
||||
char *device = p->opt.source;
|
||||
const char *nr = NULL;
|
||||
int err;
|
||||
int flags = 0;
|
||||
|
||||
if (device == NULL) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"device is NULL: %s", pcap_strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* In Libpcap, we set pshared by default if NUM_RINGS is set to > 1.
|
||||
* Since libpcap isn't thread-safe */
|
||||
if ((nr = getenv("SNF_NUM_RINGS")) && *nr && atoi(nr) > 1)
|
||||
flags |= SNF_F_PSHARED;
|
||||
else
|
||||
nr = NULL;
|
||||
|
||||
err = snf_open(p->md.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);
|
||||
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);
|
||||
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;
|
||||
else
|
||||
p->md.snf_timeout = p->md.timeout;
|
||||
|
||||
err = snf_start(p->md.snf_handle);
|
||||
if (err != 0) {
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"snf_start failed: %s", pcap_strerror(err));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* "select()" and "poll()" don't work on snf descriptors.
|
||||
*/
|
||||
p->selectable_fd = -1;
|
||||
p->linktype = DLT_EN10MB;
|
||||
p->read_op = snf_read;
|
||||
p->inject_op = snf_inject;
|
||||
p->setfilter_op = snf_setfilter;
|
||||
p->setdirection_op = NULL; /* Not implemented.*/
|
||||
p->set_datalink_op = snf_set_datalink;
|
||||
p->getnonblock_op = snf_getnonblock;
|
||||
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)
|
||||
{
|
||||
/*
|
||||
* There are no platform-specific devices since each device
|
||||
* exists as a regular Ethernet device.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
snf_create(const char *device, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
int boardnum = -1;
|
||||
struct snf_ifaddrs *ifaddrs, *ifa;
|
||||
size_t devlen;
|
||||
|
||||
if (snf_init(SNF_VERSION_API))
|
||||
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)
|
||||
return NULL;
|
||||
devlen = strlen(device) + 1;
|
||||
ifa = ifaddrs;
|
||||
while (ifa) {
|
||||
if (!strncmp(device, ifa->snf_ifa_name, devlen)) {
|
||||
boardnum = ifa->snf_ifa_boardnum;
|
||||
break;
|
||||
}
|
||||
ifa = ifa->snf_ifa_next;
|
||||
}
|
||||
snf_freeifaddrs(ifaddrs);
|
||||
|
||||
if (ifa == NULL) {
|
||||
/*
|
||||
* If we can't find the device by name, support the name "snfX"
|
||||
* and "snf10gX" where X is the board number.
|
||||
*/
|
||||
if (sscanf(device, "snf10g%d", &boardnum) != 1 &&
|
||||
sscanf(device, "snf%d", &boardnum) != 1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = pcap_create_common(device, ebuf);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
p->activate_op = snf_activate;
|
||||
p->md.snf_boardnum = boardnum;
|
||||
return p;
|
||||
}
|
||||
2
libpcap/pcap-snf.h
Normal file
2
libpcap/pcap-snf.h
Normal file
@@ -0,0 +1,2 @@
|
||||
pcap_t *snf_create(const char *, char *);
|
||||
int snf_platform_finddevs(pcap_if_t **devlistp, char *errbuf);
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.73.2.4 2008-04-14 20:41:52 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snit.c,v 1.77 2008-04-14 20:40:58 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -402,6 +402,7 @@ pcap_activate_snit(pcap_t *p)
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.55.2.3 2008-04-14 20:41:52 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-snoop.c,v 1.59 2008-12-02 16:25:14 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -226,8 +226,8 @@ pcap_activate_snoop(pcap_t *p)
|
||||
pcap_strerror(errno));
|
||||
goto bad;
|
||||
}
|
||||
if (handle->opt.buffer_size != 0)
|
||||
v = handle->opt.buffer_size;
|
||||
if (p->opt.buffer_size != 0)
|
||||
v = p->opt.buffer_size;
|
||||
else
|
||||
v = 64 * 1024; /* default to 64K buffer size */
|
||||
(void)setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char *)&v, sizeof(v));
|
||||
@@ -389,6 +389,7 @@ pcap_activate_snoop(pcap_t *p)
|
||||
|
||||
return (0);
|
||||
bad:
|
||||
pcap_cleanup_live_common(p);
|
||||
return (PCAP_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2002 - 2003
|
||||
* NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
|
||||
* Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -30,6 +30,8 @@
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-stdinc.h,v 1.10.2.1 2008-10-06 15:38:39 gianluca Exp $ (LBL)
|
||||
*/
|
||||
#ifndef pcap_stdinc_h
|
||||
#define pcap_stdinc_h
|
||||
|
||||
#define SIZEOF_CHAR 1
|
||||
#define SIZEOF_SHORT 2
|
||||
@@ -60,9 +62,12 @@
|
||||
|
||||
#define caddr_t char*
|
||||
|
||||
#if _MSC_VER < 1500
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#define inline __inline
|
||||
|
||||
#ifdef __MINGW32__
|
||||
@@ -88,3 +93,4 @@ typedef _W64 int intptr_t;
|
||||
#endif
|
||||
|
||||
#endif /*__MINGW32__*/
|
||||
#endif /* pcap_stdinc_h */
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
*/
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.16.2.8 2008-04-14 21:06:29 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.c,v 1.33 2008-12-23 21:38:50 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -60,19 +60,17 @@ static const char rcsid[] _U_ =
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#ifdef HAVE_LINUX_USBDEVICE_FS_H
|
||||
#include <linux/usbdevice_fs.h>
|
||||
#endif
|
||||
|
||||
#define USB_IFACE "usb"
|
||||
#define USB_TEXT_DIR "/sys/kernel/debug/usbmon"
|
||||
#define USB_BUS_DIR "/proc/bus/usb"
|
||||
#define USB_IFACE "usbmon"
|
||||
#define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon"
|
||||
#define USB_TEXT_DIR "/sys/kernel/debug/usb/usbmon"
|
||||
#define SYS_USB_BUS_DIR "/sys/bus/usb/devices"
|
||||
#define PROC_USB_BUS_DIR "/proc/bus/usb"
|
||||
#define USB_LINE_LEN 4096
|
||||
|
||||
|
||||
#define PIPE_IN 0x80
|
||||
#define PIPE_ISOCHRONOUS 0
|
||||
#define PIPE_INTERRUPT 1
|
||||
#define PIPE_CONTROL 2
|
||||
#define PIPE_BULK 3
|
||||
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define htols(s) s
|
||||
#define htoll(l) l
|
||||
@@ -149,27 +147,52 @@ usb_platform_finddevs(pcap_if_t **alldevsp, char *err_str)
|
||||
struct dirent* data;
|
||||
int ret = 0;
|
||||
DIR* dir;
|
||||
int n;
|
||||
char* name;
|
||||
size_t len;
|
||||
|
||||
/* scan procfs usb bus directory */
|
||||
dir = opendir(USB_BUS_DIR);
|
||||
if (!dir) return 0;
|
||||
while ((ret == 0) && ((data = readdir(dir)) != 0)) {
|
||||
int n;
|
||||
char* name = data->d_name;
|
||||
int len = strlen(name);
|
||||
/* try scanning sysfs usb bus directory */
|
||||
dir = opendir(SYS_USB_BUS_DIR);
|
||||
if (dir != NULL) {
|
||||
while ((ret == 0) && ((data = readdir(dir)) != 0)) {
|
||||
name = data->d_name;
|
||||
|
||||
/* if this file name does not end with a number it's not of our interest */
|
||||
if ((len < 1) || !isdigit(name[--len]))
|
||||
continue;
|
||||
while (isdigit(name[--len]));
|
||||
if (sscanf(&name[len+1], "%d", &n) != 1)
|
||||
continue;
|
||||
if (strncmp(name, "usb", 3) != 0)
|
||||
continue;
|
||||
|
||||
ret = usb_dev_add(alldevsp, n, err_str);
|
||||
if (sscanf(&name[3], "%d", &n) == 0)
|
||||
continue;
|
||||
|
||||
ret = usb_dev_add(alldevsp, n, err_str);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return ret;
|
||||
/* that didn't work; try scanning procfs usb bus directory */
|
||||
dir = opendir(PROC_USB_BUS_DIR);
|
||||
if (dir != NULL) {
|
||||
while ((ret == 0) && ((data = readdir(dir)) != 0)) {
|
||||
name = data->d_name;
|
||||
len = strlen(name);
|
||||
|
||||
/* if this file name does not end with a number it's not of our interest */
|
||||
if ((len < 1) || !isdigit(name[--len]))
|
||||
continue;
|
||||
while (isdigit(name[--len]));
|
||||
if (sscanf(&name[len+1], "%d", &n) != 1)
|
||||
continue;
|
||||
|
||||
ret = usb_dev_add(alldevsp, n, err_str);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* neither of them worked */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
@@ -179,8 +202,79 @@ int usb_mmap(pcap_t* handle)
|
||||
if (len < 0)
|
||||
return 0;
|
||||
|
||||
handle->buffer = mmap(0, len, PROT_READ, MAP_SHARED, handle->fd, 0);
|
||||
return handle->buffer != MAP_FAILED;
|
||||
handle->md.mmapbuflen = len;
|
||||
handle->md.mmapbuf = mmap(0, handle->md.mmapbuflen, PROT_READ,
|
||||
MAP_SHARED, handle->fd, 0);
|
||||
return handle->md.mmapbuf != MAP_FAILED;
|
||||
}
|
||||
|
||||
#define CTRL_TIMEOUT (5*1000) /* milliseconds */
|
||||
|
||||
#define USB_DIR_IN 0x80
|
||||
#define USB_TYPE_STANDARD 0x00
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
|
||||
#define USB_REQ_GET_DESCRIPTOR 6
|
||||
|
||||
#define USB_DT_DEVICE 1
|
||||
|
||||
/* probe the descriptors of the devices attached to the bus */
|
||||
/* the descriptors will end up in the captured packet stream */
|
||||
/* and be decoded by external apps like wireshark */
|
||||
/* without these identifying probes packet data can't be fully decoded */
|
||||
static void
|
||||
probe_devices(int bus)
|
||||
{
|
||||
struct usbdevfs_ctrltransfer ctrl;
|
||||
struct dirent* data;
|
||||
int ret = 0;
|
||||
char buf[40];
|
||||
DIR* dir;
|
||||
|
||||
/* scan usb bus directories for device nodes */
|
||||
snprintf(buf, sizeof(buf), "/dev/bus/usb/%03d", bus);
|
||||
dir = opendir(buf);
|
||||
if (!dir)
|
||||
return;
|
||||
|
||||
while ((ret >= 0) && ((data = readdir(dir)) != 0)) {
|
||||
int fd;
|
||||
char* name = data->d_name;
|
||||
|
||||
if (name[0] == '.')
|
||||
continue;
|
||||
|
||||
snprintf(buf, sizeof(buf), "/dev/bus/usb/%03d/%s", bus, data->d_name);
|
||||
|
||||
fd = open(buf, O_RDWR);
|
||||
if (fd == -1)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Sigh. Different kernels have different member names
|
||||
* for this structure.
|
||||
*/
|
||||
#ifdef HAVE_USBDEVFS_CTRLTRANSFER_BREQUESTTYPE
|
||||
ctrl.bRequestType = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
|
||||
ctrl.bRequest = USB_REQ_GET_DESCRIPTOR;
|
||||
ctrl.wValue = USB_DT_DEVICE << 8;
|
||||
ctrl.wIndex = 0;
|
||||
ctrl.wLength = sizeof(buf);
|
||||
#else
|
||||
ctrl.requesttype = USB_DIR_IN | USB_TYPE_STANDARD | USB_RECIP_DEVICE;
|
||||
ctrl.request = USB_REQ_GET_DESCRIPTOR;
|
||||
ctrl.value = USB_DT_DEVICE << 8;
|
||||
ctrl.index = 0;
|
||||
ctrl.length = sizeof(buf);
|
||||
#endif
|
||||
ctrl.data = buf;
|
||||
ctrl.timeout = CTRL_TIMEOUT;
|
||||
|
||||
ret = ioctl(fd, USBDEVFS_CONTROL, &ctrl);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
@@ -230,14 +324,17 @@ usb_activate(pcap_t* handle)
|
||||
/*
|
||||
* Monitor mode doesn't apply to USB devices.
|
||||
*/
|
||||
close(handle->fd);
|
||||
return PCAP_ERROR_RFMON_NOTSUP;
|
||||
}
|
||||
|
||||
/* binary api is available, try to use fast mmap access */
|
||||
if (usb_mmap(handle)) {
|
||||
handle->linktype = DLT_USB_LINUX_MMAPPED;
|
||||
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);
|
||||
|
||||
/*
|
||||
* "handle->fd" is a real file, so "select()" and
|
||||
@@ -250,6 +347,7 @@ 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);
|
||||
}
|
||||
else {
|
||||
/*Binary interface not available, try open text interface */
|
||||
@@ -257,22 +355,35 @@ usb_activate(pcap_t* handle)
|
||||
handle->fd = open(full_path, O_RDONLY, 0);
|
||||
if (handle->fd < 0)
|
||||
{
|
||||
/* no more fallback, give it up*/
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't open USB bus file %s: %s", full_path, strerror(errno));
|
||||
return PCAP_ERROR;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/*
|
||||
* Not found at the new location; try
|
||||
* the old location.
|
||||
*/
|
||||
snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex);
|
||||
handle->fd = open(full_path, O_RDONLY, 0);
|
||||
}
|
||||
if (handle->fd < 0) {
|
||||
/* no more fallback, give it up*/
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't open USB bus file %s: %s", full_path, strerror(errno));
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (handle->opt.rfmon) {
|
||||
/*
|
||||
* Monitor mode doesn't apply to USB devices.
|
||||
*/
|
||||
close(handle->fd);
|
||||
return PCAP_ERROR_RFMON_NOTSUP;
|
||||
}
|
||||
|
||||
handle->stats_op = usb_stats_linux;
|
||||
handle->read_op = usb_read_linux;
|
||||
}
|
||||
|
||||
if (handle->opt.rfmon) {
|
||||
/*
|
||||
* Monitor mode doesn't apply to USB devices.
|
||||
*/
|
||||
return PCAP_ERROR_RFMON_NOTSUP;
|
||||
}
|
||||
|
||||
/*
|
||||
* "handle->fd" is a real file, so "select()" and "poll()"
|
||||
* work on it.
|
||||
@@ -285,6 +396,7 @@ usb_activate(pcap_t* handle)
|
||||
if (!handle->buffer) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"malloc: %s", pcap_strerror(errno));
|
||||
close(handle->fd);
|
||||
return PCAP_ERROR;
|
||||
}
|
||||
return 0;
|
||||
@@ -351,7 +463,6 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
|
||||
return -1;
|
||||
}
|
||||
uhdr->id = tag;
|
||||
uhdr->endpoint_number = ep_num;
|
||||
uhdr->device_address = dev_addr;
|
||||
uhdr->bus_id = handle->md.ifindex;
|
||||
uhdr->status = 0;
|
||||
@@ -378,7 +489,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
|
||||
else if (pipeid1 == 'B')
|
||||
urb_transfer = URB_BULK;
|
||||
if (pipeid2 == 'i') {
|
||||
urb_transfer |= URB_TRANSFER_IN;
|
||||
ep_num |= URB_TRANSFER_IN;
|
||||
incoming = 1;
|
||||
}
|
||||
if (etype == 'C')
|
||||
@@ -395,6 +506,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
|
||||
return 0;
|
||||
uhdr->event_type = etype;
|
||||
uhdr->transfer_type = urb_transfer;
|
||||
uhdr->endpoint_number = ep_num;
|
||||
pkth.caplen = sizeof(pcap_usb_header);
|
||||
rawdata += sizeof(pcap_usb_header);
|
||||
|
||||
@@ -447,7 +559,7 @@ usb_read_linux(pcap_t *handle, int max_packets, pcap_handler callback, u_char *u
|
||||
uhdr->urb_len = urb_len;
|
||||
uhdr->data_flag = 1;
|
||||
data_len = 0;
|
||||
if (uhdr->urb_len == pkth.caplen)
|
||||
if (uhdr->urb_len == 0)
|
||||
goto got;
|
||||
|
||||
/* check for data presence; data is present if and only if urb tag is '=' */
|
||||
@@ -508,15 +620,27 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
||||
char string[USB_LINE_LEN];
|
||||
char token[USB_LINE_LEN];
|
||||
char * ptr = string;
|
||||
snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
|
||||
int fd;
|
||||
|
||||
int fd = open(string, O_RDONLY, 0);
|
||||
snprintf(string, USB_LINE_LEN, USB_TEXT_DIR"/%ds", handle->md.ifindex);
|
||||
fd = open(string, O_RDONLY, 0);
|
||||
if (fd < 0)
|
||||
{
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't open USB stats file %s: %s",
|
||||
string, strerror(errno));
|
||||
return -1;
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
/*
|
||||
* Not found at the new location; try the old
|
||||
* location.
|
||||
*/
|
||||
snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex);
|
||||
fd = open(string, O_RDONLY, 0);
|
||||
}
|
||||
if (fd < 0) {
|
||||
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
|
||||
"Can't open USB stats file %s: %s",
|
||||
string, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* read stats line */
|
||||
@@ -541,8 +665,10 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats)
|
||||
* of execution" but the Corrigendum seems to contradict this.
|
||||
* Do not make any assumptions on the effect of %n conversions
|
||||
* on the return value and explicitly check for cnt assignmet*/
|
||||
int ntok;
|
||||
|
||||
cnt = -1;
|
||||
int ntok = sscanf(ptr, "%s%n", token, &cnt);
|
||||
ntok = sscanf(ptr, "%s%n", token, &cnt);
|
||||
if ((ntok < 1) || (cnt < 0))
|
||||
break;
|
||||
consumed += cnt;
|
||||
@@ -590,7 +716,8 @@ usb_stats_linux_bin(pcap_t *handle, struct pcap_stat *stats)
|
||||
}
|
||||
|
||||
stats->ps_recv = handle->md.packets_read + st.queued;
|
||||
stats->ps_ifdrop = st.dropped;
|
||||
stats->ps_drop = st.dropped;
|
||||
stats->ps_ifdrop = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -636,7 +763,7 @@ usb_read_linux_bin(pcap_t *handle, int max_packets, pcap_handler callback, u_cha
|
||||
clen = info.hdr->data_len;
|
||||
info.hdr->data_len = clen;
|
||||
pkth.caplen = clen + sizeof(pcap_usb_header);
|
||||
pkth.len = info.hdr->urb_len + sizeof(pcap_usb_header);
|
||||
pkth.len = info.hdr->data_len + sizeof(pcap_usb_header);
|
||||
pkth.ts.tv_sec = info.hdr->ts_sec;
|
||||
pkth.ts.tv_usec = info.hdr->ts_usec;
|
||||
|
||||
@@ -659,6 +786,9 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
|
||||
pcap_usb_header* hdr;
|
||||
int nflush = 0;
|
||||
int packets = 0;
|
||||
int clen, max_clen;
|
||||
|
||||
max_clen = handle->snapshot - sizeof(pcap_usb_header);
|
||||
|
||||
for (;;) {
|
||||
int i, ret;
|
||||
@@ -695,13 +825,19 @@ 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->buffer[vec[i]];
|
||||
hdr = (pcap_usb_header*) &handle->md.mmapbuf[vec[i]];
|
||||
if (hdr->event_type == '@')
|
||||
continue;
|
||||
|
||||
/* we can get less that than really captured from kernel, depending on
|
||||
* snaplen, so adjust header accordingly */
|
||||
clen = max_clen;
|
||||
if (hdr->data_len < clen)
|
||||
clen = hdr->data_len;
|
||||
|
||||
/* get packet info from header*/
|
||||
pkth.caplen = hdr->data_len + sizeof(pcap_usb_header);
|
||||
pkth.len = hdr->urb_len + sizeof(pcap_usb_header);
|
||||
pkth.caplen = clen + sizeof(pcap_usb_header_mmapped);
|
||||
pkth.len = hdr->data_len + sizeof(pcap_usb_header_mmapped);
|
||||
pkth.ts.tv_sec = hdr->ts_sec;
|
||||
pkth.ts.tv_usec = hdr->ts_usec;
|
||||
|
||||
@@ -723,8 +859,10 @@ usb_read_linux_mmap(pcap_t *handle, int max_packets, pcap_handler callback, u_ch
|
||||
static void
|
||||
usb_cleanup_linux_mmap(pcap_t* handle)
|
||||
{
|
||||
/* buffer must not be freed because it's memory mapped */
|
||||
/* XXX - does it need to be unmapped? */
|
||||
handle->buffer = NULL;
|
||||
/* 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;
|
||||
}
|
||||
pcap_cleanup_live_common(handle);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* USB sniffing API implementation for Linux platform
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.h,v 1.4.2.1 2008-04-04 19:39:06 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap-usb-linux.h,v 1.5 2008-04-04 19:37:45 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.34.2.8 2008-05-21 22:11:26 gianluca Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap-win32.c,v 1.42 2008-05-21 22:15:25 gianluca Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#include <pcap-int.h>
|
||||
@@ -78,6 +78,22 @@ struct bpf_hdr {
|
||||
plus alignment padding) */
|
||||
};
|
||||
|
||||
CRITICAL_SECTION g_PcapCompileCriticalSection;
|
||||
|
||||
BOOL WINAPI DllMain(
|
||||
HANDLE hinstDLL,
|
||||
DWORD dwReason,
|
||||
LPVOID lpvReserved
|
||||
)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
InitializeCriticalSection(&g_PcapCompileCriticalSection);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Start winsock */
|
||||
int
|
||||
wsockinit()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap.3pcap.in,v 1.1.2.2 2008-10-21 07:44:57 guy Exp $
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap.3pcap.in,v 1.1 2008-10-21 07:33:01 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
||||
292
libpcap/pcap.c
292
libpcap/pcap.c
@@ -33,7 +33,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] _U_ =
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.112.2.12 2008-09-22 20:16:01 guy Exp $ (LBL)";
|
||||
"@(#) $Header: /tcpdump/master/libpcap/pcap.c,v 1.128 2008-12-23 20:13:29 guy Exp $ (LBL)";
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -43,6 +43,14 @@ static const char rcsid[] _U_ =
|
||||
#ifdef WIN32
|
||||
#include <pcap-stdinc.h>
|
||||
#else /* WIN32 */
|
||||
#if HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_BITYPES_H
|
||||
#include <sys/bitypes.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#endif /* WIN32 */
|
||||
|
||||
@@ -96,41 +104,90 @@ pcap_cant_set_rfmon(pcap_t *p _U_)
|
||||
return (0);
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
pcap_create_common(const char *source, char *ebuf)
|
||||
/*
|
||||
* Default one-shot callback; overridden for capture types where the
|
||||
* packet data cannot be guaranteed to be available after the callback
|
||||
* returns, so that a copy must be made.
|
||||
*/
|
||||
static void
|
||||
pcap_oneshot(u_char *user, const struct pcap_pkthdr *h, const u_char *pkt)
|
||||
{
|
||||
pcap_t *p;
|
||||
struct oneshot_userdata *sp = (struct oneshot_userdata *)user;
|
||||
|
||||
p = malloc(sizeof(*p));
|
||||
if (p == NULL) {
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||
pcap_strerror(errno));
|
||||
return (NULL);
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
#ifndef WIN32
|
||||
p->fd = -1; /* not opened yet */
|
||||
#endif
|
||||
*sp->hdr = *h;
|
||||
*sp->pkt = pkt;
|
||||
}
|
||||
|
||||
p->opt.source = strdup(source);
|
||||
if (p->opt.source == NULL) {
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||
pcap_strerror(errno));
|
||||
free(p);
|
||||
return (NULL);
|
||||
const u_char *
|
||||
pcap_next(pcap_t *p, struct pcap_pkthdr *h)
|
||||
{
|
||||
struct oneshot_userdata s;
|
||||
const u_char *pkt;
|
||||
|
||||
s.hdr = h;
|
||||
s.pkt = &pkt;
|
||||
s.pd = p;
|
||||
if (pcap_dispatch(p, 1, p->oneshot_callback, (u_char *)&s) <= 0)
|
||||
return (0);
|
||||
return (pkt);
|
||||
}
|
||||
|
||||
int
|
||||
pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
|
||||
const u_char **pkt_data)
|
||||
{
|
||||
struct oneshot_userdata s;
|
||||
|
||||
s.hdr = &p->pcap_header;
|
||||
s.pkt = pkt_data;
|
||||
s.pd = p;
|
||||
|
||||
/* Saves a pointer to the packet headers */
|
||||
*pkt_header= &p->pcap_header;
|
||||
|
||||
if (p->sf.rfile != NULL) {
|
||||
int status;
|
||||
|
||||
/* We are on an offline capture */
|
||||
status = pcap_offline_read(p, 1, pcap_oneshot, (u_char *)&s);
|
||||
|
||||
/*
|
||||
* Return codes for pcap_offline_read() are:
|
||||
* - 0: EOF
|
||||
* - -1: error
|
||||
* - >1: OK
|
||||
* The first one ('0') conflicts with the return code of
|
||||
* 0 from pcap_read() meaning "no packets arrived before
|
||||
* the timeout expired", so we map it to -2 so you can
|
||||
* distinguish between an EOF from a savefile and a
|
||||
* "no packets arrived before the timeout expired, try
|
||||
* again" from a live capture.
|
||||
*/
|
||||
if (status == 0)
|
||||
return (-2);
|
||||
else
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default to "can't set rfmon mode"; if it's supported by
|
||||
* a platform, it can set the op to its routine to check
|
||||
* whether a particular device supports it.
|
||||
*/
|
||||
p->can_set_rfmon_op = pcap_cant_set_rfmon;
|
||||
* Return codes for pcap_read() are:
|
||||
* - 0: timeout
|
||||
* - -1: error
|
||||
* - -2: loop was broken out of with pcap_breakloop()
|
||||
* - >1: OK
|
||||
* The first one ('0') conflicts with the return code of 0 from
|
||||
* pcap_offline_read() meaning "end of file".
|
||||
*/
|
||||
return (p->read_op(p, 1, pcap_oneshot, (u_char *)&s));
|
||||
}
|
||||
|
||||
static void
|
||||
initialize_ops(pcap_t *p)
|
||||
{
|
||||
/*
|
||||
* Some operations can be performed only on activated pcap_t's;
|
||||
* have those operations handled by a "not supported" handler
|
||||
* until the pcap_t is activated.
|
||||
* Set operation pointers for operations that only work on
|
||||
* an activated pcap_t to point to a routine that returns
|
||||
* a "this isn't activated" error.
|
||||
*/
|
||||
p->read_op = (read_op_t)pcap_not_initialized;
|
||||
p->inject_op = (inject_op_t)pcap_not_initialized;
|
||||
@@ -145,8 +202,57 @@ pcap_create_common(const char *source, char *ebuf)
|
||||
p->setmode_op = (setmode_op_t)pcap_not_initialized;
|
||||
p->setmintocopy_op = (setmintocopy_op_t)pcap_not_initialized;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default cleanup operation - implementations can override
|
||||
* this, but should call pcap_cleanup_live_common() after
|
||||
* doing their own additional cleanup.
|
||||
*/
|
||||
p->cleanup_op = pcap_cleanup_live_common;
|
||||
|
||||
/*
|
||||
* In most cases, the standard one-short callback can
|
||||
* be used for pcap_next()/pcap_next_ex().
|
||||
*/
|
||||
p->oneshot_callback = pcap_oneshot;
|
||||
}
|
||||
|
||||
pcap_t *
|
||||
pcap_create_common(const char *source, char *ebuf)
|
||||
{
|
||||
pcap_t *p;
|
||||
|
||||
p = malloc(sizeof(*p));
|
||||
if (p == NULL) {
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||
pcap_strerror(errno));
|
||||
return (NULL);
|
||||
}
|
||||
memset(p, 0, sizeof(*p));
|
||||
#ifndef WIN32
|
||||
p->fd = -1; /* not opened yet */
|
||||
p->selectable_fd = -1;
|
||||
p->send_fd = -1;
|
||||
#endif
|
||||
|
||||
p->opt.source = strdup(source);
|
||||
if (p->opt.source == NULL) {
|
||||
snprintf(ebuf, PCAP_ERRBUF_SIZE, "malloc: %s",
|
||||
pcap_strerror(errno));
|
||||
free(p);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Default to "can't set rfmon mode"; if it's supported by
|
||||
* a platform, the create routine that called us can set
|
||||
* the op to its routine to check whether a particular
|
||||
* device supports it.
|
||||
*/
|
||||
p->can_set_rfmon_op = pcap_cant_set_rfmon;
|
||||
|
||||
initialize_ops(p);
|
||||
|
||||
/* put in some defaults*/
|
||||
pcap_set_timeout(p, 0);
|
||||
pcap_set_snaplen(p, 65535); /* max packet size */
|
||||
@@ -219,6 +325,24 @@ pcap_activate(pcap_t *p)
|
||||
status = p->activate_op(p);
|
||||
if (status >= 0)
|
||||
p->activated = 1;
|
||||
else {
|
||||
if (p->errbuf[0] == '\0') {
|
||||
/*
|
||||
* No error message supplied by the activate routine;
|
||||
* for the benefit of programs that don't specially
|
||||
* handle errors other than PCAP_ERROR, return the
|
||||
* error message corresponding to the status.
|
||||
*/
|
||||
snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "%s",
|
||||
pcap_statustostr(status));
|
||||
}
|
||||
|
||||
/*
|
||||
* Undo any operation pointer setting, etc. done by
|
||||
* the activate operation.
|
||||
*/
|
||||
initialize_ops(p);
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
||||
@@ -256,9 +380,13 @@ pcap_open_live(const char *source, int snaplen, int promisc, int to_ms, char *er
|
||||
goto fail;
|
||||
return (p);
|
||||
fail:
|
||||
if (status == PCAP_ERROR || status == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
if (status == PCAP_ERROR)
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
|
||||
p->errbuf);
|
||||
else if (status == PCAP_ERROR_NO_SUCH_DEVICE ||
|
||||
status == PCAP_ERROR_PERM_DENIED)
|
||||
strlcpy(errbuf, p->errbuf, PCAP_ERRBUF_SIZE);
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s (%s)", source,
|
||||
pcap_statustostr(status), p->errbuf);
|
||||
else
|
||||
snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", source,
|
||||
pcap_statustostr(status));
|
||||
@@ -312,95 +440,6 @@ pcap_loop(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
|
||||
}
|
||||
}
|
||||
|
||||
struct singleton {
|
||||
struct pcap_pkthdr *hdr;
|
||||
const u_char *pkt;
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
pcap_oneshot(u_char *userData, const struct pcap_pkthdr *h, const u_char *pkt)
|
||||
{
|
||||
struct singleton *sp = (struct singleton *)userData;
|
||||
*sp->hdr = *h;
|
||||
sp->pkt = pkt;
|
||||
}
|
||||
|
||||
const u_char *
|
||||
pcap_next(pcap_t *p, struct pcap_pkthdr *h)
|
||||
{
|
||||
struct singleton s;
|
||||
|
||||
s.hdr = h;
|
||||
if (pcap_dispatch(p, 1, pcap_oneshot, (u_char*)&s) <= 0)
|
||||
return (0);
|
||||
return (s.pkt);
|
||||
}
|
||||
|
||||
struct pkt_for_fakecallback {
|
||||
struct pcap_pkthdr *hdr;
|
||||
const u_char **pkt;
|
||||
};
|
||||
|
||||
static void
|
||||
pcap_fakecallback(u_char *userData, const struct pcap_pkthdr *h,
|
||||
const u_char *pkt)
|
||||
{
|
||||
struct pkt_for_fakecallback *sp = (struct pkt_for_fakecallback *)userData;
|
||||
|
||||
*sp->hdr = *h;
|
||||
*sp->pkt = pkt;
|
||||
}
|
||||
|
||||
int
|
||||
pcap_next_ex(pcap_t *p, struct pcap_pkthdr **pkt_header,
|
||||
const u_char **pkt_data)
|
||||
{
|
||||
struct pkt_for_fakecallback s;
|
||||
|
||||
s.hdr = &p->pcap_header;
|
||||
s.pkt = pkt_data;
|
||||
|
||||
/* Saves a pointer to the packet headers */
|
||||
*pkt_header= &p->pcap_header;
|
||||
|
||||
if (p->sf.rfile != NULL) {
|
||||
int status;
|
||||
|
||||
/* We are on an offline capture */
|
||||
status = pcap_offline_read(p, 1, pcap_fakecallback,
|
||||
(u_char *)&s);
|
||||
|
||||
/*
|
||||
* Return codes for pcap_offline_read() are:
|
||||
* - 0: EOF
|
||||
* - -1: error
|
||||
* - >1: OK
|
||||
* The first one ('0') conflicts with the return code of
|
||||
* 0 from pcap_read() meaning "no packets arrived before
|
||||
* the timeout expired", so we map it to -2 so you can
|
||||
* distinguish between an EOF from a savefile and a
|
||||
* "no packets arrived before the timeout expired, try
|
||||
* again" from a live capture.
|
||||
*/
|
||||
if (status == 0)
|
||||
return (-2);
|
||||
else
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return codes for pcap_read() are:
|
||||
* - 0: timeout
|
||||
* - -1: error
|
||||
* - -2: loop was broken out of with pcap_breakloop()
|
||||
* - >1: OK
|
||||
* The first one ('0') conflicts with the return code of 0 from
|
||||
* pcap_offline_read() meaning "end of file".
|
||||
*/
|
||||
return (p->read_op(p, 1, pcap_fakecallback, (u_char *)&s));
|
||||
}
|
||||
|
||||
/*
|
||||
* Force the loop in "pcap_read()" or "pcap_read_offline()" to terminate.
|
||||
*/
|
||||
@@ -623,6 +662,17 @@ static struct dlt_choice dlt_choices[] = {
|
||||
DLT_CHOICE(DLT_BLUETOOTH_HCI_H4_WITH_PHDR, "Bluetooth HCI UART transport layer plus pseudo-header"),
|
||||
DLT_CHOICE(DLT_AX25_KISS, "AX.25 with KISS header"),
|
||||
DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
|
||||
DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"),
|
||||
DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"),
|
||||
DLT_CHOICE(DLT_DECT, "DECT"),
|
||||
DLT_CHOICE(DLT_AOS, "AOS Space Data Link protocol"),
|
||||
DLT_CHOICE(DLT_WIHART, "Wireless HART"),
|
||||
DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"),
|
||||
DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
|
||||
DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
|
||||
DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
|
||||
DLT_CHOICE(DLT_IPV4, "Raw IPv4"),
|
||||
DLT_CHOICE(DLT_IPV6, "Raw IPv6"),
|
||||
DLT_CHOICE_SENTINEL
|
||||
};
|
||||
|
||||
@@ -1168,6 +1218,8 @@ pcap_cleanup_live_common(pcap_t *p)
|
||||
close(p->fd);
|
||||
p->fd = -1;
|
||||
}
|
||||
p->selectable_fd = -1;
|
||||
p->send_fd = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1265,7 +1317,7 @@ pcap_offline_filter(struct bpf_program *fp, const struct pcap_pkthdr *h,
|
||||
#ifdef HAVE_VERSION_H
|
||||
#include "version.h"
|
||||
#else
|
||||
static const char pcap_version_string[] = "libpcap version 0.9[.x]";
|
||||
static const char pcap_version_string[] = "libpcap version 1.x.y";
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.59 2006/10/04 18:09:22 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.59 2006-10-04 18:09:22 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* bluetooth data struct
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/bluetooth.h,v 1.1 2007/09/22 02:10:17 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/bluetooth.h,v 1.1 2007-09-22 02:10:17 guy Exp $
|
||||
*/
|
||||
|
||||
#ifndef _PCAP_BLUETOOTH_STRUCTS_H__
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
*
|
||||
* @(#)bpf.h 7.1 (Berkeley) 5/7/91
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/bpf.h,v 1.19.2.8 2008-09-22 20:16:01 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/bpf.h,v 1.32 2008-12-23 20:13:29 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -821,6 +821,144 @@ struct bpf_version {
|
||||
*/
|
||||
#define DLT_IEEE802_15_4_NONASK_PHY 215
|
||||
|
||||
/*
|
||||
* David Gibson <david@gibson.dropbear.id.au> requested this for
|
||||
* captures from the Linux kernel /dev/input/eventN devices. This
|
||||
* is used to communicate keystrokes and mouse movements from the
|
||||
* Linux kernel to display systems, such as Xorg.
|
||||
*/
|
||||
#define DLT_LINUX_EVDEV 216
|
||||
|
||||
/*
|
||||
* GSM Um and Abis interfaces, preceded by a "gsmtap" header.
|
||||
*
|
||||
* Requested by Harald Welte <laforge@gnumonks.org>.
|
||||
*/
|
||||
#define DLT_GSMTAP_UM 217
|
||||
#define DLT_GSMTAP_ABIS 218
|
||||
|
||||
/*
|
||||
* MPLS, with an MPLS label as the link-layer header.
|
||||
* Requested by Michele Marchetto <michele@openbsd.org> on behalf
|
||||
* of OpenBSD.
|
||||
*/
|
||||
#define DLT_MPLS 219
|
||||
|
||||
/*
|
||||
* USB packets, beginning with a Linux USB header, with the USB header
|
||||
* padded to 64 bytes; required for memory-mapped access.
|
||||
*/
|
||||
#define DLT_USB_LINUX_MMAPPED 220
|
||||
|
||||
/*
|
||||
* DECT packets, with a pseudo-header; requested by
|
||||
* Matthias Wenzel <tcpdump@mazzoo.de>.
|
||||
*/
|
||||
#define DLT_DECT 221
|
||||
|
||||
/*
|
||||
* From: "Lidwa, Eric (GSFC-582.0)[SGT INC]" <eric.lidwa-1@nasa.gov>
|
||||
* Date: Mon, 11 May 2009 11:18:30 -0500
|
||||
*
|
||||
* DLT_AOS. We need it for AOS Space Data Link Protocol.
|
||||
* I have already written dissectors for but need an OK from
|
||||
* legal before I can submit a patch.
|
||||
*
|
||||
*/
|
||||
#define DLT_AOS 222
|
||||
|
||||
/*
|
||||
* Wireless HART (Highway Addressable Remote Transducer)
|
||||
* From the HART Communication Foundation
|
||||
* IES/PAS 62591
|
||||
*
|
||||
* Requested by Sam Roberts <vieuxtech@gmail.com>.
|
||||
*/
|
||||
#define DLT_WIHART 223
|
||||
|
||||
/*
|
||||
* Fibre Channel FC-2 frames, beginning with a Frame_Header.
|
||||
* Requested by Kahou Lei <kahou82@gmail.com>.
|
||||
*/
|
||||
#define DLT_FC_2 224
|
||||
|
||||
/*
|
||||
* Fibre Channel FC-2 frames, beginning with an encoding of the
|
||||
* SOF, and ending with an encoding of the EOF.
|
||||
*
|
||||
* The encodings represent the frame delimiters as 4-byte sequences
|
||||
* representing the corresponding ordered sets, with K28.5
|
||||
* represented as 0xBC, and the D symbols as the corresponding
|
||||
* byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2,
|
||||
* is represented as 0xBC 0xB5 0x55 0x55.
|
||||
*
|
||||
* Requested by Kahou Lei <kahou82@gmail.com>.
|
||||
*/
|
||||
#define DLT_FC_2_WITH_FRAME_DELIMS 225
|
||||
|
||||
/*
|
||||
* Solaris ipnet pseudo-header; requested by Darren Reed <Darren.Reed@Sun.COM>.
|
||||
*
|
||||
* The pseudo-header starts with a one-byte version number; for version 2,
|
||||
* the pseudo-header is:
|
||||
*
|
||||
* struct dl_ipnetinfo {
|
||||
* u_int8_t dli_version;
|
||||
* u_int8_t dli_family;
|
||||
* u_int16_t dli_htype;
|
||||
* u_int32_t dli_pktlen;
|
||||
* u_int32_t dli_ifindex;
|
||||
* u_int32_t dli_grifindex;
|
||||
* u_int32_t dli_zsrc;
|
||||
* u_int32_t dli_zdst;
|
||||
* };
|
||||
*
|
||||
* dli_version is 2 for the current version of the pseudo-header.
|
||||
*
|
||||
* dli_family is a Solaris address family value, so it's 2 for IPv4
|
||||
* and 26 for IPv6.
|
||||
*
|
||||
* dli_htype is a "hook type" - 0 for incoming packets, 1 for outgoing
|
||||
* packets, and 2 for packets arriving from another zone on the same
|
||||
* machine.
|
||||
*
|
||||
* dli_pktlen is the length of the packet data following the pseudo-header
|
||||
* (so the captured length minus dli_pktlen is the length of the
|
||||
* pseudo-header, assuming the entire pseudo-header was captured).
|
||||
*
|
||||
* dli_ifindex is the interface index of the interface on which the
|
||||
* packet arrived.
|
||||
*
|
||||
* dli_grifindex is the group interface index number (for IPMP interfaces).
|
||||
*
|
||||
* dli_zsrc is the zone identifier for the source of the packet.
|
||||
*
|
||||
* dli_zdst is the zone identifier for the destination of the packet.
|
||||
*
|
||||
* A zone number of 0 is the global zone; a zone number of 0xffffffff
|
||||
* means that the packet arrived from another host on the network, not
|
||||
* from another zone on the same machine.
|
||||
*
|
||||
* An IPv4 or IPv6 datagram follows the pseudo-header; dli_family indicates
|
||||
* which of those it is.
|
||||
*/
|
||||
#define DLT_IPNET 226
|
||||
|
||||
/*
|
||||
* CAN (Controller Area Network) frames, with a pseudo-header as supplied
|
||||
* by Linux SocketCAN. See Documentation/networking/can.txt in the Linux
|
||||
* source.
|
||||
*
|
||||
* Requested by Felix Obenhuber <felix@obenhuber.de>.
|
||||
*/
|
||||
#define DLT_CAN_SOCKETCAN 227
|
||||
|
||||
/*
|
||||
* Raw IPv4/IPv6; different from DLT_RAW in that the DLT_ value specifies
|
||||
* whether it's v4 or v6. Requested by Darren Reed <Darren.Reed@Sun.COM>.
|
||||
*/
|
||||
#define DLT_IPV4 228
|
||||
#define DLT_IPV6 229
|
||||
|
||||
/*
|
||||
* DLT and savefile link type values are split into a class and
|
||||
|
||||
43
libpcap/pcap/ipnet.h
Normal file
43
libpcap/pcap/ipnet.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*-
|
||||
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from the Stanford/CMU enet packet filter,
|
||||
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
||||
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
||||
* Berkeley Laboratory.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define IPH_AF_INET 2 /* Matches Solaris's AF_INET */
|
||||
#define IPH_AF_INET6 26 /* Matches Solaris's AF_INET6 */
|
||||
|
||||
#define IPNET_OUTBOUND 1
|
||||
#define IPNET_INBOUND 2
|
||||
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/namedb.h,v 1.1 2006/10/04 18:09:22 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/namedb.h,v 1.1 2006-10-04 18:09:22 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_namedb_h
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.4.2.11 2008-10-06 15:38:39 gianluca Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.15 2008-10-06 15:27:32 gianluca Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_pcap_h
|
||||
@@ -57,6 +57,13 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Version number of the current version of the pcap file format.
|
||||
*
|
||||
* NOTE: this is *NOT* the version number of the libpcap library.
|
||||
* To fetch the version information for the version of libpcap
|
||||
* you're using, use pcap_lib_version().
|
||||
*/
|
||||
#define PCAP_VERSION_MAJOR 2
|
||||
#define PCAP_VERSION_MINOR 4
|
||||
|
||||
@@ -163,7 +170,7 @@ struct pcap_pkthdr {
|
||||
struct pcap_stat {
|
||||
u_int ps_recv; /* number of packets received */
|
||||
u_int ps_drop; /* number of packets dropped */
|
||||
u_int ps_ifdrop; /* drops by interface XXX not yet supported */
|
||||
u_int ps_ifdrop; /* drops by interface -- only supported on some platforms */
|
||||
#ifdef WIN32
|
||||
u_int bs_capt; /* number of packets that reach the application */
|
||||
#endif /* WIN32 */
|
||||
@@ -253,6 +260,12 @@ typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
|
||||
#define PCAP_WARNING 1 /* generic warning code */
|
||||
#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */
|
||||
|
||||
/*
|
||||
* Value to pass to pcap_compile() as the netmask if you don't know what
|
||||
* the netmask is.
|
||||
*/
|
||||
#define PCAP_NETMASK_UNKNOWN 0xffffffff
|
||||
|
||||
char *pcap_lookupdev(char *);
|
||||
int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/sll.h,v 1.2.2.1 2008-05-30 01:36:06 guy Exp $ (LBL)
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/sll.h,v 1.3 2008-05-30 01:35:33 guy Exp $ (LBL)
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* Basic USB data struct
|
||||
* By Paolo Abeni <paolo.abeni@email.it>
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.6 2007/09/22 02:06:08 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/usb.h,v 1.9 2008-12-23 20:13:29 guy Exp $
|
||||
*/
|
||||
|
||||
#ifndef _PCAP_USB_STRUCTS_H__
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
/*
|
||||
* USB setup header as defined in USB specification.
|
||||
* Appears at the front of each packet in DLT_USB captures.
|
||||
* Appears at the front of each Control S-type packet in DLT_USB captures.
|
||||
*/
|
||||
typedef struct _usb_setup {
|
||||
u_int8_t bmRequestType;
|
||||
@@ -64,6 +64,13 @@ typedef struct _usb_setup {
|
||||
u_int16_t wLength;
|
||||
} pcap_usb_setup;
|
||||
|
||||
/*
|
||||
* Information from the URB for Isochronous transfers.
|
||||
*/
|
||||
typedef struct _iso_rec {
|
||||
int32_t error_count;
|
||||
int32_t numdesc;
|
||||
} iso_rec;
|
||||
|
||||
/*
|
||||
* Header prepended by linux kernel to each event.
|
||||
@@ -86,5 +93,51 @@ typedef struct _usb_header {
|
||||
pcap_usb_setup setup;
|
||||
} pcap_usb_header;
|
||||
|
||||
/*
|
||||
* Header prepended by linux kernel to each event for the 2.6.31
|
||||
* and later kernels; for the 2.6.21 through 2.6.30 kernels, the
|
||||
* "iso_rec" information, and the fields starting with "interval"
|
||||
* are zeroed-out padding fields.
|
||||
*
|
||||
* Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures.
|
||||
*/
|
||||
typedef struct _usb_header_mmapped {
|
||||
u_int64_t id;
|
||||
u_int8_t event_type;
|
||||
u_int8_t transfer_type;
|
||||
u_int8_t endpoint_number;
|
||||
u_int8_t device_address;
|
||||
u_int16_t bus_id;
|
||||
char setup_flag;/*if !=0 the urb setup header is not present*/
|
||||
char data_flag; /*if !=0 no urb data is present*/
|
||||
int64_t ts_sec;
|
||||
int32_t ts_usec;
|
||||
int32_t status;
|
||||
u_int32_t urb_len;
|
||||
u_int32_t data_len; /* amount of urb data really present in this event*/
|
||||
union {
|
||||
pcap_usb_setup setup;
|
||||
iso_rec iso;
|
||||
} s;
|
||||
int32_t interval; /* for Interrupt and Isochronous events */
|
||||
int32_t start_frame; /* for Isochronous events */
|
||||
u_int32_t xfer_flags; /* copy of URB's transfer flags */
|
||||
u_int32_t ndesc; /* number of isochronous descriptors */
|
||||
} pcap_usb_header_mmapped;
|
||||
|
||||
/*
|
||||
* Isochronous descriptors; for isochronous transfers there might be
|
||||
* one or more of these at the beginning of the packet data. The
|
||||
* number of descriptors is given by the "ndesc" field in the header;
|
||||
* as indicated, in older kernels that don't put the descriptors at
|
||||
* the beginning of the packet, that field is zeroed out, so that field
|
||||
* can be trusted even in captures from older kernels.
|
||||
*/
|
||||
typedef struct _usb_isodesc {
|
||||
int32_t status;
|
||||
u_int32_t offset;
|
||||
u_int32_t len;
|
||||
u_int8_t pad[4];
|
||||
} usb_isodesc;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/vlan.h,v 1.1.2.2 2008-08-06 07:45:59 guy Exp $
|
||||
* @(#) $Header: /tcpdump/master/libpcap/pcap/vlan.h,v 1.1 2008-08-06 07:45:00 guy Exp $
|
||||
*/
|
||||
|
||||
#ifndef lib_pcap_vlan_h
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap_activate.3pcap,v 1.1.2.5 2008-07-01 08:04:03 guy Exp $
|
||||
.\" @(#) $Header: /tcpdump/master/libpcap/pcap_activate.3pcap,v 1.5 2008-07-01 08:02:33 guy Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1994, 1996, 1997
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user